@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | $icon=JArray::getValue($value, "icon", 0); |
| 28 | 28 | $size=JArray::getValue($value, "size", 1); |
| 29 | 29 | } |
| 30 | - $iconO=new HtmlIcon("icon-" . $this->identifier, $icon); |
|
| 30 | + $iconO=new HtmlIcon("icon-".$this->identifier, $icon); |
|
| 31 | 31 | if (isset($size)) { |
| 32 | 32 | $iconO->setSize($size); |
| 33 | 33 | } |
@@ -35,15 +35,15 @@ discard block |
||
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | protected function createCondition($value) { |
| 38 | - return ($value instanceof HtmlIcon) === false; |
|
| 38 | + return ($value instanceof HtmlIcon)===false; |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | public function getIcon($index) { |
| 42 | 42 | return $this->content[$index]; |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | - public function run(JsUtils $js){ |
|
| 46 | - $result= parent::run($js); |
|
| 45 | + public function run(JsUtils $js) { |
|
| 46 | + $result=parent::run($js); |
|
| 47 | 47 | return $result->setItemSelector("i"); |
| 48 | 48 | } |
| 49 | 49 | |
@@ -52,8 +52,8 @@ discard block |
||
| 52 | 52 | return $this; |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - public static function corner($mainIcon,$cornerIcon,$size="huge"){ |
|
| 56 | - $icons=new HtmlIconGroups("icons",[$mainIcon,$cornerIcon],$size); |
|
| 55 | + public static function corner($mainIcon, $cornerIcon, $size="huge") { |
|
| 56 | + $icons=new HtmlIconGroups("icons", [$mainIcon, $cornerIcon], $size); |
|
| 57 | 57 | return $icons->toCorner(1); |
| 58 | 58 | } |
| 59 | 59 | } |
@@ -14,14 +14,14 @@ discard block |
||
| 14 | 14 | * @author jc |
| 15 | 15 | * @version 1.001 |
| 16 | 16 | */ |
| 17 | -class HtmlTab extends HtmlSemCollection{ |
|
| 17 | +class HtmlTab extends HtmlSemCollection { |
|
| 18 | 18 | |
| 19 | 19 | protected $params=[]; |
| 20 | 20 | |
| 21 | - public function __construct( $identifier, $tabs=array()){ |
|
| 22 | - parent::__construct( $identifier, "div", ""); |
|
| 21 | + public function __construct($identifier, $tabs=array()) { |
|
| 22 | + parent::__construct($identifier, "div", ""); |
|
| 23 | 23 | $menu=new HtmlMenu("menu".$this->identifier); |
| 24 | - $menu->asTab(false)->setAttachment(NULL,Side::TOP); |
|
| 24 | + $menu->asTab(false)->setAttachment(NULL, Side::TOP); |
|
| 25 | 25 | $this->content["menu"]=$menu; |
| 26 | 26 | $this->addItems($tabs); |
| 27 | 27 | } |
@@ -31,12 +31,12 @@ discard block |
||
| 31 | 31 | * @see \Ajax\common\html\HtmlCollection::createItem() |
| 32 | 32 | * @return HtmlSegment |
| 33 | 33 | */ |
| 34 | - protected function createItem($value){ |
|
| 34 | + protected function createItem($value) { |
|
| 35 | 35 | $count=$this->count(); |
| 36 | 36 | $title=$value; |
| 37 | 37 | $content=NULL; |
| 38 | - if(\is_array($value)){ |
|
| 39 | - $title=@$value[0];$content=@$value[1]; |
|
| 38 | + if (\is_array($value)) { |
|
| 39 | + $title=@$value[0]; $content=@$value[1]; |
|
| 40 | 40 | } |
| 41 | 41 | $menuItem=$this->content["menu"]->addItem($title); |
| 42 | 42 | $menuItem->addToProperty("data-tab", $menuItem->getIdentifier()); |
@@ -52,9 +52,9 @@ discard block |
||
| 52 | 52 | * @param string $datatab |
| 53 | 53 | * @return \Ajax\semantic\html\elements\HtmlSegment |
| 54 | 54 | */ |
| 55 | - private function createSegment($count,$content,$datatab){ |
|
| 55 | + private function createSegment($count, $content, $datatab) { |
|
| 56 | 56 | $segment=new HtmlSegment("item-".$this->identifier."-".$count, $content); |
| 57 | - $segment->setAttachment(NULL,Side::BOTTOM)->addToProperty("class", "tab")->addToProperty("data-tab",$datatab); |
|
| 57 | + $segment->setAttachment(NULL, Side::BOTTOM)->addToProperty("class", "tab")->addToProperty("data-tab", $datatab); |
|
| 58 | 58 | return $segment; |
| 59 | 59 | } |
| 60 | 60 | |
@@ -64,12 +64,12 @@ discard block |
||
| 64 | 64 | * @param String $content new content |
| 65 | 65 | * @return \Ajax\semantic\html\modules\HtmlTab |
| 66 | 66 | */ |
| 67 | - public function setTabContent($index,$content){ |
|
| 67 | + public function setTabContent($index, $content) { |
|
| 68 | 68 | $menu=$this->content["menu"]; |
| 69 | - if($index<$menu->count()){ |
|
| 70 | - if(isset($this->content[$index])===false){ |
|
| 69 | + if ($index<$menu->count()) { |
|
| 70 | + if (isset($this->content[$index])===false) { |
|
| 71 | 71 | $this->content[$index]=$this->createSegment($index, $content, $menu->getItem($index)->getIdentifier()); |
| 72 | - }else |
|
| 72 | + } else |
|
| 73 | 73 | $this->content[$index]->setContent($content); |
| 74 | 74 | } |
| 75 | 75 | return $this; |
@@ -80,9 +80,9 @@ discard block |
||
| 80 | 80 | * @param array $contents |
| 81 | 81 | * @return \Ajax\semantic\html\modules\HtmlTab |
| 82 | 82 | */ |
| 83 | - public function setTabsContent($contents){ |
|
| 83 | + public function setTabsContent($contents) { |
|
| 84 | 84 | $size=\sizeof($contents); |
| 85 | - for($i=0;$i<$size;$i++){ |
|
| 85 | + for ($i=0; $i<$size; $i++) { |
|
| 86 | 86 | $this->setTabContent($i, $contents[$i]); |
| 87 | 87 | } |
| 88 | 88 | return $this; |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | * @param int $index |
| 94 | 94 | * @return \Ajax\semantic\html\modules\HtmlTab |
| 95 | 95 | */ |
| 96 | - public function activate($index){ |
|
| 96 | + public function activate($index) { |
|
| 97 | 97 | $this->content["menu"]->getItem($index)->setActive(true); |
| 98 | 98 | $this->content[$index]->setActive(true); |
| 99 | 99 | return $this; |
@@ -105,8 +105,8 @@ discard block |
||
| 105 | 105 | * @param string $content |
| 106 | 106 | * @return \Ajax\semantic\html\elements\HtmlSegment |
| 107 | 107 | */ |
| 108 | - public function addTab($title,$content){ |
|
| 109 | - return $this->addItem([$title,$content]); |
|
| 108 | + public function addTab($title, $content) { |
|
| 109 | + return $this->addItem([$title, $content]); |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | /** |
@@ -120,13 +120,13 @@ discard block |
||
| 120 | 120 | * @param array $params |
| 121 | 121 | * @return \Ajax\semantic\html\elements\HtmlSegment |
| 122 | 122 | */ |
| 123 | - public function forwardTab($index,JsUtils $js,$title,$initialController,$controller,$action,$params=array()){ |
|
| 124 | - if(\array_key_exists($index, $this->content)){ |
|
| 125 | - $this->content[$index]=$js->forward($initialController, $controller, $action,$params); |
|
| 123 | + public function forwardTab($index, JsUtils $js, $title, $initialController, $controller, $action, $params=array()) { |
|
| 124 | + if (\array_key_exists($index, $this->content)) { |
|
| 125 | + $this->content[$index]=$js->forward($initialController, $controller, $action, $params); |
|
| 126 | 126 | return $this->content[$index]; |
| 127 | 127 | } |
| 128 | 128 | |
| 129 | - return $this->addAndForwardTab($js, $title, $initialController, $controller, $action,$params); |
|
| 129 | + return $this->addAndForwardTab($js, $title, $initialController, $controller, $action, $params); |
|
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | /** |
@@ -139,12 +139,12 @@ discard block |
||
| 139 | 139 | * @param $params The parameters to pass to the view |
| 140 | 140 | * @return \Ajax\semantic\html\elements\HtmlSegment |
| 141 | 141 | */ |
| 142 | - public function renderViewTab($index,JsUtils $js,$title,$initialController, $viewName, $params=array()) { |
|
| 143 | - if(\array_key_exists($index, $this->content)){ |
|
| 144 | - $this->content[$index]=$js->renderContent($initialController, $viewName,$params); |
|
| 142 | + public function renderViewTab($index, JsUtils $js, $title, $initialController, $viewName, $params=array()) { |
|
| 143 | + if (\array_key_exists($index, $this->content)) { |
|
| 144 | + $this->content[$index]=$js->renderContent($initialController, $viewName, $params); |
|
| 145 | 145 | return $this->content[$index]; |
| 146 | 146 | } |
| 147 | - return $this->addAndRenderViewTab($js, $title, $initialController, $viewName,$params); |
|
| 147 | + return $this->addAndRenderViewTab($js, $title, $initialController, $viewName, $params); |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | |
@@ -158,8 +158,8 @@ discard block |
||
| 158 | 158 | * @param array $params |
| 159 | 159 | * @return \Ajax\semantic\html\elements\HtmlSegment |
| 160 | 160 | */ |
| 161 | - public function addAndForwardTab(JsUtils $js,$title,$initialController,$controller,$action,$params=array()){ |
|
| 162 | - return $this->addTab($title, $js->forward($initialController, $controller, $action,$params)); |
|
| 161 | + public function addAndForwardTab(JsUtils $js, $title, $initialController, $controller, $action, $params=array()) { |
|
| 162 | + return $this->addTab($title, $js->forward($initialController, $controller, $action, $params)); |
|
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | /** |
@@ -171,8 +171,8 @@ discard block |
||
| 171 | 171 | * @param $params The parameters to pass to the view |
| 172 | 172 | * @return \Ajax\semantic\html\elements\HtmlSegment |
| 173 | 173 | */ |
| 174 | - public function addAndRenderViewTab(JsUtils $js,$title,$initialController, $viewName, $params=array()) { |
|
| 175 | - return $this->addTab($title, $js->renderContent($initialController, $viewName,$params)); |
|
| 174 | + public function addAndRenderViewTab(JsUtils $js, $title, $initialController, $viewName, $params=array()) { |
|
| 175 | + return $this->addTab($title, $js->renderContent($initialController, $viewName, $params)); |
|
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | public function setPointing($value=Direction::NONE) { |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | * @param int $index |
| 189 | 189 | * @return Ajax\semantic\html\content\HtmlMenuItem |
| 190 | 190 | */ |
| 191 | - public function getMenuTab($index){ |
|
| 191 | + public function getMenuTab($index) { |
|
| 192 | 192 | return $this->content["menu"]->getItem($index); |
| 193 | 193 | } |
| 194 | 194 | |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | * @param int $index |
| 198 | 198 | * @return HtmlSegment |
| 199 | 199 | */ |
| 200 | - public function getTab($index){ |
|
| 200 | + public function getTab($index) { |
|
| 201 | 201 | return $this->content[$index]; |
| 202 | 202 | } |
| 203 | 203 | |
@@ -206,22 +206,22 @@ discard block |
||
| 206 | 206 | * @param HtmlMenu $menu |
| 207 | 207 | * @return \Ajax\semantic\html\modules\HtmlTab |
| 208 | 208 | */ |
| 209 | - public function setMenu($menu){ |
|
| 209 | + public function setMenu($menu) { |
|
| 210 | 210 | $contentSize=\sizeof($this->content); |
| 211 | - for($i=0;$i<$contentSize;$i++){ |
|
| 212 | - if($menu->getItem($i)!==NULL){ |
|
| 213 | - if(isset($this->content[$i])){ |
|
| 214 | - $menu->getItem($i)->addToProperty("data-tab",$this->content[$i]->getProperty("data-tab")); |
|
| 211 | + for ($i=0; $i<$contentSize; $i++) { |
|
| 212 | + if ($menu->getItem($i)!==NULL) { |
|
| 213 | + if (isset($this->content[$i])) { |
|
| 214 | + $menu->getItem($i)->addToProperty("data-tab", $this->content[$i]->getProperty("data-tab")); |
|
| 215 | 215 | } |
| 216 | 216 | } |
| 217 | 217 | } |
| 218 | 218 | $menuSize=$menu->count(); |
| 219 | - for($i=0;$i<$menuSize;$i++){ |
|
| 219 | + for ($i=0; $i<$menuSize; $i++) { |
|
| 220 | 220 | $menu->getItem($i)->removeProperty("href"); |
| 221 | - if(isset($this->content[$i])===false){ |
|
| 221 | + if (isset($this->content[$i])===false) { |
|
| 222 | 222 | $this->content[$i]=$this->createSegment($i, "New content", $menu->getItem($i)->getIdentifier()); |
| 223 | 223 | } |
| 224 | - $menu->getItem($i)->addToProperty("data-tab",$this->content[$i]->getProperty("data-tab")); |
|
| 224 | + $menu->getItem($i)->addToProperty("data-tab", $this->content[$i]->getProperty("data-tab")); |
|
| 225 | 225 | } |
| 226 | 226 | |
| 227 | 227 | $this->content["menu"]=$menu; |
@@ -233,15 +233,15 @@ discard block |
||
| 233 | 233 | * @see BaseHtml::run() |
| 234 | 234 | */ |
| 235 | 235 | public function run(JsUtils $js) { |
| 236 | - if(isset($this->_bsComponent)===false) |
|
| 237 | - $this->_bsComponent=$js->semantic()->tab("#".$this->identifier." .item",$this->params); |
|
| 236 | + if (isset($this->_bsComponent)===false) |
|
| 237 | + $this->_bsComponent=$js->semantic()->tab("#".$this->identifier." .item", $this->params); |
|
| 238 | 238 | $this->addEventsOnRun($js); |
| 239 | 239 | return $this->_bsComponent; |
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
| 243 | - if($this->content["menu"]->count()>0 && \sizeof($this->content)>1) |
|
| 243 | + if ($this->content["menu"]->count()>0 && \sizeof($this->content)>1) |
|
| 244 | 244 | $this->activate(0); |
| 245 | - return parent::compile($js,$view); |
|
| 245 | + return parent::compile($js, $view); |
|
| 246 | 246 | } |
| 247 | 247 | } |
@@ -20,46 +20,46 @@ discard block |
||
| 20 | 20 | * @property string $identifier |
| 21 | 21 | */ |
| 22 | 22 | trait FieldsTrait { |
| 23 | - abstract public function addFields($fields=NULL,$label=NULL); |
|
| 23 | + abstract public function addFields($fields=NULL, $label=NULL); |
|
| 24 | 24 | abstract public function addItem($item); |
| 25 | 25 | |
| 26 | - protected function createItem($value){ |
|
| 27 | - if(\is_array($value)){ |
|
| 28 | - $itemO=new HtmlFormInput(JArray::getDefaultValue($value, "id",""),JArray::getDefaultValue($value, "label",null),JArray::getDefaultValue($value, "type", "text"),JArray::getDefaultValue($value, "value",""),JArray::getDefaultValue($value, "placeholder",JArray::getDefaultValue($value, "label",null))); |
|
| 26 | + protected function createItem($value) { |
|
| 27 | + if (\is_array($value)) { |
|
| 28 | + $itemO=new HtmlFormInput(JArray::getDefaultValue($value, "id", ""), JArray::getDefaultValue($value, "label", null), JArray::getDefaultValue($value, "type", "text"), JArray::getDefaultValue($value, "value", ""), JArray::getDefaultValue($value, "placeholder", JArray::getDefaultValue($value, "label", null))); |
|
| 29 | 29 | return $itemO; |
| 30 | - }elseif(\is_object($value)){ |
|
| 30 | + }elseif (\is_object($value)) { |
|
| 31 | 31 | $itemO=new HtmlFormField("field-".$this->identifier, $value); |
| 32 | 32 | return $itemO; |
| 33 | - }else |
|
| 33 | + } else |
|
| 34 | 34 | return new HtmlFormInput($value); |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | - protected function createCondition($value){ |
|
| 37 | + protected function createCondition($value) { |
|
| 38 | 38 | return \is_object($value)===false || $value instanceof \Ajax\semantic\html\elements\HtmlInput; |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | - public function addInputs($inputs,$fieldslabel=null){ |
|
| 41 | + public function addInputs($inputs, $fieldslabel=null) { |
|
| 42 | 42 | $fields=array(); |
| 43 | - foreach ($inputs as $input){ |
|
| 43 | + foreach ($inputs as $input) { |
|
| 44 | 44 | \extract($input); |
| 45 | - $f=new HtmlFormInput("",""); |
|
| 45 | + $f=new HtmlFormInput("", ""); |
|
| 46 | 46 | $f->fromArray($input); |
| 47 | 47 | $fields[]=$f; |
| 48 | 48 | } |
| 49 | - return $this->addFields($fields,$fieldslabel); |
|
| 49 | + return $this->addFields($fields, $fieldslabel); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | - public function addFieldRule($index,$type,$prompt=NULL,$value=NULL){ |
|
| 52 | + public function addFieldRule($index, $type, $prompt=NULL, $value=NULL) { |
|
| 53 | 53 | $field=$this->getItem($index); |
| 54 | - if(isset($field)){ |
|
| 55 | - $field->addRule($type,$prompt,$value); |
|
| 54 | + if (isset($field)) { |
|
| 55 | + $field->addRule($type, $prompt, $value); |
|
| 56 | 56 | } |
| 57 | 57 | return $this; |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - public function addFieldRules($index,$rules){ |
|
| 60 | + public function addFieldRules($index, $rules) { |
|
| 61 | 61 | $field=$this->getItem($index); |
| 62 | - if(isset($field)){ |
|
| 62 | + if (isset($field)) { |
|
| 63 | 63 | $field->addRules($rules); |
| 64 | 64 | } |
| 65 | 65 | return $this; |
@@ -74,8 +74,8 @@ discard block |
||
| 74 | 74 | * @param boolean $multiple |
| 75 | 75 | * @return HtmlFormDropdown |
| 76 | 76 | */ |
| 77 | - public function addDropdown($identifier,$items=array(), $label=NULL,$value=NULL,$multiple=false){ |
|
| 78 | - return $this->addItem(new HtmlFormDropdown($identifier,$items,$label,$value,$multiple)); |
|
| 77 | + public function addDropdown($identifier, $items=array(), $label=NULL, $value=NULL, $multiple=false) { |
|
| 78 | + return $this->addItem(new HtmlFormDropdown($identifier, $items, $label, $value, $multiple)); |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | /** |
@@ -85,8 +85,8 @@ discard block |
||
| 85 | 85 | * @param boolean $asIcons |
| 86 | 86 | * @return HtmlButtonGroups |
| 87 | 87 | */ |
| 88 | - public function addButtonGroups($identifier,$elements=[],$asIcons=false){ |
|
| 89 | - return $this->addItem(new HtmlButtonGroups($identifier,$elements,$asIcons)); |
|
| 88 | + public function addButtonGroups($identifier, $elements=[], $asIcons=false) { |
|
| 89 | + return $this->addItem(new HtmlButtonGroups($identifier, $elements, $asIcons)); |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | /** |
@@ -98,8 +98,8 @@ discard block |
||
| 98 | 98 | * @param string $icon |
| 99 | 99 | * @return HtmlButtonGroups |
| 100 | 100 | */ |
| 101 | - public function addDropdownButton($identifier,$value,$items=[],$asCombo=false,$icon=null){ |
|
| 102 | - return $this->addItem(HtmlButton::dropdown($identifier, $value,$items,$asCombo,$icon)); |
|
| 101 | + public function addDropdownButton($identifier, $value, $items=[], $asCombo=false, $icon=null) { |
|
| 102 | + return $this->addItem(HtmlButton::dropdown($identifier, $value, $items, $asCombo, $icon)); |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | /** |
@@ -110,8 +110,8 @@ discard block |
||
| 110 | 110 | * @param string $placeholder |
| 111 | 111 | * @return HtmlFormInput |
| 112 | 112 | */ |
| 113 | - public function addInput($identifier, $label=NULL,$type="text",$value=NULL,$placeholder=NULL){ |
|
| 114 | - return $this->addItem(new HtmlFormInput($identifier,$label,$type,$value,$placeholder)); |
|
| 113 | + public function addInput($identifier, $label=NULL, $type="text", $value=NULL, $placeholder=NULL) { |
|
| 114 | + return $this->addItem(new HtmlFormInput($identifier, $label, $type, $value, $placeholder)); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | /** |
@@ -122,16 +122,16 @@ discard block |
||
| 122 | 122 | * @param int $rows |
| 123 | 123 | * @return HtmlTextarea |
| 124 | 124 | */ |
| 125 | - public function addTextarea($identifier, $label,$value=NULL,$placeholder=NULL,$rows=5){ |
|
| 126 | - return $this->addItem(new HtmlFormTextarea($identifier,$label,$value,$placeholder,$rows)); |
|
| 125 | + public function addTextarea($identifier, $label, $value=NULL, $placeholder=NULL, $rows=5) { |
|
| 126 | + return $this->addItem(new HtmlFormTextarea($identifier, $label, $value, $placeholder, $rows)); |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | - public function addPassword($identifier, $label=NULL){ |
|
| 130 | - return $this->addItem(new HtmlFormInput($identifier,$label,"password","","")); |
|
| 129 | + public function addPassword($identifier, $label=NULL) { |
|
| 130 | + return $this->addItem(new HtmlFormInput($identifier, $label, "password", "", "")); |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | - public function addButton($identifier,$value,$cssStyle=NULL,$onClick=NULL){ |
|
| 134 | - return $this->addItem(new HtmlButton($identifier,$value,$cssStyle,$onClick)); |
|
| 133 | + public function addButton($identifier, $value, $cssStyle=NULL, $onClick=NULL) { |
|
| 134 | + return $this->addItem(new HtmlButton($identifier, $value, $cssStyle, $onClick)); |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | /** |
@@ -141,16 +141,16 @@ discard block |
||
| 141 | 141 | * @param string $type |
| 142 | 142 | * @return HtmlFormCheckbox |
| 143 | 143 | */ |
| 144 | - public function addCheckbox($identifier, $label=NULL,$value=NULL,$type=NULL){ |
|
| 145 | - return $this->addItem(new HtmlFormCheckbox($identifier,$label,$value,$type)); |
|
| 144 | + public function addCheckbox($identifier, $label=NULL, $value=NULL, $type=NULL) { |
|
| 145 | + return $this->addItem(new HtmlFormCheckbox($identifier, $label, $value, $type)); |
|
| 146 | 146 | } |
| 147 | 147 | |
| 148 | - public function addRadio($identifier, $name,$label=NULL,$value=NULL){ |
|
| 149 | - return $this->addItem(new HtmlFormRadio($identifier,$name,$label,$value)); |
|
| 148 | + public function addRadio($identifier, $name, $label=NULL, $value=NULL) { |
|
| 149 | + return $this->addItem(new HtmlFormRadio($identifier, $name, $label, $value)); |
|
| 150 | 150 | } |
| 151 | 151 | |
| 152 | - public function addElement($identifier,$content,$label,$tagName="div",$baseClass=""){ |
|
| 153 | - $div=new HtmlSemDoubleElement($identifier,$tagName,$baseClass,$content); |
|
| 154 | - return $this->addItem(new HtmlFormField("field-".$identifier, $div,$label)); |
|
| 152 | + public function addElement($identifier, $content, $label, $tagName="div", $baseClass="") { |
|
| 153 | + $div=new HtmlSemDoubleElement($identifier, $tagName, $baseClass, $content); |
|
| 154 | + return $this->addItem(new HtmlFormField("field-".$identifier, $div, $label)); |
|
| 155 | 155 | } |
| 156 | 156 | } |
@@ -7,29 +7,29 @@ discard block |
||
| 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 |
||
| 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); |
@@ -15,7 +15,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 | |
@@ -51,7 +51,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 | } |
@@ -16,9 +16,9 @@ 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,$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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | /** |
@@ -49,8 +49,9 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | |