From: Nicolas Boisselier Date: Wed, 20 Apr 2016 16:32:21 +0000 (+0100) Subject: wp table X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=4f24b549a4e3efd2702143fb9d8f408817059fe9;p=nb.git wp table --- diff --git a/lib/php/db/field.php b/lib/php/db/field.php index b422f938..97d3364c 100644 --- a/lib/php/db/field.php +++ b/lib/php/db/field.php @@ -8,7 +8,7 @@ $DB_FIELD_TYPES = array( 'blob' => PDO::PARAM_LOB, ); */ -class field { +class field extends nb { private $table; public $name; public $type; diff --git a/lib/php/db/table.php b/lib/php/db/table.php index 0d55567f..721e9449 100644 --- a/lib/php/db/table.php +++ b/lib/php/db/table.php @@ -2,6 +2,7 @@ require_once(realpath(dirname(__FILE__).'/../db.php')); require_once(realpath(dirname(__FILE__).'/../db/field.php')); require_once(realpath(dirname(__FILE__).'/../out.php')); +if (class_exists('WP_List_Table')) require_once(realpath(dirname(__FILE__).'/wp.php')); #$a = array('a','b','c'); $b = array('c','a'); debug(array_diff($a,$b)); define('TABLE_INDENT',NB_EOL ? "\t" : ""); @@ -583,6 +584,8 @@ Class Table extends nb { ******************************************************************/ public function rows_sql(&$opt=array()) { if (isset($this->orderby)) self::pdef('orderby',$this->orderby); + if (self::p('order')) self::pset('orderby',self::p('orderby').' '.self::p('order')); # from Wordpress + // // Select // @@ -663,7 +666,7 @@ Class Table extends nb { # Use the module out when format unknow $out_conf = null; if ($this->p('out') or !preg_match('/^('.join('|', - array( 'table','sql','div','_csv','_xml','_json','_yaml' ) # local + array( 'table','sql','div','wp','_csv','_xml','_json','_yaml' ) # local ).')$/',$format)) { @@ -827,6 +830,24 @@ Class Table extends nb { return $count; } + /*----------------------------------------------------------------- + Wordpress + -----------------------------------------------------------------*/ + public function rows_begin_wp() { + $this->_html_table = new html_table($this); + + return ''; + } + public function rows_rec_wp(&$row) { + $this->_html_table->items[] = $row; + return ''; + } + public function rows_end_wp() { + $this->_html_table->display(); + unset($this->_html_table); + return ''; + } + /*----------------------------------------------------------------- Sql -----------------------------------------------------------------*/ diff --git a/lib/php/nb.php b/lib/php/nb.php index d2820ad8..bc0171e0 100644 --- a/lib/php/nb.php +++ b/lib/php/nb.php @@ -48,7 +48,7 @@ class NB { #foreach (get_object_vars($this) as $k=>$v) { echo ("$k: $v\n"); } #if (is_object($this)) #foreach (get_object_vars($this) as $k=>$v) { unset($this->$k); }; - foreach (array_keys((array)$this) as $k) { unset($this->$k); }; + foreach (array_keys((array)$this) as $k) { if (isset($this->$k)) unset($this->$k); }; } /*