📄 table.inc
字号:
$row = 0; reset($ary); while(list($key, $val) = each($ary)) { ## Process a single row $this->table_row($row++, $key, $val, $class); } return $row; } #========================================================================== # Function : show_table_rows_result #-------------------------------------------------------------------------- # Purpose : Walks the passed database object displaying each record as an # HTML table row. # Arguments: $db - The database object # $class - [optional] Used for CSS control. # Returns : # Comments : # History : 990617 - fixed return. Was "row" changed to "$row". #========================================================================== function show_table_rows_result($db, $class="") { global $debug; if ($debug) printf("<p>show_table_rows_result()<br>\n"); if (!$this->verify_db($db)) return 0; $row = 0; while($db->next_record()) { ## Process a table row $this->table_row($row, $row, $db->Record, $class); $row++; } return $row; } #========================================================================== # Function : show_table_page_rows #-------------------------------------------------------------------------- # Purpose : Walks the passed array displaying each row of data as an HTML # table row. However, data does not start displaying until # $start element and end after $num rows. # Arguments: $ary - The array object. # $start - Start row displaying at this element. # $num - The number of rows to display. # $class - [optional] Used for CSS control. # Returns : # Comments : # History : 990616 - $row was incrementing (++) in for loop and within # the table_row function call. #========================================================================== function show_table_page_rows($ary, $start, $num, $class="") { global $debug; if ($debug) printf("<p>show_table_page_rows()<br>\n"); if (!$this->verify_2d_array($ary)) return 0; $row = 0; $max = count($ary); if (($start < 0 ) || ($start > $max)) return 0; $max = min($start+$num, $max); for ($row = $start; $row < $max; $row++) { ## Process a single row $this->table_row($row, $key, $val, $class); } return ($row - $start); } #========================================================================== # Function : show_table_page_rows_result #-------------------------------------------------------------------------- # Purpose : Walks the passed database object displaying each record as an # HTML table row. However, data does not start displaying until # $start record and ends after $num records have been displayed. # Arguments: $db - The database object. # $start - Start row displaying at this record. # $num - The number of rows to display. # $class - [optional] Used for CSS control. # Returns : The number of rows displayed # Comments : # History : #========================================================================== function show_table_page_rows_result($db, $start, $num, $class="") { global $debug; if ($debug) printf("<p>show_table_page_rows_result()<br>\n"); if (!$this->verify_db($db)) return 0; $row = $start; $fin = $start + $num; $db->seek($start); while($db->next_record() && ($row < $fin)) { ## Process a table row $this->table_row($row, $row, $db->Record, $class); $row++; } return ($row - $start); } #========================================================================== # Function : table_row #-------------------------------------------------------------------------- # Purpose : Outputs HTML code to create a table row. Calls all of the # cell-related functions. # Arguments: $row - # $row_key - # $data - The array of data that represents cells within a row. # $class - [optional] Used for CSS control. # Returns : # Comments : # History : #========================================================================== function table_row($row, $row_key, $data, $class="") { global $debug; if ($debug) printf("<p>table_row()<br>\n"); $d = $this->select_colnames($data); $this->table_row_open($row, $d, $class); $this->set_checkbox($row, $row_key, $data, $class); $this->show_table_cells($row, $row_key, $data, $class); # call virtual function if ($this->add_extra) $this->table_row_add_extra($row, $row_key, $data, $class); $this->table_row_close($row, $class); } #========================================================================== ## Field/Cell functions #========================================================================== #========================================================================== # Function : set_checkbox_heading #-------------------------------------------------------------------------- # Purpose : This function creates an empty header cell to coincide with # the checkbox option for that column. # Arguments: $class - [optional] Used for CSS control. # Returns : # Comments : # History : #========================================================================== function set_checkbox_heading($class="") { global $debug; if ($debug) printf("<p>set_checkbox_heading()<br>\n"); ## Checkbox handling... if ($this->check) $this->table_heading_cell(0, " ", $class); } #========================================================================== # Function : set_checkbox #-------------------------------------------------------------------------- # Purpose : Creates an HTML checkbox based on the passed data, only if # the member variable $check is set. # Arguments: $row - The row number. # $row_key - The row key. # $data - The data array. # $class - [optional] Used for CSS control. # Returns : # Comments : # History : #========================================================================== function set_checkbox($row, $row_key, $data, $class="") { global $debug; if ($debug) printf("<p>set_checkbox()<br>\n"); ## Checkbox handling... if ($this->check) $this->table_checkbox_cell($row, $row_key, $data, $class); } #========================================================================== # Function : show_table_heading_cells #-------------------------------------------------------------------------- # Purpose : Walks the passed array and displays each item in an HTML table # header cell. # Arguments: $data - The data array. # $class - [optional] Used for CSS control. # Returns : 1 on success, 0 on error. # Comments : # History : 990618 - Fixed problem with filtering headers (JSG). #========================================================================== function show_table_heading_cells($data, $class="") { global $debug; if ($debug) printf("<p>show_table_heading_cells()<br>\n"); if (!$this->verify_array($data)) return 0; $cell = 0; $d = $this->select_colnames($data); ## Create regular cells reset($d); while(list($key, $val) = each($d)) { $this->table_heading_cell($col++, $val, $class); } return 1; } #========================================================================== # Function : show_table_cells #-------------------------------------------------------------------------- # Purpose : Walks the passed array and displays each item in an HTML table # cell. # Arguments: $row - The row number. # $row_key - The row key. [for derived classes] # $data - The data array. # $class - [optional] Used for CSS control. # Returns : 1 on success, 0 on error. # Comments : # History : #========================================================================== function show_table_cells($row, $row_key, $data, $class="") { global $debug; if ($debug) printf("<p>show_table_cells()<br>\n"); if (!$this->verify_array($data)) return 0; $cell = 0; $d = $this->select_colnames($data); ## Create regular cells reset($d); while(list($key, $val) = each($d)) { $this->table_cell($row, $cell++, $val, $data[$val], $class); } return 1; } #========================================================================== # Function : table_cell #-------------------------------------------------------------------------- # Purpose : Outputs HTML code to render a single cell. # Arguments: $row - The row number. [for derived classes] # $col - The column number. [for derived classes] # $key - The key value. [for derived classes] # $val - The data value. # $class - [optional] Used for CSS control. # Returns : Nothing # Comments : # History : #========================================================================== function table_cell($row, $col, $key, $val, $class="") { $this->table_cell_open($class); printf("%s", $val); $this->table_cell_close($class); } function table_cell_open($class="") { printf(" <td%s>", $class?" class=$class":""); } function table_cell_close($class="") { printf("</td>\n"); } #========================================================================== # Function : table_heading_cell #-------------------------------------------------------------------------- # Purpose : Outputs HTML code to render a single header cell. # Arguments: $col - The column number. [for derived classes] # $val - The data value. # $class - [optional] Used for CSS control. # Returns : Nothing # Comments : # History : 990620 - Added column remapping. #========================================================================== function table_heading_cell($col, $val, $class="") { $this->table_heading_cell_open($class); ## Check for column name remapping if ($this->verify_array($this->map_cols)) { reset($this->map_cols); while(list($key, $name) = each($this->map_cols))
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -