@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | * @author jc |
| 16 | 16 | * |
| 17 | 17 | */ |
| 18 | -trait FormTrait{ |
|
| 18 | +trait FormTrait { |
|
| 19 | 19 | |
| 20 | 20 | /** |
| 21 | 21 | * @return HtmlForm |
@@ -23,23 +23,23 @@ discard block |
||
| 23 | 23 | abstract protected function getForm(); |
| 24 | 24 | |
| 25 | 25 | |
| 26 | - protected function addCompoValidation(Form $compo,HtmlFormField $field){ |
|
| 26 | + protected function addCompoValidation(Form $compo, HtmlFormField $field) { |
|
| 27 | 27 | $validation=$field->getValidation(); |
| 28 | - if(isset($validation)){ |
|
| 28 | + if (isset($validation)) { |
|
| 29 | 29 | $validation->setIdentifier($field->getDataField()->getIdentifier()); |
| 30 | 30 | $compo->addFieldValidation($validation); |
| 31 | 31 | } |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | - protected function addExtraCompoValidation(Form $compo,FieldValidation $validation){ |
|
| 34 | + protected function addExtraCompoValidation(Form $compo, FieldValidation $validation) { |
|
| 35 | 35 | $compo->addFieldValidation($validation); |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | - protected function _runValidationParams(Form &$compo,JsUtils $js=NULL){ |
|
| 38 | + protected function _runValidationParams(Form &$compo, JsUtils $js=NULL) { |
|
| 39 | 39 | $form=$this->getForm(); |
| 40 | 40 | $params=$form->getValidationParams(); |
| 41 | - if(isset($params["_ajaxSubmit"])){ |
|
| 42 | - $compilation=$this->_compileAjaxSubmit($params["_ajaxSubmit"],$js); |
|
| 41 | + if (isset($params["_ajaxSubmit"])) { |
|
| 42 | + $compilation=$this->_compileAjaxSubmit($params["_ajaxSubmit"], $js); |
|
| 43 | 43 | $this->onSuccess($compilation); |
| 44 | 44 | $form->removeValidationParam("_ajaxSubmit"); |
| 45 | 45 | } |
@@ -48,16 +48,16 @@ discard block |
||
| 48 | 48 | $form->addEventsOnRun($js); |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | - protected function _compileAjaxSubmit($ajaxSubmit,JsUtils $js=null){ |
|
| 51 | + protected function _compileAjaxSubmit($ajaxSubmit, JsUtils $js=null) { |
|
| 52 | 52 | $compilation=""; |
| 53 | - if(\is_array($ajaxSubmit)){ |
|
| 54 | - foreach ($ajaxSubmit as $ajaxSubmitItem){ |
|
| 53 | + if (\is_array($ajaxSubmit)) { |
|
| 54 | + foreach ($ajaxSubmit as $ajaxSubmitItem) { |
|
| 55 | 55 | $compilation.=$ajaxSubmitItem->compile($js); |
| 56 | 56 | } |
| 57 | - }elseif($ajaxSubmit instanceof AjaxCall){ |
|
| 57 | + }elseif ($ajaxSubmit instanceof AjaxCall) { |
|
| 58 | 58 | $compilation=$ajaxSubmit->compile($js); |
| 59 | 59 | } |
| 60 | - $compilation=str_ireplace("\"","%quote%", $compilation); |
|
| 60 | + $compilation=str_ireplace("\"", "%quote%", $compilation); |
|
| 61 | 61 | return $compilation; |
| 62 | 62 | } |
| 63 | 63 | |
@@ -70,14 +70,14 @@ discard block |
||
| 70 | 70 | return $this; |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | - public function setAttached($value=true){ |
|
| 73 | + public function setAttached($value=true) { |
|
| 74 | 74 | $form=$this->getForm(); |
| 75 | - if($value) |
|
| 76 | - $form->addToPropertyCtrl("class", "attached", array ("attached" )); |
|
| 75 | + if ($value) |
|
| 76 | + $form->addToPropertyCtrl("class", "attached", array("attached")); |
|
| 77 | 77 | return $form; |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | - public function addErrorMessage(){ |
|
| 80 | + public function addErrorMessage() { |
|
| 81 | 81 | return $this->getForm()->addContent((new HtmlMessage(""))->setError()); |
| 82 | 82 | } |
| 83 | 83 | |
@@ -93,48 +93,48 @@ discard block |
||
| 93 | 93 | * @param array $parameters |
| 94 | 94 | * @return HtmlForm |
| 95 | 95 | */ |
| 96 | - public function submitOn($event,$identifierOrElement,$url,$responseElement,$parameters=NULL){ |
|
| 96 | + public function submitOn($event, $identifierOrElement, $url, $responseElement, $parameters=NULL) { |
|
| 97 | 97 | $form=$this->getForm(); |
| 98 | - if($identifierOrElement instanceof BaseHtml) |
|
| 98 | + if ($identifierOrElement instanceof BaseHtml) |
|
| 99 | 99 | $elem=$identifierOrElement; |
| 100 | 100 | else |
| 101 | 101 | $elem=$form->getElementById($identifierOrElement, $form->getContent()); |
| 102 | - if(isset($elem)){ |
|
| 103 | - $this->_buttonAsSubmit($elem, $event,$url,$responseElement,$parameters); |
|
| 102 | + if (isset($elem)) { |
|
| 103 | + $this->_buttonAsSubmit($elem, $event, $url, $responseElement, $parameters); |
|
| 104 | 104 | } |
| 105 | 105 | return $form; |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | - public function submitOnClick($identifier,$url,$responseElement,$parameters=NULL){ |
|
| 109 | - return $this->submitOn("click", $identifier, $url, $responseElement,$parameters); |
|
| 108 | + public function submitOnClick($identifier, $url, $responseElement, $parameters=NULL) { |
|
| 109 | + return $this->submitOn("click", $identifier, $url, $responseElement, $parameters); |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | - public function addSubmit($identifier,$value,$cssStyle=NULL,$url=NULL,$responseElement=NULL,$parameters=NULL){ |
|
| 113 | - $bt=$this->getForm()->addButton($identifier, $value,$cssStyle); |
|
| 114 | - return $this->_buttonAsSubmit($bt, "click",$url,$responseElement,$parameters); |
|
| 112 | + public function addSubmit($identifier, $value, $cssStyle=NULL, $url=NULL, $responseElement=NULL, $parameters=NULL) { |
|
| 113 | + $bt=$this->getForm()->addButton($identifier, $value, $cssStyle); |
|
| 114 | + return $this->_buttonAsSubmit($bt, "click", $url, $responseElement, $parameters); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | - protected function _buttonAsSubmit(BaseHtml &$button,$event,$url,$responseElement=NULL,$parameters=NULL){ |
|
| 117 | + protected function _buttonAsSubmit(BaseHtml &$button, $event, $url, $responseElement=NULL, $parameters=NULL) { |
|
| 118 | 118 | $form=$this->getForm(); |
| 119 | - if(isset($url) && isset($responseElement)){ |
|
| 120 | - $button->addEvent($event, "$('#".$form->getIdentifier()."').form('validate form');",true,true); |
|
| 121 | - $this->setSubmitParams($url,$responseElement,$parameters); |
|
| 119 | + if (isset($url) && isset($responseElement)) { |
|
| 120 | + $button->addEvent($event, "$('#".$form->getIdentifier()."').form('validate form');", true, true); |
|
| 121 | + $this->setSubmitParams($url, $responseElement, $parameters); |
|
| 122 | 122 | } |
| 123 | 123 | return $button; |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | - public function setSubmitParams($url,$responseElement=NULL,$parameters=NULL){ |
|
| 126 | + public function setSubmitParams($url, $responseElement=NULL, $parameters=NULL) { |
|
| 127 | 127 | $form=$this->getForm(); |
| 128 | - $params=["form"=>$form->getIdentifier(),"responseElement"=>$responseElement,"url"=>$url,"stopPropagation"=>true]; |
|
| 129 | - if(\is_array($parameters)){ |
|
| 130 | - $params=\array_merge($params,$parameters); |
|
| 128 | + $params=["form"=>$form->getIdentifier(), "responseElement"=>$responseElement, "url"=>$url, "stopPropagation"=>true]; |
|
| 129 | + if (\is_array($parameters)) { |
|
| 130 | + $params=\array_merge($params, $parameters); |
|
| 131 | 131 | } |
| 132 | 132 | $form->addValidationParam("_ajaxSubmit", new AjaxCall("postForm", $params)); |
| 133 | 133 | return $this; |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | - public function addReset($identifier,$value,$cssStyle=NULL){ |
|
| 137 | - $bt=$this->getForm()->addButton($identifier, $value,$cssStyle); |
|
| 136 | + public function addReset($identifier, $value, $cssStyle=NULL) { |
|
| 137 | + $bt=$this->getForm()->addButton($identifier, $value, $cssStyle); |
|
| 138 | 138 | $bt->setProperty("type", "reset"); |
| 139 | 139 | return $bt; |
| 140 | 140 | } |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | * @param string $jsCode |
| 145 | 145 | * @return \Ajax\semantic\html\collections\form\HtmlForm |
| 146 | 146 | */ |
| 147 | - public function onValid($jsCode){ |
|
| 147 | + public function onValid($jsCode) { |
|
| 148 | 148 | $form=$this->getForm(); |
| 149 | 149 | $form->addValidationParam("onValid", "%function(){".$jsCode."}%"); |
| 150 | 150 | return $form; |
@@ -155,35 +155,35 @@ discard block |
||
| 155 | 155 | * @param string $jsCode can use event and fields parameters |
| 156 | 156 | * @return HtmlForm |
| 157 | 157 | */ |
| 158 | - public function onSuccess($jsCode){ |
|
| 158 | + public function onSuccess($jsCode) { |
|
| 159 | 159 | $form=$this->getForm(); |
| 160 | - $form->addValidationParam("onSuccess", $jsCode,"%function(event,fields){","}%"); |
|
| 160 | + $form->addValidationParam("onSuccess", $jsCode, "%function(event,fields){", "}%"); |
|
| 161 | 161 | return $form; |
| 162 | 162 | } |
| 163 | 163 | |
| 164 | - public function addExtraFieldRules($fieldname,$rules){ |
|
| 164 | + public function addExtraFieldRules($fieldname, $rules) { |
|
| 165 | 165 | $form=$this->getForm(); |
| 166 | 166 | $fv=$form->getExtraFieldValidation($fieldname); |
| 167 | - foreach ($rules as $rule){ |
|
| 167 | + foreach ($rules as $rule) { |
|
| 168 | 168 | $fv->addRule($rule); |
| 169 | 169 | } |
| 170 | 170 | } |
| 171 | 171 | |
| 172 | - public function addExtraFieldRule($fieldname,$type,$prompt=NULL,$value=NULL){ |
|
| 172 | + public function addExtraFieldRule($fieldname, $type, $prompt=NULL, $value=NULL) { |
|
| 173 | 173 | $form=$this->getForm(); |
| 174 | 174 | $fv=$form->getExtraFieldValidation($fieldname); |
| 175 | - $fv->addRule($type,$prompt,$value); |
|
| 175 | + $fv->addRule($type, $prompt, $value); |
|
| 176 | 176 | } |
| 177 | 177 | |
| 178 | - public function setOptional($fieldname,$optional=true){ |
|
| 178 | + public function setOptional($fieldname, $optional=true) { |
|
| 179 | 179 | $form=$this->getForm(); |
| 180 | 180 | $fv=$form->getExtraFieldValidation($fieldname); |
| 181 | 181 | $fv->setOptional($optional); |
| 182 | 182 | } |
| 183 | 183 | |
| 184 | - public function setActionTarget(string $action, string $target){ |
|
| 184 | + public function setActionTarget(string $action, string $target) { |
|
| 185 | 185 | $form=$this->getForm(); |
| 186 | - $form->setProperty('data-target',$target); |
|
| 187 | - $form->setProperty('action',$action); |
|
| 186 | + $form->setProperty('data-target', $target); |
|
| 187 | + $form->setProperty('action', $action); |
|
| 188 | 188 | } |
| 189 | 189 | } |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | * |
| 26 | 26 | */ |
| 27 | 27 | class DataTable extends Widget { |
| 28 | - use TableTrait,DataTableFieldAsTrait,HasCheckboxesTrait,BaseTrait; |
|
| 28 | + use TableTrait, DataTableFieldAsTrait, HasCheckboxesTrait, BaseTrait; |
|
| 29 | 29 | |
| 30 | 30 | protected $_searchField; |
| 31 | 31 | |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | |
| 42 | 42 | protected $_displayBehavior; |
| 43 | 43 | |
| 44 | - protected $_visibleHover = false; |
|
| 44 | + protected $_visibleHover=false; |
|
| 45 | 45 | |
| 46 | 46 | protected $_targetSelector; |
| 47 | 47 | |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | |
| 52 | 52 | protected $_json; |
| 53 | 53 | |
| 54 | - protected $_rowClass = "_element"; |
|
| 54 | + protected $_rowClass="_element"; |
|
| 55 | 55 | |
| 56 | 56 | protected $_sortable; |
| 57 | 57 | |
@@ -61,26 +61,26 @@ discard block |
||
| 61 | 61 | |
| 62 | 62 | protected $_paginationToolbar; |
| 63 | 63 | |
| 64 | - public function __construct($identifier, $model, $modelInstance = NULL) { |
|
| 64 | + public function __construct($identifier, $model, $modelInstance=NULL) { |
|
| 65 | 65 | parent::__construct($identifier, $model, $modelInstance); |
| 66 | 66 | $this->_init(new InstanceViewer($identifier), "table", new HtmlTable($identifier, 0, 0), false); |
| 67 | - $this->_urls = []; |
|
| 68 | - $this->_emptyMessage = new HtmlMessage("", "nothing to display"); |
|
| 67 | + $this->_urls=[]; |
|
| 68 | + $this->_emptyMessage=new HtmlMessage("", "nothing to display"); |
|
| 69 | 69 | $this->_emptyMessage->setIcon("info circle"); |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | public function run(JsUtils $js) { |
| 73 | - if ($this->_runned !== true) { |
|
| 74 | - $offset = $js->scriptCount(); |
|
| 73 | + if ($this->_runned!==true) { |
|
| 74 | + $offset=$js->scriptCount(); |
|
| 75 | 75 | if ($this->_hasCheckboxes && isset($js)) { |
| 76 | 76 | $this->_runCheckboxes($js); |
| 77 | 77 | } |
| 78 | 78 | if ($this->_visibleHover) { |
| 79 | - $js->execOn("mouseover", "#" . $this->identifier . " tr", "$(event.currentTarget).closest('tr').find('.visibleover').css('visibility', 'visible');", [ |
|
| 79 | + $js->execOn("mouseover", "#".$this->identifier." tr", "$(event.currentTarget).closest('tr').find('.visibleover').css('visibility', 'visible');", [ |
|
| 80 | 80 | "preventDefault" => false, |
| 81 | 81 | "stopPropagation" => true |
| 82 | 82 | ]); |
| 83 | - $js->execOn("mouseout", "#" . $this->identifier . " tr", "$(event.currentTarget).closest('tr').find('.visibleover').css('visibility', 'hidden');$(event.currentTarget).trigger('visibleoverOut');", [ |
|
| 83 | + $js->execOn("mouseout", "#".$this->identifier." tr", "$(event.currentTarget).closest('tr').find('.visibleover').css('visibility', 'hidden');$(event.currentTarget).trigger('visibleoverOut');", [ |
|
| 84 | 84 | "preventDefault" => false, |
| 85 | 85 | "stopPropagation" => true |
| 86 | 86 | ]); |
@@ -96,16 +96,16 @@ discard block |
||
| 96 | 96 | if (isset($this->_pagination)) |
| 97 | 97 | $this->_associatePaginationBehavior($js, $offset); |
| 98 | 98 | $this->_associateSearchFieldBehavior($js, $offset); |
| 99 | - $this->_runned = true; |
|
| 99 | + $this->_runned=true; |
|
| 100 | 100 | } |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | protected function _generateBehavior($op, $params, JsUtils $js) { |
| 104 | 104 | if (isset($this->_urls[$op])) { |
| 105 | - $params = \array_merge($params, [ |
|
| 105 | + $params=\array_merge($params, [ |
|
| 106 | 106 | "attr" => "data-ajax" |
| 107 | 107 | ]); |
| 108 | - $js->ajaxOnClick("#" . $this->identifier . " ._" . $op, $this->_urls[$op], $this->getTargetSelector($op), $params); |
|
| 108 | + $js->ajaxOnClick("#".$this->identifier." ._".$op, $this->_urls[$op], $this->getTargetSelector($op), $params); |
|
| 109 | 109 | } |
| 110 | 110 | } |
| 111 | 111 | |
@@ -124,21 +124,21 @@ discard block |
||
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | public function refreshTD($fieldName, $jquery, $view) { |
| 127 | - $index = $this->_getIndex($fieldName); |
|
| 127 | + $index=$this->_getIndex($fieldName); |
|
| 128 | 128 | $this->compile($jquery, $view); |
| 129 | 129 | return $this->refreshTR() |
| 130 | 130 | ->getTable() |
| 131 | 131 | ->getCell(0, $index); |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | - public function compile(JsUtils $js = NULL, &$view = NULL) { |
|
| 135 | - if (! $this->_generated) { |
|
| 134 | + public function compile(JsUtils $js=NULL, &$view=NULL) { |
|
| 135 | + if (!$this->_generated) { |
|
| 136 | 136 | if (isset($this->_buttonsColumn)) { |
| 137 | 137 | $this->_instanceViewer->sortColumnContent($this->_buttonsColumn, $this->_buttons); |
| 138 | 138 | } |
| 139 | 139 | $this->_instanceViewer->setInstance($this->_model); |
| 140 | - $captions = $this->_instanceViewer->getCaptions(); |
|
| 141 | - $table = $this->content["table"]; |
|
| 140 | + $captions=$this->_instanceViewer->getCaptions(); |
|
| 141 | + $table=$this->content["table"]; |
|
| 142 | 142 | if ($this->_hasCheckboxes) { |
| 143 | 143 | $this->_generateMainCheckbox($captions); |
| 144 | 144 | } |
@@ -153,14 +153,14 @@ discard block |
||
| 153 | 153 | $this->compileExtraElements($table, $captions); |
| 154 | 154 | $this->_compileSearchFieldBehavior($js); |
| 155 | 155 | |
| 156 | - $this->content = JArray::sortAssociative($this->content, [ |
|
| 156 | + $this->content=JArray::sortAssociative($this->content, [ |
|
| 157 | 157 | PositionInTable::BEFORETABLE, |
| 158 | 158 | "table", |
| 159 | 159 | PositionInTable::AFTERTABLE |
| 160 | 160 | ]); |
| 161 | 161 | $this->_compileForm(); |
| 162 | 162 | $this->_applyStyleAttributes($table); |
| 163 | - $this->_generated = true; |
|
| 163 | + $this->_generated=true; |
|
| 164 | 164 | } |
| 165 | 165 | return parent::compile($js, $view); |
| 166 | 166 | } |
@@ -205,21 +205,21 @@ discard block |
||
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | protected function _generateContent($table) { |
| 208 | - $objects = $this->_modelInstance; |
|
| 208 | + $objects=$this->_modelInstance; |
|
| 209 | 209 | if (isset($this->_pagination)) { |
| 210 | - $objects = $this->_pagination->getObjects($this->_modelInstance); |
|
| 210 | + $objects=$this->_pagination->getObjects($this->_modelInstance); |
|
| 211 | 211 | } |
| 212 | 212 | InstanceViewer::setIndex(0); |
| 213 | - $fields = $this->_instanceViewer->getSimpleProperties(); |
|
| 214 | - $groupByFields = $this->_instanceViewer->getGroupByFields(); |
|
| 215 | - if (! is_array($groupByFields)) { |
|
| 216 | - $table->fromDatabaseObjects($objects, function ($instance) use ($table, $fields) { |
|
| 213 | + $fields=$this->_instanceViewer->getSimpleProperties(); |
|
| 214 | + $groupByFields=$this->_instanceViewer->getGroupByFields(); |
|
| 215 | + if (!is_array($groupByFields)) { |
|
| 216 | + $table->fromDatabaseObjects($objects, function($instance) use ($table, $fields) { |
|
| 217 | 217 | return $this->_generateRow($instance, $fields, $table); |
| 218 | 218 | }); |
| 219 | 219 | } else { |
| 220 | - $activeValues = array_combine($groupByFields, array_fill(0, sizeof($groupByFields), null)); |
|
| 221 | - $uuids = []; |
|
| 222 | - $table->fromDatabaseObjects($objects, function ($instance) use ($table, $fields, &$activeValues, $groupByFields, &$uuids) { |
|
| 220 | + $activeValues=array_combine($groupByFields, array_fill(0, sizeof($groupByFields), null)); |
|
| 221 | + $uuids=[]; |
|
| 222 | + $table->fromDatabaseObjects($objects, function($instance) use ($table, $fields, &$activeValues, $groupByFields, &$uuids) { |
|
| 223 | 223 | $this->_instanceViewer->setInstance($instance); |
| 224 | 224 | foreach ($groupByFields as $index => $gbField) { |
| 225 | 225 | $this->_generateGroupByRow($index, $gbField, $table, $fields, $activeValues, $uuids); |
@@ -227,8 +227,8 @@ discard block |
||
| 227 | 227 | return $this->_generateRow($instance, $fields, $table, null, $uuids); |
| 228 | 228 | }); |
| 229 | 229 | } |
| 230 | - if ($table->getRowCount() == 0) { |
|
| 231 | - $result = $table->addRow(); |
|
| 230 | + if ($table->getRowCount()==0) { |
|
| 231 | + $result=$table->addRow(); |
|
| 232 | 232 | $result->mergeRow(); |
| 233 | 233 | $result->setValues([ |
| 234 | 234 | $this->_emptyMessage |
@@ -237,20 +237,20 @@ discard block |
||
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | protected function _generateGroupByRow($index, $gbField, $table, $fields, &$activeValues, &$uuids) { |
| 240 | - $newValue = $this->_instanceViewer->getValue($gbField); |
|
| 241 | - if ($this->getElementContent($activeValues[$gbField]) !== $this->getElementContent($newValue)) { |
|
| 242 | - if ($index == 0) { |
|
| 243 | - $uuids = []; |
|
| 240 | + $newValue=$this->_instanceViewer->getValue($gbField); |
|
| 241 | + if ($this->getElementContent($activeValues[$gbField])!==$this->getElementContent($newValue)) { |
|
| 242 | + if ($index==0) { |
|
| 243 | + $uuids=[]; |
|
| 244 | 244 | } |
| 245 | - $uuid = uniqid("grp"); |
|
| 246 | - $uuids[$gbField] = $uuid; |
|
| 247 | - $id = $this->_instanceViewer->getIdentifier(); |
|
| 248 | - $result = $table->addMergeRow(sizeof($fields) + 1, $newValue); |
|
| 249 | - $result->setIdentifier($this->identifier . "-tr-gb-" . $id); |
|
| 245 | + $uuid=uniqid("grp"); |
|
| 246 | + $uuids[$gbField]=$uuid; |
|
| 247 | + $id=$this->_instanceViewer->getIdentifier(); |
|
| 248 | + $result=$table->addMergeRow(sizeof($fields)+1, $newValue); |
|
| 249 | + $result->setIdentifier($this->identifier."-tr-gb-".$id); |
|
| 250 | 250 | $result->setProperty("data-ajax", $id); |
| 251 | 251 | $result->setProperty("data-group", $uuid); |
| 252 | 252 | $result->addToProperty("class", $this->_rowClass); |
| 253 | - $activeValues[$gbField] = $newValue; |
|
| 253 | + $activeValues[$gbField]=$newValue; |
|
| 254 | 254 | } |
| 255 | 255 | } |
| 256 | 256 | |
@@ -262,9 +262,9 @@ discard block |
||
| 262 | 262 | } |
| 263 | 263 | |
| 264 | 264 | public function getFieldValue($index) { |
| 265 | - $index = $this->_getIndex($index); |
|
| 265 | + $index=$this->_getIndex($index); |
|
| 266 | 266 | if (is_numeric($index)) { |
| 267 | - $values = $this->_instanceViewer->getValues(); |
|
| 267 | + $values=$this->_instanceViewer->getValues(); |
|
| 268 | 268 | if (isset($values[$index])) { |
| 269 | 269 | return $values[$index]; |
| 270 | 270 | } |
@@ -272,31 +272,31 @@ discard block |
||
| 272 | 272 | return null; |
| 273 | 273 | } |
| 274 | 274 | |
| 275 | - protected function _generateRow($instance, $fields, &$table, $checkedClass = null, $uuids = null) { |
|
| 275 | + protected function _generateRow($instance, $fields, &$table, $checkedClass=null, $uuids=null) { |
|
| 276 | 276 | $this->_instanceViewer->setInstance($instance); |
| 277 | - InstanceViewer::$index ++; |
|
| 278 | - $values = $this->_instanceViewer->getValues(); |
|
| 279 | - $id = $this->_instanceViewer->getIdentifier(); |
|
| 280 | - $dataAjax = $id; |
|
| 281 | - $id = $this->cleanIdentifier($id); |
|
| 277 | + InstanceViewer::$index++; |
|
| 278 | + $values=$this->_instanceViewer->getValues(); |
|
| 279 | + $id=$this->_instanceViewer->getIdentifier(); |
|
| 280 | + $dataAjax=$id; |
|
| 281 | + $id=$this->cleanIdentifier($id); |
|
| 282 | 282 | if ($this->_hasCheckboxes) { |
| 283 | - $ck = new HtmlCheckbox("ck-" . $this->identifier . "-" . $id, ""); |
|
| 284 | - $checked = false; |
|
| 283 | + $ck=new HtmlCheckbox("ck-".$this->identifier."-".$id, ""); |
|
| 284 | + $checked=false; |
|
| 285 | 285 | if (isset($this->_checkedCallback)) { |
| 286 | - $func = $this->_checkedCallback; |
|
| 287 | - $checked = $func($instance); |
|
| 286 | + $func=$this->_checkedCallback; |
|
| 287 | + $checked=$func($instance); |
|
| 288 | 288 | } |
| 289 | 289 | $ck->setChecked($checked); |
| 290 | 290 | // $ck->setOnChange("event.stopPropagation();"); |
| 291 | - $field = $ck->getField(); |
|
| 291 | + $field=$ck->getField(); |
|
| 292 | 292 | $field->setProperty("value", $dataAjax); |
| 293 | 293 | $field->setProperty("name", "selection[]"); |
| 294 | 294 | if (isset($checkedClass)) |
| 295 | 295 | $field->setClass($checkedClass); |
| 296 | 296 | \array_unshift($values, $ck); |
| 297 | 297 | } |
| 298 | - $result = $table->newRow(); |
|
| 299 | - $result->setIdentifier($this->identifier . "-tr-" . $id); |
|
| 298 | + $result=$table->newRow(); |
|
| 299 | + $result->setIdentifier($this->identifier."-tr-".$id); |
|
| 300 | 300 | $result->setProperty("data-ajax", $dataAjax); |
| 301 | 301 | $result->setValues($values); |
| 302 | 302 | $result->addToProperty("class", $this->_rowClass); |
@@ -309,63 +309,63 @@ discard block |
||
| 309 | 309 | |
| 310 | 310 | protected function _generatePagination($table) { |
| 311 | 311 | if (isset($this->_toolbar)) { |
| 312 | - if ($this->_toolbarPosition == PositionInTable::FOOTER) |
|
| 312 | + if ($this->_toolbarPosition==PositionInTable::FOOTER) |
|
| 313 | 313 | $this->_toolbar->setFloated("left"); |
| 314 | 314 | } |
| 315 | - $footer = $table->getFooter(); |
|
| 315 | + $footer=$table->getFooter(); |
|
| 316 | 316 | $footer->mergeCol(); |
| 317 | - $this->_paginationToolbar = $this->_pagination->generateMenu($this->identifier); |
|
| 317 | + $this->_paginationToolbar=$this->_pagination->generateMenu($this->identifier); |
|
| 318 | 318 | $footer->addValues($this->_paginationToolbar); |
| 319 | 319 | } |
| 320 | 320 | |
| 321 | - protected function _associatePaginationBehavior(JsUtils $js = NULL, $offset = null) { |
|
| 321 | + protected function _associatePaginationBehavior(JsUtils $js=NULL, $offset=null) { |
|
| 322 | 322 | if (isset($this->_urls["refresh"])) { |
| 323 | - $menu = $this->_pagination->getMenu(); |
|
| 323 | + $menu=$this->_pagination->getMenu(); |
|
| 324 | 324 | if (isset($menu) && isset($js)) { |
| 325 | - $js->postOnClick("#" . $menu->getIdentifier() . " .item", $this->_urls["refresh"], "{'p':$(this).attr('data-page'),'_model':'" . JString::doubleBackSlashes($this->_model) . "'}", $this->getRefreshSelector(), [ |
|
| 325 | + $js->postOnClick("#".$menu->getIdentifier()." .item", $this->_urls["refresh"], "{'p':$(this).attr('data-page'),'_model':'".JString::doubleBackSlashes($this->_model)."'}", $this->getRefreshSelector(), [ |
|
| 326 | 326 | "preventDefault" => false, |
| 327 | 327 | "jqueryDone" => "replaceWith", |
| 328 | 328 | "hasLoader" => false, |
| 329 | - "jsCallback" => '$("#' . $this->identifier . '").trigger("pageChange");$("#' . $this->identifier . '").trigger("activeRowChange");' |
|
| 329 | + "jsCallback" => '$("#'.$this->identifier.'").trigger("pageChange");$("#'.$this->identifier.'").trigger("activeRowChange");' |
|
| 330 | 330 | ]); |
| 331 | - $page = $_POST["p"] ?? null; |
|
| 331 | + $page=$_POST["p"] ?? null; |
|
| 332 | 332 | if (isset($page)) { |
| 333 | - $js->execAtLast('$("#' . $this->getIdentifier() . ' .pagination").children("a.item").removeClass("active");$("#' . $this->getIdentifier() . ' .pagination").children("a.item[data-page=' . $page . ']:not(.no-active)").addClass("active");'); |
|
| 333 | + $js->execAtLast('$("#'.$this->getIdentifier().' .pagination").children("a.item").removeClass("active");$("#'.$this->getIdentifier().' .pagination").children("a.item[data-page='.$page.']:not(.no-active)").addClass("active");'); |
|
| 334 | 334 | } |
| 335 | 335 | } |
| 336 | 336 | } |
| 337 | 337 | } |
| 338 | 338 | |
| 339 | - protected function _compileSearchFieldBehavior(JsUtils $js = NULL) { |
|
| 339 | + protected function _compileSearchFieldBehavior(JsUtils $js=NULL) { |
|
| 340 | 340 | if (isset($this->_searchField) && isset($js) && isset($this->_urls["refresh"])) { |
| 341 | - $this->_searchField->postOn("change", $this->_urls["refresh"], "{'s':$(self).val(),'_model':'" . JString::doubleBackSlashes($this->_model) . "'}", "#" . $this->identifier . " tbody", [ |
|
| 341 | + $this->_searchField->postOn("change", $this->_urls["refresh"], "{'s':$(self).val(),'_model':'".JString::doubleBackSlashes($this->_model)."'}", "#".$this->identifier." tbody", [ |
|
| 342 | 342 | "preventDefault" => false, |
| 343 | 343 | "jqueryDone" => "replaceWith", |
| 344 | 344 | "hasLoader" => "internal", |
| 345 | - "jsCallback" => '$("#' . $this->identifier . '").trigger("searchTerminate",[$(self).val()]);' |
|
| 345 | + "jsCallback" => '$("#'.$this->identifier.'").trigger("searchTerminate",[$(self).val()]);' |
|
| 346 | 346 | ]); |
| 347 | 347 | } |
| 348 | 348 | } |
| 349 | 349 | |
| 350 | - protected function _associateSearchFieldBehavior(JsUtils $js = NULL, $offset = null) {} |
|
| 350 | + protected function _associateSearchFieldBehavior(JsUtils $js=NULL, $offset=null) {} |
|
| 351 | 351 | |
| 352 | 352 | protected function _getFieldName($index) { |
| 353 | - $fieldName = parent::_getFieldName($index); |
|
| 353 | + $fieldName=parent::_getFieldName($index); |
|
| 354 | 354 | if (\is_object($fieldName)) |
| 355 | - $fieldName = "field-" . $index; |
|
| 356 | - return $fieldName . "[]"; |
|
| 355 | + $fieldName="field-".$index; |
|
| 356 | + return $fieldName."[]"; |
|
| 357 | 357 | } |
| 358 | 358 | |
| 359 | 359 | protected function _getFieldCaption($index) { |
| 360 | 360 | return null; |
| 361 | 361 | } |
| 362 | 362 | |
| 363 | - protected function applyToolbarPosition(string $position, $table, $captions = NULL) { |
|
| 363 | + protected function applyToolbarPosition(string $position, $table, $captions=NULL) { |
|
| 364 | 364 | switch ($position) { |
| 365 | 365 | case PositionInTable::BEFORETABLE: |
| 366 | 366 | case PositionInTable::AFTERTABLE: |
| 367 | - if (isset($this->_compileParts) === false) { |
|
| 368 | - $this->content[$position] = $this->_toolbar; |
|
| 367 | + if (isset($this->_compileParts)===false) { |
|
| 368 | + $this->content[$position]=$this->_toolbar; |
|
| 369 | 369 | } |
| 370 | 370 | break; |
| 371 | 371 | case PositionInTable::HEADER: |
@@ -376,7 +376,7 @@ discard block |
||
| 376 | 376 | } |
| 377 | 377 | } |
| 378 | 378 | |
| 379 | - protected function _setToolbarPosition($table, $captions = NULL) { |
|
| 379 | + protected function _setToolbarPosition($table, $captions=NULL) { |
|
| 380 | 380 | if (\is_array($this->_toolbarPosition)) { |
| 381 | 381 | foreach ($this->_toolbarPosition as $tbp) { |
| 382 | 382 | $this->applyToolbarPosition($tbp, $table, $captions); |
@@ -402,11 +402,11 @@ discard block |
||
| 402 | 402 | } |
| 403 | 403 | |
| 404 | 404 | private function addToolbarRow($part, $table, $captions) { |
| 405 | - $hasPart = $table->hasPart($part); |
|
| 405 | + $hasPart=$table->hasPart($part); |
|
| 406 | 406 | if ($hasPart) { |
| 407 | - $row = $table->getPart($part)->addRow(\sizeof($captions)); |
|
| 407 | + $row=$table->getPart($part)->addRow(\sizeof($captions)); |
|
| 408 | 408 | } else { |
| 409 | - $row = $table->getPart($part)->getRow(0); |
|
| 409 | + $row=$table->getPart($part)->getRow(0); |
|
| 410 | 410 | } |
| 411 | 411 | $row->mergeCol(); |
| 412 | 412 | $row->setValues([ |
@@ -438,12 +438,12 @@ discard block |
||
| 438 | 438 | */ |
| 439 | 439 | public function setUrls($urls) { |
| 440 | 440 | if (\is_array($urls)) { |
| 441 | - $this->_urls["refresh"] = JArray::getValue($urls, "refresh", 0); |
|
| 442 | - $this->_urls["edit"] = JArray::getValue($urls, "edit", 1); |
|
| 443 | - $this->_urls["delete"] = JArray::getValue($urls, "delete", 2); |
|
| 444 | - $this->_urls["display"] = JArray::getValue($urls, "display", 3); |
|
| 441 | + $this->_urls["refresh"]=JArray::getValue($urls, "refresh", 0); |
|
| 442 | + $this->_urls["edit"]=JArray::getValue($urls, "edit", 1); |
|
| 443 | + $this->_urls["delete"]=JArray::getValue($urls, "delete", 2); |
|
| 444 | + $this->_urls["display"]=JArray::getValue($urls, "display", 3); |
|
| 445 | 445 | } else { |
| 446 | - $this->_urls = [ |
|
| 446 | + $this->_urls=[ |
|
| 447 | 447 | "refresh" => $urls, |
| 448 | 448 | "edit" => $urls, |
| 449 | 449 | "delete" => $urls, |
@@ -466,8 +466,8 @@ discard block |
||
| 466 | 466 | * The number of visible pages in the Pagination component |
| 467 | 467 | * @return DataTable |
| 468 | 468 | */ |
| 469 | - public function paginate($page, $total_rowcount, $items_per_page = 10, $pages_visibles = null) { |
|
| 470 | - $this->_pagination = new Pagination($items_per_page, $pages_visibles, $page, $total_rowcount); |
|
| 469 | + public function paginate($page, $total_rowcount, $items_per_page=10, $pages_visibles=null) { |
|
| 470 | + $this->_pagination=new Pagination($items_per_page, $pages_visibles, $page, $total_rowcount); |
|
| 471 | 471 | return $this; |
| 472 | 472 | } |
| 473 | 473 | |
@@ -482,8 +482,8 @@ discard block |
||
| 482 | 482 | * The number of visible pages in the Pagination component |
| 483 | 483 | * @return DataTable |
| 484 | 484 | */ |
| 485 | - public function autoPaginate($page = 1, $items_per_page = 10, $pages_visibles = 4) { |
|
| 486 | - $this->_pagination = new Pagination($items_per_page, $pages_visibles, $page); |
|
| 485 | + public function autoPaginate($page=1, $items_per_page=10, $pages_visibles=4) { |
|
| 486 | + $this->_pagination=new Pagination($items_per_page, $pages_visibles, $page); |
|
| 487 | 487 | return $this; |
| 488 | 488 | } |
| 489 | 489 | |
@@ -492,10 +492,10 @@ discard block |
||
| 492 | 492 | * @param array $compileParts |
| 493 | 493 | * @return DataTable |
| 494 | 494 | */ |
| 495 | - public function refresh($compileParts = [ |
|
| 495 | + public function refresh($compileParts=[ |
|
| 496 | 496 | 'tbody' |
| 497 | 497 | ]) { |
| 498 | - $this->_compileParts = $compileParts; |
|
| 498 | + $this->_compileParts=$compileParts; |
|
| 499 | 499 | return $this; |
| 500 | 500 | } |
| 501 | 501 | |
@@ -505,14 +505,14 @@ discard block |
||
| 505 | 505 | * @param string $position |
| 506 | 506 | * @return \Ajax\common\html\HtmlDoubleElement |
| 507 | 507 | */ |
| 508 | - public function addSearchInToolbar($position = Direction::RIGHT) { |
|
| 508 | + public function addSearchInToolbar($position=Direction::RIGHT) { |
|
| 509 | 509 | return $this->addInToolbar($this->getSearchField()) |
| 510 | 510 | ->setPosition($position); |
| 511 | 511 | } |
| 512 | 512 | |
| 513 | 513 | public function getSearchField() { |
| 514 | - if (isset($this->_searchField) === false) { |
|
| 515 | - $this->_searchField = new HtmlInput("search-" . $this->identifier, "search", "", "Search..."); |
|
| 514 | + if (isset($this->_searchField)===false) { |
|
| 515 | + $this->_searchField=new HtmlInput("search-".$this->identifier, "search", "", "Search..."); |
|
| 516 | 516 | $this->_searchField->addIcon("search", Direction::RIGHT); |
| 517 | 517 | } |
| 518 | 518 | return $this->_searchField; |
@@ -540,9 +540,9 @@ discard block |
||
| 540 | 540 | } |
| 541 | 541 | |
| 542 | 542 | protected function getTargetSelector($op) { |
| 543 | - $result = $this->_targetSelector; |
|
| 544 | - if (! isset($result[$op])) |
|
| 545 | - $result = "#" . $this->identifier; |
|
| 543 | + $result=$this->_targetSelector; |
|
| 544 | + if (!isset($result[$op])) |
|
| 545 | + $result="#".$this->identifier; |
|
| 546 | 546 | return $result[$op]; |
| 547 | 547 | } |
| 548 | 548 | |
@@ -554,20 +554,20 @@ discard block |
||
| 554 | 554 | * @return DataTable |
| 555 | 555 | */ |
| 556 | 556 | public function setTargetSelector($_targetSelector) { |
| 557 | - if (! \is_array($_targetSelector)) { |
|
| 558 | - $_targetSelector = [ |
|
| 557 | + if (!\is_array($_targetSelector)) { |
|
| 558 | + $_targetSelector=[ |
|
| 559 | 559 | "edit" => $_targetSelector, |
| 560 | 560 | "delete" => $_targetSelector |
| 561 | 561 | ]; |
| 562 | 562 | } |
| 563 | - $this->_targetSelector = $_targetSelector; |
|
| 563 | + $this->_targetSelector=$_targetSelector; |
|
| 564 | 564 | return $this; |
| 565 | 565 | } |
| 566 | 566 | |
| 567 | 567 | public function getRefreshSelector() { |
| 568 | 568 | if (isset($this->_refreshSelector)) |
| 569 | 569 | return $this->_refreshSelector; |
| 570 | - return "#" . $this->identifier . " tbody"; |
|
| 570 | + return "#".$this->identifier." tbody"; |
|
| 571 | 571 | } |
| 572 | 572 | |
| 573 | 573 | /** |
@@ -576,7 +576,7 @@ discard block |
||
| 576 | 576 | * @return DataTable |
| 577 | 577 | */ |
| 578 | 578 | public function setRefreshSelector($_refreshSelector) { |
| 579 | - $this->_refreshSelector = $_refreshSelector; |
|
| 579 | + $this->_refreshSelector=$_refreshSelector; |
|
| 580 | 580 | return $this; |
| 581 | 581 | } |
| 582 | 582 | |
@@ -588,9 +588,9 @@ discard block |
||
| 588 | 588 | public function show($modelInstance) { |
| 589 | 589 | if (\is_array($modelInstance)) { |
| 590 | 590 | if (isset($modelInstance[0]) && \is_array(array_values($modelInstance)[0])) |
| 591 | - $modelInstance = \json_decode(\json_encode($modelInstance), FALSE); |
|
| 591 | + $modelInstance=\json_decode(\json_encode($modelInstance), FALSE); |
|
| 592 | 592 | } |
| 593 | - $this->_modelInstance = $modelInstance; |
|
| 593 | + $this->_modelInstance=$modelInstance; |
|
| 594 | 594 | } |
| 595 | 595 | |
| 596 | 596 | public function getRowClass() { |
@@ -604,7 +604,7 @@ discard block |
||
| 604 | 604 | * @return DataTable |
| 605 | 605 | */ |
| 606 | 606 | public function setRowClass($_rowClass) { |
| 607 | - $this->_rowClass = $_rowClass; |
|
| 607 | + $this->_rowClass=$_rowClass; |
|
| 608 | 608 | return $this; |
| 609 | 609 | } |
| 610 | 610 | |
@@ -615,16 +615,16 @@ discard block |
||
| 615 | 615 | * @return DataTable |
| 616 | 616 | */ |
| 617 | 617 | public function setEmptyMessage($_emptyMessage) { |
| 618 | - $this->_emptyMessage = $_emptyMessage; |
|
| 618 | + $this->_emptyMessage=$_emptyMessage; |
|
| 619 | 619 | return $this; |
| 620 | 620 | } |
| 621 | 621 | |
| 622 | - public function setSortable($colIndex = NULL) { |
|
| 623 | - $this->_sortable = $colIndex; |
|
| 622 | + public function setSortable($colIndex=NULL) { |
|
| 623 | + $this->_sortable=$colIndex; |
|
| 624 | 624 | return $this; |
| 625 | 625 | } |
| 626 | 626 | |
| 627 | - public function setActiveRowSelector($class = "active", $event = "click", $multiple = false) { |
|
| 627 | + public function setActiveRowSelector($class="active", $event="click", $multiple=false) { |
|
| 628 | 628 | $this->_self->setActiveRowSelector($class, $event, $multiple); |
| 629 | 629 | return $this; |
| 630 | 630 | } |
@@ -634,19 +634,19 @@ discard block |
||
| 634 | 634 | } |
| 635 | 635 | |
| 636 | 636 | public function hideColumn($colIndex) { |
| 637 | - if (! \is_array($this->_hiddenColumns)) |
|
| 638 | - $this->_hiddenColumns = []; |
|
| 639 | - $this->_hiddenColumns[] = $colIndex; |
|
| 637 | + if (!\is_array($this->_hiddenColumns)) |
|
| 638 | + $this->_hiddenColumns=[]; |
|
| 639 | + $this->_hiddenColumns[]=$colIndex; |
|
| 640 | 640 | return $this; |
| 641 | 641 | } |
| 642 | 642 | |
| 643 | 643 | public function setColWidth($colIndex, $width) { |
| 644 | - $this->_colWidths[$colIndex] = $width; |
|
| 644 | + $this->_colWidths[$colIndex]=$width; |
|
| 645 | 645 | return $this; |
| 646 | 646 | } |
| 647 | 647 | |
| 648 | 648 | public function setColWidths($_colWidths) { |
| 649 | - $this->_colWidths = $_colWidths; |
|
| 649 | + $this->_colWidths=$_colWidths; |
|
| 650 | 650 | return $this; |
| 651 | 651 | } |
| 652 | 652 | |
@@ -655,7 +655,7 @@ discard block |
||
| 655 | 655 | return $this; |
| 656 | 656 | } |
| 657 | 657 | |
| 658 | - public function trigger($event, $params = "[]") { |
|
| 658 | + public function trigger($event, $params="[]") { |
|
| 659 | 659 | return $this->getHtmlComponent()->trigger($event, $params); |
| 660 | 660 | } |
| 661 | 661 | |
@@ -693,7 +693,7 @@ discard block |
||
| 693 | 693 | * @param mixed $_displayBehavior |
| 694 | 694 | */ |
| 695 | 695 | public function setDisplayBehavior($_displayBehavior) { |
| 696 | - $this->_displayBehavior = $_displayBehavior; |
|
| 696 | + $this->_displayBehavior=$_displayBehavior; |
|
| 697 | 697 | } |
| 698 | 698 | |
| 699 | 699 | /** |
@@ -712,9 +712,9 @@ discard block |
||
| 712 | 712 | $this->_instanceViewer->setGroupByFields($_groupByFields); |
| 713 | 713 | } |
| 714 | 714 | |
| 715 | - public function addGroupBy($index){ |
|
| 716 | - $index = $this->_getIndex($index); |
|
| 717 | - if ($index !== false) { |
|
| 715 | + public function addGroupBy($index) { |
|
| 716 | + $index=$this->_getIndex($index); |
|
| 717 | + if ($index!==false) { |
|
| 718 | 718 | $this->_instanceViewer->addGroupBy($index); |
| 719 | 719 | } |
| 720 | 720 | } |
@@ -724,7 +724,7 @@ discard block |
||
| 724 | 724 | * @param boolean $_visibleHover |
| 725 | 725 | */ |
| 726 | 726 | public function setVisibleHover($_visibleHover) { |
| 727 | - $this->_visibleHover = $_visibleHover; |
|
| 727 | + $this->_visibleHover=$_visibleHover; |
|
| 728 | 728 | } |
| 729 | 729 | |
| 730 | 730 | /** |
@@ -735,7 +735,7 @@ discard block |
||
| 735 | 735 | return $this->_paginationToolbar; |
| 736 | 736 | } |
| 737 | 737 | |
| 738 | - public function setInverted($recursive = true) { |
|
| 738 | + public function setInverted($recursive=true) { |
|
| 739 | 739 | $this->getHtmlComponent()->setInverted($recursive); |
| 740 | 740 | if ($this->_emptyMessage instanceof HtmlSemDoubleElement) { |
| 741 | 741 | $this->_emptyMessage->setInverted($recursive); |
@@ -29,17 +29,17 @@ discard block |
||
| 29 | 29 | |
| 30 | 30 | protected $groupByFields; |
| 31 | 31 | |
| 32 | - public static $index = 0; |
|
| 32 | + public static $index=0; |
|
| 33 | 33 | |
| 34 | - public function __construct($identifier, $instance = NULL, $captions = NULL) { |
|
| 35 | - $this->widgetIdentifier = $identifier; |
|
| 36 | - $this->values = []; |
|
| 37 | - $this->afterCompile = []; |
|
| 34 | + public function __construct($identifier, $instance=NULL, $captions=NULL) { |
|
| 35 | + $this->widgetIdentifier=$identifier; |
|
| 36 | + $this->values=[]; |
|
| 37 | + $this->afterCompile=[]; |
|
| 38 | 38 | if (isset($instance)) |
| 39 | 39 | $this->setInstance($instance); |
| 40 | 40 | $this->setCaptions($captions); |
| 41 | - $this->captionCallback = NULL; |
|
| 42 | - $this->defaultValueFunction = function ($name, $value) { |
|
| 41 | + $this->captionCallback=NULL; |
|
| 42 | + $this->defaultValueFunction=function($name, $value) { |
|
| 43 | 43 | return $value; |
| 44 | 44 | }; |
| 45 | 45 | } |
@@ -66,47 +66,47 @@ discard block |
||
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | public function getValues() { |
| 69 | - $values = []; |
|
| 70 | - $index = 0; |
|
| 71 | - $count = $this->count(); |
|
| 72 | - $hasGroupby = is_array($this->groupByFields); |
|
| 73 | - if (! $hasGroupby) { |
|
| 74 | - while ($index < $count) { |
|
| 75 | - $values[] = $this->getValue($index ++); |
|
| 69 | + $values=[]; |
|
| 70 | + $index=0; |
|
| 71 | + $count=$this->count(); |
|
| 72 | + $hasGroupby=is_array($this->groupByFields); |
|
| 73 | + if (!$hasGroupby) { |
|
| 74 | + while ($index<$count) { |
|
| 75 | + $values[]=$this->getValue($index++); |
|
| 76 | 76 | } |
| 77 | 77 | } else { |
| 78 | - while ($index < $count) { |
|
| 79 | - if (array_search($index, $this->groupByFields) === false) { |
|
| 80 | - $values[] = $this->getValue($index); |
|
| 78 | + while ($index<$count) { |
|
| 79 | + if (array_search($index, $this->groupByFields)===false) { |
|
| 80 | + $values[]=$this->getValue($index); |
|
| 81 | 81 | } |
| 82 | - $index ++; |
|
| 82 | + $index++; |
|
| 83 | 83 | } |
| 84 | 84 | } |
| 85 | 85 | return $values; |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | - public function getIdentifier($index = NULL) { |
|
| 89 | - if (! isset($index)) |
|
| 90 | - $index = self::$index; |
|
| 91 | - $value = $index; |
|
| 88 | + public function getIdentifier($index=NULL) { |
|
| 89 | + if (!isset($index)) |
|
| 90 | + $index=self::$index; |
|
| 91 | + $value=$index; |
|
| 92 | 92 | if (isset($this->values["identifier"])) { |
| 93 | 93 | if (\is_string($this->values["identifier"])) |
| 94 | - $value = JReflection::callMethod($this->instance, $this->values["identifier"], []); |
|
| 94 | + $value=JReflection::callMethod($this->instance, $this->values["identifier"], []); |
|
| 95 | 95 | else |
| 96 | - $value = $this->values["identifier"]($index, $this->instance); |
|
| 96 | + $value=$this->values["identifier"]($index, $this->instance); |
|
| 97 | 97 | } |
| 98 | 98 | return $value; |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | public function getValue($index) { |
| 102 | - $property = $this->properties[$index]; |
|
| 102 | + $property=$this->properties[$index]; |
|
| 103 | 103 | return $this->_getValue($property, $index); |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | protected function _beforeAddProperty($index, &$field) {} |
| 107 | 107 | |
| 108 | 108 | protected function _getDefaultValue($name, $value, $index) { |
| 109 | - $func = $this->defaultValueFunction; |
|
| 109 | + $func=$this->defaultValueFunction; |
|
| 110 | 110 | return $func($name, $value, $index, $this->instance); |
| 111 | 111 | } |
| 112 | 112 | |
@@ -116,27 +116,27 @@ discard block |
||
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | protected function _getValue($property, $index) { |
| 119 | - $value = null; |
|
| 120 | - $propertyName = $property; |
|
| 119 | + $value=null; |
|
| 120 | + $propertyName=$property; |
|
| 121 | 121 | if ($property instanceof \ReflectionProperty) { |
| 122 | - $value = $this->_getPropertyValue($property); |
|
| 123 | - $propertyName = $property->getName(); |
|
| 124 | - } elseif (\is_callable($property) && \array_search($property, ['system','date']) === false){ |
|
| 125 | - try{ |
|
| 126 | - $value = $property($this->instance); |
|
| 127 | - }catch(\Error $e){} |
|
| 122 | + $value=$this->_getPropertyValue($property); |
|
| 123 | + $propertyName=$property->getName(); |
|
| 124 | + } elseif (\is_callable($property) && \array_search($property, ['system', 'date'])===false) { |
|
| 125 | + try { |
|
| 126 | + $value=$property($this->instance); |
|
| 127 | + }catch (\Error $e) {} |
|
| 128 | 128 | } |
| 129 | 129 | elseif (\is_array($property)) { |
| 130 | - $values = \array_map(function ($v) use ($index) { |
|
| 130 | + $values=\array_map(function($v) use ($index) { |
|
| 131 | 131 | return $this->_getValue($v, $index); |
| 132 | 132 | }, $property); |
| 133 | - $value = \implode('', $values); |
|
| 133 | + $value=\implode('', $values); |
|
| 134 | 134 | } elseif (\is_string($property)) { |
| 135 | - $value = ''; |
|
| 135 | + $value=''; |
|
| 136 | 136 | if (isset($this->instance->{$property})) { |
| 137 | - $value = $this->instance->{$property}; |
|
| 138 | - } elseif (\method_exists($this->instance, $getter = JReflection::getterName($property))) { |
|
| 139 | - $value = JReflection::callMethod($this->instance, $getter, []); |
|
| 137 | + $value=$this->instance->{$property}; |
|
| 138 | + } elseif (\method_exists($this->instance, $getter=JReflection::getterName($property))) { |
|
| 139 | + $value=JReflection::callMethod($this->instance, $getter, []); |
|
| 140 | 140 | } |
| 141 | 141 | } |
| 142 | 142 | |
@@ -145,9 +145,9 @@ discard block |
||
| 145 | 145 | |
| 146 | 146 | protected function _postGetValue($index, $propertyName, $value) { |
| 147 | 147 | if (isset($this->values[$index])) { |
| 148 | - $value = $this->values[$index]($value, $this->instance, $index, self::$index); |
|
| 148 | + $value=$this->values[$index]($value, $this->instance, $index, self::$index); |
|
| 149 | 149 | } else { |
| 150 | - $value = $this->_getDefaultValue($propertyName, $value, $index); |
|
| 150 | + $value=$this->_getDefaultValue($propertyName, $value, $index); |
|
| 151 | 151 | } |
| 152 | 152 | if (isset($this->afterCompile[$index])) { |
| 153 | 153 | if (\is_callable($this->afterCompile[$index])) { |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | return $value; |
| 158 | 158 | } |
| 159 | 159 | |
| 160 | - public function insertField($index, $field, $key = null) { |
|
| 160 | + public function insertField($index, $field, $key=null) { |
|
| 161 | 161 | if (isset($key)) { |
| 162 | 162 | array_splice($this->visibleProperties, $index, 0, [ |
| 163 | 163 | $key => $field |
@@ -171,29 +171,29 @@ discard block |
||
| 171 | 171 | public function sortColumnContent($index, $array) { |
| 172 | 172 | if (isset($this->visibleProperties[$index])) { |
| 173 | 173 | if (is_array($this->visibleProperties[$index])) { |
| 174 | - $this->visibleProperties[$index] = JArray::sortAssociative($this->visibleProperties[$index], $array); |
|
| 174 | + $this->visibleProperties[$index]=JArray::sortAssociative($this->visibleProperties[$index], $array); |
|
| 175 | 175 | } |
| 176 | 176 | } |
| 177 | 177 | return $this; |
| 178 | 178 | } |
| 179 | 179 | |
| 180 | - public function insertInField($index, $field, $key = null) { |
|
| 181 | - $vb = $this->visibleProperties; |
|
| 180 | + public function insertInField($index, $field, $key=null) { |
|
| 181 | + $vb=$this->visibleProperties; |
|
| 182 | 182 | if (isset($vb[$index])) { |
| 183 | 183 | if (isset($key)) { |
| 184 | 184 | if (\is_array($vb[$index])) { |
| 185 | - $this->visibleProperties[$index][$key] = $field; |
|
| 185 | + $this->visibleProperties[$index][$key]=$field; |
|
| 186 | 186 | } else { |
| 187 | - $this->visibleProperties[$index] = [ |
|
| 187 | + $this->visibleProperties[$index]=[ |
|
| 188 | 188 | $vb[$index], |
| 189 | 189 | $key => $field |
| 190 | 190 | ]; |
| 191 | 191 | } |
| 192 | 192 | } else { |
| 193 | 193 | if (\is_array($vb[$index])) { |
| 194 | - $this->visibleProperties[$index][] = $field; |
|
| 194 | + $this->visibleProperties[$index][]=$field; |
|
| 195 | 195 | } else { |
| 196 | - $this->visibleProperties[$index] = [ |
|
| 196 | + $this->visibleProperties[$index]=[ |
|
| 197 | 197 | $vb[$index], |
| 198 | 198 | $field |
| 199 | 199 | ]; |
@@ -205,19 +205,19 @@ discard block |
||
| 205 | 205 | return $this; |
| 206 | 206 | } |
| 207 | 207 | |
| 208 | - public function addField($field, $key = null) { |
|
| 208 | + public function addField($field, $key=null) { |
|
| 209 | 209 | if (isset($key)) { |
| 210 | - $this->visibleProperties[] = [ |
|
| 210 | + $this->visibleProperties[]=[ |
|
| 211 | 211 | $key => $field |
| 212 | 212 | ]; |
| 213 | 213 | } else { |
| 214 | - $this->visibleProperties[] = $field; |
|
| 214 | + $this->visibleProperties[]=$field; |
|
| 215 | 215 | } |
| 216 | 216 | return $this; |
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | public function addFields($fields) { |
| 220 | - $this->visibleProperties = \array_merge($this->visibleProperties, $fields); |
|
| 220 | + $this->visibleProperties=\array_merge($this->visibleProperties, $fields); |
|
| 221 | 221 | return $this; |
| 222 | 222 | } |
| 223 | 223 | |
@@ -234,30 +234,30 @@ discard block |
||
| 234 | 234 | } |
| 235 | 235 | |
| 236 | 236 | public function getFieldName($index) { |
| 237 | - $property = $this->getProperty($index); |
|
| 237 | + $property=$this->getProperty($index); |
|
| 238 | 238 | if ($property instanceof \ReflectionProperty) { |
| 239 | - $result = $property->getName(); |
|
| 239 | + $result=$property->getName(); |
|
| 240 | 240 | } elseif (\is_callable($property)) { |
| 241 | - $result = $this->visibleProperties[$index]; |
|
| 241 | + $result=$this->visibleProperties[$index]; |
|
| 242 | 242 | } else { |
| 243 | - $result = $property; |
|
| 243 | + $result=$property; |
|
| 244 | 244 | } |
| 245 | 245 | return $result; |
| 246 | 246 | } |
| 247 | 247 | |
| 248 | 248 | protected function showableProperty(\ReflectionProperty $rProperty) { |
| 249 | - return JString::startswith($rProperty->getName(), "_") === false; |
|
| 249 | + return JString::startswith($rProperty->getName(), "_")===false; |
|
| 250 | 250 | } |
| 251 | 251 | |
| 252 | 252 | public function setInstance($instance) { |
| 253 | 253 | if (\is_string($instance)) { |
| 254 | - $instance = new $instance(); |
|
| 254 | + $instance=new $instance(); |
|
| 255 | 255 | } |
| 256 | - $this->instance = $instance; |
|
| 257 | - $this->properties = []; |
|
| 258 | - $this->reflect = new \ReflectionClass($instance); |
|
| 259 | - if (JArray::count($this->visibleProperties) === 0) { |
|
| 260 | - $this->properties = $this->getDefaultProperties(); |
|
| 256 | + $this->instance=$instance; |
|
| 257 | + $this->properties=[]; |
|
| 258 | + $this->reflect=new \ReflectionClass($instance); |
|
| 259 | + if (JArray::count($this->visibleProperties)===0) { |
|
| 260 | + $this->properties=$this->getDefaultProperties(); |
|
| 261 | 261 | } else { |
| 262 | 262 | foreach ($this->visibleProperties as $property) { |
| 263 | 263 | $this->setInstanceProperty($property); |
@@ -268,56 +268,56 @@ discard block |
||
| 268 | 268 | |
| 269 | 269 | private function setInstanceProperty($property) { |
| 270 | 270 | if (\is_callable($property)) { |
| 271 | - $this->properties[] = $property; |
|
| 271 | + $this->properties[]=$property; |
|
| 272 | 272 | } elseif (\is_string($property)) { |
| 273 | 273 | try { |
| 274 | 274 | $this->_beforeAddProperty(\sizeof($this->properties), $property); |
| 275 | - $rProperty = $this->reflect->getProperty($property); |
|
| 276 | - $this->properties[] = $rProperty; |
|
| 277 | - } catch (\Exception $e) { |
|
| 275 | + $rProperty=$this->reflect->getProperty($property); |
|
| 276 | + $this->properties[]=$rProperty; |
|
| 277 | + }catch (\Exception $e) { |
|
| 278 | 278 | $this->_beforeAddProperty(\sizeof($this->properties), $property); |
| 279 | - $this->properties[] = $property; |
|
| 279 | + $this->properties[]=$property; |
|
| 280 | 280 | } |
| 281 | 281 | } elseif (\is_int($property)) { |
| 282 | - $props = $this->getDefaultProperties(); |
|
| 282 | + $props=$this->getDefaultProperties(); |
|
| 283 | 283 | if (isset($props[$property])) |
| 284 | - $this->properties[] = $props[$property]; |
|
| 284 | + $this->properties[]=$props[$property]; |
|
| 285 | 285 | else |
| 286 | - $this->properties[] = $property; |
|
| 286 | + $this->properties[]=$property; |
|
| 287 | 287 | } else { |
| 288 | - $this->properties[] = $property; |
|
| 288 | + $this->properties[]=$property; |
|
| 289 | 289 | } |
| 290 | 290 | } |
| 291 | 291 | |
| 292 | 292 | protected function getDefaultProperties() { |
| 293 | - $result = []; |
|
| 294 | - $properties = $this->reflect->getProperties(); |
|
| 293 | + $result=[]; |
|
| 294 | + $properties=$this->reflect->getProperties(); |
|
| 295 | 295 | foreach ($properties as $property) { |
| 296 | - $showable = $this->showableProperty($property); |
|
| 297 | - if ($showable !== false) { |
|
| 298 | - $result[] = $property; |
|
| 296 | + $showable=$this->showableProperty($property); |
|
| 297 | + if ($showable!==false) { |
|
| 298 | + $result[]=$property; |
|
| 299 | 299 | } |
| 300 | 300 | } |
| 301 | 301 | return $result; |
| 302 | 302 | } |
| 303 | 303 | |
| 304 | 304 | public function setVisibleProperties($visibleProperties) { |
| 305 | - $this->visibleProperties = $visibleProperties; |
|
| 305 | + $this->visibleProperties=$visibleProperties; |
|
| 306 | 306 | return $this; |
| 307 | 307 | } |
| 308 | 308 | |
| 309 | 309 | public function setValueFunction($index, $callback) { |
| 310 | - $this->values[$index] = $callback; |
|
| 310 | + $this->values[$index]=$callback; |
|
| 311 | 311 | return $this; |
| 312 | 312 | } |
| 313 | 313 | |
| 314 | 314 | public function setIdentifierFunction($callback) { |
| 315 | - $this->values["identifier"] = $callback; |
|
| 315 | + $this->values["identifier"]=$callback; |
|
| 316 | 316 | return $this; |
| 317 | 317 | } |
| 318 | 318 | |
| 319 | 319 | public static function setIndex($index) { |
| 320 | - self::$index = $index; |
|
| 320 | + self::$index=$index; |
|
| 321 | 321 | } |
| 322 | 322 | |
| 323 | 323 | public function getProperties() { |
@@ -337,43 +337,43 @@ discard block |
||
| 337 | 337 | } |
| 338 | 338 | |
| 339 | 339 | public function getCaptions() { |
| 340 | - $hasGroupby = is_array($this->groupByFields); |
|
| 341 | - $count = $this->count(); |
|
| 342 | - $moreAdded = false; |
|
| 340 | + $hasGroupby=is_array($this->groupByFields); |
|
| 341 | + $count=$this->count(); |
|
| 342 | + $moreAdded=false; |
|
| 343 | 343 | if (isset($this->captions)) { |
| 344 | - $captions = \array_values($this->captions); |
|
| 345 | - $gbSize = $hasGroupby ? sizeof($this->groupByFields) : 0; |
|
| 346 | - $captionsSize = \sizeof($captions); |
|
| 347 | - for ($i = $captionsSize; $i < $count - $gbSize; $i ++) { |
|
| 348 | - $captions[] = ""; |
|
| 349 | - $moreAdded = true; |
|
| 344 | + $captions=\array_values($this->captions); |
|
| 345 | + $gbSize=$hasGroupby ? sizeof($this->groupByFields) : 0; |
|
| 346 | + $captionsSize=\sizeof($captions); |
|
| 347 | + for ($i=$captionsSize; $i<$count-$gbSize; $i++) { |
|
| 348 | + $captions[]=""; |
|
| 349 | + $moreAdded=true; |
|
| 350 | 350 | } |
| 351 | 351 | } else { |
| 352 | - $captions = []; |
|
| 353 | - $index = 0; |
|
| 354 | - while ($index < $count) { |
|
| 355 | - $captions[] = $this->getCaption($index ++); |
|
| 352 | + $captions=[]; |
|
| 353 | + $index=0; |
|
| 354 | + while ($index<$count) { |
|
| 355 | + $captions[]=$this->getCaption($index++); |
|
| 356 | 356 | } |
| 357 | 357 | } |
| 358 | - if ($hasGroupby && sizeof($captions) >= $count && ! $moreAdded) { |
|
| 359 | - $captions = JArray::removeByKeys($captions, $this->groupByFields); |
|
| 358 | + if ($hasGroupby && sizeof($captions)>=$count && !$moreAdded) { |
|
| 359 | + $captions=JArray::removeByKeys($captions, $this->groupByFields); |
|
| 360 | 360 | } |
| 361 | 361 | if (isset($this->captionCallback) && \is_callable($this->captionCallback)) { |
| 362 | - $callback = $this->captionCallback; |
|
| 362 | + $callback=$this->captionCallback; |
|
| 363 | 363 | $callback($captions, $this->instance); |
| 364 | 364 | } |
| 365 | 365 | return $captions; |
| 366 | 366 | } |
| 367 | 367 | |
| 368 | 368 | public function setCaption($index, $caption) { |
| 369 | - if (isset($this->captions) === false) |
|
| 370 | - $this->captions = []; |
|
| 371 | - $this->captions[$index] = $caption; |
|
| 369 | + if (isset($this->captions)===false) |
|
| 370 | + $this->captions=[]; |
|
| 371 | + $this->captions[$index]=$caption; |
|
| 372 | 372 | return $this; |
| 373 | 373 | } |
| 374 | 374 | |
| 375 | 375 | public function setCaptions($captions) { |
| 376 | - $this->captions = $captions; |
|
| 376 | + $this->captions=$captions; |
|
| 377 | 377 | return $this; |
| 378 | 378 | } |
| 379 | 379 | |
@@ -388,7 +388,7 @@ discard block |
||
| 388 | 388 | * @return InstanceViewer |
| 389 | 389 | */ |
| 390 | 390 | public function afterCompile($index, $callback) { |
| 391 | - $this->afterCompile[$index] = $callback; |
|
| 391 | + $this->afterCompile[$index]=$callback; |
|
| 392 | 392 | return $this; |
| 393 | 393 | } |
| 394 | 394 | |
@@ -400,7 +400,7 @@ discard block |
||
| 400 | 400 | * @return \Ajax\semantic\widgets\base\InstanceViewer |
| 401 | 401 | */ |
| 402 | 402 | public function setCaptionCallback($captionCallback) { |
| 403 | - $this->captionCallback = $captionCallback; |
|
| 403 | + $this->captionCallback=$captionCallback; |
|
| 404 | 404 | return $this; |
| 405 | 405 | } |
| 406 | 406 | |
@@ -412,7 +412,7 @@ discard block |
||
| 412 | 412 | * @return \Ajax\semantic\widgets\base\InstanceViewer |
| 413 | 413 | */ |
| 414 | 414 | public function setDefaultValueFunction($defaultValueFunction) { |
| 415 | - $this->defaultValueFunction = $defaultValueFunction; |
|
| 415 | + $this->defaultValueFunction=$defaultValueFunction; |
|
| 416 | 416 | return $this; |
| 417 | 417 | } |
| 418 | 418 | |
@@ -421,8 +421,8 @@ discard block |
||
| 421 | 421 | } |
| 422 | 422 | |
| 423 | 423 | public function getSimpleProperties() { |
| 424 | - return array_filter($this->visibleProperties, function ($item) { |
|
| 425 | - return ! (is_array($item) || is_object($item)); |
|
| 424 | + return array_filter($this->visibleProperties, function($item) { |
|
| 425 | + return !(is_array($item) || is_object($item)); |
|
| 426 | 426 | }); |
| 427 | 427 | } |
| 428 | 428 | |
@@ -447,10 +447,10 @@ discard block |
||
| 447 | 447 | * @param mixed $groupByFields |
| 448 | 448 | */ |
| 449 | 449 | public function setGroupByFields($groupByFields) { |
| 450 | - $this->groupByFields = $groupByFields; |
|
| 450 | + $this->groupByFields=$groupByFields; |
|
| 451 | 451 | } |
| 452 | 452 | |
| 453 | - public function addGroupBy($groupByField){ |
|
| 453 | + public function addGroupBy($groupByField) { |
|
| 454 | 454 | $this->groupByFields[]=$groupByField; |
| 455 | 455 | } |
| 456 | 456 | |
@@ -15,71 +15,71 @@ discard block |
||
| 15 | 15 | |
| 16 | 16 | protected $ajaxTransition; |
| 17 | 17 | |
| 18 | - protected $ajaxLoader = "<div class=\"ui active centered inline text loader\">Loading</div>"; |
|
| 18 | + protected $ajaxLoader="<div class=\"ui active centered inline text loader\">Loading</div>"; |
|
| 19 | 19 | |
| 20 | 20 | abstract public function getUrl($url); |
| 21 | 21 | |
| 22 | - abstract public function _add_event($element, $js, $event, $preventDefault = false, $stopPropagation = false, $immediatly = true, $listenerOn = false); |
|
| 22 | + abstract public function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false, $immediatly=true, $listenerOn=false); |
|
| 23 | 23 | |
| 24 | - abstract public function interval($jsCode, $time, $globalName = null, $immediatly = true); |
|
| 24 | + abstract public function interval($jsCode, $time, $globalName=null, $immediatly=true); |
|
| 25 | 25 | |
| 26 | - protected function _ajax($method, $url, $responseElement = '', $parameters = []) { |
|
| 26 | + protected function _ajax($method, $url, $responseElement='', $parameters=[]) { |
|
| 27 | 27 | if (isset($this->params['ajax'])) { |
| 28 | 28 | extract($this->params['ajax']); |
| 29 | 29 | } |
| 30 | 30 | extract($parameters); |
| 31 | 31 | |
| 32 | - $jsCallback = isset($jsCallback) ? $jsCallback : ''; |
|
| 33 | - $retour = $this->_getAjaxUrl($url, $attr); |
|
| 34 | - $originalSelector = $responseElement; |
|
| 35 | - $responseElement = $this->_getResponseElement($responseElement); |
|
| 36 | - $retour .= "var self=this;\n"; |
|
| 37 | - $before = isset($before) ? $before : ""; |
|
| 38 | - $retour .= $before; |
|
| 39 | - if ($hasLoader === true && JString::isNotNull($responseElement)) { |
|
| 32 | + $jsCallback=isset($jsCallback) ? $jsCallback : ''; |
|
| 33 | + $retour=$this->_getAjaxUrl($url, $attr); |
|
| 34 | + $originalSelector=$responseElement; |
|
| 35 | + $responseElement=$this->_getResponseElement($responseElement); |
|
| 36 | + $retour.="var self=this;\n"; |
|
| 37 | + $before=isset($before) ? $before : ""; |
|
| 38 | + $retour.=$before; |
|
| 39 | + if ($hasLoader===true && JString::isNotNull($responseElement)) { |
|
| 40 | 40 | $this->addLoading($retour, $responseElement, $ajaxLoader); |
| 41 | - } elseif ($hasLoader === 'response') { |
|
| 41 | + } elseif ($hasLoader==='response') { |
|
| 42 | 42 | $this->addResponseLoading($retour, $responseElement, $ajaxLoader); |
| 43 | - } elseif ($hasLoader === 'internal-x') { |
|
| 43 | + } elseif ($hasLoader==='internal-x') { |
|
| 44 | 44 | $this->addLoading($retour, '$(this).closest(".item, .step")', $ajaxLoader); |
| 45 | - } elseif ($hasLoader === 'internal') { |
|
| 46 | - $retour .= "\n$(this).addClass('loading');"; |
|
| 45 | + } elseif ($hasLoader==='internal') { |
|
| 46 | + $retour.="\n$(this).addClass('loading');"; |
|
| 47 | 47 | } elseif (\is_string($hasLoader)) { |
| 48 | 48 | $this->addLoading($retour, $hasLoader, $ajaxLoader); |
| 49 | 49 | } |
| 50 | - $ajaxParameters = [ |
|
| 50 | + $ajaxParameters=[ |
|
| 51 | 51 | "url" => "url", |
| 52 | - "method" => "'" . \strtoupper($method) . "'" |
|
| 52 | + "method" => "'".\strtoupper($method)."'" |
|
| 53 | 53 | ]; |
| 54 | 54 | |
| 55 | - $ajaxParameters["async"] = ($async ? "true" : "false"); |
|
| 55 | + $ajaxParameters["async"]=($async ? "true" : "false"); |
|
| 56 | 56 | |
| 57 | 57 | if (isset($params)) { |
| 58 | - $ajaxParameters["data"] = self::_correctParams($params, $parameters); |
|
| 58 | + $ajaxParameters["data"]=self::_correctParams($params, $parameters); |
|
| 59 | 59 | } |
| 60 | 60 | if (isset($headers)) { |
| 61 | - $ajaxParameters["headers"] = $headers; |
|
| 61 | + $ajaxParameters["headers"]=$headers; |
|
| 62 | 62 | } |
| 63 | 63 | if ($csrf) { |
| 64 | - $csrf = (is_string($csrf)) ? $csrf : 'csrf-token'; |
|
| 65 | - $parameters["beforeSend"] = "jqXHR.setRequestHeader('{$csrf}', $('meta[name=\"{$csrf}\"]').attr('content'));"; |
|
| 64 | + $csrf=(is_string($csrf)) ? $csrf : 'csrf-token'; |
|
| 65 | + $parameters["beforeSend"]="jqXHR.setRequestHeader('{$csrf}', $('meta[name=\"{$csrf}\"]').attr('content'));"; |
|
| 66 | 66 | } |
| 67 | 67 | if (isset($partial)) { |
| 68 | - $ajaxParameters["xhr"] = "xhrProvider"; |
|
| 69 | - $retour .= "var xhr = $.ajaxSettings.xhr();function xhrProvider() {return xhr;};xhr.onreadystatechange = function (e) { if (3==e.target.readyState){let response=e.target.responseText;" . $partial . ";}; };"; |
|
| 68 | + $ajaxParameters["xhr"]="xhrProvider"; |
|
| 69 | + $retour.="var xhr = $.ajaxSettings.xhr();function xhrProvider() {return xhr;};xhr.onreadystatechange = function (e) { if (3==e.target.readyState){let response=e.target.responseText;".$partial.";}; };"; |
|
| 70 | 70 | } |
| 71 | 71 | $this->createAjaxParameters($ajaxParameters, $parameters); |
| 72 | - $retour .= "$.ajax({" . $this->implodeAjaxParameters($ajaxParameters) . "}).done(function( data, textStatus, jqXHR ) {\n"; |
|
| 73 | - $retour .= $this->_getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback, $hasLoader, ($historize ? $originalSelector : null)) . "});\n"; |
|
| 72 | + $retour.="$.ajax({".$this->implodeAjaxParameters($ajaxParameters)."}).done(function( data, textStatus, jqXHR ) {\n"; |
|
| 73 | + $retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback, $hasLoader, ($historize ? $originalSelector : null))."});\n"; |
|
| 74 | 74 | |
| 75 | - $retour = $this->_addJsCondition($jsCondition, $retour); |
|
| 75 | + $retour=$this->_addJsCondition($jsCondition, $retour); |
|
| 76 | 76 | if ($immediatly) |
| 77 | - $this->jquery_code_for_compile[] = $retour; |
|
| 77 | + $this->jquery_code_for_compile[]=$retour; |
|
| 78 | 78 | return $retour; |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | protected function createAjaxParameters(&$original, $parameters) { |
| 82 | - $validParameters = [ |
|
| 82 | + $validParameters=[ |
|
| 83 | 83 | "contentType" => "%value%", |
| 84 | 84 | "dataType" => "'%value%'", |
| 85 | 85 | "beforeSend" => "function(jqXHR,settings){%value%}", |
@@ -88,21 +88,21 @@ discard block |
||
| 88 | 88 | ]; |
| 89 | 89 | foreach ($validParameters as $param => $mask) { |
| 90 | 90 | if (isset($parameters[$param])) { |
| 91 | - $original[$param] = \str_replace("%value%", $parameters[$param], $mask); |
|
| 91 | + $original[$param]=\str_replace("%value%", $parameters[$param], $mask); |
|
| 92 | 92 | } |
| 93 | 93 | } |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | protected function implodeAjaxParameters($ajaxParameters) { |
| 97 | - $s = ''; |
|
| 97 | + $s=''; |
|
| 98 | 98 | foreach ($ajaxParameters as $k => $v) { |
| 99 | - if ($s !== '') { |
|
| 100 | - $s .= ','; |
|
| 99 | + if ($s!=='') { |
|
| 100 | + $s.=','; |
|
| 101 | 101 | } |
| 102 | 102 | if (is_array($v)) { |
| 103 | - $s .= "'{$k}':{" . self::implodeAjaxParameters($v) . "}"; |
|
| 103 | + $s.="'{$k}':{".self::implodeAjaxParameters($v)."}"; |
|
| 104 | 104 | } else { |
| 105 | - $s .= "'{$k}':{$v}"; |
|
| 105 | + $s.="'{$k}':{$v}"; |
|
| 106 | 106 | } |
| 107 | 107 | } |
| 108 | 108 | return $s; |
@@ -110,29 +110,29 @@ discard block |
||
| 110 | 110 | |
| 111 | 111 | protected function _addJsCondition($jsCondition, $jsSource) { |
| 112 | 112 | if (isset($jsCondition)) { |
| 113 | - return "if(" . $jsCondition . "){\n" . $jsSource . "\n}"; |
|
| 113 | + return "if(".$jsCondition."){\n".$jsSource."\n}"; |
|
| 114 | 114 | } |
| 115 | 115 | return $jsSource; |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | protected function _getAjaxUrl($url, $attr) { |
| 119 | - $url = $this->_correctAjaxUrl($url); |
|
| 120 | - $retour = "url='" . $url . "';"; |
|
| 121 | - $slash = "/"; |
|
| 122 | - if (JString::endswith($url, "/") === true) { |
|
| 123 | - $slash = ""; |
|
| 119 | + $url=$this->_correctAjaxUrl($url); |
|
| 120 | + $retour="url='".$url."';"; |
|
| 121 | + $slash="/"; |
|
| 122 | + if (JString::endswith($url, "/")===true) { |
|
| 123 | + $slash=""; |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | if (JString::isNotNull($attr)) { |
| 127 | - if ($attr === "value") { |
|
| 128 | - $retour .= "url=url+'" . $slash . "'+$(this).val();\n"; |
|
| 129 | - } elseif ($attr === "html") { |
|
| 130 | - $retour .= "url=url+'" . $slash . "'+$(this).html();\n"; |
|
| 131 | - } elseif (\substr($attr, 0, 3) === "js:") { |
|
| 132 | - $retour .= "url=url+'" . $slash . "'+" . \substr($attr, 3) . ";\n"; |
|
| 133 | - } elseif ($attr !== null && $attr !== "") { |
|
| 134 | - $retour .= "let elmUrl=$(this).attr('" . $attr . "')||'';"; |
|
| 135 | - $retour .= "url=(!/^((http|https|ftp):\/\/)/.test(elmUrl))?url+'" . $slash . "'+elmUrl:elmUrl;\n"; |
|
| 127 | + if ($attr==="value") { |
|
| 128 | + $retour.="url=url+'".$slash."'+$(this).val();\n"; |
|
| 129 | + } elseif ($attr==="html") { |
|
| 130 | + $retour.="url=url+'".$slash."'+$(this).html();\n"; |
|
| 131 | + } elseif (\substr($attr, 0, 3)==="js:") { |
|
| 132 | + $retour.="url=url+'".$slash."'+".\substr($attr, 3).";\n"; |
|
| 133 | + } elseif ($attr!==null && $attr!=="") { |
|
| 134 | + $retour.="let elmUrl=$(this).attr('".$attr."')||'';"; |
|
| 135 | + $retour.="url=(!/^((http|https|ftp):\/\/)/.test(elmUrl))?url+'".$slash."'+elmUrl:elmUrl;\n"; |
|
| 136 | 136 | } |
| 137 | 137 | } |
| 138 | 138 | return $retour; |
@@ -142,110 +142,110 @@ discard block |
||
| 142 | 142 | return "window.onpopstate = function(e){if(e.state){var target=e.state.jqueryDone;$(e.state.selector)[target](e.state.html);}};"; |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | - protected function autoActiveLinks($previousURL = "window.location.href") { |
|
| 146 | - $result = "\nfunction getHref(url) { return \$('a').filter(function(){return \$(this).prop('href') == url; });}"; |
|
| 147 | - $result .= "\nvar myurl={$previousURL};if(window._previousURL) getHref(window._previousURL).removeClass('active');getHref(myurl).addClass('active');window._previousURL=myurl;"; |
|
| 145 | + protected function autoActiveLinks($previousURL="window.location.href") { |
|
| 146 | + $result="\nfunction getHref(url) { return \$('a').filter(function(){return \$(this).prop('href') == url; });}"; |
|
| 147 | + $result.="\nvar myurl={$previousURL};if(window._previousURL) getHref(window._previousURL).removeClass('active');getHref(myurl).addClass('active');window._previousURL=myurl;"; |
|
| 148 | 148 | return $result; |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | - protected function _getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback, $hasLoader = false, $history = null) { |
|
| 152 | - $retour = ""; |
|
| 153 | - $call = null; |
|
| 151 | + protected function _getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback, $hasLoader=false, $history=null) { |
|
| 152 | + $retour=""; |
|
| 153 | + $call=null; |
|
| 154 | 154 | if (JString::isNotNull($responseElement)) { |
| 155 | 155 | if (isset($ajaxTransition)) { |
| 156 | - $call = $this->setAjaxDataCall($ajaxTransition); |
|
| 156 | + $call=$this->setAjaxDataCall($ajaxTransition); |
|
| 157 | 157 | } elseif (isset($this->ajaxTransition)) { |
| 158 | - $call = $this->ajaxTransition; |
|
| 158 | + $call=$this->ajaxTransition; |
|
| 159 | 159 | } |
| 160 | 160 | if (\is_callable($call)) |
| 161 | - $retour = "\t" . $call($responseElement, $jqueryDone) . ";\n"; |
|
| 161 | + $retour="\t".$call($responseElement, $jqueryDone).";\n"; |
|
| 162 | 162 | else |
| 163 | - $retour = "\t{$responseElement}.{$jqueryDone}( data );\n"; |
|
| 163 | + $retour="\t{$responseElement}.{$jqueryDone}( data );\n"; |
|
| 164 | 164 | } |
| 165 | 165 | if (isset($history)) { |
| 166 | 166 | if ($this->params["autoActiveLinks"]) { |
| 167 | - $retour .= $this->autoActiveLinks("url"); |
|
| 167 | + $retour.=$this->autoActiveLinks("url"); |
|
| 168 | 168 | } |
| 169 | - $retour .= "\nwindow.history.pushState({'html':data,'selector':" . Javascript::prep_value($history) . ",'jqueryDone':'{$jqueryDone}'},'', url);"; |
|
| 169 | + $retour.="\nwindow.history.pushState({'html':data,'selector':".Javascript::prep_value($history).",'jqueryDone':'{$jqueryDone}'},'', url);"; |
|
| 170 | 170 | } |
| 171 | - if ($hasLoader === 'internal') { |
|
| 172 | - $retour .= "\n$(self).removeClass('loading');"; |
|
| 173 | - } elseif ($hasLoader === 'internal-x') { |
|
| 174 | - $retour .= "\n$(self).children('.ajax-loader').remove();"; |
|
| 171 | + if ($hasLoader==='internal') { |
|
| 172 | + $retour.="\n$(self).removeClass('loading');"; |
|
| 173 | + } elseif ($hasLoader==='internal-x') { |
|
| 174 | + $retour.="\n$(self).children('.ajax-loader').remove();"; |
|
| 175 | 175 | } else { |
| 176 | - $retour .= "\n$(self).find('.loading').removeClass('loading');"; |
|
| 176 | + $retour.="\n$(self).find('.loading').removeClass('loading');"; |
|
| 177 | 177 | } |
| 178 | - $retour .= "\t" . $jsCallback . "\n"; |
|
| 178 | + $retour.="\t".$jsCallback."\n"; |
|
| 179 | 179 | return $retour; |
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | protected function _getResponseElement($responseElement) { |
| 183 | 183 | if (JString::isNotNull($responseElement)) { |
| 184 | - $responseElement = Javascript::prep_jquery_selector($responseElement); |
|
| 184 | + $responseElement=Javascript::prep_jquery_selector($responseElement); |
|
| 185 | 185 | } |
| 186 | 186 | return $responseElement; |
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | protected function _getFormElement($formElement) { |
| 190 | 190 | if (JString::isNotNull($formElement)) { |
| 191 | - $formElement = Javascript::prep_value($formElement); |
|
| 191 | + $formElement=Javascript::prep_value($formElement); |
|
| 192 | 192 | } |
| 193 | 193 | return $formElement; |
| 194 | 194 | } |
| 195 | 195 | |
| 196 | 196 | protected function _correctAjaxUrl($url) { |
| 197 | - if ($url !== "/" && JString::endsWith($url, "/") === true) |
|
| 198 | - $url = substr($url, 0, strlen($url) - 1); |
|
| 199 | - if (strncmp($url, 'http://', 7) != 0 && strncmp($url, 'https://', 8) != 0) { |
|
| 200 | - $url = $this->getUrl($url); |
|
| 197 | + if ($url!=="/" && JString::endsWith($url, "/")===true) |
|
| 198 | + $url=substr($url, 0, strlen($url)-1); |
|
| 199 | + if (strncmp($url, 'http://', 7)!=0 && strncmp($url, 'https://', 8)!=0) { |
|
| 200 | + $url=$this->getUrl($url); |
|
| 201 | 201 | } |
| 202 | 202 | return $url; |
| 203 | 203 | } |
| 204 | 204 | |
| 205 | - public static function _correctParams($params, $ajaxParameters = []) { |
|
| 205 | + public static function _correctParams($params, $ajaxParameters=[]) { |
|
| 206 | 206 | if (JString::isNull($params)) { |
| 207 | 207 | return ""; |
| 208 | 208 | } |
| 209 | 209 | if (\preg_match("@^\{.*?\}$@", $params)) { |
| 210 | - if (! isset($ajaxParameters['contentType']) || ! JString::contains($ajaxParameters['contentType'], 'json')) { |
|
| 211 | - return '$.param(' . $params . ')'; |
|
| 210 | + if (!isset($ajaxParameters['contentType']) || !JString::contains($ajaxParameters['contentType'], 'json')) { |
|
| 211 | + return '$.param('.$params.')'; |
|
| 212 | 212 | } else { |
| 213 | - return 'JSON.stringify(' . $params . ')'; |
|
| 213 | + return 'JSON.stringify('.$params.')'; |
|
| 214 | 214 | } |
| 215 | 215 | } |
| 216 | 216 | return $params; |
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | public static function _implodeParams($parameters) { |
| 220 | - $allParameters = []; |
|
| 220 | + $allParameters=[]; |
|
| 221 | 221 | foreach ($parameters as $params) { |
| 222 | 222 | if (isset($params)) |
| 223 | - $allParameters[] = self::_correctParams($params); |
|
| 223 | + $allParameters[]=self::_correctParams($params); |
|
| 224 | 224 | } |
| 225 | 225 | return \implode("+'&'+", $allParameters); |
| 226 | 226 | } |
| 227 | 227 | |
| 228 | - protected function addLoading(&$retour, $responseElement, $ajaxLoader = null) { |
|
| 229 | - if (! isset($ajaxLoader)) { |
|
| 230 | - $ajaxLoader = $this->ajaxLoader; |
|
| 228 | + protected function addLoading(&$retour, $responseElement, $ajaxLoader=null) { |
|
| 229 | + if (!isset($ajaxLoader)) { |
|
| 230 | + $ajaxLoader=$this->ajaxLoader; |
|
| 231 | 231 | } |
| 232 | - $loading_notifier = '<div class="ajax-loader ui active inverted dimmer">' . $ajaxLoader . '</div>'; |
|
| 233 | - $retour .= "\t\t{$responseElement}.append('{$loading_notifier}');\n"; |
|
| 232 | + $loading_notifier='<div class="ajax-loader ui active inverted dimmer">'.$ajaxLoader.'</div>'; |
|
| 233 | + $retour.="\t\t{$responseElement}.append('{$loading_notifier}');\n"; |
|
| 234 | 234 | } |
| 235 | 235 | |
| 236 | - protected function addResponseLoading(&$retour, $responseElement, $ajaxLoader = null) { |
|
| 237 | - if (! isset($ajaxLoader)) { |
|
| 238 | - $ajaxLoader = $this->ajaxLoader; |
|
| 236 | + protected function addResponseLoading(&$retour, $responseElement, $ajaxLoader=null) { |
|
| 237 | + if (!isset($ajaxLoader)) { |
|
| 238 | + $ajaxLoader=$this->ajaxLoader; |
|
| 239 | 239 | } |
| 240 | - $loading_notifier = '<div class="ajax-loader">' . $ajaxLoader . '</div>'; |
|
| 241 | - $retour .= "{$responseElement}.empty();\n"; |
|
| 242 | - $retour .= "\t\t{$responseElement}.prepend('{$loading_notifier}');\n"; |
|
| 240 | + $loading_notifier='<div class="ajax-loader">'.$ajaxLoader.'</div>'; |
|
| 241 | + $retour.="{$responseElement}.empty();\n"; |
|
| 242 | + $retour.="\t\t{$responseElement}.prepend('{$loading_notifier}');\n"; |
|
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | protected function setAjaxDataCall($params) { |
| 246 | - $result = null; |
|
| 247 | - if (! \is_callable($params)) { |
|
| 248 | - $result = function ($responseElement, $jqueryDone = 'html') use ($params) { |
|
| 246 | + $result=null; |
|
| 247 | + if (!\is_callable($params)) { |
|
| 248 | + $result=function($responseElement, $jqueryDone='html') use ($params) { |
|
| 249 | 249 | return AjaxTransition::{$params}($responseElement, $jqueryDone); |
| 250 | 250 | }; |
| 251 | 251 | } |
@@ -254,13 +254,13 @@ discard block |
||
| 254 | 254 | |
| 255 | 255 | protected function setDefaultParameters(&$parameters, $default) { |
| 256 | 256 | foreach ($default as $k => $v) { |
| 257 | - if (! isset($parameters[$k])) |
|
| 258 | - $parameters[$k] = $v; |
|
| 257 | + if (!isset($parameters[$k])) |
|
| 258 | + $parameters[$k]=$v; |
|
| 259 | 259 | } |
| 260 | 260 | } |
| 261 | 261 | |
| 262 | 262 | public function setAjaxLoader($loader) { |
| 263 | - $this->ajaxLoader = $loader; |
|
| 263 | + $this->ajaxLoader=$loader; |
|
| 264 | 264 | } |
| 265 | 265 | |
| 266 | 266 | /** |
@@ -271,7 +271,7 @@ discard block |
||
| 271 | 271 | * @param string $responseElement |
| 272 | 272 | * selector of the HTML element displaying the answer |
| 273 | 273 | */ |
| 274 | - private function _get($url, $responseElement = '', $parameters = []) { |
|
| 274 | + private function _get($url, $responseElement='', $parameters=[]) { |
|
| 275 | 275 | return $this->_ajax('get', $url, $responseElement, $parameters); |
| 276 | 276 | } |
| 277 | 277 | |
@@ -285,8 +285,8 @@ discard block |
||
| 285 | 285 | * @param array $parameters |
| 286 | 286 | * default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false,"before"=>null) |
| 287 | 287 | */ |
| 288 | - public function get($url, $responseElement = '', $parameters = []) { |
|
| 289 | - $parameters['immediatly'] = true; |
|
| 288 | + public function get($url, $responseElement='', $parameters=[]) { |
|
| 289 | + $parameters['immediatly']=true; |
|
| 290 | 290 | return $this->_get($url, $responseElement, $parameters); |
| 291 | 291 | } |
| 292 | 292 | |
@@ -302,8 +302,8 @@ discard block |
||
| 302 | 302 | * @param array $parameters |
| 303 | 303 | * default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false,"before"=>null) |
| 304 | 304 | */ |
| 305 | - public function ajax($method, $url, $responseElement = '', $parameters = []) { |
|
| 306 | - $parameters['immediatly'] = true; |
|
| 305 | + public function ajax($method, $url, $responseElement='', $parameters=[]) { |
|
| 306 | + $parameters['immediatly']=true; |
|
| 307 | 307 | return $this->_ajax($method, $url, $responseElement, $parameters); |
| 308 | 308 | } |
| 309 | 309 | |
@@ -325,7 +325,7 @@ discard block |
||
| 325 | 325 | * $immediatly |
| 326 | 326 | * @return string |
| 327 | 327 | */ |
| 328 | - public function ajaxInterval($method, $url, $interval, $globalName = null, $responseElement = '', $parameters = [], $immediatly = true) { |
|
| 328 | + public function ajaxInterval($method, $url, $interval, $globalName=null, $responseElement='', $parameters=[], $immediatly=true) { |
|
| 329 | 329 | return $this->interval($this->ajaxDeferred($method, $url, $responseElement, $parameters), $interval, $globalName, $immediatly); |
| 330 | 330 | } |
| 331 | 331 | |
@@ -341,8 +341,8 @@ discard block |
||
| 341 | 341 | * @param array $parameters |
| 342 | 342 | * default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false,"before"=>null) |
| 343 | 343 | */ |
| 344 | - public function ajaxDeferred($method, $url, $responseElement = '', $parameters = []) { |
|
| 345 | - $parameters['immediatly'] = false; |
|
| 344 | + public function ajaxDeferred($method, $url, $responseElement='', $parameters=[]) { |
|
| 345 | + $parameters['immediatly']=false; |
|
| 346 | 346 | return $this->_ajax($method, $url, $responseElement, $parameters); |
| 347 | 347 | } |
| 348 | 348 | |
@@ -356,15 +356,15 @@ discard block |
||
| 356 | 356 | * @param array $parameters |
| 357 | 357 | * default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","context"=>"document","jsCondition"=>NULL,"headers"=>null,"immediatly"=>false,"before"=>null) |
| 358 | 358 | */ |
| 359 | - private function _json($url, $method = "get", $parameters = []) { |
|
| 360 | - $parameters = \array_merge($parameters, [ |
|
| 359 | + private function _json($url, $method="get", $parameters=[]) { |
|
| 360 | + $parameters=\array_merge($parameters, [ |
|
| 361 | 361 | "hasLoader" => false |
| 362 | 362 | ]); |
| 363 | - $jsCallback = isset($parameters['jsCallback']) ? $parameters['jsCallback'] : ""; |
|
| 364 | - $context = isset($parameters['context']) ? $parameters['context'] : "document"; |
|
| 365 | - $retour = "\tdata=($.isPlainObject(data))?data:JSON.parse(data);\t" . $jsCallback . ";" . "\n\tfor(var key in data){" . "if($('#'+key," . $context . ").length){ if($('#'+key," . $context . ").is('[value]')) { $('#'+key," . $context . ").val(data[key]);} else { $('#'+key," . $context . ").html(data[key]); }}};\n"; |
|
| 366 | - $retour .= "\t$(document).trigger('jsonReady',[data]);\n"; |
|
| 367 | - $parameters["jsCallback"] = $retour; |
|
| 363 | + $jsCallback=isset($parameters['jsCallback']) ? $parameters['jsCallback'] : ""; |
|
| 364 | + $context=isset($parameters['context']) ? $parameters['context'] : "document"; |
|
| 365 | + $retour="\tdata=($.isPlainObject(data))?data:JSON.parse(data);\t".$jsCallback.";"."\n\tfor(var key in data){"."if($('#'+key,".$context.").length){ if($('#'+key,".$context.").is('[value]')) { $('#'+key,".$context.").val(data[key]);} else { $('#'+key,".$context.").html(data[key]); }}};\n"; |
|
| 366 | + $retour.="\t$(document).trigger('jsonReady',[data]);\n"; |
|
| 367 | + $parameters["jsCallback"]=$retour; |
|
| 368 | 368 | return $this->_ajax($method, $url, null, $parameters); |
| 369 | 369 | } |
| 370 | 370 | |
@@ -378,7 +378,7 @@ discard block |
||
| 378 | 378 | * @param array $parameters |
| 379 | 379 | * default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","context"=>"document","jsCondition"=>NULL,"headers"=>null,"immediatly"=>false,"before"=>null) |
| 380 | 380 | */ |
| 381 | - public function json($url, $method = "get", $parameters = []) { |
|
| 381 | + public function json($url, $method="get", $parameters=[]) { |
|
| 382 | 382 | return $this->_json($url, $method, $parameters); |
| 383 | 383 | } |
| 384 | 384 | |
@@ -394,7 +394,7 @@ discard block |
||
| 394 | 394 | * @param array $parameters |
| 395 | 395 | * default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get","immediatly"=>true,"before"=>null,"listenerOn"=>false) |
| 396 | 396 | */ |
| 397 | - public function jsonOn($event, $element, $url, $method = 'get', $parameters = array()) { |
|
| 397 | + public function jsonOn($event, $element, $url, $method='get', $parameters=array()) { |
|
| 398 | 398 | $this->setDefaultParameters($parameters, [ |
| 399 | 399 | 'preventDefault' => true, |
| 400 | 400 | 'stopPropagation' => true, |
@@ -414,8 +414,8 @@ discard block |
||
| 414 | 414 | * @param array $parameters |
| 415 | 415 | * default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","context"=>"document","jsCondition"=>NULL,"headers"=>null,"immediatly"=>false,"before"=>null) |
| 416 | 416 | */ |
| 417 | - public function jsonDeferred($url, $method = 'get', $parameters = []) { |
|
| 418 | - $parameters['immediatly'] = false; |
|
| 417 | + public function jsonDeferred($url, $method='get', $parameters=[]) { |
|
| 418 | + $parameters['immediatly']=false; |
|
| 419 | 419 | return $this->_json($url, $method, $parameters); |
| 420 | 420 | } |
| 421 | 421 | |
@@ -430,29 +430,29 @@ discard block |
||
| 430 | 430 | * @param array $parameters |
| 431 | 431 | * default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","context"=>null,"jsCondition"=>NULL,"headers"=>null,"immediatly"=>false,"rowClass"=>"_json","before"=>null) |
| 432 | 432 | */ |
| 433 | - private function _jsonArray($maskSelector, $url, $method = 'get', $parameters = []) { |
|
| 434 | - $parameters = \array_merge($parameters, [ |
|
| 433 | + private function _jsonArray($maskSelector, $url, $method='get', $parameters=[]) { |
|
| 434 | + $parameters=\array_merge($parameters, [ |
|
| 435 | 435 | "hasLoader" => false |
| 436 | 436 | ]); |
| 437 | - $rowClass = isset($parameters['rowClass']) ? $parameters['rowClass'] : "_json"; |
|
| 438 | - $jsCallback = isset($parameters['jsCallback']) ? $parameters['jsCallback'] : ""; |
|
| 439 | - $context = isset($parameters['context']) ? $parameters['context'] : null; |
|
| 440 | - if ($context === null) { |
|
| 441 | - $parent = "$('" . $maskSelector . "').parent()"; |
|
| 442 | - $newElm = "$('#'+newId)"; |
|
| 437 | + $rowClass=isset($parameters['rowClass']) ? $parameters['rowClass'] : "_json"; |
|
| 438 | + $jsCallback=isset($parameters['jsCallback']) ? $parameters['jsCallback'] : ""; |
|
| 439 | + $context=isset($parameters['context']) ? $parameters['context'] : null; |
|
| 440 | + if ($context===null) { |
|
| 441 | + $parent="$('".$maskSelector."').parent()"; |
|
| 442 | + $newElm="$('#'+newId)"; |
|
| 443 | 443 | } else { |
| 444 | - $parent = $context; |
|
| 445 | - $newElm = $context . ".find('#'+newId)"; |
|
| 444 | + $parent=$context; |
|
| 445 | + $newElm=$context.".find('#'+newId)"; |
|
| 446 | 446 | } |
| 447 | - $appendTo = "\t\tnewElm.appendTo(" . $parent . ");\n"; |
|
| 448 | - $retour = $parent . ".find('.{$rowClass}').remove();"; |
|
| 449 | - $retour .= "\tdata=($.isPlainObject(data)||$.isArray(data))?data:JSON.parse(data);\n$.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(); |
|
| 447 | + $appendTo="\t\tnewElm.appendTo(".$parent.");\n"; |
|
| 448 | + $retour=$parent.".find('.{$rowClass}').remove();"; |
|
| 449 | + $retour.="\tdata=($.isPlainObject(data)||$.isArray(data))?data:JSON.parse(data);\n$.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(); |
|
| 450 | 450 | 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"; |
| 451 | - $retour .= $appendTo; |
|
| 452 | - $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"; |
|
| 453 | - $retour .= "\t$(document).trigger('jsonReady',[data]);\n"; |
|
| 454 | - $retour .= "\t" . $jsCallback; |
|
| 455 | - $parameters["jsCallback"] = $retour; |
|
| 451 | + $retour.=$appendTo; |
|
| 452 | + $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"; |
|
| 453 | + $retour.="\t$(document).trigger('jsonReady',[data]);\n"; |
|
| 454 | + $retour.="\t".$jsCallback; |
|
| 455 | + $parameters["jsCallback"]=$retour; |
|
| 456 | 456 | return $this->_ajax($method, $url, null, $parameters); |
| 457 | 457 | } |
| 458 | 458 | |
@@ -467,7 +467,7 @@ discard block |
||
| 467 | 467 | * @param array $parameters |
| 468 | 468 | * default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","context"=>null,"jsCondition"=>NULL,"headers"=>null,"immediatly"=>false,"rowClass"=>"_json","before"=>null) |
| 469 | 469 | */ |
| 470 | - public function jsonArray($maskSelector, $url, $method = 'get', $parameters = []) { |
|
| 470 | + public function jsonArray($maskSelector, $url, $method='get', $parameters=[]) { |
|
| 471 | 471 | return $this->_jsonArray($maskSelector, $url, $method, $parameters); |
| 472 | 472 | } |
| 473 | 473 | |
@@ -482,8 +482,8 @@ discard block |
||
| 482 | 482 | * @param array $parameters |
| 483 | 483 | * default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","context"=>null,"jsCondition"=>NULL,"headers"=>null,"rowClass"=>"_json","before"=>null) |
| 484 | 484 | */ |
| 485 | - public function jsonArrayDeferred($maskSelector, $url, $method = 'get', $parameters = []) { |
|
| 486 | - $parameters['immediatly'] = false; |
|
| 485 | + public function jsonArrayDeferred($maskSelector, $url, $method='get', $parameters=[]) { |
|
| 486 | + $parameters['immediatly']=false; |
|
| 487 | 487 | return $this->jsonArray($maskSelector, $url, $method, $parameters); |
| 488 | 488 | } |
| 489 | 489 | |
@@ -499,7 +499,7 @@ discard block |
||
| 499 | 499 | * @param array $parameters |
| 500 | 500 | * default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get","rowClass"=>"_json","immediatly"=>true,"before"=>null,"listenerOn"=>false) |
| 501 | 501 | */ |
| 502 | - public function jsonArrayOn($event, $element, $maskSelector, $url, $method = 'get', $parameters = array()) { |
|
| 502 | + public function jsonArrayOn($event, $element, $maskSelector, $url, $method='get', $parameters=array()) { |
|
| 503 | 503 | $this->setDefaultParameters($parameters, [ |
| 504 | 504 | 'preventDefault' => true, |
| 505 | 505 | 'stopPropagation' => true, |
@@ -520,8 +520,8 @@ discard block |
||
| 520 | 520 | * @param array $parameters |
| 521 | 521 | * default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false,"before"=>null) |
| 522 | 522 | */ |
| 523 | - public function getDeferred($url, $responseElement = "", $parameters = []) { |
|
| 524 | - $parameters['immediatly'] = false; |
|
| 523 | + public function getDeferred($url, $responseElement="", $parameters=[]) { |
|
| 524 | + $parameters['immediatly']=false; |
|
| 525 | 525 | return $this->_get($url, $responseElement, $parameters); |
| 526 | 526 | } |
| 527 | 527 | |
@@ -540,8 +540,8 @@ discard block |
||
| 540 | 540 | * @param array $parameters |
| 541 | 541 | * default : array("preventDefault"=>true,"stopPropagation"=>true,"params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>null,"headers"=>null,"historize"=>false,"before"=>null,"listenerOn"=>false) |
| 542 | 542 | */ |
| 543 | - public function getOn($event, $element, $url, $responseElement = "", $parameters = array()) { |
|
| 544 | - $parameters['method'] = 'get'; |
|
| 543 | + public function getOn($event, $element, $url, $responseElement="", $parameters=array()) { |
|
| 544 | + $parameters['method']='get'; |
|
| 545 | 545 | return $this->ajaxOn($event, $element, $url, $responseElement, $parameters); |
| 546 | 546 | } |
| 547 | 547 | |
@@ -560,7 +560,7 @@ discard block |
||
| 560 | 560 | * @param array $parameters |
| 561 | 561 | * default : array("method"=>"get","preventDefault"=>true,"stopPropagation"=>true,"params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","jsCondition"=>NULL,"headers"=>null,"historize"=>false,"before"=>null,"listenerOn"=>false) |
| 562 | 562 | */ |
| 563 | - public function ajaxOn($event, $element, $url, $responseElement = '', $parameters = array()) { |
|
| 563 | + public function ajaxOn($event, $element, $url, $responseElement='', $parameters=array()) { |
|
| 564 | 564 | $this->setDefaultParameters($parameters, [ |
| 565 | 565 | 'preventDefault' => true, |
| 566 | 566 | 'stopPropagation' => true, |
@@ -584,7 +584,7 @@ discard block |
||
| 584 | 584 | * @param array $parameters |
| 585 | 585 | * default : array("method"=>"get","preventDefault"=>true,"stopPropagation"=>true,"params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","jsCondition"=>NULL,"headers"=>null,"historize"=>false,"before"=>null,"listenerOn"=>false) |
| 586 | 586 | */ |
| 587 | - public function ajaxOnClick($element, $url, $responseElement = '', $parameters = array()) { |
|
| 587 | + public function ajaxOnClick($element, $url, $responseElement='', $parameters=array()) { |
|
| 588 | 588 | return $this->ajaxOn('click', $element, $url, $responseElement, $parameters); |
| 589 | 589 | } |
| 590 | 590 | |
@@ -601,7 +601,7 @@ discard block |
||
| 601 | 601 | * @param array $parameters |
| 602 | 602 | * default : array("preventDefault"=>true,"stopPropagation"=>true,"params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","jsCondition"=>NULL,"headers"=>null,"historize"=>false,"before"=>null,"listenerOn"=>false) |
| 603 | 603 | */ |
| 604 | - public function getOnClick($element, $url, $responseElement = '', $parameters = array()) { |
|
| 604 | + public function getOnClick($element, $url, $responseElement='', $parameters=array()) { |
|
| 605 | 605 | return $this->getOn('click', $element, $url, $responseElement, $parameters); |
| 606 | 606 | } |
| 607 | 607 | |
@@ -616,18 +616,18 @@ discard block |
||
| 616 | 616 | * default : array("preventDefault"=>true,"stopPropagation"=>true,"params"=>"{}","jsCallback"=>NULL,"attr"=>"href","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","jsCondition"=>NULL,"headers"=>null,"historize"=>true,"before"=>null,"listenerOn"=>false) |
| 617 | 617 | * @return $this |
| 618 | 618 | */ |
| 619 | - public function getHref($element, $responseElement = "", $parameters = array()) { |
|
| 620 | - $parameters['attr'] = 'href'; |
|
| 619 | + public function getHref($element, $responseElement="", $parameters=array()) { |
|
| 620 | + $parameters['attr']='href'; |
|
| 621 | 621 | if (JString::isNull($responseElement)) { |
| 622 | - $responseElement = '%$(self).attr("data-target")%'; |
|
| 622 | + $responseElement='%$(self).attr("data-target")%'; |
|
| 623 | 623 | } else { |
| 624 | - $responseElement = '%$(self).attr("data-target") || "' . $responseElement . '"%'; |
|
| 624 | + $responseElement='%$(self).attr("data-target") || "'.$responseElement.'"%'; |
|
| 625 | 625 | } |
| 626 | - if (! isset($parameters['historize'])) { |
|
| 627 | - $parameters['historize'] = true; |
|
| 626 | + if (!isset($parameters['historize'])) { |
|
| 627 | + $parameters['historize']=true; |
|
| 628 | 628 | } |
| 629 | - if (! isset($parameters['jsCallback'])) { |
|
| 630 | - $parameters['jsCallback'] = 'var event = jQuery.Event( "getHref" );event.url = url;$(self).trigger(event);'; |
|
| 629 | + if (!isset($parameters['jsCallback'])) { |
|
| 630 | + $parameters['jsCallback']='var event = jQuery.Event( "getHref" );event.url = url;$(self).trigger(event);'; |
|
| 631 | 631 | } |
| 632 | 632 | return $this->getOnClick($element, "", $responseElement, $parameters); |
| 633 | 633 | } |
@@ -643,15 +643,15 @@ discard block |
||
| 643 | 643 | * default : array("preventDefault"=>true,"stopPropagation"=>true,"params"=>"{}","jsCallback"=>NULL,"attr"=>"href","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","jsCondition"=>NULL,"headers"=>null,"historize"=>true,"before"=>null,"listenerOn"=>false) |
| 644 | 644 | * @return $this |
| 645 | 645 | */ |
| 646 | - public function postHref($element, $responseElement = "", $parameters = array()) { |
|
| 647 | - $parameters['attr'] = 'href'; |
|
| 646 | + public function postHref($element, $responseElement="", $parameters=array()) { |
|
| 647 | + $parameters['attr']='href'; |
|
| 648 | 648 | if (JString::isNull($responseElement)) { |
| 649 | - $responseElement = '%$(this).attr("data-target")%'; |
|
| 649 | + $responseElement='%$(this).attr("data-target")%'; |
|
| 650 | 650 | } else { |
| 651 | - $responseElement = '%$(self).attr("data-target") || "' . $responseElement . '"%'; |
|
| 651 | + $responseElement='%$(self).attr("data-target") || "'.$responseElement.'"%'; |
|
| 652 | 652 | } |
| 653 | - if (! isset($parameters['historize'])) { |
|
| 654 | - $parameters['historize'] = true; |
|
| 653 | + if (!isset($parameters['historize'])) { |
|
| 654 | + $parameters['historize']=true; |
|
| 655 | 655 | } |
| 656 | 656 | return $this->postOnClick($element, '', '{}', $responseElement, $parameters); |
| 657 | 657 | } |
@@ -667,29 +667,29 @@ discard block |
||
| 667 | 667 | * default : array("preventDefault"=>true,"stopPropagation"=>true,"params"=>"{}","jsCallback"=>NULL,"attr"=>"href","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","jsCondition"=>NULL,"headers"=>null,"historize"=>true,"before"=>null,"listenerOn"=>false) |
| 668 | 668 | * @return $this |
| 669 | 669 | */ |
| 670 | - public function postFormAction($element, $responseElement = "", $parameters = array()) { |
|
| 671 | - $parameters['attr'] = 'action'; |
|
| 670 | + public function postFormAction($element, $responseElement="", $parameters=array()) { |
|
| 671 | + $parameters['attr']='action'; |
|
| 672 | 672 | if (JString::isNull($responseElement)) { |
| 673 | - $responseElement = '%$(self).attr("data-target")%'; |
|
| 673 | + $responseElement='%$(self).attr("data-target")%'; |
|
| 674 | 674 | } else { |
| 675 | - $responseElement = '%$(self).attr("data-target") || "' . $responseElement . '"%'; |
|
| 675 | + $responseElement='%$(self).attr("data-target") || "'.$responseElement.'"%'; |
|
| 676 | 676 | } |
| 677 | - $formId = '%$(this).attr("id")%'; |
|
| 678 | - if (! isset($parameters['historize'])) { |
|
| 679 | - $parameters['historize'] = true; |
|
| 677 | + $formId='%$(this).attr("id")%'; |
|
| 678 | + if (!isset($parameters['historize'])) { |
|
| 679 | + $parameters['historize']=true; |
|
| 680 | 680 | } |
| 681 | - $parameters['preventDefault'] = true; |
|
| 682 | - if (! isset($parameters['hasLoader'])) { |
|
| 683 | - $parameters['hasLoader'] = '$(self).find("button, input[type=submit], input[type=button]")'; |
|
| 681 | + $parameters['preventDefault']=true; |
|
| 682 | + if (!isset($parameters['hasLoader'])) { |
|
| 683 | + $parameters['hasLoader']='$(self).find("button, input[type=submit], input[type=button]")'; |
|
| 684 | 684 | } |
| 685 | - if (! isset($parameters['jsCallback'])) { |
|
| 686 | - $parameters['jsCallback'] = 'var event = jQuery.Event( "postFormAction" );event.params = Object.fromEntries(new URLSearchParams(params));$(self).trigger(event);'; |
|
| 685 | + if (!isset($parameters['jsCallback'])) { |
|
| 686 | + $parameters['jsCallback']='var event = jQuery.Event( "postFormAction" );event.params = Object.fromEntries(new URLSearchParams(params));$(self).trigger(event);'; |
|
| 687 | 687 | } |
| 688 | 688 | return $this->postFormOn('submit', $element, '', $formId, $responseElement, $parameters); |
| 689 | 689 | } |
| 690 | 690 | |
| 691 | - private function _post($url, $params = '{}', $responseElement = '', $parameters = []) { |
|
| 692 | - $parameters['params'] = $params; |
|
| 691 | + private function _post($url, $params='{}', $responseElement='', $parameters=[]) { |
|
| 692 | + $parameters['params']=$params; |
|
| 693 | 693 | return $this->_ajax('POST', $url, $responseElement, $parameters); |
| 694 | 694 | } |
| 695 | 695 | |
@@ -705,8 +705,8 @@ discard block |
||
| 705 | 705 | * @param array $parameters |
| 706 | 706 | * default : array("jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false,"before"=>null) |
| 707 | 707 | */ |
| 708 | - public function post($url, $params = "{}", $responseElement = "", $parameters = []) { |
|
| 709 | - $parameters['immediatly'] = true; |
|
| 708 | + public function post($url, $params="{}", $responseElement="", $parameters=[]) { |
|
| 709 | + $parameters['immediatly']=true; |
|
| 710 | 710 | return $this->_post($url, $params, $responseElement, $parameters); |
| 711 | 711 | } |
| 712 | 712 | |
@@ -723,8 +723,8 @@ discard block |
||
| 723 | 723 | * @param array $parameters |
| 724 | 724 | * default : array("jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false,"before"=>null) |
| 725 | 725 | */ |
| 726 | - public function postDeferred($url, $params = "{}", $responseElement = "", $parameters = []) { |
|
| 727 | - $parameters['immediatly'] = false; |
|
| 726 | + public function postDeferred($url, $params="{}", $responseElement="", $parameters=[]) { |
|
| 727 | + $parameters['immediatly']=false; |
|
| 728 | 728 | return $this->_post($url, $params, $responseElement, $parameters); |
| 729 | 729 | } |
| 730 | 730 | |
@@ -743,9 +743,9 @@ discard block |
||
| 743 | 743 | * @param array $parameters |
| 744 | 744 | * default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false,"before"=>null,"listenerOn"=>false) |
| 745 | 745 | */ |
| 746 | - public function postOn($event, $element, $url, $params = "{}", $responseElement = "", $parameters = array()) { |
|
| 747 | - $parameters['method'] = 'post'; |
|
| 748 | - $parameters['params'] = $params; |
|
| 746 | + public function postOn($event, $element, $url, $params="{}", $responseElement="", $parameters=array()) { |
|
| 747 | + $parameters['method']='post'; |
|
| 748 | + $parameters['params']=$params; |
|
| 749 | 749 | return $this->ajaxOn($event, $element, $url, $responseElement, $parameters); |
| 750 | 750 | } |
| 751 | 751 | |
@@ -763,71 +763,71 @@ discard block |
||
| 763 | 763 | * @param array $parameters |
| 764 | 764 | * default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false,"before"=>null,"before"=>null,"listenerOn"=>false) |
| 765 | 765 | */ |
| 766 | - public function postOnClick($element, $url, $params = '{}', $responseElement = '', $parameters = array()) { |
|
| 766 | + public function postOnClick($element, $url, $params='{}', $responseElement='', $parameters=array()) { |
|
| 767 | 767 | return $this->postOn('click', $element, $url, $params, $responseElement, $parameters); |
| 768 | 768 | } |
| 769 | 769 | |
| 770 | - private function _postForm($url, $form, $responseElement, $parameters = []) { |
|
| 770 | + private function _postForm($url, $form, $responseElement, $parameters=[]) { |
|
| 771 | 771 | if (isset($this->params['ajax'])) { |
| 772 | 772 | extract($this->params['ajax']); |
| 773 | 773 | } |
| 774 | - $params = '{}'; |
|
| 775 | - $validation = false; |
|
| 774 | + $params='{}'; |
|
| 775 | + $validation=false; |
|
| 776 | 776 | \extract($parameters); |
| 777 | - $async = ($async) ? 'true' : 'false'; |
|
| 778 | - $jsCallback = isset($jsCallback) ? $jsCallback : ""; |
|
| 779 | - $retour = $this->_getAjaxUrl($url, $attr); |
|
| 780 | - $form = $this->_getFormElement($form); |
|
| 781 | - $retour .= "\n$('#'+" . $form . ").trigger('ajaxSubmit');"; |
|
| 782 | - if (! isset($contentType) || $contentType != 'false') { |
|
| 783 | - $retour .= "\nvar params=$('#'+" . $form . ").serialize();\n"; |
|
| 777 | + $async=($async) ? 'true' : 'false'; |
|
| 778 | + $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
|
| 779 | + $retour=$this->_getAjaxUrl($url, $attr); |
|
| 780 | + $form=$this->_getFormElement($form); |
|
| 781 | + $retour.="\n$('#'+".$form.").trigger('ajaxSubmit');"; |
|
| 782 | + if (!isset($contentType) || $contentType!='false') { |
|
| 783 | + $retour.="\nvar params=$('#'+".$form.").serialize();\n"; |
|
| 784 | 784 | if (isset($params)) { |
| 785 | - $retour .= "params+='&'+" . self::_correctParams($params) . ";\n"; |
|
| 785 | + $retour.="params+='&'+".self::_correctParams($params).";\n"; |
|
| 786 | 786 | } |
| 787 | 787 | } else { |
| 788 | - $retour .= "\nvar params=new FormData($('#'+" . $form . ")[0]);\n"; |
|
| 788 | + $retour.="\nvar params=new FormData($('#'+".$form.")[0]);\n"; |
|
| 789 | 789 | } |
| 790 | - $responseElement = $this->_getResponseElement($responseElement); |
|
| 791 | - $retour .= "var self=this;\n"; |
|
| 792 | - $before = isset($before) ? $before : ""; |
|
| 793 | - $retour .= $before; |
|
| 794 | - if ($hasLoader === true) { |
|
| 790 | + $responseElement=$this->_getResponseElement($responseElement); |
|
| 791 | + $retour.="var self=this;\n"; |
|
| 792 | + $before=isset($before) ? $before : ""; |
|
| 793 | + $retour.=$before; |
|
| 794 | + if ($hasLoader===true) { |
|
| 795 | 795 | $this->addLoading($retour, $responseElement, $ajaxLoader); |
| 796 | - } elseif ($hasLoader === 'response') { |
|
| 796 | + } elseif ($hasLoader==='response') { |
|
| 797 | 797 | $this->addResponseLoading($retour, $responseElement, $ajaxLoader); |
| 798 | - } elseif ($hasLoader === 'internal-x') { |
|
| 798 | + } elseif ($hasLoader==='internal-x') { |
|
| 799 | 799 | $this->addLoading($retour, '$(this).closest(".item, .step")', $ajaxLoader); |
| 800 | - } elseif ($hasLoader === 'internal') { |
|
| 801 | - $retour .= "\n$(this).addClass('loading');"; |
|
| 800 | + } elseif ($hasLoader==='internal') { |
|
| 801 | + $retour.="\n$(this).addClass('loading');"; |
|
| 802 | 802 | } elseif (\is_string($hasLoader)) { |
| 803 | - $retour .= "\n$hasLoader.addClass('loading');"; |
|
| 803 | + $retour.="\n$hasLoader.addClass('loading');"; |
|
| 804 | 804 | } |
| 805 | - $ajaxParameters = [ |
|
| 805 | + $ajaxParameters=[ |
|
| 806 | 806 | "url" => "url", |
| 807 | 807 | "method" => "'POST'", |
| 808 | 808 | "data" => "params", |
| 809 | 809 | "async" => $async |
| 810 | 810 | ]; |
| 811 | 811 | if (isset($headers)) { |
| 812 | - $ajaxParameters["headers"] = $headers; |
|
| 812 | + $ajaxParameters["headers"]=$headers; |
|
| 813 | 813 | } |
| 814 | 814 | if (isset($partial)) { |
| 815 | - $ajaxParameters["xhr"] = "xhrProvider"; |
|
| 816 | - $retour .= "var xhr = $.ajaxSettings.xhr();function xhrProvider() {return xhr;};xhr.onreadystatechange = function (e) { if (3==e.target.readyState){let response=e.target.responseText;" . $partial . ";}; };"; |
|
| 815 | + $ajaxParameters["xhr"]="xhrProvider"; |
|
| 816 | + $retour.="var xhr = $.ajaxSettings.xhr();function xhrProvider() {return xhr;};xhr.onreadystatechange = function (e) { if (3==e.target.readyState){let response=e.target.responseText;".$partial.";}; };"; |
|
| 817 | 817 | } |
| 818 | 818 | $this->createAjaxParameters($ajaxParameters, $parameters); |
| 819 | - $retour .= "$.ajax({" . $this->implodeAjaxParameters($ajaxParameters) . "}).done(function( data ) {\n"; |
|
| 820 | - $retour .= $this->_getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback, $hasLoader) . "});\n"; |
|
| 819 | + $retour.="$.ajax({".$this->implodeAjaxParameters($ajaxParameters)."}).done(function( data ) {\n"; |
|
| 820 | + $retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback, $hasLoader)."});\n"; |
|
| 821 | 821 | |
| 822 | 822 | if ($validation) { |
| 823 | - $retour = "$('#'+" . $form . ").validate({submitHandler: function(form) { |
|
| 824 | - " . $retour . " |
|
| 823 | + $retour="$('#'+".$form.").validate({submitHandler: function(form) { |
|
| 824 | + " . $retour." |
|
| 825 | 825 | }});\n"; |
| 826 | - $retour .= "$('#'+" . $form . ").submit();\n"; |
|
| 826 | + $retour.="$('#'+".$form.").submit();\n"; |
|
| 827 | 827 | } |
| 828 | - $retour = $this->_addJsCondition($jsCondition, $retour); |
|
| 828 | + $retour=$this->_addJsCondition($jsCondition, $retour); |
|
| 829 | 829 | if ($immediatly) |
| 830 | - $this->jquery_code_for_compile[] = $retour; |
|
| 830 | + $this->jquery_code_for_compile[]=$retour; |
|
| 831 | 831 | return $retour; |
| 832 | 832 | } |
| 833 | 833 | |
@@ -843,8 +843,8 @@ discard block |
||
| 843 | 843 | * @param array $parameters |
| 844 | 844 | * default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false,"before"=>null) |
| 845 | 845 | */ |
| 846 | - public function postForm($url, $form, $responseElement, $parameters = []) { |
|
| 847 | - $parameters['immediatly'] = true; |
|
| 846 | + public function postForm($url, $form, $responseElement, $parameters=[]) { |
|
| 847 | + $parameters['immediatly']=true; |
|
| 848 | 848 | return $this->_postForm($url, $form, $responseElement, $parameters); |
| 849 | 849 | } |
| 850 | 850 | |
@@ -861,8 +861,8 @@ discard block |
||
| 861 | 861 | * @param array $parameters |
| 862 | 862 | * default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false,"before"=>null) |
| 863 | 863 | */ |
| 864 | - public function postFormDeferred($url, $form, $responseElement, $parameters = []) { |
|
| 865 | - $parameters['immediatly'] = false; |
|
| 864 | + public function postFormDeferred($url, $form, $responseElement, $parameters=[]) { |
|
| 865 | + $parameters['immediatly']=false; |
|
| 866 | 866 | return $this->_postForm($url, $form, $responseElement, $parameters); |
| 867 | 867 | } |
| 868 | 868 | |
@@ -879,7 +879,7 @@ discard block |
||
| 879 | 879 | * @param array $parameters |
| 880 | 880 | * default : array("preventDefault"=>true,"stopPropagation"=>true,"validation"=>false,"params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>null,"headers"=>null,"historize"=>false,"before"=>null,"listenerOn"=>false) |
| 881 | 881 | */ |
| 882 | - public function postFormOn($event, $element, $url, $form, $responseElement = "", $parameters = array()) { |
|
| 882 | + public function postFormOn($event, $element, $url, $form, $responseElement="", $parameters=array()) { |
|
| 883 | 883 | $this->setDefaultParameters($parameters, [ |
| 884 | 884 | 'preventDefault' => true, |
| 885 | 885 | 'stopPropagation' => true, |
@@ -901,11 +901,11 @@ discard block |
||
| 901 | 901 | * @param array $parameters |
| 902 | 902 | * default : array("preventDefault"=>true,"stopPropagation"=>true,"validation"=>false,"params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>null,"headers"=>null,"historize"=>false,"before"=>null,"listenerOn"=>false) |
| 903 | 903 | */ |
| 904 | - public function postFormOnClick($element, $url, $form, $responseElement = "", $parameters = array()) { |
|
| 904 | + public function postFormOnClick($element, $url, $form, $responseElement="", $parameters=array()) { |
|
| 905 | 905 | return $this->postFormOn("click", $element, $url, $form, $responseElement, $parameters); |
| 906 | 906 | } |
| 907 | 907 | |
| 908 | - public function addCsrf($name = 'csrf-token') { |
|
| 908 | + public function addCsrf($name='csrf-token') { |
|
| 909 | 909 | return " |
| 910 | 910 | $.ajaxSetup({ |
| 911 | 911 | beforeSend: function(xhr, settings) { |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | */ |
| 37 | 37 | trait FieldAsTrait { |
| 38 | 38 | |
| 39 | - abstract protected function _getFieldIdentifier($prefix, $name = ""); |
|
| 39 | + abstract protected function _getFieldIdentifier($prefix, $name=""); |
|
| 40 | 40 | |
| 41 | 41 | abstract public function setValueFunction($index, $callback); |
| 42 | 42 | |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | |
| 45 | 45 | abstract protected function _getFieldCaption($index); |
| 46 | 46 | |
| 47 | - abstract protected function _buttonAsSubmit(BaseHtml &$button, $event, $url, $responseElement = NULL, $parameters = NULL); |
|
| 47 | + abstract protected function _buttonAsSubmit(BaseHtml &$button, $event, $url, $responseElement=NULL, $parameters=NULL); |
|
| 48 | 48 | |
| 49 | 49 | private $_speProperties; |
| 50 | 50 | |
@@ -53,9 +53,9 @@ discard block |
||
| 53 | 53 | * @param HtmlFormField $element |
| 54 | 54 | * @param array $attributes |
| 55 | 55 | */ |
| 56 | - protected function _applyAttributes(BaseHtml $element, &$attributes, $index, $instance = null) { |
|
| 56 | + protected function _applyAttributes(BaseHtml $element, &$attributes, $index, $instance=null) { |
|
| 57 | 57 | if (isset($attributes["jsCallback"])) { |
| 58 | - $callback = $attributes["jsCallback"]; |
|
| 58 | + $callback=$attributes["jsCallback"]; |
|
| 59 | 59 | if (\is_callable($callback)) { |
| 60 | 60 | $callback($element, $instance, $index, InstanceViewer::$index); |
| 61 | 61 | } |
@@ -66,15 +66,15 @@ discard block |
||
| 66 | 66 | $element->fromArray($attributes); |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | - private function _getLabelField($caption, $icon = NULL) { |
|
| 70 | - $label = new HtmlLabel($this->_getFieldIdentifier("lbl"), $caption, $icon); |
|
| 69 | + private function _getLabelField($caption, $icon=NULL) { |
|
| 70 | + $label=new HtmlLabel($this->_getFieldIdentifier("lbl"), $caption, $icon); |
|
| 71 | 71 | return $label; |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | protected function _addRules(HtmlFormField $element, &$attributes) { |
| 75 | 75 | if (isset($attributes["rules"])) { |
| 76 | - $this->_hasRules = true; |
|
| 77 | - $rules = $attributes["rules"]; |
|
| 76 | + $this->_hasRules=true; |
|
| 77 | + $rules=$attributes["rules"]; |
|
| 78 | 78 | if (\is_array($rules)) { |
| 79 | 79 | $element->addRules($rules); |
| 80 | 80 | } else { |
@@ -90,24 +90,24 @@ discard block |
||
| 90 | 90 | return $field; |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | - protected function _fieldAs($elementCallback, &$index, $attributes = NULL, $prefix = null) { |
|
| 94 | - $this->setValueFunction($index, function ($value, $instance, $index, $rowIndex) use (&$attributes, $elementCallback, $prefix) { |
|
| 95 | - $caption = $this->_getFieldCaption($index); |
|
| 96 | - $name = $this->_getFieldName($index); |
|
| 97 | - $id = $this->_getFieldIdentifier($prefix, $name); |
|
| 93 | + protected function _fieldAs($elementCallback, &$index, $attributes=NULL, $prefix=null) { |
|
| 94 | + $this->setValueFunction($index, function($value, $instance, $index, $rowIndex) use (&$attributes, $elementCallback, $prefix) { |
|
| 95 | + $caption=$this->_getFieldCaption($index); |
|
| 96 | + $name=$this->_getFieldName($index); |
|
| 97 | + $id=$this->_getFieldIdentifier($prefix, $name); |
|
| 98 | 98 | if (isset($attributes["name"])) { |
| 99 | - $name = $attributes["name"]; |
|
| 99 | + $name=$attributes["name"]; |
|
| 100 | 100 | unset($attributes["name"]); |
| 101 | 101 | } |
| 102 | - $element = $elementCallback($id, $name, $value, $caption); |
|
| 102 | + $element=$elementCallback($id, $name, $value, $caption); |
|
| 103 | 103 | if (isset($this->_speProperties[$index])) { |
| 104 | 104 | $attributes ??= []; |
| 105 | - $attributes += $this->_speProperties[$index]; |
|
| 105 | + $attributes+=$this->_speProperties[$index]; |
|
| 106 | 106 | } |
| 107 | 107 | if (\is_array($attributes)) { |
| 108 | 108 | $this->_applyAttributes($element, $attributes, $index, $instance); |
| 109 | 109 | } |
| 110 | - $element->setDisabled(! $this->_edition); |
|
| 110 | + $element->setDisabled(!$this->_edition); |
|
| 111 | 111 | return $element; |
| 112 | 112 | }); |
| 113 | 113 | return $this; |
@@ -123,48 +123,48 @@ discard block |
||
| 123 | 123 | */ |
| 124 | 124 | public function setPropertyValues($property, $indexValues) { |
| 125 | 125 | foreach ($indexValues as $index => $value) { |
| 126 | - $ind = $this->_getIndex($index); |
|
| 127 | - $this->_speProperties[$ind][$property] = $value; |
|
| 126 | + $ind=$this->_getIndex($index); |
|
| 127 | + $this->_speProperties[$ind][$property]=$value; |
|
| 128 | 128 | } |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | - public function fieldAsProgress($index, $label = NULL, $attributes = array()) { |
|
| 132 | - $this->setValueFunction($index, function ($value) use ($label, $attributes) { |
|
| 133 | - $pb = new HtmlProgress($this->_getFieldIdentifier("pb"), $value, $label, $attributes); |
|
| 131 | + public function fieldAsProgress($index, $label=NULL, $attributes=array()) { |
|
| 132 | + $this->setValueFunction($index, function($value) use ($label, $attributes) { |
|
| 133 | + $pb=new HtmlProgress($this->_getFieldIdentifier("pb"), $value, $label, $attributes); |
|
| 134 | 134 | return $pb; |
| 135 | 135 | }); |
| 136 | 136 | return $this; |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | - public function fieldAsRating($index, $max = 5, $icon = "") { |
|
| 140 | - $this->setValueFunction($index, function ($value) use ($max, $icon) { |
|
| 141 | - $rating = new HtmlRating($this->_getFieldIdentifier("rat"), $value, $max, $icon); |
|
| 139 | + public function fieldAsRating($index, $max=5, $icon="") { |
|
| 140 | + $this->setValueFunction($index, function($value) use ($max, $icon) { |
|
| 141 | + $rating=new HtmlRating($this->_getFieldIdentifier("rat"), $value, $max, $icon); |
|
| 142 | 142 | return $rating; |
| 143 | 143 | }); |
| 144 | 144 | return $this; |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | - public function fieldAsLabel($index, $icon = NULL, $attributes = NULL) { |
|
| 148 | - return $this->_fieldAs(function ($id, $name, $value) use ($icon) { |
|
| 149 | - $lbl = new HtmlLabel($id, $value); |
|
| 147 | + public function fieldAsLabel($index, $icon=NULL, $attributes=NULL) { |
|
| 148 | + return $this->_fieldAs(function($id, $name, $value) use ($icon) { |
|
| 149 | + $lbl=new HtmlLabel($id, $value); |
|
| 150 | 150 | if (isset($icon)) |
| 151 | 151 | $lbl->addIcon($icon); |
| 152 | 152 | return $lbl; |
| 153 | 153 | }, $index, $attributes, "label"); |
| 154 | 154 | } |
| 155 | 155 | |
| 156 | - public function fieldAsHeader($index, $niveau = 1, $icon = NULL, $attributes = NULL) { |
|
| 157 | - return $this->_fieldAs(function ($id, $name, $value) use ($niveau, $icon) { |
|
| 158 | - $header = new HtmlHeader($id, $niveau, $value); |
|
| 156 | + public function fieldAsHeader($index, $niveau=1, $icon=NULL, $attributes=NULL) { |
|
| 157 | + return $this->_fieldAs(function($id, $name, $value) use ($niveau, $icon) { |
|
| 158 | + $header=new HtmlHeader($id, $niveau, $value); |
|
| 159 | 159 | if (isset($icon)) |
| 160 | 160 | $header->asIcon($icon, $value); |
| 161 | 161 | return $header; |
| 162 | 162 | }, $index, $attributes, "header"); |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | - public function fieldAsImage($index, $size = Size::MINI, $circular = false) { |
|
| 166 | - $this->setValueFunction($index, function ($img) use ($size, $circular) { |
|
| 167 | - $image = new HtmlImage($this->_getFieldIdentifier("image"), $img); |
|
| 165 | + public function fieldAsImage($index, $size=Size::MINI, $circular=false) { |
|
| 166 | + $this->setValueFunction($index, function($img) use ($size, $circular) { |
|
| 167 | + $image=new HtmlImage($this->_getFieldIdentifier("image"), $img); |
|
| 168 | 168 | $image->setSize($size); |
| 169 | 169 | if ($circular) |
| 170 | 170 | $image->setCircular(); |
@@ -174,65 +174,65 @@ discard block |
||
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | public function fieldAsFlag($index) { |
| 177 | - $this->setValueFunction($index, function ($flag) { |
|
| 178 | - $flag = new HtmlFlag($this->_getFieldIdentifier("flag"), $flag); |
|
| 177 | + $this->setValueFunction($index, function($flag) { |
|
| 178 | + $flag=new HtmlFlag($this->_getFieldIdentifier("flag"), $flag); |
|
| 179 | 179 | return $flag; |
| 180 | 180 | }); |
| 181 | 181 | return $this; |
| 182 | 182 | } |
| 183 | 183 | |
| 184 | 184 | public function fieldAsIcon($index) { |
| 185 | - $this->setValueFunction($index, function ($icon) { |
|
| 186 | - $icon = new HtmlIcon($this->_getFieldIdentifier("icon"), $icon); |
|
| 185 | + $this->setValueFunction($index, function($icon) { |
|
| 186 | + $icon=new HtmlIcon($this->_getFieldIdentifier("icon"), $icon); |
|
| 187 | 187 | return $icon; |
| 188 | 188 | }); |
| 189 | 189 | return $this; |
| 190 | 190 | } |
| 191 | 191 | |
| 192 | - public function fieldAsAvatar($index, $attributes = NULL) { |
|
| 193 | - return $this->_fieldAs(function ($id, $name, $value) { |
|
| 194 | - $img = new HtmlImage($id, $value); |
|
| 192 | + public function fieldAsAvatar($index, $attributes=NULL) { |
|
| 193 | + return $this->_fieldAs(function($id, $name, $value) { |
|
| 194 | + $img=new HtmlImage($id, $value); |
|
| 195 | 195 | $img->asAvatar(); |
| 196 | 196 | return $img; |
| 197 | 197 | }, $index, $attributes, "avatar"); |
| 198 | 198 | } |
| 199 | 199 | |
| 200 | - public function fieldAsRadio($index, $attributes = NULL) { |
|
| 201 | - return $this->_fieldAs(function ($id, $name, $value) use ($attributes) { |
|
| 202 | - $input = new HtmlFormRadio($id, $name, $value, $value); |
|
| 200 | + public function fieldAsRadio($index, $attributes=NULL) { |
|
| 201 | + return $this->_fieldAs(function($id, $name, $value) use ($attributes) { |
|
| 202 | + $input=new HtmlFormRadio($id, $name, $value, $value); |
|
| 203 | 203 | return $this->_prepareFormFields($input, $name, $attributes); |
| 204 | 204 | }, $index, $attributes, "radio"); |
| 205 | 205 | } |
| 206 | 206 | |
| 207 | - public function fieldAsRadios($index, $elements = [], $attributes = NULL) { |
|
| 208 | - return $this->_fieldAs(function ($id, $name, $value, $caption) use ($elements) { |
|
| 207 | + public function fieldAsRadios($index, $elements=[], $attributes=NULL) { |
|
| 208 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($elements) { |
|
| 209 | 209 | return HtmlFormFields::radios($name, $elements, $caption, $value); |
| 210 | 210 | }, $index, $attributes, "radios"); |
| 211 | 211 | } |
| 212 | 212 | |
| 213 | - public function fieldAsList($index, $classNames = "", $attributes = NULL) { |
|
| 214 | - return $this->_fieldAs(function ($id, $name, $value, $caption) use ($classNames) { |
|
| 215 | - $result = new HtmlList($name, $value); |
|
| 213 | + public function fieldAsList($index, $classNames="", $attributes=NULL) { |
|
| 214 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($classNames) { |
|
| 215 | + $result=new HtmlList($name, $value); |
|
| 216 | 216 | $result->addClass($classNames); |
| 217 | 217 | return $result; |
| 218 | 218 | }, $index, $attributes, "list"); |
| 219 | 219 | } |
| 220 | 220 | |
| 221 | - public function fieldAsInput($index, $attributes = NULL) { |
|
| 222 | - return $this->_fieldAs(function ($id, $name, $value, $caption) use ($attributes) { |
|
| 223 | - $input = new HtmlFormInput($id, $caption, "text", $value); |
|
| 221 | + public function fieldAsInput($index, $attributes=NULL) { |
|
| 222 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($attributes) { |
|
| 223 | + $input=new HtmlFormInput($id, $caption, "text", $value); |
|
| 224 | 224 | return $this->_prepareFormFields($input, $name, $attributes); |
| 225 | 225 | }, $index, $attributes, "input"); |
| 226 | 226 | } |
| 227 | 227 | |
| 228 | - public function fieldAsLabeledInput($index, $attributes = NULL) { |
|
| 229 | - return $this->_fieldAs(function ($id, $name, $value, $caption) use ($attributes) { |
|
| 230 | - $input = new HtmlFormInput($id, '', 'text', $value, $caption); |
|
| 231 | - $required = ''; |
|
| 228 | + public function fieldAsLabeledInput($index, $attributes=NULL) { |
|
| 229 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($attributes) { |
|
| 230 | + $input=new HtmlFormInput($id, '', 'text', $value, $caption); |
|
| 231 | + $required=''; |
|
| 232 | 232 | if (isset($attributes['rules'])) { |
| 233 | - $rules = json_encode($attributes['rules']); |
|
| 234 | - if (strpos($rules, 'empty') !== false) { |
|
| 235 | - $required = 'required'; |
|
| 233 | + $rules=json_encode($attributes['rules']); |
|
| 234 | + if (strpos($rules, 'empty')!==false) { |
|
| 235 | + $required='required'; |
|
| 236 | 236 | } |
| 237 | 237 | } |
| 238 | 238 | $input->getField() |
@@ -243,80 +243,80 @@ discard block |
||
| 243 | 243 | }, $index, $attributes, 'input'); |
| 244 | 244 | } |
| 245 | 245 | |
| 246 | - public function fieldAsDataList($index, ?array $items = [], $attributes = NULL) { |
|
| 247 | - return $this->_fieldAs(function ($id, $name, $value, $caption) use ($attributes, $items) { |
|
| 248 | - $input = new HtmlFormInput($id, $caption, "text", $value); |
|
| 246 | + public function fieldAsDataList($index, ?array $items=[], $attributes=NULL) { |
|
| 247 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($attributes, $items) { |
|
| 248 | + $input=new HtmlFormInput($id, $caption, "text", $value); |
|
| 249 | 249 | $input->getField() |
| 250 | 250 | ->addDataList($items); |
| 251 | 251 | return $this->_prepareFormFields($input, $name, $attributes); |
| 252 | 252 | }, $index, $attributes, "input"); |
| 253 | 253 | } |
| 254 | 254 | |
| 255 | - public function fieldAsFile($index, $attributes = NULL) { |
|
| 255 | + public function fieldAsFile($index, $attributes=NULL) { |
|
| 256 | 256 | if (isset($this->_form)) { |
| 257 | 257 | $this->_form->setProperty('enctype', 'multipart/form-data'); |
| 258 | 258 | } |
| 259 | - return $this->_fieldAs(function ($id, $name, $value, $caption) use ($attributes) { |
|
| 260 | - $input = new HtmlFormInput($id, $caption); |
|
| 259 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($attributes) { |
|
| 260 | + $input=new HtmlFormInput($id, $caption); |
|
| 261 | 261 | $input->asFile(); |
| 262 | 262 | return $this->_prepareFormFields($input, $name, $attributes); |
| 263 | 263 | }, $index, $attributes, "input"); |
| 264 | 264 | } |
| 265 | 265 | |
| 266 | - public function fieldAsTextarea($index, $attributes = NULL) { |
|
| 267 | - return $this->_fieldAs(function ($id, $name, $value, $caption) use ($attributes) { |
|
| 268 | - $textarea = new HtmlFormTextarea($id, $caption, $value); |
|
| 266 | + public function fieldAsTextarea($index, $attributes=NULL) { |
|
| 267 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($attributes) { |
|
| 268 | + $textarea=new HtmlFormTextarea($id, $caption, $value); |
|
| 269 | 269 | return $this->_prepareFormFields($textarea, $name, $attributes); |
| 270 | 270 | }, $index, $attributes, "textarea"); |
| 271 | 271 | } |
| 272 | 272 | |
| 273 | - public function fieldAsElement($index, $tagName = "div", $baseClass = "", $attributes = NULL) { |
|
| 274 | - return $this->_fieldAs(function ($id, $name, $value, $caption) use ($attributes, $tagName, $baseClass) { |
|
| 275 | - $div = new HtmlSemDoubleElement($id, $tagName, $baseClass); |
|
| 273 | + public function fieldAsElement($index, $tagName="div", $baseClass="", $attributes=NULL) { |
|
| 274 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($attributes, $tagName, $baseClass) { |
|
| 275 | + $div=new HtmlSemDoubleElement($id, $tagName, $baseClass); |
|
| 276 | 276 | $div->setContent(\htmlentities($value)); |
| 277 | - $textarea = new HtmlFormField("field-" . $id, $div, $caption); |
|
| 277 | + $textarea=new HtmlFormField("field-".$id, $div, $caption); |
|
| 278 | 278 | return $this->_prepareFormFields($textarea, $name, $attributes); |
| 279 | 279 | }, $index, $attributes, "element"); |
| 280 | 280 | } |
| 281 | 281 | |
| 282 | - public function fieldAsHidden($index, $attributes = NULL) { |
|
| 283 | - if (! \is_array($attributes)) { |
|
| 284 | - $attributes = []; |
|
| 282 | + public function fieldAsHidden($index, $attributes=NULL) { |
|
| 283 | + if (!\is_array($attributes)) { |
|
| 284 | + $attributes=[]; |
|
| 285 | 285 | } |
| 286 | - $attributes["inputType"] = "hidden"; |
|
| 287 | - $attributes["style"] = "display:none;"; |
|
| 286 | + $attributes["inputType"]="hidden"; |
|
| 287 | + $attributes["style"]="display:none;"; |
|
| 288 | 288 | return $this->fieldAsInput($index, $attributes); |
| 289 | 289 | } |
| 290 | 290 | |
| 291 | - public function fieldAsCheckbox($index, $attributes = NULL) { |
|
| 292 | - return $this->_fieldAs(function ($id, $name, $value, $caption) use ($attributes) { |
|
| 293 | - if ($caption === null || $caption === "") |
|
| 294 | - $caption = ""; |
|
| 295 | - $input = new HtmlFormCheckbox($id, $caption, $this->_instanceViewer->getIdentifier()); |
|
| 291 | + public function fieldAsCheckbox($index, $attributes=NULL) { |
|
| 292 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($attributes) { |
|
| 293 | + if ($caption===null || $caption==="") |
|
| 294 | + $caption=""; |
|
| 295 | + $input=new HtmlFormCheckbox($id, $caption, $this->_instanceViewer->getIdentifier()); |
|
| 296 | 296 | $input->setChecked(JString::isBooleanTrue($value)); |
| 297 | 297 | return $this->_prepareFormFields($input, $name, $attributes); |
| 298 | 298 | }, $index, $attributes, "ck"); |
| 299 | 299 | } |
| 300 | 300 | |
| 301 | - public function fieldAsDropDown($index, $elements = [], $multiple = false, $attributes = NULL) { |
|
| 302 | - return $this->_fieldAs(function ($id, $name, $value, $caption) use ($elements, $multiple, $attributes) { |
|
| 303 | - $dd = new HtmlFormDropdown($id, $elements, $caption, $value ?? ''); |
|
| 301 | + public function fieldAsDropDown($index, $elements=[], $multiple=false, $attributes=NULL) { |
|
| 302 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($elements, $multiple, $attributes) { |
|
| 303 | + $dd=new HtmlFormDropdown($id, $elements, $caption, $value ?? ''); |
|
| 304 | 304 | $dd->asSelect($name, $multiple); |
| 305 | 305 | return $this->_prepareFormFields($dd, $name, $attributes); |
| 306 | 306 | }, $index, $attributes, "dd"); |
| 307 | 307 | } |
| 308 | 308 | |
| 309 | - public function fieldAsMessage($index, $attributes = NULL) { |
|
| 310 | - return $this->_fieldAs(function ($id, $name, $value, $caption) { |
|
| 311 | - $mess = new HtmlMessage("message-" . $id, $caption); |
|
| 309 | + public function fieldAsMessage($index, $attributes=NULL) { |
|
| 310 | + return $this->_fieldAs(function($id, $name, $value, $caption) { |
|
| 311 | + $mess=new HtmlMessage("message-".$id, $caption); |
|
| 312 | 312 | $mess->addHeader($value); |
| 313 | 313 | return $mess; |
| 314 | 314 | }, $index, $attributes, "message"); |
| 315 | 315 | } |
| 316 | 316 | |
| 317 | - public function fieldAsLink($index, $attributes = NULL) { |
|
| 318 | - return $this->_fieldAs(function ($id, $name, $value, $caption) { |
|
| 319 | - $lnk = new HtmlLink("message-" . $id, "#", $caption); |
|
| 317 | + public function fieldAsLink($index, $attributes=NULL) { |
|
| 318 | + return $this->_fieldAs(function($id, $name, $value, $caption) { |
|
| 319 | + $lnk=new HtmlLink("message-".$id, "#", $caption); |
|
| 320 | 320 | return $lnk; |
| 321 | 321 | }, $index, $attributes, "link"); |
| 322 | 322 | } |
@@ -328,28 +328,28 @@ discard block |
||
| 328 | 328 | * an array or associative array $type=>$attributes |
| 329 | 329 | */ |
| 330 | 330 | public function fieldsAs(array $types) { |
| 331 | - $i = 0; |
|
| 331 | + $i=0; |
|
| 332 | 332 | if (JArray::isAssociative($types)) { |
| 333 | 333 | foreach ($types as $type => $attributes) { |
| 334 | 334 | if (\is_int($type)) |
| 335 | - $this->fieldAs($i ++, $attributes, []); |
|
| 335 | + $this->fieldAs($i++, $attributes, []); |
|
| 336 | 336 | else { |
| 337 | - $type = preg_replace('/\d/', '', $type); |
|
| 338 | - $this->fieldAs($i ++, $type, $attributes); |
|
| 337 | + $type=preg_replace('/\d/', '', $type); |
|
| 338 | + $this->fieldAs($i++, $type, $attributes); |
|
| 339 | 339 | } |
| 340 | 340 | } |
| 341 | 341 | } else { |
| 342 | 342 | foreach ($types as $type) { |
| 343 | - $this->fieldAs($i ++, $type); |
|
| 343 | + $this->fieldAs($i++, $type); |
|
| 344 | 344 | } |
| 345 | 345 | } |
| 346 | 346 | } |
| 347 | 347 | |
| 348 | - public function fieldAs($index, $type, $attributes = NULL) { |
|
| 349 | - $method = "fieldAs" . \ucfirst($type); |
|
| 348 | + public function fieldAs($index, $type, $attributes=NULL) { |
|
| 349 | + $method="fieldAs".\ucfirst($type); |
|
| 350 | 350 | if (\method_exists($this, $method)) { |
| 351 | - if (! \is_array($attributes)) { |
|
| 352 | - $attributes = [ |
|
| 351 | + if (!\is_array($attributes)) { |
|
| 352 | + $attributes=[ |
|
| 353 | 353 | $index |
| 354 | 354 | ]; |
| 355 | 355 | } else { |
@@ -362,17 +362,17 @@ discard block |
||
| 362 | 362 | } |
| 363 | 363 | } |
| 364 | 364 | |
| 365 | - public function fieldAsSubmit($index, $cssStyle = NULL, $url = NULL, $responseElement = NULL, $attributes = NULL) { |
|
| 366 | - return $this->_fieldAs(function ($id, $name, $value, $caption) use ($url, $responseElement, $cssStyle, $attributes) { |
|
| 367 | - $button = new HtmlButton($id, $caption, $cssStyle); |
|
| 365 | + public function fieldAsSubmit($index, $cssStyle=NULL, $url=NULL, $responseElement=NULL, $attributes=NULL) { |
|
| 366 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($url, $responseElement, $cssStyle, $attributes) { |
|
| 367 | + $button=new HtmlButton($id, $caption, $cssStyle); |
|
| 368 | 368 | $this->_buttonAsSubmit($button, "click", $url, $responseElement, @$attributes["ajax"]); |
| 369 | 369 | return $button; |
| 370 | 370 | }, $index, $attributes, "submit"); |
| 371 | 371 | } |
| 372 | 372 | |
| 373 | - public function fieldAsButton($index, $cssStyle = NULL, $attributes = NULL) { |
|
| 374 | - return $this->_fieldAs(function ($id, $name, $value, $caption) use ($cssStyle) { |
|
| 375 | - $button = new HtmlButton($id, $value, $cssStyle); |
|
| 373 | + public function fieldAsButton($index, $cssStyle=NULL, $attributes=NULL) { |
|
| 374 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($cssStyle) { |
|
| 375 | + $button=new HtmlButton($id, $value, $cssStyle); |
|
| 376 | 376 | return $button; |
| 377 | 377 | }, $index, $attributes, "button"); |
| 378 | 378 | } |
@@ -14,15 +14,15 @@ discard block |
||
| 14 | 14 | * @property boolean $_visibleHover |
| 15 | 15 | * @property InstanceViewer $_instanceViewer |
| 16 | 16 | */ |
| 17 | -trait DataTableFieldAsTrait{ |
|
| 18 | - protected $_buttons=["display","edit","delete"]; |
|
| 17 | +trait DataTableFieldAsTrait { |
|
| 18 | + protected $_buttons=["display", "edit", "delete"]; |
|
| 19 | 19 | protected $_buttonsColumn; |
| 20 | - abstract public function addField($field,$key=null); |
|
| 21 | - abstract public function insertField($index,$field,$key=null); |
|
| 22 | - abstract public function insertInField($index,$field,$key=null); |
|
| 23 | - abstract public function fieldAs($index,$type,$attributes=NULL); |
|
| 20 | + abstract public function addField($field, $key=null); |
|
| 21 | + abstract public function insertField($index, $field, $key=null); |
|
| 22 | + abstract public function insertInField($index, $field, $key=null); |
|
| 23 | + abstract public function fieldAs($index, $type, $attributes=NULL); |
|
| 24 | 24 | abstract protected function cleanIdentifier($id); |
| 25 | - abstract protected function _fieldAs($elementCallback,&$index,$attributes=NULL,$prefix=null); |
|
| 25 | + abstract protected function _fieldAs($elementCallback, &$index, $attributes=NULL, $prefix=null); |
|
| 26 | 26 | |
| 27 | 27 | /** |
| 28 | 28 | * @param string $caption |
@@ -30,8 +30,8 @@ discard block |
||
| 30 | 30 | * @param boolean $visibleHover |
| 31 | 31 | * @return callable |
| 32 | 32 | */ |
| 33 | - private function getFieldButtonCallable($caption,$visibleHover=true,$callback=null){ |
|
| 34 | - return $this->getCallable("getFieldButton",[$caption,$visibleHover],$callback); |
|
| 33 | + private function getFieldButtonCallable($caption, $visibleHover=true, $callback=null) { |
|
| 34 | + return $this->getCallable("getFieldButton", [$caption, $visibleHover], $callback); |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | /** |
@@ -40,20 +40,20 @@ discard block |
||
| 40 | 40 | * @param callable $callback |
| 41 | 41 | * @return callable |
| 42 | 42 | */ |
| 43 | - private function getCallable($thisCallback,$parameters,$callback=null){ |
|
| 44 | - $result=function($instance) use($thisCallback,$parameters,$callback){ |
|
| 45 | - $object=call_user_func_array(array($this,$thisCallback), $parameters); |
|
| 46 | - if(isset($callback)){ |
|
| 47 | - if(\is_callable($callback)){ |
|
| 48 | - $callback($object,$instance,$this->_instanceViewer->count()+1); |
|
| 43 | + private function getCallable($thisCallback, $parameters, $callback=null) { |
|
| 44 | + $result=function($instance) use($thisCallback, $parameters, $callback){ |
|
| 45 | + $object=call_user_func_array(array($this, $thisCallback), $parameters); |
|
| 46 | + if (isset($callback)) { |
|
| 47 | + if (\is_callable($callback)) { |
|
| 48 | + $callback($object, $instance, $this->_instanceViewer->count()+1); |
|
| 49 | 49 | } |
| 50 | 50 | } |
| 51 | - if($object instanceof HtmlSemDoubleElement){ |
|
| 51 | + if ($object instanceof HtmlSemDoubleElement) { |
|
| 52 | 52 | $id=$this->_instanceViewer->getIdentifier(); |
| 53 | - $object->setProperty("data-ajax",$id); |
|
| 54 | - if($object->propertyContains("class","visibleover")){ |
|
| 53 | + $object->setProperty("data-ajax", $id); |
|
| 54 | + if ($object->propertyContains("class", "visibleover")) { |
|
| 55 | 55 | $this->_visibleHover=true; |
| 56 | - $object->setProperty("style","visibility:hidden;"); |
|
| 56 | + $object->setProperty("style", "visibility:hidden;"); |
|
| 57 | 57 | } |
| 58 | 58 | } |
| 59 | 59 | return $object; |
@@ -65,16 +65,16 @@ discard block |
||
| 65 | 65 | * @param string $caption |
| 66 | 66 | * @return HtmlButton |
| 67 | 67 | */ |
| 68 | - private function getFieldButton($caption,$visibleHover=true){ |
|
| 69 | - $bt= new HtmlButton($this->cleanIdentifier($caption),$caption); |
|
| 70 | - if($visibleHover) |
|
| 68 | + private function getFieldButton($caption, $visibleHover=true) { |
|
| 69 | + $bt=new HtmlButton($this->cleanIdentifier($caption), $caption); |
|
| 70 | + if ($visibleHover) |
|
| 71 | 71 | $this->_visibleOver($bt); |
| 72 | 72 | return $bt; |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | - private function getFieldButtons($buttons,$visibleHover=true){ |
|
| 76 | - $bts=new HtmlButtonGroups("",$buttons); |
|
| 77 | - if($visibleHover) |
|
| 75 | + private function getFieldButtons($buttons, $visibleHover=true) { |
|
| 76 | + $bts=new HtmlButtonGroups("", $buttons); |
|
| 77 | + if ($visibleHover) |
|
| 78 | 78 | $this->_visibleOver($bts); |
| 79 | 79 | return $bts; |
| 80 | 80 | } |
@@ -88,19 +88,19 @@ discard block |
||
| 88 | 88 | * @param array $attributes associative array (<b>ajax</b> key is for ajax post) |
| 89 | 89 | * @return DataTable |
| 90 | 90 | */ |
| 91 | - public function fieldAsSubmit($index,$cssStyle=NULL,$url=NULL,$responseElement=NULL,$attributes=NULL){ |
|
| 92 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($url,$responseElement,$cssStyle,$attributes){ |
|
| 93 | - $button=new HtmlButton($id,$value,$cssStyle); |
|
| 94 | - $button->postOnClick($url,"$(event.target).closest('tr').find(':input').serialize()",$responseElement,$attributes["ajax"]); |
|
| 95 | - if(!isset($attributes["visibleHover"]) || $attributes["visibleHover"]) |
|
| 91 | + public function fieldAsSubmit($index, $cssStyle=NULL, $url=NULL, $responseElement=NULL, $attributes=NULL) { |
|
| 92 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($url, $responseElement, $cssStyle, $attributes){ |
|
| 93 | + $button=new HtmlButton($id, $value, $cssStyle); |
|
| 94 | + $button->postOnClick($url, "$(event.target).closest('tr').find(':input').serialize()", $responseElement, $attributes["ajax"]); |
|
| 95 | + if (!isset($attributes["visibleHover"]) || $attributes["visibleHover"]) |
|
| 96 | 96 | $this->_visibleOver($button); |
| 97 | 97 | return $button; |
| 98 | - }, $index,$attributes); |
|
| 98 | + }, $index, $attributes); |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | - protected function _visibleOver(BaseHtml $element){ |
|
| 101 | + protected function _visibleOver(BaseHtml $element) { |
|
| 102 | 102 | $this->_visibleHover=true; |
| 103 | - return $element->addToProperty("class", "visibleover")->setProperty("style","visibility:hidden;"); |
|
| 103 | + return $element->addToProperty("class", "visibleover")->setProperty("style", "visibility:hidden;"); |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | /** |
@@ -110,8 +110,8 @@ discard block |
||
| 110 | 110 | * @param boolean $visibleHover |
| 111 | 111 | * @return DataTable |
| 112 | 112 | */ |
| 113 | - public function addFieldButton($caption,$visibleHover=true,$callback=null){ |
|
| 114 | - $this->addField($this->getCallable("getFieldButton",[$caption,$visibleHover],$callback)); |
|
| 113 | + public function addFieldButton($caption, $visibleHover=true, $callback=null) { |
|
| 114 | + $this->addField($this->getCallable("getFieldButton", [$caption, $visibleHover], $callback)); |
|
| 115 | 115 | return $this; |
| 116 | 116 | } |
| 117 | 117 | |
@@ -122,8 +122,8 @@ discard block |
||
| 122 | 122 | * @param boolean $visibleHover |
| 123 | 123 | * @return DataTable |
| 124 | 124 | */ |
| 125 | - public function addFieldButtons($buttons,$visibleHover=true,$callback=null){ |
|
| 126 | - $this->addField($this->getCallable("getFieldButtons",[$buttons,$visibleHover],$callback)); |
|
| 125 | + public function addFieldButtons($buttons, $visibleHover=true, $callback=null) { |
|
| 126 | + $this->addField($this->getCallable("getFieldButtons", [$buttons, $visibleHover], $callback)); |
|
| 127 | 127 | return $this; |
| 128 | 128 | } |
| 129 | 129 | |
@@ -134,8 +134,8 @@ discard block |
||
| 134 | 134 | * @param callable $callback |
| 135 | 135 | * @return DataTable |
| 136 | 136 | */ |
| 137 | - public function insertFieldButton($index,$caption,$visibleHover=true,$callback=null){ |
|
| 138 | - $this->insertField($index, $this->getFieldButtonCallable($caption,$visibleHover,$callback)); |
|
| 137 | + public function insertFieldButton($index, $caption, $visibleHover=true, $callback=null) { |
|
| 138 | + $this->insertField($index, $this->getFieldButtonCallable($caption, $visibleHover, $callback)); |
|
| 139 | 139 | return $this; |
| 140 | 140 | } |
| 141 | 141 | |
@@ -146,25 +146,25 @@ discard block |
||
| 146 | 146 | * @param callable $callback |
| 147 | 147 | * @return DataTable |
| 148 | 148 | */ |
| 149 | - public function insertInFieldButton($index,$caption,$visibleHover=true,$callback=null,$key=null){ |
|
| 150 | - $this->insertInField($index, $this->getFieldButtonCallable($caption,$visibleHover,$callback),$key); |
|
| 149 | + public function insertInFieldButton($index, $caption, $visibleHover=true, $callback=null, $key=null) { |
|
| 150 | + $this->insertInField($index, $this->getFieldButtonCallable($caption, $visibleHover, $callback), $key); |
|
| 151 | 151 | return $this; |
| 152 | 152 | } |
| 153 | 153 | |
| 154 | - public function addDefaultButton($icon,$class=null,$visibleHover=true,$callback=null,$key=null){ |
|
| 155 | - $this->addField($this->getCallable("getDefaultButton",[$icon,$class,$visibleHover],$callback),$key); |
|
| 154 | + public function addDefaultButton($icon, $class=null, $visibleHover=true, $callback=null, $key=null) { |
|
| 155 | + $this->addField($this->getCallable("getDefaultButton", [$icon, $class, $visibleHover], $callback), $key); |
|
| 156 | 156 | return $this; |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | - public function insertDefaultButtonIn($index,$icon,$class=null,$visibleHover=true,$callback=null,$key=null){ |
|
| 160 | - $this->insertInField($index,$this->getCallable("getDefaultButton",[$icon,$class,$visibleHover],$callback),$key); |
|
| 159 | + public function insertDefaultButtonIn($index, $icon, $class=null, $visibleHover=true, $callback=null, $key=null) { |
|
| 160 | + $this->insertInField($index, $this->getCallable("getDefaultButton", [$icon, $class, $visibleHover], $callback), $key); |
|
| 161 | 161 | return $this; |
| 162 | 162 | } |
| 163 | 163 | |
| 164 | - private function getDefaultButton($icon,$class=null,$visibleHover=true){ |
|
| 165 | - $bt=$this->getFieldButton("",$visibleHover); |
|
| 164 | + private function getDefaultButton($icon, $class=null, $visibleHover=true) { |
|
| 165 | + $bt=$this->getFieldButton("", $visibleHover); |
|
| 166 | 166 | $bt->asIcon($icon); |
| 167 | - if(isset($class)) |
|
| 167 | + if (isset($class)) |
|
| 168 | 168 | $bt->addClass($class); |
| 169 | 169 | return $bt; |
| 170 | 170 | } |
@@ -176,9 +176,9 @@ discard block |
||
| 176 | 176 | * @param callable $callback this function takes the following arguments : $object=>the delete button, $instance : the active instance of the object |
| 177 | 177 | * @return DataTable |
| 178 | 178 | */ |
| 179 | - public function addDeleteButton($visibleHover=true,$deleteBehavior=[],$callback=null){ |
|
| 179 | + public function addDeleteButton($visibleHover=true, $deleteBehavior=[], $callback=null) { |
|
| 180 | 180 | $this->_deleteBehavior=$deleteBehavior; |
| 181 | - return $this->addDefaultButton("remove","_delete red basic",$visibleHover,$callback,"delete"); |
|
| 181 | + return $this->addDefaultButton("remove", "_delete red basic", $visibleHover, $callback, "delete"); |
|
| 182 | 182 | } |
| 183 | 183 | |
| 184 | 184 | /** |
@@ -188,9 +188,9 @@ discard block |
||
| 188 | 188 | * @param callable $callback this function takes the following arguments : $object=>the delete button, $instance : the active instance of the object |
| 189 | 189 | * @return DataTable |
| 190 | 190 | */ |
| 191 | - public function addEditButton($visibleHover=true,$editBehavior=[],$callback=null){ |
|
| 191 | + public function addEditButton($visibleHover=true, $editBehavior=[], $callback=null) { |
|
| 192 | 192 | $this->_editBehavior=$editBehavior; |
| 193 | - return $this->addDefaultButton("edit","_edit basic",$visibleHover,$callback,"edit"); |
|
| 193 | + return $this->addDefaultButton("edit", "_edit basic", $visibleHover, $callback, "edit"); |
|
| 194 | 194 | } |
| 195 | 195 | |
| 196 | 196 | /** |
@@ -200,9 +200,9 @@ discard block |
||
| 200 | 200 | * @param callable $callback this function takes the following arguments : $object=>the delete button, $instance : the active instance of the object |
| 201 | 201 | * @return DataTable |
| 202 | 202 | */ |
| 203 | - public function addDisplayButton($visibleHover=true,$displayBehavior=[],$callback=null){ |
|
| 203 | + public function addDisplayButton($visibleHover=true, $displayBehavior=[], $callback=null) { |
|
| 204 | 204 | $this->_displayBehavior=$displayBehavior; |
| 205 | - return $this->addDefaultButton("eye","_display basic",$visibleHover,$callback,"display"); |
|
| 205 | + return $this->addDefaultButton("eye", "_display basic", $visibleHover, $callback, "display"); |
|
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | /** |
@@ -213,10 +213,10 @@ discard block |
||
| 213 | 213 | * @param callable $callbackDelete this function takes the following arguments : $object=>the delete button, $instance : the active instance of the object |
| 214 | 214 | * @return DataTable |
| 215 | 215 | */ |
| 216 | - public function addEditDeleteButtons($visibleHover=true,$behavior=[],$callbackEdit=null,$callbackDelete=null){ |
|
| 217 | - $this->addEditButton($visibleHover,$behavior,$callbackEdit); |
|
| 216 | + public function addEditDeleteButtons($visibleHover=true, $behavior=[], $callbackEdit=null, $callbackDelete=null) { |
|
| 217 | + $this->addEditButton($visibleHover, $behavior, $callbackEdit); |
|
| 218 | 218 | $index=$this->_instanceViewer->visiblePropertiesCount()-1; |
| 219 | - $this->insertDeleteButtonIn($index,$visibleHover,$behavior,$callbackDelete); |
|
| 219 | + $this->insertDeleteButtonIn($index, $visibleHover, $behavior, $callbackDelete); |
|
| 220 | 220 | return $this; |
| 221 | 221 | } |
| 222 | 222 | |
@@ -229,28 +229,28 @@ discard block |
||
| 229 | 229 | * @param callable $callbackDelete this function takes the following arguments : $object=>the delete button, $instance : the active instance of the object |
| 230 | 230 | * @return DataTable |
| 231 | 231 | */ |
| 232 | - public function addAllButtons($visibleHover=true,$behavior=[],$callbackDisplay=null,$callbackEdit=null,$callbackDelete=null){ |
|
| 233 | - $this->addDisplayButton($visibleHover,$behavior,$callbackDisplay); |
|
| 232 | + public function addAllButtons($visibleHover=true, $behavior=[], $callbackDisplay=null, $callbackEdit=null, $callbackDelete=null) { |
|
| 233 | + $this->addDisplayButton($visibleHover, $behavior, $callbackDisplay); |
|
| 234 | 234 | $index=$this->_instanceViewer->visiblePropertiesCount()-1; |
| 235 | 235 | $this->_buttonsColumn=$index; |
| 236 | - $this->insertEditButtonIn($index,$visibleHover,$behavior,$callbackEdit); |
|
| 237 | - $this->insertDeleteButtonIn($index,$visibleHover,$behavior,$callbackDelete); |
|
| 236 | + $this->insertEditButtonIn($index, $visibleHover, $behavior, $callbackEdit); |
|
| 237 | + $this->insertDeleteButtonIn($index, $visibleHover, $behavior, $callbackDelete); |
|
| 238 | 238 | return $this; |
| 239 | 239 | } |
| 240 | 240 | |
| 241 | - public function insertDeleteButtonIn($index,$visibleHover=true,$deleteBehavior=[],$callback=null){ |
|
| 241 | + public function insertDeleteButtonIn($index, $visibleHover=true, $deleteBehavior=[], $callback=null) { |
|
| 242 | 242 | $this->_deleteBehavior=$deleteBehavior; |
| 243 | - return $this->insertDefaultButtonIn($index,"remove","_delete red basic",$visibleHover,$callback,"delete"); |
|
| 243 | + return $this->insertDefaultButtonIn($index, "remove", "_delete red basic", $visibleHover, $callback, "delete"); |
|
| 244 | 244 | } |
| 245 | 245 | |
| 246 | - public function insertEditButtonIn($index,$visibleHover=true,$editBehavior=[],$callback=null){ |
|
| 246 | + public function insertEditButtonIn($index, $visibleHover=true, $editBehavior=[], $callback=null) { |
|
| 247 | 247 | $this->_editBehavior=$editBehavior; |
| 248 | - return $this->insertDefaultButtonIn($index,"edit","_edit basic",$visibleHover,$callback,"edit"); |
|
| 248 | + return $this->insertDefaultButtonIn($index, "edit", "_edit basic", $visibleHover, $callback, "edit"); |
|
| 249 | 249 | } |
| 250 | 250 | |
| 251 | - public function insertDisplayButtonIn($index,$visibleHover=true,$displayBehavior=[],$callback=null){ |
|
| 251 | + public function insertDisplayButtonIn($index, $visibleHover=true, $displayBehavior=[], $callback=null) { |
|
| 252 | 252 | $this->_displayBehavior=$displayBehavior; |
| 253 | - return $this->insertDefaultButtonIn($index,"eye","_display basic",$visibleHover,$callback,"display"); |
|
| 253 | + return $this->insertDefaultButtonIn($index, "eye", "_display basic", $visibleHover, $callback, "display"); |
|
| 254 | 254 | } |
| 255 | 255 | |
| 256 | 256 | /** |
@@ -264,7 +264,7 @@ discard block |
||
| 264 | 264 | * @param array $_buttons |
| 265 | 265 | */ |
| 266 | 266 | public function setButtons($_buttons) { |
| 267 | - $this->_buttons = $_buttons; |
|
| 267 | + $this->_buttons=$_buttons; |
|
| 268 | 268 | return $this; |
| 269 | 269 | } |
| 270 | 270 | |
@@ -24,39 +24,39 @@ discard block |
||
| 24 | 24 | private $_inverted; |
| 25 | 25 | |
| 26 | 26 | public function __construct($identifier, $modelInstance=NULL) { |
| 27 | - parent::__construct($identifier, null,$modelInstance); |
|
| 27 | + parent::__construct($identifier, null, $modelInstance); |
|
| 28 | 28 | $this->_form=new HtmlForm($identifier); |
| 29 | 29 | $this->_init(new FormInstanceViewer($identifier), 'form', $this->_form, true); |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | - protected function _getFieldIdentifier($prefix,$name=''){ |
|
| 32 | + protected function _getFieldIdentifier($prefix, $name='') { |
|
| 33 | 33 | return $this->identifier."-{$name}-".$this->_instanceViewer->getIdentifier(); |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - public function compile(JsUtils $js=NULL,&$view=NULL){ |
|
| 37 | - if(!$this->_generated){ |
|
| 36 | + public function compile(JsUtils $js=NULL, &$view=NULL) { |
|
| 37 | + if (!$this->_generated) { |
|
| 38 | 38 | $this->_instanceViewer->setInstance($this->_modelInstance); |
| 39 | 39 | |
| 40 | 40 | $form=$this->content['form']; |
| 41 | 41 | $this->_generateContent($form); |
| 42 | 42 | |
| 43 | - if(isset($this->_toolbar)){ |
|
| 43 | + if (isset($this->_toolbar)) { |
|
| 44 | 44 | $this->_setToolbarPosition($form); |
| 45 | 45 | } |
| 46 | - $this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE,'form',PositionInTable::AFTERTABLE]); |
|
| 47 | - if($this->_inverted){ |
|
| 46 | + $this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE, 'form', PositionInTable::AFTERTABLE]); |
|
| 47 | + if ($this->_inverted) { |
|
| 48 | 48 | $this->content['form']->setInverted(true); |
| 49 | 49 | } |
| 50 | 50 | $this->_generated=true; |
| 51 | 51 | } |
| 52 | - return parent::compile($js,$view); |
|
| 52 | + return parent::compile($js, $view); |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | /** |
| 56 | 56 | * @param HtmlForm $form |
| 57 | 57 | */ |
| 58 | - protected function _generateContent($form){ |
|
| 59 | - $values= $this->_instanceViewer->getValues(); |
|
| 58 | + protected function _generateContent($form) { |
|
| 59 | + $values=$this->_instanceViewer->getValues(); |
|
| 60 | 60 | $count=$this->_instanceViewer->count(); |
| 61 | 61 | $separators=$this->_instanceViewer->getSeparators(); |
| 62 | 62 | $headers=$this->_instanceViewer->getHeaders(); |
@@ -65,42 +65,42 @@ discard block |
||
| 65 | 65 | \sort($separators); |
| 66 | 66 | $size=\count($separators); |
| 67 | 67 | $nb=0; |
| 68 | - if($size===1){ |
|
| 68 | + if ($size===1) { |
|
| 69 | 69 | $i=-1; |
| 70 | - foreach ($values as $k=>$v){ |
|
| 71 | - $this->_generateFields($form, [$v], $headers, $i, $wrappers,$nb++,$names[$k]??''); |
|
| 70 | + foreach ($values as $k=>$v) { |
|
| 71 | + $this->_generateFields($form, [$v], $headers, $i, $wrappers, $nb++, $names[$k] ?? ''); |
|
| 72 | 72 | $i++; |
| 73 | 73 | } |
| 74 | - }else{ |
|
| 74 | + } else { |
|
| 75 | 75 | $separators[]=$count; |
| 76 | - for($i=0;$i<$size;$i++){ |
|
| 77 | - $fields=\array_slice($values, $separators[$i]+1,$separators[$i+1]-$separators[$i]); |
|
| 78 | - $this->_generateFields($form, $fields, $headers, $separators[$i], $wrappers,$nb++,$names[$i]??''); |
|
| 76 | + for ($i=0; $i<$size; $i++) { |
|
| 77 | + $fields=\array_slice($values, $separators[$i]+1, $separators[$i+1]-$separators[$i]); |
|
| 78 | + $this->_generateFields($form, $fields, $headers, $separators[$i], $wrappers, $nb++, $names[$i] ?? ''); |
|
| 79 | 79 | } |
| 80 | 80 | } |
| 81 | - if($this->_hasRules && !$this->getForm()->hasValidationParams()){ |
|
| 81 | + if ($this->_hasRules && !$this->getForm()->hasValidationParams()) { |
|
| 82 | 82 | $this->setValidationParams(['inline'=>true]); |
| 83 | 83 | } |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | - protected function _generateFields($form, $values, $headers, $sepFirst, $wrappers, $nb, $name){ |
|
| 86 | + protected function _generateFields($form, $values, $headers, $sepFirst, $wrappers, $nb, $name) { |
|
| 87 | 87 | $wrapper=null; |
| 88 | - if(isset($headers[$sepFirst+1])) |
|
| 89 | - $form->addHeader($headers[$sepFirst+1],4,true); |
|
| 90 | - if(isset($wrappers[$sepFirst+1])){ |
|
| 88 | + if (isset($headers[$sepFirst+1])) |
|
| 89 | + $form->addHeader($headers[$sepFirst+1], 4, true); |
|
| 90 | + if (isset($wrappers[$sepFirst+1])) { |
|
| 91 | 91 | $wrapper=$wrappers[$sepFirst+1]; |
| 92 | 92 | } |
| 93 | 93 | $count=\count($values); |
| 94 | - if($count===1){ |
|
| 94 | + if ($count===1) { |
|
| 95 | 95 | $added=$form->addField($values[0]); |
| 96 | - }elseif($count>1){ |
|
| 96 | + }elseif ($count>1) { |
|
| 97 | 97 | $added=$form->addFields($values); |
| 98 | - }else |
|
| 98 | + } else |
|
| 99 | 99 | return; |
| 100 | - if(isset($wrapper)){ |
|
| 101 | - $added->wrap($wrapper[0],$wrapper[1]); |
|
| 100 | + if (isset($wrapper)) { |
|
| 101 | + $added->wrap($wrapper[0], $wrapper[1]); |
|
| 102 | 102 | } |
| 103 | - $this->execHook('onGenerateFields',$added,$nb,$name); |
|
| 103 | + $this->execHook('onGenerateFields', $added, $nb, $name); |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | /** |
@@ -108,18 +108,18 @@ discard block |
||
| 108 | 108 | * the generated field is the first parameter |
| 109 | 109 | * @param callable $callback the fonction to call when a field is generated |
| 110 | 110 | */ |
| 111 | - public function onGenerateField($callback){ |
|
| 112 | - $this->addHook('onGenerateFields',$callback); |
|
| 111 | + public function onGenerateField($callback) { |
|
| 112 | + $this->addHook('onGenerateFields', $callback); |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | /** |
| 116 | 116 | * @return HtmlForm |
| 117 | 117 | */ |
| 118 | - public function getForm(){ |
|
| 118 | + public function getForm() { |
|
| 119 | 119 | return $this->content['form']; |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | - public function addSeparatorAfter($fieldNum){ |
|
| 122 | + public function addSeparatorAfter($fieldNum) { |
|
| 123 | 123 | $fieldNum=$this->_getIndex($fieldNum); |
| 124 | 124 | $this->_instanceViewer->addSeparatorAfter($fieldNum); |
| 125 | 125 | return $this; |
@@ -134,12 +134,12 @@ discard block |
||
| 134 | 134 | return $this; |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | - public function fieldAsReset($index,$cssStyle=NULL,$attributes=NULL){ |
|
| 138 | - return $this->_fieldAs(function($id,$name,$value) use ($cssStyle){ |
|
| 139 | - $button=new HtmlButton($id,$value,$cssStyle); |
|
| 137 | + public function fieldAsReset($index, $cssStyle=NULL, $attributes=NULL) { |
|
| 138 | + return $this->_fieldAs(function($id, $name, $value) use ($cssStyle){ |
|
| 139 | + $button=new HtmlButton($id, $value, $cssStyle); |
|
| 140 | 140 | $button->setProperty('type', 'reset'); |
| 141 | 141 | return $button; |
| 142 | - }, $index,$attributes); |
|
| 142 | + }, $index, $attributes); |
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | /** |
@@ -158,19 +158,19 @@ discard block |
||
| 158 | 158 | $this->content[$this->_toolbarPosition]=$this->_toolbar; |
| 159 | 159 | } |
| 160 | 160 | |
| 161 | - public function addDividerBefore($index,$title){ |
|
| 161 | + public function addDividerBefore($index, $title) { |
|
| 162 | 162 | $index=$this->_getIndex($index); |
| 163 | 163 | $this->_instanceViewer->addHeaderDividerBefore($index, $title); |
| 164 | 164 | return $this; |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | - public function addWrapper($index,$contentBefore,$contentAfter=null){ |
|
| 167 | + public function addWrapper($index, $contentBefore, $contentAfter=null) { |
|
| 168 | 168 | $index=$this->_getIndex($index); |
| 169 | - $this->_instanceViewer->addWrapper($index, $contentBefore,$contentAfter); |
|
| 169 | + $this->_instanceViewer->addWrapper($index, $contentBefore, $contentAfter); |
|
| 170 | 170 | return $this; |
| 171 | 171 | } |
| 172 | 172 | |
| 173 | - public function run(JsUtils $js){ |
|
| 173 | + public function run(JsUtils $js) { |
|
| 174 | 174 | parent::run($js); |
| 175 | 175 | } |
| 176 | 176 | |
@@ -7,20 +7,20 @@ 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); |
|
| 12 | - $this->_identifier = $identifier; |
|
| 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 | + $this->_identifier=$identifier; |
|
| 13 | 13 | } |
| 14 | 14 | |
| 15 | 15 | public function setItems($items) { |
| 16 | 16 | return $this->getField()->setItems($items); |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | - public function addItem($item, $value = NULL, $image = NULL) { |
|
| 19 | + public function addItem($item, $value=NULL, $image=NULL) { |
|
| 20 | 20 | return $this->getField()->addItem($item, $value, $image); |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | - public static function multipleDropdown($identifier, $items = array(), $label = NULL, $value = "", $associative = true) { |
|
| 23 | + public static function multipleDropdown($identifier, $items=array(), $label=NULL, $value="", $associative=true) { |
|
| 24 | 24 | return new HtmlFormDropdown($identifier, $items, $label, $value, true, $associative); |
| 25 | 25 | } |
| 26 | 26 | |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | return $this->getField()->getInput(); |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - public function asSelect($name = NULL, $multiple = false, $selection = true) { |
|
| 35 | + public function asSelect($name=NULL, $multiple=false, $selection=true) { |
|
| 36 | 36 | $this->getField()->asSelect($name, $multiple, $selection); |
| 37 | 37 | return $this; |
| 38 | 38 | } |
@@ -42,11 +42,11 @@ discard block |
||
| 42 | 42 | * @param boolean $floating |
| 43 | 43 | * @return HtmlDropdown |
| 44 | 44 | */ |
| 45 | - public function asButton($floating = false) { |
|
| 46 | - $field = $this->content["field"]; |
|
| 47 | - $label = $this->content["label"]; |
|
| 45 | + public function asButton($floating=false) { |
|
| 46 | + $field=$this->content["field"]; |
|
| 47 | + $label=$this->content["label"]; |
|
| 48 | 48 | $field->addContent($label); |
| 49 | - $this->content = [ |
|
| 49 | + $this->content=[ |
|
| 50 | 50 | "field" => $field |
| 51 | 51 | ]; |
| 52 | 52 | $this->content["field"]->asButton($floating); |
@@ -61,15 +61,15 @@ discard block |
||
| 61 | 61 | * @param boolean $labeled |
| 62 | 62 | * @return mixed|HtmlButton |
| 63 | 63 | */ |
| 64 | - public function addAction($action, $direction = Direction::RIGHT, $icon = NULL, $labeled = false) { |
|
| 64 | + public function addAction($action, $direction=Direction::RIGHT, $icon=NULL, $labeled=false) { |
|
| 65 | 65 | $this->getField()->setStyle('display:inline-block; width: auto'); |
| 66 | - $actionO = $action; |
|
| 67 | - if (\is_object($action) === false) { |
|
| 68 | - $actionO = new HtmlButton("action-" . $this->identifier, $action); |
|
| 66 | + $actionO=$action; |
|
| 67 | + if (\is_object($action)===false) { |
|
| 68 | + $actionO=new HtmlButton("action-".$this->identifier, $action); |
|
| 69 | 69 | if (isset($icon)) |
| 70 | 70 | $actionO->addIcon($icon, true, $labeled); |
| 71 | 71 | } |
| 72 | - $this->addContent($actionO, \strstr($direction, Direction::LEFT) !== false); |
|
| 72 | + $this->addContent($actionO, \strstr($direction, Direction::LEFT)!==false); |
|
| 73 | 73 | return $actionO; |
| 74 | 74 | } |
| 75 | 75 | } |
@@ -29,12 +29,12 @@ discard block |
||
| 29 | 29 | * |
| 30 | 30 | * @var string|array |
| 31 | 31 | */ |
| 32 | - protected $_contentSeparator = ""; |
|
| 32 | + protected $_contentSeparator=""; |
|
| 33 | 33 | |
| 34 | 34 | public function __construct($identifier, $tagName, $baseClass) { |
| 35 | 35 | parent::__construct($identifier, $tagName, $baseClass); |
| 36 | - $this->root = ""; |
|
| 37 | - $this->attr = "data-ajax"; |
|
| 36 | + $this->root=""; |
|
| 37 | + $this->attr="data-ajax"; |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | /** |
@@ -54,23 +54,23 @@ discard block |
||
| 54 | 54 | return JArray::implode($this->_contentSeparator, $this->content); |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - public function setContentDivider($divider, $index = NULL) { |
|
| 58 | - $divider = "<div class='divider'> {$divider} </div>"; |
|
| 57 | + public function setContentDivider($divider, $index=NULL) { |
|
| 58 | + $divider="<div class='divider'> {$divider} </div>"; |
|
| 59 | 59 | return $this->setDivider($divider, $index); |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | - public function setIconContentDivider($iconContentDivider, $index = NULL) { |
|
| 63 | - $contentDivider = "<i class='" . $iconContentDivider . " icon divider'></i>"; |
|
| 62 | + public function setIconContentDivider($iconContentDivider, $index=NULL) { |
|
| 63 | + $contentDivider="<i class='".$iconContentDivider." icon divider'></i>"; |
|
| 64 | 64 | return $this->setDivider($contentDivider, $index); |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | protected function setDivider($divider, $index) { |
| 68 | 68 | if (isset($index)) { |
| 69 | - if (! \is_array($this->_contentSeparator)) |
|
| 70 | - $this->_contentSeparator = array_fill(0, $this->count() - 1, $this->_contentSeparator); |
|
| 71 | - $this->_contentSeparator[$index] = $divider; |
|
| 69 | + if (!\is_array($this->_contentSeparator)) |
|
| 70 | + $this->_contentSeparator=array_fill(0, $this->count()-1, $this->_contentSeparator); |
|
| 71 | + $this->_contentSeparator[$index]=$divider; |
|
| 72 | 72 | } else { |
| 73 | - $this->_contentSeparator = $divider; |
|
| 73 | + $this->_contentSeparator=$divider; |
|
| 74 | 74 | } |
| 75 | 75 | return $this; |
| 76 | 76 | } |