@@ -18,7 +18,14 @@ discard block |
||
| 18 | 18 | |
| 19 | 19 | trait FormFieldAsTrait{ |
| 20 | 20 | |
| 21 | + /** |
|
| 22 | + * @param string $prefix |
|
| 23 | + */ |
|
| 21 | 24 | abstract protected function _getFieldIdentifier($prefix); |
| 25 | + |
|
| 26 | + /** |
|
| 27 | + * @param \Closure $callback |
|
| 28 | + */ |
|
| 22 | 29 | abstract public function setValueFunction($index,$callback); |
| 23 | 30 | |
| 24 | 31 | private function _getLabelField($caption,$icon=NULL){ |
@@ -42,6 +49,9 @@ discard block |
||
| 42 | 49 | $element->fromArray($attributes); |
| 43 | 50 | } |
| 44 | 51 | |
| 52 | + /** |
|
| 53 | + * @param HtmlFormField $element |
|
| 54 | + */ |
|
| 45 | 55 | protected function _addRules($element,$attributes){ |
| 46 | 56 | if(isset($attributes["rules"])){ |
| 47 | 57 | $rules=$attributes["rules"]; |
@@ -53,6 +63,10 @@ discard block |
||
| 53 | 63 | } |
| 54 | 64 | } |
| 55 | 65 | |
| 66 | + /** |
|
| 67 | + * @param \Closure $elementCallback |
|
| 68 | + * @param string $identifier |
|
| 69 | + */ |
|
| 56 | 70 | protected function _fieldAs($elementCallback,$index,$attributes=NULL,$identifier=null){ |
| 57 | 71 | $this->setValueFunction($index,function($value) use ($index,&$attributes,$elementCallback){ |
| 58 | 72 | $caption=$this->_instanceViewer->getCaption($index); |
@@ -16,13 +16,13 @@ discard block |
||
| 16 | 16 | * @property object $_modelInstance; |
| 17 | 17 | */ |
| 18 | 18 | |
| 19 | -trait FormFieldAsTrait{ |
|
| 19 | +trait FormFieldAsTrait { |
|
| 20 | 20 | |
| 21 | 21 | abstract protected function _getFieldIdentifier($prefix); |
| 22 | - abstract public function setValueFunction($index,$callback); |
|
| 22 | + abstract public function setValueFunction($index, $callback); |
|
| 23 | 23 | |
| 24 | - private function _getLabelField($caption,$icon=NULL){ |
|
| 25 | - $label=new HtmlLabel($this->_getFieldIdentifier("lbl"),$caption,$icon); |
|
| 24 | + private function _getLabelField($caption, $icon=NULL) { |
|
| 25 | + $label=new HtmlLabel($this->_getFieldIdentifier("lbl"), $caption, $icon); |
|
| 26 | 26 | return $label; |
| 27 | 27 | } |
| 28 | 28 | |
@@ -30,22 +30,22 @@ discard block |
||
| 30 | 30 | * @param HtmlFormField $element |
| 31 | 31 | * @param array $attributes |
| 32 | 32 | */ |
| 33 | - protected function _applyAttributes($element,&$attributes,$index){ |
|
| 33 | + protected function _applyAttributes($element, &$attributes, $index) { |
|
| 34 | 34 | $this->_addRules($element, $attributes); |
| 35 | - if(isset($attributes["callback"])){ |
|
| 35 | + if (isset($attributes["callback"])) { |
|
| 36 | 36 | $callback=$attributes["callback"]; |
| 37 | - if(\is_callable($callback)){ |
|
| 38 | - $callback($element,$this->_modelInstance,$index); |
|
| 37 | + if (\is_callable($callback)) { |
|
| 38 | + $callback($element, $this->_modelInstance, $index); |
|
| 39 | 39 | unset($attributes["callback"]); |
| 40 | 40 | } |
| 41 | 41 | } |
| 42 | 42 | $element->fromArray($attributes); |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | - protected function _addRules($element,&$attributes){ |
|
| 46 | - if(isset($attributes["rules"])){ |
|
| 45 | + protected function _addRules($element, &$attributes) { |
|
| 46 | + if (isset($attributes["rules"])) { |
|
| 47 | 47 | $rules=$attributes["rules"]; |
| 48 | - if(\is_array($rules)){ |
|
| 48 | + if (\is_array($rules)) { |
|
| 49 | 49 | $element->addRules($rules); |
| 50 | 50 | } |
| 51 | 51 | else |
@@ -54,13 +54,13 @@ discard block |
||
| 54 | 54 | } |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - protected function _fieldAs($elementCallback,$index,$attributes=NULL,$identifier=null){ |
|
| 58 | - $this->setValueFunction($index,function($value) use ($index,&$attributes,$elementCallback){ |
|
| 57 | + protected function _fieldAs($elementCallback, $index, $attributes=NULL, $identifier=null) { |
|
| 58 | + $this->setValueFunction($index, function($value) use ($index, &$attributes, $elementCallback){ |
|
| 59 | 59 | $caption=$this->_instanceViewer->getCaption($index); |
| 60 | 60 | $name=$this->_instanceViewer->getFieldName($index); |
| 61 | - $element=$elementCallback($this->getIdentifier()."-".$name,$name,$value,$caption); |
|
| 62 | - if(\is_array($attributes)){ |
|
| 63 | - $this->_applyAttributes($element, $attributes,$index); |
|
| 61 | + $element=$elementCallback($this->getIdentifier()."-".$name, $name, $value, $caption); |
|
| 62 | + if (\is_array($attributes)) { |
|
| 63 | + $this->_applyAttributes($element, $attributes, $index); |
|
| 64 | 64 | } |
| 65 | 65 | return $element; |
| 66 | 66 | }); |
@@ -68,53 +68,53 @@ discard block |
||
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | |
| 71 | - public function fieldAsRadio($index,$attributes=NULL){ |
|
| 72 | - return $this->_fieldAs(function($id,$name,$value,$caption){ |
|
| 73 | - return new HtmlFormRadio($id,$name,$caption,$value); |
|
| 74 | - }, $index,$attributes); |
|
| 71 | + public function fieldAsRadio($index, $attributes=NULL) { |
|
| 72 | + return $this->_fieldAs(function($id, $name, $value, $caption) { |
|
| 73 | + return new HtmlFormRadio($id, $name, $caption, $value); |
|
| 74 | + }, $index, $attributes); |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | - public function fieldAsRadios($index,$elements=[],$attributes=NULL){ |
|
| 78 | - return $this->_fieldAs(function($id,$name,$value,$caption,$elements){ |
|
| 79 | - return HtmlFormFields::radios($name,$elements,$caption,$value); |
|
| 80 | - }, $index,$attributes); |
|
| 77 | + public function fieldAsRadios($index, $elements=[], $attributes=NULL) { |
|
| 78 | + return $this->_fieldAs(function($id, $name, $value, $caption, $elements) { |
|
| 79 | + return HtmlFormFields::radios($name, $elements, $caption, $value); |
|
| 80 | + }, $index, $attributes); |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | - public function fieldAsTextarea($index,$attributes=NULL){ |
|
| 84 | - return $this->_fieldAs(function($id,$name,$value,$caption){ |
|
| 85 | - $textarea=new HtmlFormTextarea($id,$caption,$value); |
|
| 83 | + public function fieldAsTextarea($index, $attributes=NULL) { |
|
| 84 | + return $this->_fieldAs(function($id, $name, $value, $caption) { |
|
| 85 | + $textarea=new HtmlFormTextarea($id, $caption, $value); |
|
| 86 | 86 | $textarea->setName($name); |
| 87 | 87 | return $textarea; |
| 88 | - }, $index,$attributes); |
|
| 88 | + }, $index, $attributes); |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | - public function fieldAsInput($index,$attributes=NULL){ |
|
| 92 | - return $this->_fieldAs(function($id,$name,$value,$caption){ |
|
| 93 | - $input= new HtmlFormInput($id,$caption,"text",$value); |
|
| 91 | + public function fieldAsInput($index, $attributes=NULL) { |
|
| 92 | + return $this->_fieldAs(function($id, $name, $value, $caption) { |
|
| 93 | + $input=new HtmlFormInput($id, $caption, "text", $value); |
|
| 94 | 94 | $input->setName($name); |
| 95 | 95 | return $input; |
| 96 | - }, $index,$attributes); |
|
| 96 | + }, $index, $attributes); |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | - public function fieldAsCheckbox($index,$attributes=NULL){ |
|
| 100 | - return $this->_fieldAs(function($id,$name,$value,$caption){ |
|
| 101 | - return new HtmlFormCheckbox($id,$caption,$value); |
|
| 102 | - }, $index,$attributes); |
|
| 99 | + public function fieldAsCheckbox($index, $attributes=NULL) { |
|
| 100 | + return $this->_fieldAs(function($id, $name, $value, $caption) { |
|
| 101 | + return new HtmlFormCheckbox($id, $caption, $value); |
|
| 102 | + }, $index, $attributes); |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | - public function fieldAsDropDown($index,$elements=[],$multiple=false,$attributes=NULL){ |
|
| 106 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($elements,$multiple){ |
|
| 107 | - $dd=new HtmlFormDropdown($id,$elements,$caption,$value,$multiple); |
|
| 105 | + public function fieldAsDropDown($index, $elements=[], $multiple=false, $attributes=NULL) { |
|
| 106 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($elements, $multiple){ |
|
| 107 | + $dd=new HtmlFormDropdown($id, $elements, $caption, $value, $multiple); |
|
| 108 | 108 | $dd->setName($name); |
| 109 | 109 | return $dd; |
| 110 | - }, $index,$attributes); |
|
| 110 | + }, $index, $attributes); |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | - public function fieldAsMessage($index,$attributes=NULL){ |
|
| 114 | - return $this->_fieldAs(function($id,$name,$value,$caption){ |
|
| 115 | - $mess= new HtmlMessage("message-".$id,$value); |
|
| 113 | + public function fieldAsMessage($index, $attributes=NULL) { |
|
| 114 | + return $this->_fieldAs(function($id, $name, $value, $caption) { |
|
| 115 | + $mess=new HtmlMessage("message-".$id, $value); |
|
| 116 | 116 | $mess->addHeader($caption); |
| 117 | 117 | return $mess; |
| 118 | - }, $index,$attributes,"message"); |
|
| 118 | + }, $index, $attributes, "message"); |
|
| 119 | 119 | } |
| 120 | 120 | } |
| 121 | 121 | \ No newline at end of file |
@@ -47,9 +47,9 @@ |
||
| 47 | 47 | $rules=$attributes["rules"]; |
| 48 | 48 | if(\is_array($rules)){ |
| 49 | 49 | $element->addRules($rules); |
| 50 | + } else { |
|
| 51 | + $element->addRule($rules); |
|
| 50 | 52 | } |
| 51 | - else |
|
| 52 | - $element->addRule($rules); |
|
| 53 | 53 | unset($attributes["rules"]); |
| 54 | 54 | } |
| 55 | 55 | } |
@@ -7,21 +7,21 @@ |
||
| 7 | 7 | |
| 8 | 8 | class HtmlFormDropdown extends HtmlFormField { |
| 9 | 9 | |
| 10 | - public function __construct($identifier,$items=array(), $label=NULL,$value=NULL,$multiple=false) { |
|
| 11 | - parent::__construct("field-".$identifier, (new HtmlDropdown("dropdown-".$identifier,$value,$items))->asSelect($identifier,$multiple), $label); |
|
| 10 | + public function __construct($identifier, $items=array(), $label=NULL, $value=NULL, $multiple=false) { |
|
| 11 | + parent::__construct("field-".$identifier, (new HtmlDropdown("dropdown-".$identifier, $value, $items))->asSelect($identifier, $multiple), $label); |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | - public function setItems($items){ |
|
| 14 | + public function setItems($items) { |
|
| 15 | 15 | return $this->getField()->setItems($items); |
| 16 | 16 | } |
| 17 | - public function addItem($item,$value=NULL,$image=NULL){ |
|
| 18 | - return $this->getField()->addItem($item,$value,$image); |
|
| 17 | + public function addItem($item, $value=NULL, $image=NULL) { |
|
| 18 | + return $this->getField()->addItem($item, $value, $image); |
|
| 19 | 19 | } |
| 20 | - public static function multipleDropdown($identifier,$items=array(), $label=NULL,$value=NULL){ |
|
| 21 | - return new HtmlFormDropdown($identifier,$items,$label,$value,true); |
|
| 20 | + public static function multipleDropdown($identifier, $items=array(), $label=NULL, $value=NULL) { |
|
| 21 | + return new HtmlFormDropdown($identifier, $items, $label, $value, true); |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | - public function getDataField(){ |
|
| 24 | + public function getDataField() { |
|
| 25 | 25 | return $this->getField()->getInput(); |
| 26 | 26 | } |
| 27 | 27 | } |
| 28 | 28 | \ No newline at end of file |
@@ -8,16 +8,16 @@ |
||
| 8 | 8 | class HtmlFormInput extends HtmlFormField { |
| 9 | 9 | use TextFieldsTrait; |
| 10 | 10 | |
| 11 | - public function __construct($identifier, $label=NULL,$type="text",$value=NULL,$placeholder=NULL) { |
|
| 12 | - if(!isset($placeholder) && $type==="text") |
|
| 11 | + public function __construct($identifier, $label=NULL, $type="text", $value=NULL, $placeholder=NULL) { |
|
| 12 | + if (!isset($placeholder) && $type==="text") |
|
| 13 | 13 | $placeholder=$label; |
| 14 | - parent::__construct("field-".$identifier, new HtmlInput($identifier,$type,$value,$placeholder), $label); |
|
| 14 | + parent::__construct("field-".$identifier, new HtmlInput($identifier, $type, $value, $placeholder), $label); |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | - public function getDataField(){ |
|
| 18 | - $field= $this->getField(); |
|
| 17 | + public function getDataField() { |
|
| 18 | + $field=$this->getField(); |
|
| 19 | 19 | //TODO check getField |
| 20 | - if($field instanceof HtmlInput) |
|
| 20 | + if ($field instanceof HtmlInput) |
|
| 21 | 21 | $field=$field->getDataField(); |
| 22 | 22 | return $field; |
| 23 | 23 | } |
@@ -9,16 +9,18 @@ |
||
| 9 | 9 | use TextFieldsTrait; |
| 10 | 10 | |
| 11 | 11 | public function __construct($identifier, $label=NULL,$type="text",$value=NULL,$placeholder=NULL) { |
| 12 | - if(!isset($placeholder) && $type==="text") |
|
| 13 | - $placeholder=$label; |
|
| 12 | + if(!isset($placeholder) && $type==="text") { |
|
| 13 | + $placeholder=$label; |
|
| 14 | + } |
|
| 14 | 15 | parent::__construct("field-".$identifier, new HtmlInput($identifier,$type,$value,$placeholder), $label); |
| 15 | 16 | } |
| 16 | 17 | |
| 17 | 18 | public function getDataField(){ |
| 18 | 19 | $field= $this->getField(); |
| 19 | 20 | //TODO check getField |
| 20 | - if($field instanceof HtmlInput) |
|
| 21 | - $field=$field->getDataField(); |
|
| 21 | + if($field instanceof HtmlInput) { |
|
| 22 | + $field=$field->getDataField(); |
|
| 23 | + } |
|
| 22 | 24 | return $field; |
| 23 | 25 | } |
| 24 | 26 | } |
| 25 | 27 | \ No newline at end of file |
@@ -6,19 +6,19 @@ |
||
| 6 | 6 | |
| 7 | 7 | abstract public function getDataField(); |
| 8 | 8 | abstract public function addToProperty($name, $value, $separator=" "); |
| 9 | - public function setPlaceholder($value){ |
|
| 9 | + public function setPlaceholder($value) { |
|
| 10 | 10 | $this->getDataField()->setPlaceholder($value); |
| 11 | 11 | return $this; |
| 12 | 12 | } |
| 13 | 13 | |
| 14 | - public function setValue($value){ |
|
| 14 | + public function setValue($value) { |
|
| 15 | 15 | $this->getDataField()->setValue($value); |
| 16 | 16 | return $this; |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | - public function setInputType($type){ |
|
| 20 | - if($type==="hidden") |
|
| 21 | - $this->addToProperty("style","display:none;"); |
|
| 19 | + public function setInputType($type) { |
|
| 20 | + if ($type==="hidden") |
|
| 21 | + $this->addToProperty("style", "display:none;"); |
|
| 22 | 22 | $this->getDataField()->setInputType($type); |
| 23 | 23 | return $this; |
| 24 | 24 | } |
@@ -17,8 +17,9 @@ |
||
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | public function setInputType($type){ |
| 20 | - if($type==="hidden") |
|
| 21 | - $this->addToProperty("style","display:none;"); |
|
| 20 | + if($type==="hidden") { |
|
| 21 | + $this->addToProperty("style","display:none;"); |
|
| 22 | + } |
|
| 22 | 23 | $this->getDataField()->setInputType($type); |
| 23 | 24 | return $this; |
| 24 | 25 | } |
@@ -31,38 +31,38 @@ discard block |
||
| 31 | 31 | * @param string|HtmlSemDoubleElement $header |
| 32 | 32 | * @return \Ajax\semantic\html\collections\HtmlMessage |
| 33 | 33 | */ |
| 34 | - public function addHeader($header){ |
|
| 34 | + public function addHeader($header) { |
|
| 35 | 35 | $headerO=$header; |
| 36 | - if(\is_string($header)){ |
|
| 37 | - $headerO=new HtmlSemDoubleElement("header-".$this->identifier,"div"); |
|
| 36 | + if (\is_string($header)) { |
|
| 37 | + $headerO=new HtmlSemDoubleElement("header-".$this->identifier, "div"); |
|
| 38 | 38 | $headerO->setClass("header"); |
| 39 | 39 | $headerO->setContent($header); |
| 40 | 40 | } |
| 41 | - return $this->addContent($headerO,true); |
|
| 41 | + return $this->addContent($headerO, true); |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | - public function addList($elements,$ordered=false){ |
|
| 45 | - $list=new HtmlList("list-".$this->identifier,$elements); |
|
| 44 | + public function addList($elements, $ordered=false) { |
|
| 45 | + $list=new HtmlList("list-".$this->identifier, $elements); |
|
| 46 | 46 | $list->setOrdered($ordered); |
| 47 | 47 | $list->setClass("ui list"); |
| 48 | 48 | $this->addContent($list); |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | - public function setIcon($icon){ |
|
| 51 | + public function setIcon($icon) { |
|
| 52 | 52 | $this->addToProperty("class", "icon"); |
| 53 | - $this->wrapContent("<div class='content'>","</div>"); |
|
| 53 | + $this->wrapContent("<div class='content'>", "</div>"); |
|
| 54 | 54 | $this->icon=new HtmlIcon("icon-".$this->identifier, $icon); |
| 55 | 55 | return $this; |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | - public function addLoader($loaderIcon="notched circle"){ |
|
| 58 | + public function addLoader($loaderIcon="notched circle") { |
|
| 59 | 59 | $this->setIcon($loaderIcon); |
| 60 | 60 | $this->icon->addToIcon("loading"); |
| 61 | 61 | return $this; |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | - public function setDismissable($dismiss=true){ |
|
| 65 | - if($dismiss===true) |
|
| 64 | + public function setDismissable($dismiss=true) { |
|
| 65 | + if ($dismiss===true) |
|
| 66 | 66 | $this->close=new HtmlIcon("close-".$this->identifier, "close"); |
| 67 | 67 | else |
| 68 | 68 | $this->close=NULL; |
@@ -73,34 +73,34 @@ discard block |
||
| 73 | 73 | * {@inheritDoc} |
| 74 | 74 | * @see \Ajax\semantic\html\base\HtmlSemDoubleElement::run() |
| 75 | 75 | */ |
| 76 | - public function run(JsUtils $js){ |
|
| 76 | + public function run(JsUtils $js) { |
|
| 77 | 77 | parent::run($js); |
| 78 | - if(isset($this->close)){ |
|
| 78 | + if (isset($this->close)) { |
|
| 79 | 79 | $js->execOn("click", "#".$this->identifier." .close", "$(this).closest('.message').transition('fade')"); |
| 80 | 80 | } |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | - public function setState($visible=true){ |
|
| 84 | - $visible=($visible===true)?"visible":"hidden"; |
|
| 85 | - return $this->addToPropertyCtrl("class", $visible, array("visible","hidden")); |
|
| 83 | + public function setState($visible=true) { |
|
| 84 | + $visible=($visible===true) ? "visible" : "hidden"; |
|
| 85 | + return $this->addToPropertyCtrl("class", $visible, array("visible", "hidden")); |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | - public function setVariation($value="floating"){ |
|
| 89 | - return $this->addToPropertyCtrl("class", $value, array("floating","compact")); |
|
| 88 | + public function setVariation($value="floating") { |
|
| 89 | + return $this->addToPropertyCtrl("class", $value, array("floating", "compact")); |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | - public function setStyle($style){ |
|
| 92 | + public function setStyle($style) { |
|
| 93 | 93 | return $this->addToPropertyCtrl("class", $style, Style::getConstants()); |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | - public function setError(){ |
|
| 96 | + public function setError() { |
|
| 97 | 97 | return $this->setStyle("error"); |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | - public function setMessage($message){ |
|
| 101 | - if(\is_array($this->content)){ |
|
| 100 | + public function setMessage($message) { |
|
| 101 | + if (\is_array($this->content)) { |
|
| 102 | 102 | $this->content[\sizeof($this->content)-1]=$message; |
| 103 | - }else |
|
| 103 | + } else |
|
| 104 | 104 | $this->setContent($message); |
| 105 | 105 | } |
| 106 | 106 | } |
| 107 | 107 | \ No newline at end of file |
@@ -62,10 +62,11 @@ discard block |
||
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | public function setDismissable($dismiss=true){ |
| 65 | - if($dismiss===true) |
|
| 66 | - $this->close=new HtmlIcon("close-".$this->identifier, "close"); |
|
| 67 | - else |
|
| 68 | - $this->close=NULL; |
|
| 65 | + if($dismiss===true) { |
|
| 66 | + $this->close=new HtmlIcon("close-".$this->identifier, "close"); |
|
| 67 | + } else { |
|
| 68 | + $this->close=NULL; |
|
| 69 | + } |
|
| 69 | 70 | return $this; |
| 70 | 71 | } |
| 71 | 72 | |
@@ -100,7 +101,8 @@ discard block |
||
| 100 | 101 | public function setMessage($message){ |
| 101 | 102 | if(\is_array($this->content)){ |
| 102 | 103 | $this->content[\sizeof($this->content)-1]=$message; |
| 103 | - }else |
|
| 104 | - $this->setContent($message); |
|
| 104 | + } else { |
|
| 105 | + $this->setContent($message); |
|
| 106 | + } |
|
| 105 | 107 | } |
| 106 | 108 | } |
| 107 | 109 | \ No newline at end of file |
@@ -17,8 +17,9 @@ discard block |
||
| 17 | 17 | public function __construct($instance=NULL,$captions=NULL){ |
| 18 | 18 | $this->values=[]; |
| 19 | 19 | $this->afterCompile=[]; |
| 20 | - if(isset($instance)) |
|
| 21 | - $this->setInstance($instance); |
|
| 20 | + if(isset($instance)) { |
|
| 21 | + $this->setInstance($instance); |
|
| 22 | + } |
|
| 22 | 23 | $this->setCaptions($captions); |
| 23 | 24 | } |
| 24 | 25 | |
@@ -34,8 +35,9 @@ discard block |
||
| 34 | 35 | |
| 35 | 36 | public function getIdentifier(){ |
| 36 | 37 | $value=self::$index; |
| 37 | - if(isset($this->values["identifier"])) |
|
| 38 | - $value=$this->values["identifier"](self::$index,$this->instance); |
|
| 38 | + if(isset($this->values["identifier"])) { |
|
| 39 | + $value=$this->values["identifier"](self::$index,$this->instance); |
|
| 40 | + } |
|
| 39 | 41 | return $value; |
| 40 | 42 | } |
| 41 | 43 | |
@@ -58,19 +60,19 @@ discard block |
||
| 58 | 60 | $value=$property->getValue($this->instance); |
| 59 | 61 | if(isset($this->values[$index])){ |
| 60 | 62 | $value= $this->values[$index]($value,$this->instance,$index); |
| 61 | - }else{ |
|
| 63 | + } else{ |
|
| 62 | 64 | $value=$this->_getDefaultValue($property->getName(),$value, $index); |
| 63 | 65 | } |
| 64 | - }else{ |
|
| 65 | - if(\is_callable($property)) |
|
| 66 | - $value=$property($this->instance); |
|
| 67 | - elseif(\is_array($property)){ |
|
| 66 | + } else{ |
|
| 67 | + if(\is_callable($property)) { |
|
| 68 | + $value=$property($this->instance); |
|
| 69 | + } elseif(\is_array($property)){ |
|
| 68 | 70 | $values=\array_map(function($v) use ($index){return $this->_getValue($v, $index);}, $property); |
| 69 | 71 | $value=\implode("", $values); |
| 70 | - }else{ |
|
| 72 | + } else{ |
|
| 71 | 73 | if(isset($this->values[$index])){ |
| 72 | 74 | $value= $this->values[$index]($property,$this->instance,$index); |
| 73 | - }else{ |
|
| 75 | + } else{ |
|
| 74 | 76 | $value=$property; |
| 75 | 77 | } |
| 76 | 78 | } |
@@ -93,10 +95,10 @@ discard block |
||
| 93 | 95 | if(isset($vb[$index])){ |
| 94 | 96 | if(\is_array($vb[$index])){ |
| 95 | 97 | $this->visibleProperties[$index][]=$field; |
| 96 | - }else{ |
|
| 98 | + } else{ |
|
| 97 | 99 | $this->visibleProperties[$index]=[$vb[$index],$field]; |
| 98 | 100 | } |
| 99 | - }else{ |
|
| 101 | + } else{ |
|
| 100 | 102 | return $this->insertField($index, $field); |
| 101 | 103 | } |
| 102 | 104 | return $this; |
@@ -132,26 +134,27 @@ discard block |
||
| 132 | 134 | $this->reflect=new \ReflectionClass($instance); |
| 133 | 135 | if(\sizeof($this->visibleProperties)===0){ |
| 134 | 136 | $this->properties=$this->getDefaultProperties(); |
| 135 | - }else{ |
|
| 137 | + } else{ |
|
| 136 | 138 | foreach ($this->visibleProperties as $property){ |
| 137 | 139 | if(\is_callable($property)){ |
| 138 | 140 | $this->properties[]=$property; |
| 139 | - }elseif(\is_string($property)){ |
|
| 141 | + } elseif(\is_string($property)){ |
|
| 140 | 142 | try{ |
| 141 | 143 | $this->_beforeAddProperty(\sizeof($this->properties), $property); |
| 142 | 144 | $rProperty=$this->reflect->getProperty($property); |
| 143 | 145 | $this->properties[]=$rProperty; |
| 144 | - }catch(\Exception $e){ |
|
| 146 | + } catch(\Exception $e){ |
|
| 145 | 147 | $this->_beforeAddProperty(\sizeof($this->properties), $property); |
| 146 | 148 | $this->properties[]=$property; |
| 147 | 149 | } |
| 148 | - }elseif(\is_int($property)){ |
|
| 150 | + } elseif(\is_int($property)){ |
|
| 149 | 151 | $props=$this->getDefaultProperties(); |
| 150 | - if(isset($props[$property])) |
|
| 151 | - $this->properties[]=$props[$property]; |
|
| 152 | - else |
|
| 153 | - $this->properties[]=$property; |
|
| 154 | - }else{ |
|
| 152 | + if(isset($props[$property])) { |
|
| 153 | + $this->properties[]=$props[$property]; |
|
| 154 | + } else { |
|
| 155 | + $this->properties[]=$property; |
|
| 156 | + } |
|
| 157 | + } else{ |
|
| 155 | 158 | $this->properties[]=$property; |
| 156 | 159 | } |
| 157 | 160 | } |
@@ -198,12 +201,13 @@ discard block |
||
| 198 | 201 | if(isset($this->captions[$index])){ |
| 199 | 202 | return $this->captions[$index]; |
| 200 | 203 | } |
| 201 | - if($this->properties[$index] instanceof \ReflectionProperty) |
|
| 202 | - return $this->properties[$index]->getName(); |
|
| 203 | - elseif(\is_callable($this->properties[$index])) |
|
| 204 | - return ""; |
|
| 205 | - else |
|
| 206 | - return $this->properties[$index]; |
|
| 204 | + if($this->properties[$index] instanceof \ReflectionProperty) { |
|
| 205 | + return $this->properties[$index]->getName(); |
|
| 206 | + } elseif(\is_callable($this->properties[$index])) { |
|
| 207 | + return ""; |
|
| 208 | + } else { |
|
| 209 | + return $this->properties[$index]; |
|
| 210 | + } |
|
| 207 | 211 | } |
| 208 | 212 | |
| 209 | 213 | public function getCaptions(){ |
@@ -224,8 +228,9 @@ discard block |
||
| 224 | 228 | } |
| 225 | 229 | |
| 226 | 230 | public function setCaption($index,$caption){ |
| 227 | - if(isset($this->captions)===false) |
|
| 228 | - $this->captions=[]; |
|
| 231 | + if(isset($this->captions)===false) { |
|
| 232 | + $this->captions=[]; |
|
| 233 | + } |
|
| 229 | 234 | $this->captions[$index]=$caption; |
| 230 | 235 | return $this; |
| 231 | 236 | } |
@@ -15,145 +15,145 @@ discard block |
||
| 15 | 15 | |
| 16 | 16 | public static $index=0; |
| 17 | 17 | |
| 18 | - public function __construct($identifier,$instance=NULL,$captions=NULL){ |
|
| 18 | + public function __construct($identifier, $instance=NULL, $captions=NULL) { |
|
| 19 | 19 | $this->widgetIdentifier=$identifier; |
| 20 | 20 | $this->values=[]; |
| 21 | 21 | $this->afterCompile=[]; |
| 22 | - if(isset($instance)) |
|
| 22 | + if (isset($instance)) |
|
| 23 | 23 | $this->setInstance($instance); |
| 24 | 24 | $this->setCaptions($captions); |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | - public function getValues(){ |
|
| 27 | + public function getValues() { |
|
| 28 | 28 | $values=[]; |
| 29 | 29 | $index=0; |
| 30 | 30 | $count=$this->count(); |
| 31 | - while($index<$count){ |
|
| 31 | + while ($index<$count) { |
|
| 32 | 32 | $values[]=$this->getValue($index++); |
| 33 | 33 | } |
| 34 | 34 | return $values; |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | - public function getIdentifier(){ |
|
| 37 | + public function getIdentifier() { |
|
| 38 | 38 | $value=self::$index; |
| 39 | - if(isset($this->values["identifier"])) |
|
| 40 | - $value=$this->values["identifier"](self::$index,$this->instance); |
|
| 39 | + if (isset($this->values["identifier"])) |
|
| 40 | + $value=$this->values["identifier"](self::$index, $this->instance); |
|
| 41 | 41 | return $value; |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | - public function getValue($index){ |
|
| 44 | + public function getValue($index) { |
|
| 45 | 45 | $property=$this->properties[$index]; |
| 46 | 46 | return $this->_getValue($property, $index); |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | - protected function _beforeAddProperty($index,&$field){ |
|
| 49 | + protected function _beforeAddProperty($index, &$field) { |
|
| 50 | 50 | |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | - protected function _getDefaultValue($name,$value,$index){ |
|
| 53 | + protected function _getDefaultValue($name, $value, $index) { |
|
| 54 | 54 | return $value; |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - protected function _getValue($property,$index){ |
|
| 58 | - if($property instanceof \ReflectionProperty){ |
|
| 57 | + protected function _getValue($property, $index) { |
|
| 58 | + if ($property instanceof \ReflectionProperty) { |
|
| 59 | 59 | $property->setAccessible(true); |
| 60 | 60 | $value=$property->getValue($this->instance); |
| 61 | - if(isset($this->values[$index])){ |
|
| 62 | - $value= $this->values[$index]($value,$this->instance,$index); |
|
| 63 | - }else{ |
|
| 64 | - $value=$this->_getDefaultValue($property->getName(),$value, $index); |
|
| 61 | + if (isset($this->values[$index])) { |
|
| 62 | + $value=$this->values[$index]($value, $this->instance, $index); |
|
| 63 | + } else { |
|
| 64 | + $value=$this->_getDefaultValue($property->getName(), $value, $index); |
|
| 65 | 65 | } |
| 66 | - }else{ |
|
| 67 | - if(\is_callable($property)) |
|
| 66 | + } else { |
|
| 67 | + if (\is_callable($property)) |
|
| 68 | 68 | $value=$property($this->instance); |
| 69 | - elseif(\is_array($property)){ |
|
| 70 | - $values=\array_map(function($v) use ($index){return $this->_getValue($v, $index);}, $property); |
|
| 69 | + elseif (\is_array($property)) { |
|
| 70 | + $values=\array_map(function($v) use ($index){return $this->_getValue($v, $index); }, $property); |
|
| 71 | 71 | $value=\implode("", $values); |
| 72 | - }else{ |
|
| 73 | - if(isset($this->values[$index])){ |
|
| 74 | - $value= $this->values[$index]($property,$this->instance,$index); |
|
| 75 | - }else{ |
|
| 72 | + } else { |
|
| 73 | + if (isset($this->values[$index])) { |
|
| 74 | + $value=$this->values[$index]($property, $this->instance, $index); |
|
| 75 | + } else { |
|
| 76 | 76 | $value=$property; |
| 77 | 77 | } |
| 78 | 78 | } |
| 79 | 79 | } |
| 80 | - if(isset($this->afterCompile[$index])){ |
|
| 81 | - if(\is_callable($this->afterCompile[$index])){ |
|
| 82 | - $this->afterCompile[$index]($value,$this->instance,$index); |
|
| 80 | + if (isset($this->afterCompile[$index])) { |
|
| 81 | + if (\is_callable($this->afterCompile[$index])) { |
|
| 82 | + $this->afterCompile[$index]($value, $this->instance, $index); |
|
| 83 | 83 | } |
| 84 | 84 | } |
| 85 | 85 | return $value; |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | - public function insertField($index,$field){ |
|
| 89 | - array_splice( $this->visibleProperties, $index, 0, $field ); |
|
| 88 | + public function insertField($index, $field) { |
|
| 89 | + array_splice($this->visibleProperties, $index, 0, $field); |
|
| 90 | 90 | return $this; |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | - public function insertInField($index,$field){ |
|
| 93 | + public function insertInField($index, $field) { |
|
| 94 | 94 | $vb=$this->visibleProperties; |
| 95 | - if(isset($vb[$index])){ |
|
| 96 | - if(\is_array($vb[$index])){ |
|
| 95 | + if (isset($vb[$index])) { |
|
| 96 | + if (\is_array($vb[$index])) { |
|
| 97 | 97 | $this->visibleProperties[$index][]=$field; |
| 98 | - }else{ |
|
| 99 | - $this->visibleProperties[$index]=[$vb[$index],$field]; |
|
| 98 | + } else { |
|
| 99 | + $this->visibleProperties[$index]=[$vb[$index], $field]; |
|
| 100 | 100 | } |
| 101 | - }else{ |
|
| 101 | + } else { |
|
| 102 | 102 | return $this->insertField($index, $field); |
| 103 | 103 | } |
| 104 | 104 | return $this; |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | - public function addField($field){ |
|
| 107 | + public function addField($field) { |
|
| 108 | 108 | $this->visibleProperties[]=$field; |
| 109 | 109 | return $this; |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | - public function count(){ |
|
| 112 | + public function count() { |
|
| 113 | 113 | return \sizeof($this->properties); |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | - public function visiblePropertiesCount(){ |
|
| 116 | + public function visiblePropertiesCount() { |
|
| 117 | 117 | return \sizeof($this->visibleProperties); |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | - public function getProperty($index){ |
|
| 120 | + public function getProperty($index) { |
|
| 121 | 121 | return $this->properties[$index]; |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | - protected function showableProperty(\ReflectionProperty $rProperty){ |
|
| 125 | - return JString::startswith($rProperty->getName(),"_")===false; |
|
| 124 | + protected function showableProperty(\ReflectionProperty $rProperty) { |
|
| 125 | + return JString::startswith($rProperty->getName(), "_")===false; |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | public function setInstance($instance) { |
| 129 | - if(\is_string($instance)){ |
|
| 129 | + if (\is_string($instance)) { |
|
| 130 | 130 | $instance=new $instance(); |
| 131 | 131 | } |
| 132 | 132 | $this->instance=$instance; |
| 133 | 133 | $this->properties=[]; |
| 134 | 134 | $this->reflect=new \ReflectionClass($instance); |
| 135 | - if(\sizeof($this->visibleProperties)===0){ |
|
| 135 | + if (\sizeof($this->visibleProperties)===0) { |
|
| 136 | 136 | $this->properties=$this->getDefaultProperties(); |
| 137 | - }else{ |
|
| 138 | - foreach ($this->visibleProperties as $property){ |
|
| 139 | - if(\is_callable($property)){ |
|
| 137 | + } else { |
|
| 138 | + foreach ($this->visibleProperties as $property) { |
|
| 139 | + if (\is_callable($property)) { |
|
| 140 | 140 | $this->properties[]=$property; |
| 141 | - }elseif(\is_string($property)){ |
|
| 142 | - try{ |
|
| 141 | + }elseif (\is_string($property)) { |
|
| 142 | + try { |
|
| 143 | 143 | $this->_beforeAddProperty(\sizeof($this->properties), $property); |
| 144 | 144 | $rProperty=$this->reflect->getProperty($property); |
| 145 | 145 | $this->properties[]=$rProperty; |
| 146 | - }catch(\Exception $e){ |
|
| 146 | + }catch (\Exception $e) { |
|
| 147 | 147 | $this->_beforeAddProperty(\sizeof($this->properties), $property); |
| 148 | 148 | $this->properties[]=$property; |
| 149 | 149 | } |
| 150 | - }elseif(\is_int($property)){ |
|
| 150 | + }elseif (\is_int($property)) { |
|
| 151 | 151 | $props=$this->getDefaultProperties(); |
| 152 | - if(isset($props[$property])) |
|
| 152 | + if (isset($props[$property])) |
|
| 153 | 153 | $this->properties[]=$props[$property]; |
| 154 | 154 | else |
| 155 | 155 | $this->properties[]=$property; |
| 156 | - }else{ |
|
| 156 | + } else { |
|
| 157 | 157 | $this->properties[]=$property; |
| 158 | 158 | } |
| 159 | 159 | } |
@@ -161,12 +161,12 @@ discard block |
||
| 161 | 161 | return $this; |
| 162 | 162 | } |
| 163 | 163 | |
| 164 | - protected function getDefaultProperties(){ |
|
| 164 | + protected function getDefaultProperties() { |
|
| 165 | 165 | $result=[]; |
| 166 | 166 | $properties=$this->reflect->getProperties(); |
| 167 | - foreach ($properties as $property){ |
|
| 167 | + foreach ($properties as $property) { |
|
| 168 | 168 | $showable=$this->showableProperty($property); |
| 169 | - if($showable!==false){ |
|
| 169 | + if ($showable!==false) { |
|
| 170 | 170 | $result[]=$property; |
| 171 | 171 | } |
| 172 | 172 | } |
@@ -178,12 +178,12 @@ discard block |
||
| 178 | 178 | return $this; |
| 179 | 179 | } |
| 180 | 180 | |
| 181 | - public function setValueFunction($index,$callback){ |
|
| 181 | + public function setValueFunction($index, $callback) { |
|
| 182 | 182 | $this->values[$index]=$callback; |
| 183 | 183 | return $this; |
| 184 | 184 | } |
| 185 | 185 | |
| 186 | - public function setIdentifierFunction($callback){ |
|
| 186 | + public function setIdentifierFunction($callback) { |
|
| 187 | 187 | $this->values["identifier"]=$callback; |
| 188 | 188 | return $this; |
| 189 | 189 | } |
@@ -196,22 +196,22 @@ discard block |
||
| 196 | 196 | return $this->properties; |
| 197 | 197 | } |
| 198 | 198 | |
| 199 | - public function getCaption($index){ |
|
| 200 | - if(isset($this->captions[$index])){ |
|
| 199 | + public function getCaption($index) { |
|
| 200 | + if (isset($this->captions[$index])) { |
|
| 201 | 201 | return $this->captions[$index]; |
| 202 | 202 | } |
| 203 | - if($this->properties[$index] instanceof \ReflectionProperty) |
|
| 203 | + if ($this->properties[$index] instanceof \ReflectionProperty) |
|
| 204 | 204 | return $this->properties[$index]->getName(); |
| 205 | - elseif(\is_callable($this->properties[$index])) |
|
| 205 | + elseif (\is_callable($this->properties[$index])) |
|
| 206 | 206 | return ""; |
| 207 | 207 | else |
| 208 | 208 | return $this->properties[$index]; |
| 209 | 209 | } |
| 210 | 210 | |
| 211 | - public function getCaptions(){ |
|
| 212 | - if(isset($this->captions)){ |
|
| 213 | - $result= $this->captions; |
|
| 214 | - for($i=\sizeof($result);$i<$this->count();$i++){ |
|
| 211 | + public function getCaptions() { |
|
| 212 | + if (isset($this->captions)) { |
|
| 213 | + $result=$this->captions; |
|
| 214 | + for ($i=\sizeof($result); $i<$this->count(); $i++) { |
|
| 215 | 215 | $result[]=""; |
| 216 | 216 | } |
| 217 | 217 | return $result; |
@@ -219,14 +219,14 @@ discard block |
||
| 219 | 219 | $captions=[]; |
| 220 | 220 | $index=0; |
| 221 | 221 | $count=$this->count(); |
| 222 | - while($index<$count){ |
|
| 222 | + while ($index<$count) { |
|
| 223 | 223 | $captions[]=$this->getCaption($index++); |
| 224 | 224 | } |
| 225 | 225 | return $captions; |
| 226 | 226 | } |
| 227 | 227 | |
| 228 | - public function setCaption($index,$caption){ |
|
| 229 | - if(isset($this->captions)===false) |
|
| 228 | + public function setCaption($index, $caption) { |
|
| 229 | + if (isset($this->captions)===false) |
|
| 230 | 230 | $this->captions=[]; |
| 231 | 231 | $this->captions[$index]=$caption; |
| 232 | 232 | return $this; |
@@ -244,7 +244,7 @@ discard block |
||
| 244 | 244 | * @param callable $callback function called after the field compilation |
| 245 | 245 | * @return \Ajax\semantic\widgets\datatable\InstanceViewer |
| 246 | 246 | */ |
| 247 | - public function afterCompile($index,$callback){ |
|
| 247 | + public function afterCompile($index, $callback) { |
|
| 248 | 248 | $this->afterCompile[$index]=$callback; |
| 249 | 249 | return $this; |
| 250 | 250 | } |
@@ -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,34 +155,34 @@ 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 | - if(isset($this->_validationParams["_ajaxSubmit"])){ |
|
| 183 | - if($this->_validationParams["_ajaxSubmit"] instanceof AjaxCall){ |
|
| 182 | + if (isset($this->_validationParams["_ajaxSubmit"])) { |
|
| 183 | + if ($this->_validationParams["_ajaxSubmit"] instanceof AjaxCall) { |
|
| 184 | 184 | $compilation=$this->_validationParams["_ajaxSubmit"]->compile($js); |
| 185 | - $compilation=str_ireplace("\"","%quote%", $compilation); |
|
| 185 | + $compilation=str_ireplace("\"", "%quote%", $compilation); |
|
| 186 | 186 | $this->onSuccess($compilation); |
| 187 | 187 | unset($this->_validationParams["_ajaxSubmit"]); |
| 188 | 188 | } |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | return $this->_bsComponent; |
| 194 | 194 | } |
| 195 | 195 | |
| 196 | - public function addValidationParam($paramName,$paramValue){ |
|
| 196 | + public function addValidationParam($paramName, $paramValue) { |
|
| 197 | 197 | $this->_validationParams[$paramName]=$paramValue; |
| 198 | 198 | return $this; |
| 199 | 199 | } |
@@ -52,8 +52,9 @@ discard block |
||
| 52 | 52 | */ |
| 53 | 53 | public function addHeader($title, $niveau=1, $dividing=true) { |
| 54 | 54 | $header=new HtmlHeader("", $niveau, $title); |
| 55 | - if ($dividing) |
|
| 56 | - $header->setDividing(); |
|
| 55 | + if ($dividing) { |
|
| 56 | + $header->setDividing(); |
|
| 57 | + } |
|
| 57 | 58 | return $this->addItem($header); |
| 58 | 59 | } |
| 59 | 60 | |
@@ -74,14 +75,16 @@ discard block |
||
| 74 | 75 | if (\is_string($end)) { |
| 75 | 76 | $label=$end; |
| 76 | 77 | \array_pop($fields); |
| 77 | - } else |
|
| 78 | - $label=NULL; |
|
| 78 | + } else { |
|
| 79 | + $label=NULL; |
|
| 80 | + } |
|
| 79 | 81 | } |
| 80 | 82 | $this->_fields=\array_merge($this->_fields, $fields); |
| 81 | 83 | $fields=new HtmlFormFields("fields-" . $this->identifier . "-" . $this->count(), $fields); |
| 82 | 84 | } |
| 83 | - if (isset($label)) |
|
| 84 | - $fields=new HtmlFormField("", $fields, $label); |
|
| 85 | + if (isset($label)) { |
|
| 86 | + $fields=new HtmlFormField("", $fields, $label); |
|
| 87 | + } |
|
| 85 | 88 | } else { |
| 86 | 89 | $fields=new HtmlFormFields("fields-" . $this->identifier . "-" . $this->count()); |
| 87 | 90 | } |
@@ -134,12 +137,15 @@ discard block |
||
| 134 | 137 | */ |
| 135 | 138 | public function addMessage($identifier, $content, $header=NULL, $icon=NULL, $type=NULL) { |
| 136 | 139 | $message=new HtmlMessage($identifier, $content); |
| 137 | - if (isset($header)) |
|
| 138 | - $message->addHeader($header); |
|
| 139 | - if (isset($icon)) |
|
| 140 | - $message->setIcon($icon); |
|
| 141 | - if (isset($type)) |
|
| 142 | - $message->setStyle($type); |
|
| 140 | + if (isset($header)) { |
|
| 141 | + $message->addHeader($header); |
|
| 142 | + } |
|
| 143 | + if (isset($icon)) { |
|
| 144 | + $message->setIcon($icon); |
|
| 145 | + } |
|
| 146 | + if (isset($type)) { |
|
| 147 | + $message->setStyle($type); |
|
| 148 | + } |
|
| 143 | 149 | return $this->addItem($message); |
| 144 | 150 | } |
| 145 | 151 | |
@@ -156,23 +162,26 @@ discard block |
||
| 156 | 162 | } |
| 157 | 163 | |
| 158 | 164 | public function compile(JsUtils $js=NULL,&$view=NULL){ |
| 159 | - if(\sizeof($this->_validationParams)>0) |
|
| 160 | - $this->setProperty("novalidate", ""); |
|
| 165 | + if(\sizeof($this->_validationParams)>0) { |
|
| 166 | + $this->setProperty("novalidate", ""); |
|
| 167 | + } |
|
| 161 | 168 | return parent::compile($js,$view); |
| 162 | 169 | } |
| 163 | 170 | |
| 164 | 171 | public function run(JsUtils $js) { |
| 165 | 172 | $compo=NULL; |
| 166 | 173 | foreach ($this->_fields as $field){ |
| 167 | - if($field instanceof HtmlFormField) |
|
| 168 | - $compo=$this->addCompoValidation($js, $compo, $field); |
|
| 174 | + if($field instanceof HtmlFormField) { |
|
| 175 | + $compo=$this->addCompoValidation($js, $compo, $field); |
|
| 176 | + } |
|
| 169 | 177 | } |
| 170 | 178 | foreach ($this->content as $field){ |
| 171 | 179 | if($field instanceof HtmlFormFields){ |
| 172 | 180 | $items=$field->getItems(); |
| 173 | 181 | foreach ($items as $_field){ |
| 174 | - if($_field instanceof HtmlFormField) |
|
| 175 | - $compo=$this->addCompoValidation($js, $compo, $_field); |
|
| 182 | + if($_field instanceof HtmlFormField) { |
|
| 183 | + $compo=$this->addCompoValidation($js, $compo, $_field); |
|
| 184 | + } |
|
| 176 | 185 | } |
| 177 | 186 | } |
| 178 | 187 | } |