| 1052 | | }, |
| 1053 | | }, |
| 1054 | | }, |
| 1055 | | template => { |
| 1056 | | index_templates => { |
| 1057 | | label => "Index Templates", |
| 1058 | | order => 100, |
| 1059 | | handler => sub { |
| 1060 | | my ( $terms, $args ) = @_; |
| 1061 | | |
| 1062 | | # FIXME: enumeration of types |
| 1063 | | $terms->{type} = 'index'; |
| 1064 | | }, |
| 1065 | | condition => sub { |
| 1066 | | $app->param('blog_id'); |
| 1067 | | }, |
| 1068 | | }, |
| 1069 | | archive_templates => { |
| 1070 | | label => "Archive Templates", |
| 1071 | | order => 200, |
| 1072 | | handler => sub { |
| 1073 | | my ( $terms, $args ) = @_; |
| 1074 | | $terms->{type} |
| 1075 | | = [ 'individual', 'page', 'archive', 'category' ]; |
| 1076 | | }, |
| 1077 | | condition => sub { |
| 1078 | | $app->param('blog_id'); |
| 1079 | | }, |
| 1080 | | }, |
| 1081 | | module_templates => { |
| 1082 | | label => "Template Modules", |
| 1083 | | order => 400, |
| 1084 | | handler => sub { |
| 1085 | | my ($terms) = @_; |
| 1086 | | $terms->{type} = 'custom'; |
| 1087 | | }, |
| 1088 | | }, |
| 1089 | | email_templates => { |
| 1090 | | label => "E-mail Templates", |
| 1091 | | order => 300, |
| 1092 | | handler => sub { |
| 1093 | | my ($terms) = @_; |
| 1094 | | $terms->{type} = 'email'; |
| 1095 | | }, |
| 1096 | | condition => sub { |
| 1097 | | !$app->param('blog_id'); |
| 1098 | | }, |
| 1099 | | }, |
| 1100 | | system_templates => { |
| 1101 | | label => "System Templates", |
| 1102 | | order => 200, |
| 1103 | | handler => sub { |
| 1104 | | my ($terms) = @_; |
| 1105 | | my $scope; |
| 1106 | | my $set; |
| 1107 | | if ( my $blog_id = $app->param('blog_id') ) { |
| 1108 | | my $blog = $app->model('blog')->load($blog_id); |
| 1109 | | $set = $blog->template_set; |
| 1110 | | $scope .= 'system'; |
| 1111 | | } |
| 1112 | | else { |
| 1113 | | $terms->{blog_id} = 0; |
| 1114 | | $scope = 'global:system'; |
| 1115 | | } |
| 1116 | | my @tmpl_path |
| 1117 | | = ( $set && ( $set ne 'mt_blog' ) ) |
| 1118 | | ? ( "template_sets", $set, 'templates', $scope ) |
| 1119 | | : ( "default_templates", $scope ); |
| 1120 | | my $sys_tmpl = MT->registry(@tmpl_path) || {}; |
| 1121 | | $terms->{type} = [ keys %$sys_tmpl ]; |
| 1122 | | }, |
| 1123 | | condition => sub { |
| 1124 | | $app->param('blog_id'); |
| 2440 | | push @{ $param->{button_loop} ||= [] }, |
| 2441 | | { |
| 2442 | | link => $app->uri( |
| 2443 | | mode => 'view', |
| 2444 | | args => { |
| 2445 | | blog_id => $tmpl->blog_id, |
| 2446 | | '_type' => 'template', |
| 2447 | | id => $tmpl->id |
| | 2367 | my $tmpl_edit_link = $app->uri( |
| | 2368 | mode => 'view', |
| | 2369 | args => { |
| | 2370 | blog_id => $tmpl->blog_id, |
| | 2371 | '_type' => 'template', |
| | 2372 | id => $tmpl->id |
| | 2373 | } |
| | 2374 | ); |
| | 2375 | |
| | 2376 | if ( $app->param('fs') ) { |
| | 2377 | $param->{fs} = 1; |
| | 2378 | if ( exists $app->{goback} ) { |
| | 2379 | $param->{goback} = "window.location='" . $app->{goback} . "'"; |
| | 2380 | if ( $tmpl_edit_link ne $app->{goback} ) { |
| | 2381 | push @{ $param->{button_loop} ||= [] }, |
| | 2382 | { |
| | 2383 | link => $tmpl_edit_link, |
| | 2384 | label => $app->translate("Edit Template"), |
| | 2385 | }; |
| 2449 | | ), |
| 2450 | | label => $app->translate("Edit Template"), |
| 2451 | | }; |
| 2452 | | } |
| 2453 | | |
| 2454 | | my $blog_id = $app->param('blog_id'); |
| 2455 | | my $url = $app->uri( |
| 2456 | | mode => 'rebuild_confirm', |
| 2457 | | args => { blog_id => $blog_id } |
| 2458 | | ); |
| 2459 | | $param->{goback} ||= qq{window.location='$url'}; |
| 2460 | | $param->{value} ||= $app->translate('Go Back'); |
| | 2387 | } |
| | 2388 | else { |
| | 2389 | $param->{goback} = "window.location='$tmpl_edit_link'"; |
| | 2390 | } |
| | 2391 | } |
| | 2392 | else { |
| | 2393 | push @{ $param->{button_loop} ||= [] }, |
| | 2394 | { |
| | 2395 | link => $tmpl_edit_link, |
| | 2396 | label => $app->translate("Edit Template"), |
| | 2397 | }; |
| | 2398 | } |
| | 2399 | } |
| | 2400 | |
| | 2401 | if ( !exists( $param->{goback} ) && exists( $app->{goback} ) ) { |
| | 2402 | $param->{goback} = "window.location='" . $app->{goback} . "'"; |
| | 2403 | } |
| | 2404 | else { |
| | 2405 | my $blog_id = $app->param('blog_id'); |
| | 2406 | my $url = $app->uri( |
| | 2407 | mode => 'rebuild_confirm', |
| | 2408 | args => { blog_id => $blog_id } |
| | 2409 | ); |
| | 2410 | $param->{goback} ||= qq{window.location='$url'}; |
| | 2411 | } |
| | 2412 | $param->{value} ||= $app->{value} || $app->translate('Go Back'); |