type == '') { $str .= "/user/".$this->module."/search"; } else { $str .= "/user/".$this->module."/search/type/".$this->type; } $str .= "'>
searchTerm != '') ? 'value="'.htmlentities($this->searchTerm, ENT_QUOTES).'"' : '')." />
"; $highlight = array(); if($this->searchTerm != '') { $str .= "Delete Client"; $str .= "
$this->countresult result".(($this->countresult == 1) ? '' : 's')." found
"; $str .= ""; foreach($this->getSearchTerms() as $term) { $highlight[] = "$('table').highlight('".$term."');"; $highlight[] = "$('.element .number').highlight('".$term."');"; $highlight[] = "$('.element .title').highlight('".$term."');"; $highlight[] = "$('.element .subtitle').highlight('".$term."');"; $highlight[] = "$('.element .item').highlight('".$term."');"; } } $str .= "
Display searchfilter
"; $str .= ""; $str .= ""; return $str; } public function setModule($m) { $this->module = $m; return $this; } public function setType($t) { $this->type = $t; return $this; } public function setSearchTerm($search) { $this->searchTerm = trim($search); // 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); 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; } } $this->searcha = @$searcha; $this->searchb = @$searchb; return $this; } public function getSearchTerm() { return $this->searchTerm; } public function getSearchTerms() { $beta = $this->searcha; foreach($this->searchb as $b) $beta[] = $b; return $beta; } public function search($array) { $this->countall = count($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) { if($k == $sk) { if(stristr($v, $sv) || $v == $sv) { $com1[$counter] += 1; } } } } if(count($this->searchb) >= 0) { foreach($this->searchb as $sk => $sv) { $comm = stristr($v, $sv); if($comm != false || $v == $sv) { $com2[$counter] += 1; } } } } #print_a($com2[$counter]." >= ".count($this->searchb)." && ".$com1[$counter]." >= ".count($this->searcha)); if($com2[$counter] >= count($this->searchb) && $com1[$counter] >= count($this->searcha)) { // add item in resultlist $data[] = $counter; } } foreach( $data as $c) $ges[] = $array[$c]; $this->countresult = count($ges); return $ges; } }