Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

ezlinksection.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: ezlinksection.php 7848 2001-10-15 11:32:18Z ce $
5 //
6 // Definition of eZLinkSection class
7 //
8 // Created on: <16-Mar-2001 19:25:51 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
40 // include_once( "kernel/classes/ezlinkitem.php" );
41
42 class eZLinkSection
43 {
48 function __construct( $id, $module )
49 {
50 $this->Module = $module;
51 $this->ID = $id;
52 if ( is_numeric( $id ) )
53 $this->get( $id );
54 }
55
59 function get( $id )
60 {
61 $db =& eZDB::globalDatabase();
62 $table_name = $this->Module . "_LinkSection";
63 $db->query_single( $row, "SELECT Name FROM $table_name WHERE ID='$id'" );
64 $this->fill( $row );
65 }
66
70 function store()
71 {
72 $db =& eZDB::globalDatabase();
73 $db->begin();
74 $table_name = $this->Module . "_LinkSection";
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 $res = $db->query( "$qry_text
80 SET Name='$this->Name' $qry_where" );
81
82 }
83 else
84 {
85 $db->lock( $table_name );
86 $nextID = $db->nextID( $table_name, "ID" );
87
88 $qry_text = "INSERT INTO $table_name";
89 $res = $db->query( "$qry_text
90 (ID, Name) VALUES ( '$nextID', '$this->Name' )" );
91 $db->unlock();
92 $this->ID = $nextID;
93 }
94 if ( $res == false )
95 $db->rollback( );
96 else
97 $db->commit();
98 }
99
103 function delete( $id = false, $module = false )
104 {
105 if ( !$id )
106 $id = $this->ID;
107 if ( !$module )
108 $module = $this->Module;
109 $db =& eZDB::globalDatabase();
110 $db->begin();
111 $table_name = $module . "_Link";
112 $res[] = $db->query( "DELETE FROM $table_name WHERE SectionID='$id'" );
113 $table_name = $module . "_LinkSection";
114 $res[] = $db->query( "DELETE FROM $table_name WHERE ID='$id'" );
115 if ( in_array( false, $res ) )
116 $db->rollback( );
117 else
118 $db->commit();
119 }
120
124 function fill( $row )
125 {
126 $db =& eZDB::globalDatabase();
127 $this->Name = $row[$db->fieldName( "Name" )];
128 }
129
133 function &links()
134 {
135 $db =& eZDB::globalDatabase();
136 $table_name = $this->Module . "_Link";
137 $db->array_query( $qry_array, "SELECT ID, Name, URL, Placement, ModuleType FROM $table_name
138 WHERE SectionID='$this->ID' ORDER BY Placement ASC" );
139 $ret = array();
140 foreach( $qry_array as $row )
141 {
142 $ret[] = new eZLinkItem( $row, $this->Module );
143 }
144 return $ret;
145 }
146
151 function moveUp( $objectid, $id, $module, $type )
152 {
153 $db =& eZDB::globalDatabase();
154 $db->begin();
155 $link_table_name = $module . "_$type" . "SectionDict";
156 $type_column = $type . "ID";
157 $db->query_single( $placement, "SELECT Placement FROM $link_table_name
158 WHERE SectionID='$id'", "Placement" );
159 $db->array_query( $items, "SELECT SectionID, Placement
160 FROM $link_table_name
161 WHERE $type_column='$objectid' AND Placement<'$placement'
162 ORDER BY Placement DESC", array( "Limit" => 1 ) );
163 if ( count( $items ) == 0 )
164 {
165 $db->array_query( $items, "SELECT SectionID, Placement
166 FROM $link_table_name
167 WHERE $type_column='$objectid' AND SectionID!='$id'
168 ORDER BY Placement DESC", array( "Limit" => 1 ) );
169 $swap_placement = $items[0][$db->fieldName( "Placement" )] + 1;
170 $res[] = $db->query( "UPDATE $link_table_name
171 SET Placement=$swap_placement WHERE SectionID=$id" );
172 }
173 else
174 {
175 $swap_id = $items[0][$db->fieldName( "SectionID" )];
176 $swap_placement = $items[0][$db->fieldName( "Placement" )];
177 $res[] = $db->query( "UPDATE $link_table_name
178 SET Placement=$swap_placement WHERE SectionID=$id" );
179 $res[] = $db->query( "UPDATE $link_table_name
180 SET Placement=$placement WHERE SectionID=$swap_id" );
181 }
182 if ( in_array( false, $res ) )
183 $db->rollback( );
184 else
185 $db->commit();
186 }
187
192 function moveDown( $objectid, $id, $module, $type )
193 {
194 $db =& eZDB::globalDatabase();
195 $db->begin();
196 $link_table_name = $module . "_$type" . "SectionDict";
197 $type_column = $type . "ID";
198 $db->query_single( $placement, "SELECT Placement FROM $link_table_name
199 WHERE SectionID='$id'", "Placement" );
200 $db->array_query( $items, "SELECT SectionID, Placement
201 FROM $link_table_name
202 WHERE $type_column='$objectid' AND Placement>'$placement'
203 ORDER BY Placement ASC", array( "Limit" => 1 ) );
204 if ( count( $items ) == 0 )
205 {
206 $db->array_query( $items, "SELECT SectionID, Placement
207 FROM $link_table_name
208 WHERE $type_column='$objectid' AND SectionID!='$id'
209 ORDER BY Placement ASC", array( "Limit" => 1 ) );
210 $swap_placement = $items[0][$db->fieldName( "Placement" )] - 1;
211 $res[] = $db->query( "UPDATE $link_table_name
212 SET Placement=$swap_placement WHERE SectionID=$id" );
213 }
214 else
215 {
216 $swap_id = $items[0][$db->fieldName( "SectionID" )];
217 $swap_placement = $items[0][$db->fieldName( "Placement" )];
218 $res[] = $db->query( "UPDATE $link_table_name
219 SET Placement=$swap_placement WHERE SectionID=$id" );
220 $res[] = $db->query( "UPDATE $link_table_name
221 SET Placement=$placement WHERE SectionID=$swap_id" );
222 }
223 if ( in_array( false, $res ) )
224 $db->rollback( );
225 else
226 $db->commit();
227 }
228
232 function setName( $name )
233 {
234 $this->Name = $name;
235 }
236
240 function id()
241 {
242 return $this->ID;
243 }
244
248 function name()
249 {
250 return $this->Name;
251 }
252
253 var $Module;
254 var $ID;
255 var $Name;
256 }
257
258 ?>
$items
$items
Definition: admin/orderview.php:211
eZDB\globalDatabase
static & globalDatabase()
Definition: ezdb.php:134
eZLinkItem
Definition: ezlinkitem.php:38
eZLinkSection
Definition: ezlinksection.php:43
eZLinkSection\moveDown
moveDown( $objectid, $id, $module, $type)
Definition: ezlinksection.php:192
eZLinkSection\moveUp
moveUp( $objectid, $id, $module, $type)
Definition: ezlinksection.php:151
eZLinkSection\id
id()
Definition: ezlinksection.php:240
eZLinkSection\fill
fill( $row)
Definition: ezlinksection.php:124
eZLinkSection\store
store()
Definition: ezlinksection.php:70
eZLinkSection\setName
setName( $name)
Definition: ezlinksection.php:232
eZLinkSection\$ID
$ID
Definition: ezlinksection.php:254
eZLinkSection\links
& links()
Definition: ezlinksection.php:133
eZLinkSection\__construct
__construct( $id, $module)
Definition: ezlinksection.php:48
eZLinkSection\name
name()
Definition: ezlinksection.php:248
eZLinkSection\$Module
$Module
Definition: ezlinksection.php:253
eZLinkSection\$Name
$Name
Definition: ezlinksection.php:255
$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
$ret
$ret
Definition: ezsitemanager/admin/filelist.php:88
$res
$res
Definition: ezstats/admin/cron.php:45
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+.