diff options
author | Simon | 2011-04-05 13:17:31 +0200 |
---|---|---|
committer | Simon | 2011-04-05 13:17:31 +0200 |
commit | 5f6c99a519cb14e5d67dab562c786a8bc10109f2 (patch) | |
tree | c63197576c83bb07c12858a91ac2d066540daf10 | |
parent | Merge branch 'master' of openslx.org:lsfks/master-teamprojekt/pbs2 (diff) | |
download | pbs2-5f6c99a519cb14e5d67dab562c786a8bc10109f2.tar.gz pbs2-5f6c99a519cb14e5d67dab562c786a8bc10109f2.tar.xz pbs2-5f6c99a519cb14e5d67dab562c786a8bc10109f2.zip |
Suche mit "text 1" möglich
-rw-r--r-- | library/Pbs/Search.php | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/library/Pbs/Search.php b/library/Pbs/Search.php index 46f4021..138ebcf 100644 --- a/library/Pbs/Search.php +++ b/library/Pbs/Search.php @@ -9,7 +9,7 @@ class Pbs_Search{ public function searchForm(){ $str = "<form style='float:left;' action='/user/".$this->module."/search'> - <input type='text' id='search' name='search' ".(($this->searchTerm != '')?'value="'.$this->searchTerm.'"':'')."> + <input type='text' id='search' name='search' ".(($this->searchTerm != '')?'value="'.htmlentities($this->searchTerm, ENT_QUOTES).'"':'')."> <button type='submit' class='searchbutton' value='search'> Search</button>"; $highlight = array(); if($this->searchTerm != ''){ @@ -43,14 +43,27 @@ class Pbs_Search{ public function setSearchTerm($search){ $this->searchTerm = trim($search); - $parts = explode(" ",$this->searchTerm); + // search for "text" + preg_match_all("!\"(.*?)\"!is",$this->searchTerm,$matches); + $tmpsearch = $this->searchTerm; + for($i=0;$i<=count($matches[0]);$i++){ + $replace = str_replace(" ","<|>",$matches[0][$i]); + $tmpsearch = str_replace($matches[0][$i],$replace,$tmpsearch); + } + $parts = explode(" ",$tmpsearch); 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); + $value = substr($search,strpos($search,":")+1); + if(stristr($value,'"')){ + $value = substr(str_replace('<|>',' ',$value),1,-1); + } $searcha[$key] = $value; } else{ + if(stristr($search,'"')){ + $search = substr(str_replace('<|>',' ',$search),1,-1); + } $searchb[] = $search; } } |