@@ -33,42 +33,42 @@ discard block |
||
| 33 | 33 | * @param string|HtmlSemDoubleElement $header |
| 34 | 34 | * @return \Ajax\semantic\html\collections\HtmlMessage |
| 35 | 35 | */ |
| 36 | - public function addHeader($header){ |
|
| 36 | + public function addHeader($header) { |
|
| 37 | 37 | $headerO=$header; |
| 38 | - if(\is_string($header)){ |
|
| 39 | - $headerO=new HtmlSemDoubleElement("header-".$this->identifier,"div"); |
|
| 38 | + if (\is_string($header)) { |
|
| 39 | + $headerO=new HtmlSemDoubleElement("header-".$this->identifier, "div"); |
|
| 40 | 40 | $headerO->setClass("header"); |
| 41 | 41 | $headerO->setContent($header); |
| 42 | 42 | } |
| 43 | - return $this->addContent($headerO,true); |
|
| 43 | + return $this->addContent($headerO, true); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | - public function setHeader($header){ |
|
| 46 | + public function setHeader($header) { |
|
| 47 | 47 | return $this->addHeader($header); |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | - public function addList($elements,$ordered=false){ |
|
| 51 | - $list=new HtmlList("list-".$this->identifier,$elements); |
|
| 50 | + public function addList($elements, $ordered=false) { |
|
| 51 | + $list=new HtmlList("list-".$this->identifier, $elements); |
|
| 52 | 52 | $list->setOrdered($ordered); |
| 53 | 53 | $list->setClass("ui list"); |
| 54 | 54 | $this->addContent($list); |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - public function setIcon($icon){ |
|
| 57 | + public function setIcon($icon) { |
|
| 58 | 58 | $this->addToProperty("class", "icon"); |
| 59 | - $this->wrapContent("<div class='content'>","</div>"); |
|
| 59 | + $this->wrapContent("<div class='content'>", "</div>"); |
|
| 60 | 60 | $this->icon=new HtmlIcon("icon-".$this->identifier, $icon); |
| 61 | 61 | return $this; |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | - public function addLoader($loaderIcon="notched circle"){ |
|
| 64 | + public function addLoader($loaderIcon="notched circle") { |
|
| 65 | 65 | $this->setIcon($loaderIcon); |
| 66 | 66 | $this->icon->addToIcon("loading"); |
| 67 | 67 | return $this; |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - public function setDismissable($dismiss=true){ |
|
| 71 | - if($dismiss===true) |
|
| 70 | + public function setDismissable($dismiss=true) { |
|
| 71 | + if ($dismiss===true) |
|
| 72 | 72 | $this->close=new HtmlIcon("close-".$this->identifier, "close"); |
| 73 | 73 | else |
| 74 | 74 | $this->close=NULL; |
@@ -79,41 +79,41 @@ discard block |
||
| 79 | 79 | * {@inheritDoc} |
| 80 | 80 | * @see \Ajax\semantic\html\base\HtmlSemDoubleElement::run() |
| 81 | 81 | */ |
| 82 | - public function run(JsUtils $js){ |
|
| 82 | + public function run(JsUtils $js) { |
|
| 83 | 83 | parent::run($js); |
| 84 | - if(isset($this->close)){ |
|
| 84 | + if (isset($this->close)) { |
|
| 85 | 85 | $js->execOn("click", "#".$this->identifier." .close", "$(this).closest('.message').transition({$this->_closeTransition})"); |
| 86 | 86 | } |
| 87 | - if(isset($this->_timeout)){ |
|
| 88 | - $js->exec("setTimeout(function() { $('#{$this->identifier}').transition({$this->_closeTransition}); }, {$this->_timeout});",true); |
|
| 87 | + if (isset($this->_timeout)) { |
|
| 88 | + $js->exec("setTimeout(function() { $('#{$this->identifier}').transition({$this->_closeTransition}); }, {$this->_timeout});", true); |
|
| 89 | 89 | } |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | - public function setState($visible=true){ |
|
| 93 | - $visible=($visible===true)?"visible":"hidden"; |
|
| 94 | - return $this->addToPropertyCtrl("class", $visible, array("visible","hidden")); |
|
| 92 | + public function setState($visible=true) { |
|
| 93 | + $visible=($visible===true) ? "visible" : "hidden"; |
|
| 94 | + return $this->addToPropertyCtrl("class", $visible, array("visible", "hidden")); |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | - public function setVariation($value="floating"){ |
|
| 98 | - return $this->addToPropertyCtrl("class", $value, array("floating","compact")); |
|
| 97 | + public function setVariation($value="floating") { |
|
| 98 | + return $this->addToPropertyCtrl("class", $value, array("floating", "compact")); |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | - public function setStyle($style){ |
|
| 101 | + public function setStyle($style) { |
|
| 102 | 102 | return $this->addToPropertyCtrl("class", $style, Style::getConstants()); |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | - public function setError(){ |
|
| 105 | + public function setError() { |
|
| 106 | 106 | return $this->setStyle("error"); |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | - public function setWarning(){ |
|
| 109 | + public function setWarning() { |
|
| 110 | 110 | return $this->setStyle("warning"); |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | - public function setMessage($message){ |
|
| 114 | - if(\is_array($this->content)){ |
|
| 113 | + public function setMessage($message) { |
|
| 114 | + if (\is_array($this->content)) { |
|
| 115 | 115 | $this->content[\sizeof($this->content)-1]=$message; |
| 116 | - }else |
|
| 116 | + } else |
|
| 117 | 117 | $this->setContent($message); |
| 118 | 118 | } |
| 119 | 119 | |
@@ -28,27 +28,27 @@ |
||
| 28 | 28 | $method="get"; |
| 29 | 29 | extract($this->parameters); |
| 30 | 30 | $result=$this->_eventPreparing($preventDefault, $stopPropagation); |
| 31 | - switch($this->method) { |
|
| 31 | + switch ($this->method) { |
|
| 32 | 32 | case "get": |
| 33 | - $result.=$js->getDeferred($url, $responseElement, $params, $jsCallback, $attr,$jqueryDone,$ajaxTransition); |
|
| 33 | + $result.=$js->getDeferred($url, $responseElement, $params, $jsCallback, $attr, $jqueryDone, $ajaxTransition); |
|
| 34 | 34 | break; |
| 35 | 35 | case "post": |
| 36 | - $result.=$js->postDeferred($url, $responseElement, $params, $jsCallback, $attr,$hasLoader,$jqueryDone,$ajaxTransition); |
|
| 36 | + $result.=$js->postDeferred($url, $responseElement, $params, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition); |
|
| 37 | 37 | break; |
| 38 | 38 | case "postForm": |
| 39 | - $result.=$js->postFormDeferred($url, $form, $responseElement, $validation, $jsCallback, $attr,$hasLoader,$jqueryDone,$ajaxTransition); |
|
| 39 | + $result.=$js->postFormDeferred($url, $form, $responseElement, $validation, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition); |
|
| 40 | 40 | break; |
| 41 | 41 | case "json": |
| 42 | - $result.=$js->jsonDeferred($url,$method,$params,$jsCallback); |
|
| 42 | + $result.=$js->jsonDeferred($url, $method, $params, $jsCallback); |
|
| 43 | 43 | break; |
| 44 | 44 | case "jsonArray": |
| 45 | - $result.=$js->jsonArrayDeferred($modelSelector, $url,$method,$params,$jsCallback); |
|
| 45 | + $result.=$js->jsonArrayDeferred($modelSelector, $url, $method, $params, $jsCallback); |
|
| 46 | 46 | break; |
| 47 | 47 | } |
| 48 | 48 | return $result; |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | - protected function _eventPreparing($preventDefault,$stopPropagation){ |
|
| 51 | + protected function _eventPreparing($preventDefault, $stopPropagation) { |
|
| 52 | 52 | $result=""; |
| 53 | 53 | if ($preventDefault===true) { |
| 54 | 54 | $result.=Javascript::$preventDefault; |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | use Ajax\semantic\html\modules\HtmlModal; |
| 21 | 21 | |
| 22 | 22 | abstract class Widget extends HtmlDoubleElement { |
| 23 | - use FieldAsTrait,FormTrait; |
|
| 23 | + use FieldAsTrait, FormTrait; |
|
| 24 | 24 | |
| 25 | 25 | /** |
| 26 | 26 | * @var string classname |
@@ -53,17 +53,17 @@ discard block |
||
| 53 | 53 | protected $_generated; |
| 54 | 54 | |
| 55 | 55 | |
| 56 | - public function __construct($identifier,$model,$modelInstance=NULL) { |
|
| 56 | + public function __construct($identifier, $model, $modelInstance=NULL) { |
|
| 57 | 57 | parent::__construct($identifier); |
| 58 | 58 | $this->_template="%wrapContentBefore%%content%%wrapContentAfter%"; |
| 59 | 59 | $this->setModel($model); |
| 60 | - if(isset($modelInstance)){ |
|
| 60 | + if (isset($modelInstance)) { |
|
| 61 | 61 | $this->show($modelInstance); |
| 62 | 62 | } |
| 63 | 63 | $this->_generated=false; |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | - protected function _init($instanceViewer,$contentKey,$content,$edition){ |
|
| 66 | + protected function _init($instanceViewer, $contentKey, $content, $edition) { |
|
| 67 | 67 | $this->_instanceViewer=$instanceViewer; |
| 68 | 68 | $this->content=[$contentKey=>$content]; |
| 69 | 69 | $this->_toolbarPosition=PositionInTable::BEFORETABLE; |
@@ -74,31 +74,31 @@ discard block |
||
| 74 | 74 | * @param int|string $fieldName |
| 75 | 75 | * @return int|string |
| 76 | 76 | */ |
| 77 | - protected function _getIndex($fieldName){ |
|
| 77 | + protected function _getIndex($fieldName) { |
|
| 78 | 78 | $index=$fieldName; |
| 79 | - if(\is_string($fieldName)){ |
|
| 79 | + if (\is_string($fieldName)) { |
|
| 80 | 80 | $fields=$this->_instanceViewer->getVisibleProperties(); |
| 81 | 81 | $index=\array_search($fieldName, $fields); |
| 82 | 82 | } |
| 83 | 83 | return $index; |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | - protected function _getFieldIdentifier($prefix,$name=""){ |
|
| 86 | + protected function _getFieldIdentifier($prefix, $name="") { |
|
| 87 | 87 | return $this->identifier."-{$prefix}-".$this->_instanceViewer->getIdentifier(); |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | - protected function _getFieldName($index){ |
|
| 90 | + protected function _getFieldName($index) { |
|
| 91 | 91 | return $this->_instanceViewer->getFieldName($index); |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | - protected function _getFieldCaption($index){ |
|
| 94 | + protected function _getFieldCaption($index) { |
|
| 95 | 95 | return $this->_instanceViewer->getCaption($index); |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - abstract protected function _setToolbarPosition($table,$captions=NULL); |
|
| 98 | + abstract protected function _setToolbarPosition($table, $captions=NULL); |
|
| 99 | 99 | |
| 100 | - public function show($modelInstance){ |
|
| 101 | - if(\is_array($modelInstance)){ |
|
| 100 | + public function show($modelInstance) { |
|
| 101 | + if (\is_array($modelInstance)) { |
|
| 102 | 102 | $modelInstance=\json_decode(\json_encode($modelInstance), FALSE); |
| 103 | 103 | } |
| 104 | 104 | $this->_modelInstance=$modelInstance; |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | |
| 125 | 125 | abstract public function getHtmlComponent(); |
| 126 | 126 | |
| 127 | - public function setAttached($value=true){ |
|
| 127 | + public function setAttached($value=true) { |
|
| 128 | 128 | return $this->getHtmlComponent()->setAttached($value); |
| 129 | 129 | } |
| 130 | 130 | |
@@ -135,66 +135,66 @@ discard block |
||
| 135 | 135 | * @param callable $callback function called after the field compilation |
| 136 | 136 | * @return Widget |
| 137 | 137 | */ |
| 138 | - public function afterCompile($index,$callback){ |
|
| 138 | + public function afterCompile($index, $callback) { |
|
| 139 | 139 | $index=$this->_getIndex($index); |
| 140 | 140 | $this->_instanceViewer->afterCompile($index, $callback); |
| 141 | 141 | return $this; |
| 142 | 142 | } |
| 143 | 143 | |
| 144 | - public function setColor($color){ |
|
| 144 | + public function setColor($color) { |
|
| 145 | 145 | return $this->getHtmlComponent()->setColor($color); |
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | |
| 149 | - public function setCaptions($captions){ |
|
| 149 | + public function setCaptions($captions) { |
|
| 150 | 150 | $this->_instanceViewer->setCaptions($captions); |
| 151 | 151 | return $this; |
| 152 | 152 | } |
| 153 | 153 | |
| 154 | - public function setCaption($index,$caption){ |
|
| 154 | + public function setCaption($index, $caption) { |
|
| 155 | 155 | $this->_instanceViewer->setCaption($this->_getIndex($index), $caption); |
| 156 | 156 | return $this; |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | - public function setFields($fields){ |
|
| 159 | + public function setFields($fields) { |
|
| 160 | 160 | $this->_instanceViewer->setVisibleProperties($fields); |
| 161 | 161 | return $this; |
| 162 | 162 | } |
| 163 | 163 | |
| 164 | - public function addField($field){ |
|
| 164 | + public function addField($field) { |
|
| 165 | 165 | $this->_instanceViewer->addField($field); |
| 166 | 166 | return $this; |
| 167 | 167 | } |
| 168 | 168 | |
| 169 | - public function addMessage($attributes=NULL,$fieldName="message"){ |
|
| 169 | + public function addMessage($attributes=NULL, $fieldName="message") { |
|
| 170 | 170 | $this->_instanceViewer->addField($fieldName); |
| 171 | 171 | $count=$this->_instanceViewer->visiblePropertiesCount(); |
| 172 | - return $this->fieldAsMessage($count-1,$attributes); |
|
| 172 | + return $this->fieldAsMessage($count-1, $attributes); |
|
| 173 | 173 | } |
| 174 | 174 | |
| 175 | - public function addErrorMessage(){ |
|
| 176 | - return $this->addMessage(["error"=>true],"message"); |
|
| 175 | + public function addErrorMessage() { |
|
| 176 | + return $this->addMessage(["error"=>true], "message"); |
|
| 177 | 177 | } |
| 178 | 178 | |
| 179 | - public function insertField($index,$field){ |
|
| 179 | + public function insertField($index, $field) { |
|
| 180 | 180 | $index=$this->_getIndex($index); |
| 181 | 181 | $this->_instanceViewer->insertField($index, $field); |
| 182 | 182 | return $this; |
| 183 | 183 | } |
| 184 | 184 | |
| 185 | - public function insertInField($index,$field){ |
|
| 185 | + public function insertInField($index, $field) { |
|
| 186 | 186 | $index=$this->_getIndex($index); |
| 187 | 187 | $this->_instanceViewer->insertInField($index, $field); |
| 188 | 188 | return $this; |
| 189 | 189 | } |
| 190 | 190 | |
| 191 | - public function setValueFunction($index,$callback){ |
|
| 191 | + public function setValueFunction($index, $callback) { |
|
| 192 | 192 | $index=$this->_getIndex($index); |
| 193 | 193 | $this->_instanceViewer->setValueFunction($index, $callback); |
| 194 | 194 | return $this; |
| 195 | 195 | } |
| 196 | 196 | |
| 197 | - public function setIdentifierFunction($callback){ |
|
| 197 | + public function setIdentifierFunction($callback) { |
|
| 198 | 198 | $this->_instanceViewer->setIdentifierFunction($callback); |
| 199 | 199 | return $this; |
| 200 | 200 | } |
@@ -202,8 +202,8 @@ discard block |
||
| 202 | 202 | /** |
| 203 | 203 | * @return \Ajax\semantic\html\collections\menus\HtmlMenu |
| 204 | 204 | */ |
| 205 | - public function getToolbar(){ |
|
| 206 | - if(isset($this->_toolbar)===false){ |
|
| 205 | + public function getToolbar() { |
|
| 206 | + if (isset($this->_toolbar)===false) { |
|
| 207 | 207 | $this->_toolbar=new HtmlMenu("toolbar-".$this->identifier); |
| 208 | 208 | } |
| 209 | 209 | return $this->_toolbar; |
@@ -215,15 +215,15 @@ discard block |
||
| 215 | 215 | * @param callable $callback function to call on $element |
| 216 | 216 | * @return \Ajax\common\html\HtmlDoubleElement |
| 217 | 217 | */ |
| 218 | - public function addInToolbar($element,$callback=NULL){ |
|
| 218 | + public function addInToolbar($element, $callback=NULL) { |
|
| 219 | 219 | $tb=$this->getToolbar(); |
| 220 | - if($element instanceof BaseWidget){ |
|
| 221 | - if($element->getIdentifier()===""){ |
|
| 220 | + if ($element instanceof BaseWidget) { |
|
| 221 | + if ($element->getIdentifier()==="") { |
|
| 222 | 222 | $element->setIdentifier("tb-item-".$this->identifier."-".$tb->count()); |
| 223 | 223 | } |
| 224 | 224 | } |
| 225 | - if(isset($callback)){ |
|
| 226 | - if(\is_callable($callback)){ |
|
| 225 | + if (isset($callback)) { |
|
| 226 | + if (\is_callable($callback)) { |
|
| 227 | 227 | $callback($element); |
| 228 | 228 | } |
| 229 | 229 | } |
@@ -236,9 +236,9 @@ discard block |
||
| 236 | 236 | * @param callable $callback function($element) |
| 237 | 237 | * @return \Ajax\common\html\HtmlDoubleElement |
| 238 | 238 | */ |
| 239 | - public function addItemInToolbar($caption,$icon=NULL,$callback=NULL){ |
|
| 240 | - $result=$this->addInToolbar($caption,$callback); |
|
| 241 | - if(isset($icon)) |
|
| 239 | + public function addItemInToolbar($caption, $icon=NULL, $callback=NULL) { |
|
| 240 | + $result=$this->addInToolbar($caption, $callback); |
|
| 241 | + if (isset($icon)) |
|
| 242 | 242 | $result->addIcon($icon); |
| 243 | 243 | return $result; |
| 244 | 244 | } |
@@ -248,14 +248,14 @@ discard block |
||
| 248 | 248 | * @param callable $callback function($element) |
| 249 | 249 | * @return \Ajax\common\Widget |
| 250 | 250 | */ |
| 251 | - public function addItemsInToolbar(array $items,$callback=NULL){ |
|
| 252 | - if(JArray::isAssociative($items)){ |
|
| 253 | - foreach ($items as $icon=>$item){ |
|
| 254 | - $this->addItemInToolbar($item,$icon,$callback); |
|
| 251 | + public function addItemsInToolbar(array $items, $callback=NULL) { |
|
| 252 | + if (JArray::isAssociative($items)) { |
|
| 253 | + foreach ($items as $icon=>$item) { |
|
| 254 | + $this->addItemInToolbar($item, $icon, $callback); |
|
| 255 | 255 | } |
| 256 | - }else{ |
|
| 257 | - foreach ($items as $item){ |
|
| 258 | - $this->addItemInToolbar($item,null,$callback); |
|
| 256 | + } else { |
|
| 257 | + foreach ($items as $item) { |
|
| 258 | + $this->addItemInToolbar($item, null, $callback); |
|
| 259 | 259 | } |
| 260 | 260 | } |
| 261 | 261 | return $this; |
@@ -267,12 +267,12 @@ discard block |
||
| 267 | 267 | * @param callable $callback function($element) |
| 268 | 268 | * @return \Ajax\common\html\HtmlDoubleElement |
| 269 | 269 | */ |
| 270 | - public function addDropdownInToolbar($value,$items,$callback=NULL){ |
|
| 270 | + public function addDropdownInToolbar($value, $items, $callback=NULL) { |
|
| 271 | 271 | $dd=$value; |
| 272 | 272 | if (\is_string($value)) { |
| 273 | - $dd=new HtmlDropdown("dropdown-". $this->identifier."-".$value, $value, $items); |
|
| 273 | + $dd=new HtmlDropdown("dropdown-".$this->identifier."-".$value, $value, $items); |
|
| 274 | 274 | } |
| 275 | - return $this->addInToolbar($dd,$callback); |
|
| 275 | + return $this->addInToolbar($dd, $callback); |
|
| 276 | 276 | } |
| 277 | 277 | |
| 278 | 278 | /** |
@@ -281,9 +281,9 @@ discard block |
||
| 281 | 281 | * @param callable $callback function($element) |
| 282 | 282 | * @return \Ajax\common\html\HtmlDoubleElement |
| 283 | 283 | */ |
| 284 | - public function addButtonInToolbar($caption,$cssStyle=null,$callback=NULL){ |
|
| 285 | - $bt=new HtmlButton("bt-".$caption,$caption,$cssStyle); |
|
| 286 | - return $this->addInToolbar($bt,$callback); |
|
| 284 | + public function addButtonInToolbar($caption, $cssStyle=null, $callback=NULL) { |
|
| 285 | + $bt=new HtmlButton("bt-".$caption, $caption, $cssStyle); |
|
| 286 | + return $this->addInToolbar($bt, $callback); |
|
| 287 | 287 | } |
| 288 | 288 | |
| 289 | 289 | /** |
@@ -292,9 +292,9 @@ discard block |
||
| 292 | 292 | * @param callable $callback function($element) |
| 293 | 293 | * @return \Ajax\common\html\HtmlDoubleElement |
| 294 | 294 | */ |
| 295 | - public function addButtonsInToolbar(array $captions,$asIcon=false,$callback=NULL){ |
|
| 296 | - $bts=new HtmlButtonGroups("",$captions,$asIcon); |
|
| 297 | - return $this->addInToolbar($bts,$callback); |
|
| 295 | + public function addButtonsInToolbar(array $captions, $asIcon=false, $callback=NULL) { |
|
| 296 | + $bts=new HtmlButtonGroups("", $captions, $asIcon); |
|
| 297 | + return $this->addInToolbar($bts, $callback); |
|
| 298 | 298 | } |
| 299 | 299 | |
| 300 | 300 | /** |
@@ -304,15 +304,15 @@ discard block |
||
| 304 | 304 | * @param boolean $labeled |
| 305 | 305 | * @return \Ajax\common\html\HtmlDoubleElement |
| 306 | 306 | */ |
| 307 | - public function addLabelledIconButtonInToolbar($caption,$icon,$before=true,$labeled=false){ |
|
| 308 | - $bt=new HtmlButton("",$caption); |
|
| 309 | - $bt->addIcon($icon,$before,$labeled); |
|
| 307 | + public function addLabelledIconButtonInToolbar($caption, $icon, $before=true, $labeled=false) { |
|
| 308 | + $bt=new HtmlButton("", $caption); |
|
| 309 | + $bt->addIcon($icon, $before, $labeled); |
|
| 310 | 310 | return $this->addInToolbar($bt); |
| 311 | 311 | } |
| 312 | 312 | |
| 313 | - public function addSubmitInToolbar($identifier,$value,$cssStyle=NULL,$url=NULL,$responseElement=NULL,$parameters=NULL){ |
|
| 314 | - $button=new HtmlButton($identifier,$value,$cssStyle); |
|
| 315 | - $this->_buttonAsSubmit($button,"click",$url,$responseElement,$parameters); |
|
| 313 | + public function addSubmitInToolbar($identifier, $value, $cssStyle=NULL, $url=NULL, $responseElement=NULL, $parameters=NULL) { |
|
| 314 | + $button=new HtmlButton($identifier, $value, $cssStyle); |
|
| 315 | + $this->_buttonAsSubmit($button, "click", $url, $responseElement, $parameters); |
|
| 316 | 316 | return $this->addInToolbar($button); |
| 317 | 317 | } |
| 318 | 318 | |
@@ -342,7 +342,7 @@ discard block |
||
| 342 | 342 | * @param callable $defaultValueFunction function parameters are : $name : the field name, $value : the field value ,$index : the field index, $instance : the active instance of model |
| 343 | 343 | * @return \Ajax\common\Widget |
| 344 | 344 | */ |
| 345 | - public function setDefaultValueFunction($defaultValueFunction){ |
|
| 345 | + public function setDefaultValueFunction($defaultValueFunction) { |
|
| 346 | 346 | $this->_instanceViewer->setDefaultValueFunction($defaultValueFunction); |
| 347 | 347 | return $this; |
| 348 | 348 | } |
@@ -351,7 +351,7 @@ discard block |
||
| 351 | 351 | * @param string|boolean $disable |
| 352 | 352 | * @return string |
| 353 | 353 | */ |
| 354 | - public function jsDisabled($disable=true){ |
|
| 354 | + public function jsDisabled($disable=true) { |
|
| 355 | 355 | return "$('#".$this->identifier." .ui.input,#".$this->identifier." .ui.dropdown,#".$this->identifier." .ui.checkbox').toggleClass('disabled',".$disable.");"; |
| 356 | 356 | } |
| 357 | 357 | |
@@ -360,12 +360,12 @@ discard block |
||
| 360 | 360 | * @param callable $callback function($element) |
| 361 | 361 | * @return \Ajax\common\html\HtmlDoubleElement |
| 362 | 362 | */ |
| 363 | - public function addEditButtonInToolbar($caption,$callback=NULL){ |
|
| 364 | - $bt=new HtmlButton($this->identifier."-editBtn",$caption); |
|
| 363 | + public function addEditButtonInToolbar($caption, $callback=NULL) { |
|
| 364 | + $bt=new HtmlButton($this->identifier."-editBtn", $caption); |
|
| 365 | 365 | $bt->setToggle(); |
| 366 | 366 | $bt->setActive($this->_edition); |
| 367 | 367 | $bt->onClick($this->jsDisabled(Javascript::prep_value("!$(event.target).hasClass('active')"))); |
| 368 | - return $this->addInToolbar($bt,$callback); |
|
| 368 | + return $this->addInToolbar($bt, $callback); |
|
| 369 | 369 | } |
| 370 | 370 | |
| 371 | 371 | public function setToolbar(HtmlMenu $_toolbar) { |
@@ -379,35 +379,35 @@ discard block |
||
| 379 | 379 | } |
| 380 | 380 | |
| 381 | 381 | public function getForm() { |
| 382 | - if(!isset($this->_form)){ |
|
| 382 | + if (!isset($this->_form)) { |
|
| 383 | 383 | $this->_form=new HtmlForm("frm-".$this->identifier); |
| 384 | 384 | $this->setEdition(true); |
| 385 | 385 | } |
| 386 | 386 | return $this->_form; |
| 387 | 387 | } |
| 388 | 388 | |
| 389 | - public function run(JsUtils $js){ |
|
| 389 | + public function run(JsUtils $js) { |
|
| 390 | 390 | $result=parent::run($js); |
| 391 | - if(isset($this->_form)){ |
|
| 391 | + if (isset($this->_form)) { |
|
| 392 | 392 | $result=$this->runForm($js); |
| 393 | 393 | } |
| 394 | 394 | return $result; |
| 395 | 395 | } |
| 396 | 396 | |
| 397 | - protected function runForm(JsUtils $js){ |
|
| 397 | + protected function runForm(JsUtils $js) { |
|
| 398 | 398 | $fields=$this->getContentInstances(HtmlFormField::class); |
| 399 | - foreach ($fields as $field){ |
|
| 399 | + foreach ($fields as $field) { |
|
| 400 | 400 | $this->_form->addField($field); |
| 401 | 401 | } |
| 402 | 402 | return $this->_form->run($js); |
| 403 | 403 | } |
| 404 | 404 | |
| 405 | - protected function _compileForm(){ |
|
| 406 | - if(isset($this->_form)){ |
|
| 405 | + protected function _compileForm() { |
|
| 406 | + if (isset($this->_form)) { |
|
| 407 | 407 | $noValidate=""; |
| 408 | - if(\sizeof($this->_form->getValidationParams())>0) |
|
| 408 | + if (\sizeof($this->_form->getValidationParams())>0) |
|
| 409 | 409 | $noValidate="novalidate"; |
| 410 | - $this->wrapContent("<form class='ui form' id='frm-".$this->identifier."' name='frm-".$this->identifier."' ".$noValidate.">","</form>"); |
|
| 410 | + $this->wrapContent("<form class='ui form' id='frm-".$this->identifier."' name='frm-".$this->identifier."' ".$noValidate.">", "</form>"); |
|
| 411 | 411 | } |
| 412 | 412 | } |
| 413 | 413 | |
@@ -416,26 +416,26 @@ discard block |
||
| 416 | 416 | return $this; |
| 417 | 417 | } |
| 418 | 418 | |
| 419 | - public function moveFieldTo($from,$to){ |
|
| 419 | + public function moveFieldTo($from, $to) { |
|
| 420 | 420 | return $this->_instanceViewer->moveFieldTo($from, $to); |
| 421 | 421 | } |
| 422 | 422 | |
| 423 | - public function swapFields($index1,$index2){ |
|
| 423 | + public function swapFields($index1, $index2) { |
|
| 424 | 424 | $index1=$this->_getIndex($index1); |
| 425 | 425 | $index2=$this->_getIndex($index2); |
| 426 | 426 | return $this->_instanceViewer->swapFields($index1, $index2); |
| 427 | 427 | } |
| 428 | 428 | |
| 429 | - public function removeField($index){ |
|
| 429 | + public function removeField($index) { |
|
| 430 | 430 | $index=$this->_getIndex($index); |
| 431 | 431 | $this->_instanceViewer->removeField($index); |
| 432 | 432 | return $this; |
| 433 | 433 | } |
| 434 | 434 | |
| 435 | - public function asModal($header){ |
|
| 436 | - $modal=new HtmlModal("modal-".$this->identifier,$header); |
|
| 435 | + public function asModal($header) { |
|
| 436 | + $modal=new HtmlModal("modal-".$this->identifier, $header); |
|
| 437 | 437 | $modal->setContent($this); |
| 438 | - if(isset($this->_form)){ |
|
| 438 | + if (isset($this->_form)) { |
|
| 439 | 439 | $this->_form->onSuccess($modal->jsHide()); |
| 440 | 440 | } |
| 441 | 441 | return $modal; |
@@ -15,11 +15,11 @@ discard block |
||
| 15 | 15 | * @version 1.3 |
| 16 | 16 | */ |
| 17 | 17 | abstract class BaseHtml extends BaseWidget { |
| 18 | - use BaseHtmlEventsTrait,BaseHtmlPropertiesTrait; |
|
| 18 | + use BaseHtmlEventsTrait, BaseHtmlPropertiesTrait; |
|
| 19 | 19 | protected $_template; |
| 20 | 20 | protected $tagName; |
| 21 | - protected $_wrapBefore=array (); |
|
| 22 | - protected $_wrapAfter=array (); |
|
| 21 | + protected $_wrapBefore=array(); |
|
| 22 | + protected $_wrapAfter=array(); |
|
| 23 | 23 | protected $_bsComponent; |
| 24 | 24 | protected $_compiled=false; |
| 25 | 25 | |
@@ -30,14 +30,14 @@ discard block |
||
| 30 | 30 | */ |
| 31 | 31 | abstract public function run(JsUtils $js); |
| 32 | 32 | |
| 33 | - private function _callSetter($setter,$key,$value,&$array){ |
|
| 33 | + private function _callSetter($setter, $key, $value, &$array) { |
|
| 34 | 34 | $result=false; |
| 35 | 35 | if (method_exists($this, $setter) && !JString::startswith($key, "_")) { |
| 36 | 36 | try { |
| 37 | 37 | $this->$setter($value); |
| 38 | 38 | unset($array[$key]); |
| 39 | 39 | $result=true; |
| 40 | - } catch ( \Exception $e ) { |
|
| 40 | + }catch (\Exception $e) { |
|
| 41 | 41 | $result=false; |
| 42 | 42 | } |
| 43 | 43 | } |
@@ -45,17 +45,17 @@ discard block |
||
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | protected function getTemplate(JsUtils $js=NULL) { |
| 48 | - return PropertyWrapper::wrap($this->_wrapBefore, $js) . $this->_template . PropertyWrapper::wrap($this->_wrapAfter, $js); |
|
| 48 | + return PropertyWrapper::wrap($this->_wrapBefore, $js).$this->_template.PropertyWrapper::wrap($this->_wrapAfter, $js); |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | protected function ctrl($name, $value, $typeCtrl) { |
| 52 | 52 | if (\is_array($typeCtrl)) { |
| 53 | - if (array_search($value, $typeCtrl) === false) { |
|
| 54 | - throw new \Exception("La valeur passée `" . $value . "` à la propriété `" . $name . "` ne fait pas partie des valeurs possibles : {" . implode(",", $typeCtrl) . "}"); |
|
| 53 | + if (array_search($value, $typeCtrl)===false) { |
|
| 54 | + throw new \Exception("La valeur passée `".$value."` à la propriété `".$name."` ne fait pas partie des valeurs possibles : {".implode(",", $typeCtrl)."}"); |
|
| 55 | 55 | } |
| 56 | 56 | } else { |
| 57 | 57 | if (!$typeCtrl($value)) { |
| 58 | - throw new \Exception("La fonction " . $typeCtrl . " a retourné faux pour l'affectation de la propriété " . $name); |
|
| 58 | + throw new \Exception("La fonction ".$typeCtrl." a retourné faux pour l'affectation de la propriété ".$name); |
|
| 59 | 59 | } |
| 60 | 60 | } |
| 61 | 61 | return true; |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | |
| 65 | 65 | |
| 66 | 66 | protected function setMemberCtrl(&$name, $value, $typeCtrl) { |
| 67 | - if ($this->ctrl($name, $value, $typeCtrl) === true) { |
|
| 67 | + if ($this->ctrl($name, $value, $typeCtrl)===true) { |
|
| 68 | 68 | return $name=$value; |
| 69 | 69 | } |
| 70 | 70 | return $this; |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | protected function addToMemberUnique(&$name, $value, $typeCtrl, $separator=" ") { |
| 74 | 74 | if (\is_array($typeCtrl)) { |
| 75 | 75 | $this->removeOldValues($name, $typeCtrl); |
| 76 | - $name.=$separator . $value; |
|
| 76 | + $name.=$separator.$value; |
|
| 77 | 77 | } |
| 78 | 78 | return $this; |
| 79 | 79 | } |
@@ -81,17 +81,17 @@ discard block |
||
| 81 | 81 | |
| 82 | 82 | |
| 83 | 83 | protected function addToMemberCtrl(&$name, $value, $typeCtrl, $separator=" ") { |
| 84 | - if ($this->ctrl($name, $value, $typeCtrl) === true) { |
|
| 84 | + if ($this->ctrl($name, $value, $typeCtrl)===true) { |
|
| 85 | 85 | if (\is_array($typeCtrl)) { |
| 86 | 86 | $this->removeOldValues($name, $typeCtrl); |
| 87 | 87 | } |
| 88 | - $name.=$separator . $value; |
|
| 88 | + $name.=$separator.$value; |
|
| 89 | 89 | } |
| 90 | 90 | return $this; |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | protected function addToMember(&$name, $value, $separator=" ") { |
| 94 | - $name=str_ireplace($value, "", $name) . $separator . $value; |
|
| 94 | + $name=str_ireplace($value, "", $name).$separator.$value; |
|
| 95 | 95 | return $this; |
| 96 | 96 | } |
| 97 | 97 | |
@@ -102,17 +102,17 @@ discard block |
||
| 102 | 102 | $oldValue=trim($oldValue); |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | - protected function _getElementBy($callback,$elements){ |
|
| 105 | + protected function _getElementBy($callback, $elements) { |
|
| 106 | 106 | if (\is_array($elements)) { |
| 107 | 107 | $flag=false; |
| 108 | 108 | $index=0; |
| 109 | - while ( !$flag && $index < sizeof($elements) ) { |
|
| 109 | + while (!$flag && $index<sizeof($elements)) { |
|
| 110 | 110 | if ($elements[$index] instanceof BaseHtml) |
| 111 | 111 | $flag=($callback($elements[$index])); |
| 112 | 112 | $index++; |
| 113 | 113 | } |
| 114 | - if ($flag === true) |
|
| 115 | - return $elements[$index - 1]; |
|
| 114 | + if ($flag===true) |
|
| 115 | + return $elements[$index-1]; |
|
| 116 | 116 | } elseif ($elements instanceof BaseHtml) { |
| 117 | 117 | if ($callback($elements)) |
| 118 | 118 | return $elements; |
@@ -140,13 +140,13 @@ discard block |
||
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | public function fromArray($array) { |
| 143 | - foreach ( $this as $key => $value ) { |
|
| 144 | - if(array_key_exists($key, $array)===true) |
|
| 145 | - $this->_callSetter("set" . ucfirst($key), $key, $array[$key], $array); |
|
| 143 | + foreach ($this as $key => $value) { |
|
| 144 | + if (array_key_exists($key, $array)===true) |
|
| 145 | + $this->_callSetter("set".ucfirst($key), $key, $array[$key], $array); |
|
| 146 | 146 | } |
| 147 | - foreach ( $array as $key => $value ) { |
|
| 148 | - if($this->_callSetter($key, $key, $value, $array)===false){ |
|
| 149 | - $this->_callSetter("set" . ucfirst($key), $key, $value, $array); |
|
| 147 | + foreach ($array as $key => $value) { |
|
| 148 | + if ($this->_callSetter($key, $key, $value, $array)===false) { |
|
| 149 | + $this->_callSetter("set".ucfirst($key), $key, $value, $array); |
|
| 150 | 150 | } |
| 151 | 151 | } |
| 152 | 152 | return $array; |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | |
| 155 | 155 | public function fromDatabaseObjects($objects, $function) { |
| 156 | 156 | if (isset($objects)) { |
| 157 | - foreach ( $objects as $object ) { |
|
| 157 | + foreach ($objects as $object) { |
|
| 158 | 158 | $this->fromDatabaseObject($object, $function); |
| 159 | 159 | } |
| 160 | 160 | } |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | |
| 176 | 176 | |
| 177 | 177 | public function getElementById($identifier, $elements) { |
| 178 | - return $this->_getElementBy(function($element) use ($identifier){return $element->getIdentifier()===$identifier;}, $elements); |
|
| 178 | + return $this->_getElementBy(function($element) use ($identifier){return $element->getIdentifier()===$identifier; }, $elements); |
|
| 179 | 179 | } |
| 180 | 180 | |
| 181 | 181 | public function getBsComponent() { |
@@ -190,24 +190,24 @@ discard block |
||
| 190 | 190 | protected function compile_once(JsUtils $js=NULL, &$view=NULL) { |
| 191 | 191 | } |
| 192 | 192 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
| 193 | - if(!$this->_compiled){ |
|
| 194 | - $this->compile_once($js,$view); |
|
| 193 | + if (!$this->_compiled) { |
|
| 194 | + $this->compile_once($js, $view); |
|
| 195 | 195 | $this->_compiled=true; |
| 196 | 196 | } |
| 197 | 197 | $result=$this->getTemplate($js); |
| 198 | - foreach ( $this as $key => $value ) { |
|
| 199 | - if (JString::startswith($key, "_") === false && $key !== "events") { |
|
| 198 | + foreach ($this as $key => $value) { |
|
| 199 | + if (JString::startswith($key, "_")===false && $key!=="events") { |
|
| 200 | 200 | if (\is_array($value)) { |
| 201 | 201 | $v=PropertyWrapper::wrap($value, $js); |
| 202 | 202 | } else { |
| 203 | 203 | $v=$value; |
| 204 | 204 | } |
| 205 | - $result=str_ireplace("%" . $key . "%", $v, $result); |
|
| 205 | + $result=str_ireplace("%".$key."%", $v, $result); |
|
| 206 | 206 | } |
| 207 | 207 | } |
| 208 | 208 | if (isset($js)===true) { |
| 209 | 209 | $this->run($js); |
| 210 | - if (isset($view) === true) { |
|
| 210 | + if (isset($view)===true) { |
|
| 211 | 211 | $js->addViewElement($this->_identifier, $result, $view); |
| 212 | 212 | } |
| 213 | 213 | } |
@@ -20,7 +20,7 @@ |
||
| 20 | 20 | $this->params["onUnchecked"]="%function(){".$value."}%"; |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | - public function setOnChange($value){ |
|
| 23 | + public function setOnChange($value) { |
|
| 24 | 24 | $this->params["onChange"]="%function(){".$value."}%"; |
| 25 | 25 | } |
| 26 | 26 | //TODO other events implementation |
@@ -19,28 +19,28 @@ discard block |
||
| 19 | 19 | |
| 20 | 20 | public function __construct(JsUtils $js=NULL) { |
| 21 | 21 | parent::__construct($js); |
| 22 | - $this->events=array (); |
|
| 22 | + $this->events=array(); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | protected function compileEvents() { |
| 26 | - foreach ( $this->events as $event => $jsCode ) { |
|
| 26 | + foreach ($this->events as $event => $jsCode) { |
|
| 27 | 27 | $itemSelector=JString::getValueBetween($event); |
| 28 | 28 | //echo $itemSelector.":::".$jsCode."<br>"; |
| 29 | - if($event=="execute"){ |
|
| 29 | + if ($event=="execute") { |
|
| 30 | 30 | $this->jquery_code_for_compile []=$jsCode; |
| 31 | - }else if($event=="beforeExecute"){ |
|
| 31 | + } else if ($event=="beforeExecute") { |
|
| 32 | 32 | \array_unshift($this->jquery_code_for_compile, $jsCode); |
| 33 | - }else{ |
|
| 33 | + } else { |
|
| 34 | 34 | $selector=$this->_createSelector($itemSelector, $this->attachTo); |
| 35 | 35 | $this->jquery_code_for_compile []="$( \"".$selector."\" ).on(\"".$event."\" , function( event, data ) {".$jsCode."});"; |
| 36 | 36 | } |
| 37 | 37 | } |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | - protected function _createSelector($itemSelector,$selector){ |
|
| 41 | - if(!isset($itemSelector)) |
|
| 40 | + protected function _createSelector($itemSelector, $selector) { |
|
| 41 | + if (!isset($itemSelector)) |
|
| 42 | 42 | $itemSelector=$this->itemSelector; |
| 43 | - if(isset($itemSelector) && $itemSelector!=="") |
|
| 43 | + if (isset($itemSelector) && $itemSelector!=="") |
|
| 44 | 44 | $selector.=" ".$itemSelector; |
| 45 | 45 | return $selector; |
| 46 | 46 | } |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | $result=implode("\n", $this->jquery_code_for_compile); |
| 50 | 50 | $result=str_ireplace("\"%", "", $result); |
| 51 | 51 | $result=str_ireplace("%\"", "", $result); |
| 52 | - $result=str_replace(array ( |
|
| 52 | + $result=str_replace(array( |
|
| 53 | 53 | "\\n", |
| 54 | 54 | "\\r", |
| 55 | 55 | "\\t" |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | |
| 60 | 60 | public function getScript() { |
| 61 | 61 | $allParams=$this->params; |
| 62 | - $this->jquery_code_for_compile=array (); |
|
| 62 | + $this->jquery_code_for_compile=array(); |
|
| 63 | 63 | $this->jquery_code_for_compile []="$( \"".$this->attachTo."\" ).{$this->uiName}(".$this->getParamsAsJSON($allParams).");"; |
| 64 | 64 | $this->compileEvents(); |
| 65 | 65 | return $this->compileJQueryCode(); |
@@ -2,63 +2,63 @@ |
||
| 2 | 2 | namespace Ajax\service; |
| 3 | 3 | class JString { |
| 4 | 4 | |
| 5 | - public static function contains($hay,$needle){ |
|
| 6 | - return strpos($hay, $needle) !== false; |
|
| 5 | + public static function contains($hay, $needle) { |
|
| 6 | + return strpos($hay, $needle)!==false; |
|
| 7 | 7 | } |
| 8 | 8 | public static function startswith($hay, $needle) { |
| 9 | - return substr($hay, 0, strlen($needle)) === $needle; |
|
| 9 | + return substr($hay, 0, strlen($needle))===$needle; |
|
| 10 | 10 | } |
| 11 | 11 | |
| 12 | 12 | public static function endswith($hay, $needle) { |
| 13 | - return substr($hay, -strlen($needle)) === $needle; |
|
| 13 | + return substr($hay, -strlen($needle))===$needle; |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | - public static function isNull($s){ |
|
| 16 | + public static function isNull($s) { |
|
| 17 | 17 | return (!isset($s) || NULL===$s || ""===$s); |
| 18 | 18 | } |
| 19 | - public static function isNotNull($s){ |
|
| 19 | + public static function isNotNull($s) { |
|
| 20 | 20 | return (isset($s) && NULL!==$s && ""!==$s); |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | - public static function isBoolean($value){ |
|
| 23 | + public static function isBoolean($value) { |
|
| 24 | 24 | return \is_bool($value) || $value==1 || $value==0; |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | - public static function isBooleanTrue($value){ |
|
| 27 | + public static function isBooleanTrue($value) { |
|
| 28 | 28 | return $value==1 || $value; |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | - public static function isBooleanFalse($value){ |
|
| 31 | + public static function isBooleanFalse($value) { |
|
| 32 | 32 | return $value==0 || !$value; |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - public static function camelCaseToSeparated($input,$separator=" "){ |
|
| 35 | + public static function camelCaseToSeparated($input, $separator=" ") { |
|
| 36 | 36 | return strtolower(preg_replace('/(?<!^)[A-Z]/', $separator.'$0', $input)); |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | - public static function replaceAtFirst($subject,$from, $to){ |
|
| 40 | - $from = '/\A'.preg_quote($from, '/').'/'; |
|
| 39 | + public static function replaceAtFirst($subject, $from, $to) { |
|
| 40 | + $from='/\A'.preg_quote($from, '/').'/'; |
|
| 41 | 41 | return \preg_replace($from, $to, $subject, 1); |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | - public static function replaceAtLast($subject,$from, $to){ |
|
| 45 | - $from = '/'.preg_quote($from, '/').'\z/'; |
|
| 44 | + public static function replaceAtLast($subject, $from, $to) { |
|
| 45 | + $from='/'.preg_quote($from, '/').'\z/'; |
|
| 46 | 46 | return \preg_replace($from, $to, $subject, 1); |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | - public static function replaceAtFirstAndLast($subject,$fromFirst,$toFirst,$fromLast,$toLast){ |
|
| 49 | + public static function replaceAtFirstAndLast($subject, $fromFirst, $toFirst, $fromLast, $toLast) { |
|
| 50 | 50 | $s=self::replaceAtFirst($subject, $fromFirst, $toFirst); |
| 51 | 51 | return self::replaceAtLast($s, $fromLast, $toLast); |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - public static function getValueBetween(&$str,$before="{{",$after="}}"){ |
|
| 54 | + public static function getValueBetween(&$str, $before="{{", $after="}}") { |
|
| 55 | 55 | $matches=[]; |
| 56 | 56 | $result=null; |
| 57 | 57 | $_before=\preg_quote($before); |
| 58 | 58 | $_after=\preg_quote($after); |
| 59 | - if(\preg_match('/'.$_before.'(.*?)'.$_after.'/s', $str, $matches)===1){ |
|
| 59 | + if (\preg_match('/'.$_before.'(.*?)'.$_after.'/s', $str, $matches)===1) { |
|
| 60 | 60 | $result=$matches[1]; |
| 61 | - $str=\str_replace($before.$result.$after,"", $str); |
|
| 61 | + $str=\str_replace($before.$result.$after, "", $str); |
|
| 62 | 62 | } |
| 63 | 63 | return $result; |
| 64 | 64 | } |
@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | namespace Ajax\semantic\html\collections\table\traits; |
| 3 | 3 | |
| 4 | -trait TableTrait{ |
|
| 4 | +trait TableTrait { |
|
| 5 | 5 | /** |
| 6 | 6 | * @return HtmlTable |
| 7 | 7 | */ |
@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | abstract public function addEvent($event, $jsCode, $stopPropagation=false, $preventDefault=false); |
| 10 | 10 | abstract public function getOn($event, $url, $responseElement="", $parameters=array()); |
| 11 | 11 | |
| 12 | - protected function addToPropertyTable($property,$value){ |
|
| 12 | + protected function addToPropertyTable($property, $value) { |
|
| 13 | 13 | return $this->getTable()->addToProperty($property, $value); |
| 14 | 14 | } |
| 15 | 15 | |
@@ -20,15 +20,15 @@ discard block |
||
| 20 | 20 | public function setBasic($very=false) { |
| 21 | 21 | $table=$this->getTable(); |
| 22 | 22 | if ($very) |
| 23 | - $table->addToPropertyCtrl("class", "very", array ("very" )); |
|
| 24 | - return $table->addToPropertyCtrl("class", "basic", array ("basic" )); |
|
| 23 | + $table->addToPropertyCtrl("class", "very", array("very")); |
|
| 24 | + return $table->addToPropertyCtrl("class", "basic", array("basic")); |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | public function setCompact($very=false) { |
| 28 | 28 | $table=$this->getTable(); |
| 29 | 29 | if ($very) |
| 30 | - $table->addToPropertyCtrl("class", "very", array ("very" )); |
|
| 31 | - return $table->addToPropertyCtrl("class", "compact", array ("compact" )); |
|
| 30 | + $table->addToPropertyCtrl("class", "very", array("very")); |
|
| 31 | + return $table->addToPropertyCtrl("class", "compact", array("compact")); |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | public function setCollapsing() { |
@@ -67,16 +67,16 @@ discard block |
||
| 67 | 67 | return $this->addToPropertyTable("class", "striped"); |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - public function onRowClick($jsCode, $stopPropagation=false, $preventDefault=false){ |
|
| 71 | - $this->onRowClick($jsCode,$stopPropagation,$preventDefault); |
|
| 70 | + public function onRowClick($jsCode, $stopPropagation=false, $preventDefault=false) { |
|
| 71 | + $this->onRowClick($jsCode, $stopPropagation, $preventDefault); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - public function onRow($event,$jsCode, $stopPropagation=false, $preventDefault=false){ |
|
| 75 | - $this->getTable()->addEvent($event."{{tr}}",$jsCode,$stopPropagation,$preventDefault); |
|
| 74 | + public function onRow($event, $jsCode, $stopPropagation=false, $preventDefault=false) { |
|
| 75 | + $this->getTable()->addEvent($event."{{tr}}", $jsCode, $stopPropagation, $preventDefault); |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - public function getOnRow($event, $url, $responseElement="", $parameters=array()){ |
|
| 79 | - $parameters=\array_merge($parameters,["stopPropagation"=>false,"preventDefault"=>false]); |
|
| 80 | - return $this->getTable()->getOn($event."{{tbody tr}}", $url,$responseElement,$parameters); |
|
| 78 | + public function getOnRow($event, $url, $responseElement="", $parameters=array()) { |
|
| 79 | + $parameters=\array_merge($parameters, ["stopPropagation"=>false, "preventDefault"=>false]); |
|
| 80 | + return $this->getTable()->getOn($event."{{tbody tr}}", $url, $responseElement, $parameters); |
|
| 81 | 81 | } |
| 82 | 82 | } |
| 83 | 83 | \ No newline at end of file |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | * @param string $event |
| 22 | 22 | * @param boolean $multiple |
| 23 | 23 | */ |
| 24 | - public function __construct($table,$class="active",$event="click",$multiple=false){ |
|
| 24 | + public function __construct($table, $class="active", $event="click", $multiple=false) { |
|
| 25 | 25 | $this->table=$table; |
| 26 | 26 | $this->class=$class; |
| 27 | 27 | $this->event=$event; |
@@ -55,12 +55,12 @@ discard block |
||
| 55 | 55 | return $this; |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | - public function compile(){ |
|
| 58 | + public function compile() { |
|
| 59 | 59 | $multiple=""; |
| 60 | - if(!$this->multiple){ |
|
| 60 | + if (!$this->multiple) { |
|
| 61 | 61 | $multiple="$(this).closest('tbody').children('tr').removeClass('".$this->class."');"; |
| 62 | 62 | } |
| 63 | - $this->table->onRow($this->event, $multiple."$(this).toggleClass('".$this->class."');",false,false); |
|
| 63 | + $this->table->onRow($this->event, $multiple."$(this).toggleClass('".$this->class."');", false, false); |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | } |
| 67 | 67 | \ No newline at end of file |