@@ -11,29 +11,29 @@ discard block |
||
| 11 | 11 | * @property string identifier |
| 12 | 12 | * @property array $_compileParts |
| 13 | 13 | */ |
| 14 | -trait HasCheckboxesTrait{ |
|
| 14 | +trait HasCheckboxesTrait { |
|
| 15 | 15 | protected $_hasCheckboxes; |
| 16 | 16 | protected $_hasCheckedMessage=false; |
| 17 | 17 | protected $_checkedMessage; |
| 18 | 18 | protected $_checkedClass; |
| 19 | 19 | |
| 20 | - abstract public function addInToolbar($element,$callback=NULL); |
|
| 20 | + abstract public function addInToolbar($element, $callback=NULL); |
|
| 21 | 21 | |
| 22 | - protected function _runCheckboxes(JsUtils $js){ |
|
| 22 | + protected function _runCheckboxes(JsUtils $js) { |
|
| 23 | 23 | $js->execOn("change", "#".$this->identifier." [name='selection[]']:not(._jsonArrayChecked)", $this->_getCheckedChange($js)); |
| 24 | - if(\sizeof($this->_compileParts)<3){ |
|
| 25 | - $js->trigger("#".$this->identifier." [name='selection[]']","change",true); |
|
| 24 | + if (\sizeof($this->_compileParts)<3) { |
|
| 25 | + $js->trigger("#".$this->identifier." [name='selection[]']", "change", true); |
|
| 26 | 26 | } |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | - protected function _getCheckedChange(JsUtils $js=NULL){ |
|
| 29 | + protected function _getCheckedChange(JsUtils $js=NULL) { |
|
| 30 | 30 | $callback="var \$parentCheckbox=\$('#ck-main-ck-{$this->identifier}'),\$checkbox=\$('#{$this->identifier} [name=\"selection[]\"]'),allChecked=true,allUnchecked=true; |
| 31 | 31 | \$checkbox.each(function() {if($(this).prop('checked')){allUnchecked = false;}else{allChecked = false;}}); |
| 32 | 32 | if(allChecked) {\$parentCheckbox.checkbox('set checked');}else if(allUnchecked){\$parentCheckbox.checkbox('set unchecked');}else{\$parentCheckbox.checkbox('set indeterminate');};".$this->_getCheckedMessageCall($js); |
| 33 | 33 | return $callback; |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - protected function _getCheckedMessageFunction(){ |
|
| 36 | + protected function _getCheckedMessageFunction() { |
|
| 37 | 37 | $msg=$this->getCheckedMessage(); |
| 38 | 38 | $checkedMessageFunction="$('#{$this->identifier}').bind('updateChecked',function() {var msg='".$msg[0]."',count=\$('#{$this->identifier} [name=\"selection[]\"]:checked').length,all=\$('#{$this->identifier} [name=\"selection[]\"]').length; |
| 39 | 39 | if(count==1) msg='".$msg[1]."'; |
@@ -43,23 +43,23 @@ discard block |
||
| 43 | 43 | return $checkedMessageFunction; |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | - protected function _getCheckedMessageCall(JsUtils $js=NULL){ |
|
| 46 | + protected function _getCheckedMessageCall(JsUtils $js=NULL) { |
|
| 47 | 47 | $checkedMessageCall=""; |
| 48 | - if($this->_hasCheckedMessage){ |
|
| 48 | + if ($this->_hasCheckedMessage) { |
|
| 49 | 49 | $checkedMessageCall="$('#{$this->identifier}').trigger('updateChecked');"; |
| 50 | - if(isset($this->_checkedClass)){ |
|
| 50 | + if (isset($this->_checkedClass)) { |
|
| 51 | 51 | $checkedMessageCall.="$(this).closest('tr').toggleClass('".$this->_checkedClass."',$(this).prop('checked'));"; |
| 52 | 52 | } |
| 53 | - if(isset($js)) |
|
| 54 | - $js->exec($this->_getCheckedMessageFunction(),true); |
|
| 53 | + if (isset($js)) |
|
| 54 | + $js->exec($this->_getCheckedMessageFunction(), true); |
|
| 55 | 55 | } |
| 56 | 56 | return $checkedMessageCall; |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | - protected function _generateMainCheckbox(&$captions){ |
|
| 60 | - $ck=new HtmlCheckbox("main-ck-".$this->identifier,""); |
|
| 59 | + protected function _generateMainCheckbox(&$captions) { |
|
| 60 | + $ck=new HtmlCheckbox("main-ck-".$this->identifier, ""); |
|
| 61 | 61 | $checkedMessageCall=""; |
| 62 | - if($this->_hasCheckedMessage) |
|
| 62 | + if ($this->_hasCheckedMessage) |
|
| 63 | 63 | $checkedMessageCall="$('#{$this->identifier}').trigger('updateChecked');"; |
| 64 | 64 | |
| 65 | 65 | $ck->setOnChecked($this->_setAllChecked("true").$checkedMessageCall); |
@@ -67,9 +67,9 @@ discard block |
||
| 67 | 67 | \array_unshift($captions, $ck); |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - protected function _setAllChecked($checked){ |
|
| 70 | + protected function _setAllChecked($checked) { |
|
| 71 | 71 | $result="$('#".$this->identifier." [name=%quote%selection[]%quote%]:not(._jsonArrayChecked)').prop('checked',".$checked.");"; |
| 72 | - if(isset($this->_checkedClass)){ |
|
| 72 | + if (isset($this->_checkedClass)) { |
|
| 73 | 73 | $result.="$('#".$this->identifier." tr').toggleClass('".$this->_checkedClass."',".$checked.");"; |
| 74 | 74 | } |
| 75 | 75 | return $result; |
@@ -85,9 +85,9 @@ discard block |
||
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | protected function getCheckedMessage() { |
| 88 | - $result= $this->_checkedMessage; |
|
| 89 | - if(!isset($result)){ |
|
| 90 | - $result=[0=>"none selected",1=>"one item selected","other"=>"{count} items selected"]; |
|
| 88 | + $result=$this->_checkedMessage; |
|
| 89 | + if (!isset($result)) { |
|
| 90 | + $result=[0=>"none selected", 1=>"one item selected", "other"=>"{count} items selected"]; |
|
| 91 | 91 | } |
| 92 | 92 | return $result; |
| 93 | 93 | } |
@@ -107,14 +107,14 @@ discard block |
||
| 107 | 107 | * @param array $checkedMessage |
| 108 | 108 | * @param callable $callback |
| 109 | 109 | */ |
| 110 | - public function addCountCheckedInToolbar(array $checkedMessage=null,$callback=null){ |
|
| 111 | - if(isset($checkedMessage)) |
|
| 110 | + public function addCountCheckedInToolbar(array $checkedMessage=null, $callback=null) { |
|
| 111 | + if (isset($checkedMessage)) |
|
| 112 | 112 | $this->_checkedMessage=$checkedMessage; |
| 113 | 113 | $checkedMessage=$this->getCheckedMessage(); |
| 114 | 114 | $this->_hasCheckboxes=true; |
| 115 | 115 | $this->_hasCheckedMessage=true; |
| 116 | - $element=new HtmlLabel("checked-count-".$this->identifier,$checkedMessage[0]); |
|
| 117 | - $this->addInToolbar($element,$callback); |
|
| 116 | + $element=new HtmlLabel("checked-count-".$this->identifier, $checkedMessage[0]); |
|
| 117 | + $this->addInToolbar($element, $callback); |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | public function setCheckedClass($_checkedClass) { |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | * @return \Ajax\semantic\html\HtmlIcon |
| 69 | 69 | */ |
| 70 | 70 | public function setFlipped($sens="horizontally") { |
| 71 | - return $this->addToProperty("class", "flipped " . $sens); |
|
| 71 | + return $this->addToProperty("class", "flipped ".$sens); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | /** |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | * @return \Ajax\semantic\html\HtmlIcon |
| 78 | 78 | */ |
| 79 | 79 | public function setRotated($sens="clockwise") { |
| 80 | - return $this->addToProperty("class", "rotated " . $sens); |
|
| 80 | + return $this->addToProperty("class", "rotated ".$sens); |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | /** |
@@ -86,12 +86,12 @@ discard block |
||
| 86 | 86 | * @param string target |
| 87 | 87 | * @return HtmlIcon |
| 88 | 88 | */ |
| 89 | - public function asLink($href=NULL,$target=NULL) { |
|
| 89 | + public function asLink($href=NULL, $target=NULL) { |
|
| 90 | 90 | if (isset($href)) { |
| 91 | 91 | $_target=""; |
| 92 | - if(isset($target)) |
|
| 92 | + if (isset($target)) |
|
| 93 | 93 | $_target="target='{$target}'"; |
| 94 | - $this->wrap("<a href='" . $href . "' {$_target}>", "</a>"); |
|
| 94 | + $this->wrap("<a href='".$href."' {$_target}>", "</a>"); |
|
| 95 | 95 | } |
| 96 | 96 | return $this->addToProperty("class", "link"); |
| 97 | 97 | } |
@@ -107,9 +107,9 @@ discard block |
||
| 107 | 107 | */ |
| 108 | 108 | public function setBordered($inverted=false) { |
| 109 | 109 | $invertedStr=""; |
| 110 | - if ($inverted !== false) |
|
| 110 | + if ($inverted!==false) |
|
| 111 | 111 | $invertedStr=" inverted"; |
| 112 | - return $this->addToProperty("class", "bordered" . $invertedStr); |
|
| 112 | + return $this->addToProperty("class", "bordered".$invertedStr); |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | /** |
@@ -121,11 +121,11 @@ discard block |
||
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | public function addLabel($label, $before=false, $icon=NULL) { |
| 124 | - if($before) |
|
| 124 | + if ($before) |
|
| 125 | 125 | $this->wrap($label); |
| 126 | 126 | else |
| 127 | 127 | $this->wrap("", $label); |
| 128 | - if(isset($icon)) |
|
| 128 | + if (isset($icon)) |
|
| 129 | 129 | $this->addToIcon($icon); |
| 130 | 130 | return $this; |
| 131 | 131 | } |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | public function setFocusable($value=true) { |
| 59 | - if ($value === true) |
|
| 59 | + if ($value===true) |
|
| 60 | 60 | $this->setProperty("tabindex", "0"); |
| 61 | 61 | else { |
| 62 | 62 | $this->removeProperty("tabindex"); |
@@ -66,14 +66,14 @@ discard block |
||
| 66 | 66 | |
| 67 | 67 | public function setAnimated($content, $animation="") { |
| 68 | 68 | $this->setTagName("div"); |
| 69 | - $this->addToProperty("class", "animated " . $animation); |
|
| 70 | - $visible=new HtmlSemDoubleElement("visible-" . $this->identifier, "div"); |
|
| 69 | + $this->addToProperty("class", "animated ".$animation); |
|
| 70 | + $visible=new HtmlSemDoubleElement("visible-".$this->identifier, "div"); |
|
| 71 | 71 | $visible->setClass("visible content"); |
| 72 | 72 | $visible->setContent($this->content); |
| 73 | - $hidden=new HtmlSemDoubleElement("hidden-" . $this->identifier, "div"); |
|
| 73 | + $hidden=new HtmlSemDoubleElement("hidden-".$this->identifier, "div"); |
|
| 74 | 74 | $hidden->setClass("hidden content"); |
| 75 | 75 | $hidden->setContent($content); |
| 76 | - $this->content=array ($visible,$hidden ); |
|
| 76 | + $this->content=array($visible, $hidden); |
|
| 77 | 77 | return $hidden; |
| 78 | 78 | } |
| 79 | 79 | |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | public function asIcon($icon) { |
| 86 | 86 | $iconO=$icon; |
| 87 | 87 | if (\is_string($icon)) { |
| 88 | - $iconO=new HtmlIcon("icon-" . $this->identifier, $icon); |
|
| 88 | + $iconO=new HtmlIcon("icon-".$this->identifier, $icon); |
|
| 89 | 89 | } |
| 90 | 90 | $this->addToProperty("class", "icon"); |
| 91 | 91 | $this->content=$iconO; |
@@ -107,9 +107,9 @@ discard block |
||
| 107 | 107 | public function addLabel($label, $before=false, $icon=NULL) { |
| 108 | 108 | $this->tagName="div"; |
| 109 | 109 | $this->addToProperty("class", "labeled"); |
| 110 | - $this->content=new HtmlButton("button-" . $this->identifier, $this->content); |
|
| 110 | + $this->content=new HtmlButton("button-".$this->identifier, $this->content); |
|
| 111 | 111 | $this->content->setTagName("div"); |
| 112 | - $label=new HtmlLabel("label-" . $this->identifier, $label, $icon,"a"); |
|
| 112 | + $label=new HtmlLabel("label-".$this->identifier, $label, $icon, "a"); |
|
| 113 | 113 | $label->setBasic(); |
| 114 | 114 | $this->addContent($label, $before); |
| 115 | 115 | return $label; |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | */ |
| 122 | 122 | public function fromArray($array) { |
| 123 | 123 | $array=parent::fromArray($array); |
| 124 | - foreach ( $array as $key => $value ) { |
|
| 124 | + foreach ($array as $key => $value) { |
|
| 125 | 125 | $this->setProperty($key, $value); |
| 126 | 126 | } |
| 127 | 127 | return $array; |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | * @return HtmlButton |
| 185 | 185 | */ |
| 186 | 186 | public static function social($identifier, $social, $value=NULL) { |
| 187 | - if ($value === NULL) |
|
| 187 | + if ($value===NULL) |
|
| 188 | 188 | $value=\ucfirst($social); |
| 189 | 189 | $return=new HtmlButton($identifier, $value); |
| 190 | 190 | $return->addIcon($social); |
@@ -221,8 +221,8 @@ discard block |
||
| 221 | 221 | * {@inheritDoc} |
| 222 | 222 | * @see HtmlSemDoubleElement::asLink() |
| 223 | 223 | */ |
| 224 | - public function asLink($href=NULL,$target=NULL) { |
|
| 225 | - $lnk=new HtmlLink("lnk-".$this->identifier,$href,$this->content,$target); |
|
| 224 | + public function asLink($href=NULL, $target=NULL) { |
|
| 225 | + $lnk=new HtmlLink("lnk-".$this->identifier, $href, $this->content, $target); |
|
| 226 | 226 | $this->content=$lnk; |
| 227 | 227 | return $this; |
| 228 | 228 | } |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | use BaseTrait; |
| 23 | 23 | protected $_popup=NULL; |
| 24 | 24 | protected $_dimmer=NULL; |
| 25 | - protected $_params=array (); |
|
| 25 | + protected $_params=array(); |
|
| 26 | 26 | |
| 27 | 27 | |
| 28 | 28 | public function __construct($identifier, $tagName="p", $baseClass="ui", $content=NULL) { |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | * @return HtmlDimmer |
| 79 | 79 | */ |
| 80 | 80 | public function addDimmer($params=array(), $content=NULL) { |
| 81 | - $dimmer=new HtmlDimmer("dimmer-" . $this->identifier, $content); |
|
| 81 | + $dimmer=new HtmlDimmer("dimmer-".$this->identifier, $content); |
|
| 82 | 82 | $dimmer->setParams($params); |
| 83 | 83 | $dimmer->setContainer($this); |
| 84 | 84 | $this->addContent($dimmer); |
@@ -94,12 +94,12 @@ discard block |
||
| 94 | 94 | */ |
| 95 | 95 | public function addLabel($label, $before=false, $icon=NULL) { |
| 96 | 96 | $labelO=$label; |
| 97 | - if (\is_object($label) === false) { |
|
| 98 | - $labelO=new HtmlLabel("label-" . $this->identifier, $label); |
|
| 97 | + if (\is_object($label)===false) { |
|
| 98 | + $labelO=new HtmlLabel("label-".$this->identifier, $label); |
|
| 99 | 99 | if (isset($icon)) |
| 100 | 100 | $labelO->addIcon($icon); |
| 101 | 101 | } else { |
| 102 | - $labelO->addToPropertyCtrl("class", "label", array ("label" )); |
|
| 102 | + $labelO->addToPropertyCtrl("class", "label", array("label")); |
|
| 103 | 103 | } |
| 104 | 104 | $this->addContent($labelO, $before); |
| 105 | 105 | return $labelO; |
@@ -113,9 +113,9 @@ discard block |
||
| 113 | 113 | * @param string $icon |
| 114 | 114 | * @return HtmlSemDoubleElement |
| 115 | 115 | */ |
| 116 | - public function attachLabel($label,$side=Side::TOP,$direction=Direction::NONE,$icon=NULL){ |
|
| 117 | - $label=$this->addLabel($label,true,$icon); |
|
| 118 | - $label->setAttached($side,$direction); |
|
| 116 | + public function attachLabel($label, $side=Side::TOP, $direction=Direction::NONE, $icon=NULL) { |
|
| 117 | + $label=$this->addLabel($label, true, $icon); |
|
| 118 | + $label->setAttached($side, $direction); |
|
| 119 | 119 | return $this; |
| 120 | 120 | } |
| 121 | 121 | |
@@ -123,10 +123,10 @@ discard block |
||
| 123 | 123 | * Transforms the element into a link |
| 124 | 124 | * @return HtmlSemDoubleElement |
| 125 | 125 | */ |
| 126 | - public function asLink($href=NULL,$target=NULL) { |
|
| 126 | + public function asLink($href=NULL, $target=NULL) { |
|
| 127 | 127 | if (isset($href)) |
| 128 | 128 | $this->setProperty("href", $href); |
| 129 | - if(isset($target)) |
|
| 129 | + if (isset($target)) |
|
| 130 | 130 | $this->setProperty("target", $target); |
| 131 | 131 | return $this->setTagName("a"); |
| 132 | 132 | } |
@@ -138,9 +138,9 @@ discard block |
||
| 138 | 138 | */ |
| 139 | 139 | public function jsShowDimmer($show=true) { |
| 140 | 140 | $status="hide"; |
| 141 | - if ($show === true) |
|
| 141 | + if ($show===true) |
|
| 142 | 142 | $status="show"; |
| 143 | - return '$("#.' . $this->identifier . ').dimmer("' . $status . '");'; |
|
| 143 | + return '$("#.'.$this->identifier.').dimmer("'.$status.'");'; |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | /** |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | * @see HtmlDoubleElement::run() |
| 159 | 159 | */ |
| 160 | 160 | public function run(JsUtils $js) { |
| 161 | - $this->_bsComponent=$js->semantic()->generic("#" . $this->identifier); |
|
| 161 | + $this->_bsComponent=$js->semantic()->generic("#".$this->identifier); |
|
| 162 | 162 | parent::run($js); |
| 163 | 163 | $this->addEventsOnRun($js); |
| 164 | 164 | if (isset($this->_popup)) { |
@@ -17,19 +17,19 @@ discard block |
||
| 17 | 17 | class HtmlCard extends HtmlSemDoubleElement { |
| 18 | 18 | |
| 19 | 19 | public function __construct($identifier) { |
| 20 | - parent::__construct($identifier, "div", "ui card", array ()); |
|
| 20 | + parent::__construct($identifier, "div", "ui card", array()); |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | private function createContent($content, $baseClass="content") { |
| 24 | 24 | $count=\sizeof($this->content); |
| 25 | - $result=new HtmlCardContent("content-" . $count . "-" . $this->identifier, $content); |
|
| 25 | + $result=new HtmlCardContent("content-".$count."-".$this->identifier, $content); |
|
| 26 | 26 | $result->setClass($baseClass); |
| 27 | 27 | return $result; |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | private function addElementInContent($key, $element) { |
| 31 | - if (\array_key_exists($key, $this->content) === false) { |
|
| 32 | - $this->content[$key]=array (); |
|
| 31 | + if (\array_key_exists($key, $this->content)===false) { |
|
| 32 | + $this->content[$key]=array(); |
|
| 33 | 33 | } |
| 34 | 34 | $this->content[$key][]=$element; |
| 35 | 35 | return $element; |
@@ -46,14 +46,14 @@ discard block |
||
| 46 | 46 | |
| 47 | 47 | public function addHeader($header, $niveau=4, $type="page") { |
| 48 | 48 | if (!$header instanceof HtmlHeader) { |
| 49 | - $header=new HtmlHeader("header-" . $this->identifier, $niveau, $header, $type); |
|
| 49 | + $header=new HtmlHeader("header-".$this->identifier, $niveau, $header, $type); |
|
| 50 | 50 | } |
| 51 | 51 | $this->content["header"]=$this->createContent($header); |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | public function addImage($image, $title="") { |
| 55 | 55 | if (!$image instanceof HtmlImage) { |
| 56 | - $image=new HtmlImage("image-" . $this->identifier, $image, $title); |
|
| 56 | + $image=new HtmlImage("image-".$this->identifier, $image, $title); |
|
| 57 | 57 | } |
| 58 | 58 | $image->setClass("image"); |
| 59 | 59 | return $this->addElementInContent("content", $image); |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | public function addReveal($visibleContent, $hiddenContent=NULL, $type=RevealType::FADE, $attributeType=NULL) { |
| 63 | 63 | $reveal=$visibleContent; |
| 64 | 64 | if (!$visibleContent instanceof HtmlReveal) { |
| 65 | - $reveal=new HtmlReveal("reveral-" . $this->identifier, $visibleContent, $hiddenContent, $type, $attributeType); |
|
| 65 | + $reveal=new HtmlReveal("reveral-".$this->identifier, $visibleContent, $hiddenContent, $type, $attributeType); |
|
| 66 | 66 | } |
| 67 | 67 | return $this->addElementInContent("content", $reveal); |
| 68 | 68 | } |
@@ -91,8 +91,8 @@ discard block |
||
| 91 | 91 | * @param boolean $asIcons |
| 92 | 92 | * @return \Ajax\semantic\html\elements\HtmlButtonGroups |
| 93 | 93 | */ |
| 94 | - public function addButtons($elements=array(), $asIcons=false){ |
|
| 95 | - $buttons=new HtmlButtonGroups("buttons-".$this->identifier,$elements,$asIcons); |
|
| 94 | + public function addButtons($elements=array(), $asIcons=false) { |
|
| 95 | + $buttons=new HtmlButtonGroups("buttons-".$this->identifier, $elements, $asIcons); |
|
| 96 | 96 | $this->addElementInContent("content", $buttons); |
| 97 | 97 | return $buttons; |
| 98 | 98 | } |
@@ -101,12 +101,12 @@ discard block |
||
| 101 | 101 | |
| 102 | 102 | public function addCardHeaderContent($header, $metas=array(), $description=NULL) { |
| 103 | 103 | $count=\sizeof($this->content); |
| 104 | - return $this->addElementInContent("content", new HtmlCardHeaderContent("content-" . $count . "-" . $this->identifier, $header, $metas, $description)); |
|
| 104 | + return $this->addElementInContent("content", new HtmlCardHeaderContent("content-".$count."-".$this->identifier, $header, $metas, $description)); |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | public function addCardContent($content=array()) { |
| 108 | 108 | $count=\sizeof($this->content); |
| 109 | - return $this->addElementInContent("content", new HtmlCardContent("content-" . $count . "-" . $this->identifier, $content)); |
|
| 109 | + return $this->addElementInContent("content", new HtmlCardContent("content-".$count."-".$this->identifier, $content)); |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | public function getCardContent($index=NULL) { |
@@ -132,13 +132,13 @@ discard block |
||
| 132 | 132 | * @see HtmlSemDoubleElement::compile() |
| 133 | 133 | */ |
| 134 | 134 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
| 135 | - $this->content=JArray::sortAssociative($this->content, [ "header","image","content","extra-content" ]); |
|
| 135 | + $this->content=JArray::sortAssociative($this->content, ["header", "image", "content", "extra-content"]); |
|
| 136 | 136 | return parent::compile($js, $view); |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | - public function asLink($href="",$target=NULL) { |
|
| 139 | + public function asLink($href="", $target=NULL) { |
|
| 140 | 140 | $this->addToProperty("class", "link"); |
| 141 | - if ($href !== "") { |
|
| 141 | + if ($href!=="") { |
|
| 142 | 142 | $this->setProperty("href", $href); |
| 143 | 143 | if (isset($target)) |
| 144 | 144 | $this->setProperty("target", $target); |
@@ -19,80 +19,80 @@ discard block |
||
| 19 | 19 | class DataForm extends Widget { |
| 20 | 20 | |
| 21 | 21 | public function __construct($identifier, $modelInstance=NULL) { |
| 22 | - parent::__construct($identifier, null,$modelInstance); |
|
| 22 | + parent::__construct($identifier, null, $modelInstance); |
|
| 23 | 23 | $this->_form=new HtmlForm($identifier); |
| 24 | 24 | $this->_init(new FormInstanceViewer($identifier), "form", $this->_form, true); |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | - protected function _getFieldIdentifier($prefix,$name=""){ |
|
| 27 | + protected function _getFieldIdentifier($prefix, $name="") { |
|
| 28 | 28 | return $this->identifier."-{$name}-".$this->_instanceViewer->getIdentifier(); |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | - public function compile(JsUtils $js=NULL,&$view=NULL){ |
|
| 32 | - if(!$this->_generated){ |
|
| 31 | + public function compile(JsUtils $js=NULL, &$view=NULL) { |
|
| 32 | + if (!$this->_generated) { |
|
| 33 | 33 | $this->_instanceViewer->setInstance($this->_modelInstance); |
| 34 | 34 | |
| 35 | 35 | $form=$this->content["form"]; |
| 36 | 36 | $this->_generateContent($form); |
| 37 | 37 | |
| 38 | - if(isset($this->_toolbar)){ |
|
| 38 | + if (isset($this->_toolbar)) { |
|
| 39 | 39 | $this->_setToolbarPosition($form); |
| 40 | 40 | } |
| 41 | - $this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE,"form",PositionInTable::AFTERTABLE]); |
|
| 41 | + $this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE, "form", PositionInTable::AFTERTABLE]); |
|
| 42 | 42 | $this->_generated=true; |
| 43 | 43 | } |
| 44 | - return parent::compile($js,$view); |
|
| 44 | + return parent::compile($js, $view); |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | /** |
| 48 | 48 | * @param HtmlForm $form |
| 49 | 49 | */ |
| 50 | - protected function _generateContent($form){ |
|
| 51 | - $values= $this->_instanceViewer->getValues(); |
|
| 50 | + protected function _generateContent($form) { |
|
| 51 | + $values=$this->_instanceViewer->getValues(); |
|
| 52 | 52 | $count=$this->_instanceViewer->count(); |
| 53 | 53 | $separators=$this->_instanceViewer->getSeparators(); |
| 54 | 54 | $headers=$this->_instanceViewer->getHeaders(); |
| 55 | 55 | $wrappers=$this->_instanceViewer->getWrappers(); |
| 56 | 56 | \sort($separators); |
| 57 | 57 | $size=\sizeof($separators); |
| 58 | - if($size===1){ |
|
| 59 | - foreach ($values as $v){ |
|
| 58 | + if ($size===1) { |
|
| 59 | + foreach ($values as $v) { |
|
| 60 | 60 | $form->addField($v); |
| 61 | 61 | } |
| 62 | - }else{ |
|
| 62 | + } else { |
|
| 63 | 63 | $separators[]=$count; |
| 64 | - for($i=0;$i<$size;$i++){ |
|
| 64 | + for ($i=0; $i<$size; $i++) { |
|
| 65 | 65 | $this->_generateFields($form, $values, $headers, $separators[$i], $separators[$i+1], $wrappers); |
| 66 | 66 | } |
| 67 | 67 | } |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - protected function _generateFields($form,$values,$headers,$sepFirst,$sepLast,$wrappers){ |
|
| 70 | + protected function _generateFields($form, $values, $headers, $sepFirst, $sepLast, $wrappers) { |
|
| 71 | 71 | $wrapper=null; |
| 72 | - $fields=\array_slice($values, $sepFirst+1,$sepLast-$sepFirst); |
|
| 73 | - if(isset($headers[$sepFirst+1])) |
|
| 74 | - $form->addHeader($headers[$sepFirst+1],4,true); |
|
| 75 | - if(isset($wrappers[$sepFirst+1])){ |
|
| 72 | + $fields=\array_slice($values, $sepFirst+1, $sepLast-$sepFirst); |
|
| 73 | + if (isset($headers[$sepFirst+1])) |
|
| 74 | + $form->addHeader($headers[$sepFirst+1], 4, true); |
|
| 75 | + if (isset($wrappers[$sepFirst+1])) { |
|
| 76 | 76 | $wrapper=$wrappers[$sepFirst+1]; |
| 77 | 77 | } |
| 78 | - if(\sizeof($fields)===1){ |
|
| 78 | + if (\sizeof($fields)===1) { |
|
| 79 | 79 | $added=$form->addField($fields[0]); |
| 80 | - }elseif(\sizeof($fields)>1){ |
|
| 80 | + }elseif (\sizeof($fields)>1) { |
|
| 81 | 81 | $added=$form->addFields($fields); |
| 82 | 82 | } |
| 83 | - if(isset($wrapper)) |
|
| 84 | - $added->wrap($wrapper[0],$wrapper[1]); |
|
| 83 | + if (isset($wrapper)) |
|
| 84 | + $added->wrap($wrapper[0], $wrapper[1]); |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | /** |
| 88 | 88 | * {@inheritDoc} |
| 89 | 89 | * @see \Ajax\common\Widget::getForm() |
| 90 | 90 | */ |
| 91 | - public function getForm(){ |
|
| 91 | + public function getForm() { |
|
| 92 | 92 | return $this->content["form"]; |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | - public function addSeparatorAfter($fieldNum){ |
|
| 95 | + public function addSeparatorAfter($fieldNum) { |
|
| 96 | 96 | $fieldNum=$this->_getIndex($fieldNum); |
| 97 | 97 | $this->_instanceViewer->addSeparatorAfter($fieldNum); |
| 98 | 98 | return $this; |
@@ -107,12 +107,12 @@ discard block |
||
| 107 | 107 | return $this; |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - public function fieldAsReset($index,$cssStyle=NULL,$attributes=NULL){ |
|
| 111 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($cssStyle){ |
|
| 112 | - $button=new HtmlButton($id,$value,$cssStyle); |
|
| 110 | + public function fieldAsReset($index, $cssStyle=NULL, $attributes=NULL) { |
|
| 111 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($cssStyle){ |
|
| 112 | + $button=new HtmlButton($id, $value, $cssStyle); |
|
| 113 | 113 | $button->setProperty("type", "reset"); |
| 114 | 114 | return $button; |
| 115 | - }, $index,$attributes); |
|
| 115 | + }, $index, $attributes); |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | /** |
@@ -131,19 +131,19 @@ discard block |
||
| 131 | 131 | $this->content[$this->_toolbarPosition]=$this->_toolbar; |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | - public function addDividerBefore($index,$title){ |
|
| 134 | + public function addDividerBefore($index, $title) { |
|
| 135 | 135 | $index=$this->_getIndex($index); |
| 136 | 136 | $this->_instanceViewer->addHeaderDividerBefore($index, $title); |
| 137 | 137 | return $this; |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | - public function addWrapper($index,$contentBefore,$contentAfter=null){ |
|
| 140 | + public function addWrapper($index, $contentBefore, $contentAfter=null) { |
|
| 141 | 141 | $index=$this->_getIndex($index); |
| 142 | - $this->_instanceViewer->addWrapper($index, $contentBefore,$contentAfter); |
|
| 142 | + $this->_instanceViewer->addWrapper($index, $contentBefore, $contentAfter); |
|
| 143 | 143 | return $this; |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | - public function run(JsUtils $js){ |
|
| 146 | + public function run(JsUtils $js) { |
|
| 147 | 147 | return parent::run($js); |
| 148 | 148 | } |
| 149 | 149 | } |
| 150 | 150 | \ No newline at end of file |
@@ -33,42 +33,42 @@ discard block |
||
| 33 | 33 | * @param string|HtmlSemDoubleElement $header |
| 34 | 34 | * @return \Ajax\semantic\html\collections\HtmlMessage |
| 35 | 35 | */ |
| 36 | - public function addHeader($header){ |
|
| 36 | + public function addHeader($header) { |
|
| 37 | 37 | $headerO=$header; |
| 38 | - if(\is_string($header)){ |
|
| 39 | - $headerO=new HtmlSemDoubleElement("header-".$this->identifier,"div"); |
|
| 38 | + if (\is_string($header)) { |
|
| 39 | + $headerO=new HtmlSemDoubleElement("header-".$this->identifier, "div"); |
|
| 40 | 40 | $headerO->setClass("header"); |
| 41 | 41 | $headerO->setContent($header); |
| 42 | 42 | } |
| 43 | - return $this->addContent($headerO,true); |
|
| 43 | + return $this->addContent($headerO, true); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | - public function setHeader($header){ |
|
| 46 | + public function setHeader($header) { |
|
| 47 | 47 | return $this->addHeader($header); |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | - public function addList($elements,$ordered=false){ |
|
| 51 | - $list=new HtmlList("list-".$this->identifier,$elements); |
|
| 50 | + public function addList($elements, $ordered=false) { |
|
| 51 | + $list=new HtmlList("list-".$this->identifier, $elements); |
|
| 52 | 52 | $list->setOrdered($ordered); |
| 53 | 53 | $list->setClass("ui list"); |
| 54 | 54 | $this->addContent($list); |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - public function setIcon($icon){ |
|
| 57 | + public function setIcon($icon) { |
|
| 58 | 58 | $this->addToProperty("class", "icon"); |
| 59 | - $this->wrapContent("<div class='content'>","</div>"); |
|
| 59 | + $this->wrapContent("<div class='content'>", "</div>"); |
|
| 60 | 60 | $this->icon=new HtmlIcon("icon-".$this->identifier, $icon); |
| 61 | 61 | return $this; |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | - public function addLoader($loaderIcon="notched circle"){ |
|
| 64 | + public function addLoader($loaderIcon="notched circle") { |
|
| 65 | 65 | $this->setIcon($loaderIcon); |
| 66 | 66 | $this->icon->addToIcon("loading"); |
| 67 | 67 | return $this; |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - public function setDismissable($dismiss=true){ |
|
| 71 | - if($dismiss===true) |
|
| 70 | + public function setDismissable($dismiss=true) { |
|
| 71 | + if ($dismiss===true) |
|
| 72 | 72 | $this->close=new HtmlIcon("close-".$this->identifier, "close"); |
| 73 | 73 | else |
| 74 | 74 | $this->close=NULL; |
@@ -79,41 +79,41 @@ discard block |
||
| 79 | 79 | * {@inheritDoc} |
| 80 | 80 | * @see \Ajax\semantic\html\base\HtmlSemDoubleElement::run() |
| 81 | 81 | */ |
| 82 | - public function run(JsUtils $js){ |
|
| 82 | + public function run(JsUtils $js) { |
|
| 83 | 83 | parent::run($js); |
| 84 | - if(isset($this->close)){ |
|
| 84 | + if (isset($this->close)) { |
|
| 85 | 85 | $js->execOn("click", "#".$this->identifier." .close", "$(this).closest('.message').transition({$this->_closeTransition})"); |
| 86 | 86 | } |
| 87 | - if(isset($this->_timeout)){ |
|
| 88 | - $js->exec("setTimeout(function() { $('#{$this->identifier}').transition({$this->_closeTransition}); }, {$this->_timeout});",true); |
|
| 87 | + if (isset($this->_timeout)) { |
|
| 88 | + $js->exec("setTimeout(function() { $('#{$this->identifier}').transition({$this->_closeTransition}); }, {$this->_timeout});", true); |
|
| 89 | 89 | } |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | - public function setState($visible=true){ |
|
| 93 | - $visible=($visible===true)?"visible":"hidden"; |
|
| 94 | - return $this->addToPropertyCtrl("class", $visible, array("visible","hidden")); |
|
| 92 | + public function setState($visible=true) { |
|
| 93 | + $visible=($visible===true) ? "visible" : "hidden"; |
|
| 94 | + return $this->addToPropertyCtrl("class", $visible, array("visible", "hidden")); |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | - public function setVariation($value="floating"){ |
|
| 98 | - return $this->addToPropertyCtrl("class", $value, array("floating","compact")); |
|
| 97 | + public function setVariation($value="floating") { |
|
| 98 | + return $this->addToPropertyCtrl("class", $value, array("floating", "compact")); |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | - public function setStyle($style){ |
|
| 101 | + public function setStyle($style) { |
|
| 102 | 102 | return $this->addToPropertyCtrl("class", $style, Style::getConstants()); |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | - public function setError(){ |
|
| 105 | + public function setError() { |
|
| 106 | 106 | return $this->setStyle("error"); |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | - public function setWarning(){ |
|
| 109 | + public function setWarning() { |
|
| 110 | 110 | return $this->setStyle("warning"); |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | - public function setMessage($message){ |
|
| 114 | - if(\is_array($this->content)){ |
|
| 113 | + public function setMessage($message) { |
|
| 114 | + if (\is_array($this->content)) { |
|
| 115 | 115 | $this->content[\sizeof($this->content)-1]=$message; |
| 116 | - }else |
|
| 116 | + } else |
|
| 117 | 117 | $this->setContent($message); |
| 118 | 118 | } |
| 119 | 119 | |
@@ -28,27 +28,27 @@ |
||
| 28 | 28 | $method="get"; |
| 29 | 29 | extract($this->parameters); |
| 30 | 30 | $result=$this->_eventPreparing($preventDefault, $stopPropagation); |
| 31 | - switch($this->method) { |
|
| 31 | + switch ($this->method) { |
|
| 32 | 32 | case "get": |
| 33 | - $result.=$js->getDeferred($url, $responseElement, $params, $jsCallback, $attr,$jqueryDone,$ajaxTransition); |
|
| 33 | + $result.=$js->getDeferred($url, $responseElement, $params, $jsCallback, $attr, $jqueryDone, $ajaxTransition); |
|
| 34 | 34 | break; |
| 35 | 35 | case "post": |
| 36 | - $result.=$js->postDeferred($url, $responseElement, $params, $jsCallback, $attr,$hasLoader,$jqueryDone,$ajaxTransition); |
|
| 36 | + $result.=$js->postDeferred($url, $responseElement, $params, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition); |
|
| 37 | 37 | break; |
| 38 | 38 | case "postForm": |
| 39 | - $result.=$js->postFormDeferred($url, $form, $responseElement, $validation, $jsCallback, $attr,$hasLoader,$jqueryDone,$ajaxTransition); |
|
| 39 | + $result.=$js->postFormDeferred($url, $form, $responseElement, $validation, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition); |
|
| 40 | 40 | break; |
| 41 | 41 | case "json": |
| 42 | - $result.=$js->jsonDeferred($url,$method,$params,$jsCallback); |
|
| 42 | + $result.=$js->jsonDeferred($url, $method, $params, $jsCallback); |
|
| 43 | 43 | break; |
| 44 | 44 | case "jsonArray": |
| 45 | - $result.=$js->jsonArrayDeferred($modelSelector, $url,$method,$params,$jsCallback); |
|
| 45 | + $result.=$js->jsonArrayDeferred($modelSelector, $url, $method, $params, $jsCallback); |
|
| 46 | 46 | break; |
| 47 | 47 | } |
| 48 | 48 | return $result; |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | - protected function _eventPreparing($preventDefault,$stopPropagation){ |
|
| 51 | + protected function _eventPreparing($preventDefault, $stopPropagation) { |
|
| 52 | 52 | $result=""; |
| 53 | 53 | if ($preventDefault===true) { |
| 54 | 54 | $result.=Javascript::$preventDefault; |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | use Ajax\semantic\html\modules\HtmlModal; |
| 21 | 21 | |
| 22 | 22 | abstract class Widget extends HtmlDoubleElement { |
| 23 | - use FieldAsTrait,FormTrait; |
|
| 23 | + use FieldAsTrait, FormTrait; |
|
| 24 | 24 | |
| 25 | 25 | /** |
| 26 | 26 | * @var string classname |
@@ -53,17 +53,17 @@ discard block |
||
| 53 | 53 | protected $_generated; |
| 54 | 54 | |
| 55 | 55 | |
| 56 | - public function __construct($identifier,$model,$modelInstance=NULL) { |
|
| 56 | + public function __construct($identifier, $model, $modelInstance=NULL) { |
|
| 57 | 57 | parent::__construct($identifier); |
| 58 | 58 | $this->_template="%wrapContentBefore%%content%%wrapContentAfter%"; |
| 59 | 59 | $this->setModel($model); |
| 60 | - if(isset($modelInstance)){ |
|
| 60 | + if (isset($modelInstance)) { |
|
| 61 | 61 | $this->show($modelInstance); |
| 62 | 62 | } |
| 63 | 63 | $this->_generated=false; |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | - protected function _init($instanceViewer,$contentKey,$content,$edition){ |
|
| 66 | + protected function _init($instanceViewer, $contentKey, $content, $edition) { |
|
| 67 | 67 | $this->_instanceViewer=$instanceViewer; |
| 68 | 68 | $this->content=[$contentKey=>$content]; |
| 69 | 69 | $this->_toolbarPosition=PositionInTable::BEFORETABLE; |
@@ -74,31 +74,31 @@ discard block |
||
| 74 | 74 | * @param int|string $fieldName |
| 75 | 75 | * @return int|string |
| 76 | 76 | */ |
| 77 | - protected function _getIndex($fieldName){ |
|
| 77 | + protected function _getIndex($fieldName) { |
|
| 78 | 78 | $index=$fieldName; |
| 79 | - if(\is_string($fieldName)){ |
|
| 79 | + if (\is_string($fieldName)) { |
|
| 80 | 80 | $fields=$this->_instanceViewer->getVisibleProperties(); |
| 81 | 81 | $index=\array_search($fieldName, $fields); |
| 82 | 82 | } |
| 83 | 83 | return $index; |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | - protected function _getFieldIdentifier($prefix,$name=""){ |
|
| 86 | + protected function _getFieldIdentifier($prefix, $name="") { |
|
| 87 | 87 | return $this->identifier."-{$prefix}-".$this->_instanceViewer->getIdentifier(); |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | - protected function _getFieldName($index){ |
|
| 90 | + protected function _getFieldName($index) { |
|
| 91 | 91 | return $this->_instanceViewer->getFieldName($index); |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | - protected function _getFieldCaption($index){ |
|
| 94 | + protected function _getFieldCaption($index) { |
|
| 95 | 95 | return $this->_instanceViewer->getCaption($index); |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - abstract protected function _setToolbarPosition($table,$captions=NULL); |
|
| 98 | + abstract protected function _setToolbarPosition($table, $captions=NULL); |
|
| 99 | 99 | |
| 100 | - public function show($modelInstance){ |
|
| 101 | - if(\is_array($modelInstance)){ |
|
| 100 | + public function show($modelInstance) { |
|
| 101 | + if (\is_array($modelInstance)) { |
|
| 102 | 102 | $modelInstance=\json_decode(\json_encode($modelInstance), FALSE); |
| 103 | 103 | } |
| 104 | 104 | $this->_modelInstance=$modelInstance; |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | |
| 125 | 125 | abstract public function getHtmlComponent(); |
| 126 | 126 | |
| 127 | - public function setAttached($value=true){ |
|
| 127 | + public function setAttached($value=true) { |
|
| 128 | 128 | return $this->getHtmlComponent()->setAttached($value); |
| 129 | 129 | } |
| 130 | 130 | |
@@ -135,66 +135,66 @@ discard block |
||
| 135 | 135 | * @param callable $callback function called after the field compilation |
| 136 | 136 | * @return Widget |
| 137 | 137 | */ |
| 138 | - public function afterCompile($index,$callback){ |
|
| 138 | + public function afterCompile($index, $callback) { |
|
| 139 | 139 | $index=$this->_getIndex($index); |
| 140 | 140 | $this->_instanceViewer->afterCompile($index, $callback); |
| 141 | 141 | return $this; |
| 142 | 142 | } |
| 143 | 143 | |
| 144 | - public function setColor($color){ |
|
| 144 | + public function setColor($color) { |
|
| 145 | 145 | return $this->getHtmlComponent()->setColor($color); |
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | |
| 149 | - public function setCaptions($captions){ |
|
| 149 | + public function setCaptions($captions) { |
|
| 150 | 150 | $this->_instanceViewer->setCaptions($captions); |
| 151 | 151 | return $this; |
| 152 | 152 | } |
| 153 | 153 | |
| 154 | - public function setCaption($index,$caption){ |
|
| 154 | + public function setCaption($index, $caption) { |
|
| 155 | 155 | $this->_instanceViewer->setCaption($this->_getIndex($index), $caption); |
| 156 | 156 | return $this; |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | - public function setFields($fields){ |
|
| 159 | + public function setFields($fields) { |
|
| 160 | 160 | $this->_instanceViewer->setVisibleProperties($fields); |
| 161 | 161 | return $this; |
| 162 | 162 | } |
| 163 | 163 | |
| 164 | - public function addField($field){ |
|
| 164 | + public function addField($field) { |
|
| 165 | 165 | $this->_instanceViewer->addField($field); |
| 166 | 166 | return $this; |
| 167 | 167 | } |
| 168 | 168 | |
| 169 | - public function addMessage($attributes=NULL,$fieldName="message"){ |
|
| 169 | + public function addMessage($attributes=NULL, $fieldName="message") { |
|
| 170 | 170 | $this->_instanceViewer->addField($fieldName); |
| 171 | 171 | $count=$this->_instanceViewer->visiblePropertiesCount(); |
| 172 | - return $this->fieldAsMessage($count-1,$attributes); |
|
| 172 | + return $this->fieldAsMessage($count-1, $attributes); |
|
| 173 | 173 | } |
| 174 | 174 | |
| 175 | - public function addErrorMessage(){ |
|
| 176 | - return $this->addMessage(["error"=>true],"message"); |
|
| 175 | + public function addErrorMessage() { |
|
| 176 | + return $this->addMessage(["error"=>true], "message"); |
|
| 177 | 177 | } |
| 178 | 178 | |
| 179 | - public function insertField($index,$field){ |
|
| 179 | + public function insertField($index, $field) { |
|
| 180 | 180 | $index=$this->_getIndex($index); |
| 181 | 181 | $this->_instanceViewer->insertField($index, $field); |
| 182 | 182 | return $this; |
| 183 | 183 | } |
| 184 | 184 | |
| 185 | - public function insertInField($index,$field){ |
|
| 185 | + public function insertInField($index, $field) { |
|
| 186 | 186 | $index=$this->_getIndex($index); |
| 187 | 187 | $this->_instanceViewer->insertInField($index, $field); |
| 188 | 188 | return $this; |
| 189 | 189 | } |
| 190 | 190 | |
| 191 | - public function setValueFunction($index,$callback){ |
|
| 191 | + public function setValueFunction($index, $callback) { |
|
| 192 | 192 | $index=$this->_getIndex($index); |
| 193 | 193 | $this->_instanceViewer->setValueFunction($index, $callback); |
| 194 | 194 | return $this; |
| 195 | 195 | } |
| 196 | 196 | |
| 197 | - public function setIdentifierFunction($callback){ |
|
| 197 | + public function setIdentifierFunction($callback) { |
|
| 198 | 198 | $this->_instanceViewer->setIdentifierFunction($callback); |
| 199 | 199 | return $this; |
| 200 | 200 | } |
@@ -202,8 +202,8 @@ discard block |
||
| 202 | 202 | /** |
| 203 | 203 | * @return \Ajax\semantic\html\collections\menus\HtmlMenu |
| 204 | 204 | */ |
| 205 | - public function getToolbar(){ |
|
| 206 | - if(isset($this->_toolbar)===false){ |
|
| 205 | + public function getToolbar() { |
|
| 206 | + if (isset($this->_toolbar)===false) { |
|
| 207 | 207 | $this->_toolbar=new HtmlMenu("toolbar-".$this->identifier); |
| 208 | 208 | } |
| 209 | 209 | return $this->_toolbar; |
@@ -215,15 +215,15 @@ discard block |
||
| 215 | 215 | * @param callable $callback function to call on $element |
| 216 | 216 | * @return \Ajax\common\html\HtmlDoubleElement |
| 217 | 217 | */ |
| 218 | - public function addInToolbar($element,$callback=NULL){ |
|
| 218 | + public function addInToolbar($element, $callback=NULL) { |
|
| 219 | 219 | $tb=$this->getToolbar(); |
| 220 | - if($element instanceof BaseWidget){ |
|
| 221 | - if($element->getIdentifier()===""){ |
|
| 220 | + if ($element instanceof BaseWidget) { |
|
| 221 | + if ($element->getIdentifier()==="") { |
|
| 222 | 222 | $element->setIdentifier("tb-item-".$this->identifier."-".$tb->count()); |
| 223 | 223 | } |
| 224 | 224 | } |
| 225 | - if(isset($callback)){ |
|
| 226 | - if(\is_callable($callback)){ |
|
| 225 | + if (isset($callback)) { |
|
| 226 | + if (\is_callable($callback)) { |
|
| 227 | 227 | $callback($element); |
| 228 | 228 | } |
| 229 | 229 | } |
@@ -236,9 +236,9 @@ discard block |
||
| 236 | 236 | * @param callable $callback function($element) |
| 237 | 237 | * @return \Ajax\common\html\HtmlDoubleElement |
| 238 | 238 | */ |
| 239 | - public function addItemInToolbar($caption,$icon=NULL,$callback=NULL){ |
|
| 240 | - $result=$this->addInToolbar($caption,$callback); |
|
| 241 | - if(isset($icon)) |
|
| 239 | + public function addItemInToolbar($caption, $icon=NULL, $callback=NULL) { |
|
| 240 | + $result=$this->addInToolbar($caption, $callback); |
|
| 241 | + if (isset($icon)) |
|
| 242 | 242 | $result->addIcon($icon); |
| 243 | 243 | return $result; |
| 244 | 244 | } |
@@ -248,14 +248,14 @@ discard block |
||
| 248 | 248 | * @param callable $callback function($element) |
| 249 | 249 | * @return \Ajax\common\Widget |
| 250 | 250 | */ |
| 251 | - public function addItemsInToolbar(array $items,$callback=NULL){ |
|
| 252 | - if(JArray::isAssociative($items)){ |
|
| 253 | - foreach ($items as $icon=>$item){ |
|
| 254 | - $this->addItemInToolbar($item,$icon,$callback); |
|
| 251 | + public function addItemsInToolbar(array $items, $callback=NULL) { |
|
| 252 | + if (JArray::isAssociative($items)) { |
|
| 253 | + foreach ($items as $icon=>$item) { |
|
| 254 | + $this->addItemInToolbar($item, $icon, $callback); |
|
| 255 | 255 | } |
| 256 | - }else{ |
|
| 257 | - foreach ($items as $item){ |
|
| 258 | - $this->addItemInToolbar($item,null,$callback); |
|
| 256 | + } else { |
|
| 257 | + foreach ($items as $item) { |
|
| 258 | + $this->addItemInToolbar($item, null, $callback); |
|
| 259 | 259 | } |
| 260 | 260 | } |
| 261 | 261 | return $this; |
@@ -267,12 +267,12 @@ discard block |
||
| 267 | 267 | * @param callable $callback function($element) |
| 268 | 268 | * @return \Ajax\common\html\HtmlDoubleElement |
| 269 | 269 | */ |
| 270 | - public function addDropdownInToolbar($value,$items,$callback=NULL){ |
|
| 270 | + public function addDropdownInToolbar($value, $items, $callback=NULL) { |
|
| 271 | 271 | $dd=$value; |
| 272 | 272 | if (\is_string($value)) { |
| 273 | - $dd=new HtmlDropdown("dropdown-". $this->identifier."-".$value, $value, $items); |
|
| 273 | + $dd=new HtmlDropdown("dropdown-".$this->identifier."-".$value, $value, $items); |
|
| 274 | 274 | } |
| 275 | - return $this->addInToolbar($dd,$callback); |
|
| 275 | + return $this->addInToolbar($dd, $callback); |
|
| 276 | 276 | } |
| 277 | 277 | |
| 278 | 278 | /** |
@@ -281,9 +281,9 @@ discard block |
||
| 281 | 281 | * @param callable $callback function($element) |
| 282 | 282 | * @return \Ajax\common\html\HtmlDoubleElement |
| 283 | 283 | */ |
| 284 | - public function addButtonInToolbar($caption,$cssStyle=null,$callback=NULL){ |
|
| 285 | - $bt=new HtmlButton("bt-".$caption,$caption,$cssStyle); |
|
| 286 | - return $this->addInToolbar($bt,$callback); |
|
| 284 | + public function addButtonInToolbar($caption, $cssStyle=null, $callback=NULL) { |
|
| 285 | + $bt=new HtmlButton("bt-".$caption, $caption, $cssStyle); |
|
| 286 | + return $this->addInToolbar($bt, $callback); |
|
| 287 | 287 | } |
| 288 | 288 | |
| 289 | 289 | /** |
@@ -292,9 +292,9 @@ discard block |
||
| 292 | 292 | * @param callable $callback function($element) |
| 293 | 293 | * @return \Ajax\common\html\HtmlDoubleElement |
| 294 | 294 | */ |
| 295 | - public function addButtonsInToolbar(array $captions,$asIcon=false,$callback=NULL){ |
|
| 296 | - $bts=new HtmlButtonGroups("",$captions,$asIcon); |
|
| 297 | - return $this->addInToolbar($bts,$callback); |
|
| 295 | + public function addButtonsInToolbar(array $captions, $asIcon=false, $callback=NULL) { |
|
| 296 | + $bts=new HtmlButtonGroups("", $captions, $asIcon); |
|
| 297 | + return $this->addInToolbar($bts, $callback); |
|
| 298 | 298 | } |
| 299 | 299 | |
| 300 | 300 | /** |
@@ -304,15 +304,15 @@ discard block |
||
| 304 | 304 | * @param boolean $labeled |
| 305 | 305 | * @return \Ajax\common\html\HtmlDoubleElement |
| 306 | 306 | */ |
| 307 | - public function addLabelledIconButtonInToolbar($caption,$icon,$before=true,$labeled=false){ |
|
| 308 | - $bt=new HtmlButton("",$caption); |
|
| 309 | - $bt->addIcon($icon,$before,$labeled); |
|
| 307 | + public function addLabelledIconButtonInToolbar($caption, $icon, $before=true, $labeled=false) { |
|
| 308 | + $bt=new HtmlButton("", $caption); |
|
| 309 | + $bt->addIcon($icon, $before, $labeled); |
|
| 310 | 310 | return $this->addInToolbar($bt); |
| 311 | 311 | } |
| 312 | 312 | |
| 313 | - public function addSubmitInToolbar($identifier,$value,$cssStyle=NULL,$url=NULL,$responseElement=NULL,$parameters=NULL){ |
|
| 314 | - $button=new HtmlButton($identifier,$value,$cssStyle); |
|
| 315 | - $this->_buttonAsSubmit($button,"click",$url,$responseElement,$parameters); |
|
| 313 | + public function addSubmitInToolbar($identifier, $value, $cssStyle=NULL, $url=NULL, $responseElement=NULL, $parameters=NULL) { |
|
| 314 | + $button=new HtmlButton($identifier, $value, $cssStyle); |
|
| 315 | + $this->_buttonAsSubmit($button, "click", $url, $responseElement, $parameters); |
|
| 316 | 316 | return $this->addInToolbar($button); |
| 317 | 317 | } |
| 318 | 318 | |
@@ -342,7 +342,7 @@ discard block |
||
| 342 | 342 | * @param callable $defaultValueFunction function parameters are : $name : the field name, $value : the field value ,$index : the field index, $instance : the active instance of model |
| 343 | 343 | * @return \Ajax\common\Widget |
| 344 | 344 | */ |
| 345 | - public function setDefaultValueFunction($defaultValueFunction){ |
|
| 345 | + public function setDefaultValueFunction($defaultValueFunction) { |
|
| 346 | 346 | $this->_instanceViewer->setDefaultValueFunction($defaultValueFunction); |
| 347 | 347 | return $this; |
| 348 | 348 | } |
@@ -351,7 +351,7 @@ discard block |
||
| 351 | 351 | * @param string|boolean $disable |
| 352 | 352 | * @return string |
| 353 | 353 | */ |
| 354 | - public function jsDisabled($disable=true){ |
|
| 354 | + public function jsDisabled($disable=true) { |
|
| 355 | 355 | return "$('#".$this->identifier." .ui.input,#".$this->identifier." .ui.dropdown,#".$this->identifier." .ui.checkbox').toggleClass('disabled',".$disable.");"; |
| 356 | 356 | } |
| 357 | 357 | |
@@ -360,12 +360,12 @@ discard block |
||
| 360 | 360 | * @param callable $callback function($element) |
| 361 | 361 | * @return \Ajax\common\html\HtmlDoubleElement |
| 362 | 362 | */ |
| 363 | - public function addEditButtonInToolbar($caption,$callback=NULL){ |
|
| 364 | - $bt=new HtmlButton($this->identifier."-editBtn",$caption); |
|
| 363 | + public function addEditButtonInToolbar($caption, $callback=NULL) { |
|
| 364 | + $bt=new HtmlButton($this->identifier."-editBtn", $caption); |
|
| 365 | 365 | $bt->setToggle(); |
| 366 | 366 | $bt->setActive($this->_edition); |
| 367 | 367 | $bt->onClick($this->jsDisabled(Javascript::prep_value("!$(event.target).hasClass('active')"))); |
| 368 | - return $this->addInToolbar($bt,$callback); |
|
| 368 | + return $this->addInToolbar($bt, $callback); |
|
| 369 | 369 | } |
| 370 | 370 | |
| 371 | 371 | public function setToolbar(HtmlMenu $_toolbar) { |
@@ -379,35 +379,35 @@ discard block |
||
| 379 | 379 | } |
| 380 | 380 | |
| 381 | 381 | public function getForm() { |
| 382 | - if(!isset($this->_form)){ |
|
| 382 | + if (!isset($this->_form)) { |
|
| 383 | 383 | $this->_form=new HtmlForm("frm-".$this->identifier); |
| 384 | 384 | $this->setEdition(true); |
| 385 | 385 | } |
| 386 | 386 | return $this->_form; |
| 387 | 387 | } |
| 388 | 388 | |
| 389 | - public function run(JsUtils $js){ |
|
| 389 | + public function run(JsUtils $js) { |
|
| 390 | 390 | $result=parent::run($js); |
| 391 | - if(isset($this->_form)){ |
|
| 391 | + if (isset($this->_form)) { |
|
| 392 | 392 | $result=$this->runForm($js); |
| 393 | 393 | } |
| 394 | 394 | return $result; |
| 395 | 395 | } |
| 396 | 396 | |
| 397 | - protected function runForm(JsUtils $js){ |
|
| 397 | + protected function runForm(JsUtils $js) { |
|
| 398 | 398 | $fields=$this->getContentInstances(HtmlFormField::class); |
| 399 | - foreach ($fields as $field){ |
|
| 399 | + foreach ($fields as $field) { |
|
| 400 | 400 | $this->_form->addField($field); |
| 401 | 401 | } |
| 402 | 402 | return $this->_form->run($js); |
| 403 | 403 | } |
| 404 | 404 | |
| 405 | - protected function _compileForm(){ |
|
| 406 | - if(isset($this->_form)){ |
|
| 405 | + protected function _compileForm() { |
|
| 406 | + if (isset($this->_form)) { |
|
| 407 | 407 | $noValidate=""; |
| 408 | - if(\sizeof($this->_form->getValidationParams())>0) |
|
| 408 | + if (\sizeof($this->_form->getValidationParams())>0) |
|
| 409 | 409 | $noValidate="novalidate"; |
| 410 | - $this->wrapContent("<form class='ui form' id='frm-".$this->identifier."' name='frm-".$this->identifier."' ".$noValidate.">","</form>"); |
|
| 410 | + $this->wrapContent("<form class='ui form' id='frm-".$this->identifier."' name='frm-".$this->identifier."' ".$noValidate.">", "</form>"); |
|
| 411 | 411 | } |
| 412 | 412 | } |
| 413 | 413 | |
@@ -416,26 +416,26 @@ discard block |
||
| 416 | 416 | return $this; |
| 417 | 417 | } |
| 418 | 418 | |
| 419 | - public function moveFieldTo($from,$to){ |
|
| 419 | + public function moveFieldTo($from, $to) { |
|
| 420 | 420 | return $this->_instanceViewer->moveFieldTo($from, $to); |
| 421 | 421 | } |
| 422 | 422 | |
| 423 | - public function swapFields($index1,$index2){ |
|
| 423 | + public function swapFields($index1, $index2) { |
|
| 424 | 424 | $index1=$this->_getIndex($index1); |
| 425 | 425 | $index2=$this->_getIndex($index2); |
| 426 | 426 | return $this->_instanceViewer->swapFields($index1, $index2); |
| 427 | 427 | } |
| 428 | 428 | |
| 429 | - public function removeField($index){ |
|
| 429 | + public function removeField($index) { |
|
| 430 | 430 | $index=$this->_getIndex($index); |
| 431 | 431 | $this->_instanceViewer->removeField($index); |
| 432 | 432 | return $this; |
| 433 | 433 | } |
| 434 | 434 | |
| 435 | - public function asModal($header){ |
|
| 436 | - $modal=new HtmlModal("modal-".$this->identifier,$header); |
|
| 435 | + public function asModal($header) { |
|
| 436 | + $modal=new HtmlModal("modal-".$this->identifier, $header); |
|
| 437 | 437 | $modal->setContent($this); |
| 438 | - if(isset($this->_form)){ |
|
| 438 | + if (isset($this->_form)) { |
|
| 439 | 439 | $this->_form->onSuccess($modal->jsHide()); |
| 440 | 440 | } |
| 441 | 441 | return $modal; |