Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

ezmenubox.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: ezmenubox.php 6304 2001-07-29 23:31:17Z kaid $
5 //
6 // Definition of eZMenuBox class
7 //
8 // Created on: <23-Jan-2001 17:47:58 amos>
9 //
10 // This source file is part of Exponential Basic, publishing software.
11 //
12 // Copyright (C) 1999-2001 eZ Systems. All rights reserved.
13 //
14 // This program is free software; you can redistribute it and/or
15 // modify it under the terms of the GNU General Public License
16 // as published by the Free Software Foundation; either version 2
17 // of the License, or (at your option) any later version.
18 //
19 // This program is distributed in the hope that it will be useful,
20 // but WITHOUT ANY WARRANTY; without even the implied warranty of
21 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 // GNU General Public License for more details.
23 //
24 // You should have received a copy of the GNU General Public License
25 // along with this program; if not, write to the Free Software
26 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, US
27 //
28
31
42 // include_once( "kernel/classes/INIFile.php" );
43 // include_once( "kernel/classes/eztemplate.php" );
44
45 class eZMenuBox
46 {
47 function __construct()
48 {
49 }
50
61 static public function createBox( $ModuleName, $module_dir, $place, $SiteDesign,
62 &$menuItems, $print = true, $templatefile = false,
63 $phpfile = false, $ignore_status = false, $allow_module_template = false, $settingsModuleName = false )
64 {
65 // include_once( "kernel/ezsession/classes/ezpreferences.php" );
66 $preferences = new eZPreferences();
67
68 $ini =& eZINI::instance( 'site.ini' );
69
70 if ( $settingsModuleName == false )
71 {
72 if( str_contains($ModuleName, "Main") )
73 $settingsModuleName = $ModuleName;
74 else
75 $settingsModuleName = $ModuleName . "Main";
76 }
77 $settingsModuleName = str_replace( "MainMain", "", $settingsModuleName );
78 $Language = $ini->variable( $settingsModuleName, "Language" );
79
80 $menuStatus =& $preferences->variable( $module_dir . "_status" );
81
82 if ( empty( $menuStatus ) )
83 {
84 $menuStatus = "open";
85 }
86
87 if ( $ignore_status )
88 $menuStatus = "open";
89
90 $has_cache = false;
91 $uri = $_SERVER["REQUEST_URI"];
92 $up_uri = $uri;
93 $down_uri = $uri;
94 $up_uri =& eZHTTPTool::addVariable( $up_uri, "MoveUp", $module_dir );
95 $down_uri =& eZHTTPTool::addVariable( $down_uri, "MoveDown", $module_dir );
96 $uri =& eZHTTPTool::addVariable( $uri, "ToggleMenu", $module_dir );
97
98 $modified = false;
99 if ( $phpfile )
100 {
101 $modified = eZPBFile::filemtime( $phpfile );
102 }
103
104 $template_dir = "design/admin/templates/" . $SiteDesign;
105 if ( $allow_module_template )
106 {
107 $mod_dir = $ini->variable( $settingsModuleName, "AdminTemplateDir" );
108 $mod_dir = "$module_dir/admin/$mod_dir";
109 if ( file_exists( "$mod_dir/menubox.tpl" ) and
110 file_exists( "$mod_dir/menubox_closed.tpl" ) )
111 {
112 $template_dir = $mod_dir;
113 }
114 }
115
116 $t = new eZTemplate( $template_dir,
117 $module_dir . "/$place/intl", $Language, "menubox.php",
118 $SiteDesign, $module_dir . "/$place", $menuStatus, $modified );
119
120 if ( $menuStatus == "open" )
121 {
122 $menubox_file = "menubox.tpl";
123 }
124 else
125 {
126 $menubox_file = "menubox_closed.tpl";
127 }
128
129 if ( $templatefile )
130 $menubox_file = $templatefile;
131
132 $t->set_file( array(
133 "menu_box_tpl" => $menubox_file
134 ) );
135
136 if ( $t->hasCache() )
137 {
138 $has_cache = true;
139 $t->set_root( $t->cachePath() );
140 $t->set_file( "menu_box_tpl", $t->cacheFileName() );
141 }
142 else
143 {
144 if ( $menuStatus == "open" )
145 {
146
147 $t->set_block( "menu_box_tpl", "menu_item_tpl", "menu_item" );
148 $t->set_block( "menu_item_tpl", "menu_item_link_tpl", "menu_item_link" );
149 $t->set_block( "menu_item_tpl", "menu_item_break_tpl", "menu_item_break" );
150
151 $t->set_var( "site_style", $SiteDesign );
152 $t->set_var( "module_dir", $module_dir );
153
154 foreach ( $menuItems as $menuItem )
155 {
156 $t->set_var( "menu_item_link", "" );
157 $t->set_var( "menu_item_break", "" );
158 $error = false;
159 if ( is_array( $menuItem ) )
160 {
161 $t->set_var( "target_url", $menuItem[0] );
162 $t->set_var( "name", $menuItem[1] );
163
164 $t->parse( "menu_item_link", "menu_item_link_tpl", true );
165 }
166 else if ( is_string( $menuItem ) )
167 {
168 switch( $menuItem )
169 {
170 case "break":
171 {
172 $t->parse( "menu_item_break", "menu_item_break_tpl", true );
173 break;
174 }
175 default:
176 {
177 $error = true;
178 }
179 }
180 }
181 else
182 {
183 $error = true;
184 }
185
186 if ( $error )
187 {
188 print( "<h1>Unknown menubox item, \"" );
189 print_r( $menuItem );
190 print( "\"</h1><br />" );
191 }
192 $t->parse( "menu_item", "menu_item_tpl", true );
193 }
194 }
195 else
196 {
197 $t->set_var( "site_style", $SiteDesign );
198 $t->set_var( "module_dir", $module_dir );
199 }
200 $t->setAllStrings();
201 }
202
203 $str = '';
204 if ( $has_cache )
205 {
206 $t->set_var( "request_uri", $uri );
207 $t->set_var( "move_up_uri", $up_uri );
208 $t->set_var( "move_down_uri", $down_uri );
209 if ( $print )
210 $t->pparse( "output", "menu_box_tpl" );
211 else
212 $str = $t->parse( "output", "menu_box_tpl" );
213
214 return $str;
215 }
216 else
217 {
218 $t->storeCache( "output", "menu_box_tpl", false );
219 $t->clearVars( array( "menu_box_tpl" ) );
220 $t->set_var( "request_uri", $uri );
221 $t->set_var( "move_up_uri", $up_uri );
222 $t->set_var( "move_down_uri", $down_uri );
223 if ( $print )
224 $t->pparse( "output", "menu_box_tpl" );
225 else
226 $str =& $t->parse( "output", "menu_box_tpl" );
227 return $str;
228 }
229 return false;
230 }
231 };
232
233 ?>
$uri
$uri
Definition: activate.php:71
eZHTTPTool\addVariable
static & addVariable( $url, $variable, $value)
Definition: ezhttptool.php:124
eZMenuBox
Definition: ezmenubox.php:46
eZMenuBox\__construct
__construct()
Definition: ezmenubox.php:47
eZMenuBox\createBox
static createBox( $ModuleName, $module_dir, $place, $SiteDesign, &$menuItems, $print=true, $templatefile=false, $phpfile=false, $ignore_status=false, $allow_module_template=false, $settingsModuleName=false)
Definition: ezmenubox.php:61
eZPBFile\filemtime
static filemtime( $filename)
Definition: ezpbfile.php:306
eZPreferences
Definition: ezpreferences.php:62
eZTemplate
Definition: eztemplate.php:107
$t
foreach( $Modules as $module) if(isset( $ItemInsert)) $t
Definition: classes/admin/linklist.php:168
$preferences
$preferences
Definition: classes/admin/linklist.php:186
$Language
$Language
Definition: classes/admin/linklist.php:65
$ini
$ini
Definition: classes/admin/linklist.php:64
file_exists
static file_exists( $inifilename)
Definition: eZPBINIFile.php:195
$menuItems
$menuItems
Definition: ezabout/admin/menubox.php:31
$error
$error
Definition: ezarticle/admin/categoryedit.php:51
$str
$str
Definition: ezarticle/modules/content.php:30
$ModuleName
$ModuleName
Definition: ezarticle/user/searchsupplier.php:30
$SiteDesign
$SiteDesign
Definition: ezbulkmail/user/datasupplier.php:31
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.