Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

ezsectionfrontpage.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: ezsectionfrontpage.php 7874 2001-10-16 10:32:43Z ce $
5 //
6 // ezsectionfrontpage class
7 //
8 // Created on: <02-Oct-2001 12:38:11 ce>
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
39 // include_once( "classes/ezdb.php" );
40 // include_once( "classes/ezdatetime.php" );
41
42 class eZSectionFrontPage
43 {
44
51 function __construct( $id=-1 )
52 {
53 $this->SettingID = 0;
54 $this->CategoryID = 0;
55
56 if ( $id != -1 )
57 {
58 $this->ID = $id;
59 $this->get( $this->ID );
60 }
61 }
62
66 function store()
67 {
68 $db =& eZDB::globalDatabase();
69
70 $db->begin( );
71
72 if ( !isset( $this->ID ) )
73 {
74 $db->array_query( $attribute_array, "SELECT Placement FROM eZSiteManager_SectionFrontPageRow" );
75
76 if ( count ( $attribute_array ) > 0 )
77 {
78 $place = max( $attribute_array );
79 $place = $place[$db->fieldName( "Placement" )];
80 $place++;
81 }
82
83 $db->lock( "eZSiteManager_SectionFrontPageRow" );
84
85 $nextID = $db->nextID( "eZSiteManager_SectionFrontPageRow", "ID" );
86
87 $timeStamp = (new eZDateTime())->timeStamp( true );
88
89 $res = $db->query( "INSERT INTO eZSiteManager_SectionFrontPageRow
90 ( ID, SettingID, CategoryID, Placement )
91 VALUES
92 ( '$nextID',
93 '$this->SettingID',
94 '$this->CategoryID',
95 '$place'
96 )" );
97
98 $this->ID = $nextID;
99 }
100 else
101 {
102 $query = "UPDATE eZSiteManager_SectionFrontPageRow SET
103 SettingID='$this->SettingID',
104 CategoryID='$this->CategoryID'
105 WHERE ID='$this->ID'";
106
107 $res = $db->query( $query );
108 }
109
110 $db->unlock();
111
112 if ( $res == false )
113 $db->rollback( );
114 else
115 $db->commit();
116
117 return true;
118 }
119
123 function delete( $catID=-1 )
124 {
125 if ( $catID == -1 )
126 $catID = $this->ID;
127
128 $db =& eZDB::globalDatabase();
129
130 $db->query( "DELETE FROM eZSiteManager_SectionFrontPageRowLink WHERE FrontPageID='$catID'" );
131 $db->query( "DELETE FROM eZSiteManager_SectionFrontPageRow WHERE ID='$catID'" );
132 }
133
137 function get( $id=-1 )
138 {
139 $db =& eZDB::globalDatabase();
140 $ret = false;
141
142 if ( $id != "" )
143 {
144 $db->array_query( $section_array, "SELECT * FROM eZSiteManager_SectionFrontPageRow WHERE ID='$id'" );
145 if ( count( $section_array ) > 1 )
146 {
147 die( "Error: Section's with the same ID was found in the database. This shouldent happen." );
148 }
149 else if( count( $section_array ) == 1 )
150 {
151 $this->ID =& $section_array[0][$db->fieldName("ID")];
152 $this->CategoryID =& $section_array[0][$db->fieldName("CategoryID")];
153 $this->SettingID =& $section_array[0][$db->fieldName("SettingID")];
154 $this->Placement =& $section_array[0][$db->fieldName( "Placement" )];
155 $ret = true;
156 }
157 }
158
159 return $ret;
160 }
161
162 function setSettingID( $value )
163 {
164 $this->SettingID = $value;
165 }
166
167 function setCategoryID( $value )
168 {
169 $this->CategoryID = $value;
170 }
171
172 function categoryID( )
173 {
174 return $this->CategoryID;
175 }
176
177 function settingID( )
178 {
179 return $this->SettingID;
180 }
181
182 function id( )
183 {
184 return $this->ID;
185 }
186
187 function &settingByRowID( $id )
188 {
189 $db =& eZDB::globalDatabase();
190
191 $db->query_single( $setting, "SELECT Name FROM
192 eZSiteManager_SectionFrontPageSetting,
193 eZSiteManager_SectionFrontPageRow WHERE
194 eZSiteManager_SectionFrontPageRow.ID='$id' AND
195 SettingID=eZSiteManager_SectionFrontPageSetting.ID" );
196
197 return $setting[$db->fieldName( "Name" )];
198 }
199
200 static public function &settingNames()
201 {
202 $db =& eZDB::globalDatabase();
203 $ret = array();
204 $db->array_query( $section_array, "SELECT ID, Name
205 FROM eZSiteManager_SectionFrontPageSetting ORDER BY ID" );
206
207 foreach ( $section_array as $name )
208 {
209 $ret[] = array( "Name" => $name[$db->fieldName( "Name" )], "ID" => $name[$db->fieldName( "ID" )] );
210 }
211 return $ret;
212 }
213
214 function &settingByID( $id )
215 {
216 $db =& eZDB::globalDatabase();
217 $ret = false;
218
219 $db->query_single( $setting, "SELECT Name
220 FROM eZSiteManager_SectionFrontPageSetting WHERE ID='$id'" );
221
222 if( isset( $setting[ $db->fieldName( "Name" ) ] ) )
223 return $setting[$db->fieldName( "Name" )];
224 else
225 return $ret;
226 }
227
231 function moveUp()
232 {
233 $db =& eZDB::globalDatabase();
234 $db->begin();
235 $db->query_single( $qry, "SELECT ID, Placement FROM eZSiteManager_SectionFrontPageRow
236 WHERE Placement<'$this->Placement' ORDER BY Placement DESC", array( "Limit" => 1, "Offset" => 0 ) );
237 $listorder = $qry[$db->fieldName( "Placement" )];
238 $listid = $qry[$db->fieldName( "ID" )];
239
240 $res[] = $db->query( "UPDATE eZSiteManager_SectionFrontPageRow SET Placement='$listorder' WHERE ID='$this->ID'" );
241 $res[] = $db->query( "UPDATE eZSiteManager_SectionFrontPageRow SET Placement='$this->Placement' WHERE ID='$listid'" );
242
243 eZDB::finish( $res, $db );
244 }
245
249 function moveDown()
250 {
251 $db =& eZDB::globalDatabase();
252 $db->begin();
253
254 $db->query_single( $qry, "SELECT ID, Placement FROM eZSiteManager_SectionFrontPageRow
255 WHERE Placement>'$this->Placement' ORDER BY Placement ASC", array( "Limit" => 1, "Offset" => 0 ) );
256 $listorder = $qry[$db->fieldName( "Placement" )];
257 $listid = $qry[$db->fieldName( "ID" )];
258 $res[] = $db->query( "UPDATE eZSiteManager_SectionFrontPageRow SET Placement='$listorder' WHERE ID='$this->ID'" );
259 $res[] = $db->query( "UPDATE eZSiteManager_SectionFrontPageRow SET Placement='$this->Placement' WHERE ID='$listid'" );
260
261 eZDB::finish( $res, $db );
262 }
263
264
265 var $ID;
266 var $SettingID;
267 var $CategoryID;
268 var $Placement;
269 }
270
271 ?>
eZDB\finish
static finish(&$resultArray, &$db)
Definition: ezdb.php:204
eZDB\globalDatabase
static & globalDatabase()
Definition: ezdb.php:134
eZDateTime
Definition: ezdatetime.php:55
eZSectionFrontPage
Definition: ezsectionfrontpage.php:43
eZSectionFrontPage\id
id()
Definition: ezsectionfrontpage.php:182
eZSectionFrontPage\moveDown
moveDown()
Definition: ezsectionfrontpage.php:249
eZSectionFrontPage\$SettingID
$SettingID
Definition: ezsectionfrontpage.php:266
eZSectionFrontPage\$CategoryID
$CategoryID
Definition: ezsectionfrontpage.php:267
eZSectionFrontPage\$ID
$ID
Definition: ezsectionfrontpage.php:265
eZSectionFrontPage\settingByRowID
& settingByRowID( $id)
Definition: ezsectionfrontpage.php:187
eZSectionFrontPage\store
store()
Definition: ezsectionfrontpage.php:66
eZSectionFrontPage\moveUp
moveUp()
Definition: ezsectionfrontpage.php:231
eZSectionFrontPage\setSettingID
setSettingID( $value)
Definition: ezsectionfrontpage.php:162
eZSectionFrontPage\settingNames
static & settingNames()
Definition: ezsectionfrontpage.php:200
eZSectionFrontPage\$Placement
$Placement
Definition: ezsectionfrontpage.php:268
eZSectionFrontPage\settingByID
& settingByID( $id)
Definition: ezsectionfrontpage.php:214
eZSectionFrontPage\setCategoryID
setCategoryID( $value)
Definition: ezsectionfrontpage.php:167
eZSectionFrontPage\settingID
settingID()
Definition: ezsectionfrontpage.php:177
eZSectionFrontPage\categoryID
categoryID()
Definition: ezsectionfrontpage.php:172
eZSectionFrontPage\__construct
__construct( $id=-1)
Definition: ezsectionfrontpage.php:51
$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
$ret
$ret
Definition: ezsitemanager/admin/filelist.php:88
$res
$res
Definition: ezstats/admin/cron.php:45
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.