summaryrefslogtreecommitdiffstats
path: root/frontends/php/include/config.inc.php
diff options
context:
space:
mode:
authorartem <artem@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2007-11-12 10:20:29 +0000
committerartem <artem@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2007-11-12 10:20:29 +0000
commitc0c1b50df1ec73e0cd6b72c7cc10197e6cc44a0a (patch)
tree43b9a3f70cc15cfcc674fafbd0c8a3829417331e /frontends/php/include/config.inc.php
parentd7d135227396a5b3cede974e94c25032a1bc69d2 (diff)
- [DEV-66] added sorting to screens (Artem)
git-svn-id: svn://svn.zabbix.com/trunk@4996 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php/include/config.inc.php')
-rw-r--r--frontends/php/include/config.inc.php87
1 files changed, 87 insertions, 0 deletions
diff --git a/frontends/php/include/config.inc.php b/frontends/php/include/config.inc.php
index 24cec730..931c4497 100644
--- a/frontends/php/include/config.inc.php
+++ b/frontends/php/include/config.inc.php
@@ -1766,4 +1766,91 @@ function TODO($msg) { echo "TODO: ".$msg.BR; } // DEBUG INFO!!!
}
return $new;
}
+
+
+ /* function:
+ * validate_sort_and_sortorder
+ *
+ * description:
+ * Checking,setting and saving sort params
+ *
+ * author: Aly
+ */
+ function validate_sort_and_sortorder(){
+ global $page;
+
+ $_REQUEST['sort'] = get_request('sort',get_profile('web.'.$page["file"].'.sort',NULL));
+ $_REQUEST['sortorder'] = get_request('sortorder',get_profile('web.'.$page["file"].'.sortorder',ZBX_SORT_UP));
+
+ if(!is_null($_REQUEST['sort'])){
+ $_REQUEST['sort'] = eregi_replace('[^a-z\.\_]','',$_REQUEST['sort']);
+ update_profile('web.'.$page["file"].'.sort', $_REQUEST['sort']);
+ }
+
+ if(!in_array($_REQUEST['sortorder'],array(ZBX_SORT_DOWN,ZBX_SORT_UP)))
+ $_REQUEST['sortorder'] = ZBX_SORT_UP;
+
+ update_profile('web.'.$page["file"].'.sortorder', $_REQUEST['sortorder']);
+ }
+
+ /* function:
+ * make_sorting_link
+ *
+ * description:
+ * Creates links for sorting in table header
+ *
+ * author: Aly
+ */
+ function make_sorting_link($obj,$tabfield,$url=''){
+ global $page;
+
+ $sortorder = ($_REQUEST['sortorder'] == ZBX_SORT_UP)?ZBX_SORT_DOWN:ZBX_SORT_UP;
+
+ if(empty($url)){
+ $url='?';
+ $url_params = explode('&',$_SERVER['QUERY_STRING']);
+ foreach($url_params as $id => $param){
+ if(empty($param)) continue;
+
+ list($name,$value) = explode('=',$param);
+ if(empty($name) || ($name == 'sort') || (($name == 'sortorder'))) continue;
+ $url.=$param.'&';
+ }
+ }
+ else{
+ $url.='&';
+ }
+
+ $link = new CLink($obj,$url.'sort='.$tabfield.'&sortorder='.$sortorder);
+
+ if($tabfield == $_REQUEST['sort']){
+ if($sortorder == ZBX_SORT_UP){
+ $img = new CImg('images/general/sort_downw.gif','down',10,10);
+ }
+ else{
+ $img = new CImg('images/general/sort_upw.gif','up',10,10);
+ }
+
+ $img->AddOption('style','line-height: 18px; vertical-align: middle;');
+ $link = array($link,SPACE,$img);
+ }
+
+ return $link;
+ }
+
+ function order_by($def,$allways=''){
+ global $page;
+
+ if(!empty($allways)) $allways = ','.$allways;
+ $sortable = explode(',',$def);
+
+ $tabfield = get_request('sort',get_profile('web.'.$page["file"].'.sort',null));
+
+ if(is_null($tabfield)) return ' ORDER BY '.$def.$allways;
+ if(!in_array($tabfield,$sortable)) return ' ORDER BY '.$def.$allways;
+
+ $sortorder = get_request('sortorder',get_profile('web.'.$page["file"].'.sortorder',ZBX_SORT_UP));
+
+ return ' ORDER BY '.$tabfield.' '.$sortorder.$allways;
+ }
?>