Changeset 16094 for events

Show
Ignore:
Timestamp:
07/22/08 21:45:24 (5 years ago)
Author:
heavenshell
Message:

Update phtmlc ver 0.5

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • events/phpframework/zend_framework/trunk/library/Revulo/View/Phtmlc.php

    r15709 r16094  
    1616 * @copyright   2008 revulo 
    1717 * @license     http://www.opensource.org/licenses/bsd-license.php  New BSD License 
    18  * @version     Release: 0.4 
     18 * @version     Release: 0.5 
    1919 * @link        http://www.revulo.com/ZendFramework/Component/Phtmlc.html 
    2020 */ 
     
    2828 
    2929    /** 
    30      * Flag to compile template fragments into one phtml file 
     30     * Compile template fragments into one phtml file 
    3131     * @var     boolean 
    3232     */ 
     
    8484 
    8585    /** 
     86     * Sets the flag to compile template fragments into one phtml file. 
     87     * 
     88     * @param   boolean $flag 
     89     * @return  Revulo_View_Phtmlc 
     90     */ 
     91    public function compileFragments($flag = true) 
     92    { 
     93        $this->_compileFragments = ($flag) ? true : false; 
     94        return $this; 
     95    } 
     96 
     97    /** 
    8698     * Sets the directory path to compiled view scripts. 
    8799     * 
     
    91103    public function setCompilePath($path) 
    92104    { 
    93         $path = rtrim($path, '/\\') . DIRECTORY_SEPARATOR; 
     105        $path = rtrim($path, '/\\'); 
    94106        if (is_dir($path) && is_writable($path)) { 
    95107            $this->_compilePath = $path; 
     
    100112 
    101113    /** 
    102      * Sets the flag to compile template fragments into one phtml file. 
    103      * 
    104      * @param   boolean $flag 
    105      * @return  Revulo_View_Phtmlc 
    106      */ 
    107     public function compileFragments($flag = true) 
    108     { 
    109         $this->_compileFragments = ($flag) ? true : false; 
    110         return $this; 
     114     * Returns the directory path to compiled view scripts. 
     115     * 
     116     * @param   string  $path   Directory path to the view script 
     117     * @return  string 
     118     */ 
     119    protected function _getCompilePath($path) 
     120    { 
     121        if (isset($this->_compilePath)) { 
     122            if (class_exists('Zend_Controller_Front', false)) { 
     123                $module = Zend_Controller_Front::getInstance()->getRequest()->getModuleName(); 
     124                return $this->_compilePath . DIRECTORY_SEPARATOR . $module; 
     125            } else { 
     126                return $this->_compilePath; 
     127            } 
     128        } else { 
     129            return $this->_getDefaultCompilePath($path); 
     130        } 
    111131    } 
    112132 
     
    119139    protected function _getDefaultCompilePath($path) 
    120140    { 
    121         return dirname($path) . DIRECTORY_SEPARATOR . 'compile' . DIRECTORY_SEPARATOR; 
     141        return dirname($path) . DIRECTORY_SEPARATOR . 'compile'; 
    122142    } 
    123143 
     
    143163 
    144164        $filename = substr($filename, strlen($dir)); 
    145  
    146         if (isset($this->_compilePath)) { 
    147             return $this->_compilePath . $filename; 
    148         } else { 
    149             return $this->_getDefaultCompilePath($dir) . $filename; 
    150         } 
     165        return $this->_getCompilePath($dir) . DIRECTORY_SEPARATOR . $filename; 
    151166    } 
    152167 
     
    162177    protected function _read($filename) 
    163178    { 
    164         $buffer = trim(file_get_contents($filename)); 
     179        $buffer = file_get_contents($filename); 
    165180 
    166181        if ($this->_compileFragments === true) { 
     
    202217        } 
    203218 
    204         $pattern     = '/<\?=\s*(.*?)[;\s]*\?>/'; 
     219        $pattern     = '/<\?=\s*(.*?)[;\s]*\?>/s'; 
    205220        $replacement = '<?php echo ' . $escape . ' ?>'; 
    206221        return preg_replace($pattern, $replacement, $buffer);