From a3e623e49336f6b07f7b7cb5ef39045469536b26 Mon Sep 17 00:00:00 2001 From: Simon Date: Mon, 4 Apr 2011 15:20:51 +0200 Subject: Pagination angepasst --- library/Pbs/Pagination.php | 50 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 2 deletions(-) (limited to 'library') diff --git a/library/Pbs/Pagination.php b/library/Pbs/Pagination.php index 179f2f7..2213373 100644 --- a/library/Pbs/Pagination.php +++ b/library/Pbs/Pagination.php @@ -1,8 +1,24 @@ requestpage; + if($max == null) + $max = $this->numpages; + if($url == null) + $url = $this->pageUrl; + #print_a($url,$selected,$max); + $str = "
"; if ( 1 <= $selected){ $str .= "<<"; @@ -33,6 +49,36 @@ class Pbs_Pagination{ $str .= "
"; return $str; } + public function setPerPage($perpage){ + $this->perpage = $perpage; + } + public function getPerPage(){ + return $this->perpage; + } + public function setRequestPage($requestpage){ + if($requestpage < 0 || !is_numeric($requestpage) ) + $requestpage = 0; + if($rrequestpage >= $this->numpages) + $requestpage = $this->numpages-1; + $this->requestpage = $requestpage; + } + public function getRequestPage(){ + return $this->requestpage; + } + public function setElement($element){ + $this->element = $element; + $this->maxNumber = count($element); + $this->numpages = ceil(count($element)/$this->perpage); + } + public function getStartItem(){ + return $this->requestpage * $this->perpage; + } + public function getElements(){ + return array_slice($this->element,$this->getStartItem(),$this->getPerPage()); + } + public function setPageUrl($url){ + $this->pageUrl = $url; + } } -- cgit v1.2.3-55-g7522 From d3accaaab0cfb3d3178d349c12baf821dcf38899 Mon Sep 17 00:00:00 2001 From: Simon Date: Mon, 4 Apr 2011 15:34:22 +0200 Subject: Suche in Clients eingebettet --- application/modules/user/forms/Filter.php | 14 +++++- .../modules/user/views/scripts/client/index.phtml | 9 ++++ library/Pbs/Pagination.php | 2 +- library/Pbs/Search.php | 51 ++++++++++++++++++++++ 4 files changed, 73 insertions(+), 3 deletions(-) create mode 100644 library/Pbs/Search.php (limited to 'library') diff --git a/application/modules/user/forms/Filter.php b/application/modules/user/forms/Filter.php index a7a2555..0676ba8 100644 --- a/application/modules/user/forms/Filter.php +++ b/application/modules/user/forms/Filter.php @@ -9,23 +9,33 @@ class user_Form_Filter extends Zend_Form { $this->setName("Add Filter"); $this->setMethod('post'); - + + if(Pbs_Acl::checkRight('fefp')){ + $edit = 'true'; + } + else{ + $edit = null; + } + $this->addElement('text', 'title', array( 'filters' => array('StringTrim'), 'validators' => array( array('StringLength', false, array(0, 50)), ), 'required' => true, + 'readOnly' => $edit, 'label' => 'Title:', )); $this->addElement('textarea', 'description', array( 'filters' => array('StringTrim'), 'required' => false, + 'readOnly' => $edit, 'label' => 'Description:', )); $bootmenufield = $this->createElement('select','bootmenuID'); - $bootmenufield ->setLabel('Bootmenu:'); + $bootmenufield->setLabel('Bootmenu:'); + $bootmenufield->setAttrib('readOnly', $edit); if(count($this->bootmenus)>0){ foreach($this->bootmenus as $g){ diff --git a/application/modules/user/views/scripts/client/index.phtml b/application/modules/user/views/scripts/client/index.phtml index 62c698c..0442d95 100644 --- a/application/modules/user/views/scripts/client/index.phtml +++ b/application/modules/user/views/scripts/client/index.phtml @@ -1,5 +1,14 @@

Clients

notification != ''){echo $this->notification;} ?> +
+search)?'value="'.$this->search.'"':'';?>> + +search)){ + echo "Delete Client"; +} +?> +
formButton('createbootos', 'Create Client', array( 'onclick' => 'self.location="/user/client/addclient/page/'.$this->page.'"', 'class' => 'addbutton'))?> diff --git a/library/Pbs/Pagination.php b/library/Pbs/Pagination.php index 2213373..c31dacf 100644 --- a/library/Pbs/Pagination.php +++ b/library/Pbs/Pagination.php @@ -58,7 +58,7 @@ class Pbs_Pagination{ public function setRequestPage($requestpage){ if($requestpage < 0 || !is_numeric($requestpage) ) $requestpage = 0; - if($rrequestpage >= $this->numpages) + if($requestpage >= $this->numpages) $requestpage = $this->numpages-1; $this->requestpage = $requestpage; } diff --git a/library/Pbs/Search.php b/library/Pbs/Search.php new file mode 100644 index 0000000..279cba6 --- /dev/null +++ b/library/Pbs/Search.php @@ -0,0 +1,51 @@ + $cig){ + foreach($cig as $k => $v){ + if(count($searcha) > 0){ + foreach($searcha as $sk => $sv){ + if($k == $sk){ + if(stristr($v,$sv)){ + $com1[] = $counter; + } + } + } + } + if(count($searchb) >= 0){ + foreach($searchb as $sk => $sv){ + $comm = stristr($v,$sv); + if($comm != false){ + $com2[] = $counter; + break; + } + } + } + } + } + if (count($searcha) == 0){ + $data = $com2; + } + if (count($searchb) == 0){ + $data = $com1; + } + if (count($searcha) > 0 && count($searchb) > 0){ + $data = array_intersect($com1,$com2); + } + foreach( $data as $c) + $ges[] = $array[$c]; + return $ges; + } +} -- cgit v1.2.3-55-g7522 From e5e65c03c4d1879c4cf4ef5e0f77a80e7eb73ece Mon Sep 17 00:00:00 2001 From: Simon Date: Mon, 4 Apr 2011 16:33:59 +0200 Subject: highlight für suche eingebaut --- .../modules/user/controllers/ClientController.php | 4 +- .../modules/user/views/scripts/client/index.phtml | 15 +++++- library/Pbs/Search.php | 33 +++++++++++--- public/media/css/style.css | 7 +++ public/media/js/jquery.highlight-3.js | 53 ++++++++++++++++++++++ 5 files changed, 103 insertions(+), 9 deletions(-) create mode 100644 public/media/js/jquery.highlight-3.js (limited to 'library') diff --git a/application/modules/user/controllers/ClientController.php b/application/modules/user/controllers/ClientController.php index 2a57cf0..acb6a65 100644 --- a/application/modules/user/controllers/ClientController.php +++ b/application/modules/user/controllers/ClientController.php @@ -53,7 +53,9 @@ class User_ClientController extends Zend_Controller_Action if($search != ''){ $this->view->search = $search; $mySearch = new Pbs_Search(); - $clientsInGroup = $mySearch->search($clientsInGroup,$search); + $mySearch->setSearchTerm($search); + $clientsInGroup = $mySearch->search($clientsInGroup); + $this->view->searchterms = $mySearch->getSearchTerms(); } // Pagination diff --git a/application/modules/user/views/scripts/client/index.phtml b/application/modules/user/views/scripts/client/index.phtml index 0442d95..ca78db1 100644 --- a/application/modules/user/views/scripts/client/index.phtml +++ b/application/modules/user/views/scripts/client/index.phtml @@ -5,7 +5,20 @@ search)){ - echo "Delete Client"; + ?> + Delete Client + + + + diff --git a/library/Pbs/Search.php b/library/Pbs/Search.php index 279cba6..7f6dfa7 100644 --- a/library/Pbs/Search.php +++ b/library/Pbs/Search.php @@ -1,7 +1,14 @@ searchTerm = $search; + $parts = explode(" ",$search); foreach($parts as $search){ if(stristr($search,":") && ctype_alpha(substr($search,0,strpos($search,":")))){ @@ -13,10 +20,22 @@ class Pbs_Search{ $searchb[] = $search; } } + $this->searcha = $searcha; + $this->searchb = $searchb; + } + + public function getSearchTerms(){ + $beta = $this->searcha; + foreach($this->searchb as $b) + $beta[] = $b; + return $beta; + } + public function search($array){ + foreach($array as $counter => $cig){ foreach($cig as $k => $v){ - if(count($searcha) > 0){ - foreach($searcha as $sk => $sv){ + if(count($this->searcha) > 0){ + foreach($this->searcha as $sk => $sv){ if($k == $sk){ if(stristr($v,$sv)){ $com1[] = $counter; @@ -25,7 +44,7 @@ class Pbs_Search{ } } if(count($searchb) >= 0){ - foreach($searchb as $sk => $sv){ + foreach($this->searchb as $sk => $sv){ $comm = stristr($v,$sv); if($comm != false){ $com2[] = $counter; @@ -35,13 +54,13 @@ class Pbs_Search{ } } } - if (count($searcha) == 0){ + if (count($this->searcha) == 0){ $data = $com2; } - if (count($searchb) == 0){ + if (count($this->searchb) == 0){ $data = $com1; } - if (count($searcha) > 0 && count($searchb) > 0){ + if (count($this->searcha) > 0 && count($this->searchb) > 0){ $data = array_intersect($com1,$com2); } foreach( $data as $c) diff --git a/public/media/css/style.css b/public/media/css/style.css index f71cf8b..a521aeb 100644 --- a/public/media/css/style.css +++ b/public/media/css/style.css @@ -115,6 +115,9 @@ body { min-height: 400px; background-color: #F2F3F1; } +#content img { + border:none; +} #debug { text-align: left; @@ -480,4 +483,8 @@ td.action img { cursor:default; } +.highlight { + background-color: yellow; +} + diff --git a/public/media/js/jquery.highlight-3.js b/public/media/js/jquery.highlight-3.js new file mode 100644 index 0000000..4d339ee --- /dev/null +++ b/public/media/js/jquery.highlight-3.js @@ -0,0 +1,53 @@ +/* + +highlight v3 + +Highlights arbitrary terms. + + + +MIT license. + +Johann Burkard + + + +*/ + +jQuery.fn.highlight = function(pat) { + function innerHighlight(node, pat) { + var skip = 0; + if (node.nodeType == 3) { + var pos = node.data.toUpperCase().indexOf(pat); + if (pos >= 0) { + var spannode = document.createElement('span'); + spannode.className = 'highlight'; + var middlebit = node.splitText(pos); + var endbit = middlebit.splitText(pat.length); + var middleclone = middlebit.cloneNode(true); + spannode.appendChild(middleclone); + middlebit.parentNode.replaceChild(spannode, middlebit); + skip = 1; + } + } + else if (node.nodeType == 1 && node.childNodes && !/(script|style)/i.test(node.tagName)) { + for (var i = 0; i < node.childNodes.length; ++i) { + i += innerHighlight(node.childNodes[i], pat); + } + } + return skip; + } + return this.each(function() { + innerHighlight(this, pat.toUpperCase()); + }); +}; + +jQuery.fn.removeHighlight = function() { + return this.find("span.highlight").each(function() { + this.parentNode.firstChild.nodeName; + with (this.parentNode) { + replaceChild(this.firstChild, this); + normalize(); + } + }).end(); +}; -- cgit v1.2.3-55-g7522 From 6511fb075385b9fc25ade2d4bd331e742193960e Mon Sep 17 00:00:00 2001 From: Simon Date: Mon, 4 Apr 2011 17:09:57 +0200 Subject: client-suche verändert --- .../modules/user/controllers/ClientController.php | 11 +++++----- .../modules/user/views/scripts/client/index.phtml | 23 +-------------------- library/Pbs/Search.php | 22 +++++++++++++++++++- public/media/css/style.css | 3 +++ public/media/img/search.png | Bin 0 -> 367 bytes 5 files changed, 31 insertions(+), 28 deletions(-) create mode 100644 public/media/img/search.png (limited to 'library') diff --git a/application/modules/user/controllers/ClientController.php b/application/modules/user/controllers/ClientController.php index acb6a65..c722a49 100644 --- a/application/modules/user/controllers/ClientController.php +++ b/application/modules/user/controllers/ClientController.php @@ -49,13 +49,14 @@ class User_ClientController extends Zend_Controller_Action $clientMapper = new Application_Model_ClientMapper(); $clientsInGroup = $clientMapper->findBy('groupID',$this->membership->getGroupID()); + // Search $search = $this->_request->getParam('search'); + $mySearch = new Pbs_Search(); + $mySearch->setSearchTerm($search); + $this->view->searchform = $mySearch->searchForm(); if($search != ''){ - $this->view->search = $search; - $mySearch = new Pbs_Search(); - $mySearch->setSearchTerm($search); - $clientsInGroup = $mySearch->search($clientsInGroup); - $this->view->searchterms = $mySearch->getSearchTerms(); + $this->view->search = $search; + $clientsInGroup = $mySearch->search($clientsInGroup); } // Pagination diff --git a/application/modules/user/views/scripts/client/index.phtml b/application/modules/user/views/scripts/client/index.phtml index ca78db1..5a75741 100644 --- a/application/modules/user/views/scripts/client/index.phtml +++ b/application/modules/user/views/scripts/client/index.phtml @@ -1,27 +1,6 @@

Clients

notification != ''){echo $this->notification;} ?> -
-search)?'value="'.$this->search.'"':'';?>> - -search)){ - ?> - Delete Client - - - - -
+searchform; ?> formButton('createbootos', 'Create Client', array( 'onclick' => 'self.location="/user/client/addclient/page/'.$this->page.'"', 'class' => 'addbutton'))?> diff --git a/library/Pbs/Search.php b/library/Pbs/Search.php index 7f6dfa7..e642d66 100644 --- a/library/Pbs/Search.php +++ b/library/Pbs/Search.php @@ -6,6 +6,25 @@ class Pbs_Search{ private $searcha; private $searchb; + public function searchForm(){ + $str = "
+ searchTerm != '')?'value="'.$this->searchTerm.'"':'')."> + "; + if($this->searchTerm != ''){ + $str .= "Delete Client + + "; + } + $str .= "
"; + return $str; + } + public function setSearchTerm($search){ $this->searchTerm = $search; @@ -62,7 +81,8 @@ class Pbs_Search{ } if (count($this->searcha) > 0 && count($this->searchb) > 0){ $data = array_intersect($com1,$com2); - } + } + $data = array_unique($data); foreach( $data as $c) $ges[] = $array[$c]; return $ges; diff --git a/public/media/css/style.css b/public/media/css/style.css index a521aeb..7238472 100644 --- a/public/media/css/style.css +++ b/public/media/css/style.css @@ -313,6 +313,9 @@ td { .addbutton:before { content: url(/media/img/create.png) ' '; } +.searchbutton:before { + content: url(/media/img/search.png) ' '; +} .rightbutton { float: right; diff --git a/public/media/img/search.png b/public/media/img/search.png new file mode 100644 index 0000000..6a0dd1d Binary files /dev/null and b/public/media/img/search.png differ -- cgit v1.2.3-55-g7522