Exponential 6.0.13 Exponential Enterprise Open Source CMS - PHP Class Reference

eztopmenuoperator.php
Go to the documentation of this file.
1 <?php
18 class eZTopMenuOperator
19 {
25 public function __construct( $name = 'topmenu' )
26 {
27 $this->Operators = array( $name );
28 $this->DefaultNames = array(
29 'content' => array( 'name' => ezpI18n::tr( 'design/admin/pagelayout',
30 'Content structure' ),
31 'tooltip'=> ezpI18n::tr( 'design/admin/pagelayout',
32 'Manage the main content structure of the site.' ) ),
33 'media' => array( 'name' => ezpI18n::tr( 'design/admin/pagelayout',
34 'Media library' ),
35 'tooltip'=> ezpI18n::tr( 'design/admin/pagelayout',
36 'Manage images, files, documents, etc.' ) ),
37 'users' => array( 'name' => ezpI18n::tr( 'design/admin/pagelayout',
38 'User accounts' ),
39 'tooltip'=> ezpI18n::tr( 'design/admin/pagelayout',
40 'Manage users, user groups and permission settings.' ) ),
41 'shop' => array( 'name' => ezpI18n::tr( 'design/admin/pagelayout',
42 'Webshop' ),
43 'tooltip'=> ezpI18n::tr( 'design/admin/pagelayout',
44 'Manage customers, orders, discounts and VAT types; view sales statistics.' ) ),
45 'design' => array( 'name' => ezpI18n::tr( 'design/admin/pagelayout',
46 'Design' ),
47 'tooltip'=> ezpI18n::tr( 'design/admin/pagelayout',
48 'Manage templates, menus, toolbars and other things related to appearence.' ) ),
49 'setup' => array( 'name' => ezpI18n::tr( 'design/admin/pagelayout',
50 'Setup' ),
51 'tooltip'=> ezpI18n::tr( 'design/admin/pagelayout',
52 'Configure settings and manage advanced functionality.' ) ),
53 'dashboard' => array( 'name' => ezpI18n::tr( 'design/admin/pagelayout',
54 'Dashboard' ),
55 'tooltip'=> ezpI18n::tr( 'design/admin/pagelayout',
56 'Manage items and settings that belong to your account.' ) ) );
57 }
58
62 function operatorList()
63 {
64 return $this->Operators;
65 }
66
70 function namedParameterList()
71 {
72 return array( 'context' => array( 'type' => 'string',
73 'required' => true,
74 'default' => 'content' ),
75 'filter_on_access' => array( 'type' => 'bool',
76 'required' => false,
77 'default' => false ) );
78 }
79
80 function modify( $tpl, $operatorName, $operatorParameters, $rootNamespace, $currentNamespace, &$operatorValue, $namedParameters, $placement )
81 {
82
83 $ini = eZINI::instance( 'menu.ini' );
84
85 if ( !$ini->hasVariable( 'TopAdminMenu', 'Tabs' ) )
86 {
87 eZDebug::writeError( 'Top Admin menu is not configured. Ini setting [TopAdminMenu] Tabs[] is missing' );
88 $operatorValue = array();
89 return;
90 }
91
92 $menu = array();
93 $context = $namedParameters['context'];
94 $tabIDs = $ini->variable( 'TopAdminMenu', 'Tabs' );
95 foreach ( $tabIDs as $tabID )
96 {
97 $shownList = $ini->variable( 'Topmenu_' . $tabID , 'Shown' );
98 if ( isset( $shownList[$context] ) && $shownList[$context] === 'false' )
99 {
100 continue;
101 }
102
103 $menuItem = array();
104 $menuItem['access'] = true;
105 if ( $ini->hasVariable( 'Topmenu_' . $tabID , 'PolicyList' ) )
106 {
107 $policyList = $ini->variable( 'Topmenu_' . $tabID , 'PolicyList' );
108 foreach( $policyList as $policy )
109 {
110 // Value is either "<node_id>" or "<module>/<function>"
111 if ( strpos( $policy, '/' ) !== false )
112 {
113 if ( !isset( $user ) )
114 $user = eZUser::currentUser();
115
116 list( $module, $function ) = explode( '/', $policy );
117 $result = $user->hasAccessTo( $module, $function );
118
119 if ( $result['accessWord'] === 'no' )
120 {
121 $menuItem['access'] = false;
122 break;
123 }
124 }
125 else
126 {
127 $node = eZContentObjectTreeNode::fetch( $policy );
128 if ( !$node instanceof eZContentObjectTreeNode || !$node->attribute('can_read') )
129 {
130 $menuItem['access'] = false;
131 break;
132 }
133 }
134 }
135 }
136
137 if ( $namedParameters['filter_on_access'] && !$menuItem['access'] )
138 {
139 continue;
140 }
141
142 $urlList = $ini->variable( 'Topmenu_' . $tabID , 'URL' );
143 if ( isset( $urlList[$context] ) )
144 {
145 $menuItem['url'] = $urlList[$context];
146 }
147 else
148 {
149 $menuItem['url'] = $urlList['default'];
150 }
151
152 $enabledList = $ini->variable( 'Topmenu_' . $tabID , 'Enabled' );
153 if ( isset( $enabledList[$context] ) )
154 {
155 if ( $enabledList[$context] == 'true' )
156 $menuItem['enabled'] = true;
157 else
158 $menuItem['enabled'] = false;
159 }
160 else
161 {
162 if ( $enabledList['default'] == true )
163 $menuItem['enabled'] = true;
164 else
165 $menuItem['enabled'] = false;
166 }
167
168 if ( $ini->hasVariable( 'Topmenu_' . $tabID , 'Name' ) && $ini->variable( 'Topmenu_' . $tabID , 'Name' ) != '' )
169 {
170 $menuItem['name'] = $ini->variable( 'Topmenu_' . $tabID , 'Name' );
171 }
172 else
173 {
174 $menuItem['name'] = $this->DefaultNames[$tabID]['name'];
175 }
176
177 if ( $ini->hasVariable( 'Topmenu_' . $tabID , 'Tooltip' ) && $ini->variable( 'Topmenu_' . $tabID , 'Tooltip' ) != '' )
178 {
179 $menuItem['tooltip'] = $ini->variable( 'Topmenu_' . $tabID , 'Tooltip' );
180 }
181 else
182 {
183 $menuItem['tooltip'] = isset( $this->DefaultNames[$tabID]['tooltip'] ) ? $this->DefaultNames[$tabID]['tooltip'] : '';
184 }
185
186 $menuItem['navigationpart_identifier'] = $ini->variable( 'Topmenu_' . $tabID , 'NavigationPartIdentifier' );
187 $menuItem['position'] = 'middle';
188 $menu[] = $menuItem;
189
190 }
191 $menu[0]['position'] = 'first';
192 $menu[count($menu) - 1]['position'] = 'last';
193
194 $operatorValue = $menu;
195 }
196
198 public $Operators;
199 public $DefaultNames;
200 }
201
202
203 ?>
eZContentObjectTreeNode
Definition: ezcontentobjecttreenode.php:17
eZContentObjectTreeNode\fetch
static fetch( $nodeID=false, $lang=false, $asObject=true, $conditions=false)
Definition: ezcontentobjecttreenode.php:3058
eZDebug\writeError
static writeError( $string, $label="", $backgroundClass="")
Definition: ezdebug.php:545
eZPersistentObject\attribute
attribute( $attr, $noFunction=false)
Definition: ezpersistentobject.php:1329
eZTopMenuOperator
The class eZTopMenuOperator does.
Definition: eztopmenuoperator.php:19
eZTopMenuOperator\operatorList
operatorList()
Definition: eztopmenuoperator.php:62
eZTopMenuOperator\modify
modify( $tpl, $operatorName, $operatorParameters, $rootNamespace, $currentNamespace, &$operatorValue, $namedParameters, $placement)
Definition: eztopmenuoperator.php:80
eZTopMenuOperator\$DefaultNames
$DefaultNames
Definition: eztopmenuoperator.php:199
eZTopMenuOperator\__construct
__construct( $name='topmenu')
Definition: eztopmenuoperator.php:25
eZTopMenuOperator\namedParameterList
namedParameterList()
Definition: eztopmenuoperator.php:70
eZTopMenuOperator\$Operators
$Operators
Definition: eztopmenuoperator.php:198
eZUser\currentUser
static currentUser()
Definition: ezuser.php:1716
ezpI18n\tr
static tr( $context, $source, $comment=null, $arguments=null)
Definition: ezpi18n.php:86
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.