@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * @version 1.001 |
8 | 8 | * Generates a JSON field validator |
9 | 9 | */ |
10 | -class FieldValidation implements \JsonSerializable{ |
|
10 | +class FieldValidation implements \JsonSerializable { |
|
11 | 11 | /** |
12 | 12 | * @var string |
13 | 13 | */ |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | |
25 | 25 | protected $optional; |
26 | 26 | |
27 | - public function __construct($identifier){ |
|
27 | + public function __construct($identifier) { |
|
28 | 28 | $this->identifier=$identifier; |
29 | 29 | $this->rules=[]; |
30 | 30 | } |
@@ -42,20 +42,20 @@ discard block |
||
42 | 42 | return $this->rules; |
43 | 43 | } |
44 | 44 | |
45 | - public function addRule($type,$prompt=NULL,$value=NULL){ |
|
46 | - if($type instanceof Rule) |
|
45 | + public function addRule($type, $prompt=NULL, $value=NULL) { |
|
46 | + if ($type instanceof Rule) |
|
47 | 47 | $this->rules[]=$type; |
48 | - else if(\is_array($type)){ |
|
48 | + else if (\is_array($type)) { |
|
49 | 49 | $value=JArray::getValue($type, "value", 2); |
50 | 50 | $prompt=JArray::getValue($type, "prompt", 1); |
51 | 51 | $type=JArray::getValue($type, "type", 0); |
52 | - $this->rules[]=new Rule($type,$prompt,$value); |
|
53 | - }else |
|
54 | - $this->rules[]=new Rule($type,$prompt,$value); |
|
52 | + $this->rules[]=new Rule($type, $prompt, $value); |
|
53 | + } else |
|
54 | + $this->rules[]=new Rule($type, $prompt, $value); |
|
55 | 55 | } |
56 | 56 | |
57 | - public function jsonSerialize(){ |
|
58 | - return ["identifier"=>$this->identifier,"rules"=>$this->rules]; |
|
57 | + public function jsonSerialize() { |
|
58 | + return ["identifier"=>$this->identifier, "rules"=>$this->rules]; |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | public function setDepends($depends) { |
@@ -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 | } |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | * @return HtmlModal |
87 | 87 | */ |
88 | 88 | public function htmlModal($identifier, $header="", $content="", $actions=array()) { |
89 | - return $this->addHtmlComponent(new HtmlModal($identifier, $header,$content,$actions)); |
|
89 | + return $this->addHtmlComponent(new HtmlModal($identifier, $header, $content, $actions)); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
@@ -117,8 +117,8 @@ discard block |
||
117 | 117 | * @param boolean $associative |
118 | 118 | * @return HtmlDropdown |
119 | 119 | */ |
120 | - public function htmlDropdown($identifier, $value="", $items=array(),$associative=true) { |
|
121 | - return $this->addHtmlComponent(new HtmlDropdown($identifier, $value, $items,$associative)); |
|
120 | + public function htmlDropdown($identifier, $value="", $items=array(), $associative=true) { |
|
121 | + return $this->addHtmlComponent(new HtmlDropdown($identifier, $value, $items, $associative)); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | /** |
@@ -6,27 +6,27 @@ discard block |
||
6 | 6 | use Symfony\Component\HttpFoundation\Request; |
7 | 7 | use Symfony\Component\HttpKernel\HttpKernelInterface; |
8 | 8 | use Ajax\service\JString; |
9 | -class JsUtils extends \Ajax\JsUtils{ |
|
10 | - public function getUrl($url){ |
|
9 | +class JsUtils extends \Ajax\JsUtils { |
|
10 | + public function getUrl($url) { |
|
11 | 11 | //$request = Request::createFromGlobals(); |
12 | 12 | $router=$this->getInjected(); |
13 | - if(isset($router)){ |
|
13 | + if (isset($router)) { |
|
14 | 14 | try { |
15 | 15 | $url=$router->generate($url); |
16 | - }catch (\Exception $e){ |
|
16 | + }catch (\Exception $e) { |
|
17 | 17 | return $router->getContext()->getBaseUrl(); |
18 | 18 | } |
19 | 19 | } |
20 | 20 | return $url; |
21 | 21 | } |
22 | - public function addViewElement($identifier,$content,&$view){ |
|
23 | - if(\array_key_exists("q", $view)===false){ |
|
22 | + public function addViewElement($identifier, $content, &$view) { |
|
23 | + if (\array_key_exists("q", $view)===false) { |
|
24 | 24 | $view["q"]=array(); |
25 | 25 | } |
26 | 26 | $view["q"][$identifier]=$content; |
27 | 27 | } |
28 | 28 | |
29 | - public function createScriptVariable(&$view,$view_var, $output){ |
|
29 | + public function createScriptVariable(&$view, $view_var, $output) { |
|
30 | 30 | $view[$view_var]=$output; |
31 | 31 | } |
32 | 32 | |
@@ -37,17 +37,17 @@ discard block |
||
37 | 37 | * @param array $params |
38 | 38 | * @see \Ajax\JsUtils::forward() |
39 | 39 | */ |
40 | - public function forward($initialControllerInstance,$controllerName,$actionName,$params=array()){ |
|
40 | + public function forward($initialControllerInstance, $controllerName, $actionName, $params=array()) { |
|
41 | 41 | $path=$params; |
42 | - $request = $initialControllerInstance->get('request_stack')->getCurrentRequest(); |
|
43 | - $path['_forwarded'] = $request->attributes; |
|
44 | - $path['_controller'] = $controllerName.":".$actionName; |
|
45 | - $subRequest = $request->duplicate([], null, $path); |
|
46 | - $response= $initialControllerInstance->get('http_kernel')->handle($subRequest, HttpKernelInterface::SUB_REQUEST); |
|
42 | + $request=$initialControllerInstance->get('request_stack')->getCurrentRequest(); |
|
43 | + $path['_forwarded']=$request->attributes; |
|
44 | + $path['_controller']=$controllerName.":".$actionName; |
|
45 | + $subRequest=$request->duplicate([], null, $path); |
|
46 | + $response=$initialControllerInstance->get('http_kernel')->handle($subRequest, HttpKernelInterface::SUB_REQUEST); |
|
47 | 47 | return $response->getContent(); |
48 | 48 | } |
49 | 49 | |
50 | - public function renderContent($initialControllerInstance,$viewName, $params=NULL) { |
|
50 | + public function renderContent($initialControllerInstance, $viewName, $params=NULL) { |
|
51 | 51 | if ($initialControllerInstance->has('templating')) { |
52 | 52 | return $initialControllerInstance->get('templating')->render($viewName, $params); |
53 | 53 | } |
@@ -59,10 +59,10 @@ discard block |
||
59 | 59 | return $initialControllerInstance->get('twig')->render($viewName, $params); |
60 | 60 | } |
61 | 61 | |
62 | - public function fromDispatcher($dispatcher){ |
|
63 | - $request = $dispatcher->get('request_stack')->getCurrentRequest(); |
|
62 | + public function fromDispatcher($dispatcher) { |
|
63 | + $request=$dispatcher->get('request_stack')->getCurrentRequest(); |
|
64 | 64 | $uri=$request->getPathInfo(); |
65 | - if(JString::startswith($uri, "/")){ |
|
65 | + if (JString::startswith($uri, "/")) { |
|
66 | 66 | $uri=\substr($uri, 1); |
67 | 67 | } |
68 | 68 | return \explode("/", $uri); |
@@ -9,11 +9,11 @@ discard block |
||
9 | 9 | use Ajax\common\html\HtmlDoubleElement; |
10 | 10 | use Ajax\semantic\html\base\constants\Side; |
11 | 11 | |
12 | -class HtmlStep extends HtmlSemCollection{ |
|
12 | +class HtmlStep extends HtmlSemCollection { |
|
13 | 13 | protected $_activeStep; |
14 | 14 | |
15 | - public function __construct( $identifier,$steps=array()){ |
|
16 | - parent::__construct( $identifier,"div", "ui steps"); |
|
15 | + public function __construct($identifier, $steps=array()) { |
|
16 | + parent::__construct($identifier, "div", "ui steps"); |
|
17 | 17 | $this->addItems($steps); |
18 | 18 | } |
19 | 19 | |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * @see \Ajax\common\html\html5\HtmlCollection::createItem() |
24 | 24 | */ |
25 | 25 | protected function createItem($value) { |
26 | - $itemO=new HtmlStepItem("item-".\sizeof($this->content),$value); |
|
26 | + $itemO=new HtmlStepItem("item-".\sizeof($this->content), $value); |
|
27 | 27 | return $itemO; |
28 | 28 | } |
29 | 29 | |
@@ -31,50 +31,50 @@ discard block |
||
31 | 31 | * @param string|array $step |
32 | 32 | * @return HtmlStepItem |
33 | 33 | */ |
34 | - public function addStep($step){ |
|
34 | + public function addStep($step) { |
|
35 | 35 | return $this->addItem($step); |
36 | 36 | } |
37 | 37 | |
38 | - public function setOrdered(){ |
|
38 | + public function setOrdered() { |
|
39 | 39 | return $this->addToProperty("class", "ordered"); |
40 | 40 | } |
41 | 41 | |
42 | - public function isOrdered(){ |
|
42 | + public function isOrdered() { |
|
43 | 43 | return $this->propertyContains("class", "ordered"); |
44 | 44 | } |
45 | 45 | |
46 | - public function setVertical(){ |
|
46 | + public function setVertical() { |
|
47 | 47 | return $this->addToProperty("class", "vertical"); |
48 | 48 | } |
49 | 49 | |
50 | - protected function defineActiveStep(){ |
|
50 | + protected function defineActiveStep() { |
|
51 | 51 | $activestep=$this->_activeStep; |
52 | 52 | $count=$this->count(); |
53 | - if($this->isOrdered()){ |
|
54 | - for($i=0;$i<$count;$i++){ |
|
53 | + if ($this->isOrdered()) { |
|
54 | + for ($i=0; $i<$count; $i++) { |
|
55 | 55 | $step=$this->content[$i]; |
56 | 56 | $step->removeStatus(); |
57 | - if($i<$activestep) |
|
57 | + if ($i<$activestep) |
|
58 | 58 | $step->setCompleted(); |
59 | 59 | elseif ($i===$activestep) |
60 | 60 | $step->setActive(); |
61 | 61 | else |
62 | 62 | $step->setDisabled(); |
63 | 63 | } |
64 | - }else{ |
|
65 | - foreach ($this->content as $step){ |
|
64 | + } else { |
|
65 | + foreach ($this->content as $step) { |
|
66 | 66 | $step->removeStatus(); |
67 | 67 | } |
68 | - if($activestep<$count) |
|
68 | + if ($activestep<$count) |
|
69 | 69 | $this->content[$activestep]->setActive(); |
70 | 70 | } |
71 | 71 | return $this; |
72 | 72 | } |
73 | 73 | |
74 | 74 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
75 | - if(isset($this->_activeStep) && \is_numeric($this->_activeStep)) |
|
75 | + if (isset($this->_activeStep) && \is_numeric($this->_activeStep)) |
|
76 | 76 | $this->defineActiveStep(); |
77 | - return parent::compile($js,$view); |
|
77 | + return parent::compile($js, $view); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | public function setActiveStep($_activeStep) { |
@@ -82,15 +82,15 @@ discard block |
||
82 | 82 | return $this; |
83 | 83 | } |
84 | 84 | |
85 | - public function setAttached($side="",HtmlDoubleElement $toElement=NULL){ |
|
86 | - if(isset($toElement)){ |
|
87 | - $toElement->addToPropertyCtrl("class", "attached",array("attached")); |
|
85 | + public function setAttached($side="", HtmlDoubleElement $toElement=NULL) { |
|
86 | + if (isset($toElement)) { |
|
87 | + $toElement->addToPropertyCtrl("class", "attached", array("attached")); |
|
88 | 88 | } |
89 | - return $this->addToPropertyCtrl("class", $side." attached",Side::getConstantValues("attached")); |
|
89 | + return $this->addToPropertyCtrl("class", $side." attached", Side::getConstantValues("attached")); |
|
90 | 90 | } |
91 | 91 | |
92 | - public function asLink(){ |
|
93 | - foreach ($this->content as $step){ |
|
92 | + public function asLink() { |
|
93 | + foreach ($this->content as $step) { |
|
94 | 94 | $step->asLink(); |
95 | 95 | } |
96 | 96 | return $this; |
@@ -9,27 +9,27 @@ |
||
9 | 9 | class HtmlMenuItem extends HtmlSemDoubleElement { |
10 | 10 | use MenuItemTrait; |
11 | 11 | public function __construct($identifier, $content) { |
12 | - parent::__construct($identifier,"div","item",$content); |
|
12 | + parent::__construct($identifier, "div", "item", $content); |
|
13 | 13 | } |
14 | 14 | |
15 | - protected function initContent($content){ |
|
16 | - if(\is_array($content)){ |
|
17 | - if(JArray::isAssociative($content)===false){ |
|
15 | + protected function initContent($content) { |
|
16 | + if (\is_array($content)) { |
|
17 | + if (JArray::isAssociative($content)===false) { |
|
18 | 18 | $icon=@$content[0]; |
19 | 19 | $title=@$content[1]; |
20 | 20 | $desc=@$content[2]; |
21 | - }else{ |
|
21 | + } else { |
|
22 | 22 | $icon=@$content["icon"]; |
23 | 23 | $title=@$content["title"]; |
24 | 24 | $desc=@$content["description"]; |
25 | 25 | } |
26 | - if(isset($icon)){ |
|
26 | + if (isset($icon)) { |
|
27 | 27 | $this->addIcon($icon); |
28 | 28 | } |
29 | - if(isset($title)){ |
|
30 | - $this->setTitle($title,$desc); |
|
29 | + if (isset($title)) { |
|
30 | + $this->setTitle($title, $desc); |
|
31 | 31 | } |
32 | - }else{ |
|
32 | + } else { |
|
33 | 33 | $this->setContent($content); |
34 | 34 | } |
35 | 35 | } |
@@ -4,7 +4,7 @@ |
||
4 | 4 | |
5 | 5 | trait HtmlLinkTrait { |
6 | 6 | |
7 | - abstract public function setProperty($name,$value); |
|
7 | + abstract public function setProperty($name, $value); |
|
8 | 8 | abstract public function getProperty($name); |
9 | 9 | |
10 | 10 | public function setHref($value) { |
@@ -14,89 +14,89 @@ |
||
14 | 14 | */ |
15 | 15 | class HtmlGridRow extends HtmlBsDoubleElement { |
16 | 16 | private $cols; |
17 | - public function __construct($identifier,$numCols=NULL){ |
|
18 | - parent::__construct($identifier,"div"); |
|
17 | + public function __construct($identifier, $numCols=NULL) { |
|
18 | + parent::__construct($identifier, "div"); |
|
19 | 19 | $this->setProperty("class", "row"); |
20 | 20 | $this->cols=array(); |
21 | - if(isset($numCols)){ |
|
22 | - $numCols=min(12,$numCols); |
|
23 | - $numCols=max(1,$numCols); |
|
21 | + if (isset($numCols)) { |
|
22 | + $numCols=min(12, $numCols); |
|
23 | + $numCols=max(1, $numCols); |
|
24 | 24 | $width=12/$numCols; |
25 | - for ($i=0;$i<$numCols;$i++){ |
|
26 | - $this->addCol(CssSize::SIZE_MD,$width); |
|
25 | + for ($i=0; $i<$numCols; $i++) { |
|
26 | + $this->addCol(CssSize::SIZE_MD, $width); |
|
27 | 27 | } |
28 | 28 | } |
29 | 29 | } |
30 | 30 | |
31 | - public function addCol($size=CssSize::SIZE_MD,$width=1){ |
|
32 | - $col=new HtmlGridCol($this->identifier."-col-".(sizeof($this->cols)+1),$size,$width); |
|
31 | + public function addCol($size=CssSize::SIZE_MD, $width=1) { |
|
32 | + $col=new HtmlGridCol($this->identifier."-col-".(sizeof($this->cols)+1), $size, $width); |
|
33 | 33 | $this->cols[]=$col; |
34 | 34 | return $col; |
35 | 35 | } |
36 | 36 | |
37 | - public function addColAt($size=CssSize::SIZE_MD,$width=1,$offset=1){ |
|
38 | - $col=$this->addCol($size,$width); |
|
39 | - return $col->setOffset($size, max($offset,sizeof($this->cols)+1)); |
|
37 | + public function addColAt($size=CssSize::SIZE_MD, $width=1, $offset=1) { |
|
38 | + $col=$this->addCol($size, $width); |
|
39 | + return $col->setOffset($size, max($offset, sizeof($this->cols)+1)); |
|
40 | 40 | } |
41 | 41 | |
42 | - public function getCol($index,$force=true){ |
|
42 | + public function getCol($index, $force=true) { |
|
43 | 43 | $result=null; |
44 | - if($index<sizeof($this->cols)+1){ |
|
44 | + if ($index<sizeof($this->cols)+1) { |
|
45 | 45 | $result=$this->cols[$index-1]; |
46 | - }else if ($force){ |
|
47 | - $result=$this->addColAt(CssSize::SIZE_MD,1,$index); |
|
46 | + } else if ($force) { |
|
47 | + $result=$this->addColAt(CssSize::SIZE_MD, 1, $index); |
|
48 | 48 | } |
49 | 49 | return $result; |
50 | 50 | } |
51 | 51 | |
52 | - public function getColAt($offset,$force=true){ |
|
52 | + public function getColAt($offset, $force=true) { |
|
53 | 53 | $result=null; |
54 | - foreach ($this->cols as $col){ |
|
54 | + foreach ($this->cols as $col) { |
|
55 | 55 | $offsets=$col->getOffsets(); |
56 | - if($result=array_search($offset, $offsets)){ |
|
56 | + if ($result=array_search($offset, $offsets)) { |
|
57 | 57 | break; |
58 | 58 | } |
59 | 59 | } |
60 | - if(!$result || isset($result)===false){ |
|
61 | - $result=$this->getCol($offset,$force); |
|
60 | + if (!$result || isset($result)===false) { |
|
61 | + $result=$this->getCol($offset, $force); |
|
62 | 62 | } |
63 | 63 | return $result; |
64 | 64 | } |
65 | 65 | |
66 | 66 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
67 | 67 | |
68 | - foreach ($this->cols as $col){ |
|
68 | + foreach ($this->cols as $col) { |
|
69 | 69 | $this->addContent($col); |
70 | 70 | } |
71 | - return parent::compile($js,$view); |
|
71 | + return parent::compile($js, $view); |
|
72 | 72 | } |
73 | 73 | public function getCols() { |
74 | 74 | return $this->cols; |
75 | 75 | } |
76 | 76 | |
77 | - public function setContentForAll($content){ |
|
78 | - foreach ($this->cols as $col){ |
|
77 | + public function setContentForAll($content) { |
|
78 | + foreach ($this->cols as $col) { |
|
79 | 79 | $col->setContent($content); |
80 | 80 | } |
81 | 81 | } |
82 | - public function merge($size=CssSize::SIZE_MD,$start,$width){ |
|
83 | - $col=$this->getColAt($start,false); |
|
84 | - if(isset($col)){ |
|
85 | - $col->setWidth($size,$width+1); |
|
86 | - $this->delete($size,$start+1, $width); |
|
82 | + public function merge($size=CssSize::SIZE_MD, $start, $width) { |
|
83 | + $col=$this->getColAt($start, false); |
|
84 | + if (isset($col)) { |
|
85 | + $col->setWidth($size, $width+1); |
|
86 | + $this->delete($size, $start+1, $width); |
|
87 | 87 | } |
88 | 88 | } |
89 | - public function delete($size=CssSize::SIZE_MD,$start,$width){ |
|
90 | - while($start<sizeof($this->cols)+1 && $width>0){ |
|
91 | - $col=$this->getColAt($start,false); |
|
92 | - if(isset($col)){ |
|
89 | + public function delete($size=CssSize::SIZE_MD, $start, $width) { |
|
90 | + while ($start<sizeof($this->cols)+1 && $width>0) { |
|
91 | + $col=$this->getColAt($start, false); |
|
92 | + if (isset($col)) { |
|
93 | 93 | $widthCol=$col->getWidth($size); |
94 | - if($widthCol<=$width){ |
|
94 | + if ($widthCol<=$width) { |
|
95 | 95 | unset($this->cols[$start-1]); |
96 | - $this->cols = array_values($this->cols); |
|
96 | + $this->cols=array_values($this->cols); |
|
97 | 97 | $width=$width-$widthCol; |
98 | 98 | } |
99 | - }else{ |
|
99 | + } else { |
|
100 | 100 | $width=0; |
101 | 101 | } |
102 | 102 | } |
@@ -18,14 +18,14 @@ discard block |
||
18 | 18 | } |
19 | 19 | |
20 | 20 | public function setContent($content) { |
21 | - $this->content=new HtmlSemDoubleElement("content-" . $this->identifier, "div", "content", new HtmlSemDoubleElement("", "div", "center", $content)); |
|
21 | + $this->content=new HtmlSemDoubleElement("content-".$this->identifier, "div", "content", new HtmlSemDoubleElement("", "div", "center", $content)); |
|
22 | 22 | return $this; |
23 | 23 | } |
24 | 24 | |
25 | 25 | public function asIcon($icon, $title, $subHeader=NULL) { |
26 | - $header=new HtmlHeader("header-" . $this->identifier); |
|
26 | + $header=new HtmlHeader("header-".$this->identifier); |
|
27 | 27 | $header->asIcon($icon, $title, $subHeader); |
28 | - if ($this->_inverted === false) |
|
28 | + if ($this->_inverted===false) |
|
29 | 29 | $header->setInverted(); |
30 | 30 | return $this->setContent($header); |
31 | 31 | } |
@@ -42,13 +42,13 @@ discard block |
||
42 | 42 | |
43 | 43 | public function run(JsUtils $js) { |
44 | 44 | if ($this->_container instanceof HtmlSingleElement) |
45 | - $this->_bsComponent=$js->semantic()->dimmer("#" . $this->_container->getIdentifier(), $this->_params); |
|
45 | + $this->_bsComponent=$js->semantic()->dimmer("#".$this->_container->getIdentifier(), $this->_params); |
|
46 | 46 | return parent::run($js); |
47 | 47 | } |
48 | 48 | |
49 | 49 | public function jsShow() { |
50 | 50 | if (isset($this->_container)) |
51 | - return '$("#.' . $this->_container->getIdentifier() . ').dimmer("show");'; |
|
51 | + return '$("#.'.$this->_container->getIdentifier().').dimmer("show");'; |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | public function setBlurring() { |