Completed
Push — master ( 8f54cc...872df9 )
by Jean-Christophe
03:13
created
Ajax/common/html/BaseHtml.php 2 patches
Doc Comments   +14 added lines patch added patch discarded remove patch
@@ -63,6 +63,10 @@  discard block
 block discarded – undo
63 63
 
64 64
 
65 65
 
66
+	/**
67
+	 * @param string $name
68
+	 * @param string[] $typeCtrl
69
+	 */
66 70
 	protected function setMemberCtrl(&$name, $value, $typeCtrl) {
67 71
 		if ($this->ctrl($name, $value, $typeCtrl) === true) {
68 72
 			return $name=$value;
@@ -80,6 +84,10 @@  discard block
 block discarded – undo
80 84
 
81 85
 
82 86
 
87
+	/**
88
+	 * @param string $name
89
+	 * @param string[] $typeCtrl
90
+	 */
83 91
 	protected function addToMemberCtrl(&$name, $value, $typeCtrl, $separator=" ") {
84 92
 		if ($this->ctrl($name, $value, $typeCtrl) === true) {
85 93
 			if (\is_array($typeCtrl)) {
@@ -90,6 +98,9 @@  discard block
 block discarded – undo
90 98
 		return $this;
91 99
 	}
92 100
 
101
+	/**
102
+	 * @param string $name
103
+	 */
93 104
 	protected function addToMember(&$name, $value, $separator=" ") {
94 105
 		$name=str_ireplace($value, "", $name) . $separator . $value;
95 106
 		return $this;
@@ -102,6 +113,9 @@  discard block
 block discarded – undo
102 113
 		$oldValue=trim($oldValue);
103 114
 	}
104 115
 
116
+	/**
117
+	 * @param \Closure $callback
118
+	 */
105 119
 	protected function _getElementBy($callback,$elements){
106 120
 		if (\is_array($elements)) {
107 121
 			$elements=\array_values($elements);
Please login to merge, or discard this patch.
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -15,11 +15,11 @@  discard block
 block discarded – undo
15 15
  * @version 1.3
16 16
  */
17 17
 abstract class BaseHtml extends BaseWidget {
18
-	use BaseHtmlEventsTrait,BaseHtmlPropertiesTrait;
18
+	use BaseHtmlEventsTrait, BaseHtmlPropertiesTrait;
19 19
 	protected $_template;
20 20
 	protected $tagName;
21
-	protected $_wrapBefore=array ();
22
-	protected $_wrapAfter=array ();
21
+	protected $_wrapBefore=array();
22
+	protected $_wrapAfter=array();
23 23
 	protected $_bsComponent;
24 24
 	protected $_compiled=false;
25 25
 
@@ -30,14 +30,14 @@  discard block
 block discarded – undo
30 30
 	 */
31 31
 	abstract public function run(JsUtils $js);
32 32
 
33
-	private function _callSetter($setter,$key,$value,&$array){
33
+	private function _callSetter($setter, $key, $value, &$array) {
34 34
 		$result=false;
35 35
 		if (method_exists($this, $setter) && !JString::startswith($key, "_")) {
36 36
 			try {
37 37
 				$this->$setter($value);
38 38
 				unset($array[$key]);
39 39
 				$result=true;
40
-			} catch ( \Exception $e ) {
40
+			}catch (\Exception $e) {
41 41
 				$result=false;
42 42
 			}
43 43
 		}
@@ -45,17 +45,17 @@  discard block
 block discarded – undo
45 45
 	}
46 46
 
47 47
 	protected function getTemplate(JsUtils $js=NULL) {
48
-		return PropertyWrapper::wrap($this->_wrapBefore, $js) . $this->_template . PropertyWrapper::wrap($this->_wrapAfter, $js);
48
+		return PropertyWrapper::wrap($this->_wrapBefore, $js).$this->_template.PropertyWrapper::wrap($this->_wrapAfter, $js);
49 49
 	}
50 50
 
51 51
 	protected function ctrl($name, $value, $typeCtrl) {
52 52
 		if (\is_array($typeCtrl)) {
53
-			if (array_search($value, $typeCtrl) === false) {
54
-				throw new \Exception("La valeur passée `" . $value . "` à la propriété `" . $name . "` ne fait pas partie des valeurs possibles : {" . implode(",", $typeCtrl) . "}");
53
+			if (array_search($value, $typeCtrl)===false) {
54
+				throw new \Exception("La valeur passée `".$value."` à la propriété `".$name."` ne fait pas partie des valeurs possibles : {".implode(",", $typeCtrl)."}");
55 55
 			}
56 56
 		} else {
57 57
 			if (!$typeCtrl($value)) {
58
-				throw new \Exception("La fonction " . $typeCtrl . " a retourné faux pour l'affectation de la propriété " . $name);
58
+				throw new \Exception("La fonction ".$typeCtrl." a retourné faux pour l'affectation de la propriété ".$name);
59 59
 			}
60 60
 		}
61 61
 		return true;
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 
65 65
 
66 66
 	protected function setMemberCtrl(&$name, $value, $typeCtrl) {
67
-		if ($this->ctrl($name, $value, $typeCtrl) === true) {
67
+		if ($this->ctrl($name, $value, $typeCtrl)===true) {
68 68
 			return $name=$value;
69 69
 		}
70 70
 		return $this;
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 	protected function addToMemberUnique(&$name, $value, $typeCtrl, $separator=" ") {
74 74
 		if (\is_array($typeCtrl)) {
75 75
 			$this->removeOldValues($name, $typeCtrl);
76
-			$name.=$separator . $value;
76
+			$name.=$separator.$value;
77 77
 		}
78 78
 		return $this;
79 79
 	}
@@ -81,17 +81,17 @@  discard block
 block discarded – undo
81 81
 
82 82
 
83 83
 	protected function addToMemberCtrl(&$name, $value, $typeCtrl, $separator=" ") {
84
-		if ($this->ctrl($name, $value, $typeCtrl) === true) {
84
+		if ($this->ctrl($name, $value, $typeCtrl)===true) {
85 85
 			if (\is_array($typeCtrl)) {
86 86
 				$this->removeOldValues($name, $typeCtrl);
87 87
 			}
88
-			$name.=$separator . $value;
88
+			$name.=$separator.$value;
89 89
 		}
90 90
 		return $this;
91 91
 	}
92 92
 
93 93
 	protected function addToMember(&$name, $value, $separator=" ") {
94
-		$name=str_ireplace($value, "", $name) . $separator . $value;
94
+		$name=str_ireplace($value, "", $name).$separator.$value;
95 95
 		return $this;
96 96
 	}
97 97
 
@@ -102,18 +102,18 @@  discard block
 block discarded – undo
102 102
 		$oldValue=trim($oldValue);
103 103
 	}
104 104
 
105
-	protected function _getElementBy($callback,$elements){
105
+	protected function _getElementBy($callback, $elements) {
106 106
 		if (\is_array($elements)) {
107 107
 			$elements=\array_values($elements);
108 108
 			$flag=false;
109 109
 			$index=0;
110
-			while ( !$flag && $index < sizeof($elements) ) {
110
+			while (!$flag && $index<sizeof($elements)) {
111 111
 				if ($elements[$index] instanceof BaseHtml)
112 112
 					$flag=($callback($elements[$index]));
113 113
 					$index++;
114 114
 			}
115
-			if ($flag === true)
116
-				return $elements[$index - 1];
115
+			if ($flag===true)
116
+				return $elements[$index-1];
117 117
 		} elseif ($elements instanceof BaseHtml) {
118 118
 			if ($callback($elements))
119 119
 				return $elements;
@@ -141,13 +141,13 @@  discard block
 block discarded – undo
141 141
 	}
142 142
 
143 143
 	public function fromArray($array) {
144
-		foreach ( $this as $key => $value ) {
145
-			if(array_key_exists($key, $array)===true)
146
-				$this->_callSetter("set" . ucfirst($key), $key, $array[$key], $array);
144
+		foreach ($this as $key => $value) {
145
+			if (array_key_exists($key, $array)===true)
146
+				$this->_callSetter("set".ucfirst($key), $key, $array[$key], $array);
147 147
 		}
148
-		foreach ( $array as $key => $value ) {
149
-			if($this->_callSetter($key, $key, $value, $array)===false){
150
-				$this->_callSetter("set" . ucfirst($key), $key, $value, $array);
148
+		foreach ($array as $key => $value) {
149
+			if ($this->_callSetter($key, $key, $value, $array)===false) {
150
+				$this->_callSetter("set".ucfirst($key), $key, $value, $array);
151 151
 			}
152 152
 		}
153 153
 		return $array;
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 
156 156
 	public function fromDatabaseObjects($objects, $function) {
157 157
 		if (isset($objects)) {
158
-			foreach ( $objects as $object ) {
158
+			foreach ($objects as $object) {
159 159
 				$this->fromDatabaseObject($object, $function);
160 160
 			}
161 161
 		}
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 
177 177
 
178 178
 	public function getElementById($identifier, $elements) {
179
-		return $this->_getElementBy(function($element) use ($identifier){return $element->getIdentifier()===$identifier;}, $elements);
179
+		return $this->_getElementBy(function($element) use ($identifier){return $element->getIdentifier()===$identifier; }, $elements);
180 180
 	}
181 181
 
182 182
 	public function getBsComponent() {
@@ -191,24 +191,24 @@  discard block
 block discarded – undo
191 191
 	protected function compile_once(JsUtils $js=NULL, &$view=NULL) {
192 192
 	}
193 193
 	public function compile(JsUtils $js=NULL, &$view=NULL) {
194
-		if(!$this->_compiled){
195
-			$this->compile_once($js,$view);
194
+		if (!$this->_compiled) {
195
+			$this->compile_once($js, $view);
196 196
 			$this->_compiled=true;
197 197
 		}
198 198
 		$result=$this->getTemplate($js);
199
-		foreach ( $this as $key => $value ) {
200
-			if (JString::startswith($key, "_") === false && $key !== "events") {
199
+		foreach ($this as $key => $value) {
200
+			if (JString::startswith($key, "_")===false && $key!=="events") {
201 201
 				if (\is_array($value)) {
202 202
 					$v=PropertyWrapper::wrap($value, $js);
203 203
 				} else {
204 204
 					$v=$value;
205 205
 				}
206
-				$result=str_ireplace("%" . $key . "%", $v, $result);
206
+				$result=str_ireplace("%".$key."%", $v, $result);
207 207
 			}
208 208
 		}
209 209
 		if (isset($js)===true) {
210 210
 			$this->run($js);
211
-			if (isset($view) === true) {
211
+			if (isset($view)===true) {
212 212
 				$js->addViewElement($this->_identifier, $result, $view);
213 213
 			}
214 214
 		}
Please login to merge, or discard this patch.
Ajax/semantic/html/elements/HtmlButtonGroups.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -17,18 +17,18 @@  discard block
 block discarded – undo
17 17
 
18 18
 	public function __construct($identifier, $elements=array(), $asIcons=false) {
19 19
 		parent::__construct($identifier, "div", "ui buttons");
20
-		if ($asIcons === true)
20
+		if ($asIcons===true)
21 21
 			$this->asIcons();
22 22
 		$this->addElements($elements, $asIcons);
23 23
 	}
24
-	protected function createItem($value){
24
+	protected function createItem($value) {
25 25
 		return new HtmlButton("", $value);
26 26
 	}
27 27
 
28
-	public function addDropdown($items,$asCombo=false){
29
-		$dd= new HtmlDropdown("dd-".$this->identifier,null,$items);
28
+	public function addDropdown($items, $asCombo=false) {
29
+		$dd=new HtmlDropdown("dd-".$this->identifier, null, $items);
30 30
 		$dd->asButton();
31
-		if($asCombo){
31
+		if ($asCombo) {
32 32
 			$dd->setAction("combo");
33 33
 			$dd->addToProperty("class", "combo");
34 34
 		}
@@ -38,13 +38,13 @@  discard block
 block discarded – undo
38 38
 
39 39
 	public function addElement($element, $asIcon=false) {
40 40
 		$item=$this->addItem($element);
41
-		if($asIcon)
41
+		if ($asIcon)
42 42
 			$item->asIcon($element);
43 43
 		return $item;
44 44
 	}
45 45
 
46 46
 	public function addElements($elements, $asIcons=false) {
47
-		foreach ( $elements as $element ) {
47
+		foreach ($elements as $element) {
48 48
 			$this->addElement($element, $asIcons);
49 49
 		}
50 50
 		return $this;
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 	public function insertOr($aferIndex=0, $or="or") {
54 54
 		$orElement=new HtmlSemDoubleElement("", "div", "or");
55 55
 		$orElement->setProperty("data-text", $or);
56
-		array_splice($this->content, $aferIndex + 1, 0, array ($orElement ));
56
+		array_splice($this->content, $aferIndex+1, 0, array($orElement));
57 57
 		return $this;
58 58
 	}
59 59
 
@@ -66,8 +66,8 @@  discard block
 block discarded – undo
66 66
 	}
67 67
 
68 68
 	public function asIcons() {
69
-		foreach ( $this->content as $item ) {
70
-			if($item instanceof HtmlButton)
69
+		foreach ($this->content as $item) {
70
+			if ($item instanceof HtmlButton)
71 71
 			$item->asIcon($item->getContent());
72 72
 		}
73 73
 		return $this->addToProperty("class", "icons");
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
 	 * @see \Ajax\bootstrap\html\base\BaseHtml::on()
101 101
 	 */
102 102
 	public function on($event, $jsCode, $stopPropagation=false, $preventDefault=false) {
103
-		foreach ( $this->content as $element ) {
103
+		foreach ($this->content as $element) {
104 104
 			$element->on($event, $jsCode, $stopPropagation, $preventDefault);
105 105
 		}
106 106
 		return $this;
@@ -112,10 +112,10 @@  discard block
 block discarded – undo
112 112
 
113 113
 	public function addClasses($classes=array()) {
114 114
 		$i=0;
115
-		if(!\is_array($classes)){
116
-			$classes=array_fill (0,$this->count(),$classes);
115
+		if (!\is_array($classes)) {
116
+			$classes=array_fill(0, $this->count(), $classes);
117 117
 		}
118
-		foreach ( $this->content as $button ) {
118
+		foreach ($this->content as $button) {
119 119
 			$button->addToProperty("class", $classes[$i++]);
120 120
 		}
121 121
 		return $this;
@@ -129,8 +129,8 @@  discard block
 block discarded – undo
129 129
 		$this->addElement($function($object));
130 130
 	}
131 131
 
132
-	public function run(JsUtils $js){
133
-		$result= parent::run($js);
132
+	public function run(JsUtils $js) {
133
+		$result=parent::run($js);
134 134
 		return $result->setItemSelector(".ui.button");
135 135
 	}
136 136
 }
137 137
\ No newline at end of file
Please login to merge, or discard this patch.
Ajax/semantic/html/modules/HtmlDropdown.php 2 patches
Spacing   +83 added lines, -83 removed lines patch added patch discarded remove patch
@@ -13,24 +13,24 @@  discard block
 block discarded – undo
13 13
 use Ajax\semantic\html\collections\form\traits\FieldTrait;
14 14
 
15 15
 class HtmlDropdown extends HtmlSemDoubleElement {
16
-	use FieldTrait,LabeledIconTrait {
16
+	use FieldTrait, LabeledIconTrait {
17 17
 		addIcon as addIconP;
18 18
 	}
19 19
 	protected $mClass="menu";
20 20
 	protected $mTagName="div";
21
-	protected $items=array ();
22
-	protected $_params=array("action"=>"nothing","on"=>"hover");
21
+	protected $items=array();
22
+	protected $_params=array("action"=>"nothing", "on"=>"hover");
23 23
 	protected $input;
24 24
 	protected $value;
25 25
 	protected $_associative;
26 26
 
27
-	public function __construct($identifier, $value="", $items=array(),$associative=true) {
27
+	public function __construct($identifier, $value="", $items=array(), $associative=true) {
28 28
 		parent::__construct($identifier, "div");
29 29
 		$this->_template=include dirname(__FILE__).'/../templates/tplDropdown.php';
30 30
 		$this->setProperty("class", "ui dropdown");
31 31
 		$content=[];
32
-		if(isset($value)){
33
-			$text=new HtmlSemDoubleElement("text-".$this->identifier,"div");
32
+		if (isset($value)) {
33
+			$text=new HtmlSemDoubleElement("text-".$this->identifier, "div");
34 34
 			$text->setClass("text");
35 35
 			$content=[$text];
36 36
 			$this->setValue($value);
@@ -42,29 +42,29 @@  discard block
 block discarded – undo
42 42
 		$this->addItems($items);
43 43
 	}
44 44
 
45
-	public function getField(){
45
+	public function getField() {
46 46
 		return $this->input;
47 47
 	}
48 48
 
49
-	public function getDataField(){
49
+	public function getDataField() {
50 50
 		return $this->input;
51 51
 	}
52 52
 
53
-	public function addItem($item,$value=NULL,$image=NULL,$description=NULL){
54
-		$itemO=$this->beforeAddItem($item,$value,$image,$description);
53
+	public function addItem($item, $value=NULL, $image=NULL, $description=NULL) {
54
+		$itemO=$this->beforeAddItem($item, $value, $image, $description);
55 55
 		$this->items[]=$itemO;
56 56
 		return $itemO;
57 57
 	}
58 58
 
59
-	public function addIcon($icon,$before=true,$labeled=false){
59
+	public function addIcon($icon, $before=true, $labeled=false) {
60 60
 		$this->removeArrow();
61
-		$this->addIconP($icon,$before,$labeled);
61
+		$this->addIconP($icon, $before, $labeled);
62 62
 		return $this->getElementById("text-".$this->identifier, $this->content)->setWrapAfter("");
63 63
 	}
64 64
 
65
-	public function addIcons($icons){
65
+	public function addIcons($icons) {
66 66
 		$count=$this->count();
67
-		for ($i=0;$i<\sizeof($icons) && $i<$count;$i++){
67
+		for ($i=0; $i<\sizeof($icons) && $i<$count; $i++) {
68 68
 			$this->getItem($i)->addIcon($icons[$i]);
69 69
 		}
70 70
 	}
@@ -75,33 +75,33 @@  discard block
 block discarded – undo
75 75
 	 * @param number $position
76 76
 	 * @return \Ajax\semantic\html\content\HtmlDropdownItem|unknown
77 77
 	 */
78
-	public function insertItem($item,$position=0){
78
+	public function insertItem($item, $position=0) {
79 79
 		$itemO=$this->beforeAddItem($item);
80
-		 $start = array_slice($this->items, 0, $position);
81
-		 $end = array_slice($this->items, $position);
82
-		 $start[] = $item;
80
+		 $start=array_slice($this->items, 0, $position);
81
+		 $end=array_slice($this->items, $position);
82
+		 $start[]=$item;
83 83
 		 $this->items=array_merge($start, $end);
84 84
 		 return $itemO;
85 85
 	}
86 86
 
87
-	protected function removeArrow(){
88
-		if(\sizeof($this->content)>1){
87
+	protected function removeArrow() {
88
+		if (\sizeof($this->content)>1) {
89 89
 			unset($this->content["arrow"]);
90 90
 			$this->content=\array_values($this->content);
91 91
 		}
92 92
 	}
93 93
 
94
-	protected function beforeAddItem($item,$value=NULL,$image=NULL,$description=NULL){
94
+	protected function beforeAddItem($item, $value=NULL, $image=NULL, $description=NULL) {
95 95
 		$itemO=$item;
96
-		if(\is_array($item)){
96
+		if (\is_array($item)) {
97 97
 			$description=JArray::getValue($item, "description", 3);
98 98
 			$value=JArray::getValue($item, "value", 1);
99 99
 			$image=JArray::getValue($item, "image", 2);
100 100
 			$item=JArray::getValue($item, "item", 0);
101 101
 		}
102
-		if(!$item instanceof HtmlDropdownItem){
103
-			$itemO=new HtmlDropdownItem("dd-item-".$this->identifier."-".\sizeof($this->items),$item,$value,$image,$description);
104
-		}elseif($itemO instanceof HtmlDropdownItem){
102
+		if (!$item instanceof HtmlDropdownItem) {
103
+			$itemO=new HtmlDropdownItem("dd-item-".$this->identifier."-".\sizeof($this->items), $item, $value, $image, $description);
104
+		}elseif ($itemO instanceof HtmlDropdownItem) {
105 105
 			$this->addToProperty("class", "vertical");
106 106
 		}
107 107
 		return $itemO;
@@ -114,11 +114,11 @@  discard block
 block discarded – undo
114 114
 		$this->addItem($function($object));
115 115
 	}
116 116
 
117
-	public function addInput($name){
118
-		if(!isset($name))
117
+	public function addInput($name) {
118
+		if (!isset($name))
119 119
 			$name="input-".$this->identifier;
120 120
 		$this->setAction("activate");
121
-		$this->input=new HtmlInput($name,"hidden");
121
+		$this->input=new HtmlInput($name, "hidden");
122 122
 	}
123 123
 
124 124
 	/**
@@ -127,15 +127,15 @@  discard block
 block discarded – undo
127 127
 	 * @param string $icon
128 128
 	 * @return \Ajax\semantic\html\content\HtmlDropdownItem
129 129
 	 */
130
-	public function addSearchInputItem($placeHolder=NULL,$icon=NULL){
131
-		return $this->addItem(HtmlDropdownItem::searchInput($placeHolder,$icon));
130
+	public function addSearchInputItem($placeHolder=NULL, $icon=NULL) {
131
+		return $this->addItem(HtmlDropdownItem::searchInput($placeHolder, $icon));
132 132
 	}
133 133
 
134 134
 	/**
135 135
 	 * Adds a divider item
136 136
 	 * @return \Ajax\semantic\html\content\HtmlDropdownItem
137 137
 	 */
138
-	public function addDividerItem(){
138
+	public function addDividerItem() {
139 139
 		return $this->addItem(HtmlDropdownItem::divider());
140 140
 	}
141 141
 
@@ -145,8 +145,8 @@  discard block
 block discarded – undo
145 145
 	 * @param string $icon
146 146
 	 * @return \Ajax\semantic\html\content\HtmlDropdownItem|unknown
147 147
 	 */
148
-	public function addHeaderItem($caption=NULL,$icon=NULL){
149
-		return $this->addItem(HtmlDropdownItem::header($caption,$icon));
148
+	public function addHeaderItem($caption=NULL, $icon=NULL) {
149
+		return $this->addItem(HtmlDropdownItem::header($caption, $icon));
150 150
 	}
151 151
 
152 152
 	/**
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 	 * @param string $color
156 156
 	 * @return \Ajax\semantic\html\content\HtmlDropdownItem|unknown
157 157
 	 */
158
-	public function addCircularLabelItem($caption,$color){
158
+	public function addCircularLabelItem($caption, $color) {
159 159
 		return $this->addItem(HtmlDropdownItem::circular($caption, $color));
160 160
 	}
161 161
 
@@ -164,88 +164,88 @@  discard block
 block discarded – undo
164 164
 	 * @param string $image
165 165
 	 * @return \Ajax\semantic\html\content\HtmlDropdownItem
166 166
 	 */
167
-	public function addMiniAvatarImageItem($caption,$image){
167
+	public function addMiniAvatarImageItem($caption, $image) {
168 168
 		return $this->addItem(HtmlDropdownItem::avatar($caption, $image));
169 169
 	}
170 170
 
171
-	public function addItems($items){
172
-		if(\is_array($items) && $this->_associative){
173
-			foreach ($items as $k=>$v){
171
+	public function addItems($items) {
172
+		if (\is_array($items) && $this->_associative) {
173
+			foreach ($items as $k=>$v) {
174 174
 				$this->addItem($v)->setData($k);
175 175
 			}
176
-		}else{
177
-			foreach ($items as $item){
176
+		} else {
177
+			foreach ($items as $item) {
178 178
 				$this->addItem($item);
179 179
 			}
180 180
 		}
181 181
 	}
182 182
 
183
-	public function getItem($index){
183
+	public function getItem($index) {
184 184
 		return $this->items[$index];
185 185
 	}
186 186
 
187 187
 	/**
188 188
 	 * @return int
189 189
 	 */
190
-	public function count(){
190
+	public function count() {
191 191
 		return \sizeof($this->items);
192 192
 	}
193 193
 	/**
194 194
 	 * @param boolean $dropdown
195 195
 	 */
196
-	public function asDropdown($dropdown){
197
-		if($dropdown===false){
196
+	public function asDropdown($dropdown) {
197
+		if ($dropdown===false) {
198 198
 			$this->_template=include dirname(__FILE__).'/../templates/tplDropdownMenu.php';
199 199
 			$dropdown="menu";
200
-		}else{
200
+		} else {
201 201
 			$dropdown="dropdown";
202 202
 			$this->mClass="menu";
203 203
 		}
204
-		return $this->addToPropertyCtrl("class", $dropdown,array("menu","dropdown"));
204
+		return $this->addToPropertyCtrl("class", $dropdown, array("menu", "dropdown"));
205 205
 	}
206 206
 
207
-	public function setVertical(){
208
-		return $this->addToPropertyCtrl("class", "vertical",array("vertical"));
207
+	public function setVertical() {
208
+		return $this->addToPropertyCtrl("class", "vertical", array("vertical"));
209 209
 	}
210 210
 
211
-	public function setInline(){
212
-		return $this->addToPropertyCtrl("class", "inline",["inline"]);
211
+	public function setInline() {
212
+		return $this->addToPropertyCtrl("class", "inline", ["inline"]);
213 213
 	}
214 214
 
215
-	public function setSimple(){
216
-		return $this->addToPropertyCtrl("class", "simple",array("simple"));
215
+	public function setSimple() {
216
+		return $this->addToPropertyCtrl("class", "simple", array("simple"));
217 217
 	}
218 218
 
219
-	public function asButton($floating=false){
219
+	public function asButton($floating=false) {
220 220
 		$this->removeArrow();
221
-		if($floating)
221
+		if ($floating)
222 222
 			$this->addToProperty("class", "floating");
223 223
 		$this->removePropertyValue("class", "selection");
224 224
 		return $this->addToProperty("class", "button");
225 225
 	}
226 226
 
227
-	public function asSelect($name=NULL,$multiple=false,$selection=true){
228
-		if(isset($name))
227
+	public function asSelect($name=NULL, $multiple=false, $selection=true) {
228
+		if (isset($name))
229 229
 			$this->addInput($name);
230
-		if($multiple)
230
+		if ($multiple)
231 231
 			$this->addToProperty("class", "multiple");
232
-		if ($selection){
233
-			if($this->propertyContains("class", "button")===false)
234
-				$this->addToPropertyCtrl("class", "selection",array("selection"));
232
+		if ($selection) {
233
+			if ($this->propertyContains("class", "button")===false)
234
+				$this->addToPropertyCtrl("class", "selection", array("selection"));
235 235
 		}
236 236
 		return $this;
237 237
 	}
238 238
 
239
-	public function asSearch($name=NULL,$multiple=false,$selection=true){
240
-		$this->asSelect($name,$multiple,$selection);
239
+	public function asSearch($name=NULL, $multiple=false, $selection=true) {
240
+		$this->asSelect($name, $multiple, $selection);
241 241
 		return $this->addToProperty("class", "search");
242 242
 	}
243 243
 
244
-	public function setSelect($name=NULL,$multiple=false){
245
-		if(!isset($name))
244
+	public function setSelect($name=NULL, $multiple=false) {
245
+		if (!isset($name))
246 246
 			$name="select-".$this->identifier;
247 247
 		$this->input=null;
248
-		if($multiple){
248
+		if ($multiple) {
249 249
 			$this->setProperty("multiple", true);
250 250
 			$this->addToProperty("class", "multiple");
251 251
 		}
@@ -253,37 +253,37 @@  discard block
 block discarded – undo
253 253
 		$this->tagName="select";
254 254
 		$this->setProperty("name", $name);
255 255
 		$this->content=null;
256
-		foreach ($this->items as $item){
256
+		foreach ($this->items as $item) {
257 257
 			$item->asOption();
258 258
 		}
259 259
 		return $this;
260 260
 	}
261 261
 
262
-	public function asSubmenu($pointing=NULL){
262
+	public function asSubmenu($pointing=NULL) {
263 263
 		$this->setClass("ui dropdown link item");
264
-		if(isset($pointing)){
264
+		if (isset($pointing)) {
265 265
 			$this->setPointing($pointing);
266 266
 		}
267 267
 		return $this;
268 268
 	}
269 269
 
270
-	public function setPointing($value=Direction::NONE){
271
-		return $this->addToPropertyCtrl("class", $value." pointing",Direction::getConstantValues("pointing"));
270
+	public function setPointing($value=Direction::NONE) {
271
+		return $this->addToPropertyCtrl("class", $value." pointing", Direction::getConstantValues("pointing"));
272 272
 	}
273 273
 
274
-	public function setValue($value){
274
+	public function setValue($value) {
275 275
 		$this->value=$value;
276 276
 		return $this;
277 277
 	}
278
-	private function applyValue(){
278
+	private function applyValue() {
279 279
 		$value=$this->value;
280
-		if(isset($this->input) && isset($value)){
280
+		if (isset($this->input) && isset($value)) {
281 281
 			$this->input->setProperty("value", $value);
282
-		}else{
282
+		} else {
283 283
 			$this->setProperty("value", $value);
284 284
 		}
285 285
 			$textElement=$this->getElementById("text-".$this->identifier, $this->content);
286
-			if(isset($textElement))
286
+			if (isset($textElement))
287 287
 				$textElement->setContent($value);
288 288
 		return $this;
289 289
 	}
@@ -293,35 +293,35 @@  discard block
 block discarded – undo
293 293
 	 * @see BaseHtml::run()
294 294
 	 */
295 295
 	public function run(JsUtils $js) {
296
-		if($this->propertyContains("class", "simple")===false){
297
-			if(isset($this->_bsComponent)===false)
298
-				$this->_bsComponent=$js->semantic()->dropdown("#".$this->identifier,$this->_params);
296
+		if ($this->propertyContains("class", "simple")===false) {
297
+			if (isset($this->_bsComponent)===false)
298
+				$this->_bsComponent=$js->semantic()->dropdown("#".$this->identifier, $this->_params);
299 299
 			$this->addEventsOnRun($js);
300 300
 			return $this->_bsComponent;
301 301
 		}
302 302
 	}
303 303
 
304
-	public function setCompact(){
304
+	public function setCompact() {
305 305
 		return $this->addToPropertyCtrl("class", "compact", array("compact"));
306 306
 	}
307 307
 
308
-	public function setAction($action){
308
+	public function setAction($action) {
309 309
 		$this->_params["action"]=$action;
310 310
 	}
311 311
 
312
-	public function setFullTextSearch($value){
312
+	public function setFullTextSearch($value) {
313 313
 		$this->_params["fullTextSearch"]=$value;
314 314
 	}
315 315
 
316 316
 	public function compile(JsUtils $js=NULL, &$view=NULL) {
317 317
 		$this->applyValue();
318
-		return parent::compile($js,$view);
318
+		return parent::compile($js, $view);
319 319
 	}
320 320
 
321 321
 	public function getInput() {
322 322
 		return $this->input;
323 323
 	}
324 324
 	public function addAction($action, $direction=Direction::RIGHT, $icon=NULL, $labeled=false) {
325
-		return $this->_addAction($this, $action,$direction,$icon,$labeled);
325
+		return $this->_addAction($this, $action, $direction, $icon, $labeled);
326 326
 	}
327 327
 }
328 328
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +28 added lines, -20 removed lines patch added patch discarded remove patch
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 		}
102 102
 		if(!$item instanceof HtmlDropdownItem){
103 103
 			$itemO=new HtmlDropdownItem("dd-item-".$this->identifier."-".\sizeof($this->items),$item,$value,$image,$description);
104
-		}elseif($itemO instanceof HtmlDropdownItem){
104
+		} elseif($itemO instanceof HtmlDropdownItem){
105 105
 			$this->addToProperty("class", "vertical");
106 106
 		}
107 107
 		return $itemO;
@@ -115,8 +115,9 @@  discard block
 block discarded – undo
115 115
 	}
116 116
 
117 117
 	public function addInput($name){
118
-		if(!isset($name))
119
-			$name="input-".$this->identifier;
118
+		if(!isset($name)) {
119
+					$name="input-".$this->identifier;
120
+		}
120 121
 		$this->setAction("activate");
121 122
 		$this->input=new HtmlInput($name,"hidden");
122 123
 	}
@@ -173,7 +174,7 @@  discard block
 block discarded – undo
173 174
 			foreach ($items as $k=>$v){
174 175
 				$this->addItem($v)->setData($k);
175 176
 			}
176
-		}else{
177
+		} else{
177 178
 			foreach ($items as $item){
178 179
 				$this->addItem($item);
179 180
 			}
@@ -197,7 +198,7 @@  discard block
 block discarded – undo
197 198
 		if($dropdown===false){
198 199
 			$this->_template=include dirname(__FILE__).'/../templates/tplDropdownMenu.php';
199 200
 			$dropdown="menu";
200
-		}else{
201
+		} else{
201 202
 			$dropdown="dropdown";
202 203
 			$this->mClass="menu";
203 204
 		}
@@ -218,20 +219,24 @@  discard block
 block discarded – undo
218 219
 
219 220
 	public function asButton($floating=false){
220 221
 		$this->removeArrow();
221
-		if($floating)
222
-			$this->addToProperty("class", "floating");
222
+		if($floating) {
223
+					$this->addToProperty("class", "floating");
224
+		}
223 225
 		$this->removePropertyValue("class", "selection");
224 226
 		return $this->addToProperty("class", "button");
225 227
 	}
226 228
 
227 229
 	public function asSelect($name=NULL,$multiple=false,$selection=true){
228
-		if(isset($name))
229
-			$this->addInput($name);
230
-		if($multiple)
231
-			$this->addToProperty("class", "multiple");
230
+		if(isset($name)) {
231
+					$this->addInput($name);
232
+		}
233
+		if($multiple) {
234
+					$this->addToProperty("class", "multiple");
235
+		}
232 236
 		if ($selection){
233
-			if($this->propertyContains("class", "button")===false)
234
-				$this->addToPropertyCtrl("class", "selection",array("selection"));
237
+			if($this->propertyContains("class", "button")===false) {
238
+							$this->addToPropertyCtrl("class", "selection",array("selection"));
239
+			}
235 240
 		}
236 241
 		return $this;
237 242
 	}
@@ -242,8 +247,9 @@  discard block
 block discarded – undo
242 247
 	}
243 248
 
244 249
 	public function setSelect($name=NULL,$multiple=false){
245
-		if(!isset($name))
246
-			$name="select-".$this->identifier;
250
+		if(!isset($name)) {
251
+					$name="select-".$this->identifier;
252
+		}
247 253
 		$this->input=null;
248 254
 		if($multiple){
249 255
 			$this->setProperty("multiple", true);
@@ -279,12 +285,13 @@  discard block
 block discarded – undo
279 285
 		$value=$this->value;
280 286
 		if(isset($this->input) && isset($value)){
281 287
 			$this->input->setProperty("value", $value);
282
-		}else{
288
+		} else{
283 289
 			$this->setProperty("value", $value);
284 290
 		}
285 291
 			$textElement=$this->getElementById("text-".$this->identifier, $this->content);
286
-			if(isset($textElement))
287
-				$textElement->setContent($value);
292
+			if(isset($textElement)) {
293
+							$textElement->setContent($value);
294
+			}
288 295
 		return $this;
289 296
 	}
290 297
 
@@ -294,8 +301,9 @@  discard block
 block discarded – undo
294 301
 	 */
295 302
 	public function run(JsUtils $js) {
296 303
 		if($this->propertyContains("class", "simple")===false){
297
-			if(isset($this->_bsComponent)===false)
298
-				$this->_bsComponent=$js->semantic()->dropdown("#".$this->identifier,$this->_params);
304
+			if(isset($this->_bsComponent)===false) {
305
+							$this->_bsComponent=$js->semantic()->dropdown("#".$this->identifier,$this->_params);
306
+			}
299 307
 			$this->addEventsOnRun($js);
300 308
 			return $this->_bsComponent;
301 309
 		}
Please login to merge, or discard this patch.
Ajax/semantic/widgets/datatable/DataTable.php 2 patches
Spacing   +95 added lines, -95 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
  *
24 24
  */
25 25
 class DataTable extends Widget {
26
-	use TableTrait,DataTableFieldAsTrait,HasCheckboxesTrait;
26
+	use TableTrait, DataTableFieldAsTrait, HasCheckboxesTrait;
27 27
 	protected $_searchField;
28 28
 	protected $_urls;
29 29
 	protected $_pagination;
@@ -40,35 +40,35 @@  discard block
 block discarded – undo
40 40
 	protected $_hiddenColumns;
41 41
 
42 42
 
43
-	public function __construct($identifier,$model,$modelInstance=NULL) {
44
-		parent::__construct($identifier, $model,$modelInstance);
45
-		$this->_init(new InstanceViewer($identifier), "table", new HtmlTable($identifier, 0,0), false);
43
+	public function __construct($identifier, $model, $modelInstance=NULL) {
44
+		parent::__construct($identifier, $model, $modelInstance);
45
+		$this->_init(new InstanceViewer($identifier), "table", new HtmlTable($identifier, 0, 0), false);
46 46
 		$this->_urls=[];
47
-		$this->_emptyMessage=new HtmlMessage("","nothing to display");
47
+		$this->_emptyMessage=new HtmlMessage("", "nothing to display");
48 48
 		$this->_emptyMessage->setIcon("info circle");
49 49
 	}
50 50
 
51
-	public function run(JsUtils $js){
52
-		if($this->_hasCheckboxes && isset($js)){
51
+	public function run(JsUtils $js) {
52
+		if ($this->_hasCheckboxes && isset($js)) {
53 53
 			$this->_runCheckboxes($js);
54 54
 		}
55
-		if($this->_visibleHover){
56
-			$js->execOn("mouseover", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'visible');",["preventDefault"=>false,"stopPropagation"=>true]);
57
-			$js->execOn("mouseout", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'hidden');",["preventDefault"=>false,"stopPropagation"=>true]);
55
+		if ($this->_visibleHover) {
56
+			$js->execOn("mouseover", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'visible');", ["preventDefault"=>false, "stopPropagation"=>true]);
57
+			$js->execOn("mouseout", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'hidden');", ["preventDefault"=>false, "stopPropagation"=>true]);
58 58
 		}
59
-		if(\is_array($this->_deleteBehavior))
60
-			$this->_generateBehavior("delete",$this->_deleteBehavior, $js);
61
-		if(\is_array($this->_editBehavior))
62
-			$this->_generateBehavior("edit",$this->_editBehavior,$js);
59
+		if (\is_array($this->_deleteBehavior))
60
+			$this->_generateBehavior("delete", $this->_deleteBehavior, $js);
61
+		if (\is_array($this->_editBehavior))
62
+			$this->_generateBehavior("edit", $this->_editBehavior, $js);
63 63
 		return parent::run($js);
64 64
 	}
65 65
 
66 66
 
67 67
 
68
-	protected function _generateBehavior($op,$params,JsUtils $js){
69
-		if(isset($this->_urls[$op])){
70
-			$params=\array_merge($params,["attr"=>"data-ajax"]);
71
-			$js->getOnClick("#".$this->identifier." ._".$op, $this->_urls[$op],$this->getTargetSelector(),$params);
68
+	protected function _generateBehavior($op, $params, JsUtils $js) {
69
+		if (isset($this->_urls[$op])) {
70
+			$params=\array_merge($params, ["attr"=>"data-ajax"]);
71
+			$js->getOnClick("#".$this->identifier." ._".$op, $this->_urls[$op], $this->getTargetSelector(), $params);
72 72
 		}
73 73
 	}
74 74
 
@@ -81,149 +81,149 @@  discard block
 block discarded – undo
81 81
 	}
82 82
 
83 83
 
84
-	public function compile(JsUtils $js=NULL,&$view=NULL){
85
-		if(!$this->_generated){
84
+	public function compile(JsUtils $js=NULL, &$view=NULL) {
85
+		if (!$this->_generated) {
86 86
 			$this->_instanceViewer->setInstance($this->_model);
87 87
 			$captions=$this->_instanceViewer->getCaptions();
88 88
 
89 89
 			$table=$this->content["table"];
90 90
 
91
-			if($this->_hasCheckboxes){
91
+			if ($this->_hasCheckboxes) {
92 92
 				$this->_generateMainCheckbox($captions);
93 93
 			}
94 94
 
95 95
 			$table->setRowCount(0, \sizeof($captions));
96
-			$this->_generateHeader($table,$captions);
96
+			$this->_generateHeader($table, $captions);
97 97
 
98
-			if(isset($this->_compileParts))
98
+			if (isset($this->_compileParts))
99 99
 				$table->setCompileParts($this->_compileParts);
100 100
 
101
-			if(isset($this->_searchField) && isset($js)){
102
-				if(isset($this->_urls["refresh"]))
103
-					$this->_searchField->postOn("change", $this->_urls["refresh"],"{'s':$(this).val()}","#".$this->identifier." tbody",["preventDefault"=>false,"jqueryDone"=>"replaceWith"]);
101
+			if (isset($this->_searchField) && isset($js)) {
102
+				if (isset($this->_urls["refresh"]))
103
+					$this->_searchField->postOn("change", $this->_urls["refresh"], "{'s':$(this).val()}", "#".$this->identifier." tbody", ["preventDefault"=>false, "jqueryDone"=>"replaceWith"]);
104 104
 			}
105 105
 
106 106
 			$this->_generateContent($table);
107 107
 
108
-			if($this->_hasCheckboxes && $table->hasPart("thead")){
108
+			if ($this->_hasCheckboxes && $table->hasPart("thead")) {
109 109
 					$table->getHeader()->getCell(0, 0)->addClass("no-sort");
110 110
 			}
111 111
 
112
-			if(isset($this->_toolbar)){
112
+			if (isset($this->_toolbar)) {
113 113
 				$this->_setToolbarPosition($table, $captions);
114 114
 			}
115
-			if(isset($this->_pagination) && $this->_pagination->getVisible()){
116
-				$this->_generatePagination($table,$js);
115
+			if (isset($this->_pagination) && $this->_pagination->getVisible()) {
116
+				$this->_generatePagination($table, $js);
117 117
 			}
118 118
 
119
-			$this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE,"table",PositionInTable::AFTERTABLE]);
119
+			$this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE, "table", PositionInTable::AFTERTABLE]);
120 120
 			$this->_compileForm();
121
-			if(isset($this->_hiddenColumns))
121
+			if (isset($this->_hiddenColumns))
122 122
 				$this->_hideColumns();
123 123
 			$this->_generated=true;
124 124
 		}
125
-		return parent::compile($js,$view);
125
+		return parent::compile($js, $view);
126 126
 	}
127 127
 
128
-	protected function _hideColumns(){
128
+	protected function _hideColumns() {
129 129
 		$table=$this->getTable();
130
-		foreach ($this->_hiddenColumns as $colIndex){
130
+		foreach ($this->_hiddenColumns as $colIndex) {
131 131
 			$table->hideColumn($colIndex);
132 132
 		}
133 133
 		return $this;
134 134
 	}
135 135
 
136
-	protected function _generateHeader(HtmlTable $table,$captions){
136
+	protected function _generateHeader(HtmlTable $table, $captions) {
137 137
 		$table->setHeaderValues($captions);
138
-		if(isset($this->_sortable)){
138
+		if (isset($this->_sortable)) {
139 139
 			$table->setSortable($this->_sortable);
140 140
 		}
141 141
 	}
142 142
 
143 143
 
144 144
 
145
-	protected function _generateContent($table){
145
+	protected function _generateContent($table) {
146 146
 		$objects=$this->_modelInstance;
147
-		if(isset($this->_pagination)){
147
+		if (isset($this->_pagination)) {
148 148
 			$objects=$this->_pagination->getObjects($this->_modelInstance);
149 149
 		}
150 150
 			InstanceViewer::setIndex(0);
151 151
 			$table->fromDatabaseObjects($objects, function($instance) use($table){
152 152
 				return $this->_generateRow($instance, $table);
153 153
 			});
154
-		if($table->getRowCount()==0){
154
+		if ($table->getRowCount()==0) {
155 155
 			$result=$table->addRow();
156 156
 			$result->mergeRow();
157 157
 			$result->setValues([$this->_emptyMessage]);
158 158
 		}
159 159
 	}
160 160
 
161
-	protected function _generateRow($instance,&$table,$checkedClass=null){
161
+	protected function _generateRow($instance, &$table, $checkedClass=null) {
162 162
 		$this->_instanceViewer->setInstance($instance);
163 163
 		InstanceViewer::$index++;
164
-		$values= $this->_instanceViewer->getValues();
164
+		$values=$this->_instanceViewer->getValues();
165 165
 		$id=$this->_instanceViewer->getIdentifier();
166
-		if($this->_hasCheckboxes){
167
-			$ck=new HtmlCheckbox("ck-".$this->identifier."-".$id,"");
166
+		if ($this->_hasCheckboxes) {
167
+			$ck=new HtmlCheckbox("ck-".$this->identifier."-".$id, "");
168 168
 			$ck->setOnChange("event.stopPropagation();");
169 169
 			$field=$ck->getField();
170
-			$field->setProperty("value",$id);
170
+			$field->setProperty("value", $id);
171 171
 			$field->setProperty("name", "selection[]");
172
-			if(isset($checkedClass))
172
+			if (isset($checkedClass))
173 173
 				$field->setClass($checkedClass);
174 174
 			\array_unshift($values, $ck);
175 175
 		}
176 176
 		$result=$table->newRow();
177 177
 		$result->setIdentifier($this->identifier."-tr-".$id);
178
-		$result->setProperty("data-ajax",$id);
178
+		$result->setProperty("data-ajax", $id);
179 179
 		$result->setValues($values);
180
-		$result->addToProperty("class",$this->_rowClass);
180
+		$result->addToProperty("class", $this->_rowClass);
181 181
 		return $result;
182 182
 	}
183 183
 
184
-	protected function _generatePagination($table,$js=NULL){
185
-		if(isset($this->_toolbar)){
186
-			if($this->_toolbarPosition==PositionInTable::FOOTER)
184
+	protected function _generatePagination($table, $js=NULL) {
185
+		if (isset($this->_toolbar)) {
186
+			if ($this->_toolbarPosition==PositionInTable::FOOTER)
187 187
 				$this->_toolbar->setFloated("left");
188 188
 		}
189 189
 		$footer=$table->getFooter();
190 190
 		$footer->mergeCol();
191
-		$menu=new HtmlPaginationMenu("pagination-".$this->identifier,$this->_pagination->getPagesNumbers());
191
+		$menu=new HtmlPaginationMenu("pagination-".$this->identifier, $this->_pagination->getPagesNumbers());
192 192
 		$menu->floatRight();
193 193
 		$menu->setActiveItem($this->_pagination->getPage()-1);
194 194
 		$footer->addValues($menu);
195
-		$this->_associatePaginationBehavior($menu,$js);
195
+		$this->_associatePaginationBehavior($menu, $js);
196 196
 	}
197 197
 
198
-	protected function _associatePaginationBehavior(HtmlMenu $menu,JsUtils $js=NULL){
199
-		if(isset($this->_urls["refresh"])){
200
-			$menu->postOnClick($this->_urls["refresh"],"{'p':$(this).attr('data-page')}",$this->getRefreshSelector(),["preventDefault"=>false,"jqueryDone"=>"replaceWith"]);
198
+	protected function _associatePaginationBehavior(HtmlMenu $menu, JsUtils $js=NULL) {
199
+		if (isset($this->_urls["refresh"])) {
200
+			$menu->postOnClick($this->_urls["refresh"], "{'p':$(this).attr('data-page')}", $this->getRefreshSelector(), ["preventDefault"=>false, "jqueryDone"=>"replaceWith"]);
201 201
 		}
202 202
 	}
203 203
 
204
-	protected function _getFieldName($index){
204
+	protected function _getFieldName($index) {
205 205
 		$fieldName=parent::_getFieldName($index);
206
-		if(\is_object($fieldName))
206
+		if (\is_object($fieldName))
207 207
 			$fieldName="field-".$index;
208 208
 		return $fieldName."[]";
209 209
 	}
210 210
 
211
-	protected function _getFieldCaption($index){
211
+	protected function _getFieldCaption($index) {
212 212
 		return null;
213 213
 	}
214 214
 
215
-	protected function _setToolbarPosition($table,$captions=NULL){
216
-		switch ($this->_toolbarPosition){
215
+	protected function _setToolbarPosition($table, $captions=NULL) {
216
+		switch ($this->_toolbarPosition) {
217 217
 			case PositionInTable::BEFORETABLE:
218 218
 			case PositionInTable::AFTERTABLE:
219
-				if(isset($this->_compileParts)===false){
219
+				if (isset($this->_compileParts)===false) {
220 220
 					$this->content[$this->_toolbarPosition]=$this->_toolbar;
221 221
 				}
222 222
 				break;
223 223
 			case PositionInTable::HEADER:
224 224
 			case PositionInTable::FOOTER:
225 225
 			case PositionInTable::BODY:
226
-				$this->addToolbarRow($this->_toolbarPosition,$table, $captions);
226
+				$this->addToolbarRow($this->_toolbarPosition, $table, $captions);
227 227
 				break;
228 228
 		}
229 229
 	}
@@ -235,23 +235,23 @@  discard block
 block discarded – undo
235 235
 	 * @param callable $callback function called after the field compilation
236 236
 	 * @return DataTable
237 237
 	 */
238
-	public function afterCompile($index,$callback){
239
-		$this->_instanceViewer->afterCompile($index,$callback);
238
+	public function afterCompile($index, $callback) {
239
+		$this->_instanceViewer->afterCompile($index, $callback);
240 240
 		return $this;
241 241
 	}
242 242
 
243
-	private function addToolbarRow($part,$table,$captions){
243
+	private function addToolbarRow($part, $table, $captions) {
244 244
 		$hasPart=$table->hasPart($part);
245
-		if($hasPart){
245
+		if ($hasPart) {
246 246
 			$row=$table->getPart($part)->addRow(\sizeof($captions));
247
-		}else{
247
+		} else {
248 248
 			$row=$table->getPart($part)->getRow(0);
249 249
 		}
250 250
 		$row->mergeCol();
251 251
 		$row->setValues([$this->_toolbar]);
252 252
 	}
253 253
 
254
-	public function getHtmlComponent(){
254
+	public function getHtmlComponent() {
255 255
 		return $this->content["table"];
256 256
 	}
257 257
 
@@ -265,12 +265,12 @@  discard block
 block discarded – undo
265 265
 	 * @return DataTable
266 266
 	 */
267 267
 	public function setUrls($urls) {
268
-		if(\is_array($urls)){
269
-			$this->_urls["refresh"]=JArray::getValue($urls, "refresh",0);
270
-			$this->_urls["edit"]=JArray::getValue($urls, "edit",1);
271
-			$this->_urls["delete"]=JArray::getValue($urls, "delete",2);
272
-		}else{
273
-			$this->_urls=["refresh"=>$urls,"edit"=>$urls,"delete"=>$urls];
268
+		if (\is_array($urls)) {
269
+			$this->_urls["refresh"]=JArray::getValue($urls, "refresh", 0);
270
+			$this->_urls["edit"]=JArray::getValue($urls, "edit", 1);
271
+			$this->_urls["delete"]=JArray::getValue($urls, "delete", 2);
272
+		} else {
273
+			$this->_urls=["refresh"=>$urls, "edit"=>$urls, "delete"=>$urls];
274 274
 		}
275 275
 		return $this;
276 276
 	}
@@ -283,8 +283,8 @@  discard block
 block discarded – undo
283 283
 	 * @param number $pages_visibles The number of visible pages in the Pagination component
284 284
 	 * @return DataTable
285 285
 	 */
286
-	public function paginate($page,$total_rowcount,$items_per_page=10,$pages_visibles=null){
287
-		$this->_pagination=new Pagination($items_per_page,$pages_visibles,$page,$total_rowcount);
286
+	public function paginate($page, $total_rowcount, $items_per_page=10, $pages_visibles=null) {
287
+		$this->_pagination=new Pagination($items_per_page, $pages_visibles, $page, $total_rowcount);
288 288
 		return $this;
289 289
 	}
290 290
 
@@ -295,8 +295,8 @@  discard block
 block discarded – undo
295 295
 	 * @param number $pages_visibles The number of visible pages in the Pagination component
296 296
 	 * @return DataTable
297 297
 	 */
298
-	public function autoPaginate($page=1,$items_per_page=10,$pages_visibles=4){
299
-		$this->_pagination=new Pagination($items_per_page,$pages_visibles,$page);
298
+	public function autoPaginate($page=1, $items_per_page=10, $pages_visibles=4) {
299
+		$this->_pagination=new Pagination($items_per_page, $pages_visibles, $page);
300 300
 		return $this;
301 301
 	}
302 302
 
@@ -306,20 +306,20 @@  discard block
 block discarded – undo
306 306
 	 * @param array $compileParts
307 307
 	 * @return DataTable
308 308
 	 */
309
-	public function refresh($compileParts=["tbody"]){
309
+	public function refresh($compileParts=["tbody"]) {
310 310
 		$this->_compileParts=$compileParts;
311 311
 		return $this;
312 312
 	}
313 313
 
314 314
 
315
-	public function addSearchInToolbar($position=Direction::RIGHT){
315
+	public function addSearchInToolbar($position=Direction::RIGHT) {
316 316
 		return $this->addInToolbar($this->getSearchField())->setPosition($position);
317 317
 	}
318 318
 
319
-	public function getSearchField(){
320
-		if(isset($this->_searchField)===false){
321
-			$this->_searchField=new HtmlInput("search-".$this->identifier,"search","","Search...");
322
-			$this->_searchField->addIcon("search",Direction::RIGHT);
319
+	public function getSearchField() {
320
+		if (isset($this->_searchField)===false) {
321
+			$this->_searchField=new HtmlInput("search-".$this->identifier, "search", "", "Search...");
322
+			$this->_searchField->addIcon("search", Direction::RIGHT);
323 323
 		}
324 324
 		return $this->_searchField;
325 325
 	}
@@ -335,7 +335,7 @@  discard block
 block discarded – undo
335 335
 		return $this;
336 336
 	}
337 337
 
338
-	public function asForm(){
338
+	public function asForm() {
339 339
 		return $this->getForm();
340 340
 	}
341 341
 
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
 
344 344
 	protected function getTargetSelector() {
345 345
 		$result=$this->_targetSelector;
346
-		if(!isset($result))
346
+		if (!isset($result))
347 347
 			$result="#".$this->identifier;
348 348
 		return $result;
349 349
 	}
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
 	}
360 360
 
361 361
 	public function getRefreshSelector() {
362
-		if(isset($this->_refreshSelector))
362
+		if (isset($this->_refreshSelector))
363 363
 			return $this->_refreshSelector;
364 364
 		return "#".$this->identifier." tbody";
365 365
 	}
@@ -377,9 +377,9 @@  discard block
 block discarded – undo
377 377
 	 * {@inheritDoc}
378 378
 	 * @see \Ajax\common\Widget::show()
379 379
 	 */
380
-	public function show($modelInstance){
381
-		if(\is_array($modelInstance)){
382
-			if(\is_array(array_values($modelInstance)[0]))
380
+	public function show($modelInstance) {
381
+		if (\is_array($modelInstance)) {
382
+			if (\is_array(array_values($modelInstance)[0]))
383 383
 				$modelInstance=\json_decode(\json_encode($modelInstance), FALSE);
384 384
 		}
385 385
 		$this->_modelInstance=$modelInstance;
@@ -414,13 +414,13 @@  discard block
 block discarded – undo
414 414
 		return $this;
415 415
 	}
416 416
 
417
-	public function setActiveRowSelector($class="active",$event="click",$multiple=false){
418
-		$this->getTable()->setActiveRowSelector($class,$event,$multiple);
417
+	public function setActiveRowSelector($class="active", $event="click", $multiple=false) {
418
+		$this->getTable()->setActiveRowSelector($class, $event, $multiple);
419 419
 		return $this;
420 420
 	}
421 421
 
422
-	public function hideColumn($colIndex){
423
-		if(!\is_array($this->_hiddenColumns))
422
+	public function hideColumn($colIndex) {
423
+		if (!\is_array($this->_hiddenColumns))
424 424
 			$this->_hiddenColumns=[];
425 425
 		$this->_hiddenColumns[]=$colIndex;
426 426
 		return $this;
Please login to merge, or discard this patch.
Braces   +38 added lines, -26 removed lines patch added patch discarded remove patch
@@ -56,10 +56,12 @@  discard block
 block discarded – undo
56 56
 			$js->execOn("mouseover", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'visible');",["preventDefault"=>false,"stopPropagation"=>true]);
57 57
 			$js->execOn("mouseout", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'hidden');",["preventDefault"=>false,"stopPropagation"=>true]);
58 58
 		}
59
-		if(\is_array($this->_deleteBehavior))
60
-			$this->_generateBehavior("delete",$this->_deleteBehavior, $js);
61
-		if(\is_array($this->_editBehavior))
62
-			$this->_generateBehavior("edit",$this->_editBehavior,$js);
59
+		if(\is_array($this->_deleteBehavior)) {
60
+					$this->_generateBehavior("delete",$this->_deleteBehavior, $js);
61
+		}
62
+		if(\is_array($this->_editBehavior)) {
63
+					$this->_generateBehavior("edit",$this->_editBehavior,$js);
64
+		}
63 65
 		return parent::run($js);
64 66
 	}
65 67
 
@@ -95,12 +97,14 @@  discard block
 block discarded – undo
95 97
 			$table->setRowCount(0, \sizeof($captions));
96 98
 			$this->_generateHeader($table,$captions);
97 99
 
98
-			if(isset($this->_compileParts))
99
-				$table->setCompileParts($this->_compileParts);
100
+			if(isset($this->_compileParts)) {
101
+							$table->setCompileParts($this->_compileParts);
102
+			}
100 103
 
101 104
 			if(isset($this->_searchField) && isset($js)){
102
-				if(isset($this->_urls["refresh"]))
103
-					$this->_searchField->postOn("change", $this->_urls["refresh"],"{'s':$(this).val()}","#".$this->identifier." tbody",["preventDefault"=>false,"jqueryDone"=>"replaceWith"]);
105
+				if(isset($this->_urls["refresh"])) {
106
+									$this->_searchField->postOn("change", $this->_urls["refresh"],"{'s':$(this).val()}","#".$this->identifier." tbody",["preventDefault"=>false,"jqueryDone"=>"replaceWith"]);
107
+				}
104 108
 			}
105 109
 
106 110
 			$this->_generateContent($table);
@@ -118,8 +122,9 @@  discard block
 block discarded – undo
118 122
 
119 123
 			$this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE,"table",PositionInTable::AFTERTABLE]);
120 124
 			$this->_compileForm();
121
-			if(isset($this->_hiddenColumns))
122
-				$this->_hideColumns();
125
+			if(isset($this->_hiddenColumns)) {
126
+							$this->_hideColumns();
127
+			}
123 128
 			$this->_generated=true;
124 129
 		}
125 130
 		return parent::compile($js,$view);
@@ -169,8 +174,9 @@  discard block
 block discarded – undo
169 174
 			$field=$ck->getField();
170 175
 			$field->setProperty("value",$id);
171 176
 			$field->setProperty("name", "selection[]");
172
-			if(isset($checkedClass))
173
-				$field->setClass($checkedClass);
177
+			if(isset($checkedClass)) {
178
+							$field->setClass($checkedClass);
179
+			}
174 180
 			\array_unshift($values, $ck);
175 181
 		}
176 182
 		$result=$table->newRow();
@@ -183,8 +189,9 @@  discard block
 block discarded – undo
183 189
 
184 190
 	protected function _generatePagination($table,$js=NULL){
185 191
 		if(isset($this->_toolbar)){
186
-			if($this->_toolbarPosition==PositionInTable::FOOTER)
187
-				$this->_toolbar->setFloated("left");
192
+			if($this->_toolbarPosition==PositionInTable::FOOTER) {
193
+							$this->_toolbar->setFloated("left");
194
+			}
188 195
 		}
189 196
 		$footer=$table->getFooter();
190 197
 		$footer->mergeCol();
@@ -203,8 +210,9 @@  discard block
 block discarded – undo
203 210
 
204 211
 	protected function _getFieldName($index){
205 212
 		$fieldName=parent::_getFieldName($index);
206
-		if(\is_object($fieldName))
207
-			$fieldName="field-".$index;
213
+		if(\is_object($fieldName)) {
214
+					$fieldName="field-".$index;
215
+		}
208 216
 		return $fieldName."[]";
209 217
 	}
210 218
 
@@ -244,7 +252,7 @@  discard block
 block discarded – undo
244 252
 		$hasPart=$table->hasPart($part);
245 253
 		if($hasPart){
246 254
 			$row=$table->getPart($part)->addRow(\sizeof($captions));
247
-		}else{
255
+		} else{
248 256
 			$row=$table->getPart($part)->getRow(0);
249 257
 		}
250 258
 		$row->mergeCol();
@@ -269,7 +277,7 @@  discard block
 block discarded – undo
269 277
 			$this->_urls["refresh"]=JArray::getValue($urls, "refresh",0);
270 278
 			$this->_urls["edit"]=JArray::getValue($urls, "edit",1);
271 279
 			$this->_urls["delete"]=JArray::getValue($urls, "delete",2);
272
-		}else{
280
+		} else{
273 281
 			$this->_urls=["refresh"=>$urls,"edit"=>$urls,"delete"=>$urls];
274 282
 		}
275 283
 		return $this;
@@ -343,8 +351,9 @@  discard block
 block discarded – undo
343 351
 
344 352
 	protected function getTargetSelector() {
345 353
 		$result=$this->_targetSelector;
346
-		if(!isset($result))
347
-			$result="#".$this->identifier;
354
+		if(!isset($result)) {
355
+					$result="#".$this->identifier;
356
+		}
348 357
 		return $result;
349 358
 	}
350 359
 
@@ -359,8 +368,9 @@  discard block
 block discarded – undo
359 368
 	}
360 369
 
361 370
 	public function getRefreshSelector() {
362
-		if(isset($this->_refreshSelector))
363
-			return $this->_refreshSelector;
371
+		if(isset($this->_refreshSelector)) {
372
+					return $this->_refreshSelector;
373
+		}
364 374
 		return "#".$this->identifier." tbody";
365 375
 	}
366 376
 
@@ -379,8 +389,9 @@  discard block
 block discarded – undo
379 389
 	 */
380 390
 	public function show($modelInstance){
381 391
 		if(\is_array($modelInstance)){
382
-			if(\is_array(array_values($modelInstance)[0]))
383
-				$modelInstance=\json_decode(\json_encode($modelInstance), FALSE);
392
+			if(\is_array(array_values($modelInstance)[0])) {
393
+							$modelInstance=\json_decode(\json_encode($modelInstance), FALSE);
394
+			}
384 395
 		}
385 396
 		$this->_modelInstance=$modelInstance;
386 397
 	}
@@ -420,8 +431,9 @@  discard block
 block discarded – undo
420 431
 	}
421 432
 
422 433
 	public function hideColumn($colIndex){
423
-		if(!\is_array($this->_hiddenColumns))
424
-			$this->_hiddenColumns=[];
434
+		if(!\is_array($this->_hiddenColumns)) {
435
+					$this->_hiddenColumns=[];
436
+		}
425 437
 		$this->_hiddenColumns[]=$colIndex;
426 438
 		return $this;
427 439
 	}
Please login to merge, or discard this patch.