Changeset 2019
- Timestamp:
- 04/22/08 01:21:47 (7 months ago)
- Files:
-
- branches/release-35/lib/MT/CMS/Template.pm (modified) (7 diffs)
- branches/release-35/lib/MT/WeblogPublisher.pm (modified) (34 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/release-35/lib/MT/CMS/Template.pm
r1996 r2019 93 93 && $param->{type} ne 'widget' 94 94 && !$param->{is_special}; 95 $param->{rebuild_me} =96 defined $obj->rebuild_me ? $obj->rebuild_me : 1;97 95 $param->{search_label} = $app->translate('Templates'); 98 96 $param->{object_type} = 'template'; … … 373 371 && !$param->{is_special}; 374 372 375 $param->{rebuild_me} = 1;376 373 $param->{name} = MT::Util::decode_url( $app->param('name') ) 377 374 if $app->param('name'); … … 1454 1451 $app->validate_magic or return; 1455 1452 1453 my $blog = $app->blog; 1454 $app->assert( $blog ) or return; 1455 1456 # permission check 1457 my $perms = $app->permissions; 1458 return $app->errtrans("Permission denied.") 1459 unless $app->user->is_superuser || 1460 $perms->can_administer_blog || 1461 $perms->can_edit_templates; 1462 1456 1463 my $param = {}; 1457 my $blog = $app->blog;1458 1464 $param->{dynamicity} = $blog->custom_dynamic_templates || 'none'; 1459 1465 $param->{screen_id} = "publishing-profile-dialog"; … … 1708 1714 identifier => $val->{identifier}, 1709 1715 outfile => $val->{outfile}, 1710 rebuild_me => $val->{rebuild_me} 1716 rebuild_me => $val->{rebuild_me}, 1711 1717 } 1712 1718 ); … … 1898 1904 next TEMPLATE if !defined $tmpl; 1899 1905 next TEMPLATE if $tmpl->blog_id != $blog->id; 1906 next TEMPLATE unless $tmpl->build_type; 1907 1900 1908 $app->rebuild_indexes( 1901 1909 Blog => $blog, 1902 1910 Template => $tmpl, 1911 Force => 1, 1903 1912 ); 1904 1913 } … … 1921 1930 my $templates = 1922 1931 MT->model('template')->lookup_multi( [ $app->param('id') ] ); 1923 use MT::TemplateMap; 1932 require MT::TemplateMap; 1933 # FIXME: Need multi-request support! 1924 1934 TEMPLATE: for my $tmpl (@$templates) { 1925 1935 next TEMPLATE if !defined $tmpl; … … 1927 1937 my @tmpl_maps = MT::TemplateMap->load( { template_id => $tmpl->id } ); 1928 1938 foreach my $map (@tmpl_maps) { 1939 next unless $map->build_type; 1929 1940 $app->rebuild( 1930 Blog ID => $blog->id,1941 Blog => $blog, 1931 1942 ArchiveType => $map->archive_type, 1943 TemplateMap => $map, 1932 1944 NoIndexes => 1, 1945 Force => 1, 1933 1946 ); 1934 1947 } branches/release-35/lib/MT/WeblogPublisher.pm
r2011 r2019 218 218 ArchiveType => $at, 219 219 NoStatic => $param{NoStatic}, 220 Force => ($param{Force} ? 1 : 0), 220 221 $param{TemplateMap} 221 222 ? ( TemplateMap => $param{TemplateMap} ) … … 242 243 : (), 243 244 NoStatic => $param{NoStatic}, 244 Author => $entry->author 245 Force => ($param{Force} ? 1 : 0), 246 Author => $entry->author, 245 247 ) or return; 246 248 } … … 258 260 $param{TemplateID} ) 259 261 : (), 260 NoStatic => $param{NoStatic} 262 NoStatic => $param{NoStatic}, 263 Force => ($param{Force} ? 1 : 0), 261 264 ) or return; 262 265 } … … 304 307 : (), 305 308 NoStatic => $param{NoStatic}, 309 Force => ($param{Force} ? 1 : 0), 306 310 ) or return; 307 311 } … … 352 356 : (), 353 357 NoStatic => $param{NoStatic}, 358 Force => ($param{Force} ? 1 : 0), 354 359 ) or return; 355 360 } … … 404 409 Category => $cat, 405 410 NoStatic => $param{NoStatic}, 411 # Force => ($param{Force} ? 1 : 0), 406 412 $param{TemplateMap} 407 413 ? ( TemplateMap => $param{TemplateMap} ) … … 419 425 : (), 420 426 NoStatic => $param{NoStatic}, 427 # Force => ($param{Force} ? 1 : 0), 421 428 Author => $entry->author, 422 429 ) or return; … … 487 494 $mt->_rebuild_entry_archive_type( 488 495 NoStatic => $param{NoStatic}, 496 # Force => ($param{Force} ? 1 : 0), 489 497 Entry => $prev_arch, 490 498 Blog => $blog, … … 502 510 $mt->_rebuild_entry_archive_type( 503 511 NoStatic => $param{NoStatic}, 512 # Force => ($param{Force} ? 1 : 0), 504 513 Entry => $next_arch, 505 514 Blog => $blog, … … 519 528 $mt->_rebuild_entry_archive_type( 520 529 NoStatic => $param{NoStatic}, 530 # Force => ($param{Force} ? 1 : 0), 521 531 Entry => $prev_arch, 522 532 Blog => $blog, … … 534 544 $mt->_rebuild_entry_archive_type( 535 545 NoStatic => $param{NoStatic}, 546 # Force => ($param{Force} ? 1 : 0), 536 547 Entry => $next_arch, 537 548 Blog => $blog, … … 589 600 $mt->_rebuild_entry_archive_type( 590 601 NoStatic => 0, 602 Force => ($param{Force} ? 1 : 0), 591 603 Blog => $blog, 592 604 Category => $cat, … … 600 612 $mt->_rebuild_entry_archive_type( 601 613 NoStatic => 0, 614 Force => ($param{Force} ? 1 : 0), 602 615 Blog => $blog, 603 616 Category => $cat, … … 616 629 $mt->_rebuild_entry_archive_type( 617 630 NoStatic => 0, 631 Force => ($param{Force} ? 1 : 0), 618 632 Blog => $blog, 619 633 Author => $author, … … 627 641 $mt->_rebuild_entry_archive_type( 628 642 NoStatic => 0, 643 Force => ($param{Force} ? 1 : 0), 629 644 Blog => $blog, 630 645 Author => $author, … … 638 653 $mt->_rebuild_entry_archive_type( 639 654 NoStatic => 0, 655 Force => ($param{Force} ? 1 : 0), 640 656 Blog => $blog, 641 657 ArchiveType => $at, … … 652 668 $mt->_rebuild_entry_archive_type( 653 669 NoStatic => 0, 670 Force => ($param{Force} ? 1 : 0), 654 671 Entry => $entry, 655 672 Blog => $blog, … … 782 799 require MT::Template; 783 800 for my $map (@map) { 801 next unless $map->build_type; # ignore disabled template maps 802 784 803 $mt->rebuild_file( 785 804 $blog, $arch_root, $map, $at, $ctx, \%cond, … … 790 809 StartDate => $start, 791 810 EndDate => $end, 811 Force => $param{Force} ? 1 : 0, 792 812 ) or return; 793 813 $done->{ $map->{__saved_output_file} }++; … … 798 818 sub rebuild_file { 799 819 my $mt = shift; 800 my ( $blog, $root_path, $map, $at, $ctx, $cond, $build_static, % specifier)820 my ( $blog, $root_path, $map, $at, $ctx, $cond, $build_static, %args ) 801 821 = @_; 802 822 … … 805 825 my ( $entry, $start, $end, $category, $author ); 806 826 807 if ( $finfo = $ specifier{FileInfo} ) {808 $ specifier{Author} = $finfo->author_id if $finfo->author_id;809 $ specifier{Category} = $finfo->category_id if $finfo->category_id;810 $ specifier{Entry} = $finfo->entry_id if $finfo->entry_id;827 if ( $finfo = $args{FileInfo} ) { 828 $args{Author} = $finfo->author_id if $finfo->author_id; 829 $args{Category} = $finfo->category_id if $finfo->category_id; 830 $args{Entry} = $finfo->entry_id if $finfo->entry_id; 811 831 $map ||= MT::TemplateMap->load( $finfo->templatemap_id ); 812 832 $at ||= $finfo->archive_type; 813 833 if ( $finfo->startdate ) { 814 834 if ( my ( $start, $end ) = $archiver->date_range($finfo->startdate) ) { 815 $ specifier{StartDate} = $start;816 $ specifier{EndDate} = $end;835 $args{StartDate} = $start; 836 $args{EndDate} = $end; 817 837 } 818 838 } … … 835 855 836 856 if ( $archiver->category_based ) { 837 $category = $ specifier{Category};857 $category = $args{Category}; 838 858 die "Category archive type requires Category parameter" 839 unless $ specifier{Category};859 unless $args{Category}; 840 860 $category = MT::Category->load($category) 841 861 unless ref $category; … … 844 864 } 845 865 if ( $archiver->entry_based ) { 846 $entry = $ specifier{Entry};866 $entry = $args{Entry}; 847 867 die "$at archive type requires Entry parameter" 848 868 unless $entry; … … 854 874 if ( $archiver->date_based ) { 855 875 # Date-based archive type 856 $start = $ specifier{StartDate};857 $end = $ specifier{EndDate};876 $start = $args{StartDate}; 877 $end = $args{EndDate}; 858 878 Carp::confess("Date-based archive types require StartDate parameter") 859 unless $ specifier{StartDate};879 unless $args{StartDate}; 860 880 $ctx->var( 'datebased_archive', 1 ); 861 881 } … … 863 883 864 884 # author based archive type 865 $author = $ specifier{Author};885 $author = $args{Author}; 866 886 die "Author-based archive type requires Author parameter" 867 unless $ specifier{Author};887 unless $args{Author}; 868 888 require MT::Author; 869 889 $author = MT::Author->load($author) … … 1004 1024 return 1 if ( $tmpl->build_dynamic ); 1005 1025 return 1 if ( $entry && $entry->status != MT::Entry::RELEASE() ); 1026 return 1 unless ( $tmpl->build_type ); 1006 1027 1007 1028 my $timer = MT->get_timer; … … 1035 1056 Category => $category, 1036 1057 category => $category, 1058 force => ($args{Force} ? 1 : 0), 1037 1059 ) 1038 1060 ) 1039 1061 { 1062 1040 1063 if ( $archiver->group_based ) { 1041 1064 require MT::Promise; … … 1220 1243 ); 1221 1244 } 1245 my $force = $param{Force}; 1246 1222 1247 local *FH; 1223 1248 my $site_root = $blog->site_path; … … 1235 1260 ## Note that dynamic templates do need to be "rebuilt"--the 1236 1261 ## FileInfo table needs to be maintained. 1237 if ( !$tmpl->build_dynamic && !$ param{Force}) {1262 if ( !$tmpl->build_dynamic && !$force ) { 1238 1263 next if ( defined $tmpl->rebuild_me && !$tmpl->rebuild_me ); 1239 1264 } 1265 next if ( defined $tmpl->build_type && !$tmpl->build_type ); 1266 1240 1267 my $file = $tmpl->outfile; 1241 1268 $file = '' unless defined $file; … … 1298 1325 1299 1326 next if ( $tmpl->build_dynamic ); 1327 next unless ( $tmpl->build_type ); 1300 1328 1301 1329 ## We're not building dynamically, so if the FileInfo is currently … … 1328 1356 template => $tmpl, 1329 1357 File => $file, 1330 file => $file 1358 file => $file, 1359 force => $force, 1331 1360 ) 1332 1361 ); … … 1778 1807 require MT::PublishOption; 1779 1808 my $throttle = MT::PublishOption::get_throttle($fi); 1809 1810 # Prevent building of disabled templates if they get this far 1780 1811 return 0 if $throttle->{type} == MT::PublishOption::DISABLED(); 1812 1813 # Check for 'force' flag for 'manual' publish option, which 1814 # forces the template to build; used for 'rebuild' list actions 1815 # and publish site operations 1816 if ($throttle->{type} == MT::PublishOption::MANUALLY()) { 1817 return $args{force} ? 1 : 0; 1818 } 1819 1820 # From here on, we're committed to publishing this file via TheSchwartz 1781 1821 return 1 if $throttle->{type} != MT::PublishOption::ASYNC(); 1782 1822 … … 1985 2025 =back 1986 2026 1987 =head2 $mt->rebuild_file($blog, $archive_root, $map, $archive_type, $ctx, \%cond, $build_static, % specifier)2027 =head2 $mt->rebuild_file($blog, $archive_root, $map, $archive_type, $ctx, \%cond, $build_static, %args) 1988 2028 1989 2029 Method responsible for building a single archive page from a template and … … 2000 2040 created and that is all). 2001 2041 2002 I<% specifier> is a hash that uniquely identifies the specific instance2042 I<%args> is a hash that uniquely identifies the specific instance 2003 2043 of the given archive type. That is, for a category archive page it 2004 2044 identifies the category; for a date-based archive page it identifies 2005 2045 which time period is covered by the page; for an individual archive it 2006 identifies the entry. I<% specifier> should contain just one of these2046 identifies the entry. I<%args> should contain just one of these 2007 2047 keys: 2008 2048
