Exponential 6.0.13 Exponential Enterprise Open Source CMS - PHP Class Reference

eztemplatemenufunction.php
Go to the documentation of this file.
1 <?php
17 class eZTemplateMenuFunction
18 {
19 public $BlockName;
25 public function __construct( $blockName = 'menu' )
26 {
27 $this->BlockName = $blockName;
28 }
29
34 function functionList()
35 {
36 return array( $this->BlockName );
37 }
38
39 function functionTemplateHints()
40 {
41 return array( $this->BlockName => array( 'parameters' => true,
42 'static' => false,
43 'transform-children' => false,
44 'tree-transformation' => true,
45 'transform-parameters' => true ) );
46 }
47
48 function templateNodeTransformation( $functionName, &$node,
49 $tpl, $parameters, $privateData )
50 {
51 if ( $functionName != $this->BlockName )
52 return false;
53
54 $parameters = eZTemplateNodeTool::extractFunctionNodeParameters( $node );
55
56 if ( !isset( $parameters['name'] ) )
57 return false;
58
59 $namespaceValue = false;
60 $newNodes = array();
61 if ( isset( $parameters["name"] ) )
62 {
63 $menuIni = eZINI::instance( "menu.ini" );
64 $nameData = $parameters["name"];
65 if ( !eZTemplateNodeTool::isConstantElement( $nameData ) )
66 return false;
67
68 $menuName = eZTemplateNodeTool::elementConstantValue( $nameData );
69
70 if ( $menuIni->hasVariable( 'SelectedMenu', $menuName ) )
71 {
72 $menuTemplate = $menuIni->variable( "SelectedMenu", $menuName );
73
74 if ( $menuTemplate != null )
75 {
76 $uriString = "design:menu/$menuTemplate.tpl";
77 $resourceName = "";
78 $templateName = "";
79 $resource = $tpl->resourceFor( $uriString, $resourceName, $templateName );
80 $resourceData = $tpl->resourceData( $resource, $uriString, $resourceName, $templateName );
81 $resourceData['use-comments'] = eZTemplateCompiler::isCommentsEnabled();
82
83 $includeNodes = $resource->templateNodeTransformation( $functionName, $node, $tpl, $resourceData, $parameters, $namespaceValue );
84 if ( $includeNodes === false )
85 return false;
86
87 $variableList = array();
88 foreach ( array_keys( $parameters ) as $parameterName )
89 {
90 if ( $parameterName == 'name' )
91 continue;
92 $parameterData =& $parameters[$parameterName];
93 $newNodes[] = eZTemplateNodeTool::createVariableNode( false, $parameterData, false, array(),
94 array( $namespaceValue, eZTemplate::NAMESPACE_SCOPE_RELATIVE, $parameterName ) );
95 $variableList[] = $parameterName;
96 }
97
98 $newNodes = array_merge( $newNodes, $includeNodes );
99
100 foreach ( $variableList as $variableName )
101 {
102 $newNodes[] = eZTemplateNodeTool::createVariableUnsetNode( array( $namespaceValue, eZTemplate::NAMESPACE_SCOPE_RELATIVE, $variableName ) );
103 }
104 }
105 else
106 {
107 // to do: not use this function to generate empty code.
108 $newNodes[] = eZTemplateNodeTool::createCodePieceNode( "" );
109 }
110 }
111 else
112 {
113 // to do: not use this function to generate empty code.
114 $newNodes[] = eZTemplateNodeTool::createCodePieceNode( "" );
115 }
116 }
117 return $newNodes;
118 }
119
123 function process( $tpl, &$textElements, $functionName, $functionChildren, $functionParameters, $functionPlacement, $rootNamespace, $currentNamespace )
124 {
125 $params = $functionParameters;
126 switch ( $functionName )
127 {
128 case $this->BlockName:
129 {
130 $name ="";
131 $menuIni = eZINI::instance( "menu.ini" );
132
133 if ( isset( $functionParameters["name"] ) )
134 {
135 $menuName = $tpl->elementValue( $functionParameters["name"], $rootNamespace, $currentNamespace, $functionPlacement );
136 if ( $menuIni->hasVariable( 'SelectedMenu', $menuName ) )
137 {
138 $menuTemplate = $menuIni->variable( 'SelectedMenu', $menuName );
139 if ( $menuTemplate != null )
140 {
141 $uri = "design:menu/$menuTemplate.tpl";
142 $tpl->processURI( $uri, true, $extraParameters, $textElements, $name, $name );
143 }
144 }
145 }
146 }
147 }
148 }
149
153 function hasChildren()
154 {
155 return false;
156 }
157 }
158
159 ?>
eZTemplateCompiler\isCommentsEnabled
static isCommentsEnabled()
Definition: eztemplatecompiler.php:124
eZTemplateMenuFunction
The class eZTemplateMenuFunction does.
Definition: eztemplatemenufunction.php:18
eZTemplateMenuFunction\templateNodeTransformation
templateNodeTransformation( $functionName, &$node, $tpl, $parameters, $privateData)
Definition: eztemplatemenufunction.php:48
eZTemplateMenuFunction\process
process( $tpl, &$textElements, $functionName, $functionChildren, $functionParameters, $functionPlacement, $rootNamespace, $currentNamespace)
Definition: eztemplatemenufunction.php:123
eZTemplateMenuFunction\$BlockName
$BlockName
Definition: eztemplatemenufunction.php:19
eZTemplateMenuFunction\functionList
functionList()
Definition: eztemplatemenufunction.php:34
eZTemplateMenuFunction\functionTemplateHints
functionTemplateHints()
Definition: eztemplatemenufunction.php:39
eZTemplateMenuFunction\__construct
__construct( $blockName='menu')
Definition: eztemplatemenufunction.php:25
eZTemplateMenuFunction\hasChildren
hasChildren()
Definition: eztemplatemenufunction.php:153
eZTemplateNodeTool\createVariableNode
static createVariableNode( $originalNode=false, $variableData=false, $variablePlacement=false, $parameters=array(), $variableAssignmentName=false, $onlyExisting=false, $overWrite=true, $assignFromVariable=false, $rememberSet=false)
Definition: eztemplatenodetool.php:395
eZTemplateNodeTool\elementConstantValue
static elementConstantValue( $elements)
Definition: eztemplatenodetool.php:197
eZTemplateNodeTool\createVariableUnsetNode
static createVariableUnsetNode( $variableName, $parameters=array())
Definition: eztemplatenodetool.php:462
eZTemplateNodeTool\createCodePieceNode
static createCodePieceNode( $codePiece, $parameters=array())
Definition: eztemplatenodetool.php:457
eZTemplateNodeTool\extractFunctionNodeParameters
static extractFunctionNodeParameters(&$node)
Definition: eztemplatenodetool.php:678
eZTemplateNodeTool\isConstantElement
static isConstantElement( $elements)
Definition: eztemplatenodetool.php:233
eZTemplate\NAMESPACE_SCOPE_RELATIVE
const NAMESPACE_SCOPE_RELATIVE
Definition: eztemplate.php:286
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.