Changeset 818

Show
Ignore:
Timestamp:
08/14/07 17:51:01 (1 year ago)
Author:
mikey
Message:

added basedir configuration

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/main/php/net/stubbles/websites/memphis/stubMemphisIncludeFilePageElement.php

    r803 r818  
    77 * @subpackage  websites_memphis 
    88 */ 
    9 stubClassLoader::load('net.stubbles.websites.memphis.stubMemphisPageElement'); 
     9stubClassLoader::load('net.stubbles.util.stubRegistry', 
     10                      'net.stubbles.websites.memphis.stubMemphisPageElement' 
     11); 
    1012/** 
    1113 * Page element for including a complete file as content. 
     
    2224     */ 
    2325    protected $source = ''; 
     26    /** 
     27     * base directory where content is located 
     28     * 
     29     * @var  string 
     30     */ 
     31    protected static $baseDir; 
     32 
     33    /** 
     34     * static initializing 
     35     */ 
     36    public static function __static() 
     37    { 
     38        self::$baseDir = stubRegistry::getConfig('net.stubbles.websites.memphis.templateDir', stubConfig::getLibPath() . '/../templates'); 
     39    } 
    2440 
    2541    /** 
     
    5470    public function process(stubRequest $request, stubSession $session, stubResponse $response, array $context = array()) 
    5571    { 
    56         if (file_exists($this->source) == false) { 
     72        $existsInBasePath = file_exists(self::$baseDir . DIRECTORY_SEPARATOR . $this->source); 
     73        if (false === $existsInBasePath && file_exists($this->source) === false) { 
    5774            throw new stubException('The file ' . $this->source . ' does not exist or could not be read.'); 
    5875        } 
    5976         
    60         return file_get_contents($this->source); 
     77        if (false === $existsInBasePath) { 
     78            return file_get_contents($this->source); 
     79        } 
     80         
     81        return file_get_contents(self::$baseDir . DIRECTORY_SEPARATOR . $this->source); 
    6182    } 
    6283}