From 0cd676d726c6ca0e174ca88f398497b3fe7147ad Mon Sep 17 00:00:00 2001 From: hyzboy Date: Wed, 31 Aug 2016 15:26:29 +0400 Subject: [PATCH] =?UTF-8?q?=E5=88=9D=E6=AD=A5=E6=B5=8B=E8=AF=95=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E8=A1=A8=E6=A0=BC=E6=88=90=E5=8A=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- phptools.php | 5 +- ui_table.php | 260 ++++++++++++++++++++------------------------------- 2 files changed, 105 insertions(+), 160 deletions(-) diff --git a/phptools.php b/phptools.php index a74eecc..8ba70a7 100644 --- a/phptools.php +++ b/phptools.php @@ -12,6 +12,7 @@ require_once 'form/form_button.php'; require_once 'form/form.php'; - require_once "ui_tab.php"; - require_once 'ui_sidebar.php'; +// require_once "ui_tab.php"; +// require_once 'ui_sidebar.php'; require_once "ui_navbar.php"; + require_once 'ui_table.php'; diff --git a/ui_table.php b/ui_table.php index c2ad792..7dc86b4 100644 --- a/ui_table.php +++ b/ui_table.php @@ -4,193 +4,137 @@ class UITable { - private $title=""; - protected $columns=null; - protected $columns_label=array(); //即使用label来显示列头 + private $heading=null; + private $heading_style="default"; + private $body=null; + private $fields=null; - private $row_out=0; - private $col_out=0; - - public function __construct1($name) + public function set_heading($h) { - $this->title=$name; + $this->heading=$h; } - public function __construct2($name,$field_list) + public function set_heading_style($hs) { - $this->title=$name; - $this->columns=$field_list; + $this->heading_style=$hs; } - public function set_cols($name) + public function set_body_text($bt) { - $this->columns=$name; + $this->body=$bt; } - public function add_col($name,$label=null) + public function set_fields($f) { - if($this->columns==null) - $this->columns=array(); - - if(is_array($name)) - { - for($i=0;$icolumns[]=$name[$i]; - } - else - { - $this->columns[]=$name; //增加$name到columns数组中去,不需要返回值的情况下比array_push快(PHP.net官网说的) - - if($label!=null) - $this->columns_label[$name]=$label; - } - } - - public function set_col_label($name,$label) - { - if($name!=null&&$label!=null) - $this->columns_label[$name]=$label; - } - - public function echo() - { - echo '
'; - } - - private function echo_col($index) - { - $name=$this->columns[$index]; - - if(array_key_exists($name,$this->columns_label)) - echo '{ key: "'.$name.'", label: "'.$this->columns_label[$name].'"}'; - else - echo $name; + $this->fields=$f; } public function start() { - echo ""; + echo ' + '; } };//class UITable - class UISQLTable extends UITable - { - private $sql_result=null; - private $bool_text=array(); - - public function __construct($label,$sql_table_name,$field_list,$where) - { - parent::__construct2($label,$field_list); - - if($field_list==null) - { - $field_list=get_field_list($sql_table_name); - - $this->set_cols($field_list); - - $this->sql_result=select_table($sql_table_name,null,$where,0,0); - } - else - { - $this->set_cols($field_list); - - $this->sql_result=select_table($sql_table_name,$field_list,$where,0,0); - } - } - - public function SetBoolText($field,$true_text,$false_text) - { - $this->bool_text[$field]=array($false_text,$true_text); - } - - public function get_sql_result() - { - return $this->sql_result; - } - - public function echo() - { - parent::echo(); - - $this->start(); - - for($r=0;$rsql_result);$r++) - { - $row=$this->sql_result[$r]; - - $this->start_row(); - for($c=0;$ccolumns[$c],$this->bool_text)) - { - $this->out_col($this->bool_text[$this->columns[$c]][$row[$c]]); - } - else - { - $this->out_col($row[$c]); - } - } - } - - $this->end(); - } - };//class UISQLTable +// class UISQLTable extends UITable +// { +// private $sql_result=null; +// private $bool_text=array(); +// +// public function __construct($label,$sql_table_name,$field_list,$where) +// { +// parent::__construct2($label,$field_list); +// +// if($field_list==null) +// { +// $field_list=get_field_list($sql_table_name); +// +// $this->set_cols($field_list); +// +// $this->sql_result=select_table($sql_table_name,null,$where,0,0); +// } +// else +// { +// $this->set_cols($field_list); +// +// $this->sql_result=select_table($sql_table_name,$field_list,$where,0,0); +// } +// } +// +// public function SetBoolText($field,$true_text,$false_text) +// { +// $this->bool_text[$field]=array($false_text,$true_text); +// } +// +// public function get_sql_result() +// { +// return $this->sql_result; +// } +// +// public function echo() +// { +// parent::echo(); +// +// $this->start(); +// +// for($r=0;$rsql_result);$r++) +// { +// $row=$this->sql_result[$r]; +// +// $this->start_row(); +// for($c=0;$ccolumns[$c],$this->bool_text)) +// { +// $this->out_col($this->bool_text[$this->columns[$c]][$row[$c]]); +// } +// else +// { +// $this->out_col($row[$c]); +// } +// } +// } +// +// $this->end(); +// } +// };//class UISQLTable ?>