Completed
Push — master ( 299fb1...80f966 )
by Jean-Christophe
03:11
created
Ajax/common/traits/JqueryActionsTrait.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 trait JqueryActionsTrait {
13
-	abstract public function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false,$immediatly=true);
13
+	abstract public function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false, $immediatly=true);
14 14
 
15 15
 	/**
16 16
 	 * Get or set the value of an attribute for the first element in the set of matched elements or set one or more attributes for every matched element.
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 	 * @param boolean $immediatly defers the execution if set to false
39 39
 	 * @return string
40 40
 	 */
41
-	public function after($element='this', $value='', $immediatly=false){
41
+	public function after($element='this', $value='', $immediatly=false) {
42 42
 		$element=Javascript::prep_element($element);
43 43
 		$value=Javascript::prep_value($value);
44 44
 		$str="$({$element}).after({$value});";
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 
64 64
 		$animations="\t\t\t";
65 65
 		if (is_array($params)) {
66
-			foreach ( $params as $param => $value ) {
66
+			foreach ($params as $param => $value) {
67 67
 				$animations.=$param.': \''.$value.'\', ';
68 68
 			}
69 69
 		}
@@ -356,8 +356,8 @@  discard block
 block discarded – undo
356 356
 	 * @param boolean $immediatly
357 357
 	 * @return string
358 358
 	 */
359
-	public function _doJQueryOn($event, $element, $elementToModify, $jqueryCall, $param="", $preventDefault=false, $stopPropagation=false, $jsCallback="",$immediatly=true) {
360
-		return $this->_add_event($element, $this->_doJQuery($elementToModify, $jqueryCall, $param, $jsCallback), $event, $preventDefault, $stopPropagation,$immediatly);
359
+	public function _doJQueryOn($event, $element, $elementToModify, $jqueryCall, $param="", $preventDefault=false, $stopPropagation=false, $jsCallback="", $immediatly=true) {
360
+		return $this->_add_event($element, $this->_doJQuery($elementToModify, $jqueryCall, $param, $jsCallback), $event, $preventDefault, $stopPropagation, $immediatly);
361 361
 	}
362 362
 
363 363
 	/**
@@ -383,8 +383,8 @@  discard block
 block discarded – undo
383 383
 	 * @param boolean $immediatly
384 384
 	 * @return String
385 385
 	 */
386
-	public function _execOn($element, $event, $js, $preventDefault=false, $stopPropagation=false,$immediatly=true) {
387
-		return $this->_add_event($element, $this->_exec($js), $event, $preventDefault, $stopPropagation,$immediatly);
386
+	public function _execOn($element, $event, $js, $preventDefault=false, $stopPropagation=false, $immediatly=true) {
387
+		return $this->_add_event($element, $this->_exec($js), $event, $preventDefault, $stopPropagation, $immediatly);
388 388
 	}
389 389
 
390 390
 	/**
@@ -393,8 +393,8 @@  discard block
 block discarded – undo
393 393
 	 * @return string
394 394
 	 */
395 395
 	private function _validate_speed($speed) {
396
-		if (in_array($speed, array (
397
-				'slow','normal','fast'
396
+		if (in_array($speed, array(
397
+				'slow', 'normal', 'fast'
398 398
 		))) {
399 399
 			$speed='"'.$speed.'"';
400 400
 		} elseif (preg_match("/[^0-9]/", $speed)) {
Please login to merge, or discard this patch.
Ajax/bootstrap/html/base/HtmlNavElement.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -19,8 +19,8 @@  discard block
 block discarded – undo
19 19
 	protected $attr;
20 20
 
21 21
 
22
-	public function __construct($identifier,$tagName){
23
-		parent::__construct($identifier,$tagName);
22
+	public function __construct($identifier, $tagName) {
23
+		parent::__construct($identifier, $tagName);
24 24
 		$this->root="";
25 25
 		$this->attr="data-ajax";
26 26
 	}
@@ -32,11 +32,11 @@  discard block
 block discarded – undo
32 32
 	 * @param string $attr the html attribute used to build the elements url
33 33
 	 * @return HtmlNavElement
34 34
 	 */
35
-	public function autoGetOnClick($targetSelector){
36
-		return $this->getOnClick($this->root, $targetSelector,array("attr"=>$this->attr));
35
+	public function autoGetOnClick($targetSelector) {
36
+		return $this->getOnClick($this->root, $targetSelector, array("attr"=>$this->attr));
37 37
 	}
38 38
 
39
-	public function contentAsString(){
39
+	public function contentAsString() {
40 40
 		return implode("", $this->content);
41 41
 	}
42 42
 
@@ -44,15 +44,15 @@  discard block
 block discarded – undo
44 44
 	 * Generate the jquery script to set the elements to the HtmlNavElement
45 45
 	 * @param JsUtils $jsUtils
46 46
 	 */
47
-	public function jsSetContent(JsUtils $jsUtils){
48
-		$jsUtils->html("#".$this->identifier,str_replace("\"","'", $this->contentAsString()),true);
47
+	public function jsSetContent(JsUtils $jsUtils) {
48
+		$jsUtils->html("#".$this->identifier, str_replace("\"", "'", $this->contentAsString()), true);
49 49
 	}
50 50
 
51 51
 	public function getRoot() {
52 52
 		return $this->root;
53 53
 	}
54 54
 	public function setRoot($root) {
55
-		$this->root = $root;
55
+		$this->root=$root;
56 56
 		return $this;
57 57
 	}
58 58
 	public function getAttr() {
@@ -65,12 +65,12 @@  discard block
 block discarded – undo
65 65
 	 * @return HtmlNavElement
66 66
 	 */
67 67
 	public function setAttr($attr) {
68
-		$this->attr = $attr;
68
+		$this->attr=$attr;
69 69
 		return $this;
70 70
 	}
71 71
 
72 72
 	public function __call($method, $args) {
73
-		if(isset($this->$method) && is_callable($this->$method)) {
73
+		if (isset($this->$method) && is_callable($this->$method)) {
74 74
 			return call_user_func_array(
75 75
 					$this->$method,
76 76
 					$args
@@ -78,6 +78,6 @@  discard block
 block discarded – undo
78 78
 		}
79 79
 	}
80 80
 
81
-	abstract public function fromDispatcher(JsUtils $js,$dispatcher,$startIndex=0);
81
+	abstract public function fromDispatcher(JsUtils $js, $dispatcher, $startIndex=0);
82 82
 
83 83
 }
84 84
\ No newline at end of file
Please login to merge, or discard this patch.
Ajax/semantic/html/base/traits/IconTrait.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -15,18 +15,18 @@  discard block
 block discarded – undo
15 15
 	private $_hasIcon=false;
16 16
 
17 17
 	abstract protected function addToPropertyCtrl($name, $value, $typeCtrl);
18
-	abstract public function addContent($content,$before=false);
18
+	abstract public function addContent($content, $before=false);
19 19
 
20
-	public function addIcon($icon,$direction=Direction::LEFT){
21
-		if($this->_hasIcon===false){
20
+	public function addIcon($icon, $direction=Direction::LEFT) {
21
+		if ($this->_hasIcon===false) {
22 22
 			$iconO=$icon;
23
-			if(\is_string($icon)){
23
+			if (\is_string($icon)) {
24 24
 				$iconO=new HtmlIcon("icon-".$this->identifier, $icon);
25 25
 			}
26 26
 			$this->addToPropertyCtrl("class", $direction." icon", Direction::getConstantValues("icon"));
27
-			$this->addContent($iconO,$direction===Direction::LEFT);
27
+			$this->addContent($iconO, $direction===Direction::LEFT);
28 28
 			$this->_hasIcon=true;
29
-		}else{
29
+		} else {
30 30
 			$iconO=$this->getIcon();
31 31
 			$iconO->setIcon($icon);
32 32
 			$this->addToPropertyCtrl("class", $direction." icon", Direction::getConstantValues("icon"));
@@ -34,10 +34,10 @@  discard block
 block discarded – undo
34 34
 		return $iconO;
35 35
 	}
36 36
 
37
-	public function getIcon(){
38
-		if(\is_array($this->content)){
39
-			foreach ($this->content as $item){
40
-				if($item instanceof HtmlIcon)
37
+	public function getIcon() {
38
+		if (\is_array($this->content)) {
39
+			foreach ($this->content as $item) {
40
+				if ($item instanceof HtmlIcon)
41 41
 					return $item;
42 42
 			}
43 43
 		}
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
 }
103 103
\ No newline at end of file
Please login to merge, or discard this patch.
Ajax/semantic/html/base/traits/TableElementTrait.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@
 block discarded – undo
25 25
 	}
26 26
 
27 27
 	public function setDisabled($disable=true) {
28
-		if($disable)
28
+		if ($disable)
29 29
 			$this->addState(State::DISABLED);
30 30
 		return $this;
31 31
 	}
Please login to merge, or discard this patch.
Ajax/semantic/html/base/traits/BaseTrait.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -12,8 +12,8 @@  discard block
 block discarded – undo
12 12
  * @property string $identifier
13 13
  */
14 14
 trait BaseTrait {
15
-	protected $_variations=[ ];
16
-	protected $_states=[ ];
15
+	protected $_variations=[];
16
+	protected $_states=[];
17 17
 	protected $_baseClass;
18 18
 
19 19
 	abstract protected function setPropertyCtrl($name, $value, $typeCtrl);
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 
27 27
 	abstract public function setProperty($name, $value);
28 28
 
29
-	abstract public function addContent($content,$before=false);
29
+	abstract public function addContent($content, $before=false);
30 30
 
31 31
 	abstract public function onCreate($jsCode);
32 32
 
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 		$this->setProperty("class", $this->_baseClass);
48 48
 		if (\is_string($variations))
49 49
 			$variations=\explode(" ", $variations);
50
-		foreach ( $variations as $variation ) {
50
+		foreach ($variations as $variation) {
51 51
 			$this->addVariation($variation);
52 52
 		}
53 53
 		return $this;
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 	public function addVariations($variations=array()) {
62 62
 		if (\is_string($variations))
63 63
 			$variations=\explode(" ", $variations);
64
-		foreach ( $variations as $variation ) {
64
+		foreach ($variations as $variation) {
65 65
 			$this->addVariation($variation);
66 66
 		}
67 67
 		return $this;
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 	public function addStates($states=array()) {
71 71
 		if (\is_string($states))
72 72
 			$states=\explode(" ", $states);
73
-		foreach ( $states as $state ) {
73
+		foreach ($states as $state) {
74 74
 			$this->addState($state);
75 75
 		}
76 76
 		return $this;
@@ -80,17 +80,17 @@  discard block
 block discarded – undo
80 80
 		$this->setProperty("class", $this->_baseClass);
81 81
 		if (\is_string($states))
82 82
 			$states=\explode(" ", $states);
83
-		foreach ( $states as $state ) {
83
+		foreach ($states as $state) {
84 84
 			$this->addState($state);
85 85
 		}
86 86
 		return $this;
87 87
 	}
88 88
 
89 89
 	public function addIcon($icon, $before=true) {
90
-		return $this->addContent(new HtmlIcon("icon-" . $this->identifier, $icon), $before);
90
+		return $this->addContent(new HtmlIcon("icon-".$this->identifier, $icon), $before);
91 91
 	}
92 92
 
93
-	public function addSticky($context="body"){
93
+	public function addSticky($context="body") {
94 94
 		$this->onCreate("$('#".$this->identifier."').sticky({ context: '".$context."'});");
95 95
 		return $this;
96 96
 	}
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 	 * @return \Ajax\semantic\html\elements\HtmlSemDoubleElement
112 112
 	 */
113 113
 	public function setDisabled($disable=true) {
114
-		if($disable)
114
+		if ($disable)
115 115
 			$this->addToProperty("class", "disabled");
116 116
 		return $this;
117 117
 	}
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
 	 *
138 138
 	 * @return \Ajax\semantic\html\base\HtmlSemDoubleElement
139 139
 	 */
140
-	public function asHeader(){
140
+	public function asHeader() {
141 141
 		return $this->addToProperty("class", "header");
142 142
 	}
143 143
 
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 	 * show it is currently the active user selection
146 146
 	 * @return \Ajax\semantic\html\base\HtmlSemDoubleElement
147 147
 	 */
148
-	public function setActive($value=true){
148
+	public function setActive($value=true) {
149 149
 		return $this->addToProperty("class", "active");
150 150
 	}
151 151
 
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 	}
162 162
 
163 163
 	public function setFloated($direction="right") {
164
-		return $this->addToPropertyCtrl("class", $direction . " floated", Direction::getConstantValues("floated"));
164
+		return $this->addToPropertyCtrl("class", $direction." floated", Direction::getConstantValues("floated"));
165 165
 	}
166 166
 
167 167
 	public function floatRight() {
Please login to merge, or discard this patch.
Ajax/semantic/widgets/dataelement/DataElement.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -19,33 +19,33 @@
 block discarded – undo
19 19
 class DataElement extends Widget {
20 20
 
21 21
 	public function __construct($identifier, $modelInstance=NULL) {
22
-		parent::__construct($identifier, null,$modelInstance);
23
-		$this->_init(new InstanceViewer($identifier), "table", new HtmlTable($identifier, 0,2), false);
22
+		parent::__construct($identifier, null, $modelInstance);
23
+		$this->_init(new InstanceViewer($identifier), "table", new HtmlTable($identifier, 0, 2), false);
24 24
 		$this->content["table"]->setDefinition();
25 25
 	}
26 26
 
27
-	public function compile(JsUtils $js=NULL,&$view=NULL){
27
+	public function compile(JsUtils $js=NULL, &$view=NULL) {
28 28
 		$this->_instanceViewer->setInstance($this->_modelInstance);
29 29
 
30 30
 		$table=$this->content["table"];
31 31
 		$this->_generateContent($table);
32 32
 
33
-		if(isset($this->_toolbar)){
33
+		if (isset($this->_toolbar)) {
34 34
 			$this->_setToolbarPosition($table);
35 35
 		}
36
-		$this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE,"table",PositionInTable::AFTERTABLE]);
37
-		return parent::compile($js,$view);
36
+		$this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE, "table", PositionInTable::AFTERTABLE]);
37
+		return parent::compile($js, $view);
38 38
 	}
39 39
 
40 40
 	/**
41 41
 	 * @param HtmlTable $table
42 42
 	 */
43
-	protected function _generateContent($table){
43
+	protected function _generateContent($table) {
44 44
 		$captions=$this->_instanceViewer->getCaptions();
45
-		$values= $this->_instanceViewer->getValues();
45
+		$values=$this->_instanceViewer->getValues();
46 46
 		$count=$this->_instanceViewer->count();
47
-		for($i=0;$i<$count;$i++){
48
-			$table->addRow([$captions[$i],$values[$i]]);
47
+		for ($i=0; $i<$count; $i++) {
48
+			$table->addRow([$captions[$i], $values[$i]]);
49 49
 		}
50 50
 	}
51 51
 
Please login to merge, or discard this patch.
Ajax/semantic/widgets/datatable/DataTable.php 1 patch
Spacing   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -30,8 +30,8 @@  discard block
 block discarded – undo
30 30
 	protected $_hasCheckboxes;
31 31
 	protected $_compileParts;
32 32
 
33
-	public function run(JsUtils $js){
34
-		if($this->_hasCheckboxes && isset($js)){
33
+	public function run(JsUtils $js) {
34
+		if ($this->_hasCheckboxes && isset($js)) {
35 35
 			$js->execOn("change", "#".$this->identifier." [name='selection[]']", "
36 36
 		var \$parentCheckbox=\$('#ck-main-ck-{$this->identifier}'),\$checkbox=\$('#{$this->identifier} [name=\"selection[]\"]'),allChecked=true,allUnchecked=true;
37 37
 		\$checkbox.each(function() {if($(this).prop('checked')){allUnchecked = false;}else{allChecked = false;}});
@@ -40,9 +40,9 @@  discard block
 block discarded – undo
40 40
 		parent::run($js);
41 41
 	}
42 42
 
43
-	public function __construct($identifier,$model,$modelInstance=NULL) {
44
-		parent::__construct($identifier, $model,$modelInstance);
45
-		$this->_init(new InstanceViewer($identifier), "table", new HtmlTable($identifier, 0,0), false);
43
+	public function __construct($identifier, $model, $modelInstance=NULL) {
44
+		parent::__construct($identifier, $model, $modelInstance);
45
+		$this->_init(new InstanceViewer($identifier), "table", new HtmlTable($identifier, 0, 0), false);
46 46
 	}
47 47
 
48 48
 	/**
@@ -54,61 +54,61 @@  discard block
 block discarded – undo
54 54
 	}
55 55
 
56 56
 
57
-	public function compile(JsUtils $js=NULL,&$view=NULL){
57
+	public function compile(JsUtils $js=NULL, &$view=NULL) {
58 58
 		$this->_instanceViewer->setInstance($this->_model);
59 59
 		$captions=$this->_instanceViewer->getCaptions();
60 60
 
61 61
 		$table=$this->content["table"];
62 62
 
63
-		if($this->_hasCheckboxes){
63
+		if ($this->_hasCheckboxes) {
64 64
 			$this->_generateMainCheckbox($captions);
65 65
 		}
66 66
 
67 67
 		$table->setRowCount(0, \sizeof($captions));
68 68
 		$table->setHeaderValues($captions);
69
-		if(isset($this->_compileParts))
69
+		if (isset($this->_compileParts))
70 70
 			$table->setCompileParts($this->_compileParts);
71
-		if(isset($this->_searchField) && isset($js)){
72
-			$this->_searchField->postOn("change", $this->_urls,"{'s':$(this).val()}","-#".$this->identifier." tbody",["preventDefault"=>false]);
71
+		if (isset($this->_searchField) && isset($js)) {
72
+			$this->_searchField->postOn("change", $this->_urls, "{'s':$(this).val()}", "-#".$this->identifier." tbody", ["preventDefault"=>false]);
73 73
 		}
74 74
 
75 75
 		$this->_generateContent($table);
76 76
 
77
-		if($this->_hasCheckboxes && $table->hasPart("thead")){
78
-				$table->getHeader()->getCell(0, 0)->addToProperty("class","no-sort");
77
+		if ($this->_hasCheckboxes && $table->hasPart("thead")) {
78
+				$table->getHeader()->getCell(0, 0)->addToProperty("class", "no-sort");
79 79
 		}
80 80
 
81
-		if(isset($this->_pagination) && $this->_pagination->getVisible()){
81
+		if (isset($this->_pagination) && $this->_pagination->getVisible()) {
82 82
 			$this->_generatePagination($table);
83 83
 		}
84
-		if(isset($this->_toolbar)){
84
+		if (isset($this->_toolbar)) {
85 85
 			$this->_setToolbarPosition($table, $captions);
86 86
 		}
87
-		$this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE,"table",PositionInTable::AFTERTABLE]);
88
-		return parent::compile($js,$view);
87
+		$this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE, "table", PositionInTable::AFTERTABLE]);
88
+		return parent::compile($js, $view);
89 89
 	}
90 90
 
91
-	private function _generateMainCheckbox(&$captions){
92
-		$ck=new HtmlCheckbox("main-ck-".$this->identifier,"");
91
+	private function _generateMainCheckbox(&$captions) {
92
+		$ck=new HtmlCheckbox("main-ck-".$this->identifier, "");
93 93
 		$ck->setOnChecked("$('#".$this->identifier." [name=%quote%selection[]%quote%]').prop('checked',true);");
94 94
 		$ck->setOnUnchecked("$('#".$this->identifier." [name=%quote%selection[]%quote%]').prop('checked',false);");
95 95
 		\array_unshift($captions, $ck);
96 96
 	}
97 97
 
98
-	protected function _generateContent($table){
98
+	protected function _generateContent($table) {
99 99
 		$objects=$this->_modelInstance;
100
-		if(isset($this->_pagination)){
100
+		if (isset($this->_pagination)) {
101 101
 			$objects=$this->_pagination->getObjects($this->_modelInstance);
102 102
 		}
103 103
 		InstanceViewer::setIndex(0);
104
-		$table->fromDatabaseObjects($objects, function($instance){
104
+		$table->fromDatabaseObjects($objects, function($instance) {
105 105
 			$this->_instanceViewer->setInstance($instance);
106 106
 			InstanceViewer::$index++;
107
-			$result= $this->_instanceViewer->getValues();
108
-			if($this->_hasCheckboxes){
109
-				$ck=new HtmlCheckbox("ck-".$this->identifier,"");
107
+			$result=$this->_instanceViewer->getValues();
108
+			if ($this->_hasCheckboxes) {
109
+				$ck=new HtmlCheckbox("ck-".$this->identifier, "");
110 110
 				$field=$ck->getField();
111
-				$field->setProperty("value",$this->_instanceViewer->getIdentifier());
111
+				$field->setProperty("value", $this->_instanceViewer->getIdentifier());
112 112
 				$field->setProperty("name", "selection[]");
113 113
 				\array_unshift($result, $ck);
114 114
 			}
@@ -116,25 +116,25 @@  discard block
 block discarded – undo
116 116
 		});
117 117
 	}
118 118
 
119
-	private function _generatePagination($table){
119
+	private function _generatePagination($table) {
120 120
 		$footer=$table->getFooter();
121 121
 		$footer->mergeCol();
122
-		$menu=new HtmlPaginationMenu("pagination-".$this->identifier,$this->_pagination->getPagesNumbers());
122
+		$menu=new HtmlPaginationMenu("pagination-".$this->identifier, $this->_pagination->getPagesNumbers());
123 123
 		$menu->floatRight();
124 124
 		$menu->setActiveItem($this->_pagination->getPage()-1);
125 125
 		$footer->setValues($menu);
126
-		$menu->postOnClick($this->_urls,"{'p':$(this).attr('data-page')}","-#".$this->identifier." tbody",["preventDefault"=>false]);
126
+		$menu->postOnClick($this->_urls, "{'p':$(this).attr('data-page')}", "-#".$this->identifier." tbody", ["preventDefault"=>false]);
127 127
 	}
128 128
 
129
-	protected function _setToolbarPosition($table,$captions=NULL){
130
-		switch ($this->_toolbarPosition){
129
+	protected function _setToolbarPosition($table, $captions=NULL) {
130
+		switch ($this->_toolbarPosition) {
131 131
 			case PositionInTable::BEFORETABLE:case PositionInTable::AFTERTABLE:
132
-				if(isset($this->_compileParts)===false){
132
+				if (isset($this->_compileParts)===false) {
133 133
 					$this->content[$this->_toolbarPosition]=$this->_toolbar;
134 134
 				}
135 135
 				break;
136 136
 			case PositionInTable::HEADER:case PositionInTable::FOOTER: case PositionInTable::BODY:
137
-				$this->addToolbarRow($this->_toolbarPosition,$table, $captions);
137
+				$this->addToolbarRow($this->_toolbarPosition, $table, $captions);
138 138
 				break;
139 139
 		}
140 140
 	}
@@ -146,18 +146,18 @@  discard block
 block discarded – undo
146 146
 	 * @param callable $callback function called after the field compilation
147 147
 	 * @return \Ajax\semantic\widgets\datatable\DataTable
148 148
 	 */
149
-	public function afterCompile($index,$callback){
150
-		$this->_instanceViewer->afterCompile($index,$callback);
149
+	public function afterCompile($index, $callback) {
150
+		$this->_instanceViewer->afterCompile($index, $callback);
151 151
 		return $this;
152 152
 	}
153 153
 
154
-	private function addToolbarRow($part,$table,$captions){
154
+	private function addToolbarRow($part, $table, $captions) {
155 155
 		$row=$table->getPart($part)->addRow(\sizeof($captions));
156 156
 		$row->mergeCol();
157 157
 		$row->setValues([$this->_toolbar]);
158 158
 	}
159 159
 
160
-	public function getHtmlComponent(){
160
+	public function getHtmlComponent() {
161 161
 		return $this->content["table"];
162 162
 	}
163 163
 
@@ -170,8 +170,8 @@  discard block
 block discarded – undo
170 170
 		return $this;
171 171
 	}
172 172
 
173
-	public function paginate($items_per_page=10,$page=1){
174
-		$this->_pagination=new Pagination($items_per_page,4,$page);
173
+	public function paginate($items_per_page=10, $page=1) {
174
+		$this->_pagination=new Pagination($items_per_page, 4, $page);
175 175
 	}
176 176
 
177 177
 	public function getHasCheckboxes() {
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 		return $this;
184 184
 	}
185 185
 
186
-	public function refresh($compileParts=["tbody"]){
186
+	public function refresh($compileParts=["tbody"]) {
187 187
 		$this->_compileParts=$compileParts;
188 188
 		return $this;
189 189
 	}
@@ -192,8 +192,8 @@  discard block
 block discarded – undo
192 192
 	 * @param callable $callback
193 193
 	 * @return callable
194 194
 	 */
195
-	private function getFieldButtonCallable($caption,$callback=null){
196
-		return $this->getCallable("getFieldButton",[$caption],$callback);
195
+	private function getFieldButtonCallable($caption, $callback=null) {
196
+		return $this->getCallable("getFieldButton", [$caption], $callback);
197 197
 	}
198 198
 
199 199
 	/**
@@ -201,16 +201,16 @@  discard block
 block discarded – undo
201 201
 	 * @param callable $callback
202 202
 	 * @return callable
203 203
 	 */
204
-	private function getCallable($thisCallback,$parameters,$callback=null){
205
-		$result=function($instance) use($thisCallback,$parameters,$callback){
206
-			$object=call_user_func_array(array($this,$thisCallback), $parameters);
207
-			if(isset($callback)){
208
-				if(\is_callable($callback)){
209
-					$callback($object,$instance);
204
+	private function getCallable($thisCallback, $parameters, $callback=null) {
205
+		$result=function($instance) use($thisCallback, $parameters, $callback){
206
+			$object=call_user_func_array(array($this, $thisCallback), $parameters);
207
+			if (isset($callback)) {
208
+				if (\is_callable($callback)) {
209
+					$callback($object, $instance);
210 210
 				}
211 211
 			}
212
-			if($object instanceof HtmlSemDoubleElement){
213
-				$object->setProperty("data-ajax",$this->_instanceViewer->getIdentifier());
212
+			if ($object instanceof HtmlSemDoubleElement) {
213
+				$object->setProperty("data-ajax", $this->_instanceViewer->getIdentifier());
214 214
 			}
215 215
 			return $object;
216 216
 		};
@@ -221,8 +221,8 @@  discard block
 block discarded – undo
221 221
 	 * @param string $caption
222 222
 	 * @return HtmlButton
223 223
 	 */
224
-	private function getFieldButton($caption){
225
-		return new HtmlButton("",$caption);
224
+	private function getFieldButton($caption) {
225
+		return new HtmlButton("", $caption);
226 226
 	}
227 227
 
228 228
 	/**
@@ -231,8 +231,8 @@  discard block
 block discarded – undo
231 231
 	 * @param callable $callback
232 232
 	 * @return \Ajax\semantic\widgets\datatable\DataTable
233 233
 	 */
234
-	public function addFieldButton($caption,$callback=null){
235
-		$this->addField($this->getCallable("getFieldButton",[$caption],$callback));
234
+	public function addFieldButton($caption, $callback=null) {
235
+		$this->addField($this->getCallable("getFieldButton", [$caption], $callback));
236 236
 		return $this;
237 237
 	}
238 238
 
@@ -243,8 +243,8 @@  discard block
 block discarded – undo
243 243
 	 * @param callable $callback
244 244
 	 * @return \Ajax\semantic\widgets\datatable\DataTable
245 245
 	 */
246
-	public function insertFieldButton($index,$caption,$callback=null){
247
-		$this->insertField($index, $this->getFieldButtonCallable($caption,$callback));
246
+	public function insertFieldButton($index, $caption, $callback=null) {
247
+		$this->insertField($index, $this->getFieldButtonCallable($caption, $callback));
248 248
 		return $this;
249 249
 	}
250 250
 
@@ -255,60 +255,60 @@  discard block
 block discarded – undo
255 255
 	 * @param callable $callback
256 256
 	 * @return \Ajax\semantic\widgets\datatable\DataTable
257 257
 	 */
258
-	public function insertInFieldButton($index,$caption,$callback=null){
259
-		$this->insertInField($index, $this->getFieldButtonCallable($caption,$callback));
258
+	public function insertInFieldButton($index, $caption, $callback=null) {
259
+		$this->insertInField($index, $this->getFieldButtonCallable($caption, $callback));
260 260
 		return $this;
261 261
 	}
262 262
 
263
-	private function addDefaultButton($icon,$class=null,$callback=null){
264
-		$this->addField($this->getCallable("getDefaultButton",[$icon,$class],$callback));
263
+	private function addDefaultButton($icon, $class=null, $callback=null) {
264
+		$this->addField($this->getCallable("getDefaultButton", [$icon, $class], $callback));
265 265
 		return $this;
266 266
 	}
267 267
 
268
-	private function insertDefaultButtonIn($index,$icon,$class=null,$callback=null){
269
-		$this->insertInField($index,$this->getCallable("getDefaultButton",[$icon,$class],$callback));
268
+	private function insertDefaultButtonIn($index, $icon, $class=null, $callback=null) {
269
+		$this->insertInField($index, $this->getCallable("getDefaultButton", [$icon, $class], $callback));
270 270
 		return $this;
271 271
 	}
272 272
 
273
-	private function getDefaultButton($icon,$class=null){
273
+	private function getDefaultButton($icon, $class=null) {
274 274
 		$bt=$this->getFieldButton("");
275 275
 		$bt->asIcon($icon);
276
-		if(isset($class))
276
+		if (isset($class))
277 277
 			$bt->addToProperty("class", $class);
278 278
 		return $bt;
279 279
 	}
280 280
 
281
-	public function addDeleteButton($callback=null){
282
-		return $this->addDefaultButton("remove","delete red basic",$callback);
281
+	public function addDeleteButton($callback=null) {
282
+		return $this->addDefaultButton("remove", "delete red basic", $callback);
283 283
 	}
284 284
 
285
-	public function addEditButton($callback=null){
286
-		return $this->addDefaultButton("edit","edit basic",$callback);
285
+	public function addEditButton($callback=null) {
286
+		return $this->addDefaultButton("edit", "edit basic", $callback);
287 287
 	}
288 288
 
289
-	public function addEditDeleteButtons($callbackEdit=null,$callbackDelete=null){
289
+	public function addEditDeleteButtons($callbackEdit=null, $callbackDelete=null) {
290 290
 		$this->addEditButton($callbackEdit);
291 291
 		$index=$this->_instanceViewer->visiblePropertiesCount()-1;
292
-		$this->insertDeleteButtonIn($index,$callbackDelete);
292
+		$this->insertDeleteButtonIn($index, $callbackDelete);
293 293
 		return $this;
294 294
 	}
295 295
 
296
-	public function insertDeleteButtonIn($index,$callback=null){
297
-		return $this->insertDefaultButtonIn($index,"remove","delete red basic",$callback);
296
+	public function insertDeleteButtonIn($index, $callback=null) {
297
+		return $this->insertDefaultButtonIn($index, "remove", "delete red basic", $callback);
298 298
 	}
299 299
 
300
-	public function insertEditButtonIn($index,$callback=null){
301
-		return $this->insertDefaultButtonIn($index,"edit","edit basic",$callback);
300
+	public function insertEditButtonIn($index, $callback=null) {
301
+		return $this->insertDefaultButtonIn($index, "edit", "edit basic", $callback);
302 302
 	}
303 303
 
304
-	public function addSearchInToolbar($position=Direction::RIGHT){
304
+	public function addSearchInToolbar($position=Direction::RIGHT) {
305 305
 		return $this->addInToolbar($this->getSearchField())->setPosition($position);
306 306
 	}
307 307
 
308
-	public function getSearchField(){
309
-		if(isset($this->_searchField)===false){
310
-			$this->_searchField=new HtmlInput("search-".$this->identifier,"search","","Search...");
311
-			$this->_searchField->addIcon("search",Direction::RIGHT);
308
+	public function getSearchField() {
309
+		if (isset($this->_searchField)===false) {
310
+			$this->_searchField=new HtmlInput("search-".$this->identifier, "search", "", "Search...");
311
+			$this->_searchField->addIcon("search", Direction::RIGHT);
312 312
 		}
313 313
 		return $this->_searchField;
314 314
 	}
Please login to merge, or discard this patch.
Ajax/semantic/widgets/dataform/FormFieldAsTrait.php 1 patch
Spacing   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -15,21 +15,21 @@  discard block
 block discarded – undo
15 15
  * @property object $_modelInstance
16 16
  */
17 17
 
18
-trait FormFieldAsTrait{
18
+trait FormFieldAsTrait {
19 19
 
20 20
 	abstract protected function _getFieldIdentifier($prefix);
21
-	abstract public function setValueFunction($index,$callback);
22
-	abstract protected function _applyAttributes($element,&$attributes,$index);
21
+	abstract public function setValueFunction($index, $callback);
22
+	abstract protected function _applyAttributes($element, &$attributes, $index);
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
 
29
-	protected function _addRules($element,&$attributes){
30
-		if(isset($attributes["rules"])){
29
+	protected function _addRules($element, &$attributes) {
30
+		if (isset($attributes["rules"])) {
31 31
 			$rules=$attributes["rules"];
32
-			if(\is_array($rules)){
32
+			if (\is_array($rules)) {
33 33
 				$element->addRules($rules);
34 34
 			}
35 35
 			else
@@ -38,13 +38,13 @@  discard block
 block discarded – undo
38 38
 		}
39 39
 	}
40 40
 
41
-	protected function _fieldAs($elementCallback,$index,$attributes=NULL,$identifier=null){
42
-		$this->setValueFunction($index,function($value) use ($index,&$attributes,$elementCallback){
41
+	protected function _fieldAs($elementCallback, $index, $attributes=NULL, $identifier=null) {
42
+		$this->setValueFunction($index, function($value) use ($index, &$attributes, $elementCallback){
43 43
 			$caption=$this->_instanceViewer->getCaption($index);
44 44
 			$name=$this->_instanceViewer->getFieldName($index);
45
-			$element=$elementCallback($this->getIdentifier()."-".$name,$name,$value,$caption);
46
-			if(\is_array($attributes)){
47
-				$this->_applyAttributes($element, $attributes,$index);
45
+			$element=$elementCallback($this->getIdentifier()."-".$name, $name, $value, $caption);
46
+			if (\is_array($attributes)) {
47
+				$this->_applyAttributes($element, $attributes, $index);
48 48
 			}
49 49
 			return $element;
50 50
 		});
@@ -52,53 +52,53 @@  discard block
 block discarded – undo
52 52
 	}
53 53
 
54 54
 
55
-	public function fieldAsRadio($index,$attributes=NULL){
56
-		return $this->_fieldAs(function($id,$name,$value,$caption){
57
-			return new HtmlFormRadio($id,$name,$caption,$value);
58
-		}, $index,$attributes);
55
+	public function fieldAsRadio($index, $attributes=NULL) {
56
+		return $this->_fieldAs(function($id, $name, $value, $caption) {
57
+			return new HtmlFormRadio($id, $name, $caption, $value);
58
+		}, $index, $attributes);
59 59
 	}
60 60
 
61
-	public function fieldAsRadios($index,$elements=[],$attributes=NULL){
62
-		return $this->_fieldAs(function($id,$name,$value,$caption,$elements){
63
-			return HtmlFormFields::radios($name,$elements,$caption,$value);
64
-		}, $index,$attributes);
61
+	public function fieldAsRadios($index, $elements=[], $attributes=NULL) {
62
+		return $this->_fieldAs(function($id, $name, $value, $caption, $elements) {
63
+			return HtmlFormFields::radios($name, $elements, $caption, $value);
64
+		}, $index, $attributes);
65 65
 	}
66 66
 
67
-	public function fieldAsTextarea($index,$attributes=NULL){
68
-		return $this->_fieldAs(function($id,$name,$value,$caption){
69
-			$textarea=new HtmlFormTextarea($id,$caption,$value);
67
+	public function fieldAsTextarea($index, $attributes=NULL) {
68
+		return $this->_fieldAs(function($id, $name, $value, $caption) {
69
+			$textarea=new HtmlFormTextarea($id, $caption, $value);
70 70
 			$textarea->setName($name);
71 71
 			return $textarea;
72
-		}, $index,$attributes);
72
+		}, $index, $attributes);
73 73
 	}
74 74
 
75
-	public function fieldAsInput($index,$attributes=NULL){
76
-		return $this->_fieldAs(function($id,$name,$value,$caption){
77
-			$input= new HtmlFormInput($id,$caption,"text",$value);
75
+	public function fieldAsInput($index, $attributes=NULL) {
76
+		return $this->_fieldAs(function($id, $name, $value, $caption) {
77
+			$input=new HtmlFormInput($id, $caption, "text", $value);
78 78
 			$input->setName($name);
79 79
 			return $input;
80
-		}, $index,$attributes);
80
+		}, $index, $attributes);
81 81
 	}
82 82
 
83
-	public function fieldAsCheckbox($index,$attributes=NULL){
84
-		return $this->_fieldAs(function($id,$name,$value,$caption){
85
-			return new HtmlFormCheckbox($id,$caption,$value);
86
-		}, $index,$attributes);
83
+	public function fieldAsCheckbox($index, $attributes=NULL) {
84
+		return $this->_fieldAs(function($id, $name, $value, $caption) {
85
+			return new HtmlFormCheckbox($id, $caption, $value);
86
+		}, $index, $attributes);
87 87
 	}
88 88
 
89
-	public function fieldAsDropDown($index,$elements=[],$multiple=false,$attributes=NULL){
90
-		return $this->_fieldAs(function($id,$name,$value,$caption) use ($elements,$multiple){
91
-			$dd=new HtmlFormDropdown($id,$elements,$caption,$value,$multiple);
89
+	public function fieldAsDropDown($index, $elements=[], $multiple=false, $attributes=NULL) {
90
+		return $this->_fieldAs(function($id, $name, $value, $caption) use ($elements, $multiple){
91
+			$dd=new HtmlFormDropdown($id, $elements, $caption, $value, $multiple);
92 92
 			$dd->setName($name);
93 93
 			return $dd;
94
-		}, $index,$attributes);
94
+		}, $index, $attributes);
95 95
 	}
96 96
 
97
-	public function fieldAsMessage($index,$attributes=NULL){
98
-		return $this->_fieldAs(function($id,$name,$value,$caption){
99
-			$mess= new HtmlMessage("message-".$id,$value);
97
+	public function fieldAsMessage($index, $attributes=NULL) {
98
+		return $this->_fieldAs(function($id, $name, $value, $caption) {
99
+			$mess=new HtmlMessage("message-".$id, $value);
100 100
 			$mess->addHeader($caption);
101 101
 			return $mess;
102
-		}, $index,$attributes,"message");
102
+		}, $index, $attributes, "message");
103 103
 	}
104 104
 }
105 105
\ No newline at end of file
Please login to merge, or discard this patch.