/[cvs]/nfo/php/libs/com.newsblob.phphtmllib/widgets/data_list/DataList.inc
ViewVC logotype

Contents of /nfo/php/libs/com.newsblob.phphtmllib/widgets/data_list/DataList.inc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.8 - (show annotations)
Thu May 6 16:27:46 2004 UTC (20 years, 3 months ago) by jonen
Branch: MAIN
CVS Tags: HEAD
Changes since 1.7: +205 -108 lines
 updated all to v2.4.1 - Apr 01, 2004

1 <?php
2 /**
3 * This is the base class for managing a list
4 * of data points.
5 *
6 * @author Walter A. Boring IV <waboring@buildabetterweb.com>
7 * @package phpHtmlLib
8 */
9
10 /**
11 * Some global defines used
12 */
13 define("NOT_SORTABLE", 0);
14 define("SORTABLE", 1);
15 //case insensitive sorting.
16 define("SORTABLE_ICASE", 2);
17 //numeric type sorting.
18 define("SORTABLE_NUMERIC", 3);
19
20 define("SEARCHABLE", TRUE);
21 define("NOT_SEARCHABLE", FALSE);
22
23 //Some defines for setting up the search
24 //modifier fields.
25 define("SEARCH_BEGINS_WITH", 1);
26 define("SEARCH_CONTAINS", 2);
27 define("SEARCH_EXACT", 4);
28 define("SEARCH_ENDS_WITH", 8);
29 define("SEARCH_ALL", 15);
30
31
32 /**
33 * This object is the base class that can be
34 * used to build a widget that shows lists of
35 * data from any source via the DataListSource
36 * object. It fetches/builds/gets its data
37 * from the DataListSource object, which can
38 * be written to support any data source
39 * (MySQL, Oracle, comma delimited file, xml, etc.)
40 *
41 * This base class MUST be extended by a child to
42 * actually render the list. The job of the DataList
43 * class is to provide the basic API and abstraction
44 * mechanism to handling searching, showing, sorting
45 * lists of data.
46 *
47 * Each column of data is associated with a title and a
48 * name. The title is what is shown to the user for that
49 * column. The name is the mapping between the column and
50 * the DataListSource. Each column can be marked
51 * as sortable and searchable. If a column is sortable,
52 * the title is a link that can be clicked on to sort.
53 * The sorting is done in the DataListSource object (
54 * via the sql query, or sort() functions depending on the
55 * data source itself)
56 *
57 * The DataList object will build the title, the search block
58 * (if any), the datalist controls (the links/imges for
59 * first, prev, next, last, all). Then the data columns/labels.
60 * Then it will fetch each of the rows of data to display
61 * from the DataListSource.
62 *
63 * The logic of the output calls follows in the order:
64 *
65 * title
66 * search table/block
67 * datalist controls (first, prev, next, last, all)
68 * data columns/labels
69 * data rows x through y
70 *
71 *
72 * REQUIREMENTS:
73 * You must use/define a DataListSource object.
74 * You MUST override/extend the following methods:
75 *
76 * * get_data_source() - used to set the DataListSource
77 * by this class.
78 * * user_setup() - used to set the columns to show and any
79 * options used by the DataList class and
80 * DataListSource object.
81 *
82 *
83 * UI ABSTRACTION METHODS
84 * These methods allow for some level of abstraction for
85 * the layout/look/feel of the actual list of data.
86 *
87 *
88 * * gui_init() - the function gives the child class a chance
89 * to do any building of the objects that will
90 * hold the search area, column headers and the
91 * rows of data.
92 *
93 * * child_build_column_header() - This method is responsible
94 * for building and inserting
95 * the column header title into
96 * the UI object.
97 *
98 * * child_add_row_cell() - This function is responsible for adding
99 * the cell in the current row. The method
100 * is responsible for keeping track of the
101 * location in its UI object for the current
102 * row.
103 *
104 * * child_get_gui() - This method returns the entire UI in 1 object
105 * or container. At this point the entire UI
106 * has been constructed, the entire list of data
107 * has been walked and inserted.
108 *
109 *
110 * @author Walter A. Boring IV <waboring@buildabetterweb.com>
111 * @package phpHtmlLib
112 */
113 class DataList extends BaseWidget {
114
115 /**
116 * This value holds the number
117 * of pages of data we have
118 * to display.
119 *
120 */
121 var $_num_pages=1;
122
123 /**
124 * The number of rows of data
125 * to show per "page".
126 * The default is 20.
127 *
128 */
129 var $_default_rows_per_page = 10;
130
131 /**
132 * The max number of rows to
133 * show when the user does the
134 * "EXPAND" command.
135 */
136 var $_max_rows = 200;
137
138 /**
139 * Flag to tell us to show every
140 * row that comes from the DB or not.
141 * By default this is off.
142 */
143 var $_show_all_rows = FALSE;
144
145
146 /**
147 * Do we want to alternate the row colors?
148 * This helps to see each row easier.
149 */
150 var $alternating_row_colors = TRUE;
151
152 /**
153 * prefix for all list variable
154 * names, so we can potentially
155 * have more then 1 list per page.
156 */
157 var $_global_prefix = '';
158
159
160 /**
161 * Holds an array of all the
162 * form vars we need for this
163 * class to work.
164 */
165 var $_vars = array("offsetVar" => "offset",
166 "orderbyVar" => "orderby",
167 "reverseorderVar" => "reverseorder",
168 "numrowsVar" => "numrows",
169 "expandrowsVar" => "expandrows",
170 "search_fieldVar" => "search_field",
171 "search_valueVar" => "search_value",
172 "search_typeVar" => "search_type",
173 "simple_search_modifierVar" => "simple_search_modifier");
174
175 /**
176 * Holds the db column name that
177 * we want to order by default.
178 */
179 var $_default_orderby = '';
180
181 /**
182 * Holds a flag to let us know to
183 * reverse order the column by default
184 */
185 var $_default_reverseorder = "false";
186
187 /**
188 * Flag to let us know that search
189 * is enabled.
190 *
191 */
192 var $_search_flag = FALSE;
193
194 /**
195 * Flag to let us know that
196 * advanced search is enabled
197 *
198 */
199 var $_advanced_search_flag = FALSE;
200
201 /**
202 * Flag to enable simple search modifyer.
203 * IF enabled it will add a select that adds
204 * the "beings with", "contains" options for
205 * a simple search.
206 */
207 var $_simple_search_modifier = FALSE;
208
209
210 /**
211 * Holds the object block that is the
212 * search UI
213 */
214 var $_search_table = NULL;
215
216 /**
217 * This holds a list of
218 * name=>value vars that the
219 * caller/child wants to propogate
220 * automatically.
221 *
222 */
223 var $_save_vars = array();
224
225
226 /**
227 * The column descriptions
228 * for the data we are working on
229 *
230 * @var array
231 */
232 var $_columns = array();
233
234 /**
235 * Keeps track of the # of columns we have
236 */
237 var $_num_columns = 0;
238
239
240 /**
241 * This holds the form attributes
242 *
243 */
244 var $_form_attributes = array("method" => "GET",
245 "target" => "",
246 "action" => "",
247 "name" => "datalist");
248
249 /**
250 * Build everything inside a form?
251 *
252 */
253 var $_form_render_flag = FALSE;
254
255
256 /**
257 * flag to let us know if we want to show
258 * the results or not.
259 */
260 var $_show_results_flag = TRUE;
261
262
263 /**
264 * Holds our reference/copy of the
265 * DataListSource object which is used to
266 * access the data that this object uses
267 *
268 * @var DataListSource object
269 */
270 var $_datasource = NULL;
271
272 /**
273 * This stores the base path to where the
274 * tool link images live. This lets you
275 * specify a new path to where your images
276 * live.
277 */
278 var $_image_path = "img/widgets/";
279
280
281 /**
282 * The constructor
283 *
284 * @param string - the title of the data list
285 * @param string - the overall width
286 * @param string - the column to use as the default sorting order
287 * @param boolean - sort the default column in reverse order?
288 */
289 function DataList($title, $width = "100%", $default_orderby='',
290 $default_reverseorder=FALSE) {
291 $this->set_title( $title );
292
293 if ($title != NULL && $title != "") $this->set_form_name( str_replace(' ', '_', strtolower($title)) );
294
295 $this->set_width( $width );
296
297
298 $this->_default_orderby = $default_orderby;
299 if ( $default_reverseorder === TRUE ) {
300 $default_reverseorder = "true";
301 }if ( $default_reverseorder === FALSE ) {
302 $default_reverseorder = "false";
303 }
304 $this->_default_reverseorder = $default_reverseorder;
305
306
307 //Set the global prefix for our variables.
308 //want to make sure we can have multiple
309 //item lists per html page.
310 $this->set_global_prefix('');
311
312 //allow someone to do some generic
313 //action before we get the data source
314 //and start processing rows.
315 $this->do_action();
316
317 //child class MUST override this
318 //method to automatically set
319 //the DataListSource object.
320 //This class doesn't work without it.
321 $this->get_data_source();
322
323 //Call the subclass setup function.
324 //This is a way to get around having
325 //to override the constructor and
326 //pass in the same params.
327 $this->user_setup();
328 }
329
330 /**
331 * This function renders the final
332 * widget
333 *
334 */
335 function render($indent_level, $output_debug) {
336
337 //setup the columns in their sorts
338 $this->setup_columns();
339
340 //do any data prefetch work
341 //which may be child specific
342 if ( $this->_show_results() ) {
343 $this->data_prefetch();
344 }
345
346 //This function gives the child class
347 //a chance to build the tables/divs/containers
348 //that will be responsible for the look/feel
349 //of the DataList
350 $this->gui_init();
351
352 //see if we need to build the search area.
353 if ( $this->is_search_enabled() || $this->is_advanced_search_enabled() ) {
354 $this->_search_table = $this->child_build_search_table();
355 if ( $this->_search_table ) {
356 $this->set_form_render(TRUE);
357 }
358 }
359
360
361 if ( $this->get_form_render() ) {
362 $form = new FORMtag( array("method" => $this->get_form_method(),
363 "action" => $this->build_base_url(),
364 "name" => $this->get_form_name(),
365 "style" => "margin-top: 0px;margin-bottom:0px;") );
366
367 $target = $this->get_form_target();
368 if ( $target != NULL )
369 $form->set_tag_attribute("target",$target);
370
371 $action = $this->get_form_action();
372 if ( $action != NULL )
373 $form->set_tag_attribute("action",$action);
374
375 //now build the UI and return it
376 $form->add( $this->build_gui() );
377
378 } else {
379 $form = container();
380
381 //now build the UI and return it
382 $form->add( $this->build_gui() );
383 }
384
385 //add the hidden vars if we are a POST
386 if ($this->get_form_method() == "POST") {
387 $form->add( $this->_build_default_vars() );
388 }
389
390 //add the save vars the user wants.
391 $form->add( $this->_build_save_vars() );
392
393 //add any javascript required
394 $container = container( $this->_javascript(), $form );
395 return $container->render( $indent_level, $output_debug );
396 }
397
398 /**
399 * This function is responsible for calling the child
400 * class's methods for building the GUI container.
401 * This function builds the search area, the
402 * title, page controls, the column headers,
403 * and walks the rows of data and adds them
404 *
405 * A child class can override this method to
406 * move the placement of the search box
407 * relative to the data list. By default
408 * the search area comes above the table
409 * for the data list and page controls
410 *
411 * @return Container
412 */
413 function build_gui() {
414 $container = container();
415
416 //if we have a search area to show
417 //add it to the ui.
418 if ( $this->_search_table ) {
419 $container->add( $this->_search_table );
420 }
421
422 if ( $this->_show_results() ) {
423 //walk the list of columns and call the child
424 //method to add it
425 $column_count = count($this->_columns);
426 foreach( $this->_columns as $name => $col ) {
427 $this->child_build_column_header( $name, $col, $column_count);
428 }
429
430 if ($this->_query_worked) {
431 //now walk the list of rows and build and add the
432 //cells of data
433 while ( $row = $this->_datasource->get_next_data_row() ) {
434 //try and filter the row.
435 if (!$this->_datasource->row_filter($row)) {
436 $this->_datasource->set_total_rows( $this->_datasource->get_total_rows() -1);
437 continue;
438 }
439 $cnt = 1;
440 foreach( $this->_columns as $col_name => $data ) {
441 $obj = $this->build_column_item($row, $col_name);
442 if ( !is_object($obj) ) {
443 $obj = $this->_clean_string($obj, $col_name);
444 }
445
446 $this->child_add_row_cell($obj, $col_name,
447 (($cnt == $column_count) ? TRUE : FALSE),
448 $row);
449 $cnt++;
450 }
451 }
452 }
453 $container->add( $this->child_get_gui() );
454 }
455
456
457 return $container;
458 }
459
460
461 /**
462 * This method is called prior to get_data_source
463 * and user_setup() to allow you to do some generic
464 * action on data. By default this does nothing.
465 *
466 */
467 function do_action() {
468 return null;
469 }
470
471 /**
472 * This function is called automatically by
473 * the DataList constructor. It must be
474 * extended by the child class to actually
475 * set the DataListSource object.
476 *
477 *
478 */
479 function get_data_source() {
480 user_error("DataList::get_data_source() - ".
481 "child class must override this to ".
482 "set the the DataListSource object.");
483 }
484
485 /**
486 * A subclass can override this function
487 * to setup the class variables after
488 * the constructor. The constructor
489 * automatically calls this function.
490 *
491 */
492 function user_setup() {
493 user_error("DataList::user_setup() - ".
494 "child class must override this method ".
495 "to set the columns, and any options for ".
496 "the DataListSource.");
497 }
498
499 /**
500 * A subclass can override this function
501 * to setup the class variables after
502 * the constructor. The constructor
503 * automatically calls this function.
504 *
505 */
506 function gui_init() {
507 user_error("DataList::gui_init() - ".
508 "child class must override this method ".
509 "to set up the containers/objects that will ".
510 "hold the search area, page controls, ".
511 "column headers and the data cells");
512 }
513
514 /**
515 * This method is supposed to be written by
516 * the child class to build and add the column
517 * title to the UI
518 *
519 * @param string - the title of the column
520 * @param array - the column data ( from $this->_columns )
521 * @param int - the column #
522 *
523 */
524 function child_build_column_header($title, $col_data, $col_count) {
525 user_error("DataList::child_build_column_header() - ".
526 "child class must override this method ".
527 "to build the object that will be the ".
528 "individual column header/itle");
529 }
530
531 /**
532 * This method is supposed to be written by
533 * the child class to add the cell data to the
534 * current row in the UI
535 *
536 * @param mixed - the object/string/entity that
537 * should get put into the column row cell.
538 * @param string - the name/title of the column that the
539 * object will live in
540 * @param boolean - flag that tells the function if this is
541 * is the last cell for the current row.
542 *
543 */
544 function child_add_row_cell($obj, $col_name, $last_in_row_flag) {
545 user_error("DataList::child_add_row_cell() - ".
546 "child class must override this method ".
547 "to build the object that will be the ".
548 "individual column data cell");
549 }
550
551 /**
552 * This function is called after all of the data has
553 * been added to the UI object. It just returns the
554 * container that is the entire UI for the DataList
555 *
556 * @return Container
557 */
558 function child_get_gui() {
559 user_error("DataList::child_get_gui() - ".
560 "child class must override this method ".
561 "to return the wrapper that contains ".
562 "the entire UI.");
563 }
564
565 /**
566 * This function builds the search
567 * block that lives above the results
568 *
569 * @return Container
570 */
571 function child_build_search_table() {
572 user_error("DataList::child_build_search_table() - ".
573 "child class must override this");
574 return NULL;
575 }
576
577 /**
578 * This function provides a way to automatically
579 * add javascript to this object.
580 * This function is meant to be extended by the
581 * child class.
582 *
583 * @return SCRIPTtag object
584 */
585 function _javascript() {
586 return NULL;
587 }
588
589 /**
590 * This function adds a header item to the column headers
591 * from a list of parameters.
592 *
593 * @param string - $label - the label to use for
594 * the column header.
595 * @param int - $size - the size for the table column.
596 * @param string - $dbfield - the db field associated
597 * with this label from the query.
598 * @param boolean - $sortable - flag to make this column sortable.
599 * @param boolean - $searchable - flag to make this column searchable.
600 * @param string - header align value.
601 * @param string - the sort order
602 * @param string - the maximum # of characters to allow in the cell.
603 *
604 * @return array a single header array
605 */
606 function add_header_item( $label, $size=100, $data_name=NULL,
607 $sortable=FALSE, $searchable=FALSE,
608 $align="left", $sortorder="",
609 $max_text_length=NULL) {
610
611 $this->_columns[$label] = array("size" => $size,
612 "data_name" => $data_name,
613 "sortable" => $sortable,
614 "searchable" => $searchable,
615 "align" => $align,
616 "sortorder" => $sortorder,
617 "maxtextlength" => $max_text_length,
618 "reverseorder"=>false);
619 //$this->_num_headers++;
620
621 $this->_check_datasource("add_header_item");
622 $this->_datasource->add_column($label, $data_name, $sortable,
623 $searchable, $sortorder);
624 }
625
626
627 /**
628 * This function sets a prefix for all
629 * variables that are used in the item list
630 * table on a page. This allows you to have
631 * multiple itemlists on a single html page.
632 *
633 * @param string $prefix - the prefix for all vars.
634 */
635 function set_global_prefix($prefix) {
636 $this->_global_prefix = $prefix;
637 //update all the vars used
638 foreach ($this->_vars as $name => $value ) {
639 $this->_vars[$name] = $prefix.$value;
640 }
641 }
642
643 /**
644 * returns the current variable prefix
645 * string being used.
646 *
647 * @return string - current global prefix
648 */
649 function get_global_prefix() {
650 return $this->_global_prefix;
651 }
652
653 /**
654 * This function is used to set the
655 * DataListSource object for this instance
656 *
657 * @param DataListSource object
658 */
659 function set_data_source( $datasource ) {
660 $this->_datasource = &$datasource;
661 }
662
663 /**
664 * Enable the search ability.
665 *
666 * @param boolean
667 */
668 function search_enable( ) {
669 $this->_search_flag = TRUE;
670 if ( !$this->is_advanced_search_enabled() ) {
671 $this->set_search_type("simple");
672 }
673 }
674
675 /**
676 * Disable the search ability.
677 *
678 * @param boolean
679 */
680 function search_disable( ) {
681 $this->_search_flag = FALSE;
682 }
683
684 /**
685 * get the status of the search
686 * ability.
687 *
688 * @return boolean
689 */
690 function is_search_enabled() {
691 return $this->_search_flag;
692 }
693
694
695 /**
696 * Enable the advanced search
697 * capability
698 * NOTE: Child class MUST
699 * extend the
700 * _build_advanced_search_table
701 */
702 function advanced_search_enable() {
703 $this->_advanced_search_flag = TRUE;
704 if ( !$this->is_search_enabled() ) {
705 $this->set_search_type("advanced");
706 }
707 }
708
709 /**
710 * Disable the advanced search
711 * capability
712 *
713 */
714 function advanced_search_disable() {
715 $this->_advanced_search_flag = FALSE;
716 }
717
718 /**
719 * This returns the status of the
720 * advanced search flag.
721 *
722 * @return boolean
723 */
724 function is_advanced_search_enabled() {
725 return $this->_advanced_search_flag;
726 }
727
728 /**
729 * Set the simple search modifyer
730 * flag.
731 * NOTE: by default all the modifiers
732 * are enabled. You can limit the
733 * modifiers by passing in the
734 * string of defines of which ones
735 * you want enabled.
736 *
737 * MODIFIERS:
738 * SEARCH_BEGINS_WITH
739 * SEARCH_CONTAINS
740 * SEARCH_EXACT
741 * SEARCH_ENDS_WITH
742 *
743 * ie. SEARCH_BEGINS_WITH.SEARCH_EXACT
744 * will enable ONLY the
745 * "begins with" and "exact" modifiers.
746 *
747 * @param string
748 */
749 function set_simple_search_modifier( $modifier = SEARCH_ALL ) {
750 if ( $modifier == 0 ) {
751 $this->_simple_search_modifier = SEARCH_BEGINS_WITH |
752 SEARCH_CONTAINS |
753 SEARCH_EXACT |
754 SEARCH_ENDS_WITH;
755 } else {
756 $this->_simple_search_modifier = $modifier;
757 }
758 }
759
760 /**
761 * gets the value of the search modifier
762 * flag.
763 */
764 function get_simple_search_modifier() {
765 return $this->_simple_search_modifier;
766 }
767
768 /**
769 * This function sets the default # of rows
770 * per page to display. By default its 10.
771 * This lets the user override this value.
772 *
773 * @param int - the # of rows to use.
774 */
775 function set_default_num_rows( $num_rows ) {
776 $this->_default_rows_per_page = $num_rows;
777 }
778
779 /**
780 * This function gets the current default
781 * number of rows to display setting.
782 *
783 * @return int
784 */
785 function get_default_num_rows( ) {
786 return $this->_default_rows_per_page;
787 }
788
789 /**
790 * This returns the Maximum # of rows to
791 * display when in expand mode
792 *
793 * @return int
794 */
795 function get_max_rows() {
796 return $this->_max_rows;
797 }
798
799 /**
800 * This sets the maximum # of rows to
801 * display when in expand mode
802 *
803 * @param int - new # of maximum rows
804 * to display when in 'expand' mode
805 *
806 */
807 function set_max_rows( $max ) {
808 $this->_max_rows = $max;
809 }
810
811
812 /**
813 * This method sets the flag to tell us
814 * to show every row found in the DataListSource.
815 *
816 * @param boolean TRUE = show all rows
817 */
818 function set_showall($flag=TRUE) {
819 $this->_show_all_rows = $flag;
820 }
821
822 /**
823 * This returns the value of the show all rows
824 * flag
825 *
826 * @return boolean
827 */
828 function get_showall() {
829 return $this->_show_all_rows;
830 }
831
832
833
834 /**
835 * This function is used to set up any
836 * data that needs to be munged before the
837 * data is fetched from the DataListSource
838 *
839 */
840 function data_prefetch() {
841 $this->_check_datasource("data_prefetch");
842
843 if ( $this->expandrows() ) {
844 if ($this->get_showall()) {
845 $limit = -1;
846 } else {
847 $this->set_default_num_rows( $this->get_max_rows() );
848 $this->set_numrows( $this->get_max_rows() );
849 $limit = $this->numrows();
850 }
851 } else {
852 $limit = $this->numrows();
853 }
854
855 $this->_query_worked = $this->_datasource->query($this->offset(), $limit,
856 $this->orderby(), $this->reverseorder(),
857 $this->search_field(), $this->search_value(),
858 $this->simple_search_modifier_value(),
859 $this->search_type() );
860 }
861
862
863
864 /*
865 * Takes an array of (name, sortable, db_field, alignment,
866 * size), with one element corresponding to each column.
867 */
868 function setup_columns() {
869 $temp_headers = array();
870
871 foreach( $this->_columns as $col_name => $data ) {
872 if ( $data["sortorder"] == "reverse" ) {
873 $data["reverseorder"] = "true";
874 } else {
875 $data["reverseorder"] = "false";
876 }
877 $temp_headers[$col_name] = $data;
878 }
879 $this->_columns = $temp_headers;
880 }
881
882
883
884 /**
885 * general DataListSource object checker.
886 *
887 */
888 function _check_datasource($function_name) {
889 if ( !is_object($this->_datasource) ) {
890 user_error("DataList::".$function_name."() - DataListSource object is not set");
891 exit;
892 }
893 }
894
895
896 /*********************************************/
897 /* REQUEST VARIABLE SECTION */
898 /*********************************************/
899
900
901
902 /**
903 * Function used to get the current
904 * value of one of the control vars
905 * for this class
906 *
907 * @param string - the name we want to get
908 * @param mixed - the default value if not set
909 * @return the current value or default if not set
910 */
911 function _get($name, $default_value=NULL) {
912 if ( !isset($_REQUEST[$this->_vars[$name]]) ) {
913 $this->_set($name, $default_value);
914 }
915
916 return $_REQUEST[$this->_vars[$name]];
917 }
918
919 /**
920 * This function is used to set the
921 * value of the control var
922 *
923 * @param string - the name we want to get
924 * @param mixed - the new value for it.
925 */
926 function _set($name, $value) {
927 $_REQUEST[$this->_vars[$name]] = $value;
928 }
929
930 /**
931 * This function returns the current value
932 * of the offset variable. This is an offset
933 * into the query return data set.
934 *
935 * @return int - the current value.
936 */
937 function offset() {
938 if ($this->get_showall() && $this->expandrows()) {
939 return 0;
940 } else {
941 return(int)$this->_get("offsetVar", 0);
942 }
943 }
944
945 /**
946 * This function is used to set/change
947 * the offset for this list.
948 *
949 * @param int - the new offset.
950 */
951 function set_offset($new_offset) {
952 $this->_set("offsetVar", $new_offset);
953 }
954
955 /**
956 * This function returns the value of the
957 * current orderby variable.
958 *
959 * @return string.
960 */
961 function orderby() {
962 return $this->_get("orderbyVar", $this->_default_orderby);
963 }
964
965 /**
966 * This builds a query string var for the
967 * orderby value.
968 *
969 * @return string - "orderby=(thevalue)"
970 */
971 function build_orderby_querystring() {
972 $str = $this->_vars["orderbyVar"]."=".urlencode($this->orderby());
973 return $str;
974 }
975
976 /**
977 * This function returns the current value of
978 * the reverse order member variable.
979 *
980 * @return string.
981 */
982 function reverseorder() {
983 return $this->_get("reverseorderVar", $this->_default_reverseorder);
984 }
985
986 /**
987 * This function sets the reverse order flag
988 * to a new value.
989 *
990 * @param string - the new value.
991 */
992 function set_reverseorder($new_value) {
993 $this->_set("reverseorderVar", $new_value);
994 }
995
996 /**
997 * This builds a query string var for the
998 * reverseorder value.
999 *
1000 * @return string - "orderby=(thevalue)"
1001 */
1002 function build_reverseorder_querystring() {
1003 $str = $this->_vars["reverseorderVar"]."=".urlencode($this->reverseorder());
1004 return $str;
1005 }
1006
1007 /**
1008 * This function returns the number of rows
1009 * that the query found.
1010 *
1011 * @return int - the number of rows
1012 */
1013 function numrows() {
1014 return(int)$this->_get("numrowsVar", $this->_default_rows_per_page);
1015 }
1016
1017 /**
1018 * This function sets the # of rows to display
1019 * per page.
1020 *
1021 * @param int - the # of rows
1022 */
1023 function set_numrows($new_numrows) {
1024 $this->_set("numrowsVar", $new_numrows);
1025 }
1026
1027 /**
1028 * returns the current value of
1029 * the search field name
1030 *
1031 * @return string
1032 */
1033 function search_field() {
1034 return $this->_get("search_fieldVar", '');
1035 }
1036
1037 /**
1038 * This builds a query string var for the
1039 * searchfield value.
1040 *
1041 * @return string - "orderby=(thevalue)"
1042 */
1043 function build_searchfield_querystring() {
1044 $str = $this->_vars["search_fieldVar"]."=".urlencode($this->searchfield());
1045 return $str;
1046 }
1047
1048 /**
1049 * returns the current value of
1050 * te search field value.
1051 *
1052 * @return string
1053 */
1054 function search_value() {
1055 return $this->_get("search_valueVar", '');
1056 }
1057
1058 /**
1059 * This builds a query string var for the
1060 * searchfield value.
1061 *
1062 * @return string - "orderby=(thevalue)"
1063 */
1064 function build_searchvalue_querystring() {
1065 $str = $this->_vars["search_valueVar"]."=".urlencode($this->search_value());
1066 return $str;
1067 }
1068
1069 /**
1070 * returns the current value of the
1071 * simple search modifier
1072 *
1073 * @return string
1074 */
1075 function simple_search_modifier_value() {
1076 return $this->_get("simple_search_modifierVar", '');
1077 }
1078
1079
1080 /**
1081 * returns the type of search being used
1082 *
1083 * @return string
1084 */
1085 function search_type() {
1086 return $this->_get("search_typeVar", "simple");
1087 }
1088
1089 /**
1090 * This function sets the search type
1091 *
1092 * @param string - the search type
1093 * "simple" or "advanced"
1094 */
1095 function set_search_type($type) {
1096 $this->_set("search_typeVar", $type);
1097 }
1098
1099
1100 /**
1101 * returns the current value of the expandrows
1102 * flag. This tells us if they want the entire
1103 * list of data back from the DB.
1104 *
1105 * @return string - the current value
1106 */
1107 function expandrows() {
1108 if ($this->get_showall()) {
1109 $default = 1;
1110 } else {
1111 $default = 0;
1112 }
1113 return(int)$this->_get("expandrowsVar", $default);
1114 }
1115
1116 /**
1117 * This sets the expandrows.
1118 *
1119 * @param boolean
1120 */
1121 function set_expandrows($flag=TRUE) {
1122 $flag = ($flag ? 1:0);
1123 $this->_set("expandrowsVar", $flag);
1124 }
1125
1126 /**
1127 * This is the basic function for letting us
1128 * do a mapping between the column name in
1129 * the header, to the value found in the DB.
1130 *
1131 * NOTE: this function is meant to be overridden
1132 * so that you can push whatever you want.
1133 *
1134 * @param array - $row_data - the entire data for the row
1135 * @param string - $col_name - the name of the column header
1136 * for this row to render.
1137 * @return mixed - either a HTMLTag object, or raw text.
1138 */
1139 function build_column_item($row_data, $col_name) {
1140 $key = $this->_columns[$col_name]["data_name"];
1141
1142 if (!isset($row_data[$key]) || ($row_data[$key] == '' && $row_data[$key] !== 0)) {
1143 return "&nbsp;";
1144 } else {
1145 return $this->_filter_column_string($row_data[$key]);
1146 }
1147 }
1148
1149
1150 /**
1151 * This does some magic filtering on the data
1152 * that we display in a column. This helps
1153 * to prevent nast data that may have html
1154 * tags in it.
1155 *
1156 * @param string - the column data u want to filter
1157 * @return string the cleaned/filtered data
1158 */
1159 function _filter_column_string($data) {
1160 // WAS: return htmlspecialchars(trim($data));
1161
1162 // NEW: require 'flib/Application/i18n/TextEncode.php'
1163 // this will do a 'htmlentities' RECURSIVE on each item
1164 $encoder = new Data_Encode($data);
1165 $encoder->toHTML();
1166 return $data;
1167 }
1168
1169 /*******************************************/
1170 /* FORM VARIABLES SECTION */
1171 /*******************************************/
1172
1173 /**
1174 * This function is used to set the
1175 * form name
1176 *
1177 * @param string
1178 */
1179 function set_form_name($name) {
1180 $this->_form_attributes["name"] = $name;
1181 }
1182
1183 /**
1184 * This function is used to get
1185 * the form name
1186 *
1187 * @return string
1188 */
1189 function get_form_name() {
1190 return $this->_form_attributes["name"];
1191 }
1192
1193 /**
1194 * This function is used to set the
1195 * form target
1196 *
1197 * @param string
1198 */
1199 function set_form_target($target) {
1200 $this->_form_attributes["target"] = $target;
1201 }
1202
1203 /**
1204 * This function is used to get
1205 * the form target
1206 *
1207 * @return string
1208 */
1209 function get_form_target() {
1210 return $this->_form_attributes["target"];
1211 }
1212
1213 /**
1214 * This function is used to set the
1215 * form method
1216 *
1217 * @param string (POST or GET)
1218 */
1219 function set_form_method($method) {
1220 if ( strcasecmp($method,"GET") !=0 && strcasecmp($method,"POST") !=0 ) {
1221 user_error("DataList::set_form_method() - INVALID Form method ".$method);
1222 } else {
1223 $this->_form_attributes["method"] = $method;
1224 }
1225 }
1226
1227 /**
1228 * This function is used to get
1229 * the form method
1230 *
1231 * @return string (POST or GET)
1232 */
1233 function get_form_method() {
1234 return $this->_form_attributes["method"];
1235 }
1236
1237 /**
1238 * Sets the form action
1239 *
1240 * @param string
1241 */
1242 function set_form_action($action) {
1243 $this->_form_attributes["action"] = $action;
1244 }
1245
1246 /**
1247 * This function is used to get
1248 * the form action
1249 *
1250 * @return string (POST or GET)
1251 */
1252 function get_form_action() {
1253 return $this->_form_attributes["action"];
1254 }
1255
1256 /**
1257 * Sets whether to the output into a form
1258 *
1259 * @param bool
1260 */
1261 function set_form_render($flag) {
1262 $this->_form_render_flag = $flag;
1263 }
1264
1265 /**
1266 * Return the state of the form render
1267 *
1268 * @return bool
1269 */
1270 function get_form_render() {
1271 return $this->_form_render_flag;
1272 }
1273
1274 /**
1275 * This function is used to set the
1276 * message displayed when no data is found
1277 *
1278 * @param string
1279 */
1280 function set_not_found_message($mesg) {
1281 $this->_check_datasource("set_not_found_message");
1282 $this->_datasource->set_not_found_message($mesg);
1283 }
1284
1285
1286 /**
1287 * This function is used to set the value
1288 * of the _show_results_flag
1289 *
1290 * @param boolean - TRUE to show the results
1291 */
1292 function set_show_results( $flag=TRUE ) {
1293 $this->_show_results_flag = $flag;
1294 }
1295
1296
1297 /**
1298 * This function is used to let render() know
1299 * that we should show the results or not.
1300 *
1301 * @return boolean
1302 */
1303 function _show_results() {
1304 return $this->_show_results_flag;
1305 }
1306
1307 /**
1308 * this method builds some hidden
1309 * form fields to automatically
1310 * be placed inside the form.
1311 *
1312 * This method returns a list of
1313 * hidden form fields if we are a POST.
1314 * It returns a portion of a query string
1315 * If we are a GET.
1316 *
1317 * @return mixed depending on form method
1318 */
1319 function _build_save_vars() {
1320 $container = container();
1321 foreach($this->_save_vars as $name => $value) {
1322 $container->add(form_hidden($name, $value));
1323 }
1324 return $container;
1325 }
1326
1327 /**
1328 * This function sets the save variables
1329 * that the user/child wants to automatically
1330 * propogate
1331 *
1332 * @param array - name=>value pairs of the data
1333 * that they want to propogate
1334 */
1335 function set_save_vars($vars) {
1336 $this->_save_vars = $vars;
1337 }
1338
1339 /**
1340 * This function builds the list of
1341 * default hidden form vars for when
1342 * the datalist is being rendered
1343 * as a POST
1344 *
1345 * @return Container
1346 */
1347 function _build_default_vars() {
1348 // the navigation links will set the offset anyway
1349 $container = container(form_hidden($this->_vars["offsetVar"], $this->offset()),
1350 form_hidden($this->_vars["orderbyVar"], $this->orderby()),
1351 form_hidden($this->_vars["reverseorderVar"], $this->reverseorder()),
1352 form_hidden($this->_vars["expandrowsVar"], $this->expandrows()));
1353 return $container;
1354 }
1355
1356 /**
1357 * This builds the base url used
1358 * by the column headers as well
1359 * as the page tool links.
1360 *
1361 * it basically builds:
1362 * $_SELF?$_GET
1363 *
1364 * @return string
1365 */
1366 function build_base_url() {
1367
1368 $url = $_SERVER["PHP_SELF"]."?";
1369
1370 if ( $this->get_form_method() == "POST" ) {
1371 return $url;
1372 }
1373
1374 $vars = array_merge($_POST, $_GET);
1375 //request method independant access to
1376 //browser variables
1377 if ( count($vars) ) {
1378 //walk through all of the get vars
1379 //and add them to the url to save them.
1380 foreach($vars as $name => $value) {
1381
1382 if ( $name != $this->_vars["offsetVar"] &&
1383 $name != $this->_vars["orderbyVar"] &&
1384 $name != $this->_vars["reverseorderVar"] &&
1385 $name != $this->_vars["search_valueVar"]
1386 ) {
1387 if ( is_array($value) ) {
1388 $url .= $name."[]=".implode("&".$name."[]=",$value)."&";
1389 } else {
1390 $url .= $name."=".urlencode(stripslashes($value))."&";
1391 }
1392 }
1393 }
1394 }
1395
1396 return htmlentities($url);
1397 }
1398
1399 /**
1400 * This function builds the 'tool' images that
1401 * allow you to walk through the data list itself.
1402 * It provides image links for
1403 * first - go to the first page in the data list
1404 * prev - go to the previous page in the data list
1405 * next - go to the next page in the data list
1406 * last - go to the last page in the data list
1407 * all - show the rest of the list from the current offset
1408 *
1409 * @param string - which tool image to build
1410 * @return Object
1411 */
1412 function build_tool_link( $which ) {
1413 $num_pages = $this->get_num_pages();
1414 $cur_page = $this->get_current_page();
1415 $last_page = $this->get_last_page();
1416
1417 $image_path = $this->get_image_path();
1418 switch ( $which ) {
1419
1420 case "first":
1421 $rows_string = "First ".$this->get_default_num_rows()." Rows";
1422 if ( $this->offset() <= 0 ) {
1423 $obj = html_img($image_path."/first_group_button_inactive.gif",
1424 '','',0,$rows_string, NULL, $rows_string . ": Disabled Link");
1425 } else {
1426 $url = $this->_build_tool_url(0);
1427 $obj = html_img_href($url, $image_path."/first_group_button.gif",
1428 '','',0, $rows_string, NULL, NULL, $rows_string);
1429 }
1430 break;
1431
1432 case "prev":
1433 $rows_string = "Previous ".$this->get_default_num_rows()." Rows";
1434 if ( $this->offset() <= 0 ) {
1435 $obj = html_img($image_path."/prev_group_button_inactive.gif",
1436 '','',0,$rows_string, NULL, $rows_string . ": Disabled Link");
1437 } else {
1438 $offset = $this->offset() - $this->numrows();
1439 if ( $offset < 0 ) {
1440 $offset = 0;
1441 }
1442 $url = $this->_build_tool_url($offset);
1443 $obj = html_img_href($url, $image_path."/prev_group_button.gif",
1444 '','',0, $rows_string, NULL, NULL, $rows_string);
1445 }
1446 break;
1447
1448 case "next":
1449 $rows_string = "Next ".$this->get_default_num_rows()." Rows";
1450 if ( ($num_pages == 1) || ($cur_page == $last_page) ) {
1451 $obj = html_img($image_path."/next_group_button_inactive.gif",
1452 '','',0, $rows_string, NULL, $rows_string . ": Disabled Link");
1453 } else {
1454 $offset = $this->offset() + $this->numrows();
1455 $url = $this->_build_tool_url($offset);
1456 $obj = html_img_href($url, $image_path."/next_group_button.gif",
1457 '','',0, $rows_string, NULL, NULL, $rows_string);
1458 }
1459 break;
1460
1461 case "last":
1462 $rows_string = "Last ".$this->get_default_num_rows()." Rows";
1463 if ( ($num_pages == 1) || ($cur_page == $last_page) ) {
1464 $obj = html_img($image_path."/last_group_button_inactive.gif",
1465 '','',0, $rows_string, NULL, $rows_string . ": Disabled Link");
1466 } else {
1467 $offset = (int)(($num_pages - 1) * $this->numrows());
1468 $url = $this->_build_tool_url($offset);
1469 $obj = html_img_href($url, $image_path."/last_group_button.gif",
1470 '','',0, $rows_string, NULL, NULL, $rows_string);
1471 }
1472 break;
1473
1474 case "expand":
1475 $offset = $this->offset();
1476 if ( $this->expandrows() ) {
1477 $url = $this->_build_tool_url($offset, TRUE, 0);
1478 $obj = html_img_href($url, $image_path."/close_group_button.gif",
1479 '','',0,"Collapse Rows", NULL, NULL, "Collapse Rows");
1480 } else {
1481 if ( ($num_pages == 1) ) {
1482 $obj = html_img($image_path."/expand_group_button_inactive.gif",
1483 '','',0, "Expand Rows", NULL, "Expand Rows" . ": Disabled Link");
1484 } else {
1485 $url = $this->_build_tool_url($offset, TRUE, 1);
1486 $obj = html_img_href($url, $image_path."/expand_group_button.gif",
1487 '','',0,"Expand Rows", NULL, NULL, "Expand Rows");
1488 }
1489 }
1490 //so we don't save it into the mozilla navigation bar links
1491 unset($url);
1492 break;
1493 }
1494
1495 if ( !empty($url) ) {
1496 $this->_save_mozilla_nav_link($which, $url);
1497 }
1498
1499 return $obj;
1500 }
1501
1502 /**
1503 * This function is used to build the url
1504 * for a tool link.
1505 * (first, prev, next, last, all)
1506 *
1507 * @param int - the offset for the link
1508 * @param boolean - add the expandrows value to the url
1509 * @param int - the expandrows value to use if the flag is on
1510 *
1511 * @return string
1512 */
1513 function _build_tool_url($offset, $expandrows_flag=FALSE, $expandrows_value=0) {
1514 if ( $this->get_form_method() == "POST" ) {
1515 $form_name = $this->get_form_name();
1516 $url = "javascript: document.".$form_name;
1517 $url .= ".".$this->_vars["offsetVar"].".value='".$offset."';";
1518
1519 //add the expandrows variable to the post
1520 if ( $expandrows_flag ) {
1521 $form_field = $this->_vars["expandrowsVar"];
1522 $url .= "document.".$form_name.".";
1523 $url .= $form_field.".value='".$expandrows_value."';";
1524 }
1525
1526 $url .= "document.".$form_name.".submit();";
1527 } else {
1528 $url = $this->build_base_url();
1529 $url .= $this->build_state_vars_query_string($offset, $expandrows_flag,
1530 $expandrows_value);
1531 }
1532 return $url;
1533 }
1534
1535 /**
1536 * this function is used to build a sub query string
1537 * of all of the query string vars to save the
1538 * state of the DBItemList. This is used for pages
1539 * that want to come back to the list at the same state
1540 *
1541 * @param int - the offset for the link
1542 * @param boolean - add the expandrows value to the url
1543 * @param int - the expandrows value to use if the flag is on
1544 * @return string - name=value& pairs
1545 */
1546 function build_state_vars_query_string($offset, $expandrows_flag=FALSE,
1547 $expandrows_value=0) {
1548 $str = "";
1549
1550 $str .= $this->_vars["offsetVar"]."=".urlencode($offset);
1551 $str .= "&".$this->_vars["orderbyVar"]."=".urlencode($this->orderby());
1552 $str .= "&".$this->_vars["reverseorderVar"]."=".urlencode($this->reverseorder());
1553 $str .= "&".$this->_vars["search_fieldVar"]."=".urlencode($this->search_field());
1554 $str .= "&".$this->_vars["search_valueVar"]."=".urlencode($this->search_value());
1555 $str .= "&".$this->_vars["simple_search_modifierVar"]."=".urlencode($this->simple_search_modifier_value());
1556 $str .= "&".$this->_vars["search_typeVar"]."=".urlencode($this->search_type());
1557 if ( $expandrows_flag ) {
1558 $str .= "&".$this->_vars["expandrowsVar"]."=".urlencode($expandrows_value);
1559 }
1560
1561 return htmlentities($str);
1562 }
1563
1564 /**
1565 * This function stores the url for each of the tool
1566 * urls, so we can push these out for mozilla.
1567 * Mozilla has a nice navigation bar feature that
1568 * lets you program first, prev, next, last links
1569 *
1570 * @param string - which tool link
1571 * @param string - the url for that link
1572 */
1573 function _save_mozilla_nav_link($which, $url) {
1574 $this->_mozilla_nav_links[$which] = $url;
1575 }
1576
1577
1578 /**
1579 * This function returns the path to the
1580 * images used in this class
1581 *
1582 * @return string
1583 */
1584 function get_image_path() {
1585 return $this->_image_path;
1586 }
1587
1588 /**
1589 * This function returns the path to the
1590 * images used in this class
1591 *
1592 * @return string
1593 */
1594 function set_image_path($path) {
1595 return $this->_image_path = $path;
1596 }
1597
1598 /**
1599 * This function returns the current
1600 * page that the item list is on.
1601 *
1602 * @return int
1603 */
1604 function get_current_page() {
1605 return((int) ($this->offset() / $this->numrows())) + 1;
1606 }
1607
1608 /**
1609 * This function returns the #
1610 * of pages that are available
1611 * for this list of items.
1612 *
1613 * @return int
1614 */
1615 function get_num_pages() {
1616 $this->_check_datasource("get_num_pages");
1617 $total_rows = $this->_datasource->get_total_rows();
1618
1619 if ($this->get_showall() && $this->expandrows()) {
1620 return 1;
1621 }
1622
1623 $cnt = (int)($total_rows / $this->numrows());
1624 if ( (($total_rows % $this->numrows()) != 0) || ($total_rows == 0) ) {
1625 $cnt++;
1626 }
1627 return $cnt;
1628 }
1629
1630 /**
1631 * This calculates the last page #
1632 * for this list of items
1633 *
1634 * @return int
1635 */
1636 function get_last_page() {
1637 return $this->get_num_pages();
1638 }
1639
1640 /**
1641 * This function builds the string
1642 * that describes the current page
1643 * out of n pages the list is showing
1644 *
1645 * @return string (ie. 1 to 10 of 25)
1646 */
1647 function get_page_info() {
1648 $cur_page = $this->get_current_page();
1649 $low_range = $this->offset() + 1;
1650 $num_pages = $this->get_num_pages();
1651
1652 $this->_check_datasource("get_page_info");
1653 $total_rows = $this->_datasource->get_total_rows();
1654
1655 if ($this->get_showall() && $this->expandrows()) {
1656 $num_rows_per_page = $total_rows;
1657 } else {
1658 $num_rows_per_page = $this->numrows();
1659 }
1660
1661 $high_range = $low_range + ($num_rows_per_page - 1);
1662 if ( $high_range > $total_rows ) {
1663 $high_range = $total_rows;
1664 }
1665
1666 if ( $total_rows == 0 ) {
1667 $str = "0 of 0";
1668 } else {
1669 $str = $low_range . " to ". $high_range;
1670 $str .= " of ".$total_rows;
1671 }
1672
1673 return $str;
1674 }
1675
1676
1677
1678 /**
1679 * This builds a url for a particular
1680 * column header.
1681 *
1682 * @param string - $col_name
1683 * @return Atag object;
1684 */
1685 function build_column_url($col_name) {
1686 $orderby = $this->orderby();
1687 $reverseorder = $this->reverseorder();
1688 $search_value = $this->search_value();
1689
1690 $order_value = $this->_columns[$col_name]["data_name"];
1691 $reverse_value = "false";
1692 if ( !$reverseorder ) {
1693 $reverseorder = 'false';
1694 }
1695
1696 if ( $orderby == $order_value && $reverseorder === 'false' ) {
1697 $reverse_value = "true";
1698 }
1699
1700 if ( $this->get_form_method() == "POST" ) {
1701 //we have to construct this url
1702 //specially.
1703 $form_name = $this->get_form_name();
1704
1705 $url = "javascript: ";
1706 //set the offset correctly
1707 $url .= "document.".$form_name.".".$this->_vars["offsetVar"].".value='".$this->offset()."';";
1708 //set the orderby correctly.
1709 $url .= "document.".$form_name.".".$this->_vars["orderbyVar"].".value='".$order_value."';";
1710 //set the reverseorder
1711 $url .= "document.".$form_name.".".$this->_vars["reverseorderVar"].".value='".$reverse_value."';";
1712
1713 $url .= "document.".$form_name.".submit();";
1714 } else {
1715 //handle the normal get.
1716 $url = $this->build_base_url();
1717 //Now add the orderby, reverseorder and offset vars
1718 $url .= $this->_vars["offsetVar"] ."=0&";
1719 //set the orderbyvar
1720 $url .= $this->_vars["orderbyVar"] ."=".$order_value."&";
1721 //set the reverseorder
1722 $url .= $this->_vars["reverseorderVar"] ."=".$reverse_value."&";
1723 //set the search value
1724 $url .= $this->_vars["search_valueVar"] ."=".$search_value;
1725 }
1726
1727 return $url;
1728 }
1729
1730
1731 /**
1732 * This function is used to make sure that the string we are
1733 * placing in a cell has been "cleaned"
1734 *
1735 * @param mixed - the cell object. It can be a string.
1736 * @param string - the name of the column this object/string
1737 * will live
1738 *
1739 * @return mixed - the cleaned string or object
1740 */
1741 function _clean_string($obj, $col_name) {
1742 if ( is_string($obj) ) {
1743 if ( $this->_columns[$col_name]["maxtextlength"] ) {
1744 //looks like we need to make sure we
1745 //truncate the string to a max length
1746 if ( strlen($obj) > $this->_columns[$col_name]["maxtextlength"] ) {
1747 //we need to truncate it and
1748 //add a hover title attribute for the full
1749 //object
1750 $obj = new SPANtag(array("title"=>$obj),
1751 substr($obj, 0, $this->_columns[$col_name]["maxtextlength"]) . "...");
1752 }
1753 }
1754 }
1755 return $obj;
1756 }
1757
1758 /********************************/
1759 /* SEARCH RELATED */
1760 /********************************/
1761
1762 /**
1763 * This method gets the array of
1764 * searchable header fields (columns)
1765 *
1766 * @return array
1767 */
1768 function _get_searchable_fields() {
1769 $fields = array();
1770 foreach($this->_columns as $name => $header) {
1771 if ( $header["searchable"] == SORTABLE ||
1772 $header["searchable"] == SORTABLE_ICASE ||
1773 $header["searchable"] == SORTABLE_NUMERIC) {
1774 $fields[$name] = $header["data_name"];
1775 }
1776 }
1777 return $fields;
1778 }
1779
1780 /**
1781 * This builds the simple search modifier
1782 * select box.
1783 *
1784 * @return INPUTtag object.
1785 */
1786 function _build_simple_search_modifier() {
1787
1788 $options = array();
1789
1790 $modifier = $this->get_simple_search_modifier();
1791
1792 if ( $modifier & SEARCH_BEGINS_WITH ) {
1793 $options["beginning with"] = "BEGINS";
1794 }
1795 if ( $modifier & SEARCH_CONTAINS ) {
1796 $options["containing"] = "CONTAINS";
1797 }
1798 if ( $modifier & SEARCH_EXACT ) {
1799 $options["matching"] = "EXACT";
1800 }
1801 if ( $modifier & SEARCH_ENDS_WITH ) {
1802 $options["ending with"] = "ENDS";
1803 }
1804
1805 $selected = $this->simple_search_modifier_value();
1806 //make the default Begins with
1807 if ( !$selected ) {
1808 $selected = "BEGINS";
1809 }
1810
1811 return form_select($this->_vars["simple_search_modifierVar"], $options, $selected);
1812 }
1813
1814 /**
1815 * This function is used to make safe
1816 * any query string value that is used
1817 *
1818 * @param string
1819 * @return string
1820 */
1821 function search_value_filter( $value ) {
1822 return stripslashes( trim($value) );
1823 }
1824 }
1825 ?>

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed