Completed
Push — master ( 735cac...641d44 )
by Jean-Christophe
04:20
created
Ajax/semantic/components/search/SearchCategories.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -6,25 +6,25 @@  discard block
 block discarded – undo
6 6
 	private $categories;
7 7
 
8 8
 	public function __construct() {
9
-		$this->categories=array ();
9
+		$this->categories=array();
10 10
 	}
11 11
 
12 12
 	public function add($results, $category) {
13 13
 		$count=\sizeof($this->categories);
14 14
 		if (\array_key_exists($category, $this->categories)) {
15 15
 			$this->categories[$category]->addResults($results);
16
-		} else {
17
-			$categoryO=new SearchCategory("category" . $count, $category, $results);
16
+		}else {
17
+			$categoryO=new SearchCategory("category".$count, $category, $results);
18 18
 			$this->categories[$category]=$categoryO;
19 19
 		}
20 20
 		return $this;
21 21
 	}
22 22
 
23 23
 	public function search($query, $field="title") {
24
-		$result=array ();
25
-		foreach ( $this->categories as $category ) {
24
+		$result=array();
25
+		foreach ($this->categories as $category) {
26 26
 			$r=$category->search($query, $field);
27
-			if ($r !== false)
27
+			if ($r!==false)
28 28
 				$result[]=$r;
29 29
 		}
30 30
 		$this->categories=$result;
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 	}
33 33
 
34 34
 	public function __toString() {
35
-		return "{\"results\":{" . \implode(",", \array_values($this->categories)) . "}}";
35
+		return "{\"results\":{".\implode(",", \array_values($this->categories))."}}";
36 36
 	}
37 37
 
38 38
 	public function getResponse() {
Please login to merge, or discard this patch.
Ajax/semantic/components/search/SearchResults.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -8,55 +8,55 @@  discard block
 block discarded – undo
8 8
 	private $elements;
9 9
 
10 10
 	public function __construct($objects=NULL) {
11
-		$this->elements=array ();
11
+		$this->elements=array();
12 12
 		if (isset($objects)) {
13 13
 			if (\is_array($objects)) {
14 14
 				$this->addResults($objects);
15
-			} else {
15
+			}else {
16 16
 				$this->addResult($objects);
17 17
 			}
18 18
 		}
19 19
 	}
20 20
 
21 21
 	public function addResult($object) {
22
-		if (\is_array($object) === false) {
23
-			$object=[ "title" => $object ];
22
+		if (\is_array($object)===false) {
23
+			$object=["title" => $object];
24 24
 		}
25 25
 		$this->elements[]=new SearchResult($object);
26 26
 		return $this;
27 27
 	}
28 28
 
29 29
 	public function addResults($objects) {
30
-		if (\is_array($objects) === false) {
30
+		if (\is_array($objects)===false) {
31 31
 			return $this->addResult($objects);
32 32
 		}
33
-		if (JArray::dimension($objects) === 1) {
34
-			foreach ( $objects as $object ) {
35
-				$this->addResult([ "title" => $object ]);
33
+		if (JArray::dimension($objects)===1) {
34
+			foreach ($objects as $object) {
35
+				$this->addResult(["title" => $object]);
36 36
 			}
37
-		} else
37
+		}else
38 38
 			$this->elements=\array_merge($this->elements, $objects);
39 39
 		return $this;
40 40
 	}
41 41
 
42 42
 	public function search($query, $field="title") {
43
-		$result=array ();
44
-		foreach ( $this->elements as $element ) {
43
+		$result=array();
44
+		foreach ($this->elements as $element) {
45 45
 			if (\array_key_exists($field, $element)) {
46 46
 				$value=$element[$field];
47
-				if (\stripos($value, $query) !== false) {
47
+				if (\stripos($value, $query)!==false) {
48 48
 					$result[]=$element;
49 49
 				}
50 50
 			}
51 51
 		}
52
-		if (\sizeof($result) > 0) {
52
+		if (\sizeof($result)>0) {
53 53
 			return $result;
54 54
 		}
55 55
 		return false;
56 56
 	}
57 57
 
58 58
 	public function __toString() {
59
-		$result="\"results\": " . \json_encode($this->elements);
59
+		$result="\"results\": ".\json_encode($this->elements);
60 60
 		return $result;
61 61
 	}
62 62
 
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 	}
66 66
 
67 67
 	public function getResponse() {
68
-		return "{" . $this . "}";
68
+		return "{".$this."}";
69 69
 	}
70 70
 
71 71
 	/**
Please login to merge, or discard this patch.
Ajax/semantic/components/search/AbstractSearchResult.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@
 block discarded – undo
6 6
 
7 7
 	public function fromDatabaseObjects($objects, $function) {
8 8
 		if (isset($objects)) {
9
-			foreach ( $objects as $object ) {
9
+			foreach ($objects as $object) {
10 10
 				$this->fromDatabaseObject($object, $function);
11 11
 			}
12 12
 		}
Please login to merge, or discard this patch.
Ajax/semantic/components/search/SearchResult.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 	public function __construct($id=NULL, $title=NULL, $description=NULL, $image=NULL, $price=NULL) {
13 13
 		if (\is_array($id)) {
14 14
 			$this->fromArray($id);
15
-		} else {
15
+		}else {
16 16
 			$this->id=$id;
17 17
 			$this->title=$title;
18 18
 			$this->description=$description;
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 	}
68 68
 
69 69
 	public function fromArray($array) {
70
-		foreach ( $array as $key => $value ) {
70
+		foreach ($array as $key => $value) {
71 71
 			$this->{$key}=$value;
72 72
 		}
73 73
 		return $this;
@@ -75,8 +75,8 @@  discard block
 block discarded – undo
75 75
 
76 76
 	public function JsonSerialize() {
77 77
 		$vars=get_object_vars($this);
78
-		$result=array ();
79
-		foreach ( $vars as $k => $v ) {
78
+		$result=array();
79
+		foreach ($vars as $k => $v) {
80 80
 			if (isset($v))
81 81
 				$result[$k]=$v;
82 82
 		}
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -77,8 +77,9 @@
 block discarded – undo
77 77
 		$vars=get_object_vars($this);
78 78
 		$result=array ();
79 79
 		foreach ( $vars as $k => $v ) {
80
-			if (isset($v))
81
-				$result[$k]=$v;
80
+			if (isset($v)) {
81
+							$result[$k]=$v;
82
+			}
82 83
 		}
83 84
 		return $result;
84 85
 	}
Please login to merge, or discard this patch.
Ajax/semantic/html/modules/HtmlSearch.php 2 patches
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -8,13 +8,13 @@  discard block
 block discarded – undo
8 8
 use Ajax\semantic\html\base\constants\Direction;
9 9
 
10 10
 class HtmlSearch extends HtmlSemDoubleElement {
11
-	private $_elements=array ();
12
-	private $_params=array ();
13
-	private $_searchFields=array ("title" );
11
+	private $_elements=array();
12
+	private $_params=array();
13
+	private $_searchFields=array("title");
14 14
 	private $_local=false;
15 15
 
16 16
 	public function __construct($identifier, $placeholder=NULL, $icon=NULL) {
17
-		parent::__construct("search-" . $identifier, "div", "ui search", array ());
17
+		parent::__construct("search-".$identifier, "div", "ui search", array());
18 18
 		$this->createField($placeholder, $icon);
19 19
 		$this->createResult();
20 20
 		$this->_params["type"]="standard";
@@ -22,9 +22,9 @@  discard block
 block discarded – undo
22 22
 
23 23
 	private function createField($placeholder=NULL, $icon=NULL) {
24 24
 		$field=new HtmlInput($this->identifier);
25
-		if (isset($placeholder) === true)
25
+		if (isset($placeholder)===true)
26 26
 			$field->setPlaceholder($placeholder);
27
-		if (isset($icon) === true)
27
+		if (isset($icon)===true)
28 28
 			$field->addIcon($icon, Direction::RIGHT);
29 29
 		$field->getField()->setClass("prompt");
30 30
 		$this->content["field"]=$field;
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 	}
33 33
 
34 34
 	private function createResult() {
35
-		$this->content["result"]=new HtmlSemDoubleElement("results-" . $this->identifier, "div", "results");
35
+		$this->content["result"]=new HtmlSemDoubleElement("results-".$this->identifier, "div", "results");
36 36
 		return $this->content["result"];
37 37
 	}
38 38
 
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 	}
50 50
 
51 51
 	public function setUrl($url) {
52
-		$this->_params["apiSettings"]="%{url: %quote%" . $url . "%quote%}%";
52
+		$this->_params["apiSettings"]="%{url: %quote%".$url."%quote%}%";
53 53
 		return $this;
54 54
 	}
55 55
 
@@ -74,13 +74,13 @@  discard block
 block discarded – undo
74 74
 	public function run(JsUtils $js) {
75 75
 		$searchFields=\json_encode($this->_searchFields);
76 76
 		$searchFields=str_ireplace("\"", "%quote%", $searchFields);
77
-		$this->_params["searchFields"]="%" . $searchFields . "%";
78
-		if ($this->_local === true) {
77
+		$this->_params["searchFields"]="%".$searchFields."%";
78
+		if ($this->_local===true) {
79 79
 			$this->_params["source"]="%content%";
80
-			$this->addEvent("beforeExecute", "var content=" . $this->resultsToJson() . ";");
80
+			$this->addEvent("beforeExecute", "var content=".$this->resultsToJson().";");
81 81
 		}
82
-		if (isset($this->_bsComponent) === false) {
83
-			$this->_bsComponent=$js->semantic()->search("#" . $this->identifier, $this->_params);
82
+		if (isset($this->_bsComponent)===false) {
83
+			$this->_bsComponent=$js->semantic()->search("#".$this->identifier, $this->_params);
84 84
 		}
85 85
 		$this->addEventsOnRun($js);
86 86
 		return $this->_bsComponent;
Please login to merge, or discard this patch.
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -22,10 +22,12 @@
 block discarded – undo
22 22
 
23 23
 	private function createField($placeholder=NULL, $icon=NULL) {
24 24
 		$field=new HtmlInput($this->identifier);
25
-		if (isset($placeholder) === true)
26
-			$field->setPlaceholder($placeholder);
27
-		if (isset($icon) === true)
28
-			$field->addIcon($icon, Direction::RIGHT);
25
+		if (isset($placeholder) === true) {
26
+					$field->setPlaceholder($placeholder);
27
+		}
28
+		if (isset($icon) === true) {
29
+					$field->addIcon($icon, Direction::RIGHT);
30
+		}
29 31
 		$field->getField()->setClass("prompt");
30 32
 		$this->content["field"]=$field;
31 33
 		return $field;
Please login to merge, or discard this patch.