@@ -67,6 +67,9 @@ discard block |
||
67 | 67 | } |
68 | 68 | } |
69 | 69 | |
70 | + /** |
|
71 | + * @param HtmlForm $form |
|
72 | + */ |
|
70 | 73 | protected function _generateFields($form,$values,$headers,$sepFirst,$sepLast,$wrappers){ |
71 | 74 | $wrapper=null; |
72 | 75 | $fields=\array_slice($values, $sepFirst+1,$sepLast-$sepFirst); |
@@ -132,12 +135,20 @@ discard block |
||
132 | 135 | $this->content[$this->_toolbarPosition]=$this->_toolbar; |
133 | 136 | } |
134 | 137 | |
138 | + /** |
|
139 | + * @param integer $index |
|
140 | + * @param string $title |
|
141 | + */ |
|
135 | 142 | public function addDividerBefore($index,$title){ |
136 | 143 | $index=$this->_getIndex($index); |
137 | 144 | $this->_instanceViewer->addHeaderDividerBefore($index, $title); |
138 | 145 | return $this; |
139 | 146 | } |
140 | 147 | |
148 | + /** |
|
149 | + * @param string $index |
|
150 | + * @param string $contentAfter |
|
151 | + */ |
|
141 | 152 | public function addWrapper($index,$contentBefore,$contentAfter=null){ |
142 | 153 | $index=$this->_getIndex($index); |
143 | 154 | $this->_instanceViewer->addWrapper($index, $contentBefore,$contentAfter); |
@@ -19,80 +19,80 @@ discard block |
||
19 | 19 | class DataForm extends Widget { |
20 | 20 | |
21 | 21 | public function __construct($identifier, $modelInstance=NULL) { |
22 | - parent::__construct($identifier, null,$modelInstance); |
|
22 | + parent::__construct($identifier, null, $modelInstance); |
|
23 | 23 | $this->_form=new HtmlForm($identifier); |
24 | 24 | $this->_init(new FormInstanceViewer($identifier), "form", $this->_form, true); |
25 | 25 | } |
26 | 26 | |
27 | - protected function _getFieldIdentifier($prefix,$name=""){ |
|
27 | + protected function _getFieldIdentifier($prefix, $name="") { |
|
28 | 28 | return $this->identifier."-{$name}-".$this->_instanceViewer->getIdentifier(); |
29 | 29 | } |
30 | 30 | |
31 | - public function compile(JsUtils $js=NULL,&$view=NULL){ |
|
32 | - if(!$this->_generated){ |
|
31 | + public function compile(JsUtils $js=NULL, &$view=NULL) { |
|
32 | + if (!$this->_generated) { |
|
33 | 33 | $this->_instanceViewer->setInstance($this->_modelInstance); |
34 | 34 | |
35 | 35 | $form=$this->content["form"]; |
36 | 36 | $this->_generateContent($form); |
37 | 37 | |
38 | - if(isset($this->_toolbar)){ |
|
38 | + if (isset($this->_toolbar)) { |
|
39 | 39 | $this->_setToolbarPosition($form); |
40 | 40 | } |
41 | - $this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE,"form",PositionInTable::AFTERTABLE]); |
|
41 | + $this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE, "form", PositionInTable::AFTERTABLE]); |
|
42 | 42 | $this->_generated=true; |
43 | 43 | } |
44 | - return parent::compile($js,$view); |
|
44 | + return parent::compile($js, $view); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | /** |
48 | 48 | * @param HtmlForm $form |
49 | 49 | */ |
50 | - protected function _generateContent($form){ |
|
51 | - $values= $this->_instanceViewer->getValues(); |
|
50 | + protected function _generateContent($form) { |
|
51 | + $values=$this->_instanceViewer->getValues(); |
|
52 | 52 | $count=$this->_instanceViewer->count(); |
53 | 53 | $separators=$this->_instanceViewer->getSeparators(); |
54 | 54 | $headers=$this->_instanceViewer->getHeaders(); |
55 | 55 | $wrappers=$this->_instanceViewer->getWrappers(); |
56 | 56 | \sort($separators); |
57 | 57 | $size=\sizeof($separators); |
58 | - if($size===1){ |
|
59 | - foreach ($values as $v){ |
|
58 | + if ($size===1) { |
|
59 | + foreach ($values as $v) { |
|
60 | 60 | $form->addField($v); |
61 | 61 | } |
62 | - }else{ |
|
62 | + } else { |
|
63 | 63 | $separators[]=$count; |
64 | - for($i=0;$i<$size;$i++){ |
|
64 | + for ($i=0; $i<$size; $i++) { |
|
65 | 65 | $this->_generateFields($form, $values, $headers, $separators[$i], $separators[$i+1], $wrappers); |
66 | 66 | } |
67 | 67 | } |
68 | 68 | } |
69 | 69 | |
70 | - protected function _generateFields($form,$values,$headers,$sepFirst,$sepLast,$wrappers){ |
|
70 | + protected function _generateFields($form, $values, $headers, $sepFirst, $sepLast, $wrappers) { |
|
71 | 71 | $wrapper=null; |
72 | - $fields=\array_slice($values, $sepFirst+1,$sepLast-$sepFirst); |
|
73 | - if(isset($headers[$sepFirst+1])) |
|
74 | - $form->addHeader($headers[$sepFirst+1],4,true); |
|
75 | - if(isset($wrappers[$sepFirst+1])){ |
|
72 | + $fields=\array_slice($values, $sepFirst+1, $sepLast-$sepFirst); |
|
73 | + if (isset($headers[$sepFirst+1])) |
|
74 | + $form->addHeader($headers[$sepFirst+1], 4, true); |
|
75 | + if (isset($wrappers[$sepFirst+1])) { |
|
76 | 76 | $wrapper=$wrappers[$sepFirst+1]; |
77 | 77 | } |
78 | - if(\sizeof($fields)===1){ |
|
78 | + if (\sizeof($fields)===1) { |
|
79 | 79 | $added=$form->addField($fields[0]); |
80 | - }elseif(\sizeof($fields)>1){ |
|
80 | + }elseif (\sizeof($fields)>1) { |
|
81 | 81 | $added=$form->addFields($fields); |
82 | 82 | } |
83 | - if(isset($wrapper)) |
|
84 | - $added->wrap($wrapper[0],$wrapper[1]); |
|
83 | + if (isset($wrapper)) |
|
84 | + $added->wrap($wrapper[0], $wrapper[1]); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | /** |
88 | 88 | * {@inheritDoc} |
89 | 89 | * @see \Ajax\common\Widget::getForm() |
90 | 90 | */ |
91 | - public function getForm(){ |
|
91 | + public function getForm() { |
|
92 | 92 | return $this->content["form"]; |
93 | 93 | } |
94 | 94 | |
95 | - public function addSeparatorAfter($fieldNum){ |
|
95 | + public function addSeparatorAfter($fieldNum) { |
|
96 | 96 | $fieldNum=$this->_getIndex($fieldNum); |
97 | 97 | $this->_instanceViewer->addSeparatorAfter($fieldNum); |
98 | 98 | return $this; |
@@ -107,12 +107,12 @@ discard block |
||
107 | 107 | return $this; |
108 | 108 | } |
109 | 109 | |
110 | - public function fieldAsReset($index,$cssStyle=NULL,$attributes=NULL){ |
|
111 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($cssStyle){ |
|
112 | - $button=new HtmlButton($id,$value,$cssStyle); |
|
110 | + public function fieldAsReset($index, $cssStyle=NULL, $attributes=NULL) { |
|
111 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($cssStyle){ |
|
112 | + $button=new HtmlButton($id, $value, $cssStyle); |
|
113 | 113 | $button->setProperty("type", "reset"); |
114 | 114 | return $button; |
115 | - }, $index,$attributes); |
|
115 | + }, $index, $attributes); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | /** |
@@ -131,19 +131,19 @@ discard block |
||
131 | 131 | $this->content[$this->_toolbarPosition]=$this->_toolbar; |
132 | 132 | } |
133 | 133 | |
134 | - public function addDividerBefore($index,$title){ |
|
134 | + public function addDividerBefore($index, $title) { |
|
135 | 135 | $index=$this->_getIndex($index); |
136 | 136 | $this->_instanceViewer->addHeaderDividerBefore($index, $title); |
137 | 137 | return $this; |
138 | 138 | } |
139 | 139 | |
140 | - public function addWrapper($index,$contentBefore,$contentAfter=null){ |
|
140 | + public function addWrapper($index, $contentBefore, $contentAfter=null) { |
|
141 | 141 | $index=$this->_getIndex($index); |
142 | - $this->_instanceViewer->addWrapper($index, $contentBefore,$contentAfter); |
|
142 | + $this->_instanceViewer->addWrapper($index, $contentBefore, $contentAfter); |
|
143 | 143 | return $this; |
144 | 144 | } |
145 | 145 | |
146 | - public function run(JsUtils $js){ |
|
146 | + public function run(JsUtils $js) { |
|
147 | 147 | return parent::run($js); |
148 | 148 | } |
149 | 149 | } |
150 | 150 | \ No newline at end of file |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | foreach ($values as $v){ |
60 | 60 | $form->addField($v); |
61 | 61 | } |
62 | - }else{ |
|
62 | + } else{ |
|
63 | 63 | $separators[]=$count; |
64 | 64 | for($i=0;$i<$size;$i++){ |
65 | 65 | $this->_generateFields($form, $values, $headers, $separators[$i], $separators[$i+1], $wrappers); |
@@ -70,18 +70,20 @@ discard block |
||
70 | 70 | protected function _generateFields($form,$values,$headers,$sepFirst,$sepLast,$wrappers){ |
71 | 71 | $wrapper=null; |
72 | 72 | $fields=\array_slice($values, $sepFirst+1,$sepLast-$sepFirst); |
73 | - if(isset($headers[$sepFirst+1])) |
|
74 | - $form->addHeader($headers[$sepFirst+1],4,true); |
|
73 | + if(isset($headers[$sepFirst+1])) { |
|
74 | + $form->addHeader($headers[$sepFirst+1],4,true); |
|
75 | + } |
|
75 | 76 | if(isset($wrappers[$sepFirst+1])){ |
76 | 77 | $wrapper=$wrappers[$sepFirst+1]; |
77 | 78 | } |
78 | 79 | if(\sizeof($fields)===1){ |
79 | 80 | $added=$form->addField($fields[0]); |
80 | - }elseif(\sizeof($fields)>1){ |
|
81 | + } elseif(\sizeof($fields)>1){ |
|
81 | 82 | $added=$form->addFields($fields); |
82 | 83 | } |
83 | - if(isset($wrapper)) |
|
84 | - $added->wrap($wrapper[0],$wrapper[1]); |
|
84 | + if(isset($wrapper)) { |
|
85 | + $added->wrap($wrapper[0],$wrapper[1]); |
|
86 | + } |
|
85 | 87 | } |
86 | 88 | |
87 | 89 | /** |
@@ -21,7 +21,7 @@ |
||
21 | 21 | if($class->getProperty($property)!==null){ |
22 | 22 | \call_user_func_array([$object,$name],[$value]); |
23 | 23 | } |
24 | - }catch(\Exception $e){ |
|
24 | + } catch(\Exception $e){ |
|
25 | 25 | //Nothing to do |
26 | 26 | } |
27 | 27 | } |
@@ -3,25 +3,25 @@ discard block |
||
3 | 3 | namespace Ajax\service; |
4 | 4 | |
5 | 5 | class JReflection { |
6 | - public static function shortClassName($object){ |
|
7 | - $classNameWithNamespace = get_class($object); |
|
6 | + public static function shortClassName($object) { |
|
7 | + $classNameWithNamespace=get_class($object); |
|
8 | 8 | return substr($classNameWithNamespace, strrpos($classNameWithNamespace, '\\')+1); |
9 | 9 | } |
10 | 10 | |
11 | - public static function jsonObject($classname){ |
|
11 | + public static function jsonObject($classname) { |
|
12 | 12 | $object=new $classname(); |
13 | - $class = new \ReflectionClass($classname); |
|
13 | + $class=new \ReflectionClass($classname); |
|
14 | 14 | $methods=$class->getMethods(\ReflectionMethod::IS_PUBLIC); |
15 | - foreach ($methods as $method){ |
|
15 | + foreach ($methods as $method) { |
|
16 | 16 | $name=$method->getName(); |
17 | - if(JString::startswith($name, "set")){ |
|
17 | + if (JString::startswith($name, "set")) { |
|
18 | 18 | $property=\lcfirst(JString::replaceAtFirst($name, "set", "")); |
19 | 19 | $value="__".$property."__"; |
20 | - try{ |
|
21 | - if($class->getProperty($property)!==null){ |
|
22 | - \call_user_func_array([$object,$name],[$value]); |
|
20 | + try { |
|
21 | + if ($class->getProperty($property)!==null) { |
|
22 | + \call_user_func_array([$object, $name], [$value]); |
|
23 | 23 | } |
24 | - }catch(\Exception $e){ |
|
24 | + }catch (\Exception $e) { |
|
25 | 25 | //Nothing to do |
26 | 26 | } |
27 | 27 | } |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | return $object; |
30 | 30 | } |
31 | 31 | |
32 | - public static function callMethod($object,$callback,array $values){ |
|
33 | - return \call_user_func_array([$object,$callback],$values); |
|
32 | + public static function callMethod($object, $callback, array $values) { |
|
33 | + return \call_user_func_array([$object, $callback], $values); |
|
34 | 34 | } |
35 | 35 | } |
36 | 36 | \ No newline at end of file |
@@ -10,10 +10,10 @@ discard block |
||
10 | 10 | class HtmlLink extends HtmlSemDoubleElement { |
11 | 11 | use HtmlLinkTrait; |
12 | 12 | |
13 | - public function __construct($identifier, $href="#", $content="Link",$target=NULL) { |
|
13 | + public function __construct($identifier, $href="#", $content="Link", $target=NULL) { |
|
14 | 14 | parent::__construct($identifier, "a", ""); |
15 | 15 | $this->setHref($href); |
16 | - if(isset($target)) |
|
16 | + if (isset($target)) |
|
17 | 17 | $this->setTarget($target); |
18 | 18 | $this->content=$content; |
19 | 19 | } |
@@ -23,13 +23,13 @@ discard block |
||
23 | 23 | * @see \Ajax\bootstrap\html\base\HtmlSingleElement::run() |
24 | 24 | */ |
25 | 25 | public function run(JsUtils $js) { |
26 | - $this->_bsComponent=$js->semantic()->generic("#" . $this->identifier); |
|
26 | + $this->_bsComponent=$js->semantic()->generic("#".$this->identifier); |
|
27 | 27 | $this->addEventsOnRun($js); |
28 | 28 | return $this->_bsComponent; |
29 | 29 | } |
30 | 30 | |
31 | 31 | public function addIcon($icon, $before=true) { |
32 | - return $this->addContent(new HtmlIcon("icon-" . $this->identifier, $icon), $before); |
|
32 | + return $this->addContent(new HtmlIcon("icon-".$this->identifier, $icon), $before); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | public static function icon($identifier, $icon, $href="#", $label=NULL) { |
@@ -13,8 +13,9 @@ |
||
13 | 13 | public function __construct($identifier, $href="#", $content="Link",$target=NULL) { |
14 | 14 | parent::__construct($identifier, "a", ""); |
15 | 15 | $this->setHref($href); |
16 | - if(isset($target)) |
|
17 | - $this->setTarget($target); |
|
16 | + if(isset($target)) { |
|
17 | + $this->setTarget($target); |
|
18 | + } |
|
18 | 19 | $this->content=$content; |
19 | 20 | } |
20 | 21 |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | * @return \Ajax\semantic\html\HtmlIcon |
69 | 69 | */ |
70 | 70 | public function setFlipped($sens="horizontally") { |
71 | - return $this->addToProperty("class", "flipped " . $sens); |
|
71 | + return $this->addToProperty("class", "flipped ".$sens); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | * @return \Ajax\semantic\html\HtmlIcon |
78 | 78 | */ |
79 | 79 | public function setRotated($sens="clockwise") { |
80 | - return $this->addToProperty("class", "rotated " . $sens); |
|
80 | + return $this->addToProperty("class", "rotated ".$sens); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | /** |
@@ -86,12 +86,12 @@ discard block |
||
86 | 86 | * @param string target |
87 | 87 | * @return HtmlIcon |
88 | 88 | */ |
89 | - public function asLink($href=NULL,$target=NULL) { |
|
89 | + public function asLink($href=NULL, $target=NULL) { |
|
90 | 90 | if (isset($href)) { |
91 | 91 | $_target=""; |
92 | - if(isset($target)) |
|
92 | + if (isset($target)) |
|
93 | 93 | $_target="target='{$target}'"; |
94 | - $this->wrap("<a href='" . $href . "' {$_target}>", "</a>"); |
|
94 | + $this->wrap("<a href='".$href."' {$_target}>", "</a>"); |
|
95 | 95 | } |
96 | 96 | return $this->addToProperty("class", "link"); |
97 | 97 | } |
@@ -107,9 +107,9 @@ discard block |
||
107 | 107 | */ |
108 | 108 | public function setBordered($inverted=false) { |
109 | 109 | $invertedStr=""; |
110 | - if ($inverted !== false) |
|
110 | + if ($inverted!==false) |
|
111 | 111 | $invertedStr=" inverted"; |
112 | - return $this->addToProperty("class", "bordered" . $invertedStr); |
|
112 | + return $this->addToProperty("class", "bordered".$invertedStr); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | /** |
@@ -121,11 +121,11 @@ discard block |
||
121 | 121 | } |
122 | 122 | |
123 | 123 | public function addLabel($label, $before=false, $icon=NULL) { |
124 | - if($before) |
|
124 | + if ($before) |
|
125 | 125 | $this->wrap($label); |
126 | 126 | else |
127 | 127 | $this->wrap("", $label); |
128 | - if(isset($icon)) |
|
128 | + if (isset($icon)) |
|
129 | 129 | $this->addToIcon($icon); |
130 | 130 | return $this; |
131 | 131 | } |
@@ -89,8 +89,9 @@ discard block |
||
89 | 89 | public function asLink($href=NULL,$target=NULL) { |
90 | 90 | if (isset($href)) { |
91 | 91 | $_target=""; |
92 | - if(isset($target)) |
|
93 | - $_target="target='{$target}'"; |
|
92 | + if(isset($target)) { |
|
93 | + $_target="target='{$target}'"; |
|
94 | + } |
|
94 | 95 | $this->wrap("<a href='" . $href . "' {$_target}>", "</a>"); |
95 | 96 | } |
96 | 97 | return $this->addToProperty("class", "link"); |
@@ -107,8 +108,9 @@ discard block |
||
107 | 108 | */ |
108 | 109 | public function setBordered($inverted=false) { |
109 | 110 | $invertedStr=""; |
110 | - if ($inverted !== false) |
|
111 | - $invertedStr=" inverted"; |
|
111 | + if ($inverted !== false) { |
|
112 | + $invertedStr=" inverted"; |
|
113 | + } |
|
112 | 114 | return $this->addToProperty("class", "bordered" . $invertedStr); |
113 | 115 | } |
114 | 116 | |
@@ -121,12 +123,14 @@ discard block |
||
121 | 123 | } |
122 | 124 | |
123 | 125 | public function addLabel($label, $before=false, $icon=NULL) { |
124 | - if($before) |
|
125 | - $this->wrap($label); |
|
126 | - else |
|
127 | - $this->wrap("", $label); |
|
128 | - if(isset($icon)) |
|
129 | - $this->addToIcon($icon); |
|
126 | + if($before) { |
|
127 | + $this->wrap($label); |
|
128 | + } else { |
|
129 | + $this->wrap("", $label); |
|
130 | + } |
|
131 | + if(isset($icon)) { |
|
132 | + $this->addToIcon($icon); |
|
133 | + } |
|
130 | 134 | return $this; |
131 | 135 | } |
132 | 136 |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | } |
57 | 57 | |
58 | 58 | public function setFocusable($value=true) { |
59 | - if ($value === true) |
|
59 | + if ($value===true) |
|
60 | 60 | $this->setProperty("tabindex", "0"); |
61 | 61 | else { |
62 | 62 | $this->removeProperty("tabindex"); |
@@ -66,14 +66,14 @@ discard block |
||
66 | 66 | |
67 | 67 | public function setAnimated($content, $animation="") { |
68 | 68 | $this->setTagName("div"); |
69 | - $this->addToProperty("class", "animated " . $animation); |
|
70 | - $visible=new HtmlSemDoubleElement("visible-" . $this->identifier, "div"); |
|
69 | + $this->addToProperty("class", "animated ".$animation); |
|
70 | + $visible=new HtmlSemDoubleElement("visible-".$this->identifier, "div"); |
|
71 | 71 | $visible->setClass("visible content"); |
72 | 72 | $visible->setContent($this->content); |
73 | - $hidden=new HtmlSemDoubleElement("hidden-" . $this->identifier, "div"); |
|
73 | + $hidden=new HtmlSemDoubleElement("hidden-".$this->identifier, "div"); |
|
74 | 74 | $hidden->setClass("hidden content"); |
75 | 75 | $hidden->setContent($content); |
76 | - $this->content=array ($visible,$hidden ); |
|
76 | + $this->content=array($visible, $hidden); |
|
77 | 77 | return $hidden; |
78 | 78 | } |
79 | 79 | |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | public function asIcon($icon) { |
86 | 86 | $iconO=$icon; |
87 | 87 | if (\is_string($icon)) { |
88 | - $iconO=new HtmlIcon("icon-" . $this->identifier, $icon); |
|
88 | + $iconO=new HtmlIcon("icon-".$this->identifier, $icon); |
|
89 | 89 | } |
90 | 90 | $this->addToProperty("class", "icon"); |
91 | 91 | $this->content=$iconO; |
@@ -107,9 +107,9 @@ discard block |
||
107 | 107 | public function addLabel($label, $before=false, $icon=NULL) { |
108 | 108 | $this->tagName="div"; |
109 | 109 | $this->addToProperty("class", "labeled"); |
110 | - $this->content=new HtmlButton("button-" . $this->identifier, $this->content); |
|
110 | + $this->content=new HtmlButton("button-".$this->identifier, $this->content); |
|
111 | 111 | $this->content->setTagName("div"); |
112 | - $label=new HtmlLabel("label-" . $this->identifier, $label, $icon,"a"); |
|
112 | + $label=new HtmlLabel("label-".$this->identifier, $label, $icon, "a"); |
|
113 | 113 | $label->setBasic(); |
114 | 114 | $this->addContent($label, $before); |
115 | 115 | return $label; |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | */ |
122 | 122 | public function fromArray($array) { |
123 | 123 | $array=parent::fromArray($array); |
124 | - foreach ( $array as $key => $value ) { |
|
124 | + foreach ($array as $key => $value) { |
|
125 | 125 | $this->setProperty($key, $value); |
126 | 126 | } |
127 | 127 | return $array; |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | * @return HtmlButton |
185 | 185 | */ |
186 | 186 | public static function social($identifier, $social, $value=NULL) { |
187 | - if ($value === NULL) |
|
187 | + if ($value===NULL) |
|
188 | 188 | $value=\ucfirst($social); |
189 | 189 | $return=new HtmlButton($identifier, $value); |
190 | 190 | $return->addIcon($social); |
@@ -221,8 +221,8 @@ discard block |
||
221 | 221 | * {@inheritDoc} |
222 | 222 | * @see HtmlSemDoubleElement::asLink() |
223 | 223 | */ |
224 | - public function asLink($href=NULL,$target=NULL) { |
|
225 | - $lnk=new HtmlLink("lnk-".$this->identifier,$href,$this->content,$target); |
|
224 | + public function asLink($href=NULL, $target=NULL) { |
|
225 | + $lnk=new HtmlLink("lnk-".$this->identifier, $href, $this->content, $target); |
|
226 | 226 | $this->content=$lnk; |
227 | 227 | return $this; |
228 | 228 | } |
@@ -56,9 +56,9 @@ discard block |
||
56 | 56 | } |
57 | 57 | |
58 | 58 | public function setFocusable($value=true) { |
59 | - if ($value === true) |
|
60 | - $this->setProperty("tabindex", "0"); |
|
61 | - else { |
|
59 | + if ($value === true) { |
|
60 | + $this->setProperty("tabindex", "0"); |
|
61 | + } else { |
|
62 | 62 | $this->removeProperty("tabindex"); |
63 | 63 | } |
64 | 64 | return $this; |
@@ -184,8 +184,9 @@ discard block |
||
184 | 184 | * @return HtmlButton |
185 | 185 | */ |
186 | 186 | public static function social($identifier, $social, $value=NULL) { |
187 | - if ($value === NULL) |
|
188 | - $value=\ucfirst($social); |
|
187 | + if ($value === NULL) { |
|
188 | + $value=\ucfirst($social); |
|
189 | + } |
|
189 | 190 | $return=new HtmlButton($identifier, $value); |
190 | 191 | $return->addIcon($social); |
191 | 192 | return $return->addToPropertyCtrl("class", $social, Social::getConstants()); |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | use BaseTrait; |
23 | 23 | protected $_popup=NULL; |
24 | 24 | protected $_dimmer=NULL; |
25 | - protected $_params=array (); |
|
25 | + protected $_params=array(); |
|
26 | 26 | |
27 | 27 | |
28 | 28 | public function __construct($identifier, $tagName="p", $baseClass="ui", $content=NULL) { |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | * @return HtmlDimmer |
79 | 79 | */ |
80 | 80 | public function addDimmer($params=array(), $content=NULL) { |
81 | - $dimmer=new HtmlDimmer("dimmer-" . $this->identifier, $content); |
|
81 | + $dimmer=new HtmlDimmer("dimmer-".$this->identifier, $content); |
|
82 | 82 | $dimmer->setParams($params); |
83 | 83 | $dimmer->setContainer($this); |
84 | 84 | $this->addContent($dimmer); |
@@ -94,12 +94,12 @@ discard block |
||
94 | 94 | */ |
95 | 95 | public function addLabel($label, $before=false, $icon=NULL) { |
96 | 96 | $labelO=$label; |
97 | - if (\is_object($label) === false) { |
|
98 | - $labelO=new HtmlLabel("label-" . $this->identifier, $label); |
|
97 | + if (\is_object($label)===false) { |
|
98 | + $labelO=new HtmlLabel("label-".$this->identifier, $label); |
|
99 | 99 | if (isset($icon)) |
100 | 100 | $labelO->addIcon($icon); |
101 | 101 | } else { |
102 | - $labelO->addToPropertyCtrl("class", "label", array ("label" )); |
|
102 | + $labelO->addToPropertyCtrl("class", "label", array("label")); |
|
103 | 103 | } |
104 | 104 | $this->addContent($labelO, $before); |
105 | 105 | return $labelO; |
@@ -113,9 +113,9 @@ discard block |
||
113 | 113 | * @param string $icon |
114 | 114 | * @return HtmlSemDoubleElement |
115 | 115 | */ |
116 | - public function attachLabel($label,$side=Side::TOP,$direction=Direction::NONE,$icon=NULL){ |
|
117 | - $label=$this->addLabel($label,true,$icon); |
|
118 | - $label->setAttached($side,$direction); |
|
116 | + public function attachLabel($label, $side=Side::TOP, $direction=Direction::NONE, $icon=NULL) { |
|
117 | + $label=$this->addLabel($label, true, $icon); |
|
118 | + $label->setAttached($side, $direction); |
|
119 | 119 | return $this; |
120 | 120 | } |
121 | 121 | |
@@ -123,10 +123,10 @@ discard block |
||
123 | 123 | * Transforms the element into a link |
124 | 124 | * @return HtmlSemDoubleElement |
125 | 125 | */ |
126 | - public function asLink($href=NULL,$target=NULL) { |
|
126 | + public function asLink($href=NULL, $target=NULL) { |
|
127 | 127 | if (isset($href)) |
128 | 128 | $this->setProperty("href", $href); |
129 | - if(isset($target)) |
|
129 | + if (isset($target)) |
|
130 | 130 | $this->setProperty("target", $target); |
131 | 131 | return $this->setTagName("a"); |
132 | 132 | } |
@@ -138,9 +138,9 @@ discard block |
||
138 | 138 | */ |
139 | 139 | public function jsShowDimmer($show=true) { |
140 | 140 | $status="hide"; |
141 | - if ($show === true) |
|
141 | + if ($show===true) |
|
142 | 142 | $status="show"; |
143 | - return '$("#.' . $this->identifier . ').dimmer("' . $status . '");'; |
|
143 | + return '$("#.'.$this->identifier.').dimmer("'.$status.'");'; |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | /** |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | * @see HtmlDoubleElement::run() |
159 | 159 | */ |
160 | 160 | public function run(JsUtils $js) { |
161 | - $this->_bsComponent=$js->semantic()->generic("#" . $this->identifier); |
|
161 | + $this->_bsComponent=$js->semantic()->generic("#".$this->identifier); |
|
162 | 162 | parent::run($js); |
163 | 163 | $this->addEventsOnRun($js); |
164 | 164 | if (isset($this->_popup)) { |
@@ -40,8 +40,9 @@ discard block |
||
40 | 40 | * @param string $popupEvent |
41 | 41 | */ |
42 | 42 | public function setPopupAttributes($variation=NULL, $popupEvent=NULL) { |
43 | - if (isset($this->_popup)) |
|
44 | - $this->_popup->setAttributes($variation, $popupEvent); |
|
43 | + if (isset($this->_popup)) { |
|
44 | + $this->_popup->setAttributes($variation, $popupEvent); |
|
45 | + } |
|
45 | 46 | } |
46 | 47 | |
47 | 48 | /** |
@@ -96,8 +97,9 @@ discard block |
||
96 | 97 | $labelO=$label; |
97 | 98 | if (\is_object($label) === false) { |
98 | 99 | $labelO=new HtmlLabel("label-" . $this->identifier, $label); |
99 | - if (isset($icon)) |
|
100 | - $labelO->addIcon($icon); |
|
100 | + if (isset($icon)) { |
|
101 | + $labelO->addIcon($icon); |
|
102 | + } |
|
101 | 103 | } else { |
102 | 104 | $labelO->addToPropertyCtrl("class", "label", array ("label" )); |
103 | 105 | } |
@@ -124,10 +126,12 @@ discard block |
||
124 | 126 | * @return HtmlSemDoubleElement |
125 | 127 | */ |
126 | 128 | public function asLink($href=NULL,$target=NULL) { |
127 | - if (isset($href)) |
|
128 | - $this->setProperty("href", $href); |
|
129 | - if(isset($target)) |
|
130 | - $this->setProperty("target", $target); |
|
129 | + if (isset($href)) { |
|
130 | + $this->setProperty("href", $href); |
|
131 | + } |
|
132 | + if(isset($target)) { |
|
133 | + $this->setProperty("target", $target); |
|
134 | + } |
|
131 | 135 | return $this->setTagName("a"); |
132 | 136 | } |
133 | 137 | |
@@ -138,8 +142,9 @@ discard block |
||
138 | 142 | */ |
139 | 143 | public function jsShowDimmer($show=true) { |
140 | 144 | $status="hide"; |
141 | - if ($show === true) |
|
142 | - $status="show"; |
|
145 | + if ($show === true) { |
|
146 | + $status="show"; |
|
147 | + } |
|
143 | 148 | return '$("#.' . $this->identifier . ').dimmer("' . $status . '");'; |
144 | 149 | } |
145 | 150 | |
@@ -148,8 +153,9 @@ discard block |
||
148 | 153 | * @see BaseHtml::compile() |
149 | 154 | */ |
150 | 155 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
151 | - if (isset($this->_popup)) |
|
152 | - $this->_popup->compile($js); |
|
156 | + if (isset($this->_popup)) { |
|
157 | + $this->_popup->compile($js); |
|
158 | + } |
|
153 | 159 | return parent::compile($js, $view); |
154 | 160 | } |
155 | 161 |
@@ -17,19 +17,19 @@ discard block |
||
17 | 17 | class HtmlCard extends HtmlSemDoubleElement { |
18 | 18 | |
19 | 19 | public function __construct($identifier) { |
20 | - parent::__construct($identifier, "div", "ui card", array ()); |
|
20 | + parent::__construct($identifier, "div", "ui card", array()); |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | private function createContent($content, $baseClass="content") { |
24 | 24 | $count=\sizeof($this->content); |
25 | - $result=new HtmlCardContent("content-" . $count . "-" . $this->identifier, $content); |
|
25 | + $result=new HtmlCardContent("content-".$count."-".$this->identifier, $content); |
|
26 | 26 | $result->setClass($baseClass); |
27 | 27 | return $result; |
28 | 28 | } |
29 | 29 | |
30 | 30 | private function addElementInContent($key, $element) { |
31 | - if (\array_key_exists($key, $this->content) === false) { |
|
32 | - $this->content[$key]=array (); |
|
31 | + if (\array_key_exists($key, $this->content)===false) { |
|
32 | + $this->content[$key]=array(); |
|
33 | 33 | } |
34 | 34 | $this->content[$key][]=$element; |
35 | 35 | return $element; |
@@ -46,14 +46,14 @@ discard block |
||
46 | 46 | |
47 | 47 | public function addHeader($header, $niveau=4, $type="page") { |
48 | 48 | if (!$header instanceof HtmlHeader) { |
49 | - $header=new HtmlHeader("header-" . $this->identifier, $niveau, $header, $type); |
|
49 | + $header=new HtmlHeader("header-".$this->identifier, $niveau, $header, $type); |
|
50 | 50 | } |
51 | 51 | $this->content["header"]=$this->createContent($header); |
52 | 52 | } |
53 | 53 | |
54 | 54 | public function addImage($image, $title="") { |
55 | 55 | if (!$image instanceof HtmlImage) { |
56 | - $image=new HtmlImage("image-" . $this->identifier, $image, $title); |
|
56 | + $image=new HtmlImage("image-".$this->identifier, $image, $title); |
|
57 | 57 | } |
58 | 58 | $image->setClass("image"); |
59 | 59 | return $this->addElementInContent("content", $image); |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | public function addReveal($visibleContent, $hiddenContent=NULL, $type=RevealType::FADE, $attributeType=NULL) { |
63 | 63 | $reveal=$visibleContent; |
64 | 64 | if (!$visibleContent instanceof HtmlReveal) { |
65 | - $reveal=new HtmlReveal("reveral-" . $this->identifier, $visibleContent, $hiddenContent, $type, $attributeType); |
|
65 | + $reveal=new HtmlReveal("reveral-".$this->identifier, $visibleContent, $hiddenContent, $type, $attributeType); |
|
66 | 66 | } |
67 | 67 | return $this->addElementInContent("content", $reveal); |
68 | 68 | } |
@@ -91,8 +91,8 @@ discard block |
||
91 | 91 | * @param boolean $asIcons |
92 | 92 | * @return \Ajax\semantic\html\elements\HtmlButtonGroups |
93 | 93 | */ |
94 | - public function addButtons($elements=array(), $asIcons=false){ |
|
95 | - $buttons=new HtmlButtonGroups("buttons-".$this->identifier,$elements,$asIcons); |
|
94 | + public function addButtons($elements=array(), $asIcons=false) { |
|
95 | + $buttons=new HtmlButtonGroups("buttons-".$this->identifier, $elements, $asIcons); |
|
96 | 96 | $this->addElementInContent("content", $buttons); |
97 | 97 | return $buttons; |
98 | 98 | } |
@@ -101,12 +101,12 @@ discard block |
||
101 | 101 | |
102 | 102 | public function addCardHeaderContent($header, $metas=array(), $description=NULL) { |
103 | 103 | $count=\sizeof($this->content); |
104 | - return $this->addElementInContent("content", new HtmlCardHeaderContent("content-" . $count . "-" . $this->identifier, $header, $metas, $description)); |
|
104 | + return $this->addElementInContent("content", new HtmlCardHeaderContent("content-".$count."-".$this->identifier, $header, $metas, $description)); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | public function addCardContent($content=array()) { |
108 | 108 | $count=\sizeof($this->content); |
109 | - return $this->addElementInContent("content", new HtmlCardContent("content-" . $count . "-" . $this->identifier, $content)); |
|
109 | + return $this->addElementInContent("content", new HtmlCardContent("content-".$count."-".$this->identifier, $content)); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | public function getCardContent($index=NULL) { |
@@ -132,13 +132,13 @@ discard block |
||
132 | 132 | * @see HtmlSemDoubleElement::compile() |
133 | 133 | */ |
134 | 134 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
135 | - $this->content=JArray::sortAssociative($this->content, [ "header","image","content","extra-content" ]); |
|
135 | + $this->content=JArray::sortAssociative($this->content, ["header", "image", "content", "extra-content"]); |
|
136 | 136 | return parent::compile($js, $view); |
137 | 137 | } |
138 | 138 | |
139 | - public function asLink($href="",$target=NULL) { |
|
139 | + public function asLink($href="", $target=NULL) { |
|
140 | 140 | $this->addToProperty("class", "link"); |
141 | - if ($href !== "") { |
|
141 | + if ($href!=="") { |
|
142 | 142 | $this->setProperty("href", $href); |
143 | 143 | if (isset($target)) |
144 | 144 | $this->setProperty("target", $target); |
@@ -37,8 +37,9 @@ discard block |
||
37 | 37 | |
38 | 38 | private function getPart($part, $index=NULL) { |
39 | 39 | if (\array_key_exists($part, $this->content)) { |
40 | - if (isset($index)) |
|
41 | - return $this->content[$part][$index]; |
|
40 | + if (isset($index)) { |
|
41 | + return $this->content[$part][$index]; |
|
42 | + } |
|
42 | 43 | return $this->content[$part]; |
43 | 44 | } |
44 | 45 | return NULL; |
@@ -140,8 +141,9 @@ discard block |
||
140 | 141 | $this->addToProperty("class", "link"); |
141 | 142 | if ($href !== "") { |
142 | 143 | $this->setProperty("href", $href); |
143 | - if (isset($target)) |
|
144 | - $this->setProperty("target", $target); |
|
144 | + if (isset($target)) { |
|
145 | + $this->setProperty("target", $target); |
|
146 | + } |
|
145 | 147 | } |
146 | 148 | return $this; |
147 | 149 | } |
@@ -33,42 +33,42 @@ discard block |
||
33 | 33 | * @param string|HtmlSemDoubleElement $header |
34 | 34 | * @return \Ajax\semantic\html\collections\HtmlMessage |
35 | 35 | */ |
36 | - public function addHeader($header){ |
|
36 | + public function addHeader($header) { |
|
37 | 37 | $headerO=$header; |
38 | - if(\is_string($header)){ |
|
39 | - $headerO=new HtmlSemDoubleElement("header-".$this->identifier,"div"); |
|
38 | + if (\is_string($header)) { |
|
39 | + $headerO=new HtmlSemDoubleElement("header-".$this->identifier, "div"); |
|
40 | 40 | $headerO->setClass("header"); |
41 | 41 | $headerO->setContent($header); |
42 | 42 | } |
43 | - return $this->addContent($headerO,true); |
|
43 | + return $this->addContent($headerO, true); |
|
44 | 44 | } |
45 | 45 | |
46 | - public function setHeader($header){ |
|
46 | + public function setHeader($header) { |
|
47 | 47 | return $this->addHeader($header); |
48 | 48 | } |
49 | 49 | |
50 | - public function addList($elements,$ordered=false){ |
|
51 | - $list=new HtmlList("list-".$this->identifier,$elements); |
|
50 | + public function addList($elements, $ordered=false) { |
|
51 | + $list=new HtmlList("list-".$this->identifier, $elements); |
|
52 | 52 | $list->setOrdered($ordered); |
53 | 53 | $list->setClass("ui list"); |
54 | 54 | $this->addContent($list); |
55 | 55 | } |
56 | 56 | |
57 | - public function setIcon($icon){ |
|
57 | + public function setIcon($icon) { |
|
58 | 58 | $this->addToProperty("class", "icon"); |
59 | - $this->wrapContent("<div class='content'>","</div>"); |
|
59 | + $this->wrapContent("<div class='content'>", "</div>"); |
|
60 | 60 | $this->icon=new HtmlIcon("icon-".$this->identifier, $icon); |
61 | 61 | return $this; |
62 | 62 | } |
63 | 63 | |
64 | - public function addLoader($loaderIcon="notched circle"){ |
|
64 | + public function addLoader($loaderIcon="notched circle") { |
|
65 | 65 | $this->setIcon($loaderIcon); |
66 | 66 | $this->icon->addToIcon("loading"); |
67 | 67 | return $this; |
68 | 68 | } |
69 | 69 | |
70 | - public function setDismissable($dismiss=true){ |
|
71 | - if($dismiss===true) |
|
70 | + public function setDismissable($dismiss=true) { |
|
71 | + if ($dismiss===true) |
|
72 | 72 | $this->close=new HtmlIcon("close-".$this->identifier, "close"); |
73 | 73 | else |
74 | 74 | $this->close=NULL; |
@@ -79,41 +79,41 @@ discard block |
||
79 | 79 | * {@inheritDoc} |
80 | 80 | * @see \Ajax\semantic\html\base\HtmlSemDoubleElement::run() |
81 | 81 | */ |
82 | - public function run(JsUtils $js){ |
|
82 | + public function run(JsUtils $js) { |
|
83 | 83 | parent::run($js); |
84 | - if(isset($this->close)){ |
|
84 | + if (isset($this->close)) { |
|
85 | 85 | $js->execOn("click", "#".$this->identifier." .close", "$(this).closest('.message').transition({$this->_closeTransition})"); |
86 | 86 | } |
87 | - if(isset($this->_timeout)){ |
|
88 | - $js->exec("setTimeout(function() { $('#{$this->identifier}').transition({$this->_closeTransition}); }, {$this->_timeout});",true); |
|
87 | + if (isset($this->_timeout)) { |
|
88 | + $js->exec("setTimeout(function() { $('#{$this->identifier}').transition({$this->_closeTransition}); }, {$this->_timeout});", true); |
|
89 | 89 | } |
90 | 90 | } |
91 | 91 | |
92 | - public function setState($visible=true){ |
|
93 | - $visible=($visible===true)?"visible":"hidden"; |
|
94 | - return $this->addToPropertyCtrl("class", $visible, array("visible","hidden")); |
|
92 | + public function setState($visible=true) { |
|
93 | + $visible=($visible===true) ? "visible" : "hidden"; |
|
94 | + return $this->addToPropertyCtrl("class", $visible, array("visible", "hidden")); |
|
95 | 95 | } |
96 | 96 | |
97 | - public function setVariation($value="floating"){ |
|
98 | - return $this->addToPropertyCtrl("class", $value, array("floating","compact")); |
|
97 | + public function setVariation($value="floating") { |
|
98 | + return $this->addToPropertyCtrl("class", $value, array("floating", "compact")); |
|
99 | 99 | } |
100 | 100 | |
101 | - public function setStyle($style){ |
|
101 | + public function setStyle($style) { |
|
102 | 102 | return $this->addToPropertyCtrl("class", $style, Style::getConstants()); |
103 | 103 | } |
104 | 104 | |
105 | - public function setError(){ |
|
105 | + public function setError() { |
|
106 | 106 | return $this->setStyle("error"); |
107 | 107 | } |
108 | 108 | |
109 | - public function setWarning(){ |
|
109 | + public function setWarning() { |
|
110 | 110 | return $this->setStyle("warning"); |
111 | 111 | } |
112 | 112 | |
113 | - public function setMessage($message){ |
|
114 | - if(\is_array($this->content)){ |
|
113 | + public function setMessage($message) { |
|
114 | + if (\is_array($this->content)) { |
|
115 | 115 | $this->content[\sizeof($this->content)-1]=$message; |
116 | - }else |
|
116 | + } else |
|
117 | 117 | $this->setContent($message); |
118 | 118 | } |
119 | 119 |
@@ -68,10 +68,11 @@ discard block |
||
68 | 68 | } |
69 | 69 | |
70 | 70 | public function setDismissable($dismiss=true){ |
71 | - if($dismiss===true) |
|
72 | - $this->close=new HtmlIcon("close-".$this->identifier, "close"); |
|
73 | - else |
|
74 | - $this->close=NULL; |
|
71 | + if($dismiss===true) { |
|
72 | + $this->close=new HtmlIcon("close-".$this->identifier, "close"); |
|
73 | + } else { |
|
74 | + $this->close=NULL; |
|
75 | + } |
|
75 | 76 | return $this; |
76 | 77 | } |
77 | 78 | |
@@ -113,8 +114,9 @@ discard block |
||
113 | 114 | public function setMessage($message){ |
114 | 115 | if(\is_array($this->content)){ |
115 | 116 | $this->content[\sizeof($this->content)-1]=$message; |
116 | - }else |
|
117 | - $this->setContent($message); |
|
117 | + } else { |
|
118 | + $this->setContent($message); |
|
119 | + } |
|
118 | 120 | } |
119 | 121 | |
120 | 122 | public function setTimeout($_timeout) { |
@@ -5,10 +5,17 @@ discard block |
||
5 | 5 | public static function contains($hay,$needle){ |
6 | 6 | return strpos($hay, $needle) !== false; |
7 | 7 | } |
8 | + |
|
9 | + /** |
|
10 | + * @param string $needle |
|
11 | + */ |
|
8 | 12 | public static function startswith($hay, $needle) { |
9 | 13 | return substr($hay, 0, strlen($needle)) === $needle; |
10 | 14 | } |
11 | 15 | |
16 | + /** |
|
17 | + * @param string $needle |
|
18 | + */ |
|
12 | 19 | public static function endswith($hay, $needle) { |
13 | 20 | return substr($hay, -strlen($needle)) === $needle; |
14 | 21 | } |
@@ -46,6 +53,12 @@ discard block |
||
46 | 53 | return \preg_replace($from, $to, $subject, 1); |
47 | 54 | } |
48 | 55 | |
56 | + /** |
|
57 | + * @param string $fromFirst |
|
58 | + * @param string $toFirst |
|
59 | + * @param string $fromLast |
|
60 | + * @param string $toLast |
|
61 | + */ |
|
49 | 62 | public static function replaceAtFirstAndLast($subject,$fromFirst,$toFirst,$fromLast,$toLast){ |
50 | 63 | $s=self::replaceAtFirst($subject, $fromFirst, $toFirst); |
51 | 64 | return self::replaceAtLast($s, $fromLast, $toLast); |
@@ -2,62 +2,62 @@ |
||
2 | 2 | namespace Ajax\service; |
3 | 3 | class JString { |
4 | 4 | |
5 | - public static function contains($hay,$needle){ |
|
6 | - return strpos($hay, $needle) !== false; |
|
5 | + public static function contains($hay, $needle) { |
|
6 | + return strpos($hay, $needle)!==false; |
|
7 | 7 | } |
8 | 8 | public static function startswith($hay, $needle) { |
9 | - return substr($hay, 0, strlen($needle)) === $needle; |
|
9 | + return substr($hay, 0, strlen($needle))===$needle; |
|
10 | 10 | } |
11 | 11 | |
12 | 12 | public static function endswith($hay, $needle) { |
13 | - return substr($hay, -strlen($needle)) === $needle; |
|
13 | + return substr($hay, -strlen($needle))===$needle; |
|
14 | 14 | } |
15 | 15 | |
16 | - public static function isNull($s){ |
|
16 | + public static function isNull($s) { |
|
17 | 17 | return (!isset($s) || NULL===$s || ""===$s); |
18 | 18 | } |
19 | - public static function isNotNull($s){ |
|
19 | + public static function isNotNull($s) { |
|
20 | 20 | return (isset($s) && NULL!==$s && ""!==$s); |
21 | 21 | } |
22 | 22 | |
23 | - public static function isBoolean($value){ |
|
23 | + public static function isBoolean($value) { |
|
24 | 24 | return \is_bool($value) || $value==1 || $value==0; |
25 | 25 | } |
26 | 26 | |
27 | - public static function isBooleanTrue($value){ |
|
27 | + public static function isBooleanTrue($value) { |
|
28 | 28 | return $value==1 || $value; |
29 | 29 | } |
30 | 30 | |
31 | - public static function isBooleanFalse($value){ |
|
31 | + public static function isBooleanFalse($value) { |
|
32 | 32 | return $value==0 || !$value; |
33 | 33 | } |
34 | 34 | |
35 | - public static function camelCaseToSeparated($input,$separator=" "){ |
|
35 | + public static function camelCaseToSeparated($input, $separator=" ") { |
|
36 | 36 | return strtolower(preg_replace('/(?<!^)[A-Z]/', $separator.'$0', $input)); |
37 | 37 | } |
38 | 38 | |
39 | - public static function replaceAtFirst($subject,$from, $to){ |
|
40 | - $from = '/\A'.preg_quote($from, '/').'/'; |
|
39 | + public static function replaceAtFirst($subject, $from, $to) { |
|
40 | + $from='/\A'.preg_quote($from, '/').'/'; |
|
41 | 41 | return \preg_replace($from, $to, $subject, 1); |
42 | 42 | } |
43 | 43 | |
44 | - public static function replaceAtLast($subject,$from, $to){ |
|
45 | - $from = '/'.preg_quote($from, '/').'\z/'; |
|
44 | + public static function replaceAtLast($subject, $from, $to) { |
|
45 | + $from='/'.preg_quote($from, '/').'\z/'; |
|
46 | 46 | return \preg_replace($from, $to, $subject, 1); |
47 | 47 | } |
48 | 48 | |
49 | - public static function replaceAtFirstAndLast($subject,$fromFirst,$toFirst,$fromLast,$toLast){ |
|
49 | + public static function replaceAtFirstAndLast($subject, $fromFirst, $toFirst, $fromLast, $toLast) { |
|
50 | 50 | $s=self::replaceAtFirst($subject, $fromFirst, $toFirst); |
51 | 51 | return self::replaceAtLast($s, $fromLast, $toLast); |
52 | 52 | } |
53 | 53 | |
54 | - public static function getValueBetween(&$str,$before="{{",$after="}}"){ |
|
54 | + public static function getValueBetween(&$str, $before="{{", $after="}}") { |
|
55 | 55 | $matches=[]; |
56 | 56 | $_before=\preg_quote($before); |
57 | 57 | $_after=\preg_quote($after); |
58 | - if(\preg_match('/'.$_before.'(.*?)'.$_after.'/s', $str, $matches)===1){ |
|
58 | + if (\preg_match('/'.$_before.'(.*?)'.$_after.'/s', $str, $matches)===1) { |
|
59 | 59 | $result=$matches[1]; |
60 | - $str=\str_replace($before.$result.$after,"", $str); |
|
60 | + $str=\str_replace($before.$result.$after, "", $str); |
|
61 | 61 | } |
62 | 62 | return $result; |
63 | 63 | } |