Show
Ignore:
Timestamp:
04/09/09 11:54:50 (12 months ago)
Author:
asawada
Message:

Removed all handlers from MT::Template::Context namespace and moved into new namespace that is same as filename.

  • added new routine MT::T::C::invoke_handler. it can use to invoke handlers existing in other package.
  • added and modified some helper routins in MT::T::Context.
  • removed temporary 'require' hack.
Location:
branches/feature-contexthandlers-splitting/lib/MT/Template
Files:
23 modified

Legend:

Unmodified
Added
Removed
  • branches/feature-contexthandlers-splitting/lib/MT/Template/Context.pm

    r3596 r3616  
    8282                        $prev_hdlr = $h->{$tag}; 
    8383                    } 
    84                     $h->{$tag} = [ $block->{$orig_tag}, $type, $prev_hdlr ]; 
     84                    if (ref($block->{$orig_tag}) eq 'HASH') { 
     85                        if ( $block->{$orig_tag}{handler} ) { 
     86                            $h->{$tag} = [ $block->{$orig_tag}{handler}, $type, $prev_hdlr ]; 
     87                        } 
     88                    } else { 
     89                        $h->{$tag} = [ $block->{$orig_tag}, $type, $prev_hdlr ]; 
     90                    } 
    8591                } 
    8692            } 
     
    96102                        $prev_hdlr = $h->{$tag}; 
    97103                    } 
    98                     $h->{$tag} = [ $func->{$orig_tag}, 0, $prev_hdlr ]; 
     104                    if (ref($func->{$orig_tag}) eq 'HASH') { 
     105                        $h->{$tag} = [ $func->{$orig_tag}{handler}, 0, $prev_hdlr ]; 
     106                    } else { 
     107                        $h->{$tag} = [ $func->{$orig_tag}, 0, $prev_hdlr ]; 
     108                    } 
    99109                } 
    100110            } 
     
    119129    if ($orig_tag && $orig_tag->[0]) { 
    120130        my $orig_hdlr = $orig_tag->[0]; 
    121         if (!ref $orig_hdlr) { 
    122             $orig_tag->[0] = $orig_hdlr = MT->handler_to_coderef( $orig_hdlr ); 
    123         } 
    124         elsif ( 'HASH' eq ref $orig_hdlr ) { 
    125             if (my $req = $orig_hdlr->{require}) { 
    126                 eval "require $req" or die "Cannot load module $req for tag $tag"; 
    127             } 
    128             $orig_hdlr = $orig_hdlr->{handler}; 
    129             if ( $orig_hdlr !~ /::/ ) { $orig_hdlr = '$Core::'."MT::Template::Context::$orig_hdlr"; } 
     131        unless (ref $orig_hdlr) { 
    130132            $orig_tag->[0] = $orig_hdlr = MT->handler_to_coderef( $orig_hdlr ); 
    131133        } 
     
    210212        } 
    211213    } 
    212     elsif ( 'HASH' eq ref $h[0] ) { 
    213         ## FIXME: this is temporary hack for compatibility. 
    214         ## many handlers expect that all core handlers are installed in 
    215         ## MT::Template::Contexti, so now placing there. 
    216         ## should replace them to appropriate namespace. 
    217         my $h = $h[0]; 
    218         if (my $req = $h->{require}) { 
    219             ## if handler wants an require key, load that module. 
    220             eval "require $req" 
    221                 or die "Cannot load module $req for tag $tag"; 
    222             my $subname = $h->{handler}; 
    223             if ( $subname !~ /::/ ) { $subname = '$Core::MT::Template::Context::'.$subname; } 
    224             $h[0] = MT->handler_to_coderef($subname); 
    225         } 
    226     } 
    227214    return ref($v) eq 'ARRAY' ? @h : $h[0]; 
     215} 
     216 
     217sub invoke_handler { 
     218    my $ctx = shift; 
     219    my $tag = shift; 
     220    my ( $handler ) = $ctx->handler_for( $tag ); 
     221    die "cannot find handler for $tag" unless $handler; 
     222    $handler->( $ctx, @_ ); 
    228223} 
    229224 
     
    276271                if (ref $code eq 'HASH') { 
    277272                    $code = $code->{code} ||= MT->handler_to_coderef($code->{handler}); 
     273                } 
     274                elsif ( !ref $code ) { 
     275                    $code = MT->handler_to_coderef( $code ); 
    278276                } 
    279277                $str = $code->($str, $val, $ctx); 
  • branches/feature-contexthandlers-splitting/lib/MT/Template/ContextHandlers.pm

    r3615 r3616  
    99use strict; 
    1010 
    11 use MT; 
    12 use MT::Util qw( start_end_day start_end_week  
    13                  start_end_month week2ymd archive_file_for 
    14                  format_ts offset_time_list first_n_words dirify get_entry 
    15                  encode_html encode_js remove_html wday_from_ts days_in 
    16                  spam_protect encode_php encode_url decode_html encode_xml 
    17                  decode_xml relative_date asset_cleanup ); 
    18 use MT::Request; 
    19 use Time::Local qw( timegm timelocal ); 
    20 use MT::Promise qw( delay ); 
    21 use MT::Category; 
    22 use MT::Entry; 
    23 use MT::I18N qw( first_n_text const uppercase lowercase substr_text length_text wrap_text ); 
    24 use MT::Asset; 
     11use MT::Util qw( format_ts relative_date ); 
     12use Time::Local qw( timelocal ); 
    2513 
    2614sub init_default_handlers {} 
     
    3018    my $tags = { 
    3119        help_url => sub { MT->translate('http://www.movabletype.org/documentation/appendices/tags/%t.html') }, 
    32     }; 
    33  
    34     my $tag_sets = { 
    35         'MT::Template::Tags::Core' => { 
    36             block => { 
    37             # Core tags 
    38                 Ignore => sub { '' }, 
    39                 'If?' => '_hdlr_if', 
    40                 'Unless?' => '_hdlr_unless', 
    41                 'Else' => '_hdlr_else', 
    42                 'ElseIf' => '_hdlr_elseif', 
    43                 'IfNonEmpty?' => '_hdlr_if_nonempty', 
    44                 'IfNonZero?' => '_hdlr_if_nonzero', 
    45                 Loop => '_hdlr_loop', 
    46                 'For' => '_hdlr_for', 
    47                 SetVarBlock => '_hdlr_set_var', 
    48                 SetVarTemplate => '_hdlr_set_var', 
    49                 SetVars => '_hdlr_set_vars', 
    50                 SetHashVar => '_hdlr_set_hashvar', 
    51             }, 
    52             function => { 
    53                 SetVar => '_hdlr_set_var', 
    54                 GetVar => '_hdlr_get_var', 
    55                 Var => '_hdlr_get_var', 
    56                 TemplateNote => sub { '' }, 
    57             }, 
     20        block => { 
     21 
     22            ## Core 
     23            Ignore         =>   sub { '' }, 
     24            'If?'          => '$Core::MT::Template::Tags::Core::_hdlr_if', 
     25            'Unless?'      => '$Core::MT::Template::Tags::Core::_hdlr_unless', 
     26            'Else'         => '$Core::MT::Template::Tags::Core::_hdlr_else', 
     27            'ElseIf'       => '$Core::MT::Template::Tags::Core::_hdlr_elseif', 
     28            'IfNonEmpty?'  => '$Core::MT::Template::Tags::Core::_hdlr_if_nonempty', 
     29            'IfNonZero?'   => '$Core::MT::Template::Tags::Core::_hdlr_if_nonzero', 
     30            Loop           => '$Core::MT::Template::Tags::Core::_hdlr_loop', 
     31            'For'          => '$Core::MT::Template::Tags::Core::_hdlr_for', 
     32            SetVarBlock    => '$Core::MT::Template::Tags::Core::_hdlr_set_var', 
     33            SetVarTemplate => '$Core::MT::Template::Tags::Core::_hdlr_set_var', 
     34            SetVars        => '$Core::MT::Template::Tags::Core::_hdlr_set_vars', 
     35            SetHashVar     => '$Core::MT::Template::Tags::Core::_hdlr_set_hashvar', 
     36 
     37            ## System 
     38            IncludeBlock => '$Core::MT::Template::Tags::System::_hdlr_include_block', 
     39            IfStatic     => \&slurp, 
     40            IfDynamic    => \&else, 
     41            Section      => '$Core::MT::Template::Tags::System::_hdlr_section', 
     42 
     43            ## App 
     44            'App:Setting'      => '$Core::MT::Template::Tags::App::_hdlr_app_setting', 
     45            'App:Widget'       => '$Core::MT::Template::Tags::App::_hdlr_app_widget', 
     46            'App:StatusMsg'    => '$Core::MT::Template::Tags::App::_hdlr_app_statusmsg', 
     47            'App:Listing'      => '$Core::MT::Template::Tags::App::_hdlr_app_listing', 
     48            'App:SettingGroup' => '$Core::MT::Template::Tags::App::_hdlr_app_setting_group', 
     49            'App:Form'         => '$Core::MT::Template::Tags::App::_hdlr_app_form', 
     50 
     51            ## Blog 
     52            Blogs              => '$Core::MT::Template::Tags::Blog::_hdlr_blogs', 
     53            'IfBlog?'          => '$Core::MT::Template::Tags::Blog::_hdlr_blog_id', 
     54            'BlogIfCCLicense?' => '$Core::MT::Template::Tags::Blog::_hdlr_blog_if_cc_license', 
     55 
     56            ## Author 
     57            Authors        => '$Core::MT::Template::Tags::Author::_hdlr_authors', 
     58            AuthorNext     => '$Core::MT::Template::Tags::Author::_hdlr_author_next_prev', 
     59            AuthorPrevious => '$Core::MT::Template::Tags::Author::_hdlr_author_next_prev', 
     60            'IfAuthor?'    => '$Core::MT::Template::Tags::Author::_hdlr_if_author', 
     61 
     62            ## Commenter 
     63            'IfExternalUserManagement?'       => '$Core::MT::Template::Tags::Commenter::_hdlr_if_external_user_management', 
     64            'IfCommenterRegistrationAllowed?' => '$Core::MT::Template::Tags::Commenter::_hdlr_if_commenter_registration_allowed', 
     65            'IfCommenterTrusted?'             => '$Core::MT::Template::Tags::Commenter::_hdlr_commenter_trusted', 
     66            'CommenterIfTrusted?'             => '$Core::MT::Template::Tags::Commenter::_hdlr_commenter_trusted', 
     67            'IfCommenterIsAuthor?'            => '$Core::MT::Template::Tags::Commenter::_hdlr_commenter_isauthor', 
     68            'IfCommenterIsEntryAuthor?'       => '$Core::MT::Template::Tags::Commenter::_hdlr_commenter_isauthor', 
     69 
     70            ## Archive 
     71            Archives                => '$Core::MT::Template::Tags::Archive::_hdlr_archive_set', 
     72            ArchiveList             => '$Core::MT::Template::Tags::Archive::_hdlr_archives', 
     73            ArchiveListHeader       => \&slurp, 
     74            ArchiveListFooter       => \&slurp, 
     75            ArchivePrevious         => '$Core::MT::Template::Tags::Archive::_hdlr_archive_prev_next', 
     76            ArchiveNext             => '$Core::MT::Template::Tags::Archive::_hdlr_archive_prev_next', 
     77            'IfArchiveType?'        => '$Core::MT::Template::Tags::Archive::_hdlr_if_archive_type', 
     78            'IfArchiveTypeEnabled?' => '$Core::MT::Template::Tags::Archive::_hdlr_archive_type_enabled', 
     79            IndexList               => '$Core::MT::Template::Tags::Archive::_hdlr_index_list', 
     80 
     81            ## Entry 
     82            Entries            => '$Core::MT::Template::Tags::Entry::_hdlr_entries', 
     83            EntriesHeader      => \&slurp, 
     84            EntriesFooter      => \&slurp, 
     85            EntryPrevious      => '$Core::MT::Template::Tags::Entry::_hdlr_entry_previous', 
     86            EntryNext          => '$Core::MT::Template::Tags::Entry::_hdlr_entry_next', 
     87            DateHeader         => \&slurp, 
     88            DateFooter         => \&slurp, 
     89            'EntryIfExtended?' => '$Core::MT::Template::Tags::Entry::_hdlr_entry_if_extended', 
     90            'AuthorHasEntry?'  => '$Core::MT::Template::Tags::Entry::_hdlr_author_has_entry', 
     91 
     92            ## Comment 
     93            'IfCommentsModerated?'       => '$Core::MT::Template::Tags::Comment::_hdlr_comments_moderated', 
     94            'BlogIfCommentsOpen?'        => '$Core::MT::Template::Tags::Comment::_hdlr_blog_if_comments_open', 
     95            Comments                     => '$Core::MT::Template::Tags::Comment::_hdlr_comments', 
     96            CommentsHeader               => \&slurp, 
     97            CommentsFooter               => \&slurp, 
     98            CommentEntry                 => '$Core::MT::Template::Tags::Comment::_hdlr_comment_entry', 
     99            'CommentIfModerated?'        => '$Core::MT::Template::Tags::Comment::_hdlr_comment_if_moderated', 
     100            CommentParent                => '$Core::MT::Template::Tags::Comment::_hdlr_comment_parent', 
     101            CommentReplies               => '$Core::MT::Template::Tags::Comment::_hdlr_comment_replies', 
     102            'IfCommentParent?'           => '$Core::MT::Template::Tags::Comment::_hdlr_if_comment_parent', 
     103            'IfCommentReplies?'          => '$Core::MT::Template::Tags::Comment::_hdlr_if_comment_replies', 
     104            'IfRegistrationRequired?'    => '$Core::MT::Template::Tags::Comment::_hdlr_reg_required', 
     105            'IfRegistrationNotRequired?' => '$Core::MT::Template::Tags::Comment::_hdlr_reg_not_required', 
     106            'IfRegistrationAllowed?'     => '$Core::MT::Template::Tags::Comment::_hdlr_reg_allowed', 
     107            'IfTypeKeyToken?'            => '$Core::MT::Template::Tags::Comment::_hdlr_if_typekey_token', 
     108            'IfAllowCommentHTML?'        => '$Core::MT::Template::Tags::Comment::_hdlr_if_allow_comment_html', 
     109            'IfCommentsAllowed?'         => '$Core::MT::Template::Tags::Comment::_hdlr_if_comments_allowed', 
     110            'IfCommentsAccepted?'        => '$Core::MT::Template::Tags::Comment::_hdlr_if_comments_accepted', 
     111            'IfCommentsActive?'          => '$Core::MT::Template::Tags::Comment::_hdlr_if_comments_active', 
     112            'IfNeedEmail?'               => '$Core::MT::Template::Tags::Comment::_hdlr_if_need_email', 
     113            'IfRequireCommentEmails?'    => '$Core::MT::Template::Tags::Comment::_hdlr_if_need_email', 
     114            'EntryIfAllowComments?'      => '$Core::MT::Template::Tags::Comment::_hdlr_entry_if_allow_comments', 
     115            'EntryIfCommentsOpen?'       => '$Core::MT::Template::Tags::Comment::_hdlr_entry_if_comments_open', 
     116 
     117            ## Ping 
     118            Pings                    => '$Core::MT::Template::Tags::Ping::_hdlr_pings', 
     119            PingsHeader              => \&slurp, 
     120            PingsFooter              => \&slurp, 
     121            PingsSent                => '$Core::MT::Template::Tags::Ping::_hdlr_pings_sent', 
     122            PingEntry                => '$Core::MT::Template::Tags::Ping::_hdlr_ping_entry', 
     123            'IfPingsAllowed?'        => '$Core::MT::Template::Tags::Ping::_hdlr_if_pings_allowed', 
     124            'IfPingsAccepted?'       => '$Core::MT::Template::Tags::Ping::_hdlr_if_pings_accepted', 
     125            'IfPingsActive?'         => '$Core::MT::Template::Tags::Ping::_hdlr_if_pings_active', 
     126            'IfPingsModerated?'      => '$Core::MT::Template::Tags::Ping::_hdlr_if_pings_moderated', 
     127            'EntryIfAllowPings?'     => '$Core::MT::Template::Tags::Ping::_hdlr_entry_if_allow_pings', 
     128            'CategoryIfAllowPings?'  => '$Core::MT::Template::Tags::Ping::_hdlr_category_allow_pings', 
     129 
     130            ## Category 
     131            Categories                => '$Core::MT::Template::Tags::Category::_hdlr_categories', 
     132            CategoryPrevious          => '$Core::MT::Template::Tags::Category::_hdlr_category_prevnext', 
     133            CategoryNext              => '$Core::MT::Template::Tags::Category::_hdlr_category_prevnext', 
     134            SubCategories             => '$Core::MT::Template::Tags::Category::_hdlr_sub_categories', 
     135            TopLevelCategories        => '$Core::MT::Template::Tags::Category::_hdlr_top_level_categories', 
     136            ParentCategory            => '$Core::MT::Template::Tags::Category::_hdlr_parent_category', 
     137            ParentCategories          => '$Core::MT::Template::Tags::Category::_hdlr_parent_categories', 
     138            TopLevelParent            => '$Core::MT::Template::Tags::Category::_hdlr_top_level_parent', 
     139            EntriesWithSubCategories  => '$Core::MT::Template::Tags::Category::_hdlr_entries_with_sub_categories', 
     140            'IfCategory?'             => '$Core::MT::Template::Tags::Category::_hdlr_if_category', 
     141            'EntryIfCategory?'        => '$Core::MT::Template::Tags::Category::_hdlr_if_category', 
     142            'SubCatIsFirst?'          => '$Core::MT::Template::Tags::Category::_hdlr_sub_cat_is_first', 
     143            'SubCatIsLast?'           => '$Core::MT::Template::Tags::Category::_hdlr_sub_cat_is_last', 
     144            'HasSubCategories?'       => '$Core::MT::Template::Tags::Category::_hdlr_has_sub_categories', 
     145            'HasNoSubCategories?'     => '$Core::MT::Template::Tags::Category::_hdlr_has_no_sub_categories', 
     146            'HasParentCategory?'      => '$Core::MT::Template::Tags::Category::_hdlr_has_parent_category', 
     147            'HasNoParentCategory?'    => '$Core::MT::Template::Tags::Category::_hdlr_has_no_parent_category', 
     148            'IfIsAncestor?'           => '$Core::MT::Template::Tags::Category::_hdlr_is_ancestor', 
     149            'IfIsDescendant?'         => '$Core::MT::Template::Tags::Category::_hdlr_is_descendant', 
     150            EntryCategories           => '$Core::MT::Template::Tags::Category::_hdlr_entry_categories', 
     151            EntryAdditionalCategories => '$Core::MT::Template::Tags::Category::_hdlr_entry_additional_categories', 
     152 
     153            ## Page 
     154            'AuthorHasPage?' => '$Core::MT::Template::Tags::Page::_hdlr_author_has_page', 
     155            Pages            => '$Core::MT::Template::Tags::Page::_hdlr_pages', 
     156            PagePrevious     => '$Core::MT::Template::Tags::Page::_hdlr_page_previous', 
     157            PageNext         => '$Core::MT::Template::Tags::Page::_hdlr_page_next', 
     158            PagesHeader      => \&slurp, 
     159            PagesFooter      => \&slurp, 
     160 
     161            ## Folder 
     162            'IfFolder?'        => '$Core::MT::Template::Tags::Folder::_hdlr_if_folder', 
     163            'FolderHeader?'    => '$Core::MT::Template::Tags::Folder::_hdlr_folder_header', 
     164            'FolderFooter?'    => '$Core::MT::Template::Tags::Folder::_hdlr_folder_footer', 
     165            'HasSubFolders?'   => '$Core::MT::Template::Tags::Folder::_hdlr_has_sub_folders', 
     166            'HasParentFolder?' => '$Core::MT::Template::Tags::Folder::_hdlr_has_parent_folder', 
     167            PageFolder         => '$Core::MT::Template::Tags::Folder::_hdlr_page_folder', 
     168            Folders            => '$Core::MT::Template::Tags::Folder::_hdlr_folders', 
     169            FolderPrevious     => '$Core::MT::Template::Tags::Folder::_hdlr_folder_prevnext', 
     170            FolderNext         => '$Core::MT::Template::Tags::Folder::_hdlr_folder_prevnext', 
     171            SubFolders         => '$Core::MT::Template::Tags::Folder::_hdlr_sub_folders', 
     172            ParentFolders      => '$Core::MT::Template::Tags::Folder::_hdlr_parent_folders', 
     173            ParentFolder       => '$Core::MT::Template::Tags::Folder::_hdlr_parent_folder', 
     174            TopLevelFolders    => '$Core::MT::Template::Tags::Folder::_hdlr_top_level_folders', 
     175            TopLevelFolder     => '$Core::MT::Template::Tags::Folder::_hdlr_top_level_folder', 
     176 
     177            ## Asset 
     178            EntryAssets       => '$Core::MT::Template::Tags::Asset::_hdlr_assets', 
     179            PageAssets        => '$Core::MT::Template::Tags::Asset::_hdlr_assets', 
     180            Assets            => '$Core::MT::Template::Tags::Asset::_hdlr_assets', 
     181            Asset             => '$Core::MT::Template::Tags::Asset::_hdlr_asset', 
     182            AssetIsFirstInRow => \&slurp, 
     183            AssetIsLastInRow  => \&slurp, 
     184            AssetsHeader      => \&slurp, 
     185            AssetsFooter      => \&slurp, 
     186 
     187            ## Userpic 
     188            AuthorUserpicAsset      => '$Core::MT::Template::Tags::Userpic::_hdlr_author_userpic_asset', 
     189            EntryAuthorUserpicAsset => '$Core::MT::Template::Tags::Userpic::_hdlr_entry_author_userpic_asset', 
     190            CommenterUserpicAsset   => '$Core::MT::Template::Tags::Userpic::_hdlr_commenter_userpic_asset', 
     191 
     192            ## Tag 
     193            Tags             => '$Core::MT::Template::Tags::Tag::_hdlr_tags', 
     194            EntryTags        => '$Core::MT::Template::Tags::Tag::_hdlr_entry_tags', 
     195            PageTags         => '$Core::MT::Template::Tags::Tag::_hdlr_page_tags', 
     196            AssetTags        => '$Core::MT::Template::Tags::Tag::_hdlr_asset_tags', 
     197            'EntryIfTagged?' => '$Core::MT::Template::Tags::Tag::_hdlr_entry_if_tagged', 
     198            'PageIfTagged?'  => '$Core::MT::Template::Tags::Tag::_hdlr_page_if_tagged', 
     199            'AssetIfTagged?' => '$Core::MT::Template::Tags::Tag::_hdlr_asset_if_tagged', 
     200 
     201            ## Calendar 
     202            Calendar            => '$Core::MT::Template::Tags::Calendar::_hdlr_calendar', 
     203            CalendarWeekHeader  => \&slurp, 
     204            CalendarWeekFooter  => \&slurp, 
     205            CalendarIfBlank     => \&slurp, 
     206            CalendarIfToday     => \&slurp, 
     207            CalendarIfEntries   => \&slurp, 
     208            CalendarIfNoEntries => \&slurp, 
     209 
     210            ## Pager 
     211            'IfMoreResults?'     => '$Core::MT::Template::Tags::Pager::_hdlr_if_more_results', 
     212            'IfPreviousResults?' => '$Core::MT::Template::Tags::Pager::_hdlr_if_previous_results', 
     213            PagerBlock           => '$Core::MT::Template::Tags::Pager::_hdlr_pager_block', 
     214            IfCurrentPage        => \&slurp, 
     215 
     216            ## Search 
     217            IfTagSearch         => sub { '' }, 
     218            SearchResults       => sub { '' }, 
     219            IfStraightSearch    => sub { '' }, 
     220            NoSearchResults     => \&slurp, 
     221            NoSearch            => \&slurp, 
     222            SearchResultsHeader => sub { '' }, 
     223            SearchResultsFooter => sub { '' }, 
     224            BlogResultHeader    => sub { '' }, 
     225            BlogResultFooter    => sub { '' }, 
     226            IfMaxResultsCutoff  => sub { '' }, 
     227 
     228            ## Misc 
     229            'IfImageSupport?' => '$Core::MT::Template::Tags::Misc::_hdlr_if_image_support', 
    58230        }, 
    59         'MT::Template::Tags::System' => { 
    60             block => { 
    61                 IncludeBlock => '_hdlr_include_block', 
    62                 IfStatic => '_hdlr_pass_tokens', 
    63                 IfDynamic => '_hdlr_pass_tokens_else', 
    64                 Section => '_hdlr_section', 
    65             }, 
    66             function => { 
    67                 Include => '_hdlr_include', 
    68                 Link => '_hdlr_link', 
    69                 Date => '_hdlr_sys_date', 
    70                 AdminScript => '_hdlr_admin_script', 
    71                 CommentScript => '_hdlr_comment_script', 
    72                 TrackbackScript => '_hdlr_trackback_script', 
    73                 SearchScript => '_hdlr_search_script', 
    74                 XMLRPCScript => '_hdlr_xmlrpc_script', 
    75                 AtomScript => '_hdlr_atom_script', 
    76                 NotifyScript => '_hdlr_notify_script', 
    77                 CGIHost => '_hdlr_cgi_host', 
    78                 CGIPath => '_hdlr_cgi_path', 
    79                 AdminCGIPath => '_hdlr_admin_cgi_path', 
    80                 CGIRelativeURL => '_hdlr_cgi_relative_url', 
    81                 CGIServerPath => '_hdlr_cgi_server_path', 
    82                 StaticWebPath => '_hdlr_static_path', 
    83                 StaticFilePath => '_hdlr_static_file_path', 
    84                 Version => '_hdlr_mt_version', 
    85                 ProductName => '_hdlr_product_name', 
    86                 PublishCharset => '_hdlr_publish_charset', 
    87                 DefaultLanguage => '_hdlr_default_language', 
    88                 ConfigFile => '_hdlr_config_file', 
    89                 IndexBasename => '_hdlr_index_basename', 
    90                 HTTPContentType => '_hdlr_http_content_type', 
    91                 FileTemplate => '_hdlr_file_template', 
    92                 TemplateCreatedOn => '_hdlr_template_created_on', 
    93                 BuildTemplateID => '_hdlr_build_template_id', 
    94                 ErrorMessage => '_hdlr_error_message', 
    95             }, 
     231        function => { 
     232 
     233            ## Core 
     234            SetVar       => '$Core::MT::Template::Tags::Core::_hdlr_set_var', 
     235            GetVar       => '$Core::MT::Template::Tags::Core::_hdlr_get_var', 
     236            Var          => '$Core::MT::Template::Tags::Core::_hdlr_get_var', 
     237            TemplateNote => sub { '' }, 
     238 
     239            ## System 
     240            Include           => '$Core::MT::Template::Tags::System::_hdlr_include', 
     241            Link              => '$Core::MT::Template::Tags::System::_hdlr_link', 
     242            Date              => '$Core::MT::Template::Tags::System::_hdlr_sys_date', 
     243            AdminScript       => '$Core::MT::Template::Tags::System::_hdlr_admin_script', 
     244            CommentScript     => '$Core::MT::Template::Tags::System::_hdlr_comment_script', 
     245            TrackbackScript   => '$Core::MT::Template::Tags::System::_hdlr_trackback_script', 
     246            SearchScript      => '$Core::MT::Template::Tags::System::_hdlr_search_script', 
     247            XMLRPCScript      => '$Core::MT::Template::Tags::System::_hdlr_xmlrpc_script', 
     248            AtomScript        => '$Core::MT::Template::Tags::System::_hdlr_atom_script', 
     249            NotifyScript      => '$Core::MT::Template::Tags::System::_hdlr_notify_script', 
     250            CGIHost           => '$Core::MT::Template::Tags::System::_hdlr_cgi_host', 
     251            CGIPath           => '$Core::MT::Template::Tags::System::_hdlr_cgi_path', 
     252            AdminCGIPath      => '$Core::MT::Template::Tags::System::_hdlr_admin_cgi_path', 
     253            CGIRelativeURL    => '$Core::MT::Template::Tags::System::_hdlr_cgi_relative_url', 
     254            CGIServerPath     => '$Core::MT::Template::Tags::System::_hdlr_cgi_server_path', 
     255            StaticWebPath     => '$Core::MT::Template::Tags::System::_hdlr_static_path', 
     256            StaticFilePath    => '$Core::MT::Template::Tags::System::_hdlr_static_file_path', 
     257            Version           => '$Core::MT::Template::Tags::System::_hdlr_mt_version', 
     258            ProductName       => '$Core::MT::Template::Tags::System::_hdlr_product_name', 
     259            PublishCharset    => '$Core::MT::Template::Tags::System::_hdlr_publish_charset', 
     260            DefaultLanguage   => '$Core::MT::Template::Tags::System::_hdlr_default_language', 
     261            ConfigFile        => '$Core::MT::Template::Tags::System::_hdlr_config_file', 
     262            IndexBasename     => '$Core::MT::Template::Tags::System::_hdlr_index_basename', 
     263            HTTPContentType   => '$Core::MT::Template::Tags::System::_hdlr_http_content_type', 
     264            FileTemplate      => '$Core::MT::Template::Tags::System::_hdlr_file_template', 
     265            TemplateCreatedOn => '$Core::MT::Template::Tags::System::_hdlr_template_created_on', 
     266            BuildTemplateID   => '$Core::MT::Template::Tags::System::_hdlr_build_template_id', 
     267            ErrorMessage      => '$Core::MT::Template::Tags::System::_hdlr_error_message', 
     268 
     269            ## App 
     270 
     271            'App:PageActions' => '$Core::MT::Template::Tags::App::_hdlr_app_page_actions', 
     272            'App:ListFilters' => '$Core::MT::Template::Tags::App::_hdlr_app_list_filters', 
     273            'App:ActionBar'   => '$Core::MT::Template::Tags::App::_hdlr_app_action_bar', 
     274            'App:Link'        => '$Core::MT::Template::Tags::App::_hdlr_app_link', 
     275 
     276            ## Blog 
     277            BlogID             => '$Core::MT::Template::Tags::Blog::_hdlr_blog_id', 
     278            BlogName           => '$Core::MT::Template::Tags::Blog::_hdlr_blog_name', 
     279            BlogDescription    => '$Core::MT::Template::Tags::Blog::_hdlr_blog_description', 
     280            BlogLanguage       => '$Core::MT::Template::Tags::Blog::_hdlr_blog_language', 
     281            BlogURL            => '$Core::MT::Template::Tags::Blog::_hdlr_blog_url', 
     282            BlogArchiveURL     => '$Core::MT::Template::Tags::Blog::_hdlr_blog_archive_url', 
     283            BlogRelativeURL    => '$Core::MT::Template::Tags::Blog::_hdlr_blog_relative_url', 
     284            BlogSitePath       => '$Core::MT::Template::Tags::Blog::_hdlr_blog_site_path', 
     285            BlogHost           => '$Core::MT::Template::Tags::Blog::_hdlr_blog_host', 
     286            BlogTimezone       => '$Core::MT::Template::Tags::Blog::_hdlr_blog_timezone', 
     287            BlogCCLicenseURL   => '$Core::MT::Template::Tags::Blog::_hdlr_blog_cc_license_url', 
     288            BlogCCLicenseImage => '$Core::MT::Template::Tags::Blog::_hdlr_blog_cc_license_image', 
     289            CCLicenseRDF       => '$Core::MT::Template::Tags::Blog::_hdlr_cc_license_rdf', 
     290            BlogFileExtension  => '$Core::MT::Template::Tags::Blog::_hdlr_blog_file_extension', 
     291            BlogTemplateSetID  => '$Core::MT::Template::Tags::Blog::_hdlr_blog_template_set_id', 
     292 
     293            ## Author 
     294            AuthorID          => '$Core::MT::Template::Tags::Author::_hdlr_author_id', 
     295            AuthorName        => '$Core::MT::Template::Tags::Author::_hdlr_author_name', 
     296            AuthorDisplayName => '$Core::MT::Template::Tags::Author::_hdlr_author_display_name', 
     297            AuthorEmail       => '$Core::MT::Template::Tags::Author::_hdlr_author_email', 
     298            AuthorURL         => '$Core::MT::Template::Tags::Author::_hdlr_author_url', 
     299            AuthorAuthType    => '$Core::MT::Template::Tags::Author::_hdlr_author_auth_type', 
     300            AuthorAuthIconURL => '$Core::MT::Template::Tags::Author::_hdlr_author_auth_icon_url', 
     301            AuthorBasename    => '$Core::MT::Template::Tags::Author::_hdlr_author_basename', 
     302 
     303            ## Commenter 
     304            CommenterNameThunk       => '$Core::MT::Template::Tags::Commenter::_hdlr_commenter_name_thunk', 
     305            CommenterUsername        => '$Core::MT::Template::Tags::Commenter::_hdlr_commenter_username',  
     306            CommenterName            => '$Core::MT::Template::Tags::Commenter::_hdlr_commenter_name', 
     307            CommenterEmail           => '$Core::MT::Template::Tags::Commenter::_hdlr_commenter_email', 
     308            CommenterAuthType        => '$Core::MT::Template::Tags::Commenter::_hdlr_commenter_auth_type', 
     309            CommenterAuthIconURL     => '$Core::MT::Template::Tags::Commenter::_hdlr_commenter_auth_icon_url', 
     310            CommenterID              => '$Core::MT::Template::Tags::Commenter::_hdlr_commenter_id', 
     311            CommenterURL             => '$Core::MT::Template::Tags::Commenter::_hdlr_commenter_url', 
     312            UserSessionState         => '$Core::MT::Template::Tags::Commenter::_hdlr_user_session_state', 
     313            UserSessionCookieTimeout => '$Core::MT::Template::Tags::Commenter::_hdlr_user_session_cookie_timeout', 
     314            UserSessionCookieName    => '$Core::MT::Template::Tags::Commenter::_hdlr_user_session_cookie_name', 
     315            UserSessionCookiePath    => '$Core::MT::Template::Tags::Commenter::_hdlr_user_session_cookie_path', 
     316            UserSessionCookieDomain  => '$Core::MT::Template::Tags::Commenter::_hdlr_user_session_cookie_domain', 
     317 
     318            ## Archive 
     319            ArchiveLink      => '$Core::MT::Template::Tags::Archive::_hdlr_archive_link', 
     320            ArchiveTitle     => '$Core::MT::Template::Tags::Archive::_hdlr_archive_title', 
     321            ArchiveType      => '$Core::MT::Template::Tags::Archive::_hdlr_archive_type', 
     322            ArchiveTypeLabel => '$Core::MT::Template::Tags::Archive::_hdlr_archive_label', 
     323            ArchiveLabel     => '$Core::MT::Template::Tags::Archive::_hdlr_archive_label', 
     324            ArchiveCount     => '$Core::MT::Template::Tags::Archive::_hdlr_archive_count', 
     325            ArchiveDate      => \&build_date, 
     326            ArchiveDateEnd   => '$Core::MT::Template::Tags::Archive::_hdlr_archive_date_end', 
     327            ArchiveFile      => '$Core::MT::Template::Tags::Archive::_hdlr_archive_file', 
     328            IndexLink        => '$Core::MT::Template::Tags::Archive::_hdlr_index_link', 
     329            IndexName        => '$Core::MT::Template::Tags::Archive::_hdlr_index_name', 
     330 
     331            ## Entry 
     332            EntriesCount           => '$Core::MT::Template::Tags::Entry::_hdlr_entries_count', 
     333            EntryID                => '$Core::MT::Template::Tags::Entry::_hdlr_entry_id', 
     334            EntryTitle             => '$Core::MT::Template::Tags::Entry::_hdlr_entry_title', 
     335            EntryStatus            => '$Core::MT::Template::Tags::Entry::_hdlr_entry_status', 
     336            EntryFlag              => '$Core::MT::Template::Tags::Entry::_hdlr_entry_flag', 
     337            EntryBody              => '$Core::MT::Template::Tags::Entry::_hdlr_entry_body', 
     338            EntryMore              => '$Core::MT::Template::Tags::Entry::_hdlr_entry_more', 
     339            EntryExcerpt           => '$Core::MT::Template::Tags::Entry::_hdlr_entry_excerpt', 
     340            EntryKeywords          => '$Core::MT::Template::Tags::Entry::_hdlr_entry_keywords', 
     341            EntryLink              => '$Core::MT::Template::Tags::Entry::_hdlr_entry_link', 
     342            EntryBasename          => '$Core::MT::Template::Tags::Entry::_hdlr_entry_basename', 
     343            EntryAtomID            => '$Core::MT::Template::Tags::Entry::_hdlr_entry_atom_id', 
     344            EntryPermalink         => '$Core::MT::Template::Tags::Entry::_hdlr_entry_permalink', 
     345            EntryClass             => '$Core::MT::Template::Tags::Entry::_hdlr_entry_class', 
     346            EntryClassLabel        => '$Core::MT::Template::Tags::Entry::_hdlr_entry_class_label', 
     347            EntryAuthor            => '$Core::MT::Template::Tags::Entry::_hdlr_entry_author', 
     348            EntryAuthorDisplayName => '$Core::MT::Template::Tags::Entry::_hdlr_entry_author_display_name', 
     349            EntryAuthorNickname    => '$Core::MT::Template::Tags::Entry::_hdlr_entry_author_nick', 
     350            EntryAuthorUsername    => '$Core::MT::Template::Tags::Entry::_hdlr_entry_author_username', 
     351            EntryAuthorEmail       => '$Core::MT::Template::Tags::Entry::_hdlr_entry_author_email', 
     352            EntryAuthorURL         => '$Core::MT::Template::Tags::Entry::_hdlr_entry_author_url', 
     353            EntryAuthorLink        => '$Core::MT::Template::Tags::Entry::_hdlr_entry_author_link', 
     354            EntryAuthorID          => '$Core::MT::Template::Tags::Entry::_hdlr_entry_author_id', 
     355 
     356            AuthorEntryCount       => '$Core::MT::Template::Tags::Entry::_hdlr_author_entry_count', 
     357            EntryDate              => '$Core::MT::Template::Tags::Entry::_hdlr_entry_date', 
     358            EntryCreatedDate       => '$Core::MT::Template::Tags::Entry::_hdlr_entry_create_date', 
     359            EntryModifiedDate      => '$Core::MT::Template::Tags::Entry::_hdlr_entry_mod_date', 
     360 
     361            EntryBlogID            => '$Core::MT::Template::Tags::Entry::_hdlr_entry_blog_id', 
     362            EntryBlogName          => '$Core::MT::Template::Tags::Entry::_hdlr_entry_blog_name', 
     363            EntryBlogDescription   => '$Core::MT::Template::Tags::Entry::_hdlr_entry_blog_description', 
     364            EntryBlogURL           => '$Core::MT::Template::Tags::Entry::_hdlr_entry_blog_url', 
     365            EntryEditLink          => '$Core::MT::Template::Tags::Entry::_hdlr_entry_edit_link', 
     366            BlogEntryCount         => '$Core::MT::Template::Tags::Entry::_hdlr_blog_entry_count', 
     367 
     368            ## Comment 
     369            CommentID                 => '$Core::MT::Template::Tags::Comment::_hdlr_comment_id', 
     370            CommentBlogID             => '$Core::MT::Template::Tags::Comment::_hdlr_comment_blog_id', 
     371            CommentEntryID            => '$Core::MT::Template::Tags::Comment::_hdlr_comment_entry_id', 
     372            CommentName               => '$Core::MT::Template::Tags::Comment::_hdlr_comment_author', 
     373            CommentIP                 => '$Core::MT::Template::Tags::Comment::_hdlr_comment_ip', 
     374            CommentAuthor             => '$Core::MT::Template::Tags::Comment::_hdlr_comment_author', 
     375            CommentAuthorLink         => '$Core::MT::Template::Tags::Comment::_hdlr_comment_author_link', 
     376            CommentAuthorIdentity     => '$Core::MT::Template::Tags::Comment::_hdlr_comment_author_identity', 
     377            CommentEmail              => '$Core::MT::Template::Tags::Comment::_hdlr_comment_email', 
     378            CommentLink               => '$Core::MT::Template::Tags::Comment::_hdlr_comment_link', 
     379            CommentURL                => '$Core::MT::Template::Tags::Comment::_hdlr_comment_url', 
     380            CommentBody               => '$Core::MT::Template::Tags::Comment::_hdlr_comment_body', 
     381            CommentOrderNumber        => '$Core::MT::Template::Tags::Comment::_hdlr_comment_order_num', 
     382            CommentDate               => '$Core::MT::Template::Tags::Comment::_hdlr_comment_date', 
     383            CommentParentID           => '$Core::MT::Template::Tags::Comment::_hdlr_comment_parent_id', 
     384            CommentReplyToLink        => '$Core::MT::Template::Tags::Comment::_hdlr_comment_reply_link', 
     385            CommentPreviewAuthor      => '$Core::MT::Template::Tags::Comment::_hdlr_comment_author', 
     386            CommentPreviewIP          => '$Core::MT::Template::Tags::Comment::_hdlr_comment_ip', 
     387            CommentPreviewAuthorLink  => '$Core::MT::Template::Tags::Comment::_hdlr_comment_author_link', 
     388            CommentPreviewEmail       => '$Core::MT::Template::Tags::Comment::_hdlr_comment_email', 
     389            CommentPreviewURL         => '$Core::MT::Template::Tags::Comment::_hdlr_comment_url', 
     390            CommentPreviewBody        => '$Core::MT::Template::Tags::Comment::_hdlr_comment_body', 
     391            CommentPreviewDate        => \&build_date, 
     392            CommentPreviewState       => '$Core::MT::Template::Tags::Comment::_hdlr_comment_prev_state', 
     393            CommentPreviewIsStatic    => '$Core::MT::Template::Tags::Comment::_hdlr_comment_prev_static', 
     394            CommentRepliesRecurse     => '$Core::MT::Template::Tags::Comment::_hdlr_comment_replies_recurse', 
     395            BlogCommentCount          => '$Core::MT::Template::Tags::Comment::_hdlr_blog_comment_count', 
     396            EntryCommentCount         => '$Core::MT::Template::Tags::Comment::_hdlr_entry_comments', 
     397            CategoryCommentCount      => '$Core::MT::Template::Tags::Comment::_hdlr_category_comment_count', 
     398            TypeKeyToken              => '$Core::MT::Template::Tags::Comment::_hdlr_typekey_token', 
     399            CommentFields             => '$Core::MT::Template::Tags::Comment::_hdlr_comment_fields', 
     400            RemoteSignOutLink         => '$Core::MT::Template::Tags::Comment::_hdlr_remote_sign_out_link', 
     401            RemoteSignInLink          => '$Core::MT::Template::Tags::Comment::_hdlr_remote_sign_in_link', 
     402            SignOutLink               => '$Core::MT::Template::Tags::Comment::_hdlr_sign_out_link', 
     403            SignInLink                => '$Core::MT::Template::Tags::Comment::_hdlr_sign_in_link', 
     404            SignOnURL                 => '$Core::MT::Template::Tags::Comment::_hdlr_signon_url', 
     405 
     406            ## Ping', => { 
     407            PingsSentURL           => '$Core::MT::Template::Tags::Ping::_hdlr_pings_sent_url', 
     408            PingTitle              => '$Core::MT::Template::Tags::Ping::_hdlr_ping_title', 
     409            PingID                 => '$Core::MT::Template::Tags::Ping::_hdlr_ping_id', 
     410            PingURL                => '$Core::MT::Template::Tags::Ping::_hdlr_ping_url', 
     411            PingExcerpt            => '$Core::MT::Template::Tags::Ping::_hdlr_ping_excerpt', 
     412            PingBlogName           => '$Core::MT::Template::Tags::Ping::_hdlr_ping_blog_name', 
     413            PingIP                 => '$Core::MT::Template::Tags::Ping::_hdlr_ping_ip', 
     414            PingDate               => '$Core::MT::Template::Tags::Ping::_hdlr_ping_date', 
     415            BlogPingCount          => '$Core::MT::Template::Tags::Ping::_hdlr_blog_ping_count', 
     416            EntryTrackbackCount    => '$Core::MT::Template::Tags::Ping::_hdlr_entry_ping_count', 
     417            EntryTrackbackLink     => '$Core::MT::Template::Tags::Ping::_hdlr_entry_tb_link', 
     418            EntryTrackbackData     => '$Core::MT::Template::Tags::Ping::_hdlr_entry_tb_data', 
     419            EntryTrackbackID       => '$Core::MT::Template::Tags::Ping::_hdlr_entry_tb_id', 
     420            CategoryTrackbackLink  => '$Core::MT::Template::Tags::Ping::_hdlr_category_tb_link', 
     421            CategoryTrackbackCount => '$Core::MT::Template::Tags::Ping::_hdlr_category_tb_count', 
     422 
     423            ## Category 
     424            CategoryID          => '$Core::MT::Template::Tags::Category::_hdlr_category_id', 
     425            CategoryLabel       => '$Core::MT::Template::Tags::Category::_hdlr_category_label', 
     426            CategoryBasename    => '$Core::MT::Template::Tags::Category::_hdlr_category_basename', 
     427            CategoryDescription => '$Core::MT::Template::Tags::Category::_hdlr_category_desc', 
     428            CategoryArchiveLink => '$Core::MT::Template::Tags::Category::_hdlr_category_archive', 
     429            CategoryCount       => '$Core::MT::Template::Tags::Category::_hdlr_category_count', 
     430            SubCatsRecurse      => '$Core::MT::Template::Tags::Category::_hdlr_sub_cats_recurse', 
     431            SubCategoryPath     => '$Core::MT::Template::Tags::Category::_hdlr_sub_category_path', 
     432            BlogCategoryCount   => '$Core::MT::Template::Tags::Category::_hdlr_blog_category_count', 
     433            ArchiveCategory     => '$Core::MT::Template::Tags::Category::_hdlr_archive_category', 
     434            EntryCategory       => '$Core::MT::Template::Tags::Category::_hdlr_entry_category', 
     435 
     436            ## Page 
     437            PageID                => '$Core::MT::Template::Tags::Page::_hdlr_page_id', 
     438            PageTitle             => '$Core::MT::Template::Tags::Page::_hdlr_page_title', 
     439            PageBody              => '$Core::MT::Template::Tags::Page::_hdlr_page_body',  
     440            PageMore              => '$Core::MT::Template::Tags::Page::_hdlr_page_more', 
     441            PageDate              => '$Core::MT::Template::Tags::Page::_hdlr_page_date', 
     442            PageModifiedDate      => '$Core::MT::Template::Tags::Page::_hdlr_page_modified_date', 
     443            PageKeywords          => '$Core::MT::Template::Tags::Page::_hdlr_page_keywords', 
     444            PageBasename          => '$Core::MT::Template::Tags::Page::_hdlr_page_basename', 
     445            PagePermalink         => '$Core::MT::Template::Tags::Page::_hdlr_page_permalink', 
     446            PageAuthorDisplayName => '$Core::MT::Template::Tags::Page::_hdlr_page_author_display_name', 
     447            PageAuthorEmail       => '$Core::MT::Template::Tags::Page::_hdlr_page_author_email', 
     448            PageAuthorLink        => '$Core::MT::Template::Tags::Page::_hdlr_page_author_link', 
     449            PageAuthorURL         => '$Core::MT::Template::Tags::Page::_hdlr_page_author_url', 
     450            PageExcerpt           => '$Core::MT::Template::Tags::Page::_hdlr_page_excerpt', 
     451            BlogPageCount         => '$Core::MT::Template::Tags::Page::_hdlr_blog_page_count', 
     452 
     453            ## Folder 
     454            FolderBasename    => '$Core::MT::Template::Tags::Folder::_hdlr_folder_basename', 
     455            FolderCount       => '$Core::MT::Template::Tags::Folder::_hdlr_folder_count', 
     456            FolderDescription => '$Core::MT::Template::Tags::Folder::_hdlr_folder_description', 
     457            FolderID          => '$Core::MT::Template::Tags::Folder::_hdlr_folder_id', 
     458            FolderLabel       => '$Core::MT::Template::Tags::Folder::_hdlr_folder_label', 
     459            FolderPath        => '$Core::MT::Template::Tags::Folder::_hdlr_folder_path', 
     460            SubFolderRecurse  => '$Core::MT::Template::Tags::Folder::_hdlr_sub_folder_recurse', 
     461 
     462            ## Asset 
     463            AssetID            => '$Core::MT::Template::Tags::Asset::_hdlr_asset_id', 
     464            AssetFileName      => '$Core::MT::Template::Tags::Asset::_hdlr_asset_file_name', 
     465            AssetLabel         => '$Core::MT::Template::Tags::Asset::_hdlr_asset_label', 
     466            AssetURL           => '$Core::MT::Template::Tags::Asset::_hdlr_asset_url', 
     467            AssetType          => '$Core::MT::Template::Tags::Asset::_hdlr_asset_type', 
     468            AssetMimeType      => '$Core::MT::Template::Tags::Asset::_hdlr_asset_mime_type', 
     469            AssetFilePath      => '$Core::MT::Template::Tags::Asset::_hdlr_asset_file_path', 
     470            AssetDateAdded     => '$Core::MT::Template::Tags::Asset::_hdlr_asset_date_added', 
     471            AssetAddedBy       => '$Core::MT::Template::Tags::Asset::_hdlr_asset_added_by', 
     472            AssetProperty      => '$Core::MT::Template::Tags::Asset::_hdlr_asset_property', 
     473            AssetFileExt       => '$Core::MT::Template::Tags::Asset::_hdlr_asset_file_ext', 
     474            AssetThumbnailURL  => '$Core::MT::Template::Tags::Asset::_hdlr_asset_thumbnail_url', 
     475            AssetLink          => '$Core::MT::Template::Tags::Asset::_hdlr_asset_link', 
     476            AssetThumbnailLink => '$Core::MT::Template::Tags::Asset::_hdlr_asset_thumbnail_link', 
     477            AssetDescription   => '$Core::MT::Template::Tags::Asset::_hdlr_asset_description', 
     478            AssetCount         => '$Core::MT::Template::Tags::Asset::_hdlr_asset_count', 
     479 
     480            ## Userpic 
     481            AuthorUserpic         => '$Core::MT::Template::Tags::Userpic::_hdlr_author_userpic', 
     482            AuthorUserpicURL      => '$Core::MT::Template::Tags::Userpic::_hdlr_author_userpic_url', 
     483            EntryAuthorUserpic    => '$Core::MT::Template::Tags::Userpic::_hdlr_entry_author_userpic', 
     484            EntryAuthorUserpicURL => '$Core::MT::Template::Tags::Userpic::_hdlr_entry_author_userpic_url', 
     485            CommenterUserpic      => '$Core::MT::Template::Tags::Userpic::_hdlr_commenter_userpic', 
     486            CommenterUserpicURL   => '$Core::MT::Template::Tags::Userpic::_hdlr_commenter_userpic_url', 
     487 
     488            ## Tag 
     489            TagName       => '$Core::MT::Template::Tags::Tag::_hdlr_tag_name', 
     490            TagLabel      => '$Core::MT::Template::Tags::Tag::_hdlr_tag_name', 
     491            TagID         => '$Core::MT::Template::Tags::Tag::_hdlr_tag_id', 
     492            TagCount      => '$Core::MT::Template::Tags::Tag::_hdlr_tag_count', 
     493            TagRank       => '$Core::MT::Template::Tags::Tag::_hdlr_tag_rank', 
     494            TagSearchLink => '$Core::MT::Template::Tags::Tag::_hdlr_tag_search_link', 
     495 
     496            ## Calendar 
     497            CalendarDay        => '$Core::MT::Template::Tags::Calendar::_hdlr_calendar_day', 
     498            CalendarCellNumber => '$Core::MT::Template::Tags::Calendar::_hdlr_calendar_cell_num', 
     499            CalendarDate       => \&build_date, 
     500 
     501            ## Score 
     502            # Rating related handlers 
     503            EntryScore   => '$Core::MT::Template::Tags::Score::_hdlr_entry_score', 
     504            CommentScore => '$Core::MT::Template::Tags::Score::_hdlr_comment_score', 
     505            PingScore    => '$Core::MT::Template::Tags::Score::_hdlr_ping_score', 
     506            AssetScore   => '$Core::MT::Template::Tags::Score::_hdlr_asset_score', 
     507            AuthorScore  => '$Core::MT::Template::Tags::Score::_hdlr_author_score', 
     508 
     509            EntryScoreHigh   => '$Core::MT::Template::Tags::Score::_hdlr_entry_score_high', 
     510            CommentScoreHigh => '$Core::MT::Template::Tags::Score::_hdlr_comment_score_high', 
     511            PingScoreHigh    => '$Core::MT::Template::Tags::Score::_hdlr_ping_score_high', 
     512            AssetScoreHigh   => '$Core::MT::Template::Tags::Score::_hdlr_asset_score_high', 
     513            AuthorScoreHigh  => '$Core::MT::Template::Tags::Score::_hdlr_author_score_high', 
     514 
     515            EntryScoreLow   => '$Core::MT::Template::Tags::Score::_hdlr_entry_score_low', 
     516            CommentScoreLow => '$Core::MT::Template::Tags::Score::_hdlr_comment_score_low', 
     517            PingScoreLow    => '$Core::MT::Template::Tags::Score::_hdlr_ping_score_low', 
     518            AssetScoreLow   => '$Core::MT::Template::Tags::Score::_hdlr_asset_score_low', 
     519            AuthorScoreLow  => '$Core::MT::Template::Tags::Score::_hdlr_author_score_low', 
     520 
     521            EntryScoreAvg   => '$Core::MT::Template::Tags::Score::_hdlr_entry_score_avg', 
     522            CommentScoreAvg => '$Core::MT::Template::Tags::Score::_hdlr_comment_score_avg', 
     523            PingScoreAvg    => '$Core::MT::Template::Tags::Score::_hdlr_ping_score_avg', 
     524            AssetScoreAvg   => '$Core::MT::Template::Tags::Score::_hdlr_asset_score_avg', 
     525            AuthorScoreAvg  => '$Core::MT::Template::Tags::Score::_hdlr_author_score_avg', 
     526 
     527            EntryScoreCount   => '$Core::MT::Template::Tags::Score::_hdlr_entry_score_count', 
     528            CommentScoreCount => '$Core::MT::Template::Tags::Score::_hdlr_comment_score_count', 
     529            PingScoreCount    => '$Core::MT::Template::Tags::Score::_hdlr_ping_score_count', 
     530            AssetScoreCount   => '$Core::MT::Template::Tags::Score::_hdlr_asset_score_count', 
     531            AuthorScoreCount  => '$Core::MT::Template::Tags::Score::_hdlr_author_score_count', 
     532 
     533            EntryRank   => '$Core::MT::Template::Tags::Score::_hdlr_entry_rank', 
     534            CommentRank => '$Core::MT::Template::Tags::Score::_hdlr_comment_rank', 
     535            PingRank    => '$Core::MT::Template::Tags::Score::_hdlr_ping_rank', 
     536            AssetRank   => '$Core::MT::Template::Tags::Score::_hdlr_asset_rank', 
     537            AuthorRank  => '$Core::MT::Template::Tags::Score::_hdlr_author_rank', 
     538 
     539            ## Pager 
     540            PagerLink    => '$Core::MT::Template::Tags::Pager::_hdlr_pager_link', 
     541            NextLink     => '$Core::MT::Template::Tags::Pager::_hdlr_next_link', 
     542            PreviousLink => '$Core::MT::Template::Tags::Pager::_hdlr_previous_link', 
     543            CurrentPage  => '$Core::MT::Template::Tags::Pager::_hdlr_current_page', 
     544            TotalPages   => '$Core::MT::Template::Tags::Pager::_hdlr_total_pages', 
     545 
     546            ## Search 
     547            # stubs for mt-search tags used in template includes 
     548            SearchString       => sub { '' }, 
     549            SearchResultCount  => sub { 0 },  
     550            MaxResults         => sub { '' }, 
     551            SearchMaxResults   => '$Core::MT::Template::Tags::Search::_hdlr_search_max_results', 
     552            SearchIncludeBlogs => sub { '' }, 
     553            SearchTemplateID   => sub { 0 }, 
     554 
     555            ## Misc 
     556            FeedbackScore => '$Core::MT::Template::Tags::Misc::_hdlr_feedback_score', 
     557            ImageURL      => '$Core::MT::Template::Tags::Misc::_hdlr_image_url', 
     558            ImageWidth    => '$Core::MT::Template::Tags::Misc::_hdlr_image_width', 
     559            ImageHeight   => '$Core::MT::Template::Tags::Misc::_hdlr_image_height', 
     560            WidgetManager => '$Core::MT::Template::Tags::Misc::_hdlr_widget_manager', 
     561            WidgetSet     => '$Core::MT::Template::Tags::Misc::_hdlr_widget_manager', 
     562            CaptchaFields => '$Core::MT::Template::Tags::Misc::_hdlr_captcha_fields', 
    96563        }, 
    97         'MT::Template::Tags::App' => { 
    98             block => { 
    99                 'App:Setting'      => '_hdlr_app_setting', 
    100                 'App:Widget'       => '_hdlr_app_widget', 
    101                 'App:StatusMsg'    => '_hdlr_app_statusmsg', 
    102                 'App:Listing'      => '_hdlr_app_listing', 
    103                 'App:SettingGroup' => '_hdlr_app_setting_group', 
    104                 'App:Form'         => '_hdlr_app_form', 
    105  
    106             }, 
    107             function => { 
    108                 'App:PageActions' => '_hdlr_app_page_actions', 
    109                 'App:ListFilters' => '_hdlr_app_list_filters', 
    110                 'App:ActionBar'   => '_hdlr_app_action_bar', 
    111                 'App:Link'        => '_hdlr_app_link', 
    112             }, 
    113         }, 
    114         'MT::Template::Tags::Blog' => { 
    115             block => { 
    116                 Blogs              => '_hdlr_blogs', 
    117                 'IfBlog?'          => '_hdlr_blog_id', 
    118                 'BlogIfCCLicense?' => '_hdlr_blog_if_cc_license', 
    119             }, 
    120             function => { 
    121                 BlogID             => '_hdlr_blog_id', 
    122                 BlogName           => '_hdlr_blog_name', 
    123                 BlogDescription    => '_hdlr_blog_description', 
    124                 BlogLanguage       => '_hdlr_blog_language', 
    125                 BlogURL            => '_hdlr_blog_url', 
    126                 BlogArchiveURL     => '_hdlr_blog_archive_url', 
    127                 BlogRelativeURL    => '_hdlr_blog_relative_url', 
    128                 BlogSitePath       => '_hdlr_blog_site_path', 
    129                 BlogHost           => '_hdlr_blog_host', 
    130                 BlogTimezone       => '_hdlr_blog_timezone', 
    131                 BlogCCLicenseURL   => '_hdlr_blog_cc_license_url', 
    132                 BlogCCLicenseImage => '_hdlr_blog_cc_license_image', 
    133                 CCLicenseRDF       => '_hdlr_cc_license_rdf', 
    134                 BlogFileExtension  => '_hdlr_blog_file_extension', 
    135                 BlogTemplateSetID  => '_hdlr_blog_template_set_id', 
    136             }, 
    137         }, 
    138         'MT::Template::Tags::Author' => { 
    139             block => { 
    140                 Authors        => '_hdlr_authors', 
    141                 AuthorNext     => '_hdlr_author_next_prev', 
    142                 AuthorPrevious => '_hdlr_author_next_prev', 
    143                 'IfAuthor?'    => '_hdlr_if_author', 
    144             }, 
    145             function => { 
    146                 AuthorID          => '_hdlr_author_id', 
    147                 AuthorName        => '_hdlr_author_name', 
    148                 AuthorDisplayName =>'_hdlr_author_display_name', 
    149                 AuthorEmail       => '_hdlr_author_email', 
    150                 AuthorURL         => '_hdlr_author_url', 
    151                 AuthorAuthType    => '_hdlr_author_auth_type', 
    152                 AuthorAuthIconURL => '_hdlr_author_auth_icon_url', 
    153                 AuthorBasename    => '_hdlr_author_basename', 
    154             }, 
    155         }, 
    156         'MT::Template::Tags::Commenter' => { 
    157             block => { 
    158                 'IfExternalUserManagement?'       => '_hdlr_if_external_user_management', 
    159                 'IfCommenterRegistrationAllowed?' => '_hdlr_if_commenter_registration_allowed', 
    160                 'IfCommenterTrusted?'             => '_hdlr_commenter_trusted', 
    161                 'CommenterIfTrusted?'             => '_hdlr_commenter_trusted', 
    162                 'IfCommenterIsAuthor?'            => '_hdlr_commenter_isauthor', 
    163                 'IfCommenterIsEntryAuthor?'       => '_hdlr_commenter_isauthor', 
    164             }, 
    165             function => { 
    166                 CommenterNameThunk       => '_hdlr_commenter_name_thunk', 
    167                 CommenterUsername        => '_hdlr_commenter_username',  
    168                 CommenterName            => '_hdlr_commenter_name', 
    169                 CommenterEmail           => '_hdlr_commenter_email', 
    170                 CommenterAuthType        => '_hdlr_commenter_auth_type', 
    171                 CommenterAuthIconURL     => '_hdlr_commenter_auth_icon_url', 
    172                 CommenterID              => '_hdlr_commenter_id', 
    173                 CommenterURL             => '_hdlr_commenter_url', 
    174                 UserSessionState         => '_hdlr_user_session_state', 
    175                 UserSessionCookieTimeout => '_hdlr_user_session_cookie_timeout', 
    176                 UserSessionCookieName    => '_hdlr_user_session_cookie_name', 
    177                 UserSessionCookiePath    => '_hdlr_user_session_cookie_path', 
    178                 UserSessionCookieDomain  => '_hdlr_user_session_cookie_domain', 
    179             }, 
    180         }, 
    181         'MT::Template::Tags::Archive' => { 
    182             block => { 
    183                 Archives                => '_hdlr_archive_set', 
    184                 ArchiveList             => '_hdlr_archives', 
    185                 ArchiveListHeader       => '_hdlr_pass_tokens', 
    186                 ArchiveListFooter       => '_hdlr_pass_tokens', 
    187                 ArchivePrevious         => '_hdlr_archive_prev_next', 
    188                 ArchiveNext             => '_hdlr_archive_prev_next', 
    189                 'IfArchiveType?'        => '_hdlr_if_archive_type', 
    190                 'IfArchiveTypeEnabled?' => '_hdlr_archive_type_enabled', 
    191                 IndexList               => '_hdlr_index_list', 
    192             }, 
    193             function => { 
    194                 ArchiveLink      => '_hdlr_archive_link', 
    195                 ArchiveTitle     => '_hdlr_archive_title', 
    196                 ArchiveType      => '_hdlr_archive_type', 
    197                 ArchiveTypeLabel => '_hdlr_archive_label', 
    198                 ArchiveLabel     => '_hdlr_archive_label', 
    199                 ArchiveCount     => '_hdlr_archive_count', 
    200                 ArchiveDate      => '_hdlr_date', 
    201                 ArchiveDateEnd   => '_hdlr_archive_date_end', 
    202                 ArchiveFile      => '_hdlr_archive_file', 
    203                 IndexLink        => '_hdlr_index_link', 
    204                 IndexName        => '_hdlr_index_name', 
    205             }, 
    206         }, 
    207         'MT::Template::Tags::Entry' => { 
    208             block => { 
    209                 Entries            => '_hdlr_entries', 
    210                 EntriesHeader      => '_hdlr_pass_tokens', 
    211                 EntriesFooter      => '_hdlr_pass_tokens', 
    212                 EntryPrevious      => '_hdlr_entry_previous', 
    213                 EntryNext          => '_hdlr_entry_next', 
    214                 DateHeader         => '_hdlr_pass_tokens', 
    215                 DateFooter         => '_hdlr_pass_tokens', 
    216                 'EntryIfExtended?' => '_hdlr_entry_if_extended', 
    217                 'AuthorHasEntry?'  => '_hdlr_author_has_entry', 
    218             }, 
    219             function => { 
    220                 EntriesCount           => '_hdlr_entries_count', 
    221                 EntryID                => '_hdlr_entry_id', 
    222                 EntryTitle             => '_hdlr_entry_title', 
    223                 EntryStatus            => '_hdlr_entry_status', 
    224                 EntryFlag              => '_hdlr_entry_flag', 
    225                 EntryBody              => '_hdlr_entry_body', 
    226                 EntryMore              => '_hdlr_entry_more', 
    227                 EntryExcerpt           => '_hdlr_entry_excerpt', 
    228                 EntryKeywords          => '_hdlr_entry_keywords', 
    229                 EntryLink              => '_hdlr_entry_link', 
    230                 EntryBasename          => '_hdlr_entry_basename', 
    231                 EntryAtomID            => '_hdlr_entry_atom_id', 
    232                 EntryPermalink         => '_hdlr_entry_permalink', 
    233                 EntryClass             => '_hdlr_entry_class', 
    234                 EntryClassLabel        => '_hdlr_entry_class_label', 
    235                 EntryAuthor            => '_hdlr_entry_author', 
    236                 EntryAuthorDisplayName => '_hdlr_entry_author_display_name', 
    237                 EntryAuthorNickname    => '_hdlr_entry_author_nick', 
    238                 EntryAuthorUsername    => '_hdlr_entry_author_username', 
    239                 EntryAuthorEmail       => '_hdlr_entry_author_email', 
    240                 EntryAuthorURL         => '_hdlr_entry_author_url', 
    241                 EntryAuthorLink        => '_hdlr_entry_author_link', 
    242                 EntryAuthorID          => '_hdlr_entry_author_id', 
    243  
    244                 AuthorEntryCount       => '_hdlr_author_entry_count', 
    245                 EntryDate              => '_hdlr_entry_date', 
    246                 EntryCreatedDate       => '_hdlr_entry_create_date', 
    247                 EntryModifiedDate      => '_hdlr_entry_mod_date', 
    248  
    249                 EntryBlogID            => '_hdlr_entry_blog_id', 
    250                 EntryBlogName          => '_hdlr_entry_blog_name', 
    251                 EntryBlogDescription   => '_hdlr_entry_blog_description', 
    252                 EntryBlogURL           => '_hdlr_entry_blog_url', 
    253                 EntryEditLink          => '_hdlr_entry_edit_link', 
    254                 BlogEntryCount         => '_hdlr_blog_entry_count', 
    255             }, 
    256         }, 
    257         'MT::Template::Tags::Comment' => { 
    258             block => { 
    259                 'IfCommentsModerated?'       => '_hdlr_comments_moderated', 
    260                 'BlogIfCommentsOpen?'        => '_hdlr_blog_if_comments_open', 
    261                 Comments                     => '_hdlr_comments', 
    262                 CommentsHeader               => '_hdlr_pass_tokens', 
    263                 CommentsFooter               => '_hdlr_pass_tokens', 
    264                 CommentEntry                 => '_hdlr_comment_entry', 
    265                 'CommentIfModerated?'        => '_hdlr_comment_if_moderated', 
    266                 CommentParent                => '_hdlr_comment_parent', 
    267                 CommentReplies               => '_hdlr_comment_replies', 
    268                 'IfCommentParent?'           => '_hdlr_if_comment_parent', 
    269                 'IfCommentReplies?'          => '_hdlr_if_comment_replies', 
    270                 'IfRegistrationRequired?'    => '_hdlr_reg_required', 
    271                 'IfRegistrationNotRequired?' => '_hdlr_reg_not_required', 
    272                 'IfRegistrationAllowed?'     => '_hdlr_reg_allowed', 
    273                 'IfTypeKeyToken?'            => '_hdlr_if_typekey_token', 
    274                 'IfAllowCommentHTML?'        => '_hdlr_if_allow_comment_html', 
    275                 'IfCommentsAllowed?'         => '_hdlr_if_comments_allowed', 
    276                 'IfCommentsAccepted?'        => '_hdlr_if_comments_accepted', 
    277                 'IfCommentsActive?'          => '_hdlr_if_comments_active', 
    278                 'IfNeedEmail?'               => '_hdlr_if_need_email', 
    279                 'IfRequireCommentEmails?'    => '_hdlr_if_need_email', 
    280                 'EntryIfAllowComments?'      => '_hdlr_entry_if_allow_comments', 
    281                 'EntryIfCommentsOpen?'       => '_hdlr_entry_if_comments_open', 
    282             }, 
    283             function => { 
    284                 CommentID                 => '_hdlr_comment_id', 
    285                 CommentBlogID             => '_hdlr_comment_blog_id', 
    286                 CommentEntryID            => '_hdlr_comment_entry_id', 
    287                 CommentName               => '_hdlr_comment_author', 
    288                 CommentIP                 => '_hdlr_comment_ip', 
    289                 CommentAuthor             => '_hdlr_comment_author', 
    290                 CommentAuthorLink         => '_hdlr_comment_author_link', 
    291                 CommentAuthorIdentity     => '_hdlr_comment_author_identity', 
    292                 CommentEmail              => '_hdlr_comment_email', 
    293                 CommentLink               => '_hdlr_comment_link', 
    294                 CommentURL                => '_hdlr_comment_url', 
    295                 CommentBody               => '_hdlr_comment_body', 
    296                 CommentOrderNumber        => '_hdlr_comment_order_num', 
    297                 CommentDate               => '_hdlr_comment_date', 
    298                 CommentParentID           => '_hdlr_comment_parent_id', 
    299                 CommentReplyToLink        => '_hdlr_comment_reply_link', 
    300                 CommentPreviewAuthor      => '_hdlr_comment_author', 
    301                 CommentPreviewIP          => '_hdlr_comment_ip', 
    302                 CommentPreviewAuthorLink  => '_hdlr_comment_author_link', 
    303                 CommentPreviewEmail       => '_hdlr_comment_email', 
    304                 CommentPreviewURL         => '_hdlr_comment_url', 
    305                 CommentPreviewBody        => '_hdlr_comment_body', 
    306                 CommentPreviewDate        => '_hdlr_date', 
    307                 CommentPreviewState       => '_hdlr_comment_prev_state', 
    308                 CommentPreviewIsStatic    => '_hdlr_comment_prev_static', 
    309                 CommentRepliesRecurse     => '_hdlr_comment_replies_recurse', 
    310                 BlogCommentCount          => '_hdlr_blog_comment_count', 
    311                 EntryCommentCount         => '_hdlr_entry_comments', 
    312                 CategoryCommentCount      => '_hdlr_category_comment_count', 
    313                 TypeKeyToken              => '_hdlr_typekey_token', 
    314                 CommentFields             => '_hdlr_comment_fields', 
    315                 RemoteSignOutLink         => '_hdlr_remote_sign_out_link', 
    316                 RemoteSignInLink          => '_hdlr_remote_sign_in_link', 
    317                 SignOutLink               => '_hdlr_sign_out_link', 
    318                 SignInLink                => '_hdlr_sign_in_link', 
    319                 SignOnURL                 => '_hdlr_signon_url', 
    320             }, 
    321         }, 
    322         'MT::Template::Tags::Ping', => { 
    323             block => { 
    324                 Pings                    => '_hdlr_pings', 
    325                 PingsHeader              => '_hdlr_pass_tokens', 
    326                 PingsFooter              => '_hdlr_pass_tokens', 
    327                 PingsSent                => '_hdlr_pings_sent', 
    328                 PingEntry                => '_hdlr_ping_entry', 
    329                 'IfPingsAllowed?'        => '_hdlr_if_pings_allowed', 
    330                 'IfPingsAccepted?'       => '_hdlr_if_pings_accepted', 
    331                 'IfPingsActive?'         => '_hdlr_if_pings_active', 
    332                 'IfPingsModerated?'      => '_hdlr_if_pings_moderated', 
    333                 'EntryIfAllowPings?'     => '_hdlr_entry_if_allow_pings', 
    334                 'CategoryIfAllowPings?'  => '_hdlr_category_allow_pings', 
    335             }, 
    336             function => { 
    337                 PingsSentURL           => '_hdlr_pings_sent_url', 
    338                 PingTitle              => '_hdlr_ping_title', 
    339                 PingID                 => '_hdlr_ping_id', 
    340                 PingURL                => '_hdlr_ping_url', 
    341                 PingExcerpt            => '_hdlr_ping_excerpt', 
    342                 PingBlogName           => '_hdlr_ping_blog_name', 
    343                 PingIP                 => '_hdlr_ping_ip', 
    344                 PingDate               => '_hdlr_ping_date', 
    345                 BlogPingCount          => '_hdlr_blog_ping_count', 
    346                 EntryTrackbackCount    => '_hdlr_entry_ping_count', 
    347                 EntryTrackbackLink     => '_hdlr_entry_tb_link', 
    348                 EntryTrackbackData     => '_hdlr_entry_tb_data', 
    349                 EntryTrackbackID       => '_hdlr_entry_tb_id', 
    350                 CategoryTrackbackLink  => '_hdlr_category_tb_link', 
    351                 CategoryTrackbackCount => '_hdlr_category_tb_count', 
    352  
    353             }, 
    354         }, 
    355         'MT::Template::Tags::Category' => { 
    356             block => { 
    357                 Categories                => '_hdlr_categories', 
    358                 CategoryPrevious          => '_hdlr_category_prevnext', 
    359                 CategoryNext              => '_hdlr_category_prevnext', 
    360                 SubCategories             => '_hdlr_sub_categories', 
    361                 TopLevelCategories        => '_hdlr_top_level_categories', 
    362                 ParentCategory            => '_hdlr_parent_category', 
    363                 ParentCategories          => '_hdlr_parent_categories', 
    364                 TopLevelParent            => '_hdlr_top_level_parent', 
    365                 EntriesWithSubCategories  => '_hdlr_entries_with_sub_categories', 
    366                 'IfCategory?'             => '_hdlr_if_category', 
    367                 'EntryIfCategory?'        => '_hdlr_if_category', 
    368                 'SubCatIsFirst?'          => '_hdlr_sub_cat_is_first', 
    369                 'SubCatIsLast?'           => '_hdlr_sub_cat_is_last', 
    370                 'HasSubCategories?'       => '_hdlr_has_sub_categories', 
    371                 'HasNoSubCategories?'     => '_hdlr_has_no_sub_categories', 
    372                 'HasParentCategory?'      => '_hdlr_has_parent_category', 
    373                 'HasNoParentCategory?'    => '_hdlr_has_no_parent_category', 
    374                 'IfIsAncestor?'           => '_hdlr_is_ancestor', 
    375                 'IfIsDescendant?'         => '_hdlr_is_descendant', 
    376                 EntryCategories           => '_hdlr_entry_categories', 
    377                 EntryAdditionalCategories => '_hdlr_entry_additional_categories', 
    378  
    379             }, 
    380             function => { 
    381                 CategoryID          => '_hdlr_category_id', 
    382                 CategoryLabel       => '_hdlr_category_label', 
    383                 CategoryBasename    => '_hdlr_category_basename', 
    384                 CategoryDescription => '_hdlr_category_desc', 
    385                 CategoryArchiveLink => '_hdlr_category_archive', 
    386                 CategoryCount       => '_hdlr_category_count', 
    387                 SubCatsRecurse      => '_hdlr_sub_cats_recurse', 
    388                 SubCategoryPath     => '_hdlr_sub_category_path', 
    389                 BlogCategoryCount   => '_hdlr_blog_category_count', 
    390                 ArchiveCategory     => '_hdlr_archive_category', 
    391                 EntryCategory       => '_hdlr_entry_category', 
    392             }, 
    393         }, 
    394         'MT::Template::Tags::Page' => { 
    395             block => { 
    396                 'AuthorHasPage?' => '_hdlr_author_has_page', 
    397                 Pages            => '_hdlr_pages', 
    398                 PagePrevious     => '_hdlr_page_previous', 
    399                 PageNext         => '_hdlr_page_next', 
    400                 PagesHeader      => '_hdlr_pass_tokens', 
    401                 PagesFooter      => '_hdlr_pass_tokens', 
    402             }, 
    403             function => { 
    404                 PageID                => '_hdlr_page_id', 
    405                 PageTitle             => '_hdlr_page_title', 
    406                 PageBody              => '_hdlr_page_body',  
    407                 PageMore              => '_hdlr_page_more', 
    408                 PageDate              => '_hdlr_page_date', 
    409                 PageModifiedDate      => '_hdlr_page_modified_date', 
    410                 PageKeywords          => '_hdlr_page_keywords', 
    411                 PageBasename          => '_hdlr_page_basename', 
    412                 PagePermalink         => '_hdlr_page_permalink', 
    413                 PageAuthorDisplayName => '_hdlr_page_author_display_name', 
    414                 PageAuthorEmail       => '_hdlr_page_author_email', 
    415                 PageAuthorLink        => '_hdlr_page_author_link', 
    416                 PageAuthorURL         => '_hdlr_page_author_url', 
    417                 PageExcerpt           => '_hdlr_page_excerpt', 
    418                 BlogPageCount         => '_hdlr_blog_page_count', 
    419             }, 
    420         }, 
    421         'MT::Template::Tags::Folder' => { 
    422             block => { 
    423                 'IfFolder?'        => '_hdlr_if_folder', 
    424                 'FolderHeader?'    => '_hdlr_folder_header', 
    425                 'FolderFooter?'    => '_hdlr_folder_footer', 
    426                 'HasSubFolders?'   => '_hdlr_has_sub_folders', 
    427                 'HasParentFolder?' => '_hdlr_has_parent_folder', 
    428                 PageFolder         => '_hdlr_page_folder', 
    429                 Folders            => '_hdlr_folders', 
    430                 FolderPrevious     => '_hdlr_folder_prevnext', 
    431                 FolderNext         => '_hdlr_folder_prevnext', 
    432                 SubFolders         => '_hdlr_sub_folders', 
    433                 ParentFolders      => '_hdlr_parent_folders', 
    434                 ParentFolder       => '_hdlr_parent_folder', 
    435                 TopLevelFolders    => '_hdlr_top_level_folders', 
    436                 TopLevelFolder     => '_hdlr_top_level_folder', 
    437             }, 
    438             function => { 
    439                 FolderBasename    => '_hdlr_folder_basename', 
    440                 FolderCount       => '_hdlr_folder_count', 
    441                 FolderDescription => '_hdlr_folder_description', 
    442                 FolderID          => '_hdlr_folder_id', 
    443                 FolderLabel       => '_hdlr_folder_label', 
    444                 FolderPath        => '_hdlr_folder_path', 
    445                 SubFolderRecurse  => '_hdlr_sub_folder_recurse', 
    446             }, 
    447         }, 
    448         'MT::Template::Tags::Asset' => { 
    449             block => { 
    450                 EntryAssets       => '_hdlr_assets', 
    451                 PageAssets        => '_hdlr_assets', 
    452                 Assets            => '_hdlr_assets', 
    453                 Asset             => '_hdlr_asset', 
    454                 AssetIsFirstInRow => '_hdlr_pass_tokens', 
    455                 AssetIsLastInRow  => '_hdlr_pass_tokens', 
    456                 AssetsHeader      => '_hdlr_pass_tokens', 
    457                 AssetsFooter      => '_hdlr_pass_tokens', 
    458             }, 
    459             function => { 
    460                 AssetID            => '_hdlr_asset_id', 
    461                 AssetFileName      => '_hdlr_asset_file_name', 
    462                 AssetLabel         => '_hdlr_asset_label', 
    463                 AssetURL           => '_hdlr_asset_url', 
    464                 AssetType          => '_hdlr_asset_type', 
    465                 AssetMimeType      => '_hdlr_asset_mime_type', 
    466                 AssetFilePath      => '_hdlr_asset_file_path', 
    467                 AssetDateAdded     => '_hdlr_asset_date_added', 
    468                 AssetAddedBy       => '_hdlr_asset_added_by', 
    469                 AssetProperty      => '_hdlr_asset_property', 
    470                 AssetFileExt       => '_hdlr_asset_file_ext', 
    471                 AssetThumbnailURL  => '_hdlr_asset_thumbnail_url', 
    472                 AssetLink          => '_hdlr_asset_link', 
    473                 AssetThumbnailLink => '_hdlr_asset_thumbnail_link', 
    474                 AssetDescription   => '_hdlr_asset_description', 
    475                 AssetCount         => '_hdlr_asset_count', 
    476             }, 
    477         }, 
    478         'MT::Template::Tags::Userpic' => { 
    479             block => { 
    480                 AuthorUserpicAsset      => '_hdlr_author_userpic_asset', 
    481                 EntryAuthorUserpicAsset => '_hdlr_entry_author_userpic_asset', 
    482                 CommenterUserpicAsset   => '_hdlr_commenter_userpic_asset', 
    483             }, 
    484             function => { 
    485                 AuthorUserpic         => '_hdlr_author_userpic', 
    486                 AuthorUserpicURL      => '_hdlr_author_userpic_url', 
    487                 EntryAuthorUserpic    => '_hdlr_entry_author_userpic', 
    488                 EntryAuthorUserpicURL => '_hdlr_entry_author_userpic_url', 
    489                 CommenterUserpic      => '_hdlr_commenter_userpic', 
    490                 CommenterUserpicURL   => '_hdlr_commenter_userpic_url', 
    491             }, 
    492         }, 
    493         'MT::Template::Tags::Tag' => { 
    494             block => { 
    495                 Tags             => '_hdlr_tags', 
    496                 EntryTags        => '_hdlr_entry_tags', 
    497                 PageTags         => '_hdlr_page_tags', 
    498                 AssetTags        => '_hdlr_asset_tags', 
    499                 'EntryIfTagged?' => '_hdlr_entry_if_tagged', 
    500                 'PageIfTagged?'  => '_hdlr_page_if_tagged', 
    501                 'AssetIfTagged?' => '_hdlr_asset_if_tagged', 
    502             }, 
    503             function => { 
    504                 TagName       => '_hdlr_tag_name', 
    505                 TagLabel      => '_hdlr_tag_name', 
    506                 TagID         => '_hdlr_tag_id', 
    507                 TagCount      => '_hdlr_tag_count', 
    508                 TagRank       => '_hdlr_tag_rank', 
    509                 TagSearchLink => '_hdlr_tag_search_link', 
    510             }, 
    511         }, 
    512         'MT::Template::Tags::Calender' => { 
    513             block => { 
    514                 Calendar            => '_hdlr_calendar', 
    515                 CalendarWeekHeader  => '_hdlr_pass_tokens', 
    516                 CalendarWeekFooter  => '_hdlr_pass_tokens', 
    517                 CalendarIfBlank     => '_hdlr_pass_tokens', 
    518                 CalendarIfToday     => '_hdlr_pass_tokens', 
    519                 CalendarIfEntries   => '_hdlr_pass_tokens', 
    520                 CalendarIfNoEntries => '_hdlr_pass_tokens', 
    521  
    522             }, 
    523             function => { 
    524                 CalendarDay        => '_hdlr_calendar_day', 
    525                 CalendarCellNumber => '_hdlr_calendar_cell_num', 
    526                 CalendarDate       => '_hdlr_date', 
    527             }, 
    528         }, 
    529         'MT::Template::Tags::Score' => { 
    530             function => { 
    531                 # Rating related handlers 
    532                 EntryScore   => '_hdlr_entry_score', 
    533                 CommentScore => '_hdlr_comment_score', 
    534                 PingScore    => '_hdlr_ping_score', 
    535                 AssetScore   => '_hdlr_asset_score', 
    536                 AuthorScore  => '_hdlr_author_score', 
    537  
    538                 EntryScoreHigh   => '_hdlr_entry_score_high', 
    539                 CommentScoreHigh => '_hdlr_comment_score_high', 
    540                 PingScoreHigh    => '_hdlr_ping_score_high', 
    541                 AssetScoreHigh   => '_hdlr_asset_score_high', 
    542                 AuthorScoreHigh  => '_hdlr_author_score_high', 
    543  
    544                 EntryScoreLow   => '_hdlr_entry_score_low', 
    545                 CommentScoreLow => '_hdlr_comment_score_low', 
    546                 PingScoreLow    => '_hdlr_ping_score_low', 
    547                 AssetScoreLow   => '_hdlr_asset_score_low', 
    548                 AuthorScoreLow  => '_hdlr_author_score_low', 
    549  
    550                 EntryScoreAvg   => '_hdlr_entry_score_avg', 
    551                 CommentScoreAvg => '_hdlr_comment_score_avg', 
    552                 PingScoreAvg    => '_hdlr_ping_score_avg', 
    553                 AssetScoreAvg   => '_hdlr_asset_score_avg', 
    554                 AuthorScoreAvg  => '_hdlr_author_score_avg', 
    555  
    556                 EntryScoreCount   => '_hdlr_entry_score_count', 
    557                 CommentScoreCount => '_hdlr_comment_score_count', 
    558                 PingScoreCount    => '_hdlr_ping_score_count', 
    559                 AssetScoreCount   => '_hdlr_asset_score_count', 
    560                 AuthorScoreCount  => '_hdlr_author_score_count', 
    561  
    562                 EntryRank   => '_hdlr_entry_rank', 
    563                 CommentRank => '_hdlr_comment_rank', 
    564                 PingRank    => '_hdlr_ping_rank', 
    565                 AssetRank   => '_hdlr_asset_rank', 
    566                 AuthorRank  => '_hdlr_author_rank', 
    567             }, 
    568         }, 
    569         'MT::Template::Tags::Pager' => { 
    570             block => { 
    571                 'IfMoreResults?'     => '_hdlr_if_more_results', 
    572                 'IfPreviousResults?' => '_hdlr_if_previous_results', 
    573                 PagerBlock           => '_hdlr_pager_block', 
    574                 IfCurrentPage        => '_hdlr_pass_tokens', 
    575             }, 
    576             function => { 
    577                 PagerLink    => '_hdlr_pager_link', 
    578                 NextLink     => '_hdlr_next_link', 
    579                 PreviousLink => '_hdlr_previous_link', 
    580                 CurrentPage  => '_hdlr_current_page', 
    581                 TotalPages   => '_hdlr_total_pages', 
    582             }, 
    583         }, 
    584         # stubs for mt-search tags used in template includes 
    585         'MT::Template::Tags::Search' => { 
    586             block => { 
    587                 IfTagSearch         => sub { '' }, 
    588                 SearchResults       => sub { '' }, 
    589                 IfStraightSearch    => sub { '' }, 
    590                 NoSearchResults     => \&_hdlr_pass_tokens, 
    591                 NoSearch            => \&_hdlr_pass_tokens, 
    592                 SearchResultsHeader => sub { '' }, 
    593                 SearchResultsFooter => sub { '' }, 
    594                 BlogResultHeader    => sub { '' }, 
    595                 BlogResultFooter    => sub { '' }, 
    596                 IfMaxResultsCutoff  => sub { '' }, 
    597             }, 
    598             function => { 
    599                 SearchString       => sub { '' }, 
    600                 SearchResultCount  => sub { 0 },  
    601                 MaxResults         => sub { '' }, 
    602                 SearchMaxResults   => \&_hdlr_search_max_results, 
    603                 SearchIncludeBlogs => sub { '' }, 
    604                 SearchTemplateID   => sub { 0 }, 
    605             }, 
    606         }, 
    607         'MT::Template::Tags::Misc' => { 
    608             block => { 
    609                 'IfImageSupport?' => '_hdlr_if_image_support', 
    610             }, 
    611             function => { 
    612                 FeedbackScore => '_hdlr_feedback_score', 
    613                 ImageURL      => '_hdlr_image_url', 
    614                 ImageWidth    => '_hdlr_image_width', 
    615                 ImageHeight   => '_hdlr_image_height', 
    616                 WidgetManager => '_hdlr_widget_manager', 
    617                 WidgetSet     => '_hdlr_widget_manager', 
    618                 CaptchaFields => '_hdlr_captcha_fields', 
    619             }, 
    620         }, 
    621         'MT::Template::Tags::Filters' => { 
    622             modifier => { 
    623                 'numify'           => '_fltr_numify', 
    624                 'mteval'           => '_fltr_mteval', 
    625                 'filters'          => '_fltr_filters', 
    626                 'trim_to'          => '_fltr_trim_to', 
    627                 'trim'             => '_fltr_trim', 
    628                 'ltrim'            => '_fltr_ltrim', 
    629                 'rtrim'            => '_fltr_rtrim', 
    630                 'decode_html'      => '_fltr_decode_html', 
    631                 'decode_xml'       => '_fltr_decode_xml', 
    632                 'remove_html'      => '_fltr_remove_html', 
    633                 'dirify'           => '_fltr_dirify', 
    634                 'sanitize'         => '_fltr_sanitize', 
    635                 'encode_sha1'      => '_fltr_sha1', 
    636                 'encode_html'      => '_fltr_encode_html', 
    637                 'encode_xml'       => '_fltr_encode_xml', 
    638                 'encode_js'        => '_fltr_encode_js', 
    639                 'encode_php'       => '_fltr_encode_php', 
    640                 'encode_url'       => '_fltr_encode_url', 
    641                 'upper_case'       => '_fltr_upper_case', 
    642                 'lower_case'       => '_fltr_lower_case', 
    643                 'strip_linefeeds'  => '_fltr_strip_linefeeds', 
    644                 'space_pad'        => '_fltr_space_pad', 
    645                 'zero_pad'         => '_fltr_zero_pad', 
    646                 'sprintf'          => '_fltr_sprintf', 
    647                 'regex_replace'    => '_fltr_regex_replace', 
    648                 'capitalize'       => '_fltr_capitalize', 
    649                 'count_characters' => '_fltr_count_characters', 
    650                 'cat'              => '_fltr_cat', 
    651                 'count_paragraphs' => '_fltr_count_paragraphs', 
    652                 'count_words'      => '_fltr_count_words', 
    653                 'escape'           => '_fltr_escape', 
    654                 'indent'           => '_fltr_indent', 
    655                 'nl2br'            => '_fltr_nl2br', 
    656                 'replace'          => '_fltr_replace', 
    657                 'spacify'          => '_fltr_spacify', 
    658                 'string_format'    => '_fltr_sprintf', 
    659                 'strip'            => '_fltr_strip', 
    660                 'strip_tags'       => '_fltr_strip_tags', 
    661                 '_default'         => '_fltr_default', 
    662                 'nofollowfy'       => '_fltr_nofollowfy', 
    663                 'wrap_text'        => '_fltr_wrap_text', 
    664                 'setvar'           => '_fltr_setvar', 
    665             }, 
     564        modifier => { 
     565            'numify'           => '$Core::MT::Template::Tags::Filters::_fltr_numify', 
     566            'mteval'           => '$Core::MT::Template::Tags::Filters::_fltr_mteval', 
     567            'filters'          => '$Core::MT::Template::Tags::Filters::_fltr_filters', 
     568            'trim_to'          => '$Core::MT::Template::Tags::Filters::_fltr_trim_to', 
     569            'trim'             => '$Core::MT::Template::Tags::Filters::_fltr_trim', 
     570            'ltrim'            => '$Core::MT::Template::Tags::Filters::_fltr_ltrim', 
     571            'rtrim'            => '$Core::MT::Template::Tags::Filters::_fltr_rtrim', 
     572            'decode_html'      => '$Core::MT::Template::Tags::Filters::_fltr_decode_html', 
     573            'decode_xml'       => '$Core::MT::Template::Tags::Filters::_fltr_decode_xml', 
     574            'remove_html'      => '$Core::MT::Template::Tags::Filters::_fltr_remove_html', 
     575            'dirify'           => '$Core::MT::Template::Tags::Filters::_fltr_dirify', 
     576            'sanitize'         => '$Core::MT::Template::Tags::Filters::_fltr_sanitize', 
     577            'encode_sha1'      => '$Core::MT::Template::Tags::Filters::_fltr_sha1', 
     578            'encode_html'      => '$Core::MT::Template::Tags::Filters::_fltr_encode_html', 
     579            'encode_xml'       => '$Core::MT::Template::Tags::Filters::_fltr_encode_xml', 
     580            'encode_js'        => '$Core::MT::Template::Tags::Filters::_fltr_encode_js', 
     581            'encode_php'       => '$Core::MT::Template::Tags::Filters::_fltr_encode_php', 
     582            'encode_url'       => '$Core::MT::Template::Tags::Filters::_fltr_encode_url', 
     583            'upper_case'       => '$Core::MT::Template::Tags::Filters::_fltr_upper_case', 
     584            'lower_case'       => '$Core::MT::Template::Tags::Filters::_fltr_lower_case', 
     585            'strip_linefeeds'  => '$Core::MT::Template::Tags::Filters::_fltr_strip_linefeeds', 
     586            'space_pad'        => '$Core::MT::Template::Tags::Filters::_fltr_space_pad', 
     587            'zero_pad'         => '$Core::MT::Template::Tags::Filters::_fltr_zero_pad', 
     588            'sprintf'          => '$Core::MT::Template::Tags::Filters::_fltr_sprintf', 
     589            'regex_replace'    => '$Core::MT::Template::Tags::Filters::_fltr_regex_replace', 
     590            'capitalize'       => '$Core::MT::Template::Tags::Filters::_fltr_capitalize', 
     591            'count_characters' => '$Core::MT::Template::Tags::Filters::_fltr_count_characters', 
     592            'cat'              => '$Core::MT::Template::Tags::Filters::_fltr_cat', 
     593            'count_paragraphs' => '$Core::MT::Template::Tags::Filters::_fltr_count_paragraphs', 
     594            'count_words'      => '$Core::MT::Template::Tags::Filters::_fltr_count_words', 
     595            'escape'           => '$Core::MT::Template::Tags::Filters::_fltr_escape', 
     596            'indent'           => '$Core::MT::Template::Tags::Filters::_fltr_indent', 
     597            'nl2br'            => '$Core::MT::Template::Tags::Filters::_fltr_nl2br', 
     598            'replace'          => '$Core::MT::Template::Tags::Filters::_fltr_replace', 
     599            'spacify'          => '$Core::MT::Template::Tags::Filters::_fltr_spacify', 
     600            'string_format'    => '$Core::MT::Template::Tags::Filters::_fltr_sprintf', 
     601            'strip'            => '$Core::MT::Template::Tags::Filters::_fltr_strip', 
     602            'strip_tags'       => '$Core::MT::Template::Tags::Filters::_fltr_strip_tags', 
     603            '_default'         => '$Core::MT::Template::Tags::Filters::_fltr_default', 
     604            'nofollowfy'       => '$Core::MT::Template::Tags::Filters::_fltr_nofollowfy', 
     605            'wrap_text'        => '$Core::MT::Template::Tags::Filters::_fltr_wrap_text', 
     606            'setvar'           => '$Core::MT::Template::Tags::Filters::_fltr_setvar', 
    666607        }, 
    667608    }; 
    668  
    669     for my $module ( keys %$tag_sets ) { 
    670         my $module_tags = $tag_sets->{$module}; 
    671         for my $kind ( qw{ block function } ) { 
    672             my $tag_set = $module_tags->{$kind}; 
    673             for my $tag_name ( keys %$tag_set ) { 
    674                 $tags->{$kind}{$tag_name} = { 
    675                     require => $module, 
    676                     handler => $tag_set->{$tag_name}, 
    677                 }; 
    678             } 
    679         } 
    680         my $filters = $module_tags->{modifier}; 
    681         for my $flt_name ( keys %$filters ) { 
    682             $tags->{modifier}{$flt_name} = { 
    683                 handler => '$Core::'.$module.'::'.$filters->{$flt_name} 
    684             }; 
    685         } 
    686     } 
    687609    return $tags; 
    688610} 
     
    690612## used in both Comment.pm and Ping.pm 
    691613sub sanitize_on { 
    692     my ($ctx) = @_; 
    693     unless ( exists $ctx->{'sanitize'} ) { 
     614    my ($ctx, $args) = @_; 
     615    ## backward compatibility. in MT4, this didn't take $ctx. 
     616    if (!UNIVERSAL::isa( $ctx, 'MT::Template::Context' ) ) { 
     617        $args = $ctx; 
     618    } 
     619    unless ( exists $args->{'sanitize'} ) { 
    694620        # Important to come before other manipulation attributes 
    695621        # like encode_xml 
    696         unshift @{$ctx->{'@'} ||= []}, ['sanitize' => 1]; 
    697         $ctx->{'sanitize'} = 1; 
     622        unshift @{$args->{'@'} ||= []}, ['sanitize' => 1]; 
     623        $args->{'sanitize'} = 1; 
    698624    } 
    699625} 
     
    709635## used in both Category.pm and Entry.pm. 
    710636sub cat_path_to_category { 
     637    ## for backward compatibility. 
     638    shift if UNIVERSAL::isa($_[0], 'MT::Template::Context'); 
    711639    my ($path, $blog_id, $class_type) = @_; 
    712640 
     
    848776*_hdlr_date = *build_date; 
    849777 
    850 # FIXME: Unused? 
    851 sub _hdlr_if_commenter_pending { 
    852     my ($ctx, $args, $cond) = @_; 
    853     my $cmtr = $ctx->stash('commenter'); 
    854     my $blog = $ctx->stash('blog'); 
    855     if ($cmtr && $blog && $cmtr->commenter_status($blog->id) == MT::Author::PENDING()) { 
    856         return 1; 
    857     } else { 
    858         return 0; 
    859     } 
     778sub cgi_path { 
     779    my ($ctx) = @_; 
     780    my $path = $ctx->{config}->CGIPath; 
     781    if ($path =~ m!^/!) { 
     782        # relative path, prepend blog domain 
     783        if (my $blog = $ctx->stash('blog')) { 
     784            my ($blog_domain) = $blog->archive_url =~ m|(.+://[^/]+)|; 
     785            $path = $blog_domain . $path; 
     786        } 
     787    } 
     788    $path .= '/' unless $path =~ m{/$}; 
     789    return $path; 
    860790} 
    861791 
     792sub check_page { 
     793    my ($ctx) = @_; 
     794    my $e = $ctx->stash('entry') 
     795        or return $ctx->_no_page_error(); 
     796    return $ctx->_no_page_error() 
     797        if ref $e ne 'MT::Page'; 
     798    1; 
     799} 
     800*_check_page = *check_page; 
     801 
    8628021; 
    863803 
  • branches/feature-contexthandlers-splitting/lib/MT/Template/Tags/App.pm

    r3610 r3616  
    1 package MT::Template::Context; 
     1package MT::Template::Tags::App; 
    22 
    33use strict; 
     
    506506    unless ((ref($loop_obj) eq 'ARRAY') && (@$loop_obj)) { 
    507507        my @else = @{ $ctx->stash('tokens_else') || [] }; 
    508         return &_hdlr_pass_tokens_else if @else; 
     508        return MT::Template::Context::_hdlr_pass_tokens_else if @else; 
    509509        my $msg = $args->{empty_message} || MT->translate("No [_1] could be found.", $class ? lowercase($class->class_label_plural) : ($type ? $type : MT->translate("records"))); 
    510510        return $ctx->build(qq{<mtapp:statusmsg 
     
    541541    { 
    542542        local $args->{name} = $loop; 
    543         defined($insides = _hdlr_loop($ctx, $args, $cond)) 
     543        defined($insides = $ctx->invoke_handler('loop', $args, $cond)) 
    544544            or return; 
    545545    } 
  • branches/feature-contexthandlers-splitting/lib/MT/Template/Tags/Archive.pm

    r3607 r3616  
    1 package MT::Template::Context; 
     1package MT::Template::Tags::Archive; 
    22 
    33use strict; 
     
    178178    ## If we are producing a Category archive list, don't bother to 
    179179    ## handle it here--instead hand it over to <MTCategories>. 
    180     return _hdlr_categories(@_) if $at eq 'Category'; 
     180    return $ctx->invoke_handler( 'categories', $args, $cond ) if $at eq 'Category'; 
    181181    my %args; 
    182182    my $sort_order = lc ($args->{sort_order} || '') eq 'ascend' ? 'ascend' : 'descend'; 
     
    376376        $entry = $is_prev ? $arctype->previous_archive_entry($param) : $arctype->next_archive_entry($param); 
    377377    } elsif ($arctype->category_based) { 
    378         return _hdlr_category_prevnext(@_); 
     378        return $is_prev ? $ctx->invoke_handler( 'categoryprevious', $args, $cond ) 
     379                        : $ctx->invoke_handler( 'categorynext',     $args, $cond ); 
    379380    } elsif ($arctype->author_based) { 
    380381        if ($is_prev) { 
     
    383384            $ctx->stash('tag', 'AuthorNext'); 
    384385        } 
    385         return _hdlr_author_next_prev(@_); 
     386        require MT::Template::Tags::Author; 
     387        return MT::Template::Tags::Author::_hdlr_author_next_prev(@_); 
    386388    } elsif ($arctype->entry_based) { 
    387389        my $e = $ctx->stash('entry'); 
     
    583585 
    584586    my $at = $args->{type} || $args->{archive_type}; 
    585     return _hdlr_category_archive(@_) 
     587    return $ctx->invoke_handler('categoryarchive', $args) 
    586588        if ($at && ('Category' eq $at)) || 
    587589           ($ctx->{current_archive_type} && 'Category' eq $ctx->{current_archive_type}); 
     
    671673 
    672674    my $at = $ctx->{current_archive_type} || $ctx->{archive_type}; 
    673     return _hdlr_category_label(@_) if $at eq 'Category'; 
     675    return $ctx->invoke_handler('categorylabel', $args) if $at eq 'Category'; 
    674676 
    675677    my $archiver = MT->publisher->archiver($at); 
     
    812814    my $archiver = MT->publisher->archiver($at); 
    813815    if ($ctx->{inside_mt_categories} && !$archiver->date_based) { 
    814         return _hdlr_category_count($ctx); 
     816        return $ctx->invoke_handler('categorycount', $args, $cond); 
    815817    } elsif (my $count = $ctx->stash('archive_count')) { 
    816818        return $ctx->count_format($count, $args); 
     
    888890            '<$MTArchiveDateEnd$>' )); 
    889891    $args->{ts} = $end; 
    890     return _hdlr_date(@_); 
     892    return $ctx->build_date($args); 
    891893} 
    892894 
  • branches/feature-contexthandlers-splitting/lib/MT/Template/Tags/Asset.pm

    r3604 r3616  
    1 package MT::Template::Context; 
     1package MT::Template::Tags::Asset; 
    22 
    33use strict; 
     
    824824        or return $ctx->_no_asset_error(); 
    825825    $args->{ts} = $a->created_on; 
    826     return _hdlr_date($ctx, $args); 
     826    return $ctx->build_date($args); 
    827827} 
    828828 
  • branches/feature-contexthandlers-splitting/lib/MT/Template/Tags/Author.pm

    r3613 r3616  
    1 package MT::Template::Context; 
     1package MT::Template::Tags::Author; 
    22 
    33use strict; 
  • branches/feature-contexthandlers-splitting/lib/MT/Template/Tags/Blog.pm

    r3606 r3616  
    1 package MT::Template::Context; 
     1package MT::Template::Tags::Blog; 
    22 
    33use strict; 
     
    454454 
    455455sub _hdlr_cc_license_rdf { 
    456     my ($ctx, $arg) = @_; 
     456    my $ctx = shift; 
     457    my ($arg) = @_; 
    457458    my $blog = $ctx->stash('blog'); 
    458459    return '' unless $blog; 
     
    478479<Work rdf:about="$link"> 
    479480<dc:title>@{[ encode_xml($strip_hyphen->($entry->title)) ]}</dc:title> 
    480 <dc:description>@{[ encode_xml($strip_hyphen->(_hdlr_entry_excerpt(@_))) ]}</dc:description> 
     481<dc:description>@{[ encode_xml($strip_hyphen->($ctx->invoke_handler('entryexcerpt', @_))) ]}</dc:description> 
    481482<dc:creator>@{[ encode_xml($strip_hyphen->($author_name)) ]}</dc:creator> 
    482 <dc:date>@{[ _hdlr_entry_date($ctx, { 'format' => "%Y-%m-%dT%H:%M:%S" }) . 
    483              _hdlr_blog_timezone($ctx) ]}</dc:date> 
     483<dc:date>@{[ $ctx->invoke_handler( 'entrydate', { 'format' => "%Y-%m-%dT%H:%M:%S" }) . 
     484             $ctx->invoke_handler('blogtimezone', @_) ]}</dc:date> 
    484485<license rdf:resource="$cc_url" /> 
    485486</Work> 
  • branches/feature-contexthandlers-splitting/lib/MT/Template/Tags/Calendar.pm

    r3604 r3616  
    1 package MT::Template::Context; 
     1package MT::Template::Tags::Calendar; 
    22 
    33use strict; 
  • branches/feature-contexthandlers-splitting/lib/MT/Template/Tags/Category.pm

    r3614 r3616  
    1 package MT::Template::Context; 
     1package MT::Template::Tags::Category; 
    22 
    33use strict; 
     
    410410        local $ctx->{__stash}{entries} = $cats->[$pos]->{_entries} if $needs_entries; 
    411411        local $ctx->{__stash}{category_count} = $cats->[$pos]->{_placement_count}; 
    412         return _hdlr_pass_tokens($ctx, $args, $cond); 
     412        return $ctx->slurp($args, $cond); 
    413413    } 
    414414    return ''; 
     
    499499        if ($args->{category}) { 
    500500            # user specified category; list from this category down 
    501             ($current_cat) = cat_path_to_category($args->{category}, $ctx->stash('blog_id'), $class_type); 
     501            ($current_cat) = $ctx->cat_path_to_category($args->{category}, $ctx->stash('blog_id'), $class_type); 
    502502        } else { 
    503503            $current_cat = $ctx->stash('category') || $ctx->stash('archive_category'); 
     
    781781    local $args->{include_subcategories} = 1; 
    782782    local $args->{category} ||= ['OR', [$cat]] if defined $cat; 
    783     my $res = _hdlr_entries($ctx, $args, $cond); 
     783    my $res = $ctx->invoke_handler('entries', $args, $cond); 
    784784    $ctx->{__stash}{entries} = $saved_stash_entries  
    785785        if $save_entries && $saved_stash_entries; 
  • branches/feature-contexthandlers-splitting/lib/MT/Template/Tags/Comment.pm

    r3613 r3616  
    1 package MT::Template::Context; 
     1package MT::Template::Tags::Comment; 
    22 
    33use strict; 
     
    2424            } 
    2525            if (!defined $cmntr || ($cmntr && !$cmntr->is_trusted($blog->id))) { 
    26                 nofollowfy_on($arg); 
     26                $ctx->nofollowfy_on($arg); 
    2727            } 
    2828        } else { 
    29             nofollowfy_on($arg); 
     29            $ctx->nofollowfy_on($arg); 
    3030        } 
    3131    } 
     
    427427    } 
    428428    if (!@comments) { 
    429         return _hdlr_pass_tokens_else(@_); 
     429        return MT::Template::Context::_hdlr_pass_tokens_else(@_); 
    430430    } 
    431431    return $html; 
     
    615615    } 
    616616    if (!@comments) { 
    617         return _hdlr_pass_tokens_else(@_); 
     617        return MT::Template::Context::_hdlr_pass_tokens_else(@_); 
    618618    } 
    619619    $html; 
     
    10591059sub _hdlr_comment_author { 
    10601060    my ($ctx, $args) = @_; 
    1061     sanitize_on($args); 
     1061    $ctx->sanitize_on($args); 
    10621062    my $c = $ctx->stash('comment') 
    10631063        or return $ctx->_no_comment_error(); 
     
    11441144    } elsif ($show_url && $c->url) { 
    11451145        my $cfg = $ctx->{config}; 
    1146         my $cgi_path = _hdlr_cgi_path($ctx); 
     1146        my $cgi_path = $ctx->cgi_path; 
    11471147        my $comment_script = $cfg->CommentScript; 
    11481148        $name = remove_html($name); 
     
    11921192    } 
    11931193    my $link = $cmntr->url; 
    1194     my $static_path = _hdlr_static_path($ctx); 
     1194    my $static_path = $ctx->invoke_handler('StaticWebPath', $args); 
    11951195    my $logo = $cmntr->auth_icon_url; 
    11961196    unless ($logo) { 
     
    12351235sub _hdlr_comment_email { 
    12361236    my ($ctx, $args) = @_; 
    1237     sanitize_on($args); 
     1237    $ctx->sanitize_on($args); 
    12381238    my $c = $ctx->stash('comment') 
    12391239        or return $ctx->_no_comment_error(); 
     
    12801280sub _hdlr_comment_url { 
    12811281    my ($ctx, $args) = @_; 
    1282     sanitize_on($args); 
     1282    $ctx->sanitize_on($args); 
    12831283    my $c = $ctx->stash('comment') 
    12841284        or return $ctx->_no_comment_error(); 
     
    13231323sub _hdlr_comment_body { 
    13241324    my($ctx, $args) = @_; 
    1325     sanitize_on($args); 
     1325    $ctx->sanitize_on($args); 
    13261326    _comment_follow($ctx, $args); 
    13271327 
     
    13801380        or return $ctx->_no_comment_error(); 
    13811381    $args->{ts} = $c->created_on; 
    1382     return _hdlr_date($ctx, $args); 
     1382    return $ctx->build_date($args); 
    13831383} 
    13841384 
     
    16411641    } 
    16421642    if (!@comments) { 
    1643         return _hdlr_pass_tokens_else(@_); 
     1643        return MT::Template::Context::_hdlr_pass_tokens_else(@_); 
    16441644    } 
    16451645    $html; 
     
    17831783    my $needs_email = $blog->require_typekey_emails ? "&amp;need_email=1" : ""; 
    17841784    my $signon_url = $cfg->SignOnURL; 
    1785     my $path = _hdlr_cgi_path($ctx); 
     1785    my $path = $ctx->cgi_path; 
    17861786    my $comment_script = $cfg->CommentScript; 
    17871787    my $static_arg = $args->{static} ? "static=" . encode_url( encode_url( $args->{static} ) ) : "static=0"; 
     
    18071807    my ($ctx, $args) = @_; 
    18081808    my $cfg = $ctx->{config}; 
    1809     my $path = _hdlr_cgi_path($ctx); 
     1809    my $path = $ctx->cgi_path; 
    18101810    my $comment_script = $cfg->CommentScript; 
    18111811    my $static_arg; 
     
    18401840    my $cfg = $ctx->{config}; 
    18411841    my $blog = $ctx->stash('blog'); 
    1842     my $path = _hdlr_cgi_path($ctx); 
     1842    my $path = $ctx->cgi_path; 
    18431843    $path .= '/' unless $path =~ m!/$!; 
    18441844    my $comment_script = $cfg->CommentScript; 
     
    18621862    my ($ctx, $args) = @_; 
    18631863    my $cfg = $ctx->{config}; 
    1864     my $path = _hdlr_cgi_path($ctx); 
     1864    my $path = $ctx->cgi_path; 
    18651865    $path .= '/' unless $path =~ m!/$!; 
    18661866    my $comment_script = $cfg->CommentScript; 
  • branches/feature-contexthandlers-splitting/lib/MT/Template/Tags/Commenter.pm

    r3609 r3616  
    1 package MT::Template::Context; 
     1package MT::Template::Tags::Commenter; 
    22 
    33use strict; 
    44 
    55use MT; 
    6 use MT::Template::Tags::Author; 
    76 
    87########################################################################### 
     
    127126    return $ctx->error(MT->translate('Can\'t load blog #[_1].', $ctx->stash('blog_id'))) unless $blog; 
    128127    my ($blog_domain) = $blog->archive_url =~ m|://([^/]*)|; 
    129     my $cgi_path = _hdlr_cgi_path($ctx); 
     128    my $cgi_path = $ctx->cgi_path; 
    130129    my ($mt_domain) = $cgi_path =~ m|://([^/]*)|; 
    131130    $mt_domain ||= ''; 
     
    184183    my $a = $ctx->stash('commenter'); 
    185184    my $name = $a ? $a->nickname || '' : ''; 
    186     $name = _hdlr_comment_author($ctx) unless $name; 
     185    $name = $ctx->invoke_handler('commentauthor') unless $name; 
    187186    return $name; 
    188187} 
     
    447446} 
    448447 
     448# FIXME: Unused? 
     449sub _hdlr_if_commenter_pending { 
     450    my ($ctx, $args, $cond) = @_; 
     451    my $cmtr = $ctx->stash('commenter'); 
     452    my $blog = $ctx->stash('blog'); 
     453    if ($cmtr && $blog && $cmtr->commenter_status($blog->id) == MT::Author::PENDING()) { 
     454        return 1; 
     455    } else { 
     456        return 0; 
     457    } 
     458} 
     459 
    4494601; 
  • branches/feature-contexthandlers-splitting/lib/MT/Template/Tags/Core.pm

    r3615 r3616  
    1 package MT::Template::Context; 
     1package MT::Template::Tags::Core; 
    22use strict; 
    33 
     
    280280            } elsif (UNIVERSAL::isa($value, 'MT::Template::Tokens')) { 
    281281                local $ctx->{__stash}{tokens} = $value; 
    282                 $value = _hdlr_pass_tokens(@_) or return; 
     282                $value = $ctx->slurp($args, $cond) or return; 
    283283            } elsif (ref($value) eq 'ARRAY') { 
    284284                $value = $value->[$index] if defined $index; 
     
    996996    my($ctx, $args) = @_; 
    997997    my $tag = lc $ctx->stash('tag'); 
    998     my $val =_hdlr_pass_tokens(@_); 
     998    my $val = $ctx->slurp($args); 
    999999    $val =~ s/(^\s+|\s+$)//g; 
    10001000    my @pairs = split /\r?\n/, $val; 
     
    10511051    { 
    10521052        local $ctx->{__inside_set_hashvar} = $hash; 
    1053         _hdlr_pass_tokens(@_); 
     1053        $ctx->slurp($args); 
    10541054    } 
    10551055    if ( my $parent_hash = $ctx->{__inside_set_hashvar} ) { 
     
    11471147        $val = defined $args->{value} ? $args->{value} : ''; 
    11481148    } elsif ($tag eq 'setvarblock') { 
    1149         $val = _hdlr_pass_tokens(@_); 
     1149        $val = $ctx->slurp($args); 
    11501150        return unless defined($val); 
    11511151    } elsif ($tag eq 'setvartemplate') { 
     
    14651465                local $args->{var} = undef; 
    14661466                $ctx->var($_, $args->{$_}) for keys %{$args || {}}; 
    1467                 $value = _hdlr_pass_tokens(@_) or return; 
     1467                $value = $ctx->slurp($args) or return; 
    14681468            } elsif (ref($value) eq 'ARRAY') { 
    14691469                if ( defined $index ) { 
  • branches/feature-contexthandlers-splitting/lib/MT/Template/Tags/Entry.pm

    r3609 r3616  
    1 package MT::Template::Context; 
     1package MT::Template::Tags::Entry; 
    22 
    33use strict; 
     
    77use MT::Entry; 
    88use MT::I18N qw( first_n_text const ); 
     9 
     10# returns an iterator that supplies entries, in the order of last comment 
     11# date (descending) 
     12sub _rco_entries_iter { 
     13    my ($entry_terms, $entry_args, $blog_terms, $blog_args) = @_; 
     14 
     15    my $offset = 0; 
     16    my $limit = $entry_args->{limit} || 20; 
     17    my @entries; 
     18    delete $entry_args->{direction} 
     19        if exists $entry_args->{direction}; 
     20    delete $entry_args->{sort} 
     21        if exists $entry_args->{sort}; 
     22 
     23    my $rco_iter = sub { 
     24        if (! @entries) { 
     25            require MT::Comment; 
     26            my $iter = MT::Comment->max_group_by({ 
     27                visible => 1, 
     28                %$blog_terms, 
     29            }, { 
     30                join => MT::Entry->join_on(undef, 
     31                    { 
     32                        'id' => \'=comment_entry_id', 
     33                        %$entry_terms, 
     34                    }, { %$entry_args }), 
     35                %$blog_args, 
     36                group => ['entry_id'], 
     37                max => 'created_on', 
     38                offset => $offset, 
     39                limit => $limit, 
     40            }); 
     41            my @ids; 
     42            my %order; 
     43            my $num = 0; 
     44            while (my ($max, $id) = $iter->()) { 
     45                push @ids, $id; 
     46                $order{$id} = $num++; 
     47            } 
     48            if ( @ids ) { 
     49                @entries = MT::Entry->load({ id => \@ids }); 
     50                @entries = sort { $order{$a->id} <=> $order{$b->id} } @entries; 
     51            } 
     52        } 
     53        if ( @entries ) { 
     54            $offset++; 
     55            return shift @entries; 
     56        } else { 
     57            return undef; 
     58        } 
     59    }; 
     60    return Data::ObjectDriver::Iterator->new($rco_iter); 
     61} 
    962 
    1063########################################################################### 
     
    369422                 ($cat_class_type ne 'category' && !$args->{include_subfolders}))) 
    370423            { 
    371                 my @cats = cat_path_to_category($category_arg, [ \%blog_terms, \%blog_args ], $cat_class_type); 
     424                my @cats = $ctx->cat_path_to_category($category_arg, [ \%blog_terms, \%blog_args ], $cat_class_type); 
    372425                if (@cats) { 
    373426                    $cats = \@cats; 
     
    379432                @args_cat = grep { $_ } @args_cat; 
    380433                for my $c (@args_cat) { 
    381                     my @categories = cat_path_to_category($c, [ \%blog_terms, \%blog_args ], $cat_class_type); 
     434                    my @categories = $ctx->cat_path_to_category($c, [ \%blog_terms, \%blog_args ], $cat_class_type); 
    382435                    push @cats, @categories; 
    383436                } 
     
    939992    } 
    940993    if (!@entries) { 
    941         return _hdlr_pass_tokens_else(@_); 
     994        return MT::Template::Context::_hdlr_pass_tokens_else(@_); 
    942995    } 
    943996 
     
    18931946        if ($a->type == MT::Author::AUTHOR()) { 
    18941947            local $ctx->{__stash}{author} = $a; 
    1895             if (my $link = _hdlr_archive_link($ctx, { type => 'Author' }, $cond)) { 
     1948            if (my $link = $ctx->invoke_handler('archivelink', { type => 'Author' }, $cond)) { 
    18961949                return sprintf qq{<a href="%s"%s>%s</a>}, $link, $target, $displayname; 
    18971950            } 
     
    19632016        or return $ctx->_no_entry_error(); 
    19642017    $args->{ts} = $e->authored_on; 
    1965     return _hdlr_date($ctx, $args); 
     2018    return $ctx->build_date($args); 
    19662019} 
    19672020 
     
    19822035        or return $ctx->_no_entry_error(); 
    19832036    $args->{ts} = $e->created_on; 
    1984     return _hdlr_date($ctx, $args); 
     2037    return $ctx->build_date($args); 
    19852038} 
    19862039 
     
    20012054        or return $ctx->_no_entry_error(); 
    20022055    $args->{ts} = $e->modified_on || $e->created_on; 
    2003     return _hdlr_date($ctx, $args); 
     2056    return $ctx->build_date($args); 
    20042057} 
    20052058 
  • branches/feature-contexthandlers-splitting/lib/MT/Template/Tags/Folder.pm

    r3602 r3616  
    1 package MT::Template::Context; 
     1package MT::Template::Tags::Folder; 
    22 
    33use strict; 
     
    3636 
    3737sub _hdlr_if_folder { 
    38     my ($ctx) = @_; 
     38    my ($ctx, $args, $cond) = @_; 
    3939    my $e = $ctx->stash('entry'); 
    4040    return undef if ($e && !defined $e->category); 
    4141    return undef unless &_check_folder(@_); 
    42     return _hdlr_if_category(@_); 
     42    return $ctx->invoke_handler('ifcategory', $args, $cond); 
    4343} 
    4444 
     
    130130    my($ctx, $args, $cond) = @_; 
    131131 
    132     return undef unless &_check_page(@_); 
     132    return undef unless $ctx->check_page; 
    133133    require MT::Page; 
    134134    $args->{class_type} = MT::Page->properties->{class_type}; 
    135135    local $ctx->{inside_mt_categories} = 1; 
    136     &_hdlr_entry_categories(@_);  
     136    $ctx->invoke_handler('entrycategories', $args, $cond); 
    137137} 
    138138 
     
    164164    require MT::Folder; 
    165165    $args->{class_type} = MT::Folder->properties->{class_type}; 
    166     _hdlr_categories($ctx, $args, $cond); 
     166    $ctx->invoke_handler('categories', $args, $cond); 
    167167} 
    168168 
     
    194194    require MT::Folder; 
    195195    $args->{class_type} = MT::Folder->properties->{class_type}; 
    196     _hdlr_category_prevnext($ctx, $args, $cond); 
     196    require MT::Template::Tags::Category; 
     197    MT::Template::Tags::Category::_hdlr_category_prevnext($ctx, $args, $cond); 
     198     
    197199} 
    198200 
     
    240242    require MT::Folder; 
    241243    $args->{class_type} = MT::Folder->properties->{class_type}; 
    242     _hdlr_sub_categories($ctx, $args, $cond); 
     244    $ctx->invoke_handler('subcategories', $args, $cond); 
    243245} 
    244246 
     
    274276    require MT::Folder; 
    275277    $args->{class_type} = MT::Folder->properties->{class_type}; 
    276     _hdlr_parent_categories($ctx, $args, $cond); 
     278    $ctx->invoke_handler('parentcategories', $args, $cond); 
    277279} 
    278280 
     
    298300    require MT::Folder; 
    299301    $args->{class_type} = MT::Folder->properties->{class_type}; 
    300     _hdlr_parent_category($ctx, $args, $cond); 
     302    $ctx->invoke_handler('parentcategory', $args, $cond); 
    301303} 
    302304 
     
    321323    require MT::Folder; 
    322324    $args->{class_type} = MT::Folder->properties->{class_type}; 
    323     _hdlr_top_level_categories($ctx, $args, $cond); 
     325    $ctx->invoke_handler('toplevelcategories', $args, $cond); 
    324326} 
    325327 
     
    340342    require MT::Folder; 
    341343    $args->{class_type} = MT::Folder->properties->{class_type}; 
    342     return _hdlr_top_level_parent($ctx, $args, $cond); 
     344    $ctx->invoke_handler('toplevelcategory', $args, $cond); 
    343345} 
    344346 
     
    375377sub _hdlr_folder_basename { 
    376378    return undef unless &_check_folder(@_); 
    377     return _hdlr_category_basename(@_); 
     379    shift->invoke_handler('categorybasename', @_); 
    378380} 
    379381 
     
    394396sub _hdlr_folder_description { 
    395397    return undef unless &_check_folder(@_); 
    396     return _hdlr_category_desc(@_); 
     398    shift->invoke_handler('categorydescription', @_); 
    397399} 
    398400 
     
    413415sub _hdlr_folder_id { 
    414416    return undef unless &_check_folder(@_); 
    415     return _hdlr_category_id(@_); 
     417    shift->invoke_handler('categoryid', @_); 
    416418} 
    417419 
     
    432434sub _hdlr_folder_label { 
    433435    return undef unless &_check_folder(@_); 
    434     return _hdlr_category_label(@_); 
     436    shift->invoke_handler('categorylabel', @_); 
    435437} 
    436438 
     
    451453sub _hdlr_folder_count { 
    452454    return undef unless &_check_folder(@_); 
    453     return _hdlr_category_count(@_); 
     455    shift->invoke_handler('categorycount', @_); 
    454456} 
    455457 
     
    482484sub _hdlr_folder_path { 
    483485    return undef unless &_check_folder(@_); 
    484     return _hdlr_sub_category_path(@_); 
     486    shift->invoke_handler('subcategorypath', @_); 
    485487} 
    486488 
     
    539541    require MT::Folder; 
    540542    $args->{class_type} = MT::Folder->properties->{class_type}; 
    541     _hdlr_sub_cats_recurse($ctx, $args, $cond); 
     543    $ctx->invoke_handler('subcatsrecurse', $args, $cond); 
    542544} 
    543545 
  • branches/feature-contexthandlers-splitting/lib/MT/Template/Tags/Misc.pm

    r3612 r3616  
    1 package MT::Template::Context; 
     1package MT::Template::Tags::Misc; 
    22 
    33use strict; 
  • branches/feature-contexthandlers-splitting/lib/MT/Template/Tags/Page.pm

    r3604 r3616  
    1 package MT::Template::Context; 
     1package MT::Template::Tags::Page; 
    22 
    33use strict; 
    44 
    55use MT; 
    6 use MT::Template::Tags::Entry; 
     6 
    77 
    88########################################################################### 
     
    9898    require MT::Page; 
    9999    $args->{class_type} = MT::Page->properties->{class_type}; 
    100     _hdlr_entries($ctx, $args, $cond); 
     100    $ctx->invoke_handler('entries', $args, $cond); 
    101101} 
    102102 
     
    114114    my($ctx, $args, $cond) = @_; 
    115115 
    116     return undef unless &_check_page(@_); 
     116    return undef unless $ctx->check_page; 
    117117    require MT::Page; 
    118118    $args->{class_type} = MT::Page->properties->{class_type}; 
    119     &_hdlr_entry_previous(@_);  
     119    $ctx->invoke_handler('entryprevious', $args, $cond); 
    120120} 
    121121 
     
    135135    require MT::Page; 
    136136    $args->{class_type} = MT::Page->properties->{class_type}; 
    137     return undef unless &_check_page(@_); 
    138     &_hdlr_entry_next(@_);  
     137    return undef unless $ctx->check_page; 
     138    $ctx->invoke_handler('entrynext', $args, $cond); 
    139139} 
    140140 
     
    170170=cut 
    171171 
    172 # returns an iterator that supplies entries, in the order of last comment 
    173 # date (descending) 
    174 sub _rco_entries_iter { 
    175     my ($entry_terms, $entry_args, $blog_terms, $blog_args) = @_; 
    176  
    177     my $offset = 0; 
    178     my $limit = $entry_args->{limit} || 20; 
    179     my @entries; 
    180     delete $entry_args->{direction} 
    181         if exists $entry_args->{direction}; 
    182     delete $entry_args->{sort} 
    183         if exists $entry_args->{sort}; 
    184  
    185     my $rco_iter = sub { 
    186         if (! @entries) { 
    187             require MT::Comment; 
    188             my $iter = MT::Comment->max_group_by({ 
    189                 visible => 1, 
    190                 %$blog_terms, 
    191             }, { 
    192                 join => MT::Entry->join_on(undef, 
    193                     { 
    194                         'id' => \'=comment_entry_id', 
    195                         %$entry_terms, 
    196                     }, { %$entry_args }), 
    197                 %$blog_args, 
    198                 group => ['entry_id'], 
    199                 max => 'created_on', 
    200                 offset => $offset, 
    201                 limit => $limit, 
    202             }); 
    203             my @ids; 
    204             my %order; 
    205             my $num = 0; 
    206             while (my ($max, $id) = $iter->()) { 
    207                 push @ids, $id; 
    208                 $order{$id} = $num++; 
    209             } 
    210             if ( @ids ) { 
    211                 @entries = MT::Entry->load({ id => \@ids }); 
    212                 @entries = sort { $order{$a->id} <=> $order{$b->id} } @entries; 
    213             } 
    214         } 
    215         if ( @entries ) { 
    216             $offset++; 
    217             return shift @entries; 
    218         } else { 
    219             return undef; 
    220         } 
    221     }; 
    222     return Data::ObjectDriver::Iterator->new($rco_iter); 
    223 } 
    224  
    225172########################################################################### 
    226173 
     
    236183 
    237184sub _hdlr_page_id { 
    238     return undef unless &_check_page(@_); 
    239     &_hdlr_entry_id(@_);  
     185    return undef unless $_[0]->check_page; 
     186    shift->invoke_handler('entryid', @_); 
    240187} 
    241188 
     
    255202 
    256203sub _hdlr_page_title { 
    257     return undef unless &_check_page(@_); 
    258     &_hdlr_entry_title(@_);  
     204    return undef unless $_[0]->check_page; 
     205    shift->invoke_handler('entrytitle', @_); 
    259206} 
    260207 
     
    292239 
    293240sub _hdlr_page_body { 
    294     return undef unless &_check_page(@_); 
    295     &_hdlr_entry_body(@_);  
     241    return undef unless $_[0]->check_page; 
     242    shift->invoke_handler('entrybody', @_); 
    296243} 
    297244 
     
    325272 
    326273sub _hdlr_page_more { 
    327     return undef unless &_check_page(@_); 
    328     &_hdlr_entry_more(@_);  
     274    return undef unless $_[0]->check_page; 
     275    shift->invoke_handler('entrymore', @_); 
    329276} 
    330277 
     
    365312 
    366313sub _hdlr_page_date { 
    367     return undef unless &_check_page(@_); 
    368     &_hdlr_entry_date(@_);  
     314    return undef unless $_[0]->check_page; 
     315    shift->invoke_handler('entrydate', @_); 
    369316} 
    370317 
     
    405352 
    406353sub _hdlr_page_modified_date { 
    407     return undef unless &_check_page(@_); 
    408     &_hdlr_entry_mod_date(@_);  
     354    return undef unless $_[0]->check_page; 
     355    shift->invoke_handler('entrymodifieddate', @_); 
    409356} 
    410357 
     
    422369 
    423370sub _hdlr_page_keywords { 
    424     return undef unless &_check_page(@_); 
    425     &_hdlr_entry_keywords(@_);  
     371    return undef unless $_[0]->check_page; 
     372    shift->invoke_handler('entrykeywords', @_); 
    426373} 
    427374 
     
    467414 
    468415sub _hdlr_page_basename { 
    469     return undef unless &_check_page(@_); 
    470     &_hdlr_entry_basename(@_); 
     416    return undef unless $_[0]->check_page; 
     417    shift->invoke_handler('entrybasename', @_); 
    471418} 
    472419 
     
    488435 
    489436sub _hdlr_page_permalink { 
    490     return undef unless &_check_page(@_); 
    491     &_hdlr_entry_permalink(@_); 
     437    return undef unless $_[0]->check_page; 
     438    shift->invoke_handler('entrypermalink', @_); 
    492439} 
    493440 
     
    508455 
    509456sub _hdlr_page_author_display_name { 
    510     return undef unless &_check_page(@_); 
    511     &_hdlr_entry_author_display_name(@_); 
     457    return undef unless $_[0]->check_page; 
     458    shift->invoke_handler('entryauthordisplayname', @_); 
    512459} 
    513460 
     
    529476 
    530477sub _hdlr_page_author_email { 
    531     return undef unless &_check_page(@_); 
    532     &_hdlr_entry_author_email(@_); 
     478    return undef unless $_[0]->check_page; 
     479    shift->invoke_handler('entryauthoremail', @_); 
    533480} 
    534481 
     
    572519 
    573520sub _hdlr_page_author_link { 
    574     return undef unless &_check_page(@_); 
    575     &_hdlr_entry_author_link(@_); 
     521    return undef unless $_[0]->check_page; 
     522    shift->invoke_handler('entryauthorlink', @_); 
    576523} 
    577524 
     
    589536 
    590537sub _hdlr_page_author_url { 
    591     return undef unless &_check_page(@_); 
    592     &_hdlr_entry_author_url(@_); 
     538    return undef unless $_[0]->check_page; 
     539    shift->invoke_handler('entryauthorurl', @_); 
    593540} 
    594541 
     
    628575 
    629576sub _hdlr_page_excer