From: hickert Date: Tue, 6 Nov 2007 07:32:44 +0000 (+0000) Subject: Updated viewport X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=218dea6a864b69c5d90c1b33df5f839c74140d5e;p=gosa.git Updated viewport git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.6-playground@7737 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa.conf b/gosa.conf index 02f25da4c..36b145b2e 100644 --- a/gosa.conf +++ b/gosa.conf @@ -119,6 +119,6 @@ kiosk-path = "/var/spool/kiosk" ppd-path = "/var/spool/ppds" [plugin/sample] -headline= "|{16px}|{90%}Name|{64px:R}Actions|" +headline= "|{196px}|{:CB}Name|{64px:R}Actions|" footer= "Statistics with no information currently" entryFormat= "|{_icon}|{cn} ({_filter(uppercase,{cn})})|{_actions}|" diff --git a/include/class_ObjectList.inc b/include/class_ObjectList.inc index 9185c7b42..9958f2fc8 100644 --- a/include/class_ObjectList.inc +++ b/include/class_ObjectList.inc @@ -68,14 +68,286 @@ class ObjectList implements IteratorAggregate { defined filter modules. Handles sorting, too. */ private function load(){ - # Crap filling +# Crap filling $this->objects= array( - array("dn" => "cn=Demo client,ou=systems,dc=gonicus,dc=de", "cn" => "Demo client", "_icon" => "s_terminal.png", "_actions" => "ED", "objectClass" => array('gotoWorkstation')), - array("dn" => "cn=Demo client2,ou=systems,dc=gonicus,dc=de", "cn" => "Demo client2", "_icon" => "s_terminal.png", "_actions" => "ED", "objectClass" => array('gotoWorkstation')), - array("dn" => "cn=Printer,ou=systems,dc=gonicus,dc=de", "cn" => "Printer", "_icon" => "s_printer.png", "_actions" => "ED", "objectClass" => array('gotoPrinter')), - array("dn" => "cn=Server,ou=systems,dc=gonicus,dc=de", "cn" => "Server", "_icon" => "s_server.png", "_actions" => "ED", "objectClass" => array("goServer")), - ); - } + + array("dn" => "cn=1aherbertskiste,ou=workstations,ou=systems,o=Landeshauptstadt München,c=de", + "cn" => "1aherbertskiste", + "_icon" => "select_workstation.png", + "_actions" => "CPSRED", + "objectClass" => array('gotoWorkstation')), + + array("dn" => "cn=72:9c:13:e9:72:2b,ou=incoming,o=Landeshauptstadt München,c=de", + "cn" => "72:9c:13:e9:72:2b", + "_icon" => "select_newsystem.png", + "_actions" => "CPSRED", + "objectClass" => array('gotoWorkstation')), + + array("dn" => "cn=8f:9c:d0:d5:42:c0,ou=incoming,o=Landeshauptstadt München,c=de", + "cn" => "8f:9c:d0:d5:42:c0", + "_icon" => "select_newsystem.png", + "_actions" => "CPSRED", + "objectClass" => array('gotoWorkstation')), + + array("dn" => "cn=a.b_c,ou=printers,ou=systems,o=Landeshauptstadt München,c=de", + "cn" => "a.b_c", + "_icon" => "select_printer.png", + "_actions" => "CPSRED", + "objectClass" => array('gotoWorkstation')), + + array("dn" => "cn=a5:35:77:86:ff:ca,ou=workstations,ou=systems,o=Landeshauptstadt München,c=de", + "cn" => "a5:35:77:86:ff:ca", + "_icon" => "select_workstation.png", + "_actions" => "CPSRED", + "objectClass" => array('gotoWorkstation')), + + array("dn" => "cn=cl1--141,ou=workstations,ou=systems,o=Landeshauptstadt München,c=de", + "cn" => "cl1--141", + "_icon" => "select_workstation.png", + "_actions" => "CPSRED", + "objectClass" => array('gotoWorkstation')), + + array("dn" => "cn=d9:57:9d:08:2c:65,ou=incoming,o=Landeshauptstadt München,c=de", + "cn" => "d9:57:9d:08:2c:65", + "_icon" => "select_newsystem.png", + "_actions" => "CPSRED", + "objectClass" => array('gotoWorkstation')), + + array("dn" => "cn=dyn-111,ou=servers,ou=systems,o=Landeshauptstadt München,c=de", + "cn" => "dyn-111", + "_icon" => "select_server.png", + "_actions" => "CPSRED", + "objectClass" => array('gotoWorkstation')), + + array("dn" => "cn=e3:b4:43:51:f6:13,ou=incoming,o=Landeshauptstadt München,c=de", + "cn" => "e3:b4:43:51:f6:13", + "_icon" => "select_newsystem.png", + "_actions" => "CPSRED", + "objectClass" => array('gotoWorkstation')), + + array("dn" => "cn=f2:d7:ef:92:e6:43,ou=incoming,o=Landeshauptstadt München,c=de", + "cn" => "f2:d7:ef:92:e6:43", + "_icon" => "select_newsystem.png", + "_actions" => "CPSRED", + "objectClass" => array('gotoWorkstation')), + + array("dn" => "cn=f9:fa:4e:f8:1a:40,ou=incoming,o=Landeshauptstadt München,c=de", + "cn" => "f9:fa:4e:f8:1a:40", + "_icon" => "select_newsystem.png", + "_actions" => "CPSRED", + "objectClass" => array('gotoWorkstation')), + + array("dn" => "cn=hu_ber-test.gonicus.de,ou=printers,ou=systems,o=Landeshauptstadt München,c=de", + "cn" => "hu_ber-test.gonicus.de", + "_icon" => "select_printer.png", + "_actions" => "CPSRED", + "objectClass" => array('gotoWorkstation')), + + array("dn" => "cn=loghost-01,ou=servers,ou=systems,o=Landeshauptstadt München,c=de", + "cn" => "loghost-01", + "_icon" => "select_server.png", + "_actions" => "CPSRED", + "objectClass" => array('gotoWorkstation')), + + array("dn" => "cn=ntp.jp.,ou=servers,ou=systems,o=Landeshauptstadt München,c=de", + "cn" => "ntp.jp.", + "_icon" => "select_server.png", + "_actions" => "CPSRED", + "objectClass" => array('gotoWorkstation')), + + array("dn" => "cn=phone-1.gonicus.de.,ou=phones,ou=systems,o=Landeshauptstadt München,c=de", + "cn" => "phone-1.gonicus.de.", + "_icon" => "select_phone.png", + "_actions" => "CPSRED", + "objectClass" => array('gotoWorkstation')), + + array("dn" => "cn=printer.222,ou=printers,ou=systems,o=Landeshauptstadt München,c=de", + "cn" => "printer.222", + "_icon" => "select_printer.png", + "_actions" => "CPSRED", + "objectClass" => array('gotoWorkstation')), + + array("dn" => "cn=printer,ou=printers,ou=systems,o=Landeshauptstadt München,c=de", + "cn" => "printer", + "_icon" => "select_printer.png", + "_actions" => "CPSRED", + "objectClass" => array('gotoWorkstation')), + + array("dn" => "cn=shares.jp.,ou=servers,ou=systems,o=Landeshauptstadt München,c=de", + "cn" => "shares.jp. [Share server]", + "_icon" => "select_server.png", + "_actions" => "CPSRED", + "objectClass" => array('gotoWorkstation')), + + array("dn" => "cn=terminal.jp.,ou=servers,ou=systems,o=Landeshauptstadt München,c=de", + "cn" => "terminal.jp.", + "_icon" => "select_server.png", + "_actions" => "CPSRED", + "objectClass" => array('gotoWorkstation')), + + array("dn" => "cn=test.test.etst,ou=printers,ou=systems,o=Landeshauptstadt München,c=de", + "cn" => "test.test.etst", + "_icon" => "select_printer.png", + "_actions" => "CPSRED", + "objectClass" => array('gotoWorkstation')), + + array("dn" => "cn=tester,ou=printers,ou=systems,o=Landeshauptstadt München,c=de", + "cn" => "tester", + "_icon" => "select_printer.png", + "_actions" => "CPSRED", + "objectClass" => array('gotoWorkstation')), + + array("dn" => "cn=vserver-04.intranet.gonicus.de,ou=servers,ou=systems,o=Landeshauptstadt München,c=de", + "cn" => "vserver-04.intranet.gonicus.de [Mail Server]", + "_icon" => "select_server.png", + "_actions" => "CPSRED", + "objectClass" => array('gotoWorkstation')), + + array("dn" => "cn=workstation,ou=workstations,ou=systems,o=Landeshauptstadt München,c=de", + "cn" => "workstation", + "_icon" => "select_workstation.png", + "_actions" => "CPSRED", + "objectClass" => array('gotoWorkstation')), + array("dn" => "cn=1aherbertskiste,ou=workstations,ou=systems,o=Landeshauptstadt München,c=de", + "cn" => "1aherbertskiste", + "_icon" => "select_workstation.png", + "_actions" => "CPSRED", + "objectClass" => array('gotoWorkstation')), + + array("dn" => "cn=72:9c:13:e9:72:2b,ou=incoming,o=Landeshauptstadt München,c=de", + "cn" => "72:9c:13:e9:72:2b", + "_icon" => "select_newsystem.png", + "_actions" => "CPSRED", + "objectClass" => array('gotoWorkstation')), + + array("dn" => "cn=8f:9c:d0:d5:42:c0,ou=incoming,o=Landeshauptstadt München,c=de", + "cn" => "8f:9c:d0:d5:42:c0", + "_icon" => "select_newsystem.png", + "_actions" => "CPSRED", + "objectClass" => array('gotoWorkstation')), + + array("dn" => "cn=a.b_c,ou=printers,ou=systems,o=Landeshauptstadt München,c=de", + "cn" => "a.b_c", + "_icon" => "select_printer.png", + "_actions" => "CPSRED", + "objectClass" => array('gotoWorkstation')), + + array("dn" => "cn=a5:35:77:86:ff:ca,ou=workstations,ou=systems,o=Landeshauptstadt München,c=de", + "cn" => "a5:35:77:86:ff:ca", + "_icon" => "select_workstation.png", + "_actions" => "CPSRED", + "objectClass" => array('gotoWorkstation')), + + array("dn" => "cn=cl1--141,ou=workstations,ou=systems,o=Landeshauptstadt München,c=de", + "cn" => "cl1--141", + "_icon" => "select_workstation.png", + "_actions" => "CPSRED", + "objectClass" => array('gotoWorkstation')), + + array("dn" => "cn=d9:57:9d:08:2c:65,ou=incoming,o=Landeshauptstadt München,c=de", + "cn" => "d9:57:9d:08:2c:65", + "_icon" => "select_newsystem.png", + "_actions" => "CPSRED", + "objectClass" => array('gotoWorkstation')), + + array("dn" => "cn=dyn-111,ou=servers,ou=systems,o=Landeshauptstadt München,c=de", + "cn" => "dyn-111", + "_icon" => "select_server.png", + "_actions" => "CPSRED", + "objectClass" => array('gotoWorkstation')), + + array("dn" => "cn=e3:b4:43:51:f6:13,ou=incoming,o=Landeshauptstadt München,c=de", + "cn" => "e3:b4:43:51:f6:13", + "_icon" => "select_newsystem.png", + "_actions" => "CPSRED", + "objectClass" => array('gotoWorkstation')), + + array("dn" => "cn=f2:d7:ef:92:e6:43,ou=incoming,o=Landeshauptstadt München,c=de", + "cn" => "f2:d7:ef:92:e6:43", + "_icon" => "select_newsystem.png", + "_actions" => "CPSRED", + "objectClass" => array('gotoWorkstation')), + + array("dn" => "cn=f9:fa:4e:f8:1a:40,ou=incoming,o=Landeshauptstadt München,c=de", + "cn" => "f9:fa:4e:f8:1a:40", + "_icon" => "select_newsystem.png", + "_actions" => "CPSRED", + "objectClass" => array('gotoWorkstation')), + + array("dn" => "cn=hu_ber-test.gonicus.de,ou=printers,ou=systems,o=Landeshauptstadt München,c=de", + "cn" => "hu_ber-test.gonicus.de", + "_icon" => "select_printer.png", + "_actions" => "CPSRED", + "objectClass" => array('gotoWorkstation')), + + array("dn" => "cn=loghost-01,ou=servers,ou=systems,o=Landeshauptstadt München,c=de", + "cn" => "loghost-01", + "_icon" => "select_server.png", + "_actions" => "CPSRED", + "objectClass" => array('gotoWorkstation')), + + array("dn" => "cn=ntp.jp.,ou=servers,ou=systems,o=Landeshauptstadt München,c=de", + "cn" => "ntp.jp.", + "_icon" => "select_server.png", + "_actions" => "CPSRED", + "objectClass" => array('gotoWorkstation')), + + array("dn" => "cn=phone-1.gonicus.de.,ou=phones,ou=systems,o=Landeshauptstadt München,c=de", + "cn" => "phone-1.gonicus.de.", + "_icon" => "select_phone.png", + "_actions" => "CPSRED", + "objectClass" => array('gotoWorkstation')), + + array("dn" => "cn=printer.222,ou=printers,ou=systems,o=Landeshauptstadt München,c=de", + "cn" => "printer.222", + "_icon" => "select_printer.png", + "_actions" => "CPSRED", + "objectClass" => array('gotoWorkstation')), + + array("dn" => "cn=printer,ou=printers,ou=systems,o=Landeshauptstadt München,c=de", + "cn" => "printer", + "_icon" => "select_printer.png", + "_actions" => "CPSRED", + "objectClass" => array('gotoWorkstation')), + + array("dn" => "cn=shares.jp.,ou=servers,ou=systems,o=Landeshauptstadt München,c=de", + "cn" => "shares.jp. [Share server]", + "_icon" => "select_server.png", + "_actions" => "CPSRED", + "objectClass" => array('gotoWorkstation')), + + array("dn" => "cn=terminal.jp.,ou=servers,ou=systems,o=Landeshauptstadt München,c=de", + "cn" => "terminal.jp.", + "_icon" => "select_server.png", + "_actions" => "CPSRED", + "objectClass" => array('gotoWorkstation')), + + array("dn" => "cn=test.test.etst,ou=printers,ou=systems,o=Landeshauptstadt München,c=de", + "cn" => "test.test.etst", + "_icon" => "select_printer.png", + "_actions" => "CPSRED", + "objectClass" => array('gotoWorkstation')), + + array("dn" => "cn=tester,ou=printers,ou=systems,o=Landeshauptstadt München,c=de", + "cn" => "tester", + "_icon" => "select_printer.png", + "_actions" => "CPSRED", + "objectClass" => array('gotoWorkstation')), + + array("dn" => "cn=vserver-04.intranet.gonicus.de,ou=servers,ou=systems,o=Landeshauptstadt München,c=de", + "cn" => "vserver-04.intranet.gonicus.de [Mail Server]", + "_icon" => "select_server.png", + "_actions" => "CPSRED", + "objectClass" => array('gotoWorkstation')), + + array("dn" => "cn=workstation,ou=workstations,ou=systems,o=Landeshauptstadt München,c=de", + "cn" => "workstation", + "_icon" => "select_workstation.png", + "_actions" => "CPSRED", + "objectClass" => array('gotoWorkstation')) + + ); + } /*! \brief Function to reload object list in case of external changes diff --git a/include/class_ObjectListViewport.inc b/include/class_ObjectListViewport.inc index da9b98508..84cf37c64 100644 --- a/include/class_ObjectListViewport.inc +++ b/include/class_ObjectListViewport.inc @@ -57,7 +57,7 @@ class ObjectListViewport { /* Dummy here */ $cr= Registry::getInstance("ConfigManager"); $cr->setSection($config); - $this->headline= $cr->getValue("headline"); + $this->headline= $this->parseHeadline($cr->getValue("headline")); $this->footer= $cr->getValue("footer"); $this->entryFormat= $cr->getValue("entryFormat"); @@ -117,6 +117,14 @@ class ObjectListViewport { /* Copy template */ $buffer= $this->entryFormat; + $tmp = split("\|",trim($this->entryFormat,"|")); + + $buffer ="\n"; + foreach($tmp as $key => $value){ + $buffer .= "".$value."\n"; + } + $buffer.="\n"; + /* Replace set of attributes */ foreach ($this->attributes as $attribute){ if (!isset($entry[$attribute])){ @@ -131,7 +139,7 @@ class ObjectListViewport { foreach ($matches as $match){ $filterName= preg_replace('/,.+$/', '', $match[1]); $filterParameter= preg_replace('/^[^,]+,/', '', $match[1]); - $buffer= preg_replace('/\{_filter\('.$match[1].'\)\}/', $this->applyEntryFilter($filterName, $filterParameter), $buffer); + $buffer= preg_replace('/\{_filter\('.normalizePreg($match[1]).'\)\}/', $this->applyEntryFilter($filterName, $filterParameter), $buffer); } #TODO: Make $buffer a proper HTML table output @@ -159,6 +167,7 @@ class ObjectListViewport { \return HTML rendered list */ public function render() { + /* Generate fixed headline */ $buffer= $this->renderHeadline(); @@ -171,9 +180,67 @@ class ObjectListViewport { /* Generate footer */ $buffer.= $this->renderFooter(); - return ($buffer); + return ("".$buffer."
"); } + + /*! \brief Parses the given headline format string + + \return Array with cell properties (width, alignment,name) + */ + private function parseHeadline($data) + { + /* Each cell definition is seperated by | + * split by and go through each definition + */ + $tmp = split("\|",trim($data,"|")); + $cell_formats = array(); + foreach($tmp as $key => $data){ + + $s_width = ""; + $s_alignment= ""; + $s_name = preg_replace("/\{[^\}]*+\}/","",$data); + $s_style = "height:40px;"; + + /* Parse format string and detect width & alignment */ + if(preg_match("/\{.*\}/",$data)){ + $s_format= preg_replace("/^[^\{]*+\{([^\}]*).*$/","\\1",$data); + + /* Get aligment */ + if(preg_match("/:/",$s_format)){ + $s_al = preg_replace("/^[^:]*+:([a-z]*).*$/i","\\1",$s_format); + + if(preg_match("/T/i",$s_al)){ + $s_alignment.= "top-" ; + $s_style.= "vertical-align: top;"; + } + if(preg_match("/B/i",$s_al)){ + $s_alignment.= "bottom-" ; + $s_style.= "vertical-align: bottom;"; + } + if(preg_match("/R/i",$s_al)){ + $s_alignment.= "right" ; + $s_style.= "text-align: right;"; + }elseif(preg_match("/L/i",$s_al)){ + $s_alignment.= "left" ; + $s_style.= "text-align: left;"; + }elseif(preg_match("/C/i",$s_al) || preg_match("/M/i",$s_al) ){ + $s_alignment.= "center" ; + $s_style.= "text-align: center;"; + } + } + + /* Get width */ + $s_width = preg_replace("/^([^:]*).*$/","\\1",$s_format); + if(!empty($s_width)){ + $s_style = "width: ".$s_width.";"; + } + + $cell_formats[$key] = array("name" => $s_name, "width" => $s_width, "alignment" => $s_alignment,"style" => $s_style); + } + } + return($cell_formats); + } } // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: diff --git a/test b/test index ff8262398..3c8f54fe2 100755 --- a/test +++ b/test @@ -4,9 +4,17 @@ /* This is good for testing... */ error_reporting (E_ALL | E_STRICT); +/* Escape all preg_* relevant characters */ +function normalizePreg($input) +{ + return (addcslashes($input, '[]()|/.*+-')); +} + + + /* Initiate autoloader... */ require_once("include/autoload.inc"); - +restore_error_handler(); try { /* Get new test instance of the Configuration */