Completed
Push — master ( 042f42...691772 )
by Jean-Christophe
03:21
created
Ajax/semantic/html/collections/form/HtmlFormTextarea.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -9,10 +9,10 @@  discard block
 block discarded – undo
9 9
 class HtmlFormTextarea extends HtmlFormField {
10 10
 	use TextFieldsTrait;
11 11
 
12
-	public function __construct($identifier, $label=NULL,$value=NULL,$placeholder=NULL,$rows=NULL) {
13
-		if(!isset($placeholder))
12
+	public function __construct($identifier, $label=NULL, $value=NULL, $placeholder=NULL, $rows=NULL) {
13
+		if (!isset($placeholder))
14 14
 			$placeholder=$label;
15
-		parent::__construct("field-".$identifier, new HtmlTextarea($identifier,$value,$placeholder,$rows), $label);
15
+		parent::__construct("field-".$identifier, new HtmlTextarea($identifier, $value, $placeholder, $rows), $label);
16 16
 		$this->_identifier=$identifier;
17 17
 	}
18 18
 
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 	 * Defines the textarea row count
21 21
 	 * @param int $count
22 22
 	 */
23
-	public function setRows($count){
23
+	public function setRows($count) {
24 24
 		$this->getField()->setRows($count);
25 25
 	}
26 26
 
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 		return $this->content["field"];
29 29
 	}
30 30
 
31
-	public function setName($name){
32
-		$this->getDataField()->setProperty("name",$name);
31
+	public function setName($name) {
32
+		$this->getDataField()->setProperty("name", $name);
33 33
 	}
34 34
 }
Please login to merge, or discard this patch.
Ajax/semantic/html/collections/form/traits/FormTrait.php 1 patch
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -13,27 +13,27 @@  discard block
 block discarded – undo
13 13
  * @author jc
14 14
  *
15 15
  */
16
-trait FormTrait{
16
+trait FormTrait {
17 17
 
18 18
 	/**
19 19
 	 * @return HtmlForm
20 20
 	 */
21 21
 	abstract protected function getForm();
22 22
 
23
-	protected function addCompoValidation($compo,$field){
23
+	protected function addCompoValidation($compo, $field) {
24 24
 		$validation=$field->getValidation();
25
-		if(isset($validation)){
25
+		if (isset($validation)) {
26 26
 			$validation->setIdentifier($field->getDataField()->getIdentifier());
27 27
 			$compo->addFieldValidation($validation);
28 28
 		}
29 29
 		return $compo;
30 30
 	}
31 31
 
32
-	protected function _runValidationParams(&$compo,JsUtils $js=NULL){
32
+	protected function _runValidationParams(&$compo, JsUtils $js=NULL) {
33 33
 		$form=$this->getForm();
34 34
 		$params=$form->getValidationParams();
35
-		if(isset($params["_ajaxSubmit"])){
36
-			$compilation=$this->_compileAjaxSubmit($params["_ajaxSubmit"],$js);
35
+		if (isset($params["_ajaxSubmit"])) {
36
+			$compilation=$this->_compileAjaxSubmit($params["_ajaxSubmit"], $js);
37 37
 			$this->onSuccess($compilation);
38 38
 			$form->removeValidationParam("_ajaxSubmit");
39 39
 		}
@@ -42,16 +42,16 @@  discard block
 block discarded – undo
42 42
 		$form->addEventsOnRun($js);
43 43
 	}
44 44
 
45
-	protected function _compileAjaxSubmit($ajaxSubmit,JsUtils $js=null){
45
+	protected function _compileAjaxSubmit($ajaxSubmit, JsUtils $js=null) {
46 46
 		$compilation="";
47
-		if(\is_array($ajaxSubmit)){
48
-			foreach ($ajaxSubmit as $ajaxSubmitItem){
47
+		if (\is_array($ajaxSubmit)) {
48
+			foreach ($ajaxSubmit as $ajaxSubmitItem) {
49 49
 				$compilation.=$ajaxSubmitItem->compile($js);
50 50
 			}
51
-		}elseif($ajaxSubmit instanceof AjaxCall){
51
+		}elseif ($ajaxSubmit instanceof AjaxCall) {
52 52
 			$compilation=$ajaxSubmit->compile($js);
53 53
 		}
54
-		$compilation=str_ireplace("\"","%quote%", $compilation);
54
+		$compilation=str_ireplace("\"", "%quote%", $compilation);
55 55
 		return $compilation;
56 56
 	}
57 57
 
@@ -64,14 +64,14 @@  discard block
 block discarded – undo
64 64
 		return $this;
65 65
 	}
66 66
 
67
-	public function setAttached($value=true){
67
+	public function setAttached($value=true) {
68 68
 		$form=$this->getForm();
69
-		if($value)
70
-			$form->addToPropertyCtrl("class", "attached", array ("attached" ));
69
+		if ($value)
70
+			$form->addToPropertyCtrl("class", "attached", array("attached"));
71 71
 		return $form;
72 72
 	}
73 73
 
74
-	public function addErrorMessage(){
74
+	public function addErrorMessage() {
75 75
 		return $this->getForm()->addContent((new HtmlMessage(""))->setError());
76 76
 	}
77 77
 
@@ -87,47 +87,47 @@  discard block
 block discarded – undo
87 87
 	 * @param array $parameters
88 88
 	 * @return HtmlForm
89 89
 	 */
90
-	public function submitOn($event,$identifierOrElement,$url,$responseElement,$parameters=NULL){
90
+	public function submitOn($event, $identifierOrElement, $url, $responseElement, $parameters=NULL) {
91 91
 		$form=$this->getForm();
92
-		if($identifierOrElement  instanceof BaseHtml)
92
+		if ($identifierOrElement  instanceof BaseHtml)
93 93
 			$elem=$identifierOrElement;
94 94
 		else
95 95
 			$elem=$form->getElementById($identifierOrElement, $form->getContent());
96
-		if(isset($elem)){
97
-			$this->_buttonAsSubmit($elem, $event,$url,$responseElement,$parameters);
96
+		if (isset($elem)) {
97
+			$this->_buttonAsSubmit($elem, $event, $url, $responseElement, $parameters);
98 98
 		}
99 99
 		return $form;
100 100
 	}
101 101
 
102
-	public function submitOnClick($identifier,$url,$responseElement,$parameters=NULL){
103
-		return $this->submitOn("click", $identifier, $url, $responseElement,$parameters);
102
+	public function submitOnClick($identifier, $url, $responseElement, $parameters=NULL) {
103
+		return $this->submitOn("click", $identifier, $url, $responseElement, $parameters);
104 104
 	}
105 105
 
106
-	public function addSubmit($identifier,$value,$cssStyle=NULL,$url=NULL,$responseElement=NULL,$parameters=NULL){
107
-		$bt=$this->getForm()->addButton($identifier, $value,$cssStyle);
108
-		return $this->_buttonAsSubmit($bt, "click",$url,$responseElement,$parameters);
106
+	public function addSubmit($identifier, $value, $cssStyle=NULL, $url=NULL, $responseElement=NULL, $parameters=NULL) {
107
+		$bt=$this->getForm()->addButton($identifier, $value, $cssStyle);
108
+		return $this->_buttonAsSubmit($bt, "click", $url, $responseElement, $parameters);
109 109
 	}
110 110
 
111
-	protected function _buttonAsSubmit(BaseHtml &$button,$event,$url,$responseElement=NULL,$parameters=NULL){
111
+	protected function _buttonAsSubmit(BaseHtml&$button, $event, $url, $responseElement=NULL, $parameters=NULL) {
112 112
 		$form=$this->getForm();
113
-		if(isset($url) && isset($responseElement)){
114
-			$button->addEvent($event, "$('#".$form->getIdentifier()."').form('validate form');",true,true);
115
-			$this->setSubmitParams($url,$responseElement,$parameters);
113
+		if (isset($url) && isset($responseElement)) {
114
+			$button->addEvent($event, "$('#".$form->getIdentifier()."').form('validate form');", true, true);
115
+			$this->setSubmitParams($url, $responseElement, $parameters);
116 116
 		}
117 117
 		return $button;
118 118
 	}
119 119
 
120
-	public function setSubmitParams($url,$responseElement=NULL,$parameters=NULL){
120
+	public function setSubmitParams($url, $responseElement=NULL, $parameters=NULL) {
121 121
 		$form=$this->getForm();
122
-		$params=["form"=>$form->getIdentifier(),"responseElement"=>$responseElement,"url"=>$url,"stopPropagation"=>true];
123
-		if(\is_array($parameters))
124
-			$params=\array_merge($params,$parameters);
122
+		$params=["form"=>$form->getIdentifier(), "responseElement"=>$responseElement, "url"=>$url, "stopPropagation"=>true];
123
+		if (\is_array($parameters))
124
+			$params=\array_merge($params, $parameters);
125 125
 		$form->addValidationParam("_ajaxSubmit", new AjaxCall("postForm", $params));
126 126
 		return $this;
127 127
 	}
128 128
 
129
-	public function addReset($identifier,$value,$cssStyle=NULL){
130
-		$bt=$this->getForm()->addButton($identifier, $value,$cssStyle);
129
+	public function addReset($identifier, $value, $cssStyle=NULL) {
130
+		$bt=$this->getForm()->addButton($identifier, $value, $cssStyle);
131 131
 		$bt->setProperty("type", "reset");
132 132
 		return $bt;
133 133
 	}
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
 	 * @param string $jsCode
138 138
 	 * @return \Ajax\semantic\html\collections\form\HtmlForm
139 139
 	 */
140
-	public function onValid($jsCode){
140
+	public function onValid($jsCode) {
141 141
 		$form=$this->getForm();
142 142
 		$form->addValidationParam("onValid", "%function(){".$jsCode."}%");
143 143
 		return $form;
@@ -148,9 +148,9 @@  discard block
 block discarded – undo
148 148
 	 * @param string $jsCode can use event and fields parameters
149 149
 	 * @return HtmlForm
150 150
 	 */
151
-	public function onSuccess($jsCode){
151
+	public function onSuccess($jsCode) {
152 152
 		$form=$this->getForm();
153
-		$form->addValidationParam("onSuccess", $jsCode,"%function(event,fields){","}%");
153
+		$form->addValidationParam("onSuccess", $jsCode, "%function(event,fields){", "}%");
154 154
 		return $form;
155 155
 	}
156 156
 }
Please login to merge, or discard this patch.
Ajax/semantic/html/collections/form/traits/FieldTrait.php 1 patch
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -47,8 +47,9 @@  discard block
 block discarded – undo
47 47
 		$actionO=$action;
48 48
 		if (\is_object($action) === false) {
49 49
 			$actionO=new HtmlButton("action-" . $this->identifier, $action);
50
-			if (isset($icon))
51
-				$actionO->addIcon($icon, true, $labeled);
50
+			if (isset($icon)) {
51
+							$actionO->addIcon($icon, true, $labeled);
52
+			}
52 53
 		}
53 54
 		$field->addToProperty("class", $direction . " action");
54 55
 		$field->addContent($actionO, \strstr($direction, Direction::LEFT) !== false);
@@ -82,8 +83,9 @@  discard block
 block discarded – undo
82 83
 
83 84
 	public function setDisabled($disable=true) {
84 85
 		$field=$this->getField();
85
-		if($disable)
86
-			$field->addToProperty("class", "disabled");
86
+		if($disable) {
87
+					$field->addToProperty("class", "disabled");
88
+		}
87 89
 		return $this;
88 90
 	}
89 91
 }
Please login to merge, or discard this patch.
Ajax/semantic/html/collections/form/traits/FieldsTrait.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -15,46 +15,46 @@  discard block
 block discarded – undo
15 15
  * @property string $identifier
16 16
  */
17 17
 trait FieldsTrait {
18
-	abstract public function addFields($fields=NULL,$label=NULL);
18
+	abstract public function addFields($fields=NULL, $label=NULL);
19 19
 	abstract public function addItem($item);
20 20
 
21
-	protected function createItem($value){
22
-		if(\is_array($value)){
23
-			$itemO=new HtmlFormInput(JArray::getDefaultValue($value, "id",""),JArray::getDefaultValue($value, "label",null),JArray::getDefaultValue($value, "type", "text"),JArray::getDefaultValue($value, "value",""),JArray::getDefaultValue($value, "placeholder",JArray::getDefaultValue($value, "label",null)));
21
+	protected function createItem($value) {
22
+		if (\is_array($value)) {
23
+			$itemO=new HtmlFormInput(JArray::getDefaultValue($value, "id", ""), JArray::getDefaultValue($value, "label", null), JArray::getDefaultValue($value, "type", "text"), JArray::getDefaultValue($value, "value", ""), JArray::getDefaultValue($value, "placeholder", JArray::getDefaultValue($value, "label", null)));
24 24
 			return $itemO;
25
-		}elseif(\is_object($value)){
25
+		}elseif (\is_object($value)) {
26 26
 			$itemO=new HtmlFormField("field-".$this->identifier, $value);
27 27
 			return $itemO;
28
-		}else
28
+		} else
29 29
 			return new HtmlFormInput($value);
30 30
 	}
31 31
 
32
-	protected function createCondition($value){
32
+	protected function createCondition($value) {
33 33
 		return \is_object($value)===false || $value instanceof \Ajax\semantic\html\elements\HtmlInput;
34 34
 	}
35 35
 
36
-	public function addInputs($inputs,$fieldslabel=null){
36
+	public function addInputs($inputs, $fieldslabel=null) {
37 37
 		$fields=array();
38
-		foreach ($inputs as $input){
38
+		foreach ($inputs as $input) {
39 39
 			\extract($input);
40
-			$f=new HtmlFormInput("","");
40
+			$f=new HtmlFormInput("", "");
41 41
 			$f->fromArray($input);
42 42
 			$fields[]=$f;
43 43
 		}
44
-		return $this->addFields($fields,$fieldslabel);
44
+		return $this->addFields($fields, $fieldslabel);
45 45
 	}
46 46
 
47
-	public function addFieldRule($index,$type,$prompt=NULL,$value=NULL){
47
+	public function addFieldRule($index, $type, $prompt=NULL, $value=NULL) {
48 48
 		$field=$this->getItem($index);
49
-		if(isset($field)){
50
-			$field->addRule($type,$prompt,$value);
49
+		if (isset($field)) {
50
+			$field->addRule($type, $prompt, $value);
51 51
 		}
52 52
 		return $this;
53 53
 	}
54 54
 
55
-	public function addFieldRules($index,$rules){
55
+	public function addFieldRules($index, $rules) {
56 56
 		$field=$this->getItem($index);
57
-		if(isset($field)){
57
+		if (isset($field)) {
58 58
 			$field->addRules($rules);
59 59
 		}
60 60
 		return $this;
@@ -68,8 +68,8 @@  discard block
 block discarded – undo
68 68
 	 * @param boolean $multiple
69 69
 	 * @return \Ajax\common\html\HtmlDoubleElement
70 70
 	 */
71
-	public function addDropdown($identifier,$items=array(), $label=NULL,$value=NULL,$multiple=false){
72
-		return $this->addItem(new HtmlFormDropdown($identifier,$items,$label,$value,$multiple));
71
+	public function addDropdown($identifier, $items=array(), $label=NULL, $value=NULL, $multiple=false) {
72
+		return $this->addItem(new HtmlFormDropdown($identifier, $items, $label, $value, $multiple));
73 73
 	}
74 74
 
75 75
 	/**
@@ -80,23 +80,23 @@  discard block
 block discarded – undo
80 80
 	 * @param string $placeholder
81 81
 	 * @return HtmlFormInput
82 82
 	 */
83
-	public function addInput($identifier, $label=NULL,$type="text",$value=NULL,$placeholder=NULL){
84
-		return $this->addItem(new HtmlFormInput($identifier,$label,$type,$value,$placeholder));
83
+	public function addInput($identifier, $label=NULL, $type="text", $value=NULL, $placeholder=NULL) {
84
+		return $this->addItem(new HtmlFormInput($identifier, $label, $type, $value, $placeholder));
85 85
 	}
86 86
 
87
-	public function addPassword($identifier, $label=NULL){
88
-		return $this->addItem(new HtmlFormInput($identifier,$label,"password","",""));
87
+	public function addPassword($identifier, $label=NULL) {
88
+		return $this->addItem(new HtmlFormInput($identifier, $label, "password", "", ""));
89 89
 	}
90 90
 
91
-	public function addButton($identifier,$value,$cssStyle=NULL,$onClick=NULL){
92
-		return $this->addItem(new HtmlButton($identifier,$value,$cssStyle,$onClick));
91
+	public function addButton($identifier, $value, $cssStyle=NULL, $onClick=NULL) {
92
+		return $this->addItem(new HtmlButton($identifier, $value, $cssStyle, $onClick));
93 93
 	}
94 94
 
95
-	public function addCheckbox($identifier, $label=NULL,$value=NULL,$type=NULL){
96
-		return $this->addItem(new HtmlFormCheckbox($identifier,$label,$value,$type));
95
+	public function addCheckbox($identifier, $label=NULL, $value=NULL, $type=NULL) {
96
+		return $this->addItem(new HtmlFormCheckbox($identifier, $label, $value, $type));
97 97
 	}
98 98
 
99
-	public function addRadio($identifier, $name,$label=NULL,$value=NULL){
100
-		return $this->addItem(new HtmlFormRadio($identifier,$name,$label,$value));
99
+	public function addRadio($identifier, $name, $label=NULL, $value=NULL) {
100
+		return $this->addItem(new HtmlFormRadio($identifier, $name, $label, $value));
101 101
 	}
102 102
 }
Please login to merge, or discard this patch.
Ajax/semantic/widgets/datatable/PositionInTable.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -3,5 +3,5 @@
 block discarded – undo
3 3
 use Ajax\common\BaseEnum;
4 4
 
5 5
 abstract class PositionInTable extends BaseEnum {
6
-	const BEFORETABLE="beforeTable",AFTERTABLE="afterTable",HEADER="thead",FOOTER="tfoot",BODY="tbody";
6
+	const BEFORETABLE="beforeTable", AFTERTABLE="afterTable", HEADER="thead", FOOTER="tfoot", BODY="tbody";
7 7
 }
Please login to merge, or discard this patch.
Ajax/semantic/widgets/datatable/DataTable.php 1 patch
Spacing   +101 added lines, -101 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
  *
25 25
  */
26 26
 class DataTable extends Widget {
27
-	use TableTrait,DataTableFieldAsTrait,HasCheckboxesTrait,BaseTrait;
27
+	use TableTrait, DataTableFieldAsTrait, HasCheckboxesTrait, BaseTrait;
28 28
 	protected $_searchField;
29 29
 	protected $_urls;
30 30
 	protected $_pagination;
@@ -42,35 +42,35 @@  discard block
 block discarded – undo
42 42
 	protected $_colWidths;
43 43
 
44 44
 
45
-	public function __construct($identifier,$model,$modelInstance=NULL) {
46
-		parent::__construct($identifier, $model,$modelInstance);
47
-		$this->_init(new InstanceViewer($identifier), "table", new HtmlTable($identifier, 0,0), false);
45
+	public function __construct($identifier, $model, $modelInstance=NULL) {
46
+		parent::__construct($identifier, $model, $modelInstance);
47
+		$this->_init(new InstanceViewer($identifier), "table", new HtmlTable($identifier, 0, 0), false);
48 48
 		$this->_urls=[];
49
-		$this->_emptyMessage=new HtmlMessage("","nothing to display");
49
+		$this->_emptyMessage=new HtmlMessage("", "nothing to display");
50 50
 		$this->_emptyMessage->setIcon("info circle");
51 51
 	}
52 52
 
53
-	public function run(JsUtils $js){
54
-		if($this->_hasCheckboxes && isset($js)){
53
+	public function run(JsUtils $js) {
54
+		if ($this->_hasCheckboxes && isset($js)) {
55 55
 			$this->_runCheckboxes($js);
56 56
 		}
57
-		if($this->_visibleHover){
58
-			$js->execOn("mouseover", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'visible');",["preventDefault"=>false,"stopPropagation"=>true]);
59
-			$js->execOn("mouseout", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'hidden');",["preventDefault"=>false,"stopPropagation"=>true]);
57
+		if ($this->_visibleHover) {
58
+			$js->execOn("mouseover", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'visible');", ["preventDefault"=>false, "stopPropagation"=>true]);
59
+			$js->execOn("mouseout", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'hidden');", ["preventDefault"=>false, "stopPropagation"=>true]);
60 60
 		}
61
-		if(\is_array($this->_deleteBehavior))
62
-			$this->_generateBehavior("delete",$this->_deleteBehavior, $js);
63
-		if(\is_array($this->_editBehavior))
64
-			$this->_generateBehavior("edit",$this->_editBehavior,$js);
61
+		if (\is_array($this->_deleteBehavior))
62
+			$this->_generateBehavior("delete", $this->_deleteBehavior, $js);
63
+		if (\is_array($this->_editBehavior))
64
+			$this->_generateBehavior("edit", $this->_editBehavior, $js);
65 65
 		return parent::run($js);
66 66
 	}
67 67
 
68 68
 
69 69
 
70
-	protected function _generateBehavior($op,$params,JsUtils $js){
71
-		if(isset($this->_urls[$op])){
72
-			$params=\array_merge($params,["attr"=>"data-ajax"]);
73
-			$js->getOnClick("#".$this->identifier." ._".$op, $this->_urls[$op],$this->getTargetSelector(),$params);
70
+	protected function _generateBehavior($op, $params, JsUtils $js) {
71
+		if (isset($this->_urls[$op])) {
72
+			$params=\array_merge($params, ["attr"=>"data-ajax"]);
73
+			$js->getOnClick("#".$this->identifier." ._".$op, $this->_urls[$op], $this->getTargetSelector(), $params);
74 74
 		}
75 75
 	}
76 76
 
@@ -83,154 +83,154 @@  discard block
 block discarded – undo
83 83
 	}
84 84
 
85 85
 
86
-	public function compile(JsUtils $js=NULL,&$view=NULL){
87
-		if(!$this->_generated){
86
+	public function compile(JsUtils $js=NULL, &$view=NULL) {
87
+		if (!$this->_generated) {
88 88
 			$this->_instanceViewer->setInstance($this->_model);
89 89
 			$captions=$this->_instanceViewer->getCaptions();
90 90
 			$table=$this->content["table"];
91
-			if($this->_hasCheckboxes){
91
+			if ($this->_hasCheckboxes) {
92 92
 				$this->_generateMainCheckbox($captions);
93 93
 			}
94 94
 			$table->setRowCount(0, \sizeof($captions));
95
-			$this->_generateHeader($table,$captions);
95
+			$this->_generateHeader($table, $captions);
96 96
 
97
-			if(isset($this->_compileParts))
97
+			if (isset($this->_compileParts))
98 98
 				$table->setCompileParts($this->_compileParts);
99 99
 
100
-			if(isset($this->_searchField) && isset($js)){
101
-				if(isset($this->_urls["refresh"]))
102
-					$this->_searchField->postOn("change", $this->_urls["refresh"],"{'s':$(this).val()}","#".$this->identifier." tbody",["preventDefault"=>false,"jqueryDone"=>"replaceWith"]);
100
+			if (isset($this->_searchField) && isset($js)) {
101
+				if (isset($this->_urls["refresh"]))
102
+					$this->_searchField->postOn("change", $this->_urls["refresh"], "{'s':$(this).val()}", "#".$this->identifier." tbody", ["preventDefault"=>false, "jqueryDone"=>"replaceWith"]);
103 103
 			}
104 104
 
105 105
 			$this->_generateContent($table);
106 106
 
107
-			if($this->_hasCheckboxes && $table->hasPart("thead")){
107
+			if ($this->_hasCheckboxes && $table->hasPart("thead")) {
108 108
 					$table->getHeader()->getCell(0, 0)->addClass("no-sort");
109 109
 			}
110 110
 
111
-			if(isset($this->_toolbar)){
111
+			if (isset($this->_toolbar)) {
112 112
 				$this->_setToolbarPosition($table, $captions);
113 113
 			}
114
-			if(isset($this->_pagination) && $this->_pagination->getVisible()){
115
-				$this->_generatePagination($table,$js);
114
+			if (isset($this->_pagination) && $this->_pagination->getVisible()) {
115
+				$this->_generatePagination($table, $js);
116 116
 			}
117 117
 
118
-			$this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE,"table",PositionInTable::AFTERTABLE]);
118
+			$this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE, "table", PositionInTable::AFTERTABLE]);
119 119
 			$this->_compileForm();
120 120
 			$this->_applyStyleAttributes($table);
121 121
 			$this->_generated=true;
122 122
 		}
123
-		return parent::compile($js,$view);
123
+		return parent::compile($js, $view);
124 124
 	}
125 125
 
126
-	protected function _applyStyleAttributes($table){
127
-		if(isset($this->_hiddenColumns))
126
+	protected function _applyStyleAttributes($table) {
127
+		if (isset($this->_hiddenColumns))
128 128
 			$this->_hideColumns();
129
-			if(isset($this->_colWidths)){
130
-				foreach ($this->_colWidths as $colIndex=>$width){
131
-					$table->setColWidth($colIndex,$width);
129
+			if (isset($this->_colWidths)) {
130
+				foreach ($this->_colWidths as $colIndex=>$width) {
131
+					$table->setColWidth($colIndex, $width);
132 132
 				}
133 133
 			}
134 134
 	}
135 135
 
136
-	protected function _hideColumns(){
137
-		foreach ($this->_hiddenColumns as $colIndex){
136
+	protected function _hideColumns() {
137
+		foreach ($this->_hiddenColumns as $colIndex) {
138 138
 			$this->_self->hideColumn($colIndex);
139 139
 		}
140 140
 		return $this;
141 141
 	}
142 142
 
143
-	protected function _generateHeader(HtmlTable $table,$captions){
143
+	protected function _generateHeader(HtmlTable $table, $captions) {
144 144
 		$table->setHeaderValues($captions);
145
-		if(isset($this->_sortable)){
145
+		if (isset($this->_sortable)) {
146 146
 			$table->setSortable($this->_sortable);
147 147
 		}
148 148
 	}
149 149
 
150 150
 
151 151
 
152
-	protected function _generateContent($table){
152
+	protected function _generateContent($table) {
153 153
 		$objects=$this->_modelInstance;
154
-		if(isset($this->_pagination)){
154
+		if (isset($this->_pagination)) {
155 155
 			$objects=$this->_pagination->getObjects($this->_modelInstance);
156 156
 		}
157 157
 			InstanceViewer::setIndex(0);
158 158
 			$table->fromDatabaseObjects($objects, function($instance) use($table){
159 159
 				return $this->_generateRow($instance, $table);
160 160
 			});
161
-		if($table->getRowCount()==0){
161
+		if ($table->getRowCount()==0) {
162 162
 			$result=$table->addRow();
163 163
 			$result->mergeRow();
164 164
 			$result->setValues([$this->_emptyMessage]);
165 165
 		}
166 166
 	}
167 167
 
168
-	protected function _generateRow($instance,&$table,$checkedClass=null){
168
+	protected function _generateRow($instance, &$table, $checkedClass=null) {
169 169
 		$this->_instanceViewer->setInstance($instance);
170 170
 		InstanceViewer::$index++;
171
-		$values= $this->_instanceViewer->getValues();
171
+		$values=$this->_instanceViewer->getValues();
172 172
 		$id=$this->_instanceViewer->getIdentifier();
173
-		if($this->_hasCheckboxes){
174
-			$ck=new HtmlCheckbox("ck-".$this->identifier."-".$id,"");
173
+		if ($this->_hasCheckboxes) {
174
+			$ck=new HtmlCheckbox("ck-".$this->identifier."-".$id, "");
175 175
 			$ck->setOnChange("event.stopPropagation();");
176 176
 			$field=$ck->getField();
177
-			$field->setProperty("value",$id);
177
+			$field->setProperty("value", $id);
178 178
 			$field->setProperty("name", "selection[]");
179
-			if(isset($checkedClass))
179
+			if (isset($checkedClass))
180 180
 				$field->setClass($checkedClass);
181 181
 			\array_unshift($values, $ck);
182 182
 		}
183 183
 		$result=$table->newRow();
184 184
 		$result->setIdentifier($this->identifier."-tr-".$id);
185
-		$result->setProperty("data-ajax",$id);
185
+		$result->setProperty("data-ajax", $id);
186 186
 		$result->setValues($values);
187
-		$result->addToProperty("class",$this->_rowClass);
187
+		$result->addToProperty("class", $this->_rowClass);
188 188
 		return $result;
189 189
 	}
190 190
 
191
-	protected function _generatePagination($table,$js=NULL){
192
-		if(isset($this->_toolbar)){
193
-			if($this->_toolbarPosition==PositionInTable::FOOTER)
191
+	protected function _generatePagination($table, $js=NULL) {
192
+		if (isset($this->_toolbar)) {
193
+			if ($this->_toolbarPosition==PositionInTable::FOOTER)
194 194
 				$this->_toolbar->setFloated("left");
195 195
 		}
196 196
 		$footer=$table->getFooter();
197 197
 		$footer->mergeCol();
198
-		$menu=new HtmlPaginationMenu("pagination-".$this->identifier,$this->_pagination->getPagesNumbers());
198
+		$menu=new HtmlPaginationMenu("pagination-".$this->identifier, $this->_pagination->getPagesNumbers());
199 199
 		$menu->floatRight();
200 200
 		$menu->setActiveItem($this->_pagination->getPage()-1);
201 201
 		$footer->addValues($menu);
202
-		$this->_associatePaginationBehavior($menu,$js);
202
+		$this->_associatePaginationBehavior($menu, $js);
203 203
 	}
204 204
 
205
-	protected function _associatePaginationBehavior(HtmlMenu $menu,JsUtils $js=NULL){
206
-		if(isset($this->_urls["refresh"])){
207
-			$menu->postOnClick($this->_urls["refresh"],"{'p':$(this).attr('data-page')}",$this->getRefreshSelector(),["preventDefault"=>false,"jqueryDone"=>"replaceWith"]);
205
+	protected function _associatePaginationBehavior(HtmlMenu $menu, JsUtils $js=NULL) {
206
+		if (isset($this->_urls["refresh"])) {
207
+			$menu->postOnClick($this->_urls["refresh"], "{'p':$(this).attr('data-page')}", $this->getRefreshSelector(), ["preventDefault"=>false, "jqueryDone"=>"replaceWith"]);
208 208
 		}
209 209
 	}
210 210
 
211
-	protected function _getFieldName($index){
211
+	protected function _getFieldName($index) {
212 212
 		$fieldName=parent::_getFieldName($index);
213
-		if(\is_object($fieldName))
213
+		if (\is_object($fieldName))
214 214
 			$fieldName="field-".$index;
215 215
 		return $fieldName."[]";
216 216
 	}
217 217
 
218
-	protected function _getFieldCaption($index){
218
+	protected function _getFieldCaption($index) {
219 219
 		return null;
220 220
 	}
221 221
 
222
-	protected function _setToolbarPosition($table,$captions=NULL){
223
-		switch ($this->_toolbarPosition){
222
+	protected function _setToolbarPosition($table, $captions=NULL) {
223
+		switch ($this->_toolbarPosition) {
224 224
 			case PositionInTable::BEFORETABLE:
225 225
 			case PositionInTable::AFTERTABLE:
226
-				if(isset($this->_compileParts)===false){
226
+				if (isset($this->_compileParts)===false) {
227 227
 					$this->content[$this->_toolbarPosition]=$this->_toolbar;
228 228
 				}
229 229
 				break;
230 230
 			case PositionInTable::HEADER:
231 231
 			case PositionInTable::FOOTER:
232 232
 			case PositionInTable::BODY:
233
-				$this->addToolbarRow($this->_toolbarPosition,$table, $captions);
233
+				$this->addToolbarRow($this->_toolbarPosition, $table, $captions);
234 234
 				break;
235 235
 		}
236 236
 	}
@@ -242,16 +242,16 @@  discard block
 block discarded – undo
242 242
 	 * @param callable $callback function called after the field compilation
243 243
 	 * @return DataTable
244 244
 	 */
245
-	public function afterCompile($index,$callback){
246
-		$this->_instanceViewer->afterCompile($index,$callback);
245
+	public function afterCompile($index, $callback) {
246
+		$this->_instanceViewer->afterCompile($index, $callback);
247 247
 		return $this;
248 248
 	}
249 249
 
250
-	private function addToolbarRow($part,$table,$captions){
250
+	private function addToolbarRow($part, $table, $captions) {
251 251
 		$hasPart=$table->hasPart($part);
252
-		if($hasPart){
252
+		if ($hasPart) {
253 253
 			$row=$table->getPart($part)->addRow(\sizeof($captions));
254
-		}else{
254
+		} else {
255 255
 			$row=$table->getPart($part)->getRow(0);
256 256
 		}
257 257
 		$row->mergeCol();
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
 	 * @see Widget::getHtmlComponent()
264 264
 	 * @return HtmlTable
265 265
 	 */
266
-	public function getHtmlComponent(){
266
+	public function getHtmlComponent() {
267 267
 		return $this->content["table"];
268 268
 	}
269 269
 
@@ -277,12 +277,12 @@  discard block
 block discarded – undo
277 277
 	 * @return DataTable
278 278
 	 */
279 279
 	public function setUrls($urls) {
280
-		if(\is_array($urls)){
281
-			$this->_urls["refresh"]=JArray::getValue($urls, "refresh",0);
282
-			$this->_urls["edit"]=JArray::getValue($urls, "edit",1);
283
-			$this->_urls["delete"]=JArray::getValue($urls, "delete",2);
284
-		}else{
285
-			$this->_urls=["refresh"=>$urls,"edit"=>$urls,"delete"=>$urls];
280
+		if (\is_array($urls)) {
281
+			$this->_urls["refresh"]=JArray::getValue($urls, "refresh", 0);
282
+			$this->_urls["edit"]=JArray::getValue($urls, "edit", 1);
283
+			$this->_urls["delete"]=JArray::getValue($urls, "delete", 2);
284
+		} else {
285
+			$this->_urls=["refresh"=>$urls, "edit"=>$urls, "delete"=>$urls];
286 286
 		}
287 287
 		return $this;
288 288
 	}
@@ -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 paginate($page,$total_rowcount,$items_per_page=10,$pages_visibles=null){
299
-		$this->_pagination=new Pagination($items_per_page,$pages_visibles,$page,$total_rowcount);
298
+	public function paginate($page, $total_rowcount, $items_per_page=10, $pages_visibles=null) {
299
+		$this->_pagination=new Pagination($items_per_page, $pages_visibles, $page, $total_rowcount);
300 300
 		return $this;
301 301
 	}
302 302
 
@@ -307,8 +307,8 @@  discard block
 block discarded – undo
307 307
 	 * @param number $pages_visibles The number of visible pages in the Pagination component
308 308
 	 * @return DataTable
309 309
 	 */
310
-	public function autoPaginate($page=1,$items_per_page=10,$pages_visibles=4){
311
-		$this->_pagination=new Pagination($items_per_page,$pages_visibles,$page);
310
+	public function autoPaginate($page=1, $items_per_page=10, $pages_visibles=4) {
311
+		$this->_pagination=new Pagination($items_per_page, $pages_visibles, $page);
312 312
 		return $this;
313 313
 	}
314 314
 
@@ -318,20 +318,20 @@  discard block
 block discarded – undo
318 318
 	 * @param array $compileParts
319 319
 	 * @return DataTable
320 320
 	 */
321
-	public function refresh($compileParts=["tbody"]){
321
+	public function refresh($compileParts=["tbody"]) {
322 322
 		$this->_compileParts=$compileParts;
323 323
 		return $this;
324 324
 	}
325 325
 
326 326
 
327
-	public function addSearchInToolbar($position=Direction::RIGHT){
327
+	public function addSearchInToolbar($position=Direction::RIGHT) {
328 328
 		return $this->addInToolbar($this->getSearchField())->setPosition($position);
329 329
 	}
330 330
 
331
-	public function getSearchField(){
332
-		if(isset($this->_searchField)===false){
333
-			$this->_searchField=new HtmlInput("search-".$this->identifier,"search","","Search...");
334
-			$this->_searchField->addIcon("search",Direction::RIGHT);
331
+	public function getSearchField() {
332
+		if (isset($this->_searchField)===false) {
333
+			$this->_searchField=new HtmlInput("search-".$this->identifier, "search", "", "Search...");
334
+			$this->_searchField->addIcon("search", Direction::RIGHT);
335 335
 		}
336 336
 		return $this->_searchField;
337 337
 	}
@@ -347,7 +347,7 @@  discard block
 block discarded – undo
347 347
 		return $this;
348 348
 	}
349 349
 
350
-	public function asForm(){
350
+	public function asForm() {
351 351
 		return $this->getForm();
352 352
 	}
353 353
 
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
 
356 356
 	protected function getTargetSelector() {
357 357
 		$result=$this->_targetSelector;
358
-		if(!isset($result))
358
+		if (!isset($result))
359 359
 			$result="#".$this->identifier;
360 360
 		return $result;
361 361
 	}
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
 	}
372 372
 
373 373
 	public function getRefreshSelector() {
374
-		if(isset($this->_refreshSelector))
374
+		if (isset($this->_refreshSelector))
375 375
 			return $this->_refreshSelector;
376 376
 		return "#".$this->identifier." tbody";
377 377
 	}
@@ -389,9 +389,9 @@  discard block
 block discarded – undo
389 389
 	 * {@inheritDoc}
390 390
 	 * @see \Ajax\common\Widget::show()
391 391
 	 */
392
-	public function show($modelInstance){
393
-		if(\is_array($modelInstance)){
394
-			if(\is_array(array_values($modelInstance)[0]))
392
+	public function show($modelInstance) {
393
+		if (\is_array($modelInstance)) {
394
+			if (\is_array(array_values($modelInstance)[0]))
395 395
 				$modelInstance=\json_decode(\json_encode($modelInstance), FALSE);
396 396
 		}
397 397
 		$this->_modelInstance=$modelInstance;
@@ -426,24 +426,24 @@  discard block
 block discarded – undo
426 426
 		return $this;
427 427
 	}
428 428
 
429
-	public function setActiveRowSelector($class="active",$event="click",$multiple=false){
430
-		$this->_self->setActiveRowSelector($class,$event,$multiple);
429
+	public function setActiveRowSelector($class="active", $event="click", $multiple=false) {
430
+		$this->_self->setActiveRowSelector($class, $event, $multiple);
431 431
 		return $this;
432 432
 	}
433 433
 
434
-	public function hideColumn($colIndex){
435
-		if(!\is_array($this->_hiddenColumns))
434
+	public function hideColumn($colIndex) {
435
+		if (!\is_array($this->_hiddenColumns))
436 436
 			$this->_hiddenColumns=[];
437 437
 		$this->_hiddenColumns[]=$colIndex;
438 438
 		return $this;
439 439
 	}
440 440
 
441
-	public function setColWidth($colIndex,$width){
441
+	public function setColWidth($colIndex, $width) {
442 442
 		$this->_colWidths[$colIndex]=$width;
443 443
 		return $this;
444 444
 	}
445 445
 	public function setColWidths($_colWidths) {
446
-		$this->_colWidths = $_colWidths;
446
+		$this->_colWidths=$_colWidths;
447 447
 		return $this;
448 448
 	}
449 449
 }
Please login to merge, or discard this patch.
Ajax/semantic/widgets/datatable/DataTableFieldAsTrait.php 1 patch
Spacing   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -12,19 +12,19 @@  discard block
 block discarded – undo
12 12
  * @property boolean $_visibleHover
13 13
  * @property InstanceViewer $_instanceViewer
14 14
  */
15
-trait DataTableFieldAsTrait{
15
+trait DataTableFieldAsTrait {
16 16
 	abstract public function addField($field);
17
-	abstract public function insertField($index,$field);
18
-	abstract public function insertInField($index,$field);
19
-	abstract public function fieldAs($index,$type,$attributes=NULL);
17
+	abstract public function insertField($index, $field);
18
+	abstract public function insertInField($index, $field);
19
+	abstract public function fieldAs($index, $type, $attributes=NULL);
20 20
 	/**
21 21
 	 * @param string $caption
22 22
 	 * @param callable $callback
23 23
 	 * @param boolean $visibleHover
24 24
 	 * @return callable
25 25
 	 */
26
-	private function getFieldButtonCallable($caption,$visibleHover=true,$callback=null){
27
-		return $this->getCallable("getFieldButton",[$caption,$visibleHover],$callback);
26
+	private function getFieldButtonCallable($caption, $visibleHover=true, $callback=null) {
27
+		return $this->getCallable("getFieldButton", [$caption, $visibleHover], $callback);
28 28
 	}
29 29
 
30 30
 	/**
@@ -33,19 +33,19 @@  discard block
 block discarded – undo
33 33
 	 * @param callable $callback
34 34
 	 * @return callable
35 35
 	 */
36
-	private function getCallable($thisCallback,$parameters,$callback=null){
37
-		$result=function($instance) use($thisCallback,$parameters,$callback){
38
-			$object=call_user_func_array(array($this,$thisCallback), $parameters);
39
-			if(isset($callback)){
40
-				if(\is_callable($callback)){
41
-					$callback($object,$instance);
36
+	private function getCallable($thisCallback, $parameters, $callback=null) {
37
+		$result=function($instance) use($thisCallback, $parameters, $callback){
38
+			$object=call_user_func_array(array($this, $thisCallback), $parameters);
39
+			if (isset($callback)) {
40
+				if (\is_callable($callback)) {
41
+					$callback($object, $instance);
42 42
 				}
43 43
 			}
44
-			if($object instanceof HtmlSemDoubleElement){
45
-				$object->setProperty("data-ajax",$this->_instanceViewer->getIdentifier());
46
-				if($object->propertyContains("class","visibleover")){
44
+			if ($object instanceof HtmlSemDoubleElement) {
45
+				$object->setProperty("data-ajax", $this->_instanceViewer->getIdentifier());
46
+				if ($object->propertyContains("class", "visibleover")) {
47 47
 					$this->_visibleHover=true;
48
-					$object->setProperty("style","visibility:hidden;");
48
+					$object->setProperty("style", "visibility:hidden;");
49 49
 				}
50 50
 			}
51 51
 			return $object;
@@ -57,9 +57,9 @@  discard block
 block discarded – undo
57 57
 	 * @param string $caption
58 58
 	 * @return HtmlButton
59 59
 	 */
60
-	private function getFieldButton($caption,$visibleHover=true){
61
-		$bt= new HtmlButton("",$caption);
62
-		if($visibleHover)
60
+	private function getFieldButton($caption, $visibleHover=true) {
61
+		$bt=new HtmlButton("", $caption);
62
+		if ($visibleHover)
63 63
 			$this->_visibleOver($bt);
64 64
 			return $bt;
65 65
 	}
@@ -73,19 +73,19 @@  discard block
 block discarded – undo
73 73
 	 * @param array $attributes associative array (<b>ajax</b> key is for ajax post)
74 74
 	 * @return \Ajax\semantic\widgets\datatable\DataTable
75 75
 	 */
76
-	public function fieldAsSubmit($index,$cssStyle=NULL,$url=NULL,$responseElement=NULL,$attributes=NULL){
77
-		return $this->_fieldAs(function($id,$name,$value,$caption) use ($url,$responseElement,$cssStyle,$index,$attributes){
78
-			$button=new HtmlButton($id,$value,$cssStyle);
79
-			$button->postOnClick($url,"$(event.target).closest('tr').find(':input').serialize()",$responseElement,$attributes["ajax"]);
80
-			if(!isset($attributes["visibleHover"]) || $attributes["visibleHover"])
76
+	public function fieldAsSubmit($index, $cssStyle=NULL, $url=NULL, $responseElement=NULL, $attributes=NULL) {
77
+		return $this->_fieldAs(function($id, $name, $value, $caption) use ($url, $responseElement, $cssStyle, $index, $attributes){
78
+			$button=new HtmlButton($id, $value, $cssStyle);
79
+			$button->postOnClick($url, "$(event.target).closest('tr').find(':input').serialize()", $responseElement, $attributes["ajax"]);
80
+			if (!isset($attributes["visibleHover"]) || $attributes["visibleHover"])
81 81
 				$this->_visibleOver($button);
82 82
 				return $button;
83
-		}, $index,$attributes);
83
+		}, $index, $attributes);
84 84
 	}
85 85
 
86
-	protected function _visibleOver($element){
86
+	protected function _visibleOver($element) {
87 87
 		$this->_visibleHover=true;
88
-		return $element->addToProperty("class", "visibleover")->setProperty("style","visibility:hidden;");
88
+		return $element->addToProperty("class", "visibleover")->setProperty("style", "visibility:hidden;");
89 89
 	}
90 90
 
91 91
 	/**
@@ -95,8 +95,8 @@  discard block
 block discarded – undo
95 95
 	 * @param boolean $visibleHover
96 96
 	 * @return \Ajax\semantic\widgets\datatable\DataTable
97 97
 	 */
98
-	public function addFieldButton($caption,$visibleHover=true,$callback=null){
99
-		$this->addField($this->getCallable("getFieldButton",[$caption,$visibleHover],$callback));
98
+	public function addFieldButton($caption, $visibleHover=true, $callback=null) {
99
+		$this->addField($this->getCallable("getFieldButton", [$caption, $visibleHover], $callback));
100 100
 		return $this;
101 101
 	}
102 102
 
@@ -107,8 +107,8 @@  discard block
 block discarded – undo
107 107
 	 * @param callable $callback
108 108
 	 * @return \Ajax\semantic\widgets\datatable\DataTable
109 109
 	 */
110
-	public function insertFieldButton($index,$caption,$visibleHover=true,$callback=null){
111
-		$this->insertField($index, $this->getFieldButtonCallable($caption,$visibleHover,$callback));
110
+	public function insertFieldButton($index, $caption, $visibleHover=true, $callback=null) {
111
+		$this->insertField($index, $this->getFieldButtonCallable($caption, $visibleHover, $callback));
112 112
 		return $this;
113 113
 	}
114 114
 
@@ -119,25 +119,25 @@  discard block
 block discarded – undo
119 119
 	 * @param callable $callback
120 120
 	 * @return \Ajax\semantic\widgets\datatable\DataTable
121 121
 	 */
122
-	public function insertInFieldButton($index,$caption,$visibleHover=true,$callback=null){
123
-		$this->insertInField($index, $this->getFieldButtonCallable($caption,$visibleHover,$callback));
122
+	public function insertInFieldButton($index, $caption, $visibleHover=true, $callback=null) {
123
+		$this->insertInField($index, $this->getFieldButtonCallable($caption, $visibleHover, $callback));
124 124
 		return $this;
125 125
 	}
126 126
 
127
-	private function addDefaultButton($icon,$class=null,$visibleHover=true,$callback=null){
128
-		$this->addField($this->getCallable("getDefaultButton",[$icon,$class,$visibleHover],$callback));
127
+	private function addDefaultButton($icon, $class=null, $visibleHover=true, $callback=null) {
128
+		$this->addField($this->getCallable("getDefaultButton", [$icon, $class, $visibleHover], $callback));
129 129
 		return $this;
130 130
 	}
131 131
 
132
-	private function insertDefaultButtonIn($index,$icon,$class=null,$visibleHover=true,$callback=null){
133
-		$this->insertInField($index,$this->getCallable("getDefaultButton",[$icon,$class,$visibleHover],$callback));
132
+	private function insertDefaultButtonIn($index, $icon, $class=null, $visibleHover=true, $callback=null) {
133
+		$this->insertInField($index, $this->getCallable("getDefaultButton", [$icon, $class, $visibleHover], $callback));
134 134
 		return $this;
135 135
 	}
136 136
 
137
-	private function getDefaultButton($icon,$class=null,$visibleHover=true){
138
-		$bt=$this->getFieldButton("",$visibleHover);
137
+	private function getDefaultButton($icon, $class=null, $visibleHover=true) {
138
+		$bt=$this->getFieldButton("", $visibleHover);
139 139
 		$bt->asIcon($icon);
140
-		if(isset($class))
140
+		if (isset($class))
141 141
 			$bt->addClass($class);
142 142
 		return $bt;
143 143
 	}
@@ -148,30 +148,30 @@  discard block
 block discarded – undo
148 148
 	 * @param callable $callback
149 149
 	 * @return DataTable
150 150
 	 */
151
-	public function addDeleteButton($visibleHover=true,$deleteBehavior=[],$callback=null){
151
+	public function addDeleteButton($visibleHover=true, $deleteBehavior=[], $callback=null) {
152 152
 		$this->_deleteBehavior=$deleteBehavior;
153
-		return $this->addDefaultButton("remove","_delete red basic",$visibleHover,$callback);
153
+		return $this->addDefaultButton("remove", "_delete red basic", $visibleHover, $callback);
154 154
 	}
155 155
 
156
-	public function addEditButton($visibleHover=true,$editBehavior=[],$callback=null){
156
+	public function addEditButton($visibleHover=true, $editBehavior=[], $callback=null) {
157 157
 		$this->_editBehavior=$editBehavior;
158
-		return $this->addDefaultButton("edit","_edit basic",$visibleHover,$callback);
158
+		return $this->addDefaultButton("edit", "_edit basic", $visibleHover, $callback);
159 159
 	}
160 160
 
161
-	public function addEditDeleteButtons($visibleHover=true,$behavior=[],$callbackEdit=null,$callbackDelete=null){
162
-		$this->addEditButton($visibleHover,$behavior,$callbackEdit);
161
+	public function addEditDeleteButtons($visibleHover=true, $behavior=[], $callbackEdit=null, $callbackDelete=null) {
162
+		$this->addEditButton($visibleHover, $behavior, $callbackEdit);
163 163
 		$index=$this->_instanceViewer->visiblePropertiesCount()-1;
164
-		$this->insertDeleteButtonIn($index,$visibleHover,$behavior,$callbackDelete);
164
+		$this->insertDeleteButtonIn($index, $visibleHover, $behavior, $callbackDelete);
165 165
 		return $this;
166 166
 	}
167 167
 
168
-	public function insertDeleteButtonIn($index,$visibleHover=true,$deleteBehavior=[],$callback=null){
168
+	public function insertDeleteButtonIn($index, $visibleHover=true, $deleteBehavior=[], $callback=null) {
169 169
 		$this->_deleteBehavior=$deleteBehavior;
170
-		return $this->insertDefaultButtonIn($index,"remove","_delete red basic",$visibleHover,$callback);
170
+		return $this->insertDefaultButtonIn($index, "remove", "_delete red basic", $visibleHover, $callback);
171 171
 	}
172 172
 
173
-	public function insertEditButtonIn($index,$visibleHover=true,$editBehavior=[],$callback=null){
173
+	public function insertEditButtonIn($index, $visibleHover=true, $editBehavior=[], $callback=null) {
174 174
 		$this->_editBehavior=$editBehavior;
175
-		return $this->insertDefaultButtonIn($index,"edit","_edit basic",$visibleHover,$callback);
175
+		return $this->insertDefaultButtonIn($index, "edit", "_edit basic", $visibleHover, $callback);
176 176
 	}
177 177
 }
Please login to merge, or discard this patch.
Ajax/semantic/widgets/base/FieldAsTrait.php 1 patch
Spacing   +110 added lines, -110 removed lines patch added patch discarded remove patch
@@ -27,23 +27,23 @@  discard block
 block discarded – undo
27 27
  * @property boolean $_edition
28 28
  * @property mixed _modelInstance
29 29
  */
30
-trait FieldAsTrait{
30
+trait FieldAsTrait {
31 31
 
32
-	abstract protected function _getFieldIdentifier($prefix,$name="");
33
-	abstract public function setValueFunction($index,$callback);
32
+	abstract protected function _getFieldIdentifier($prefix, $name="");
33
+	abstract public function setValueFunction($index, $callback);
34 34
 	abstract protected function _getFieldName($index);
35 35
 	abstract protected function _getFieldCaption($index);
36
-	abstract protected function _buttonAsSubmit(BaseHtml &$button,$event,$url,$responseElement=NULL,$parameters=NULL);
36
+	abstract protected function _buttonAsSubmit(BaseHtml&$button, $event, $url, $responseElement=NULL, $parameters=NULL);
37 37
 
38 38
 	/**
39 39
 	 * @param HtmlFormField $element
40 40
 	 * @param array $attributes
41 41
 	 */
42
-	protected function _applyAttributes($element,&$attributes,$index){
43
-		if(isset($attributes["jsCallback"])){
42
+	protected function _applyAttributes($element, &$attributes, $index) {
43
+		if (isset($attributes["jsCallback"])) {
44 44
 			$callback=$attributes["jsCallback"];
45
-			if(\is_callable($callback)){
46
-				$callback($element,$this->_modelInstance,$index);
45
+			if (\is_callable($callback)) {
46
+				$callback($element, $this->_modelInstance, $index);
47 47
 				unset($attributes["jsCallback"]);
48 48
 			}
49 49
 		}
@@ -53,43 +53,43 @@  discard block
 block discarded – undo
53 53
 		$element->fromArray($attributes);
54 54
 	}
55 55
 
56
-	private function _getLabelField($caption,$icon=NULL){
57
-		$label=new HtmlLabel($this->_getFieldIdentifier("lbl"),$caption,$icon);
56
+	private function _getLabelField($caption, $icon=NULL) {
57
+		$label=new HtmlLabel($this->_getFieldIdentifier("lbl"), $caption, $icon);
58 58
 		return $label;
59 59
 	}
60 60
 
61 61
 
62
-	protected function _addRules($element,&$attributes){
63
-		if(isset($attributes["rules"])){
62
+	protected function _addRules($element, &$attributes) {
63
+		if (isset($attributes["rules"])) {
64 64
 			$rules=$attributes["rules"];
65
-			if(\is_array($rules)){
65
+			if (\is_array($rules)) {
66 66
 				$element->addRules($rules);
67 67
 			}
68
-			else{
68
+			else {
69 69
 				$element->addRule($rules);
70 70
 			}
71 71
 			unset($attributes["rules"]);
72 72
 		}
73 73
 	}
74 74
 
75
-	protected function _prepareFormFields(&$field,$name,&$attributes){
75
+	protected function _prepareFormFields(&$field, $name, &$attributes) {
76 76
 		$field->setName($name);
77 77
 		$this->_addRules($field, $attributes);
78 78
 		return $field;
79 79
 	}
80 80
 
81
-	protected function _fieldAs($elementCallback,&$index,$attributes=NULL,$prefix=null){
82
-		$this->setValueFunction($index,function($value,$instance,$index) use (&$attributes,$elementCallback,$prefix){
81
+	protected function _fieldAs($elementCallback, &$index, $attributes=NULL, $prefix=null) {
82
+		$this->setValueFunction($index, function($value, $instance, $index) use (&$attributes, $elementCallback, $prefix){
83 83
 			$caption=$this->_getFieldCaption($index);
84 84
 			$name=$this->_getFieldName($index);
85
-			$id=$this->_getFieldIdentifier($prefix,$name);
86
-			if(isset($attributes["name"])){
85
+			$id=$this->_getFieldIdentifier($prefix, $name);
86
+			if (isset($attributes["name"])) {
87 87
 				$name=$attributes["name"];
88 88
 				unset($attributes["name"]);
89 89
 			}
90
-			$element=$elementCallback($id,$name,$value,$caption);
91
-			if(\is_array($attributes)){
92
-				$this->_applyAttributes($element, $attributes,$index);
90
+			$element=$elementCallback($id, $name, $value, $caption);
91
+			if (\is_array($attributes)) {
92
+				$this->_applyAttributes($element, $attributes, $index);
93 93
 			}
94 94
 			$element->setDisabled(!$this->_edition);
95 95
 			return $element;
@@ -98,178 +98,178 @@  discard block
 block discarded – undo
98 98
 	}
99 99
 
100 100
 
101
-	public function fieldAsProgress($index,$label=NULL, $attributes=array()){
102
-		$this->setValueFunction($index,function($value) use($label,$attributes){
103
-			$pb=new HtmlProgress($this->_getFieldIdentifier("pb"),$value,$label,$attributes);
101
+	public function fieldAsProgress($index, $label=NULL, $attributes=array()) {
102
+		$this->setValueFunction($index, function($value) use($label, $attributes){
103
+			$pb=new HtmlProgress($this->_getFieldIdentifier("pb"), $value, $label, $attributes);
104 104
 			return $pb;
105 105
 		});
106 106
 			return $this;
107 107
 	}
108 108
 
109
-	public function fieldAsRating($index,$max=5, $icon=""){
110
-		$this->setValueFunction($index,function($value) use($max,$icon){
111
-			$rating=new HtmlRating($this->_getFieldIdentifier("rat"),$value,$max,$icon);
109
+	public function fieldAsRating($index, $max=5, $icon="") {
110
+		$this->setValueFunction($index, function($value) use($max, $icon){
111
+			$rating=new HtmlRating($this->_getFieldIdentifier("rat"), $value, $max, $icon);
112 112
 			return $rating;
113 113
 		});
114 114
 			return $this;
115 115
 	}
116 116
 
117
-	public function fieldAsLabel($index,$icon=NULL,$attributes=NULL){
118
-		return $this->_fieldAs(function($id,$name,$value) use($icon){
119
-			$lbl=new HtmlLabel($id,$value);
120
-			if(isset($icon))
117
+	public function fieldAsLabel($index, $icon=NULL, $attributes=NULL) {
118
+		return $this->_fieldAs(function($id, $name, $value) use($icon){
119
+			$lbl=new HtmlLabel($id, $value);
120
+			if (isset($icon))
121 121
 				$lbl->addIcon($icon);
122 122
 				return $lbl;
123
-		}, $index,$attributes,"label");
123
+		}, $index, $attributes, "label");
124 124
 	}
125 125
 
126
-	public function fieldAsHeader($index,$niveau=1,$icon=NULL,$attributes=NULL){
127
-		return $this->_fieldAs(function($id,$name,$value) use($niveau,$icon){
128
-			$header=new HtmlHeader($id,$niveau,$value);
129
-			if(isset($icon))
126
+	public function fieldAsHeader($index, $niveau=1, $icon=NULL, $attributes=NULL) {
127
+		return $this->_fieldAs(function($id, $name, $value) use($niveau, $icon){
128
+			$header=new HtmlHeader($id, $niveau, $value);
129
+			if (isset($icon))
130 130
 				$header->asIcon($icon, $value);
131 131
 			return $header;
132
-		}, $index,$attributes,"header");
132
+		}, $index, $attributes, "header");
133 133
 	}
134 134
 
135 135
 
136
-	public function fieldAsImage($index,$size=Size::MINI,$circular=false){
137
-		$this->setValueFunction($index,function($img) use($size,$circular){
138
-			$image=new HtmlImage($this->_getFieldIdentifier("image"),$img);$image->setSize($size);if($circular)$image->setCircular();
136
+	public function fieldAsImage($index, $size=Size::MINI, $circular=false) {
137
+		$this->setValueFunction($index, function($img) use($size, $circular){
138
+			$image=new HtmlImage($this->_getFieldIdentifier("image"), $img); $image->setSize($size); if ($circular)$image->setCircular();
139 139
 			return $image;
140 140
 		});
141 141
 			return $this;
142 142
 	}
143 143
 
144
-	public function fieldAsFlag($index){
145
-		$this->setValueFunction($index,function($flag){
146
-			$flag=new HtmlFlag($this->_getFieldIdentifier("flag"),$flag);
144
+	public function fieldAsFlag($index) {
145
+		$this->setValueFunction($index, function($flag) {
146
+			$flag=new HtmlFlag($this->_getFieldIdentifier("flag"), $flag);
147 147
 			return $flag;
148 148
 		});
149 149
 			return $this;
150 150
 	}
151 151
 
152
-	public function fieldAsAvatar($index,$attributes=NULL){
153
-		return $this->_fieldAs(function($id,$name,$value){
154
-			$img=new HtmlImage($id,$value);
152
+	public function fieldAsAvatar($index, $attributes=NULL) {
153
+		return $this->_fieldAs(function($id, $name, $value) {
154
+			$img=new HtmlImage($id, $value);
155 155
 			$img->asAvatar();
156 156
 			return $img;
157
-		}, $index,$attributes,"avatar");
157
+		}, $index, $attributes, "avatar");
158 158
 	}
159 159
 
160
-	public function fieldAsRadio($index,$attributes=NULL){
161
-		return $this->_fieldAs(function($id,$name,$value) use($attributes){
162
-			$input= new HtmlRadio($id,$name,$value,$value);
160
+	public function fieldAsRadio($index, $attributes=NULL) {
161
+		return $this->_fieldAs(function($id, $name, $value) use($attributes){
162
+			$input=new HtmlRadio($id, $name, $value, $value);
163 163
 			return $this->_prepareFormFields($input, $name, $attributes);
164
-		}, $index,$attributes,"radio");
164
+		}, $index, $attributes, "radio");
165 165
 	}
166 166
 
167
-	public function fieldAsRadios($index,$elements=[],$attributes=NULL){
168
-		return $this->_fieldAs(function($id,$name,$value,$caption) use ($elements){
169
-			return HtmlFormFields::radios($name,$elements,$caption,$value);
170
-		}, $index,$attributes,"radios");
167
+	public function fieldAsRadios($index, $elements=[], $attributes=NULL) {
168
+		return $this->_fieldAs(function($id, $name, $value, $caption) use ($elements){
169
+			return HtmlFormFields::radios($name, $elements, $caption, $value);
170
+		}, $index, $attributes, "radios");
171 171
 	}
172 172
 
173
-	public function fieldAsInput($index,$attributes=NULL){
174
-		return $this->_fieldAs(function($id,$name,$value,$caption) use ($attributes){
175
-			$input= new HtmlFormInput($id,$caption,"text",$value);
173
+	public function fieldAsInput($index, $attributes=NULL) {
174
+		return $this->_fieldAs(function($id, $name, $value, $caption) use ($attributes){
175
+			$input=new HtmlFormInput($id, $caption, "text", $value);
176 176
 			return $this->_prepareFormFields($input, $name, $attributes);
177
-		}, $index,$attributes,"input");
177
+		}, $index, $attributes, "input");
178 178
 	}
179 179
 
180
-	public function fieldAsTextarea($index,$attributes=NULL){
181
-		return $this->_fieldAs(function($id,$name,$value,$caption) use ($attributes){
182
-			$textarea=new HtmlFormTextarea($id,$caption,$value);
180
+	public function fieldAsTextarea($index, $attributes=NULL) {
181
+		return $this->_fieldAs(function($id, $name, $value, $caption) use ($attributes){
182
+			$textarea=new HtmlFormTextarea($id, $caption, $value);
183 183
 			return $this->_prepareFormFields($textarea, $name, $attributes);
184
-		}, $index,$attributes,"textarea");
184
+		}, $index, $attributes, "textarea");
185 185
 	}
186 186
 
187
-	public function fieldAsHidden($index,$attributes=NULL){
188
-		if(!\is_array($attributes)){
187
+	public function fieldAsHidden($index, $attributes=NULL) {
188
+		if (!\is_array($attributes)) {
189 189
 			$attributes=[];
190 190
 		}
191 191
 		$attributes["inputType"]="hidden";
192
-		return $this->fieldAsInput($index,$attributes);
192
+		return $this->fieldAsInput($index, $attributes);
193 193
 	}
194 194
 
195
-	public function fieldAsCheckbox($index,$attributes=NULL){
196
-		return $this->_fieldAs(function($id,$name,$value,$caption) use($attributes){
197
-			if($caption===null || $caption==="")
195
+	public function fieldAsCheckbox($index, $attributes=NULL) {
196
+		return $this->_fieldAs(function($id, $name, $value, $caption) use($attributes){
197
+			if ($caption===null || $caption==="")
198 198
 				$caption="";
199
-			$input=new HtmlFormCheckbox($id,$caption,$this->_instanceViewer->getIdentifier());
199
+			$input=new HtmlFormCheckbox($id, $caption, $this->_instanceViewer->getIdentifier());
200 200
 			$input->setChecked(JString::isBooleanTrue($value));
201 201
 			return $this->_prepareFormFields($input, $name, $attributes);
202
-		}, $index,$attributes,"ck");
202
+		}, $index, $attributes, "ck");
203 203
 	}
204 204
 
205
-	public function fieldAsDropDown($index,$elements=[],$multiple=false,$attributes=NULL){
206
-		return $this->_fieldAs(function($id,$name,$value,$caption) use($elements,$multiple,$attributes){
207
-			$dd=new HtmlFormDropdown($id,$elements,$caption,$value);
208
-			$dd->asSelect($name,$multiple);
205
+	public function fieldAsDropDown($index, $elements=[], $multiple=false, $attributes=NULL) {
206
+		return $this->_fieldAs(function($id, $name, $value, $caption) use($elements, $multiple, $attributes){
207
+			$dd=new HtmlFormDropdown($id, $elements, $caption, $value);
208
+			$dd->asSelect($name, $multiple);
209 209
 			return $this->_prepareFormFields($dd, $name, $attributes);
210
-		}, $index,$attributes,"dd");
210
+		}, $index, $attributes, "dd");
211 211
 	}
212 212
 
213
-	public function fieldAsMessage($index,$attributes=NULL){
214
-		return $this->_fieldAs(function($id,$name,$value,$caption){
215
-			$mess= new HtmlMessage("message-".$id,$caption);
213
+	public function fieldAsMessage($index, $attributes=NULL) {
214
+		return $this->_fieldAs(function($id, $name, $value, $caption) {
215
+			$mess=new HtmlMessage("message-".$id, $caption);
216 216
 			$mess->addHeader($value);
217 217
 			return $mess;
218
-		}, $index,$attributes,"message");
218
+		}, $index, $attributes, "message");
219 219
 	}
220 220
 
221
-	public function fieldAsLink($index,$attributes=NULL){
222
-		return $this->_fieldAs(function($id,$name,$value,$caption){
223
-			$lnk= new HtmlLink("message-".$id,"#",$caption);
221
+	public function fieldAsLink($index, $attributes=NULL) {
222
+		return $this->_fieldAs(function($id, $name, $value, $caption) {
223
+			$lnk=new HtmlLink("message-".$id, "#", $caption);
224 224
 			return $lnk;
225
-		}, $index,$attributes,"link");
225
+		}, $index, $attributes, "link");
226 226
 	}
227 227
 
228 228
 	/**Change fields type
229 229
 	 * @param array $types an array or associative array $type=>$attributes
230 230
 	 */
231
-	public function fieldsAs(array $types){
231
+	public function fieldsAs(array $types) {
232 232
 		$i=0;
233
-		if(JArray::isAssociative($types)){
234
-			foreach ($types as $type=>$attributes){
235
-				if(\is_int($type))
236
-					$this->fieldAs($i++,$attributes,[]);
237
-				else{
238
-					$type=preg_replace('/\d/', '', $type );
239
-					$this->fieldAs($i++,$type,$attributes);
233
+		if (JArray::isAssociative($types)) {
234
+			foreach ($types as $type=>$attributes) {
235
+				if (\is_int($type))
236
+					$this->fieldAs($i++, $attributes, []);
237
+				else {
238
+					$type=preg_replace('/\d/', '', $type);
239
+					$this->fieldAs($i++, $type, $attributes);
240 240
 				}
241 241
 			}
242
-		}else{
243
-			foreach ($types as $type){
244
-				$this->fieldAs($i++,$type);
242
+		} else {
243
+			foreach ($types as $type) {
244
+				$this->fieldAs($i++, $type);
245 245
 			}
246 246
 		}
247 247
 	}
248 248
 
249
-	public function fieldAs($index,$type,$attributes=NULL){
249
+	public function fieldAs($index, $type, $attributes=NULL) {
250 250
 		$method="fieldAs".\ucfirst($type);
251
-		if(\method_exists($this, $method)){
252
-			if(!\is_array($attributes)){
251
+		if (\method_exists($this, $method)) {
252
+			if (!\is_array($attributes)) {
253 253
 				$attributes=[$index];
254
-			}else{
254
+			} else {
255 255
 				\array_unshift($attributes, $index);
256 256
 			}
257
-			\call_user_func_array([$this,$method], $attributes);
257
+			\call_user_func_array([$this, $method], $attributes);
258 258
 		}
259 259
 	}
260 260
 
261
-	public function fieldAsSubmit($index,$cssStyle=NULL,$url=NULL,$responseElement=NULL,$attributes=NULL){
262
-		return $this->_fieldAs(function($id,$name,$value,$caption) use ($url,$responseElement,$cssStyle,$attributes){
263
-			$button=new HtmlButton($id,$caption,$cssStyle);
264
-			$this->_buttonAsSubmit($button,"click",$url,$responseElement,@$attributes["ajax"]);
261
+	public function fieldAsSubmit($index, $cssStyle=NULL, $url=NULL, $responseElement=NULL, $attributes=NULL) {
262
+		return $this->_fieldAs(function($id, $name, $value, $caption) use ($url, $responseElement, $cssStyle, $attributes){
263
+			$button=new HtmlButton($id, $caption, $cssStyle);
264
+			$this->_buttonAsSubmit($button, "click", $url, $responseElement, @$attributes["ajax"]);
265 265
 			return $button;
266
-		}, $index,$attributes,"submit");
266
+		}, $index, $attributes, "submit");
267 267
 	}
268 268
 
269
-	public function fieldAsButton($index,$cssStyle=NULL,$attributes=NULL){
270
-		return $this->_fieldAs(function($id,$name,$value,$caption) use ($cssStyle){
271
-			$button=new HtmlButton($id,$value,$cssStyle);
269
+	public function fieldAsButton($index, $cssStyle=NULL, $attributes=NULL) {
270
+		return $this->_fieldAs(function($id, $name, $value, $caption) use ($cssStyle){
271
+			$button=new HtmlButton($id, $value, $cssStyle);
272 272
 			return $button;
273
-		}, $index,$attributes,"button");
273
+		}, $index, $attributes, "button");
274 274
 	}
275 275
 }
Please login to merge, or discard this patch.
Ajax/semantic/widgets/dataform/DataForm.php 1 patch
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -21,83 +21,83 @@  discard block
 block discarded – undo
21 21
 	use BaseTrait;
22 22
 
23 23
 	public function __construct($identifier, $modelInstance=NULL) {
24
-		parent::__construct($identifier, null,$modelInstance);
24
+		parent::__construct($identifier, null, $modelInstance);
25 25
 		$this->_form=new HtmlForm($identifier);
26 26
 		$this->_init(new FormInstanceViewer($identifier), "form", $this->_form, true);
27 27
 	}
28 28
 
29
-	protected function _getFieldIdentifier($prefix,$name=""){
29
+	protected function _getFieldIdentifier($prefix, $name="") {
30 30
 		return $this->identifier."-{$name}-".$this->_instanceViewer->getIdentifier();
31 31
 	}
32 32
 
33
-	public function compile(JsUtils $js=NULL,&$view=NULL){
34
-		if(!$this->_generated){
33
+	public function compile(JsUtils $js=NULL, &$view=NULL) {
34
+		if (!$this->_generated) {
35 35
 			$this->_instanceViewer->setInstance($this->_modelInstance);
36 36
 
37 37
 			$form=$this->content["form"];
38 38
 			$this->_generateContent($form);
39 39
 
40
-			if(isset($this->_toolbar)){
40
+			if (isset($this->_toolbar)) {
41 41
 				$this->_setToolbarPosition($form);
42 42
 			}
43
-			$this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE,"form",PositionInTable::AFTERTABLE]);
43
+			$this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE, "form", PositionInTable::AFTERTABLE]);
44 44
 			$this->_generated=true;
45 45
 		}
46
-		return parent::compile($js,$view);
46
+		return parent::compile($js, $view);
47 47
 	}
48 48
 
49 49
 	/**
50 50
 	 * @param HtmlForm $form
51 51
 	 */
52
-	protected function _generateContent($form){
53
-		$values= $this->_instanceViewer->getValues();
52
+	protected function _generateContent($form) {
53
+		$values=$this->_instanceViewer->getValues();
54 54
 		$count=$this->_instanceViewer->count();
55 55
 		$separators=$this->_instanceViewer->getSeparators();
56 56
 		$headers=$this->_instanceViewer->getHeaders();
57 57
 		$wrappers=$this->_instanceViewer->getWrappers();
58 58
 		\sort($separators);
59 59
 		$size=\sizeof($separators);
60
-		if($size===1){
60
+		if ($size===1) {
61 61
 			$i=-1;
62
-			foreach ($values as $v){
62
+			foreach ($values as $v) {
63 63
 				$this->_generateFields($form, [$v], $headers, $i, $wrappers);
64 64
 				$i++;
65 65
 			}
66
-		}else{
66
+		} else {
67 67
 			$separators[]=$count;
68
-			for($i=0;$i<$size;$i++){
69
-				$fields=\array_slice($values, $separators[$i]+1,$separators[$i+1]-$separators[$i]);
68
+			for ($i=0; $i<$size; $i++) {
69
+				$fields=\array_slice($values, $separators[$i]+1, $separators[$i+1]-$separators[$i]);
70 70
 				$this->_generateFields($form, $fields, $headers, $separators[$i], $wrappers);
71 71
 			}
72 72
 		}
73 73
 	}
74 74
 
75
-	protected function _generateFields($form,$values,$headers,$sepFirst,$wrappers){
75
+	protected function _generateFields($form, $values, $headers, $sepFirst, $wrappers) {
76 76
 		$wrapper=null;
77
-		if(isset($headers[$sepFirst+1]))
78
-			$form->addHeader($headers[$sepFirst+1],4,true);
79
-		if(isset($wrappers[$sepFirst+1])){
77
+		if (isset($headers[$sepFirst+1]))
78
+			$form->addHeader($headers[$sepFirst+1], 4, true);
79
+		if (isset($wrappers[$sepFirst+1])) {
80 80
 			$wrapper=$wrappers[$sepFirst+1];
81 81
 		}
82
-		if(\sizeof($values)===1){
82
+		if (\sizeof($values)===1) {
83 83
 			$added=$form->addField($values[0]);
84
-		}elseif(\sizeof($values)>1){
84
+		}elseif (\sizeof($values)>1) {
85 85
 			$added=$form->addFields($values);
86
-		}else
86
+		} else
87 87
 			return;
88
-		if(isset($wrapper)){
89
-			$added->wrap($wrapper[0],$wrapper[1]);
88
+		if (isset($wrapper)) {
89
+			$added->wrap($wrapper[0], $wrapper[1]);
90 90
 		}
91 91
 	}
92 92
 
93 93
 	/**
94 94
 	 * @return HtmlForm
95 95
 	 */
96
-	public function getForm(){
96
+	public function getForm() {
97 97
 		return $this->content["form"];
98 98
 	}
99 99
 
100
-	public function addSeparatorAfter($fieldNum){
100
+	public function addSeparatorAfter($fieldNum) {
101 101
 		$fieldNum=$this->_getIndex($fieldNum);
102 102
 		$this->_instanceViewer->addSeparatorAfter($fieldNum);
103 103
 		return $this;
@@ -112,12 +112,12 @@  discard block
 block discarded – undo
112 112
 		return $this;
113 113
 	}
114 114
 
115
-	public function fieldAsReset($index,$cssStyle=NULL,$attributes=NULL){
116
-		return $this->_fieldAs(function($id,$name,$value,$caption) use ($cssStyle){
117
-			$button=new HtmlButton($id,$value,$cssStyle);
115
+	public function fieldAsReset($index, $cssStyle=NULL, $attributes=NULL) {
116
+		return $this->_fieldAs(function($id, $name, $value, $caption) use ($cssStyle){
117
+			$button=new HtmlButton($id, $value, $cssStyle);
118 118
 			$button->setProperty("type", "reset");
119 119
 			return $button;
120
-		}, $index,$attributes);
120
+		}, $index, $attributes);
121 121
 	}
122 122
 
123 123
 	/**
@@ -136,19 +136,19 @@  discard block
 block discarded – undo
136 136
 		$this->content[$this->_toolbarPosition]=$this->_toolbar;
137 137
 	}
138 138
 
139
-	public function addDividerBefore($index,$title){
139
+	public function addDividerBefore($index, $title) {
140 140
 		$index=$this->_getIndex($index);
141 141
 		$this->_instanceViewer->addHeaderDividerBefore($index, $title);
142 142
 		return $this;
143 143
 	}
144 144
 
145
-	public function addWrapper($index,$contentBefore,$contentAfter=null){
145
+	public function addWrapper($index, $contentBefore, $contentAfter=null) {
146 146
 		$index=$this->_getIndex($index);
147
-		$this->_instanceViewer->addWrapper($index, $contentBefore,$contentAfter);
147
+		$this->_instanceViewer->addWrapper($index, $contentBefore, $contentAfter);
148 148
 		return $this;
149 149
 	}
150 150
 
151
-	public function run(JsUtils $js){
151
+	public function run(JsUtils $js) {
152 152
 		return parent::run($js);
153 153
 	}
154 154
 }
Please login to merge, or discard this patch.