Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

ezlink/admin/categoryedit.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: categoryedit.php 8123 2001-10-31 12:06:39Z br $
5 //
6 // Created on: <26-Oct-2000 14:57:28 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
28 // include_once( "classes/INIFile.php" );
29
30 $ini =& eZINI::instance( 'site.ini' );
31 $Language = $ini->variable( "eZLinkMain", "Language" );
32 $error = new eZINI( "kernel/ezuser/admin/intl/" . $Language . "/useredit.php.ini", false );
33 $error_msg = false;
34
35 // include_once( "classes/eztemplate.php" );
36 // include_once( "classes/ezhttptool.php" );
37 // include_once( "classes/ezcachefile.php" );
38
39 // include_once( "ezlink/classes/ezlinkcategory.php" );
40 // include_once( "ezlink/classes/ezlink.php" );
41 // include_once( "ezlink/classes/ezhit.php" );
42
43 // include_once( "ezimagecatalogue/classes/ezimage.php" );
44 // include_once( "ezimagecatalogue/classes/ezimagecategory.php" );
45
46 // include_once( "ezsitemanager/classes/ezsection.php" );
47
48
49 require( "kernel/ezuser/admin/admincheck.php" );
50
51 if ( isset ( $DeleteCategories ) )
52 {
53 $Action = "DeleteCategories";
54 }
55
56 // Get images from the image browse function.
57 if ( ( isset ( $AddImages ) ) and ( is_numeric( $LinkCategoryID ) ) and ( is_numeric ( $LinkCategoryID ) ) )
58 {
59 $image = new eZImage( $ImageID );
60 $category = new eZLinkCategory( $LinkCategoryID );
61 $category->setImage( $image );
62 $category->update();
63 $Action = "edit";
64 }
65
66 // Insert a category.
67
68 if ( isset( $Action ) && $Action == "insert" )
69 {
70 // clear the menu cache
71 $files =& eZCacheFile::files( "kernel/ezlink/cache/",
72 array( "menubox",
73 NULL ),
74 "cache", "," );
75 foreach( $files as $file )
76 {
77 $file->delete();
78 }
79
80 if ( eZPermission::checkPermission( $user, "eZLink", "LinkCategoryAdd" ) )
81 {
82 if ( $Name != "" &&
83 $ParentCategory != "" )
84 {
85 $category = new eZLinkCategory();
86
87 $category->setName( $Name );
88 $category->setDescription( $Description );
89 $category->setSectionID( $SectionID );
90 $category->setParent( $ParentCategory );
91 $ttile = "";
92
93 $file = new eZPBImageFile();
94 if ( $file->getUploadedFile( "ImageFile" ) )
95 {
96 $image = new eZImage( );
97 $image->setName( "Image" );
98 $image->setImage( $file );
99
100 $image->store();
101
102 $category->setImage( $image );
103 }
104 else
105 {
106 $category->setImage( 0 );
107 }
108
109 $category->store();
110
111 if ( isset ( $Browse ) )
112 {
113 $categoryID = $category->id();
114
115 $session =& eZSession::globalSession();
116 $session->setVariable( "SelectImages", "single" );
117 $session->setVariable( "ImageListReturnTo", "/link/categoryedit/edit/$categoryID/" );
118 $session->setVariable( "NameInBrowse", $category->name() );
119 eZHTTPTool::header( "Location: /imagecatalogue/browse/" );
120 exit();
121 }
122 eZHTTPTool::header( "Location: /link/category/". $ParentCategory );
123 exit();
124 }
125 else
126 {
127 $error_msg = $error->variable( "strings", "error_missingdata" );
128 }
129 }
130 else
131 {
132 $error_msg = $error->variable( "strings", "error_norights" );
133 eZHTTPTool::header( "Location: /link/norights" );
134 exit();
135 }
136 }
137
138 // Delete a category.
139 if ( isset( $Action ) && $Action == "delete" )
140 {
141 // clear the menu cache
142 $files =& eZCacheFile::files( "kernel/ezlink/cache/",
143 array( "menubox",
144 NULL ),
145 "cache", "," );
146 foreach( $files as $file )
147 {
148 $file->delete();
149 }
150
151 if ( eZPermission::checkPermission( $user, "eZLink", "LinkCategoryDelete" ) )
152 {
153 $category = new eZLinkCategory();
154 $category->get( $LinkCategoryID );
155 $category->delete();
156
157 eZHTTPTool::header( "Location: /link/category/" );
158 exit();
159 }
160 else
161 {
162 eZHTTPTool::header( "Location: /link/norights" );
163 }
164 }
165
166 if ( isset( $Action ) && $Action == "DeleteCategories" )
167 {
168 // clear the menu cache
169 $files =& eZCacheFile::files( "kernel/ezlink/cache/",
170 array( "menubox",
171 NULL ),
172 "cache", "," );
173 foreach( $files as $file )
174 {
175 $file->delete();
176 }
177
178 if ( eZPermission::checkPermission( $user, "eZLink", "LinkCategoryDelete" ) )
179 {
180 if ( count ( $CategoryArrayID ) != 0 )
181 {
182 foreach( $CategoryArrayID as $CategoryID )
183 {
184 $category = new eZLinkCategory();
185 $category->get( $CategoryID );
186 $parentID = $category->parent();
187 $category->delete();
188 }
189 eZHTTPTool::header( "Location: /link/category/$parentID" );
190 exit();
191 }
192 }
193 else
194 {
195 eZHTTPTool::header( "Location: /link/norights" );
196 }
197 }
198
199 // Update a category.
200 if ( isset( $Action ) && $Action == "update" )
201 {
202 // clear the menu cache
203 $files =& eZCacheFile::files( "kernel/ezlink/cache/",
204 array( "menubox",
205 NULL ),
206 "cache", "," );
207 foreach( $files as $file )
208 {
209 $file->delete();
210 }
211
212 if ( eZPermission::checkPermission( $user, "eZLink", "LinkCategoryModify" ) )
213 {
214 if ( $Name != "" &&
215 $ParentCategory != "" )
216 {
217 $category = new eZLinkCategory();
218 $category->get( $LinkCategoryID );
219 $category->setName( $Name );
220 $category->setDescription( $Description );
221 $category->setSectionID( $SectionID );
222 $category->setParent( $ParentCategory );
223
224 $file = new eZPBImageFile();
225 if ( $file->getUploadedFile( "ImageFile" ) )
226 {
227 $image = new eZImage( );
228 $image->setName( "Image" );
229 $image->setImage( $file );
230
231 $image->store();
232
233 $category->setImage( $image );
234 }
235
236 $category->update();
237
238 if ( $DeleteImage )
239 {
240 $category->deleteImage();
241 }
242
243 if ( isset ( $Browse ) )
244 {
245 $categoryID = $category->id();
246 $session = eZSession::globalSession();
247 $session->setVariable( "SelectImages", "single" );
248 $session->setVariable( "ImageListReturnTo", "/link/categoryedit/edit/$categoryID/" );
249 $session->setVariable( "NameInBrowse", $category->name() );
250 eZHTTPTool::header( "Location: /imagecatalogue/browse/" );
251 exit();
252 }
253
254 eZHTTPTool::header( "Location: /link/category/$ParentCategory" );
255 exit();
256 }
257 else
258 {
259 $error_msg = $error->variable( "strings", "error_missingdata" );
260 }
261 }
262 else
263 {
264 eZHTTPTool::header( "Location: /link/norights" );
265 }
266 }
267
268 $t = new eZTemplate( "kernel/ezlink/admin/" . $ini->variable( "eZLinkMain", "AdminTemplateDir" ),
269 "kernel/ezlink/admin/" . "/intl/", $Language, "categoryedit.php" );
270 $t->setAllStrings();
271
272 $t->set_file( array(
273 "category_edit" => "categoryedit.tpl"
274 ));
275
276 $languageIni = new eZINI( "kernel/ezlink/admin/intl/" . $Language . "/categoryedit.php.ini", false );
277 $headline = $languageIni->variable( "strings", "headline_insert" );
278
279 $t->set_block( "category_edit", "section_item_tpl", "section_item" );
280 $t->set_block( "category_edit", "parent_category_tpl", "parent_category" );
281 $t->set_block( "category_edit", "image_item_tpl", "image_item" );
282 $t->set_block( "category_edit", "no_image_item_tpl", "no_image_item" );
283 $t->set_var( "category_id", "" );
284
285 $categoryselect = new eZLinkCategory();
286 $categoryLinkList = $categoryselect->getTree( );
287
288 if ( $Action == "new" )
289 {
290 if ( !eZPermission::checkPermission( $user, "eZLink", "LinkCategoryAdd" ) )
291 {
292 eZHTTPTool::header( "Location: /link/norights" );
293 }
294
295 $t->set_var( "image_item", "" );
296 $t->set_var( "no_image_item", "" );
297 $t->set_var( "category_name", "" );
298 $t->set_var( "category_description", "" );
299 $t->set_var( "category_id", "" );
300
301 $t->set_var( "action_value", "insert" );
302
303 $error_msg = false;
304 $sectionID = false;
305 $parentID = false;
306 }
307
308 // Modifing a category.
309 if ( $Action == "edit" )
310 {
311 $languageIni = new eZINI( "kernel/ezlink/admin/intl/" . $Language . "/categoryedit.php.ini", false );
312 $headline = $languageIni->variable( "strings", "headline_edit" );
313
314 if ( !eZPermission::checkPermission( $user, "eZLink", "LinkCategoryModify" ) )
315 {
316 eZHTTPTool::header( "Location: /link/norights" );
317 }
318 else
319 {
320 $linkCategory = new eZLinkCategory();
321 $linkCategory->get( $LinkCategoryID );
322
323 $parentID = $linkCategory->parent();
324 $sectionID = $linkCategory->sectionID();
325
326 $t->set_var( "category_name", $linkCategory->name() );
327 $t->set_var( "category_description", $linkCategory->description() );
328 $t->set_var( "category_id", $linkCategory->id() );
329
330 $image =& $linkCategory->image();
331
332 if ( is_a( $image, "eZImage" ) && $image->id() != 0 )
333 {
334 $imageWidth =& $ini->variable( "eZLinkMain", "CategoryImageWidth" );
335 $imageHeight =& $ini->variable( "eZLinkMain", "CategoryImageHeight" );
336
337 $variation =& $image->requestImageVariation( $imageWidth, $imageHeight );
338
339 $imageURL = "/" . $variation->imagePath();
340 $imageWidth = $variation->width();
341 $imageHeight = $variation->height();
342 $imageCaption = $image->caption();
343
344 $t->set_var( "image_width", $imageWidth );
345 $t->set_var( "image_height", $imageHeight );
346 $t->set_var( "image_url", $imageURL );
347 $t->set_var( "image_caption", $imageCaption );
348 $t->set_var( "no_image_item", "" );
349 $t->parse( "image_item", "image_item_tpl" );
350 }
351 else
352 {
353 $t->parse( "no_image_item", "no_image_item_tpl" );
354 $t->set_var( "image_item", "" );
355 }
356
357 $t->set_var( "action_value", "update" );
358 }
359
360 }
361
362 // Selecter
363 $category_select_dict = "";
364 foreach( $categoryLinkList as $i => $categoryLinkItem )
365 {
366 $t->set_var( "categorylink_id", $categoryLinkItem[0]->id() );
367 $t->set_var( "categorylink_name", $categoryLinkItem[0]->name() );
368 $t->set_var( "categorylink_parent", $categoryLinkItem[0]->parent() );
369
370 if ( is_numeric( $parentID ) )
371 {
372 if ( $parentID == $categoryLinkItem[0]->id() )
373 {
374 $t->set_var( "is_selected", "selected" );
375 }
376 else
377 {
378 $t->set_var( "is_selected", "" );
379 }
380 }
381
382 if ( $categoryLinkItem[1] > 0 )
383 $t->set_var( "option_level", str_repeat( "&nbsp;", $categoryLinkItem[1] ) );
384 else
385 $t->set_var( "option_level", "" );
386
387
388 $category_select_dict[ $categoryLinkItem[0]->id() ] = $i;
389
390 $t->parse( "parent_category", "parent_category_tpl", true );
391 }
392
393
394 // Get all sections
395
396 $sectionList =& eZSection::getAll();
397
398 if ( count( $sectionList ) > 0 )
399 {
400 foreach ( $sectionList as $section )
401 {
402 $t->set_var( "section_id", $section->id() );
403 $t->set_var( "section_name", $section->name() );
404
405 if ( $sectionID == $section->id() )
406 $t->set_var( "section_is_selected", "selected" );
407 else
408 $t->set_var( "section_is_selected", "" );
409
410 $t->parse( "section_item", "section_item_tpl", true );
411 }
412 }
413 else
414 $t->set_var( "section_item", "" );
415
416
417
418 $t->set_var( "headline", $headline );
419
420 $t->set_var( "error_msg", $error_msg );
421
422 $t->pparse( "output", "category_edit" );
423
424 ?>
$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
$linkCategory
$linkCategory
Definition: admin/linkcategorylist.php:90
$Description
$Description
Definition: articlelistrss.php:38
$files
$files
Definition: articlepreview.php:91
eZHTTPTool\header
static header( $string)
Definition: ezhttptool.php:96
eZINI
Reads and writes .ini style configuration files.
eZImage
Definition: ezimage.php:95
eZLinkCategory
Definition: ezlinkcategory.php:37
eZPBImageFile
Definition: ezpbimagefile.php:71
eZPermission\checkPermission
static checkPermission( $user, $moduleName, $permissionName)
Definition: ezpermission.php:430
eZSection\getAll
static getAll( $offset=0, $limit=40)
Definition: ezsection.php:177
eZSession\globalSession
static & globalSession( $id="", $fetch=true)
Definition: kernel/ezsession/classes/ezsession.php:614
eZTemplate
Definition: eztemplate.php:107
$Action
$Action
Definition: companysearch.php:80
$ImageID
$ImageID
Definition: companytypelist.php:201
$file
$file
Definition: ezfilemanager/user/filedownload.php:35
$SectionID
$SectionID
Definition: ezfilemanager/user/filelist.php:46
$section
$section
Definition: ezimagecatalogue/user/categoryedit.php:393
$variation
$variation
Definition: ezimagecatalogue/user/menubox.php:55
$languageIni
$languageIni
Definition: ezlink/admin/categoryedit.php:276
$headline
$headline
Definition: ezlink/admin/categoryedit.php:277
$categoryLinkList
$categoryLinkList
Definition: ezlink/admin/categoryedit.php:286
$sectionList
foreach( $categoryLinkList as $i=> $categoryLinkItem) $sectionList
Definition: ezlink/admin/categoryedit.php:396
$Language
$Language
Definition: ezlink/admin/categoryedit.php:31
$category_select_dict
if( $Action=="new") if( $Action=="edit") $category_select_dict
Definition: ezlink/admin/categoryedit.php:363
$ini
$ini
Definition: ezlink/admin/categoryedit.php:30
$t
if(isset( $DeleteCategories)) if((isset( $AddImages)) and(is_numeric( $LinkCategoryID)) and(is_numeric( $LinkCategoryID))) if(isset( $Action) && $Action=="insert") if(isset( $Action) && $Action=="delete") if(isset( $Action) && $Action=="DeleteCategories") if(isset( $Action) && $Action=="update") $t
Definition: ezlink/admin/categoryedit.php:268
$categoryselect
$categoryselect
Definition: ezlink/admin/categoryedit.php:285
$error_msg
$error_msg
Definition: ezlink/admin/categoryedit.php:33
$error
$error
Definition: ezlink/admin/categoryedit.php:32
exit
exit
Definition: folder.php:81
$Name
$Name
Definition: polledit.php:250
$categoryID
else $categoryID
Definition: productview.php:66
$user
$user
Definition: user/adlist.php:39
$image
$image
Definition: user/articlelist.php:242
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.