Completed
Push — master ( 22ba15...552305 )
by Jean-Christophe
03:10
created
Ajax/semantic/widgets/dataform/FormFieldAsTrait.php 3 patches
Braces   +8 added lines, -6 removed lines patch added patch discarded remove patch
@@ -43,10 +43,11 @@  discard block
 block discarded – undo
43 43
 	protected function _addRules($element,$attributes){
44 44
 		if(isset($attributes["rules"])){
45 45
 			$rules=$attributes["rules"];
46
-			if(\is_array($rules))
47
-				$element->addRules($rules);
48
-				else
49
-					$element->addRule($rules);
46
+			if(\is_array($rules)) {
47
+							$element->addRules($rules);
48
+			} else {
49
+									$element->addRule($rules);
50
+				}
50 51
 				unset($attributes["rules"]);
51 52
 		}
52 53
 	}
@@ -56,8 +57,9 @@  discard block
 block discarded – undo
56 57
 			$caption=$this->_instanceViewer->getCaption($index);
57 58
 			$name=$this->_instanceViewer->getFieldName($index);
58 59
 			$element=$elementCallback($name,$caption,$value);
59
-			if(\is_array($attributes))
60
-				$this->_applyAttributes($element, $attributes,$index);
60
+			if(\is_array($attributes)) {
61
+							$this->_applyAttributes($element, $attributes,$index);
62
+			}
61 63
 			return $element;
62 64
 		});
63 65
 			return $this;
Please login to merge, or discard this patch.
Doc Comments   +14 added lines patch added patch discarded remove patch
@@ -18,7 +18,14 @@  discard block
 block discarded – undo
18 18
 
19 19
 trait FormFieldAsTrait{
20 20
 
21
+	/**
22
+	 * @param string $prefix
23
+	 */
21 24
 	abstract protected function _getFieldIdentifier($prefix);
25
+
26
+	/**
27
+	 * @param \Closure $callback
28
+	 */
22 29
 	abstract public function setValueFunction($index,$callback);
23 30
 
24 31
 	private function _getLabelField($caption,$icon=NULL){
@@ -42,6 +49,9 @@  discard block
 block discarded – undo
42 49
 		$element->fromArray($attributes);
43 50
 	}
44 51
 
52
+	/**
53
+	 * @param HtmlFormField $element
54
+	 */
45 55
 	protected function _addRules($element,$attributes){
46 56
 		if(isset($attributes["rules"])){
47 57
 			$rules=$attributes["rules"];
@@ -53,6 +63,10 @@  discard block
 block discarded – undo
53 63
 		}
54 64
 	}
55 65
 
66
+	/**
67
+	 * @param \Closure $elementCallback
68
+	 * @param string $identifier
69
+	 */
56 70
 	protected function _fieldAs($elementCallback,$index,$attributes=NULL,$identifier=null){
57 71
 		$this->setValueFunction($index,function($value) use ($index,&$attributes,$elementCallback){
58 72
 			$caption=$this->_instanceViewer->getCaption($index);
Please login to merge, or discard this patch.
Spacing   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -16,13 +16,13 @@  discard block
 block discarded – undo
16 16
  * @property object $_modelInstance;
17 17
  */
18 18
 
19
-trait FormFieldAsTrait{
19
+trait FormFieldAsTrait {
20 20
 
21 21
 	abstract protected function _getFieldIdentifier($prefix);
22
-	abstract public function setValueFunction($index,$callback);
22
+	abstract public function setValueFunction($index, $callback);
23 23
 
24
-	private function _getLabelField($caption,$icon=NULL){
25
-		$label=new HtmlLabel($this->_getFieldIdentifier("lbl"),$caption,$icon);
24
+	private function _getLabelField($caption, $icon=NULL) {
25
+		$label=new HtmlLabel($this->_getFieldIdentifier("lbl"), $caption, $icon);
26 26
 		return $label;
27 27
 	}
28 28
 
@@ -30,22 +30,22 @@  discard block
 block discarded – undo
30 30
 	 * @param HtmlFormField $element
31 31
 	 * @param array $attributes
32 32
 	 */
33
-	protected function _applyAttributes($element,&$attributes,$index){
33
+	protected function _applyAttributes($element, &$attributes, $index) {
34 34
 		$this->_addRules($element, $attributes);
35
-		if(isset($attributes["callback"])){
35
+		if (isset($attributes["callback"])) {
36 36
 			$callback=$attributes["callback"];
37
-			if(\is_callable($callback)){
38
-				$callback($element,$this->_modelInstance,$index);
37
+			if (\is_callable($callback)) {
38
+				$callback($element, $this->_modelInstance, $index);
39 39
 				unset($attributes["callback"]);
40 40
 			}
41 41
 		}
42 42
 		$element->fromArray($attributes);
43 43
 	}
44 44
 
45
-	protected function _addRules($element,$attributes){
46
-		if(isset($attributes["rules"])){
45
+	protected function _addRules($element, $attributes) {
46
+		if (isset($attributes["rules"])) {
47 47
 			$rules=$attributes["rules"];
48
-			if(\is_array($rules))
48
+			if (\is_array($rules))
49 49
 				$element->addRules($rules);
50 50
 				else
51 51
 					$element->addRule($rules);
@@ -53,66 +53,66 @@  discard block
 block discarded – undo
53 53
 		}
54 54
 	}
55 55
 
56
-	protected function _fieldAs($elementCallback,$index,$attributes=NULL,$identifier=null){
57
-		$this->setValueFunction($index,function($value) use ($index,&$attributes,$elementCallback){
56
+	protected function _fieldAs($elementCallback, $index, $attributes=NULL, $identifier=null) {
57
+		$this->setValueFunction($index, function($value) use ($index, &$attributes, $elementCallback){
58 58
 			$caption=$this->_instanceViewer->getCaption($index);
59 59
 			$name=$this->_instanceViewer->getFieldName($index);
60
-			$element=$elementCallback($this->getIdentifier()."-".$name,$name,$value,$caption);
61
-			if(\is_array($attributes))
62
-				$this->_applyAttributes($element, $attributes,$index);
60
+			$element=$elementCallback($this->getIdentifier()."-".$name, $name, $value, $caption);
61
+			if (\is_array($attributes))
62
+				$this->_applyAttributes($element, $attributes, $index);
63 63
 			return $element;
64 64
 		});
65 65
 			return $this;
66 66
 	}
67 67
 
68 68
 
69
-	public function fieldAsRadio($index,$attributes=NULL){
70
-		return $this->_fieldAs(function($id,$name,$value,$caption){
71
-			return new HtmlFormRadio($id,$name,$caption,$value);
72
-		}, $index,$attributes);
69
+	public function fieldAsRadio($index, $attributes=NULL) {
70
+		return $this->_fieldAs(function($id, $name, $value, $caption) {
71
+			return new HtmlFormRadio($id, $name, $caption, $value);
72
+		}, $index, $attributes);
73 73
 	}
74 74
 
75
-	public function fieldAsRadios($index,$elements=[],$attributes=NULL){
76
-		return $this->_fieldAs(function($id,$name,$value,$caption,$elements){
77
-			return HtmlFormFields::radios($name,$elements,$caption,$value);
78
-		}, $index,$attributes);
75
+	public function fieldAsRadios($index, $elements=[], $attributes=NULL) {
76
+		return $this->_fieldAs(function($id, $name, $value, $caption, $elements) {
77
+			return HtmlFormFields::radios($name, $elements, $caption, $value);
78
+		}, $index, $attributes);
79 79
 	}
80 80
 
81
-	public function fieldAsTextarea($index,$attributes=NULL){
82
-		return $this->_fieldAs(function($id,$name,$value,$caption){
83
-			$textarea=new HtmlFormTextarea($id,$caption,$value);
81
+	public function fieldAsTextarea($index, $attributes=NULL) {
82
+		return $this->_fieldAs(function($id, $name, $value, $caption) {
83
+			$textarea=new HtmlFormTextarea($id, $caption, $value);
84 84
 			$textarea->setName($name);
85 85
 			return $textarea;
86
-		}, $index,$attributes);
86
+		}, $index, $attributes);
87 87
 	}
88 88
 
89
-	public function fieldAsInput($index,$attributes=NULL){
90
-		return $this->_fieldAs(function($id,$name,$value,$caption){
91
-			$input= new HtmlFormInput($id,$caption,"text",$value);
89
+	public function fieldAsInput($index, $attributes=NULL) {
90
+		return $this->_fieldAs(function($id, $name, $value, $caption) {
91
+			$input=new HtmlFormInput($id, $caption, "text", $value);
92 92
 			$input->setName($name);
93 93
 			return $input;
94
-		}, $index,$attributes);
94
+		}, $index, $attributes);
95 95
 	}
96 96
 
97
-	public function fieldAsCheckbox($index,$attributes=NULL){
98
-		return $this->_fieldAs(function($id,$name,$value,$caption){
99
-			return new HtmlFormCheckbox($id,$caption,$value);
100
-		}, $index,$attributes);
97
+	public function fieldAsCheckbox($index, $attributes=NULL) {
98
+		return $this->_fieldAs(function($id, $name, $value, $caption) {
99
+			return new HtmlFormCheckbox($id, $caption, $value);
100
+		}, $index, $attributes);
101 101
 	}
102 102
 
103
-	public function fieldAsDropDown($index,$elements=[],$multiple=false,$attributes=NULL){
104
-		return $this->_fieldAs(function($id,$name,$value,$caption) use ($elements,$multiple){
105
-			$dd=new HtmlFormDropdown($id,$elements,$caption,$value,$multiple);
103
+	public function fieldAsDropDown($index, $elements=[], $multiple=false, $attributes=NULL) {
104
+		return $this->_fieldAs(function($id, $name, $value, $caption) use ($elements, $multiple){
105
+			$dd=new HtmlFormDropdown($id, $elements, $caption, $value, $multiple);
106 106
 			$dd->setName($name);
107 107
 			return $dd;
108
-		}, $index,$attributes);
108
+		}, $index, $attributes);
109 109
 	}
110 110
 
111
-	public function fieldAsMessage($index,$attributes=NULL){
112
-		return $this->_fieldAs(function($id,$name,$value,$caption){
113
-			$mess= new HtmlMessage($id,$value);
111
+	public function fieldAsMessage($index, $attributes=NULL) {
112
+		return $this->_fieldAs(function($id, $name, $value, $caption) {
113
+			$mess=new HtmlMessage($id, $value);
114 114
 			$mess->addHeader($caption);
115 115
 			return $mess;
116
-		}, $index,$attributes,"message");
116
+		}, $index, $attributes, "message");
117 117
 	}
118 118
 }
119 119
\ No newline at end of file
Please login to merge, or discard this patch.
Ajax/semantic/html/collections/form/traits/FormTrait.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
 use Ajax\semantic\html\collections\HtmlMessage;
6 6
 use Ajax\service\AjaxCall;
7 7
 
8
-trait FormTrait{
8
+trait FormTrait {
9 9
 	/**
10 10
 	 * @return HtmlForm
11 11
 	 */
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 		return $this->getForm()->addToProperty("class", "loading");
16 16
 	}
17 17
 
18
-	public function addErrorMessage(){
18
+	public function addErrorMessage() {
19 19
 		return $this->getForm()->addContent((new HtmlMessage(""))->setError());
20 20
 	}
21 21
 
@@ -30,35 +30,35 @@  discard block
 block discarded – undo
30 30
 	 * @param string $responseElement
31 31
 	 * @return \Ajax\semantic\html\collections\form\HtmlForm
32 32
 	 */
33
-	public function submitOn($event,$identifier,$url,$responseElement){
33
+	public function submitOn($event, $identifier, $url, $responseElement) {
34 34
 		$form=$this->getForm();
35 35
 		$elem=$form->getElementById($identifier, $form->getContent());
36
-		if(isset($elem)){
37
-			$this->_buttonAsSubmit($elem, $event,$url,$responseElement);
36
+		if (isset($elem)) {
37
+			$this->_buttonAsSubmit($elem, $event, $url, $responseElement);
38 38
 		}
39 39
 		return $form;
40 40
 	}
41 41
 
42
-	public function submitOnClick($identifier,$url,$responseElement){
42
+	public function submitOnClick($identifier, $url, $responseElement) {
43 43
 		return $this->submitOn("click", $identifier, $url, $responseElement);
44 44
 	}
45 45
 
46
-	public function addSubmit($identifier,$value,$cssStyle=NULL,$url=NULL,$responseElement=NULL){
47
-		$bt=$this->getForm()->addButton($identifier, $value,$cssStyle);
48
-		return $this->_buttonAsSubmit($bt, "click",$url,$responseElement);
46
+	public function addSubmit($identifier, $value, $cssStyle=NULL, $url=NULL, $responseElement=NULL) {
47
+		$bt=$this->getForm()->addButton($identifier, $value, $cssStyle);
48
+		return $this->_buttonAsSubmit($bt, "click", $url, $responseElement);
49 49
 	}
50 50
 
51
-	protected function _buttonAsSubmit($button,$event,$url,$responseElement=NULL){
51
+	protected function _buttonAsSubmit($button, $event, $url, $responseElement=NULL) {
52 52
 		$form=$this->getForm();
53
-		if(isset($url) && isset($responseElement)){
53
+		if (isset($url) && isset($responseElement)) {
54 54
 			$button->addEvent($event, "$('#".$form->getIdentifier()."').form('validate form');");
55
-			$form->addValidationParam("_ajaxSubmit", new AjaxCall("postForm", ["form"=>$form->getIdentifier(),"responseElement"=>$responseElement,"url"=>$url]));
55
+			$form->addValidationParam("_ajaxSubmit", new AjaxCall("postForm", ["form"=>$form->getIdentifier(), "responseElement"=>$responseElement, "url"=>$url]));
56 56
 		}
57 57
 		return $button;
58 58
 	}
59 59
 
60
-	public function addReset($identifier,$value,$cssStyle=NULL){
61
-		$bt=$this->getForm()->addButton($identifier, $value,$cssStyle);
60
+	public function addReset($identifier, $value, $cssStyle=NULL) {
61
+		$bt=$this->getForm()->addButton($identifier, $value, $cssStyle);
62 62
 		$bt->setProperty("type", "reset");
63 63
 		return $bt;
64 64
 	}
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 	 * @param string $jsCode
69 69
 	 * @return \Ajax\semantic\html\collections\form\HtmlForm
70 70
 	 */
71
-	public function onValid($jsCode){
71
+	public function onValid($jsCode) {
72 72
 		$form=$this->getForm();
73 73
 		$form->addValidationParam("onValid", "%function(){".$jsCode."}%");
74 74
 		return $form;
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 	 * @param string $jsCode can use event and fields parameters
80 80
 	 * @return HtmlForm
81 81
 	 */
82
-	public function onSuccess($jsCode){
82
+	public function onSuccess($jsCode) {
83 83
 		$form=$this->getForm();
84 84
 		$form->addValidationParam("onSuccess", "%function(evt,fields){".$jsCode."}%");
85 85
 		return $form;
Please login to merge, or discard this patch.
Ajax/semantic/html/collections/form/HtmlFormDropdown.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -7,21 +7,21 @@
 block discarded – undo
7 7
 
8 8
 class HtmlFormDropdown extends HtmlFormField {
9 9
 
10
-	public function __construct($identifier,$items=array(), $label=NULL,$value=NULL,$multiple=false) {
11
-		parent::__construct("field-".$identifier, (new HtmlDropdown("dropdown-".$identifier,$value,$items))->asSelect($identifier,$multiple), $label);
10
+	public function __construct($identifier, $items=array(), $label=NULL, $value=NULL, $multiple=false) {
11
+		parent::__construct("field-".$identifier, (new HtmlDropdown("dropdown-".$identifier, $value, $items))->asSelect($identifier, $multiple), $label);
12 12
 	}
13 13
 
14
-	public function setItems($items){
14
+	public function setItems($items) {
15 15
 		return $this->getField()->setItems($items);
16 16
 	}
17
-	public function addItem($item,$value=NULL,$image=NULL){
18
-		return $this->getField()->addItem($item,$value,$image);
17
+	public function addItem($item, $value=NULL, $image=NULL) {
18
+		return $this->getField()->addItem($item, $value, $image);
19 19
 	}
20
-	public static function multipleDropdown($identifier,$items=array(), $label=NULL,$value=NULL){
21
-		return new HtmlFormDropdown($identifier,$items,$label,$value,true);
20
+	public static function multipleDropdown($identifier, $items=array(), $label=NULL, $value=NULL) {
21
+		return new HtmlFormDropdown($identifier, $items, $label, $value, true);
22 22
 	}
23 23
 
24
-	public function getDataField(){
24
+	public function getDataField() {
25 25
 		return $this->getField()->getInput();
26 26
 	}
27 27
 }
28 28
\ No newline at end of file
Please login to merge, or discard this patch.
Ajax/semantic/html/collections/form/HtmlFormInput.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -8,16 +8,16 @@
 block discarded – undo
8 8
 class HtmlFormInput extends HtmlFormField {
9 9
 	use TextFieldsTrait;
10 10
 
11
-	public function __construct($identifier, $label=NULL,$type="text",$value=NULL,$placeholder=NULL) {
12
-		if(!isset($placeholder) && $type==="text")
11
+	public function __construct($identifier, $label=NULL, $type="text", $value=NULL, $placeholder=NULL) {
12
+		if (!isset($placeholder) && $type==="text")
13 13
 			$placeholder=$label;
14
-		parent::__construct("field-".$identifier, new HtmlInput($identifier,$type,$value,$placeholder), $label);
14
+		parent::__construct("field-".$identifier, new HtmlInput($identifier, $type, $value, $placeholder), $label);
15 15
 	}
16 16
 
17
-	public function getDataField(){
18
-		$field= $this->getField();
17
+	public function getDataField() {
18
+		$field=$this->getField();
19 19
 		//TODO check getField
20
-		if($field instanceof HtmlInput)
20
+		if ($field instanceof HtmlInput)
21 21
 			$field=$field->getDataField();
22 22
 		return $field;
23 23
 	}
Please login to merge, or discard this patch.
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -9,16 +9,18 @@
 block discarded – undo
9 9
 	use TextFieldsTrait;
10 10
 
11 11
 	public function __construct($identifier, $label=NULL,$type="text",$value=NULL,$placeholder=NULL) {
12
-		if(!isset($placeholder) && $type==="text")
13
-			$placeholder=$label;
12
+		if(!isset($placeholder) && $type==="text") {
13
+					$placeholder=$label;
14
+		}
14 15
 		parent::__construct("field-".$identifier, new HtmlInput($identifier,$type,$value,$placeholder), $label);
15 16
 	}
16 17
 
17 18
 	public function getDataField(){
18 19
 		$field= $this->getField();
19 20
 		//TODO check getField
20
-		if($field instanceof HtmlInput)
21
-			$field=$field->getDataField();
21
+		if($field instanceof HtmlInput) {
22
+					$field=$field->getDataField();
23
+		}
22 24
 		return $field;
23 25
 	}
24 26
 }
25 27
\ No newline at end of file
Please login to merge, or discard this patch.
Ajax/semantic/html/collections/form/traits/TextFieldsTrait.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -6,19 +6,19 @@
 block discarded – undo
6 6
 
7 7
 	abstract public function getDataField();
8 8
 	abstract public function addToProperty($name, $value, $separator=" ");
9
-	public function setPlaceholder($value){
9
+	public function setPlaceholder($value) {
10 10
 		$this->getDataField()->setPlaceholder($value);
11 11
 		return $this;
12 12
 	}
13 13
 
14
-	public function setValue($value){
14
+	public function setValue($value) {
15 15
 		$this->getDataField()->setValue($value);
16 16
 		return $this;
17 17
 	}
18 18
 
19
-	public function setInputType($type){
20
-		if($type==="hidden")
21
-			$this->addToProperty("style","display:none;");
19
+	public function setInputType($type) {
20
+		if ($type==="hidden")
21
+			$this->addToProperty("style", "display:none;");
22 22
 		$this->getDataField()->setInputType($type);
23 23
 		return $this;
24 24
 	}
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -17,8 +17,9 @@
 block discarded – undo
17 17
 	}
18 18
 
19 19
 	public function setInputType($type){
20
-		if($type==="hidden")
21
-			$this->addToProperty("style","display:none;");
20
+		if($type==="hidden") {
21
+					$this->addToProperty("style","display:none;");
22
+		}
22 23
 		$this->getDataField()->setInputType($type);
23 24
 		return $this;
24 25
 	}
Please login to merge, or discard this patch.
Ajax/semantic/html/collections/HtmlMessage.php 2 patches
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -31,38 +31,38 @@  discard block
 block discarded – undo
31 31
 	 * @param string|HtmlSemDoubleElement $header
32 32
 	 * @return \Ajax\semantic\html\collections\HtmlMessage
33 33
 	 */
34
-	public function addHeader($header){
34
+	public function addHeader($header) {
35 35
 		$headerO=$header;
36
-		if(\is_string($header)){
37
-			$headerO=new HtmlSemDoubleElement("header-".$this->identifier,"div");
36
+		if (\is_string($header)) {
37
+			$headerO=new HtmlSemDoubleElement("header-".$this->identifier, "div");
38 38
 			$headerO->setClass("header");
39 39
 			$headerO->setContent($header);
40 40
 		}
41
-		return $this->addContent($headerO,true);
41
+		return $this->addContent($headerO, true);
42 42
 	}
43 43
 
44
-	public function addList($elements,$ordered=false){
45
-		$list=new HtmlList("list-".$this->identifier,$elements);
44
+	public function addList($elements, $ordered=false) {
45
+		$list=new HtmlList("list-".$this->identifier, $elements);
46 46
 		$list->setOrdered($ordered);
47 47
 		$list->setClass("ui list");
48 48
 		$this->addContent($list);
49 49
 	}
50 50
 
51
-	public function setIcon($icon){
51
+	public function setIcon($icon) {
52 52
 		$this->addToProperty("class", "icon");
53
-		$this->wrapContent("<div class='content'>","</div>");
53
+		$this->wrapContent("<div class='content'>", "</div>");
54 54
 		$this->icon=new HtmlIcon("icon-".$this->identifier, $icon);
55 55
 		return $this;
56 56
 	}
57 57
 
58
-	public function addLoader($loaderIcon="notched circle"){
58
+	public function addLoader($loaderIcon="notched circle") {
59 59
 		$this->setIcon($loaderIcon);
60 60
 		$this->icon->addToIcon("loading");
61 61
 		return $this;
62 62
 	}
63 63
 
64
-	public function setDismissable($dismiss=true){
65
-		if($dismiss===true)
64
+	public function setDismissable($dismiss=true) {
65
+		if ($dismiss===true)
66 66
 			$this->close=new HtmlIcon("close-".$this->identifier, "close");
67 67
 		else
68 68
 			$this->close=NULL;
@@ -73,34 +73,34 @@  discard block
 block discarded – undo
73 73
 	 * {@inheritDoc}
74 74
 	 * @see \Ajax\semantic\html\base\HtmlSemDoubleElement::run()
75 75
 	 */
76
-	public function run(JsUtils $js){
76
+	public function run(JsUtils $js) {
77 77
 		parent::run($js);
78
-		if(isset($this->close)){
78
+		if (isset($this->close)) {
79 79
 			$js->execOn("click", "#".$this->identifier." .close", "$(this).closest('.message').transition('fade')");
80 80
 		}
81 81
 	}
82 82
 
83
-	public function setState($visible=true){
84
-		$visible=($visible===true)?"visible":"hidden";
85
-		return $this->addToPropertyCtrl("class", $visible, array("visible","hidden"));
83
+	public function setState($visible=true) {
84
+		$visible=($visible===true) ? "visible" : "hidden";
85
+		return $this->addToPropertyCtrl("class", $visible, array("visible", "hidden"));
86 86
 	}
87 87
 
88
-	public function setVariation($value="floating"){
89
-		return $this->addToPropertyCtrl("class", $value, array("floating","compact"));
88
+	public function setVariation($value="floating") {
89
+		return $this->addToPropertyCtrl("class", $value, array("floating", "compact"));
90 90
 	}
91 91
 
92
-	public function setStyle($style){
92
+	public function setStyle($style) {
93 93
 		return $this->addToPropertyCtrl("class", $style, Style::getConstants());
94 94
 	}
95 95
 
96
-	public function setError(){
96
+	public function setError() {
97 97
 		return $this->setStyle("error");
98 98
 	}
99 99
 
100
-	public function setMessage($message){
101
-		if(\is_array($this->content)){
100
+	public function setMessage($message) {
101
+		if (\is_array($this->content)) {
102 102
 			$this->content[\sizeof($this->content)-1]=$message;
103
-		}else
103
+		} else
104 104
 			$this->setContent($message);
105 105
 	}
106 106
 }
107 107
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +8 added lines, -6 removed lines patch added patch discarded remove patch
@@ -62,10 +62,11 @@  discard block
 block discarded – undo
62 62
 	}
63 63
 
64 64
 	public function setDismissable($dismiss=true){
65
-		if($dismiss===true)
66
-			$this->close=new HtmlIcon("close-".$this->identifier, "close");
67
-		else
68
-			$this->close=NULL;
65
+		if($dismiss===true) {
66
+					$this->close=new HtmlIcon("close-".$this->identifier, "close");
67
+		} else {
68
+					$this->close=NULL;
69
+		}
69 70
 		return $this;
70 71
 	}
71 72
 
@@ -100,7 +101,8 @@  discard block
 block discarded – undo
100 101
 	public function setMessage($message){
101 102
 		if(\is_array($this->content)){
102 103
 			$this->content[\sizeof($this->content)-1]=$message;
103
-		}else
104
-			$this->setContent($message);
104
+		} else {
105
+					$this->setContent($message);
106
+		}
105 107
 	}
106 108
 }
107 109
\ No newline at end of file
Please login to merge, or discard this patch.
Ajax/semantic/widgets/base/InstanceViewer.php 2 patches
Spacing   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -14,144 +14,144 @@  discard block
 block discarded – undo
14 14
 
15 15
 	public static $index=0;
16 16
 
17
-	public function __construct($instance=NULL,$captions=NULL){
17
+	public function __construct($instance=NULL, $captions=NULL) {
18 18
 		$this->values=[];
19 19
 		$this->afterCompile=[];
20
-		if(isset($instance))
20
+		if (isset($instance))
21 21
 			$this->setInstance($instance);
22 22
 		$this->setCaptions($captions);
23 23
 	}
24 24
 
25
-	public function getValues(){
25
+	public function getValues() {
26 26
 		$values=[];
27 27
 		$index=0;
28 28
 		$count=$this->count();
29
-		while($index<$count){
29
+		while ($index<$count) {
30 30
 			$values[]=$this->getValue($index++);
31 31
 		}
32 32
 		return $values;
33 33
 	}
34 34
 
35
-	public function getIdentifier(){
35
+	public function getIdentifier() {
36 36
 		$value=self::$index;
37
-		if(isset($this->values["identifier"]))
38
-			$value=$this->values["identifier"](self::$index,$this->instance);
37
+		if (isset($this->values["identifier"]))
38
+			$value=$this->values["identifier"](self::$index, $this->instance);
39 39
 		return $value;
40 40
 	}
41 41
 
42
-	public function getValue($index){
42
+	public function getValue($index) {
43 43
 		$property=$this->properties[$index];
44 44
 		return $this->_getValue($property, $index);
45 45
 	}
46 46
 
47
-	protected function _beforeAddProperty($index,&$field){
47
+	protected function _beforeAddProperty($index, &$field) {
48 48
 
49 49
 	}
50 50
 
51
-	protected function _getDefaultValue($name,$value,$index){
51
+	protected function _getDefaultValue($name, $value, $index) {
52 52
 		return $value;
53 53
 	}
54 54
 
55
-	protected function _getValue($property,$index){
56
-		if($property instanceof \ReflectionProperty){
55
+	protected function _getValue($property, $index) {
56
+		if ($property instanceof \ReflectionProperty) {
57 57
 			$property->setAccessible(true);
58 58
 			$value=$property->getValue($this->instance);
59
-			if(isset($this->values[$index])){
60
-				$value= $this->values[$index]($value,$this->instance,$index);
61
-			}else{
62
-				$value=$this->_getDefaultValue($property->getName(),$value, $index);
59
+			if (isset($this->values[$index])) {
60
+				$value=$this->values[$index]($value, $this->instance, $index);
61
+			} else {
62
+				$value=$this->_getDefaultValue($property->getName(), $value, $index);
63 63
 			}
64
-		}else{
65
-			if(\is_callable($property))
64
+		} else {
65
+			if (\is_callable($property))
66 66
 				$value=$property($this->instance);
67
-			elseif(\is_array($property)){
68
-				$values=\array_map(function($v) use ($index){return $this->_getValue($v, $index);}, $property);
67
+			elseif (\is_array($property)) {
68
+				$values=\array_map(function($v) use ($index){return $this->_getValue($v, $index); }, $property);
69 69
 				$value=\implode("", $values);
70
-			}else{
71
-				if(isset($this->values[$index])){
72
-					$value= $this->values[$index]($property,$this->instance,$index);
73
-				}else{
70
+			} else {
71
+				if (isset($this->values[$index])) {
72
+					$value=$this->values[$index]($property, $this->instance, $index);
73
+				} else {
74 74
 					$value=$property;
75 75
 				}
76 76
 			}
77 77
 		}
78
-		if(isset($this->afterCompile[$index])){
79
-			if(\is_callable($this->afterCompile[$index])){
80
-				$this->afterCompile[$index]($value,$this->instance,$index);
78
+		if (isset($this->afterCompile[$index])) {
79
+			if (\is_callable($this->afterCompile[$index])) {
80
+				$this->afterCompile[$index]($value, $this->instance, $index);
81 81
 			}
82 82
 		}
83 83
 		return $value;
84 84
 	}
85 85
 
86
-	public function insertField($index,$field){
87
-		array_splice( $this->visibleProperties, $index, 0, $field );
86
+	public function insertField($index, $field) {
87
+		array_splice($this->visibleProperties, $index, 0, $field);
88 88
 		return $this;
89 89
 	}
90 90
 
91
-	public function insertInField($index,$field){
91
+	public function insertInField($index, $field) {
92 92
 		$vb=$this->visibleProperties;
93
-		if(isset($vb[$index])){
94
-			if(\is_array($vb[$index])){
93
+		if (isset($vb[$index])) {
94
+			if (\is_array($vb[$index])) {
95 95
 				$this->visibleProperties[$index][]=$field;
96
-			}else{
97
-				$this->visibleProperties[$index]=[$vb[$index],$field];
96
+			} else {
97
+				$this->visibleProperties[$index]=[$vb[$index], $field];
98 98
 			}
99
-		}else{
99
+		} else {
100 100
 			return $this->insertField($index, $field);
101 101
 		}
102 102
 		return $this;
103 103
 	}
104 104
 
105
-	public function addField($field){
105
+	public function addField($field) {
106 106
 		$this->visibleProperties[]=$field;
107 107
 		return $this;
108 108
 	}
109 109
 
110
-	public function count(){
110
+	public function count() {
111 111
 		return \sizeof($this->properties);
112 112
 	}
113 113
 
114
-	public function visiblePropertiesCount(){
114
+	public function visiblePropertiesCount() {
115 115
 		return \sizeof($this->visibleProperties);
116 116
 	}
117 117
 
118
-	public function getProperty($index){
118
+	public function getProperty($index) {
119 119
 		return $this->properties[$index];
120 120
 	}
121 121
 
122
-	protected function showableProperty(\ReflectionProperty $rProperty){
123
-		return JString::startswith($rProperty->getName(),"_")===false;
122
+	protected function showableProperty(\ReflectionProperty $rProperty) {
123
+		return JString::startswith($rProperty->getName(), "_")===false;
124 124
 	}
125 125
 
126 126
 	public function setInstance($instance) {
127
-		if(\is_string($instance)){
127
+		if (\is_string($instance)) {
128 128
 			$instance=new $instance();
129 129
 		}
130 130
 		$this->instance=$instance;
131 131
 		$this->properties=[];
132 132
 		$this->reflect=new \ReflectionClass($instance);
133
-		if(\sizeof($this->visibleProperties)===0){
133
+		if (\sizeof($this->visibleProperties)===0) {
134 134
 			$this->properties=$this->getDefaultProperties();
135
-		}else{
136
-			foreach ($this->visibleProperties as $property){
137
-				if(\is_callable($property)){
135
+		} else {
136
+			foreach ($this->visibleProperties as $property) {
137
+				if (\is_callable($property)) {
138 138
 					$this->properties[]=$property;
139
-				}elseif(\is_string($property)){
140
-					try{
139
+				}elseif (\is_string($property)) {
140
+					try {
141 141
 						$this->_beforeAddProperty(\sizeof($this->properties), $property);
142 142
 						$rProperty=$this->reflect->getProperty($property);
143 143
 						$this->properties[]=$rProperty;
144
-					}catch(\Exception $e){
144
+					}catch (\Exception $e) {
145 145
 						$this->_beforeAddProperty(\sizeof($this->properties), $property);
146 146
 						$this->properties[]=$property;
147 147
 					}
148
-				}elseif(\is_int($property)){
148
+				}elseif (\is_int($property)) {
149 149
 					$props=$this->getDefaultProperties();
150
-					if(isset($props[$property]))
150
+					if (isset($props[$property]))
151 151
 						$this->properties[]=$props[$property];
152 152
 					else
153 153
 						$this->properties[]=$property;
154
-				}else{
154
+				} else {
155 155
 					$this->properties[]=$property;
156 156
 				}
157 157
 			}
@@ -159,12 +159,12 @@  discard block
 block discarded – undo
159 159
 		return $this;
160 160
 	}
161 161
 
162
-	protected function getDefaultProperties(){
162
+	protected function getDefaultProperties() {
163 163
 		$result=[];
164 164
 		$properties=$this->reflect->getProperties();
165
-		foreach ($properties as $property){
165
+		foreach ($properties as $property) {
166 166
 			$showable=$this->showableProperty($property);
167
-			if($showable!==false){
167
+			if ($showable!==false) {
168 168
 				$result[]=$property;
169 169
 			}
170 170
 		}
@@ -176,12 +176,12 @@  discard block
 block discarded – undo
176 176
 		return $this;
177 177
 	}
178 178
 
179
-	public function setValueFunction($index,$callback){
179
+	public function setValueFunction($index, $callback) {
180 180
 		$this->values[$index]=$callback;
181 181
 		return $this;
182 182
 	}
183 183
 
184
-	public function setIdentifierFunction($callback){
184
+	public function setIdentifierFunction($callback) {
185 185
 		$this->values["identifier"]=$callback;
186 186
 		return $this;
187 187
 	}
@@ -194,22 +194,22 @@  discard block
 block discarded – undo
194 194
 		return $this->properties;
195 195
 	}
196 196
 
197
-	public function getCaption($index){
198
-		if(isset($this->captions[$index])){
197
+	public function getCaption($index) {
198
+		if (isset($this->captions[$index])) {
199 199
 			return $this->captions[$index];
200 200
 		}
201
-		if($this->properties[$index] instanceof \ReflectionProperty)
201
+		if ($this->properties[$index] instanceof \ReflectionProperty)
202 202
 			return $this->properties[$index]->getName();
203
-		elseif(\is_callable($this->properties[$index]))
203
+		elseif (\is_callable($this->properties[$index]))
204 204
 			return "";
205 205
 		else
206 206
 			return $this->properties[$index];
207 207
 	}
208 208
 
209
-	public function getCaptions(){
210
-		if(isset($this->captions)){
211
-			$result= $this->captions;
212
-			for($i=\sizeof($result);$i<$this->count();$i++){
209
+	public function getCaptions() {
210
+		if (isset($this->captions)) {
211
+			$result=$this->captions;
212
+			for ($i=\sizeof($result); $i<$this->count(); $i++) {
213 213
 				$result[]="";
214 214
 			}
215 215
 			return $result;
@@ -217,14 +217,14 @@  discard block
 block discarded – undo
217 217
 		$captions=[];
218 218
 		$index=0;
219 219
 		$count=$this->count();
220
-		while($index<$count){
220
+		while ($index<$count) {
221 221
 			$captions[]=$this->getCaption($index++);
222 222
 		}
223 223
 		return $captions;
224 224
 	}
225 225
 
226
-	public function setCaption($index,$caption){
227
-		if(isset($this->captions)===false)
226
+	public function setCaption($index, $caption) {
227
+		if (isset($this->captions)===false)
228 228
 			$this->captions=[];
229 229
 		$this->captions[$index]=$caption;
230 230
 		return $this;
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
 	 * @param callable $callback function called after the field compilation
243 243
 	 * @return \Ajax\semantic\widgets\datatable\InstanceViewer
244 244
 	 */
245
-	public function afterCompile($index,$callback){
245
+	public function afterCompile($index, $callback) {
246 246
 		$this->afterCompile[$index]=$callback;
247 247
 		return $this;
248 248
 	}
Please login to merge, or discard this patch.
Braces   +35 added lines, -30 removed lines patch added patch discarded remove patch
@@ -17,8 +17,9 @@  discard block
 block discarded – undo
17 17
 	public function __construct($instance=NULL,$captions=NULL){
18 18
 		$this->values=[];
19 19
 		$this->afterCompile=[];
20
-		if(isset($instance))
21
-			$this->setInstance($instance);
20
+		if(isset($instance)) {
21
+					$this->setInstance($instance);
22
+		}
22 23
 		$this->setCaptions($captions);
23 24
 	}
24 25
 
@@ -34,8 +35,9 @@  discard block
 block discarded – undo
34 35
 
35 36
 	public function getIdentifier(){
36 37
 		$value=self::$index;
37
-		if(isset($this->values["identifier"]))
38
-			$value=$this->values["identifier"](self::$index,$this->instance);
38
+		if(isset($this->values["identifier"])) {
39
+					$value=$this->values["identifier"](self::$index,$this->instance);
40
+		}
39 41
 		return $value;
40 42
 	}
41 43
 
@@ -58,19 +60,19 @@  discard block
 block discarded – undo
58 60
 			$value=$property->getValue($this->instance);
59 61
 			if(isset($this->values[$index])){
60 62
 				$value= $this->values[$index]($value,$this->instance,$index);
61
-			}else{
63
+			} else{
62 64
 				$value=$this->_getDefaultValue($property->getName(),$value, $index);
63 65
 			}
64
-		}else{
65
-			if(\is_callable($property))
66
-				$value=$property($this->instance);
67
-			elseif(\is_array($property)){
66
+		} else{
67
+			if(\is_callable($property)) {
68
+							$value=$property($this->instance);
69
+			} elseif(\is_array($property)){
68 70
 				$values=\array_map(function($v) use ($index){return $this->_getValue($v, $index);}, $property);
69 71
 				$value=\implode("", $values);
70
-			}else{
72
+			} else{
71 73
 				if(isset($this->values[$index])){
72 74
 					$value= $this->values[$index]($property,$this->instance,$index);
73
-				}else{
75
+				} else{
74 76
 					$value=$property;
75 77
 				}
76 78
 			}
@@ -93,10 +95,10 @@  discard block
 block discarded – undo
93 95
 		if(isset($vb[$index])){
94 96
 			if(\is_array($vb[$index])){
95 97
 				$this->visibleProperties[$index][]=$field;
96
-			}else{
98
+			} else{
97 99
 				$this->visibleProperties[$index]=[$vb[$index],$field];
98 100
 			}
99
-		}else{
101
+		} else{
100 102
 			return $this->insertField($index, $field);
101 103
 		}
102 104
 		return $this;
@@ -132,26 +134,27 @@  discard block
 block discarded – undo
132 134
 		$this->reflect=new \ReflectionClass($instance);
133 135
 		if(\sizeof($this->visibleProperties)===0){
134 136
 			$this->properties=$this->getDefaultProperties();
135
-		}else{
137
+		} else{
136 138
 			foreach ($this->visibleProperties as $property){
137 139
 				if(\is_callable($property)){
138 140
 					$this->properties[]=$property;
139
-				}elseif(\is_string($property)){
141
+				} elseif(\is_string($property)){
140 142
 					try{
141 143
 						$this->_beforeAddProperty(\sizeof($this->properties), $property);
142 144
 						$rProperty=$this->reflect->getProperty($property);
143 145
 						$this->properties[]=$rProperty;
144
-					}catch(\Exception $e){
146
+					} catch(\Exception $e){
145 147
 						$this->_beforeAddProperty(\sizeof($this->properties), $property);
146 148
 						$this->properties[]=$property;
147 149
 					}
148
-				}elseif(\is_int($property)){
150
+				} elseif(\is_int($property)){
149 151
 					$props=$this->getDefaultProperties();
150
-					if(isset($props[$property]))
151
-						$this->properties[]=$props[$property];
152
-					else
153
-						$this->properties[]=$property;
154
-				}else{
152
+					if(isset($props[$property])) {
153
+											$this->properties[]=$props[$property];
154
+					} else {
155
+											$this->properties[]=$property;
156
+					}
157
+				} else{
155 158
 					$this->properties[]=$property;
156 159
 				}
157 160
 			}
@@ -198,12 +201,13 @@  discard block
 block discarded – undo
198 201
 		if(isset($this->captions[$index])){
199 202
 			return $this->captions[$index];
200 203
 		}
201
-		if($this->properties[$index] instanceof \ReflectionProperty)
202
-			return $this->properties[$index]->getName();
203
-		elseif(\is_callable($this->properties[$index]))
204
-			return "";
205
-		else
206
-			return $this->properties[$index];
204
+		if($this->properties[$index] instanceof \ReflectionProperty) {
205
+					return $this->properties[$index]->getName();
206
+		} elseif(\is_callable($this->properties[$index])) {
207
+					return "";
208
+		} else {
209
+					return $this->properties[$index];
210
+		}
207 211
 	}
208 212
 
209 213
 	public function getCaptions(){
@@ -224,8 +228,9 @@  discard block
 block discarded – undo
224 228
 	}
225 229
 
226 230
 	public function setCaption($index,$caption){
227
-		if(isset($this->captions)===false)
228
-			$this->captions=[];
231
+		if(isset($this->captions)===false) {
232
+					$this->captions=[];
233
+		}
229 234
 		$this->captions[$index]=$caption;
230 235
 		return $this;
231 236
 	}
Please login to merge, or discard this patch.