Show
Ignore:
Timestamp:
04/17/08 13:11:31 (20 months ago)
Author:
takayama
Message:

Fixed BugId:75137
* Changed to using cache_key for include cache directory

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/release-35/lib/MT/Blog.pm

    r1945 r1949  
    379379sub include_path_parts { 
    380380    my $blog = shift; 
    381     my ($name) = @_; 
    382  
    383     my $filestem = MT::Util::dirify($name); 
     381    my ($param) = @_; 
     382 
     383    my $filestem = MT::Util::dirify($param->{name}) || 'template_'.$param->{id}; 
    384384    my $filename = join q{.}, $filestem, $blog->file_extension; 
    385     return (MT->config('IncludesDir'), substr($filestem, 0, 3), $filename); 
     385    my $path = $param->{path} || ''; 
     386    my @path; 
     387    if ($path =~ m!^/!) { 
     388        # absolute 
     389        @path = split /\//, $path; 
     390    } else { 
     391        # relative 
     392        push @path, MT->config('IncludesDir'); 
     393        push @path, split /\//, $path; 
     394    } 
     395    return ($filename, @path); 
    386396} 
    387397 
    388398sub include_path { 
    389399    my $blog = shift; 
    390     my ($name) = @_; 
    391  
    392     my @parts = $blog->include_path_parts($name); 
    393     my $filename = pop @parts; 
    394     my $path = File::Spec->catdir($blog->site_path, @parts); 
    395     my $file_path = File::Spec->catfile($path, $filename); 
    396     return wantarray ? ($path, $file_path) : $file_path; 
     400 
     401    my ($filename, @path) = $blog->include_path_parts(@_); 
     402    my $extra_path = File::Spec->catdir(@path); 
     403    my $full_path = File::Spec->catdir($blog->site_path, $extra_path); 
     404    my $file_path = File::Spec->catfile($full_path, $filename); 
     405    return wantarray ? ($file_path, $full_path, $filename) : $file_path; 
    397406} 
    398407 
    399408sub include_url { 
    400409    my $blog = shift; 
    401     my ($name) = @_; 
    402  
    403     my @parts = $blog->include_path_parts(); 
    404     my $url = join q{/}, $blog->site_url, @parts; 
     410 
     411    my ($filename, @path) = $blog->include_path_parts(@_); 
     412    my $url = join q{/}, $blog->site_url, @path, $filename; 
    405413    return $url; 
    406414} 
     
    408416sub include_statement { 
    409417    my $blog = shift; 
    410     my ($name) = @_; 
    411418 
    412419    my $system = $blog->include_system or return; 
     
    416423        $statement = q{<!--#include virtual="%s" -->}; 
    417424 
     425        my ($filename, @path) = $blog->include_path_parts(@_); 
    418426        my $site_url = $blog->site_url; 
    419427        $site_url =~ s{ \A \w+ :// [^/]+ }{}xms; 
    420428        $site_url =~ s{ / \z }{}xms; 
    421         $include = join q{/}, $site_url, $blog->include_path_parts($name); 
     429        $include = join q{/}, $site_url, @path, $filename; 
    422430    } 
    423431    else { 
    424         $include = $blog->include_path($name); 
     432        $include = $blog->include_path(@_); 
    425433        $statement = $system eq 'php'   ? q{<?php include("%s") ?>} 
    426434                   : $system eq 'jsp'   ? q{<%@ include file="%s" %>}