Changeset 1949 for branches/release-35/lib/MT/Template/ContextHandlers.pm
- Timestamp:
- 04/17/08 13:11:31 (20 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
branches/release-35/lib/MT/Template/ContextHandlers.pm
r1926 r1949 2328 2328 my $blog = $ctx->stash('blog') || MT->model('blog')->load($blog_id); 2329 2329 2330 my %include_recipe; 2330 2331 my $use_ssi = $blog && $blog->include_system 2331 2332 && ($arg->{ssi} || $tmpl->include_with_ssi) ? 1 : 0; … … 2334 2335 # easiest way to determine this is from the variable 2335 2336 # space setting. 2336 $use_ssi = 0 if $ctx->var('system_template'); 2337 if ($ctx->var('system_template')) { 2338 $use_ssi = 0; 2339 } else { 2340 my $extra_path = $arg->{cache_key} ? $arg->{cache_key} 2341 : $tmpl->cache_path ? $tmpl->cache_path 2342 : ''; 2343 %include_recipe = ( 2344 name => $tmpl_name, 2345 id => $tmpl->id, 2346 path => $extra_path, 2347 ); 2348 } 2337 2349 } 2338 2350 … … 2342 2354 && $blog->include_cache 2343 2355 && ( ( $arg->{cache} && $arg->{cache} > 0 ) 2344 || $arg->{ key}2356 || $arg->{cache_key} 2345 2357 || ( exists $arg->{ttl} ) 2346 2358 || $tmpl->use_cache ) ? 1 : 0; 2347 2359 my $cache_key = 2348 $arg->{ key}2349 ? $arg->{ key}2360 $arg->{cache_key} 2361 ? $arg->{cache_key} 2350 2362 : 'blog::' . $blog_id . '::template_' . $type . '::' . $tmpl_name; 2351 2363 my $ttl = … … 2362 2374 if ($use_ssi) { 2363 2375 # base cache expiration on physical file timestamp 2364 my $include_ name = $arg->{key} || $tmpl_name;2365 my $mtime = (stat($ blog->include_path($include_name)))[9];2376 my $include_file = $blog->include_path(\%include_recipe); 2377 my $mtime = (stat($include_file))[9]; 2366 2378 if ($mtime && (MT::Util::ts2epoch(undef, $latest) > $mtime ) ) { 2367 2379 $ttl = 1; # bound to force an update … … 2388 2400 return $cache_value if !$use_ssi; 2389 2401 2390 my $include_name = $arg->{key} || $tmpl_name;2391 2402 # The template may still be cached from before we were using SSI 2392 2403 # for this template, so check that it's also on disk. 2393 my ($path, $file_path) = $blog->include_path($include_name);2394 if ($blog->file_mgr->exists($ file_path)) {2395 return $blog->include_statement( $include_name);2404 my $include_file = $blog->include_path(\%include_recipe); 2405 if ($blog->file_mgr->exists($include_file)) { 2406 return $blog->include_statement(\%include_recipe); 2396 2407 } 2397 2408 } … … 2424 2435 2425 2436 if ($use_ssi) { 2426 my $include_name = $arg->{key} || $tmpl_name; 2437 my ($include_file, $path, $filename) = 2438 $blog->include_path(\%include_recipe); 2427 2439 my $fmgr = $blog->file_mgr; 2428 my ($path, $file_path) = $blog->include_path($include_name);2429 2440 if (!$fmgr->exists($path)) { 2430 2441 if (!$fmgr->mkpath($path)) { … … 2433 2444 } 2434 2445 } 2435 defined($fmgr->put_data($ret, $ file_path))2446 defined($fmgr->put_data($ret, $include_file)) 2436 2447 or return $ctx->error(MT->translate("Writing to '[_1]' failed: [_2]", 2437 $ file_path, $fmgr->errstr));2448 $include_file, $fmgr->errstr)); 2438 2449 2439 2450 MT->upload_file_to_sync( 2440 url => $blog->include_url( $include_name),2441 file => $ file_path,2451 url => $blog->include_url(\%include_recipe), 2452 file => $include_file, 2442 2453 blog => $blog, 2443 2454 ); 2444 2455 2445 return $blog->include_statement($include_name); 2456 my $stat = $blog->include_statement(\%include_recipe); 2457 return $stat; 2446 2458 } 2447 2459
