Changeset 259

Show
Ignore:
Timestamp:
02/14/07 16:50:20 (2 years ago)
Author:
mikey
Message:

added static setIncludePath()
bugfix: create cache path if it does not exist
bugfix in appendError(): do not append into the xpointer part if it could not be found, use document root instead

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/main/php/net/stubbles/xml/stubXMLXIncludeStreamWrapper.php

    r207 r259  
    3535    protected static $cachePath; 
    3636    /** 
     37     * include path to use if file not found in current path 
     38     * 
     39     * @var  string 
     40     */ 
     41    protected static $includePath; 
     42    /** 
    3743     * current xml file 
    3844     * 
     
    8793    /** 
    8894     * sets the cache path to use 
     95     *  
     96     * @param  string  $cachePath 
    8997     */ 
    9098    public static function setCachePath($cachePath) 
    9199    { 
    92100        self::$cachePath = $cachePath; 
     101        if (file_exists($cachePath . '/xml') == false) { 
     102            mkdir($cachePath . '/xml', 0700, true); 
     103        } 
     104    } 
     105     
     106    /** 
     107     * sets the include path to use 
     108     * 
     109     * @param  string  $includePath 
     110     */ 
     111    public static function setIncludePath($includePath) 
     112    { 
     113        self::$includePath = $includePath; 
    93114    } 
    94115 
     
    106127        $this->parsePath($path); 
    107128        if (file_exists($this->fileName) == false) { 
    108             return false; 
     129            if (file_exists(self::$includePath . '/' . $this->fileName) == false) { 
     130                return false; 
     131            } 
     132             
     133            $this->fileName = self::$includePath . '/' . $this->fileName; 
    109134        } 
    110135         
     
    170195    protected function appendError(DOMDocument $resultDoc, $level, $message) 
    171196    { 
    172         $element = $resultDoc->createElement('stub:error', ucfirst($level) . ': ' . $message); 
    173         $element->setAttribute('stub:errorType', $level); 
     197        $element = $resultDoc->createElement('error', ucfirst($level) . ': ' . $message); 
     198        $element->setAttribute('errorType', $level); 
    174199        if (null != $this->part && strlen($this->part) > 0) { 
    175200            $xpath = new DOMXPath($resultDoc); 
    176201            $entry = $xpath->query("/parts/part[@name='" . $this->part ."']")->item(0); 
    177             $entry->appendChild($element); 
     202            if (null !== $entry) { 
     203                $entry->appendChild($element); 
     204            } else { 
     205                $resultDoc->documentElement->appendChild($element); 
     206            } 
    178207        } else { 
    179208            $resultDoc->documentElement->appendChild($element);