Show
Ignore:
Timestamp:
04/26/08 06:54:49 (19 months ago)
Author:
bchoate
Message:

Paginate rebuild operation for list action to publish archive templates. Added 'save and rebuild' button for archive templates. BugId:79515

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/release-36/lib/MT/CMS/Template.pm

    r2110 r2115  
    19801980      || $perms->can_rebuild; 
    19811981 
    1982     my $blog = $app->blog; 
    1983     my $templates = 
    1984       MT->model('template')->lookup_multi( [ $app->param('id') ] ); 
     1982    my @ids = $app->param('id'); 
     1983    if (scalar @ids == 1) { 
     1984        # we also support a list of comma-delimited ids like this 
     1985        @ids = split /,/, $ids[0]; 
     1986    } 
     1987    return $app->error($app->translate("Invalid request.")) 
     1988        unless @ids; 
     1989 
     1990    my $tmpl_id; 
     1991    my %ats; 
    19851992    require MT::TemplateMap; 
    1986     # FIXME: Need multi-request support! 
    1987     TEMPLATE: for my $tmpl (@$templates) { 
    1988         next TEMPLATE if !defined $tmpl; 
    1989         next TEMPLATE if $tmpl->blog_id != $blog->id; 
    1990         my @tmpl_maps = MT::TemplateMap->load( { template_id => $tmpl->id } ); 
     1993    while (!$tmpl_id && @ids) { 
     1994        $tmpl_id = shift @ids; 
     1995        my @tmpl_maps = MT::TemplateMap->load( { template_id => $tmpl_id } ); 
    19911996        foreach my $map (@tmpl_maps) { 
    19921997            next unless $map->build_type; 
    1993             $app->rebuild( 
    1994                 Blog        => $blog, 
    1995                 ArchiveType => $map->archive_type, 
    1996                 TemplateMap => $map, 
    1997                 NoIndexes   => 1, 
    1998                 Force       => 1, 
    1999             ); 
    2000         } 
    2001     } 
    2002  
    2003     $app->call_return( published => 1 ); 
     1998            $ats{ $map->archive_type } = 1; 
     1999        } 
     2000        undef $tmpl_id unless keys %ats; 
     2001    } 
     2002 
     2003    # we have a template and archive types to publish! 
     2004 
     2005    require MT::CMS::Blog; 
     2006    my $return_args; 
     2007    if (@ids) { 
     2008        # we have more to do after this, so save the list 
     2009        # of remaining archive templates... 
     2010        $return_args = $app->uri_params( 
     2011            mode => 'publish_archive_templates', 
     2012            args => { 
     2013                magic_token => $app->current_magic, 
     2014                blog_id => scalar $app->param('blog_id'), 
     2015                id => join(",", @ids), 
     2016            } 
     2017        ); 
     2018    } else { 
     2019        # nothing left after this publish operation; just return 
     2020        # to the listing screen. 
     2021        $return_args = $app->uri_params( 
     2022            mode => 'list', 
     2023            args => { 
     2024                _type => 'template', 
     2025                blog_id => scalar $app->param('blog_id'), 
     2026                published => 1 
     2027            } 
     2028        ); 
     2029    } 
     2030    $return_args =~ s/^\?//; 
     2031 
     2032    $app->return_args( $return_args ); 
     2033    $app->param( 'template_id', $tmpl_id ); 
     2034    $app->param( 'single_template', 1 ); # forces fullscreen mode 
     2035    $app->param( 'type', join(",", keys %ats) ); 
     2036    return MT::CMS::Blog::start_rebuild_pages($app); 
    20042037} 
    20052038