Completed
Push — master ( 030ef0...22ba15 )
by Jean-Christophe
03:09
created
Ajax/semantic/widgets/dataform/DataForm.php 2 patches
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -17,47 +17,47 @@  discard block
 block discarded – undo
17 17
  * @since 2.2
18 18
  */
19 19
 class DataForm extends Widget {
20
-	use FormFieldAsTrait,FormTrait;
20
+	use FormFieldAsTrait, FormTrait;
21 21
 
22 22
 	public function __construct($identifier, $modelInstance=NULL) {
23
-		parent::__construct($identifier, null,$modelInstance);
23
+		parent::__construct($identifier, null, $modelInstance);
24 24
 		$this->_instanceViewer=new FormInstanceViewer();
25 25
 		$this->content=["form"=>new HtmlForm($identifier)];
26 26
 		$this->_toolbarPosition=PositionInTable::BEFORETABLE;
27 27
 	}
28 28
 
29
-	public function compile(JsUtils $js=NULL,&$view=NULL){
29
+	public function compile(JsUtils $js=NULL, &$view=NULL) {
30 30
 		$this->_instanceViewer->setInstance($this->_modelInstance);
31 31
 
32 32
 		$form=$this->content["form"];
33 33
 		$this->_generateContent($form);
34 34
 
35
-		if(isset($this->_toolbar)){
35
+		if (isset($this->_toolbar)) {
36 36
 			$this->_setToolbarPosition($form);
37 37
 		}
38
-		$this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE,"form",PositionInTable::AFTERTABLE]);
39
-		return parent::compile($js,$view);
38
+		$this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE, "form", PositionInTable::AFTERTABLE]);
39
+		return parent::compile($js, $view);
40 40
 	}
41 41
 
42 42
 	/**
43 43
 	 * @param HtmlForm $form
44 44
 	 */
45
-	protected function _generateContent($form){
46
-		$values= $this->_instanceViewer->getValues();
45
+	protected function _generateContent($form) {
46
+		$values=$this->_instanceViewer->getValues();
47 47
 		$count=$this->_instanceViewer->count();
48 48
 		$separators=$this->_instanceViewer->getSeparators();
49 49
 		$size=\sizeof($separators);
50
-		if($size===1){
51
-			foreach ($values as $v){
50
+		if ($size===1) {
51
+			foreach ($values as $v) {
52 52
 				$form->addField($v);
53 53
 			}
54
-		}else{
54
+		} else {
55 55
 			$separators[]=$count;
56
-			for($i=0;$i<$size-1;$i++){
57
-				$fields=\array_slice($values, $separators[$i]+1,$separators[$i+1]-$separators[$i]);
58
-				if(\sizeof($fields)===1){
56
+			for ($i=0; $i<$size-1; $i++) {
57
+				$fields=\array_slice($values, $separators[$i]+1, $separators[$i+1]-$separators[$i]);
58
+				if (\sizeof($fields)===1) {
59 59
 					$form->addField($fields[0]);
60
-				}else
60
+				} else
61 61
 					$form->addFields($fields);
62 62
 			}
63 63
 		}
@@ -66,11 +66,11 @@  discard block
 block discarded – undo
66 66
 	/**
67 67
 	 * @return HtmlForm
68 68
 	 */
69
-	protected function getForm(){
69
+	protected function getForm() {
70 70
 		return $this->content["form"];
71 71
 	}
72 72
 
73
-	public function addSeparatorAfter($fieldNum){
73
+	public function addSeparatorAfter($fieldNum) {
74 74
 		$this->_instanceViewer->addSeparatorAfter($fieldNum);
75 75
 		return $this;
76 76
 	}
@@ -84,26 +84,26 @@  discard block
 block discarded – undo
84 84
 		return $this;
85 85
 	}
86 86
 
87
-	public function addSubmitInToolbar($identifier,$value,$cssStyle=NULL,$url=NULL,$responseElement=NULL){
88
-		$button=new HtmlButton($identifier,$value,$cssStyle);
89
-		$this->_buttonAsSubmit($button,"click",$url,$responseElement);
87
+	public function addSubmitInToolbar($identifier, $value, $cssStyle=NULL, $url=NULL, $responseElement=NULL) {
88
+		$button=new HtmlButton($identifier, $value, $cssStyle);
89
+		$this->_buttonAsSubmit($button, "click", $url, $responseElement);
90 90
 		return $this->addInToolbar($button);
91 91
 	}
92 92
 
93
-	public function fieldAsSubmit($index,$cssStyle=NULL,$url=NULL,$responseElement=NULL,$attributes=NULL){
94
-		return $this->_fieldAs(function($id,$name,$value,$caption) use ($url,$responseElement,$cssStyle){
95
-			$button=new HtmlButton($id,$value,$cssStyle);
96
-			$this->_buttonAsSubmit($button,"click",$url,$responseElement);
93
+	public function fieldAsSubmit($index, $cssStyle=NULL, $url=NULL, $responseElement=NULL, $attributes=NULL) {
94
+		return $this->_fieldAs(function($id, $name, $value, $caption) use ($url, $responseElement, $cssStyle){
95
+			$button=new HtmlButton($id, $value, $cssStyle);
96
+			$this->_buttonAsSubmit($button, "click", $url, $responseElement);
97 97
 			return $button;
98
-		}, $index,$attributes);
98
+		}, $index, $attributes);
99 99
 	}
100 100
 
101
-	public function fieldAsReset($index,$cssStyle=NULL,$attributes=NULL){
102
-		return $this->_fieldAs(function($id,$name,$value,$caption) use ($cssStyle){
103
-			$button=new HtmlButton($id,$value,$cssStyle);
101
+	public function fieldAsReset($index, $cssStyle=NULL, $attributes=NULL) {
102
+		return $this->_fieldAs(function($id, $name, $value, $caption) use ($cssStyle){
103
+			$button=new HtmlButton($id, $value, $cssStyle);
104 104
 			$button->setProperty("type", "reset");
105 105
 			return $button;
106
-		}, $index,$attributes);
106
+		}, $index, $attributes);
107 107
 	}
108 108
 
109 109
 	/**
Please login to merge, or discard this patch.
Braces   +4 added lines, -3 removed lines patch added patch discarded remove patch
@@ -51,14 +51,15 @@
 block discarded – undo
51 51
 			foreach ($values as $v){
52 52
 				$form->addField($v);
53 53
 			}
54
-		}else{
54
+		} else{
55 55
 			$separators[]=$count;
56 56
 			for($i=0;$i<$size-1;$i++){
57 57
 				$fields=\array_slice($values, $separators[$i]+1,$separators[$i+1]-$separators[$i]);
58 58
 				if(\sizeof($fields)===1){
59 59
 					$form->addField($fields[0]);
60
-				}else
61
-					$form->addFields($fields);
60
+				} else {
61
+									$form->addFields($fields);
62
+				}
62 63
 			}
63 64
 		}
64 65
 	}
Please login to merge, or discard this patch.
Ajax/semantic/html/collections/form/traits/FormTrait.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
 use Ajax\semantic\html\collections\HtmlMessage;
6 6
 use Ajax\service\AjaxCall;
7 7
 
8
-trait FormTrait{
8
+trait FormTrait {
9 9
 	/**
10 10
 	 * @return HtmlForm
11 11
 	 */
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 		return $this->getForm()->addToProperty("class", "loading");
16 16
 	}
17 17
 
18
-	public function addErrorMessage(){
18
+	public function addErrorMessage() {
19 19
 		return $this->getForm()->addContent((new HtmlMessage(""))->setError());
20 20
 	}
21 21
 
@@ -30,35 +30,35 @@  discard block
 block discarded – undo
30 30
 	 * @param string $responseElement
31 31
 	 * @return \Ajax\semantic\html\collections\form\HtmlForm
32 32
 	 */
33
-	public function submitOn($event,$identifier,$url,$responseElement){
33
+	public function submitOn($event, $identifier, $url, $responseElement) {
34 34
 		$form=$this->getForm();
35 35
 		$elem=$form->getElementById($identifier, $form->getContent());
36
-		if(isset($elem)){
37
-			$this->_buttonAsSubmit($elem, $event,$url,$responseElement);
36
+		if (isset($elem)) {
37
+			$this->_buttonAsSubmit($elem, $event, $url, $responseElement);
38 38
 		}
39 39
 		return $form;
40 40
 	}
41 41
 
42
-	public function submitOnClick($identifier,$url,$responseElement){
42
+	public function submitOnClick($identifier, $url, $responseElement) {
43 43
 		return $this->submitOn("click", $identifier, $url, $responseElement);
44 44
 	}
45 45
 
46
-	public function addSubmit($identifier,$value,$cssStyle=NULL,$url=NULL,$responseElement=NULL){
47
-		$bt=$this->getForm()->addButton($identifier, $value,$cssStyle);
48
-		return $this->_buttonAsSubmit($bt, "click",$url,$responseElement);
46
+	public function addSubmit($identifier, $value, $cssStyle=NULL, $url=NULL, $responseElement=NULL) {
47
+		$bt=$this->getForm()->addButton($identifier, $value, $cssStyle);
48
+		return $this->_buttonAsSubmit($bt, "click", $url, $responseElement);
49 49
 	}
50 50
 
51
-	protected function _buttonAsSubmit($button,$event,$url,$responseElement=NULL){
51
+	protected function _buttonAsSubmit($button, $event, $url, $responseElement=NULL) {
52 52
 		$form=$this->getForm();
53
-		if(isset($url) && isset($responseElement)){
53
+		if (isset($url) && isset($responseElement)) {
54 54
 			$button->addEvent($event, "$('#".$form->getIdentifier()."').form('validate form');");
55
-			$form->addValidationParam("_ajaxSubmit", new AjaxCall("postForm", ["form"=>$form->getIdentifier(),"responseElement"=>$responseElement,"url"=>$url]));
55
+			$form->addValidationParam("_ajaxSubmit", new AjaxCall("postForm", ["form"=>$form->getIdentifier(), "responseElement"=>$responseElement, "url"=>$url]));
56 56
 		}
57 57
 		return $button;
58 58
 	}
59 59
 
60
-	public function addReset($identifier,$value,$cssStyle=NULL){
61
-		$bt=$this->getForm()->addButton($identifier, $value,$cssStyle);
60
+	public function addReset($identifier, $value, $cssStyle=NULL) {
61
+		$bt=$this->getForm()->addButton($identifier, $value, $cssStyle);
62 62
 		$bt->setProperty("type", "reset");
63 63
 		return $bt;
64 64
 	}
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 	 * @param string $jsCode
69 69
 	 * @return \Ajax\semantic\html\collections\form\HtmlForm
70 70
 	 */
71
-	public function onValid($jsCode){
71
+	public function onValid($jsCode) {
72 72
 		$form=$this->getForm();
73 73
 		$form->addValidationParam("onValid", "%function(){".$jsCode."}%");
74 74
 		return $form;
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 	 * @param string $jsCode can use event and fields parameters
80 80
 	 * @return HtmlForm
81 81
 	 */
82
-	public function onSuccess($jsCode){
82
+	public function onSuccess($jsCode) {
83 83
 		$form=$this->getForm();
84 84
 		$form->addValidationParam("onSuccess", "%function(evt,fields){".$jsCode."}%");
85 85
 		return $form;
Please login to merge, or discard this patch.