@@ -19,46 +19,46 @@ discard block |
||
| 19 | 19 | * @property string $identifier |
| 20 | 20 | */ |
| 21 | 21 | trait FieldsTrait { |
| 22 | - abstract public function addFields($fields=NULL,$label=NULL); |
|
| 22 | + abstract public function addFields($fields=NULL, $label=NULL); |
|
| 23 | 23 | abstract public function addItem($item); |
| 24 | 24 | |
| 25 | - protected function createItem($value){ |
|
| 26 | - if(\is_array($value)){ |
|
| 27 | - $itemO=new HtmlFormInput(JArray::getDefaultValue($value, "id",""),JArray::getDefaultValue($value, "label",null),JArray::getDefaultValue($value, "type", "text"),JArray::getDefaultValue($value, "value",""),JArray::getDefaultValue($value, "placeholder",JArray::getDefaultValue($value, "label",null))); |
|
| 25 | + protected function createItem($value) { |
|
| 26 | + if (\is_array($value)) { |
|
| 27 | + $itemO=new HtmlFormInput(JArray::getDefaultValue($value, "id", ""), JArray::getDefaultValue($value, "label", null), JArray::getDefaultValue($value, "type", "text"), JArray::getDefaultValue($value, "value", ""), JArray::getDefaultValue($value, "placeholder", JArray::getDefaultValue($value, "label", null))); |
|
| 28 | 28 | return $itemO; |
| 29 | - }elseif(\is_object($value)){ |
|
| 29 | + }elseif (\is_object($value)) { |
|
| 30 | 30 | $itemO=new HtmlFormField("field-".$this->identifier, $value); |
| 31 | 31 | return $itemO; |
| 32 | - }else |
|
| 32 | + } else |
|
| 33 | 33 | return new HtmlFormInput($value); |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - protected function createCondition($value){ |
|
| 36 | + protected function createCondition($value) { |
|
| 37 | 37 | return \is_object($value)===false || $value instanceof \Ajax\semantic\html\elements\HtmlInput; |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | - public function addInputs($inputs,$fieldslabel=null){ |
|
| 40 | + public function addInputs($inputs, $fieldslabel=null) { |
|
| 41 | 41 | $fields=array(); |
| 42 | - foreach ($inputs as $input){ |
|
| 42 | + foreach ($inputs as $input) { |
|
| 43 | 43 | \extract($input); |
| 44 | - $f=new HtmlFormInput("",""); |
|
| 44 | + $f=new HtmlFormInput("", ""); |
|
| 45 | 45 | $f->fromArray($input); |
| 46 | 46 | $fields[]=$f; |
| 47 | 47 | } |
| 48 | - return $this->addFields($fields,$fieldslabel); |
|
| 48 | + return $this->addFields($fields, $fieldslabel); |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | - public function addFieldRule($index,$type,$prompt=NULL,$value=NULL){ |
|
| 51 | + public function addFieldRule($index, $type, $prompt=NULL, $value=NULL) { |
|
| 52 | 52 | $field=$this->getItem($index); |
| 53 | - if(isset($field)){ |
|
| 54 | - $field->addRule($type,$prompt,$value); |
|
| 53 | + if (isset($field)) { |
|
| 54 | + $field->addRule($type, $prompt, $value); |
|
| 55 | 55 | } |
| 56 | 56 | return $this; |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | - public function addFieldRules($index,$rules){ |
|
| 59 | + public function addFieldRules($index, $rules) { |
|
| 60 | 60 | $field=$this->getItem($index); |
| 61 | - if(isset($field)){ |
|
| 61 | + if (isset($field)) { |
|
| 62 | 62 | $field->addRules($rules); |
| 63 | 63 | } |
| 64 | 64 | return $this; |
@@ -72,8 +72,8 @@ discard block |
||
| 72 | 72 | * @param boolean $multiple |
| 73 | 73 | * @return HtmlDoubleElement |
| 74 | 74 | */ |
| 75 | - public function addDropdown($identifier,$items=array(), $label=NULL,$value=NULL,$multiple=false){ |
|
| 76 | - return $this->addItem(new HtmlFormDropdown($identifier,$items,$label,$value,$multiple)); |
|
| 75 | + public function addDropdown($identifier, $items=array(), $label=NULL, $value=NULL, $multiple=false) { |
|
| 76 | + return $this->addItem(new HtmlFormDropdown($identifier, $items, $label, $value, $multiple)); |
|
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | /** |
@@ -84,8 +84,8 @@ discard block |
||
| 84 | 84 | * @param string $placeholder |
| 85 | 85 | * @return HtmlFormInput |
| 86 | 86 | */ |
| 87 | - public function addInput($identifier, $label=NULL,$type="text",$value=NULL,$placeholder=NULL){ |
|
| 88 | - return $this->addItem(new HtmlFormInput($identifier,$label,$type,$value,$placeholder)); |
|
| 87 | + public function addInput($identifier, $label=NULL, $type="text", $value=NULL, $placeholder=NULL) { |
|
| 88 | + return $this->addItem(new HtmlFormInput($identifier, $label, $type, $value, $placeholder)); |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | /** |
@@ -96,28 +96,28 @@ discard block |
||
| 96 | 96 | * @param int $rows |
| 97 | 97 | * @return HtmlTextarea |
| 98 | 98 | */ |
| 99 | - public function addTextarea($identifier, $label,$value=NULL,$placeholder=NULL,$rows=5){ |
|
| 100 | - return $this->addItem(new HtmlFormTextarea($identifier,$label,$value,$placeholder,$rows)); |
|
| 99 | + public function addTextarea($identifier, $label, $value=NULL, $placeholder=NULL, $rows=5) { |
|
| 100 | + return $this->addItem(new HtmlFormTextarea($identifier, $label, $value, $placeholder, $rows)); |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | - public function addPassword($identifier, $label=NULL){ |
|
| 104 | - return $this->addItem(new HtmlFormInput($identifier,$label,"password","","")); |
|
| 103 | + public function addPassword($identifier, $label=NULL) { |
|
| 104 | + return $this->addItem(new HtmlFormInput($identifier, $label, "password", "", "")); |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | - public function addButton($identifier,$value,$cssStyle=NULL,$onClick=NULL){ |
|
| 108 | - return $this->addItem(new HtmlButton($identifier,$value,$cssStyle,$onClick)); |
|
| 107 | + public function addButton($identifier, $value, $cssStyle=NULL, $onClick=NULL) { |
|
| 108 | + return $this->addItem(new HtmlButton($identifier, $value, $cssStyle, $onClick)); |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | - public function addCheckbox($identifier, $label=NULL,$value=NULL,$type=NULL){ |
|
| 112 | - return $this->addItem(new HtmlFormCheckbox($identifier,$label,$value,$type)); |
|
| 111 | + public function addCheckbox($identifier, $label=NULL, $value=NULL, $type=NULL) { |
|
| 112 | + return $this->addItem(new HtmlFormCheckbox($identifier, $label, $value, $type)); |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | - public function addRadio($identifier, $name,$label=NULL,$value=NULL){ |
|
| 116 | - return $this->addItem(new HtmlFormRadio($identifier,$name,$label,$value)); |
|
| 115 | + public function addRadio($identifier, $name, $label=NULL, $value=NULL) { |
|
| 116 | + return $this->addItem(new HtmlFormRadio($identifier, $name, $label, $value)); |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | - public function addElement($identifier,$content,$label,$tagName="div",$baseClass=""){ |
|
| 120 | - $div=new HtmlSemDoubleElement($identifier,$tagName,$baseClass,$content); |
|
| 121 | - return $this->addItem(new HtmlFormField("field-".$identifier, $div,$label)); |
|
| 119 | + public function addElement($identifier, $content, $label, $tagName="div", $baseClass="") { |
|
| 120 | + $div=new HtmlSemDoubleElement($identifier, $tagName, $baseClass, $content); |
|
| 121 | + return $this->addItem(new HtmlFormField("field-".$identifier, $div, $label)); |
|
| 122 | 122 | } |
| 123 | 123 | } |
@@ -16,19 +16,19 @@ discard block |
||
| 16 | 16 | protected $ajaxLoader='<span></span><span></span><span></span><span></span><span></span>'; |
| 17 | 17 | |
| 18 | 18 | abstract public function getUrl($url); |
| 19 | - abstract public function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false,$immediatly=true); |
|
| 19 | + abstract public function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false, $immediatly=true); |
|
| 20 | 20 | |
| 21 | - protected function _ajax($method,$url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true,$jqueryDone="html",$ajaxTransition=null,$immediatly=false) { |
|
| 22 | - if(JString::isNull($params)){$params="{}";} |
|
| 21 | + protected function _ajax($method, $url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true, $jqueryDone="html", $ajaxTransition=null, $immediatly=false) { |
|
| 22 | + if (JString::isNull($params)) {$params="{}"; } |
|
| 23 | 23 | $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
| 24 | 24 | $retour=$this->_getAjaxUrl($url, $attr); |
| 25 | 25 | $responseElement=$this->_getResponseElement($responseElement); |
| 26 | 26 | $retour.="var self=this;\n"; |
| 27 | - if($hasLoader===true){ |
|
| 27 | + if ($hasLoader===true) { |
|
| 28 | 28 | $this->addLoading($retour, $responseElement); |
| 29 | 29 | } |
| 30 | 30 | $retour.="$.".$method."(url,".$params.").done(function( data ) {\n"; |
| 31 | - $retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone,$ajaxTransition,$jsCallback)."});\n"; |
|
| 31 | + $retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback)."});\n"; |
|
| 32 | 32 | if ($immediatly) |
| 33 | 33 | $this->jquery_code_for_compile[]=$retour; |
| 34 | 34 | return $retour; |
@@ -36,33 +36,33 @@ discard block |
||
| 36 | 36 | |
| 37 | 37 | |
| 38 | 38 | |
| 39 | - protected function _getAjaxUrl($url,$attr){ |
|
| 39 | + protected function _getAjaxUrl($url, $attr) { |
|
| 40 | 40 | $url=$this->_correctAjaxUrl($url); |
| 41 | 41 | $retour="url='".$url."';"; |
| 42 | 42 | $slash="/"; |
| 43 | - if(JString::endswith($url, "/")===true) |
|
| 43 | + if (JString::endswith($url, "/")===true) |
|
| 44 | 44 | $slash=""; |
| 45 | - if(JString::isNotNull($attr)){ |
|
| 45 | + if (JString::isNotNull($attr)) { |
|
| 46 | 46 | if ($attr==="value") |
| 47 | 47 | $retour.="url=url+'".$slash."'+$(this).val();\n"; |
| 48 | 48 | elseif ($attr==="html") |
| 49 | 49 | $retour.="url=url+'".$slash."'+$(this).html();\n"; |
| 50 | - elseif($attr!==null && $attr!=="") |
|
| 50 | + elseif ($attr!==null && $attr!=="") |
|
| 51 | 51 | $retour.="url=url+'".$slash."'+($(this).attr('".$attr."')||'');\n"; |
| 52 | 52 | } |
| 53 | 53 | return $retour; |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | - protected function _getOnAjaxDone($responseElement,$jqueryDone,$ajaxTransition,$jsCallback){ |
|
| 57 | - $retour="";$call=null; |
|
| 56 | + protected function _getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback) { |
|
| 57 | + $retour=""; $call=null; |
|
| 58 | 58 | if ($responseElement!=="") { |
| 59 | - if(isset($ajaxTransition)){ |
|
| 59 | + if (isset($ajaxTransition)) { |
|
| 60 | 60 | $call=$this->setAjaxDataCall($ajaxTransition); |
| 61 | - }elseif(isset($this->ajaxTransition)){ |
|
| 61 | + }elseif (isset($this->ajaxTransition)) { |
|
| 62 | 62 | $call=$this->ajaxTransition; |
| 63 | 63 | } |
| 64 | - if(\is_callable($call)) |
|
| 65 | - $retour="\t".$call($responseElement,$jqueryDone).";\n"; |
|
| 64 | + if (\is_callable($call)) |
|
| 65 | + $retour="\t".$call($responseElement, $jqueryDone).";\n"; |
|
| 66 | 66 | else |
| 67 | 67 | $retour="\t$({$responseElement}).{$jqueryDone}( data );\n"; |
| 68 | 68 | } |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | return $retour; |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | - protected function _getResponseElement($responseElement){ |
|
| 73 | + protected function _getResponseElement($responseElement) { |
|
| 74 | 74 | if ($responseElement!=="") { |
| 75 | 75 | $responseElement=Javascript::prep_value($responseElement); |
| 76 | 76 | } |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | protected function _correctAjaxUrl($url) { |
| 81 | 81 | if ($url!=="/" && JString::endsWith($url, "/")===true) |
| 82 | 82 | $url=substr($url, 0, strlen($url)-1); |
| 83 | - if (strncmp($url, 'http://', 7)!=0&&strncmp($url, 'https://', 8)!=0) { |
|
| 83 | + if (strncmp($url, 'http://', 7)!=0 && strncmp($url, 'https://', 8)!=0) { |
|
| 84 | 84 | $url=$this->getUrl($url); |
| 85 | 85 | } |
| 86 | 86 | return $url; |
@@ -98,11 +98,11 @@ discard block |
||
| 98 | 98 | $retour.="\t\t$({$responseElement}).prepend('{$loading_notifier}');\n"; |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | - protected function setAjaxDataCall($params){ |
|
| 101 | + protected function setAjaxDataCall($params) { |
|
| 102 | 102 | $result=null; |
| 103 | - if(!\is_callable($params)){ |
|
| 104 | - $result=function ($responseElement,$jqueryDone="html") use($params){ |
|
| 105 | - return AjaxTransition::{$params}($responseElement,$jqueryDone); |
|
| 103 | + if (!\is_callable($params)) { |
|
| 104 | + $result=function($responseElement, $jqueryDone="html") use($params){ |
|
| 105 | + return AjaxTransition::{$params}($responseElement, $jqueryDone); |
|
| 106 | 106 | }; |
| 107 | 107 | } |
| 108 | 108 | return $result; |
@@ -122,8 +122,8 @@ discard block |
||
| 122 | 122 | * @param string $jqueryDone the jquery function call on ajax data. default:html |
| 123 | 123 | * @param string|callable $ajaxTransition |
| 124 | 124 | */ |
| 125 | - private function _get($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true,$jqueryDone="html",$ajaxTransition=null,$immediatly=false) { |
|
| 126 | - return $this->_ajax("get", $url,$params,$responseElement,$jsCallback,$attr,$hasLoader,$jqueryDone,$ajaxTransition,$immediatly); |
|
| 125 | + private function _get($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true, $jqueryDone="html", $ajaxTransition=null, $immediatly=false) { |
|
| 126 | + return $this->_ajax("get", $url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition, $immediatly); |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | /** |
@@ -136,8 +136,8 @@ discard block |
||
| 136 | 136 | * @param string $jqueryDone the jquery function call on ajax data. default:html |
| 137 | 137 | * @param string|callable $ajaxTransition |
| 138 | 138 | */ |
| 139 | - public function get($url, $responseElement="", $params="{}", $jsCallback=NULL,$hasLoader=true,$jqueryDone="html",$ajaxTransition=null) { |
|
| 140 | - return $this->_get($url,$params,$responseElement,$jsCallback,null,$hasLoader,$jqueryDone,$ajaxTransition,true); |
|
| 139 | + public function get($url, $responseElement="", $params="{}", $jsCallback=NULL, $hasLoader=true, $jqueryDone="html", $ajaxTransition=null) { |
|
| 140 | + return $this->_get($url, $params, $responseElement, $jsCallback, null, $hasLoader, $jqueryDone, $ajaxTransition, true); |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | /** |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | * @param string $context |
| 151 | 151 | * @param boolean $immediatly |
| 152 | 152 | */ |
| 153 | - private function _json($url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context="document",$immediatly=false) { |
|
| 153 | + private function _json($url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context="document", $immediatly=false) { |
|
| 154 | 154 | $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
| 155 | 155 | $retour=$this->_getAjaxUrl($url, $attr); |
| 156 | 156 | $retour.="$.{$method}(url,".$params.").done(function( data ) {\n"; |
@@ -173,8 +173,8 @@ discard block |
||
| 173 | 173 | * @param string $context |
| 174 | 174 | * @param boolean $immediatly |
| 175 | 175 | */ |
| 176 | - public function json($url, $method="get", $params="{}", $jsCallback=NULL,$context="document",$immediatly=false) { |
|
| 177 | - return $this->_json($url,$method,$params,$jsCallback,NULL,$context,$immediatly); |
|
| 176 | + public function json($url, $method="get", $params="{}", $jsCallback=NULL, $context="document", $immediatly=false) { |
|
| 177 | + return $this->_json($url, $method, $params, $jsCallback, NULL, $context, $immediatly); |
|
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | /** |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | * @param string $url the request address |
| 185 | 185 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get","immediatly"=>true) |
| 186 | 186 | */ |
| 187 | - public function jsonOn($event,$element, $url,$parameters=array()) { |
|
| 187 | + public function jsonOn($event, $element, $url, $parameters=array()) { |
|
| 188 | 188 | $preventDefault=true; |
| 189 | 189 | $stopPropagation=true; |
| 190 | 190 | $jsCallback=null; |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | $params="{}"; |
| 195 | 195 | $immediatly=true; |
| 196 | 196 | extract($parameters); |
| 197 | - return $this->_add_event($element, $this->_json($url,$method, $params,$jsCallback, $attr,$context), $event, $preventDefault, $stopPropagation,$immediatly); |
|
| 197 | + return $this->_add_event($element, $this->_json($url, $method, $params, $jsCallback, $attr, $context), $event, $preventDefault, $stopPropagation, $immediatly); |
|
| 198 | 198 | } |
| 199 | 199 | |
| 200 | 200 | /** |
@@ -205,8 +205,8 @@ discard block |
||
| 205 | 205 | * @param string $jsCallback javascript code to execute after the request |
| 206 | 206 | * @param string $context jquery DOM element, array container. |
| 207 | 207 | */ |
| 208 | - public function jsonDeferred($url, $method="get", $params="{}", $jsCallback=NULL,$context=NULL) { |
|
| 209 | - return $this->json($url, $method, $params, $jsCallback, $context,false); |
|
| 208 | + public function jsonDeferred($url, $method="get", $params="{}", $jsCallback=NULL, $context=NULL) { |
|
| 209 | + return $this->json($url, $method, $params, $jsCallback, $context, false); |
|
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | /** |
@@ -219,22 +219,22 @@ discard block |
||
| 219 | 219 | * @param string $rowClass the css class for the new element |
| 220 | 220 | * @param boolean $immediatly |
| 221 | 221 | */ |
| 222 | - private function _jsonArray($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL,$rowClass="_json",$context=NULL,$attr="id",$immediatly=false) { |
|
| 222 | + private function _jsonArray($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL, $rowClass="_json", $context=NULL, $attr="id", $immediatly=false) { |
|
| 223 | 223 | $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
| 224 | 224 | $retour=$this->_getAjaxUrl($url, $attr); |
| 225 | - if($context===null){ |
|
| 225 | + if ($context===null) { |
|
| 226 | 226 | $parent="$('".$maskSelector."').parent()"; |
| 227 | - $newElm = "$('#'+newId)"; |
|
| 228 | - }else{ |
|
| 227 | + $newElm="$('#'+newId)"; |
|
| 228 | + } else { |
|
| 229 | 229 | $parent=$context; |
| 230 | - $newElm = $context.".find('#'+newId)"; |
|
| 230 | + $newElm=$context.".find('#'+newId)"; |
|
| 231 | 231 | } |
| 232 | 232 | $appendTo="\t\tnewElm.appendTo(".$parent.");\n"; |
| 233 | 233 | $retour.="var self = $(this);\n$.{$method}(url,".$params.").done(function( data ) {\n"; |
| 234 | 234 | $retour.=$parent.".find('._json').remove();"; |
| 235 | 235 | $retour.="\tdata=$.parseJSON(data);$.each(data, function(index, value) {\n"."\tvar created=false;var maskElm=$('".$maskSelector."').first();maskElm.hide();"."\tvar newId=(maskElm.attr('id') || 'mask')+'-'+index;"."\tvar newElm=".$newElm.";\n"."\tif(!newElm.length){\n"."\t\tnewElm=maskElm.clone(); |
| 236 | 236 | newElm.attr('id',newId);\n;newElm.addClass('{$rowClass}').removeClass('_jsonArrayModel');\nnewElm.find('[id]').each(function(){ var newId=$(this).attr('id')+'-'+index;$(this).attr('id',newId).removeClass('_jsonArrayChecked');});\n"; |
| 237 | - $retour.= $appendTo; |
|
| 237 | + $retour.=$appendTo; |
|
| 238 | 238 | $retour.="\t}\n"."\tfor(var key in value){\n"."\t\t\tvar html = $('<div />').append($(newElm).clone()).html();\n"."\t\t\tif(html.indexOf('__'+key+'__')>-1){\n"."\t\t\t\tcontent=$(html.split('__'+key+'__').join(value[key]));\n"."\t\t\t\t$(newElm).replaceWith(content);newElm=content;\n"."\t\t\t}\n"."\t\tvar sel='[data-id=\"'+key+'\"]';if($(sel,newElm).length){\n"."\t\t\tvar selElm=$(sel,newElm);\n"."\t\t\t if(selElm.is('[value]')) { selElm.attr('value',value[key]);selElm.val(value[key]);} else { selElm.html(value[key]); }\n"."\t\t}\n"."}\n"."\t$(newElm).show(true);"."\n"."\t$(newElm).removeClass('hide');"."});\n"; |
| 239 | 239 | $retour.="\t$(document).trigger('jsonReady',[data]);\n"; |
| 240 | 240 | $retour.="\t".$jsCallback."\n"."});\n"; |
@@ -253,8 +253,8 @@ discard block |
||
| 253 | 253 | * @param string $context jquery DOM element, array container. |
| 254 | 254 | * @param boolean $immediatly |
| 255 | 255 | */ |
| 256 | - public function jsonArray($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL,$rowClass="_json",$context=NULL,$immediatly=false) { |
|
| 257 | - return $this->_jsonArray($maskSelector, $url,$method,$params,$jsCallback,$rowClass,$context,NULL,$immediatly); |
|
| 256 | + public function jsonArray($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL, $rowClass="_json", $context=NULL, $immediatly=false) { |
|
| 257 | + return $this->_jsonArray($maskSelector, $url, $method, $params, $jsCallback, $rowClass, $context, NULL, $immediatly); |
|
| 258 | 258 | } |
| 259 | 259 | |
| 260 | 260 | /** |
@@ -267,8 +267,8 @@ discard block |
||
| 267 | 267 | * @param string $rowClass the css class for the new element |
| 268 | 268 | * @param string $context jquery DOM element, array container. |
| 269 | 269 | */ |
| 270 | - public function jsonArrayDeferred($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL,$rowClass="_json",$context=NULL) { |
|
| 271 | - return $this->jsonArray($maskSelector, $url, $method, $params, $jsCallback,$rowClass,$context,false); |
|
| 270 | + public function jsonArrayDeferred($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL, $rowClass="_json", $context=NULL) { |
|
| 271 | + return $this->jsonArray($maskSelector, $url, $method, $params, $jsCallback, $rowClass, $context, false); |
|
| 272 | 272 | } |
| 273 | 273 | |
| 274 | 274 | /** |
@@ -278,18 +278,18 @@ discard block |
||
| 278 | 278 | * @param string $url the request url |
| 279 | 279 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get","rowClass"=>"_json","immediatly"=>true) |
| 280 | 280 | */ |
| 281 | - public function jsonArrayOn($event,$element,$maskSelector, $url,$parameters=array()) { |
|
| 281 | + public function jsonArrayOn($event, $element, $maskSelector, $url, $parameters=array()) { |
|
| 282 | 282 | $preventDefault=true; |
| 283 | 283 | $stopPropagation=true; |
| 284 | 284 | $jsCallback=null; |
| 285 | 285 | $attr="id"; |
| 286 | 286 | $method="get"; |
| 287 | - $context = null; |
|
| 287 | + $context=null; |
|
| 288 | 288 | $params="{}"; |
| 289 | 289 | $immediatly=true; |
| 290 | 290 | $rowClass="_json"; |
| 291 | 291 | extract($parameters); |
| 292 | - return $this->_add_event($element, $this->_jsonArray($maskSelector,$url,$method, $params,$jsCallback, $rowClass, $context,$attr), $event, $preventDefault, $stopPropagation,$immediatly); |
|
| 292 | + return $this->_add_event($element, $this->_jsonArray($maskSelector, $url, $method, $params, $jsCallback, $rowClass, $context, $attr), $event, $preventDefault, $stopPropagation, $immediatly); |
|
| 293 | 293 | } |
| 294 | 294 | |
| 295 | 295 | /** |
@@ -303,8 +303,8 @@ discard block |
||
| 303 | 303 | * @param string $jqueryDone the jquery function call on ajax data. default:html |
| 304 | 304 | * @param string|callable $ajaxTransition |
| 305 | 305 | */ |
| 306 | - public function getDeferred($url, $responseElement="", $params="{}", $jsCallback=NULL,$attr="id",$jqueryDone="html",$ajaxTransition=null) { |
|
| 307 | - return $this->_get($url, $params,$responseElement,$jsCallback,$attr,false,$jqueryDone,$ajaxTransition); |
|
| 306 | + public function getDeferred($url, $responseElement="", $params="{}", $jsCallback=NULL, $attr="id", $jqueryDone="html", $ajaxTransition=null) { |
|
| 307 | + return $this->_get($url, $params, $responseElement, $jsCallback, $attr, false, $jqueryDone, $ajaxTransition); |
|
| 308 | 308 | } |
| 309 | 309 | |
| 310 | 310 | /** |
@@ -327,7 +327,7 @@ discard block |
||
| 327 | 327 | $ajaxTransition=null; |
| 328 | 328 | $params="{}"; |
| 329 | 329 | extract($parameters); |
| 330 | - return $this->_add_event($element, $this->_get($url, $params,$responseElement,$jsCallback,$attr, $hasLoader,$jqueryDone,$ajaxTransition), $event, $preventDefault, $stopPropagation,$immediatly); |
|
| 330 | + return $this->_add_event($element, $this->_get($url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition), $event, $preventDefault, $stopPropagation, $immediatly); |
|
| 331 | 331 | } |
| 332 | 332 | |
| 333 | 333 | /** |
@@ -342,8 +342,8 @@ discard block |
||
| 342 | 342 | return $this->getOn("click", $element, $url, $responseElement, $parameters); |
| 343 | 343 | } |
| 344 | 344 | |
| 345 | - private function _post($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true,$jqueryDone="html",$ajaxTransition=null,$immediatly=false) { |
|
| 346 | - return $this->_ajax("post", $url,$params,$responseElement,$jsCallback,$attr,$hasLoader,$jqueryDone,$ajaxTransition,$immediatly); |
|
| 345 | + private function _post($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true, $jqueryDone="html", $ajaxTransition=null, $immediatly=false) { |
|
| 346 | + return $this->_ajax("post", $url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition, $immediatly); |
|
| 347 | 347 | } |
| 348 | 348 | |
| 349 | 349 | /** |
@@ -356,8 +356,8 @@ discard block |
||
| 356 | 356 | * @param string $jqueryDone the jquery function call on ajax data. default:html |
| 357 | 357 | * @param string|callable $ajaxTransition |
| 358 | 358 | */ |
| 359 | - public function post($url, $responseElement="", $params="{}", $jsCallback=NULL,$hasLoader=true,$jqueryDone="html",$ajaxTransition=null) { |
|
| 360 | - return $this->_post($url, $params, $responseElement, $jsCallback, NULL, $hasLoader,$jqueryDone,$ajaxTransition,true); |
|
| 359 | + public function post($url, $responseElement="", $params="{}", $jsCallback=NULL, $hasLoader=true, $jqueryDone="html", $ajaxTransition=null) { |
|
| 360 | + return $this->_post($url, $params, $responseElement, $jsCallback, NULL, $hasLoader, $jqueryDone, $ajaxTransition, true); |
|
| 361 | 361 | } |
| 362 | 362 | |
| 363 | 363 | /** |
@@ -372,8 +372,8 @@ discard block |
||
| 372 | 372 | * @param string $jqueryDone the jquery function call on ajax data. default:html |
| 373 | 373 | * @param string|callable $ajaxTransition |
| 374 | 374 | */ |
| 375 | - public function postDeferred($url, $responseElement="", $params="{}", $jsCallback=NULL, $attr="id",$hasLoader=true,$jqueryDone="html",$ajaxTransition=null) { |
|
| 376 | - return $this->_post($url, $params, $responseElement, $jsCallback, $attr, $hasLoader,$jqueryDone,$ajaxTransition,false); |
|
| 375 | + public function postDeferred($url, $responseElement="", $params="{}", $jsCallback=NULL, $attr="id", $hasLoader=true, $jqueryDone="html", $ajaxTransition=null) { |
|
| 376 | + return $this->_post($url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition, false); |
|
| 377 | 377 | } |
| 378 | 378 | |
| 379 | 379 | /** |
@@ -396,7 +396,7 @@ discard block |
||
| 396 | 396 | $jqueryDone="html"; |
| 397 | 397 | $ajaxTransition=null; |
| 398 | 398 | extract($parameters); |
| 399 | - return $this->_add_event($element, $this->_post($url, $params, $responseElement, $jsCallback, $attr,$hasLoader,$jqueryDone,$ajaxTransition), $event, $preventDefault, $stopPropagation,$immediatly); |
|
| 399 | + return $this->_add_event($element, $this->_post($url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition), $event, $preventDefault, $stopPropagation, $immediatly); |
|
| 400 | 400 | } |
| 401 | 401 | |
| 402 | 402 | /** |
@@ -412,20 +412,20 @@ discard block |
||
| 412 | 412 | return $this->postOn("click", $element, $url, $params, $responseElement, $parameters); |
| 413 | 413 | } |
| 414 | 414 | |
| 415 | - private function _postForm($url, $form, $responseElement, $params=null,$validation=false, $jsCallback=NULL, $attr="id", $hasLoader=true,$jqueryDone="html",$ajaxTransition=null,$immediatly=false) { |
|
| 415 | + private function _postForm($url, $form, $responseElement, $params=null, $validation=false, $jsCallback=NULL, $attr="id", $hasLoader=true, $jqueryDone="html", $ajaxTransition=null, $immediatly=false) { |
|
| 416 | 416 | $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
| 417 | 417 | $retour=$this->_getAjaxUrl($url, $attr); |
| 418 | 418 | $retour.="\nvar params=$('#".$form."').serialize();\n"; |
| 419 | - if(isset($params)){ |
|
| 419 | + if (isset($params)) { |
|
| 420 | 420 | $retour.="params+='&'+$.param(".$params.");\n"; |
| 421 | 421 | } |
| 422 | 422 | $responseElement=$this->_getResponseElement($responseElement); |
| 423 | 423 | $retour.="var self=this;\n"; |
| 424 | - if($hasLoader===true){ |
|
| 424 | + if ($hasLoader===true) { |
|
| 425 | 425 | $this->addLoading($retour, $responseElement); |
| 426 | 426 | } |
| 427 | 427 | $retour.="$.post(url,params).done(function( data ) {\n"; |
| 428 | - $retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone,$ajaxTransition,$jsCallback)."});\n"; |
|
| 428 | + $retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback)."});\n"; |
|
| 429 | 429 | |
| 430 | 430 | if ($validation) { |
| 431 | 431 | $retour="$('#".$form."').validate({submitHandler: function(form) { |
@@ -449,8 +449,8 @@ discard block |
||
| 449 | 449 | * @param string $jqueryDone the jquery function call on ajax data. default:html |
| 450 | 450 | * @param string|callable $ajaxTransition |
| 451 | 451 | */ |
| 452 | - public function postForm($url, $form, $responseElement, $params=NULL,$validation=false, $jsCallback=NULL,$hasLoader=true,$jqueryDone="html",$ajaxTransition=null) { |
|
| 453 | - return $this->_postForm($url, $form, $responseElement, $params,$validation, $jsCallback, NULL, $hasLoader,$jqueryDone,$ajaxTransition,true); |
|
| 452 | + public function postForm($url, $form, $responseElement, $params=NULL, $validation=false, $jsCallback=NULL, $hasLoader=true, $jqueryDone="html", $ajaxTransition=null) { |
|
| 453 | + return $this->_postForm($url, $form, $responseElement, $params, $validation, $jsCallback, NULL, $hasLoader, $jqueryDone, $ajaxTransition, true); |
|
| 454 | 454 | } |
| 455 | 455 | |
| 456 | 456 | /** |
@@ -467,8 +467,8 @@ discard block |
||
| 467 | 467 | * @param string $jqueryDone the jquery function call on ajax data. default:html |
| 468 | 468 | * @param string|callable $ajaxTransition |
| 469 | 469 | */ |
| 470 | - public function postFormDeferred($url, $form, $responseElement, $params=NULL,$validation=false, $jsCallback=NULL,$attr="id",$hasLoader=true,$jqueryDone="html",$ajaxTransition=null) { |
|
| 471 | - return $this->_postForm($url, $form, $responseElement, $params,$validation, $jsCallback, $attr, $hasLoader,$jqueryDone,$ajaxTransition,false); |
|
| 470 | + public function postFormDeferred($url, $form, $responseElement, $params=NULL, $validation=false, $jsCallback=NULL, $attr="id", $hasLoader=true, $jqueryDone="html", $ajaxTransition=null) { |
|
| 471 | + return $this->_postForm($url, $form, $responseElement, $params, $validation, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition, false); |
|
| 472 | 472 | } |
| 473 | 473 | |
| 474 | 474 | /** |
@@ -493,7 +493,7 @@ discard block |
||
| 493 | 493 | $jqueryDone="html"; |
| 494 | 494 | $ajaxTransition=null; |
| 495 | 495 | extract($parameters); |
| 496 | - return $this->_add_event($element, $this->_postForm($url, $form, $responseElement,$params, $validation, $jsCallback, $attr,$hasLoader,$jqueryDone,$ajaxTransition), $event, $preventDefault, $stopPropagation,$immediatly); |
|
| 496 | + return $this->_add_event($element, $this->_postForm($url, $form, $responseElement, $params, $validation, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition), $event, $preventDefault, $stopPropagation, $immediatly); |
|
| 497 | 497 | } |
| 498 | 498 | |
| 499 | 499 | /** |
@@ -29,27 +29,27 @@ |
||
| 29 | 29 | $rowClass="_json"; |
| 30 | 30 | extract($this->parameters); |
| 31 | 31 | $result=$this->_eventPreparing($preventDefault, $stopPropagation); |
| 32 | - switch($this->method) { |
|
| 32 | + switch ($this->method) { |
|
| 33 | 33 | case "get": |
| 34 | - $result.=$js->getDeferred($url, $responseElement, $params, $jsCallback, $attr,$jqueryDone,$ajaxTransition); |
|
| 34 | + $result.=$js->getDeferred($url, $responseElement, $params, $jsCallback, $attr, $jqueryDone, $ajaxTransition); |
|
| 35 | 35 | break; |
| 36 | 36 | case "post": |
| 37 | - $result.=$js->postDeferred($url, $responseElement, $params, $jsCallback, $attr,$hasLoader,$jqueryDone,$ajaxTransition); |
|
| 37 | + $result.=$js->postDeferred($url, $responseElement, $params, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition); |
|
| 38 | 38 | break; |
| 39 | 39 | case "postForm": |
| 40 | - $result.=$js->postFormDeferred($url, $form, $responseElement, $params,$validation, $jsCallback, $attr,$hasLoader,$jqueryDone,$ajaxTransition); |
|
| 40 | + $result.=$js->postFormDeferred($url, $form, $responseElement, $params, $validation, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition); |
|
| 41 | 41 | break; |
| 42 | 42 | case "json": |
| 43 | - $result.=$js->jsonDeferred($url,$method,$params,$jsCallback); |
|
| 43 | + $result.=$js->jsonDeferred($url, $method, $params, $jsCallback); |
|
| 44 | 44 | break; |
| 45 | 45 | case "jsonArray": |
| 46 | - $result.=$js->jsonArrayDeferred($modelSelector, $url,$method,$params,$jsCallback,$rowClass); |
|
| 46 | + $result.=$js->jsonArrayDeferred($modelSelector, $url, $method, $params, $jsCallback, $rowClass); |
|
| 47 | 47 | break; |
| 48 | 48 | } |
| 49 | 49 | return $result; |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | - protected function _eventPreparing($preventDefault,$stopPropagation){ |
|
| 52 | + protected function _eventPreparing($preventDefault, $stopPropagation) { |
|
| 53 | 53 | $result=""; |
| 54 | 54 | if ($preventDefault===true) { |
| 55 | 55 | $result.=Javascript::$preventDefault; |
@@ -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; |
@@ -105,17 +105,17 @@ discard block |
||
| 105 | 105 | * @return HtmlLabel |
| 106 | 106 | */ |
| 107 | 107 | public function addLabel($label, $before=false, $icon=NULL) { |
| 108 | - $this->tagName="div";$prefix=""; |
|
| 109 | - if($before) |
|
| 108 | + $this->tagName="div"; $prefix=""; |
|
| 109 | + if ($before) |
|
| 110 | 110 | $prefix="left "; |
| 111 | 111 | $this->addToProperty("class", $prefix."labeled"); |
| 112 | 112 | $isIcon=(isset($this->content[0]) && $this->content[0] instanceof HtmlIcon); |
| 113 | - $this->content=new HtmlButton("button-" . $this->identifier, $this->content); |
|
| 114 | - if($isIcon){ |
|
| 113 | + $this->content=new HtmlButton("button-".$this->identifier, $this->content); |
|
| 114 | + if ($isIcon) { |
|
| 115 | 115 | $this->content->addClass("icon"); |
| 116 | 116 | } |
| 117 | 117 | $this->content->setTagName("div"); |
| 118 | - $label=new HtmlLabel("label-" . $this->identifier, $label, $icon,"a"); |
|
| 118 | + $label=new HtmlLabel("label-".$this->identifier, $label, $icon, "a"); |
|
| 119 | 119 | $label->setBasic(); |
| 120 | 120 | $this->addContent($label, $before); |
| 121 | 121 | return $label; |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | */ |
| 128 | 128 | public function fromArray($array) { |
| 129 | 129 | $array=parent::fromArray($array); |
| 130 | - foreach ( $array as $key => $value ) { |
|
| 130 | + foreach ($array as $key => $value) { |
|
| 131 | 131 | $this->setProperty($key, $value); |
| 132 | 132 | } |
| 133 | 133 | return $array; |
@@ -141,10 +141,10 @@ discard block |
||
| 141 | 141 | return $this->addToProperty("class", "positive"); |
| 142 | 142 | } |
| 143 | 143 | |
| 144 | - public function setColor($color){ |
|
| 145 | - if(\is_array($this->content)){ |
|
| 146 | - foreach ($this->content as $content){ |
|
| 147 | - if($content instanceof HtmlButton) |
|
| 144 | + public function setColor($color) { |
|
| 145 | + if (\is_array($this->content)) { |
|
| 146 | + foreach ($this->content as $content) { |
|
| 147 | + if ($content instanceof HtmlButton) |
|
| 148 | 148 | $content->setColor($color); |
| 149 | 149 | } |
| 150 | 150 | } |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | * @return HtmlButton |
| 203 | 203 | */ |
| 204 | 204 | public static function social($identifier, $social, $value=NULL) { |
| 205 | - if ($value === NULL) |
|
| 205 | + if ($value===NULL) |
|
| 206 | 206 | $value=\ucfirst($social); |
| 207 | 207 | $return=new HtmlButton($identifier, $value); |
| 208 | 208 | $return->addIcon($social); |
@@ -239,8 +239,8 @@ discard block |
||
| 239 | 239 | * {@inheritDoc} |
| 240 | 240 | * @see HtmlSemDoubleElement::asLink() |
| 241 | 241 | */ |
| 242 | - public function asLink($href=NULL,$target=NULL) { |
|
| 243 | - parent::asLink($href,$target); |
|
| 242 | + public function asLink($href=NULL, $target=NULL) { |
|
| 243 | + parent::asLink($href, $target); |
|
| 244 | 244 | /*$lnk=new HtmlLink("lnk-".$this->identifier,$href,$this->content,$target); |
| 245 | 245 | $this->content=$lnk;*/ |
| 246 | 246 | return $this; |
@@ -2,5 +2,5 @@ |
||
| 2 | 2 | namespace Ajax\semantic\html\base\constants; |
| 3 | 3 | use Ajax\common\BaseEnum; |
| 4 | 4 | abstract class Social extends BaseEnum { |
| 5 | - const FACEBOOK="facebook", TWITTER="twitter",GOOGLEPLUS="google plus",VK="vk",LINKEDIN="linkedin",INSTAGRAM="instagram",YOUTUBE="youtube",GITHUB="github"; |
|
| 5 | + const FACEBOOK="facebook", TWITTER="twitter", GOOGLEPLUS="google plus", VK="vk", LINKEDIN="linkedin", INSTAGRAM="instagram", YOUTUBE="youtube", GITHUB="github"; |
|
| 6 | 6 | } |
@@ -13,27 +13,27 @@ discard block |
||
| 13 | 13 | use Ajax\semantic\html\collections\form\traits\FieldTrait; |
| 14 | 14 | |
| 15 | 15 | class HtmlDropdown extends HtmlSemDoubleElement { |
| 16 | - use FieldTrait,LabeledIconTrait { |
|
| 16 | + use FieldTrait, LabeledIconTrait { |
|
| 17 | 17 | addIcon as addIconP; |
| 18 | 18 | } |
| 19 | 19 | protected $mClass="menu"; |
| 20 | 20 | protected $mTagName="div"; |
| 21 | - protected $items=array (); |
|
| 22 | - protected $_params=array("action"=>"nothing","on"=>"hover"); |
|
| 21 | + protected $items=array(); |
|
| 22 | + protected $_params=array("action"=>"nothing", "on"=>"hover"); |
|
| 23 | 23 | protected $input; |
| 24 | 24 | protected $value; |
| 25 | 25 | protected $_associative; |
| 26 | 26 | |
| 27 | - public function __construct($identifier, $value="", $items=array(),$associative=true) { |
|
| 27 | + public function __construct($identifier, $value="", $items=array(), $associative=true) { |
|
| 28 | 28 | parent::__construct($identifier, "div"); |
| 29 | 29 | $this->_template=include dirname(__FILE__).'/../templates/tplDropdown.php'; |
| 30 | 30 | $this->setProperty("class", "ui dropdown"); |
| 31 | 31 | $content=[]; |
| 32 | - if(isset($value)){ |
|
| 33 | - if($value instanceof HtmlSemDoubleElement){ |
|
| 32 | + if (isset($value)) { |
|
| 33 | + if ($value instanceof HtmlSemDoubleElement) { |
|
| 34 | 34 | $text=$value; |
| 35 | - }else{ |
|
| 36 | - $text=new HtmlSemDoubleElement("text-".$this->identifier,"div"); |
|
| 35 | + } else { |
|
| 36 | + $text=new HtmlSemDoubleElement("text-".$this->identifier, "div"); |
|
| 37 | 37 | $text->setClass("text"); |
| 38 | 38 | $this->setValue($value); |
| 39 | 39 | } |
@@ -46,29 +46,29 @@ discard block |
||
| 46 | 46 | $this->addItems($items); |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | - public function getField(){ |
|
| 49 | + public function getField() { |
|
| 50 | 50 | return $this->input; |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | - public function getDataField(){ |
|
| 53 | + public function getDataField() { |
|
| 54 | 54 | return $this->input; |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - public function addItem($item,$value=NULL,$image=NULL,$description=NULL){ |
|
| 58 | - $itemO=$this->beforeAddItem($item,$value,$image,$description); |
|
| 57 | + public function addItem($item, $value=NULL, $image=NULL, $description=NULL) { |
|
| 58 | + $itemO=$this->beforeAddItem($item, $value, $image, $description); |
|
| 59 | 59 | $this->items[]=$itemO; |
| 60 | 60 | return $itemO; |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | - public function addIcon($icon,$before=true,$labeled=false){ |
|
| 63 | + public function addIcon($icon, $before=true, $labeled=false) { |
|
| 64 | 64 | $this->removeArrow(); |
| 65 | - $this->addIconP($icon,$before,$labeled); |
|
| 65 | + $this->addIconP($icon, $before, $labeled); |
|
| 66 | 66 | return $this->getElementById("text-".$this->identifier, $this->content)->setWrapAfter(""); |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | - public function addIcons($icons){ |
|
| 69 | + public function addIcons($icons) { |
|
| 70 | 70 | $count=$this->count(); |
| 71 | - for ($i=0;$i<\sizeof($icons) && $i<$count;$i++){ |
|
| 71 | + for ($i=0; $i<\sizeof($icons) && $i<$count; $i++) { |
|
| 72 | 72 | $this->getItem($i)->addIcon($icons[$i]); |
| 73 | 73 | } |
| 74 | 74 | } |
@@ -79,33 +79,33 @@ discard block |
||
| 79 | 79 | * @param number $position |
| 80 | 80 | * @return \Ajax\semantic\html\content\HtmlDropdownItem|unknown |
| 81 | 81 | */ |
| 82 | - public function insertItem($item,$position=0){ |
|
| 82 | + public function insertItem($item, $position=0) { |
|
| 83 | 83 | $itemO=$this->beforeAddItem($item); |
| 84 | - $start = array_slice($this->items, 0, $position); |
|
| 85 | - $end = array_slice($this->items, $position); |
|
| 86 | - $start[] = $item; |
|
| 84 | + $start=array_slice($this->items, 0, $position); |
|
| 85 | + $end=array_slice($this->items, $position); |
|
| 86 | + $start[]=$item; |
|
| 87 | 87 | $this->items=array_merge($start, $end); |
| 88 | 88 | return $itemO; |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | - protected function removeArrow(){ |
|
| 92 | - if(\sizeof($this->content)>1){ |
|
| 91 | + protected function removeArrow() { |
|
| 92 | + if (\sizeof($this->content)>1) { |
|
| 93 | 93 | unset($this->content["arrow"]); |
| 94 | 94 | $this->content=\array_values($this->content); |
| 95 | 95 | } |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - protected function beforeAddItem($item,$value=NULL,$image=NULL,$description=NULL){ |
|
| 98 | + protected function beforeAddItem($item, $value=NULL, $image=NULL, $description=NULL) { |
|
| 99 | 99 | $itemO=$item; |
| 100 | - if(\is_array($item)){ |
|
| 100 | + if (\is_array($item)) { |
|
| 101 | 101 | $description=JArray::getValue($item, "description", 3); |
| 102 | 102 | $value=JArray::getValue($item, "value", 1); |
| 103 | 103 | $image=JArray::getValue($item, "image", 2); |
| 104 | 104 | $item=JArray::getValue($item, "item", 0); |
| 105 | 105 | } |
| 106 | - if(!$item instanceof HtmlDropdownItem){ |
|
| 107 | - $itemO=new HtmlDropdownItem("dd-item-".$this->identifier."-".\sizeof($this->items),$item,$value,$image,$description); |
|
| 108 | - }elseif($itemO instanceof HtmlDropdownItem){ |
|
| 106 | + if (!$item instanceof HtmlDropdownItem) { |
|
| 107 | + $itemO=new HtmlDropdownItem("dd-item-".$this->identifier."-".\sizeof($this->items), $item, $value, $image, $description); |
|
| 108 | + }elseif ($itemO instanceof HtmlDropdownItem) { |
|
| 109 | 109 | $this->addToProperty("class", "vertical"); |
| 110 | 110 | } |
| 111 | 111 | return $itemO; |
@@ -118,11 +118,11 @@ discard block |
||
| 118 | 118 | $this->addItem($function($object)); |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | - public function addInput($name){ |
|
| 122 | - if(!isset($name)) |
|
| 121 | + public function addInput($name) { |
|
| 122 | + if (!isset($name)) |
|
| 123 | 123 | $name="input-".$this->identifier; |
| 124 | 124 | $this->setAction("activate"); |
| 125 | - $this->input=new HtmlInput($name,"hidden"); |
|
| 125 | + $this->input=new HtmlInput($name, "hidden"); |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | /** |
@@ -131,15 +131,15 @@ discard block |
||
| 131 | 131 | * @param string $icon |
| 132 | 132 | * @return \Ajax\semantic\html\content\HtmlDropdownItem |
| 133 | 133 | */ |
| 134 | - public function addSearchInputItem($placeHolder=NULL,$icon=NULL){ |
|
| 135 | - return $this->addItem(HtmlDropdownItem::searchInput($placeHolder,$icon)); |
|
| 134 | + public function addSearchInputItem($placeHolder=NULL, $icon=NULL) { |
|
| 135 | + return $this->addItem(HtmlDropdownItem::searchInput($placeHolder, $icon)); |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | /** |
| 139 | 139 | * Adds a divider item |
| 140 | 140 | * @return \Ajax\semantic\html\content\HtmlDropdownItem |
| 141 | 141 | */ |
| 142 | - public function addDividerItem(){ |
|
| 142 | + public function addDividerItem() { |
|
| 143 | 143 | return $this->addItem(HtmlDropdownItem::divider()); |
| 144 | 144 | } |
| 145 | 145 | |
@@ -149,8 +149,8 @@ discard block |
||
| 149 | 149 | * @param string $icon |
| 150 | 150 | * @return \Ajax\semantic\html\content\HtmlDropdownItem|unknown |
| 151 | 151 | */ |
| 152 | - public function addHeaderItem($caption=NULL,$icon=NULL){ |
|
| 153 | - return $this->addItem(HtmlDropdownItem::header($caption,$icon)); |
|
| 152 | + public function addHeaderItem($caption=NULL, $icon=NULL) { |
|
| 153 | + return $this->addItem(HtmlDropdownItem::header($caption, $icon)); |
|
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | /** |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | * @param string $color |
| 160 | 160 | * @return \Ajax\semantic\html\content\HtmlDropdownItem|unknown |
| 161 | 161 | */ |
| 162 | - public function addCircularLabelItem($caption,$color){ |
|
| 162 | + public function addCircularLabelItem($caption, $color) { |
|
| 163 | 163 | return $this->addItem(HtmlDropdownItem::circular($caption, $color)); |
| 164 | 164 | } |
| 165 | 165 | |
@@ -168,88 +168,88 @@ discard block |
||
| 168 | 168 | * @param string $image |
| 169 | 169 | * @return \Ajax\semantic\html\content\HtmlDropdownItem |
| 170 | 170 | */ |
| 171 | - public function addMiniAvatarImageItem($caption,$image){ |
|
| 171 | + public function addMiniAvatarImageItem($caption, $image) { |
|
| 172 | 172 | return $this->addItem(HtmlDropdownItem::avatar($caption, $image)); |
| 173 | 173 | } |
| 174 | 174 | |
| 175 | - public function addItems($items){ |
|
| 176 | - if(\is_array($items) && $this->_associative){ |
|
| 177 | - foreach ($items as $k=>$v){ |
|
| 175 | + public function addItems($items) { |
|
| 176 | + if (\is_array($items) && $this->_associative) { |
|
| 177 | + foreach ($items as $k=>$v) { |
|
| 178 | 178 | $this->addItem($v)->setData($k); |
| 179 | 179 | } |
| 180 | - }else{ |
|
| 181 | - foreach ($items as $item){ |
|
| 180 | + } else { |
|
| 181 | + foreach ($items as $item) { |
|
| 182 | 182 | $this->addItem($item); |
| 183 | 183 | } |
| 184 | 184 | } |
| 185 | 185 | } |
| 186 | 186 | |
| 187 | - public function getItem($index){ |
|
| 187 | + public function getItem($index) { |
|
| 188 | 188 | return $this->items[$index]; |
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 | /** |
| 192 | 192 | * @return int |
| 193 | 193 | */ |
| 194 | - public function count(){ |
|
| 194 | + public function count() { |
|
| 195 | 195 | return \sizeof($this->items); |
| 196 | 196 | } |
| 197 | 197 | /** |
| 198 | 198 | * @param boolean $dropdown |
| 199 | 199 | */ |
| 200 | - public function asDropdown($dropdown){ |
|
| 201 | - if($dropdown===false){ |
|
| 200 | + public function asDropdown($dropdown) { |
|
| 201 | + if ($dropdown===false) { |
|
| 202 | 202 | $this->_template=include dirname(__FILE__).'/../templates/tplDropdownMenu.php'; |
| 203 | 203 | $dropdown="menu"; |
| 204 | - }else{ |
|
| 204 | + } else { |
|
| 205 | 205 | $dropdown="dropdown"; |
| 206 | 206 | $this->mClass="menu"; |
| 207 | 207 | } |
| 208 | - return $this->addToPropertyCtrl("class", $dropdown,array("menu","dropdown")); |
|
| 208 | + return $this->addToPropertyCtrl("class", $dropdown, array("menu", "dropdown")); |
|
| 209 | 209 | } |
| 210 | 210 | |
| 211 | - public function setVertical(){ |
|
| 212 | - return $this->addToPropertyCtrl("class", "vertical",array("vertical")); |
|
| 211 | + public function setVertical() { |
|
| 212 | + return $this->addToPropertyCtrl("class", "vertical", array("vertical")); |
|
| 213 | 213 | } |
| 214 | 214 | |
| 215 | - public function setInline(){ |
|
| 216 | - return $this->addToPropertyCtrl("class", "inline",["inline"]); |
|
| 215 | + public function setInline() { |
|
| 216 | + return $this->addToPropertyCtrl("class", "inline", ["inline"]); |
|
| 217 | 217 | } |
| 218 | 218 | |
| 219 | - public function setSimple(){ |
|
| 220 | - return $this->addToPropertyCtrl("class", "simple",array("simple")); |
|
| 219 | + public function setSimple() { |
|
| 220 | + return $this->addToPropertyCtrl("class", "simple", array("simple")); |
|
| 221 | 221 | } |
| 222 | 222 | |
| 223 | - public function asButton($floating=false){ |
|
| 223 | + public function asButton($floating=false) { |
|
| 224 | 224 | $this->removeArrow(); |
| 225 | - if($floating) |
|
| 225 | + if ($floating) |
|
| 226 | 226 | $this->addToProperty("class", "floating"); |
| 227 | 227 | $this->removePropertyValue("class", "selection"); |
| 228 | 228 | return $this->addToProperty("class", "button"); |
| 229 | 229 | } |
| 230 | 230 | |
| 231 | - public function asSelect($name=NULL,$multiple=false,$selection=true){ |
|
| 232 | - if(isset($name)) |
|
| 231 | + public function asSelect($name=NULL, $multiple=false, $selection=true) { |
|
| 232 | + if (isset($name)) |
|
| 233 | 233 | $this->addInput($name); |
| 234 | - if($multiple) |
|
| 234 | + if ($multiple) |
|
| 235 | 235 | $this->addToProperty("class", "multiple"); |
| 236 | - if ($selection){ |
|
| 237 | - if($this->propertyContains("class", "button")===false) |
|
| 238 | - $this->addToPropertyCtrl("class", "selection",array("selection")); |
|
| 236 | + if ($selection) { |
|
| 237 | + if ($this->propertyContains("class", "button")===false) |
|
| 238 | + $this->addToPropertyCtrl("class", "selection", array("selection")); |
|
| 239 | 239 | } |
| 240 | 240 | return $this; |
| 241 | 241 | } |
| 242 | 242 | |
| 243 | - public function asSearch($name=NULL,$multiple=false,$selection=true){ |
|
| 244 | - $this->asSelect($name,$multiple,$selection); |
|
| 243 | + public function asSearch($name=NULL, $multiple=false, $selection=true) { |
|
| 244 | + $this->asSelect($name, $multiple, $selection); |
|
| 245 | 245 | return $this->addToProperty("class", "search"); |
| 246 | 246 | } |
| 247 | 247 | |
| 248 | - public function setSelect($name=NULL,$multiple=false){ |
|
| 249 | - if(!isset($name)) |
|
| 248 | + public function setSelect($name=NULL, $multiple=false) { |
|
| 249 | + if (!isset($name)) |
|
| 250 | 250 | $name="select-".$this->identifier; |
| 251 | 251 | $this->input=null; |
| 252 | - if($multiple){ |
|
| 252 | + if ($multiple) { |
|
| 253 | 253 | $this->setProperty("multiple", true); |
| 254 | 254 | $this->addToProperty("class", "multiple"); |
| 255 | 255 | } |
@@ -257,37 +257,37 @@ discard block |
||
| 257 | 257 | $this->tagName="select"; |
| 258 | 258 | $this->setProperty("name", $name); |
| 259 | 259 | $this->content=null; |
| 260 | - foreach ($this->items as $item){ |
|
| 260 | + foreach ($this->items as $item) { |
|
| 261 | 261 | $item->asOption(); |
| 262 | 262 | } |
| 263 | 263 | return $this; |
| 264 | 264 | } |
| 265 | 265 | |
| 266 | - public function asSubmenu($pointing=NULL){ |
|
| 266 | + public function asSubmenu($pointing=NULL) { |
|
| 267 | 267 | $this->setClass("ui dropdown link item"); |
| 268 | - if(isset($pointing)){ |
|
| 268 | + if (isset($pointing)) { |
|
| 269 | 269 | $this->setPointing($pointing); |
| 270 | 270 | } |
| 271 | 271 | return $this; |
| 272 | 272 | } |
| 273 | 273 | |
| 274 | - public function setPointing($value=Direction::NONE){ |
|
| 275 | - return $this->addToPropertyCtrl("class", $value." pointing",Direction::getConstantValues("pointing")); |
|
| 274 | + public function setPointing($value=Direction::NONE) { |
|
| 275 | + return $this->addToPropertyCtrl("class", $value." pointing", Direction::getConstantValues("pointing")); |
|
| 276 | 276 | } |
| 277 | 277 | |
| 278 | - public function setValue($value){ |
|
| 278 | + public function setValue($value) { |
|
| 279 | 279 | $this->value=$value; |
| 280 | 280 | return $this; |
| 281 | 281 | } |
| 282 | - private function applyValue(){ |
|
| 282 | + private function applyValue() { |
|
| 283 | 283 | $value=$this->value; |
| 284 | - if(isset($this->input) && isset($value)){ |
|
| 284 | + if (isset($this->input) && isset($value)) { |
|
| 285 | 285 | $this->input->setProperty("value", $value); |
| 286 | - }else{ |
|
| 286 | + } else { |
|
| 287 | 287 | $this->setProperty("value", $value); |
| 288 | 288 | } |
| 289 | 289 | $textElement=$this->getElementById("text-".$this->identifier, $this->content); |
| 290 | - if(isset($textElement)) |
|
| 290 | + if (isset($textElement)) |
|
| 291 | 291 | $textElement->setContent($value); |
| 292 | 292 | return $this; |
| 293 | 293 | } |
@@ -297,9 +297,9 @@ discard block |
||
| 297 | 297 | * @see BaseHtml::run() |
| 298 | 298 | */ |
| 299 | 299 | public function run(JsUtils $js) { |
| 300 | - if($this->propertyContains("class", "simple")===false){ |
|
| 301 | - if(isset($this->_bsComponent)===false){ |
|
| 302 | - $this->_bsComponent=$js->semantic()->dropdown("#".$this->identifier,$this->_params); |
|
| 300 | + if ($this->propertyContains("class", "simple")===false) { |
|
| 301 | + if (isset($this->_bsComponent)===false) { |
|
| 302 | + $this->_bsComponent=$js->semantic()->dropdown("#".$this->identifier, $this->_params); |
|
| 303 | 303 | $this->_bsComponent->setItemSelector(".item"); |
| 304 | 304 | } |
| 305 | 305 | $this->addEventsOnRun($js); |
@@ -307,31 +307,31 @@ discard block |
||
| 307 | 307 | } |
| 308 | 308 | } |
| 309 | 309 | |
| 310 | - public function setCompact(){ |
|
| 310 | + public function setCompact() { |
|
| 311 | 311 | return $this->addToPropertyCtrl("class", "compact", array("compact")); |
| 312 | 312 | } |
| 313 | 313 | |
| 314 | - public function setAction($action){ |
|
| 314 | + public function setAction($action) { |
|
| 315 | 315 | $this->_params["action"]=$action; |
| 316 | 316 | } |
| 317 | 317 | |
| 318 | - public function setFullTextSearch($value){ |
|
| 318 | + public function setFullTextSearch($value) { |
|
| 319 | 319 | $this->_params["fullTextSearch"]=$value; |
| 320 | 320 | } |
| 321 | 321 | |
| 322 | 322 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
| 323 | 323 | $this->applyValue(); |
| 324 | - return parent::compile($js,$view); |
|
| 324 | + return parent::compile($js, $view); |
|
| 325 | 325 | } |
| 326 | 326 | |
| 327 | 327 | public function getInput() { |
| 328 | 328 | return $this->input; |
| 329 | 329 | } |
| 330 | 330 | public function addAction($action, $direction=Direction::RIGHT, $icon=NULL, $labeled=false) { |
| 331 | - return $this->_addAction($this, $action,$direction,$icon,$labeled); |
|
| 331 | + return $this->_addAction($this, $action, $direction, $icon, $labeled); |
|
| 332 | 332 | } |
| 333 | 333 | |
| 334 | - public function jsAddItem($caption){ |
|
| 334 | + public function jsAddItem($caption) { |
|
| 335 | 335 | $js="var first=$('#{$this->identifier} .item').first();if(first!=undefined){var new =first.clone();first.parent().append(new);first.html('{$caption}};')"; |
| 336 | 336 | return $js; |
| 337 | 337 | } |
@@ -27,11 +27,11 @@ discard block |
||
| 27 | 27 | * @return $this |
| 28 | 28 | */ |
| 29 | 29 | public function setOnShow($jsCode) { |
| 30 | - $jsCode=str_ireplace("\"","%quote%", $jsCode); |
|
| 30 | + $jsCode=str_ireplace("\"", "%quote%", $jsCode); |
|
| 31 | 31 | return $this->setParam("onShow", "%function(){".$jsCode."}%"); |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | - public function setExclusive($value){ |
|
| 34 | + public function setExclusive($value) { |
|
| 35 | 35 | return $this->setParam("exclusive", $value); |
| 36 | 36 | } |
| 37 | 37 | |
@@ -40,19 +40,19 @@ discard block |
||
| 40 | 40 | * @param string $popup the css selector of the popup |
| 41 | 41 | * @return \Ajax\semantic\components\Popup |
| 42 | 42 | */ |
| 43 | - public function setPopup($popup){ |
|
| 43 | + public function setPopup($popup) { |
|
| 44 | 44 | return $this->setParam("popup", $popup); |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - public function setInline($value){ |
|
| 47 | + public function setInline($value) { |
|
| 48 | 48 | return $this->setParam("inline", $value); |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | - public function setPosition($value){ |
|
| 51 | + public function setPosition($value) { |
|
| 52 | 52 | return $this->setParam("position", $value); |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - public function setSetFluidWidth($value){ |
|
| 55 | + public function setSetFluidWidth($value) { |
|
| 56 | 56 | return $this->setParam("setFluidWidth", $value); |
| 57 | 57 | } |
| 58 | 58 | } |
@@ -10,56 +10,56 @@ |
||
| 10 | 10 | * @param string $identifier |
| 11 | 11 | * @param object $modelInstance |
| 12 | 12 | */ |
| 13 | - public function __construct($identifier,$modelInstance=null,$fieldsOrder=[],$fieldsDefinition=[],$fields=[],$captions=[],$separators=[]) { |
|
| 14 | - parent::__construct($identifier,$modelInstance,$fieldsOrder,$fieldsDefinition,$fields,$captions,$separators); |
|
| 13 | + public function __construct($identifier, $modelInstance=null, $fieldsOrder=[], $fieldsDefinition=[], $fields=[], $captions=[], $separators=[]) { |
|
| 14 | + parent::__construct($identifier, $modelInstance, $fieldsOrder, $fieldsDefinition, $fields, $captions, $separators); |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | - protected function getDefaultModelInstance(){ |
|
| 17 | + protected function getDefaultModelInstance() { |
|
| 18 | 18 | return new UserModel(); |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | - public static function regular($identifier,$modelInstance=null){ |
|
| 22 | - return new FormAccount($identifier,$modelInstance, |
|
| 23 | - ["message","login","password","passwordConf","email","submit","error"], |
|
| 21 | + public static function regular($identifier, $modelInstance=null) { |
|
| 22 | + return new FormAccount($identifier, $modelInstance, |
|
| 23 | + ["message", "login", "password", "passwordConf", "email", "submit", "error"], |
|
| 24 | 24 | ["message"=>[["icon"=>"sign in"]], |
| 25 | 25 | "input0"=>[["rules"=>"empty"]], |
| 26 | - "input1"=>[["inputType"=>"password","rules"=> ['minLength[6]', 'empty']]], |
|
| 27 | - "input2"=>[["inputType"=>"password","rules"=> ['minLength[6]', 'empty', 'match[password]']]], |
|
| 26 | + "input1"=>[["inputType"=>"password", "rules"=> ['minLength[6]', 'empty']]], |
|
| 27 | + "input2"=>[["inputType"=>"password", "rules"=> ['minLength[6]', 'empty', 'match[password]']]], |
|
| 28 | 28 | "input3"=>[["rules"=>"email"]], |
| 29 | 29 | "submit"=>["green fluid"], |
| 30 | 30 | "message2"=>[["error"=>true]]], |
| 31 | - ["Account","login","password","passwordConf","email","submit","error"], |
|
| 32 | - ["Please enter your account informations","Login","Password","Password confirmation","Email address","Creation"], |
|
| 33 | - [0,1,3,4,5,6]); |
|
| 31 | + ["Account", "login", "password", "passwordConf", "email", "submit", "error"], |
|
| 32 | + ["Please enter your account informations", "Login", "Password", "Password confirmation", "Email address", "Creation"], |
|
| 33 | + [0, 1, 3, 4, 5, 6]); |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - public static function smallInline($identifier,$modelInstance=null){ |
|
| 37 | - $result=new FormAccount($identifier,$modelInstance, |
|
| 38 | - ["login","password","submit"], |
|
| 39 | - ["input0"=>[["rules"=>"empty"]],"input1"=>[["inputType"=>"password","rules"=>"empty"]],"submit"=>["green basic"]], |
|
| 40 | - ["login","password","submit"], |
|
| 41 | - ["","","Connection"], |
|
| 36 | + public static function smallInline($identifier, $modelInstance=null) { |
|
| 37 | + $result=new FormAccount($identifier, $modelInstance, |
|
| 38 | + ["login", "password", "submit"], |
|
| 39 | + ["input0"=>[["rules"=>"empty"]], "input1"=>[["inputType"=>"password", "rules"=>"empty"]], "submit"=>["green basic"]], |
|
| 40 | + ["login", "password", "submit"], |
|
| 41 | + ["", "", "Connection"], |
|
| 42 | 42 | [2]); |
| 43 | 43 | $result->addDividerBefore(0, "Connection"); |
| 44 | 44 | return $result; |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - public static function small($identifier,$modelInstance=null){ |
|
| 48 | - $result=new FormAccount($identifier,$modelInstance, |
|
| 49 | - ["login","password","submit"], |
|
| 50 | - ["input0"=>[["rules"=>"empty"]],"input1"=>[["inputType"=>"password","rules"=>"empty"]],"submit"=>["green basic"]], |
|
| 51 | - ["login","password","submit"], |
|
| 52 | - ["Login","Password","Connection"], |
|
| 53 | - [1,2]); |
|
| 47 | + public static function small($identifier, $modelInstance=null) { |
|
| 48 | + $result=new FormAccount($identifier, $modelInstance, |
|
| 49 | + ["login", "password", "submit"], |
|
| 50 | + ["input0"=>[["rules"=>"empty"]], "input1"=>[["inputType"=>"password", "rules"=>"empty"]], "submit"=>["green basic"]], |
|
| 51 | + ["login", "password", "submit"], |
|
| 52 | + ["Login", "Password", "Connection"], |
|
| 53 | + [1, 2]); |
|
| 54 | 54 | $result->addDividerBefore(0, "Connection"); |
| 55 | 55 | return $result; |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | - public static function attachedSegment($identifier,$modelInstance=null){ |
|
| 59 | - $result=self::regular($identifier,$modelInstance); |
|
| 60 | - $result->fieldAsMessage("message",["icon"=>"sign in","attached"=>true]); |
|
| 61 | - $result->addWrapper("message",null,"<div class='ui attached segment'>"); |
|
| 62 | - $result->addWrapper("error", null,"</div>"); |
|
| 58 | + public static function attachedSegment($identifier, $modelInstance=null) { |
|
| 59 | + $result=self::regular($identifier, $modelInstance); |
|
| 60 | + $result->fieldAsMessage("message", ["icon"=>"sign in", "attached"=>true]); |
|
| 61 | + $result->addWrapper("message", null, "<div class='ui attached segment'>"); |
|
| 62 | + $result->addWrapper("error", null, "</div>"); |
|
| 63 | 63 | return $result; |
| 64 | 64 | } |
| 65 | 65 | } |
@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | private $pages_visibles; |
| 10 | 10 | private $row_count; |
| 11 | 11 | |
| 12 | - public function __construct($items_per_page=10,$pages_visibles=null,$page=1,$row_count=null){ |
|
| 12 | + public function __construct($items_per_page=10, $pages_visibles=null, $page=1, $row_count=null) { |
|
| 13 | 13 | $this->items_per_page=$items_per_page; |
| 14 | 14 | $this->row_count=$row_count; |
| 15 | 15 | $this->page=$page; |
@@ -17,30 +17,30 @@ discard block |
||
| 17 | 17 | $this->visible=true; |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | - public function getObjects($objects){ |
|
| 20 | + public function getObjects($objects) { |
|
| 21 | 21 | $auto=(!isset($this->row_count)); |
| 22 | 22 | $os=$objects; |
| 23 | - if(!\is_array($os)){ |
|
| 23 | + if (!\is_array($os)) { |
|
| 24 | 24 | $os=[]; |
| 25 | - foreach ($objects as $o){ |
|
| 25 | + foreach ($objects as $o) { |
|
| 26 | 26 | $os[]=$o; |
| 27 | 27 | } |
| 28 | 28 | } |
| 29 | - $this->page_count = 0; |
|
| 30 | - $row_count=($auto)?\sizeof($os):$this->row_count; |
|
| 31 | - if (0 === $row_count) { |
|
| 29 | + $this->page_count=0; |
|
| 30 | + $row_count=($auto) ? \sizeof($os) : $this->row_count; |
|
| 31 | + if (0===$row_count) { |
|
| 32 | 32 | $this->visible=false; |
| 33 | 33 | } else { |
| 34 | 34 | |
| 35 | - $this->page_count = (int)ceil($row_count / $this->items_per_page); |
|
| 35 | + $this->page_count=(int)ceil($row_count/$this->items_per_page); |
|
| 36 | 36 | $this->visible=$this->page_count>1; |
| 37 | - if($this->page > $this->page_count+1) { |
|
| 38 | - $this->page = 1; |
|
| 37 | + if ($this->page>$this->page_count+1) { |
|
| 38 | + $this->page=1; |
|
| 39 | 39 | } |
| 40 | 40 | } |
| 41 | - if($auto){ |
|
| 42 | - $offset = ($this->page - 1) * $this->items_per_page; |
|
| 43 | - return array_slice($os, $offset,$this->items_per_page); |
|
| 41 | + if ($auto) { |
|
| 42 | + $offset=($this->page-1)*$this->items_per_page; |
|
| 43 | + return array_slice($os, $offset, $this->items_per_page); |
|
| 44 | 44 | } |
| 45 | 45 | return $os; |
| 46 | 46 | } |
@@ -76,22 +76,22 @@ discard block |
||
| 76 | 76 | return $this->page_count; |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | - public function getPagesNumbers(){ |
|
| 80 | - $middle= (int)ceil(($this->pages_visibles-1)/ 2); |
|
| 79 | + public function getPagesNumbers() { |
|
| 80 | + $middle=(int)ceil(($this->pages_visibles-1)/2); |
|
| 81 | 81 | $first=$this->page-$middle; |
| 82 | - if($first<1){ |
|
| 82 | + if ($first<1) { |
|
| 83 | 83 | $first=1; |
| 84 | 84 | } |
| 85 | 85 | $last=$first+$this->pages_visibles-1; |
| 86 | - if($last>$this->page_count){ |
|
| 86 | + if ($last>$this->page_count) { |
|
| 87 | 87 | $last=$this->page_count; |
| 88 | 88 | } |
| 89 | 89 | return \range($first, $last); |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | public function setPagesVisibles($pages_visibles) { |
| 93 | - if(!isset($pages_visibles)) |
|
| 94 | - $pages_visibles=(int)ceil($this->row_count / $this->items_per_page)+1; |
|
| 93 | + if (!isset($pages_visibles)) |
|
| 94 | + $pages_visibles=(int)ceil($this->row_count/$this->items_per_page)+1; |
|
| 95 | 95 | $this->pages_visibles=$pages_visibles; |
| 96 | 96 | return $this; |
| 97 | 97 | } |