Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

eztip/admin/categoryedit.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: categoryedit.php,v 1.10 2001/07/19 11:56:33 jakobn Exp $
5 //
6 // Created on: <18-Sep-2000 14:46:19 bf>
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/ezhttptool.php" );
28 // include_once( "ezsitemanager/classes/ezsection.php" );
29
30 if ( isset( $Cancel ) )
31 {
32 eZHTTPTool::header( "Location: /tip/archive/0/" );
33 exit();
34 }
35
36 if ( isset ( $DeleteCategories ) )
37 {
38 $Action = "DeleteCategories";
39 }
40
41 // include_once( "classes/INIFile.php" );
42 // include_once( "classes/eztemplate.php" );
43
44 $ini =& eZINI::instance( 'site.ini' );
45 $Language = $ini->variable( "eZTipMain", "Language" );
46
47 // include_once( "eztip/classes/eztip.php" );
48 // include_once( "eztip/classes/eztipcategory.php" );
49
50 if ( !isset( $ParentID ) )
51 {
52 $ParentID = 0;
53 }
54
55 // Direct actions
56 if ( $Action == "Insert" )
57 {
58
59 $category = new eZTipCategory();
60 $category->setName( $Name );
61
62 $parentCategory = new eZTipCategory();
63
64 if ( $parentCategory->get( $ParentID ) == true )
65 $category->setParent( $parentCategory );
66
67 $category->setParent( $ParentID );
68
69 $category->setDescription( $Description );
70 $category->setIsPublished( $IsPublished );
71 $category->setSectionArray( $SectionArray );
72
73 $category->setLocationID( $LocationID );
74
75 $category->store();
76
77 $categoryID = $category->id();
78
79 eZHTTPTool::header( "Location: /tip/archive/$categoryID/" );
80 exit();
81 }
82
83 if ( $Action == "Update" )
84 {
85 $category = new eZTipCategory();
86 $category->get( $CategoryID );
87 $category->setName( $Name );
88
89 $parentCategory = new eZTipCategory();
90 $category->setParent( $ParentID );
91
92 $category->setDescription( $Description );
93 $category->setIsPublished( $IsPublished );
94 $category->setSectionArray( $SectionArray );
95
96 $category->setLocationID( $LocationID );
97
98 $category->store();
99
100 $categoryID = $category->id();
101
102 eZHTTPTool::header( "Location: /tip/archive/$categoryID/" );
103 exit();
104 }
105
106 if ( $Action == "Delete" )
107 {
108 $category = new eZTipCategory();
109 $category->get( $CategoryID );
110
111 $category->delete();
112
113 eZHTTPTool::header( "Location: /tip/archive/" );
114 exit();
115 }
116
117 if ( $Action == "DeleteCategories" )
118 {
119 if ( count ( $CategoryArrayID ) != 0 )
120 {
121 foreach( $CategoryArrayID as $ID )
122 {
123 $category = new eZTipCategory( $ID );
124 $category->delete();
125 }
126 }
127
128 eZHTTPTool::header( "Location: /tip/archive/" );
129 exit();
130 }
131
132 $t = new eZTemplate( "kernel/eztip/admin/" . $ini->variable( "eZTipMain", "AdminTemplateDir" ),
133 "kernel/eztip/admin/intl/", $Language, "categoryedit.php" );
134
135 $t->setAllStrings();
136
137 $t->set_file( array( "category_edit_tpl" => "categoryedit.tpl" ) );
138
139
140 //$t->set_block( "category_edit_tpl", "value_tpl", "value" );
141
142 $category = new eZTipCategory();
143
144 $categoryArray = $category->getAll( );
145
146 $t->set_var( "category_id", isset( $CategoryID ) ? $CategoryID : 0 );
147
148 // edit
149 if ( $Action == "Edit" )
150 {
151 $category = new eZTipCategory();
152 $category->get( $CategoryID );
153
154 $t->set_var( "name_value", $category->name() );
155 $t->set_var( "description_value", $category->description() );
156 $t->set_var( "action_value", "update" );
157 $t->set_var( "category_id", $category->id() );
158
159 $parent = $category->parent();
160
161 if( is_object( $parent ) )
162 {
163 $parentID = $parent->id();
164 }
165 else
166 {
167 $parentID = 0;
168 }
169 if ( $category->ispublished() == true )
170 {
171 $t->set_var( "is_published", "checked" );
172 }
173
174 }
175
176 if ( $Action == "Edit" || $Action == "New")
177 {
178
179 $t->set_var( "description_value", "" );
180 $t->set_var( "name_value", "" );
181 $t->set_var( "action_value", "insert" );
182 // $t->set_var( "category_id", "" );
183
184 $category = new eZTipCategory();
185
186 //get category tree
187 // $tree = $category->getTree();
188
189 // foreach( $tree as $item )
190 // {
191 // if ($item[0]->id() != $CategoryID) {
192 // $t->set_var( "option_value", $item[0]->id() );
193 // $t->set_var( "option_name", $item[0]->name() );
194
195 // if ( $item[1] > 0 )
196 // $t->set_var( "option_level", str_repeat( "&nbsp;", $item[1] ) );
197 // else
198 // $t->set_var( "option_level", "" );
199
200 // if ( $item[0]->id() == $parentID )
201 // {
202 // $t->set_var( "selected", "selected" );
203 // $selected = true;
204 // }
205 // else
206 // {
207 // $t->set_var( "selected", "" );
208 // }
209
210 // $t->parse( "value", "value_tpl", true );
211 // }
212 // }
213
214 // section selector
215 $section = new eZSection();
216 $sectionList = $section->getAll();
217 $category = new eZTipCategory();
218 $category->get( $CategoryID );
219 $sectionArrayList = $category->getSectionArray();
220
221 $t->set_block( "category_edit_tpl", "section_item_tpl", "section_item" );
222 $t->set_var( "selected", "" );
223
224 if ( in_array( "0", $sectionArrayList ) )
225 {
226 $t->set_var( "all-selected", "selected" );
227 }
228
229 foreach ( $sectionList as $sectionItem )
230 {
231 $t->set_var( "section_name", $sectionItem->name() );
232 $t->set_var( "section_id", $sectionItem->id() );
233 if ( in_array( $sectionItem->id(), $sectionArrayList ) )
234 $t->set_var( "selected", "selected" );
235 else
236 $t->set_var( "selected", "" );
237 $t->parse( "section_item", "section_item_tpl", true );
238 }
239
240 // Location selector
241 $TipLocations = $ini->variable( "eZTipMain", "TipLocations" );
242 //$LocationList = array();
243 $LocationList = explode(";" , $TipLocations);
244 $category = new eZTipCategory();
245 $category->get( $CategoryID );
246
247 $t->set_block( "category_edit_tpl", "location_item_tpl", "location_item" );
248 $t->set_var( "selected", "" );
249 $locID = 0;
250 foreach ( $LocationList as $LocationItem )
251 {
252 $t->set_var( "location_name", $LocationList[$locID] );
253 $t->set_var( "location_id", $locID );
254 if ( $category->locationID() == $locID)
255 $t->set_var( "selected", "selected" );
256 else
257 $t->set_var( "selected", "" );
258
259 $t->parse( "location_item", "location_item_tpl", true );
260 $locID ++;
261 }
262 }
263
264 $t->pparse( "output", "category_edit_tpl" );
265
266 ?>
$CategoryID
$CategoryID
Definition: admin/articleedit.php:53
$Description
$Description
Definition: articlelistrss.php:38
eZHTTPTool\header
static header( $string)
Definition: ezhttptool.php:96
eZSection
Definition: ezsection.php:45
eZTemplate
Definition: eztemplate.php:107
eZTipCategory
Definition: eztipcategory.php:44
$Action
$Action
Definition: companysearch.php:80
$sectionList
foreach( $groupList as $groupItem) $sectionList
Definition: ezarticle/admin/categoryedit.php:615
$section
$section
Definition: ezimagecatalogue/user/categoryedit.php:393
$category
$category
Definition: eztip/admin/categoryedit.php:142
$ini
if(isset( $Cancel)) if(isset( $DeleteCategories)) $ini
Definition: eztip/admin/categoryedit.php:44
$Language
$Language
Definition: eztip/admin/categoryedit.php:45
$t
if(!isset( $ParentID)) if( $Action=="Insert") if( $Action=="Update") if( $Action=="Delete") if( $Action=="DeleteCategories") $t
Definition: eztip/admin/categoryedit.php:132
$categoryArray
$categoryArray
Definition: eztip/admin/categoryedit.php:144
$ParentID
$ParentID
Definition: eztrade/admin/categorylist.php:171
exit
exit
Definition: folder.php:81
$Name
$Name
Definition: polledit.php:250
$categoryID
else $categoryID
Definition: productview.php:66
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.