Varien_Filter_Template_Tokenizer_Variable Class Reference

Inheritance diagram for Varien_Filter_Template_Tokenizer_Variable:

Varien_Filter_Template_Tokenizer_Abstract

List of all members.

Public Member Functions

 tokenize ()
 getString ()
 isNumeric ()
 isQuote ()
 getMethodArgs ()
 getNumber ()


Detailed Description

Definition at line 35 of file Variable.php.


Member Function Documentation

getMethodArgs (  ) 

Return array of arguments for method.

Returns:
array

Definition at line 150 of file Variable.php.

00150                                     {
00151         $value = array();
00152         $numberStr = '';
00153 
00154         while($this->next() && $this->char() != ')') {
00155             if($this->isWhiteSpace() || $this->char() == ',') {
00156                 continue;
00157             } else if($this->isNumeric()) {
00158                 $value[] = $this->getNumber();
00159             } else {
00160                 $value[] = $this->getString();
00161             }
00162         }
00163 
00164         return $value;
00165     }

getNumber (  ) 

Return number value for method args

Returns:
float

Definition at line 172 of file Variable.php.

00172                                 {
00173         $value = $this->char();
00174         while( ($this->isNumeric() || $this->char()=='.') && $this->next() ) {
00175             $value.= $this->char();
00176         }
00177 
00178         if(!$this->isNumeric()) {
00179             $this->prev();
00180         }
00181 
00182         return floatval($value);
00183     }

getString (  ) 

Get string value for method args

Returns:
string

Definition at line 94 of file Variable.php.

00094                                 {
00095 
00096         $value = '';
00097         if($this->isWhiteSpace()) {
00098             return $value;
00099         }
00100         $qouteStart = $this->isQuote();
00101 
00102         if($qouteStart) {
00103            $breakSymbol = $this->char();
00104         } else {
00105            $breakSymbol = false;
00106            $value .= $this->char();
00107         }
00108 
00109         while ($this->next()) {
00110             if (!$breakSymbol && ($this->isWhiteSpace() || $this->char() == ',' || $this->char() == ')') ) {
00111                 $this->prev();
00112                 break;
00113             } else if ($breakSymbol && $this->char() == $breakSymbol) {
00114                 break;
00115             } else if ($this->char() == '\\') {
00116                 $this->next();
00117                 $value .= $this->char();
00118             } else {
00119                 $value .= $this->char();
00120 
00121             }
00122         }
00123 
00124         return $value;
00125     }

isNumeric (  ) 

Return true if current char is a number

Returns:
boolean

Definition at line 132 of file Variable.php.

00132                                 {
00133         return $this->char() >= '0' && $this->char() <= '9';
00134     }

isQuote (  ) 

Return true if current char is qoute or apostroph

Returns:
boolean

Definition at line 141 of file Variable.php.

00141                               {
00142         return $this->char() == '"' || $this->char() == "'";
00143     }

tokenize (  ) 

Tokenize string and return getted variable stack path

Returns:
array

Reimplemented from Varien_Filter_Template_Tokenizer_Abstract.

Definition at line 43 of file Variable.php.

00044     {
00045         $actions = array();
00046         $parameterName = '';
00047         $variableSet = false;
00048         do {
00049             if($this->isWhiteSpace()) {
00050                 // Ignore white spaces
00051                 continue;
00052             } else if($this->char()!='.' && $this->char()!='(') {
00053                 // Property or method name
00054                 $parameterName .= $this->char();
00055             } else if($this->char()=='(') {
00056                 // Method declaration
00057                 $methodArgs = $this->getMethodArgs();
00058                 $actions[] = array('type'=>'method',
00059                                    'name'=>$parameterName,
00060                                    'args'=>$methodArgs);
00061                 $parameterName = '';
00062             } else if($parameterName!='') {
00063                 // Property or variable declaration
00064                 if($variableSet) {
00065                     $actions[] = array('type'=>'property',
00066                                        'name'=>$parameterName);
00067                 } else {
00068                     $variableSet = true;
00069                     $actions[] = array('type'=>'variable',
00070                                        'name'=>$parameterName);
00071                 }
00072                 $parameterName = '';
00073             }
00074         } while ($this->next());
00075 
00076         if($parameterName != '' ) {
00077             if($variableSet) {
00078                     $actions[] = array('type'=>'property',
00079                                        'name'=>$parameterName);
00080             } else {
00081                 $actions[] = array('type'=>'variable',
00082                                    'name'=>$parameterName);
00083             }
00084         }
00085 
00086         return $actions;
00087     }


The documentation for this class was generated from the following file:

Generated on Sat Jul 4 17:25:03 2009 for Magento by  doxygen 1.5.8