Completed
Push — master ( ab06fe...ef9455 )
by Jean-Christophe
02:37
created
Ajax/semantic/html/elements/HtmlStep.php 2 patches
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -9,12 +9,12 @@  discard block
 block discarded – undo
9 9
 use Ajax\common\html\HtmlDoubleElement;
10 10
 use Ajax\semantic\html\base\constants\Side;
11 11
 
12
-class HtmlStep extends HtmlSemCollection{
12
+class HtmlStep extends HtmlSemCollection {
13 13
 	protected $_activeStep;
14 14
 	protected $_startStep;
15 15
 
16
-	public function __construct( $identifier,$steps=array()){
17
-		parent::__construct( $identifier,"div", "ui steps");
16
+	public function __construct($identifier, $steps=array()) {
17
+		parent::__construct($identifier, "div", "ui steps");
18 18
 		$this->addItems($steps);
19 19
 	}
20 20
 
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 	 * @see \Ajax\common\html\html5\HtmlCollection::createItem()
25 25
 	 */
26 26
 	protected function createItem($value) {
27
-		$itemO=new HtmlStepItem("item-".\sizeof($this->content),$value);
27
+		$itemO=new HtmlStepItem("item-".\sizeof($this->content), $value);
28 28
 		return $itemO;
29 29
 	}
30 30
 
@@ -32,50 +32,50 @@  discard block
 block discarded – undo
32 32
 	 * @param string|array $step
33 33
 	 * @return HtmlStepItem
34 34
 	 */
35
-	public function addStep($step){
35
+	public function addStep($step) {
36 36
 		return $this->addItem($step);
37 37
 	}
38 38
 
39
-	public function setOrdered(){
39
+	public function setOrdered() {
40 40
 		return $this->addToProperty("class", "ordered");
41 41
 	}
42 42
 
43
-	public function isOrdered(){
43
+	public function isOrdered() {
44 44
 		return $this->propertyContains("class", "ordered");
45 45
 	}
46 46
 
47
-	public function setVertical(){
47
+	public function setVertical() {
48 48
 		return $this->addToProperty("class", "vertical");
49 49
 	}
50 50
 
51
-	protected function defineActiveStep(){
51
+	protected function defineActiveStep() {
52 52
 		$activestep=$this->_activeStep;
53 53
 		$count=$this->count();
54
-		if(!$this->isOrdered()){
55
-			for($i=$this->_startStep;$i<$count;$i++){
54
+		if (!$this->isOrdered()) {
55
+			for ($i=$this->_startStep; $i<$count; $i++) {
56 56
 				$step=$this->content[$i];
57 57
 				$step->removeStatus();
58
-				if($i<$activestep)
58
+				if ($i<$activestep)
59 59
 					$step->setCompleted();
60 60
 				elseif ($i===$activestep)
61 61
 					$step->setActive();
62 62
 				else
63 63
 					$step->setDisabled();
64 64
 			}
65
-		}else{
66
-			foreach ($this->content as $step){
65
+		} else {
66
+			foreach ($this->content as $step) {
67 67
 				$step->removeStatus();
68 68
 			}
69
-			if($activestep<$count)
69
+			if ($activestep<$count)
70 70
 				$this->content[$activestep]->setActive();
71 71
 		}
72 72
 		return $this;
73 73
 	}
74 74
 
75 75
 	public function compile(JsUtils $js=NULL, &$view=NULL) {
76
-		if(isset($this->_activeStep) && \is_numeric($this->_activeStep))
76
+		if (isset($this->_activeStep) && \is_numeric($this->_activeStep))
77 77
 			$this->defineActiveStep();
78
-		return parent::compile($js,$view);
78
+		return parent::compile($js, $view);
79 79
 	}
80 80
 
81 81
 	public function setActiveStep($_activeStep) {
@@ -83,15 +83,15 @@  discard block
 block discarded – undo
83 83
 		return $this;
84 84
 	}
85 85
 
86
-	public function setAttached($side="",HtmlDoubleElement $toElement=NULL){
87
-		if(isset($toElement)){
88
-			$toElement->addToPropertyCtrl("class", "attached",array("attached"));
86
+	public function setAttached($side="", HtmlDoubleElement $toElement=NULL) {
87
+		if (isset($toElement)) {
88
+			$toElement->addToPropertyCtrl("class", "attached", array("attached"));
89 89
 		}
90
-		return $this->addToPropertyCtrl("class", $side." attached",Side::getConstantValues("attached"));
90
+		return $this->addToPropertyCtrl("class", $side." attached", Side::getConstantValues("attached"));
91 91
 	}
92 92
 
93
-	public function asLink(){
94
-		foreach ($this->content as $step){
93
+	public function asLink() {
94
+		foreach ($this->content as $step) {
95 95
 			$step->asLink();
96 96
 		}
97 97
 		return $this;
Please login to merge, or discard this patch.
Braces   +14 added lines, -11 removed lines patch added patch discarded remove patch
@@ -55,26 +55,29 @@
 block discarded – undo
55 55
 			for($i=$this->_startStep;$i<$count;$i++){
56 56
 				$step=$this->content[$i];
57 57
 				$step->removeStatus();
58
-				if($i<$activestep)
59
-					$step->setCompleted();
60
-				elseif ($i===$activestep)
61
-					$step->setActive();
62
-				else
63
-					$step->setDisabled();
58
+				if($i<$activestep) {
59
+									$step->setCompleted();
60
+				} elseif ($i===$activestep) {
61
+									$step->setActive();
62
+				} else {
63
+									$step->setDisabled();
64
+				}
64 65
 			}
65
-		}else{
66
+		} else{
66 67
 			foreach ($this->content as $step){
67 68
 				$step->removeStatus();
68 69
 			}
69
-			if($activestep<$count)
70
-				$this->content[$activestep]->setActive();
70
+			if($activestep<$count) {
71
+							$this->content[$activestep]->setActive();
72
+			}
71 73
 		}
72 74
 		return $this;
73 75
 	}
74 76
 
75 77
 	public function compile(JsUtils $js=NULL, &$view=NULL) {
76
-		if(isset($this->_activeStep) && \is_numeric($this->_activeStep))
77
-			$this->defineActiveStep();
78
+		if(isset($this->_activeStep) && \is_numeric($this->_activeStep)) {
79
+					$this->defineActiveStep();
80
+		}
78 81
 		return parent::compile($js,$view);
79 82
 	}
80 83
 
Please login to merge, or discard this patch.
Ajax/semantic/html/content/HtmlListItem.php 2 patches
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -9,15 +9,15 @@  discard block
 block discarded – undo
9 9
 	protected $image;
10 10
 
11 11
 	public function __construct($identifier, $content=NULL) {
12
-		parent::__construct($identifier,"item",$content);
12
+		parent::__construct($identifier, "item", $content);
13 13
 	}
14
-	protected function initContent($content){
15
-		if(\is_array($content)){
16
-			if(JArray::isAssociative($content)===false){
14
+	protected function initContent($content) {
15
+		if (\is_array($content)) {
16
+			if (JArray::isAssociative($content)===false) {
17 17
 				$icon=@$content[0];
18 18
 				$title=@$content[1];
19 19
 				$desc=@$content[2];
20
-			}else{
20
+			} else {
21 21
 				$icon=@$content["icon"];
22 22
 				$image=@$content["image"];
23 23
 				$title=@$content["title"];
@@ -25,38 +25,38 @@  discard block
 block discarded – undo
25 25
 				$desc=@$content["description"];
26 26
 				$items=@$content["items"];
27 27
 			}
28
-			if(isset($icon)){
28
+			if (isset($icon)) {
29 29
 				$this->setIcon($icon);
30 30
 			}
31
-			if(isset($image)){
31
+			if (isset($image)) {
32 32
 				$this->setImage($image);
33 33
 			}
34
-			if(isset($title)){
35
-				$this->setTitle($title,$desc);
36
-			}elseif (isset($header)){
37
-				$this->setTitle($header,$desc,"header");
34
+			if (isset($title)) {
35
+				$this->setTitle($title, $desc);
36
+			}elseif (isset($header)) {
37
+				$this->setTitle($header, $desc, "header");
38 38
 			}
39
-			if(isset($items)){
39
+			if (isset($items)) {
40 40
 				$this->addList($items);
41 41
 			}
42
-		}else{
42
+		} else {
43 43
 			$this->setContent($content);
44 44
 		}
45 45
 	}
46
-	public function addList($items=array(),$ordered=false) {
46
+	public function addList($items=array(), $ordered=false) {
47 47
 		$list=new HtmlList("", $items);
48
-		if($ordered)
48
+		if ($ordered)
49 49
 			$list->setOrdered();
50 50
 		$list->setClass("list");
51 51
 		$this->content["list"]=$list;
52 52
 		return $list;
53 53
 	}
54 54
 
55
-	public function getList(){
55
+	public function getList() {
56 56
 		return $this->content["list"];
57 57
 	}
58 58
 
59
-	public function getItem($index){
59
+	public function getItem($index) {
60 60
 		return $this->getList()->getItem($index);
61 61
 	}
62 62
 }
Please login to merge, or discard this patch.
Braces   +6 added lines, -5 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 				$icon=@$content[0];
18 18
 				$title=@$content[1];
19 19
 				$desc=@$content[2];
20
-			}else{
20
+			} else{
21 21
 				$icon=@$content["icon"];
22 22
 				$image=@$content["image"];
23 23
 				$title=@$content["title"];
@@ -33,20 +33,21 @@  discard block
 block discarded – undo
33 33
 			}
34 34
 			if(isset($title)){
35 35
 				$this->setTitle($title,$desc);
36
-			}elseif (isset($header)){
36
+			} elseif (isset($header)){
37 37
 				$this->setTitle($header,$desc,"header");
38 38
 			}
39 39
 			if(isset($items)){
40 40
 				$this->addList($items);
41 41
 			}
42
-		}else{
42
+		} else{
43 43
 			$this->setContent($content);
44 44
 		}
45 45
 	}
46 46
 	public function addList($items=array(),$ordered=false) {
47 47
 		$list=new HtmlList("", $items);
48
-		if($ordered)
49
-			$list->setOrdered();
48
+		if($ordered) {
49
+					$list->setOrdered();
50
+		}
50 51
 		$list->setClass("list");
51 52
 		$this->content["list"]=$list;
52 53
 		return $list;
Please login to merge, or discard this patch.
Ajax/semantic/html/modules/HtmlPopup.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 
12 12
 class HtmlPopup extends HtmlSemDoubleElement {
13 13
 	private $_container;
14
-	public function __construct(BaseHtml $container,$identifier, $content="") {
14
+	public function __construct(BaseHtml $container, $identifier, $content="") {
15 15
 		parent::__construct($identifier, "div");
16 16
 		$this->_container=$container;
17 17
 		$this->setClass("ui popup");
@@ -23,9 +23,9 @@  discard block
 block discarded – undo
23 23
 	 * {@inheritDoc}
24 24
 	 * @see \Ajax\semantic\html\base\HtmlSemDoubleElement::addList()
25 25
 	 */
26
-	public function addList($items=array(),$header=NULL){
27
-		if(!$this->content instanceof HtmlGrid){
28
-			$this->content=new HtmlGrid("Grid-".$this->identifier,0);
26
+	public function addList($items=array(), $header=NULL) {
27
+		if (!$this->content instanceof HtmlGrid) {
28
+			$this->content=new HtmlGrid("Grid-".$this->identifier, 0);
29 29
 		}
30 30
 		$grid=$this->content;
31 31
 
@@ -33,12 +33,12 @@  discard block
 block discarded – undo
33 33
 		$colCount++;
34 34
 		$grid->setColsCount($colCount);
35 35
 
36
-		$list=new HtmlList("",$items);
36
+		$list=new HtmlList("", $items);
37 37
 		$list->asLink();
38
-		if(isset($header)){
39
-			$list->addHeader(4,$header);
38
+		if (isset($header)) {
39
+			$list->addHeader(4, $header);
40 40
 		}
41
-		$grid->getCell(0,$colCount-1)->setContent($list);
41
+		$grid->getCell(0, $colCount-1)->setContent($list);
42 42
 		$grid->setDivided()->setRelaxed(true);
43 43
 		return $list;
44 44
 	}
@@ -46,14 +46,14 @@  discard block
 block discarded – undo
46 46
 	/**
47 47
 	 * A popup can have no maximum width and continue to flow to fit its content
48 48
 	 */
49
-	public function setFlowing(){
49
+	public function setFlowing() {
50 50
 		return $this->addToProperty("class", "flowing");
51 51
 	}
52 52
 
53 53
 	/**
54 54
 	 * A popup can provide more basic formatting
55 55
 	 */
56
-	public function setBasic(){
56
+	public function setBasic() {
57 57
 		return $this->addToProperty("class", "basic");
58 58
 	}
59 59
 
@@ -61,23 +61,23 @@  discard block
 block discarded – undo
61 61
 	 * {@inheritDoc}
62 62
 	 * @see \Ajax\semantic\html\base\HtmlSemDoubleElement::run()
63 63
 	 */
64
-	public function run(JsUtils $js){
64
+	public function run(JsUtils $js) {
65 65
 		parent::run($js);
66 66
 		$this->_params["popup"]="#".$this->identifier;
67
-		$js->semantic()->popup("#".$this->_container->getIdentifier(),$this->_params);
67
+		$js->semantic()->popup("#".$this->_container->getIdentifier(), $this->_params);
68 68
 	}
69 69
 
70
-	public function setOn($event="click"){
70
+	public function setOn($event="click") {
71 71
 		$this->_params["on"]=$event;
72 72
 		return $this;
73 73
 	}
74 74
 
75
-	public function setInline($value=true){
75
+	public function setInline($value=true) {
76 76
 		$this->_params["inline"]=$value;
77 77
 		return $this;
78 78
 	}
79 79
 
80
-	public function setPosition($position){
80
+	public function setPosition($position) {
81 81
 		$this->_params["position"]=$position;
82 82
 		return $this;
83 83
 	}
Please login to merge, or discard this patch.
Ajax/service/AjaxCall.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -25,27 +25,27 @@
 block discarded – undo
25 25
 		$this->parameters["immediatly"]=false;
26 26
 		extract($this->parameters);
27 27
 		$result=$this->_eventPreparing($preventDefault, $stopPropagation);
28
-		switch($this->method) {
28
+		switch ($this->method) {
29 29
 			case "get":
30 30
 				$result.=$js->getDeferred($url, $responseElement, $this->parameters);
31 31
 				break;
32 32
 			case "post":
33
-				$result.=$js->postDeferred($url, $params,$responseElement, $this->parameters);
33
+				$result.=$js->postDeferred($url, $params, $responseElement, $this->parameters);
34 34
 				break;
35 35
 			case "postForm":
36 36
 				$result.=$js->postFormDeferred($url, $form, $responseElement, $this->parameters);
37 37
 				break;
38 38
 			case "json":
39
-				$result.=$js->jsonDeferred($url,$method,$params,$jsCallback);
39
+				$result.=$js->jsonDeferred($url, $method, $params, $jsCallback);
40 40
 				break;
41 41
 			case "jsonArray":
42
-				$result.=$js->jsonArrayDeferred($modelSelector, $url,$method,$params,$jsCallback,$rowClass);
42
+				$result.=$js->jsonArrayDeferred($modelSelector, $url, $method, $params, $jsCallback, $rowClass);
43 43
 				break;
44 44
 		}
45 45
 		return $result;
46 46
 	}
47 47
 
48
-	protected function _eventPreparing($preventDefault,$stopPropagation){
48
+	protected function _eventPreparing($preventDefault, $stopPropagation) {
49 49
 		$result="";
50 50
 		if ($preventDefault===true) {
51 51
 			$result.=Javascript::$preventDefault;
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -14,8 +14,9 @@
 block discarded – undo
14 14
 	}
15 15
 
16 16
 	public function compile(JsUtils $js=null) {
17
-		if ($js===null)
18
-			return;
17
+		if ($js===null) {
18
+					return;
19
+		}
19 20
 		$params="{}";
20 21
 		$jsCallback=NULL;
21 22
 		$stopPropagation=true;
Please login to merge, or discard this patch.
Ajax/semantic/html/collections/form/HtmlFormDropdown.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -7,29 +7,29 @@  discard block
 block discarded – undo
7 7
 
8 8
 class HtmlFormDropdown extends HtmlFormField {
9 9
 
10
-	public function __construct($identifier,$items=array(), $label=NULL,$value="",$multiple=false,$associative=true) {
11
-		parent::__construct("field-".$identifier, (new HtmlDropdown("dropdown-".$identifier,$value,$items,$associative))->asSelect($identifier,$multiple), $label);
10
+	public function __construct($identifier, $items=array(), $label=NULL, $value="", $multiple=false, $associative=true) {
11
+		parent::__construct("field-".$identifier, (new HtmlDropdown("dropdown-".$identifier, $value, $items, $associative))->asSelect($identifier, $multiple), $label);
12 12
 		$this->_identifier=$identifier;
13 13
 	}
14 14
 
15
-	public function setItems($items){
15
+	public function setItems($items) {
16 16
 		return $this->getField()->setItems($items);
17 17
 	}
18
-	public function addItem($item,$value=NULL,$image=NULL){
19
-		return $this->getField()->addItem($item,$value,$image);
18
+	public function addItem($item, $value=NULL, $image=NULL) {
19
+		return $this->getField()->addItem($item, $value, $image);
20 20
 	}
21
-	public static function multipleDropdown($identifier,$items=array(), $label=NULL,$value="",$associative=true){
22
-		return new HtmlFormDropdown($identifier,$items,$label,$value,true,$associative);
21
+	public static function multipleDropdown($identifier, $items=array(), $label=NULL, $value="", $associative=true) {
22
+		return new HtmlFormDropdown($identifier, $items, $label, $value, true, $associative);
23 23
 	}
24 24
 
25 25
 	/**
26 26
 	 * @return HtmlDropdown
27 27
 	 */
28
-	public function getDataField(){
28
+	public function getDataField() {
29 29
 		return $this->getField()->getInput();
30 30
 	}
31
-	public function asSelect($name=NULL,$multiple=false,$selection=true){
32
-		$this->getField()->asSelect($name,$multiple,$selection);
31
+	public function asSelect($name=NULL, $multiple=false, $selection=true) {
32
+		$this->getField()->asSelect($name, $multiple, $selection);
33 33
 		return $this;
34 34
 	}
35 35
 
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 	 * @param boolean $floating
38 38
 	 * @return HtmlDropdown
39 39
 	 */
40
-	public function asButton($floating=false){
40
+	public function asButton($floating=false) {
41 41
 		$field=$this->content["field"];
42 42
 		$label=$this->content["label"];
43 43
 		$field->addContent($label);
Please login to merge, or discard this patch.
Ajax/semantic/html/collections/HtmlMessage.php 2 patches
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
  * @version 1.001
16 16
  */
17 17
 class HtmlMessage extends HtmlSemDoubleElement {
18
-	use AttachedTrait,HasTimeoutTrait;
18
+	use AttachedTrait, HasTimeoutTrait;
19 19
 	protected $icon;
20 20
 	protected $close;
21 21
 
@@ -32,39 +32,39 @@  discard block
 block discarded – undo
32 32
 	 * @param string|HtmlSemDoubleElement $header
33 33
 	 * @return \Ajax\semantic\html\collections\HtmlMessage
34 34
 	 */
35
-	public function addHeader($header){
35
+	public function addHeader($header) {
36 36
 		$headerO=$header;
37
-		if(\is_string($header)){
38
-			$headerO=new HtmlSemDoubleElement("header-".$this->identifier,"div");
37
+		if (\is_string($header)) {
38
+			$headerO=new HtmlSemDoubleElement("header-".$this->identifier, "div");
39 39
 			$headerO->setClass("header");
40 40
 			$headerO->setContent($header);
41 41
 		}
42
-		return $this->addContent($headerO,true);
42
+		return $this->addContent($headerO, true);
43 43
 	}
44 44
 
45
-	public function setHeader($header){
45
+	public function setHeader($header) {
46 46
 		return $this->addHeader($header);
47 47
 	}
48 48
 
49
-	public function setIcon($icon){
49
+	public function setIcon($icon) {
50 50
 		$this->addToProperty("class", "icon");
51
-		$this->wrapContent("<div class='content'>","</div>");
52
-		if(\is_string($icon)){
51
+		$this->wrapContent("<div class='content'>", "</div>");
52
+		if (\is_string($icon)) {
53 53
 			$this->icon=new HtmlIcon("icon-".$this->identifier, $icon);
54
-		}else{
54
+		} else {
55 55
 			$this->icon=$icon;
56 56
 		}
57 57
 		return $this;
58 58
 	}
59 59
 
60
-	public function addLoader($loaderIcon="notched circle"){
60
+	public function addLoader($loaderIcon="notched circle") {
61 61
 		$this->setIcon($loaderIcon);
62 62
 		$this->icon->addToIcon("loading");
63 63
 		return $this;
64 64
 	}
65 65
 
66
-	public function setDismissable($dismiss=true){
67
-		if($dismiss===true)
66
+	public function setDismissable($dismiss=true) {
67
+		if ($dismiss===true)
68 68
 			$this->close=new HtmlIcon("close-".$this->identifier, "close");
69 69
 		else
70 70
 			$this->close=NULL;
@@ -75,43 +75,43 @@  discard block
 block discarded – undo
75 75
 	 * {@inheritDoc}
76 76
 	 * @see \Ajax\semantic\html\base\HtmlSemDoubleElement::run()
77 77
 	 */
78
-	public function run(JsUtils $js){
79
-		if(!isset($this->_bsComponent)){
80
-			if(isset($this->close)){
78
+	public function run(JsUtils $js) {
79
+		if (!isset($this->_bsComponent)) {
80
+			if (isset($this->close)) {
81 81
 				$js->execOn("click", "#".$this->identifier." .close", "$(this).closest('.message').transition({$this->_closeTransition})");
82 82
 			}
83
-			if(isset($this->_timeout)){
84
-				$js->exec("setTimeout(function() { $('#{$this->identifier}').transition({$this->_closeTransition}); }, {$this->_timeout});",true);
83
+			if (isset($this->_timeout)) {
84
+				$js->exec("setTimeout(function() { $('#{$this->identifier}').transition({$this->_closeTransition}); }, {$this->_timeout});", true);
85 85
 			}
86 86
 		}
87 87
 		return parent::run($js);
88 88
 	}
89 89
 
90
-	public function setState($visible=true){
91
-		$visible=($visible===true)?"visible":"hidden";
92
-		return $this->addToPropertyCtrl("class", $visible, array("visible","hidden"));
90
+	public function setState($visible=true) {
91
+		$visible=($visible===true) ? "visible" : "hidden";
92
+		return $this->addToPropertyCtrl("class", $visible, array("visible", "hidden"));
93 93
 	}
94 94
 
95
-	public function setVariation($value="floating"){
96
-		return $this->addToPropertyCtrl("class", $value, array("floating","compact"));
95
+	public function setVariation($value="floating") {
96
+		return $this->addToPropertyCtrl("class", $value, array("floating", "compact"));
97 97
 	}
98 98
 
99
-	public function setStyle($style){
99
+	public function setStyle($style) {
100 100
 		return $this->addToPropertyCtrl("class", $style, Style::getConstants());
101 101
 	}
102 102
 
103
-	public function setError(){
103
+	public function setError() {
104 104
 		return $this->setStyle("error");
105 105
 	}
106 106
 
107
-	public function setWarning(){
107
+	public function setWarning() {
108 108
 		return $this->setStyle("warning");
109 109
 	}
110 110
 
111
-	public function setMessage($message){
112
-		if(\is_array($this->content)){
111
+	public function setMessage($message) {
112
+		if (\is_array($this->content)) {
113 113
 			$this->content[\sizeof($this->content)-1]=$message;
114
-		}else
114
+		} else
115 115
 			$this->setContent($message);
116 116
 	}
117 117
 
Please login to merge, or discard this patch.
Braces   +9 added lines, -7 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 		$this->wrapContent("<div class='content'>","</div>");
52 52
 		if(\is_string($icon)){
53 53
 			$this->icon=new HtmlIcon("icon-".$this->identifier, $icon);
54
-		}else{
54
+		} else{
55 55
 			$this->icon=$icon;
56 56
 		}
57 57
 		return $this;
@@ -64,10 +64,11 @@  discard block
 block discarded – undo
64 64
 	}
65 65
 
66 66
 	public function setDismissable($dismiss=true){
67
-		if($dismiss===true)
68
-			$this->close=new HtmlIcon("close-".$this->identifier, "close");
69
-		else
70
-			$this->close=NULL;
67
+		if($dismiss===true) {
68
+					$this->close=new HtmlIcon("close-".$this->identifier, "close");
69
+		} else {
70
+					$this->close=NULL;
71
+		}
71 72
 		return $this;
72 73
 	}
73 74
 
@@ -111,8 +112,9 @@  discard block
 block discarded – undo
111 112
 	public function setMessage($message){
112 113
 		if(\is_array($this->content)){
113 114
 			$this->content[\sizeof($this->content)-1]=$message;
114
-		}else
115
-			$this->setContent($message);
115
+		} else {
116
+					$this->setContent($message);
117
+		}
116 118
 	}
117 119
 
118 120
 }
Please login to merge, or discard this patch.
Ajax/common/traits/JsUtilsAjaxTrait.php 2 patches
Spacing   +92 added lines, -92 removed lines patch added patch discarded remove patch
@@ -16,9 +16,9 @@  discard block
 block discarded – undo
16 16
 	protected $ajaxLoader='<span></span><span></span><span></span><span></span><span></span>';
17 17
 
18 18
 	abstract public function getUrl($url);
19
-	abstract public function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false,$immediatly=true);
19
+	abstract public function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false, $immediatly=true);
20 20
 
21
-	protected function _ajax($method,$url,$responseElement="",$parameters=[]) {
21
+	protected function _ajax($method, $url, $responseElement="", $parameters=[]) {
22 22
 		$jsCallback=null;
23 23
 		$attr="id";
24 24
 		$hasLoader=true;
@@ -34,78 +34,78 @@  discard block
 block discarded – undo
34 34
 		$retour=$this->_getAjaxUrl($url, $attr);
35 35
 		$responseElement=$this->_getResponseElement($responseElement);
36 36
 		$retour.="var self=this;\n";
37
-		if($hasLoader===true){
37
+		if ($hasLoader===true) {
38 38
 			$this->addLoading($retour, $responseElement);
39 39
 		}
40 40
 
41
-		$ajaxParameters=["url"=>"url","method"=>"'".\strtoupper($method)."'"];
42
-		if(isset($params)){
41
+		$ajaxParameters=["url"=>"url", "method"=>"'".\strtoupper($method)."'"];
42
+		if (isset($params)) {
43 43
 			$ajaxParameters["data"]=self::_correctParams($params);
44 44
 		}
45
-		if(isset($headers)){
45
+		if (isset($headers)) {
46 46
 			$ajaxParameters["headers"]=$headers;
47 47
 		}
48 48
 		$this->createAjaxParameters($ajaxParameters, $parameters);
49 49
 		$retour.="$.ajax({".$this->implodeAjaxParameters($ajaxParameters)."}).done(function( data, textStatus, jqXHR ) {\n";
50
-		$retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone,$ajaxTransition,$jsCallback)."});\n";
51
-		$retour=$this->_addJsCondition($jsCondition,$retour);
50
+		$retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback)."});\n";
51
+		$retour=$this->_addJsCondition($jsCondition, $retour);
52 52
 		if ($immediatly)
53 53
 			$this->jquery_code_for_compile[]=$retour;
54 54
 		return $retour;
55 55
 	}
56 56
 
57
-	protected function createAjaxParameters(&$original,$parameters){
58
-		$validParameters=["dataType"=>"'%value%'","beforeSend"=>"function(jqXHR,settings){%value%}","complete"=>"function(jqXHR){%value%}"];
59
-		foreach ($validParameters as $param=>$mask){
60
-			if(isset($parameters[$param])){
57
+	protected function createAjaxParameters(&$original, $parameters) {
58
+		$validParameters=["dataType"=>"'%value%'", "beforeSend"=>"function(jqXHR,settings){%value%}", "complete"=>"function(jqXHR){%value%}"];
59
+		foreach ($validParameters as $param=>$mask) {
60
+			if (isset($parameters[$param])) {
61 61
 				$original[$param]=\str_replace("%value%", $parameters[$param], $mask);
62 62
 			}
63 63
 		}
64 64
 	}
65 65
 
66
-	protected function implodeAjaxParameters($ajaxParameters){
67
-		$s = ''; foreach ($ajaxParameters as $k=>$v) { if ($s !== '') { $s .= ','; } $s .= "'{$k}':{$v}"; }
66
+	protected function implodeAjaxParameters($ajaxParameters) {
67
+		$s=''; foreach ($ajaxParameters as $k=>$v) { if ($s!=='') { $s.=','; } $s.="'{$k}':{$v}"; }
68 68
 		return $s;
69 69
 	}
70 70
 
71
-	protected function _addJsCondition($jsCondition,$jsSource){
72
-		if(isset($jsCondition)){
71
+	protected function _addJsCondition($jsCondition, $jsSource) {
72
+		if (isset($jsCondition)) {
73 73
 			return "if(".$jsCondition."){\n".$jsSource."\n}";
74 74
 		}
75 75
 		return $jsSource;
76 76
 	}
77 77
 
78 78
 
79
-	protected function _getAjaxUrl($url,$attr){
79
+	protected function _getAjaxUrl($url, $attr) {
80 80
 		$url=$this->_correctAjaxUrl($url);
81 81
 		$retour="url='".$url."';";
82 82
 		$slash="/";
83
-		if(JString::endswith($url, "/")===true){
83
+		if (JString::endswith($url, "/")===true) {
84 84
 			$slash="";
85 85
 		}
86
-		if(JString::isNotNull($attr)){
87
-			if ($attr==="value"){
86
+		if (JString::isNotNull($attr)) {
87
+			if ($attr==="value") {
88 88
 				$retour.="url=url+'".$slash."'+$(this).val();\n";
89
-			}elseif ($attr==="html"){
89
+			}elseif ($attr==="html") {
90 90
 				$retour.="url=url+'".$slash."'+$(this).html();\n";
91
-			}elseif(\substr($attr, 0,3)==="js:"){
91
+			}elseif (\substr($attr, 0, 3)==="js:") {
92 92
 				$retour.="url=url+'".$slash."'+".\substr($attr, 3).";\n";
93
-			}elseif($attr!==null && $attr!=="")
93
+			}elseif ($attr!==null && $attr!=="")
94 94
 				$retour.="url=url+'".$slash."'+($(this).attr('".$attr."')||'');\n";
95 95
 		}
96 96
 		return $retour;
97 97
 	}
98 98
 
99
-	protected function _getOnAjaxDone($responseElement,$jqueryDone,$ajaxTransition,$jsCallback){
100
-		$retour="";$call=null;
99
+	protected function _getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback) {
100
+		$retour=""; $call=null;
101 101
 		if ($responseElement!=="") {
102
-			if(isset($ajaxTransition)){
102
+			if (isset($ajaxTransition)) {
103 103
 				$call=$this->setAjaxDataCall($ajaxTransition);
104
-			}elseif(isset($this->ajaxTransition)){
104
+			}elseif (isset($this->ajaxTransition)) {
105 105
 				$call=$this->ajaxTransition;
106 106
 			}
107
-			if(\is_callable($call))
108
-				$retour="\t".$call($responseElement,$jqueryDone).";\n";
107
+			if (\is_callable($call))
108
+				$retour="\t".$call($responseElement, $jqueryDone).";\n";
109 109
 			else
110 110
 				$retour="\t$({$responseElement}).{$jqueryDone}( data );\n";
111 111
 		}
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 		return $retour;
114 114
 	}
115 115
 
116
-	protected function _getResponseElement($responseElement){
116
+	protected function _getResponseElement($responseElement) {
117 117
 		if ($responseElement!=="") {
118 118
 			$responseElement=Javascript::prep_value($responseElement);
119 119
 		}
@@ -123,26 +123,26 @@  discard block
 block discarded – undo
123 123
 	protected function _correctAjaxUrl($url) {
124 124
 		if ($url!=="/" && JString::endsWith($url, "/")===true)
125 125
 			$url=substr($url, 0, strlen($url)-1);
126
-			if (strncmp($url, 'http://', 7)!=0&&strncmp($url, 'https://', 8)!=0) {
126
+			if (strncmp($url, 'http://', 7)!=0 && strncmp($url, 'https://', 8)!=0) {
127 127
 				$url=$this->getUrl($url);
128 128
 			}
129 129
 			return $url;
130 130
 	}
131 131
 
132
-	public static function _correctParams($params){
133
-		if(JString::isNull($params)){
132
+	public static function _correctParams($params) {
133
+		if (JString::isNull($params)) {
134 134
 			return "";
135 135
 		}
136
-		if(\preg_match("@^\{.*?\}$@", $params)){
136
+		if (\preg_match("@^\{.*?\}$@", $params)) {
137 137
 			return '$.param('.$params.')';
138 138
 		}
139 139
 		return $params;
140 140
 	}
141 141
 
142
-	public static function _implodeParams($parameters){
142
+	public static function _implodeParams($parameters) {
143 143
 		$allParameters=[];
144
-		foreach ($parameters as $params){
145
-			if(isset($params))
144
+		foreach ($parameters as $params) {
145
+			if (isset($params))
146 146
 				$allParameters[]=self::_correctParams($params);
147 147
 		}
148 148
 		return \implode("+'&'+", $allParameters);
@@ -160,19 +160,19 @@  discard block
 block discarded – undo
160 160
 		$retour.="\t\t$({$responseElement}).prepend('{$loading_notifier}');\n";
161 161
 	}
162 162
 
163
-	protected function setAjaxDataCall($params){
163
+	protected function setAjaxDataCall($params) {
164 164
 		$result=null;
165
-		if(!\is_callable($params)){
166
-			$result=function ($responseElement,$jqueryDone="html") use($params){
167
-				return AjaxTransition::{$params}($responseElement,$jqueryDone);
165
+		if (!\is_callable($params)) {
166
+			$result=function($responseElement, $jqueryDone="html") use($params){
167
+				return AjaxTransition::{$params}($responseElement, $jqueryDone);
168 168
 			};
169 169
 		}
170 170
 		return $result;
171 171
 	}
172 172
 
173
-	protected function setDefaultParameters(&$parameters,$default){
174
-		foreach ($default as $k=>$v){
175
-			if(!isset($parameters[$k]))
173
+	protected function setDefaultParameters(&$parameters, $default) {
174
+		foreach ($default as $k=>$v) {
175
+			if (!isset($parameters[$k]))
176 176
 				$parameters[$k]=$v;
177 177
 		}
178 178
 	}
@@ -186,8 +186,8 @@  discard block
 block discarded – undo
186 186
 	 * @param string $url The url of the request
187 187
 	 * @param string $responseElement selector of the HTML element displaying the answer
188 188
 	 */
189
-	private function _get($url, $responseElement="",$parameters=[]) {
190
-		return $this->_ajax("get", $url,$responseElement,$parameters);
189
+	private function _get($url, $responseElement="", $parameters=[]) {
190
+		return $this->_ajax("get", $url, $responseElement, $parameters);
191 191
 	}
192 192
 
193 193
 	/**
@@ -196,9 +196,9 @@  discard block
 block discarded – undo
196 196
 	 * @param string $responseElement selector of the HTML element displaying the answer
197 197
 	 * @param array $parameters default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null)
198 198
 	 */
199
-	public function get($url, $responseElement="",$parameters=[]) {
199
+	public function get($url, $responseElement="", $parameters=[]) {
200 200
 		$parameters["immediatly"]=true;
201
-		return $this->_get($url,$responseElement,$parameters);
201
+		return $this->_get($url, $responseElement, $parameters);
202 202
 	}
203 203
 
204 204
 	/**
@@ -208,9 +208,9 @@  discard block
 block discarded – undo
208 208
 	 * @param string $responseElement selector of the HTML element displaying the answer
209 209
 	 * @param array $parameters default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null)
210 210
 	 */
211
-	public function ajax($method,$url, $responseElement="", $parameters=[]) {
211
+	public function ajax($method, $url, $responseElement="", $parameters=[]) {
212 212
 		$parameters["immediatly"]=true;
213
-		return $this->_ajax($method,$url,$responseElement,$parameters);
213
+		return $this->_ajax($method, $url, $responseElement, $parameters);
214 214
 	}
215 215
 
216 216
 	/**
@@ -220,9 +220,9 @@  discard block
 block discarded – undo
220 220
 	 * @param string $responseElement selector of the HTML element displaying the answer
221 221
 	 * @param array $parameters default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null)
222 222
 	 */
223
-	public function ajaxDeferred($method,$url, $responseElement="", $parameters=[]) {
223
+	public function ajaxDeferred($method, $url, $responseElement="", $parameters=[]) {
224 224
 		$parameters["immediatly"]=false;
225
-		return $this->_ajax($method,$url,$responseElement,$parameters);
225
+		return $this->_ajax($method, $url, $responseElement, $parameters);
226 226
 	}
227 227
 
228 228
 	/**
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
 	 * @param string $context
236 236
 	 * @param boolean $immediatly
237 237
 	 */
238
-	private function _json($url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context="document",$immediatly=false) {
238
+	private function _json($url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context="document", $immediatly=false) {
239 239
 		$jsCallback=isset($jsCallback) ? $jsCallback : "";
240 240
 		$retour=$this->_getAjaxUrl($url, $attr);
241 241
 		$retour.="$.{$method}(url,".$params.").done(function( data ) {\n";
@@ -258,8 +258,8 @@  discard block
 block discarded – undo
258 258
 	 * @param string $context
259 259
 	 * @param boolean $immediatly
260 260
 	 */
261
-	public function json($url, $method="get", $params="{}", $jsCallback=NULL,$context="document",$immediatly=false) {
262
-		return $this->_json($url,$method,$params,$jsCallback,NULL,$context,$immediatly);
261
+	public function json($url, $method="get", $params="{}", $jsCallback=NULL, $context="document", $immediatly=false) {
262
+		return $this->_json($url, $method, $params, $jsCallback, NULL, $context, $immediatly);
263 263
 	}
264 264
 
265 265
 	/**
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
 	 * @param string $url the request address
270 270
 	 * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get","immediatly"=>true)
271 271
 	 */
272
-	public function jsonOn($event,$element, $url,$parameters=array()) {
272
+	public function jsonOn($event, $element, $url, $parameters=array()) {
273 273
 		$preventDefault=true;
274 274
 		$stopPropagation=true;
275 275
 		$jsCallback=null;
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
 		$params="{}";
280 280
 		$immediatly=true;
281 281
 		extract($parameters);
282
-		return $this->_add_event($element, $this->_json($url,$method, $params,$jsCallback, $attr,$context), $event, $preventDefault, $stopPropagation,$immediatly);
282
+		return $this->_add_event($element, $this->_json($url, $method, $params, $jsCallback, $attr, $context), $event, $preventDefault, $stopPropagation, $immediatly);
283 283
 	}
284 284
 
285 285
 	/**
@@ -290,8 +290,8 @@  discard block
 block discarded – undo
290 290
 	 * @param string $jsCallback javascript code to execute after the request
291 291
 	 * @param string $context jquery DOM element, array container.
292 292
 	 */
293
-	public function jsonDeferred($url, $method="get", $params="{}", $jsCallback=NULL,$context=NULL) {
294
-		return $this->json($url, $method, $params, $jsCallback, $context,false);
293
+	public function jsonDeferred($url, $method="get", $params="{}", $jsCallback=NULL, $context=NULL) {
294
+		return $this->json($url, $method, $params, $jsCallback, $context, false);
295 295
 	}
296 296
 
297 297
 	/**
@@ -304,22 +304,22 @@  discard block
 block discarded – undo
304 304
 	 * @param string $rowClass the css class for the new element
305 305
 	 * @param boolean $immediatly
306 306
 	 */
307
-	private function _jsonArray($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL,$rowClass="_json",$context=NULL,$attr="id",$immediatly=false) {
307
+	private function _jsonArray($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL, $rowClass="_json", $context=NULL, $attr="id", $immediatly=false) {
308 308
 		$jsCallback=isset($jsCallback) ? $jsCallback : "";
309 309
 		$retour=$this->_getAjaxUrl($url, $attr);
310
-		if($context===null){
310
+		if ($context===null) {
311 311
 			$parent="$('".$maskSelector."').parent()";
312
-			$newElm = "$('#'+newId)";
313
-		}else{
312
+			$newElm="$('#'+newId)";
313
+		} else {
314 314
 			$parent=$context;
315
-			$newElm = $context.".find('#'+newId)";
315
+			$newElm=$context.".find('#'+newId)";
316 316
 		}
317 317
 		$appendTo="\t\tnewElm.appendTo(".$parent.");\n";
318 318
 		$retour.="var self = $(this);\n$.{$method}(url,".$params.").done(function( data ) {\n";
319 319
 		$retour.=$parent.".find('._json').remove();";
320 320
 		$retour.="\tdata=$.parseJSON(data);$.each(data, function(index, value) {\n"."\tvar created=false;var maskElm=$('".$maskSelector."').first();maskElm.hide();"."\tvar newId=(maskElm.attr('id') || 'mask')+'-'+index;"."\tvar newElm=".$newElm.";\n"."\tif(!newElm.length){\n"."\t\tnewElm=maskElm.clone();
321 321
 		newElm.attr('id',newId);\n;newElm.addClass('{$rowClass}').removeClass('_jsonArrayModel');\nnewElm.find('[id]').each(function(){ var newId=$(this).attr('id')+'-'+index;$(this).attr('id',newId).removeClass('_jsonArrayChecked');});\n";
322
-		$retour.= $appendTo;
322
+		$retour.=$appendTo;
323 323
 		$retour.="\t}\n"."\tfor(var key in value){\n"."\t\t\tvar html = $('<div />').append($(newElm).clone()).html();\n"."\t\t\tif(html.indexOf('__'+key+'__')>-1){\n"."\t\t\t\tcontent=$(html.split('__'+key+'__').join(value[key]));\n"."\t\t\t\t$(newElm).replaceWith(content);newElm=content;\n"."\t\t\t}\n"."\t\tvar sel='[data-id=\"'+key+'\"]';if($(sel,newElm).length){\n"."\t\t\tvar selElm=$(sel,newElm);\n"."\t\t\t if(selElm.is('[value]')) { selElm.attr('value',value[key]);selElm.val(value[key]);} else { selElm.html(value[key]); }\n"."\t\t}\n"."}\n"."\t$(newElm).show(true);"."\n"."\t$(newElm).removeClass('hide');"."});\n";
324 324
 		$retour.="\t$(document).trigger('jsonReady',[data]);\n";
325 325
 		$retour.="\t".$jsCallback."\n"."});\n";
@@ -338,8 +338,8 @@  discard block
 block discarded – undo
338 338
 	 * @param string $context jquery DOM element, array container.
339 339
 	 * @param boolean $immediatly
340 340
 	 */
341
-	public function jsonArray($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL,$rowClass="_json",$context=NULL,$immediatly=false) {
342
-		return $this->_jsonArray($maskSelector, $url,$method,$params,$jsCallback,$rowClass,$context,NULL,$immediatly);
341
+	public function jsonArray($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL, $rowClass="_json", $context=NULL, $immediatly=false) {
342
+		return $this->_jsonArray($maskSelector, $url, $method, $params, $jsCallback, $rowClass, $context, NULL, $immediatly);
343 343
 	}
344 344
 
345 345
 	/**
@@ -352,8 +352,8 @@  discard block
 block discarded – undo
352 352
 	 * @param string $rowClass the css class for the new element
353 353
 	 * @param string $context jquery DOM element, array container.
354 354
 	 */
355
-	public function jsonArrayDeferred($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL,$rowClass="_json",$context=NULL) {
356
-		return $this->jsonArray($maskSelector, $url, $method, $params, $jsCallback,$rowClass,$context,false);
355
+	public function jsonArrayDeferred($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL, $rowClass="_json", $context=NULL) {
356
+		return $this->jsonArray($maskSelector, $url, $method, $params, $jsCallback, $rowClass, $context, false);
357 357
 	}
358 358
 
359 359
 	/**
@@ -363,18 +363,18 @@  discard block
 block discarded – undo
363 363
 	 * @param string $url the request url
364 364
 	 * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get","rowClass"=>"_json","immediatly"=>true)
365 365
 	 */
366
-	public function jsonArrayOn($event,$element,$maskSelector, $url,$parameters=array()) {
366
+	public function jsonArrayOn($event, $element, $maskSelector, $url, $parameters=array()) {
367 367
 		$preventDefault=true;
368 368
 		$stopPropagation=true;
369 369
 		$jsCallback=null;
370 370
 		$attr="id";
371 371
 		$method="get";
372
-		$context = null;
372
+		$context=null;
373 373
 		$params="{}";
374 374
 		$immediatly=true;
375 375
 		$rowClass="_json";
376 376
 		extract($parameters);
377
-		return $this->_add_event($element, $this->_jsonArray($maskSelector,$url,$method, $params,$jsCallback, $rowClass, $context,$attr), $event, $preventDefault, $stopPropagation,$immediatly);
377
+		return $this->_add_event($element, $this->_jsonArray($maskSelector, $url, $method, $params, $jsCallback, $rowClass, $context, $attr), $event, $preventDefault, $stopPropagation, $immediatly);
378 378
 	}
379 379
 
380 380
 	/**
@@ -386,7 +386,7 @@  discard block
 block discarded – undo
386 386
 	 */
387 387
 	public function getDeferred($url, $responseElement="", $parameters=[]) {
388 388
 		$parameters["immediatly"]=false;
389
-		return $this->_get($url, $responseElement,$parameters);
389
+		return $this->_get($url, $responseElement, $parameters);
390 390
 	}
391 391
 
392 392
 	/**
@@ -399,8 +399,8 @@  discard block
 block discarded – undo
399 399
 	 * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"immediatly"=>true,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>null,"headers"=>null)
400 400
 	 */
401 401
 	public function getOn($event, $element, $url, $responseElement="", $parameters=array()) {
402
-		$this->setDefaultParameters($parameters, ["preventDefault"=>true,"stopPropagation"=>true,"immediatly"=>true]);
403
-		return $this->_add_event($element, $this->getDeferred($url,$responseElement,$parameters), $event, $parameters["preventDefault"], $parameters["stopPropagation"],$parameters["immediatly"]);
402
+		$this->setDefaultParameters($parameters, ["preventDefault"=>true, "stopPropagation"=>true, "immediatly"=>true]);
403
+		return $this->_add_event($element, $this->getDeferred($url, $responseElement, $parameters), $event, $parameters["preventDefault"], $parameters["stopPropagation"], $parameters["immediatly"]);
404 404
 	}
405 405
 
406 406
 	/**
@@ -413,8 +413,8 @@  discard block
 block discarded – undo
413 413
 	 * @param array $parameters default : array("method"=>"get","preventDefault"=>true,"stopPropagation"=>true,"params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"immediatly"=>true,"jqueryDone"=>"html","jsCondition"=>NULL,"headers"=>null)
414 414
 	 */
415 415
 	public function ajaxOn($event, $element, $url, $responseElement="", $parameters=array()) {
416
-		$this->setDefaultParameters($parameters, ["preventDefault"=>true,"stopPropagation"=>true,"immediatly"=>true,"method"=>"get"]);
417
-		return $this->_add_event($element, $this->ajaxDeferred($parameters["method"],$url,$responseElement,$parameters), $event, $parameters["preventDefault"], $parameters["stopPropagation"],$parameters["immediatly"]);
416
+		$this->setDefaultParameters($parameters, ["preventDefault"=>true, "stopPropagation"=>true, "immediatly"=>true, "method"=>"get"]);
417
+		return $this->_add_event($element, $this->ajaxDeferred($parameters["method"], $url, $responseElement, $parameters), $event, $parameters["preventDefault"], $parameters["stopPropagation"], $parameters["immediatly"]);
418 418
 	}
419 419
 
420 420
 	/**
@@ -441,9 +441,9 @@  discard block
 block discarded – undo
441 441
 		return $this->getOn("click", $element, $url, $responseElement, $parameters);
442 442
 	}
443 443
 
444
-	private function _post($url, $params="{}",$responseElement="", $parameters=[]) {
444
+	private function _post($url, $params="{}", $responseElement="", $parameters=[]) {
445 445
 		$parameters["params"]=$params;
446
-		return $this->_ajax("POST", $url,$responseElement,$parameters);
446
+		return $this->_ajax("POST", $url, $responseElement, $parameters);
447 447
 	}
448 448
 
449 449
 	/**
@@ -453,8 +453,8 @@  discard block
 block discarded – undo
453 453
 	 * @param string $params JSON parameters
454 454
 	 * @param array $parameters default : array("jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"immediatly"=>true,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null)
455 455
 	 */
456
-	public function post($url, $params="{}",$responseElement="", $parameters=[]) {
457
-		return $this->_post($url, $params,$responseElement, $parameters);
456
+	public function post($url, $params="{}", $responseElement="", $parameters=[]) {
457
+		return $this->_post($url, $params, $responseElement, $parameters);
458 458
 	}
459 459
 
460 460
 	/**
@@ -465,7 +465,7 @@  discard block
 block discarded – undo
465 465
 	 * @param string $responseElement selector of the HTML element displaying the answer
466 466
 	 * @param array $parameters default : array("jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"immediatly"=>true,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null)
467 467
 	 */
468
-	public function postDeferred($url, $params="{}",$responseElement="", $parameters=[]) {
468
+	public function postDeferred($url, $params="{}", $responseElement="", $parameters=[]) {
469 469
 		$parameters["immediatly"]=false;
470 470
 		return $this->_post($url, $params, $responseElement, $parameters);
471 471
 	}
@@ -481,8 +481,8 @@  discard block
 block discarded – undo
481 481
 	 * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"immediatly"=>true,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null)
482 482
 	 */
483 483
 	public function postOn($event, $element, $url, $params="{}", $responseElement="", $parameters=array()) {
484
-		$this->setDefaultParameters($parameters, ["preventDefault"=>true,"stopPropagation"=>true,"immediatly"=>true]);
485
-		return $this->_add_event($element, $this->postDeferred($url, $params, $responseElement, $parameters), $event, $parameters["preventDefault"], $parameters["stopPropagation"],$parameters["immediatly"]);
484
+		$this->setDefaultParameters($parameters, ["preventDefault"=>true, "stopPropagation"=>true, "immediatly"=>true]);
485
+		return $this->_add_event($element, $this->postDeferred($url, $params, $responseElement, $parameters), $event, $parameters["preventDefault"], $parameters["stopPropagation"], $parameters["immediatly"]);
486 486
 	}
487 487
 
488 488
 	/**
@@ -499,26 +499,26 @@  discard block
 block discarded – undo
499 499
 	}
500 500
 
501 501
 	private function _postForm($url, $form, $responseElement, $parameters=[]) {
502
-		$params="{}";$validation=false;$jsCallback=NULL;$attr="id";$hasLoader=true;$jqueryDone="html";$ajaxTransition=null;$immediatly=false;$jsCondition=NULL;$headers=NULL;
502
+		$params="{}"; $validation=false; $jsCallback=NULL; $attr="id"; $hasLoader=true; $jqueryDone="html"; $ajaxTransition=null; $immediatly=false; $jsCondition=NULL; $headers=NULL;
503 503
 		\extract($parameters);
504 504
 		$jsCallback=isset($jsCallback) ? $jsCallback : "";
505 505
 		$retour=$this->_getAjaxUrl($url, $attr);
506 506
 		$retour.="\nvar params=$('#".$form."').serialize();\n";
507
-		if(isset($params)){
507
+		if (isset($params)) {
508 508
 			$retour.="params+='&'+".self::_correctParams($params).";\n";
509 509
 		}
510 510
 		$responseElement=$this->_getResponseElement($responseElement);
511 511
 		$retour.="var self=this;\n";
512
-		if($hasLoader===true){
512
+		if ($hasLoader===true) {
513 513
 			$this->addLoading($retour, $responseElement);
514 514
 		}
515
-		$ajaxParameters=["url"=>"url","method"=>"'POST'","data"=>"params"];
516
-		if(isset($headers)){
515
+		$ajaxParameters=["url"=>"url", "method"=>"'POST'", "data"=>"params"];
516
+		if (isset($headers)) {
517 517
 			$ajaxParameters["headers"]=$headers;
518 518
 		}
519 519
 		$this->createAjaxParameters($ajaxParameters, $parameters);
520 520
 		$retour.="$.ajax({".$this->implodeAjaxParameters($ajaxParameters)."}).done(function( data ) {\n";
521
-		$retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone,$ajaxTransition,$jsCallback)."});\n";
521
+		$retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback)."});\n";
522 522
 
523 523
 		if ($validation) {
524 524
 			$retour="$('#".$form."').validate({submitHandler: function(form) {
@@ -568,8 +568,8 @@  discard block
 block discarded – undo
568 568
 	 * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"validation"=>false,"params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"immediatly"=>true,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>null,"headers"=>null)
569 569
 	 */
570 570
 	public function postFormOn($event, $element, $url, $form, $responseElement="", $parameters=array()) {
571
-		$this->setDefaultParameters($parameters, ["preventDefault"=>true,"stopPropagation"=>true,"immediatly"=>true]);
572
-		return $this->_add_event($element, $this->postFormDeferred($url, $form, $responseElement,$parameters), $event, $parameters["preventDefault"], $parameters["stopPropagation"],$parameters["immediatly"]);
571
+		$this->setDefaultParameters($parameters, ["preventDefault"=>true, "stopPropagation"=>true, "immediatly"=>true]);
572
+		return $this->_add_event($element, $this->postFormDeferred($url, $form, $responseElement, $parameters), $event, $parameters["preventDefault"], $parameters["stopPropagation"], $parameters["immediatly"]);
573 573
 	}
574 574
 
575 575
 	/**
Please login to merge, or discard this patch.
Braces   +33 added lines, -24 removed lines patch added patch discarded remove patch
@@ -49,8 +49,9 @@  discard block
 block discarded – undo
49 49
 		$retour.="$.ajax({".$this->implodeAjaxParameters($ajaxParameters)."}).done(function( data, textStatus, jqXHR ) {\n";
50 50
 		$retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone,$ajaxTransition,$jsCallback)."});\n";
51 51
 		$retour=$this->_addJsCondition($jsCondition,$retour);
52
-		if ($immediatly)
53
-			$this->jquery_code_for_compile[]=$retour;
52
+		if ($immediatly) {
53
+					$this->jquery_code_for_compile[]=$retour;
54
+		}
54 55
 		return $retour;
55 56
 	}
56 57
 
@@ -86,12 +87,13 @@  discard block
 block discarded – undo
86 87
 		if(JString::isNotNull($attr)){
87 88
 			if ($attr==="value"){
88 89
 				$retour.="url=url+'".$slash."'+$(this).val();\n";
89
-			}elseif ($attr==="html"){
90
+			} elseif ($attr==="html"){
90 91
 				$retour.="url=url+'".$slash."'+$(this).html();\n";
91
-			}elseif(\substr($attr, 0,3)==="js:"){
92
+			} elseif(\substr($attr, 0,3)==="js:"){
92 93
 				$retour.="url=url+'".$slash."'+".\substr($attr, 3).";\n";
93
-			}elseif($attr!==null && $attr!=="")
94
-				$retour.="url=url+'".$slash."'+($(this).attr('".$attr."')||'');\n";
94
+			} elseif($attr!==null && $attr!=="") {
95
+							$retour.="url=url+'".$slash."'+($(this).attr('".$attr."')||'');\n";
96
+			}
95 97
 		}
96 98
 		return $retour;
97 99
 	}
@@ -101,13 +103,14 @@  discard block
 block discarded – undo
101 103
 		if ($responseElement!=="") {
102 104
 			if(isset($ajaxTransition)){
103 105
 				$call=$this->setAjaxDataCall($ajaxTransition);
104
-			}elseif(isset($this->ajaxTransition)){
106
+			} elseif(isset($this->ajaxTransition)){
105 107
 				$call=$this->ajaxTransition;
106 108
 			}
107
-			if(\is_callable($call))
108
-				$retour="\t".$call($responseElement,$jqueryDone).";\n";
109
-			else
110
-				$retour="\t$({$responseElement}).{$jqueryDone}( data );\n";
109
+			if(\is_callable($call)) {
110
+							$retour="\t".$call($responseElement,$jqueryDone).";\n";
111
+			} else {
112
+							$retour="\t$({$responseElement}).{$jqueryDone}( data );\n";
113
+			}
111 114
 		}
112 115
 		$retour.="\t".$jsCallback."\n";
113 116
 		return $retour;
@@ -121,8 +124,9 @@  discard block
 block discarded – undo
121 124
 	}
122 125
 
123 126
 	protected function _correctAjaxUrl($url) {
124
-		if ($url!=="/" && JString::endsWith($url, "/")===true)
125
-			$url=substr($url, 0, strlen($url)-1);
127
+		if ($url!=="/" && JString::endsWith($url, "/")===true) {
128
+					$url=substr($url, 0, strlen($url)-1);
129
+		}
126 130
 			if (strncmp($url, 'http://', 7)!=0&&strncmp($url, 'https://', 8)!=0) {
127 131
 				$url=$this->getUrl($url);
128 132
 			}
@@ -142,8 +146,9 @@  discard block
 block discarded – undo
142 146
 	public static function _implodeParams($parameters){
143 147
 		$allParameters=[];
144 148
 		foreach ($parameters as $params){
145
-			if(isset($params))
146
-				$allParameters[]=self::_correctParams($params);
149
+			if(isset($params)) {
150
+							$allParameters[]=self::_correctParams($params);
151
+			}
147 152
 		}
148 153
 		return \implode("+'&'+", $allParameters);
149 154
 	}
@@ -172,8 +177,9 @@  discard block
 block discarded – undo
172 177
 
173 178
 	protected function setDefaultParameters(&$parameters,$default){
174 179
 		foreach ($default as $k=>$v){
175
-			if(!isset($parameters[$k]))
176
-				$parameters[$k]=$v;
180
+			if(!isset($parameters[$k])) {
181
+							$parameters[$k]=$v;
182
+			}
177 183
 		}
178 184
 	}
179 185
 
@@ -244,8 +250,9 @@  discard block
 block discarded – undo
244 250
 				$retour.="\t".$jsCallback."\n".
245 251
 						"\t$(document).trigger('jsonReady',[data]);\n".
246 252
 						"});\n";
247
-				if ($immediatly)
248
-					$this->jquery_code_for_compile[]=$retour;
253
+				if ($immediatly) {
254
+									$this->jquery_code_for_compile[]=$retour;
255
+				}
249 256
 		return $retour;
250 257
 	}
251 258
 
@@ -310,7 +317,7 @@  discard block
 block discarded – undo
310 317
 		if($context===null){
311 318
 			$parent="$('".$maskSelector."').parent()";
312 319
 			$newElm = "$('#'+newId)";
313
-		}else{
320
+		} else{
314 321
 			$parent=$context;
315 322
 			$newElm = $context.".find('#'+newId)";
316 323
 		}
@@ -323,8 +330,9 @@  discard block
 block discarded – undo
323 330
 		$retour.="\t}\n"."\tfor(var key in value){\n"."\t\t\tvar html = $('<div />').append($(newElm).clone()).html();\n"."\t\t\tif(html.indexOf('__'+key+'__')>-1){\n"."\t\t\t\tcontent=$(html.split('__'+key+'__').join(value[key]));\n"."\t\t\t\t$(newElm).replaceWith(content);newElm=content;\n"."\t\t\t}\n"."\t\tvar sel='[data-id=\"'+key+'\"]';if($(sel,newElm).length){\n"."\t\t\tvar selElm=$(sel,newElm);\n"."\t\t\t if(selElm.is('[value]')) { selElm.attr('value',value[key]);selElm.val(value[key]);} else { selElm.html(value[key]); }\n"."\t\t}\n"."}\n"."\t$(newElm).show(true);"."\n"."\t$(newElm).removeClass('hide');"."});\n";
324 331
 		$retour.="\t$(document).trigger('jsonReady',[data]);\n";
325 332
 		$retour.="\t".$jsCallback."\n"."});\n";
326
-		if ($immediatly)
327
-			$this->jquery_code_for_compile[]=$retour;
333
+		if ($immediatly) {
334
+					$this->jquery_code_for_compile[]=$retour;
335
+		}
328 336
 		return $retour;
329 337
 	}
330 338
 
@@ -527,8 +535,9 @@  discard block
 block discarded – undo
527 535
 			$retour.="$('#".$form."').submit();\n";
528 536
 		}
529 537
 		$retour=$this->_addJsCondition($jsCondition, $retour);
530
-		if ($immediatly)
531
-			$this->jquery_code_for_compile[]=$retour;
538
+		if ($immediatly) {
539
+					$this->jquery_code_for_compile[]=$retour;
540
+		}
532 541
 		return $retour;
533 542
 	}
534 543
 
Please login to merge, or discard this patch.