Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

ezsection.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: ezsection.php 8954 2002-01-16 10:37:22Z kaid $
5 //
6 // ezsection class
7 //
8 // Created on: <10-May-2001 15:13:08 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 // include_once( "ezsitemanager/classes/ezsectionfrontpage.php" );
43
44 class eZSection
45 {
46
53 function __construct( $id=-1 )
54 {
55 if ( $id != -1 )
56 {
57 $this->ID = $id;
58 $this->get( $this->ID );
59 }
60 }
61
65 function store()
66 {
67 $db =& eZDB::globalDatabase();
68 $db->begin( );
69
70 $name = $db->escapeString( $this->Name );
71 $description = $db->escapeString( $this->Description );
72 $siteDesign = $db->escapeString( $this->SiteDesign );
73 $templateStyle = $db->escapeString( $this->TemplateStyle );
74 $secLanguage = $db->escapeString( $this->SecLanguage );
75
76 if ( !isset( $this->ID ) )
77 {
78 $db->lock( "eZSiteManager_Section" );
79
80 $nextID = $db->nextID( "eZSiteManager_Section", "ID" );
81
82 $timeStamp = (new eZDateTime())->timeStamp( true );
83
84 $res = $db->query( "INSERT INTO eZSiteManager_Section
85 ( ID, Name, Created, Description, TemplateStyle, SiteDesign, Language )
86 VALUES
87 ( '$nextID',
88 '$name',
89 '$timeStamp',
90 '$description',
91 '$templateStyle',
92 '$siteDesign',
93 '$secLanguage' )" );
94
95 $this->ID = $nextID;
96 }
97 else
98 {
99 $query = "UPDATE eZSiteManager_Section SET
100 Name='$name',
101 SiteDesign='$siteDesign',
102 TemplateStyle='$templateStyle',
103 Description='$description',
104 Language='$secLanguage'
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_Section WHERE ID='$this->ID'" );
131 }
132
136 function get( $id=-1 )
137 {
138 $db =& eZDB::globalDatabase();
139 $ret = false;
140
141 if ( $id != "" )
142 {
143 $query = "SELECT * FROM eZSiteManager_Section WHERE ID='$id'";
144 $db->array_query( $section_array, $query );
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->Name = $section_array[0][$db->fieldName("Name")];
153 $this->SiteDesign = $section_array[0][$db->fieldName("SiteDesign")];
154 // if ( !isset( $section_array[0][$db->fieldName("TemplateStyle")] ) )
155 // $section_array[0][$db->fieldName("TemplateStyle")] = "";
156 $this->TemplateStyle = $section_array[0][$db->fieldName("TemplateStyle")];
157 if ( !isset( $section_array[0][$db->fieldName("Description")] ) )
158 $section_array[0][$db->fieldName("Description")] = "";
159 $this->Description = $section_array[0][$db->fieldName("Description")];
160 $this->Created = $section_array[0][$db->fieldName("Created")];
161 if ( !isset( $section_array[0][$db->fieldName("Language")] ) )
162 $section_array[0][$db->fieldName("Language")] = "";
163 $this->SecLanguage = $section_array[0][$db->fieldName("Language")];
164 $ret = true;
165 }
166 }
167
168 return $ret;
169 }
170
177 static public function getAll( $offset=0, $limit=40)
178 {
179 $db =& eZDB::globalDatabase();
180
181 $return_array = array();
182 $section_array = array();
183
184 $db->array_query( $section_array, "SELECT ID, Created
185 FROM eZSiteManager_Section
186 ORDER BY Created ASC",
187 array( "Limit" => $limit, "Offset" => $offset ) );
188
189 for ( $i=0; $i < count($section_array); $i++ )
190 {
191 $return_array[$i] = new eZSection( $section_array[$i][$db->fieldName("ID")] );
192 }
193
194 return $return_array;
195 }
196
200 static public function count()
201 {
202 $db =& eZDB::globalDatabase();
203 $ret = false;
204
205 $db->query_single( $result, "SELECT COUNT(ID) as Count
206 FROM eZSiteManager_Section" );
207 $ret = $result[$db->fieldName("Count")];
208 return $ret;
209 }
210
211
215 function id()
216 {
217 return $this->ID;
218 }
219
223 function name()
224 {
225 if( isset( $this->Name ) )
226 return htmlspecialchars( $this->Name );
227
228 return $this->Name;
229 }
230
237 public function siteDesign( $sectionID=false )
238 {
239 if ( $sectionID != false )
240 {
241 $db =& eZDB::globalDatabase();
242 $db->query_single( $siteDesign, "SELECT SiteDesign FROM eZSiteManager_Section WHERE ID='$sectionID'" );
243 if( is_array( $siteDesign ) && !empty( $siteDesign ) )
244 {
245 return $siteDesign[$db->fieldName("SiteDesign")];
246 }
247 }
248 else {
249 if( isset( $this->SiteDesign ) )
250 return htmlspecialchars( $this->SiteDesign );
251 }
252
253 return false;
254 }
255
256 static public function siteDesignStatic( $sectionID=false )
257 {
258 if ( $sectionID != false )
259 {
260 $db =& eZDB::globalDatabase();
261 $db->query_single( $siteDesign, "SELECT SiteDesign FROM eZSiteManager_Section WHERE ID='$sectionID'" );
262 return $siteDesign[$db->fieldName("SiteDesign")];
263 }
264
265 return false;
266 }
267
268
273 function templateStyle( $sectionID=false )
274 {
275 if ( $sectionID != false )
276 {
277 $db =& eZDB::globalDatabase();
278 $db->query_single( $templateStyle, "SELECT TemplateStyle FROM eZSiteManager_Section WHERE ID='$sectionID'" );
279 return $templateStyle[$db->fieldName("TemplateStyle")];
280 }
281 else {
282 if( isset( $this->TemplateStyle ) )
283 return htmlspecialchars( $this->TemplateStyle );
284 }
285 }
286
287 static public function templateStyleStatic( $sectionID=false )
288 {
289 if ( $sectionID != false )
290 {
291 $db =& eZDB::globalDatabase();
292 $db->query_single( $templateStyle, "SELECT TemplateStyle FROM eZSiteManager_Section WHERE ID='$sectionID'" );
293 return $templateStyle[$db->fieldName("TemplateStyle")];
294 }
295
296 return false;
297 }
302 static public function language( $sectionID=false )
303 {
304 if ( is_numeric ( $sectionID ) )
305 {
306 $db =& eZDB::globalDatabase();
307 $db->query_single( $templateStyle, "SELECT Language FROM eZSiteManager_Section WHERE ID='$sectionID'" );
308 return $templateStyle[$db->fieldName("Language")];
309 }
310 // else
311 // return htmlspecialchars( $this->SecLanguage );
312 }
313
317 function description()
318 {
319 return htmlspecialchars( $this->Description );
320 }
321
325 function setName( $value )
326 {
327 $this->Name = $value;
328 }
329
333 function setSiteDesign( $value )
334 {
335 $this->SiteDesign = $value;
336 }
337
341 function setTemplateStyle( $value )
342 {
343 $this->TemplateStyle = $value;
344 }
345
349 function setLanguage( $value )
350 {
351 $this->SecLanguage = $value;
352 }
353
357 function setDescription( $value )
358 {
359 $this->Description = $value;
360 }
361
366 static public function &globalSectionObject( $sectionID )
367 {
368 $objName = "eZSectionObject_$sectionID";
369 global $GLOBALS;
370
371 if ( !isset( $GLOBALS[$objName] ) or !is_a( $GLOBALS[$objName], "eZSection" ) )
372 {
373 $GLOBALS[$objName] = new eZSection( $sectionID );
374 }
375
376 return $GLOBALS[$objName];
377 }
378
384 function setOverrideVariables()
385 {
386 global $GLOBALS;
387 $ini =& eZINI::instance( 'site.ini' );
388
389 // set the sitedesign from the section
390 if ( $ini->variable( "site", "Sections" ) == "enabled" )
391 {
392 if ( !is_null( $this->TemplateStyle ) && trim( $this->TemplateStyle ) != "" )
393 {
394 $GLOBALS["eZTemplateOverride"] = trim( $this->TemplateStyle );
395 }
396
397 if ( !is_null( $this->SecLanguage ) && trim( $this->SecLanguage ) != "" )
398 {
399 $GLOBALS["eZLanguageOverride"] = trim( $this->SecLanguage );
400 }
401 }
402 }
403
404 static public function &settingNames()
405 {
406 $db =& eZDB::globalDatabase();
407
408 $db->array_query( $section_array, "SELECT ID, Name
409 FROM eZSiteManager_SectionFrontPageSetting" );
410
411 return $section_array;
412 }
413
414 function &frontPageRows()
415 {
416 $db =& eZDB::globalDatabase();
417
418 $returnArray = array();
419
420 $db->array_query( $rows, "SELECT eZSiteManager_SectionFrontPageRow.ID as ID FROM eZSiteManager_SectionFrontPageRowLink, eZSiteManager_SectionFrontPageRow
421 WHERE eZSiteManager_SectionFrontPageRowLink.SectionID='$this->ID' AND eZSiteManager_SectionFrontPageRowLink.FrontPageID = eZSiteManager_SectionFrontPageRow.ID ORDER BY eZSiteManager_SectionFrontPageRow.Placement" );
422
423 foreach( $rows as $row )
424 {
425 $returnArray[] = new eZSectionFrontPage( $row[$db->fieldName( "ID" )] );
426 }
427
428 return $returnArray;
429 }
430
431 function addFrontPageRow( $rowID )
432 {
433 if ( is_a( $rowID, "eZSectionFrontPage" ) )
434 $rowID = $rowID->id();
435 $db =& eZDB::globalDatabase();
436 $db->begin( );
437
438 $db->lock( "eZSiteManager_SectionFrontPageRowLink" );
439
440 $nextID = $db->nextID( "eZSiteManager_SectionFrontPageRowLink", "ID" );
441
442 $timeStamp = (new eZDateTime())->timeStamp( true );
443
444 $res[] = $db->query( "INSERT INTO eZSiteManager_SectionFrontPageRowLink
445 ( ID, SectionID, FrontPageID )
446 VALUES
447 ( '$nextID',
448 '$this->ID',
449 '$rowID'
450 )" );
451
452 $db->unlock();
453 if ( in_array( false, $res ) )
454 $db->rollback( );
455 else
456 $db->commit();
457 }
458
459 var $ID;
460 var $Name;
461 var $SiteDesign;
462 var $TemplateStyle;
463 var $Description;
464 var $Created;
465 var $SecLanguage;
466
467 }
468
469 ?>
$i
$i
Definition: admin/adlist.php:91
eZDB\globalDatabase
static & globalDatabase()
Definition: ezdb.php:134
eZDateTime
Definition: ezdatetime.php:55
eZSectionFrontPage
Definition: ezsectionfrontpage.php:43
eZSection
Definition: ezsection.php:45
eZSection\getAll
static getAll( $offset=0, $limit=40)
Definition: ezsection.php:177
eZSection\$SecLanguage
$SecLanguage
Definition: ezsection.php:465
eZSection\setTemplateStyle
setTemplateStyle( $value)
Definition: ezsection.php:341
eZSection\addFrontPageRow
addFrontPageRow( $rowID)
Definition: ezsection.php:431
eZSection\id
id()
Definition: ezsection.php:215
eZSection\settingNames
static & settingNames()
Definition: ezsection.php:404
eZSection\name
name()
Definition: ezsection.php:223
eZSection\$ID
$ID
Definition: ezsection.php:459
eZSection\setSiteDesign
setSiteDesign( $value)
Definition: ezsection.php:333
eZSection\$TemplateStyle
$TemplateStyle
Definition: ezsection.php:462
eZSection\siteDesignStatic
static siteDesignStatic( $sectionID=false)
Definition: ezsection.php:256
eZSection\$Created
$Created
Definition: ezsection.php:464
eZSection\globalSectionObject
static & globalSectionObject( $sectionID)
Definition: ezsection.php:366
eZSection\siteDesign
siteDesign( $sectionID=false)
Definition: ezsection.php:237
eZSection\frontPageRows
& frontPageRows()
Definition: ezsection.php:414
eZSection\setName
setName( $value)
Definition: ezsection.php:325
eZSection\language
static language( $sectionID=false)
Definition: ezsection.php:302
eZSection\$SiteDesign
$SiteDesign
Definition: ezsection.php:461
eZSection\templateStyle
templateStyle( $sectionID=false)
Definition: ezsection.php:273
eZSection\setLanguage
setLanguage( $value)
Definition: ezsection.php:349
eZSection\setOverrideVariables
setOverrideVariables()
Definition: ezsection.php:384
eZSection\count
static count()
Definition: ezsection.php:200
eZSection\description
description()
Definition: ezsection.php:317
eZSection\$Description
$Description
Definition: ezsection.php:463
eZSection\$Name
$Name
Definition: ezsection.php:460
eZSection\setDescription
setDescription( $value)
Definition: ezsection.php:357
eZSection\templateStyleStatic
static templateStyleStatic( $sectionID=false)
Definition: ezsection.php:287
eZSection\__construct
__construct( $id=-1)
Definition: ezsection.php:53
eZSection\store
store()
Definition: ezsection.php:65
$ini
$ini
Definition: classes/admin/linklist.php:64
$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
$row
$row
Definition: ezcalendar/user/dayview.php:403
$limit
$limit
Definition: ezimagecatalogue/admin/imagelist.php:312
$ret
$ret
Definition: ezsitemanager/admin/filelist.php:88
$res
$res
Definition: ezstats/admin/cron.php:45
$offset
$offset
Definition: ezstats/admin/cron.php:51
$rows
$rows
Definition: frontpage.php:128
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+.