@@ -15,6 +15,7 @@ |
||
| 15 | 15 | * {@inheritdoc} |
| 16 | 16 | * |
| 17 | 17 | * @see \Ajax\semantic\widgets\dataform\DataForm::__construct() |
| 18 | + * @param string $identifier |
|
| 18 | 19 | */ |
| 19 | 20 | public function __construct($identifier,$modelInstance=null,$fieldsOrder,$fieldsDefinition,$fields=[],$captions=[],$separators=[]) { |
| 20 | 21 | if(!isset($modelInstance)){ |
@@ -121,6 +121,10 @@ |
||
| 121 | 121 | $this->content[$this->_toolbarPosition]=$this->_toolbar; |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | + /** |
|
| 125 | + * @param integer $index |
|
| 126 | + * @param string $title |
|
| 127 | + */ |
|
| 124 | 128 | public function addDividerBefore($index,$title){ |
| 125 | 129 | $index=$this->_getIndex($index); |
| 126 | 130 | $this->_instanceViewer->addHeaderDividerBefore($index, $title); |
@@ -58,16 +58,17 @@ |
||
| 58 | 58 | foreach ($values as $v){ |
| 59 | 59 | $form->addField($v); |
| 60 | 60 | } |
| 61 | - }else{ |
|
| 61 | + } else{ |
|
| 62 | 62 | $separators[]=$count; |
| 63 | 63 | for($i=0;$i<$size;$i++){ |
| 64 | 64 | $fields=\array_slice($values, $separators[$i]+1,$separators[$i+1]-$separators[$i]); |
| 65 | - if(isset($headers[$separators[$i]+1])) |
|
| 66 | - $form->addHeader($headers[$separators[$i]+1],4,true); |
|
| 65 | + if(isset($headers[$separators[$i]+1])) { |
|
| 66 | + $form->addHeader($headers[$separators[$i]+1],4,true); |
|
| 67 | + } |
|
| 67 | 68 | //TODO check why $fields is empty |
| 68 | 69 | if(\sizeof($fields)===1){ |
| 69 | 70 | $form->addField($fields[0]); |
| 70 | - }elseif(\sizeof($fields)>1){ |
|
| 71 | + } elseif(\sizeof($fields)>1){ |
|
| 71 | 72 | $form->addFields($fields); |
| 72 | 73 | } |
| 73 | 74 | } |
@@ -48,8 +48,9 @@ discard block |
||
| 48 | 48 | } |
| 49 | 49 | $retour.="$.".$method."(url,".$params.").done(function( data ) {\n"; |
| 50 | 50 | $retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone,$ajaxTransition,$jsCallback)."});\n"; |
| 51 | - if ($immediatly) |
|
| 52 | - $this->jquery_code_for_compile[]=$retour; |
|
| 51 | + if ($immediatly) { |
|
| 52 | + $this->jquery_code_for_compile[]=$retour; |
|
| 53 | + } |
|
| 53 | 54 | return $retour; |
| 54 | 55 | } |
| 55 | 56 | |
@@ -67,15 +68,17 @@ discard block |
||
| 67 | 68 | $url=$this->_correctAjaxUrl($url); |
| 68 | 69 | $retour="url='".$url."';"; |
| 69 | 70 | $slash="/"; |
| 70 | - if(JString::endswith($url, "/")===true) |
|
| 71 | - $slash=""; |
|
| 71 | + if(JString::endswith($url, "/")===true) { |
|
| 72 | + $slash=""; |
|
| 73 | + } |
|
| 72 | 74 | if(JString::isNotNull($attr)){ |
| 73 | - if ($attr==="value") |
|
| 74 | - $retour.="url=url+'".$slash."'+$(this).val();\n"; |
|
| 75 | - elseif ($attr==="html") |
|
| 76 | - $retour.="url=url+'".$slash."'+$(this).html();\n"; |
|
| 77 | - elseif($attr!=null && $attr!=="") |
|
| 78 | - $retour.="url=url+'".$slash."'+($(this).attr('".$attr."')||'');\n"; |
|
| 75 | + if ($attr==="value") { |
|
| 76 | + $retour.="url=url+'".$slash."'+$(this).val();\n"; |
|
| 77 | + } elseif ($attr==="html") { |
|
| 78 | + $retour.="url=url+'".$slash."'+$(this).html();\n"; |
|
| 79 | + } elseif($attr!=null && $attr!=="") { |
|
| 80 | + $retour.="url=url+'".$slash."'+($(this).attr('".$attr."')||'');\n"; |
|
| 81 | + } |
|
| 79 | 82 | } |
| 80 | 83 | return $retour; |
| 81 | 84 | } |
@@ -85,13 +88,14 @@ discard block |
||
| 85 | 88 | if ($responseElement!=="") { |
| 86 | 89 | if(isset($ajaxTransition)){ |
| 87 | 90 | $call=$this->setAjaxDataCall($ajaxTransition); |
| 88 | - }elseif(isset($this->ajaxTransition)){ |
|
| 91 | + } elseif(isset($this->ajaxTransition)){ |
|
| 89 | 92 | $call=$this->ajaxTransition; |
| 90 | 93 | } |
| 91 | - if(\is_callable($call)) |
|
| 92 | - $retour="\t".$call($responseElement,$jqueryDone).";\n"; |
|
| 93 | - else |
|
| 94 | - $retour="\t$({$responseElement}).{$jqueryDone}( data );\n"; |
|
| 94 | + if(\is_callable($call)) { |
|
| 95 | + $retour="\t".$call($responseElement,$jqueryDone).";\n"; |
|
| 96 | + } else { |
|
| 97 | + $retour="\t$({$responseElement}).{$jqueryDone}( data );\n"; |
|
| 98 | + } |
|
| 95 | 99 | } |
| 96 | 100 | $retour.="\t".$jsCallback."\n"; |
| 97 | 101 | return $retour; |
@@ -105,8 +109,9 @@ discard block |
||
| 105 | 109 | } |
| 106 | 110 | |
| 107 | 111 | protected function _correctAjaxUrl($url) { |
| 108 | - if ($url!=="/" && JString::endsWith($url, "/")===true) |
|
| 109 | - $url=substr($url, 0, strlen($url)-1); |
|
| 112 | + if ($url!=="/" && JString::endsWith($url, "/")===true) { |
|
| 113 | + $url=substr($url, 0, strlen($url)-1); |
|
| 114 | + } |
|
| 110 | 115 | if (strncmp($url, 'http://', 7)!=0&&strncmp($url, 'https://', 8)!=0) { |
| 111 | 116 | $url=$this->jsUtils->getUrl($url); |
| 112 | 117 | } |
@@ -130,8 +135,9 @@ discard block |
||
| 130 | 135 | $retour.="\t".$jsCallback."\n". |
| 131 | 136 | "\t$(document).trigger('jsonReady',[data]);\n". |
| 132 | 137 | "});\n"; |
| 133 | - if ($immediatly) |
|
| 134 | - $this->jquery_code_for_compile[]=$retour; |
|
| 138 | + if ($immediatly) { |
|
| 139 | + $this->jquery_code_for_compile[]=$retour; |
|
| 140 | + } |
|
| 135 | 141 | return $retour; |
| 136 | 142 | } |
| 137 | 143 | |
@@ -170,7 +176,7 @@ discard block |
||
| 170 | 176 | if($context===null){ |
| 171 | 177 | $appendTo="\t\tnewElm.appendTo($('".$maskSelector."').parent());\n"; |
| 172 | 178 | $newElm = "$('#'+newId)"; |
| 173 | - }else{ |
|
| 179 | + } else{ |
|
| 174 | 180 | $appendTo="\t\tnewElm.appendTo(".$context.");\n"; |
| 175 | 181 | $newElm = $context.".find('#'+newId)"; |
| 176 | 182 | } |
@@ -180,8 +186,9 @@ discard block |
||
| 180 | 186 | $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"; |
| 181 | 187 | $retour.="\t$(document).trigger('jsonReady',[data]);\n"; |
| 182 | 188 | $retour.="\t".$jsCallback."\n"."});\n"; |
| 183 | - if ($immediatly) |
|
| 184 | - $this->jquery_code_for_compile[]=$retour; |
|
| 189 | + if ($immediatly) { |
|
| 190 | + $this->jquery_code_for_compile[]=$retour; |
|
| 191 | + } |
|
| 185 | 192 | return $retour; |
| 186 | 193 | } |
| 187 | 194 | /** |
@@ -222,8 +229,9 @@ discard block |
||
| 222 | 229 | }});\n"; |
| 223 | 230 | $retour.="$('#".$form."').submit();\n"; |
| 224 | 231 | } |
| 225 | - if ($immediatly) |
|
| 226 | - $this->jquery_code_for_compile[]=$retour; |
|
| 232 | + if ($immediatly) { |
|
| 233 | + $this->jquery_code_for_compile[]=$retour; |
|
| 234 | + } |
|
| 227 | 235 | return $retour; |
| 228 | 236 | } |
| 229 | 237 | |
@@ -47,15 +47,17 @@ |
||
| 47 | 47 | |
| 48 | 48 | |
| 49 | 49 | public function addSeparatorAfter($fieldNum){ |
| 50 | - if(\array_search($fieldNum, $this->separators)===false) |
|
| 51 | - $this->separators[]=$fieldNum; |
|
| 50 | + if(\array_search($fieldNum, $this->separators)===false) { |
|
| 51 | + $this->separators[]=$fieldNum; |
|
| 52 | + } |
|
| 52 | 53 | return $this; |
| 53 | 54 | } |
| 54 | 55 | |
| 55 | 56 | public function addHeaderDividerBefore($fieldNum,$header){ |
| 56 | 57 | $this->headers[$fieldNum]=$header; |
| 57 | - if($fieldNum>0) |
|
| 58 | - $this->addSeparatorAfter($fieldNum-1); |
|
| 58 | + if($fieldNum>0) { |
|
| 59 | + $this->addSeparatorAfter($fieldNum-1); |
|
| 60 | + } |
|
| 59 | 61 | return $this; |
| 60 | 62 | } |
| 61 | 63 | |
@@ -46,8 +46,9 @@ discard block |
||
| 46 | 46 | |
| 47 | 47 | public function setVariations($variations) { |
| 48 | 48 | $this->setProperty("class", $this->_baseClass); |
| 49 | - if (\is_string($variations)) |
|
| 50 | - $variations=\explode(" ", $variations); |
|
| 49 | + if (\is_string($variations)) { |
|
| 50 | + $variations=\explode(" ", $variations); |
|
| 51 | + } |
|
| 51 | 52 | foreach ( $variations as $variation ) { |
| 52 | 53 | $this->addVariation($variation); |
| 53 | 54 | } |
@@ -60,8 +61,9 @@ discard block |
||
| 60 | 61 | } |
| 61 | 62 | |
| 62 | 63 | public function addVariations($variations=array()) { |
| 63 | - if (\is_string($variations)) |
|
| 64 | - $variations=\explode(" ", $variations); |
|
| 64 | + if (\is_string($variations)) { |
|
| 65 | + $variations=\explode(" ", $variations); |
|
| 66 | + } |
|
| 65 | 67 | foreach ( $variations as $variation ) { |
| 66 | 68 | $this->addVariation($variation); |
| 67 | 69 | } |
@@ -69,8 +71,9 @@ discard block |
||
| 69 | 71 | } |
| 70 | 72 | |
| 71 | 73 | public function addStates($states=array()) { |
| 72 | - if (\is_string($states)) |
|
| 73 | - $states=\explode(" ", $states); |
|
| 74 | + if (\is_string($states)) { |
|
| 75 | + $states=\explode(" ", $states); |
|
| 76 | + } |
|
| 74 | 77 | foreach ( $states as $state ) { |
| 75 | 78 | $this->addState($state); |
| 76 | 79 | } |
@@ -79,8 +82,9 @@ discard block |
||
| 79 | 82 | |
| 80 | 83 | public function setStates($states) { |
| 81 | 84 | $this->setProperty("class", $this->_baseClass); |
| 82 | - if (\is_string($states)) |
|
| 83 | - $states=\explode(" ", $states); |
|
| 85 | + if (\is_string($states)) { |
|
| 86 | + $states=\explode(" ", $states); |
|
| 87 | + } |
|
| 84 | 88 | foreach ( $states as $state ) { |
| 85 | 89 | $this->addState($state); |
| 86 | 90 | } |
@@ -112,8 +116,9 @@ discard block |
||
| 112 | 116 | * @return \Ajax\semantic\html\elements\HtmlSemDoubleElement |
| 113 | 117 | */ |
| 114 | 118 | public function setDisabled($disable=true) { |
| 115 | - if($disable) |
|
| 116 | - $this->addToProperty("class", "disabled"); |
|
| 119 | + if($disable) { |
|
| 120 | + $this->addToProperty("class", "disabled"); |
|
| 121 | + } |
|
| 117 | 122 | return $this; |
| 118 | 123 | } |
| 119 | 124 | |
@@ -147,14 +152,16 @@ discard block |
||
| 147 | 152 | * @return \Ajax\semantic\html\base\HtmlSemDoubleElement |
| 148 | 153 | */ |
| 149 | 154 | public function setActive($value=true){ |
| 150 | - if($value) |
|
| 151 | - $this->addToProperty("class", "active"); |
|
| 155 | + if($value) { |
|
| 156 | + $this->addToProperty("class", "active"); |
|
| 157 | + } |
|
| 152 | 158 | return $this; |
| 153 | 159 | } |
| 154 | 160 | |
| 155 | 161 | public function setAttached($value=true){ |
| 156 | - if($value) |
|
| 157 | - $this->addToPropertyCtrl("class", "attached", array ("attached" )); |
|
| 162 | + if($value) { |
|
| 163 | + $this->addToPropertyCtrl("class", "attached", array ("attached" )); |
|
| 164 | + } |
|
| 158 | 165 | return $this; |
| 159 | 166 | } |
| 160 | 167 | |
@@ -190,10 +197,12 @@ discard block |
||
| 190 | 197 | if(isset($array[$key])){ |
| 191 | 198 | $p=JString::replaceAtFirstAndLast($array[$key], $before, "", $after, ""); |
| 192 | 199 | $array[$key]=$before.$p.$value.$after; |
| 193 | - }else |
|
| 194 | - $array[$key]=$before.$value.$after; |
|
| 195 | - }else |
|
| 196 | - $array[$key]=$value; |
|
| 200 | + } else { |
|
| 201 | + $array[$key]=$before.$value.$after; |
|
| 202 | + } |
|
| 203 | + } else { |
|
| 204 | + $array[$key]=$value; |
|
| 205 | + } |
|
| 197 | 206 | return $this; |
| 198 | 207 | } |
| 199 | 208 | } |
| 200 | 209 | \ No newline at end of file |
@@ -18,8 +18,9 @@ discard block |
||
| 18 | 18 | parent::__construct($identifier, "div","field"); |
| 19 | 19 | $this->content=array(); |
| 20 | 20 | $this->_states=[State::ERROR,State::DISABLED]; |
| 21 | - if(isset($label) && $label!=="") |
|
| 22 | - $this->setLabel($label); |
|
| 21 | + if(isset($label) && $label!=="") { |
|
| 22 | + $this->setLabel($label); |
|
| 23 | + } |
|
| 23 | 24 | $this->setField($field); |
| 24 | 25 | $this->_validation=NULL; |
| 25 | 26 | } |
@@ -50,8 +51,9 @@ discard block |
||
| 50 | 51 | * @return mixed |
| 51 | 52 | */ |
| 52 | 53 | public function getLabel(){ |
| 53 | - if(\array_key_exists("label", $this->content)) |
|
| 54 | - return $this->content["label"]; |
|
| 54 | + if(\array_key_exists("label", $this->content)) { |
|
| 55 | + return $this->content["label"]; |
|
| 56 | + } |
|
| 55 | 57 | } |
| 56 | 58 | |
| 57 | 59 | /** |