phpMv -UI toolkit 2.4.12
jQuery, jQuery UI, Twitter Bootstrap and Semantic-UI library for php & php MVC Frameworks
Loading...
Searching...
No Matches
SearchCategory.php
Go to the documentation of this file.
1<?php
2
4
5class SearchCategory implements ISearch {
6 private $id;
7 private $name;
8 private $results;
9
10 public function __construct($id, $name, $results=NULL) {
11 $this->results=new SearchResults($results);
12 $this->id=$id;
13 $this->name=$name;
14 }
15
16 public function addResult($object) {
17 $this->results->addResult($object);
18 return $this;
19 }
20
21 public function addResults($objects) {
22 $this->results->addResults($objects);
23 return $this;
24 }
25
26 public function __toString() {
27 $result="\"" . $this->id . "\": { \"name\": \"" . $this->name . "\"," . $this->results . "}";
28 return $result;
29 }
30
31 public function getId() {
32 return $this->id;
33 }
34
35 public function setId($id) {
36 $this->id=$id;
37 return $this;
38 }
39
40 public function getName() {
41 return $this->name;
42 }
43
44 public function setName($name) {
45 $this->name=$name;
46 return $this;
47 }
48
49 public function getResults() {
50 return $this->results;
51 }
52
53 public function setResults($results) {
54 $this->results=$results;
55 return $this;
56 }
57
58 public function search($query, $field="title") {
59 $result=$this->results->_search($query, $field);
60 if ($result !== false) {
61 return new SearchCategory($this->id, $this->name, $result);
62 }
63 return false;
64 }
65
66 public function getResponse() {
67 return $this->__toString();
68 }
69}