summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon2011-04-04 16:33:59 +0200
committerSimon2011-04-04 16:33:59 +0200
commite5e65c03c4d1879c4cf4ef5e0f77a80e7eb73ece (patch)
treeb5e094bd07a9b783e6b8e4418997be0458af74e0
parentleerzeichen in kcl entfernt (diff)
downloadpbs2-e5e65c03c4d1879c4cf4ef5e0f77a80e7eb73ece.tar.gz
pbs2-e5e65c03c4d1879c4cf4ef5e0f77a80e7eb73ece.tar.xz
pbs2-e5e65c03c4d1879c4cf4ef5e0f77a80e7eb73ece.zip
highlight für suche eingebaut
-rw-r--r--application/modules/user/controllers/ClientController.php4
-rw-r--r--application/modules/user/views/scripts/client/index.phtml15
-rw-r--r--library/Pbs/Search.php33
-rw-r--r--public/media/css/style.css7
-rw-r--r--public/media/js/jquery.highlight-3.js53
5 files changed, 103 insertions, 9 deletions
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 @@
<input type='submit' value='search'>
<?php
if(isset($this->search)){
- echo "<a href='/user/client/'><img src='/media/img/delete.png' alt='Delete Client'/></a>";
+ ?>
+ <a href='/user/client/'><img src='/media/img/delete.png' alt='Delete Client'/></a>
+ <script type='text/javascript' src='/media/js/jquery.highlight-3.js'></script>
+ <script>
+ $(document).ready(function(){
+ <?php foreach($this->searchterms as $term){?>
+ $('table').highlight('<?php echo $term;?>');
+ <?php
+ }
+ ?>
+ });
+ </script>
+
+ <?php
}
?>
</form>
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 @@
<?php
class Pbs_Search{
- public function search($array, $search){
+
+ private $searchTerm = '';
+ private $searcha;
+ private $searchb;
+
+ public function setSearchTerm($search){
+ $this->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.
+
+<http://johannburkard.de/blog/programming/javascript/highlight-javascript-text-higlighting-jquery-plugin.html>
+
+MIT license.
+
+Johann Burkard
+<http://johannburkard.de>
+<mailto:jb@eaio.com>
+
+*/
+
+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();
+};