📄 datatable.class.inc
字号:
<?php/** * @copyright Intermesh 2005 * @author Merijn Schering <mschering@intermesh.nl> * @version $Revision: 1.1 $ $Date: 2006/11/22 11:02:00 $ * This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. * @package Framework * @subpackage Controls *//** * Creates a table that uses tabs to show multiple screens * * @package Framework * @subpackage Controls * * @access public */require_once($GO_CONFIG->class_path.'base/controls/table.class.inc');class datatable extends table{ var $footer; var $form_name = 'forms[0]'; var $sort_index; var $sort_ascending = true; var $sql_sort_order='ASC'; var $sort_table = array(); var $start = 0; var $offset = 0; var $total_rows = 0; var $max_links=10; var $row_count = 0; var $autosort = false; var $task =''; var $selected = array(); var $hidden_selected = array(); var $remind_selected = false; var $multiselect = true; var $enabled_columns=array(); var $allow_configuration=false; function datatable($id, $autosort=false, $form_name='0') { global $GO_CONFIG, $GO_SECURITY; $this->tagname = 'table'; $this->set_linebreak("\n"); $this->set_attribute('id', $id); $this->set_attribute('onselectstart', 'return false;'); $_SESSION[$this->attributes['id']] = (isset($_SESSION[$this->attributes['id']]) && is_array($_SESSION[$this->attributes['id']])) ? $_SESSION[$this->attributes['id']] : array(); $this->form_name = $form_name; $this->autosort = $autosort; $this->sort_index = $GO_CONFIG->get_setting('sort_index_'.$id, $GO_SECURITY->user_id); $this->sort_ascending = $GO_CONFIG->get_setting('sort_asc_'.$id, $GO_SECURITY->user_id); if(isset($_POST[$id]['sort_index']) && $_POST[$id]['sort_index'] != $this->sort_index) { $GO_CONFIG->save_setting( 'sort_index_'.$id, smart_addslashes($_POST[$id]['sort_index']), $GO_SECURITY->user_id); $this->sort_index = smart_stripslashes($_POST[$id]['sort_index']); } if(isset($_POST[$id]['sort_ascending']) && $_POST[$id]['sort_ascending'] != $this->sort_ascending) { $GO_CONFIG->save_setting( 'sort_asc_'.$id, smart_addslashes($_POST[$id]['sort_ascending']), $GO_SECURITY->user_id); $this->sort_ascending = smart_stripslashes($_POST[$id]['sort_ascending']); } $this->sql_sort_order = $this->sort_ascending ? 'ASC' : 'DESC'; $_SESSION['GO_SESSION']['max_rows_list'] = isset($_SESSION['GO_SESSION']['max_rows_list']) ? $_SESSION['GO_SESSION']['max_rows_list'] : 25; $this->offset = isset($_POST[$this->attributes['id']]['offset']) ? $_POST[$this->attributes['id']]['offset'] : $_SESSION['GO_SESSION']['max_rows_list']; if(isset($_POST[$this->attributes['id']]['start'])) { $this->start = $_SESSION[$this->attributes['id']]['start'] = $_POST[$this->attributes['id']]['start']; }else { $this->start = isset($_SESSION[$this->attributes['id']]['start']) ? $_SESSION[$this->attributes['id']]['start'] : 0; } $this->task = isset($_POST[$this->attributes['id']]['task']) ? $_POST[$this->attributes['id']]['task'] : ''; $this->selected = isset($_POST[$this->attributes['id']]['selected']) ? array_map('smart_stripslashes',$_POST[$this->attributes['id']]['selected']) : array(); } function allow_configuration() { $this->allow_configuration=true; global $GO_CONFIG; $this->enabled_columns = $GO_CONFIG->get_setting('enabled_columns_'.$this->attributes['id']); if(!$this->enabled_columns) { $this->enabled_columns = array(0,1,2,3,4,5,6); }else { $this->enabled_columns = explode(',', $this->enabled_columns); } } function enable_select() { $this->set_attribute('style','-moz-user-select:text'); $this->set_attribute('onselectstart',''); } function is_sort_index($sort_index=null) { if(!isset($sort_index)) { $sort_index=$this->sort_index; } foreach($this->headings as $heading) { if($heading->sort_name==$this->sort_index) { return true; } } return false; } function get_header() { global $GO_CONFIG; return '<script type="text/javascript" src="'.$GO_CONFIG->host.'javascript/datatable.js"></script>'; } function set_remind_selected($remind_selected) { $this->remind_selected = $remind_selected; } function set_multiselect($multiselect) { $this->multiselect=$multiselect; } function set_pagination($total_rows) { $this->total_rows = $total_rows; if($this->start>$this->total_rows) { $this->start=0; } } function add_column($heading) { if(empty($this->sort_index)) { if($this->autosort) { $this->sort_index = 0; }else { if(!empty($heading->sort_name)) { $this->sort_index = $heading->sort_name; } } } $this->headings[] = $heading; } function unshift_column($heading) { if(empty($this->sort_index)) { if($this->autosort) { $this->sort_index = 0; }else { if(!empty($heading->sort_name)) { $this->sort_index = $heading->sort_name; } } } array_unshift($this->headings, $heading); } function add_footer($row) { $row->ignore_configuration=true; $this->footer = $row; } function add_row($row) { $row->table= &$this; if($this->hover_effect) { $row->set_attribute('onmouseover','javascript:table_glow_row(this);'); $row->set_attribute('onmouseout','javascript:table_unglow_row(this);'); } $this->rows[] = $row; if($this->autosort) { $this->sort_table[] = $row->cells[$this->sort_index]->sort_name; } } function sort($sort_index, $sort_ascending =true) { $this->sort_index = $sort_index; $this->sort_ascending = $sort_ascending ; } function get_count_selected_handler() { return "table_count_selected('".$this->form_name."','".$this->attributes['id']."');"; } function get_unlink_handler() { return "javascript:table_confirm_unlink('".$this->form_name."','".$this->attributes['id']."', '". htmlspecialchars(addslashes($GLOBALS['strNoItemSelected']))."', '". htmlspecialchars(addslashes($GLOBALS['strSelectedItem']))."', '". htmlspecialchars(addslashes($GLOBALS['strSelectedItems']))."', '". htmlspecialchars(addslashes($GLOBALS['strUnlinkPrefix']))."', '". htmlspecialchars(addslashes($GLOBALS['strUnlinkSuffix']))."');"; } function get_delete_handler($row_id=0, $confirm_delete=true) { if ($row_id > 0) { $str = "javascript:table_select_single('".$this->form_name."','".$this->attributes['id']."', '".$row_id."');"; }else { $str = "javascript:"; } if($confirm_delete) { $str .= "table_confirm_delete('".$this->form_name."','".$this->attributes['id']."', '". htmlspecialchars(addslashes($GLOBALS['strNoItemSelected']))."', '". htmlspecialchars(addslashes($GLOBALS['strSelectedItem']))."', '". htmlspecialchars(addslashes($GLOBALS['strSelectedItems']))."', '". htmlspecialchars(addslashes($GLOBALS['strDeletePrefix']))."', '". htmlspecialchars(addslashes($GLOBALS['strDeleteSuffix']))."');"; }else { $str .= "table_delete('".$this->form_name."','".$this->attributes['id']."');"; } return $str; } function set_page_one() { return 'document.forms[\''.$this->form_name.'\'].elements[\''.$this->attributes['id'].'[start]\'].value=0;'; } function get_task_var()
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -