@@ -17,9 +17,9 @@ discard block |
||
| 17 | 17 | return $this; |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | - protected function generateParamParts(){ |
|
| 20 | + protected function generateParamParts() { |
|
| 21 | 21 | $results=[]; |
| 22 | - foreach ($this->paramParts as $paramPart){ |
|
| 22 | + foreach ($this->paramParts as $paramPart) { |
|
| 23 | 23 | $results[]="{$this->uiName}(".\implode(",", $paramPart).")"; |
| 24 | 24 | } |
| 25 | 25 | return \implode(".", $results); |
@@ -27,10 +27,10 @@ discard block |
||
| 27 | 27 | |
| 28 | 28 | public function getScript() { |
| 29 | 29 | $allParams=$this->params; |
| 30 | - $this->jquery_code_for_compile=array (); |
|
| 30 | + $this->jquery_code_for_compile=array(); |
|
| 31 | 31 | $this->compileJsCodes(); |
| 32 | 32 | $paramParts=""; |
| 33 | - if(\sizeof($this->paramParts)>0){ |
|
| 33 | + if (\sizeof($this->paramParts)>0) { |
|
| 34 | 34 | $paramParts=".".$this->generateParamParts(); |
| 35 | 35 | } |
| 36 | 36 | $this->jquery_code_for_compile []="$( \"".$this->attachTo."\" ).{$this->uiName}(".$this->getParamsAsJSON($allParams).")".$paramParts.";"; |
@@ -43,12 +43,12 @@ discard block |
||
| 43 | 43 | return $this; |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | - public function addComponentEvent($event,$jsCode){ |
|
| 47 | - $jsCode=\str_ireplace("\"","%quote%", $jsCode); |
|
| 46 | + public function addComponentEvent($event, $jsCode) { |
|
| 47 | + $jsCode=\str_ireplace("\"", "%quote%", $jsCode); |
|
| 48 | 48 | return $this->setParam($event, "%function(module){".$jsCode."}%"); |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | - public function setJs(JsUtils $js){ |
|
| 51 | + public function setJs(JsUtils $js) { |
|
| 52 | 52 | $this->js=$js; |
| 53 | 53 | $js->semantic()->addComponent($this, $this->attachTo, $this->params); |
| 54 | 54 | } |
@@ -19,75 +19,75 @@ |
||
| 19 | 19 | $this->uiName='toast'; |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | - public function close(){ |
|
| 22 | + public function close() { |
|
| 23 | 23 | return $this->addBehavior('close'); |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | - public function setClass($value){ |
|
| 26 | + public function setClass($value) { |
|
| 27 | 27 | $this->params['class']=$value; |
| 28 | 28 | return $this; |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | - public function setCloseIcon(){ |
|
| 31 | + public function setCloseIcon() { |
|
| 32 | 32 | $this->params['closeIcon']=true; |
| 33 | 33 | return $this; |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - public function setShowIcon($value=false){ |
|
| 36 | + public function setShowIcon($value=false) { |
|
| 37 | 37 | $this->params['showIcon']=$value; |
| 38 | 38 | return $this; |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | - public function setPreserveHTML($value=false){ |
|
| 41 | + public function setPreserveHTML($value=false) { |
|
| 42 | 42 | $this->params['preserveHTML']=$value; |
| 43 | 43 | return $this; |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | - public function setCloseOnClick($value){ |
|
| 46 | + public function setCloseOnClick($value) { |
|
| 47 | 47 | $this->params['closeOnClick']=$value; |
| 48 | 48 | return $this; |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | - public function setTitle($title){ |
|
| 51 | + public function setTitle($title) { |
|
| 52 | 52 | $this->params['title']=$title; |
| 53 | 53 | return $this; |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | - public function setActions(array $actions){ |
|
| 57 | - foreach ($actions as &$action){ |
|
| 58 | - if(isset($action['click'])){ |
|
| 59 | - $js=\str_ireplace("\"","%quote%", $action['click']); |
|
| 56 | + public function setActions(array $actions) { |
|
| 57 | + foreach ($actions as &$action) { |
|
| 58 | + if (isset($action['click'])) { |
|
| 59 | + $js=\str_ireplace("\"", "%quote%", $action['click']); |
|
| 60 | 60 | $action['click']="%function(){".$js."}%"; |
| 61 | 61 | } |
| 62 | 62 | } |
| 63 | 63 | $this->params['actions']=$actions; |
| 64 | - if(count($actions)>0) { |
|
| 65 | - $this->params['displayTime'] = 0; |
|
| 64 | + if (count($actions)>0) { |
|
| 65 | + $this->params['displayTime']=0; |
|
| 66 | 66 | } |
| 67 | 67 | return $this; |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - public function setMessage($message){ |
|
| 70 | + public function setMessage($message) { |
|
| 71 | 71 | $this->params['message']=$message; |
| 72 | 72 | return $this; |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | - public function setPosition($position){ |
|
| 75 | + public function setPosition($position) { |
|
| 76 | 76 | $this->params['position']=$position; |
| 77 | 77 | return $this; |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | - public function setDisplayTime($time){ |
|
| 80 | + public function setDisplayTime($time) { |
|
| 81 | 81 | $this->params['displayTime']=$time; |
| 82 | 82 | return $this; |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | - public function setShowProgress($value='top'){ |
|
| 85 | + public function setShowProgress($value='top') { |
|
| 86 | 86 | $this->params['showProgress']=$value; |
| 87 | 87 | return $this; |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | - public function setClassProgress($value){ |
|
| 90 | + public function setClassProgress($value) { |
|
| 91 | 91 | $this->params['classProgress']=$value; |
| 92 | 92 | return $this; |
| 93 | 93 | } |
@@ -10,8 +10,8 @@ discard block |
||
| 10 | 10 | * @version 1.001 |
| 11 | 11 | */ |
| 12 | 12 | abstract class BaseComponent { |
| 13 | - public $jquery_code_for_compile=array (); |
|
| 14 | - protected $params=array (); |
|
| 13 | + public $jquery_code_for_compile=array(); |
|
| 14 | + protected $params=array(); |
|
| 15 | 15 | |
| 16 | 16 | /** |
| 17 | 17 | * |
@@ -68,9 +68,9 @@ discard block |
||
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | public function setParams($params) { |
| 71 | - if(\is_array($params)) { |
|
| 71 | + if (\is_array($params)) { |
|
| 72 | 72 | foreach ($params as $k => $v) { |
| 73 | - $method = "set" . ucfirst($k); |
|
| 73 | + $method="set".ucfirst($k); |
|
| 74 | 74 | if (method_exists($this, $method)) |
| 75 | 75 | $this->$method($v); |
| 76 | 76 | else { |
@@ -83,8 +83,8 @@ discard block |
||
| 83 | 83 | return $this; |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | - public function addParams($params){ |
|
| 87 | - foreach ($params as $k=>$v){ |
|
| 86 | + public function addParams($params) { |
|
| 87 | + foreach ($params as $k=>$v) { |
|
| 88 | 88 | $this->setParam($k, $v); |
| 89 | 89 | } |
| 90 | 90 | return $this; |
@@ -92,11 +92,11 @@ discard block |
||
| 92 | 92 | |
| 93 | 93 | abstract public function getScript(); |
| 94 | 94 | |
| 95 | - public function setDebug($value){ |
|
| 95 | + public function setDebug($value) { |
|
| 96 | 96 | return $this->setParam("debug", $value); |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | - public function setVerbose($value){ |
|
| 99 | + public function setVerbose($value) { |
|
| 100 | 100 | return $this->setParam("verbose", $value); |
| 101 | 101 | } |
| 102 | 102 | |
@@ -39,8 +39,9 @@ discard block |
||
| 39 | 39 | |
| 40 | 40 | public function getParam($key) { |
| 41 | 41 | $value=null; |
| 42 | - if (array_key_exists($key, $this->params)) |
|
| 43 | - $value=$this->params [$key]; |
|
| 42 | + if (array_key_exists($key, $this->params)) { |
|
| 43 | + $value=$this->params [$key]; |
|
| 44 | + } |
|
| 44 | 45 | return $value; |
| 45 | 46 | } |
| 46 | 47 | |
@@ -49,16 +50,18 @@ discard block |
||
| 49 | 50 | } |
| 50 | 51 | |
| 51 | 52 | public function compile(JsUtils $js=NULL) { |
| 52 | - if ($js==NULL) |
|
| 53 | - $js=$this->js; |
|
| 53 | + if ($js==NULL) { |
|
| 54 | + $js=$this->js; |
|
| 55 | + } |
|
| 54 | 56 | $script=$this->getScript(); |
| 55 | 57 | $js->addToCompile($script); |
| 56 | 58 | } |
| 57 | 59 | |
| 58 | 60 | protected function setParamCtrl($key, $value, $typeCtrl) { |
| 59 | 61 | if (\is_array($typeCtrl)) { |
| 60 | - if (array_search($value, $typeCtrl)===false) |
|
| 61 | - throw new \Exception("La valeur passée a propriété `".$key."` ne fait pas partie des valeurs possibles : {".implode(",", $typeCtrl)."}"); |
|
| 62 | + if (array_search($value, $typeCtrl)===false) { |
|
| 63 | + throw new \Exception("La valeur passée a propriété `".$key."` ne fait pas partie des valeurs possibles : {".implode(",", $typeCtrl)."}"); |
|
| 64 | + } |
|
| 62 | 65 | } else { |
| 63 | 66 | if (!$typeCtrl($value)) { |
| 64 | 67 | throw new \Exception("La fonction ".$typeCtrl." a retourné faux pour l'affectation de la propriété ".$key); |
@@ -71,9 +74,9 @@ discard block |
||
| 71 | 74 | if(\is_array($params)) { |
| 72 | 75 | foreach ($params as $k => $v) { |
| 73 | 76 | $method = "set" . ucfirst($k); |
| 74 | - if (method_exists($this, $method)) |
|
| 75 | - $this->$method($v); |
|
| 76 | - else { |
|
| 77 | + if (method_exists($this, $method)) { |
|
| 78 | + $this->$method($v); |
|
| 79 | + } else { |
|
| 77 | 80 | $this->setParam($k, $v); |
| 78 | 81 | trigger_error("`{$k}` doesn't exists!", E_USER_NOTICE); |
| 79 | 82 | } |
@@ -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 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | |
| 17 | 17 | private $language; |
| 18 | 18 | |
| 19 | - private $style; |
|
| 19 | + private $style; |
|
| 20 | 20 | |
| 21 | 21 | public function __construct($autoCompile=true) { |
| 22 | 22 | parent::__construct($autoCompile); |
@@ -34,25 +34,25 @@ discard block |
||
| 34 | 34 | } |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | - public function compile($internal = false) { |
|
| 38 | - if($this->style!=null){ |
|
| 39 | - parent::compile($internal); |
|
| 40 | - }else { |
|
| 41 | - if ($internal === false && $this->autoCompile === true) |
|
| 42 | - throw new \Exception("Impossible to compile if autoCompile is set to 'true'"); |
|
| 43 | - $style=$this->style; |
|
| 44 | - foreach ($this->components as $component) { |
|
| 45 | - $component->addToProperty("class", $style); |
|
| 46 | - $component->compile(); |
|
| 47 | - } |
|
| 48 | - } |
|
| 49 | - } |
|
| 50 | - |
|
| 51 | - public function setStyle($style='inverted'){ |
|
| 52 | - $this->style=$style; |
|
| 53 | - } |
|
| 54 | - |
|
| 55 | - public function getStyle(){ |
|
| 56 | - return $this->style; |
|
| 57 | - } |
|
| 37 | + public function compile($internal = false) { |
|
| 38 | + if($this->style!=null){ |
|
| 39 | + parent::compile($internal); |
|
| 40 | + }else { |
|
| 41 | + if ($internal === false && $this->autoCompile === true) |
|
| 42 | + throw new \Exception("Impossible to compile if autoCompile is set to 'true'"); |
|
| 43 | + $style=$this->style; |
|
| 44 | + foreach ($this->components as $component) { |
|
| 45 | + $component->addToProperty("class", $style); |
|
| 46 | + $component->compile(); |
|
| 47 | + } |
|
| 48 | + } |
|
| 49 | + } |
|
| 50 | + |
|
| 51 | + public function setStyle($style='inverted'){ |
|
| 52 | + $this->style=$style; |
|
| 53 | + } |
|
| 54 | + |
|
| 55 | + public function getStyle(){ |
|
| 56 | + return $this->style; |
|
| 57 | + } |
|
| 58 | 58 | } |
@@ -11,8 +11,8 @@ discard block |
||
| 11 | 11 | use Ajax\semantic\traits\SemanticWidgetsTrait; |
| 12 | 12 | |
| 13 | 13 | class Semantic extends BaseGui { |
| 14 | - use SemanticComponentsTrait,SemanticHtmlElementsTrait,SemanticHtmlCollectionsTrait, |
|
| 15 | - SemanticHtmlModulesTrait,SemanticHtmlViewsTrait,SemanticWidgetsTrait; |
|
| 14 | + use SemanticComponentsTrait, SemanticHtmlElementsTrait, SemanticHtmlCollectionsTrait, |
|
| 15 | + SemanticHtmlModulesTrait, SemanticHtmlViewsTrait, SemanticWidgetsTrait; |
|
| 16 | 16 | |
| 17 | 17 | private $language; |
| 18 | 18 | |
@@ -23,22 +23,22 @@ discard block |
||
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | |
| 26 | - public function setLanguage($language){ |
|
| 27 | - if($language!==$this->language){ |
|
| 26 | + public function setLanguage($language) { |
|
| 27 | + if ($language!==$this->language) { |
|
| 28 | 28 | $file=\realpath(dirname(__FILE__)."/semantic/components/validation/languages/".$language.".js"); |
| 29 | - if(\file_exists($file)){ |
|
| 29 | + if (\file_exists($file)) { |
|
| 30 | 30 | $script=\file_get_contents($file); |
| 31 | - $this->js->exec($script,true); |
|
| 31 | + $this->js->exec($script, true); |
|
| 32 | 32 | $this->language=$language; |
| 33 | 33 | } |
| 34 | 34 | } |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | - public function compile($internal = false) { |
|
| 38 | - if($this->style!=null){ |
|
| 37 | + public function compile($internal=false) { |
|
| 38 | + if ($this->style!=null) { |
|
| 39 | 39 | parent::compile($internal); |
| 40 | - }else { |
|
| 41 | - if ($internal === false && $this->autoCompile === true) |
|
| 40 | + } else { |
|
| 41 | + if ($internal===false && $this->autoCompile===true) |
|
| 42 | 42 | throw new \Exception("Impossible to compile if autoCompile is set to 'true'"); |
| 43 | 43 | $style=$this->style; |
| 44 | 44 | foreach ($this->components as $component) { |
@@ -48,11 +48,11 @@ discard block |
||
| 48 | 48 | } |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | - public function setStyle($style='inverted'){ |
|
| 51 | + public function setStyle($style='inverted') { |
|
| 52 | 52 | $this->style=$style; |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - public function getStyle(){ |
|
| 55 | + public function getStyle() { |
|
| 56 | 56 | return $this->style; |
| 57 | 57 | } |
| 58 | 58 | } |
@@ -37,9 +37,10 @@ |
||
| 37 | 37 | public function compile($internal = false) { |
| 38 | 38 | if($this->style!=null){ |
| 39 | 39 | parent::compile($internal); |
| 40 | - }else { |
|
| 41 | - if ($internal === false && $this->autoCompile === true) |
|
| 42 | - throw new \Exception("Impossible to compile if autoCompile is set to 'true'"); |
|
| 40 | + } else { |
|
| 41 | + if ($internal === false && $this->autoCompile === true) { |
|
| 42 | + throw new \Exception("Impossible to compile if autoCompile is set to 'true'"); |
|
| 43 | + } |
|
| 43 | 44 | $style=$this->style; |
| 44 | 45 | foreach ($this->components as $component) { |
| 45 | 46 | $component->addToProperty("class", $style); |