@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | */ |
| 21 | 21 | class HtmlForm extends HtmlSemCollection { |
| 22 | 22 | |
| 23 | - use FieldsTrait,FormTrait; |
|
| 23 | + use FieldsTrait, FormTrait; |
|
| 24 | 24 | /** |
| 25 | 25 | * @var array |
| 26 | 26 | */ |
@@ -33,14 +33,14 @@ discard block |
||
| 33 | 33 | |
| 34 | 34 | public function __construct($identifier, $elements=array()) { |
| 35 | 35 | parent::__construct($identifier, "form", "ui form"); |
| 36 | - $this->_states=[ State::ERROR,State::SUCCESS,State::WARNING,State::DISABLED ]; |
|
| 36 | + $this->_states=[State::ERROR, State::SUCCESS, State::WARNING, State::DISABLED]; |
|
| 37 | 37 | $this->setProperty("name", $this->identifier); |
| 38 | - $this->_fields=array (); |
|
| 38 | + $this->_fields=array(); |
|
| 39 | 39 | $this->_validationParams=[]; |
| 40 | 40 | $this->addItems($elements); |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | - protected function getForm(){ |
|
| 43 | + protected function getForm() { |
|
| 44 | 44 | return $this; |
| 45 | 45 | } |
| 46 | 46 | |
@@ -61,14 +61,14 @@ discard block |
||
| 61 | 61 | * @param string $caption |
| 62 | 62 | * @return \Ajax\semantic\html\collections\form\HtmlForm |
| 63 | 63 | */ |
| 64 | - public function addDivider($caption=NULL){ |
|
| 65 | - return $this->addContent(new HtmlDivider("",$caption)); |
|
| 64 | + public function addDivider($caption=NULL) { |
|
| 65 | + return $this->addContent(new HtmlDivider("", $caption)); |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | public function addFields($fields=NULL, $label=NULL) { |
| 69 | 69 | if (isset($fields)) { |
| 70 | 70 | if (!$fields instanceof HtmlFormFields) { |
| 71 | - if (\is_array($fields) === false) { |
|
| 71 | + if (\is_array($fields)===false) { |
|
| 72 | 72 | $fields=\func_get_args(); |
| 73 | 73 | $end=\end($fields); |
| 74 | 74 | if (\is_string($end)) { |
@@ -78,12 +78,12 @@ discard block |
||
| 78 | 78 | $label=NULL; |
| 79 | 79 | } |
| 80 | 80 | $this->_fields=\array_merge($this->_fields, $fields); |
| 81 | - $fields=new HtmlFormFields("fields-" . $this->identifier . "-" . $this->count(), $fields); |
|
| 81 | + $fields=new HtmlFormFields("fields-".$this->identifier."-".$this->count(), $fields); |
|
| 82 | 82 | } |
| 83 | 83 | if (isset($label)) |
| 84 | 84 | $fields=new HtmlFormField("", $fields, $label); |
| 85 | 85 | } else { |
| 86 | - $fields=new HtmlFormFields("fields-" . $this->identifier . "-" . $this->count()); |
|
| 86 | + $fields=new HtmlFormFields("fields-".$this->identifier."-".$this->count()); |
|
| 87 | 87 | } |
| 88 | 88 | $this->addItem($fields); |
| 89 | 89 | return $fields; |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | |
| 92 | 92 | public function addItem($item) { |
| 93 | 93 | $item=parent::addItem($item); |
| 94 | - if (\is_subclass_of($item, HtmlFormField::class) === true) { |
|
| 94 | + if (\is_subclass_of($item, HtmlFormField::class)===true) { |
|
| 95 | 95 | $this->_fields[]=$item; |
| 96 | 96 | } |
| 97 | 97 | return $item; |
@@ -143,10 +143,10 @@ discard block |
||
| 143 | 143 | return $this->addItem($message); |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | - private function addCompoValidation($js,$compo,$field){ |
|
| 146 | + private function addCompoValidation($js, $compo, $field) { |
|
| 147 | 147 | $validation=$field->getValidation(); |
| 148 | - if(isset($validation)){ |
|
| 149 | - if(isset($compo)===false){ |
|
| 148 | + if (isset($validation)) { |
|
| 149 | + if (isset($compo)===false) { |
|
| 150 | 150 | $compo=$js->semantic()->form("#".$this->identifier); |
| 151 | 151 | } |
| 152 | 152 | $validation->setIdentifier($field->getDataField()->getIdentifier()); |
@@ -155,38 +155,38 @@ discard block |
||
| 155 | 155 | return $compo; |
| 156 | 156 | } |
| 157 | 157 | |
| 158 | - public function compile(JsUtils $js=NULL,&$view=NULL){ |
|
| 159 | - if(\sizeof($this->_validationParams)>0) |
|
| 158 | + public function compile(JsUtils $js=NULL, &$view=NULL) { |
|
| 159 | + if (\sizeof($this->_validationParams)>0) |
|
| 160 | 160 | $this->setProperty("novalidate", ""); |
| 161 | - return parent::compile($js,$view); |
|
| 161 | + return parent::compile($js, $view); |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | public function run(JsUtils $js) { |
| 165 | 165 | $compo=NULL; |
| 166 | - foreach ($this->_fields as $field){ |
|
| 167 | - if($field instanceof HtmlFormField) |
|
| 166 | + foreach ($this->_fields as $field) { |
|
| 167 | + if ($field instanceof HtmlFormField) |
|
| 168 | 168 | $compo=$this->addCompoValidation($js, $compo, $field); |
| 169 | 169 | } |
| 170 | - foreach ($this->content as $field){ |
|
| 171 | - if($field instanceof HtmlFormFields){ |
|
| 170 | + foreach ($this->content as $field) { |
|
| 171 | + if ($field instanceof HtmlFormFields) { |
|
| 172 | 172 | $items=$field->getItems(); |
| 173 | - foreach ($items as $_field){ |
|
| 174 | - if($_field instanceof HtmlFormField) |
|
| 173 | + foreach ($items as $_field) { |
|
| 174 | + if ($_field instanceof HtmlFormField) |
|
| 175 | 175 | $compo=$this->addCompoValidation($js, $compo, $_field); |
| 176 | 176 | } |
| 177 | 177 | } |
| 178 | 178 | } |
| 179 | - if(isset($compo)===false){ |
|
| 179 | + if (isset($compo)===false) { |
|
| 180 | 180 | return parent::run($js); |
| 181 | 181 | } |
| 182 | - $this->_runValidationParams($compo,$js); |
|
| 182 | + $this->_runValidationParams($compo, $js); |
|
| 183 | 183 | return $this->_bsComponent; |
| 184 | 184 | } |
| 185 | 185 | |
| 186 | - private function _runValidationParams(&$compo,JsUtils $js=NULL){ |
|
| 187 | - if(isset($this->_validationParams["_ajaxSubmit"]) && $this->_validationParams["_ajaxSubmit"] instanceof AjaxCall){ |
|
| 186 | + private function _runValidationParams(&$compo, JsUtils $js=NULL) { |
|
| 187 | + if (isset($this->_validationParams["_ajaxSubmit"]) && $this->_validationParams["_ajaxSubmit"] instanceof AjaxCall) { |
|
| 188 | 188 | $compilation=$this->_validationParams["_ajaxSubmit"]->compile($js); |
| 189 | - $compilation=str_ireplace("\"","%quote%", $compilation); |
|
| 189 | + $compilation=str_ireplace("\"", "%quote%", $compilation); |
|
| 190 | 190 | $this->onSuccess($compilation); |
| 191 | 191 | unset($this->_validationParams["_ajaxSubmit"]); |
| 192 | 192 | } |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | $this->addEventsOnRun($js); |
| 196 | 196 | } |
| 197 | 197 | |
| 198 | - public function addValidationParam($paramName,$paramValue){ |
|
| 198 | + public function addValidationParam($paramName, $paramValue) { |
|
| 199 | 199 | $this->_validationParams[$paramName]=$paramValue; |
| 200 | 200 | return $this; |
| 201 | 201 | } |
@@ -10,16 +10,16 @@ discard block |
||
| 10 | 10 | * @property SimpleExtComponent $_bsComponent |
| 11 | 11 | * @property string identifier |
| 12 | 12 | */ |
| 13 | -trait BaseHtmlEventsTrait{ |
|
| 13 | +trait BaseHtmlEventsTrait { |
|
| 14 | 14 | |
| 15 | - protected $_events=array (); |
|
| 15 | + protected $_events=array(); |
|
| 16 | 16 | |
| 17 | 17 | public function addEvent($event, $jsCode, $stopPropagation=false, $preventDefault=false) { |
| 18 | - if ($stopPropagation === true) { |
|
| 19 | - $jsCode="event.stopPropagation();" . $jsCode; |
|
| 18 | + if ($stopPropagation===true) { |
|
| 19 | + $jsCode="event.stopPropagation();".$jsCode; |
|
| 20 | 20 | } |
| 21 | - if ($preventDefault === true) { |
|
| 22 | - $jsCode="event.preventDefault();" . $jsCode; |
|
| 21 | + if ($preventDefault===true) { |
|
| 22 | + $jsCode="event.preventDefault();".$jsCode; |
|
| 23 | 23 | } |
| 24 | 24 | return $this->_addEvent($event, $jsCode); |
| 25 | 25 | } |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | if (is_array($this->_events[$event])) { |
| 30 | 30 | $this->_events[$event][]=$jsCode; |
| 31 | 31 | } else { |
| 32 | - $this->_events[$event]=array ($this->_events[$event],$jsCode ); |
|
| 32 | + $this->_events[$event]=array($this->_events[$event], $jsCode); |
|
| 33 | 33 | } |
| 34 | 34 | } else { |
| 35 | 35 | $this->_events[$event]=$jsCode; |
@@ -49,10 +49,10 @@ discard block |
||
| 49 | 49 | return $this->onClick($jsCode); |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | - public function onCreate($jsCode){ |
|
| 53 | - if(isset($this->_events["_create"])){ |
|
| 52 | + public function onCreate($jsCode) { |
|
| 53 | + if (isset($this->_events["_create"])) { |
|
| 54 | 54 | $this->_events["_create"][]=$jsCode; |
| 55 | - }else{ |
|
| 55 | + } else { |
|
| 56 | 56 | $this->_events["_create"]=[$jsCode]; |
| 57 | 57 | } |
| 58 | 58 | return $this; |
@@ -61,15 +61,15 @@ discard block |
||
| 61 | 61 | public function addEventsOnRun(JsUtils $js=NULL) { |
| 62 | 62 | $this->_eventsOnCreate($js); |
| 63 | 63 | if (isset($this->_bsComponent)) { |
| 64 | - foreach ( $this->_events as $event => $jsCode ) { |
|
| 64 | + foreach ($this->_events as $event => $jsCode) { |
|
| 65 | 65 | $code=$jsCode; |
| 66 | 66 | if (is_array($jsCode)) { |
| 67 | 67 | $code=""; |
| 68 | - foreach ( $jsCode as $jsC ) { |
|
| 68 | + foreach ($jsCode as $jsC) { |
|
| 69 | 69 | if ($jsC instanceof AjaxCall) { |
| 70 | - $code.="\n" . $jsC->compile($js); |
|
| 70 | + $code.="\n".$jsC->compile($js); |
|
| 71 | 71 | } else { |
| 72 | - $code.="\n" . $jsC; |
|
| 72 | + $code.="\n".$jsC; |
|
| 73 | 73 | } |
| 74 | 74 | } |
| 75 | 75 | } elseif ($jsCode instanceof AjaxCall) { |
@@ -77,24 +77,24 @@ discard block |
||
| 77 | 77 | } |
| 78 | 78 | $this->_bsComponent->addEvent($event, $code); |
| 79 | 79 | } |
| 80 | - $this->_events=array (); |
|
| 80 | + $this->_events=array(); |
|
| 81 | 81 | } |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | - protected function _eventsOnCreate(JsUtils $js=NULL){ |
|
| 85 | - if(isset($this->_events["_create"])){ |
|
| 84 | + protected function _eventsOnCreate(JsUtils $js=NULL) { |
|
| 85 | + if (isset($this->_events["_create"])) { |
|
| 86 | 86 | $create=$this->_events["_create"]; |
| 87 | - if(\is_array($create)){ |
|
| 87 | + if (\is_array($create)) { |
|
| 88 | 88 | $create=\implode("", $create); |
| 89 | 89 | } |
| 90 | - if(isset($js) && $create!=="") |
|
| 91 | - $js->exec($create,true); |
|
| 90 | + if (isset($js) && $create!=="") |
|
| 91 | + $js->exec($create, true); |
|
| 92 | 92 | unset($this->_events["_create"]); |
| 93 | 93 | } |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | public function _ajaxOn($operation, $event, $url, $responseElement="", $parameters=array()) { |
| 97 | - $params=array ("url" => $url,"responseElement" => $responseElement ); |
|
| 97 | + $params=array("url" => $url, "responseElement" => $responseElement); |
|
| 98 | 98 | $params=array_merge($params, $parameters); |
| 99 | 99 | $this->_addEvent($event, new AjaxCall($operation, $params)); |
| 100 | 100 | return $this; |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | public function jsDoJquery($jqueryCall, $param="") { |
| 130 | - return "$('#" . $this->identifier . "')." . $jqueryCall . "(" . Javascript::prep_value($param) . ");"; |
|
| 130 | + return "$('#".$this->identifier."').".$jqueryCall."(".Javascript::prep_value($param).");"; |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | public function executeOnRun($jsCode) { |
@@ -17,9 +17,9 @@ discard block |
||
| 17 | 17 | use BaseHtmlEventsTrait; |
| 18 | 18 | protected $_template; |
| 19 | 19 | protected $tagName; |
| 20 | - protected $properties=array (); |
|
| 21 | - protected $_wrapBefore=array (); |
|
| 22 | - protected $_wrapAfter=array (); |
|
| 20 | + protected $properties=array(); |
|
| 21 | + protected $_wrapBefore=array(); |
|
| 22 | + protected $_wrapAfter=array(); |
|
| 23 | 23 | protected $_bsComponent; |
| 24 | 24 | |
| 25 | 25 | public function getBsComponent() { |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | protected function getTemplate(JsUtils $js=NULL) { |
| 35 | - return PropertyWrapper::wrap($this->_wrapBefore, $js) . $this->_template . PropertyWrapper::wrap($this->_wrapAfter, $js); |
|
| 35 | + return PropertyWrapper::wrap($this->_wrapBefore, $js).$this->_template.PropertyWrapper::wrap($this->_wrapAfter, $js); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | public function getProperties() { |
@@ -56,13 +56,13 @@ discard block |
||
| 56 | 56 | |
| 57 | 57 | public function addToProperty($name, $value, $separator=" ") { |
| 58 | 58 | if (\is_array($value)) { |
| 59 | - foreach ( $value as $v ) { |
|
| 59 | + foreach ($value as $v) { |
|
| 60 | 60 | $this->addToProperty($name, $v, $separator); |
| 61 | 61 | } |
| 62 | - } else if ($value !== "" && $this->propertyContains($name, $value) === false) { |
|
| 62 | + } else if ($value!=="" && $this->propertyContains($name, $value)===false) { |
|
| 63 | 63 | $v=@$this->properties[$name]; |
| 64 | - if (isset($v) && $v !== "") |
|
| 65 | - $v=$v . $separator . $value; |
|
| 64 | + if (isset($v) && $v!=="") |
|
| 65 | + $v=$v.$separator.$value; |
|
| 66 | 66 | else |
| 67 | 67 | $v=$value; |
| 68 | 68 | |
@@ -78,19 +78,19 @@ discard block |
||
| 78 | 78 | |
| 79 | 79 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
| 80 | 80 | $result=$this->getTemplate($js); |
| 81 | - foreach ( $this as $key => $value ) { |
|
| 82 | - if (JString::startswith($key, "_") === false && $key !== "events") { |
|
| 81 | + foreach ($this as $key => $value) { |
|
| 82 | + if (JString::startswith($key, "_")===false && $key!=="events") { |
|
| 83 | 83 | if (is_array($value)) { |
| 84 | 84 | $v=PropertyWrapper::wrap($value, $js); |
| 85 | 85 | } else { |
| 86 | 86 | $v=$value; |
| 87 | 87 | } |
| 88 | - $result=str_ireplace("%" . $key . "%", $v, $result); |
|
| 88 | + $result=str_ireplace("%".$key."%", $v, $result); |
|
| 89 | 89 | } |
| 90 | 90 | } |
| 91 | 91 | if (isset($js)===true) { |
| 92 | 92 | $this->run($js); |
| 93 | - if (isset($view) === true) { |
|
| 93 | + if (isset($view)===true) { |
|
| 94 | 94 | $js->addViewElement($this->identifier, $result, $view); |
| 95 | 95 | } |
| 96 | 96 | } |
@@ -99,12 +99,12 @@ discard block |
||
| 99 | 99 | |
| 100 | 100 | protected function ctrl($name, $value, $typeCtrl) { |
| 101 | 101 | if (is_array($typeCtrl)) { |
| 102 | - if (array_search($value, $typeCtrl) === false) { |
|
| 103 | - throw new \Exception("La valeur passée `" . $value . "` à la propriété `" . $name . "` ne fait pas partie des valeurs possibles : {" . implode(",", $typeCtrl) . "}"); |
|
| 102 | + if (array_search($value, $typeCtrl)===false) { |
|
| 103 | + throw new \Exception("La valeur passée `".$value."` à la propriété `".$name."` ne fait pas partie des valeurs possibles : {".implode(",", $typeCtrl)."}"); |
|
| 104 | 104 | } |
| 105 | 105 | } else { |
| 106 | 106 | if (!$typeCtrl($value)) { |
| 107 | - throw new \Exception("La fonction " . $typeCtrl . " a retourné faux pour l'affectation de la propriété " . $name); |
|
| 107 | + throw new \Exception("La fonction ".$typeCtrl." a retourné faux pour l'affectation de la propriété ".$name); |
|
| 108 | 108 | } |
| 109 | 109 | } |
| 110 | 110 | return true; |
@@ -119,13 +119,13 @@ discard block |
||
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | protected function setPropertyCtrl($name, $value, $typeCtrl) { |
| 122 | - if ($this->ctrl($name, $value, $typeCtrl) === true) |
|
| 122 | + if ($this->ctrl($name, $value, $typeCtrl)===true) |
|
| 123 | 123 | return $this->setProperty($name, $value); |
| 124 | 124 | return $this; |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | protected function setMemberCtrl(&$name, $value, $typeCtrl) { |
| 128 | - if ($this->ctrl($name, $value, $typeCtrl) === true) { |
|
| 128 | + if ($this->ctrl($name, $value, $typeCtrl)===true) { |
|
| 129 | 129 | return $name=$value; |
| 130 | 130 | } |
| 131 | 131 | return $this; |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | protected function addToMemberUnique(&$name, $value, $typeCtrl, $separator=" ") { |
| 135 | 135 | if (is_array($typeCtrl)) { |
| 136 | 136 | $this->removeOldValues($name, $typeCtrl); |
| 137 | - $name.=$separator . $value; |
|
| 137 | + $name.=$separator.$value; |
|
| 138 | 138 | } |
| 139 | 139 | return $this; |
| 140 | 140 | } |
@@ -156,17 +156,17 @@ discard block |
||
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | protected function addToMemberCtrl(&$name, $value, $typeCtrl, $separator=" ") { |
| 159 | - if ($this->ctrl($name, $value, $typeCtrl) === true) { |
|
| 159 | + if ($this->ctrl($name, $value, $typeCtrl)===true) { |
|
| 160 | 160 | if (is_array($typeCtrl)) { |
| 161 | 161 | $this->removeOldValues($name, $typeCtrl); |
| 162 | 162 | } |
| 163 | - $name.=$separator . $value; |
|
| 163 | + $name.=$separator.$value; |
|
| 164 | 164 | } |
| 165 | 165 | return $this; |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | protected function addToMember(&$name, $value, $separator=" ") { |
| 169 | - $name=str_ireplace($value, "", $name) . $separator . $value; |
|
| 169 | + $name=str_ireplace($value, "", $name).$separator.$value; |
|
| 170 | 170 | return $this; |
| 171 | 171 | } |
| 172 | 172 | |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | } |
| 185 | 185 | |
| 186 | 186 | public function addToPropertyCtrlCheck($name, $value, $typeCtrl) { |
| 187 | - if ($this->ctrl($name, $value, $typeCtrl) === true) { |
|
| 187 | + if ($this->ctrl($name, $value, $typeCtrl)===true) { |
|
| 188 | 188 | return $this->addToProperty($name, $value); |
| 189 | 189 | } |
| 190 | 190 | return $this; |
@@ -212,26 +212,26 @@ discard block |
||
| 212 | 212 | } |
| 213 | 213 | |
| 214 | 214 | public function fromArray($array) { |
| 215 | - foreach ( $this as $key => $value ) { |
|
| 216 | - if(array_key_exists($key, $array)===true) |
|
| 217 | - $this->_callSetter("set" . ucfirst($key), $key, $array[$key], $array); |
|
| 215 | + foreach ($this as $key => $value) { |
|
| 216 | + if (array_key_exists($key, $array)===true) |
|
| 217 | + $this->_callSetter("set".ucfirst($key), $key, $array[$key], $array); |
|
| 218 | 218 | } |
| 219 | - foreach ( $array as $key => $value ) { |
|
| 220 | - if($this->_callSetter($key, $key, $value, $array)===false){ |
|
| 221 | - $this->_callSetter("set" . ucfirst($key), $key, $value, $array); |
|
| 219 | + foreach ($array as $key => $value) { |
|
| 220 | + if ($this->_callSetter($key, $key, $value, $array)===false) { |
|
| 221 | + $this->_callSetter("set".ucfirst($key), $key, $value, $array); |
|
| 222 | 222 | } |
| 223 | 223 | } |
| 224 | 224 | return $array; |
| 225 | 225 | } |
| 226 | 226 | |
| 227 | - private function _callSetter($setter,$key,$value,&$array){ |
|
| 227 | + private function _callSetter($setter, $key, $value, &$array) { |
|
| 228 | 228 | $result=false; |
| 229 | 229 | if (method_exists($this, $setter) && !JString::startswith($key, "_")) { |
| 230 | 230 | try { |
| 231 | 231 | $this->$setter($value); |
| 232 | 232 | unset($array[$key]); |
| 233 | 233 | $result=true; |
| 234 | - } catch ( \Exception $e ) { |
|
| 234 | + }catch (\Exception $e) { |
|
| 235 | 235 | $result=false; |
| 236 | 236 | } |
| 237 | 237 | } |
@@ -240,7 +240,7 @@ discard block |
||
| 240 | 240 | |
| 241 | 241 | public function fromDatabaseObjects($objects, $function) { |
| 242 | 242 | if (isset($objects)) { |
| 243 | - foreach ( $objects as $object ) { |
|
| 243 | + foreach ($objects as $object) { |
|
| 244 | 244 | $this->fromDatabaseObject($object, $function); |
| 245 | 245 | } |
| 246 | 246 | } |
@@ -264,33 +264,33 @@ discard block |
||
| 264 | 264 | if (is_array($elements)) { |
| 265 | 265 | $flag=false; |
| 266 | 266 | $index=0; |
| 267 | - while ( !$flag && $index < sizeof($elements) ) { |
|
| 267 | + while (!$flag && $index<sizeof($elements)) { |
|
| 268 | 268 | if ($elements[$index] instanceof BaseHtml) |
| 269 | - $flag=($elements[$index]->getIdentifier() === $identifier); |
|
| 269 | + $flag=($elements[$index]->getIdentifier()===$identifier); |
|
| 270 | 270 | $index++; |
| 271 | 271 | } |
| 272 | - if ($flag === true) |
|
| 273 | - return $elements[$index - 1]; |
|
| 272 | + if ($flag===true) |
|
| 273 | + return $elements[$index-1]; |
|
| 274 | 274 | } elseif ($elements instanceof BaseHtml) { |
| 275 | - if ($elements->getIdentifier() === $identifier) |
|
| 275 | + if ($elements->getIdentifier()===$identifier) |
|
| 276 | 276 | return $elements; |
| 277 | 277 | } |
| 278 | 278 | return null; |
| 279 | 279 | } |
| 280 | 280 | |
| 281 | - protected function getElementByPropertyValue($propertyName,$value, $elements) { |
|
| 281 | + protected function getElementByPropertyValue($propertyName, $value, $elements) { |
|
| 282 | 282 | if (is_array($elements)) { |
| 283 | 283 | $flag=false; |
| 284 | 284 | $index=0; |
| 285 | - while ( !$flag && $index < sizeof($elements) ) { |
|
| 285 | + while (!$flag && $index<sizeof($elements)) { |
|
| 286 | 286 | if ($elements[$index] instanceof BaseHtml) |
| 287 | - $flag=($elements[$index]->propertyContains($propertyName, $value) === true); |
|
| 287 | + $flag=($elements[$index]->propertyContains($propertyName, $value)===true); |
|
| 288 | 288 | $index++; |
| 289 | 289 | } |
| 290 | - if ($flag === true) |
|
| 291 | - return $elements[$index - 1]; |
|
| 290 | + if ($flag===true) |
|
| 291 | + return $elements[$index-1]; |
|
| 292 | 292 | } elseif ($elements instanceof BaseHtml) { |
| 293 | - if ($elements->propertyContains($propertyName, $value) === true) |
|
| 293 | + if ($elements->propertyContains($propertyName, $value)===true) |
|
| 294 | 294 | return $elements; |
| 295 | 295 | } |
| 296 | 296 | return null; |
@@ -4,7 +4,7 @@ |
||
| 4 | 4 | |
| 5 | 5 | trait HtmlLinkTrait { |
| 6 | 6 | |
| 7 | - abstract public function setProperty($name,$value); |
|
| 7 | + abstract public function setProperty($name, $value); |
|
| 8 | 8 | abstract public function getProperty($name); |
| 9 | 9 | |
| 10 | 10 | public function setHref($value) { |
@@ -14,8 +14,8 @@ |
||
| 14 | 14 | */ |
| 15 | 15 | public function setAttachment($toElement, $side=Side::BOTH) { |
| 16 | 16 | if (isset($toElement)) { |
| 17 | - $toElement->addToPropertyCtrl("class", "attached", array ("attached" )); |
|
| 17 | + $toElement->addToPropertyCtrl("class", "attached", array("attached")); |
|
| 18 | 18 | } |
| 19 | - return $this->addToPropertyCtrl("class", $side . " attached", Side::getConstantValues("attached")); |
|
| 19 | + return $this->addToPropertyCtrl("class", $side." attached", Side::getConstantValues("attached")); |
|
| 20 | 20 | } |
| 21 | 21 | } |
| 22 | 22 | \ No newline at end of file |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | trait LabeledIconTrait { |
| 14 | 14 | |
| 15 | 15 | abstract public function addToProperty($name, $value, $separator=" "); |
| 16 | - abstract public function addContent($content,$before=false); |
|
| 16 | + abstract public function addContent($content, $before=false); |
|
| 17 | 17 | |
| 18 | 18 | /** |
| 19 | 19 | * Adds an icon before or after |
@@ -22,17 +22,17 @@ discard block |
||
| 22 | 22 | * @param boolean $labeled |
| 23 | 23 | * @return \Ajax\semantic\html\elements\HtmlIcon |
| 24 | 24 | */ |
| 25 | - public function addIcon($icon,$before=true,$labeled=false){ |
|
| 25 | + public function addIcon($icon, $before=true, $labeled=false) { |
|
| 26 | 26 | $iconO=$icon; |
| 27 | - if(\is_string($icon)){ |
|
| 27 | + if (\is_string($icon)) { |
|
| 28 | 28 | $iconO=new HtmlIcon("icon-".$this->identifier, $icon); |
| 29 | 29 | } |
| 30 | - if($labeled!==false){ |
|
| 31 | - $direction=($before===true)?Direction::LEFT:Direction::RIGHT; |
|
| 30 | + if ($labeled!==false) { |
|
| 31 | + $direction=($before===true) ? Direction::LEFT : Direction::RIGHT; |
|
| 32 | 32 | $this->addToProperty("class", $direction." labeled icon"); |
| 33 | 33 | $this->tagName="div"; |
| 34 | 34 | } |
| 35 | - $this->addContent($iconO,$before); |
|
| 35 | + $this->addContent($iconO, $before); |
|
| 36 | 36 | return $iconO; |
| 37 | 37 | } |
| 38 | 38 | } |
| 39 | 39 | \ No newline at end of file |
@@ -14,89 +14,89 @@ |
||
| 14 | 14 | */ |
| 15 | 15 | class HtmlGridRow extends HtmlBsDoubleElement { |
| 16 | 16 | private $cols; |
| 17 | - public function __construct($identifier,$numCols=NULL){ |
|
| 18 | - parent::__construct($identifier,"div"); |
|
| 17 | + public function __construct($identifier, $numCols=NULL) { |
|
| 18 | + parent::__construct($identifier, "div"); |
|
| 19 | 19 | $this->setProperty("class", "row"); |
| 20 | 20 | $this->cols=array(); |
| 21 | - if(isset($numCols)){ |
|
| 22 | - $numCols=min(12,$numCols); |
|
| 23 | - $numCols=max(1,$numCols); |
|
| 21 | + if (isset($numCols)) { |
|
| 22 | + $numCols=min(12, $numCols); |
|
| 23 | + $numCols=max(1, $numCols); |
|
| 24 | 24 | $width=12/$numCols; |
| 25 | - for ($i=0;$i<$numCols;$i++){ |
|
| 26 | - $this->addCol(CssSize::SIZE_MD,$width); |
|
| 25 | + for ($i=0; $i<$numCols; $i++) { |
|
| 26 | + $this->addCol(CssSize::SIZE_MD, $width); |
|
| 27 | 27 | } |
| 28 | 28 | } |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | - public function addCol($size=CssSize::SIZE_MD,$width=1){ |
|
| 32 | - $col=new HtmlGridCol($this->identifier."-col-".(sizeof($this->cols)+1),$size,$width); |
|
| 31 | + public function addCol($size=CssSize::SIZE_MD, $width=1) { |
|
| 32 | + $col=new HtmlGridCol($this->identifier."-col-".(sizeof($this->cols)+1), $size, $width); |
|
| 33 | 33 | $this->cols[]=$col; |
| 34 | 34 | return $col; |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | - public function addColAt($size=CssSize::SIZE_MD,$width=1,$offset=1){ |
|
| 38 | - $col=$this->addCol($size,$width); |
|
| 39 | - return $col->setOffset($size, max($offset,sizeof($this->cols)+1)); |
|
| 37 | + public function addColAt($size=CssSize::SIZE_MD, $width=1, $offset=1) { |
|
| 38 | + $col=$this->addCol($size, $width); |
|
| 39 | + return $col->setOffset($size, max($offset, sizeof($this->cols)+1)); |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | - public function getCol($index,$force=true){ |
|
| 42 | + public function getCol($index, $force=true) { |
|
| 43 | 43 | $result=null; |
| 44 | - if($index<sizeof($this->cols)+1){ |
|
| 44 | + if ($index<sizeof($this->cols)+1) { |
|
| 45 | 45 | $result=$this->cols[$index-1]; |
| 46 | - }else if ($force){ |
|
| 47 | - $result=$this->addColAt(CssSize::SIZE_MD,1,$index); |
|
| 46 | + } else if ($force) { |
|
| 47 | + $result=$this->addColAt(CssSize::SIZE_MD, 1, $index); |
|
| 48 | 48 | } |
| 49 | 49 | return $result; |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | - public function getColAt($offset,$force=true){ |
|
| 52 | + public function getColAt($offset, $force=true) { |
|
| 53 | 53 | $result=null; |
| 54 | - foreach ($this->cols as $col){ |
|
| 54 | + foreach ($this->cols as $col) { |
|
| 55 | 55 | $offsets=$col->getOffsets(); |
| 56 | - if($result=array_search($offset, $offsets)){ |
|
| 56 | + if ($result=array_search($offset, $offsets)) { |
|
| 57 | 57 | break; |
| 58 | 58 | } |
| 59 | 59 | } |
| 60 | - if(!$result || isset($result)===false){ |
|
| 61 | - $result=$this->getCol($offset,$force); |
|
| 60 | + if (!$result || isset($result)===false) { |
|
| 61 | + $result=$this->getCol($offset, $force); |
|
| 62 | 62 | } |
| 63 | 63 | return $result; |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
| 67 | 67 | |
| 68 | - foreach ($this->cols as $col){ |
|
| 68 | + foreach ($this->cols as $col) { |
|
| 69 | 69 | $this->addContent($col); |
| 70 | 70 | } |
| 71 | - return parent::compile($js,$view); |
|
| 71 | + return parent::compile($js, $view); |
|
| 72 | 72 | } |
| 73 | 73 | public function getCols() { |
| 74 | 74 | return $this->cols; |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | - public function setContentForAll($content){ |
|
| 78 | - foreach ($this->cols as $col){ |
|
| 77 | + public function setContentForAll($content) { |
|
| 78 | + foreach ($this->cols as $col) { |
|
| 79 | 79 | $col->setContent($content); |
| 80 | 80 | } |
| 81 | 81 | } |
| 82 | - public function merge($size=CssSize::SIZE_MD,$start,$width){ |
|
| 83 | - $col=$this->getColAt($start,false); |
|
| 84 | - if(isset($col)){ |
|
| 85 | - $col->setWidth($size,$width+1); |
|
| 86 | - $this->delete($size,$start+1, $width); |
|
| 82 | + public function merge($size=CssSize::SIZE_MD, $start, $width) { |
|
| 83 | + $col=$this->getColAt($start, false); |
|
| 84 | + if (isset($col)) { |
|
| 85 | + $col->setWidth($size, $width+1); |
|
| 86 | + $this->delete($size, $start+1, $width); |
|
| 87 | 87 | } |
| 88 | 88 | } |
| 89 | - public function delete($size=CssSize::SIZE_MD,$start,$width){ |
|
| 90 | - while($start<sizeof($this->cols)+1 && $width>0){ |
|
| 91 | - $col=$this->getColAt($start,false); |
|
| 92 | - if(isset($col)){ |
|
| 89 | + public function delete($size=CssSize::SIZE_MD, $start, $width) { |
|
| 90 | + while ($start<sizeof($this->cols)+1 && $width>0) { |
|
| 91 | + $col=$this->getColAt($start, false); |
|
| 92 | + if (isset($col)) { |
|
| 93 | 93 | $widthCol=$col->getWidth($size); |
| 94 | - if($widthCol<=$width){ |
|
| 94 | + if ($widthCol<=$width) { |
|
| 95 | 95 | unset($this->cols[$start-1]); |
| 96 | - $this->cols = array_values($this->cols); |
|
| 96 | + $this->cols=array_values($this->cols); |
|
| 97 | 97 | $width=$width-$widthCol; |
| 98 | 98 | } |
| 99 | - }else{ |
|
| 99 | + } else { |
|
| 100 | 100 | $width=0; |
| 101 | 101 | } |
| 102 | 102 | } |
@@ -18,14 +18,14 @@ discard block |
||
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | public function setContent($content) { |
| 21 | - $this->content=new HtmlSemDoubleElement("content-" . $this->identifier, "div", "content", new HtmlSemDoubleElement("", "div", "center", $content)); |
|
| 21 | + $this->content=new HtmlSemDoubleElement("content-".$this->identifier, "div", "content", new HtmlSemDoubleElement("", "div", "center", $content)); |
|
| 22 | 22 | return $this; |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | public function asIcon($icon, $title, $subHeader=NULL) { |
| 26 | - $header=new HtmlHeader("header-" . $this->identifier); |
|
| 26 | + $header=new HtmlHeader("header-".$this->identifier); |
|
| 27 | 27 | $header->asIcon($icon, $title, $subHeader); |
| 28 | - if ($this->_inverted === false) |
|
| 28 | + if ($this->_inverted===false) |
|
| 29 | 29 | $header->setInverted(); |
| 30 | 30 | return $this->setContent($header); |
| 31 | 31 | } |
@@ -42,13 +42,13 @@ discard block |
||
| 42 | 42 | |
| 43 | 43 | public function run(JsUtils $js) { |
| 44 | 44 | if ($this->_container instanceof HtmlSingleElement) |
| 45 | - $this->_bsComponent=$js->semantic()->dimmer("#" . $this->_container->getIdentifier(), $this->_params); |
|
| 45 | + $this->_bsComponent=$js->semantic()->dimmer("#".$this->_container->getIdentifier(), $this->_params); |
|
| 46 | 46 | return parent::run($js); |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | public function jsShow() { |
| 50 | 50 | if (isset($this->_container)) |
| 51 | - return '$("#.' . $this->_container->getIdentifier() . ').dimmer("show");'; |
|
| 51 | + return '$("#.'.$this->_container->getIdentifier().').dimmer("show");'; |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | public function setBlurring() { |
@@ -8,12 +8,12 @@ discard block |
||
| 8 | 8 | use Ajax\semantic\html\base\constants\Direction; |
| 9 | 9 | |
| 10 | 10 | class HtmlSearch extends HtmlSemDoubleElement { |
| 11 | - private $_elements=array (); |
|
| 12 | - private $_searchFields=array ("title" ); |
|
| 11 | + private $_elements=array(); |
|
| 12 | + private $_searchFields=array("title"); |
|
| 13 | 13 | private $_local=false; |
| 14 | 14 | |
| 15 | 15 | public function __construct($identifier, $placeholder=NULL, $icon=NULL) { |
| 16 | - parent::__construct("search-" . $identifier, "div", "ui search", array ()); |
|
| 16 | + parent::__construct("search-".$identifier, "div", "ui search", array()); |
|
| 17 | 17 | $this->createField($placeholder, $icon); |
| 18 | 18 | $this->createResult(); |
| 19 | 19 | $this->_params["type"]="standard"; |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | private function createResult() { |
| 35 | - $this->content["result"]=new HtmlSemDoubleElement("results-" . $this->identifier, "div", "results"); |
|
| 35 | + $this->content["result"]=new HtmlSemDoubleElement("results-".$this->identifier, "div", "results"); |
|
| 36 | 36 | return $this->content["result"]; |
| 37 | 37 | } |
| 38 | 38 | |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | public function setUrl($url) { |
| 52 | - $this->_params["apiSettings"]="%{url: %quote%" . $url . "%quote%}%"; |
|
| 52 | + $this->_params["apiSettings"]="%{url: %quote%".$url."%quote%}%"; |
|
| 53 | 53 | return $this; |
| 54 | 54 | } |
| 55 | 55 | |
@@ -72,16 +72,16 @@ discard block |
||
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | public function run(JsUtils $js) { |
| 75 | - $this->_params["onSelect"]='%function(result,response){$(%quote%#' . $this->identifier . '%quote%).trigger(%quote%onSelect%quote%, {%quote%result%quote%: result, %quote%response%quote%:response} );}%'; |
|
| 75 | + $this->_params["onSelect"]='%function(result,response){$(%quote%#'.$this->identifier.'%quote%).trigger(%quote%onSelect%quote%, {%quote%result%quote%: result, %quote%response%quote%:response} );}%'; |
|
| 76 | 76 | $searchFields=\json_encode($this->_searchFields); |
| 77 | 77 | $searchFields=str_ireplace("\"", "%quote%", $searchFields); |
| 78 | - $this->_params["searchFields"]="%" . $searchFields . "%"; |
|
| 79 | - if ($this->_local === true) { |
|
| 78 | + $this->_params["searchFields"]="%".$searchFields."%"; |
|
| 79 | + if ($this->_local===true) { |
|
| 80 | 80 | $this->_params["source"]="%content%"; |
| 81 | - $this->addEvent("beforeExecute", "var content=" . $this->resultsToJson() . ";"); |
|
| 81 | + $this->addEvent("beforeExecute", "var content=".$this->resultsToJson().";"); |
|
| 82 | 82 | } |
| 83 | - if (isset($this->_bsComponent) === false) { |
|
| 84 | - $this->_bsComponent=$js->semantic()->search("#" . $this->identifier, $this->_params); |
|
| 83 | + if (isset($this->_bsComponent)===false) { |
|
| 84 | + $this->_bsComponent=$js->semantic()->search("#".$this->identifier, $this->_params); |
|
| 85 | 85 | } |
| 86 | 86 | $this->addEventsOnRun($js); |
| 87 | 87 | return $this->_bsComponent; |