Changeset 1957
- Timestamp:
- 04/17/08 22:43:48 (19 months ago)
- Location:
- branches/release-35/lib/MT
- Files:
-
- 3 modified
-
CMS/Blog.pm (modified) (5 diffs)
-
Template.pm (modified) (1 diff)
-
TemplateMap.pm (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/release-35/lib/MT/CMS/Blog.pm
r1951 r1957 1836 1836 } 1837 1837 1838 sub _switch_publish_options {1839 my ( $blog, $current, $new, $dcty ) = @_;1840 require MT::Template;1841 require MT::TemplateMap;1842 my @tmpl = MT::Template->load( { blog_id => $blog->id } );1843 my $pref_at = $blog->archive_type_preferred || '';1844 for my $tmpl (@tmpl) {1845 # FIXME: enumeration of types1846 next1847 if !( $tmpl->type =~ m/^(individual|page|category|archive)$/ );1848 # if ( $tmpl->build_type == $current ) {1849 # $tmpl->build_type($new);1850 # $tmpl->save;1851 # }1852 my @tmpl_maps = MT::TemplateMap->load( { template_id => $tmpl->id } );1853 foreach my $tmpl_map (@tmpl_maps) {1854 if ($dcty eq 'async_partial') {1855 # build the preferred individual/page archives synchronously1856 if (($tmpl_map->archive_type =~ m/^(Individual|Page)$/) &&1857 ($tmpl_map->is_preferred)) {1858 $tmpl_map->build_type(MT::PublishOption::ONDEMAND());1859 $tmpl_map->save;1860 next;1861 }1862 }1863 if ( $tmpl_map->build_type != $new ) {1864 $tmpl_map->build_type($new);1865 $tmpl_map->save;1866 }1867 }1868 }1869 1;1870 }1871 1872 1838 sub cfg_archives_save { 1873 1839 my $app = shift; … … 1895 1861 $app->translate( "Saving blog failed: [_1]", $blog->errstr ) ); 1896 1862 1897 require MT::PublishOption;1898 if ($pq) {1899 _switch_publish_options(1900 $blog,1901 MT::PublishOption::ONDEMAND(),1902 MT::PublishOption::ASYNC(),1903 $dcty,1904 );1905 }1906 else {1907 _switch_publish_options(1908 $blog,1909 MT::PublishOption::ASYNC(),1910 MT::PublishOption::ONDEMAND(),1911 $dcty,1912 );1913 }1914 1915 1863 1; 1916 1864 } 1917 1865 1866 # FIXME: Faulty, since it doesn't take into account module includes 1918 1867 sub RegistrationAffectsArchives { 1919 1868 my ( $blog_id, $archive_type ) = @_; … … 1966 1915 $tmpl->build_type(MT::PublishOption::ONDEMAND()); 1967 1916 } 1968 $tmpl->build_dynamic(0);1969 1917 $tmpl->save(); 1970 1918 } … … 1979 1927 for my $tmpl (@templates) { 1980 1928 $tmpl->build_type( $tmpl->type ne 'index' ? MT::PublishOption::DYNAMIC() : MT::PublishOption::ONDEMAND() ); 1981 $tmpl->build_dynamic( $tmpl->type ne 'index' ? 1 : 0 );1982 1929 $tmpl->save(); 1983 1930 } … … 1995 1942 for my $tmpl (@templates) { 1996 1943 $tmpl->build_type( MT::PublishOption::DYNAMIC() ); 1997 $tmpl->build_dynamic(1);1998 1944 $tmpl->save(); 1999 1945 } -
branches/release-35/lib/MT/Template.pm
r1949 r1957 291 291 return $tmpl->error(MT->translate('Template with the same name already exists in this blog.')); 292 292 } 293 294 if ($tmpl->id && ($tmpl->is_changed('build_type'))) { 295 # check for templatemaps, and update them appropriately 296 require MT::TemplateMap; 297 require MT::PublishOption; 298 my @maps = MT::TemplateMap->load({ template_id => $tmpl->id }); 299 foreach my $map (@maps) { 300 $map->build_type($tmpl->build_type); 301 $map->save or die $map->errstr; 302 } 303 } 304 293 305 if ($tmpl->linked_file) { 294 306 $tmpl->_sync_to_disk($tmpl->SUPER::text) or return; 295 307 } 296 308 $tmpl->{needs_db_sync} = 0; 297 if ((!$tmpl->id) && (my $blog = $tmpl->blog)) { 298 my $dcty = $blog->custom_dynamic_templates; 299 if ($dcty eq 'all') { 300 if (('index' eq $tmpl->type) || ('archive' eq $tmpl->type) || 301 ('individual' eq $tmpl->type) || ('page' eq $tmpl->type) || 302 ('category' eq $tmpl->type)) { 303 $tmpl->build_dynamic(1); 304 } 305 } elsif ($dcty eq 'archives') { 306 if (('archive' eq $tmpl->type) || ('page' eq $tmpl->type) || 307 ('individual' eq $tmpl->type) || ('category' eq $tmpl->type)) { 308 $tmpl->build_dynamic(1); 309 } 310 } 311 } 309 310 # if ((!$tmpl->id) && (my $blog = $tmpl->blog)) { 311 # my $dcty = $blog->custom_dynamic_templates; 312 # if ($dcty eq 'all') { 313 # if (('index' eq $tmpl->type) || ('archive' eq $tmpl->type) || 314 # ('individual' eq $tmpl->type) || ('page' eq $tmpl->type) || 315 # ('category' eq $tmpl->type)) { 316 # $tmpl->build_dynamic(1); 317 # } 318 # } elsif ($dcty eq 'archives') { 319 # if (('archive' eq $tmpl->type) || ('page' eq $tmpl->type) || 320 # ('individual' eq $tmpl->type) || ('category' eq $tmpl->type)) { 321 # $tmpl->build_dynamic(1); 322 # } 323 # } 324 # } 325 312 326 $tmpl->SUPER::save; 327 } 328 329 sub build_dynamic { 330 my $tmpl = shift; 331 require MT::PublishOption; 332 if (@_) { 333 $tmpl->build_type($_[0] ? MT::PublishOption::DYNAMIC() : MT::PublishOption::ONDEMAND()); 334 } 335 return 1 if $tmpl->build_type == MT::PublishOption::DYNAMIC(); 313 336 } 314 337 -
branches/release-35/lib/MT/TemplateMap.pm
r1873 r1957 46 46 sub save { 47 47 my $map = shift; 48 $map->SUPER::save(); 48 my $res = $map->SUPER::save(); 49 return $res unless $res; 50 49 51 my $at = $map->archive_type; 50 52 my $blog = MT->model('blog')->load($map->blog_id) … … 56 58 if $blog_at ne 'None'; 57 59 push @ats, $map->archive_type; 58 $blog->archive_type(join ',', @ats); 59 $blog->save; 60 my $new_at = join ',', @ats; 61 if ($new_at ne $blog_at) { 62 $blog->archive_type($new_at); 63 $blog->save; 64 } 65 return 1; 60 66 } 61 67
