Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

ezmediacatalogue/admin/typeedit.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: typeedit.php 6292 2001-07-26 11:23:53Z ce $
5 //
6 // Created on: <29-Jan-2001 11:44:23 jhe>
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: /mediacatalogue/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( "eZMediaCatalogueMain", "Language" );
41 $move_item = true;
42
43 // include_once( "ezmediacatalogue/classes/ezmediatype.php" );
44 // include_once( "ezmediacatalogue/classes/ezmediaattribute.php" );
45
46 if ( isset( $Action ) && $Action == "Insert" )
47 {
48 $type = new eZMediaType();
49 $type->setName( $Name );
50
51 $type->store();
52
53 $TypeID = $type->id();
54 $Action = "Edit";
55 }
56
57
58 if ( ( isset( $Action ) && $Action == "Update" ) || ( isset ( $Update ) ) )
59 {
60 $type = new eZMediaType( $TypeID );
61 $type->setName( $Name );
62
63 $type->store();
64
65 // update attributes
66 $i =0;
67 if ( isset( $AttributeName ) && count( $AttributeName ) > 0 )
68 {
69 foreach ( $AttributeName as $attribute )
70 {
71 $att = new eZMediaAttribute( $AttributeID[$i] );
72 $att->setName( $attribute );
73 $att->setDefaultValue( $AttributeDefault[$i] );
74 $att->store();
75
76 $i++;
77 }
78 }
79 $Action = "Edit";
80 }
81
82 if( isset( $Action ) && $Action == "up" )
83 {
84 $attribute = new eZMediaAttribute( $AttributeID );
85 $attribute->moveUp();
86 eZHTTPTool::header( "Location: /mediacatalogue/typeedit/edit/$TypeID" );
87 exit();
88 }
89
90 if( isset( $Action ) && $Action == "down" )
91 {
92 $attribute = new eZMediaAttribute( $AttributeID );
93 $attribute->moveDown();
94 eZHTTPTool::header( "Location: /mediacatalogue/typeedit/edit/$TypeID" );
95 exit();
96 }
97
98 if( isset( $Ok ) )
99 {
100 eZHTTPTool::header( "Location: /mediacatalogue/typelist/" );
101 exit();
102 }
103
104 if ( isset ( $DeleteSelected ) )
105 {
106 if ( isset( $DeleteAttributes ) && count ( $DeleteAttributes ) > 0 )
107 {
108 foreach ( $DeleteAttributes as $attID )
109 {
110 $attribute = new eZMediaAttribute( $attID );
111 $attribute->delete();
112 }
113 }
114 $Action = "Edit";
115 }
116
117
118 if ( isset( $NewAttribute ) )
119 {
120 $attribute = new eZMediaAttribute();
121 $attribute->setType( $type );
122 $attribute->setName( "New attribute" );
123 $attribute->store();
124 }
125
126
127 if ( isset( $Action ) && $Action == "Delete" )
128 {
129 $type = new eZProductType();
130 $type->get( $TypeID );
131
132 $type->delete();
133
134 eZHTTPTool::header( "Location: /mediacatalogue/typelist/" );
135 exit();
136 }
137
138 $t = new eZTemplate( "kernel/ezmediacatalogue/admin/" . $ini->variable( "eZMediaCatalogueMain", "AdminTemplateDir" ),
139 "kernel/ezmediacatalogue/admin/intl/", $Language, "typeedit.php" );
140
141 $t->setAllStrings();
142
143 $t->set_file( "type_edit_tpl", "typeedit.tpl" );
144 $t->set_block( "type_edit_tpl", "value_tpl", "value" );
145
146 $t->set_block( "type_edit_tpl", "attribute_list_tpl", "attribute_list" );
147 $t->set_block( "attribute_list_tpl", "attribute_tpl", "attribute" );
148
149 $t->set_block( "attribute_tpl", "item_move_up_tpl", "item_move_up" );
150 $t->set_block( "attribute_tpl", "item_separator_tpl", "item_separator" );
151 $t->set_block( "attribute_tpl", "item_move_down_tpl", "item_move_down" );
152 $t->set_block( "attribute_tpl", "no_item_move_up_tpl", "no_item_move_up" );
153 $t->set_block( "attribute_tpl", "no_item_separator_tpl", "no_item_separator" );
154 $t->set_block( "attribute_tpl", "no_item_move_down_tpl", "no_item_move_down" );
155
156 $type = new eZMediaType();
157
158 $typeArray = $type->getAll( );
159
160 $t->set_var( "attribute_list", "" );
161 $t->set_var( "name_value", "" );
162 $t->set_var( "type_id", "" );
163 $t->set_var( "action_value", "Insert" );
164
165 // edit
166 if ( isset( $Action ) && $Action == "Edit" )
167 {
168 $type = new eZMediaType();
169 $type->get( $TypeID );
170
171 $t->set_var( "name_value", $type->name() );
172 $t->set_var( "action_value", "Update" );
173 $t->set_var( "type_id", $type->id() );
174
175 $attributes = $type->attributes();
176
177 $count = count ( $attributes );
178 $i = 0;
179 foreach ( $attributes as $attribute )
180 {
181 $t->set_var( "item_move_up", "" );
182 $t->set_var( "no_item_move_up", "" );
183 $t->set_var( "item_move_down", "" );
184 $t->set_var( "no_item_move_down", "" );
185 $t->set_var( "item_separator", "" );
186 $t->set_var( "no_item_separator", "" );
187
188 $t->set_var( "attribute_id", $attribute->id( ) );
189 $t->set_var( "attribute_name", $attribute->name( ) );
190 $t->set_var( "attribute_default", $attribute->defaultValue( ) );
191
192 $t->set_var( "is_1_selected", "" );
193 $t->set_var( "is_2_selected", "" );
194
195 if ( $i > 0 && isset( $move_item ) )
196 {
197 $t->parse( "item_move_up", "item_move_up_tpl" );
198 }
199 else
200 {
201 $t->parse( "no_item_move_up", "no_item_move_up_tpl" );
202 }
203
204 if ( $i > 0 && $i < $count - 1 && isset( $move_item ) )
205 {
206 $t->parse( "item_separator", "item_separator_tpl" );
207 }
208 else
209 {
210 $t->parse( "no_item_separator", "no_item_separator_tpl" );
211 }
212
213 if ( $i < $count - 1 && isset( $move_item ) )
214 {
215 $t->parse( "item_move_down", "item_move_down_tpl" );
216 }
217 else
218 {
219 $t->parse( "no_item_move_down", "no_item_move_down_tpl" );
220 }
221
222 if ( ( $i % 2 ) == 0 )
223 {
224 $t->set_var( "td_class", "bglight" );
225 }
226 else
227 {
228 $t->set_var( "td_class", "bgdark" );
229 }
230 $t->set_var( "counter", $i );
231 $t->parse( "attribute", "attribute_tpl", true );
232 $i++;
233 }
234
235 if ( count( $attributes ) > 0 )
236 {
237 $t->parse( "attribute_list", "attribute_list_tpl", true );
238 }
239 else
240 {
241 $t->set_var( "attribute_list", " ", true );
242 }
243
244 }
245
246 $t->pparse( "output", "type_edit_tpl" );
247
248 ?>
$i
$i
Definition: admin/adlist.php:91
eZHTTPTool\header
static header( $string)
Definition: ezhttptool.php:96
eZMediaAttribute
Definition: ezmediaattribute.php:49
eZMediaType
Definition: ezmediatype.php:33
eZProductType
Definition: ezproducttype.php:46
eZTemplate
Definition: eztemplate.php:107
$Action
$Action
Definition: companysearch.php:80
$t
if(isset( $Action) && $Action=="Insert") if((isset( $Action) && $Action=="Update")||(isset( $Update))) if(isset( $Action) && $Action=="up") if(isset( $Action) && $Action=="down") if(isset( $Ok)) if(isset( $DeleteSelected)) if(isset( $NewAttribute)) if(isset( $Action) && $Action=="Delete") $t
Definition: ezmediacatalogue/admin/typeedit.php:138
$ini
if(isset( $Cancel)) $ini
Definition: ezmediacatalogue/admin/typeedit.php:39
$Language
$Language
Definition: ezmediacatalogue/admin/typeedit.php:40
$type
$type
Definition: ezmediacatalogue/admin/typeedit.php:156
$move_item
$move_item
Definition: ezmediacatalogue/admin/typeedit.php:41
$typeArray
$typeArray
Definition: ezmediacatalogue/admin/typeedit.php:158
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+.