summaryrefslogtreecommitdiffstats
path: root/library
diff options
context:
space:
mode:
authorBjörn Geiger2011-04-05 13:44:30 +0200
committerBjörn Geiger2011-04-05 13:44:30 +0200
commit699bf86b8098eb4d0b2b847ddd692057b11fd7fb (patch)
tree661fed9f69726d43e59e18aea5b02f94d7f23534 /library
parentRights im Personen Controller eingeführt, verwalten von anderen Accounts nun... (diff)
parentMerge branch 'master' of openslx.org:lsfks/master-teamprojekt/pbs2 (diff)
downloadpbs2-699bf86b8098eb4d0b2b847ddd692057b11fd7fb.tar.gz
pbs2-699bf86b8098eb4d0b2b847ddd692057b11fd7fb.tar.xz
pbs2-699bf86b8098eb4d0b2b847ddd692057b11fd7fb.zip
Merge branch 'master' of ssh://git.openslx.org/lsfks/master-teamprojekt/pbs2
Diffstat (limited to 'library')
-rw-r--r--library/Pbs/Search.php53
1 files changed, 30 insertions, 23 deletions
diff --git a/library/Pbs/Search.php b/library/Pbs/Search.php
index c06f519..46f4021 100644
--- a/library/Pbs/Search.php
+++ b/library/Pbs/Search.php
@@ -5,14 +5,15 @@ class Pbs_Search{
private $searchTerm = '';
private $searcha;
private $searchb;
+ private $module;
public function searchForm(){
- $str = "<form style='text-align:right;' action='/user/client/search'>
+ $str = "<form style='float:left;' action='/user/".$this->module."/search'>
<input type='text' id='search' name='search' ".(($this->searchTerm != '')?'value="'.$this->searchTerm.'"':'').">
<button type='submit' class='searchbutton' value='search'> Search</button>";
$highlight = array();
if($this->searchTerm != ''){
- $str .= "<a href='/user/client/'><img src='/media/img/delete.png' alt='Delete Client'/></a>
+ $str .= "<a href='/user/".$this->module."/'><img src='/media/img/delete.png' alt='Delete Client'/></a>
<script type='text/javascript' src='/media/js/jquery.highlight-3.js'></script>";
foreach($this->getSearchTerms() as $term){
$highlight[] = "$('table').highlight('".$term."');";
@@ -23,29 +24,28 @@ class Pbs_Search{
$(document).ready(function(){";
$str .= implode("\n",$highlight);
$str .= "$('#search')
- .focus(function() {
- $('table tr .code').show();
- }).focusout(function() {
- $('table tr .code').css('verticalAlign','-2px').animate({
- opacity: 0,
- width:0
- }, 1000, function() {
- $(this).attr({'style': 'display:none'});
- });
-
- });";
+ .focus(function() {
+ $('table th .code').show();
+ }).focusout(function() {
+ $('table th .code').hide();
+ });
+ $('table th').click(function(){
+ $('#search').val($('#search').val()+' '+$(this).find('.code').text()+':');
+ });";
$str .= "});
</script>";
$str .= "</form>";
return $str;
}
-
+ public function setModule($m){
+ $this->module = $m;
+ }
public function setSearchTerm($search){
- $this->searchTerm = $search;
+ $this->searchTerm = trim($search);
- $parts = explode(" ",$search);
- foreach($parts as $search){
- if(stristr($search,":") && ctype_alpha(substr($search,0,strpos($search,":")))){
+ $parts = explode(" ",$this->searchTerm);
+ foreach($parts as $search){
+ if(stristr($search,":") && preg_match('/^[a-z_A-Z]+$/',$search) >= 0){
$key = substr($search,0,strpos($search,":"));
$value = substr($search,strpos($search,":")+1);
$searcha[$key] = $value;
@@ -56,17 +56,23 @@ class Pbs_Search{
}
$this->searcha = $searcha;
$this->searchb = $searchb;
+ #print_a($searcha,$searchb);
+ }
+ public function getSearchTerm(){
+ return $this->searchTerm;
}
-
public function getSearchTerms(){
$beta = $this->searcha;
foreach($this->searchb as $b)
$beta[] = $b;
- return $beta;
+ return $beta;
}
public function search($array){
foreach($array as $counter => $cig){
+ if(is_object($cig)){
+ $cig = $cig->toArray();
+ }
foreach($cig as $k => $v){
if(count($this->searcha) > 0){
foreach($this->searcha as $sk => $sv){
@@ -86,7 +92,8 @@ class Pbs_Search{
}
}
}
- }
+ }
+
}
if (count($this->searcha) == 0){
$data = $com2;
@@ -96,8 +103,8 @@ class Pbs_Search{
}
if (count($this->searcha) > 0 && count($this->searchb) > 0){
$data = array_intersect($com1,$com2);
- }
- $data = array_unique($data);
+ }
+ $data = array_unique($data);
foreach( $data as $c)
$ges[] = $array[$c];
return $ges;