|
TYPO3 API
SVNRelease
|
00001 <?php 00002 00003 /* * 00004 * This script belongs to the FLOW3 package "Fluid". * 00005 * * 00006 * It is free software; you can redistribute it and/or modify it under * 00007 * the terms of the GNU Lesser General Public License as published by the * 00008 * Free Software Foundation, either version 3 of the License, or (at your * 00009 * option) any later version. * 00010 * * 00011 * This script is distributed in the hope that it will be useful, but * 00012 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- * 00013 * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser * 00014 * General Public License for more details. * 00015 * * 00016 * You should have received a copy of the GNU Lesser General Public * 00017 * License along with the script. * 00018 * If not, see http://www.gnu.org/licenses/lgpl.html * 00019 * * 00020 * The TYPO3 project - inspiring people to share! * 00021 * */ 00022 00023 /** 00024 * Stores all information relevant for one parsing pass - that is, the root node, 00025 * and the current stack of open nodes (nodeStack) and a variable container used 00026 * for PostParseFacets. 00027 * 00028 * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later 00029 */ 00030 class Tx_Fluid_Core_Parser_ParsingState implements Tx_Fluid_Core_Parser_ParsedTemplateInterface { 00031 00032 /** 00033 * Root node reference 00034 * @var Tx_Fluid_Core_Parser_SyntaxTree_RootNode 00035 */ 00036 protected $rootNode; 00037 00038 /** 00039 * Array of node references currently open. 00040 * @var array 00041 */ 00042 protected $nodeStack = array(); 00043 00044 /** 00045 * Variable container where ViewHelpers implementing the PostParseFacet can 00046 * store things in. 00047 * @var Tx_Fluid_Core_ViewHelper_TemplateVariableContainer 00048 */ 00049 protected $variableContainer; 00050 00051 /** 00052 * Injects a variable container. ViewHelpers implementing the PostParse 00053 * Facet can store information inside this variableContainer. 00054 * 00055 * @param Tx_Fluid_Core_ViewHelper_TemplateVariableContainer $variableContainer 00056 * @return void 00057 * @author Sebastian Kurfürst <sebastian@typo3.org> 00058 */ 00059 public function setVariableContainer(Tx_Fluid_Core_ViewHelper_TemplateVariableContainer $variableContainer) { 00060 $this->variableContainer = $variableContainer; 00061 } 00062 00063 /** 00064 * Set root node of this parsing state 00065 * 00066 * @param Tx_Fluid_Core_Parser_SyntaxTree_AbstractNode $rootNode 00067 * @return void 00068 * @author Sebastian Kurfürst <sebastian@typo3.org> 00069 */ 00070 public function setRootNode(Tx_Fluid_Core_Parser_SyntaxTree_AbstractNode $rootNode) { 00071 $this->rootNode = $rootNode; 00072 } 00073 00074 /** 00075 * Get root node of this parsing state. 00076 * 00077 * @return Tx_Fluid_Core_Parser_SyntaxTree_AbstractNode The root node 00078 * @author Sebastian Kurfürst <sebastian@typo3.org> 00079 */ 00080 public function getRootNode() { 00081 return $this->rootNode; 00082 } 00083 00084 /** 00085 * Render the parsed template with rendering context 00086 * 00087 * @param Tx_Fluid_Core_Rendering_RenderingContextInterface $renderingContext The rendering context to use 00088 * @return Rendered string 00089 */ 00090 public function render(Tx_Fluid_Core_Rendering_RenderingContextInterface $renderingContext) { 00091 return $this->rootNode->evaluate($renderingContext); 00092 } 00093 00094 /** 00095 * Push a node to the node stack. The node stack holds all currently open 00096 * templating tags. 00097 * 00098 * @param Tx_Fluid_Core_Parser_SyntaxTree_AbstractNode $node Node to push to node stack 00099 * @return void 00100 * @author Sebastian Kurfürst <sebastian@typo3.org> 00101 */ 00102 public function pushNodeToStack(Tx_Fluid_Core_Parser_SyntaxTree_AbstractNode $node) { 00103 array_push($this->nodeStack, $node); 00104 } 00105 00106 /** 00107 * Get the top stack element, without removing it. 00108 * 00109 * @return Tx_Fluid_Core_Parser_SyntaxTree_AbstractNode the top stack element. 00110 * @author Sebastian Kurfürst <sebastian@typo3.org> 00111 */ 00112 public function getNodeFromStack() { 00113 return $this->nodeStack[count($this->nodeStack)-1]; 00114 } 00115 00116 /** 00117 * Pop the top stack element (=remove it) and return it back. 00118 * 00119 * @return Tx_Fluid_Core_Parser_SyntaxTree_AbstractNode the top stack element, which was removed. 00120 * @author Sebastian Kurfürst <sebastian@typo3.org> 00121 */ 00122 public function popNodeFromStack() { 00123 return array_pop($this->nodeStack); 00124 } 00125 00126 /** 00127 * Count the size of the node stack 00128 * 00129 * @return integer Number of elements on the node stack (i.e. number of currently open Fluid tags) 00130 * @author Sebastian Kurfürst <sebastian@typo3.org> 00131 */ 00132 public function countNodeStack() { 00133 return count($this->nodeStack); 00134 } 00135 00136 /** 00137 * Returns a variable container which will be then passed to the postParseFacet. 00138 * 00139 * @return Tx_Fluid_Core_ViewHelper_TemplateVariableContainer The variable container or NULL if none has been set yet 00140 * @author Sebastian Kurfürst <sebastian@typo3.org> 00141 * @todo Rename to getPostParseVariableContainer 00142 */ 00143 public function getVariableContainer() { 00144 return $this->variableContainer; 00145 } 00146 } 00147 ?>
1.8.0