Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

ezaddress/admin/typeedit.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: typeedit.php 7938 2001-10-17 12:19:26Z ce $
5 //
6 // Created on: <23-Oct-2000 17:53:46 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 /*
28 This code can be reused for simple type edits. It requires an object with the following functions:
29 name() and setName(): Used for reading and setting the name of the type.
30 id(): Used for retrieving the id of the type in the database
31 count(): Used for calculating the number of external items dependent on this type
32
33 The object must be initialized in the $item_type variable.
34 Also these following variables must be set properly.
35 $language_file: The file used for reading language translations, for example: consultationtype.php
36 $page_path: The base name of the url, for example: /address/consultationtype
37 If $template_array, $block_array, $func_call and $func_call_set is set they are used for
38 reading and writing extra information not available from the standard template.
39 */
40
41 $ini =& eZINI::instance( 'site.ini' );
42 $Language = $ini->variable( "eZAddressMain", "Language" );
43 $DOC_ROOT = $ini->variable( "eZAddressMain", "DocumentRoot" );
44
45 // include_once( "classes/eztemplate.php" );
46
47 // include_once( "ezuser/classes/ezuser.php" );
48 // include_once( "ezuser/classes/ezusergroup.php" );
49 // include_once( "ezuser/classes/ezmodule.php" );
50 // include_once( "ezuser/classes/ezpermission.php" );
51
52 require( "kernel/ezuser/admin/admincheck.php" );
53 $t =new eZTemplate( "kernel/ezaddress/admin/" . $ini->variable( "eZAddressMain", "AdminTemplateDir" ), "kernel/ezaddress/admin/" . "/intl", $Language, $language_file );
54
55 $t->setAllStrings();
56
57 $item_error = true;
58
59 if( empty( $HTTP_REFERER ) )
60 {
61 if( empty( $BackUrl ) )
62 {
63 $back_command = "$page_path/list";
64 }
65 else
66 {
67 $back_command = $BackUrl;
68 }
69 }
70 else
71 {
72 $back_command = $HTTP_REFERER;
73 }
74
75 if ( isset( $Delete ) and isset( $ItemArrayID ) and isset( $item_types ) )
76 {
77 foreach( $item_types as $item_type )
78 {
79 $item_type->delete( false );
80 }
81 // include_once( "classes/ezhttptool.php" );
82 eZHTTPTool::header( "Location: $page_path/list" );
83 exit();
84 }
85
86 if( isset( $Action ) && $Action == "up" )
87 {
88 $item_type->moveUp();
89 // include_once( "classes/ezhttptool.php" );
90 eZHTTPTool::header( "Location: $page_path/list" );
91 exit();
92 }
93
94 if( isset( $Action ) && $Action == "down" )
95 {
96 $item_type->moveDown();
97 // include_once( "classes/ezhttptool.php" );
98 eZHTTPTool::header( "Location: $page_path/list" );
99 exit();
100 }
101
102 if( isset( $Action ) && $Action == "insert" or isset( $Action ) && $Action == "update" )
103 {
104 if ( isset( $Action ) && $Action == "insert" )
105 unset( $item_type->ID );
106
107 if ( isset( $func_call_set ) and is_array( $func_call_set ) )
108 {
109 reset( $func_call_set );
110 foreach( $func_call_set as $key => $val )
111 {
112 if ( $key == "setHasVAT" )
113 {
114 if ( ${$val} == "on" )
115 $item_type->$key( true );
116 else
117 $item_type->$key( false );
118 }
119 else
120 $item_type->$key( ${$val} );
121 }
122 }
123 else
124 {
125 $item_type->setName( $ItemName );
126 }
127 $item_type->store();
128 // include_once( "classes/ezhttptool.php" );
129 eZHTTPTool::header( "Location: $page_path/list" );
130 }
131
132 if ( !isset( $typeedit ) )
133 $typeedit = "typeedit.tpl";
134 if ( isset( $template_array ) and isset( $block_array ) and
135 is_array( $template_array ) and is_array( $block_array ) )
136 {
137 $standard_array = array( "list_page" => $typeedit );
138 $t->set_file( array_merge( $standard_array, $template_array ) );
139 $t->set_file_block( $template_array );
140 $t->parse( $block_array );
141 }
142 else
143 {
144 $t->set_var( "extra_type_input", "" );
145 $t->set_file( "list_page", $typeedit );
146 }
147 $t->set_block( "list_page", "type_edit_tpl", "type_edit" );
148
149 $t->set_block( "type_edit_tpl", "line_item_tpl", "line_item" );
150 $t->set_block( "type_edit_tpl", "no_line_item_tpl", "no_line_item" );
151
152 $t->set_var( "no_line_item", "" );
153 $t->set_var( "line_item", "" );
154
155 $t->set_var( "item_id", isset( $ItemID ) ? $ItemID : false );
156 $t->set_var( "item_name", isset( $ItemName ) ? $ItemName : false );
157
158 $t->set_var( "back_url", $back_command );
159 $t->set_var( "item_back_command", $back_command );
160
161 if( !isset( $error ) || $error == false )
162 {
163 $t->set_var( "errors", "" );
164 }
165
166 if ( isset( $func_call ) and is_array( $func_call ) )
167 {
168 reset( $func_call );
169 foreach( $func_call as $key => $val )
170 {
171 if ( $key == "item_has_vat" )
172 {
173 if( $item_type->$val() )
174 {
175 $t->set_var( $key, "checked" );
176 }
177 else
178 {
179 $t->set_var( $key, "" );
180 }
181 }
182 else
183 $t->set_var( $key, $item_type->$val() );
184 }
185 }
186 else
187 {
188 if( is_numeric( $item_type->id() ) )
189 {
190 $t->set_var( "item_id", $item_type->id() );
191 $t->set_var( "item_name", $item_type->name() );
192 }
193 }
194
195 if( isset( $Action ) && $Action == "edit" )
196 {
197 $action_value = "update";
198
199 if( is_numeric( $item_type->id() ) )
200 {
201 $item_error = false;
202 }
203 }
204
205 if( isset( $Action ) && $Action == "new" )
206 {
207 $action_value = "insert";
208
209 $item_error = false;
210 }
211
212 if( $item_error == true )
213 {
214 $t->parse( "no_line_item", "no_line_item_tpl" );
215 }
216 else
217 {
218 $t->parse( "line_item", "line_item_tpl" );
219 }
220
221 $t->parse( "type_edit", "type_edit_tpl", true );
222
223 $t->set_var( "form_path", $page_path );
224 $t->set_var( "action_value", $action_value );
225 $t->pparse( "output", "list_page" );
226
227 ?>
$language_file
$language_file
Definition: addresstypeedit.php:30
$item_type
$item_type
Definition: addresstypeedit.php:31
$page_path
if(isset( $ItemArrayID) and is_array( $ItemArrayID)) $page_path
Definition: addresstypeedit.php:42
$item_types
$item_types
Definition: addresstypeedit.php:32
eZHTTPTool\header
static header( $string)
Definition: ezhttptool.php:96
eZTemplate
Definition: eztemplate.php:107
$Action
$Action
Definition: companysearch.php:80
$typeedit
$typeedit
Definition: countryedit.php:42
$func_call
$func_call
Definition: countryedit.php:46
$func_call_set
$func_call_set
Definition: countryedit.php:51
$block_array
$block_array
Definition: countryedit.php:44
$template_array
$template_array
Definition: countryedit.php:43
$DOC_ROOT
$DOC_ROOT
Definition: ezaddress/admin/typeedit.php:43
$t
$t
Definition: ezaddress/admin/typeedit.php:53
$item_error
$item_error
Definition: ezaddress/admin/typeedit.php:57
$Language
$Language
Definition: ezaddress/admin/typeedit.php:42
$ini
$ini
Definition: ezaddress/admin/typeedit.php:41
$error
$error
Definition: ezarticle/admin/categoryedit.php:51
$action_value
$action_value
Definition: ezforum/admin/categoryedit.php:212
exit
exit
Definition: folder.php:81
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.