Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

sectionedit.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: sectionedit.php 9825 2003-06-02 10:02:22Z jhe $
5 //
6 // Created on: <10-May-2001 16:17:29 ce>
7 //
8 // This source file is part of Exponential Basic, publishing software.
9 //
10 // Copyright (C) 1999-2001 eZ Systems. All rights reserved.
11 //
12 // This program is free software; you can redistribute it and/or
13 // modify it under the terms of the GNU General Public License
14 // as published by the Free Software Foundation; either version 2
15 // of the License, or (at your option) any later version.
16 //
17 // This program is distributed in the hope that it will be useful,
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 // GNU General Public License for more details.
21 //
22 // You should have received a copy of the GNU General Public License
23 // along with this program; if not, write to the Free Software
24 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, US
25 //
26
27 // include_once( "classes/INIFile.php" );
28 // include_once( "classes/eztemplate.php" );
29 // include_once( "classes/ezhttptool.php" );
30
31 // include_once( "ezsitemanager/classes/ezsection.php" );
32 // include_once( "ezsitemanager/classes/ezsectionfrontpage.php" );
33
34 // include_once( "ezarticle/classes/ezarticlecategory.php" );
35
36 // include_once( "ezad/classes/ezadcategory.php" );
37
38 $Action = "";
39
40 if ( isset ( $OK ) )
41 {
42 $Action = "Insert";
43 }
44 if ( isset ( $Delete ) )
45 {
46 $Action = "Delete";
47 }
48 if ( isset ( $Cancel ) )
49 {
50 eZHTTPTool::header( "Location: /sitemanager/section/list/" );
51 exit();
52 }
53
54 $ini =& eZINI::instance( 'site.ini' );
55 $Language = $ini->variable( "eZSiteManagerMain", "Language" );
56 $move_item = true;
57 $languageINI = new eZINI( "kernel/ezsitemanager/admin/intl/" . $Language . "/sectionedit.php.ini", false );
58
59 $t = new eZTemplate( "kernel/ezsitemanager/admin/" . $ini->variable( "eZSiteManagerMain", "AdminTemplateDir" ),
60 "kernel/ezsitemanager/admin/" . "/intl", $Language, "sectionedit.php" );
61 $t->setAllStrings();
62
63 $t->set_file( array(
64 "section_edit_page" => "sectionedit.tpl"
65 ) );
66
67
68 $t->set_block( "section_edit_page", "setting_list_tpl", "setting_list" );
69 $t->set_block( "setting_list_tpl", "setting_item_tpl", "setting_item" );
70 $t->set_block( "setting_item_tpl", "settings_tpl", "settings" );
71
72
73 $t->set_block( "setting_item_tpl", "article_category_list_tpl", "article_category_list" );
74 $t->set_block( "article_category_list_tpl", "article_category_item_tpl", "article_category_item" );
75
76 $t->set_block( "setting_item_tpl", "product_category_list_tpl", "product_category_list" );
77 $t->set_block( "product_category_list_tpl", "product_category_item_tpl", "product_category_item" );
78
79
80 $t->set_block( "setting_item_tpl", "item_move_up_tpl", "item_move_up" );
81 $t->set_block( "setting_item_tpl", "item_separator_tpl", "item_separator" );
82 $t->set_block( "setting_item_tpl", "item_move_down_tpl", "item_move_down" );
83 $t->set_block( "setting_item_tpl", "no_item_move_up_tpl", "no_item_move_up" );
84 $t->set_block( "setting_item_tpl", "no_item_separator_tpl", "no_item_separator" );
85 $t->set_block( "setting_item_tpl", "no_item_move_down_tpl", "no_item_move_down" );
86
87
88 $t->set_var( "section_name", isset( $Name ) ? $Name : false );
89 $t->set_var( "section_sitedesign", isset( $SiteDesign ) ? $SiteDesign : false );
90 $t->set_var( "section_templatestyle", isset( $TemplateStyle ) ? $TemplateStyle : false );
91 $t->set_var( "section_description", isset( $Description ) ? $Description : false );
92 $t->set_var( "section_language", isset( $SecLanguage ) ? $SecLanguage : false );
93 $t->set_var( "setting_list", "" );
94
95 $warning = true;
96
97 if ( isset ( $AddRow ) )
98 $Action = "Update";
99
100 if ( isset ( $OK ) )
101 $Action = "Update";
102
103 if ( isset ( $Store ) )
104 $Action = "Update";
105
106 if ( isset ( $DeleteRows ) )
107 {
108 $Action = "Update";
109
110 if ( isset( $RowDeleteArrayID ) && count ( $RowDeleteArrayID ) > 0 )
111 {
112 foreach( $RowDeleteArrayID as $RowID )
113 (new eZSectionFrontPage())->delete( $RowID );
114 }
115 }
116
117 if ( $Action == "up" )
118 {
119 $row = new eZSectionFrontPage( $RowID );
120 $row->moveUp();
121
122 // include_once( "classes/ezhttptool.php" );
123 eZHTTPTool::header( "Location: /sitemanager/section/edit/$SectionID" );
124 exit();
125 }
126
127 if ( $Action == "down" )
128 {
129 $row = new eZSectionFrontPage( $RowID );
130 $row->moveDown();
131 // include_once( "classes/ezhttptool.php" );
132 eZHTTPTool::header( "Location: /sitemanager/section/edit/$SectionID" );
133 exit();
134 }
135
136 if ( ( $Action == "Insert" ) || ( $Action == "Update" ) && ( $user ) )
137 {
138 if ( $warning )
139 {
140 if ( eZPBFile::is_dir( "design/" . $Name ) == false );
141 {
142 $session =& eZSession::globalSession();
143 $session->setVariable( "DirNotExists", "true" );
144 }
145 }
146
147 if ( isset( $SectionID ) )
148 {
149 $section = new eZSection( $SectionID );
150 }
151 else
152 {
153 $section = new eZSection();
154 }
155
156 $section->setName( $Name );
157 $section->setSiteDesign( $SiteDesign );
158 $section->setTemplateStyle( $TemplateStyle );
159 $section->setLanguage( $SecLanguage );
160 $section->setDescription( $Description );
161 $section->store();
162
163 if ( isset ( $Store ) || isset( $OK ) )
164 {
165 $i=0;
166 foreach( $RowArrayID as $RowID )
167 {
168 $pageRow = new eZSectionFrontPage( $RowID );
169 if( isset( $CategoryID[$i] ) )
170 {
171 $pageRow->setCategoryID($CategoryID[$i]);
172 }
173 else
174 {
175 $pageRow->setCategoryID( 1 );
176 }
177 $pageRow->setSettingID( $SettingID[$i] );
178 $pageRow->store();
179 $i++;
180 }
181 }
182
183 if ( isset ( $AddRow ) )
184 {
185 $pageRow = new eZSectionFrontPage();
186 $pageRow->store();
187 $section->addFrontPageRow( $pageRow );
188
189 eZHTTPTool::header( "Location: /sitemanager/section/edit/" . $section->id() );
190 exit();
191 }
192 else if ( ( !isset( $DeleteRows ) ) and isset( $OK ) )
193 {
194 eZHTTPTool::header( "Location: /sitemanager/section/list/" );
195 exit();
196 }
197 }
198
199
200 if ( $Action == "Delete" )
201 {
202 if ( count ( $SectionArrayID ) > 0 )
203 {
204 foreach( $SectionArrayID as $SectionID )
205 {
206 $section = new eZSection( $SectionID );
207 $section->delete();
208 }
209 }
210 eZHTTPTool::header( "Location: /sitemanager/section/list/" );
211 exit();
212 }
213
214 if ( isset( $SectionID ) )
215 {
216 $section = new eZSection( $SectionID );
217 $t->set_var( "section_id", $section->id() );
218 $t->set_var( "section_name", $section->name() );
219 $t->set_var( "section_description", $section->description() );
220 $t->set_var( "section_sitedesign", $section->siteDesign( $SectionID ) );
221 $t->set_var( "section_language", $section->language() );
222 $t->set_var( "section_templatestyle", $section->templateStyle() );
223 $t->set_var( "setting_list", "" );
224 }
225 elseif( isset( $Name ) && isset( $SecLanguage ) )
226 {
227
228 $t->set_var( "section_name", $Name );
229 $t->set_var( "section_sitedesign", $SiteDesign );
230 $t->set_var( "section_templatestyle", $TemplateStyle );
231 $t->set_var( "section_description", $Description );
232 $t->set_var( "section_language", $SecLanguage );
233 $t->set_var( "setting_list", "" );
234 }
235 else
236 {
237 $t->set_var( "section_name", '' );
238 $t->set_var( "section_sitedesign", '' );
239 $t->set_var( "section_templatestyle", '' );
240 $t->set_var( "section_description", '' );
241 $t->set_var( "section_language", '' );
242 $t->set_var( "setting_list", "" );
243 }
244
245 if ( isset( $section ) && $section )
246 $rows = $section->frontPageRows();
247 $settingNames =& eZSectionFrontPage::settingNames();
248
249
250 if ( isset( $rows ) && count ( $rows ) > 0 )
251 {
252 $tree = new eZArticleCategory();
253 $articleTreeArray =& $tree->getTree();
254
255 $category = new eZProductCategory();
256 $productCategoryArray =& $category->getTree( );
257
258 $ad = new eZAdCategory();
259 $adCategoryArray =& $ad->getTree();
260
261 $i=0;
262 $count = count( $rows );
263 foreach ( $rows as $row )
264 {
265 $t->set_var( "item_move_up", "" );
266 $t->set_var( "no_item_move_up", "" );
267 $t->set_var( "item_move_down", "" );
268 $t->set_var( "no_item_move_down", "" );
269 $t->set_var( "item_separator", "" );
270 $t->set_var( "no_item_separator", "" );
271
272 if ( ( $i %2 ) == 0 )
273 $t->set_var( "td_class", "bglight" );
274 else
275 $t->set_var( "td_class", "bgdark" );
276
277 $t->set_var( "row_id", $row->id() );
278 $settingName = $row->settingByID( $row->settingID() );
279
280 $t->set_var( "product_category_list", "" );
281 $t->set_var( "article_category_list", "" );
282
283 switch ( $settingName )
284 {
285 case "1column":
286 case "2column":
287 case "1short":
288 {
289 $t->set_var( "article_category_item", "" );
290 if ( count( $articleTreeArray ) > 0 )
291 {
292 foreach ( $articleTreeArray as $catItem )
293 {
294 $t->set_var( "option_value", $catItem[0]->id() );
295 $t->set_var( "option_name", $catItem[0]->name() );
296
297 if ( $catItem[0]->id() == $row->categoryID() )
298 $t->set_var( "selected", "selected" );
299 else
300 $t->set_var( "selected", "" );
301
302 if ( $catItem[1] > 1 )
303 $t->set_var( "option_level", str_repeat( "&nbsp;&nbsp;", $catItem[1] ) );
304 else
305 $t->set_var( "option_level", "" );
306
307 $t->parse( "article_category_item", "article_category_item_tpl", true );
308 }
309 $t->parse( "article_category_list", "article_category_list_tpl", true );
310 }
311
312 }
313 break;
314
315 case "1columnProduct":
316 case "2columnProduct":
317 {
318 $t->set_var( "product_category_item", "" );
319 if ( count ( $productCategoryArray ) > 0 )
320 {
321 foreach ( $productCategoryArray as $catItem )
322 {
323 $t->set_var( "option_value", $catItem[0]->id() );
324 $t->set_var( "option_name", $catItem[0]->name() );
325
326 if ( $catItem[0]->id() == $row->categoryID() )
327 $t->set_var( "selected", "selected" );
328 else
329 $t->set_var( "selected", "" );
330
331 if ( $catItem[1] > 0 )
332 $t->set_var( "option_level", str_repeat( "&nbsp;", $catItem[1] ) );
333 else
334 $t->set_var( "option_level", "" );
335
336 $t->parse( "product_category_item", "product_category_item_tpl", true );
337 }
338 $t->parse( "product_category_list", "product_category_list_tpl" );
339 }
340 }
341 break;
342
343 case "ad":
344 {
345 $t->set_var( "product_category_item", "" );
346 if ( count( $adCategoryArray ) > 0 )
347 {
348 foreach ( $adCategoryArray as $catItem )
349 {
350 $t->set_var( "option_value", $catItem[0]->id() );
351 $t->set_var( "option_name", $catItem[0]->name() );
352
353 if ( $catItem[0]->id() == $row->categoryID() )
354 $t->set_var( "selected", "selected" );
355 else
356 $t->set_var( "selected", "" );
357
358 if ( $catItem[1] > 0 )
359 $t->set_var( "option_level", str_repeat( "&nbsp;", $catItem[1] ) );
360 else
361 $t->set_var( "option_level", "" );
362
363 $t->parse( "product_category_item", "product_category_item_tpl", true );
364 }
365 $t->parse( "product_category_list", "product_category_list_tpl" );
366 }
367 }
368 break;
369
370 }
371
372 $t->set_var( "settings", "" );
373 foreach ( $settingNames as $name )
374 {
375 $t->set_var( "setting_name", $languageINI->variable( "strings", $name["Name"] ) );
376 $t->set_var( "setting_id", $name["ID"] );
377
378 if ( $row->settingID() == $name["ID"] )
379 $t->set_var( "selected", "selected" );
380 else
381 $t->set_var( "selected", "" );
382
383 $t->parse( "settings", "settings_tpl", true );
384 }
385 if ( $i > 0 && isset( $move_item ) )
386 {
387 $t->parse( "item_move_up", "item_move_up_tpl" );
388 }
389 else
390 {
391 $t->parse( "no_item_move_up", "no_item_move_up_tpl" );
392 }
393
394 if ( $i > 0 && $i < $count - 1 && isset( $move_item ) )
395 {
396 $t->parse( "item_separator", "item_separator_tpl" );
397 }
398 else
399 {
400 $t->parse( "no_item_separator", "no_item_separator_tpl" );
401 }
402
403 if ( $i < $count - 1 && isset( $move_item ) )
404 {
405 $t->parse( "item_move_down", "item_move_down_tpl" );
406 }
407 else
408 {
409 $t->parse( "no_item_move_down", "no_item_move_down_tpl" );
410 }
411
412 if ( ( $i % 2 ) == 0 )
413 {
414 $t->set_var( "td_class", "bglight" );
415 }
416 else
417 {
418 $t->set_var( "td_class", "bgdark" );
419 }
420 $t->set_var( "counter", $i );
421 $t->parse( "setting_item", "setting_item_tpl", true );
422 $i++;
423 }
424 $t->parse( "setting_list", "setting_list_tpl" );
425 }
426
427 $t->pparse( "output", "section_edit_page" );
428
429 ?>
$category
if( $Action=="Edit") $category
Definition: adedit.php:378
$i
$i
Definition: admin/adlist.php:91
$CategoryID
$CategoryID
Definition: admin/articleedit.php:53
$session
$session
Definition: admin/articlelist.php:44
$ad
$ad
Definition: adstatistics.php:56
$Description
$Description
Definition: articlelistrss.php:38
eZAdCategory
Definition: ezadcategory.php:44
eZArticleCategory
Definition: ezarticlecategory.php:45
eZHTTPTool\header
static header( $string)
Definition: ezhttptool.php:96
eZINI
Reads and writes .ini style configuration files.
eZPBFile\is_dir
static is_dir( $dir)
Definition: ezpbfile.php:402
eZProductCategory
Definition: ezproductcategory.php:90
eZSectionFrontPage
Definition: ezsectionfrontpage.php:43
eZSectionFrontPage\settingNames
static & settingNames()
Definition: ezsectionfrontpage.php:200
eZSection
Definition: ezsection.php:45
eZSession\globalSession
static & globalSession( $id="", $fetch=true)
Definition: kernel/ezsession/classes/ezsession.php:614
eZTemplate
Definition: eztemplate.php:107
$name
$name
Definition: companytypelist.php:194
$tree
$tree
Definition: ezad/admin/categoryedit.php:172
$SiteDesign
$SiteDesign
Definition: ezbulkmail/user/datasupplier.php:31
$row
$row
Definition: ezcalendar/user/dayview.php:403
$SectionID
$SectionID
Definition: ezfilemanager/user/filelist.php:46
$section
$section
Definition: ezimagecatalogue/user/categoryedit.php:393
exit
exit
Definition: folder.php:81
$rows
$rows
Definition: frontpage.php:128
$count
$count
Definition: onlinetypelist.php:108
$Name
$Name
Definition: polledit.php:250
$warning
$warning
Definition: sectionedit.php:95
$t
$t
Definition: sectionedit.php:59
$languageINI
$languageINI
Definition: sectionedit.php:57
$Language
$Language
Definition: sectionedit.php:55
$settingNames
$settingNames
Definition: sectionedit.php:247
$Action
$Action
Definition: sectionedit.php:38
$move_item
$move_item
Definition: sectionedit.php:56
$ini
if(isset( $OK)) if(isset( $Delete)) if(isset( $Cancel)) $ini
Definition: sectionedit.php:54
$user
$user
Definition: user/adlist.php:39
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.