Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

ezcontact/admin/typelist.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: typelist.php 6927 2001-09-04 12:06:17Z jhe $
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 lists. It requires an object with the following functions:
29 name(): Used for reading the name of the type.
30 id(): Used for retrieving the id of the type in the database
31
32 The object list must be initialized in the $item_type_array variable.
33 Also these following variables must be set properly.
34 $language_file: The file used for reading language translations, for example: consultationtype.php
35 $page_path: The base name of the url, for example: /contact/consultationtype
36 You can also enable item placement by setting the $move_item variable to true, to make sure an
37 item can be moved it must implement the moveUp() and moveDown() functions.
38 If the $SortPage variable is set all items will have hyperlinked names linked to the variable content.
39 */
40
41 $ini =& $GlobalSiteIni;
42 $Language = $ini->variable( "eZContactMain", "Language" );
43 $DOC_ROOT = $ini->variable( "eZContactMain", "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
54 $t = new eZTemplate( $DOC_ROOT . "/admin/" . $ini->variable( "eZContactMain", "AdminTemplateDir" ),
55 $DOC_ROOT . "admin/intl", $Language, $language_file );
56 $t->setAllStrings();
57
58 $item_error = true;
59
60 if ( empty( $_SERVER['HTTP_REFERER'] ) )
61 {
62 if ( empty( $BackUrl ) )
63 {
64 $back_command = "$page_path/list";
65 }
66 else
67 {
68 $back_command = $BackUrl;
69 }
70 }
71 else
72 {
73 $back_command = $_SERVER['HTTP_REFERER'];
74 }
75
76 if ( !isset( $typelist ) )
77 $typelist = "typelist.tpl";
78
79 if ( isset( $template_array ) and isset( $variable_array ) and
80 is_array( $template_array ) and is_array( $variable_array ) )
81 {
82 $standard_array = array( "list_page" => $typelist );
83 $t->set_file( array_merge( $standard_array, $template_array ) );
84 $t->set_file_block( $template_array );
85 if ( isset( $block_array ) and is_array( $block_array ) )
86 $t->set_block( $block_array );
87 $t->parse( $variable_array );
88 }
89 else
90 {
91 $t->set_var( "extra_type_header", "" );
92 $t->set_var( "extra_type_item", "" );
93 $t->set_file( "list_page", $typelist );
94 }
95
96 $t->set_block( "list_page", "list_item_tpl", "list_item" );
97 $t->set_block( "list_item_tpl", "line_item_tpl", "line_item" );
98 $t->set_block( "list_page", "no_line_item_tpl", "no_line_item" );
99 $t->set_block( "list_page", "search_item_tpl", "search_item" );
100
101 $t->set_block( "line_item_tpl", "item_plain_tpl", "item_plain" );
102 $t->set_block( "line_item_tpl", "item_linked_tpl", "item_linked" );
103 $t->set_block( "line_item_tpl", "item_move_up_tpl", "item_move_up" );
104 $t->set_block( "line_item_tpl", "item_separator_tpl", "item_separator" );
105 $t->set_block( "line_item_tpl", "item_move_down_tpl", "item_move_down" );
106 $t->set_block( "line_item_tpl", "no_item_move_up_tpl", "no_item_move_up" );
107 $t->set_block( "line_item_tpl", "no_item_separator_tpl", "no_item_separator" );
108 $t->set_block( "line_item_tpl", "no_item_move_down_tpl", "no_item_move_down" );
109
110 $t->set_block( "list_page", "type_list_tpl", "type_list" );
111 $t->set_block( "type_list_tpl", "type_list_previous_tpl", "type_list_previous" );
112 $t->set_block( "type_list_tpl", "type_list_item_tpl", "type_list_item" );
113 $t->set_block( "type_list_tpl", "type_list_next_tpl", "type_list_next" );
114 $t->set_block( "type_list_tpl", "type_list_previous_inactive_tpl", "type_list_previous_inactive" );
115 $t->set_block( "type_list_tpl", "type_list_next_inactive_tpl", "type_list_next_inactive" );
116
117 $t->set_var( "no_line_item", "" );
118 $t->set_var( "line_item", "" );
119 $t->set_var( "list_item", "" );
120 $t->set_var( "search_item", "" );
121
122 $t->set_var( "item_up_command", "$page_path/up" );
123 $t->set_var( "item_down_command", "$page_path/down" );
124 $t->set_var( "item_edit_command", "$page_path/edit" );
125 $t->set_var( "item_delete_command", "$page_path/delete" );
126 $t->set_var( "item_view_command", "$page_path/view" );
127 $t->set_var( "item_list_command", "$page_path/list" );
128 $t->set_var( "item_new_command", "$page_path/new" );
129 $t->set_var( "item_id", isset( $ItemID ) ? $ItemID : false );
130 $t->set_var( "item_name", isset( $ItemName ) ? $ItemName : false );
131 $t->set_var( "back_url", $back_command );
132 $t->set_var( "item_back_command", $back_command );
133
134 $t->set_var( "action", $Action );
135 $t->set_var( "type", $ListType );
136
137 $t->set_var( "search_form_text", isset( $SearchText ) ? $SearchText : false );
138 $t->set_var( "search_text", isset( $search_encoded ) ? $search_encoded : false );
139
140 if ( isset( $Searchable ) )
141 $t->parse( "search_item", "search_item_tpl" );
142
143 $count = count( $item_type_array );
144
145 $i = 0;
146 foreach ( $item_type_array as $item )
147 {
148 $t->set_var( "item_move_up", "" );
149 $t->set_var( "no_item_move_up", "" );
150 $t->set_var( "item_move_down", "" );
151 $t->set_var( "no_item_move_down", "" );
152 $t->set_var( "item_separator", "" );
153 $t->set_var( "no_item_separator", "" );
154
155 $t->set_var( "item_plain", "" );
156 $t->set_var( "item_linked", "" );
157
158 if ( ( $i %2 ) == 0 )
159 $t->set_var( "bg_color", "bglight" );
160 else
161 $t->set_var( "bg_color", "bgdark" );
162
163 if ( isset( $func_call ) and is_array( $func_call ) )
164 {
165 reset( $func_call );
166 while( list( $key,$val ) = each( $func_call ) )
167 {
168 $t->set_var( $key, $item->$val() );
169 }
170 }
171 else
172 {
173 $t->set_var( "item_id", $item->id() );
174 $t->set_var( "item_name", $item->name() );
175 }
176
177 if ( isset( $SortPage ) )
178 {
179 $t->set_var( "item_sort_command", $SortPage );
180 $t->parse( "item_linked", "item_linked_tpl" );
181 }
182 else
183 {
184 $t->parse( "item_plain", "item_plain_tpl" );
185 }
186
187 if ( $i > 0 && isset( $move_item ) )
188 {
189 $t->parse( "item_move_up", "item_move_up_tpl" );
190 }
191 else
192 {
193 $t->parse( "no_item_move_up", "no_item_move_up_tpl" );
194 }
195
196 if ( $i > 0 && $i < $count - 1 && isset( $move_item ) )
197 {
198 $t->parse( "item_separator", "item_separator_tpl" );
199 }
200 else
201 {
202 $t->parse( "no_item_separator", "no_item_separator_tpl" );
203 }
204
205 if ( $i < $count - 1 && isset( $move_item ) )
206 {
207 $t->parse( "item_move_down", "item_move_down_tpl" );
208 }
209 else
210 {
211 $t->parse( "no_item_move_down", "no_item_move_down_tpl" );
212 }
213
214 $t->parse( "line_item", "line_item_tpl", true );
215
216 $i++;
217 }
218
219 if ( $count < 1 )
220 {
221 $t->parse( "no_line_item", "no_line_item_tpl" );
222 }
223 else
224 {
225 $t->parse( "list_item", "list_item_tpl" );
226 }
227
228 if ( isset( $total_types ) && $total_types > $Max || $Offset > 0 )
229 {
230 $t->set_var( "type_list_previous", "" );
231 $t->set_var( "type_list_item", "" );
232 $t->set_var( "type_list_next", "" );
233 $t->set_var( "type_list_previous_inactive", "" );
234 $t->set_var( "type_list_next_inactive", "" );
235
236 if ( $Offset > 0 )
237 {
238 $t->set_var( "item_previous_index", max( $Offset - $Max, 0 ) );
239 $t->parse( "type_list_previous", "type_list_previous_tpl" );
240 }
241 else
242 {
243 $t->parse( "type_list_previous_inactive", "type_list_previous_inactive_tpl" );
244 }
245 if ( $Offset + $Max < $total_types )
246 {
247 $t->set_var( "item_next_index", $Offset + $Max );
248 $t->parse( "type_list_next", "type_list_next_tpl" );
249 }
250 else
251 {
252 $t->parse( "type_list_next_inactive", "type_list_next_inactive_tpl" );
253 }
254
255 $total = $total_types;
256 $i = 0;
257 while ( $total > 0 )
258 {
259 $t->set_var( "item_index", $i*$Max );
260 $t->set_var( "type_item_name", $i );
261 $t->parse( "type_list_item", "type_list_item_tpl", true );
262
263 $total = $total - $Max;
264 $i++;
265 }
266
267 $t->parse( "type_list", "type_list_tpl" );
268 }
269 else
270 {
271 $t->set_var( "type_list", "" );
272 }
273
274 $t->pparse( "output", "list_page" );
275
276 ?>
$language_file
$language_file
Definition: addresstypeedit.php:30
$item_type_array
$item_type_array
Definition: addresstypelist.php:34
$move_item
$move_item
Definition: addresstypelist.php:35
$total
else $total["inctax"]
Definition: checkout.php:1359
eZTemplate
Definition: eztemplate.php:107
$item
$item
Definition: classes/admin/linklist.php:228
$Action
$Action
Definition: companysearch.php:80
$SortPage
$SortPage
Definition: consultationtypelist.php:51
$func_call
$func_call
Definition: countryedit.php:46
$block_array
$block_array
Definition: countryedit.php:44
$template_array
$template_array
Definition: countryedit.php:43
$Max
$Max
Definition: countrylist.php:31
$total_types
$total_types
Definition: countrylist.php:47
$Searchable
$Searchable
Definition: countrylist.php:51
$typelist
$typelist
Definition: countrylist.php:37
$variable_array
$variable_array
Definition: countrylist.php:39
$ListType
$ListType
Definition: ezaddress/admin/datasupplier.php:31
$SearchText
$SearchText
Definition: ezaddress/admin/typelist.php:143
$search_encoded
$search_encoded
Definition: ezaddress/admin/typelist_pre.php:49
$Offset
$Offset
Definition: ezarticle/user/search.php:110
$GlobalSiteIni
$GlobalSiteIni
Definition: ezarticle/xmlrpc/xmlrpcserver.php:33
$DOC_ROOT
$DOC_ROOT
Definition: ezcontact/admin/typelist.php:43
$t
$t
Definition: ezcontact/admin/typelist.php:54
$item_error
$item_error
Definition: ezcontact/admin/typelist.php:58
$i
$i
Definition: ezcontact/admin/typelist.php:145
$Language
$Language
Definition: ezcontact/admin/typelist.php:42
$ini
$ini
Definition: ezcontact/admin/typelist.php:41
$count
$count
Definition: ezcontact/admin/typelist.php:143
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.