| 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 | } |
| 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 | ); |