Changeset 1778
- Timestamp:
- 04/05/08 01:31:43 (5 months ago)
- Files:
-
- branches/release-33/lib/MT/App.pm (modified) (1 diff)
- branches/release-33/lib/MT/App/CMS.pm (modified) (4 diffs)
- branches/release-33/lib/MT/CMS/Blog.pm (modified) (10 diffs)
- branches/release-33/lib/MT/CMS/Entry.pm (modified) (2 diffs)
- branches/release-33/lib/MT/Util.pm (modified) (1 diff)
- branches/release-33/tmpl/cms/popup/rebuilt.tmpl (modified) (2 diffs)
- branches/release-33/tmpl/cms/rebuilding.tmpl (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/release-33/lib/MT/App.pm
r1769 r1778 664 664 MT->add_callback('post_save', 0, $app, \&_cb_mark_blog ); 665 665 MT->add_callback('MT::Blog::post_remove', 0, $app, \&_cb_unmark_blog ); 666 MT->add_callback('pre_build', 9, $app, sub { $app->touch_blogs() } ); 666 667 MT->add_callback('new_user_provisioning', 5, $app, \&_cb_user_provisioning); 667 668 } branches/release-33/lib/MT/App/CMS.pm
r1770 r1778 3076 3076 # now, rebuild indexes for affected blogs 3077 3077 my @blogs = $app->param('blog_ids'); 3078 foreach my $blog_id (@blogs) { 3079 my $blog = MT::Blog->load($blog_id) or next; 3080 $app->rebuild_indexes( Blog => $blog ) 3081 or return $app->publish_error(); 3082 } 3083 my $this_blog = MT::Blog->load( $app->param('blog_id') ); 3084 $app->run_callbacks( 'rebuild', $this_blog ); 3078 if (@blogs) { 3079 $app->run_callbacks( 'pre_build' ) if @blogs; 3080 foreach my $blog_id (@blogs) { 3081 my $blog = MT::Blog->load($blog_id) or next; 3082 $app->rebuild_indexes( Blog => $blog ) 3083 or return $app->publish_error(); 3084 } 3085 my $blog_id = int($app->param('blog_id')); 3086 my $this_blog = MT::Blog->load( $blog_id ) if $blog_id; 3087 $app->run_callbacks( 'rebuild', $this_blog ); 3088 $app->run_callbacks( 'post_build' ); 3089 } 3085 3090 return $app->call_return; 3086 3091 } 3087 3092 3088 3093 if ( exists $options{how} && ( $options{how} eq NEW_PHASE ) ) { 3094 my $start_time = time; 3095 $app->run_callbacks( 'pre_build' ); 3089 3096 my $params = { 3090 3097 return_args => $app->return_args, 3091 3098 blog_id => $app->param('blog_id') || 0, 3092 id => [ keys %$rebuild_set ] 3099 id => [ keys %$rebuild_set ], 3100 start_time => $start_time, 3093 3101 }; 3094 3102 my %param = ( … … 3103 3111 else { 3104 3112 my @blogs = $app->param('blog_ids'); 3113 my $start_time = $app->param('start_time'); 3105 3114 my %blogs = map { $_ => () } @blogs; 3106 3115 my @set = keys %$rebuild_set; … … 3118 3127 # Rebuilding something that isn't an entry, rebless as required 3119 3128 if ( $type ne MT::Entry->class_type ) { 3129 die "had to rebless? $e"; 3120 3130 my $pkg = MT->model($type) or next; 3121 3131 bless $e, $pkg; … … 3139 3149 blog_ids => [ keys %blogs ], 3140 3150 id => \@rest, 3151 start_time => $start_time, 3141 3152 }; 3142 3153 my %param = ( branches/release-33/lib/MT/CMS/Blog.pm
r1776 r1778 531 531 } 532 532 } 533 $app->run_callbacks('post_build'); 533 534 $app->call_return; 534 535 } … … 541 542 require MT::Blog; 542 543 my $q = $app->param; 543 my $blog_id = $q->param('blog_id'); 544 my $start_time = $q->param('start_time'); 545 546 if ( ! $start_time ) { 547 # start of build; invoke callback 548 $app->run_callbacks('pre_build'); 549 $start_time = time; 550 } 551 552 my $blog_id = int($q->param('blog_id')); 553 return $app->errtrans("Invalid request.") unless $blog_id; 554 544 555 my $blog = MT::Blog->load($blog_id); 545 556 my $order = $q->param('type'); … … 550 561 my $archiver = $app->publisher->archiver($type); 551 562 my $archive_label = $archiver ? $archiver->archive_label : ''; 563 552 564 $archive_label = $app->translate($type) unless $archive_label; 553 565 $archive_label = $archive_label->() if ( ref $archive_label ) eq 'CODE'; … … 556 568 my $offset = 0; 557 569 my ($total) = $q->param('total'); 558 559 ## Tells MT::_rebuild_entry_archive_type to cache loaded templates so560 ## that each template is only loaded once.561 $app->{cache_templates} = 1;562 570 563 571 my ($tmpl_saved); … … 774 782 offset => $offset, 775 783 complete => $complete, 784 start_time => $start_time, 776 785 incomplete => 100 - $complete, 777 786 entry_id => scalar $q->param('entry_id'), … … 783 792 } 784 793 else { 794 $app->run_callbacks( 'post_build' ); 785 795 if ( $q->param('entry_id') ) { 786 796 require MT::Entry; … … 809 819 } 810 820 my %param = ( 811 all => $all, 812 type => $archive_label, 813 is_one_index => $is_one_index, 814 is_entry => $is_entry, 815 archives => $type ne 'index', 821 all => $all, 822 type => $archive_label, 823 is_one_index => $is_one_index, 824 is_entry => $is_entry, 825 archives => $type ne 'index', 826 start_timestamp => MT::Util::epoch2ts($blog, $start_time), 827 total_time => time - $start_time, 816 828 ); 817 829 if ($is_one_index) { … … 838 850 } 839 851 else { # popup--just go to cnfrmn. page 840 $app->run_callbacks( 'rebuild', $blog );841 852 return $app->load_tmpl( 'popup/rebuilt.tmpl', \%param ); 842 853 } … … 854 865 my $app = shift; 855 866 my $q = $app->param; 867 my $start_time = $q->param('start_time'); 868 869 if ( ! $start_time ) { 870 # start of build; invoke callback 871 $app->run_callbacks('pre_build'); 872 $start_time = time; 873 } 874 856 875 my $type = $q->param('type'); 857 876 my $next = $q->param('next') || 0; … … 906 925 build_next => $next, 907 926 total => $total, 927 start_time => $start_time, 908 928 complete => 0, 909 929 incomplete => 100, branches/release-33/lib/MT/CMS/Entry.pm
r1746 r1778 1388 1388 my $res = MT::Util::start_background_task( 1389 1389 sub { 1390 $app->run_callbacks('pre_build'); 1390 1391 $app->rebuild_entry( 1391 1392 Entry => $obj, … … 1398 1399 ) or return $app->publish_error(); 1399 1400 $app->run_callbacks( 'rebuild', $blog ); 1401 $app->run_callbacks( 'post_build' ); 1400 1402 1; 1401 1403 } branches/release-33/lib/MT/Util.pm
r1744 r1778 208 208 } elsif ($hours) { 209 209 $result = $future ? MT->translate("[quant,_1,hour,hours] from now", $hours) : MT->translate("[quant,_1,hour,hours] ago", $hours); 210 } 211 return $result; 212 } 213 } elsif ($style == 3) { 214 if ($delta < 60) { 215 return $future ? MT->translate("[quant,_1,second,seconds] from now", $delta) : MT->translate("[quant,_1,second,seconds]", $delta); 216 } elsif ($delta <= 3600) { 217 # less than 1 hour 218 my $min = int(($delta % 3600) / 60); 219 my $sec = $delta % 60; 220 my $result; 221 if ($sec && $min) { 222 $result = $future ? MT->translate("[quant,_1,minute,minutes], [quant,_2,second,seconds] from now", $min, $sec) : MT->translate("[quant,_1,minute,minutes], [quant,_2,second,seconds]", $min, $sec); 223 } elsif ($min) { 224 $result = $future ? MT->translate("[quant,_1,minute,minutes] from now", $min) : MT->translate("[quant,_1,minute,minutes]", $min); 225 } elsif ($sec) { 226 $result = $future ? MT->translate("[quant,_1,second,seconds] from now", $sec) : MT->translate("[quant,_1,second,seconds]", $sec); 227 } 228 return $result; 229 } elsif ($delta <= 86400) { 230 # less than 1 day 231 my $hours = int($delta / 3600); 232 my $min = int(($delta % 3600) / 60); 233 my $result; 234 if ($hours && $min) { 235 $result = $future ? MT->translate("[quant,_1,hour,hours], [quant,_2,minute,minutes] from now", $hours, $min) : MT->translate("[quant,_1,hour,hours], [quant,_2,minute,minutes]", $hours, $min); 236 } elsif ($hours) { 237 $result = $future ? MT->translate("[quant,_1,hour,hours] from now", $hours) : MT->translate("[quant,_1,hour,hours]", $hours); 238 } elsif ($min) { 239 $result = $future ? MT->translate("[quant,_1,minute,minutes] from now", $min) : MT->translate("[quant,_1,minute,minutes]", $min); 240 } 241 return $result; 242 } elsif ($delta <= 604800) { 243 # less than 1 week 244 my $days = int($delta / 86400); 245 my $hours = int(($delta % 86400) / 3600); 246 my $result; 247 if ($days && $hours) { 248 $result = $future ? MT->translate("[quant,_1,day,days], [quant,_2,hour,hours] from now", $days, $hours) : MT->translate("[quant,_1,day,days], [quant,_2,hour,hours]", $days, $hours); 249 } elsif ($days) { 250 $result = $future ? MT->translate("[quant,_1,day,days] from now", $days) : MT->translate("[quant,_1,day,days]", $days); 251 } elsif ($hours) { 252 $result = $future ? MT->translate("[quant,_1,hour,hours] from now", $hours) : MT->translate("[quant,_1,hour,hours]", $hours); 210 253 } 211 254 return $result; branches/release-33/tmpl/cms/popup/rebuilt.tmpl
r1098 r1778 7 7 id="message" 8 8 class="success"> 9 <p> 9 10 <mt:if name="all"> 10 11 <__trans phrase="All of your files have been published."> … … 25 26 </mt:if> 26 27 <br /> 28 <mt:if name="start_timestamp"> 29 <__trans phrase="Publish time: [_1]." params="<mt:date ts="$start_timestamp" relative="3">"> 30 </mt:if> 31 </p> 32 <p> 27 33 <a target="_blank" href="<mt:var name="blog_url" escape="html">"><__trans phrase="View your site."></a> 28 34 <mt:if name="is_one_index"> 29 35 <a target="_blank" href="<mt:var name="tmpl_url">"><__trans phrase="View this page."></a> 30 36 </mt:if> 37 </p> 31 38 </mtapp:statusmsg> 32 39 branches/release-33/tmpl/cms/rebuilding.tmpl
r1309 r1778 1 <mt:setvarblock name="html_head" append="1"> 2 <script type="text/javascript"> 3 /* <![CDATA[ */ 4 function doRedirect () { 5 <mt:if name="redirect_target"> 6 window.location='<mt:var name="redirect_target">'; 7 <mt:else> 8 window.location='<mt:var name="script_url">?__mode=rebuild&blog_id=<mt:var name="blog_id">&type=<mt:var name="build_type">&next=<mt:var name="build_next">&offset=<mt:var name="offset">&limit=<mt:var name="limit">&total=<mt:var name="total">&start_time=<mt:var name="start_time">&entry_id=<mt:var name="entry_id">&is_new=<mt:var name="is_new">&old_status=<mt:var name="old_status">&old_previous=<mt:var name="old_previous">&old_next=<mt:var name="old_next"><mt:if name="is_full_screen">&fs=1</mt:if>'; 9 </mt:if> 10 } 11 setTimeout('doRedirect()', 200); 12 /* ]]> */ 13 </script> 14 </mt:setvarblock> 15 1 16 <mt:if name="is_full_screen"> 2 17 <$mt:setvar name="screen_class" value="rebuilding-screen"$> … … 9 24 </mt:if> 10 25 11 <script type="text/javascript">12 /* <![CDATA[ */13 function doRedirect () {14 <mt:if name="redirect_target">15 window.location='<mt:var name="redirect_target">';16 <mt:else>17 window.location='<mt:var name="script_url">?__mode=rebuild&blog_id=<mt:var name="blog_id">&type=<mt:var name="build_type">&next=<mt:var name="build_next">&offset=<mt:var name="offset">&limit=<mt:var name="limit">&total=<mt:var name="total">&entry_id=<mt:var name="entry_id">&is_new=<mt:var name="is_new">&old_status=<mt:var name="old_status">&old_previous=<mt:var name="old_previous">&old_next=<mt:var name="old_next"><mt:if name="is_full_screen">&fs=1</mt:if>';18 </mt:if>19 }20 setTimeout('doRedirect()', 200);21 /* ]]> */22 </script>23 24 25 <!-- <img valign="bottom" src="<mt:var name="static_uri">images/ani-rebuild.gif" height="18" width="18" alt="" /> -->26 26 <mt:if name="is_one_index"> 27 27 <mtapp:statusmsg
