Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

ezmenu.php
Go to the documentation of this file.
1 <?
3 //
4 // $Id: ezmenu.php 7507 2001-09-27 10:43:55Z ce $
5 //
6 // eZMenu class
7 //
8 // Christoffer A. Elo <ce@ez.no>
9 // Created on: <27-Sep-2001 10:24:02 ce>
10 //
11 // This source file is part of Exponential Basic, publishing software.
12 // Copyright (C) 1999-2001 eZ systems as
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
39 // include_once( "eztrade/classes/ezvoucher.php" );
40 // include_once( "eztrade/classes/ezpreorder.php" );
41
42 // include_once( "ezaddress/classes/ezonline.php" );
43
44 class eZMenu
45 {
52 function __construct( $id=-1 )
53 {
54 $this->Type = 0;
55 if ( is_array( $id ) )
56 {
57 $this->fill( $id );
58 }
59 else if ( $id != -1 )
60 {
61 $this->ID = $id;
62 $this->get( $this->ID );
63 }
64 }
65
69 function store()
70 {
71 $db =& eZDB::globalDatabase();
72 $db->begin();
73
74 $name =& $db->escapeString( $this->Name );
75 $link =& $db->escapeString( $this->Link );
76
77 if ( !isset( $this->ID ) )
78 {
79 $db->lock( "eZSiteManager_Menu" );
80 $nextID = $db->nextID( "eZSiteManager_Menu", "ID" );
81 $query = "INSERT INTO eZSiteManager_Menu
82 ( ID, Name, Link, Type, ParentID )
83 VALUES
84 ( '$nextID',
85 '$name',
86 '$link',
87 '$this->Type',
88 '$this->ParentID'
89 )
90 ";
91
92 $res = $db->query( $query );
93
94 $this->ID = $nextID;
95 }
96 elseif ( is_numeric( $this->ID ) )
97 {
98 $res = $db->query( "UPDATE eZSiteManager_Menu SET
99 Name='$name',
100 Link='$link',
101 Type='$this->Type',
102 ParentID='$this->ParentID'
103 WHERE ID='$this->ID'" );
104 }
105 $db->unlock();
106
107 if ( $res == false )
108 $db->rollback( );
109 else
110 $db->commit();
111
112 return true;
113 }
114
118 function delete( $catID=-1 )
119 {
120 $ret = false;
121 if ( $catID == -1 )
122 $catID = $this->ID;
123
124 $db =& eZDB::globalDatabase();
125 $db->begin();
126
127 $ret = $db->query( "DELETE FROM eZSiteManager_Menu WHERE ID='$this->ID'" );
128
129 if ( $ret == false )
130 $db->rollback( );
131 else
132 $db->commit();
133 }
134
140 function get( $id=-1 )
141 {
142 $db =& eZDB::globalDatabase();
143
144 $ret = false;
145 if ( $id != "" )
146 {
147 $db->array_query( $quizArray, "SELECT * FROM eZSiteManager_Menu WHERE ID='$id'",
148 0, 1 );
149 if( count( $quizArray ) == 1 )
150 {
151 $this->fill( $quizArray[0] );
152 $ret = true;
153 }
154 elseif( count( $quizArray ) == 1 )
155 {
156 $this->ID = 0;
157 }
158 }
159 return $ret;
160 }
161
165 function fill( &$value )
166 {
167 $db =& eZDB::globalDatabase();
168 $this->ID =& $value[$db->fieldName( "ID" )];
169 $this->Name =& $value[$db->fieldName( "Name" )];
170 $this->Link =& $value[$db->fieldName( "Link" )];
171 $this->Type =& $value[$db->fieldName( "Type" )];
172 $this->ParentID =& $value[$db->fieldName( "ParentID" )];
173 }
174
180 static public function &getAll( $offset=0, $limit=20 )
181 {
182 $db =& eZDB::globalDatabase();
183
184 $returnArray = array();
185 $quizArray = array();
186
187 $db->array_query( $quizArray, "SELECT ID
188 FROM eZSiteManager_Menu
189 ORDER BY Type DESC",
190 array( "Limit" => $limit,
191 "Offset" => $offset ) );
192
193 for ( $i=0; $i < count($quizArray); $i++ )
194 {
195 $returnArray[$i] = new eZMenu( $quizArray[$i][$db->fieldName( "ID" )] );
196 }
197
198 return $returnArray;
199 }
200
206 static public function &getByParent( $parent=0, $offset=0, $limit=20 )
207 {
208 $parentID = 0;
209 $db =& eZDB::globalDatabase();
210
211 $returnArray = array();
212 $quizArray = array();
213
214 if ( is_a( $parent, "eZMenu" ) )
215 $parentID = $parent->id();
216 elseif ( is_numeric( $parent ) )
217 $parentID = $parent;
218
219 $db->array_query( $quizArray, "SELECT ID
220 FROM eZSiteManager_Menu
221 WHERE ParentID='$parentID' ORDER BY Type DESC",
222 array( "Limit" => $limit,
223 "Offset" => $offset ) );
224
225 for ( $i=0; $i < count($quizArray); $i++ )
226 {
227 $returnArray[$i] = new eZMenu( $quizArray[$i][$db->fieldName( "ID" )] );
228 }
229
230 return $returnArray;
231 }
232
236 static public function count( $parent=0 )
237 {
238 $parentID = 0;
239 $db =& eZDB::globalDatabase();
240 $ret = false;
241
242 if ( is_a( $parent, "eZMenu" ) )
243 $parentID = $parent->id();
244 else if ( is_numeric ( $parent ) )
245 $parentID = $parent;
246
247 $db->query_single( $result, "SELECT COUNT(ID) as Count
248 FROM eZSiteManager_Menu WHERE ParentID='$parentID'" );
249 $ret = $result[$db->fieldName( "Count" )];
250 return $ret;
251 }
252
260 function &path( $menuID=0 )
261 {
262 if ( $menuID == 0 )
263 {
264 $menuID = $this->ID;
265 }
266
267 $menu = new eZMenu( $menuID );
268
269 $path = array();
270
271 $parent = $menu->parent();
272 if ( $parent != 0 )
273 {
274 $path = array_merge( $path, $this->path( $parent->id() ) );
275
276 }
277 else
278 {
279 // array_push( $path, $category->name() );
280 }
281
282 if ( $menuID != 0 )
283 array_push( $path, array( $menu->id(), $menu->name() ) );
284
285 return $path;
286 }
287
288
292 function id()
293 {
294 return $this->ID;
295 }
296
300 function &name()
301 {
302 return $this->Name;
303 }
304
308 function setName( &$value )
309 {
310 $this->Name = $value;
311 }
312
316 function &link()
317 {
318 return $this->Link;
319 }
320
324 function setLink( &$value )
325 {
326 $this->Link = $value;
327 }
328
332 function setParent( &$value )
333 {
334 if ( is_a( $value, "eZMenu" ) )
335 $this->ParentID = $value->id();
336 else if ( is_numeric ( $value ) )
337 $this->ParentID = $value;
338 }
339
343 function parent( )
344 {
345 if ( $this->ParentID != 0 )
346 {
347 return new eZMenu( $this->ParentID );
348 }
349 else
350 {
351 return 0;
352 }
353 }
354
360 function type( )
361 {
362 return $this->Type;
363 }
364
370 function setType( $value )
371 {
372 $this->Type = $value;
373 }
374
375 var $ID;
376 var $Name;
377 var $Link;
378 var $Type;
379 var $ParentID;
380 }
381
382 ?>
$i
$i
Definition: admin/adlist.php:91
eZDB\globalDatabase
static & globalDatabase()
Definition: ezdb.php:134
eZMenu
Definition: ezmenu.php:45
eZMenu\setParent
setParent(&$value)
Definition: ezmenu.php:332
eZMenu\getByParent
static & getByParent( $parent=0, $offset=0, $limit=20)
Definition: ezmenu.php:206
eZMenu\store
store()
Definition: ezmenu.php:69
eZMenu\fill
fill(&$value)
Definition: ezmenu.php:165
eZMenu\$Link
$Link
Definition: ezmenu.php:377
eZMenu\name
& name()
Definition: ezmenu.php:300
eZMenu\setName
setName(&$value)
Definition: ezmenu.php:308
eZMenu\setLink
setLink(&$value)
Definition: ezmenu.php:324
eZMenu\path
& path( $menuID=0)
Definition: ezmenu.php:260
eZMenu\$Name
$Name
Definition: ezmenu.php:376
eZMenu\link
& link()
Definition: ezmenu.php:316
eZMenu\parent
parent()
Definition: ezmenu.php:343
eZMenu\id
id()
Definition: ezmenu.php:292
eZMenu\$Type
$Type
Definition: ezmenu.php:378
eZMenu\$ParentID
$ParentID
Definition: ezmenu.php:379
eZMenu\setType
setType( $value)
Definition: ezmenu.php:370
eZMenu\getAll
static & getAll( $offset=0, $limit=20)
Definition: ezmenu.php:180
eZMenu\count
static count( $parent=0)
Definition: ezmenu.php:236
eZMenu\__construct
__construct( $id=-1)
Definition: ezmenu.php:52
eZMenu\$ID
$ID
Definition: ezmenu.php:375
eZMenu\type
type()
Definition: ezmenu.php:360
$result
$result
Definition: companysearch.php:94
$name
$name
Definition: companytypelist.php:194
$id
$id
Definition: companytypelist.php:193
$query
if(isset( $Year) &&!is_numeric( $Year)||isset( $Month) &&!is_numeric( $Month)) $query
Definition: entryexitpages.php:65
$db
$db
Definition: ezarticle/user/authorlist.php:53
$limit
$limit
Definition: ezimagecatalogue/admin/imagelist.php:312
$link
$link
Definition: ezlink/admin/attributeedit.php:49
$ret
$ret
Definition: ezsitemanager/admin/filelist.php:88
$res
$res
Definition: ezstats/admin/cron.php:45
$offset
$offset
Definition: ezstats/admin/cron.php:51
$menu
$menu
Definition: menulist.php:61
Name
if($user) if(isset( $next) && $next)<?=isset($all_fields_error) &&$all_fields_error ?><?=isset($password_error) &&$password_error ?></p ><? endif;?>< form method="post">< table border="0" cellspacing="2" cellpadding="2" class="boxtext" style="font-size=13;">< tr >< td style="color:<?= isset( $error['first_name'] ) ?> First Name
Definition: step1.php:127
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.