| [ Index ] |
|
Code source de eZ Publish 3.9.0 |
1 <?php 2 // 3 // Definition of eZTemplateMenuFunction class 4 // 5 // Created on: <10-Mar-2004 15:34:50 wy> 6 // 7 // SOFTWARE NAME: eZ publish 8 // SOFTWARE RELEASE: 3.9.0 9 // BUILD VERSION: 17785 10 // COPYRIGHT NOTICE: Copyright (C) 1999-2006 eZ systems AS 11 // SOFTWARE LICENSE: GNU General Public License v2.0 12 // NOTICE: > 13 // This program is free software; you can redistribute it and/or 14 // modify it under the terms of version 2.0 of the GNU General 15 // Public License as published by the Free Software Foundation. 16 // 17 // This program is distributed in the hope that it will be useful, 18 // but WITHOUT ANY WARRANTY; without even the implied warranty of 19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 // GNU General Public License for more details. 21 // 22 // You should have received a copy of version 2.0 of the GNU General 23 // Public License along with this program; if not, write to the Free 24 // Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 25 // MA 02110-1301, USA. 26 // 27 // 28 29 /*! \file eztemplatemenufunction.php 30 */ 31 32 /*! 33 \class eZTemplateMenuFunction eztemplatemenufunction.php 34 \brief The class eZTemplateMenuFunction does 35 36 */ 37 38 class eZTemplateMenuFunction 39 { 40 /*! 41 Initializes the object with names. 42 */ 43 function eZTemplateMenuFunction( $blockName = 'menu' ) 44 { 45 $this->BlockName = $blockName; 46 } 47 48 /*! 49 Returns an array containing the name of the block function, default is "block". 50 The name is specified in the constructor. 51 */ 52 function functionList() 53 { 54 return array( $this->BlockName ); 55 } 56 57 function functionTemplateHints() 58 { 59 return array( $this->BlockName => array( 'parameters' => true, 60 'static' => false, 61 'transform-children' => false, 62 'tree-transformation' => true, 63 'transform-parameters' => true ) ); 64 } 65 66 function templateNodeTransformation( $functionName, &$node, 67 &$tpl, $parameters, $privateData ) 68 { 69 if ( $functionName != $this->BlockName ) 70 return false; 71 72 $parameters = eZTemplateNodeTool::extractFunctionNodeParameters( $node ); 73 74 if ( !isset( $parameters['name'] ) ) 75 return false; 76 77 $namespaceValue = false; 78 $newNodes = array(); 79 if ( isset( $parameters["name"] ) ) 80 { 81 $menuIni =& eZINI::instance( "menu.ini" ); 82 $nameData = $parameters["name"]; 83 if ( !eZTemplateNodeTool::isStaticElement( $nameData ) ) 84 return false; 85 86 $menuName = eZTemplateNodeTool::elementStaticValue( $nameData ); 87 88 if ( $menuIni->hasVariable( 'SelectedMenu', $menuName ) ) 89 { 90 $menuTemplate = $menuIni->variable( "SelectedMenu", $menuName ); 91 92 if ( $menuTemplate != null ) 93 { 94 $uriString = "design:menu/$menuTemplate.tpl"; 95 $resourceName = ""; 96 $templateName = ""; 97 $resource =& $tpl->resourceFor( $uriString, $resourceName, $templateName ); 98 $resourceData = $tpl->resourceData( $resource, $uriString, $resourceName, $templateName ); 99 $resourceData['use-comments'] = eZTemplateCompiler::isCommentsEnabled(); 100 101 $includeNodes = $resource->templateNodeTransformation( $functionName, $node, $tpl, $resourceData, $parameters, $namespaceValue ); 102 if ( $includeNodes === false ) 103 return false; 104 105 $variableList = array(); 106 foreach ( array_keys( $parameters ) as $parameterName ) 107 { 108 if ( $parameterName == 'name' ) 109 continue; 110 $parameterData =& $parameters[$parameterName]; 111 $newNodes[] = eZTemplateNodeTool::createVariableNode( false, $parameterData, false, array(), 112 array( $namespaceValue, EZ_TEMPLATE_NAMESPACE_SCOPE_RELATIVE, $parameterName ) ); 113 $variableList[] = $parameterName; 114 } 115 116 $newNodes = array_merge( $newNodes, $includeNodes ); 117 118 foreach ( $variableList as $variableName ) 119 { 120 $newNodes[] = eZTemplateNodeTool::createVariableUnsetNode( array( $namespaceValue, EZ_TEMPLATE_NAMESPACE_SCOPE_RELATIVE, $variableName ) ); 121 } 122 } 123 else 124 { 125 // to do: not use this function to generate empty code. 126 $newNodes[] = eZTemplateNodeTool::createCodePieceNode( "" ); 127 } 128 } 129 else 130 { 131 // to do: not use this function to generate empty code. 132 $newNodes[] = eZTemplateNodeTool::createCodePieceNode( "" ); 133 } 134 } 135 return $newNodes; 136 } 137 138 /*! 139 Processes the function with all it's children. 140 */ 141 function process( &$tpl, &$textElements, $functionName, $functionChildren, $functionParameters, $functionPlacement, $rootNamespace, $currentNamespace ) 142 { 143 $params = $functionParameters; 144 switch ( $functionName ) 145 { 146 case $this->BlockName: 147 { 148 $name =""; 149 $menuIni =& eZINI::instance( "menu.ini" ); 150 151 if ( isset( $functionParameters["name"] ) ) 152 { 153 $menuName = $tpl->elementValue( $functionParameters["name"], $rootNamespace, $currentNamespace, $functionPlacement ); 154 if ( $menuIni->hasVariable( 'SelectedMenu', $menuName ) ) 155 { 156 $menuTemplate = $menuIni->variable( 'SelectedMenu', $menuName ); 157 if ( $menuTemplate != null ) 158 { 159 $uri = "design:menu/$menuTemplate.tpl"; 160 $tpl->processURI( $uri, true, $extraParameters, $textElements, $name, $name ); 161 } 162 } 163 } 164 } 165 } 166 } 167 168 /*! 169 Returns false. 170 */ 171 function hasChildren() 172 { 173 return false; 174 } 175 } 176 177 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
| Généré le : Sat Feb 24 10:30:04 2007 | par Balluche grâce à PHPXref 0.7 |