Changeset 2051

Show
Ignore:
Timestamp:
04/24/08 03:02:29 (4 months ago)
Author:
fumiakiy
Message:

Fixed to create required files for dynamic publishing when an individual template is set to publish dynamically. BugId:79337

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/release-36/lib/MT/Blog.pm

    r1971 r2051  
    497497                                      archive_type => $archive_type}); 
    498498    return 0 unless @maps; 
    499     require MT::Template
     499    require MT::PublishOption
    500500    foreach my $map (@maps) {   
    501         my $tmpl = MT::Template->load($map->template_id) 
    502             or return 0; 
    503         $result++ if !$tmpl->build_dynamic; 
     501        $result++ if $map->build_type != MT::PublishOption::DYNAMIC(); 
    504502    } 
    505503    #$result ||= 1 if ($blog->custom_dynamic_templates || '') ne 'custom'; 
  • branches/release-36/lib/MT/CMS/Blog.pm

    r2026 r2051  
    21682168      && ( -f $htaccess_path ) 
    21692169      && ( -f $mtview_path ); 
    2170     return 1  
    2171         if 'all' ne $blog->custom_dynamic_templates 
    2172         && 'archives' ne $blog->custom_dynamic_templates; 
    21732170 
    21742171    # IIS itself does not handle .htaccess, 
  • branches/release-36/lib/MT/CMS/Template.pm

    r2049 r2051  
    12861286    $sess_obj->remove if $sess_obj; 
    12871287 
    1288     require MT::TemplateMap
     1288    my $dynamic = 0
    12891289    my $q = $app->param; 
    1290     my @p = $q->param; 
    1291     for my $p (@p) { 
    1292         if ( $p =~ /^archive_tmpl_preferred_(\w+)_(\d+)$/ ) { 
    1293             my $at     = $1; 
    1294             my $map_id = $2; 
    1295             my $map    = MT::TemplateMap->load($map_id) 
    1296                 or next; 
    1297             $map->prefer( $q->param($p) );    # prefer method saves in itself 
    1298         } 
    1299         elsif ( $p =~ /^archive_file_tmpl_(\d+)$/ ) { 
    1300             my $map_id = $1; 
    1301             my $map    = MT::TemplateMap->load($map_id) 
    1302                 or next; 
    1303             $map->file_template( $q->param($p) ); 
    1304             $map->save; 
    1305         } 
    1306         elsif ( $p =~ /^map_build_type_(\d+)$/ ) { 
    1307             my $map_id     = $1; 
    1308             my $map        = MT::TemplateMap->load($map_id) 
    1309                 or next; 
    1310             my $build_type = $q->param($p); 
    1311             require MT::PublishOption; 
    1312             $map->build_type($build_type); 
    1313             if ( $build_type == MT::PublishOption::SCHEDULED() ) { 
    1314                 my $period   = $q->param( 'map_schedule_period_' . $map_id ); 
    1315                 my $interval = $q->param( 'map_schedule_interval_' . $map_id ); 
    1316                 my $sec      = _get_interval( $period, $interval ); 
    1317                 $map->build_interval($sec); 
    1318             } 
    1319             $map->save; 
     1290    my $type = $q->param('type'); 
     1291    # FIXME: enumeration of types 
     1292    if ( $type eq 'custom' 
     1293      || $type eq 'index' 
     1294      || $type eq 'widget' 
     1295      || $type eq 'widgetset' ) 
     1296    { 
     1297        $dynamic = $obj->build_dynamic; 
     1298    } 
     1299    else 
     1300    { 
     1301        # archive template specific post_save tasks 
     1302        require MT::TemplateMap; 
     1303        my @p = $q->param; 
     1304        for my $p (@p) { 
     1305            my $map; 
     1306            if ( $p =~ /^archive_tmpl_preferred_(\w+)_(\d+)$/ ) { 
     1307                my $at     = $1; 
     1308                my $map_id = $2; 
     1309                $map    = MT::TemplateMap->load($map_id) 
     1310                    or next; 
     1311                $map->prefer( $q->param($p) );    # prefer method saves in itself 
     1312            } 
     1313            elsif ( $p =~ /^archive_file_tmpl_(\d+)$/ ) { 
     1314                my $map_id = $1; 
     1315                $map    = MT::TemplateMap->load($map_id) 
     1316                    or next; 
     1317                $map->file_template( $q->param($p) ); 
     1318                $map->save; 
     1319            } 
     1320            elsif ( $p =~ /^map_build_type_(\d+)$/ ) { 
     1321                my $map_id     = $1; 
     1322                $map        = MT::TemplateMap->load($map_id) 
     1323                    or next; 
     1324                my $build_type = $q->param($p); 
     1325                require MT::PublishOption; 
     1326                $map->build_type($build_type); 
     1327                if ( $build_type == MT::PublishOption::SCHEDULED() ) { 
     1328                    my $period   = $q->param( 'map_schedule_period_' . $map_id ); 
     1329                    my $interval = $q->param( 'map_schedule_interval_' . $map_id ); 
     1330                    my $sec      = _get_interval( $period, $interval ); 
     1331                    $map->build_interval($sec); 
     1332                } 
     1333                $map->save; 
     1334            } 
     1335            if ( !$dynamic 
     1336              && $map && $map->build_type == MT::PublishOption::DYNAMIC() ) 
     1337            { 
     1338                $dynamic = 1; 
     1339            } 
    13201340        } 
    13211341    } 
     
    13351355    } 
    13361356 
    1337     if ( $obj->build_dynamic ) { 
     1357    if ( $dynamic ) { 
    13381358        if ( $obj->type eq 'index' ) { 
    13391359            $app->rebuild_indexes( 
     
    13431363            ) or return $app->publish_error();    # XXXX 
    13441364        } 
    1345         else { 
    1346             $app->rebuild( 
    1347                 BlogID     => $obj->blog_id, 
    1348                 TemplateID => $obj->id, 
    1349                 NoStatic   => 1, 
    1350             ) or return $app->publish_error(); 
     1365        if ( my $blog = $app->blog ) { 
     1366            require MT::CMS::Blog; 
     1367            my ( $path, $url ); 
     1368            if ( $obj->type eq 'index' ) { 
     1369                $path = $blog->site_path; 
     1370                $url = $blog->site_url; 
     1371            } 
     1372            else { 
     1373                # must be archive since other types can't be dynamic 
     1374                if ( $path = $blog->archive_path ) { 
     1375                    $url = $blog->archive_url; 
     1376                } 
     1377                else { 
     1378                    $path = $blog->site_path; 
     1379                    $url = $blog->site_url; 
     1380                } 
     1381            } 
     1382            # specific arguments so not to overwrite mtview and htaccess 
     1383            MT::CMS::Blog::prepare_dynamic_publishing( 
     1384                $eh,  
     1385                $blog, 
     1386                undef, 
     1387                undef, 
     1388                $path, 
     1389                $url 
     1390            ); 
    13511391        } 
    13521392    } 
  • branches/release-36/lib/MT/WeblogPublisher.pm

    r2023 r2051  
    10091009    # we move the file that might be there so that the custom 
    10101010    # 404 will be triggered. 
    1011     if ( $tmpl->build_dynamic ) { 
     1011    require MT::PublishOption; 
     1012    if ( $tmpl->build_dynamic 
     1013      || ( $map->build_type == MT::PublishOption::DYNAMIC() ) ) 
     1014    { 
    10121015        rename( 
    10131016            $finfo->file_path,    # is this just $file ? 
     
    10221025    } 
    10231026 
    1024     return 1 if ( $tmpl->build_dynamic ); 
     1027    return 1 if ( $tmpl->build_dynamic ) 
     1028        || ( $map->build_type == MT::PublishOption::DYNAMIC() ); 
    10251029    return 1 if ( $entry && $entry->status != MT::Entry::RELEASE() ); 
    10261030    return 1 unless ( $tmpl->build_type );