/[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.7 by jonen, Wed Feb 26 21:39:35 2003 UTC revision 1.8 by jonen, Thu May 6 16:27:46 2004 UTC
# Line 8  Line 8 
8   */   */
9    
10  /**  /**
11   * Some global defines used   * Some global defines used
12   */   */
13  define("SORTABLE", TRUE);  define("NOT_SORTABLE", 0);
14  define("NOT_SORTABLE", FALSE);  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 30  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 50  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 65  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 92  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 130  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 154  class DataList extends BaseWidget { Line 166  class DataList extends BaseWidget {
166                         "orderbyVar" => "orderby",                         "orderbyVar" => "orderby",
167                         "reverseorderVar" => "reverseorder",                         "reverseorderVar" => "reverseorder",
168                         "numrowsVar" => "numrows",                         "numrowsVar" => "numrows",
169                         "showallVar" => "showall",                         "expandrowsVar" => "expandrows",
170                         "search_fieldVar" => "search_field",                         "search_fieldVar" => "search_field",
171                         "search_valueVar" => "search_value",                         "search_valueVar" => "search_value",
172                         "search_typeVar" => "search_type",                         "search_typeVar" => "search_type",
# Line 211  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();
# Line 232  class DataList extends BaseWidget { Line 244  class DataList extends BaseWidget {
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?
# Line 263  class DataList extends BaseWidget { Line 275  class DataList extends BaseWidget {
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      /**      /**
# Line 274  class DataList extends BaseWidget { Line 286  class DataList extends BaseWidget {
286       * @param string - the column to use as the default sorting order       * @param string - the column to use as the default sorting order
287       * @param boolean - sort the default column in reverse order?       * @param boolean - sort the default column in reverse order?
288       */       */
289      function DataList($title, $width = "100%", $default_orderby='',      function DataList($title, $width = "100%", $default_orderby='',
290                        $default_reverseorder=FALSE) {                        $default_reverseorder=FALSE) {
291          $this->set_title( $title );          $this->set_title( $title );
292          $this->set_form_name( str_replace(' ', '_', strtolower($title)) );  
293            if ($title != NULL && $title != "") $this->set_form_name( str_replace(' ', '_', strtolower($title)) );
294    
295          $this->set_width( $width );          $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;
# Line 295  class DataList extends BaseWidget { Line 309  class DataList extends BaseWidget {
309          //item lists per html page.          //item lists per html page.
310          $this->set_global_prefix('');          $this->set_global_prefix('');
311    
312            //allow someone to do some generic
313            //action before we get the data source
314            //and start processing rows.
315            $this->do_action();
316    
317          //child class MUST override this          //child class MUST override this
318          //method to automatically set          //method to automatically set
319          //the DataListSource object.          //the DataListSource object.
# Line 309  class DataList extends BaseWidget { Line 328  class DataList extends BaseWidget {
328      }      }
329    
330      /**      /**
331       * This function renders the final       * This function renders the final
332       * widget       * widget
333       *       *
334       */       */
# Line 355  class DataList extends BaseWidget { Line 374  class DataList extends BaseWidget {
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                
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          //add the hidden vars if we are a POST
386          if ($this->get_form_method() == "POST") {          if ($this->get_form_method() == "POST") {
387              $form->add( $this->_build_default_vars() );              $form->add( $this->_build_default_vars() );
# Line 379  class DataList extends BaseWidget { Line 398  class DataList extends BaseWidget {
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
# Line 388  class DataList extends BaseWidget { Line 407  class DataList extends BaseWidget {
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() {
# Line 408  class DataList extends BaseWidget { Line 427  class DataList extends BaseWidget {
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;
438                          $obj = $this->_clean_string($obj, $col_name);                      }
439                        $cnt = 1;
440                        foreach( $this->_columns as $col_name => $data ) {
441                            $obj = $this->build_column_item($row, $col_name);
442                            if ( !is_object($obj) ) {
443                                $obj = $this->_clean_string($obj, $col_name);
444                            }
445    
446                            $this->child_add_row_cell($obj, $col_name,
447                                                      (($cnt == $column_count) ? TRUE : FALSE),
448                                                      $row);
449                            $cnt++;
450                      }                      }
                     //  
                     $this->child_add_row_cell($obj, $col_name,  
                                               (($cnt == $col_count) ? TRUE : FALSE),  
                                               $row);  
                     $cnt++;  
451                  }                  }
452              }              }
453              $container->add( $this->child_get_gui() );              $container->add( $this->child_get_gui() );
# Line 432  class DataList extends BaseWidget { Line 457  class DataList extends BaseWidget {
457          return $container;          return $container;
458      }      }
459    
460    
461        /**
462         * This method is called prior to get_data_source
463         * and user_setup() to allow you to do some generic
464         * action on data.  By default this does nothing.
465         *
466         */
467        function do_action() {
468            return null;
469        }
470    
471      /**      /**
472       * This function is called automatically by       * This function is called automatically by
473       * the DataList constructor.  It must be       * the DataList constructor.  It must be
474       * extended by the child class to actually       * extended by the child class to actually
475       * set the DataListSource object.       * set the DataListSource object.
476       *       *
477       *       *
478       */       */
479      function get_data_source() {      function get_data_source() {
480          user_error("DataList::get_data_source() - ".          user_error("DataList::get_data_source() - ".
# Line 477  class DataList extends BaseWidget { Line 513  class DataList extends BaseWidget {
513    
514      /**      /**
515       * This method is supposed to be written by       * This method is supposed to be written by
516       * the child class to build and add the column       * the child class to build and add the column
517       * title to the UI       * title to the UI
518       *       *
519       * @param string - the title of the column       * @param string - the title of the column
520       * @param array - the column data ( from $this->_columns )       * @param array - the column data ( from $this->_columns )
521       * @param int - the column #       * @param int - the column #
# Line 496  class DataList extends BaseWidget { Line 532  class DataList extends BaseWidget {
532       * This method is supposed to be written by       * This method is supposed to be written by
533       * the child class to add the cell data to the       * the child class to add the cell data to the
534       * current row in the UI       * current row in the UI
535       *       *
536       * @param mixed - the object/string/entity that       * @param mixed - the object/string/entity that
537       *                should get put into the column row cell.       *                should get put into the column row cell.
538       * @param string - the name/title of the column that the       * @param string - the name/title of the column that the
# Line 513  class DataList extends BaseWidget { Line 549  class DataList extends BaseWidget {
549      }      }
550    
551      /**      /**
552       * This function is called after all of the data has       * This function is called after all of the data has
553       * been added to the UI object.  It just returns the       * been added to the UI object.  It just returns the
554       * container that is the entire UI for the DataList       * container that is the entire UI for the DataList
555       *       *
556       * @return Container       * @return Container
# Line 562  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 577  class DataList extends BaseWidget { Line 614  class DataList extends BaseWidget {
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    
621          $this->_check_datasource("add_header_item");          $this->_check_datasource("add_header_item");
622          $this->_datasource->add_column($label, $data_name, $sortable,          $this->_datasource->add_column($label, $data_name, $sortable,
# Line 613  class DataList extends BaseWidget { Line 651  class DataList extends BaseWidget {
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
# Line 699  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 735  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 749  class DataList extends BaseWidget { Line 787  class DataList extends BaseWidget {
787      }      }
788    
789      /**      /**
790       * This returns the Maximum # of rows to       * This returns the Maximum # of rows to
791       * display when in expand mode       * display when in expand mode
792       *       *
793       * @return int       * @return int
# Line 771  class DataList extends BaseWidget { Line 809  class DataList extends BaseWidget {
809      }      }
810    
811    
812        /**
813         * This method sets the flag to tell us
814         * to show every row found in the DataListSource.
815         *
816         * @param boolean TRUE = show all rows
817         */
818        function set_showall($flag=TRUE) {
819            $this->_show_all_rows = $flag;
820        }
821    
822        /**
823         * This returns the value of the show all rows
824         * flag
825         *
826         * @return boolean
827         */
828        function get_showall() {
829            return $this->_show_all_rows;
830        }
831    
832    
833    
834      /**      /**
835       * This function is used to set up any       * This function is used to set up any
# Line 781  class DataList extends BaseWidget { Line 840  class DataList extends BaseWidget {
840      function data_prefetch() {      function data_prefetch() {
841          $this->_check_datasource("data_prefetch");          $this->_check_datasource("data_prefetch");
842    
843          if ( $this->showall() ) {          if ( $this->expandrows() ) {            
844              $this->set_default_num_rows( $this->get_max_rows() );              if ($this->get_showall()) {
845              $this->set_numrows( $this->get_max_rows() );                  $limit = -1;
846                } else {
847                    $this->set_default_num_rows( $this->get_max_rows() );
848                    $this->set_numrows( $this->get_max_rows() );
849                    $limit = $this->numrows();
850                }            
851            } else {
852                $limit = $this->numrows();
853          }          }
854    
855          $limit = $this->numrows();          $this->_query_worked = $this->_datasource->query($this->offset(), $limit,
856          $this->_datasource->query($this->offset(), $limit,                                                           $this->orderby(), $this->reverseorder(),
857                                    $this->orderby(), $this->reverseorder(),                                                           $this->search_field(), $this->search_value(),
858                                    $this->search_field(), $this->search_value(),                                                           $this->simple_search_modifier_value(),
859                                    $this->simple_search_modifier_value(),                                                           $this->search_type() );
                                   $this->search_type() );  
860      }      }
861    
862    
# Line 844  class DataList extends BaseWidget { Line 909  class DataList extends BaseWidget {
909       * @return the current value or default if not set       * @return the current value or default if not set
910       */       */
911      function _get($name, $default_value=NULL) {      function _get($name, $default_value=NULL) {
912          if ( !$_REQUEST[$this->_vars[$name]] ) {          if ( !isset($_REQUEST[$this->_vars[$name]]) ) {
913              $this->_set($name, $default_value);              $this->_set($name, $default_value);
914          }          }
915          //ddd( $name . " : ". $_REQUEST[$this->_vars[$name]] );          
916          return $_REQUEST[$this->_vars[$name]];          return $_REQUEST[$this->_vars[$name]];
917      }      }
918    
919      /**      /**
920       * This function is used to set the       * This function is used to set the
921       * value of the control var       * value of the control var
922       *       *
923       * @param string - the name we want to get       * @param string - the name we want to get
# Line 870  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          return(int)$this->_get("offsetVar", 0);          if ($this->get_showall() && $this->expandrows()) {
939                return 0;
940            } else {
941                return(int)$this->_get("offsetVar", 0);
942            }        
943      }      }
944    
945      /**      /**
# Line 1029  class DataList extends BaseWidget { Line 1098  class DataList extends BaseWidget {
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          return(int)$this->_get("showallVar", 0);          if ($this->get_showall()) {
1109                $default = 1;
1110            } else {
1111                $default = 0;
1112            }
1113            return(int)$this->_get("expandrowsVar", $default);
1114        }
1115    
1116        /**
1117         * This sets the expandrows.
1118         *
1119         * @param boolean
1120         */
1121        function set_expandrows($flag=TRUE) {
1122            $flag = ($flag ? 1:0);
1123            $this->_set("expandrowsVar", $flag);
1124      }      }
1125    
1126      /**      /**
# Line 1055  class DataList extends BaseWidget { Line 1139  class DataList extends BaseWidget {
1139      function build_column_item($row_data, $col_name) {      function build_column_item($row_data, $col_name) {
1140          $key = $this->_columns[$col_name]["data_name"];          $key = $this->_columns[$col_name]["data_name"];
1141    
1142          if ( $row_data[$key] == '' ) {          if (!isset($row_data[$key]) || ($row_data[$key] == '' && $row_data[$key] !== 0)) {
1143              return "&nbsp;";              return "&nbsp;";
1144          } else {          } else {
1145              return $this->_filter_column_string($row_data[$key]);              return $this->_filter_column_string($row_data[$key]);
# Line 1082  class DataList extends BaseWidget { Line 1166  class DataList extends BaseWidget {
1166          return $data;              return $data;    
1167      }      }
1168    
   
1169      /*******************************************/      /*******************************************/
1170      /*         FORM VARIABLES SECTION          */      /*         FORM VARIABLES SECTION          */
1171      /*******************************************/      /*******************************************/
# Line 1134  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;
# Line 1214  class DataList extends BaseWidget { Line 1297  class DataList extends BaseWidget {
1297      /**      /**
1298       * This function is used to let render() know       * This function is used to let render() know
1299       * that we should show the results or not.       * that we should show the results or not.
1300       *       *
1301       * @return boolean       * @return boolean
1302       */       */
1303      function _show_results() {      function _show_results() {
# Line 1225  class DataList extends BaseWidget { Line 1308  class DataList extends BaseWidget {
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       * This method returns a list of       * This method returns a list of
1313       * hidden form fields if we are a POST.       * hidden form fields if we are a POST.
1314       * It returns a portion of a query string       * It returns a portion of a query string
1315       * If we are a GET.       * If we are a GET.
# Line 1254  class DataList extends BaseWidget { Line 1337  class DataList extends BaseWidget {
1337      }      }
1338    
1339      /**      /**
1340       * This function builds the list of       * This function builds the list of
1341       * default hidden form vars for when       * default hidden form vars for when
1342       * the datalist is being rendered       * the datalist is being rendered
1343       * as a POST       * as a POST
# Line 1266  class DataList extends BaseWidget { Line 1349  class DataList extends BaseWidget {
1349          $container = container(form_hidden($this->_vars["offsetVar"], $this->offset()),          $container = container(form_hidden($this->_vars["offsetVar"], $this->offset()),
1350                                 form_hidden($this->_vars["orderbyVar"], $this->orderby()),                                 form_hidden($this->_vars["orderbyVar"], $this->orderby()),
1351                                 form_hidden($this->_vars["reverseorderVar"], $this->reverseorder()),                                 form_hidden($this->_vars["reverseorderVar"], $this->reverseorder()),
1352                                 form_hidden($this->_vars["showallVar"], $this->showall()));                                 form_hidden($this->_vars["expandrowsVar"], $this->expandrows()));
1353          return $container;          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
# Line 1318  class DataList extends BaseWidget { Line 1399  class DataList extends BaseWidget {
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
# Line 1335  class DataList extends BaseWidget { Line 1416  class DataList extends BaseWidget {
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",
# Line 1352  class DataList extends BaseWidget { Line 1433  class DataList extends BaseWidget {
1433              $rows_string = "Previous ".$this->get_default_num_rows()." Rows";              $rows_string = "Previous ".$this->get_default_num_rows()." Rows";
1434              if ( $this->offset() <= 0 ) {              if ( $this->offset() <= 0 ) {
1435                  $obj = html_img($image_path."/prev_group_button_inactive.gif",                  $obj = html_img($image_path."/prev_group_button_inactive.gif",
1436                                  '','',0,$rows_string, NULL, $rows_string);                                  '','',0,$rows_string, NULL, $rows_string . ": Disabled Link");
1437              } else {              } else {
1438                  $offset = $this->offset() - $this->numrows();                  $offset = $this->offset() - $this->numrows();
1439                  if ( $offset < 0 ) {                  if ( $offset < 0 ) {
# Line 1368  class DataList extends BaseWidget { Line 1449  class DataList extends BaseWidget {
1449              $rows_string = "Next ".$this->get_default_num_rows()." Rows";              $rows_string = "Next ".$this->get_default_num_rows()." Rows";
1450              if ( ($num_pages == 1) || ($cur_page == $last_page) ) {              if ( ($num_pages == 1) || ($cur_page == $last_page) ) {
1451                  $obj = html_img($image_path."/next_group_button_inactive.gif",                  $obj = html_img($image_path."/next_group_button_inactive.gif",
1452                                  '','',0, $rows_string, NULL, $rows_string);                                  '','',0, $rows_string, NULL, $rows_string . ": Disabled Link");
1453              } else {              } else {
1454                  $offset = $this->offset() + $this->numrows();                  $offset = $this->offset() + $this->numrows();
1455                  $url = $this->_build_tool_url($offset);                  $url = $this->_build_tool_url($offset);
# Line 1381  class DataList extends BaseWidget { Line 1462  class DataList extends BaseWidget {
1462              $rows_string = "Last ".$this->get_default_num_rows()." Rows";              $rows_string = "Last ".$this->get_default_num_rows()." Rows";
1463              if ( ($num_pages == 1) || ($cur_page == $last_page) ) {              if ( ($num_pages == 1) || ($cur_page == $last_page) ) {
1464                  $obj = html_img($image_path."/last_group_button_inactive.gif",                  $obj = html_img($image_path."/last_group_button_inactive.gif",
1465                                  '','',0, $rows_string, NULL, $rows_string);                                  '','',0, $rows_string, NULL, $rows_string . ": Disabled Link");
1466              } else {              } else {
1467                  $offset = (int)(($num_pages - 1) * $this->numrows());                  $offset = (int)(($num_pages - 1) * $this->numrows());
1468                  $url = $this->_build_tool_url($offset);                  $url = $this->_build_tool_url($offset);
# Line 1390  class DataList extends BaseWidget { Line 1471  class DataList extends BaseWidget {
1471              }              }
1472              break;              break;
1473    
1474          case "all":          case "expand":
1475              $offset = $this->offset();              $offset = $this->offset();
1476              if ( $this->showall() ) {              if ( $this->expandrows() ) {
1477                  $url = $this->_build_tool_url($offset, TRUE, 0);                  $url = $this->_build_tool_url($offset, TRUE, 0);
1478                  $obj = html_img_href($url, $image_path."/close_group_button.gif",                  $obj = html_img_href($url, $image_path."/close_group_button.gif",
1479                                       '','',0,"Collapse Rows", NULL, NULL, "Collapse Rows");                                       '','',0,"Collapse Rows", NULL, NULL, "Collapse Rows");
1480              } else {              } else {
1481                  if ( ($num_pages == 1) ) {                  if ( ($num_pages == 1) ) {
1482                      $obj = html_img($image_path."/expand_group_button_inactive.gif",                      $obj = html_img($image_path."/expand_group_button_inactive.gif",
1483                                      '','',0, "Expand Rows", NULL, "Expand Rows");                                      '','',0, "Expand Rows", NULL, "Expand Rows" . ": Disabled Link");
1484                  } else {                  } else {
1485                      $url = $this->_build_tool_url($offset, TRUE, 1);                      $url = $this->_build_tool_url($offset, TRUE, 1);
1486                      $obj = html_img_href($url, $image_path."/expand_group_button.gif",                      $obj = html_img_href($url, $image_path."/expand_group_button.gif",
# Line 1411  class DataList extends BaseWidget { Line 1492  class DataList extends BaseWidget {
1492              break;              break;
1493          }          }
1494    
1495          if ( $url ) {          if ( !empty($url) ) {
1496              $this->_save_mozilla_nav_link($which, $url);              $this->_save_mozilla_nav_link($which, $url);
1497          }          }
1498    
# Line 1420  class DataList extends BaseWidget { Line 1501  class DataList extends BaseWidget {
1501    
1502      /**      /**
1503       * This function is used to build the url       * This function is used to build the url
1504       * for a tool link.         * for a tool link.
1505       * (first, prev, next, last, all)       * (first, prev, next, last, all)
1506       *       *
1507       * @param int - the offset for the link       * @param int - the offset for the link
1508       * @param boolean - add the showall value to the url       * @param boolean - add the expandrows value to the url
1509       * @param int - the showall value to use if the flag is on       * @param int - the expandrows value to use if the flag is on
1510       *       *
1511       * @return string       * @return string
1512       */       */
1513      function _build_tool_url($offset, $showall_flag=FALSE, $showall_value=0) {      function _build_tool_url($offset, $expandrows_flag=FALSE, $expandrows_value=0) {
1514          if ( $this->get_form_method() == "POST" ) {          if ( $this->get_form_method() == "POST" ) {
1515              $form_name = $this->get_form_name();              $form_name = $this->get_form_name();
1516              $url = "javascript: document.".$form_name;              $url = "javascript: document.".$form_name;
1517              $url .= ".".$this->_vars["offsetVar"].".value='".$offset."';";              $url .= ".".$this->_vars["offsetVar"].".value='".$offset."';";
1518    
1519              //add the showall variable to the post              //add the expandrows variable to the post
1520              if ( $showall_flag ) {              if ( $expandrows_flag ) {
1521                  $form_field = $this->_vars["showallVar"];                  $form_field = $this->_vars["expandrowsVar"];
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      }      }
# Line 1457  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->_vars["offsetVar"]."=".urlencode($offset);          $str .= $this->_vars["offsetVar"]."=".urlencode($offset);
# Line 1470  class DataList extends BaseWidget { Line 1554  class DataList extends BaseWidget {
1554          $str .= "&".$this->_vars["search_valueVar"]."=".urlencode($this->search_value());          $str .= "&".$this->_vars["search_valueVar"]."=".urlencode($this->search_value());
1555          $str .= "&".$this->_vars["simple_search_modifierVar"]."=".urlencode($this->simple_search_modifier_value());          $str .= "&".$this->_vars["simple_search_modifierVar"]."=".urlencode($this->simple_search_modifier_value());
1556          $str .= "&".$this->_vars["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->_vars["showallVar"]."=".urlencode($showall_value);              $str .= "&".$this->_vars["expandrowsVar"]."=".urlencode($expandrows_value);
1559          }          }
1560    
1561          return htmlentities($str);          return htmlentities($str);
# Line 1532  class DataList extends BaseWidget { Line 1616  class DataList extends BaseWidget {
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++;
# Line 1560  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;
# Line 1640  class DataList extends BaseWidget { Line 1733  class DataList extends BaseWidget {
1733       * placing in a cell has been "cleaned"       * placing in a cell has been "cleaned"
1734       *       *
1735       * @param mixed - the cell object.  It can be a string.       * @param mixed - the cell object.  It can be a string.
1736       * @param string - the name of the column this object/string       * @param string - the name of the column this object/string
1737       *                 will live       *                 will live
1738       *       *
1739       * @return mixed - the cleaned string or object       * @return mixed - the cleaned string or object
# Line 1651  class DataList extends BaseWidget { Line 1744  class DataList extends BaseWidget {
1744                  //looks like we need to make sure we                  //looks like we need to make sure we
1745                  //truncate the string to a max length                  //truncate the string to a max length
1746                  if ( strlen($obj) > $this->_columns[$col_name]["maxtextlength"] ) {                  if ( strlen($obj) > $this->_columns[$col_name]["maxtextlength"] ) {
1747                      //we need to truncate it.                      //we need to truncate it and
1748                      $obj = substr($obj, 0, $this->_columns[$col_name]["maxtextlength"]);                      //add a hover title attribute for the full
1749                      $obj .= "...";                      //object
1750                        $obj = new SPANtag(array("title"=>$obj),
1751                                           substr($obj, 0, $this->_columns[$col_name]["maxtextlength"]) . "...");
1752                  }                  }
1753              }              }
1754          }          }
# Line 1673  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          }          }

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

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