@@ -2,5 +2,5 @@ |
||
2 | 2 | namespace Ajax\semantic\html\base\constants; |
3 | 3 | use Ajax\common\BaseEnum; |
4 | 4 | abstract class Social extends BaseEnum { |
5 | - const FACEBOOK="facebook", TWITTER="twitter",GOOGLEPLUS="google plus",VK="vk",LINKEDIN="linkedin",INSTAGRAM="instagram",YOUTUBE="youtube",GITHUB="github"; |
|
5 | + const FACEBOOK="facebook", TWITTER="twitter", GOOGLEPLUS="google plus", VK="vk", LINKEDIN="linkedin", INSTAGRAM="instagram", YOUTUBE="youtube", GITHUB="github"; |
|
6 | 6 | } |
@@ -27,11 +27,11 @@ discard block |
||
27 | 27 | * @return $this |
28 | 28 | */ |
29 | 29 | public function setOnShow($jsCode) { |
30 | - $jsCode=str_ireplace("\"","%quote%", $jsCode); |
|
30 | + $jsCode=str_ireplace("\"", "%quote%", $jsCode); |
|
31 | 31 | return $this->setParam("onShow", "%function(){".$jsCode."}%"); |
32 | 32 | } |
33 | 33 | |
34 | - public function setExclusive($value){ |
|
34 | + public function setExclusive($value) { |
|
35 | 35 | return $this->setParam("exclusive", $value); |
36 | 36 | } |
37 | 37 | |
@@ -40,19 +40,19 @@ discard block |
||
40 | 40 | * @param string $popup the css selector of the popup |
41 | 41 | * @return \Ajax\semantic\components\Popup |
42 | 42 | */ |
43 | - public function setPopup($popup){ |
|
43 | + public function setPopup($popup) { |
|
44 | 44 | return $this->setParam("popup", $popup); |
45 | 45 | } |
46 | 46 | |
47 | - public function setInline($value){ |
|
47 | + public function setInline($value) { |
|
48 | 48 | return $this->setParam("inline", $value); |
49 | 49 | } |
50 | 50 | |
51 | - public function setPosition($value){ |
|
51 | + public function setPosition($value) { |
|
52 | 52 | return $this->setParam("position", $value); |
53 | 53 | } |
54 | 54 | |
55 | - public function setSetFluidWidth($value){ |
|
55 | + public function setSetFluidWidth($value) { |
|
56 | 56 | return $this->setParam("setFluidWidth", $value); |
57 | 57 | } |
58 | 58 | } |
@@ -18,8 +18,8 @@ discard block |
||
18 | 18 | * @param array $instances |
19 | 19 | * @return DataTable |
20 | 20 | */ |
21 | - public function dataTable($identifier,$model, $instances){ |
|
22 | - return $this->addHtmlComponent(new DataTable($identifier,$model,$instances)); |
|
21 | + public function dataTable($identifier, $model, $instances) { |
|
22 | + return $this->addHtmlComponent(new DataTable($identifier, $model, $instances)); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | /** |
@@ -28,8 +28,8 @@ discard block |
||
28 | 28 | * @param array $instances |
29 | 29 | * @return JsonDataTable |
30 | 30 | */ |
31 | - public function jsonDataTable($identifier,$model, $instances){ |
|
32 | - return $this->addHtmlComponent(new JsonDataTable($identifier,$model,$instances)); |
|
31 | + public function jsonDataTable($identifier, $model, $instances) { |
|
32 | + return $this->addHtmlComponent(new JsonDataTable($identifier, $model, $instances)); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | /** |
@@ -37,8 +37,8 @@ discard block |
||
37 | 37 | * @param object $instance |
38 | 38 | * @return DataElement |
39 | 39 | */ |
40 | - public function dataElement($identifier, $instance){ |
|
41 | - return $this->addHtmlComponent(new DataElement($identifier,$instance)); |
|
40 | + public function dataElement($identifier, $instance) { |
|
41 | + return $this->addHtmlComponent(new DataElement($identifier, $instance)); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
@@ -46,8 +46,8 @@ discard block |
||
46 | 46 | * @param object $instance |
47 | 47 | * @return DataForm |
48 | 48 | */ |
49 | - public function dataForm($identifier, $instance){ |
|
50 | - return $this->addHtmlComponent(new DataForm($identifier,$instance)); |
|
49 | + public function dataForm($identifier, $instance) { |
|
50 | + return $this->addHtmlComponent(new DataForm($identifier, $instance)); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | /** |
@@ -55,8 +55,8 @@ discard block |
||
55 | 55 | * @param object $instance |
56 | 56 | * @return FormLogin |
57 | 57 | */ |
58 | - public function defaultLogin($identifier,$instance=null){ |
|
59 | - return $this->addHtmlComponent(FormLogin::regular($identifier,$instance)); |
|
58 | + public function defaultLogin($identifier, $instance=null) { |
|
59 | + return $this->addHtmlComponent(FormLogin::regular($identifier, $instance)); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | /** |
@@ -64,8 +64,8 @@ discard block |
||
64 | 64 | * @param object $instance |
65 | 65 | * @return FormLogin |
66 | 66 | */ |
67 | - public function smallLogin($identifier,$instance=null){ |
|
68 | - return $this->addHtmlComponent(FormLogin::small($identifier,$instance)); |
|
67 | + public function smallLogin($identifier, $instance=null) { |
|
68 | + return $this->addHtmlComponent(FormLogin::small($identifier, $instance)); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | /** |
@@ -73,8 +73,8 @@ discard block |
||
73 | 73 | * @param object $instance |
74 | 74 | * @return FormLogin |
75 | 75 | */ |
76 | - public function segmentedLogin($identifier,$instance=null){ |
|
77 | - return $this->addHtmlComponent(FormLogin::attachedSegment($identifier,$instance)); |
|
76 | + public function segmentedLogin($identifier, $instance=null) { |
|
77 | + return $this->addHtmlComponent(FormLogin::attachedSegment($identifier, $instance)); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | /** |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | * @param object $instance |
83 | 83 | * @return FormAccount |
84 | 84 | */ |
85 | - public function defaultAccount($identifier,$instance=null){ |
|
86 | - return $this->addHtmlComponent(FormAccount::regular($identifier,$instance)); |
|
85 | + public function defaultAccount($identifier, $instance=null) { |
|
86 | + return $this->addHtmlComponent(FormAccount::regular($identifier, $instance)); |
|
87 | 87 | } |
88 | 88 | } |
@@ -7,26 +7,26 @@ |
||
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 | - public function getDataField(){ |
|
25 | + public function getDataField() { |
|
26 | 26 | return $this->getField()->getInput(); |
27 | 27 | } |
28 | - public function asSelect($name=NULL,$multiple=false,$selection=true){ |
|
29 | - $this->getField()->asSelect($name,$multiple,$selection); |
|
28 | + public function asSelect($name=NULL, $multiple=false, $selection=true) { |
|
29 | + $this->getField()->asSelect($name, $multiple, $selection); |
|
30 | 30 | return $this; |
31 | 31 | } |
32 | 32 | } |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | } |
56 | 56 | |
57 | 57 | public function setFocusable($value=true) { |
58 | - if ($value === true) |
|
58 | + if ($value===true) |
|
59 | 59 | $this->setProperty("tabindex", "0"); |
60 | 60 | else { |
61 | 61 | $this->removeProperty("tabindex"); |
@@ -65,14 +65,14 @@ discard block |
||
65 | 65 | |
66 | 66 | public function setAnimated($content, $animation="") { |
67 | 67 | $this->setTagName("div"); |
68 | - $this->addToProperty("class", "animated " . $animation); |
|
69 | - $visible=new HtmlSemDoubleElement("visible-" . $this->identifier, "div"); |
|
68 | + $this->addToProperty("class", "animated ".$animation); |
|
69 | + $visible=new HtmlSemDoubleElement("visible-".$this->identifier, "div"); |
|
70 | 70 | $visible->setClass("visible content"); |
71 | 71 | $visible->setContent($this->content); |
72 | - $hidden=new HtmlSemDoubleElement("hidden-" . $this->identifier, "div"); |
|
72 | + $hidden=new HtmlSemDoubleElement("hidden-".$this->identifier, "div"); |
|
73 | 73 | $hidden->setClass("hidden content"); |
74 | 74 | $hidden->setContent($content); |
75 | - $this->content=array ($visible,$hidden ); |
|
75 | + $this->content=array($visible, $hidden); |
|
76 | 76 | return $hidden; |
77 | 77 | } |
78 | 78 | |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | public function asIcon($icon) { |
85 | 85 | $iconO=$icon; |
86 | 86 | if (\is_string($icon)) { |
87 | - $iconO=new HtmlIcon("icon-" . $this->identifier, $icon); |
|
87 | + $iconO=new HtmlIcon("icon-".$this->identifier, $icon); |
|
88 | 88 | } |
89 | 89 | $this->addToProperty("class", "icon"); |
90 | 90 | $this->content=$iconO; |
@@ -104,17 +104,17 @@ discard block |
||
104 | 104 | * @return HtmlLabel |
105 | 105 | */ |
106 | 106 | public function addLabel($label, $before=false, $icon=NULL) { |
107 | - $this->tagName="div";$prefix=""; |
|
108 | - if($before) |
|
107 | + $this->tagName="div"; $prefix=""; |
|
108 | + if ($before) |
|
109 | 109 | $prefix="left "; |
110 | 110 | $this->addToProperty("class", $prefix."labeled"); |
111 | 111 | $isIcon=(isset($this->content[0]) && $this->content[0] instanceof HtmlIcon); |
112 | - $this->content=new HtmlButton("button-" . $this->identifier, $this->content); |
|
113 | - if($isIcon){ |
|
112 | + $this->content=new HtmlButton("button-".$this->identifier, $this->content); |
|
113 | + if ($isIcon) { |
|
114 | 114 | $this->content->addClass("icon"); |
115 | 115 | } |
116 | 116 | $this->content->setTagName("div"); |
117 | - $label=new HtmlLabel("label-" . $this->identifier, $label, $icon,"a"); |
|
117 | + $label=new HtmlLabel("label-".$this->identifier, $label, $icon, "a"); |
|
118 | 118 | $label->setBasic(); |
119 | 119 | $this->addContent($label, $before); |
120 | 120 | return $label; |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | */ |
127 | 127 | public function fromArray($array) { |
128 | 128 | $array=parent::fromArray($array); |
129 | - foreach ( $array as $key => $value ) { |
|
129 | + foreach ($array as $key => $value) { |
|
130 | 130 | $this->setProperty($key, $value); |
131 | 131 | } |
132 | 132 | return $array; |
@@ -140,10 +140,10 @@ discard block |
||
140 | 140 | return $this->addToProperty("class", "positive"); |
141 | 141 | } |
142 | 142 | |
143 | - public function setColor($color){ |
|
144 | - if(\is_array($this->content)){ |
|
145 | - foreach ($this->content as $content){ |
|
146 | - if($content instanceof HtmlButton) |
|
143 | + public function setColor($color) { |
|
144 | + if (\is_array($this->content)) { |
|
145 | + foreach ($this->content as $content) { |
|
146 | + if ($content instanceof HtmlButton) |
|
147 | 147 | $content->setColor($color); |
148 | 148 | } |
149 | 149 | } |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | * @return HtmlButton |
202 | 202 | */ |
203 | 203 | public static function social($identifier, $social, $value=NULL) { |
204 | - if ($value === NULL) |
|
204 | + if ($value===NULL) |
|
205 | 205 | $value=\ucfirst($social); |
206 | 206 | $return=new HtmlButton($identifier, $value); |
207 | 207 | $return->addIcon($social); |
@@ -238,8 +238,8 @@ discard block |
||
238 | 238 | * {@inheritDoc} |
239 | 239 | * @see HtmlSemDoubleElement::asLink() |
240 | 240 | */ |
241 | - public function asLink($href=NULL,$target=NULL) { |
|
242 | - parent::asLink($href,$target); |
|
241 | + public function asLink($href=NULL, $target=NULL) { |
|
242 | + parent::asLink($href, $target); |
|
243 | 243 | return $this; |
244 | 244 | } |
245 | 245 | } |
@@ -13,29 +13,29 @@ discard block |
||
13 | 13 | use Ajax\semantic\html\collections\form\traits\FieldTrait; |
14 | 14 | |
15 | 15 | class HtmlDropdown extends HtmlSemDoubleElement { |
16 | - use FieldTrait,LabeledIconTrait { |
|
16 | + use FieldTrait, LabeledIconTrait { |
|
17 | 17 | addIcon as addIconP; |
18 | 18 | } |
19 | 19 | protected $mClass="menu"; |
20 | 20 | protected $mTagName="div"; |
21 | - protected $items=array (); |
|
22 | - protected $_params=array("action"=>"nothing","on"=>"hover"); |
|
21 | + protected $items=array(); |
|
22 | + protected $_params=array("action"=>"nothing", "on"=>"hover"); |
|
23 | 23 | protected $input; |
24 | 24 | protected $value; |
25 | 25 | protected $_associative; |
26 | 26 | protected $_multiple; |
27 | 27 | |
28 | - public function __construct($identifier, $value="", $items=array(),$associative=true) { |
|
28 | + public function __construct($identifier, $value="", $items=array(), $associative=true) { |
|
29 | 29 | parent::__construct($identifier, "div"); |
30 | 30 | $this->_template=include dirname(__FILE__).'/../templates/tplDropdown.php'; |
31 | 31 | $this->setProperty("class", "ui dropdown"); |
32 | 32 | $this->_multiple=false; |
33 | 33 | $content=[]; |
34 | - if(isset($value)){ |
|
35 | - if($value instanceof HtmlSemDoubleElement){ |
|
34 | + if (isset($value)) { |
|
35 | + if ($value instanceof HtmlSemDoubleElement) { |
|
36 | 36 | $text=$value; |
37 | - }else{ |
|
38 | - $text=new HtmlSemDoubleElement("text-".$this->identifier,"div"); |
|
37 | + } else { |
|
38 | + $text=new HtmlSemDoubleElement("text-".$this->identifier, "div"); |
|
39 | 39 | $text->setClass("text"); |
40 | 40 | $this->setValue($value); |
41 | 41 | } |
@@ -48,29 +48,29 @@ discard block |
||
48 | 48 | $this->addItems($items); |
49 | 49 | } |
50 | 50 | |
51 | - public function getField(){ |
|
51 | + public function getField() { |
|
52 | 52 | return $this->input; |
53 | 53 | } |
54 | 54 | |
55 | - public function getDataField(){ |
|
55 | + public function getDataField() { |
|
56 | 56 | return $this->input; |
57 | 57 | } |
58 | 58 | |
59 | - public function addItem($item,$value=NULL,$image=NULL,$description=NULL){ |
|
60 | - $itemO=$this->beforeAddItem($item,$value,$image,$description); |
|
59 | + public function addItem($item, $value=NULL, $image=NULL, $description=NULL) { |
|
60 | + $itemO=$this->beforeAddItem($item, $value, $image, $description); |
|
61 | 61 | $this->items[]=$itemO; |
62 | 62 | return $itemO; |
63 | 63 | } |
64 | 64 | |
65 | - public function addIcon($icon,$before=true,$labeled=false){ |
|
65 | + public function addIcon($icon, $before=true, $labeled=false) { |
|
66 | 66 | $this->removeArrow(); |
67 | - $this->addIconP($icon,$before,$labeled); |
|
67 | + $this->addIconP($icon, $before, $labeled); |
|
68 | 68 | return $this->getElementById("text-".$this->identifier, $this->content)->setWrapAfter(""); |
69 | 69 | } |
70 | 70 | |
71 | - public function addIcons($icons){ |
|
71 | + public function addIcons($icons) { |
|
72 | 72 | $count=$this->count(); |
73 | - for ($i=0;$i<\sizeof($icons) && $i<$count;$i++){ |
|
73 | + for ($i=0; $i<\sizeof($icons) && $i<$count; $i++) { |
|
74 | 74 | $this->getItem($i)->addIcon($icons[$i]); |
75 | 75 | } |
76 | 76 | } |
@@ -81,33 +81,33 @@ discard block |
||
81 | 81 | * @param number $position |
82 | 82 | * @return \Ajax\semantic\html\content\HtmlDropdownItem|unknown |
83 | 83 | */ |
84 | - public function insertItem($item,$position=0){ |
|
84 | + public function insertItem($item, $position=0) { |
|
85 | 85 | $itemO=$this->beforeAddItem($item); |
86 | - $start = array_slice($this->items, 0, $position); |
|
87 | - $end = array_slice($this->items, $position); |
|
88 | - $start[] = $item; |
|
86 | + $start=array_slice($this->items, 0, $position); |
|
87 | + $end=array_slice($this->items, $position); |
|
88 | + $start[]=$item; |
|
89 | 89 | $this->items=array_merge($start, $end); |
90 | 90 | return $itemO; |
91 | 91 | } |
92 | 92 | |
93 | - protected function removeArrow(){ |
|
94 | - if(\sizeof($this->content)>1){ |
|
93 | + protected function removeArrow() { |
|
94 | + if (\sizeof($this->content)>1) { |
|
95 | 95 | unset($this->content["arrow"]); |
96 | 96 | $this->content=\array_values($this->content); |
97 | 97 | } |
98 | 98 | } |
99 | 99 | |
100 | - protected function beforeAddItem($item,$value=NULL,$image=NULL,$description=NULL){ |
|
100 | + protected function beforeAddItem($item, $value=NULL, $image=NULL, $description=NULL) { |
|
101 | 101 | $itemO=$item; |
102 | - if(\is_array($item)){ |
|
102 | + if (\is_array($item)) { |
|
103 | 103 | $description=JArray::getValue($item, "description", 3); |
104 | 104 | $value=JArray::getValue($item, "value", 1); |
105 | 105 | $image=JArray::getValue($item, "image", 2); |
106 | 106 | $item=JArray::getValue($item, "item", 0); |
107 | 107 | } |
108 | - if(!$item instanceof HtmlDropdownItem){ |
|
109 | - $itemO=new HtmlDropdownItem("dd-item-".$this->identifier."-".\sizeof($this->items),$item,$value,$image,$description); |
|
110 | - }elseif($itemO instanceof HtmlDropdownItem){ |
|
108 | + if (!$item instanceof HtmlDropdownItem) { |
|
109 | + $itemO=new HtmlDropdownItem("dd-item-".$this->identifier."-".\sizeof($this->items), $item, $value, $image, $description); |
|
110 | + }elseif ($itemO instanceof HtmlDropdownItem) { |
|
111 | 111 | $this->addToProperty("class", "vertical"); |
112 | 112 | } |
113 | 113 | return $itemO; |
@@ -120,11 +120,11 @@ discard block |
||
120 | 120 | $this->addItem($function($object)); |
121 | 121 | } |
122 | 122 | |
123 | - public function addInput($name){ |
|
124 | - if(!isset($name)) |
|
123 | + public function addInput($name) { |
|
124 | + if (!isset($name)) |
|
125 | 125 | $name="input-".$this->identifier; |
126 | 126 | $this->setAction("activate"); |
127 | - $this->input=new HtmlInput($name,"hidden"); |
|
127 | + $this->input=new HtmlInput($name, "hidden"); |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | /** |
@@ -133,15 +133,15 @@ discard block |
||
133 | 133 | * @param string $icon |
134 | 134 | * @return \Ajax\semantic\html\content\HtmlDropdownItem |
135 | 135 | */ |
136 | - public function addSearchInputItem($placeHolder=NULL,$icon=NULL){ |
|
137 | - return $this->addItem(HtmlDropdownItem::searchInput($placeHolder,$icon)); |
|
136 | + public function addSearchInputItem($placeHolder=NULL, $icon=NULL) { |
|
137 | + return $this->addItem(HtmlDropdownItem::searchInput($placeHolder, $icon)); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | /** |
141 | 141 | * Adds a divider item |
142 | 142 | * @return \Ajax\semantic\html\content\HtmlDropdownItem |
143 | 143 | */ |
144 | - public function addDividerItem(){ |
|
144 | + public function addDividerItem() { |
|
145 | 145 | return $this->addItem(HtmlDropdownItem::divider()); |
146 | 146 | } |
147 | 147 | |
@@ -151,8 +151,8 @@ discard block |
||
151 | 151 | * @param string $icon |
152 | 152 | * @return \Ajax\semantic\html\content\HtmlDropdownItem|unknown |
153 | 153 | */ |
154 | - public function addHeaderItem($caption=NULL,$icon=NULL){ |
|
155 | - return $this->addItem(HtmlDropdownItem::header($caption,$icon)); |
|
154 | + public function addHeaderItem($caption=NULL, $icon=NULL) { |
|
155 | + return $this->addItem(HtmlDropdownItem::header($caption, $icon)); |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | /** |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | * @param string $color |
162 | 162 | * @return \Ajax\semantic\html\content\HtmlDropdownItem|unknown |
163 | 163 | */ |
164 | - public function addCircularLabelItem($caption,$color){ |
|
164 | + public function addCircularLabelItem($caption, $color) { |
|
165 | 165 | return $this->addItem(HtmlDropdownItem::circular($caption, $color)); |
166 | 166 | } |
167 | 167 | |
@@ -170,90 +170,90 @@ discard block |
||
170 | 170 | * @param string $image |
171 | 171 | * @return \Ajax\semantic\html\content\HtmlDropdownItem |
172 | 172 | */ |
173 | - public function addMiniAvatarImageItem($caption,$image){ |
|
173 | + public function addMiniAvatarImageItem($caption, $image) { |
|
174 | 174 | return $this->addItem(HtmlDropdownItem::avatar($caption, $image)); |
175 | 175 | } |
176 | 176 | |
177 | - public function addItems($items){ |
|
178 | - if(\is_array($items) && $this->_associative){ |
|
179 | - foreach ($items as $k=>$v){ |
|
177 | + public function addItems($items) { |
|
178 | + if (\is_array($items) && $this->_associative) { |
|
179 | + foreach ($items as $k=>$v) { |
|
180 | 180 | $this->addItem($v)->setData($k); |
181 | 181 | } |
182 | - }else{ |
|
183 | - foreach ($items as $item){ |
|
182 | + } else { |
|
183 | + foreach ($items as $item) { |
|
184 | 184 | $this->addItem($item); |
185 | 185 | } |
186 | 186 | } |
187 | 187 | } |
188 | 188 | |
189 | - public function getItem($index){ |
|
189 | + public function getItem($index) { |
|
190 | 190 | return $this->items[$index]; |
191 | 191 | } |
192 | 192 | |
193 | 193 | /** |
194 | 194 | * @return int |
195 | 195 | */ |
196 | - public function count(){ |
|
196 | + public function count() { |
|
197 | 197 | return \sizeof($this->items); |
198 | 198 | } |
199 | 199 | /** |
200 | 200 | * @param boolean $dropdown |
201 | 201 | */ |
202 | - public function asDropdown($dropdown){ |
|
203 | - if($dropdown===false){ |
|
202 | + public function asDropdown($dropdown) { |
|
203 | + if ($dropdown===false) { |
|
204 | 204 | $this->_template=include dirname(__FILE__).'/../templates/tplDropdownMenu.php'; |
205 | 205 | $dropdown="menu"; |
206 | - }else{ |
|
206 | + } else { |
|
207 | 207 | $dropdown="dropdown"; |
208 | 208 | $this->mClass="menu"; |
209 | 209 | } |
210 | - return $this->addToPropertyCtrl("class", $dropdown,array("menu","dropdown")); |
|
210 | + return $this->addToPropertyCtrl("class", $dropdown, array("menu", "dropdown")); |
|
211 | 211 | } |
212 | 212 | |
213 | - public function setVertical(){ |
|
214 | - return $this->addToPropertyCtrl("class", "vertical",array("vertical")); |
|
213 | + public function setVertical() { |
|
214 | + return $this->addToPropertyCtrl("class", "vertical", array("vertical")); |
|
215 | 215 | } |
216 | 216 | |
217 | - public function setInline(){ |
|
218 | - return $this->addToPropertyCtrl("class", "inline",["inline"]); |
|
217 | + public function setInline() { |
|
218 | + return $this->addToPropertyCtrl("class", "inline", ["inline"]); |
|
219 | 219 | } |
220 | 220 | |
221 | - public function setSimple(){ |
|
222 | - return $this->addToPropertyCtrl("class", "simple",array("simple")); |
|
221 | + public function setSimple() { |
|
222 | + return $this->addToPropertyCtrl("class", "simple", array("simple")); |
|
223 | 223 | } |
224 | 224 | |
225 | - public function asButton($floating=false){ |
|
225 | + public function asButton($floating=false) { |
|
226 | 226 | $this->removeArrow(); |
227 | - if($floating) |
|
227 | + if ($floating) |
|
228 | 228 | $this->addToProperty("class", "floating"); |
229 | 229 | $this->removePropertyValue("class", "selection"); |
230 | 230 | return $this->addToProperty("class", "button"); |
231 | 231 | } |
232 | 232 | |
233 | - public function asSelect($name=NULL,$multiple=false,$selection=true){ |
|
233 | + public function asSelect($name=NULL, $multiple=false, $selection=true) { |
|
234 | 234 | $this->_multiple=$multiple; |
235 | - if(isset($name)) |
|
235 | + if (isset($name)) |
|
236 | 236 | $this->addInput($name); |
237 | - if($multiple){ |
|
237 | + if ($multiple) { |
|
238 | 238 | $this->addToProperty("class", "multiple"); |
239 | 239 | } |
240 | - if ($selection){ |
|
241 | - if($this->propertyContains("class", "button")===false) |
|
242 | - $this->addToPropertyCtrl("class", "selection",array("selection")); |
|
240 | + if ($selection) { |
|
241 | + if ($this->propertyContains("class", "button")===false) |
|
242 | + $this->addToPropertyCtrl("class", "selection", array("selection")); |
|
243 | 243 | } |
244 | 244 | return $this; |
245 | 245 | } |
246 | 246 | |
247 | - public function asSearch($name=NULL,$multiple=false,$selection=true){ |
|
248 | - $this->asSelect($name,$multiple,$selection); |
|
247 | + public function asSearch($name=NULL, $multiple=false, $selection=true) { |
|
248 | + $this->asSelect($name, $multiple, $selection); |
|
249 | 249 | return $this->addToProperty("class", "search"); |
250 | 250 | } |
251 | 251 | |
252 | - public function setSelect($name=NULL,$multiple=false){ |
|
253 | - if(!isset($name)) |
|
252 | + public function setSelect($name=NULL, $multiple=false) { |
|
253 | + if (!isset($name)) |
|
254 | 254 | $name="select-".$this->identifier; |
255 | 255 | $this->input=null; |
256 | - if($multiple){ |
|
256 | + if ($multiple) { |
|
257 | 257 | $this->setProperty("multiple", true); |
258 | 258 | $this->addToProperty("class", "multiple"); |
259 | 259 | } |
@@ -261,37 +261,37 @@ discard block |
||
261 | 261 | $this->tagName="select"; |
262 | 262 | $this->setProperty("name", $name); |
263 | 263 | $this->content=null; |
264 | - foreach ($this->items as $item){ |
|
264 | + foreach ($this->items as $item) { |
|
265 | 265 | $item->asOption(); |
266 | 266 | } |
267 | 267 | return $this; |
268 | 268 | } |
269 | 269 | |
270 | - public function asSubmenu($pointing=NULL){ |
|
270 | + public function asSubmenu($pointing=NULL) { |
|
271 | 271 | $this->setClass("ui dropdown link item"); |
272 | - if(isset($pointing)){ |
|
272 | + if (isset($pointing)) { |
|
273 | 273 | $this->setPointing($pointing); |
274 | 274 | } |
275 | 275 | return $this; |
276 | 276 | } |
277 | 277 | |
278 | - public function setPointing($value=Direction::NONE){ |
|
279 | - return $this->addToPropertyCtrl("class", $value." pointing",Direction::getConstantValues("pointing")); |
|
278 | + public function setPointing($value=Direction::NONE) { |
|
279 | + return $this->addToPropertyCtrl("class", $value." pointing", Direction::getConstantValues("pointing")); |
|
280 | 280 | } |
281 | 281 | |
282 | - public function setValue($value){ |
|
282 | + public function setValue($value) { |
|
283 | 283 | $this->value=$value; |
284 | 284 | return $this; |
285 | 285 | } |
286 | - private function applyValue(){ |
|
286 | + private function applyValue() { |
|
287 | 287 | $value=$this->value; |
288 | - if(isset($this->input) && isset($value)){ |
|
288 | + if (isset($this->input) && isset($value)) { |
|
289 | 289 | $this->input->setProperty("value", $value); |
290 | - }else{ |
|
290 | + } else { |
|
291 | 291 | $this->setProperty("value", $value); |
292 | 292 | } |
293 | 293 | $textElement=$this->getElementById("text-".$this->identifier, $this->content); |
294 | - if(isset($textElement) && !$this->_multiple) |
|
294 | + if (isset($textElement) && !$this->_multiple) |
|
295 | 295 | $textElement->setContent($value); |
296 | 296 | return $this; |
297 | 297 | } |
@@ -301,9 +301,9 @@ discard block |
||
301 | 301 | * @see BaseHtml::run() |
302 | 302 | */ |
303 | 303 | public function run(JsUtils $js) { |
304 | - if($this->propertyContains("class", "simple")===false){ |
|
305 | - if(isset($this->_bsComponent)===false){ |
|
306 | - $this->_bsComponent=$js->semantic()->dropdown("#".$this->identifier,$this->_params); |
|
304 | + if ($this->propertyContains("class", "simple")===false) { |
|
305 | + if (isset($this->_bsComponent)===false) { |
|
306 | + $this->_bsComponent=$js->semantic()->dropdown("#".$this->identifier, $this->_params); |
|
307 | 307 | $this->_bsComponent->setItemSelector(".item"); |
308 | 308 | } |
309 | 309 | $this->addEventsOnRun($js); |
@@ -311,31 +311,31 @@ discard block |
||
311 | 311 | } |
312 | 312 | } |
313 | 313 | |
314 | - public function setCompact(){ |
|
314 | + public function setCompact() { |
|
315 | 315 | return $this->addToPropertyCtrl("class", "compact", array("compact")); |
316 | 316 | } |
317 | 317 | |
318 | - public function setAction($action){ |
|
318 | + public function setAction($action) { |
|
319 | 319 | $this->_params["action"]=$action; |
320 | 320 | } |
321 | 321 | |
322 | - public function setFullTextSearch($value){ |
|
322 | + public function setFullTextSearch($value) { |
|
323 | 323 | $this->_params["fullTextSearch"]=$value; |
324 | 324 | } |
325 | 325 | |
326 | 326 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
327 | 327 | $this->applyValue(); |
328 | - return parent::compile($js,$view); |
|
328 | + return parent::compile($js, $view); |
|
329 | 329 | } |
330 | 330 | |
331 | 331 | public function getInput() { |
332 | 332 | return $this->input; |
333 | 333 | } |
334 | 334 | public function addAction($action, $direction=Direction::RIGHT, $icon=NULL, $labeled=false) { |
335 | - return $this->_addAction($this, $action,$direction,$icon,$labeled); |
|
335 | + return $this->_addAction($this, $action, $direction, $icon, $labeled); |
|
336 | 336 | } |
337 | 337 | |
338 | - public function jsAddItem($caption){ |
|
338 | + public function jsAddItem($caption) { |
|
339 | 339 | $js="var first=$('#{$this->identifier} .item').first();if(first!=undefined){var new =first.clone();first.parent().append(new);first.html('{$caption}};')"; |
340 | 340 | return $js; |
341 | 341 | } |
@@ -10,61 +10,61 @@ |
||
10 | 10 | * @param string $identifier |
11 | 11 | * @param object $modelInstance |
12 | 12 | */ |
13 | - public function __construct($identifier,$modelInstance=null,$fieldsOrder=[],$fieldsDefinition=[],$fields=[],$captions=[],$separators=[]) { |
|
14 | - parent::__construct($identifier,$modelInstance,$fieldsOrder,$fieldsDefinition,$fields,$captions,$separators); |
|
13 | + public function __construct($identifier, $modelInstance=null, $fieldsOrder=[], $fieldsDefinition=[], $fields=[], $captions=[], $separators=[]) { |
|
14 | + parent::__construct($identifier, $modelInstance, $fieldsOrder, $fieldsDefinition, $fields, $captions, $separators); |
|
15 | 15 | } |
16 | 16 | |
17 | - protected function getDefaultModelInstance(){ |
|
17 | + protected function getDefaultModelInstance() { |
|
18 | 18 | return new UserModel(); |
19 | 19 | } |
20 | 20 | |
21 | - public static function regular($identifier,$modelInstance=null){ |
|
22 | - return new FormAccount($identifier,$modelInstance, |
|
23 | - ["message","login","password","passwordConf","email","submit","error"], |
|
21 | + public static function regular($identifier, $modelInstance=null) { |
|
22 | + return new FormAccount($identifier, $modelInstance, |
|
23 | + ["message", "login", "password", "passwordConf", "email", "submit", "error"], |
|
24 | 24 | ["message"=>[["icon"=>"sign in"]], |
25 | 25 | "input0"=>[["rules"=>"empty"]], |
26 | - "input1"=>[["inputType"=>"password","rules"=> ['minLength[6]', 'empty']]], |
|
27 | - "input2"=>[["inputType"=>"password","rules"=> ['minLength[6]', 'empty', 'match[password]']]], |
|
26 | + "input1"=>[["inputType"=>"password", "rules"=> ['minLength[6]', 'empty']]], |
|
27 | + "input2"=>[["inputType"=>"password", "rules"=> ['minLength[6]', 'empty', 'match[password]']]], |
|
28 | 28 | "input3"=>[["rules"=>"email"]], |
29 | 29 | "submit"=>["green fluid"], |
30 | 30 | "message2"=>[["error"=>true]]], |
31 | - ["Account","login","password","passwordConf","email","submit","error"], |
|
32 | - ["Please enter your account informations","Login","Password","Password confirmation","Email address","Creation"], |
|
33 | - [0,1,3,4,5,6]); |
|
31 | + ["Account", "login", "password", "passwordConf", "email", "submit", "error"], |
|
32 | + ["Please enter your account informations", "Login", "Password", "Password confirmation", "Email address", "Creation"], |
|
33 | + [0, 1, 3, 4, 5, 6]); |
|
34 | 34 | } |
35 | 35 | |
36 | - public static function smallInline($identifier,$modelInstance=null){ |
|
37 | - $result=new FormAccount($identifier,$modelInstance, |
|
38 | - ["login","password","submit"], |
|
39 | - ["input0"=>[["rules"=>"empty"]],"input1"=>[["inputType"=>"password","rules"=>"empty"]],"submit"=>["green basic"]], |
|
40 | - ["login","password","submit"], |
|
41 | - ["","","Connection"], |
|
36 | + public static function smallInline($identifier, $modelInstance=null) { |
|
37 | + $result=new FormAccount($identifier, $modelInstance, |
|
38 | + ["login", "password", "submit"], |
|
39 | + ["input0"=>[["rules"=>"empty"]], "input1"=>[["inputType"=>"password", "rules"=>"empty"]], "submit"=>["green basic"]], |
|
40 | + ["login", "password", "submit"], |
|
41 | + ["", "", "Connection"], |
|
42 | 42 | [2]); |
43 | 43 | $result->addDividerBefore(0, "Connection"); |
44 | 44 | return $result; |
45 | 45 | } |
46 | 46 | |
47 | - public static function small($identifier,$modelInstance=null){ |
|
48 | - $result=new FormAccount($identifier,$modelInstance, |
|
49 | - ["login","password","passwordConf","email","submit"], |
|
47 | + public static function small($identifier, $modelInstance=null) { |
|
48 | + $result=new FormAccount($identifier, $modelInstance, |
|
49 | + ["login", "password", "passwordConf", "email", "submit"], |
|
50 | 50 | [ |
51 | 51 | "input0"=>[["rules"=>"empty"]], |
52 | - "input1"=>[["inputType"=>"password","rules"=>['minLength[6]', 'empty']]], |
|
53 | - "input2"=>[["inputType"=>"password","rules"=> ['minLength[6]', 'empty', 'match[password]']]], |
|
52 | + "input1"=>[["inputType"=>"password", "rules"=>['minLength[6]', 'empty']]], |
|
53 | + "input2"=>[["inputType"=>"password", "rules"=> ['minLength[6]', 'empty', 'match[password]']]], |
|
54 | 54 | "input3"=>[["rules"=>"email"]], |
55 | 55 | "submit"=>["green basic"]], |
56 | - ["login","password","passwordConf","email","submit"], |
|
57 | - ["Login","Password","Password confirmation","Email address","Creation"], |
|
58 | - [1,2]); |
|
56 | + ["login", "password", "passwordConf", "email", "submit"], |
|
57 | + ["Login", "Password", "Password confirmation", "Email address", "Creation"], |
|
58 | + [1, 2]); |
|
59 | 59 | $result->addDividerBefore(0, "Creation"); |
60 | 60 | return $result; |
61 | 61 | } |
62 | 62 | |
63 | - public static function attachedSegment($identifier,$modelInstance=null){ |
|
64 | - $result=self::regular($identifier,$modelInstance); |
|
65 | - $result->fieldAsMessage("message",["icon"=>"sign in","attached"=>true]); |
|
66 | - $result->addWrapper("message",null,"<div class='ui attached segment'>"); |
|
67 | - $result->addWrapper("error", null,"</div>"); |
|
63 | + public static function attachedSegment($identifier, $modelInstance=null) { |
|
64 | + $result=self::regular($identifier, $modelInstance); |
|
65 | + $result->fieldAsMessage("message", ["icon"=>"sign in", "attached"=>true]); |
|
66 | + $result->addWrapper("message", null, "<div class='ui attached segment'>"); |
|
67 | + $result->addWrapper("error", null, "</div>"); |
|
68 | 68 | return $result; |
69 | 69 | } |
70 | 70 | } |
@@ -16,19 +16,19 @@ discard block |
||
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, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true,$jqueryDone="html",$ajaxTransition=null,$immediatly=false) { |
|
22 | - if(JString::isNull($params)){$params="{}";} |
|
21 | + protected function _ajax($method, $url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true, $jqueryDone="html", $ajaxTransition=null, $immediatly=false) { |
|
22 | + if (JString::isNull($params)) {$params="{}"; } |
|
23 | 23 | $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
24 | 24 | $retour=$this->_getAjaxUrl($url, $attr); |
25 | 25 | $responseElement=$this->_getResponseElement($responseElement); |
26 | 26 | $retour.="var self=this;\n"; |
27 | - if($hasLoader===true){ |
|
27 | + if ($hasLoader===true) { |
|
28 | 28 | $this->addLoading($retour, $responseElement); |
29 | 29 | } |
30 | 30 | $retour.="$.".$method."(url,".$params.").done(function( data ) {\n"; |
31 | - $retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone,$ajaxTransition,$jsCallback)."});\n"; |
|
31 | + $retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback)."});\n"; |
|
32 | 32 | if ($immediatly) |
33 | 33 | $this->jquery_code_for_compile[]=$retour; |
34 | 34 | return $retour; |
@@ -36,33 +36,33 @@ discard block |
||
36 | 36 | |
37 | 37 | |
38 | 38 | |
39 | - protected function _getAjaxUrl($url,$attr){ |
|
39 | + protected function _getAjaxUrl($url, $attr) { |
|
40 | 40 | $url=$this->_correctAjaxUrl($url); |
41 | 41 | $retour="url='".$url."';"; |
42 | 42 | $slash="/"; |
43 | - if(JString::endswith($url, "/")===true) |
|
43 | + if (JString::endswith($url, "/")===true) |
|
44 | 44 | $slash=""; |
45 | - if(JString::isNotNull($attr)){ |
|
45 | + if (JString::isNotNull($attr)) { |
|
46 | 46 | if ($attr==="value") |
47 | 47 | $retour.="url=url+'".$slash."'+$(this).val();\n"; |
48 | 48 | elseif ($attr==="html") |
49 | 49 | $retour.="url=url+'".$slash."'+$(this).html();\n"; |
50 | - elseif($attr!==null && $attr!=="") |
|
50 | + elseif ($attr!==null && $attr!=="") |
|
51 | 51 | $retour.="url=url+'".$slash."'+($(this).attr('".$attr."')||'');\n"; |
52 | 52 | } |
53 | 53 | return $retour; |
54 | 54 | } |
55 | 55 | |
56 | - protected function _getOnAjaxDone($responseElement,$jqueryDone,$ajaxTransition,$jsCallback){ |
|
57 | - $retour="";$call=null; |
|
56 | + protected function _getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback) { |
|
57 | + $retour=""; $call=null; |
|
58 | 58 | if ($responseElement!=="") { |
59 | - if(isset($ajaxTransition)){ |
|
59 | + if (isset($ajaxTransition)) { |
|
60 | 60 | $call=$this->setAjaxDataCall($ajaxTransition); |
61 | - }elseif(isset($this->ajaxTransition)){ |
|
61 | + }elseif (isset($this->ajaxTransition)) { |
|
62 | 62 | $call=$this->ajaxTransition; |
63 | 63 | } |
64 | - if(\is_callable($call)) |
|
65 | - $retour="\t".$call($responseElement,$jqueryDone).";\n"; |
|
64 | + if (\is_callable($call)) |
|
65 | + $retour="\t".$call($responseElement, $jqueryDone).";\n"; |
|
66 | 66 | else |
67 | 67 | $retour="\t$({$responseElement}).{$jqueryDone}( data );\n"; |
68 | 68 | } |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | return $retour; |
71 | 71 | } |
72 | 72 | |
73 | - protected function _getResponseElement($responseElement){ |
|
73 | + protected function _getResponseElement($responseElement) { |
|
74 | 74 | if ($responseElement!=="") { |
75 | 75 | $responseElement=Javascript::prep_value($responseElement); |
76 | 76 | } |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | protected function _correctAjaxUrl($url) { |
81 | 81 | if ($url!=="/" && JString::endsWith($url, "/")===true) |
82 | 82 | $url=substr($url, 0, strlen($url)-1); |
83 | - if (strncmp($url, 'http://', 7)!=0&&strncmp($url, 'https://', 8)!=0) { |
|
83 | + if (strncmp($url, 'http://', 7)!=0 && strncmp($url, 'https://', 8)!=0) { |
|
84 | 84 | $url=$this->getUrl($url); |
85 | 85 | } |
86 | 86 | return $url; |
@@ -98,11 +98,11 @@ discard block |
||
98 | 98 | $retour.="\t\t$({$responseElement}).prepend('{$loading_notifier}');\n"; |
99 | 99 | } |
100 | 100 | |
101 | - protected function setAjaxDataCall($params){ |
|
101 | + protected function setAjaxDataCall($params) { |
|
102 | 102 | $result=null; |
103 | - if(!\is_callable($params)){ |
|
104 | - $result=function ($responseElement,$jqueryDone="html") use($params){ |
|
105 | - return AjaxTransition::{$params}($responseElement,$jqueryDone); |
|
103 | + if (!\is_callable($params)) { |
|
104 | + $result=function($responseElement, $jqueryDone="html") use($params){ |
|
105 | + return AjaxTransition::{$params}($responseElement, $jqueryDone); |
|
106 | 106 | }; |
107 | 107 | } |
108 | 108 | return $result; |
@@ -122,8 +122,8 @@ discard block |
||
122 | 122 | * @param string $jqueryDone the jquery function call on ajax data. default:html |
123 | 123 | * @param string|callable $ajaxTransition |
124 | 124 | */ |
125 | - private function _get($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true,$jqueryDone="html",$ajaxTransition=null,$immediatly=false) { |
|
126 | - return $this->_ajax("get", $url,$params,$responseElement,$jsCallback,$attr,$hasLoader,$jqueryDone,$ajaxTransition,$immediatly); |
|
125 | + private function _get($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true, $jqueryDone="html", $ajaxTransition=null, $immediatly=false) { |
|
126 | + return $this->_ajax("get", $url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition, $immediatly); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | /** |
@@ -136,8 +136,8 @@ discard block |
||
136 | 136 | * @param string $jqueryDone the jquery function call on ajax data. default:html |
137 | 137 | * @param string|callable $ajaxTransition |
138 | 138 | */ |
139 | - public function get($url, $responseElement="", $params="{}", $jsCallback=NULL,$hasLoader=true,$jqueryDone="html",$ajaxTransition=null) { |
|
140 | - return $this->_get($url,$params,$responseElement,$jsCallback,null,$hasLoader,$jqueryDone,$ajaxTransition,true); |
|
139 | + public function get($url, $responseElement="", $params="{}", $jsCallback=NULL, $hasLoader=true, $jqueryDone="html", $ajaxTransition=null) { |
|
140 | + return $this->_get($url, $params, $responseElement, $jsCallback, null, $hasLoader, $jqueryDone, $ajaxTransition, true); |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | /** |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | * @param string $context |
151 | 151 | * @param boolean $immediatly |
152 | 152 | */ |
153 | - private function _json($url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context="document",$immediatly=false) { |
|
153 | + private function _json($url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context="document", $immediatly=false) { |
|
154 | 154 | $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
155 | 155 | $retour=$this->_getAjaxUrl($url, $attr); |
156 | 156 | $retour.="$.{$method}(url,".$params.").done(function( data ) {\n"; |
@@ -173,8 +173,8 @@ discard block |
||
173 | 173 | * @param string $context |
174 | 174 | * @param boolean $immediatly |
175 | 175 | */ |
176 | - public function json($url, $method="get", $params="{}", $jsCallback=NULL,$context="document",$immediatly=false) { |
|
177 | - return $this->_json($url,$method,$params,$jsCallback,NULL,$context,$immediatly); |
|
176 | + public function json($url, $method="get", $params="{}", $jsCallback=NULL, $context="document", $immediatly=false) { |
|
177 | + return $this->_json($url, $method, $params, $jsCallback, NULL, $context, $immediatly); |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | /** |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | * @param string $url the request address |
185 | 185 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get","immediatly"=>true) |
186 | 186 | */ |
187 | - public function jsonOn($event,$element, $url,$parameters=array()) { |
|
187 | + public function jsonOn($event, $element, $url, $parameters=array()) { |
|
188 | 188 | $preventDefault=true; |
189 | 189 | $stopPropagation=true; |
190 | 190 | $jsCallback=null; |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | $params="{}"; |
195 | 195 | $immediatly=true; |
196 | 196 | extract($parameters); |
197 | - return $this->_add_event($element, $this->_json($url,$method, $params,$jsCallback, $attr,$context), $event, $preventDefault, $stopPropagation,$immediatly); |
|
197 | + return $this->_add_event($element, $this->_json($url, $method, $params, $jsCallback, $attr, $context), $event, $preventDefault, $stopPropagation, $immediatly); |
|
198 | 198 | } |
199 | 199 | |
200 | 200 | /** |
@@ -205,8 +205,8 @@ discard block |
||
205 | 205 | * @param string $jsCallback javascript code to execute after the request |
206 | 206 | * @param string $context jquery DOM element, array container. |
207 | 207 | */ |
208 | - public function jsonDeferred($url, $method="get", $params="{}", $jsCallback=NULL,$context=NULL) { |
|
209 | - return $this->json($url, $method, $params, $jsCallback, $context,false); |
|
208 | + public function jsonDeferred($url, $method="get", $params="{}", $jsCallback=NULL, $context=NULL) { |
|
209 | + return $this->json($url, $method, $params, $jsCallback, $context, false); |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | /** |
@@ -219,22 +219,22 @@ discard block |
||
219 | 219 | * @param string $rowClass the css class for the new element |
220 | 220 | * @param boolean $immediatly |
221 | 221 | */ |
222 | - private function _jsonArray($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL,$rowClass="_json",$context=NULL,$attr="id",$immediatly=false) { |
|
222 | + private function _jsonArray($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL, $rowClass="_json", $context=NULL, $attr="id", $immediatly=false) { |
|
223 | 223 | $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
224 | 224 | $retour=$this->_getAjaxUrl($url, $attr); |
225 | - if($context===null){ |
|
225 | + if ($context===null) { |
|
226 | 226 | $parent="$('".$maskSelector."').parent()"; |
227 | - $newElm = "$('#'+newId)"; |
|
228 | - }else{ |
|
227 | + $newElm="$('#'+newId)"; |
|
228 | + } else { |
|
229 | 229 | $parent=$context; |
230 | - $newElm = $context.".find('#'+newId)"; |
|
230 | + $newElm=$context.".find('#'+newId)"; |
|
231 | 231 | } |
232 | 232 | $appendTo="\t\tnewElm.appendTo(".$parent.");\n"; |
233 | 233 | $retour.="var self = $(this);\n$.{$method}(url,".$params.").done(function( data ) {\n"; |
234 | 234 | $retour.=$parent.".find('._json').remove();"; |
235 | 235 | $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(); |
236 | 236 | 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"; |
237 | - $retour.= $appendTo; |
|
237 | + $retour.=$appendTo; |
|
238 | 238 | $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"; |
239 | 239 | $retour.="\t$(document).trigger('jsonReady',[data]);\n"; |
240 | 240 | $retour.="\t".$jsCallback."\n"."});\n"; |
@@ -253,8 +253,8 @@ discard block |
||
253 | 253 | * @param string $context jquery DOM element, array container. |
254 | 254 | * @param boolean $immediatly |
255 | 255 | */ |
256 | - public function jsonArray($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL,$rowClass="_json",$context=NULL,$immediatly=false) { |
|
257 | - return $this->_jsonArray($maskSelector, $url,$method,$params,$jsCallback,$rowClass,$context,NULL,$immediatly); |
|
256 | + public function jsonArray($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL, $rowClass="_json", $context=NULL, $immediatly=false) { |
|
257 | + return $this->_jsonArray($maskSelector, $url, $method, $params, $jsCallback, $rowClass, $context, NULL, $immediatly); |
|
258 | 258 | } |
259 | 259 | |
260 | 260 | /** |
@@ -267,8 +267,8 @@ discard block |
||
267 | 267 | * @param string $rowClass the css class for the new element |
268 | 268 | * @param string $context jquery DOM element, array container. |
269 | 269 | */ |
270 | - public function jsonArrayDeferred($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL,$rowClass="_json",$context=NULL) { |
|
271 | - return $this->jsonArray($maskSelector, $url, $method, $params, $jsCallback,$rowClass,$context,false); |
|
270 | + public function jsonArrayDeferred($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL, $rowClass="_json", $context=NULL) { |
|
271 | + return $this->jsonArray($maskSelector, $url, $method, $params, $jsCallback, $rowClass, $context, false); |
|
272 | 272 | } |
273 | 273 | |
274 | 274 | /** |
@@ -278,18 +278,18 @@ discard block |
||
278 | 278 | * @param string $url the request url |
279 | 279 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get","rowClass"=>"_json","immediatly"=>true) |
280 | 280 | */ |
281 | - public function jsonArrayOn($event,$element,$maskSelector, $url,$parameters=array()) { |
|
281 | + public function jsonArrayOn($event, $element, $maskSelector, $url, $parameters=array()) { |
|
282 | 282 | $preventDefault=true; |
283 | 283 | $stopPropagation=true; |
284 | 284 | $jsCallback=null; |
285 | 285 | $attr="id"; |
286 | 286 | $method="get"; |
287 | - $context = null; |
|
287 | + $context=null; |
|
288 | 288 | $params="{}"; |
289 | 289 | $immediatly=true; |
290 | 290 | $rowClass="_json"; |
291 | 291 | extract($parameters); |
292 | - return $this->_add_event($element, $this->_jsonArray($maskSelector,$url,$method, $params,$jsCallback, $rowClass, $context,$attr), $event, $preventDefault, $stopPropagation,$immediatly); |
|
292 | + return $this->_add_event($element, $this->_jsonArray($maskSelector, $url, $method, $params, $jsCallback, $rowClass, $context, $attr), $event, $preventDefault, $stopPropagation, $immediatly); |
|
293 | 293 | } |
294 | 294 | |
295 | 295 | /** |
@@ -303,8 +303,8 @@ discard block |
||
303 | 303 | * @param string $jqueryDone the jquery function call on ajax data. default:html |
304 | 304 | * @param string|callable $ajaxTransition |
305 | 305 | */ |
306 | - public function getDeferred($url, $responseElement="", $params="{}", $jsCallback=NULL,$attr="id",$jqueryDone="html",$ajaxTransition=null) { |
|
307 | - return $this->_get($url, $params,$responseElement,$jsCallback,$attr,false,$jqueryDone,$ajaxTransition); |
|
306 | + public function getDeferred($url, $responseElement="", $params="{}", $jsCallback=NULL, $attr="id", $jqueryDone="html", $ajaxTransition=null) { |
|
307 | + return $this->_get($url, $params, $responseElement, $jsCallback, $attr, false, $jqueryDone, $ajaxTransition); |
|
308 | 308 | } |
309 | 309 | |
310 | 310 | /** |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | $ajaxTransition=null; |
328 | 328 | $params="{}"; |
329 | 329 | extract($parameters); |
330 | - return $this->_add_event($element, $this->_get($url, $params,$responseElement,$jsCallback,$attr, $hasLoader,$jqueryDone,$ajaxTransition), $event, $preventDefault, $stopPropagation,$immediatly); |
|
330 | + return $this->_add_event($element, $this->_get($url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition), $event, $preventDefault, $stopPropagation, $immediatly); |
|
331 | 331 | } |
332 | 332 | |
333 | 333 | /** |
@@ -351,7 +351,7 @@ discard block |
||
351 | 351 | $ajaxTransition=null; |
352 | 352 | $params="{}"; |
353 | 353 | extract($parameters); |
354 | - return $this->_add_event($element, $this->_ajax($method,$url, $params,$responseElement,$jsCallback,$attr, $hasLoader,$jqueryDone,$ajaxTransition), $event, $preventDefault, $stopPropagation,$immediatly); |
|
354 | + return $this->_add_event($element, $this->_ajax($method, $url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition), $event, $preventDefault, $stopPropagation, $immediatly); |
|
355 | 355 | } |
356 | 356 | |
357 | 357 | /** |
@@ -378,8 +378,8 @@ discard block |
||
378 | 378 | return $this->getOn("click", $element, $url, $responseElement, $parameters); |
379 | 379 | } |
380 | 380 | |
381 | - private function _post($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true,$jqueryDone="html",$ajaxTransition=null,$immediatly=false) { |
|
382 | - return $this->_ajax("post", $url,$params,$responseElement,$jsCallback,$attr,$hasLoader,$jqueryDone,$ajaxTransition,$immediatly); |
|
381 | + private function _post($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true, $jqueryDone="html", $ajaxTransition=null, $immediatly=false) { |
|
382 | + return $this->_ajax("post", $url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition, $immediatly); |
|
383 | 383 | } |
384 | 384 | |
385 | 385 | /** |
@@ -392,8 +392,8 @@ discard block |
||
392 | 392 | * @param string $jqueryDone the jquery function call on ajax data. default:html |
393 | 393 | * @param string|callable $ajaxTransition |
394 | 394 | */ |
395 | - public function post($url, $responseElement="", $params="{}", $jsCallback=NULL,$hasLoader=true,$jqueryDone="html",$ajaxTransition=null) { |
|
396 | - return $this->_post($url, $params, $responseElement, $jsCallback, NULL, $hasLoader,$jqueryDone,$ajaxTransition,true); |
|
395 | + public function post($url, $responseElement="", $params="{}", $jsCallback=NULL, $hasLoader=true, $jqueryDone="html", $ajaxTransition=null) { |
|
396 | + return $this->_post($url, $params, $responseElement, $jsCallback, NULL, $hasLoader, $jqueryDone, $ajaxTransition, true); |
|
397 | 397 | } |
398 | 398 | |
399 | 399 | /** |
@@ -408,8 +408,8 @@ discard block |
||
408 | 408 | * @param string $jqueryDone the jquery function call on ajax data. default:html |
409 | 409 | * @param string|callable $ajaxTransition |
410 | 410 | */ |
411 | - public function postDeferred($url, $responseElement="", $params="{}", $jsCallback=NULL, $attr="id",$hasLoader=true,$jqueryDone="html",$ajaxTransition=null) { |
|
412 | - return $this->_post($url, $params, $responseElement, $jsCallback, $attr, $hasLoader,$jqueryDone,$ajaxTransition,false); |
|
411 | + public function postDeferred($url, $responseElement="", $params="{}", $jsCallback=NULL, $attr="id", $hasLoader=true, $jqueryDone="html", $ajaxTransition=null) { |
|
412 | + return $this->_post($url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition, false); |
|
413 | 413 | } |
414 | 414 | |
415 | 415 | /** |
@@ -432,7 +432,7 @@ discard block |
||
432 | 432 | $jqueryDone="html"; |
433 | 433 | $ajaxTransition=null; |
434 | 434 | extract($parameters); |
435 | - return $this->_add_event($element, $this->_post($url, $params, $responseElement, $jsCallback, $attr,$hasLoader,$jqueryDone,$ajaxTransition), $event, $preventDefault, $stopPropagation,$immediatly); |
|
435 | + return $this->_add_event($element, $this->_post($url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition), $event, $preventDefault, $stopPropagation, $immediatly); |
|
436 | 436 | } |
437 | 437 | |
438 | 438 | /** |
@@ -448,20 +448,20 @@ discard block |
||
448 | 448 | return $this->postOn("click", $element, $url, $params, $responseElement, $parameters); |
449 | 449 | } |
450 | 450 | |
451 | - private function _postForm($url, $form, $responseElement, $params=null,$validation=false, $jsCallback=NULL, $attr="id", $hasLoader=true,$jqueryDone="html",$ajaxTransition=null,$immediatly=false) { |
|
451 | + private function _postForm($url, $form, $responseElement, $params=null, $validation=false, $jsCallback=NULL, $attr="id", $hasLoader=true, $jqueryDone="html", $ajaxTransition=null, $immediatly=false) { |
|
452 | 452 | $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
453 | 453 | $retour=$this->_getAjaxUrl($url, $attr); |
454 | 454 | $retour.="\nvar params=$('#".$form."').serialize();\n"; |
455 | - if(isset($params)){ |
|
455 | + if (isset($params)) { |
|
456 | 456 | $retour.="params+='&'+$.param(".$params.");\n"; |
457 | 457 | } |
458 | 458 | $responseElement=$this->_getResponseElement($responseElement); |
459 | 459 | $retour.="var self=this;\n"; |
460 | - if($hasLoader===true){ |
|
460 | + if ($hasLoader===true) { |
|
461 | 461 | $this->addLoading($retour, $responseElement); |
462 | 462 | } |
463 | 463 | $retour.="$.post(url,params).done(function( data ) {\n"; |
464 | - $retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone,$ajaxTransition,$jsCallback)."});\n"; |
|
464 | + $retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback)."});\n"; |
|
465 | 465 | |
466 | 466 | if ($validation) { |
467 | 467 | $retour="$('#".$form."').validate({submitHandler: function(form) { |
@@ -485,8 +485,8 @@ discard block |
||
485 | 485 | * @param string $jqueryDone the jquery function call on ajax data. default:html |
486 | 486 | * @param string|callable $ajaxTransition |
487 | 487 | */ |
488 | - public function postForm($url, $form, $responseElement, $params=NULL,$validation=false, $jsCallback=NULL,$hasLoader=true,$jqueryDone="html",$ajaxTransition=null) { |
|
489 | - return $this->_postForm($url, $form, $responseElement, $params,$validation, $jsCallback, NULL, $hasLoader,$jqueryDone,$ajaxTransition,true); |
|
488 | + public function postForm($url, $form, $responseElement, $params=NULL, $validation=false, $jsCallback=NULL, $hasLoader=true, $jqueryDone="html", $ajaxTransition=null) { |
|
489 | + return $this->_postForm($url, $form, $responseElement, $params, $validation, $jsCallback, NULL, $hasLoader, $jqueryDone, $ajaxTransition, true); |
|
490 | 490 | } |
491 | 491 | |
492 | 492 | /** |
@@ -503,8 +503,8 @@ discard block |
||
503 | 503 | * @param string $jqueryDone the jquery function call on ajax data. default:html |
504 | 504 | * @param string|callable $ajaxTransition |
505 | 505 | */ |
506 | - public function postFormDeferred($url, $form, $responseElement, $params=NULL,$validation=false, $jsCallback=NULL,$attr="id",$hasLoader=true,$jqueryDone="html",$ajaxTransition=null) { |
|
507 | - return $this->_postForm($url, $form, $responseElement, $params,$validation, $jsCallback, $attr, $hasLoader,$jqueryDone,$ajaxTransition,false); |
|
506 | + public function postFormDeferred($url, $form, $responseElement, $params=NULL, $validation=false, $jsCallback=NULL, $attr="id", $hasLoader=true, $jqueryDone="html", $ajaxTransition=null) { |
|
507 | + return $this->_postForm($url, $form, $responseElement, $params, $validation, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition, false); |
|
508 | 508 | } |
509 | 509 | |
510 | 510 | /** |
@@ -529,7 +529,7 @@ discard block |
||
529 | 529 | $jqueryDone="html"; |
530 | 530 | $ajaxTransition=null; |
531 | 531 | extract($parameters); |
532 | - return $this->_add_event($element, $this->_postForm($url, $form, $responseElement,$params, $validation, $jsCallback, $attr,$hasLoader,$jqueryDone,$ajaxTransition), $event, $preventDefault, $stopPropagation,$immediatly); |
|
532 | + return $this->_add_event($element, $this->_postForm($url, $form, $responseElement, $params, $validation, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition), $event, $preventDefault, $stopPropagation, $immediatly); |
|
533 | 533 | } |
534 | 534 | |
535 | 535 | /** |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | trait LabeledIconTrait { |
14 | 14 | |
15 | 15 | abstract public function addToProperty($name, $value, $separator=" "); |
16 | - abstract public function addContent($content,$before=false); |
|
16 | + abstract public function addContent($content, $before=false); |
|
17 | 17 | |
18 | 18 | /** |
19 | 19 | * Adds an icon before or after |
@@ -22,17 +22,17 @@ discard block |
||
22 | 22 | * @param boolean $labeled |
23 | 23 | * @return \Ajax\semantic\html\elements\HtmlIcon |
24 | 24 | */ |
25 | - public function addIcon($icon,$before=true,$labeled=false){ |
|
25 | + public function addIcon($icon, $before=true, $labeled=false) { |
|
26 | 26 | $iconO=$icon; |
27 | - if(\is_string($icon)){ |
|
27 | + if (\is_string($icon)) { |
|
28 | 28 | $iconO=new HtmlIcon("icon-".$this->identifier, $icon); |
29 | 29 | } |
30 | - if($labeled!==false){ |
|
31 | - $direction=($before===true)?Direction::LEFT:Direction::RIGHT; |
|
30 | + if ($labeled!==false) { |
|
31 | + $direction=($before===true) ?Direction::LEFT : Direction::RIGHT; |
|
32 | 32 | $this->addToProperty("class", $direction." labeled icon"); |
33 | 33 | $this->tagName="div"; |
34 | 34 | } |
35 | - $this->addContent($iconO,$before); |
|
35 | + $this->addContent($iconO, $before); |
|
36 | 36 | return $iconO; |
37 | 37 | } |
38 | 38 | } |