From: Thomas Mudrunka Date: Mon, 22 Oct 2012 17:17:04 +0000 (+0200) Subject: Knihovna pro generovani query stringu, fix blbosti s orderby X-Git-Url: https://git.harvie.cz/?a=commitdiff_plain;h=e0568aca4c4fc5f5da72d0fa7fcef3d8499cb14a;p=mirrors%2FSokoMan.git Knihovna pro generovani query stringu, fix blbosti s orderby --- diff --git a/index.php b/index.php index b9860e3..ef5d5b5 100755 --- a/index.php +++ b/index.php @@ -1,7 +1,7 @@ array( 'item' => array('category_name'), @@ -506,12 +506,12 @@ EOF; if($class) $this->table_hide_columns($table,$class); $this->table_sort($table); - //TODO: orderbaj fixme (napsat funkci na pridavani/ubirani soucasnych URL parametru) - $get = $_SERVER['QUERY_STRING'] != '' ? '?'.$_SERVER['QUERY_STRING'] : ''; - $moreget = isset($get[0]) ? '&' : '?'; - $path=$_SERVER['PATH_INFO'].$get.$moreget; + //Orderby: + $path = $_GET; + unset($path['orderby']); + $path = '?'.Query::build($path).'orderby'; - return $this->table($table,$colspan,$rowspan,$break_after,$path.'orderby'); + return $this->table($table,$colspan,$rowspan,$break_after,$path); } function render_insert_inputs($class,$columns,$selectbox,$current,$hidecols,$update) { diff --git a/lib/Query.class.php b/lib/Query.class.php new file mode 100755 index 0000000..48a2bb0 --- /dev/null +++ b/lib/Query.class.php @@ -0,0 +1,39 @@ +. +*/ + +/** +* Trida implementuje funkce pro manipulaci s query stringem +* +* @package Query +* @author Tomas Mudrunka +*/ +class Query { + + static function build($query=array(),$prefix=false) { + $q=''; + if(is_array($query)) foreach($query as $key => $val) { + $pre = !$prefix ? $key : $prefix.'['.$key.']'; + $q.=Query::build($val,$pre); + } else { + return $prefix.'='.$query.'&'; + } + return $q; + } + +}