Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

ezlist.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: ezlist.php 7213 2001-09-14 11:00:57Z br $
5 //
6 // Definition of eZList class
7 //
8 // Created on: <06-Feb-2001 15:31:37 amos>
9 //
10 // This source file is part of Exponential Basic, publishing software.
11 //
12 // Copyright (C) 1999-2001 eZ Systems. All rights reserved.
13 //
14 // This program is free software; you can redistribute it and/or
15 // modify it under the terms of the GNU General Public License
16 // as published by the Free Software Foundation; either version 2
17 // of the License, or (at your option) any later version.
18 //
19 // This program is distributed in the hope that it will be useful,
20 // but WITHOUT ANY WARRANTY; without even the implied warranty of
21 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 // GNU General Public License for more details.
23 //
24 // You should have received a copy of the GNU General Public License
25 // along with this program; if not, write to the Free Software
26 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, US
27 //
28
31
48 //include_once( "kernel/classes/INIFile.php" );
49 //include_once( "kernel/classes/eztexttool.php" );
50
51 class eZList
52 {
53
70 static public function drawList( $params, $no_print = false )
71 {
72 if ( !is_array( $params ) )
73 {
74 print( "<br /><b>eZList::drawList() requires $" .
75 "params to be an array</b><br />" );
76 return false;
77 }
78
79 if ( isset( $params["ini"] ) )
80 $ini =& $params["ini"];
81 else
82 $ini =& eZINI::instance( 'site.ini' );
83 if ( !is_a( $ini, "INIFile" ) )
84 $ini =& eZINI::instance( 'site.ini' );
85
86 $module = $params["module"];
87 $module_main = $params["module_main"];
88 $place = $params["place"];
89 if ( $place == "" )
90 $place = "admin";
91 $template_dir = $params["templatedir"];
92 if ( $template_dir == "" )
93 $template_dir = "AdminTemplateDir";
94 $language_file = $params["language_file"];
95
96 $Language = $ini->variable( $module_main, "Language" );
97 // $DOC_ROOT = $ini->variable( $module_main, "DocumentRoot" );
98
99 // include_once( "kernel/classes/eztemplate.php" );
100
101 if ( !isset( $params["typelist"] ) )
102 $template_dir = "kernel/classes/" . $ini->variable( "classes", $template_dir );
103 else
104 $template_dir = "kernel/$module/$place/" . $ini->variable( $module_main, $template_dir );
105
106
107 if ( !isset( $params["template"] ) or !is_a( $params["template"], "eZTemplate" ) )
108 $t = new eZTemplate( $template_dir,
109 "kernel/$module/$place/intl", $Language, $language_file );
110 else
111 $t =& $params["template"];
112
113 $item_error = true;
114
115 $HTTP_REFERER = $params["HTTP_REFERER"];
116 $BackUrl = $params["back_url"];
117 $page_path = $params["page_path"];
118 $search_encoded = $params['search_encoded'];
119
120 if( $HTTP_REFERER == "" )
121 {
122 if( $BackUrl == "" )
123 {
124 $back_command = "$page_path/list";
125 }
126 else
127 {
128 $back_command = $BackUrl;
129 }
130 }
131 else
132 {
133 $back_command = $HTTP_REFERER;
134 }
135
136 if ( !isset( $params["typelist"] ) )
137 $typelist = "typelist.tpl";
138 else
139 $typelist = $params["typelist"];
140
141 if ( isset( $params["template_array"] ) )
142 $template_array = $params["template_array"];
143 if ( isset( $params["variable_array"] ) )
144 $variable_array = $params["variable_array"];
145 if ( isset( $params["block_array"] ) )
146 $block_array = $params["block_array"];
147
148 if ( isset( $template_array ) and isset( $variable_array ) and
149 is_array( $template_array ) and is_array( $variable_array ) )
150 {
151 $standard_array = array( "list_page" => $typelist );
152 $t->set_file( array_merge( $standard_array, $template_array ) );
153 $t->set_file_block( $template_array );
154 if ( isset( $block_array ) and is_array( $block_array ) )
155 $t->set_block( $block_array );
156 $t->parse( $variable_array );
157 }
158 else
159 {
160 $t->set_var( "extra_type_header", "" );
161 $t->set_var( "extra_type_item", "" );
162 $t->set_file( "list_page", $typelist );
163 }
164
165 $t->set_block( "list_page", "list_item_tpl", "list_item" );
166 $t->set_block( "list_item_tpl", "line_item_tpl", "line_item" );
167 $t->set_block( "list_page", "no_line_item_tpl", "no_line_item" );
168 $t->set_block( "list_page", "search_item_tpl", "search_item" );
169
170 $t->set_block( "list_item_tpl", "name_header_item_tpl", "name_header_item" );
171 $t->set_block( "list_item_tpl", "custom_header_item_tpl", "custom_header_item" );
172 $t->set_block( "list_item_tpl", "header_move_down_tpl", "header_move_down" );
173 $t->set_block( "list_item_tpl", "header_separator_tpl", "header_separator" );
174 $t->set_block( "list_item_tpl", "header_move_up_tpl", "header_move_up" );
175 $t->set_block( "list_item_tpl", "delete_header_item_tpl", "delete_header_item" );
176
177 $t->set_block( "line_item_tpl", "type_item_tpl", "type_item" );
178 $t->set_block( "type_item_tpl", "item_plain_tpl", "item_plain" );
179 $t->set_block( "type_item_tpl", "item_linked_tpl", "item_linked" );
180 $t->set_block( "line_item_tpl", "item_move_up_tpl", "item_move_up" );
181 $t->set_block( "line_item_tpl", "item_separator_tpl", "item_separator" );
182 $t->set_block( "line_item_tpl", "item_move_down_tpl", "item_move_down" );
183 $t->set_block( "line_item_tpl", "no_item_move_up_tpl", "no_item_move_up" );
184 $t->set_block( "line_item_tpl", "no_item_separator_tpl", "no_item_separator" );
185 $t->set_block( "line_item_tpl", "no_item_move_down_tpl", "no_item_move_down" );
186 $t->set_block( "line_item_tpl", "delete_box_item_tpl", "delete_box_item" );
187
188 $t->set_block( "list_page", "delete_button_item_tpl", "delete_button_item" );
189
190 $t->set_var( "no_line_item", "" );
191 $t->set_var( "line_item", "" );
192 $t->set_var( "list_item", "" );
193 $t->set_var( "search_item", "" );
194
195 $ItemID = $params["item_id"];
196 $ItemName = $params["item_name"];
197 $Action = $params["action"];
198 $ListType = $params["list_type"];
199 $SearchText = $params["search_text"];
200 if ( isset( $params["searchable"] ) )
201 $Searchable = $params["searchable"];
202 $item_type_array =& $params["item_type_array"];
203
204 if ( isset( $params["form_command"] ) )
205 $item_form_command = $params["form_command"];
206 else
207 $itme_form_command = "$page_path/new";
208
209 $t->set_var( "item_up_command", "$page_path/up" );
210 $t->set_var( "item_down_command", "$page_path/down" );
211 $t->set_var( "item_edit_command", "$page_path/edit" );
212 $t->set_var( "item_delete_command", "$page_path/delete" );
213 $t->set_var( "item_view_command", "$page_path/view" );
214 $t->set_var( "item_list_command", "$page_path/list" );
215 $t->set_var( "item_new_command", "$page_path/new" );
216 $t->set_var( "item_form_command", $item_form_command );
217 $t->set_var( "item_id", $ItemID );
218 $t->set_var( "item_name", $ItemName );
219 $t->set_var( "back_url", $back_command );
220 $t->set_var( "item_back_command", $back_command );
221
222 $t->set_var( "action", $Action );
223 $t->set_var( "type", $ListType );
224
225 $SearchText = stripslashes( $SearchText );
226 $t->set_var( "search_form_text", $SearchText );
227 $t->set_var( "search_text", $search_encoded );
228
229 if ( isset( $Searchable ) )
230 $t->parse( "search_item", "search_item_tpl" );
231
232 $count = count( $item_type_array );
233
234 if ( isset( $params["func_call"] ) )
235 $func_call =& $params["func_call"];
236 if ( isset( $params["custom_func_call"] ) )
237 $custom_func_call =& $params["custom_func_call"];
238 if ( isset( $params["item_url"] ) )
239 $ItemUrl = $params["item_url"];
240 if ( isset( $params["move_item" ] ) )
241 $move_item = $params["move_item"];
242
243 $t->set_var( "name_header_item", "" );
244 $t->set_var( "custom_header_item", "" );
245 if ( isset( $params["header_names"] ) )
246 {
247 foreach( $params["header_names"] as $header )
248 {
249 $t->set_var( "custom_header", $header );
250 $t->parse( "custom_header_item", "custom_header_item_tpl", true );
251 }
252 }
253 else
254 {
255 $t->parse( "name_header_item", "name_header_item_tpl" );
256 }
257
258 $t->set_var( "delete_header_item", "" );
259 $t->set_var( "delete_box_item", "" );
260 $t->set_var( "delete_button_item", "" );
261 if ( !isset( $params["no_delete"] ) )
262 {
263 $t->parse( "delete_header_item", "delete_header_item_tpl" );
264 $t->parse( "delete_button_item", "delete_button_item_tpl" );
265 }
266
267 $i = 0;
268 foreach( $item_type_array as $item )
269 {
270 $t->set_var( "item_move_up", "" );
271 $t->set_var( "no_item_move_up", "" );
272 $t->set_var( "item_move_down", "" );
273 $t->set_var( "no_item_move_down", "" );
274 $t->set_var( "item_separator", "" );
275 $t->set_var( "no_item_separator", "" );
276
277 $t->set_var( "type_item", "" );
278 $t->set_var( "item_plain", "" );
279 $t->set_var( "item_linked", "" );
280
281 $t->set_var( "bg_color", ( $i %2 ) == 0 ? "bglight" : "bgdark" );
282
283 if ( isset( $func_call ) and is_array( $func_call ) )
284 {
285 reset( $func_call );
286 foreach( $func_call as $key => $val )
287 {
288 $t->set_var( $key, eZTextTool::htmlspecialchars( $item->$val() ) );
289 }
290 }
291 else
292 {
293 $t->set_var( "item_id", $item->id() );
294 $t->set_var( "item_name", eZTextTool::htmlspecialchars( $item->name() ) );
295 }
296
297 if ( isset( $ItemUrl ) )
298 {
299 $t->set_var( "item_url_command", $ItemUrl );
300 $t->parse( "item_linked", "item_linked_tpl" );
301 }
302 else
303 {
304 $t->parse( "item_plain", "item_plain_tpl" );
305 }
306 $t->parse( "type_item", "type_item_tpl", true );
307
308 if ( isset( $custom_func_call ) and is_array( $custom_func_call ) )
309 {
310 $t->set_var( "item_plain", "" );
311 $t->set_var( "item_linked", "" );
312 reset( $custom_func_call );
313 foreach( $custom_func_call as $key => $val )
314 {
315 $t->set_var( "item_name", eZTextTool::htmlspecialchars( $item->$val() ) );
316 $t->parse( "item_plain", "item_plain_tpl" );
317 $t->parse( "type_item", "type_item_tpl", true );
318 }
319 }
320
321 if ( $i > 0 && isset( $move_item ) )
322 {
323 $t->parse( "item_move_up", "item_move_up_tpl" );
324 }
325 else
326 {
327 $t->parse( "no_item_move_up", "no_item_move_up_tpl" );
328 }
329
330 if ( $i > 0 && $i < $count - 1 && isset( $move_item ) )
331 {
332 $t->parse( "item_separator", "item_separator_tpl" );
333 }
334 else
335 {
336 $t->parse( "no_item_separator", "no_item_separator_tpl" );
337 }
338
339 if ( $i < $count - 1 && isset( $move_item ) )
340 {
341 $t->parse( "item_move_down", "item_move_down_tpl" );
342 }
343 else
344 {
345 $t->parse( "no_item_move_down", "no_item_move_down_tpl" );
346 }
347 if ( !isset( $params["no_delete"] ) )
348 $t->parse( "delete_box_item", "delete_box_item_tpl" );
349
350 $t->parse( "line_item", "line_item_tpl", true );
351
352 $i++;
353 }
354
355 if( $count < 1 )
356 {
357 $t->parse( "no_line_item", "no_line_item_tpl" );
358 }
359 else
360 {
361 $t->parse( "list_item", "list_item_tpl" );
362 }
363
364 $t->setAllStrings();
365
366 $Max = $params["max"];
367 $Offset = $params["offset"];
368 $total_types = $params["total_types"];
369
370 if ( is_numeric( $total_types ) and $total_types >= 0 )
371 eZList::drawNavigator( $t, $total_types, $Max, $Offset, "list_page" );
372
373 if ( !$no_print )
374 $t->pparse( "output", "list_page" );
375 else
376 return $t->parse( "output", "list_page" );
377 }
378
401 static public function drawNavigator( &$t, $total_types, $max_types, $index, $parent = false,
402 $variables = false )
403 {
404 if ( is_array( $variables ) )
405 {
406 $next = $variables["next"];
407 $prev = $variables["previous"];
408 $next_inactive = $variables["next_inactive"];
409 $prev_inactive = $variables["previous_inactive"];
410 $item = $variables["item"];
411 $item_inactive = $variables["item_inactive"];
412 $item_list = $variables["item_list"];
413 $next_index = $variables["next_index"];
414 $prev_index = $variables["previous_index"];
415 $item_index = $variables["item_index"];
416 $item_name = $variables["item_name"];
417 $type_list = $variables["type_list"];
418 }
419
420 if ( empty( $next ) )
421 $next = "type_list_next";
422 if ( empty( $prev ) )
423 $prev = "type_list_previous";
424 if ( empty( $next_inactive ) )
425 $next_inactive = "type_list_next_inactive";
426 if ( empty( $prev_inactive ) )
427 $prev_inactive = "type_list_previous_inactive";
428 if ( empty( $item_list ) )
429 $item_list = "type_list_item_list";
430 if ( empty( $item ) )
431 $item = "type_list_item";
432 if ( empty( $item_inactive ) )
433 $item_inactive = "type_list_inactive_item";
434 if ( empty( $next_index ) )
435 $next_index = "item_next_index";
436 if ( empty( $prev_index ) )
437 $prev_index = "item_previous_index";
438 if ( empty( $item_index ) )
439 $item_index = "item_index";
440 if ( empty( $item_name ) )
441 $item_name = "type_item_name";
442 if ( empty( $type_list ) )
443 $type_list = "type_list";
444
445 if ( is_string( $parent ) )
446 $t->set_block( $parent, $type_list . "_tpl", $type_list );
447
448 if ( ( $total_types > $max_types || $index > 0 ) and is_string( $parent ) )
449 {
450 $t->set_block( $type_list . "_tpl", $prev . "_tpl", $prev );
451 $t->set_block( $type_list . "_tpl", $item_list . "_tpl", $item_list );
452 $t->set_block( $item_list . "_tpl", $item . "_tpl", $item );
453 $t->set_block( $item_list . "_tpl", $item_inactive . "_tpl", $item_inactive );
454 $t->set_block( $type_list . "_tpl", $next . "_tpl", $next );
455 $t->set_block( $type_list . "_tpl", $prev_inactive . "_tpl", $prev_inactive );
456 $t->set_block( $type_list . "_tpl", $next_inactive . "_tpl", $next_inactive );
457 }
458
459 if ( $total_types > $max_types || $index > 0 )
460 {
461 $t->set_var( $prev, "" );
462 $t->set_var( $next, "" );
463 $t->set_var( $prev_inactive, "" );
464 $t->set_var( $next_inactive, "" );
465
466 if ( $index > 0 )
467 {
468 $t->set_var( $prev_index, max( $index - $max_types, 0 ) );
469 $t->parse( $prev, $prev . "_tpl" );
470 }
471 else
472 {
473 $t->parse( $prev_inactive, $prev_inactive . "_tpl" );
474 }
475 if ( $index + $max_types < $total_types )
476 {
477 $t->set_var( $next_index, $index + $max_types );
478 $t->parse( $next, $next . "_tpl" );
479 }
480 else
481 {
482 $t->parse( $next_inactive, $next_inactive . "_tpl" );
483 }
484 $total = $total_types;
485 $page = ($index / ($max_types * 10));
486 settype( $page, "integer" );
487
488 $i = ( ( $page * 10 ) + 1) - $max_types;
489 settype( $i, "integer" );
490
491 if($i < 0)
492 $i=1;
493 $item_count = 49;
494 $max = $i + $item_count;
495
496 if( ( $max * $max_types ) > $total_types )
497 {
498 $max = $i + ( ( $total_types - ( $i * $max_types ) ) / $max_types ) + 1;
499 settype( $max, "integer" );
500 if ( $max - $item_count <= 0 )
501 {
502 $i = 1;
503 }
504 else
505 {
506 $i = $max - $item_count;
507 if ( ( $i % 10 ) + 1 != 1 )
508 {
509 $i += 10 - ( $i % 10 ) + 1;
510 }
511 }
512 }
513
514 while ( $total > 0 && $i <= $max )
515 {
516 $cur_i = $i;
517 $t->set_var( $item, "" );
518 $t->set_var( $item_inactive, "" );
519 $cur_page = (($i-1) / (10));
520 settype( $cur_page, "integer" );
521 if ( $cur_page == $page )
522 {
523 $t->set_var( $item_index, ($i - 1)*$max_types );
524 $t->set_var( $item_name, $i );
525 $i++;
526 $total = $total - $max_types;
527 }
528 else
529 {
530 $i_start = $i;
531 $i_end = $i + 9;
532 $total_pages = (($total_types-1)/$max_types) + 1;
533 settype( $total_pages, "integer" );
534 if ( $i_end > $total_pages )
535 {
536 $i_end = $total_pages;
537 }
538 $t->set_var( $item_index, ($i - 1)*$max_types );
539 if ( $i_start != $i_end )
540 $t->set_var( $item_name, $i_start . "-" . $i_end );
541 else
542 $t->set_var( $item_name, $i_start );
543 $i += 10;
544 $total = $total - $max_types*10;
545 }
546 if ( ($cur_i - 1)*$max_types == $index )
547 {
548 $t->parse( $item_inactive, $item_inactive . "_tpl" );
549 }
550 else
551 {
552 $t->parse( $item, $item . "_tpl" );
553 }
554 $t->parse( $item_list, $item_list . "_tpl", true );
555 }
556
557 $t->parse( $type_list, $type_list . "_tpl" );
558 }
559 else
560 {
561 $t->set_var( $type_list, "" );
562 }
563 }
564 }
565
566 ?>
$language_file
$language_file
Definition: addresstypeedit.php:30
$page_path
if(isset( $ItemArrayID) and is_array( $ItemArrayID)) $page_path
Definition: addresstypeedit.php:42
$item_type_array
$item_type_array
Definition: addresstypelist.php:34
$move_item
$move_item
Definition: addresstypelist.php:35
$i
$i
Definition: admin/adlist.php:91
$total
else $total["inctax"]
Definition: checkout.php:1359
eZList
Definition: ezlist.php:52
eZList\drawList
static drawList( $params, $no_print=false)
Definition: ezlist.php:70
eZList\drawNavigator
static drawNavigator(&$t, $total_types, $max_types, $index, $parent=false, $variables=false)
Definition: ezlist.php:401
eZTemplate
Definition: eztemplate.php:107
eZTextTool\htmlspecialchars
static htmlspecialchars( $string)
Definition: eztexttool.php:144
$t
foreach( $Modules as $module) if(isset( $ItemInsert)) $t
Definition: classes/admin/linklist.php:168
$Language
$Language
Definition: classes/admin/linklist.php:65
$ini
$ini
Definition: classes/admin/linklist.php:64
$item
$item
Definition: classes/admin/linklist.php:228
$module
$module
Definition: classes/admin/linkselect.php:219
$Action
$Action
Definition: companysearch.php:80
$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
$page
$page
Definition: ezarticle/modules/content.php:28
$Offset
$Offset
Definition: ezarticle/user/search.php:110
$index
$index
Definition: ezforum/user/messageedit.php:36
$item_error
$item_error
Definition: onlinetypeedit.php:59
$count
$count
Definition: onlinetypelist.php:108
$header
$header
Definition: paypalnotify.php:141
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.