@@ -32,15 +32,15 @@ |
||
| 32 | 32 | if ($stopPropagation===true) { |
| 33 | 33 | $result.=Javascript::$stopPropagation; |
| 34 | 34 | } |
| 35 | - switch($this->method) { |
|
| 35 | + switch ($this->method) { |
|
| 36 | 36 | case "get": |
| 37 | - $result.=$js->getDeferred($url, $responseElement, $params, $callback, $attr,$jqueryDone); |
|
| 37 | + $result.=$js->getDeferred($url, $responseElement, $params, $callback, $attr, $jqueryDone); |
|
| 38 | 38 | break; |
| 39 | 39 | case "post": |
| 40 | - $result.=$js->postDeferred($url, $responseElement, $params, $callback, $attr,$hasLoader,$jqueryDone); |
|
| 40 | + $result.=$js->postDeferred($url, $responseElement, $params, $callback, $attr, $hasLoader, $jqueryDone); |
|
| 41 | 41 | break; |
| 42 | 42 | case "postForm": |
| 43 | - $result.=$js->postFormDeferred($url, $form, $responseElement, $validation, $callback, $attr,$hasLoader,$jqueryDone); |
|
| 43 | + $result.=$js->postFormDeferred($url, $form, $responseElement, $validation, $callback, $attr, $hasLoader, $jqueryDone); |
|
| 44 | 44 | break; |
| 45 | 45 | } |
| 46 | 46 | return $result; |
@@ -40,12 +40,12 @@ discard block |
||
| 40 | 40 | * @return \Ajax\semantic\html\collections\HtmlMenu |
| 41 | 41 | */ |
| 42 | 42 | public function setType($type="") { |
| 43 | - return $this->addToPropertyCtrl("class", $type, array ("","item","text" )); |
|
| 43 | + return $this->addToPropertyCtrl("class", $type, array("", "item", "text")); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | public function setActiveItem($index) { |
| 47 | 47 | $item=$this->getItem($index); |
| 48 | - if ($item !== null) { |
|
| 48 | + if ($item!==null) { |
|
| 49 | 49 | $item->addToProperty("class", "active"); |
| 50 | 50 | } |
| 51 | 51 | return $this; |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | |
| 54 | 54 | private function getItemToInsert($item) { |
| 55 | 55 | if ($item instanceof HtmlInput || $item instanceof HtmlImg || $item instanceof HtmlIcon || $item instanceof HtmlButtonGroups || $item instanceof HtmlButton || $item instanceof HtmlLabel) { |
| 56 | - $itemO=new HtmlMenuItem("item-" . $this->identifier . "-" . \sizeof($this->content) , $item); |
|
| 56 | + $itemO=new HtmlMenuItem("item-".$this->identifier."-".\sizeof($this->content), $item); |
|
| 57 | 57 | $item=$itemO; |
| 58 | 58 | } |
| 59 | 59 | return $item; |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | |
| 62 | 62 | private function afterInsert($item) { |
| 63 | 63 | if (!$item instanceof HtmlMenu && $item->propertyContains("class", "header")===false) |
| 64 | - $item->addToPropertyCtrl("class", "item", array ("item" )); |
|
| 64 | + $item->addToPropertyCtrl("class", "item", array("item")); |
|
| 65 | 65 | else { |
| 66 | 66 | $this->setSecondary(); |
| 67 | 67 | } |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | public function addItem($item) { |
| 78 | 78 | $number=$item; |
| 79 | 79 | $item=parent::addItem($this->getItemToInsert($item)); |
| 80 | - if(\is_int($number)) |
|
| 80 | + if (\is_int($number)) |
|
| 81 | 81 | $item->setProperty("data-page", $number); |
| 82 | 82 | return $this->afterInsert($item); |
| 83 | 83 | } |
@@ -95,15 +95,15 @@ discard block |
||
| 95 | 95 | |
| 96 | 96 | public function generateMenuAsItem($menu, $header=null) { |
| 97 | 97 | $count=$this->count(); |
| 98 | - $item=new HtmlSemDoubleElement("item-" . $this->identifier . "-" . $count, "div"); |
|
| 98 | + $item=new HtmlSemDoubleElement("item-".$this->identifier."-".$count, "div"); |
|
| 99 | 99 | if (isset($header)) { |
| 100 | - $headerItem=new HtmlSemDoubleElement("item-header-" . $this->identifier . "-" . $count, "div", "header"); |
|
| 100 | + $headerItem=new HtmlSemDoubleElement("item-header-".$this->identifier."-".$count, "div", "header"); |
|
| 101 | 101 | $headerItem->setContent($header); |
| 102 | 102 | $item->addContent($headerItem); |
| 103 | 103 | $this->_itemHeader=$headerItem; |
| 104 | 104 | } |
| 105 | - if(\is_array($menu)){ |
|
| 106 | - $menu=new HtmlMenu("menu-" . $this->identifier . "-" . $count,$menu); |
|
| 105 | + if (\is_array($menu)) { |
|
| 106 | + $menu=new HtmlMenu("menu-".$this->identifier."-".$count, $menu); |
|
| 107 | 107 | } |
| 108 | 108 | $menu->setClass("menu"); |
| 109 | 109 | $item->addContent($menu); |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | $value=new HtmlSemDoubleElement($identifier, "a", "browse item", $value); |
| 119 | 119 | $value->addContent(new HtmlIcon("", "dropdown")); |
| 120 | 120 | $value=$this->addItem($value); |
| 121 | - $popup=new HtmlPopup($value, "popup-" . $this->identifier . "-" . $this->count(), $content); |
|
| 121 | + $popup=new HtmlPopup($value, "popup-".$this->identifier."-".$this->count(), $content); |
|
| 122 | 122 | $popup->setFlowing()->setPosition("bottom left")->setOn("click"); |
| 123 | 123 | $this->wrap("", $popup); |
| 124 | 124 | return $popup; |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | public function addDropdownAsItem($value, $items=NULL) { |
| 128 | 128 | $dd=$value; |
| 129 | 129 | if (\is_string($value)) { |
| 130 | - $dd=new HtmlDropdown("dropdown-" . $this->identifier . "-" . $this->count(), $value, $items); |
|
| 130 | + $dd=new HtmlDropdown("dropdown-".$this->identifier."-".$this->count(), $value, $items); |
|
| 131 | 131 | } |
| 132 | 132 | $this->addItem($dd); |
| 133 | 133 | return $dd; |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | * @see \Ajax\common\html\html5\HtmlCollection::createItem() |
| 141 | 141 | */ |
| 142 | 142 | protected function createItem($value) { |
| 143 | - $itemO=new HtmlMenuItem($this->identifier."-item-" . \sizeof($this->content),""); |
|
| 143 | + $itemO=new HtmlMenuItem($this->identifier."-item-".\sizeof($this->content), ""); |
|
| 144 | 144 | $itemO->setTagName("a"); |
| 145 | 145 | $itemO->setContent($value); |
| 146 | 146 | return $itemO; |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | public function setSecondary($value=true) { |
| 154 | - if($value) |
|
| 154 | + if ($value) |
|
| 155 | 155 | $this->addToProperty("class", "secondary"); |
| 156 | 156 | else |
| 157 | 157 | $this->removePropertyValue("class", "secondary"); |
@@ -159,28 +159,28 @@ discard block |
||
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | public function setVertical() { |
| 162 | - return $this->addToPropertyCtrl("class", "vertical", array ("vertical" )); |
|
| 162 | + return $this->addToPropertyCtrl("class", "vertical", array("vertical")); |
|
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | public function setPosition($value="right") { |
| 166 | - return $this->addToPropertyCtrl("class", $value, array ("right","left" )); |
|
| 166 | + return $this->addToPropertyCtrl("class", $value, array("right", "left")); |
|
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | public function setPointing($value=Direction::NONE) { |
| 170 | - return $this->addToPropertyCtrl("class", $value . " pointing", Direction::getConstantValues("pointing")); |
|
| 170 | + return $this->addToPropertyCtrl("class", $value." pointing", Direction::getConstantValues("pointing")); |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | public function asTab($vertical=false) { |
| 174 | - $this->apply(function (HtmlDoubleElement &$item) { |
|
| 174 | + $this->apply(function(HtmlDoubleElement&$item) { |
|
| 175 | 175 | $item->setTagName("a"); |
| 176 | 176 | }); |
| 177 | - if ($vertical === true) |
|
| 177 | + if ($vertical===true) |
|
| 178 | 178 | $this->setVertical(); |
| 179 | 179 | return $this->addToProperty("class", "tabular"); |
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | public function asPagination() { |
| 183 | - $this->apply(function (HtmlDoubleElement &$item) { |
|
| 183 | + $this->apply(function(HtmlDoubleElement&$item) { |
|
| 184 | 184 | $item->setTagName("a"); |
| 185 | 185 | }); |
| 186 | 186 | return $this->addToProperty("class", "pagination"); |
@@ -217,10 +217,10 @@ discard block |
||
| 217 | 217 | */ |
| 218 | 218 | public function setWidth($width) { |
| 219 | 219 | if (\is_int($width)) { |
| 220 | - $width=Wide::getConstants()["W" . $width]; |
|
| 220 | + $width=Wide::getConstants()["W".$width]; |
|
| 221 | 221 | } |
| 222 | 222 | $this->addToPropertyCtrl("class", $width, Wide::getConstants()); |
| 223 | - return $this->addToPropertyCtrl("class", "item", array ("item" )); |
|
| 223 | + return $this->addToPropertyCtrl("class", "item", array("item")); |
|
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | public function addImage($identifier, $src="", $alt="") { |
@@ -235,8 +235,8 @@ discard block |
||
| 235 | 235 | return $this->_itemHeader; |
| 236 | 236 | } |
| 237 | 237 | |
| 238 | - public function run(JsUtils $js){ |
|
| 239 | - $result= parent::run($js); |
|
| 238 | + public function run(JsUtils $js) { |
|
| 239 | + $result=parent::run($js); |
|
| 240 | 240 | return $result->setItemSelector(".item"); |
| 241 | 241 | } |
| 242 | 242 | } |
| 243 | 243 | \ No newline at end of file |
@@ -16,33 +16,33 @@ discard block |
||
| 16 | 16 | |
| 17 | 17 | public function __construct($identifier, $elements=array(), $asIcons=false) { |
| 18 | 18 | parent::__construct($identifier, "div", "ui buttons"); |
| 19 | - if ($asIcons === true) |
|
| 19 | + if ($asIcons===true) |
|
| 20 | 20 | $this->asIcons(); |
| 21 | 21 | $this->addElements($elements, $asIcons); |
| 22 | 22 | } |
| 23 | - protected function createItem($value){ |
|
| 24 | - return new HtmlButton("button-" . $this->identifier . "-" . \sizeof($this->content), $value); |
|
| 23 | + protected function createItem($value) { |
|
| 24 | + return new HtmlButton("button-".$this->identifier."-".\sizeof($this->content), $value); |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | |
| 28 | 28 | public function addElement($element, $asIcon=false) { |
| 29 | 29 | $item=$this->addItem($element); |
| 30 | - if($asIcon) |
|
| 30 | + if ($asIcon) |
|
| 31 | 31 | $item->asIcon($element); |
| 32 | 32 | return $item; |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | public function addElements($elements, $asIcons=false) { |
| 36 | - foreach ( $elements as $element ) { |
|
| 36 | + foreach ($elements as $element) { |
|
| 37 | 37 | $this->addElement($element, $asIcons); |
| 38 | 38 | } |
| 39 | 39 | return $this; |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | public function insertOr($aferIndex=0, $or="or") { |
| 43 | - $orElement=new HtmlSemDoubleElement("or-" . $this->identifier, "div", "or"); |
|
| 43 | + $orElement=new HtmlSemDoubleElement("or-".$this->identifier, "div", "or"); |
|
| 44 | 44 | $orElement->setProperty("data-text", $or); |
| 45 | - array_splice($this->content, $aferIndex + 1, 0, array ($orElement )); |
|
| 45 | + array_splice($this->content, $aferIndex+1, 0, array($orElement)); |
|
| 46 | 46 | return $this; |
| 47 | 47 | } |
| 48 | 48 | |
@@ -55,8 +55,8 @@ discard block |
||
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | public function asIcons() { |
| 58 | - foreach ( $this->content as $item ) { |
|
| 59 | - if($item instanceof HtmlButton) |
|
| 58 | + foreach ($this->content as $item) { |
|
| 59 | + if ($item instanceof HtmlButton) |
|
| 60 | 60 | $item->asIcon($item->getContent()); |
| 61 | 61 | } |
| 62 | 62 | return $this->addToProperty("class", "icons"); |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | * @see \Ajax\bootstrap\html\base\BaseHtml::on() |
| 90 | 90 | */ |
| 91 | 91 | public function on($event, $jsCode, $stopPropagation=false, $preventDefault=false) { |
| 92 | - foreach ( $this->content as $element ) { |
|
| 92 | + foreach ($this->content as $element) { |
|
| 93 | 93 | $element->on($event, $jsCode, $stopPropagation, $preventDefault); |
| 94 | 94 | } |
| 95 | 95 | return $this; |
@@ -101,10 +101,10 @@ discard block |
||
| 101 | 101 | |
| 102 | 102 | public function addClasses($classes=array()) { |
| 103 | 103 | $i=0; |
| 104 | - if(!\is_array($classes)){ |
|
| 105 | - $classes=array_fill (0,$this->count(),$classes); |
|
| 104 | + if (!\is_array($classes)) { |
|
| 105 | + $classes=array_fill(0, $this->count(), $classes); |
|
| 106 | 106 | } |
| 107 | - foreach ( $this->content as $button ) { |
|
| 107 | + foreach ($this->content as $button) { |
|
| 108 | 108 | $button->addToProperty("class", $classes[$i++]); |
| 109 | 109 | } |
| 110 | 110 | return $this; |
@@ -118,8 +118,8 @@ discard block |
||
| 118 | 118 | $this->addElement($function($object)); |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | - public function run(JsUtils $js){ |
|
| 122 | - $result= parent::run($js); |
|
| 121 | + public function run(JsUtils $js) { |
|
| 122 | + $result=parent::run($js); |
|
| 123 | 123 | return $result->setItemSelector(".ui.button"); |
| 124 | 124 | } |
| 125 | 125 | } |
| 126 | 126 | \ No newline at end of file |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | use Ajax\semantic\html\collections\form\traits\FormTrait; |
| 19 | 19 | |
| 20 | 20 | abstract class Widget extends HtmlDoubleElement { |
| 21 | - use FieldAsTrait,FormTrait; |
|
| 21 | + use FieldAsTrait, FormTrait; |
|
| 22 | 22 | |
| 23 | 23 | /** |
| 24 | 24 | * @var string classname |
@@ -51,12 +51,12 @@ discard block |
||
| 51 | 51 | protected $_generated; |
| 52 | 52 | |
| 53 | 53 | |
| 54 | - public function __construct($identifier,$model,$modelInstance=NULL) { |
|
| 54 | + public function __construct($identifier, $model, $modelInstance=NULL) { |
|
| 55 | 55 | parent::__construct($identifier); |
| 56 | 56 | $this->_template="%wrapContentBefore%%content%%wrapContentAfter%"; |
| 57 | 57 | $this->setModel($model); |
| 58 | - if(isset($modelInstance)){ |
|
| 59 | - if(\is_array($modelInstance)){ |
|
| 58 | + if (isset($modelInstance)) { |
|
| 59 | + if (\is_array($modelInstance)) { |
|
| 60 | 60 | $modelInstance=\json_decode(\json_encode($modelInstance), FALSE); |
| 61 | 61 | } |
| 62 | 62 | $this->show($modelInstance); |
@@ -64,28 +64,28 @@ discard block |
||
| 64 | 64 | $this->_generated=false; |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | - protected function _init($instanceViewer,$contentKey,$content,$edition){ |
|
| 67 | + protected function _init($instanceViewer, $contentKey, $content, $edition) { |
|
| 68 | 68 | $this->_instanceViewer=$instanceViewer; |
| 69 | 69 | $this->content=[$contentKey=>$content]; |
| 70 | 70 | $this->_toolbarPosition=PositionInTable::BEFORETABLE; |
| 71 | 71 | $this->_edition=$edition; |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - protected function _getFieldIdentifier($prefix,$name=""){ |
|
| 74 | + protected function _getFieldIdentifier($prefix, $name="") { |
|
| 75 | 75 | return $this->identifier."-{$prefix}-".$this->_instanceViewer->getIdentifier(); |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - protected function _getFieldName($index){ |
|
| 78 | + protected function _getFieldName($index) { |
|
| 79 | 79 | return $this->_instanceViewer->getFieldName($index); |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | - protected function _getFieldCaption($index){ |
|
| 82 | + protected function _getFieldCaption($index) { |
|
| 83 | 83 | return $this->_instanceViewer->getCaption($index); |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | - abstract protected function _setToolbarPosition($table,$captions=NULL); |
|
| 86 | + abstract protected function _setToolbarPosition($table, $captions=NULL); |
|
| 87 | 87 | |
| 88 | - public function show($modelInstance){ |
|
| 88 | + public function show($modelInstance) { |
|
| 89 | 89 | $this->_modelInstance=$modelInstance; |
| 90 | 90 | } |
| 91 | 91 | |
@@ -109,56 +109,56 @@ discard block |
||
| 109 | 109 | |
| 110 | 110 | abstract public function getHtmlComponent(); |
| 111 | 111 | |
| 112 | - public function setAttached($value=true){ |
|
| 112 | + public function setAttached($value=true) { |
|
| 113 | 113 | return $this->getHtmlComponent()->setAttached($value); |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | - public function setColor($color){ |
|
| 116 | + public function setColor($color) { |
|
| 117 | 117 | return $this->getHtmlComponent()->setColor($color); |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | |
| 121 | - public function setCaptions($captions){ |
|
| 121 | + public function setCaptions($captions) { |
|
| 122 | 122 | $this->_instanceViewer->setCaptions($captions); |
| 123 | 123 | return $this; |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | - public function setFields($fields){ |
|
| 126 | + public function setFields($fields) { |
|
| 127 | 127 | $this->_instanceViewer->setVisibleProperties($fields); |
| 128 | 128 | return $this; |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | - public function addField($field){ |
|
| 131 | + public function addField($field) { |
|
| 132 | 132 | $this->_instanceViewer->addField($field); |
| 133 | 133 | return $this; |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | - public function addMessage($attributes=NULL,$fieldName="message"){ |
|
| 136 | + public function addMessage($attributes=NULL, $fieldName="message") { |
|
| 137 | 137 | $this->_instanceViewer->addField($fieldName); |
| 138 | 138 | $count=$this->_instanceViewer->visiblePropertiesCount(); |
| 139 | - return $this->fieldAsMessage($count-1,$attributes); |
|
| 139 | + return $this->fieldAsMessage($count-1, $attributes); |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | - public function addErrorMessage(){ |
|
| 143 | - return $this->addMessage(["error"=>true],"message"); |
|
| 142 | + public function addErrorMessage() { |
|
| 143 | + return $this->addMessage(["error"=>true], "message"); |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | - public function insertField($index,$field){ |
|
| 146 | + public function insertField($index, $field) { |
|
| 147 | 147 | $this->_instanceViewer->insertField($index, $field); |
| 148 | 148 | return $this; |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | - public function insertInField($index,$field){ |
|
| 151 | + public function insertInField($index, $field) { |
|
| 152 | 152 | $this->_instanceViewer->insertInField($index, $field); |
| 153 | 153 | return $this; |
| 154 | 154 | } |
| 155 | 155 | |
| 156 | - public function setValueFunction($index,$callback){ |
|
| 156 | + public function setValueFunction($index, $callback) { |
|
| 157 | 157 | $this->_instanceViewer->setValueFunction($index, $callback); |
| 158 | 158 | return $this; |
| 159 | 159 | } |
| 160 | 160 | |
| 161 | - public function setIdentifierFunction($callback){ |
|
| 161 | + public function setIdentifierFunction($callback) { |
|
| 162 | 162 | $this->_instanceViewer->setIdentifierFunction($callback); |
| 163 | 163 | return $this; |
| 164 | 164 | } |
@@ -166,8 +166,8 @@ discard block |
||
| 166 | 166 | /** |
| 167 | 167 | * @return \Ajax\semantic\html\collections\menus\HtmlMenu |
| 168 | 168 | */ |
| 169 | - public function getToolbar(){ |
|
| 170 | - if(isset($this->_toolbar)===false){ |
|
| 169 | + public function getToolbar() { |
|
| 170 | + if (isset($this->_toolbar)===false) { |
|
| 171 | 171 | $this->_toolbar=new HtmlMenu("toolbar-".$this->identifier); |
| 172 | 172 | } |
| 173 | 173 | return $this->_toolbar; |
@@ -179,10 +179,10 @@ discard block |
||
| 179 | 179 | * @param callable $callback function to call on $element |
| 180 | 180 | * @return \Ajax\common\html\HtmlDoubleElement |
| 181 | 181 | */ |
| 182 | - public function addInToolbar($element,$callback=NULL){ |
|
| 182 | + public function addInToolbar($element, $callback=NULL) { |
|
| 183 | 183 | $tb=$this->getToolbar(); |
| 184 | - if(isset($callback)){ |
|
| 185 | - if(\is_callable($callback)){ |
|
| 184 | + if (isset($callback)) { |
|
| 185 | + if (\is_callable($callback)) { |
|
| 186 | 186 | $callback($element); |
| 187 | 187 | } |
| 188 | 188 | } |
@@ -195,9 +195,9 @@ discard block |
||
| 195 | 195 | * @param callable $callback function($element) |
| 196 | 196 | * @return \Ajax\common\html\HtmlDoubleElement |
| 197 | 197 | */ |
| 198 | - public function addItemInToolbar($caption,$icon=NULL,$callback=NULL){ |
|
| 199 | - $result=$this->addInToolbar($caption,$callback); |
|
| 200 | - if(isset($icon)) |
|
| 198 | + public function addItemInToolbar($caption, $icon=NULL, $callback=NULL) { |
|
| 199 | + $result=$this->addInToolbar($caption, $callback); |
|
| 200 | + if (isset($icon)) |
|
| 201 | 201 | $result->addIcon($icon); |
| 202 | 202 | return $result; |
| 203 | 203 | } |
@@ -207,14 +207,14 @@ discard block |
||
| 207 | 207 | * @param callable $callback function($element) |
| 208 | 208 | * @return \Ajax\common\Widget |
| 209 | 209 | */ |
| 210 | - public function addItemsInToolbar(array $items,$callback=NULL){ |
|
| 211 | - if(JArray::isAssociative($items)){ |
|
| 212 | - foreach ($items as $icon=>$item){ |
|
| 213 | - $this->addItemInToolbar($item,$icon,$callback); |
|
| 210 | + public function addItemsInToolbar(array $items, $callback=NULL) { |
|
| 211 | + if (JArray::isAssociative($items)) { |
|
| 212 | + foreach ($items as $icon=>$item) { |
|
| 213 | + $this->addItemInToolbar($item, $icon, $callback); |
|
| 214 | 214 | } |
| 215 | - }else{ |
|
| 216 | - foreach ($items as $item){ |
|
| 217 | - $this->addItemInToolbar($item,null,$callback); |
|
| 215 | + } else { |
|
| 216 | + foreach ($items as $item) { |
|
| 217 | + $this->addItemInToolbar($item, null, $callback); |
|
| 218 | 218 | } |
| 219 | 219 | } |
| 220 | 220 | return $this; |
@@ -226,12 +226,12 @@ discard block |
||
| 226 | 226 | * @param callable $callback function($element) |
| 227 | 227 | * @return \Ajax\common\html\HtmlDoubleElement |
| 228 | 228 | */ |
| 229 | - public function addDropdownInToolbar($value,$items,$callback=NULL){ |
|
| 229 | + public function addDropdownInToolbar($value, $items, $callback=NULL) { |
|
| 230 | 230 | $dd=$value; |
| 231 | 231 | if (\is_string($value)) { |
| 232 | - $dd=new HtmlDropdown("dropdown-". $this->identifier."-".$value, $value, $items); |
|
| 232 | + $dd=new HtmlDropdown("dropdown-".$this->identifier."-".$value, $value, $items); |
|
| 233 | 233 | } |
| 234 | - return $this->addInToolbar($dd,$callback); |
|
| 234 | + return $this->addInToolbar($dd, $callback); |
|
| 235 | 235 | } |
| 236 | 236 | |
| 237 | 237 | /** |
@@ -240,9 +240,9 @@ discard block |
||
| 240 | 240 | * @param callable $callback function($element) |
| 241 | 241 | * @return \Ajax\common\html\HtmlDoubleElement |
| 242 | 242 | */ |
| 243 | - public function addButtonInToolbar($caption,$cssStyle=null,$callback=NULL){ |
|
| 244 | - $bt=new HtmlButton("bt-".$caption,$caption,$cssStyle); |
|
| 245 | - return $this->addInToolbar($bt,$callback); |
|
| 243 | + public function addButtonInToolbar($caption, $cssStyle=null, $callback=NULL) { |
|
| 244 | + $bt=new HtmlButton("bt-".$caption, $caption, $cssStyle); |
|
| 245 | + return $this->addInToolbar($bt, $callback); |
|
| 246 | 246 | } |
| 247 | 247 | |
| 248 | 248 | /** |
@@ -251,9 +251,9 @@ discard block |
||
| 251 | 251 | * @param callable $callback function($element) |
| 252 | 252 | * @return \Ajax\common\html\HtmlDoubleElement |
| 253 | 253 | */ |
| 254 | - public function addButtonsInToolbar(array $captions,$asIcon=false,$callback=NULL){ |
|
| 255 | - $bts=new HtmlButtonGroups("",$captions,$asIcon); |
|
| 256 | - return $this->addInToolbar($bts,$callback); |
|
| 254 | + public function addButtonsInToolbar(array $captions, $asIcon=false, $callback=NULL) { |
|
| 255 | + $bts=new HtmlButtonGroups("", $captions, $asIcon); |
|
| 256 | + return $this->addInToolbar($bts, $callback); |
|
| 257 | 257 | } |
| 258 | 258 | |
| 259 | 259 | /** |
@@ -263,15 +263,15 @@ discard block |
||
| 263 | 263 | * @param boolean $labeled |
| 264 | 264 | * @return \Ajax\common\html\HtmlDoubleElement |
| 265 | 265 | */ |
| 266 | - public function addLabelledIconButtonInToolbar($caption,$icon,$before=true,$labeled=false){ |
|
| 267 | - $bt=new HtmlButton("",$caption); |
|
| 268 | - $bt->addIcon($icon,$before,$labeled); |
|
| 266 | + public function addLabelledIconButtonInToolbar($caption, $icon, $before=true, $labeled=false) { |
|
| 267 | + $bt=new HtmlButton("", $caption); |
|
| 268 | + $bt->addIcon($icon, $before, $labeled); |
|
| 269 | 269 | return $this->addInToolbar($bt); |
| 270 | 270 | } |
| 271 | 271 | |
| 272 | - public function addSubmitInToolbar($identifier,$value,$cssStyle=NULL,$url=NULL,$responseElement=NULL,$parameters=NULL){ |
|
| 273 | - $button=new HtmlButton($identifier,$value,$cssStyle); |
|
| 274 | - $this->_buttonAsSubmit($button,"click",$url,$responseElement,$parameters); |
|
| 272 | + public function addSubmitInToolbar($identifier, $value, $cssStyle=NULL, $url=NULL, $responseElement=NULL, $parameters=NULL) { |
|
| 273 | + $button=new HtmlButton($identifier, $value, $cssStyle); |
|
| 274 | + $this->_buttonAsSubmit($button, "click", $url, $responseElement, $parameters); |
|
| 275 | 275 | return $this->addInToolbar($button); |
| 276 | 276 | } |
| 277 | 277 | |
@@ -301,7 +301,7 @@ discard block |
||
| 301 | 301 | * @param callable $defaultValueFunction function parameters are : $name : the field name, $value : the field value ,$index : the field index, $instance : the active instance of model |
| 302 | 302 | * @return \Ajax\common\Widget |
| 303 | 303 | */ |
| 304 | - public function setDefaultValueFunction($defaultValueFunction){ |
|
| 304 | + public function setDefaultValueFunction($defaultValueFunction) { |
|
| 305 | 305 | $this->_instanceViewer->setDefaultValueFunction($defaultValueFunction); |
| 306 | 306 | return $this; |
| 307 | 307 | } |
@@ -310,7 +310,7 @@ discard block |
||
| 310 | 310 | * @param string|boolean $disable |
| 311 | 311 | * @return string |
| 312 | 312 | */ |
| 313 | - public function jsDisabled($disable=true){ |
|
| 313 | + public function jsDisabled($disable=true) { |
|
| 314 | 314 | return "$('#".$this->identifier." .ui.input,#".$this->identifier." .ui.dropdown,#".$this->identifier." .ui.checkbox').toggleClass('disabled',".$disable.");"; |
| 315 | 315 | } |
| 316 | 316 | |
@@ -319,12 +319,12 @@ discard block |
||
| 319 | 319 | * @param callable $callback function($element) |
| 320 | 320 | * @return \Ajax\common\html\HtmlDoubleElement |
| 321 | 321 | */ |
| 322 | - public function addEditButtonInToolbar($caption,$callback=NULL){ |
|
| 323 | - $bt=new HtmlButton($this->identifier."-editBtn",$caption); |
|
| 322 | + public function addEditButtonInToolbar($caption, $callback=NULL) { |
|
| 323 | + $bt=new HtmlButton($this->identifier."-editBtn", $caption); |
|
| 324 | 324 | $bt->setToggle(); |
| 325 | 325 | $bt->setActive($this->_edition); |
| 326 | 326 | $bt->onClick($this->jsDisabled(Javascript::prep_value("!$(event.target).hasClass('active')"))); |
| 327 | - return $this->addInToolbar($bt,$callback); |
|
| 327 | + return $this->addInToolbar($bt, $callback); |
|
| 328 | 328 | } |
| 329 | 329 | |
| 330 | 330 | public function setToolbar(HtmlMenu $_toolbar) { |
@@ -338,35 +338,35 @@ discard block |
||
| 338 | 338 | } |
| 339 | 339 | |
| 340 | 340 | public function getForm() { |
| 341 | - if(!isset($this->_form)){ |
|
| 341 | + if (!isset($this->_form)) { |
|
| 342 | 342 | $this->_form=new HtmlForm("frm-".$this->identifier); |
| 343 | 343 | $this->setEdition(true); |
| 344 | 344 | } |
| 345 | 345 | return $this->_form; |
| 346 | 346 | } |
| 347 | 347 | |
| 348 | - public function run(JsUtils $js){ |
|
| 348 | + public function run(JsUtils $js) { |
|
| 349 | 349 | $result=parent::run($js); |
| 350 | - if(isset($this->_form)){ |
|
| 350 | + if (isset($this->_form)) { |
|
| 351 | 351 | $result=$this->runForm($js); |
| 352 | 352 | } |
| 353 | 353 | return $result; |
| 354 | 354 | } |
| 355 | 355 | |
| 356 | - protected function runForm(JsUtils $js){ |
|
| 356 | + protected function runForm(JsUtils $js) { |
|
| 357 | 357 | $fields=$this->getContentInstances(HtmlFormField::class); |
| 358 | - foreach ($fields as $field){ |
|
| 358 | + foreach ($fields as $field) { |
|
| 359 | 359 | $this->_form->addField($field); |
| 360 | 360 | } |
| 361 | 361 | return $this->_form->run($js); |
| 362 | 362 | } |
| 363 | 363 | |
| 364 | - protected function _compileForm(){ |
|
| 365 | - if(isset($this->_form)){ |
|
| 364 | + protected function _compileForm() { |
|
| 365 | + if (isset($this->_form)) { |
|
| 366 | 366 | $noValidate=""; |
| 367 | - if(\sizeof($this->_form->getValidationParams())>0) |
|
| 367 | + if (\sizeof($this->_form->getValidationParams())>0) |
|
| 368 | 368 | $noValidate="novalidate"; |
| 369 | - $this->wrapContent("<form class='ui form' id='frm-".$this->identifier."' name='frm-".$this->identifier."' ".$noValidate.">","</form>"); |
|
| 369 | + $this->wrapContent("<form class='ui form' id='frm-".$this->identifier."' name='frm-".$this->identifier."' ".$noValidate.">", "</form>"); |
|
| 370 | 370 | } |
| 371 | 371 | } |
| 372 | 372 | |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | } |
| 14 | 14 | |
| 15 | 15 | public function setClass($classNames) { |
| 16 | - if(\is_array($classNames)){ |
|
| 16 | + if (\is_array($classNames)) { |
|
| 17 | 17 | $classNames=implode(" ", $classNames); |
| 18 | 18 | } |
| 19 | 19 | $this->setProperty("class", $classNames); |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | public function addClass($classNames) { |
| 24 | - if(\is_array($classNames)){ |
|
| 24 | + if (\is_array($classNames)) { |
|
| 25 | 25 | $classNames=implode(" ", $classNames); |
| 26 | 26 | } |
| 27 | 27 | $this->addToProperty("class", $classNames); |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | */ |
| 53 | 53 | public function fromArray($array) { |
| 54 | 54 | $array=parent::fromArray($array); |
| 55 | - foreach ( $array as $key => $value ) { |
|
| 55 | + foreach ($array as $key => $value) { |
|
| 56 | 56 | $this->setProperty($key, $value); |
| 57 | 57 | } |
| 58 | 58 | return $array; |
@@ -8,12 +8,12 @@ discard block |
||
| 8 | 8 | * @author jc |
| 9 | 9 | * |
| 10 | 10 | */ |
| 11 | -trait BaseHtmlPropertiesTrait{ |
|
| 11 | +trait BaseHtmlPropertiesTrait { |
|
| 12 | 12 | |
| 13 | - protected $properties=array (); |
|
| 13 | + protected $properties=array(); |
|
| 14 | 14 | abstract protected function ctrl($name, $value, $typeCtrl); |
| 15 | 15 | abstract protected function removeOldValues(&$oldValue, $allValues); |
| 16 | - abstract protected function _getElementBy($callback,$elements); |
|
| 16 | + abstract protected function _getElementBy($callback, $elements); |
|
| 17 | 17 | public function getProperties() { |
| 18 | 18 | return $this->properties; |
| 19 | 19 | } |
@@ -39,13 +39,13 @@ discard block |
||
| 39 | 39 | |
| 40 | 40 | public function addToProperty($name, $value, $separator=" ") { |
| 41 | 41 | if (\is_array($value)) { |
| 42 | - foreach ( $value as $v ) { |
|
| 42 | + foreach ($value as $v) { |
|
| 43 | 43 | $this->addToProperty($name, $v, $separator); |
| 44 | 44 | } |
| 45 | - } else if ($value !== "" && $this->propertyContains($name, $value) === false) { |
|
| 45 | + } else if ($value!=="" && $this->propertyContains($name, $value)===false) { |
|
| 46 | 46 | $v=@$this->properties[$name]; |
| 47 | - if (isset($v) && $v !== "") |
|
| 48 | - $v=$v . $separator . $value; |
|
| 47 | + if (isset($v) && $v!=="") |
|
| 48 | + $v=$v.$separator.$value; |
|
| 49 | 49 | else |
| 50 | 50 | $v=$value; |
| 51 | 51 | |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | public function addToPropertyCtrlCheck($name, $value, $typeCtrl) { |
| 86 | - if ($this->ctrl($name, $value, $typeCtrl) === true) { |
|
| 86 | + if ($this->ctrl($name, $value, $typeCtrl)===true) { |
|
| 87 | 87 | return $this->addToProperty($name, $value); |
| 88 | 88 | } |
| 89 | 89 | return $this; |
@@ -104,12 +104,12 @@ discard block |
||
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | protected function setPropertyCtrl($name, $value, $typeCtrl) { |
| 107 | - if ($this->ctrl($name, $value, $typeCtrl) === true) |
|
| 107 | + if ($this->ctrl($name, $value, $typeCtrl)===true) |
|
| 108 | 108 | return $this->setProperty($name, $value); |
| 109 | 109 | return $this; |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | - protected function getElementByPropertyValue($propertyName,$value, $elements) { |
|
| 113 | - return $this->_getElementBy(function($element) use ($propertyName,$value){return $element->propertyContains($propertyName, $value) === true;}, $elements); |
|
| 112 | + protected function getElementByPropertyValue($propertyName, $value, $elements) { |
|
| 113 | + return $this->_getElementBy(function($element) use ($propertyName, $value){return $element->propertyContains($propertyName, $value)===true; }, $elements); |
|
| 114 | 114 | } |
| 115 | 115 | } |
| 116 | 116 | \ No newline at end of file |
@@ -14,64 +14,64 @@ |
||
| 14 | 14 | protected $params; |
| 15 | 15 | protected $semElement; |
| 16 | 16 | |
| 17 | - public function __construct($semElement,$title="",$content="",$variation=NULL,$params=array()){ |
|
| 17 | + public function __construct($semElement, $title="", $content="", $variation=NULL, $params=array()) { |
|
| 18 | 18 | $this->semElement=$semElement; |
| 19 | 19 | $this->title=$title; |
| 20 | 20 | $this->content=$content; |
| 21 | - $this->setAttributes($variation,$params); |
|
| 21 | + $this->setAttributes($variation, $params); |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | public function setHtml($html) { |
| 25 | - $this->html= $html; |
|
| 25 | + $this->html=$html; |
|
| 26 | 26 | return $this; |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | - public function setAttributes($variation=NULL,$params=array()){ |
|
| 29 | + public function setAttributes($variation=NULL, $params=array()) { |
|
| 30 | 30 | $this->variation=$variation; |
| 31 | 31 | $this->params=$params; |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | - public function onShow($jsCode){ |
|
| 34 | + public function onShow($jsCode) { |
|
| 35 | 35 | $this->params["onShow"]=$jsCode; |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | - public function compile(JsUtils $js=NULL){ |
|
| 39 | - if(JString::isNotNull($this->title)){ |
|
| 38 | + public function compile(JsUtils $js=NULL) { |
|
| 39 | + if (JString::isNotNull($this->title)) { |
|
| 40 | 40 | $this->semElement->addToProperty("data-title", $this->title); |
| 41 | 41 | } |
| 42 | - if(JString::isNotNull($this->content)){ |
|
| 42 | + if (JString::isNotNull($this->content)) { |
|
| 43 | 43 | $this->semElement->addToProperty("data-content", $this->content); |
| 44 | 44 | } |
| 45 | 45 | $this->_compileHtml($js); |
| 46 | - if(JString::isNotNull($this->variation)){ |
|
| 46 | + if (JString::isNotNull($this->variation)) { |
|
| 47 | 47 | $this->semElement->addToProperty("data-variation", $this->variation); |
| 48 | 48 | } |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | - private function _compileHtml(JsUtils $js=NULL){ |
|
| 52 | - if(JString::isNotNull($this->html)){ |
|
| 51 | + private function _compileHtml(JsUtils $js=NULL) { |
|
| 52 | + if (JString::isNotNull($this->html)) { |
|
| 53 | 53 | $html=$this->html; |
| 54 | - if(\is_array($html)){ |
|
| 54 | + if (\is_array($html)) { |
|
| 55 | 55 | \array_walk($html, function(&$item) use($js){ |
| 56 | - if($item instanceof HtmlSemDoubleElement){ |
|
| 56 | + if ($item instanceof HtmlSemDoubleElement) { |
|
| 57 | 57 | $comp=$item->compile($js); |
| 58 | - if(isset($js)){ |
|
| 58 | + if (isset($js)) { |
|
| 59 | 59 | $bs=$item->run($js); |
| 60 | - if(isset($bs)) |
|
| 60 | + if (isset($bs)) |
|
| 61 | 61 | $this->params['onShow']=$bs->getScript(); |
| 62 | 62 | } |
| 63 | 63 | $item=$comp; |
| 64 | 64 | } |
| 65 | 65 | }); |
| 66 | - $html=\implode("",$html); |
|
| 66 | + $html=\implode("", $html); |
|
| 67 | 67 | } |
| 68 | 68 | $html=\str_replace("\"", "'", $html); |
| 69 | 69 | $this->semElement->addToProperty("data-html", $html); |
| 70 | 70 | } |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | - public function run(JsUtils $js){ |
|
| 74 | - $js->semantic()->popup("#".$this->semElement->getIdentifier(),$this->params); |
|
| 73 | + public function run(JsUtils $js) { |
|
| 74 | + $js->semantic()->popup("#".$this->semElement->getIdentifier(), $this->params); |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | } |
| 78 | 78 | \ No newline at end of file |
@@ -17,186 +17,186 @@ discard block |
||
| 17 | 17 | |
| 18 | 18 | public static $index=0; |
| 19 | 19 | |
| 20 | - public function __construct($identifier,$instance=NULL,$captions=NULL){ |
|
| 20 | + public function __construct($identifier, $instance=NULL, $captions=NULL) { |
|
| 21 | 21 | $this->widgetIdentifier=$identifier; |
| 22 | 22 | $this->values=[]; |
| 23 | 23 | $this->afterCompile=[]; |
| 24 | - if(isset($instance)) |
|
| 24 | + if (isset($instance)) |
|
| 25 | 25 | $this->setInstance($instance); |
| 26 | 26 | $this->setCaptions($captions); |
| 27 | 27 | $this->captionCallback=NULL; |
| 28 | - $this->defaultValueFunction=function($name,$value){return $value;}; |
|
| 28 | + $this->defaultValueFunction=function($name, $value) {return $value; }; |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | - public function getValues(){ |
|
| 31 | + public function getValues() { |
|
| 32 | 32 | $values=[]; |
| 33 | 33 | $index=0; |
| 34 | 34 | $count=$this->count(); |
| 35 | - while($index<$count){ |
|
| 35 | + while ($index<$count) { |
|
| 36 | 36 | $values[]=$this->getValue($index++); |
| 37 | 37 | } |
| 38 | 38 | return $values; |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | - public function getIdentifier($index=NULL){ |
|
| 42 | - if(!isset($index)) |
|
| 41 | + public function getIdentifier($index=NULL) { |
|
| 42 | + if (!isset($index)) |
|
| 43 | 43 | $index=self::$index; |
| 44 | 44 | $value=$index; |
| 45 | - if(isset($this->values["identifier"])) |
|
| 46 | - $value=$this->values["identifier"]($index,$this->instance); |
|
| 45 | + if (isset($this->values["identifier"])) |
|
| 46 | + $value=$this->values["identifier"]($index, $this->instance); |
|
| 47 | 47 | return $value; |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | - public function getValue($index){ |
|
| 50 | + public function getValue($index) { |
|
| 51 | 51 | $property=$this->properties[$index]; |
| 52 | 52 | return $this->_getValue($property, $index); |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - protected function _beforeAddProperty($index,&$field){ |
|
| 55 | + protected function _beforeAddProperty($index, &$field) { |
|
| 56 | 56 | |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | - protected function _getDefaultValue($name,$value,$index){ |
|
| 59 | + protected function _getDefaultValue($name, $value, $index) { |
|
| 60 | 60 | $func=$this->defaultValueFunction; |
| 61 | - return $func($name,$value,$index,$this->instance); |
|
| 61 | + return $func($name, $value, $index, $this->instance); |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | - protected function _getPropertyValue(\ReflectionProperty $property,$index){ |
|
| 64 | + protected function _getPropertyValue(\ReflectionProperty $property, $index) { |
|
| 65 | 65 | $property->setAccessible(true); |
| 66 | 66 | $value=$property->getValue($this->instance); |
| 67 | - if(isset($this->values[$index])){ |
|
| 68 | - $value= $this->values[$index]($value,$this->instance,$index); |
|
| 69 | - }else{ |
|
| 70 | - $value=$this->_getDefaultValue($property->getName(),$value, $index); |
|
| 67 | + if (isset($this->values[$index])) { |
|
| 68 | + $value=$this->values[$index]($value, $this->instance, $index); |
|
| 69 | + } else { |
|
| 70 | + $value=$this->_getDefaultValue($property->getName(), $value, $index); |
|
| 71 | 71 | } |
| 72 | 72 | return $value; |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | - protected function _getValue($property,$index){ |
|
| 75 | + protected function _getValue($property, $index) { |
|
| 76 | 76 | $value=null; |
| 77 | - if($property instanceof \ReflectionProperty){ |
|
| 77 | + if ($property instanceof \ReflectionProperty) { |
|
| 78 | 78 | $value=$this->_getPropertyValue($property, $index); |
| 79 | - }else{ |
|
| 80 | - if(\is_callable($property)) |
|
| 79 | + } else { |
|
| 80 | + if (\is_callable($property)) |
|
| 81 | 81 | $value=$property($this->instance); |
| 82 | - elseif(\is_array($property)){ |
|
| 83 | - $values=\array_map(function($v) use ($index){return $this->_getValue($v, $index);}, $property); |
|
| 82 | + elseif (\is_array($property)) { |
|
| 83 | + $values=\array_map(function($v) use ($index){return $this->_getValue($v, $index); }, $property); |
|
| 84 | 84 | $value=\implode("", $values); |
| 85 | - }else{ |
|
| 86 | - if(isset($this->values[$index])){ |
|
| 87 | - $value= $this->values[$index]($property,$this->instance,$index); |
|
| 88 | - }elseif(isset($this->instance->{$property})){ |
|
| 85 | + } else { |
|
| 86 | + if (isset($this->values[$index])) { |
|
| 87 | + $value=$this->values[$index]($property, $this->instance, $index); |
|
| 88 | + }elseif (isset($this->instance->{$property})) { |
|
| 89 | 89 | $value=$this->instance->{$property}; |
| 90 | 90 | } |
| 91 | 91 | } |
| 92 | 92 | } |
| 93 | - if(isset($this->afterCompile[$index])){ |
|
| 94 | - if(\is_callable($this->afterCompile[$index])){ |
|
| 95 | - $this->afterCompile[$index]($value,$this->instance,$index); |
|
| 93 | + if (isset($this->afterCompile[$index])) { |
|
| 94 | + if (\is_callable($this->afterCompile[$index])) { |
|
| 95 | + $this->afterCompile[$index]($value, $this->instance, $index); |
|
| 96 | 96 | } |
| 97 | 97 | } |
| 98 | 98 | return $value; |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | - public function insertField($index,$field){ |
|
| 102 | - array_splice( $this->visibleProperties, $index, 0, $field ); |
|
| 101 | + public function insertField($index, $field) { |
|
| 102 | + array_splice($this->visibleProperties, $index, 0, $field); |
|
| 103 | 103 | return $this; |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | - public function insertInField($index,$field){ |
|
| 106 | + public function insertInField($index, $field) { |
|
| 107 | 107 | $vb=$this->visibleProperties; |
| 108 | - if(isset($vb[$index])){ |
|
| 109 | - if(\is_array($vb[$index])){ |
|
| 108 | + if (isset($vb[$index])) { |
|
| 109 | + if (\is_array($vb[$index])) { |
|
| 110 | 110 | $this->visibleProperties[$index][]=$field; |
| 111 | - }else{ |
|
| 112 | - $this->visibleProperties[$index]=[$vb[$index],$field]; |
|
| 111 | + } else { |
|
| 112 | + $this->visibleProperties[$index]=[$vb[$index], $field]; |
|
| 113 | 113 | } |
| 114 | - }else{ |
|
| 114 | + } else { |
|
| 115 | 115 | return $this->insertField($index, $field); |
| 116 | 116 | } |
| 117 | 117 | return $this; |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | - public function addField($field){ |
|
| 120 | + public function addField($field) { |
|
| 121 | 121 | $this->visibleProperties[]=$field; |
| 122 | 122 | return $this; |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | - public function count(){ |
|
| 125 | + public function count() { |
|
| 126 | 126 | return \sizeof($this->properties); |
| 127 | 127 | } |
| 128 | 128 | |
| 129 | - public function visiblePropertiesCount(){ |
|
| 129 | + public function visiblePropertiesCount() { |
|
| 130 | 130 | return \sizeof($this->visibleProperties); |
| 131 | 131 | } |
| 132 | 132 | |
| 133 | - public function getProperty($index){ |
|
| 133 | + public function getProperty($index) { |
|
| 134 | 134 | return $this->properties[$index]; |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | - public function getFieldName($index){ |
|
| 137 | + public function getFieldName($index) { |
|
| 138 | 138 | $property=$this->getProperty($index); |
| 139 | - if($property instanceof \ReflectionProperty){ |
|
| 139 | + if ($property instanceof \ReflectionProperty) { |
|
| 140 | 140 | $result=$property->getName(); |
| 141 | - }elseif(\is_callable($property)){ |
|
| 141 | + }elseif (\is_callable($property)) { |
|
| 142 | 142 | $result=$this->visibleProperties[$index]; |
| 143 | - }else{ |
|
| 143 | + } else { |
|
| 144 | 144 | $result=$property; |
| 145 | 145 | } |
| 146 | 146 | return $result; |
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | |
| 150 | - protected function showableProperty(\ReflectionProperty $rProperty){ |
|
| 151 | - return JString::startswith($rProperty->getName(),"_")===false; |
|
| 150 | + protected function showableProperty(\ReflectionProperty $rProperty) { |
|
| 151 | + return JString::startswith($rProperty->getName(), "_")===false; |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | public function setInstance($instance) { |
| 155 | - if(\is_string($instance)){ |
|
| 155 | + if (\is_string($instance)) { |
|
| 156 | 156 | $instance=new $instance(); |
| 157 | 157 | } |
| 158 | 158 | $this->instance=$instance; |
| 159 | 159 | $this->properties=[]; |
| 160 | 160 | $this->reflect=new \ReflectionClass($instance); |
| 161 | - if(\sizeof($this->visibleProperties)===0){ |
|
| 161 | + if (\sizeof($this->visibleProperties)===0) { |
|
| 162 | 162 | $this->properties=$this->getDefaultProperties(); |
| 163 | - }else{ |
|
| 164 | - foreach ($this->visibleProperties as $property){ |
|
| 163 | + } else { |
|
| 164 | + foreach ($this->visibleProperties as $property) { |
|
| 165 | 165 | $this->setInstanceProperty($property); |
| 166 | 166 | } |
| 167 | 167 | } |
| 168 | 168 | return $this; |
| 169 | 169 | } |
| 170 | 170 | |
| 171 | - private function setInstanceProperty($property){ |
|
| 172 | - if(\is_callable($property)){ |
|
| 171 | + private function setInstanceProperty($property) { |
|
| 172 | + if (\is_callable($property)) { |
|
| 173 | 173 | $this->properties[]=$property; |
| 174 | - }elseif(\is_string($property)){ |
|
| 175 | - try{ |
|
| 174 | + }elseif (\is_string($property)) { |
|
| 175 | + try { |
|
| 176 | 176 | $this->_beforeAddProperty(\sizeof($this->properties), $property); |
| 177 | 177 | $rProperty=$this->reflect->getProperty($property); |
| 178 | 178 | $this->properties[]=$rProperty; |
| 179 | - }catch(\Exception $e){ |
|
| 179 | + }catch (\Exception $e) { |
|
| 180 | 180 | $this->_beforeAddProperty(\sizeof($this->properties), $property); |
| 181 | 181 | $this->properties[]=$property; |
| 182 | 182 | } |
| 183 | - }elseif(\is_int($property)){ |
|
| 183 | + }elseif (\is_int($property)) { |
|
| 184 | 184 | $props=$this->getDefaultProperties(); |
| 185 | - if(isset($props[$property])) |
|
| 185 | + if (isset($props[$property])) |
|
| 186 | 186 | $this->properties[]=$props[$property]; |
| 187 | 187 | else |
| 188 | 188 | $this->properties[]=$property; |
| 189 | - }else{ |
|
| 189 | + } else { |
|
| 190 | 190 | $this->properties[]=$property; |
| 191 | 191 | } |
| 192 | 192 | } |
| 193 | 193 | |
| 194 | - protected function getDefaultProperties(){ |
|
| 194 | + protected function getDefaultProperties() { |
|
| 195 | 195 | $result=[]; |
| 196 | 196 | $properties=$this->reflect->getProperties(); |
| 197 | - foreach ($properties as $property){ |
|
| 197 | + foreach ($properties as $property) { |
|
| 198 | 198 | $showable=$this->showableProperty($property); |
| 199 | - if($showable!==false){ |
|
| 199 | + if ($showable!==false) { |
|
| 200 | 200 | $result[]=$property; |
| 201 | 201 | } |
| 202 | 202 | } |
@@ -208,12 +208,12 @@ discard block |
||
| 208 | 208 | return $this; |
| 209 | 209 | } |
| 210 | 210 | |
| 211 | - public function setValueFunction($index,$callback){ |
|
| 211 | + public function setValueFunction($index, $callback) { |
|
| 212 | 212 | $this->values[$index]=$callback; |
| 213 | 213 | return $this; |
| 214 | 214 | } |
| 215 | 215 | |
| 216 | - public function setIdentifierFunction($callback){ |
|
| 216 | + public function setIdentifierFunction($callback) { |
|
| 217 | 217 | $this->values["identifier"]=$callback; |
| 218 | 218 | return $this; |
| 219 | 219 | } |
@@ -226,41 +226,41 @@ discard block |
||
| 226 | 226 | return $this->properties; |
| 227 | 227 | } |
| 228 | 228 | |
| 229 | - public function getCaption($index){ |
|
| 230 | - if(isset($this->captions[$index])){ |
|
| 229 | + public function getCaption($index) { |
|
| 230 | + if (isset($this->captions[$index])) { |
|
| 231 | 231 | return $this->captions[$index]; |
| 232 | 232 | } |
| 233 | - if($this->properties[$index] instanceof \ReflectionProperty) |
|
| 233 | + if ($this->properties[$index] instanceof \ReflectionProperty) |
|
| 234 | 234 | return $this->properties[$index]->getName(); |
| 235 | - elseif(\is_callable($this->properties[$index])) |
|
| 235 | + elseif (\is_callable($this->properties[$index])) |
|
| 236 | 236 | return ""; |
| 237 | 237 | else |
| 238 | 238 | return $this->properties[$index]; |
| 239 | 239 | } |
| 240 | 240 | |
| 241 | - public function getCaptions(){ |
|
| 242 | - if(isset($this->captions)){ |
|
| 243 | - $captions= $this->captions; |
|
| 244 | - for($i=\sizeof($captions);$i<$this->count();$i++){ |
|
| 241 | + public function getCaptions() { |
|
| 242 | + if (isset($this->captions)) { |
|
| 243 | + $captions=$this->captions; |
|
| 244 | + for ($i=\sizeof($captions); $i<$this->count(); $i++) { |
|
| 245 | 245 | $captions[]=""; |
| 246 | 246 | } |
| 247 | - }else{ |
|
| 247 | + } else { |
|
| 248 | 248 | $captions=[]; |
| 249 | 249 | $index=0; |
| 250 | 250 | $count=$this->count(); |
| 251 | - while($index<$count){ |
|
| 251 | + while ($index<$count) { |
|
| 252 | 252 | $captions[]=$this->getCaption($index++); |
| 253 | 253 | } |
| 254 | 254 | } |
| 255 | - if(isset($this->captionCallback) && \is_callable($this->captionCallback)){ |
|
| 255 | + if (isset($this->captionCallback) && \is_callable($this->captionCallback)) { |
|
| 256 | 256 | $callback=$this->captionCallback; |
| 257 | - $callback($captions,$this->instance); |
|
| 257 | + $callback($captions, $this->instance); |
|
| 258 | 258 | } |
| 259 | 259 | return $captions; |
| 260 | 260 | } |
| 261 | 261 | |
| 262 | - public function setCaption($index,$caption){ |
|
| 263 | - if(isset($this->captions)===false) |
|
| 262 | + public function setCaption($index, $caption) { |
|
| 263 | + if (isset($this->captions)===false) |
|
| 264 | 264 | $this->captions=[]; |
| 265 | 265 | $this->captions[$index]=$caption; |
| 266 | 266 | return $this; |
@@ -278,7 +278,7 @@ discard block |
||
| 278 | 278 | * @param callable $callback function called after the field compilation |
| 279 | 279 | * @return \Ajax\semantic\widgets\datatable\InstanceViewer |
| 280 | 280 | */ |
| 281 | - public function afterCompile($index,$callback){ |
|
| 281 | + public function afterCompile($index, $callback) { |
|
| 282 | 282 | $this->afterCompile[$index]=$callback; |
| 283 | 283 | return $this; |
| 284 | 284 | } |
@@ -15,11 +15,11 @@ discard block |
||
| 15 | 15 | * @version 1.3 |
| 16 | 16 | */ |
| 17 | 17 | abstract class BaseHtml extends BaseWidget { |
| 18 | - use BaseHtmlEventsTrait,BaseHtmlPropertiesTrait; |
|
| 18 | + use BaseHtmlEventsTrait, BaseHtmlPropertiesTrait; |
|
| 19 | 19 | protected $_template; |
| 20 | 20 | protected $tagName; |
| 21 | - protected $_wrapBefore=array (); |
|
| 22 | - protected $_wrapAfter=array (); |
|
| 21 | + protected $_wrapBefore=array(); |
|
| 22 | + protected $_wrapAfter=array(); |
|
| 23 | 23 | protected $_bsComponent; |
| 24 | 24 | |
| 25 | 25 | /** |
@@ -29,14 +29,14 @@ discard block |
||
| 29 | 29 | */ |
| 30 | 30 | abstract public function run(JsUtils $js); |
| 31 | 31 | |
| 32 | - private function _callSetter($setter,$key,$value,&$array){ |
|
| 32 | + private function _callSetter($setter, $key, $value, &$array) { |
|
| 33 | 33 | $result=false; |
| 34 | 34 | if (method_exists($this, $setter) && !JString::startswith($key, "_")) { |
| 35 | 35 | try { |
| 36 | 36 | $this->$setter($value); |
| 37 | 37 | unset($array[$key]); |
| 38 | 38 | $result=true; |
| 39 | - } catch ( \Exception $e ) { |
|
| 39 | + }catch (\Exception $e) { |
|
| 40 | 40 | $result=false; |
| 41 | 41 | } |
| 42 | 42 | } |
@@ -44,17 +44,17 @@ discard block |
||
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | protected function getTemplate(JsUtils $js=NULL) { |
| 47 | - return PropertyWrapper::wrap($this->_wrapBefore, $js) . $this->_template . PropertyWrapper::wrap($this->_wrapAfter, $js); |
|
| 47 | + return PropertyWrapper::wrap($this->_wrapBefore, $js).$this->_template.PropertyWrapper::wrap($this->_wrapAfter, $js); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | protected function ctrl($name, $value, $typeCtrl) { |
| 51 | 51 | if (\is_array($typeCtrl)) { |
| 52 | - if (array_search($value, $typeCtrl) === false) { |
|
| 53 | - throw new \Exception("La valeur passée `" . $value . "` à la propriété `" . $name . "` ne fait pas partie des valeurs possibles : {" . implode(",", $typeCtrl) . "}"); |
|
| 52 | + if (array_search($value, $typeCtrl)===false) { |
|
| 53 | + throw new \Exception("La valeur passée `".$value."` à la propriété `".$name."` ne fait pas partie des valeurs possibles : {".implode(",", $typeCtrl)."}"); |
|
| 54 | 54 | } |
| 55 | 55 | } else { |
| 56 | 56 | if (!$typeCtrl($value)) { |
| 57 | - throw new \Exception("La fonction " . $typeCtrl . " a retourné faux pour l'affectation de la propriété " . $name); |
|
| 57 | + throw new \Exception("La fonction ".$typeCtrl." a retourné faux pour l'affectation de la propriété ".$name); |
|
| 58 | 58 | } |
| 59 | 59 | } |
| 60 | 60 | return true; |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | |
| 64 | 64 | |
| 65 | 65 | protected function setMemberCtrl(&$name, $value, $typeCtrl) { |
| 66 | - if ($this->ctrl($name, $value, $typeCtrl) === true) { |
|
| 66 | + if ($this->ctrl($name, $value, $typeCtrl)===true) { |
|
| 67 | 67 | return $name=$value; |
| 68 | 68 | } |
| 69 | 69 | return $this; |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | protected function addToMemberUnique(&$name, $value, $typeCtrl, $separator=" ") { |
| 73 | 73 | if (\is_array($typeCtrl)) { |
| 74 | 74 | $this->removeOldValues($name, $typeCtrl); |
| 75 | - $name.=$separator . $value; |
|
| 75 | + $name.=$separator.$value; |
|
| 76 | 76 | } |
| 77 | 77 | return $this; |
| 78 | 78 | } |
@@ -80,17 +80,17 @@ discard block |
||
| 80 | 80 | |
| 81 | 81 | |
| 82 | 82 | protected function addToMemberCtrl(&$name, $value, $typeCtrl, $separator=" ") { |
| 83 | - if ($this->ctrl($name, $value, $typeCtrl) === true) { |
|
| 83 | + if ($this->ctrl($name, $value, $typeCtrl)===true) { |
|
| 84 | 84 | if (\is_array($typeCtrl)) { |
| 85 | 85 | $this->removeOldValues($name, $typeCtrl); |
| 86 | 86 | } |
| 87 | - $name.=$separator . $value; |
|
| 87 | + $name.=$separator.$value; |
|
| 88 | 88 | } |
| 89 | 89 | return $this; |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | protected function addToMember(&$name, $value, $separator=" ") { |
| 93 | - $name=str_ireplace($value, "", $name) . $separator . $value; |
|
| 93 | + $name=str_ireplace($value, "", $name).$separator.$value; |
|
| 94 | 94 | return $this; |
| 95 | 95 | } |
| 96 | 96 | |
@@ -101,17 +101,17 @@ discard block |
||
| 101 | 101 | $oldValue=trim($oldValue); |
| 102 | 102 | } |
| 103 | 103 | |
| 104 | - protected function _getElementBy($callback,$elements){ |
|
| 104 | + protected function _getElementBy($callback, $elements) { |
|
| 105 | 105 | if (\is_array($elements)) { |
| 106 | 106 | $flag=false; |
| 107 | 107 | $index=0; |
| 108 | - while ( !$flag && $index < sizeof($elements) ) { |
|
| 108 | + while (!$flag && $index<sizeof($elements)) { |
|
| 109 | 109 | if ($elements[$index] instanceof BaseHtml) |
| 110 | 110 | $flag=($callback($elements[$index])); |
| 111 | 111 | $index++; |
| 112 | 112 | } |
| 113 | - if ($flag === true) |
|
| 114 | - return $elements[$index - 1]; |
|
| 113 | + if ($flag===true) |
|
| 114 | + return $elements[$index-1]; |
|
| 115 | 115 | } elseif ($elements instanceof BaseHtml) { |
| 116 | 116 | if ($callback($elements)) |
| 117 | 117 | return $elements; |
@@ -139,13 +139,13 @@ discard block |
||
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | public function fromArray($array) { |
| 142 | - foreach ( $this as $key => $value ) { |
|
| 143 | - if(array_key_exists($key, $array)===true) |
|
| 144 | - $this->_callSetter("set" . ucfirst($key), $key, $array[$key], $array); |
|
| 142 | + foreach ($this as $key => $value) { |
|
| 143 | + if (array_key_exists($key, $array)===true) |
|
| 144 | + $this->_callSetter("set".ucfirst($key), $key, $array[$key], $array); |
|
| 145 | 145 | } |
| 146 | - foreach ( $array as $key => $value ) { |
|
| 147 | - if($this->_callSetter($key, $key, $value, $array)===false){ |
|
| 148 | - $this->_callSetter("set" . ucfirst($key), $key, $value, $array); |
|
| 146 | + foreach ($array as $key => $value) { |
|
| 147 | + if ($this->_callSetter($key, $key, $value, $array)===false) { |
|
| 148 | + $this->_callSetter("set".ucfirst($key), $key, $value, $array); |
|
| 149 | 149 | } |
| 150 | 150 | } |
| 151 | 151 | return $array; |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | |
| 154 | 154 | public function fromDatabaseObjects($objects, $function) { |
| 155 | 155 | if (isset($objects)) { |
| 156 | - foreach ( $objects as $object ) { |
|
| 156 | + foreach ($objects as $object) { |
|
| 157 | 157 | $this->fromDatabaseObject($object, $function); |
| 158 | 158 | } |
| 159 | 159 | } |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | |
| 175 | 175 | |
| 176 | 176 | public function getElementById($identifier, $elements) { |
| 177 | - return $this->_getElementBy(function($element) use ($identifier){return $element->getIdentifier()===$identifier;}, $elements); |
|
| 177 | + return $this->_getElementBy(function($element) use ($identifier){return $element->getIdentifier()===$identifier; }, $elements); |
|
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | public function getBsComponent() { |
@@ -188,19 +188,19 @@ discard block |
||
| 188 | 188 | |
| 189 | 189 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
| 190 | 190 | $result=$this->getTemplate($js); |
| 191 | - foreach ( $this as $key => $value ) { |
|
| 192 | - if (JString::startswith($key, "_") === false && $key !== "events") { |
|
| 191 | + foreach ($this as $key => $value) { |
|
| 192 | + if (JString::startswith($key, "_")===false && $key!=="events") { |
|
| 193 | 193 | if (\is_array($value)) { |
| 194 | 194 | $v=PropertyWrapper::wrap($value, $js); |
| 195 | 195 | } else { |
| 196 | 196 | $v=$value; |
| 197 | 197 | } |
| 198 | - $result=str_ireplace("%" . $key . "%", $v, $result); |
|
| 198 | + $result=str_ireplace("%".$key."%", $v, $result); |
|
| 199 | 199 | } |
| 200 | 200 | } |
| 201 | 201 | if (isset($js)===true) { |
| 202 | 202 | $this->run($js); |
| 203 | - if (isset($view) === true) { |
|
| 203 | + if (isset($view)===true) { |
|
| 204 | 204 | $js->addViewElement($this->identifier, $result, $view); |
| 205 | 205 | } |
| 206 | 206 | } |