From bb4e3c32b934a0cfe663fdc5c010d5c14265149b Mon Sep 17 00:00:00 2001 From: Nicolas Boisselier Date: Thu, 9 Jul 2015 16:35:32 +0100 Subject: [PATCH] css,nav --- lib/css/db.css | 6 ++- lib/php/db.php | 1 - lib/php/db/table.php | 116 +++++++++++++++++++++++++------------------ 3 files changed, 74 insertions(+), 49 deletions(-) diff --git a/lib/css/db.css b/lib/css/db.css index 85f359f8..814be6d8 100644 --- a/lib/css/db.css +++ b/lib/css/db.css @@ -1,7 +1,11 @@ +/* + All +.rows { margin: 0 auto; } +*/ + /* Edit */ -.rows { margin: 0 auto; } form.Zdb.edit ,form.db.edit label ,form.db.edit input diff --git a/lib/php/db.php b/lib/php/db.php index e28405cf..1f354230 100644 --- a/lib/php/db.php +++ b/lib/php/db.php @@ -197,7 +197,6 @@ EOF; $r .= ''.PHP_EOL; $r .= ''.PHP_EOL; - $r .= '
'.PHP_EOL; return $r; diff --git a/lib/php/db/table.php b/lib/php/db/table.php index a7527fa8..aa19e14f 100644 --- a/lib/php/db/table.php +++ b/lib/php/db/table.php @@ -1,6 +1,7 @@ '.PHP_EOL); class table { public $name; @@ -249,6 +250,7 @@ FROM pg_catalog.pg_attribute a WHERE a.attrelid = (SELECT c.oid FROM pg_catalog. function nav($count,$tot,$limit) { + $html = ''; if ($count<$tot) { list($x,$y) = strpos($limit,',')!==false ? preg_split('/\s*,\s*/',$limit) @@ -266,24 +268,26 @@ FROM pg_catalog.pg_attribute a WHERE a.attrelid = (SELECT c.oid FROM pg_catalog. $next = 999999; } - echo ''.PHP_EOL; static $js = null; if ($js === null) { - echo ''.PHP_EOL ; $js = '1'; } + return $html; + } function form_criterias($opt=array()) { @@ -501,7 +505,6 @@ FROM pg_catalog.pg_attribute a WHERE a.attrelid = (SELECT c.oid FROM pg_catalog. $format = (!empty($opt['format']) ? $opt['format'] : 'table'); if (!@$opt['is_html']) $opt['is_html'] = preg_match('/^(table)$/',$format) ? true : false; - if ($opt['is_html']) echo ''.PHP_EOL; $escape = preg_match('/^(table|row|xml)$/',$format) ? true : false; if (preg_match('/^(1)?$/',$this->db->p('header'))) echo $this->{"rows_begin_$format"}($opt); @@ -526,25 +529,18 @@ FROM pg_catalog.pg_attribute a WHERE a.attrelid = (SELECT c.oid FROM pg_catalog. } $count_fields++; - /* only if in latin1 - if ($this->db->p('format') == 'csv') { - $row[$f] = utf8_encode($row[$f]); - } elseif ($spec['extra']) { - $row[$f] = htmlentities($row[$f]); - - } - */ } - #debug($this->url_edit($row)); - if ($format == 'table') array_unshift($row,''.DB_HTML_EDIT.''); + if ($opt['is_html']) array_unshift($row,''.DB_HTML_EDIT.''); echo $this->{"rows_rec_$format"}($row); } + $opt['count'] = $count; + $opt['tot'] = $tot; + $opt['limit'] = $limit; echo $this->{"rows_end_$format"}($opt); - if ($opt['is_html']) echo $this->nav($count,$tot,$limit); $st->closeCursor(); @@ -556,28 +552,29 @@ FROM pg_catalog.pg_attribute a WHERE a.attrelid = (SELECT c.oid FROM pg_catalog. -----------------------------------------------------------------*/ function rows_begin_json() { $this->_row_json = null; - echo '['.PHP_EOL; + return '['.PHP_EOL; } function rows_rec_json($row) { + $json = ''; if ($this->_row_json === null) { $this->_row_json = true; } else { - echo ','; + $json .= ','; } - echo json_encode($row).PHP_EOL; + return $json . json_encode($row).PHP_EOL; } function rows_end_json() { unset($this->_row_json); - echo ']'.PHP_EOL; + return ']'.PHP_EOL; } /*----------------------------------------------------------------- Yaml -----------------------------------------------------------------*/ function rows_begin_yaml() { - echo "---\n"; + return "---\n"; } function rows_rec_yaml($row) { @@ -585,52 +582,55 @@ FROM pg_catalog.pg_attribute a WHERE a.attrelid = (SELECT c.oid FROM pg_catalog. $yaml = preg_replace('/^---\n/','',$yaml); $yaml = preg_replace('/\n\.\.\.$/','',$yaml); $yaml = preg_replace('/^/m',' ',$yaml); - echo '- '.trim($yaml)."\n"; + return '- '.trim($yaml)."\n"; } function rows_end_yaml() { - echo ''; + return ''; } /*----------------------------------------------------------------- Xml -----------------------------------------------------------------*/ function rows_begin_xml() { - echo '' + return '' .''.PHP_EOL .''.PHP_EOL ; } function rows_rec_xml($row) { - echo "\t<".$this->name.">".PHP_EOL; + $xml = ''; + $xml .= "\t".PHP_EOL; foreach (array_keys($this->fields()) as $f) { - if ($row[$f] !== '') echo '' + if ($row[$f] !== '') $xml .= '' . "\t\t<".$f.'>' .'' . '' .PHP_EOL; } - echo "\tname.">".PHP_EOL; + $xml .= "\t".PHP_EOL; + return $xml; } function rows_end_xml() { - #echo 'name.'>'.PHP_EOL; - echo ''.PHP_EOL; + return ''.PHP_EOL; } /*----------------------------------------------------------------- Csv -----------------------------------------------------------------*/ function rows_begin_csv() { - echo join("\t",array_keys($this->fields()))."\n"; + return join("\t",array_keys($this->fields()))."\n"; } function rows_rec_csv($row) { - echo join("\t",array_values($row))."\n"; + return join("\t",array_values($row))."\n"; } function rows_end_csv() { + return $this->nav($opt['count'],$opt['tot'],$opt['limit']); + return ''; } /*----------------------------------------------------------------- @@ -639,51 +639,73 @@ FROM pg_catalog.pg_attribute a WHERE a.attrelid = (SELECT c.oid FROM pg_catalog. // NB 14.04.14 function rows_begin_table($opt=array()) { function rows_begin_table() { - echo ''.PHP_EOL; + $html = ''; + $html .= '
'.PHP_EOL; + + if (DB_HTML_NAV_TOP) $html .= '' + . '' + . ''.PHP_EOL + ; - echo ''; - echo ''; + $html .= ''; + $html .= ''; foreach (array_keys($this->fields()) as $f) { - echo ''; + $html .= ''; } - echo ''.PHP_EOL; + $html .= ''.PHP_EOL.''.PHP_EOL; + + return $html; } function rows_rec_table($row) { - echo ''; + $html = ''; foreach ($row as $k => $v) { - echo ''; + $html .= ''; } - echo ''.PHP_EOL; + $html .= ''.PHP_EOL; + + return $html; } - function rows_end_table() { - echo '
' . DB_HTML_NAV_TOP . '
'.$this->url_sort($f).''.$this->url_sort($f).'
'.$v.''.$v.'
'.PHP_EOL; + function rows_end_table($opt=array()) { + $html = PHP_EOL.''.PHP_EOL; + + if (!empty($opt['count'])) $html .= '' + . '' + . $this->nav($opt['count'],$opt['tot'],$opt['limit']) + . '' + . ''.PHP_EOL + ; + + $html .= ''.PHP_EOL; + return $html; } /*----------------------------------------------------------------- Html Div -----------------------------------------------------------------*/ function rows_begin_div() { - echo '
'.PHP_EOL; + return '
'.DB_HTML_NAV_TOP.PHP_EOL; } function rows_rec_div($row) { - echo '
    '; + $html = ''; + $html .= '
      '; foreach ($row as $k => $v) { - echo '
    • ' + $html .= '
    • ' .''.$k.'' .': ' .''.$v.'' .'
    • '; } - echo '
    '.PHP_EOL; + $html .= '
'.PHP_EOL; + return $html; } function rows_end_div() { -- 2.47.3