Changeset 875

Show
Ignore:
Timestamp:
12/11/06 07:48:06 (2 years ago)
Author:
fumiakiy
Message:

Fixed a bug which forced to overwrite mtview.php everytime cfg_archive screen was saved. BugId: 45815

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/wheeljack/lib/MT/App/CMS.pm

    r873 r875  
    81998199    $param{dynamic_all} = $blog->custom_dynamic_templates eq 'all'; 
    82008200    $param{show_build_options} = $app->config('ObjectDriver') =~ m/^DBI::(postgres|sqlite|mysql)/; 
     8201    my $mtview_path = File::Spec->catfile($blog->site_path(), "mtview.php"); 
     8202    if (-f $mtview_path) { 
     8203        open my($fh), $mtview_path; 
     8204        while (my $line = <$fh>) { 
     8205            $param{dynamic_caching} = 1 if $line =~ m/^\s*\$mt->caching\s*=\s*true;/i; 
     8206            $param{dynamic_conditional} = 1 if $line =~ /^\s*\$mt->conditional\s*=\s*true;/i; 
     8207        } 
     8208        close $fh; 
     8209    } 
    82018210    $iter = MT::Template->load_iter({ blog_id => $blog->id }); 
    82028211    my(@tmpl); 
     
    1032110330                open(my $mv, "<$mtview_path"); 
    1032210331                while (my $line = <$mv>) { 
    10323                     $mv_contents .= "//$line" if ($line !~ /<\?(?:php)?|\?>/); 
     10332                    $mv_contents .= $line if ($line !~ m!^//|<\?(?:php)?|\?>!); 
    1032410333                } 
    1032510334                close $mv; 
     
    1033210341            my $cache_code = $cache ? "\n    \$mt->caching = true;" : ''; 
    1033310342            my $conditional_code = $conditional ? "\n    \$mt->conditional = true;" : ''; 
    10334             my $mtview = <<MTVIEW; 
    10335 <?php 
    10336 $mv_contents 
     10343            my $new_mtview = <<NEW_MTVIEW; 
     10344 
    1033710345    include('$mtphp_path'); 
    1033810346    \$mt = new MT($blog_id, '$config');$cache_code$conditional_code 
    1033910347    \$mt->view(); 
     10348NEW_MTVIEW 
     10349            if ($new_mtview ne substr($mv_contents, 0, length($new_mtview))) { 
     10350                $mv_contents =~ s!\n!\n//!gs; 
     10351                my $mtview = <<MTVIEW; 
     10352<?php 
     10353$new_mtview 
     10354$mv_contents 
    1034010355?> 
    1034110356MTVIEW 
    10342             $blog->file_mgr->mkpath($blog->site_path); 
    10343  
    10344             open(my $mv, ">$mtview_path") 
    10345                 || die "Couldn't open $mtview_path for appending"; 
    10346             print $mv $mtview || die "Couldn't write to $mtview_path"; 
    10347             close $mv; 
     10357 
     10358                $blog->file_mgr->mkpath($blog->site_path); 
     10359                open(my $mv, ">$mtview_path") 
     10360                    || die "Couldn't open $mtview_path for appending"; 
     10361                print $mv $mtview || die "Couldn't write to $mtview_path"; 
     10362                close $mv; 
     10363            } 
    1034810364        }; if ($@) { print STDERR $@; }  
    1034910365 
  • branches/wheeljack/tmpl/cms/cfg_archives.tmpl

    r873 r875  
    121121        } else { 
    122122            fld.style.display = 'block'; 
    123             TC.Client.call({ 
    124                 'load': function(c, response) { 
    125                     var result; 
    126                     try { 
    127                         result = eval('('+response+')'); 
    128                         var cache = getByID("dynamic_cache"); 
    129                         if (cache) 
    130                             cache.checked = result.cache; 
    131                         var condition = getByID("dynamic_conditional"); 
    132                         if (condition) 
    133                             condition.checked = result.conditional; 
    134                         var progress = getByID("progress-bar"); 
    135                         if (progress) { 
    136                             progress.style.display = "none"; 
    137                         } else { 
    138                         } 
    139                         var area = getByID('dynamic_options'); 
    140                         if (area) { 
    141                             area.style.display = "block"; 
    142                         } 
    143                     } catch ( e ) { 
    144                         alert(e.message); 
    145                     } 
    146                 }, 
    147                 'method': 'POST', 
    148                 'uri': '<TMPL_VAR NAME=MT_URL>', 
    149                 'arguments': { '__mode': 'js_check_mtview', 
    150                     'blog_id': '<TMPL_VAR NAME=BLOG_ID>', 
    151                     'magic_token': '<TMPL_VAR NAME=MAGIC_TOKEN>'} 
    152             }); 
    153123        } 
    154124    } 
     
    363333<option value="all"<TMPL_IF NAME=DYNAMIC_ALL> selected="selected"</TMPL_IF>><MT_TRANS phrase="Build all templates dynamically"></option> 
    364334</select> 
    365 <div id="dynamic_options_area" style="display:none;"> 
    366 <div id="progress-bar"><p><img src="<TMPL_VAR NAME=STATIC_URI>images/indeterminate-progress-bar.gif" alt="" height="24" width="124" /></p></div> 
    367 <div id="dynamic_options" style="display:none;"> 
     335<div id="dynamic_options_area"<TMPL_IF NAME=DYNAMIC_NONE> style="display:none;"</TMPL_IF>> 
    368336<p><MT_TRANS phrase="Optional Settings for Dynamic Publishing:"> <a href="#" onclick="return openManual('blog_settings_publishing', 'dynamic_publishing_options')" class="help">?</a></p> 
    369337<div class="field"> 
    370 <input type="checkbox" id="dynamic_cache" name="dynamic_cache" /><label for="dynamic_cache"><MT_TRANS phrase="Enable caching"></label> <input type="checkbox" id="dynamic_conditional" name="dynamic_conditional" /><label for="dynamic_conditional"><MT_TRANS phrase="Enable conditional retrieval"></label> 
     338<input type="checkbox" id="dynamic_cache" name="dynamic_cache" <TMPL_IF NAME=DYNAMIC_CACHING>checked="checked"</TMPL_IF>/><label for="dynamic_cache"><MT_TRANS phrase="Enable caching"></label> <input type="checkbox" id="dynamic_conditional" name="dynamic_conditional" <TMPL_IF NAME=DYNAMIC_CONDITIONAL>checked="checked"</TMPL_IF>/><label for="dynamic_conditional"><MT_TRANS phrase="Enable conditional retrieval"></label> 
    371339</div> 
    372340</div><a href="#" onclick="return openManual('blog_settings_publishing', 'dynamic_publishing')" class="help">?</a> 
    373 </div> 
    374341</div> 
    375342</TMPL_IF>