@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | use Ajax\JsUtils; |
8 | 8 | |
9 | 9 | abstract class AbstractCheckbox extends HtmlSemDoubleElement { |
10 | - protected $_params=array (); |
|
10 | + protected $_params=array(); |
|
11 | 11 | |
12 | 12 | public function __construct($identifier, $name=NULL, $label=NULL, $value=NULL, $inputType="checkbox", $type="checkbox") { |
13 | 13 | parent::__construct("ck-".$identifier, "div", "ui ".$type); |
@@ -18,10 +18,10 @@ discard block |
||
18 | 18 | $this->setLabel($label); |
19 | 19 | } |
20 | 20 | |
21 | - public function setChecked($value=true){ |
|
22 | - if($value===true){ |
|
21 | + public function setChecked($value=true) { |
|
22 | + if ($value===true) { |
|
23 | 23 | $this->getField()->setProperty("checked", "checked"); |
24 | - }else{ |
|
24 | + } else { |
|
25 | 25 | $this->getField()->removeProperty("checked"); |
26 | 26 | } |
27 | 27 | return $this; |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | * @return \Ajax\semantic\html\collections\form\AbstractHtmlFormRadioCheckbox |
84 | 84 | */ |
85 | 85 | public function attachEvent($selector, $action=NULL) { |
86 | - if (isset($action)!==false||\is_numeric($action)===true) { |
|
86 | + if (isset($action)!==false || \is_numeric($action)===true) { |
|
87 | 87 | $js='$("#%identifier%").checkbox("attach events", "'.$selector.'", "'.$action.'");'; |
88 | 88 | } else { |
89 | 89 | $js='$("#%identifier%").checkbox("attach events", "'.$selector.'");'; |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | */ |
100 | 100 | public function attachEvents($events=array()) { |
101 | 101 | if (\is_array($events)) { |
102 | - foreach ( $events as $action => $selector ) { |
|
102 | + foreach ($events as $action => $selector) { |
|
103 | 103 | $this->attachEvent($selector, $action); |
104 | 104 | } |
105 | 105 | } |
@@ -110,16 +110,16 @@ discard block |
||
110 | 110 | return $this->addToProperty("class", "fitted"); |
111 | 111 | } |
112 | 112 | |
113 | - public function setOnChecked($jsCode){ |
|
113 | + public function setOnChecked($jsCode) { |
|
114 | 114 | $this->_params["onChecked"]=$jsCode; |
115 | 115 | } |
116 | 116 | |
117 | - public function setOnUnchecked($jsCode){ |
|
117 | + public function setOnUnchecked($jsCode) { |
|
118 | 118 | $this->_params["onUnchecked"]=$jsCode; |
119 | 119 | } |
120 | 120 | |
121 | 121 | public function run(JsUtils $js) { |
122 | - $this->_bsComponent=$js->semantic()->checkbox("#" . $this->identifier, $this->_params); |
|
122 | + $this->_bsComponent=$js->semantic()->checkbox("#".$this->identifier, $this->_params); |
|
123 | 123 | return parent::run($js); |
124 | 124 | } |
125 | 125 | } |
126 | 126 | \ No newline at end of file |
@@ -2,33 +2,33 @@ |
||
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 | 35 | \ No newline at end of file |
@@ -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 | } |
8 | 8 | \ No newline at end of file |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | } |
36 | 36 | if (isset($label)) |
37 | 37 | $this->setLabel($label); |
38 | - foreach ( $fields as $field ) { |
|
38 | + foreach ($fields as $field) { |
|
39 | 39 | $this->addItem($field); |
40 | 40 | } |
41 | 41 | return $this; |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | |
58 | 58 | public function addItem($item) { |
59 | 59 | $item=parent::addItem($item); |
60 | - if($item instanceof HtmlFormField) |
|
60 | + if ($item instanceof HtmlFormField) |
|
61 | 61 | $item->setContainer($this); |
62 | 62 | return $item; |
63 | 63 | } |
@@ -98,9 +98,9 @@ discard block |
||
98 | 98 | |
99 | 99 | |
100 | 100 | public static function radios($name, $items=array(), $label=NULL, $value=null, $type=NULL) { |
101 | - $fields=array (); |
|
101 | + $fields=array(); |
|
102 | 102 | $i=0; |
103 | - foreach ( $items as $val => $caption ) { |
|
103 | + foreach ($items as $val => $caption) { |
|
104 | 104 | $itemO=new HtmlFormRadio($name."-".$i++, $name, $caption, $val, $type); |
105 | 105 | if ($val===$value) { |
106 | 106 | $itemO->getField()->setProperty("checked", ""); |
@@ -114,9 +114,9 @@ discard block |
||
114 | 114 | } |
115 | 115 | |
116 | 116 | public static function checkeds($name, $items=array(), $label=NULL, $values=array(), $type=NULL) { |
117 | - $fields=array (); |
|
117 | + $fields=array(); |
|
118 | 118 | $i=0; |
119 | - foreach ( $items as $val => $caption ) { |
|
119 | + foreach ($items as $val => $caption) { |
|
120 | 120 | $itemO=new HtmlFormCheckbox($name."-".$i++, $name, $caption, $val, $type); |
121 | 121 | if (\array_search($val, $values)!==false) { |
122 | 122 | $itemO->getField()->getField()->setProperty("checked", ""); |
@@ -15,8 +15,8 @@ discard block |
||
15 | 15 | * @param array $instances |
16 | 16 | * @return DataTable |
17 | 17 | */ |
18 | - public function dataTable($identifier,$model, $instances){ |
|
19 | - return $this->addHtmlComponent(new DataTable($identifier,$model,$instances)); |
|
18 | + public function dataTable($identifier, $model, $instances) { |
|
19 | + return $this->addHtmlComponent(new DataTable($identifier, $model, $instances)); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | /** |
@@ -24,8 +24,8 @@ discard block |
||
24 | 24 | * @param object $instance |
25 | 25 | * @return DataElement |
26 | 26 | */ |
27 | - public function dataElement($identifier, $instance){ |
|
28 | - return $this->addHtmlComponent(new DataElement($identifier,$instance)); |
|
27 | + public function dataElement($identifier, $instance) { |
|
28 | + return $this->addHtmlComponent(new DataElement($identifier, $instance)); |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | /** |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | * @param object $instance |
34 | 34 | * @return DataForm |
35 | 35 | */ |
36 | - public function dataForm($identifier, $instance){ |
|
37 | - return $this->addHtmlComponent(new DataForm($identifier,$instance)); |
|
36 | + public function dataForm($identifier, $instance) { |
|
37 | + return $this->addHtmlComponent(new DataForm($identifier, $instance)); |
|
38 | 38 | } |
39 | 39 | } |
40 | 40 | \ No newline at end of file |
@@ -8,16 +8,16 @@ |
||
8 | 8 | class HtmlFormInput extends HtmlFormField { |
9 | 9 | use TextFieldsTrait; |
10 | 10 | |
11 | - public function __construct($identifier, $label=NULL,$type="text",$value=NULL,$placeholder=NULL) { |
|
12 | - if(!isset($placeholder) && $type==="text") |
|
11 | + public function __construct($identifier, $label=NULL, $type="text", $value=NULL, $placeholder=NULL) { |
|
12 | + if (!isset($placeholder) && $type==="text") |
|
13 | 13 | $placeholder=$label; |
14 | - parent::__construct("field-".$identifier, new HtmlInput($identifier,$type,$value,$placeholder), $label); |
|
14 | + parent::__construct("field-".$identifier, new HtmlInput($identifier, $type, $value, $placeholder), $label); |
|
15 | 15 | } |
16 | 16 | |
17 | - public function getDataField(){ |
|
18 | - $field= $this->getField(); |
|
17 | + public function getDataField() { |
|
18 | + $field=$this->getField(); |
|
19 | 19 | //TODO check getField |
20 | - if($field instanceof HtmlInput) |
|
20 | + if ($field instanceof HtmlInput) |
|
21 | 21 | $field=$field->getDataField(); |
22 | 22 | return $field; |
23 | 23 | } |
@@ -9,17 +9,17 @@ 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 | } |
17 | 17 | |
18 | 18 | /** |
19 | 19 | * Defines the textarea row count |
20 | 20 | * @param int $count |
21 | 21 | */ |
22 | - public function setRows($count){ |
|
22 | + public function setRows($count) { |
|
23 | 23 | $this->getField()->setRows($count); |
24 | 24 | } |
25 | 25 | |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | return $this->content["field"]; |
28 | 28 | } |
29 | 29 | |
30 | - public function setName($name){ |
|
31 | - $this->getDataField()->setProperty("name",$name); |
|
30 | + public function setName($name) { |
|
31 | + $this->getDataField()->setProperty("name", $name); |
|
32 | 32 | } |
33 | 33 | } |
34 | 34 | \ No newline at end of file |
@@ -6,19 +6,19 @@ |
||
6 | 6 | |
7 | 7 | abstract public function getDataField(); |
8 | 8 | abstract public function addToProperty($name, $value, $separator=" "); |
9 | - public function setPlaceholder($value){ |
|
9 | + public function setPlaceholder($value) { |
|
10 | 10 | $this->getDataField()->setPlaceholder($value); |
11 | 11 | return $this; |
12 | 12 | } |
13 | 13 | |
14 | - public function setValue($value){ |
|
14 | + public function setValue($value) { |
|
15 | 15 | $this->getDataField()->setValue($value); |
16 | 16 | return $this; |
17 | 17 | } |
18 | 18 | |
19 | - public function setInputType($type){ |
|
20 | - if($type==="hidden") |
|
21 | - $this->addToProperty("style","display:none;"); |
|
19 | + public function setInputType($type) { |
|
20 | + if ($type==="hidden") |
|
21 | + $this->addToProperty("style", "display:none;"); |
|
22 | 22 | $this->getDataField()->setInputType($type); |
23 | 23 | return $this; |
24 | 24 | } |
@@ -11,14 +11,14 @@ discard block |
||
11 | 11 | |
12 | 12 | abstract public function addToProperty($name, $value, $separator=" "); |
13 | 13 | abstract public function addLabel($caption, $style="label-default", $leftSeparator=" "); |
14 | - abstract public function addContent($content,$before=false); |
|
14 | + abstract public function addContent($content, $before=false); |
|
15 | 15 | abstract public function getField(); |
16 | 16 | public function setFocus() { |
17 | 17 | $this->getField()->addToProperty("class", State::FOCUS); |
18 | 18 | } |
19 | 19 | |
20 | 20 | public function addLoading() { |
21 | - if ($this->_hasIcon === false) { |
|
21 | + if ($this->_hasIcon===false) { |
|
22 | 22 | throw new \Exception("Input must have an icon for showing a loader, use addIcon before"); |
23 | 23 | } |
24 | 24 | return $this->addToProperty("class", State::LOADING); |
@@ -26,44 +26,44 @@ discard block |
||
26 | 26 | |
27 | 27 | public function labeled($label, $direction=Direction::LEFT, $icon=NULL) { |
28 | 28 | $field=$this->getField(); |
29 | - $labelO=$field->addLabel($label,$direction===Direction::LEFT,$icon); |
|
30 | - $field->addToProperty("class", $direction . " labeled"); |
|
29 | + $labelO=$field->addLabel($label, $direction===Direction::LEFT, $icon); |
|
30 | + $field->addToProperty("class", $direction." labeled"); |
|
31 | 31 | return $labelO; |
32 | 32 | } |
33 | 33 | |
34 | 34 | public function labeledToCorner($icon, $direction=Direction::LEFT) { |
35 | - return $this->labeled("", $direction . " corner", $icon)->toCorner($direction); |
|
35 | + return $this->labeled("", $direction." corner", $icon)->toCorner($direction); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | public function addAction($action, $direction=Direction::RIGHT, $icon=NULL, $labeled=false) { |
39 | 39 | $field=$this->getField(); |
40 | 40 | $actionO=$action; |
41 | - if (\is_object($action) === false) { |
|
42 | - $actionO=new HtmlButton("action-" . $this->identifier, $action); |
|
41 | + if (\is_object($action)===false) { |
|
42 | + $actionO=new HtmlButton("action-".$this->identifier, $action); |
|
43 | 43 | if (isset($icon)) |
44 | 44 | $actionO->addIcon($icon, true, $labeled); |
45 | 45 | } |
46 | - $field->addToProperty("class", $direction . " action"); |
|
47 | - $field->addContent($actionO, \strstr($direction, Direction::LEFT) !== false); |
|
46 | + $field->addToProperty("class", $direction." action"); |
|
47 | + $field->addContent($actionO, \strstr($direction, Direction::LEFT)!==false); |
|
48 | 48 | return $actionO; |
49 | 49 | } |
50 | 50 | |
51 | - public function addDropdown($label="", $items=array(),$direction=Direction::RIGHT){ |
|
52 | - $labelO=new HtmlDropdown("dd-".$this->identifier,$label,$items); |
|
53 | - $labelO->asSelect("select-".$this->identifier,false,true); |
|
54 | - return $this->labeled($labelO,$direction); |
|
51 | + public function addDropdown($label="", $items=array(), $direction=Direction::RIGHT) { |
|
52 | + $labelO=new HtmlDropdown("dd-".$this->identifier, $label, $items); |
|
53 | + $labelO->asSelect("select-".$this->identifier, false, true); |
|
54 | + return $this->labeled($labelO, $direction); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | public function setTransparent() { |
58 | 58 | return $this->getField()->addToProperty("class", "transparent"); |
59 | 59 | } |
60 | 60 | |
61 | - public function setReadonly(){ |
|
61 | + public function setReadonly() { |
|
62 | 62 | $this->getDataField()->setProperty("readonly", ""); |
63 | 63 | } |
64 | 64 | |
65 | - public function setName($name){ |
|
66 | - $this->getDataField()->setProperty("name",$name); |
|
65 | + public function setName($name) { |
|
66 | + $this->getDataField()->setProperty("name", $name); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | } |
70 | 70 | \ No newline at end of file |