Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

eztrade/admin/typeedit.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: typeedit.php 7163 2001-09-12 10:50:36Z br $
5 //
6 // Created on: <20-Dec-2000 18:24:06 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
29 if ( isset( $Cancel ) )
30 {
31 eZHTTPTool::header( "Location: /trade/typelist/" );
32 exit();
33 }
34
35 // include_once( "classes/INIFile.php" );
36 // include_once( "classes/eztemplate.php" );
37
38
39 $ini =& eZINI::instance( 'site.ini' );
40 $Language = $ini->variable( "eZTradeMain", "Language" );
41 $move_item = true;
42
43 // include_once( "eztrade/classes/ezproducttype.php" );
44 // include_once( "eztrade/classes/ezproductattribute.php" );
45
46 if ( $Action == "Insert" )
47 {
48 $type = new eZProductType();
49 $type->setName( $Name );
50 $type->setDescription( $Description );
51
52 $type->store();
53
54 $TypeID = $type->id();
55 $Action = "Edit";
56 }
57
58
59 if ( ( $Action == "Update" ) || ( isset ( $Update ) ) )
60 {
61 $type = new eZProductType( $TypeID );
62 $type->setName( $Name );
63 $type->setDescription( $Description );
64
65 $type->store();
66
67 // update attributes
68 $i =0;
69 if ( count( $AttributeName ) > 0 )
70 {
71
72 foreach ( $AttributeName as $attribute )
73 {
74 $att = new eZProductAttribute( $AttributeID[$i] );
75 $att->setName( $attribute );
76 $att->setAttributeType( $AttributeType[$i] );
77 $att->setUnit( $Unit[$i] );
78 $att->store();
79
80 $i++;
81 }
82 }
83 $Action="Edit";
84 }
85
86 if( $Action == "up" )
87 {
88 $attribute = new eZProductAttribute( $AttributeID );
89 $attribute->moveUp();
90 // include_once( "classes/ezhttptool.php" );
91 eZHTTPTool::header( "Location: /trade/typeedit/edit/$TypeID" );
92 exit();
93 }
94
95 if( $Action == "down" )
96 {
97 $attribute = new eZProductAttribute( $AttributeID );
98 $attribute->moveDown();
99 // include_once( "classes/ezhttptool.php" );
100 eZHTTPTool::header( "Location: /trade/typeedit/edit/$TypeID" );
101 exit();
102 }
103
104 if( isset( $Ok ) )
105 {
106 eZHTTPTool::header( "Location: /trade/typelist/" );
107 exit();
108 }
109
110 if ( isset ( $DeleteSelected ) )
111 {
112 if ( count ( $DeleteAttributes ) > 0 )
113 {
114 foreach ( $DeleteAttributes as $attID )
115 {
116 $attribute = new eZProductAttribute( $attID );
117 $attribute->delete();
118 }
119 }
120 $Action = "Edit";
121 }
122
123
124 if ( isset( $NewAttribute ) )
125 {
126 $attribute = new eZProductAttribute();
127 $attribute->setType( $type );
128 $attribute->setAttributeType( 1 );
129 $attribute->setName( "New attribute" );
130 $attribute->store();
131 }
132
133
134 if ( $Action == "Delete" )
135 {
136 $type = new eZProductType();
137 $type->get( $TypeID );
138
139 $type->delete();
140
141 eZHTTPTool::header( "Location: /trade/typelist/" );
142 exit();
143 }
144
145 $t = new eZTemplate( "kernel/eztrade/admin/" . $ini->variable( "eZTradeMain", "AdminTemplateDir" ),
146 "kernel/eztrade/admin/intl/", $Language, "typeedit.php" );
147
148 $t->setAllStrings();
149
150 $t->set_file( array( "type_edit_tpl" => "typeedit.tpl" ) );
151
152
153 $t->set_block( "type_edit_tpl", "value_tpl", "value" );
154
155 $t->set_block( "type_edit_tpl", "attribute_list_tpl", "attribute_list" );
156 $t->set_block( "attribute_list_tpl", "attribute_tpl", "attribute" );
157
158 $t->set_block( "attribute_tpl", "item_move_up_tpl", "item_move_up" );
159 $t->set_block( "attribute_tpl", "item_separator_tpl", "item_separator" );
160 $t->set_block( "attribute_tpl", "item_move_down_tpl", "item_move_down" );
161 $t->set_block( "attribute_tpl", "no_item_move_up_tpl", "no_item_move_up" );
162 $t->set_block( "attribute_tpl", "no_item_separator_tpl", "no_item_separator" );
163 $t->set_block( "attribute_tpl", "no_item_move_down_tpl", "no_item_move_down" );
164
165
166 $type = new eZProductType();
167
168 $typeArray = $type->getAll( );
169
170 $t->set_var( "attribute_list", "" );
171 $t->set_var( "description_value", "" );
172 $t->set_var( "name_value", "" );
173 $t->set_var( "type_id", "" );
174 $t->set_var( "action_value", "Insert" );
175
176 // edit
177 if ( $Action == "Edit" )
178 {
179 $type = new eZProductType();
180 $type->get( $TypeID );
181
182 $t->set_var( "name_value", $type->name() );
183 $t->set_var( "description_value", $type->description() );
184 $t->set_var( "action_value", "Update" );
185 $t->set_var( "type_id", $type->id() );
186
187
188 $attributes = $type->attributes();
189
190 $count = count ( $attributes );
191 $i = 0;
192 foreach ( $attributes as $attribute )
193 {
194 $t->set_var( "item_move_up", "" );
195 $t->set_var( "no_item_move_up", "" );
196 $t->set_var( "item_move_down", "" );
197 $t->set_var( "no_item_move_down", "" );
198 $t->set_var( "item_separator", "" );
199 $t->set_var( "no_item_separator", "" );
200
201 $t->set_var( "attribute_id", $attribute->id( ) );
202 $t->set_var( "attribute_name", $attribute->name( ) );
203 $t->set_var( "attribute_unit", $attribute->unit( ) );
204
205 $t->set_var( "is_1_selected", "" );
206 $t->set_var( "is_2_selected", "" );
207
208 if ( $attribute->attributeType() == 1 )
209 $t->set_var( "is_1_selected", "checked" );
210 elseif ( $attribute->attributeType() == 2 )
211 $t->set_var( "is_2_selected", "checked" );
212
213
214 if ( $i > 0 && isset( $move_item ) )
215 {
216 $t->parse( "item_move_up", "item_move_up_tpl" );
217 }
218 else
219 {
220 $t->parse( "no_item_move_up", "no_item_move_up_tpl" );
221 }
222
223 if ( $i > 0 && $i < $count - 1 && isset( $move_item ) )
224 {
225 $t->parse( "item_separator", "item_separator_tpl" );
226 }
227 else
228 {
229 $t->parse( "no_item_separator", "no_item_separator_tpl" );
230 }
231
232 if ( $i < $count - 1 && isset( $move_item ) )
233 {
234 $t->parse( "item_move_down", "item_move_down_tpl" );
235 }
236 else
237 {
238 $t->parse( "no_item_move_down", "no_item_move_down_tpl" );
239 }
240
241 if ( ( $i % 2 ) == 0 )
242 {
243 $t->set_var( "td_class", "bglight" );
244 }
245 else
246 {
247 $t->set_var( "td_class", "bgdark" );
248 }
249 $t->set_var( "counter", $i );
250 $t->parse( "attribute", "attribute_tpl", true );
251 $i++;
252 }
253
254 if ( count( $attributes ) > 0 )
255 {
256 $t->parse( "attribute_list", "attribute_list_tpl", true );
257 }
258 else
259 {
260 $t->set_var( "attribute_list", "" );
261 }
262
263 }
264
265
266 $t->pparse( "output", "type_edit_tpl" );
267
268 ?>
$i
$i
Definition: admin/adlist.php:91
$Description
$Description
Definition: articlelistrss.php:38
eZHTTPTool\header
static header( $string)
Definition: ezhttptool.php:96
eZProductAttribute
Definition: ezproductattribute.php:49
eZProductType
Definition: ezproducttype.php:46
eZTemplate
Definition: eztemplate.php:107
$Action
$Action
Definition: companysearch.php:80
$ini
if(isset( $Cancel)) $ini
Definition: eztrade/admin/typeedit.php:39
$Language
$Language
Definition: eztrade/admin/typeedit.php:40
$type
$type
Definition: eztrade/admin/typeedit.php:166
$t
if( $Action=="Insert") if(( $Action=="Update")||(isset( $Update))) if( $Action=="up") if( $Action=="down") if(isset( $Ok)) if(isset( $DeleteSelected)) if(isset( $NewAttribute)) if( $Action=="Delete") $t
Definition: eztrade/admin/typeedit.php:145
$move_item
$move_item
Definition: eztrade/admin/typeedit.php:41
$typeArray
$typeArray
Definition: eztrade/admin/typeedit.php:168
exit
exit
Definition: folder.php:81
$count
$count
Definition: onlinetypelist.php:108
$Name
$Name
Definition: polledit.php:250
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.