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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3 by jonen, Mon Feb 3 16:21:09 2003 UTC revision 1.8 by jonen, Thu May 6 16:27:46 2004 UTC
# Line 1  Line 1 
1  <?php  <?php
   
2  /**  /**
3   * This is the base class for managing a list   * This is the base class for managing a list
4   * of data points.   * of data points.
# Line 8  Line 7 
7   * @package phpHtmlLib   * @package phpHtmlLib
8   */   */
9    
10  define("SORTABLE", TRUE);  /**
11  define("NOT_SORTABLE", FALSE);   * 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);  define("SEARCHABLE", TRUE);
21  define("NOT_SEARCHABLE", FALSE);  define("NOT_SEARCHABLE", FALSE);
22    
# Line 28  define("SEARCH_ALL", 15); Line 35  define("SEARCH_ALL", 15);
35   * data from any source via the DataListSource   * data from any source via the DataListSource
36   * object.  It fetches/builds/gets its data   * object.  It fetches/builds/gets its data
37   * from the DataListSource object, which can   * from the DataListSource object, which can
38   * be written to support any data source   * be written to support any data source
39   * (MySQL, Oracle, comma delimited file, xml, etc.)   * (MySQL, Oracle, comma delimited file, xml, etc.)
40   *   *
41   * This base class MUST be extended by a child to   * This base class MUST be extended by a child to
# Line 48  define("SEARCH_ALL", 15); Line 55  define("SEARCH_ALL", 15);
55   * data source itself)   * data source itself)
56   *   *
57   * The DataList object will build the title, the search block   * The DataList object will build the title, the search block
58   * (if any), the datalist controls (the links/imges for   * (if any), the datalist controls (the links/imges for
59   * first, prev, next, last, all).  Then the data columns/labels.   * first, prev, next, last, all).  Then the data columns/labels.
60   * Then it will fetch each of the rows of data to display   * Then it will fetch each of the rows of data to display
61   * from the DataListSource.   * from the DataListSource.
62   *   *
63   * The logic of the output calls follows in the order:   * The logic of the output calls follows in the order:
# Line 63  define("SEARCH_ALL", 15); Line 70  define("SEARCH_ALL", 15);
70   *   *
71   *   *
72   * REQUIREMENTS:   * REQUIREMENTS:
73   *  You must use/define a DataListSource object.   *  You must use/define a DataListSource object.
74   *  You MUST override/extend the following methods:   *  You MUST override/extend the following methods:
75   *   *
76   *  * get_data_source() - used to set the DataListSource   *  * get_data_source() - used to set the DataListSource
# Line 90  define("SEARCH_ALL", 15); Line 97  define("SEARCH_ALL", 15);
97   *   *
98   *  * child_add_row_cell() - This function is responsible for adding   *  * child_add_row_cell() - This function is responsible for adding
99   *                           the cell in the current row.  The method   *                           the cell in the current row.  The method
100   *                           is responsible for keeping track of the   *                           is responsible for keeping track of the
101   *                           location in its UI object for the current   *                           location in its UI object for the current
102   *                           row.   *                           row.
103   *   *
104   *  * child_get_gui() - This method returns the entire UI in 1 object   *  * child_get_gui() - This method returns the entire UI in 1 object
105   *                      or container.  At this point the entire UI   *                      or container.  At this point the entire UI
106   *                      has been constructed, the entire list of data   *                      has been constructed, the entire list of data
107   *                      has been walked and inserted.     *                      has been walked and inserted.
108   *   *
109   *   *
110   * @author Walter A. Boring IV <waboring@buildabetterweb.com>   * @author Walter A. Boring IV <waboring@buildabetterweb.com>
111   * @package phpHtmlLib   * @package phpHtmlLib
112   */   */
113  class DataList extends BaseWidget {  class DataList extends BaseWidget {
114    
# Line 128  class DataList extends BaseWidget { Line 135  class DataList extends BaseWidget {
135       */       */
136      var $_max_rows = 200;      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?       * Do we want to alternate the row colors?
# Line 142  class DataList extends BaseWidget { Line 156  class DataList extends BaseWidget {
156       */       */
157      var $_global_prefix = '';      var $_global_prefix = '';
158    
     /**  
      * The offset variable name  
      */  
     var $_offsetVar = "offset";  
159    
160      /**      /**
161       * The order by variable name       * Holds an array of all the
162       */       * form vars we need for this
163      var $_orderbyVar = "orderby";       * 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       * Holds the db column name that
# Line 159  class DataList extends BaseWidget { Line 179  class DataList extends BaseWidget {
179      var $_default_orderby = '';      var $_default_orderby = '';
180    
181      /**      /**
      * The reverseorder variable name  
      */  
     var $_reverseorderVar = "reverseorder";  
   
     /**  
182       * Holds a flag to let us know to       * Holds a flag to let us know to
183       * reverse order the column by default       * reverse order the column by default
184       */       */
185      var $_default_reverseorder = "false";      var $_default_reverseorder = "false";
186    
187      /**      /**
      * The number of rows variable name  
      */  
     var $_numrowsVar = "numrows";  
   
         /**  
      * This var to tell us to show all  
      * data or not.  
      */  
     var $_showallVar = "showall";  
   
     /**  
      * The search field variable  
      */  
     var $_search_fieldVar  = "search_field";  
   
     /**  
      * The search value  
      */  
     var $_search_valueVar  = "search_value";  
   
     /**  
      * The type of search  
      * advanced/simple  
      */  
     var $_search_typeVar = "search_type";  
   
     /**  
      * The simple search modifier  
      * var name.  
      *  
      */  
     var $_simple_search_modifierVar = "simple_search_modifier";  
     
   
     /**  
188       * Flag to let us know that search       * Flag to let us know that search
189       * is enabled.       * is enabled.
190       *       *
# Line 227  class DataList extends BaseWidget { Line 207  class DataList extends BaseWidget {
207      var $_simple_search_modifier = FALSE;      var $_simple_search_modifier = FALSE;
208    
209    
210          /**      /**
211           * Holds the object block that is the       * Holds the object block that is the
212           * search UI       * search UI
213           */       */
214          var $_search_table = NULL;      var $_search_table = NULL;
215    
216      /**      /**
217       * This holds a list of       * This holds a list of
# Line 243  class DataList extends BaseWidget { Line 223  class DataList extends BaseWidget {
223      var $_save_vars = array();      var $_save_vars = array();
224    
225    
226          /**      /**
227           * The column descriptions       * The column descriptions
228           * for the data we are working on       * for the data we are working on
229           *       *
230           * @var array       * @var array
231           */       */
232          var $_columns = array();      var $_columns = array();
233    
234          /**      /**
235       * Keeps track of the # of columns we have       * Keeps track of the # of columns we have
236       */       */
237      var $_num_columns = 0;      var $_num_columns = 0;
238    
239    
240          /**      /**
241           * This holds the form attributes       * This holds the form attributes
242           *       *
243           */       */
244          var $_form_attributes = array("method" => "GET",      var $_form_attributes = array("method" => "GET",
245                                                                    "target" => "",                                    "target" => "",
246                                                                    "action" => "",                                    "action" => "",
247                                                                    "name" => "");                                    "name" => "datalist");
248    
249          /**      /**
250           * Build everything inside a form?       * Build everything inside a form?
251           *       *
252           */       */
253          var $_form_render_flag = FALSE;      var $_form_render_flag = FALSE;
254    
255    
256          /**      /**
257           * flag to let us know if we want to show       * flag to let us know if we want to show
258           * the results or not.       * the results or not.
259           */       */
260          var $_show_results_flag = TRUE;      var $_show_results_flag = TRUE;
261    
262    
263          /**      /**
264           * Holds our reference/copy of the       * Holds our reference/copy of the
265           * DataListSource object which is used to       * DataListSource object which is used to
266           * access the data that this object uses       * access the data that this object uses
267           *       *
268           * @var DataListSource object       * @var DataListSource object
269           */       */
270          var $_datasource = NULL;      var $_datasource = NULL;
271    
272          /**      /**
273           * This stores the base path to where the       * This stores the base path to where the
274           * tool link images live.  This lets you       * tool link images live.  This lets you
275           * specify a new path to where your images       * specify a new path to where your images
276           * live.       * live.
277           */       */
278          var $_image_path = "img/widgets";      var $_image_path = "img/widgets/";
279            
280            
281        /**
282          /**       * The constructor
283           * The constructor       *
284           *       * @param string - the title of the data list
285           * @param string - the title of the data list       * @param string - the overall width
286           * @param string - the overall width       * @param string - the column to use as the default sorting order
287           * @param string - the column to use as the default sorting order       * @param boolean - sort the default column in reverse order?
288           * @param boolean - sort the default column in reverse order?       */
289           */      function DataList($title, $width = "100%", $default_orderby='',
290          function DataList($title, $width = "100%", $default_orderby='',                        $default_reverseorder=FALSE) {
291                                            $default_reverseorder=FALSE ) {          $this->set_title( $title );
292                  $this->set_title( $title );  
293                  $this->set_form_name( str_replace(' ', '_', strtolower($title)) );          if ($title != NULL && $title != "") $this->set_form_name( str_replace(' ', '_', strtolower($title)) );
294                  $this->set_width( $width );  
295            $this->set_width( $width );
296    
297    
298          $this->_default_orderby = $default_orderby;          $this->_default_orderby = $default_orderby;
299                  if ($default_reverseorder === TRUE) {          if ( $default_reverseorder === TRUE ) {
300                          $default_reverseorder = "true";              $default_reverseorder = "true";
301                  } if ($default_reverse_order === FALSE) {          }if ( $default_reverseorder === FALSE ) {
302                          $default_reverseorder = "false";              $default_reverseorder = "false";
303                  }          }
304          $this->_default_reverseorder = $default_reverseorder;          $this->_default_reverseorder = $default_reverseorder;
305    
306    
307          //Set the global prefix for our variables.          //Set the global prefix for our variables.
308          //want to make sure we can have multiple          //want to make sure we can have multiple
309          //item lists per html page.          //item lists per html page.
310          $this->set_global_prefix('');          $this->set_global_prefix('');
311    
312                  //child class MUST override this          //allow someone to do some generic
313                  //method to automatically set          //action before we get the data source
314                  //the DataListSource object.          //and start processing rows.
315                  //This class doesn't work without it.          $this->do_action();
316                  $this->get_data_source();  
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.          //Call the subclass setup function.
324          //This is a way to get around having          //This is a way to get around having
325          //to override the constructor and          //to override the constructor and
326          //pass in the same params.          //pass in the same params.
327          $this->user_setup();          $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 function renders the final          $this->setup_columns();
339           * widget  
340           *          //do any data prefetch work
341           */          //which may be child specific
342          function render($indent_level, $output_debug) {          if ( $this->_show_results() ) {
343                $this->data_prefetch();
344                  //setup the columns in their sorts          }
345                  $this->setup_columns();  
346            //This function gives the child class
347                  //do any data prefetch work          //a chance to build the tables/divs/containers
348                  //which may be child specific          //that will be responsible for the look/feel
349                  if ($this->_show_results()) {          //of the DataList
350                          $this->data_prefetch();          $this->gui_init();
351                  }  
352            //see if we need to build the search area.
353                  //This function gives the child class          if ( $this->is_search_enabled() || $this->is_advanced_search_enabled() ) {
354                  //a chance to build the tables/divs/containers              $this->_search_table = $this->child_build_search_table();
355                  //that will be responsible for the look/feel              if ( $this->_search_table ) {
356                  //of the DataList                  $this->set_form_render(TRUE);
357                  $this->gui_init();              }
   
                 //see if we need to build the search area.  
                 if ($this->is_search_enabled() || $this->is_advanced_search_enabled()) {  
                         $this->_search_table = $this->child_build_search_table();  
                         if ($this->_search_table) {  
                                 $this->set_form_render(TRUE);  
                         }  
358          }          }
                   
359    
360          if ($this->get_form_render()) {  
361            if ( $this->get_form_render() ) {
362              $form =  new FORMtag( array("method" => $this->get_form_method(),              $form =  new FORMtag( array("method" => $this->get_form_method(),
363                                          "action" => $this->build_base_url(),                                          "action" => $this->build_base_url(),
364                                          "name" => $this->get_form_name(),                                          "name" => $this->get_form_name(),
365                                          "style" => "margin-top: 0px;margin-bottom:0px;") );                                          "style" => "margin-top: 0px;margin-bottom:0px;") );
366    
367                          $target = $this->get_form_target();              $target = $this->get_form_target();
368              if ($target != NULL)              if ( $target != NULL )
369                  $form->set_tag_attribute("target",$target);                  $form->set_tag_attribute("target",$target);
370    
371                          $action = $this->get_form_action();              $action = $this->get_form_action();
372              if ($action != NULL)              if ( $action != NULL )
373                  $form->set_tag_attribute("action",$action);                  $form->set_tag_attribute("action",$action);
374    
375                          //now build the UI and return it              //now build the UI and return it
376                          $form->add( $this->build_gui() );              $form->add( $this->build_gui() );
377    
                         //add the save vars the user wants.  
                         $form->add( $this->_build_save_vars() );  
378          } else {          } else {
379                          $form = container();              $form = container();
380    
381                          //now build the UI and return it              //now build the UI and return it
382                          $form->add( $this->build_gui() );              $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          //add any javascript required
394          $container = container( $this->_javascript(), $form );          $container = container( $this->_javascript(), $form );
395          return $container->render( $indent_level, $output_debug );          return $container->render( $indent_level, $output_debug );
396          }      }
397    
398          /**      /**
399           * This function is responsible for calling the child       * This function is responsible for calling the child
400           * class's methods for building the GUI container.       * class's methods for building the GUI container.
401           * This function builds the search area, the       * This function builds the search area, the
402           * title, page controls, the column headers,       * title, page controls, the column headers,
403           * and walks the rows of data and adds them       * and walks the rows of data and adds them
404           *       *
405           * A child class can override this method to       * A child class can override this method to
406           * move the placement of the search box       * move the placement of the search box
407           * relative to the data list.  By default       * relative to the data list.  By default
408           * the search area comes above the table       * the search area comes above the table
409           * for the data list and page controls       * for the data list and page controls
410           *       *
411           * @return Container       * @return Container
412           */       */
413          function build_gui() {      function build_gui() {
414                  $container = container();          $container = container();
415                    
416                  //if we have a search area to show          //if we have a search area to show
417                  //add it to the ui.          //add it to the ui.
418                  if ($this->_search_table) {          if ( $this->_search_table ) {
419                          $container->add( $this->_search_table );              $container->add( $this->_search_table );
420                  }          }
421    
422                  if ($this->_show_results()) {          if ( $this->_show_results() ) {
423                          //walk the list of columns and call the child              //walk the list of columns and call the child
424                          //method to add it              //method to add it
425                          $column_count = count($this->_columns);              $column_count = count($this->_columns);
426                          foreach( $this->_columns as $name => $col ) {              foreach( $this->_columns as $name => $col ) {
427                                  $this->child_build_column_header( $name, $col, $column_count);                  $this->child_build_column_header( $name, $col, $column_count);
428                          }              }
429                            
430                          //now walk the list of rows and build and add the              if ($this->_query_worked) {
431                          //cells of data                  //now walk the list of rows and build and add the
432                          $col_count = count($this->_columns);                  //cells of data
433                          while ($row = $this->_datasource->get_next_data_row()) {                  while ( $row = $this->_datasource->get_next_data_row() ) {
434                                  $cnt = 1;                      //try and filter the row.
435                                  foreach( $this->_columns as $col_name => $data ) {                      if (!$this->_datasource->row_filter($row)) {
436                                          $obj = $this->build_column_item($row, $col_name);                          $this->_datasource->set_total_rows( $this->_datasource->get_total_rows() -1);
437                                          if (!is_object($obj)) {                          continue;
                                                 $obj = $this->_clean_string($obj, $col_name);  
438                      }                      }
439                                          //                      $cnt = 1;
440                                          $this->child_add_row_cell($obj, $col_name, ($cnt == $col_count) ? TRUE : FALSE );                      foreach( $this->_columns as $col_name => $data ) {
441                                          $cnt++;                          $obj = $this->build_column_item($row, $col_name);
442                                  }                          if ( !is_object($obj) ) {
443                          }                              $obj = $this->_clean_string($obj, $col_name);
444                          $container->add( $this->child_get_gui() );                          }
445                  }  
446                                            $this->child_add_row_cell($obj, $col_name,
447                                                      (($cnt == $column_count) ? TRUE : FALSE),
448                  return $container;                                                    $row);
449          }                          $cnt++;
450                        }
451          /**                  }
452           * This function is called automatically by              }
453           * the DataList constructor.  It must be              $container->add( $this->child_get_gui() );
454           * extended by the child class to actually          }
455           * set the DataListSource object.  
456           *  
457           *          return $container;
458           */      }
459          function get_data_source() {  
460                  user_error("DataList::get_data_source() - ".  
461                                     "child class must override this to ".      /**
462                                     "set the the DataListSource object.");       * 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       * A subclass can override this function
487       * to setup the class variables after       * to setup the class variables after
488       * the constructor.  The constructor       * the constructor.  The constructor
489       * automatically calls this function.       * automatically calls this function.
490           *       *
491       */       */
492      function user_setup() {      function user_setup() {
493          user_error("DataList::user_setup() - ".          user_error("DataList::user_setup() - ".
494                                     "child class must override this method ".                     "child class must override this method ".
495                                     "to set the columns, and any options for ".                     "to set the columns, and any options for ".
496                                     "the DataListSource.");                     "the DataListSource.");
497      }      }
498    
499      /**      /**
# Line 488  class DataList extends BaseWidget { Line 501  class DataList extends BaseWidget {
501       * to setup the class variables after       * to setup the class variables after
502       * the constructor.  The constructor       * the constructor.  The constructor
503       * automatically calls this function.       * automatically calls this function.
504           *       *
505       */       */
506      function gui_init() {      function gui_init() {
507          user_error("DataList::gui_init() - ".          user_error("DataList::gui_init() - ".
508                                     "child class must override this method ".                     "child class must override this method ".
509                                     "to set up the containers/objects that will ".                     "to set up the containers/objects that will ".
510                                     "hold the search area, page controls, ".                     "hold the search area, page controls, ".
511                                     "column headers and the data cells");                     "column headers and the data cells");
512      }      }
   
         /**  
          * This method is supposed to be written by  
          * the child class to build and add the column  
          * title to the UI  
          *  
          * @param string - the title of the column  
          * @param array - the column data ( from $this->_columns )  
          * @param int - the column #  
          *  
          */  
         function child_build_column_header($title, $col_data, $col_count) {  
                 user_error("DataList::child_build_column_header() - ".  
                                    "child class must override this method ".  
                                    "to build the object that will be the ".  
                                    "individual column header/itle");  
         }  
   
         /**  
          * This method is supposed to be written by  
          * the child class to add the cell data to the  
          * current row in the UI  
          *  
          * @param mixed - the object/string/entity that  
          *                should get put into the column row cell.  
          * @param string - the name/title of the column that the  
          *                 object will live in  
          * @param boolean - flag that tells the function if this is  
          *                  is the last cell for the current row.  
          *  
          */  
         function child_add_row_cell($obj, $col_name, $last_in_row_flag) {  
                 user_error("DataList::child_build_column_header() - ".  
                                    "child class must override this method ".  
                                    "to build the object that will be the ".  
                                    "individual column header/itle");  
         }  
   
         /**  
          * This function is called after all of the data has  
          * been added to the UI object.  It just returns the  
          * container that is the entire UI for the DataList  
          *  
          * @return Container  
          */  
         function child_get_gui() {  
                 user_error("DataList::child_get_gui() - ".  
                                    "child class must override this method ".  
                                    "to return the wrapper that contains ".  
                                    "the entire UI.");  
         }  
   
         /**  
          * This function builds the search  
          * block that lives above the results  
          *  
          * @return Container  
          */  
         function child_build_search_table() {  
                 user_error("DataList::child_build_search_table() - ".  
                                    "child class must override this");  
                 return NULL;  
         }  
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       * This function provides a way to automatically
579       * add javascript to this object.       * add javascript to this object.
580       * This function is meant to be extended by the       * This function is meant to be extended by the
# Line 585  class DataList extends BaseWidget { Line 598  class DataList extends BaseWidget {
598       * @param boolean - $sortable - flag to make this column sortable.       * @param boolean - $sortable - flag to make this column sortable.
599       * @param boolean - $searchable - flag to make this column searchable.       * @param boolean - $searchable - flag to make this column searchable.
600       * @param string - header align value.       * @param string - header align value.
601         * @param string - the sort order
602       * @param string - the maximum # of characters to allow in the cell.       * @param string - the maximum # of characters to allow in the cell.
603       *       *
604       * @return array a single header array       * @return array a single header array
# Line 595  class DataList extends BaseWidget { Line 609  class DataList extends BaseWidget {
609                                $max_text_length=NULL) {                                $max_text_length=NULL) {
610    
611          $this->_columns[$label] = array("size" => $size,          $this->_columns[$label] = array("size" => $size,
612                                                                             "data_name" => $data_name,                                          "data_name" => $data_name,
613                                                                             "sortable" => $sortable,                                          "sortable" => $sortable,
614                                                                             "searchable" => $searchable,                                          "searchable" => $searchable,
615                                                                             "align" => $align,                                          "align" => $align,
616                                                                             "sortorder" => $sortorder,                                          "sortorder" => $sortorder,
617                                                                             "maxtextlength" => $max_text_length);                                          "maxtextlength" => $max_text_length,
618          $this->_num_headers++;                                          "reverseorder"=>false);
619                            //$this->_num_headers++;
620                  $this->_check_datasource("add_header_item");  
621                  $this->_datasource->add_column($label, $data_name, $sortable,          $this->_check_datasource("add_header_item");
622                                                                                  $searchable, $sortorder);          $this->_datasource->add_column($label, $data_name, $sortable,
623                                           $searchable, $sortorder);
624      }      }
625    
626    
# Line 618  class DataList extends BaseWidget { Line 633  class DataList extends BaseWidget {
633       * @param string $prefix - the prefix for all vars.       * @param string $prefix - the prefix for all vars.
634       */       */
635      function set_global_prefix($prefix) {      function set_global_prefix($prefix) {
636          $this->_global_prefix           = $prefix;          $this->_global_prefix = $prefix;
637          $this->_offsetVar                       = $prefix . "offset";          //update all the vars used
638          $this->_orderbyVar                      = $prefix . "orderby";          foreach ($this->_vars as $name => $value ) {
639          $this->_reverseorderVar         = $prefix . "reverseorder";              $this->_vars[$name] = $prefix.$value;
640          $this->_numrowsVar                      = $prefix . "numrows";          }
         $this->_showallVar                      = $prefix . "showall";  
         $this->_search_fieldVar         = $prefix . "search_field";  
         $this->_search_valueVar         = $prefix . "search_value";  
                 $this->_search_typeVar          = $prefix . $this->_search_typeVar;  
         $this->_simple_search_modifierVar = $prefix . $this->_simple_search_modifierVar;  
641      }      }
642    
643      /**      /**
# Line 640  class DataList extends BaseWidget { Line 650  class DataList extends BaseWidget {
650          return $this->_global_prefix;          return $this->_global_prefix;
651      }      }
652    
653          /**      /**
654           * This function is used to set the       * This function is used to set the
655           * DataListSource object for this instance       * DataListSource object for this instance
656           *       *
657           * @param DataListSource object       * @param DataListSource object
658           */       */
659          function set_data_source( $datasource ) {      function set_data_source( $datasource ) {
660                  $this->_datasource = &$datasource;          $this->_datasource = &$datasource;
661          }      }
662    
663      /**      /**
664       * Enable the search ability.       * Enable the search ability.
# Line 657  class DataList extends BaseWidget { Line 667  class DataList extends BaseWidget {
667       */       */
668      function search_enable( ) {      function search_enable( ) {
669          $this->_search_flag = TRUE;          $this->_search_flag = TRUE;
670          if (!$this->is_advanced_search_enabled()) {          if ( !$this->is_advanced_search_enabled() ) {
671              $this->set_search_type("simple");              $this->set_search_type("simple");
672          }          }
673      }      }
# Line 691  class DataList extends BaseWidget { Line 701  class DataList extends BaseWidget {
701       */       */
702      function advanced_search_enable() {      function advanced_search_enable() {
703          $this->_advanced_search_flag = TRUE;          $this->_advanced_search_flag = TRUE;
704          if (!$this->is_search_enabled()) {          if ( !$this->is_search_enabled() ) {
705              $this->set_search_type("advanced");              $this->set_search_type("advanced");
706          }          }
707      }      }
# Line 727  class DataList extends BaseWidget { Line 737  class DataList extends BaseWidget {
737       * MODIFIERS:       * MODIFIERS:
738       *          SEARCH_BEGINS_WITH       *          SEARCH_BEGINS_WITH
739       *          SEARCH_CONTAINS       *          SEARCH_CONTAINS
740       *          SEARCH_EXACT       *      SEARCH_EXACT
741       *          SEARCH_ENDS_WITH       *      SEARCH_ENDS_WITH
742       *       *
743       *       ie. SEARCH_BEGINS_WITH.SEARCH_EXACT       *       ie. SEARCH_BEGINS_WITH.SEARCH_EXACT
744       *           will enable ONLY the       *           will enable ONLY the
# Line 737  class DataList extends BaseWidget { Line 747  class DataList extends BaseWidget {
747       * @param string       * @param string
748       */       */
749      function set_simple_search_modifier( $modifier = SEARCH_ALL ) {      function set_simple_search_modifier( $modifier = SEARCH_ALL ) {
750          if ($modifier == 0) {          if ( $modifier == 0 ) {
751              $this->_simple_search_modifier = SEARCH_BEGINS_WITH |              $this->_simple_search_modifier = SEARCH_BEGINS_WITH |
752                                               SEARCH_CONTAINS |                                               SEARCH_CONTAINS |
753                                               SEARCH_EXACT |                                               SEARCH_EXACT |
# Line 763  class DataList extends BaseWidget { Line 773  class DataList extends BaseWidget {
773       * @param int - the # of rows to use.       * @param int - the # of rows to use.
774       */       */
775      function set_default_num_rows( $num_rows ) {      function set_default_num_rows( $num_rows ) {
776          $this->default_rows_per_page = $num_rows;          $this->_default_rows_per_page = $num_rows;
777      }      }
778    
779      /**      /**
# Line 776  class DataList extends BaseWidget { Line 786  class DataList extends BaseWidget {
786          return $this->_default_rows_per_page;          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 function sets the save variables       * This sets the maximum # of rows to
801       * that the user/child wants to automatically       * display when in expand mode
802       * propogate       *
803         * @param int - new # of maximum rows
804         *              to display when in 'expand' mode
805       *       *
      * @param array - name=>value pairs of the data  
      *                that they want to propogate  
806       */       */
807      function set_save_vars( $vars ) {      function set_max_rows( $max ) {
808          $this->_save_vars = $vars;          $this->_max_rows = $max;
809      }      }
810    
         /**  
          * This returns the Maximum # of rows to  
          * display when in expand mode  
          *  
          * @return int  
          */  
         function get_max_rows() {  
                 return $this->_max_rows;  
         }  
   
         /**  
          * This sets the maximum # of rows to  
          * display when in expand mode  
          *  
          * @param int - new # of maximum rows  
          *              to display when in 'expand' mode  
          *  
          */  
         function set_max_rows( $max ) {  
                 $this->_max_rows = $max;  
         }  
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           * This function is used to set up any  
834           * data that needs to be munged before the      /**
835           * data is fetched from the DataListSource       * 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          function data_prefetch() {       *
839                  $this->_check_datasource("data_prefetch");       */
840        function data_prefetch() {
841                  if ($this->showall()) {          $this->_check_datasource("data_prefetch");
842                          $this->set_default_num_rows( $this->get_max_rows() );  
843                          $this->set_numrows( $this->get_max_rows() );          if ( $this->expandrows() ) {            
844                  }              if ($this->get_showall()) {
845                    $limit = -1;
846                  $limit = $this->numrows();              } else {
847                  $this->_datasource->query($this->offset(), $limit,                  $this->set_default_num_rows( $this->get_max_rows() );
848                                                                     $this->orderby(), $this->reverseorder(),                  $this->set_numrows( $this->get_max_rows() );
849                                                                     $this->search_field(), $this->search_value(),                  $limit = $this->numrows();
850                                                                     $this->simple_search_modifier_value(),              }            
851                                                                     $this->search_type() );          } 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    
# Line 845  class DataList extends BaseWidget { Line 869  class DataList extends BaseWidget {
869          $temp_headers = array();          $temp_headers = array();
870    
871          foreach( $this->_columns as $col_name => $data ) {          foreach( $this->_columns as $col_name => $data ) {
872              if ($data["sortorder"] == "reverse") {              if ( $data["sortorder"] == "reverse" ) {
873                  $data["reverseorder"] = "true";                  $data["reverseorder"] = "true";
874              }              } else {
             else {  
875                  $data["reverseorder"] = "false";                  $data["reverseorder"] = "false";
876              }              }
877              $temp_headers[$col_name] = $data;              $temp_headers[$col_name] = $data;
# Line 858  class DataList extends BaseWidget { Line 881  class DataList extends BaseWidget {
881    
882    
883    
884          /**      /**
885           * general DataListSource object checker.       * general DataListSource object checker.
886           *       *
887           */       */
888          function _check_datasource($function_name) {      function _check_datasource($function_name) {
889                  if (!is_object($this->_datasource)) {          if ( !is_object($this->_datasource) ) {
890                          user_error("DataList::".$function_name."() - DataListSource object is not set");              user_error("DataList::".$function_name."() - DataListSource object is not set");
891                          exit;              exit;
892                  }          }
893          }      }
894    
895    
896          /*********************************************/      /*********************************************/
897          /*     REQUEST VARIABLE SECTION              */      /*     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       * This function returns the current value
932       * of the offset variable. This is an offset       * of the offset variable. This is an offset
933       * into the query return data set.       * into the query return data set.
# Line 882  class DataList extends BaseWidget { Line 935  class DataList extends BaseWidget {
935       * @return int - the current value.       * @return int - the current value.
936       */       */
937      function offset() {      function offset() {
938                  if (!$_REQUEST[$this->_offsetVar]) {          if ($this->get_showall() && $this->expandrows()) {
939                          $this->set_offset(0);              return 0;
940                  }          } else {
941                  return (int)$_REQUEST[$this->_offsetVar];              return(int)$this->_get("offsetVar", 0);
942            }        
943      }      }
944    
945          /**      /**
946       * This function is used to set/change       * This function is used to set/change
947       * the offset for this list.       * the offset for this list.
948       *       *
949       * @param int - the new offset.       * @param int - the new offset.
950       */       */
951      function set_offset($new_offset) {      function set_offset($new_offset) {
952                  $_REQUEST[$this->_offsetVar] = $new_offset;          $this->_set("offsetVar", $new_offset);
953      }      }
954    
955          /**      /**
956       * This function returns the value of the       * This function returns the value of the
957       * current orderby variable.       * current orderby variable.
958       *       *
959       * @return string.       * @return string.
960       */       */
961      function orderby() {      function orderby() {
962                  if (!$_REQUEST[$this->_orderbyVar]) {          return $this->_get("orderbyVar", $this->_default_orderby);
                         $_REQUEST[$this->_orderbyVar] = $this->_default_orderby;  
                 }  
   
                 return $_REQUEST[$this->_orderbyVar];  
963      }      }
964    
965          /**      /**
966       * This builds a query string var for the       * This builds a query string var for the
967       * orderby value.       * orderby value.
968       *       *
969       * @return string - "orderby=(thevalue)"       * @return string - "orderby=(thevalue)"
970       */       */
971      function build_orderby_querystring() {      function build_orderby_querystring() {
972          $str = $this->_orderbyVar."=".$this->orderby();          $str = $this->_vars["orderbyVar"]."=".urlencode($this->orderby());
973          return $str;          return $str;
974      }      }
975    
# Line 930  class DataList extends BaseWidget { Line 980  class DataList extends BaseWidget {
980       * @return string.       * @return string.
981       */       */
982      function reverseorder() {      function reverseorder() {
983                  if (!$_REQUEST[$this->_reverseorderVar]) {          return $this->_get("reverseorderVar", $this->_default_reverseorder);
                         $this->set_reverseorder($this->_default_reverseorder);  
                 }  
                 return $_REQUEST[$this->_reverseorderVar];  
984      }      }
985    
986      /**      /**
# Line 943  class DataList extends BaseWidget { Line 990  class DataList extends BaseWidget {
990       * @param string - the new value.       * @param string - the new value.
991       */       */
992      function set_reverseorder($new_value) {      function set_reverseorder($new_value) {
993                  $_REQUEST[$this->_reverseorderVar] = $new_value;          $this->_set("reverseorderVar", $new_value);
994      }      }
995    
996          /**      /**
997       * This builds a query string var for the       * This builds a query string var for the
998       * reverseorder value.       * reverseorder value.
999       *       *
1000       * @return string - "orderby=(thevalue)"       * @return string - "orderby=(thevalue)"
1001       */       */
1002      function build_reverseorder_querystring() {      function build_reverseorder_querystring() {
1003          $str = $this->_reverseorderVar."=".$this->reverseorder();          $str = $this->_vars["reverseorderVar"]."=".urlencode($this->reverseorder());
1004          return $str;          return $str;
1005      }      }
1006    
# Line 964  class DataList extends BaseWidget { Line 1011  class DataList extends BaseWidget {
1011       * @return int - the number of rows       * @return int - the number of rows
1012       */       */
1013      function numrows() {      function numrows() {
1014                  if (!$_REQUEST[$this->_numrowsVar]) {          return(int)$this->_get("numrowsVar", $this->_default_rows_per_page);
                         $this->set_numrows($this->_default_rows_per_page);  
                 }  
                 return (int) $_REQUEST[$this->_numrowsVar];  
1015      }      }
1016    
1017      /**      /**
# Line 977  class DataList extends BaseWidget { Line 1021  class DataList extends BaseWidget {
1021       * @param int - the # of rows       * @param int - the # of rows
1022       */       */
1023      function set_numrows($new_numrows) {      function set_numrows($new_numrows) {
1024                  $_REQUEST[$this->_numrowsVar] = $new_numrows;          $this->_set("numrowsVar", $new_numrows);
1025      }      }
1026    
1027      /**      /**
# Line 987  class DataList extends BaseWidget { Line 1031  class DataList extends BaseWidget {
1031       * @return string       * @return string
1032       */       */
1033      function search_field() {      function search_field() {
1034                  if (!$_REQUEST[$this->_search_fieldVar]) {          return $this->_get("search_fieldVar", '');
                         $_REQUEST[$this->_search_fieldVar] = '';  
                 }  
                 return $_REQUEST[$this->_search_fieldVar];  
1035      }      }
1036    
1037          /**      /**
1038       * This builds a query string var for the       * This builds a query string var for the
1039       * searchfield value.       * searchfield value.
1040       *       *
1041       * @return string - "orderby=(thevalue)"       * @return string - "orderby=(thevalue)"
1042       */       */
1043      function build_searchfield_querystring() {      function build_searchfield_querystring() {
1044          $str = $this->_search_fieldVar."=".$this->searchfield();          $str = $this->_vars["search_fieldVar"]."=".urlencode($this->searchfield());
1045          return $str;          return $str;
1046      }      }
1047    
# Line 1011  class DataList extends BaseWidget { Line 1052  class DataList extends BaseWidget {
1052       * @return string       * @return string
1053       */       */
1054      function search_value() {      function search_value() {
1055                  if (!$_REQUEST[$this->_search_valueVar]) {          return $this->_get("search_valueVar", '');
                         $_REQUEST[$this->_search_valueVar] = '';  
                 }  
                 return $_REQUEST[$this->_search_valueVar];  
1056      }      }
1057    
1058          /**      /**
1059       * This builds a query string var for the       * This builds a query string var for the
1060       * searchfield value.       * searchfield value.
1061       *       *
1062       * @return string - "orderby=(thevalue)"       * @return string - "orderby=(thevalue)"
1063       */       */
1064      function build_searchvalue_querystring() {      function build_searchvalue_querystring() {
1065          $str = $this->_search_valueVar."=".$this->search_value();          $str = $this->_vars["search_valueVar"]."=".urlencode($this->search_value());
1066          return $str;          return $str;
1067      }      }
1068    
# Line 1035  class DataList extends BaseWidget { Line 1073  class DataList extends BaseWidget {
1073       * @return string       * @return string
1074       */       */
1075      function simple_search_modifier_value() {      function simple_search_modifier_value() {
1076                  if (!$_REQUEST[$this->_simple_search_modifierVar]) {          return $this->_get("simple_search_modifierVar", '');
                         $_REQUEST[$this->_simple_search_modifierVar] = '';  
                 }  
                 return $_REQUEST[$this->_simple_search_modifierVar];  
1077      }      }
1078    
1079    
# Line 1048  class DataList extends BaseWidget { Line 1083  class DataList extends BaseWidget {
1083       * @return string       * @return string
1084       */       */
1085      function search_type() {      function search_type() {
1086                  if (!$_REQUEST[$this->_search_typeVar]) {          return $this->_get("search_typeVar", "simple");
                         $_REQUEST[$this->_search_typeVar] = "simple";  
                 }  
                 return $_REQUEST[$this->_search_typeVar];  
1087      }      }
1088    
1089      /**      /**
# Line 1061  class DataList extends BaseWidget { Line 1093  class DataList extends BaseWidget {
1093       *                 "simple" or "advanced"       *                 "simple" or "advanced"
1094       */       */
1095      function set_search_type($type) {      function set_search_type($type) {
1096                  $_REQUEST[$this->_search_typeVar] = $type;          $this->_set("search_typeVar", $type);
1097      }      }
1098    
1099    
1100      /**      /**
1101       * returns the current value of the showall       * returns the current value of the expandrows
1102       * flag.  This tells us if they want the entire       * flag.  This tells us if they want the entire
1103       * list of data back from the DB.       * list of data back from the DB.
1104       *       *
1105       * @return string - the current value       * @return string - the current value
1106       */       */
1107      function showall() {      function expandrows() {
1108                  if (!$_REQUEST[$this->_showallVar]) {          if ($this->get_showall()) {
1109                          $_REQUEST[$this->_showallVar] = 0;              $default = 1;
1110                  }          } else {
1111                  return (int) $_REQUEST[$this->_showallVar];              $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          */      /*         FORM VARIABLES SECTION          */
1171          /*******************************************/      /*******************************************/
1172    
1173          /**      /**
1174       * This function is used to set the       * This function is used to set the
1175       * form name       * form name
1176       *       *
# Line 1124  class DataList extends BaseWidget { Line 1209  class DataList extends BaseWidget {
1209      function get_form_target() {      function get_form_target() {
1210          return $this->_form_attributes["target"];          return $this->_form_attributes["target"];
1211      }      }
1212        
1213      /**      /**
1214       * This function is used to set the       * This function is used to set the
1215       * form method       * form method
# Line 1132  class DataList extends BaseWidget { Line 1217  class DataList extends BaseWidget {
1217       * @param string (POST or GET)       * @param string (POST or GET)
1218       */       */
1219      function set_form_method($method) {      function set_form_method($method) {
1220                  if ($method != "GET" && $method != "POST") {          if ( strcasecmp($method,"GET") !=0 && strcasecmp($method,"POST") !=0 ) {
1221                          user_error("DataList::set_form_method() - INVALID Form method ".$method);              user_error("DataList::set_form_method() - INVALID Form method ".$method);
1222                  } else {          } else {
1223                          $this->_form_attributes["method"] = $method;              $this->_form_attributes["method"] = $method;
1224                  }          }
1225      }      }
1226    
1227      /**      /**
# Line 1149  class DataList extends BaseWidget { Line 1234  class DataList extends BaseWidget {
1234          return $this->_form_attributes["method"];          return $this->_form_attributes["method"];
1235      }      }
1236    
1237     /**      /**
1238      * Sets the form action       * Sets the form action
1239      *       *
1240      * @param string       * @param string
1241      */       */
1242      function set_form_action($action) {      function set_form_action($action) {
1243          $this->_form_attributes["action"] = $action;          $this->_form_attributes["action"] = $action;
1244      }      }
1245    
1246          /**      /**
1247       * This function is used to get       * This function is used to get
1248       * the form action       * the form action
1249       *       *
# Line 1187  class DataList extends BaseWidget { Line 1272  class DataList extends BaseWidget {
1272      }      }
1273    
1274      /**      /**
1275           * This function is used to set the       * This function is used to set the
1276           * message displayed when no data is found       * message displayed when no data is found
1277           *       *
1278           * @param string       * @param string
1279           */       */
1280      function set_not_found_message($mesg) {      function set_not_found_message($mesg) {
1281                  $this->_check_datasource("set_not_found_message");          $this->_check_datasource("set_not_found_message");
1282          $this->_datasource->set_not_found_message($mesg);          $this->_datasource->set_not_found_message($mesg);
1283      }      }
1284    
1285    
1286          /**      /**
1287           * This function is used to set the value       * This function is used to set the value
1288           * of the _show_results_flag       * of the _show_results_flag
1289           *       *
1290           * @param boolean - TRUE to show the results       * @param boolean - TRUE to show the results
1291           */       */
1292          function set_show_results( $flag=TRUE ) {      function set_show_results( $flag=TRUE ) {
1293                  $this->_show_results_flag = $flag;          $this->_show_results_flag = $flag;
1294          }      }
1295            
   
         /**  
          * This function is used to let render() know  
          * that we should show the results or not.  
          *  
          * @return boolean  
          */  
         function _show_results() {  
                 return $this->_show_results_flag;  
         }  
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       * this method builds some hidden
1309       * form fields to automatically       * form fields to automatically
1310       * be placed inside the form.       * be placed inside the form.
1311       *       *
1312       * @return ContainerWidget object.       * 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() {      function _build_save_vars() {
1320          $container = container();          $container = container();
# Line 1234  class DataList extends BaseWidget { Line 1324  class DataList extends BaseWidget {
1324          return $container;          return $container;
1325      }      }
1326    
1327          /**      /**
1328       * This function sets the save variables       * This function sets the save variables
1329       * that the user/child wants to automatically       * that the user/child wants to automatically
1330       * propogate       * propogate
# Line 1247  class DataList extends BaseWidget { Line 1337  class DataList extends BaseWidget {
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       * This builds the base url used
1358       * by the column headers as well       * by the column headers as well
1359       * as the page tool links.       * as the page tool links.
# Line 1260  class DataList extends BaseWidget { Line 1367  class DataList extends BaseWidget {
1367    
1368          $url = $_SERVER["PHP_SELF"]."?";          $url = $_SERVER["PHP_SELF"]."?";
1369    
1370          if ($this->get_form_method() == "POST") {          if ( $this->get_form_method() == "POST" ) {
1371              return $url;              return $url;
1372          }          }
1373    
1374                  $vars = array_merge($_POST, $_GET);          $vars = array_merge($_POST, $_GET);
1375          //request method independant access to          //request method independant access to
1376          //browser variables          //browser variables
1377          if (count($vars)) {          if ( count($vars) ) {
1378              //walk through all of the get vars              //walk through all of the get vars
1379              //and add them to the url to save them.              //and add them to the url to save them.
1380              foreach($vars as $name => $value) {              foreach($vars as $name => $value) {
1381    
1382                  if ($name != $this->_offsetVar &&                  if ( $name != $this->_vars["offsetVar"] &&
1383                      $name != $this->_orderbyVar &&                       $name != $this->_vars["orderbyVar"] &&
1384                      $name != $this->_reverseorderVar &&                       $name != $this->_vars["reverseorderVar"] &&
1385                      $name != $this->_search_valueVar                       $name != $this->_vars["search_valueVar"]
1386                     ) {                     ) {
1387                      if (is_array($value)) {                      if ( is_array($value) ) {
1388                          $url .= $name."[]=".implode("&".$name."[]=",$value)."&";                          $url .= $name."[]=".implode("&".$name."[]=",$value)."&";
1389                      } else {                      } else {
1390                                                  $url .= $name."=".urlencode(stripslashes($value))."&";                          $url .= $name."=".urlencode(stripslashes($value))."&";
1391                                          }                      }
1392                  }                  }
1393              }              }
1394          }          }
1395    
1396          return $url;          return htmlentities($url);
1397      }      }
1398    
1399          /**      /**
1400           * This function builds the 'tool' images that       * This function builds the 'tool' images that
1401           * allow  you to walk through the data list itself.       * allow  you to walk through the data list itself.
1402           * It provides image links for       * It provides image links for
1403           * first - go to the first page in the data list       * first - go to the first page in the data list
1404           * prev - go to the previous page in the data list       * prev - go to the previous page in the data list
1405           * next - go to the next page in the data list       * next - go to the next page in the data list
1406           * last - go to the last page in the data list       * last - go to the last page in the data list
1407           * all - show the rest of the list from the current offset       * all - show the rest of the list from the current offset
1408           *       *
1409           * @param string - which tool image to build       * @param string - which tool image to build
1410           * @return Object       * @return Object
1411           */       */
1412          function build_tool_link( $which ) {      function build_tool_link( $which ) {
1413                  $num_pages = $this->get_num_pages();          $num_pages = $this->get_num_pages();
1414          $cur_page = $this->get_current_page();          $cur_page = $this->get_current_page();
1415          $last_page = $this->get_last_page();          $last_page = $this->get_last_page();
1416    
1417                  $image_path = $this->get_image_path();          $image_path = $this->get_image_path();
1418                  switch ($which) {          switch ( $which ) {
1419                    
1420                  case "first":          case "first":
1421                          $rows_string = "First ".$this->get_default_num_rows()." Rows";              $rows_string = "First ".$this->get_default_num_rows()." Rows";
1422                          if ($this->offset() <= 0) {              if ( $this->offset() <= 0 ) {
1423                                  $obj = html_img($image_path."/first_group_button_inactive.gif",                  $obj = html_img($image_path."/first_group_button_inactive.gif",
1424                                                                  '','',0,$rows_string, NULL, $rows_string);                                  '','',0,$rows_string, NULL, $rows_string . ": Disabled Link");
1425                          } else {              } else {
1426                  $url = $this->_build_tool_url(0);                  $url = $this->_build_tool_url(0);
1427                                  $obj = html_img_href($url, $image_path."/first_group_button.gif",                  $obj = html_img_href($url, $image_path."/first_group_button.gif",
1428                                                                           '','',0, $rows_string, NULL, NULL, $rows_string);                                       '','',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;              break;
1473    
1474                  case "prev":          case "expand":
1475                          $rows_string = "Previous ".$this->get_default_num_rows()." Rows";              $offset = $this->offset();
1476                          if ($this->offset() <= 0) {              if ( $this->expandrows() ) {
1477                                  $obj = html_img($image_path."/prev_group_button_inactive.gif",                  $url = $this->_build_tool_url($offset, TRUE, 0);
1478                                                                  '','',0,$rows_string, NULL, $rows_string);                  $obj = html_img_href($url, $image_path."/close_group_button.gif",
1479                          } else {                                       '','',0,"Collapse Rows", NULL, NULL, "Collapse Rows");
1480                                  $offset = $this->offset() - $this->numrows();              } else {
1481                                  if ($offset < 0) {                  if ( ($num_pages == 1) ) {
1482                                          $offset = 0;                      $obj = html_img($image_path."/expand_group_button_inactive.gif",
1483                                  }                                      '','',0, "Expand Rows", NULL, "Expand Rows" . ": Disabled Link");
1484                                  $url = $this->_build_tool_url($offset);                  } else {
1485                                  $obj = html_img_href($url, $image_path."/prev_group_button.gif",                      $url = $this->_build_tool_url($offset, TRUE, 1);
1486                                                                           '','',0, $rows_string, NULL, NULL, $rows_string);                      $obj = html_img_href($url, $image_path."/expand_group_button.gif",
1487                          }                                           '','',0,"Expand Rows", NULL, NULL, "Expand Rows");
1488                          break;                  }
1489                }
1490                  case "next":              //so we don't save it into the mozilla navigation bar links
1491                          $rows_string = "Next ".$this->get_default_num_rows()." Rows";              unset($url);
1492                          if (($num_pages == 1) || ($cur_page == $last_page)) {              break;
1493                                  $obj = html_img($image_path."/next_group_button_inactive.gif",          }
1494                                                                  '','',0, $rows_string, NULL, $rows_string);  
1495                          } else {          if ( !empty($url) ) {
1496                                  $offset = $this->offset() + $this->numrows();              $this->_save_mozilla_nav_link($which, $url);
1497                                  $url = $this->_build_tool_url($offset);          }
1498                                  $obj = html_img_href($url, $image_path."/next_group_button.gif",  
1499                                                                           '','',0, $rows_string, NULL, NULL, $rows_string);          return $obj;
1500                          }      }
1501                          break;  
1502        /**
1503                  case "last":       * This function is used to build the url
1504                          $rows_string = "Last ".$this->get_default_num_rows()." Rows";       * for a tool link.
1505                          if (($num_pages == 1) || ($cur_page == $last_page)) {       * (first, prev, next, last, all)
1506                                  $obj = html_img($image_path."/last_group_button_inactive.gif",       *
1507                                                                  '','',0, $rows_string, NULL, $rows_string);       * @param int - the offset for the link
1508                          } else {       * @param boolean - add the expandrows value to the url
1509                                  $offset = (int)(($num_pages - 1) * $this->numrows());       * @param int - the expandrows value to use if the flag is on
1510                                  $url = $this->_build_tool_url($offset);       *
1511                                  $obj = html_img_href($url, $image_path."/last_group_button.gif",       * @return string
1512                                                                           '','',0, $rows_string, NULL, NULL, $rows_string);       */
1513                          }      function _build_tool_url($offset, $expandrows_flag=FALSE, $expandrows_value=0) {
1514                          break;          if ( $this->get_form_method() == "POST" ) {
1515                $form_name = $this->get_form_name();
1516                  case "all":              $url = "javascript: document.".$form_name;
1517                          $offset = $this->offset();              $url .= ".".$this->_vars["offsetVar"].".value='".$offset."';";
1518                          if ($this->showall()) {  
1519                                  $url = $this->_build_tool_url($offset, TRUE, 0);              //add the expandrows variable to the post
1520                                  $obj = html_img_href($url, $image_path."/close_group_button.gif",              if ( $expandrows_flag ) {
1521                                                                           '','',0,"Collapse Rows", NULL, NULL, "Collapse Rows");                  $form_field = $this->_vars["expandrowsVar"];
                         } else {  
                                 if (($num_pages == 1)) {  
                                         $obj = html_img($image_path."/expand_group_button_inactive.gif",  
                                                                         '','',0, "Expand Rows", NULL, "Expand Rows");  
                                 } else {  
                                         $url = $this->_build_tool_url($offset, TRUE, 1);  
                                         $obj = html_img_href($url, $image_path."/expand_group_button.gif",  
                                                                                  '','',0,"Expand Rows", NULL, NULL, "Expand Rows");  
                                 }  
                         }  
                         //so we don't save it into the mozilla navigation bar links  
                         unset($url);  
                         break;  
                 }  
   
                 if ($url) {  
                         $this->_save_mozilla_nav_link($which, $url);  
                 }  
                   
                 return $obj;  
         }  
   
         /**  
          * This function is used to build the url  
          * for a tool link.    
          * (first, prev, next, last, all)  
          *  
          * @param int - the offset for the link  
          * @param boolean - add the showall value to the url  
          * @param int - the showall value to use if the flag is on  
          *  
          * @return string  
          */  
         function _build_tool_url($offset, $showall_flag=FALSE, $showall_value=0) {  
                 if ($this->get_form_method() == "POST") {  
                         $form_name = $this->get_form_name();  
                         $url = "javascript: document.".$form_name;  
                         $url .= ".".$this->_offsetVar.".value='".$offset."';";  
   
                         //add the showall variable to the post  
                         if ($showall_flag) {  
                                 $form_field = $this->_showallVar;  
1522                  $url .= "document.".$form_name.".";                  $url .= "document.".$form_name.".";
1523                                  $url .= $form_field.".value='".$showall_value."';";                  $url .= $form_field.".value='".$expandrows_value."';";
1524                          }              }
1525    
1526                          $url .= "document.".$form_name.".submit();";              $url .= "document.".$form_name.".submit();";
1527                  } else {          } else {
1528                          $url = $this->build_base_url();              $url = $this->build_base_url();
1529                          $url .= $this->build_state_vars_query_string($offset, $showall_flag,              $url .= $this->build_state_vars_query_string($offset, $expandrows_flag,
1530                                                                                                                   $showall_value);                                                           $expandrows_value);
1531                  }          }
1532                  return $url;          return $url;
1533          }      }
1534    
1535      /**      /**
1536       * this function is used to build a sub query string       * this function is used to build a sub query string
# Line 1431  class DataList extends BaseWidget { Line 1538  class DataList extends BaseWidget {
1538       * state of the DBItemList.  This is used for pages       * state of the DBItemList.  This is used for pages
1539       * that want to come back to the list at the same state       * 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       * @return string - name=value& pairs
1545       */       */
1546      function build_state_vars_query_string($offset, $showall_flag=FALSE,      function build_state_vars_query_string($offset, $expandrows_flag=FALSE,
1547                                                                                     $showall_value=0) {                                             $expandrows_value=0) {
1548          $str = "";          $str = "";
1549    
1550          $str .= $this->_offsetVar."=".urlencode($offset);          $str .= $this->_vars["offsetVar"]."=".urlencode($offset);
1551          $str .= "&".$this->_orderbyVar."=".urlencode($this->orderby());          $str .= "&".$this->_vars["orderbyVar"]."=".urlencode($this->orderby());
1552          $str .= "&".$this->_reverseorderVar."=".urlencode($this->reverseorder());          $str .= "&".$this->_vars["reverseorderVar"]."=".urlencode($this->reverseorder());
1553          $str .= "&".$this->_search_fieldVar."=".urlencode($this->search_field());          $str .= "&".$this->_vars["search_fieldVar"]."=".urlencode($this->search_field());
1554          $str .= "&".$this->_search_valueVar."=".urlencode($this->search_value());          $str .= "&".$this->_vars["search_valueVar"]."=".urlencode($this->search_value());
1555          $str .= "&".$this->_simple_search_modifierVar."=".urlencode($this->simple_search_modifier_value());          $str .= "&".$this->_vars["simple_search_modifierVar"]."=".urlencode($this->simple_search_modifier_value());
1556          $str .= "&".$this->_search_typeVar."=".urlencode($this->search_type());          $str .= "&".$this->_vars["search_typeVar"]."=".urlencode($this->search_type());
1557                  if ($showall_flag) {          if ( $expandrows_flag ) {
1558                          $str .= "&".$this->_showallVar."=".urlencode($showall_value);              $str .= "&".$this->_vars["expandrowsVar"]."=".urlencode($expandrows_value);
1559                  }          }
1560    
1561          return $str;          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 stores the url for each of the tool       * This function returns the path to the
1590           * urls, so we can push these out for mozilla.       * images used in this class
1591           * Mozilla has a nice navigation bar feature that       *
1592           * lets you program first, prev, next, last links       * @return string
1593           *       */
1594           * @param string - which tool link      function set_image_path($path) {
1595           * @param string - the url for that link          return $this->_image_path = $path;
1596           */      }
         function _save_mozilla_nav_link($which, $url) {  
                 $this->_mozilla_nav_links[$which] = $url;  
         }  
   
   
         /**  
          * This function returns the path to the  
          * images used in this class  
          *  
          * @return string  
          */  
         function get_image_path() {  
                 return $this->_image_path;  
         }  
   
         /**  
          * This function returns the path to the  
          * images used in this class  
          *  
          * @return string  
          */  
         function set_image_path($path) {  
                 return $this->_image_path = $path;  
         }  
1597    
1598      /**      /**
1599       * This function returns the current       * This function returns the current
# Line 1503  class DataList extends BaseWidget { Line 1613  class DataList extends BaseWidget {
1613       * @return int       * @return int
1614       */       */
1615      function get_num_pages() {      function get_num_pages() {
1616                  $this->_check_datasource("get_num_pages");          $this->_check_datasource("get_num_pages");
1617                  $total_rows = $this->_datasource->get_total_rows();          $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());          $cnt = (int)($total_rows / $this->numrows());
1624          if ((($total_rows % $this->numrows()) != 0) || ($total_rows == 0)) {          if ( (($total_rows % $this->numrows()) != 0) || ($total_rows == 0) ) {
1625              $cnt++;              $cnt++;
1626          }          }
1627          return $cnt;          return $cnt;
# Line 1534  class DataList extends BaseWidget { Line 1648  class DataList extends BaseWidget {
1648          $cur_page = $this->get_current_page();          $cur_page = $this->get_current_page();
1649          $low_range = $this->offset() + 1;          $low_range = $this->offset() + 1;
1650          $num_pages = $this->get_num_pages();          $num_pages = $this->get_num_pages();
         $num_rows_per_page = $this->numrows();  
1651    
1652                  $this->_check_datasource("get_page_info");          $this->_check_datasource("get_page_info");
1653                  $total_rows = $this->_datasource->get_total_rows();          $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);          $high_range = $low_range + ($num_rows_per_page - 1);
1662          if ($high_range > $total_rows) {          if ( $high_range > $total_rows ) {
1663              $high_range = $total_rows;              $high_range = $total_rows;
1664          }          }
1665    
1666          if ($total_rows == 0) {          if ( $total_rows == 0 ) {
1667              $str = "0 of 0";              $str = "0 of 0";
1668          } else {          } else {
1669              $str  = $low_range . " to ". $high_range;              $str  = $low_range . " to ". $high_range;
# Line 1570  class DataList extends BaseWidget { Line 1689  class DataList extends BaseWidget {
1689    
1690          $order_value = $this->_columns[$col_name]["data_name"];          $order_value = $this->_columns[$col_name]["data_name"];
1691          $reverse_value = "false";          $reverse_value = "false";
1692          if (!$reverseorder) {          if ( !$reverseorder ) {
1693              $reverseorder = 'false';              $reverseorder = 'false';
1694          }          }
1695    
1696          if ($orderby == $order_value && $reverseorder === 'false') {          if ( $orderby == $order_value && $reverseorder === 'false' ) {
1697              $reverse_value = "true";              $reverse_value = "true";
1698          }          }
1699    
1700          if ($this->form_method == "POST") {          if ( $this->get_form_method() == "POST" ) {
1701              //we have to construct this url              //we have to construct this url
1702              //specially.              //specially.
1703              $form_name = $this->get_form_name();              $form_name = $this->get_form_name();
1704    
1705              $url = "javascript: ";              $url = "javascript: ";
1706              //set the offset correctly              //set the offset correctly
1707              $url .= "document.".$form_name.".".$this->_offsetVar.".value='".$this->offset()."';";              $url .= "document.".$form_name.".".$this->_vars["offsetVar"].".value='".$this->offset()."';";
1708              //set the orderby correctly.              //set the orderby correctly.
1709              $url .= "document.".$form_name.".".$this->_orderbyVar.".value='".$order_value."';";              $url .= "document.".$form_name.".".$this->_vars["orderbyVar"].".value='".$order_value."';";
1710              //set the reverseorder              //set the reverseorder
1711              $url .= "document.".$form_name.".".$this->_reverseorderVar.".value='".$reverse_value."';";              $url .= "document.".$form_name.".".$this->_vars["reverseorderVar"].".value='".$reverse_value."';";
1712    
1713              $url .= "document.".$form_name.".submit();";              $url .= "document.".$form_name.".submit();";
1714          } else {          } else {
1715              //handle the normal get.              //handle the normal get.
1716              $url = $this->build_base_url();              $url = $this->build_base_url();
1717              //Now add the orderby, reverseorder and offset vars              //Now add the orderby, reverseorder and offset vars
1718              $url .= $this->_offsetVar ."=0&";              $url .= $this->_vars["offsetVar"] ."=0&";
1719              //set the orderbyvar              //set the orderbyvar
1720              $url .= $this->_orderbyVar ."=".$order_value."&";              $url .= $this->_vars["orderbyVar"] ."=".$order_value."&";
1721              //set the reverseorder              //set the reverseorder
1722              $url .= $this->_reverseorderVar ."=".$reverse_value."&";              $url .= $this->_vars["reverseorderVar"] ."=".$reverse_value."&";
1723              //set the search value              //set the search value
1724              $url .= $this->_search_valueVar ."=".$search_value;              $url .= $this->_vars["search_valueVar"] ."=".$search_value;
1725          }          }
1726    
1727          return $url;          return $url;
1728      }      }
1729    
     /**  
      * This is the basic function for letting us  
      * do a mapping between the column name in  
      * the header, to the value found in the DB.  
      *  
      * NOTE: this function is meant to be overridden  
      *       so that you can push whatever you want.  
      *  
      * @param array - $row_data - the entire data for the row  
      * @param string - $col_name - the name of the column header  
      *                             for this row to render.  
      * @return  mixed - either a HTMLTag object, or raw text.  
      */  
     function build_column_item($row_data, $col_name) {  
         $key = $this->_columns[$col_name]["data_name"];  
   
         if ($row_data[$key] == '') {  
             return "&nbsp;";  
         } else {  
             return $this->filter_column_string($row_data[$key]);  
         }  
     }  
   
1730    
1731      /**      /**
1732       * This does some magic filtering on the data       * This function is used to make sure that the string we are
1733       * that we display in a column.  This helps       * placing in a cell has been "cleaned"
      * to prevent nast data that may have html  
      * tags in it.  
1734       *       *
1735       * @param string - the column data u want to filter       * @param mixed - the cell object.  It can be a string.
1736       * @return string the cleaned/filtered data       * @param string - the name of the column this object/string
1737       */       *                 will live
1738      function filter_column_string($data) {       *
1739          // WAS: return htmlspecialchars(trim($data));       * @return mixed - the cleaned string or object
1740                 */
1741          // NEW: require 'flib/Application/i18n/TextEncode.php'      function _clean_string($obj, $col_name) {
1742          //  this will do a 'htmlentities' RECURSIVE on each item          if ( is_string($obj) ) {
1743          $encoder = new TextEncode($data);              if ( $this->_columns[$col_name]["maxtextlength"] ) {
1744          $encoder->toHTML();                  //looks like we need to make sure we
1745          return $data;                  //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           * This function is used to make sure that the string we are      /********************************/
          * placing in a cell has been "cleaned"  
          *  
          * @param mixed - the cell object.  It can be a string.  
          * @param string - the name of the column this object/string  
          *                 will live  
          *  
          * @return mixed - the cleaned string or object  
          */  
         function _clean_string($obj, $col_name){  
                 if (is_string($obj)) {  
                         if ($this->_columns[$col_name]["maxtextlength"]) {  
                                 //looks like we need to make sure we  
                                 //truncate the string to a max length  
                                 if (strlen($obj) > $this->_columns[$col_name]["maxtextlength"]) {  
                                         //we need to truncate it.  
                                         $obj = substr($obj, 0, $this->_columns[$col_name]["maxtextlength"]);  
                                         $obj .= "...";  
                                 }  
                         }  
                 }  
                 return $obj;  
         }  
   
         /********************************/  
         /*      SEARCH RELATED          */  
         /********************************/  
1761    
1762      /**      /**
1763       * This method gets the array of       * This method gets the array of
# Line 1691  class DataList extends BaseWidget { Line 1768  class DataList extends BaseWidget {
1768      function _get_searchable_fields() {      function _get_searchable_fields() {
1769          $fields = array();          $fields = array();
1770          foreach($this->_columns as $name => $header) {          foreach($this->_columns as $name => $header) {
1771              if ($header["searchable"] == TRUE) {              if ( $header["searchable"] == SORTABLE ||
1772                     $header["searchable"] == SORTABLE_ICASE ||
1773                     $header["searchable"] == SORTABLE_NUMERIC) {
1774                  $fields[$name] = $header["data_name"];                  $fields[$name] = $header["data_name"];
1775              }              }
1776          }          }
# Line 1710  class DataList extends BaseWidget { Line 1789  class DataList extends BaseWidget {
1789    
1790          $modifier = $this->get_simple_search_modifier();          $modifier = $this->get_simple_search_modifier();
1791    
1792          if ($modifier & SEARCH_BEGINS_WITH) {          if ( $modifier & SEARCH_BEGINS_WITH ) {
1793              $options["beginning with"] = "BEGINS";              $options["beginning with"] = "BEGINS";
1794          }          }
1795          if ($modifier & SEARCH_CONTAINS) {          if ( $modifier & SEARCH_CONTAINS ) {
1796              $options["containing"] = "CONTAINS";              $options["containing"] = "CONTAINS";
1797          }          }
1798          if ($modifier & SEARCH_EXACT) {          if ( $modifier & SEARCH_EXACT ) {
1799              $options["matching"] = "EXACT";              $options["matching"] = "EXACT";
1800          }          }
1801          if ($modifier & SEARCH_ENDS_WITH) {          if ( $modifier & SEARCH_ENDS_WITH ) {
1802              $options["ending with"] = "ENDS";              $options["ending with"] = "ENDS";
1803          }          }
1804    
1805          $selected = $this->simple_search_modifier_value();          $selected = $this->simple_search_modifier_value();
1806          //make the default Begins with          //make the default Begins with
1807          if (!$selected) {          if ( !$selected ) {
1808              $selected = "BEGINS";              $selected = "BEGINS";
1809          }          }
1810    
1811          return form_select($this->_simple_search_modifierVar, $options, $selected);          return form_select($this->_vars["simple_search_modifierVar"], $options, $selected);
1812      }      }
1813    
1814          /**      /**
1815       * This function is used to make safe       * This function is used to make safe
1816       * any query string value that is used       * any query string value that is used
1817       *       *

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.8

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