@@ -12,11 +12,13 @@ discard block |
||
12 | 12 | |
13 | 13 | public function __construct($identifier, $value=NULL, $label=NULL) { |
14 | 14 | parent::__construct($identifier, "div", "ui progress"); |
15 | - if (isset($value) === true) |
|
16 | - $this->setProperty("data-percent", $value); |
|
15 | + if (isset($value) === true) { |
|
16 | + $this->setProperty("data-percent", $value); |
|
17 | + } |
|
17 | 18 | $this->createBar(); |
18 | - if (isset($label) === true) |
|
19 | - $this->setLabel($label); |
|
19 | + if (isset($label) === true) { |
|
20 | + $this->setLabel($label); |
|
21 | + } |
|
20 | 22 | } |
21 | 23 | |
22 | 24 | public function setLabel($label) { |
@@ -93,8 +95,9 @@ discard block |
||
93 | 95 | * @see BaseHtml::run() |
94 | 96 | */ |
95 | 97 | public function run(JsUtils $js) { |
96 | - if (isset($this->_bsComponent) === false) |
|
97 | - $this->_bsComponent=$js->semantic()->progress("#" . $this->identifier, $this->_params); |
|
98 | + if (isset($this->_bsComponent) === false) { |
|
99 | + $this->_bsComponent=$js->semantic()->progress("#" . $this->identifier, $this->_params); |
|
100 | + } |
|
98 | 101 | $this->addEventsOnRun($js); |
99 | 102 | return $this->_bsComponent; |
100 | 103 | } |
@@ -9,26 +9,26 @@ discard block |
||
9 | 9 | use Ajax\semantic\html\base\constants\State; |
10 | 10 | |
11 | 11 | class HtmlProgress extends HtmlSemDoubleElement { |
12 | - private $_params=array (); |
|
12 | + private $_params=array(); |
|
13 | 13 | |
14 | 14 | public function __construct($identifier, $value=NULL, $label=NULL, $attributes=array()) { |
15 | 15 | parent::__construct($identifier, "div", "ui progress"); |
16 | - if (isset($value) === true) |
|
16 | + if (isset($value)===true) |
|
17 | 17 | $this->setProperty("data-percent", $value); |
18 | 18 | $this->createBar(); |
19 | - if (isset($label) === true) |
|
19 | + if (isset($label)===true) |
|
20 | 20 | $this->setLabel($label); |
21 | - $this->_states=[ State::SUCCESS,State::WARNING,State::ERROR,State::ACTIVE,State::DISABLED ]; |
|
21 | + $this->_states=[State::SUCCESS, State::WARNING, State::ERROR, State::ACTIVE, State::DISABLED]; |
|
22 | 22 | $this->addToProperty("class", $attributes); |
23 | 23 | } |
24 | 24 | |
25 | 25 | public function setLabel($label) { |
26 | - $this->content["label"]=new HtmlSemDoubleElement("lbl-" . $this->identifier, "div", "label", $label); |
|
26 | + $this->content["label"]=new HtmlSemDoubleElement("lbl-".$this->identifier, "div", "label", $label); |
|
27 | 27 | return $this; |
28 | 28 | } |
29 | 29 | |
30 | 30 | private function createBar() { |
31 | - $bar=new HtmlSemDoubleElement("bar-" . $this->identifier, "div", "bar", new HtmlSemDoubleElement("progress-" . $this->identifier, "div", "progress")); |
|
31 | + $bar=new HtmlSemDoubleElement("bar-".$this->identifier, "div", "bar", new HtmlSemDoubleElement("progress-".$this->identifier, "div", "progress")); |
|
32 | 32 | $this->content["bar"]=$bar; |
33 | 33 | return $this; |
34 | 34 | } |
@@ -68,20 +68,20 @@ discard block |
||
68 | 68 | * @see \Ajax\semantic\html\base\HtmlSemDoubleElement::compile() |
69 | 69 | */ |
70 | 70 | public function compile(JsUtils $js=NULL, View $view=NULL) { |
71 | - $this->content=JArray::sortAssociative($this->content, [ "bar","label" ]); |
|
71 | + $this->content=JArray::sortAssociative($this->content, ["bar", "label"]); |
|
72 | 72 | return parent::compile($js, $view); |
73 | 73 | } |
74 | 74 | |
75 | 75 | public function jsSetValue($value) { |
76 | - return '$("#' . $this->identifier . '").progress({value:' . $value . '});'; |
|
76 | + return '$("#'.$this->identifier.'").progress({value:'.$value.'});'; |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | public function jsIncValue() { |
80 | - return '$("#' . $this->identifier . '").progress("increment");'; |
|
80 | + return '$("#'.$this->identifier.'").progress("increment");'; |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | public function jsDecValue() { |
84 | - return '$("#' . $this->identifier . '").progress("decrement");'; |
|
84 | + return '$("#'.$this->identifier.'").progress("decrement");'; |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | /** |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | * @return HtmlProgress |
96 | 96 | */ |
97 | 97 | public function setTextValues($active=false, $error=false, $success=false, $warning=false, $percent="{percent}%", $ratio="{value} of {total}") { |
98 | - if (\is_array($active) == true) { |
|
98 | + if (\is_array($active)==true) { |
|
99 | 99 | $array=$active; |
100 | 100 | $active=JArray::getDefaultValue($array, "active", false); |
101 | 101 | $success=JArray::getDefaultValue($array, "success", $success); |
@@ -103,12 +103,12 @@ discard block |
||
103 | 103 | $percent=JArray::getDefaultValue($array, "percent", $percent); |
104 | 104 | $ratio=JArray::getDefaultValue($array, "ratio", $ratio); |
105 | 105 | } |
106 | - $this->_params["text"]="%{active : " . \var_export($active, true) . ",error: " . \var_export($error, true) . ",success : " . \var_export($success, true) . ",warning : " . \var_export($warning, true) . ",percent : " . \var_export($percent, true) . ",ratio : " . \var_export($ratio, true) . "}%"; |
|
106 | + $this->_params["text"]="%{active : ".\var_export($active, true).",error: ".\var_export($error, true).",success : ".\var_export($success, true).",warning : ".\var_export($warning, true).",percent : ".\var_export($percent, true).",ratio : ".\var_export($ratio, true)."}%"; |
|
107 | 107 | return $this; |
108 | 108 | } |
109 | 109 | |
110 | 110 | public function onChange($jsCode) { |
111 | - return $this->_params["onChange"]="%function(percent, value, total){" . $jsCode . "}%"; |
|
111 | + return $this->_params["onChange"]="%function(percent, value, total){".$jsCode."}%"; |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | /* |
@@ -116,8 +116,8 @@ discard block |
||
116 | 116 | * @see BaseHtml::run() |
117 | 117 | */ |
118 | 118 | public function run(JsUtils $js) { |
119 | - if (isset($this->_bsComponent) === false) |
|
120 | - $this->_bsComponent=$js->semantic()->progress("#" . $this->identifier, $this->_params); |
|
119 | + if (isset($this->_bsComponent)===false) |
|
120 | + $this->_bsComponent=$js->semantic()->progress("#".$this->identifier, $this->_params); |
|
121 | 121 | $this->addEventsOnRun($js); |
122 | 122 | return $this->_bsComponent; |
123 | 123 | } |
@@ -20,7 +20,7 @@ |
||
20 | 20 | * @see \Ajax\bootstrap\html\base\HtmlSingleElement::run() |
21 | 21 | */ |
22 | 22 | public function run(JsUtils $js) { |
23 | - $this->_bsComponent=$js->semantic()->generic("#" . $this->identifier); |
|
23 | + $this->_bsComponent=$js->semantic()->generic("#".$this->identifier); |
|
24 | 24 | $this->addEventsOnRun($js); |
25 | 25 | return $this->_bsComponent; |
26 | 26 | } |
@@ -14,8 +14,8 @@ discard block |
||
14 | 14 | |
15 | 15 | public function __construct($identifier, $elements=array(), $asIcons=false) { |
16 | 16 | parent::__construct($identifier, "div", "ui buttons"); |
17 | - $this->content=array (); |
|
18 | - if ($asIcons === true) |
|
17 | + $this->content=array(); |
|
18 | + if ($asIcons===true) |
|
19 | 19 | $this->asIcons(); |
20 | 20 | $this->addElements($elements, $asIcons); |
21 | 21 | } |
@@ -24,25 +24,25 @@ discard block |
||
24 | 24 | $elementO=$element; |
25 | 25 | if (\is_string($element)) { |
26 | 26 | if ($asIcon) { |
27 | - $elementO=new HtmlButton("button-" . $this->identifier . "-" . \sizeof($this->content)); |
|
27 | + $elementO=new HtmlButton("button-".$this->identifier."-".\sizeof($this->content)); |
|
28 | 28 | $elementO->asIcon($element); |
29 | - } else |
|
30 | - $elementO=new HtmlButton("button-" . $this->identifier . "-" . \sizeof($this->content), $element); |
|
29 | + }else |
|
30 | + $elementO=new HtmlButton("button-".$this->identifier."-".\sizeof($this->content), $element); |
|
31 | 31 | } |
32 | 32 | $this->addContent($elementO); |
33 | 33 | } |
34 | 34 | |
35 | 35 | public function addElements($elements, $asIcons=false) { |
36 | - foreach ( $elements as $element ) { |
|
36 | + foreach ($elements as $element) { |
|
37 | 37 | $this->addElement($element, $asIcons); |
38 | 38 | } |
39 | 39 | return $this; |
40 | 40 | } |
41 | 41 | |
42 | 42 | public function insertOr($aferIndex=0, $or="or") { |
43 | - $orElement=new HtmlSemDoubleElement("or-" . $this->identifier, "div", "or"); |
|
43 | + $orElement=new HtmlSemDoubleElement("or-".$this->identifier, "div", "or"); |
|
44 | 44 | $orElement->setProperty("data-text", $or); |
45 | - array_splice($this->content, $aferIndex + 1, 0, array ($orElement )); |
|
45 | + array_splice($this->content, $aferIndex+1, 0, array($orElement)); |
|
46 | 46 | return $this; |
47 | 47 | } |
48 | 48 | |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | } |
56 | 56 | |
57 | 57 | public function asIcons() { |
58 | - foreach ( $this->content as $item ) { |
|
58 | + foreach ($this->content as $item) { |
|
59 | 59 | $item->asIcon($item->getContent()); |
60 | 60 | } |
61 | 61 | return $this->addToProperty("class", "icons"); |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | * @see \Ajax\bootstrap\html\base\BaseHtml::on() |
94 | 94 | */ |
95 | 95 | public function on($event, $jsCode, $stopPropagation=false, $preventDefault=false) { |
96 | - foreach ( $this->content as $element ) { |
|
96 | + foreach ($this->content as $element) { |
|
97 | 97 | $element->on($event, $jsCode, $stopPropagation, $preventDefault); |
98 | 98 | } |
99 | 99 | return $this; |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | |
106 | 106 | public function addClasses($classes=array()) { |
107 | 107 | $i=0; |
108 | - foreach ( $this->content as $button ) { |
|
108 | + foreach ($this->content as $button) { |
|
109 | 109 | $button->addToProperty("class", $classes[$i++]); |
110 | 110 | } |
111 | 111 | return $this; |
@@ -15,8 +15,9 @@ discard block |
||
15 | 15 | public function __construct($identifier, $elements=array(), $asIcons=false) { |
16 | 16 | parent::__construct($identifier, "div", "ui buttons"); |
17 | 17 | $this->content=array (); |
18 | - if ($asIcons === true) |
|
19 | - $this->asIcons(); |
|
18 | + if ($asIcons === true) { |
|
19 | + $this->asIcons(); |
|
20 | + } |
|
20 | 21 | $this->addElements($elements, $asIcons); |
21 | 22 | } |
22 | 23 | |
@@ -26,8 +27,9 @@ discard block |
||
26 | 27 | if ($asIcon) { |
27 | 28 | $elementO=new HtmlButton("button-" . $this->identifier . "-" . \sizeof($this->content)); |
28 | 29 | $elementO->asIcon($element); |
29 | - } else |
|
30 | - $elementO=new HtmlButton("button-" . $this->identifier . "-" . \sizeof($this->content), $element); |
|
30 | + } else { |
|
31 | + $elementO=new HtmlButton("button-" . $this->identifier . "-" . \sizeof($this->content), $element); |
|
32 | + } |
|
31 | 33 | } |
32 | 34 | $this->addContent($elementO); |
33 | 35 | } |
@@ -75,9 +77,9 @@ discard block |
||
75 | 77 | * @return HtmlButton |
76 | 78 | */ |
77 | 79 | public function getElement($index) { |
78 | - if (is_int($index)) |
|
79 | - return $this->content[$index]; |
|
80 | - else { |
|
80 | + if (is_int($index)) { |
|
81 | + return $this->content[$index]; |
|
82 | + } else { |
|
81 | 83 | $elm=$this->getElementById($index, $this->content); |
82 | 84 | return $elm; |
83 | 85 | } |
@@ -29,8 +29,9 @@ discard block |
||
29 | 29 | |
30 | 30 | public function addHeader($title, $niveau=1, $dividing=true) { |
31 | 31 | $header=new HtmlHeader("", $niveau, $title); |
32 | - if ($dividing) |
|
33 | - $header->setDividing(); |
|
32 | + if ($dividing) { |
|
33 | + $header->setDividing(); |
|
34 | + } |
|
34 | 35 | return $this->addItem($header); |
35 | 36 | } |
36 | 37 | |
@@ -43,14 +44,16 @@ discard block |
||
43 | 44 | if (\is_string($end)) { |
44 | 45 | $label=$end; |
45 | 46 | \array_pop($fields); |
46 | - } else |
|
47 | - $label=NULL; |
|
47 | + } else { |
|
48 | + $label=NULL; |
|
49 | + } |
|
48 | 50 | } |
49 | 51 | $this->_fields=\array_merge($this->_fields, $fields); |
50 | 52 | $fields=new HtmlFormFields("fields-" . $this->identifier . "-" . $this->count(), $fields); |
51 | 53 | } |
52 | - if (isset($label)) |
|
53 | - $fields=new HtmlFormField("", $fields, $label); |
|
54 | + if (isset($label)) { |
|
55 | + $fields=new HtmlFormField("", $fields, $label); |
|
56 | + } |
|
54 | 57 | } else { |
55 | 58 | $fields=new HtmlFormFields("fields-" . $this->identifier . "-" . $this->count()); |
56 | 59 | } |
@@ -103,12 +106,15 @@ discard block |
||
103 | 106 | */ |
104 | 107 | public function addMessage($identifier, $content, $header=NULL, $icon=NULL, $type=NULL) { |
105 | 108 | $message=new HtmlMessage($identifier, $content); |
106 | - if (isset($header)) |
|
107 | - $message->addHeader($header); |
|
108 | - if (isset($icon)) |
|
109 | - $message->setIcon($icon); |
|
110 | - if (isset($type)) |
|
111 | - $message->setStyle($type); |
|
109 | + if (isset($header)) { |
|
110 | + $message->addHeader($header); |
|
111 | + } |
|
112 | + if (isset($icon)) { |
|
113 | + $message->setIcon($icon); |
|
114 | + } |
|
115 | + if (isset($type)) { |
|
116 | + $message->setStyle($type); |
|
117 | + } |
|
112 | 118 | return $this->addItem($message); |
113 | 119 | } |
114 | 120 |
@@ -21,9 +21,9 @@ discard block |
||
21 | 21 | |
22 | 22 | public function __construct($identifier, $elements=array()) { |
23 | 23 | parent::__construct($identifier, "form", "ui form"); |
24 | - $this->_states=[ State::ERROR,State::SUCCESS,State::WARNING,State::DISABLED ]; |
|
24 | + $this->_states=[State::ERROR, State::SUCCESS, State::WARNING, State::DISABLED]; |
|
25 | 25 | $this->setProperty("name", $this->identifier); |
26 | - $this->_fields=array (); |
|
26 | + $this->_fields=array(); |
|
27 | 27 | $this->addItems($elements); |
28 | 28 | } |
29 | 29 | |
@@ -37,22 +37,22 @@ discard block |
||
37 | 37 | public function addFields($fields=NULL, $label=NULL) { |
38 | 38 | if (isset($fields)) { |
39 | 39 | if (!$fields instanceof HtmlFormFields) { |
40 | - if (\is_array($fields) === false) { |
|
40 | + if (\is_array($fields)===false) { |
|
41 | 41 | $fields=\func_get_args(); |
42 | 42 | $end=\end($fields); |
43 | 43 | if (\is_string($end)) { |
44 | 44 | $label=$end; |
45 | 45 | \array_pop($fields); |
46 | - } else |
|
46 | + }else |
|
47 | 47 | $label=NULL; |
48 | 48 | } |
49 | 49 | $this->_fields=\array_merge($this->_fields, $fields); |
50 | - $fields=new HtmlFormFields("fields-" . $this->identifier . "-" . $this->count(), $fields); |
|
50 | + $fields=new HtmlFormFields("fields-".$this->identifier."-".$this->count(), $fields); |
|
51 | 51 | } |
52 | 52 | if (isset($label)) |
53 | 53 | $fields=new HtmlFormField("", $fields, $label); |
54 | - } else { |
|
55 | - $fields=new HtmlFormFields("fields-" . $this->identifier . "-" . $this->count()); |
|
54 | + }else { |
|
55 | + $fields=new HtmlFormFields("fields-".$this->identifier."-".$this->count()); |
|
56 | 56 | } |
57 | 57 | $this->addItem($fields); |
58 | 58 | return $fields; |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | |
61 | 61 | public function addItem($item) { |
62 | 62 | $item=parent::addItem($item); |
63 | - if (\is_subclass_of($item, HtmlFormField::class) === true) { |
|
63 | + if (\is_subclass_of($item, HtmlFormField::class)===true) { |
|
64 | 64 | $this->_fields[]=$item; |
65 | 65 | } |
66 | 66 | return $item; |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | public function getField($index) { |
70 | 70 | if (\is_string($index)) { |
71 | 71 | $field=$this->getElementById($index, $this->_fields); |
72 | - } else { |
|
72 | + }else { |
|
73 | 73 | $field=$this->_fields[$index]; |
74 | 74 | } |
75 | 75 | return $field; |
@@ -20,7 +20,7 @@ |
||
20 | 20 | * @see \Ajax\bootstrap\html\base\HtmlSingleElement::run() |
21 | 21 | */ |
22 | 22 | public function run(JsUtils $js) { |
23 | - $this->_bsComponent=$js->semantic()->generic("#" . $this->identifier); |
|
23 | + $this->_bsComponent=$js->semantic()->generic("#".$this->identifier); |
|
24 | 24 | $this->addEventsOnRun($js); |
25 | 25 | return $this->_bsComponent; |
26 | 26 | } |
@@ -27,8 +27,9 @@ discard block |
||
27 | 27 | } |
28 | 28 | |
29 | 29 | public function setPopupAttributes($variation=NULL, $popupEvent=NULL) { |
30 | - if (isset($this->_popup)) |
|
31 | - $this->_popup->setAttributes($variation, $popupEvent); |
|
30 | + if (isset($this->_popup)) { |
|
31 | + $this->_popup->setAttributes($variation, $popupEvent); |
|
32 | + } |
|
32 | 33 | } |
33 | 34 | |
34 | 35 | public function addPopup($title="", $content="", $variation=NULL, $params=array()) { |
@@ -44,8 +45,9 @@ discard block |
||
44 | 45 | } |
45 | 46 | |
46 | 47 | public function compile(JsUtils $js=NULL, View $view=NULL) { |
47 | - if (isset($this->_popup)) |
|
48 | - $this->_popup->compile(); |
|
48 | + if (isset($this->_popup)) { |
|
49 | + $this->_popup->compile(); |
|
50 | + } |
|
49 | 51 | return parent::compile($js, $view); |
50 | 52 | } |
51 | 53 |
@@ -57,6 +57,9 @@ discard block |
||
57 | 57 | return $this->addComponent(new Accordion($this->js), $attachTo, $params); |
58 | 58 | } |
59 | 59 | |
60 | + /** |
|
61 | + * @param string $attachTo |
|
62 | + */ |
|
60 | 63 | public function sticky($attachTo=NULL, $params=NULL) { |
61 | 64 | return $this->addComponent(new Sticky($this->js), $attachTo, $params); |
62 | 65 | } |
@@ -65,14 +68,23 @@ discard block |
||
65 | 68 | return $this->addComponent(new Checkbox($this->js), $attachTo, $params); |
66 | 69 | } |
67 | 70 | |
71 | + /** |
|
72 | + * @param string $attachTo |
|
73 | + */ |
|
68 | 74 | public function rating($attachTo=NULL, $params=NULL) { |
69 | 75 | return $this->addComponent(new Rating($this->js), $attachTo, $params); |
70 | 76 | } |
71 | 77 | |
78 | + /** |
|
79 | + * @param string $attachTo |
|
80 | + */ |
|
72 | 81 | public function progress($attachTo=NULL, $params=NULL) { |
73 | 82 | return $this->addComponent(new Progress($this->js), $attachTo, $params); |
74 | 83 | } |
75 | 84 | |
85 | + /** |
|
86 | + * @param string $attachTo |
|
87 | + */ |
|
76 | 88 | public function search($attachTo=NULL, $params=NULL) { |
77 | 89 | return $this->addComponent(new Search($this->js), $attachTo, $params); |
78 | 90 | } |
@@ -16,14 +16,14 @@ discard block |
||
16 | 16 | |
17 | 17 | public function __construct(JsUtils $js) { |
18 | 18 | parent::__construct($js); |
19 | - $this->events=array (); |
|
19 | + $this->events=array(); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | protected function compileEvents() { |
23 | - foreach ( $this->events as $event => $jsCode ) { |
|
24 | - if($event=="execute"){ |
|
23 | + foreach ($this->events as $event => $jsCode) { |
|
24 | + if ($event=="execute") { |
|
25 | 25 | $this->jquery_code_for_compile []=$jsCode; |
26 | - }else if($event=="beforeExecute"){ |
|
26 | + }else if ($event=="beforeExecute") { |
|
27 | 27 | \array_unshift($this->jquery_code_for_compile, $jsCode); |
28 | 28 | }else |
29 | 29 | $this->jquery_code_for_compile []="$( \"".$this->attachTo."\" ).on(\"".$event."\" , function( event, data ) {".$jsCode."});"; |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | $result=implode("\n", $this->jquery_code_for_compile); |
35 | 35 | $result=str_ireplace("\"%", "", $result); |
36 | 36 | $result=str_ireplace("%\"", "", $result); |
37 | - $result=str_replace(array ( |
|
37 | + $result=str_replace(array( |
|
38 | 38 | "\\n", |
39 | 39 | "\\r", |
40 | 40 | "\\t" |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | |
45 | 45 | public function getScript() { |
46 | 46 | $allParams=$this->params; |
47 | - $this->jquery_code_for_compile=array (); |
|
47 | + $this->jquery_code_for_compile=array(); |
|
48 | 48 | $this->jquery_code_for_compile []="$( \"".$this->attachTo."\" ).{$this->uiName}(".$this->getParamsAsJSON($allParams).");"; |
49 | 49 | $this->compileEvents(); |
50 | 50 | return $this->compileJQueryCode(); |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | if (is_array($typeCtrl)) { |
72 | 72 | if (array_search($value, $typeCtrl)===false) |
73 | 73 | throw new \Exception("La valeur passée a propriété `".$key."` pour le composant `".$this->uiName."` ne fait pas partie des valeurs possibles : {".implode(",", $typeCtrl)."}"); |
74 | - } else { |
|
74 | + }else { |
|
75 | 75 | if (!$typeCtrl($value)) { |
76 | 76 | throw new \Exception("La fonction ".$typeCtrl." a retourné faux pour l'affectation de la propriété ".$key." au composant ".$this->uiName); |
77 | 77 | } |
@@ -23,10 +23,11 @@ discard block |
||
23 | 23 | foreach ( $this->events as $event => $jsCode ) { |
24 | 24 | if($event=="execute"){ |
25 | 25 | $this->jquery_code_for_compile []=$jsCode; |
26 | - }else if($event=="beforeExecute"){ |
|
26 | + } else if($event=="beforeExecute"){ |
|
27 | 27 | \array_unshift($this->jquery_code_for_compile, $jsCode); |
28 | - }else |
|
29 | - $this->jquery_code_for_compile []="$( \"".$this->attachTo."\" ).on(\"".$event."\" , function( event, data ) {".$jsCode."});"; |
|
28 | + } else { |
|
29 | + $this->jquery_code_for_compile []="$( \"".$this->attachTo."\" ).on(\"".$event."\" , function( event, data ) {".$jsCode."});"; |
|
30 | + } |
|
30 | 31 | } |
31 | 32 | } |
32 | 33 | |
@@ -69,8 +70,9 @@ discard block |
||
69 | 70 | |
70 | 71 | protected function setParamCtrl($key, $value, $typeCtrl) { |
71 | 72 | if (is_array($typeCtrl)) { |
72 | - if (array_search($value, $typeCtrl)===false) |
|
73 | - throw new \Exception("La valeur passée a propriété `".$key."` pour le composant `".$this->uiName."` ne fait pas partie des valeurs possibles : {".implode(",", $typeCtrl)."}"); |
|
73 | + if (array_search($value, $typeCtrl)===false) { |
|
74 | + throw new \Exception("La valeur passée a propriété `".$key."` pour le composant `".$this->uiName."` ne fait pas partie des valeurs possibles : {".implode(",", $typeCtrl)."}"); |
|
75 | + } |
|
74 | 76 | } else { |
75 | 77 | if (!$typeCtrl($value)) { |
76 | 78 | throw new \Exception("La fonction ".$typeCtrl." a retourné faux pour l'affectation de la propriété ".$key." au composant ".$this->uiName); |
@@ -28,8 +28,9 @@ |
||
28 | 28 | foreach ( $objects as $object ) { |
29 | 29 | $this->addResult([ "title" => $object ]); |
30 | 30 | } |
31 | - } else |
|
32 | - $this->elements=\array_merge($this->elements, $objects); |
|
31 | + } else { |
|
32 | + $this->elements=\array_merge($this->elements, $objects); |
|
33 | + } |
|
33 | 34 | return $this; |
34 | 35 | } |
35 | 36 |
@@ -8,55 +8,55 @@ discard block |
||
8 | 8 | private $elements; |
9 | 9 | |
10 | 10 | public function __construct($objects=NULL) { |
11 | - $this->elements=array (); |
|
11 | + $this->elements=array(); |
|
12 | 12 | if (isset($objects)) { |
13 | 13 | if (\is_array($objects)) { |
14 | 14 | $this->addResults($objects); |
15 | - } else { |
|
15 | + }else { |
|
16 | 16 | $this->addResult($objects); |
17 | 17 | } |
18 | 18 | } |
19 | 19 | } |
20 | 20 | |
21 | 21 | public function addResult($object) { |
22 | - if (\is_array($object) === false) { |
|
23 | - $object=[ "title" => $object ]; |
|
22 | + if (\is_array($object)===false) { |
|
23 | + $object=["title" => $object]; |
|
24 | 24 | } |
25 | 25 | $this->elements[]=new SearchResult($object); |
26 | 26 | return $this; |
27 | 27 | } |
28 | 28 | |
29 | 29 | public function addResults($objects) { |
30 | - if (\is_array($objects) === false) { |
|
30 | + if (\is_array($objects)===false) { |
|
31 | 31 | return $this->addResult($objects); |
32 | 32 | } |
33 | - if (JArray::dimension($objects) === 1) { |
|
34 | - foreach ( $objects as $object ) { |
|
35 | - $this->addResult([ "title" => $object ]); |
|
33 | + if (JArray::dimension($objects)===1) { |
|
34 | + foreach ($objects as $object) { |
|
35 | + $this->addResult(["title" => $object]); |
|
36 | 36 | } |
37 | - } else |
|
37 | + }else |
|
38 | 38 | $this->elements=\array_merge($this->elements, $objects); |
39 | 39 | return $this; |
40 | 40 | } |
41 | 41 | |
42 | 42 | public function search($query, $field="title") { |
43 | - $result=array (); |
|
44 | - foreach ( $this->elements as $element ) { |
|
43 | + $result=array(); |
|
44 | + foreach ($this->elements as $element) { |
|
45 | 45 | if (\array_key_exists($field, $element)) { |
46 | 46 | $value=$element[$field]; |
47 | - if (\stripos($value, $query) !== false) { |
|
47 | + if (\stripos($value, $query)!==false) { |
|
48 | 48 | $result[]=$element; |
49 | 49 | } |
50 | 50 | } |
51 | 51 | } |
52 | - if (\sizeof($result) > 0) { |
|
52 | + if (\sizeof($result)>0) { |
|
53 | 53 | return $result; |
54 | 54 | } |
55 | 55 | return false; |
56 | 56 | } |
57 | 57 | |
58 | 58 | public function __toString() { |
59 | - $result="\"results\": " . \json_encode($this->elements); |
|
59 | + $result="\"results\": ".\json_encode($this->elements); |
|
60 | 60 | return $result; |
61 | 61 | } |
62 | 62 | |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | } |
66 | 66 | |
67 | 67 | public function getResponse() { |
68 | - return "{" . $this . "}"; |
|
68 | + return "{".$this."}"; |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | /** |
@@ -20,8 +20,9 @@ |
||
20 | 20 | $result=array (); |
21 | 21 | foreach ( $this->categories as $category ) { |
22 | 22 | $r=$category->search($query, $field); |
23 | - if ($r !== false) |
|
24 | - $result[]=$r; |
|
23 | + if ($r !== false) { |
|
24 | + $result[]=$r; |
|
25 | + } |
|
25 | 26 | } |
26 | 27 | $this->categories=$result; |
27 | 28 | return $this; |
@@ -6,25 +6,25 @@ discard block |
||
6 | 6 | private $categories; |
7 | 7 | |
8 | 8 | public function __construct() { |
9 | - $this->categories=array (); |
|
9 | + $this->categories=array(); |
|
10 | 10 | } |
11 | 11 | |
12 | 12 | public function add($results, $category) { |
13 | 13 | $count=\sizeof($this->categories); |
14 | 14 | if (\array_key_exists($category, $this->categories)) { |
15 | 15 | $this->categories[$category]->addResults($results); |
16 | - } else { |
|
17 | - $categoryO=new SearchCategory("category" . $count, $category, $results); |
|
16 | + }else { |
|
17 | + $categoryO=new SearchCategory("category".$count, $category, $results); |
|
18 | 18 | $this->categories[$category]=$categoryO; |
19 | 19 | } |
20 | 20 | return $this; |
21 | 21 | } |
22 | 22 | |
23 | 23 | public function search($query, $field="title") { |
24 | - $result=array (); |
|
25 | - foreach ( $this->categories as $category ) { |
|
24 | + $result=array(); |
|
25 | + foreach ($this->categories as $category) { |
|
26 | 26 | $r=$category->search($query, $field); |
27 | - if ($r !== false) |
|
27 | + if ($r!==false) |
|
28 | 28 | $result[]=$r; |
29 | 29 | } |
30 | 30 | $this->categories=$result; |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | } |
33 | 33 | |
34 | 34 | public function __toString() { |
35 | - return "{\"results\":{" . \implode(",", \array_values($this->categories)) . "}}"; |
|
35 | + return "{\"results\":{".\implode(",", \array_values($this->categories))."}}"; |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | public function getResponse() { |