Show
Ignore:
Timestamp:
12/12/06 22:00:38 (2 years ago)
Author:
schst
Message:

Fixed bugs #164 and #165

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/patTemplate/InputFilter/ShortModifiers.php

    r409 r449  
    4343                            'copyVars' => true 
    4444                        ); 
    45      
     45 
    4646   /** 
    4747    * namespace 
     
    5151    */ 
    5252    var $_ns = null; 
    53      
     53 
    5454   /** 
    5555    * reference to the patTemplate object 
     
    7070        $this->_tmpl = &$tmpl; 
    7171    } 
    72      
     72 
    7373   /** 
    7474    * generate the <patTemplate:var/> tag 
     
    8080    function _generateReplace($matches) 
    8181    { 
    82         if ($this->getParam('copyVars') === true) { 
    83             $newName = $matches[2] . '_' . $matches[3]; 
    84             $replace = $matches[1] . '<' . $this->_ns . ':var copyFrom="' . $matches[2] . '" name="' . $newName . '" modifier="' . $matches[3] . '"'; 
    85         } else { 
     82        if ($this->getParam('copyVars') === true) { 
     83            $newName = $matches[2] . '_' . $matches[3]; 
     84            if (isset( $matches[4] )) { 
     85                $newName .= $matches[4]; 
     86            } 
     87            $replace = $matches[1] . '<' . $this->_ns . ':var copyFrom="' . $matches[2] . '" name="' . $newName . '" modifier="' . $matches[3] . '"'; 
     88        } else { 
    8689            $replace = $matches[1] . '<' . $this->_ns . ':var name="' . $matches[2] . '" modifier="' . $matches[3] . '"'; 
    87        } 
    88  
    89        for ($i = 4; $i < count($matches) - 1; $i++ ) { 
    90            $replace .= ' ' . $matches[++$i] . '="' . $matches[++$i] . '"'; 
    91        
    92        $replace .= '/>'; 
    93        return $replace; 
     90        } 
     91        $n = count($matches) - 1; 
     92        for ($i = 4; $i < $n; $i++ ) { 
     93            $replace .= ' ' . $matches[++$i] . '="' . $matches[++$i] . '"'; 
     94       
     95        $replace .= '/>'; 
     96        return $replace; 
    9497    } 
    9598 
     
    110113            $this->_ns = array_shift($this->_ns); 
    111114        } 
    112         $regex = "°([^\\\])" . $startTag . "([^a-z]+)\|(.+[^\\\])(\|(.+):(.+[^\\\]))*" . $endTag . "°U"; 
     115        $regex = chr( 1 ) . "([^\\\])" . $startTag . "([^a-z]+)\|(.+[^\\\])(\|(.+):(.+[^\\\]))*" . $endTag . chr( 1 ) . "U"; 
    113116        $data = preg_replace_callback($regex, array( $this, '_generateReplace' ), $data); 
    114117        return $data;