Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

ezlinkitem.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: ezlinkitem.php 9873 2003-07-22 10:57:19Z vl $
5 //
6 // Definition of eZLinkItem class
7 //
8 // Created on: <19-Mar-2001 13:15:16 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
37 class eZLinkItem
38 {
42 function __construct( $id, $module )
43 {
44 $this->Module = $module;
45 if ( is_array( $id ) )
46 {
47 $this->fill( $id );
48 }
49 else if ( is_numeric( $id ) )
50 {
51 $this->get( $id );
52 }
53 }
54
58 function get( $id )
59 {
60 $db =& eZDB::globalDatabase();
61 $table_name = $this->Module . "_Link";
62 $db->query_single( $row, "SELECT ID, Name, URL, Placement, ModuleType FROM $table_name WHERE ID='$id'" );
63 $this->fill( $row );
64 }
65
69 function store()
70 {
71 $table_name = $this->Module . "_Link";
72 $db =& eZDB::globalDatabase();
73 $db->begin();
74 $name = $db->escapeString( $this->Name );
75 if ( is_numeric( $this->ID ) and $this->ID > 0 )
76 {
77 $qry_text = "UPDATE $table_name";
78 $qry_where = "WHERE ID='$this->ID'";
79
80 $db->query( "$qry_text
81 SET SectionID='$this->Section',
82 Name='$name',
83 URL='$this->URL',
84 Placement='$this->Placement',
85 ModuleType='$this->ModuleType' $qry_where" );
86 }
87 else
88 {
89 $qry_text = "INSERT INTO $table_name";
90 $db->array_query( $qry_array, "SELECT Placement FROM $table_name
91 WHERE SectionID='$this->Section'
92 ORDER BY Placement", array( "Limit" => 1 ) );
93 $this->Placement = count( $qry_array ) == 1 ? $qry_array[0][$db->fieldName( "Placement" )] + 1 : 1;
94
95 $db->lock( $table_name );
96 $nextID = $db->nextID( $table_name, "ID" );
97
98 $res = $db->query( "$qry_text
99 ( ID, SectionID, Name, URL, Placement, ModuleType )
100 VALUES( '$nextID', '$this->Section', '$name', '$this->URL', '$this->Placement', '$this->ModuleType' )" );
101 $this->ID = $nextID;
102 $db->unlock();
103 }
104
105 if ( $res == false )
106 $db->rollback( );
107 else
108 $db->commit();
109 }
110
114 function delete( $id = false, $module = false )
115 {
116 if ( !$id )
117 $id = $this->ID;
118 if ( !$module )
119 $module = $this->Module;
120 $table_name = $module . "_Link";
121 $db =& eZDB::globalDatabase();
122 $db->begin();
123 $res = $db->query( "DELETE FROM $table_name WHERE ID='$id'" );
124 if ( $res == false )
125 $db->rollback( );
126 else
127 $db->commit();
128 }
129
133 function fill( $row )
134 {
135 $db =& eZDB::globalDatabase();
136 $this->ID = $row[$db->fieldName( "ID" )];
137 $this->Name = $row[$db->fieldName( "Name" )];
138 $this->URL = $row[$db->fieldName( "URL" )];
139 $this->Placement = $row[$db->fieldName( "Placement" )];
140 $this->ModuleType = $row[$db->fieldName( "ModuleType" )];
141 }
142
146 function setSection( $section )
147 {
148 $this->Section = $section;
149 }
150
154 function setName( $name )
155 {
156 $this->Name = $name;
157 }
158
162 function setURL( $url )
163 {
164 $this->URL = $url;
165 }
166
170 function id()
171 {
172 return $this->ID;
173 }
174
178 function section()
179 {
180 return $this->Section;
181 }
182
186 function name()
187 {
188 return $this->Name;
189 }
190
194 function url()
195 {
196 return $this->URL;
197 }
198
203 function type( $as_name = false )
204 {
205 if ( !$as_name )
206 {
207 return $this->ModuleType;
208 }
209 else
210 {
211 $db =& eZDB::globalDatabase();
212 $db->query_single( $row, "SELECT Module, Type FROM eZModule_LinkModuleType
213 WHERE ID='$this->ModuleType'" );
214 return $row;
215 }
216 }
217
223 function setType( $module, $type )
224 {
225 $db =& eZDB::globalDatabase();
226 $db->array_query( $rows, "SELECT ID FROM eZModule_LinkModuleType
227 WHERE Module='$module' AND Type='$type'", 0, 1, "ID" );
228 if ( count( $rows ) == 0 )
229 {
230 $db->begin();
231 $db->lock( "eZModule_LinkModuleType" );
232 $nextID = $db->nextID( "eZModule_LinkModuleType", "ID" );
233
234 $res = $db->query( "INSERT INTO eZModule_LinkModuleType ( ID, Module, Type ) VALUES ( '$nextID', '$module', '$type' )" );
235 $this->ModuleType = $nextID;
236 $db->unlock();
237
238 if ( $res == false )
239 $db->rollback( );
240 else
241 $db->commit();
242 }
243 else
244 {
245 $this->ModuleType = $rows[0];
246 }
247 }
248
252 function moveUp( $sectionid, $id, $module )
253 {
254 $db =& eZDB::globalDatabase();
255 $db->begin();
256 $table_name = $module . "_Link";
257 $db->query_single( $placement, "SELECT Placement FROM $table_name
258 WHERE ID='$id'", "Placement" );
259 $db->array_query( $items, "SELECT ID, Placement
260 FROM $table_name
261 WHERE SectionID='$sectionid' AND Placement<'$placement'
262 ORDER BY Placement DESC", array( "Limit" => 1 ) );
263 if ( count( $items ) == 0 )
264 {
265 $db->array_query( $items, "SELECT Placement
266 FROM $table_name
267 WHERE SectionID='$sectionid' AND ID!='$id'
268 ORDER BY Placement DESC", array( "Limit" => 1 ) );
269 $swap_placement = $items[0][$db->fieldName( "Placement" )] + 1;
270 $res[] = $db->query( "UPDATE $table_name
271 SET Placement=$swap_placement WHERE ID=$id" );
272 }
273 else
274 {
275 $swap_id = $items[0][$db->fieldName("ID")];
276 $swap_placement = $items[0][$db->fieldName("Placement")];
277 $res[] = $db->query( "UPDATE $table_name
278 SET Placement=$swap_placement WHERE ID=$id" );
279 $res[] = $db->query( "UPDATE $table_name
280 SET Placement=$placement WHERE ID=$swap_id" );
281 }
282 if ( in_array( false, $res ) )
283 $db->rollback( );
284 else
285 $db->commit();
286 }
287
291 function moveDown( $sectionid, $id, $module )
292 {
293 $db =& eZDB::globalDatabase();
294 $db->begin();
295 $table_name = $module . "_Link";
296 $db->query_single( $placement, "SELECT Placement FROM $table_name
297 WHERE ID='$id'", "Placement" );
298 $db->array_query( $items, "SELECT ID, Placement
299 FROM $table_name
300 WHERE SectionID='$sectionid' AND Placement>'$placement'
301 ORDER BY Placement ASC", array( "Limit" => 1 ) );
302 if ( count( $items ) == 0 )
303 {
304 $db->array_query( $items, "SELECT Placement
305 FROM $table_name
306 WHERE SectionID='$sectionid' AND ID!='$id'
307 ORDER BY Placement ASC", array( "Limit" => 1 ) );
308 $swap_placement = $items[0][$db->fieldName( "Placement" )] - 1;
309 $res[] = $db->query( "UPDATE $table_name
310 SET Placement=$swap_placement WHERE ID=$id" );
311 }
312 else
313 {
314 $swap_id = $items[0][$db->fieldName( "ID" )];
315 $swap_placement = $items[0][$db->fieldName("Placement" )];
316 $res[] = $db->query( "UPDATE $table_name
317 SET Placement=$swap_placement WHERE ID=$id" );
318 $res[] = $db->query( "UPDATE $table_name
319 SET Placement=$placement WHERE ID=$swap_id" );
320 }
321 if ( in_array( false, $res ) )
322 $db->rollback( );
323 else
324 $db->commit();
325 }
326
327 var $ID;
328 var $Section;
329 var $Name;
330 var $URL;
331 var $Placement;
332 var $Module;
333 var $ModuleType;
334 }
335
336 ?>
$items
$items
Definition: admin/orderview.php:211
eZDB\globalDatabase
static & globalDatabase()
Definition: ezdb.php:134
eZLinkItem
Definition: ezlinkitem.php:38
eZLinkItem\store
store()
Definition: ezlinkitem.php:69
eZLinkItem\__construct
__construct( $id, $module)
Definition: ezlinkitem.php:42
eZLinkItem\section
section()
Definition: ezlinkitem.php:178
eZLinkItem\$Placement
$Placement
Definition: ezlinkitem.php:331
eZLinkItem\setType
setType( $module, $type)
Definition: ezlinkitem.php:223
eZLinkItem\setName
setName( $name)
Definition: ezlinkitem.php:154
eZLinkItem\type
type( $as_name=false)
Definition: ezlinkitem.php:203
eZLinkItem\moveUp
moveUp( $sectionid, $id, $module)
Definition: ezlinkitem.php:252
eZLinkItem\fill
fill( $row)
Definition: ezlinkitem.php:133
eZLinkItem\setURL
setURL( $url)
Definition: ezlinkitem.php:162
eZLinkItem\moveDown
moveDown( $sectionid, $id, $module)
Definition: ezlinkitem.php:291
eZLinkItem\url
url()
Definition: ezlinkitem.php:194
eZLinkItem\name
name()
Definition: ezlinkitem.php:186
eZLinkItem\setSection
setSection( $section)
Definition: ezlinkitem.php:146
eZLinkItem\$Module
$Module
Definition: ezlinkitem.php:332
eZLinkItem\$Section
$Section
Definition: ezlinkitem.php:328
eZLinkItem\$ID
$ID
Definition: ezlinkitem.php:327
eZLinkItem\id
id()
Definition: ezlinkitem.php:170
eZLinkItem\$URL
$URL
Definition: ezlinkitem.php:330
eZLinkItem\$ModuleType
$ModuleType
Definition: ezlinkitem.php:333
eZLinkItem\$Name
$Name
Definition: ezlinkitem.php:329
$type
$type
Definition: classes/admin/linkselect.php:220
$module
$module
Definition: classes/admin/linkselect.php:219
$name
$name
Definition: companytypelist.php:194
$id
$id
Definition: companytypelist.php:193
$db
$db
Definition: ezarticle/user/authorlist.php:53
$row
$row
Definition: ezcalendar/user/dayview.php:403
$section
$section
Definition: ezimagecatalogue/user/categoryedit.php:393
$res
$res
Definition: ezstats/admin/cron.php:45
$rows
$rows
Definition: frontpage.php:128
$url
$url
Definition: messagereviewlist.php:153
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+.