@@ -9,10 +9,10 @@ discard block |
||
| 9 | 9 | class HtmlFormTextarea extends HtmlFormField { |
| 10 | 10 | use TextFieldsTrait; |
| 11 | 11 | |
| 12 | - public function __construct($identifier, $label=NULL,$value=NULL,$placeholder=NULL,$rows=NULL) { |
|
| 13 | - if(!isset($placeholder)) |
|
| 12 | + public function __construct($identifier, $label=NULL, $value=NULL, $placeholder=NULL, $rows=NULL) { |
|
| 13 | + if (!isset($placeholder)) |
|
| 14 | 14 | $placeholder=$label; |
| 15 | - parent::__construct("field-".$identifier, new HtmlTextarea($identifier,$value,$placeholder,$rows), $label); |
|
| 15 | + parent::__construct("field-".$identifier, new HtmlTextarea($identifier, $value, $placeholder, $rows), $label); |
|
| 16 | 16 | $this->_identifier=$identifier; |
| 17 | 17 | } |
| 18 | 18 | |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | * Defines the textarea row count |
| 21 | 21 | * @param int $count |
| 22 | 22 | */ |
| 23 | - public function setRows($count){ |
|
| 23 | + public function setRows($count) { |
|
| 24 | 24 | $this->getField()->setRows($count); |
| 25 | 25 | } |
| 26 | 26 | |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | return $this->content["field"]; |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | - public function setName($name){ |
|
| 32 | - $this->getDataField()->setProperty("name",$name); |
|
| 31 | + public function setName($name) { |
|
| 32 | + $this->getDataField()->setProperty("name", $name); |
|
| 33 | 33 | } |
| 34 | 34 | } |
@@ -3,5 +3,5 @@ |
||
| 3 | 3 | use Ajax\common\BaseEnum; |
| 4 | 4 | |
| 5 | 5 | abstract class PositionInTable extends BaseEnum { |
| 6 | - const BEFORETABLE="beforeTable",AFTERTABLE="afterTable",HEADER="thead",FOOTER="tfoot",BODY="tbody"; |
|
| 6 | + const BEFORETABLE="beforeTable", AFTERTABLE="afterTable", HEADER="thead", FOOTER="tfoot", BODY="tbody"; |
|
| 7 | 7 | } |
@@ -21,83 +21,83 @@ discard block |
||
| 21 | 21 | use BaseTrait; |
| 22 | 22 | |
| 23 | 23 | public function __construct($identifier, $modelInstance=NULL) { |
| 24 | - parent::__construct($identifier, null,$modelInstance); |
|
| 24 | + parent::__construct($identifier, null, $modelInstance); |
|
| 25 | 25 | $this->_form=new HtmlForm($identifier); |
| 26 | 26 | $this->_init(new FormInstanceViewer($identifier), "form", $this->_form, true); |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | - protected function _getFieldIdentifier($prefix,$name=""){ |
|
| 29 | + protected function _getFieldIdentifier($prefix, $name="") { |
|
| 30 | 30 | return $this->identifier."-{$name}-".$this->_instanceViewer->getIdentifier(); |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | - public function compile(JsUtils $js=NULL,&$view=NULL){ |
|
| 34 | - if(!$this->_generated){ |
|
| 33 | + public function compile(JsUtils $js=NULL, &$view=NULL) { |
|
| 34 | + if (!$this->_generated) { |
|
| 35 | 35 | $this->_instanceViewer->setInstance($this->_modelInstance); |
| 36 | 36 | |
| 37 | 37 | $form=$this->content["form"]; |
| 38 | 38 | $this->_generateContent($form); |
| 39 | 39 | |
| 40 | - if(isset($this->_toolbar)){ |
|
| 40 | + if (isset($this->_toolbar)) { |
|
| 41 | 41 | $this->_setToolbarPosition($form); |
| 42 | 42 | } |
| 43 | - $this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE,"form",PositionInTable::AFTERTABLE]); |
|
| 43 | + $this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE, "form", PositionInTable::AFTERTABLE]); |
|
| 44 | 44 | $this->_generated=true; |
| 45 | 45 | } |
| 46 | - return parent::compile($js,$view); |
|
| 46 | + return parent::compile($js, $view); |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | /** |
| 50 | 50 | * @param HtmlForm $form |
| 51 | 51 | */ |
| 52 | - protected function _generateContent($form){ |
|
| 53 | - $values= $this->_instanceViewer->getValues(); |
|
| 52 | + protected function _generateContent($form) { |
|
| 53 | + $values=$this->_instanceViewer->getValues(); |
|
| 54 | 54 | $count=$this->_instanceViewer->count(); |
| 55 | 55 | $separators=$this->_instanceViewer->getSeparators(); |
| 56 | 56 | $headers=$this->_instanceViewer->getHeaders(); |
| 57 | 57 | $wrappers=$this->_instanceViewer->getWrappers(); |
| 58 | 58 | \sort($separators); |
| 59 | 59 | $size=\sizeof($separators); |
| 60 | - if($size===1){ |
|
| 60 | + if ($size===1) { |
|
| 61 | 61 | $i=-1; |
| 62 | - foreach ($values as $v){ |
|
| 62 | + foreach ($values as $v) { |
|
| 63 | 63 | $this->_generateFields($form, [$v], $headers, $i, $wrappers); |
| 64 | 64 | $i++; |
| 65 | 65 | } |
| 66 | - }else{ |
|
| 66 | + } else { |
|
| 67 | 67 | $separators[]=$count; |
| 68 | - for($i=0;$i<$size;$i++){ |
|
| 69 | - $fields=\array_slice($values, $separators[$i]+1,$separators[$i+1]-$separators[$i]); |
|
| 68 | + for ($i=0; $i<$size; $i++) { |
|
| 69 | + $fields=\array_slice($values, $separators[$i]+1, $separators[$i+1]-$separators[$i]); |
|
| 70 | 70 | $this->_generateFields($form, $fields, $headers, $separators[$i], $wrappers); |
| 71 | 71 | } |
| 72 | 72 | } |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | - protected function _generateFields($form,$values,$headers,$sepFirst,$wrappers){ |
|
| 75 | + protected function _generateFields($form, $values, $headers, $sepFirst, $wrappers) { |
|
| 76 | 76 | $wrapper=null; |
| 77 | - if(isset($headers[$sepFirst+1])) |
|
| 78 | - $form->addHeader($headers[$sepFirst+1],4,true); |
|
| 79 | - if(isset($wrappers[$sepFirst+1])){ |
|
| 77 | + if (isset($headers[$sepFirst+1])) |
|
| 78 | + $form->addHeader($headers[$sepFirst+1], 4, true); |
|
| 79 | + if (isset($wrappers[$sepFirst+1])) { |
|
| 80 | 80 | $wrapper=$wrappers[$sepFirst+1]; |
| 81 | 81 | } |
| 82 | - if(\sizeof($values)===1){ |
|
| 82 | + if (\sizeof($values)===1) { |
|
| 83 | 83 | $added=$form->addField($values[0]); |
| 84 | - }elseif(\sizeof($values)>1){ |
|
| 84 | + }elseif (\sizeof($values)>1) { |
|
| 85 | 85 | $added=$form->addFields($values); |
| 86 | - }else |
|
| 86 | + } else |
|
| 87 | 87 | return; |
| 88 | - if(isset($wrapper)){ |
|
| 89 | - $added->wrap($wrapper[0],$wrapper[1]); |
|
| 88 | + if (isset($wrapper)) { |
|
| 89 | + $added->wrap($wrapper[0], $wrapper[1]); |
|
| 90 | 90 | } |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | /** |
| 94 | 94 | * @return HtmlForm |
| 95 | 95 | */ |
| 96 | - public function getForm(){ |
|
| 96 | + public function getForm() { |
|
| 97 | 97 | return $this->content["form"]; |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | - public function addSeparatorAfter($fieldNum){ |
|
| 100 | + public function addSeparatorAfter($fieldNum) { |
|
| 101 | 101 | $fieldNum=$this->_getIndex($fieldNum); |
| 102 | 102 | $this->_instanceViewer->addSeparatorAfter($fieldNum); |
| 103 | 103 | return $this; |
@@ -112,12 +112,12 @@ discard block |
||
| 112 | 112 | return $this; |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | - public function fieldAsReset($index,$cssStyle=NULL,$attributes=NULL){ |
|
| 116 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($cssStyle){ |
|
| 117 | - $button=new HtmlButton($id,$value,$cssStyle); |
|
| 115 | + public function fieldAsReset($index, $cssStyle=NULL, $attributes=NULL) { |
|
| 116 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($cssStyle){ |
|
| 117 | + $button=new HtmlButton($id, $value, $cssStyle); |
|
| 118 | 118 | $button->setProperty("type", "reset"); |
| 119 | 119 | return $button; |
| 120 | - }, $index,$attributes); |
|
| 120 | + }, $index, $attributes); |
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | /** |
@@ -136,19 +136,19 @@ discard block |
||
| 136 | 136 | $this->content[$this->_toolbarPosition]=$this->_toolbar; |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | - public function addDividerBefore($index,$title){ |
|
| 139 | + public function addDividerBefore($index, $title) { |
|
| 140 | 140 | $index=$this->_getIndex($index); |
| 141 | 141 | $this->_instanceViewer->addHeaderDividerBefore($index, $title); |
| 142 | 142 | return $this; |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | - public function addWrapper($index,$contentBefore,$contentAfter=null){ |
|
| 145 | + public function addWrapper($index, $contentBefore, $contentAfter=null) { |
|
| 146 | 146 | $index=$this->_getIndex($index); |
| 147 | - $this->_instanceViewer->addWrapper($index, $contentBefore,$contentAfter); |
|
| 147 | + $this->_instanceViewer->addWrapper($index, $contentBefore, $contentAfter); |
|
| 148 | 148 | return $this; |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | - public function run(JsUtils $js){ |
|
| 151 | + public function run(JsUtils $js) { |
|
| 152 | 152 | return parent::run($js); |
| 153 | 153 | } |
| 154 | 154 | } |
@@ -16,17 +16,17 @@ discard block |
||
| 16 | 16 | * |
| 17 | 17 | * @see \Ajax\semantic\widgets\dataform\DataForm::__construct() |
| 18 | 18 | */ |
| 19 | - public function __construct($identifier,$modelInstance=null,$fieldsOrder,$fieldsDefinition,$fields=[],$captions=[],$separators=[]) { |
|
| 20 | - if(!isset($modelInstance)){ |
|
| 19 | + public function __construct($identifier, $modelInstance=null, $fieldsOrder, $fieldsDefinition, $fields=[], $captions=[], $separators=[]) { |
|
| 20 | + if (!isset($modelInstance)) { |
|
| 21 | 21 | $modelInstance=$this->getDefaultModelInstance(); |
| 22 | 22 | } |
| 23 | - parent::__construct($identifier,$modelInstance); |
|
| 24 | - $this->_initForm($fieldsOrder, $fieldsDefinition,$fields,$captions,$separators); |
|
| 23 | + parent::__construct($identifier, $modelInstance); |
|
| 24 | + $this->_initForm($fieldsOrder, $fieldsDefinition, $fields, $captions, $separators); |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | abstract protected function getDefaultModelInstance(); |
| 28 | 28 | |
| 29 | - protected function _initForm($fieldsOrder,$fieldsDefinition,$fields=[],$captions=[],$separators=[]){ |
|
| 29 | + protected function _initForm($fieldsOrder, $fieldsDefinition, $fields=[], $captions=[], $separators=[]) { |
|
| 30 | 30 | $this->_fieldsOrder=$fieldsOrder; |
| 31 | 31 | $this->setFields($fields); |
| 32 | 32 | $this->setSeparators($separators); |
@@ -34,26 +34,26 @@ discard block |
||
| 34 | 34 | $this->setCaptions($captions); |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | - protected function _getIndex($fieldName){ |
|
| 37 | + protected function _getIndex($fieldName) { |
|
| 38 | 38 | $index=$fieldName; |
| 39 | - if(\is_string($fieldName)){ |
|
| 39 | + if (\is_string($fieldName)) { |
|
| 40 | 40 | $index=\array_search($fieldName, $this->_fieldsOrder); |
| 41 | 41 | } |
| 42 | 42 | return $index; |
| 43 | 43 | } |
| 44 | - protected function _fieldAs($elementCallback,&$index,$attributes=NULL,$prefix=null){ |
|
| 44 | + protected function _fieldAs($elementCallback, &$index, $attributes=NULL, $prefix=null) { |
|
| 45 | 45 | $index=$this->_getIndex($index); |
| 46 | - return parent::_fieldAs($elementCallback, $index,$attributes,$prefix); |
|
| 46 | + return parent::_fieldAs($elementCallback, $index, $attributes, $prefix); |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | |
| 50 | - public function removeField($fieldName){ |
|
| 50 | + public function removeField($fieldName) { |
|
| 51 | 51 | parent::removeField($fieldName); |
| 52 | - \array_splice($this->_fieldsOrder,$this->_getIndex($fieldName),1); |
|
| 52 | + \array_splice($this->_fieldsOrder, $this->_getIndex($fieldName), 1); |
|
| 53 | 53 | return $this; |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | - public function compile(JsUtils $js=NULL,&$view=NULL){ |
|
| 57 | - return parent::compile($js,$view); |
|
| 56 | + public function compile(JsUtils $js=NULL, &$view=NULL) { |
|
| 57 | + return parent::compile($js, $view); |
|
| 58 | 58 | } |
| 59 | 59 | } |
@@ -10,50 +10,50 @@ |
||
| 10 | 10 | * @param string $identifier |
| 11 | 11 | * @param object $modelInstance |
| 12 | 12 | */ |
| 13 | - public function __construct($identifier,$modelInstance=null,$fieldsOrder=[],$fieldsDefinition=[],$fields=[],$captions=[],$separators=[]) { |
|
| 14 | - parent::__construct($identifier,$modelInstance,$fieldsOrder,$fieldsDefinition,$fields,$captions,$separators); |
|
| 13 | + public function __construct($identifier, $modelInstance=null, $fieldsOrder=[], $fieldsDefinition=[], $fields=[], $captions=[], $separators=[]) { |
|
| 14 | + parent::__construct($identifier, $modelInstance, $fieldsOrder, $fieldsDefinition, $fields, $captions, $separators); |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | - protected function getDefaultModelInstance(){ |
|
| 17 | + protected function getDefaultModelInstance() { |
|
| 18 | 18 | return new UserModel(); |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | - public static function regular($identifier,$modelInstance=null){ |
|
| 22 | - return new FormLogin($identifier,$modelInstance, |
|
| 23 | - ["message","login","password","remember","forget","submit","error"], |
|
| 24 | - ["message"=>[["icon"=>"sign in"]],"input0"=>[["rules"=>"empty"]],"input1"=>[["inputType"=>"password","rules"=>"empty"]],"checkbox","link","submit"=>["green fluid"],"message2"=>[["error"=>true]]], |
|
| 25 | - ["Connection","login","password","remember","forget","submit","error"], |
|
| 26 | - ["Please enter login and password to connect","Login","Password","Remember me.","Forgot your password?","Connection"], |
|
| 27 | - [0,2,4,5,6]); |
|
| 21 | + public static function regular($identifier, $modelInstance=null) { |
|
| 22 | + return new FormLogin($identifier, $modelInstance, |
|
| 23 | + ["message", "login", "password", "remember", "forget", "submit", "error"], |
|
| 24 | + ["message"=>[["icon"=>"sign in"]], "input0"=>[["rules"=>"empty"]], "input1"=>[["inputType"=>"password", "rules"=>"empty"]], "checkbox", "link", "submit"=>["green fluid"], "message2"=>[["error"=>true]]], |
|
| 25 | + ["Connection", "login", "password", "remember", "forget", "submit", "error"], |
|
| 26 | + ["Please enter login and password to connect", "Login", "Password", "Remember me.", "Forgot your password?", "Connection"], |
|
| 27 | + [0, 2, 4, 5, 6]); |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | - public static function smallInline($identifier,$modelInstance=null){ |
|
| 31 | - $result=new FormLogin($identifier,$modelInstance, |
|
| 32 | - ["login","password","submit"], |
|
| 33 | - ["input0"=>[["rules"=>"empty"]],"input1"=>[["inputType"=>"password","rules"=>"empty"]],"submit"=>["green basic"]], |
|
| 34 | - ["login","password","submit"], |
|
| 35 | - ["","","Connection"], |
|
| 30 | + public static function smallInline($identifier, $modelInstance=null) { |
|
| 31 | + $result=new FormLogin($identifier, $modelInstance, |
|
| 32 | + ["login", "password", "submit"], |
|
| 33 | + ["input0"=>[["rules"=>"empty"]], "input1"=>[["inputType"=>"password", "rules"=>"empty"]], "submit"=>["green basic"]], |
|
| 34 | + ["login", "password", "submit"], |
|
| 35 | + ["", "", "Connection"], |
|
| 36 | 36 | [2]); |
| 37 | 37 | $result->addDividerBefore(0, "Connection"); |
| 38 | 38 | return $result; |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | - public static function small($identifier,$modelInstance=null){ |
|
| 42 | - $result=new FormLogin($identifier,$modelInstance, |
|
| 43 | - ["login","password","submit"], |
|
| 44 | - ["input0"=>[["rules"=>"empty"]],"input1"=>[["inputType"=>"password","rules"=>"empty"]],"submit"=>["green basic"]], |
|
| 45 | - ["login","password","submit"], |
|
| 46 | - ["Login","Password","Connection"], |
|
| 47 | - [1,2]); |
|
| 41 | + public static function small($identifier, $modelInstance=null) { |
|
| 42 | + $result=new FormLogin($identifier, $modelInstance, |
|
| 43 | + ["login", "password", "submit"], |
|
| 44 | + ["input0"=>[["rules"=>"empty"]], "input1"=>[["inputType"=>"password", "rules"=>"empty"]], "submit"=>["green basic"]], |
|
| 45 | + ["login", "password", "submit"], |
|
| 46 | + ["Login", "Password", "Connection"], |
|
| 47 | + [1, 2]); |
|
| 48 | 48 | $result->addDividerBefore(0, "Connection"); |
| 49 | 49 | return $result; |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | - public static function attachedSegment($identifier,$modelInstance=null){ |
|
| 53 | - $result=self::regular($identifier,$modelInstance); |
|
| 54 | - $result->fieldAsMessage("message",["icon"=>"sign in","attached"=>true]); |
|
| 55 | - $result->addWrapper("message",null,"<div class='ui attached segment'>"); |
|
| 56 | - $result->addWrapper("error", null,"</div>"); |
|
| 52 | + public static function attachedSegment($identifier, $modelInstance=null) { |
|
| 53 | + $result=self::regular($identifier, $modelInstance); |
|
| 54 | + $result->fieldAsMessage("message", ["icon"=>"sign in", "attached"=>true]); |
|
| 55 | + $result->addWrapper("message", null, "<div class='ui attached segment'>"); |
|
| 56 | + $result->addWrapper("error", null, "</div>"); |
|
| 57 | 57 | return $result; |
| 58 | 58 | } |
| 59 | 59 | } |
@@ -20,15 +20,15 @@ discard block |
||
| 20 | 20 | $this->params["fields"]=[]; |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | - public function addField($identifier){ |
|
| 23 | + public function addField($identifier) { |
|
| 24 | 24 | $this->params["fields"][$identifier]=new FieldValidation($identifier); |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | - public function setInline($value){ |
|
| 27 | + public function setInline($value) { |
|
| 28 | 28 | return $this->setParam("inline", true); |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | - public function setOn($value){ |
|
| 31 | + public function setOn($value) { |
|
| 32 | 32 | return $this->setParam("on", $value); |
| 33 | 33 | } |
| 34 | 34 | |
@@ -40,33 +40,33 @@ discard block |
||
| 40 | 40 | * @param mixed $value |
| 41 | 41 | * @param string|NULL $prompt |
| 42 | 42 | */ |
| 43 | - public function addFieldRule($identifier,$type,$prompt=NULL,$value=NULL){ |
|
| 44 | - if(isset($this->params["fields"][$identifier])===false){ |
|
| 43 | + public function addFieldRule($identifier, $type, $prompt=NULL, $value=NULL) { |
|
| 44 | + if (isset($this->params["fields"][$identifier])===false) { |
|
| 45 | 45 | $this->addField($identifier); |
| 46 | 46 | } |
| 47 | - $this->params["fields"][$identifier]->addRule($type,$prompt,$value); |
|
| 47 | + $this->params["fields"][$identifier]->addRule($type, $prompt, $value); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | /** |
| 51 | 51 | * @param FieldValidation $fieldValidation |
| 52 | 52 | */ |
| 53 | - public function addFieldValidation($fieldValidation){ |
|
| 53 | + public function addFieldValidation($fieldValidation) { |
|
| 54 | 54 | $this->params["fields"][$fieldValidation->getIdentifier()]=$fieldValidation; |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - public function setJs(JsUtils $js){ |
|
| 57 | + public function setJs(JsUtils $js) { |
|
| 58 | 58 | $this->js=$js; |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | public function getScript() { |
| 62 | 62 | $allParams=$this->params; |
| 63 | - $this->jquery_code_for_compile=array (); |
|
| 63 | + $this->jquery_code_for_compile=array(); |
|
| 64 | 64 | $this->jquery_code_for_compile []="$( \"".$this->attachTo."\" ).{$this->uiName}(".$this->getParamsAsJSON($allParams).");"; |
| 65 | 65 | $this->compileEvents(); |
| 66 | 66 | return $this->compileJQueryCode(); |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | - public function onValid($jsCode){ |
|
| 69 | + public function onValid($jsCode) { |
|
| 70 | 70 | $this->addComponentEvent("onValid", $jsCode); |
| 71 | 71 | } |
| 72 | 72 | } |
@@ -17,8 +17,8 @@ discard block |
||
| 17 | 17 | * @param string $action one of "select","auto","activate","combo","nothing","hide" |
| 18 | 18 | * @return \Ajax\semantic\components\Dropdown |
| 19 | 19 | */ |
| 20 | - public function setAction($action){ |
|
| 21 | - return $this->setParamCtrl("action", $action,array("select","auto","activate","combo","nothing","hide")); |
|
| 20 | + public function setAction($action) { |
|
| 21 | + return $this->setParamCtrl("action", $action, array("select", "auto", "activate", "combo", "nothing", "hide")); |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | /** |
@@ -26,11 +26,11 @@ discard block |
||
| 26 | 26 | * @param string $event Event used to trigger dropdown (Hover, Click, Custom Event) |
| 27 | 27 | * @return \Ajax\semantic\components\Dropdown |
| 28 | 28 | */ |
| 29 | - public function setOn($event){ |
|
| 29 | + public function setOn($event) { |
|
| 30 | 30 | return $this->setParam("on", $event); |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | - public function setFullTextSearch($value){ |
|
| 33 | + public function setFullTextSearch($value) { |
|
| 34 | 34 | return $this->setParam("fullTextSearch", $value); |
| 35 | 35 | } |
| 36 | 36 | } |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | public function fromArray($array) { |
| 70 | - foreach ( $array as $key => $value ) { |
|
| 70 | + foreach ($array as $key => $value) { |
|
| 71 | 71 | $this->{$key}=$value; |
| 72 | 72 | } |
| 73 | 73 | return $this; |
@@ -79,8 +79,8 @@ discard block |
||
| 79 | 79 | |
| 80 | 80 | public function JsonSerialize() { |
| 81 | 81 | $vars=get_object_vars($this); |
| 82 | - $result=array (); |
|
| 83 | - foreach ( $vars as $k => $v ) { |
|
| 82 | + $result=array(); |
|
| 83 | + foreach ($vars as $k => $v) { |
|
| 84 | 84 | if (isset($v)) |
| 85 | 85 | $result[$k]=$v; |
| 86 | 86 | } |
@@ -89,6 +89,6 @@ discard block |
||
| 89 | 89 | |
| 90 | 90 | public function search($query, $field="title") { |
| 91 | 91 | $value=$this->$field; |
| 92 | - return \stripos($value, $query) !== false; |
|
| 92 | + return \stripos($value, $query)!==false; |
|
| 93 | 93 | } |
| 94 | 94 | } |
@@ -5,7 +5,7 @@ discard block |
||
| 5 | 5 | * @version 1.001 |
| 6 | 6 | * Generates a JSON Rule for the validation of a field |
| 7 | 7 | */ |
| 8 | -class Rule implements \JsonSerializable{ |
|
| 8 | +class Rule implements \JsonSerializable { |
|
| 9 | 9 | /** |
| 10 | 10 | * @var string |
| 11 | 11 | */ |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | */ |
| 21 | 21 | private $value; |
| 22 | 22 | |
| 23 | - public function __construct($type,$prompt=NULL,$value=NULL){ |
|
| 23 | + public function __construct($type, $prompt=NULL, $value=NULL) { |
|
| 24 | 24 | $this->type=$type; |
| 25 | 25 | $this->prompt=$prompt; |
| 26 | 26 | $this->value=$value; |
@@ -54,10 +54,10 @@ discard block |
||
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | public function jsonSerialize() { |
| 57 | - $result= ["type"=>$this->type]; |
|
| 58 | - if(isset($this->prompt)) |
|
| 57 | + $result=["type"=>$this->type]; |
|
| 58 | + if (isset($this->prompt)) |
|
| 59 | 59 | $result["prompt"]=$this->prompt; |
| 60 | - if(isset($this->value)) |
|
| 60 | + if (isset($this->value)) |
|
| 61 | 61 | $result["value"]=$this->value; |
| 62 | 62 | return $result; |
| 63 | 63 | } |
@@ -68,8 +68,8 @@ discard block |
||
| 68 | 68 | * @param string $prompt |
| 69 | 69 | * @return \Ajax\semantic\components\validation\Rule |
| 70 | 70 | */ |
| 71 | - public static function match($name,$prompt=NULL){ |
|
| 72 | - return new Rule("match[".$name."]",$prompt); |
|
| 71 | + public static function match($name, $prompt=NULL) { |
|
| 72 | + return new Rule("match[".$name."]", $prompt); |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | /** |
@@ -78,8 +78,8 @@ discard block |
||
| 78 | 78 | * @param string $prompt |
| 79 | 79 | * @return \Ajax\semantic\components\validation\Rule |
| 80 | 80 | */ |
| 81 | - public static function different($name,$prompt=NULL){ |
|
| 82 | - return new Rule("different[".$name."]",$prompt); |
|
| 81 | + public static function different($name, $prompt=NULL) { |
|
| 82 | + return new Rule("different[".$name."]", $prompt); |
|
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | /** |
@@ -89,78 +89,78 @@ discard block |
||
| 89 | 89 | * @param string $prompt |
| 90 | 90 | * @return \Ajax\semantic\components\validation\Rule |
| 91 | 91 | */ |
| 92 | - public static function integer($min=NULL,$max=NULL,$prompt=NULL){ |
|
| 93 | - if(\is_int($min) && \is_int($max)) |
|
| 94 | - return new Rule("integer[{$min}..{$max}]",$prompt); |
|
| 95 | - return new Rule("integer",$prompt); |
|
| 92 | + public static function integer($min=NULL, $max=NULL, $prompt=NULL) { |
|
| 93 | + if (\is_int($min) && \is_int($max)) |
|
| 94 | + return new Rule("integer[{$min}..{$max}]", $prompt); |
|
| 95 | + return new Rule("integer", $prompt); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - public static function decimal($prompt=NULL){ |
|
| 99 | - return new Rule("decimal",$prompt); |
|
| 98 | + public static function decimal($prompt=NULL) { |
|
| 99 | + return new Rule("decimal", $prompt); |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | - public static function number($prompt=NULL){ |
|
| 103 | - return new Rule("number",$prompt); |
|
| 102 | + public static function number($prompt=NULL) { |
|
| 103 | + return new Rule("number", $prompt); |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | - public static function is($value,$prompt=NULL){ |
|
| 107 | - return new Rule("is[".$value."]",$prompt); |
|
| 106 | + public static function is($value, $prompt=NULL) { |
|
| 107 | + return new Rule("is[".$value."]", $prompt); |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - public static function isExactly($value,$prompt=NULL){ |
|
| 111 | - return new Rule("isExactly[".$value."]",$prompt); |
|
| 110 | + public static function isExactly($value, $prompt=NULL) { |
|
| 111 | + return new Rule("isExactly[".$value."]", $prompt); |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | - public static function not($value,$prompt=NULL){ |
|
| 115 | - return new Rule("not[".$value."]",$prompt); |
|
| 114 | + public static function not($value, $prompt=NULL) { |
|
| 115 | + return new Rule("not[".$value."]", $prompt); |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | - public static function notExactly($value,$prompt=NULL){ |
|
| 119 | - return new Rule("notExactly[".$value."]",$prompt); |
|
| 118 | + public static function notExactly($value, $prompt=NULL) { |
|
| 119 | + return new Rule("notExactly[".$value."]", $prompt); |
|
| 120 | 120 | } |
| 121 | 121 | |
| 122 | - public static function contains($value,$prompt=NULL){ |
|
| 123 | - return new Rule("contains[".$value."]",$prompt); |
|
| 122 | + public static function contains($value, $prompt=NULL) { |
|
| 123 | + return new Rule("contains[".$value."]", $prompt); |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | - public static function containsExactly($value,$prompt=NULL){ |
|
| 127 | - return new Rule("containsExactly[".$value."]",$prompt); |
|
| 126 | + public static function containsExactly($value, $prompt=NULL) { |
|
| 127 | + return new Rule("containsExactly[".$value."]", $prompt); |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | - public static function doesntContain($value,$prompt=NULL){ |
|
| 131 | - return new Rule("doesntContain[".$value."]",$prompt); |
|
| 130 | + public static function doesntContain($value, $prompt=NULL) { |
|
| 131 | + return new Rule("doesntContain[".$value."]", $prompt); |
|
| 132 | 132 | } |
| 133 | 133 | |
| 134 | - public static function doesntContainExactly($value,$prompt=NULL){ |
|
| 135 | - return new Rule("doesntContainExactly[".$value."]",$prompt); |
|
| 134 | + public static function doesntContainExactly($value, $prompt=NULL) { |
|
| 135 | + return new Rule("doesntContainExactly[".$value."]", $prompt); |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | - public static function minCount($value,$prompt=NULL){ |
|
| 139 | - return new Rule("minCount[".$value."]",$prompt); |
|
| 138 | + public static function minCount($value, $prompt=NULL) { |
|
| 139 | + return new Rule("minCount[".$value."]", $prompt); |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | - public static function maxCount($value,$prompt=NULL){ |
|
| 143 | - return new Rule("maxCount[".$value."]",$prompt); |
|
| 142 | + public static function maxCount($value, $prompt=NULL) { |
|
| 143 | + return new Rule("maxCount[".$value."]", $prompt); |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | - public static function exactCount($value,$prompt=NULL){ |
|
| 147 | - return new Rule("exactCount[".$value."]",$prompt); |
|
| 146 | + public static function exactCount($value, $prompt=NULL) { |
|
| 147 | + return new Rule("exactCount[".$value."]", $prompt); |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | - public static function email($prompt=NULL){ |
|
| 151 | - return new Rule("email",$prompt); |
|
| 150 | + public static function email($prompt=NULL) { |
|
| 151 | + return new Rule("email", $prompt); |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | - public static function url($prompt=NULL){ |
|
| 155 | - return new Rule("url",$prompt); |
|
| 154 | + public static function url($prompt=NULL) { |
|
| 155 | + return new Rule("url", $prompt); |
|
| 156 | 156 | } |
| 157 | 157 | |
| 158 | - public static function regExp($value,$prompt=NULL){ |
|
| 159 | - return new Rule("regExp",$prompt,$value); |
|
| 158 | + public static function regExp($value, $prompt=NULL) { |
|
| 159 | + return new Rule("regExp", $prompt, $value); |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | - public static function custom($name,$jsFunction){ |
|
| 163 | - return "$.fn.form.settings.rules.".$name." =".$jsFunction ; |
|
| 162 | + public static function custom($name, $jsFunction) { |
|
| 163 | + return "$.fn.form.settings.rules.".$name." =".$jsFunction; |
|
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | } |