From fc5c5b8bde0f069e5d1e496d32f476d73463816f Mon Sep 17 00:00:00 2001 From: Thomas Mudrunka Date: Mon, 18 Jul 2011 16:57:56 +0200 Subject: [PATCH] Trida Sklad_HTML nyni nic nevypisuje (priprava na templatovaci system) --- index.php | 65 ++++++++++++++++++++++++++++++------------------------- 1 file changed, 35 insertions(+), 30 deletions(-) diff --git a/index.php b/index.php index d1d0942..68c81d7 100755 --- a/index.php +++ b/index.php @@ -24,15 +24,17 @@ require_once('HTTP_Auth.class.php'); /** * Trida poskytuje podpurne funkce pro generovani HTML kodu specificke pro sklad * +* Tato trida by nemela sama nic vypisovat (vyjma chybovych a debugovacich hlasek)! +* * @package Sklad_HTML * @author Tomas Mudrunka */ class Sklad_HTML { - function header_print($title='') { + function header($title='') { $home = URL_HOME; $script = $_SERVER['SCRIPT_NAME']; $search = @trim($_GET['q']); - echo << @@ -54,26 +56,28 @@ class Sklad_HTML { EOF; } - function row_print($row) { - echo(''); + function row($row) { + $html=''; foreach($row as $var) { if(trim($var) == '') $var = ' '; - echo("$var"); + $html.="$var"; } - echo(''); + $html.=''; + return $html; } - function table_print(&$table, $params='border=1') { - echo(""); + function table(&$table, $params='border=1') { + $html="
"; $header=true; foreach($table as $row) { if($header) { - $this->row_print(array_keys($row)); + $html.=$this->row(array_keys($row)); $header=false; } - $this->row_print($row); + $html.=$this->row($row); } - echo('
'); + $html.=''; + return $html; } function link($title='n/a', $link='#void', $internal=true) { @@ -130,11 +134,11 @@ EOF; $table = $table_sorted; } - function print_item_table($table) { + function render_item_table($table) { $this->table_add_images($table); $this->table_collapse($table); $this->table_sort($table); - return $this->table_print($table); + return $this->table($table); } function input($name=false, $value=false, $type='text', $placeholder=false, $options=false) { @@ -163,7 +167,7 @@ EOF; return $html; } - function print_insert_form($class, $columns, $selectbox=array(), $current=false, $multi_insert=true) { + function render_insert_form($class, $columns, $selectbox=array(), $current=false, $multi_insert=true) { //echo('
'); print_r($selectbox);
 		//echo('
'); print_r($current);
 		$update = false;
@@ -172,33 +176,33 @@ EOF;
 			$current = array_shift($current);
 		}
 
-		echo('
'); - if($multi_insert) echo('
'); - echo $this->input('table', $class, 'hidden'); + $html=''; + if($multi_insert) $html.='
'; + $html.=$this->input('table', $class, 'hidden'); foreach($columns as $column) { - echo($column['Field'].': '); + $html.=$column['Field'].': '; $name='value:'.$column['Field'].'[]'; switch(true) { case preg_match('/auto_increment/', $column['Extra']): $val = $update ? $current[$column['Field']] : ''; //opakuje se (skoro) zbytecne - echo $this->input($name, $val, 'hidden'); - echo($val.'(AUTO)'); + $html.=$this->input($name, $val, 'hidden'); + $html.=$val.'(AUTO)'; break; case isset($selectbox[$column['Field']]): $val = $update ? $current[$column['Field']] : false; - echo $this->select($name,$selectbox[$column['Field']],$val); //opakuje se + $html.=$this->select($name,$selectbox[$column['Field']],$val); //opakuje se break; default: $val = $update ? $current[$column['Field']] : false; //opakuje se - echo $this->input($name, $val); + $html.=$this->input($name, $val); break; } - echo('
'); + $html.='
'; } if($multi_insert) { //TODO, move to separate JS file - echo <<