@@ -9,15 +9,15 @@ discard block |
||
9 | 9 | protected $image; |
10 | 10 | |
11 | 11 | public function __construct($identifier, $content=NULL) { |
12 | - parent::__construct($identifier,"item",$content); |
|
12 | + parent::__construct($identifier, "item", $content); |
|
13 | 13 | } |
14 | - protected function initContent($content){ |
|
15 | - if(\is_array($content)){ |
|
16 | - if(JArray::isAssociative($content)===false){ |
|
14 | + protected function initContent($content) { |
|
15 | + if (\is_array($content)) { |
|
16 | + if (JArray::isAssociative($content)===false) { |
|
17 | 17 | $icon=@$content[0]; |
18 | 18 | $title=@$content[1]; |
19 | 19 | $desc=@$content[2]; |
20 | - }else{ |
|
20 | + }else { |
|
21 | 21 | $icon=@$content["icon"]; |
22 | 22 | $image=@$content["image"]; |
23 | 23 | $title=@$content["title"]; |
@@ -25,21 +25,21 @@ discard block |
||
25 | 25 | $desc=@$content["description"]; |
26 | 26 | $items=@$content["items"]; |
27 | 27 | } |
28 | - if(isset($icon)===true){ |
|
28 | + if (isset($icon)===true) { |
|
29 | 29 | $this->setIcon($icon); |
30 | 30 | } |
31 | - if(isset($image)===true){ |
|
31 | + if (isset($image)===true) { |
|
32 | 32 | $this->setImage($image); |
33 | 33 | } |
34 | - if(isset($title)===true){ |
|
35 | - $this->setTitle($title,$desc); |
|
36 | - }elseif (isset($header)===true){ |
|
37 | - $this->setTitle($header,$desc,"header"); |
|
34 | + if (isset($title)===true) { |
|
35 | + $this->setTitle($title, $desc); |
|
36 | + }elseif (isset($header)===true) { |
|
37 | + $this->setTitle($header, $desc, "header"); |
|
38 | 38 | } |
39 | - if(isset($items)===true){ |
|
39 | + if (isset($items)===true) { |
|
40 | 40 | $this->addList($items); |
41 | 41 | } |
42 | - }else{ |
|
42 | + }else { |
|
43 | 43 | $this->setContent($content); |
44 | 44 | } |
45 | 45 | } |
@@ -50,11 +50,11 @@ discard block |
||
50 | 50 | return $list; |
51 | 51 | } |
52 | 52 | |
53 | - public function getList(){ |
|
53 | + public function getList() { |
|
54 | 54 | return $this->content["list"]; |
55 | 55 | } |
56 | 56 | |
57 | - public function getItem($index){ |
|
57 | + public function getItem($index) { |
|
58 | 58 | return $this->getList()->getItem($index); |
59 | 59 | } |
60 | 60 | } |
61 | 61 | \ No newline at end of file |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | $icon=@$content[0]; |
18 | 18 | $title=@$content[1]; |
19 | 19 | $desc=@$content[2]; |
20 | - }else{ |
|
20 | + } else{ |
|
21 | 21 | $icon=@$content["icon"]; |
22 | 22 | $image=@$content["image"]; |
23 | 23 | $title=@$content["title"]; |
@@ -33,13 +33,13 @@ discard block |
||
33 | 33 | } |
34 | 34 | if(isset($title)===true){ |
35 | 35 | $this->setTitle($title,$desc); |
36 | - }elseif (isset($header)===true){ |
|
36 | + } elseif (isset($header)===true){ |
|
37 | 37 | $this->setTitle($header,$desc,"header"); |
38 | 38 | } |
39 | 39 | if(isset($items)===true){ |
40 | 40 | $this->addList($items); |
41 | 41 | } |
42 | - }else{ |
|
42 | + } else{ |
|
43 | 43 | $this->setContent($content); |
44 | 44 | } |
45 | 45 | } |
@@ -20,30 +20,30 @@ |
||
20 | 20 | $this->_title=$title; |
21 | 21 | } |
22 | 22 | |
23 | - public function setTitle($title){ |
|
23 | + public function setTitle($title) { |
|
24 | 24 | $this->_title=$title; |
25 | 25 | } |
26 | 26 | |
27 | - public function setIcon($icon){ |
|
27 | + public function setIcon($icon) { |
|
28 | 28 | $this->_icon=$icon; |
29 | 29 | } |
30 | 30 | |
31 | - protected function createTitleElement(){ |
|
32 | - $element=new HtmlSemDoubleElement("title-".$this->identifier,"div","title"); |
|
33 | - $element->setContent(array(new HtmlIcon("", $this->_icon),$this->_title)); |
|
34 | - if($this->_active===true) |
|
31 | + protected function createTitleElement() { |
|
32 | + $element=new HtmlSemDoubleElement("title-".$this->identifier, "div", "title"); |
|
33 | + $element->setContent(array(new HtmlIcon("", $this->_icon), $this->_title)); |
|
34 | + if ($this->_active===true) |
|
35 | 35 | $element->addToProperty("class", "active"); |
36 | 36 | return $element; |
37 | 37 | } |
38 | 38 | |
39 | - public function compile(JsUtils $js=NULL, $view=NULL){ |
|
39 | + public function compile(JsUtils $js=NULL, $view=NULL) { |
|
40 | 40 | $this->titleElement=$this->createTitleElement(); |
41 | - return parent::compile($js,$view); |
|
41 | + return parent::compile($js, $view); |
|
42 | 42 | } |
43 | 43 | |
44 | - public function setActive($value=true){ |
|
44 | + public function setActive($value=true) { |
|
45 | 45 | $this->_active=$value; |
46 | - if($value===true) |
|
46 | + if ($value===true) |
|
47 | 47 | $this->addToPropertyCtrl("class", "active", array("active")); |
48 | 48 | else |
49 | 49 | $this->removePropertyValue("class", "active"); |
@@ -10,33 +10,33 @@ discard block |
||
10 | 10 | |
11 | 11 | class HtmlFormField extends HtmlSemDoubleElement { |
12 | 12 | protected $_container; |
13 | - public function __construct($identifier, $field,$label=NULL) { |
|
14 | - parent::__construct($identifier, "div","field"); |
|
13 | + public function __construct($identifier, $field, $label=NULL) { |
|
14 | + parent::__construct($identifier, "div", "field"); |
|
15 | 15 | $this->content=array(); |
16 | - $this->_states=[State::ERROR,State::DISABLED]; |
|
17 | - if(isset($label)) |
|
16 | + $this->_states=[State::ERROR, State::DISABLED]; |
|
17 | + if (isset($label)) |
|
18 | 18 | $this->setLabel($label); |
19 | 19 | $this->setField($field); |
20 | 20 | } |
21 | 21 | |
22 | - public function addPointingLabel($label,$pointing=Direction::NONE){ |
|
23 | - $labelO=new HtmlLabel("",$label); |
|
22 | + public function addPointingLabel($label, $pointing=Direction::NONE) { |
|
23 | + $labelO=new HtmlLabel("", $label); |
|
24 | 24 | $labelO->setPointing($pointing); |
25 | - $this->addContent($labelO,$pointing==="below" || $pointing==="right"); |
|
25 | + $this->addContent($labelO, $pointing==="below" || $pointing==="right"); |
|
26 | 26 | return $labelO; |
27 | 27 | } |
28 | 28 | |
29 | - public function setLabel($label){ |
|
29 | + public function setLabel($label) { |
|
30 | 30 | $labelO=$label; |
31 | - if(\is_string($label)){ |
|
32 | - $labelO=new HtmlSemDoubleElement("","label",""); |
|
31 | + if (\is_string($label)) { |
|
32 | + $labelO=new HtmlSemDoubleElement("", "label", ""); |
|
33 | 33 | $labelO->setContent($label); |
34 | - $labelO->setProperty("for", \str_replace("field-", "",$this->identifier)); |
|
34 | + $labelO->setProperty("for", \str_replace("field-", "", $this->identifier)); |
|
35 | 35 | } |
36 | 36 | $this->content["label"]=$labelO; |
37 | 37 | } |
38 | 38 | |
39 | - public function setField($field){ |
|
39 | + public function setField($field) { |
|
40 | 40 | $this->content["field"]=$field; |
41 | 41 | } |
42 | 42 | |
@@ -44,8 +44,8 @@ discard block |
||
44 | 44 | * Returns the label or null |
45 | 45 | * @return mixed |
46 | 46 | */ |
47 | - public function getLabel(){ |
|
48 | - if(\array_key_exists("label", $this->content)) |
|
47 | + public function getLabel() { |
|
48 | + if (\array_key_exists("label", $this->content)) |
|
49 | 49 | return $this->content["label"]; |
50 | 50 | } |
51 | 51 | |
@@ -53,14 +53,14 @@ discard block |
||
53 | 53 | * Return the field |
54 | 54 | * @return mixed |
55 | 55 | */ |
56 | - public function getField(){ |
|
56 | + public function getField() { |
|
57 | 57 | return $this->content["field"]; |
58 | 58 | } |
59 | 59 | |
60 | 60 | /** |
61 | 61 | * puts the label before or behind |
62 | 62 | */ |
63 | - public function swapLabel(){ |
|
63 | + public function swapLabel() { |
|
64 | 64 | $label=$this->getLabel(); |
65 | 65 | unset($this->content["label"]); |
66 | 66 | $this->content["label"]=$label; |
@@ -71,31 +71,31 @@ discard block |
||
71 | 71 | * @param int $width |
72 | 72 | * @return \Ajax\semantic\html\collections\form\HtmlFormField |
73 | 73 | */ |
74 | - public function setWidth($width){ |
|
75 | - if(\is_int($width)){ |
|
74 | + public function setWidth($width) { |
|
75 | + if (\is_int($width)) { |
|
76 | 76 | $width=Wide::getConstants()["W".$width]; |
77 | 77 | } |
78 | 78 | $this->addToPropertyCtrl("class", $width, Wide::getConstants()); |
79 | - if(isset($this->_container)){ |
|
79 | + if (isset($this->_container)) { |
|
80 | 80 | $this->_container->setEqualWidth(false); |
81 | 81 | } |
82 | - return $this->addToPropertyCtrl("class", "wide",array("wide")); |
|
82 | + return $this->addToPropertyCtrl("class", "wide", array("wide")); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | /** |
86 | 86 | * Field displays an error state |
87 | 87 | * @return \Ajax\semantic\html\collections\form\HtmlFormField |
88 | 88 | */ |
89 | - public function setError(){ |
|
89 | + public function setError() { |
|
90 | 90 | return $this->addToProperty("class", "error"); |
91 | 91 | } |
92 | 92 | |
93 | - public function setInline(){ |
|
93 | + public function setInline() { |
|
94 | 94 | return $this->addToProperty("class", "inline"); |
95 | 95 | } |
96 | 96 | |
97 | - public function jsState($state){ |
|
98 | - return $this->jsDoJquery("addClass",$state); |
|
97 | + public function jsState($state) { |
|
98 | + return $this->jsDoJquery("addClass", $state); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | public function setContainer($_container) { |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | return $this; |
104 | 104 | } |
105 | 105 | |
106 | - public function setReadonly(){ |
|
106 | + public function setReadonly() { |
|
107 | 107 | $this->getField()->setProperty("readonly", ""); |
108 | 108 | } |
109 | 109 |
@@ -9,26 +9,26 @@ discard block |
||
9 | 9 | use Ajax\semantic\html\collections\form\HtmlFormCheckbox; |
10 | 10 | use Ajax\semantic\html\collections\form\HtmlFormRadio; |
11 | 11 | trait FieldsTrait { |
12 | - public abstract function addFields($fields=NULL,$label=NULL); |
|
12 | + public abstract function addFields($fields=NULL, $label=NULL); |
|
13 | 13 | public abstract function addItem($item); |
14 | 14 | |
15 | - protected function createItem($value){ |
|
16 | - if(\is_array($value)){ |
|
17 | - $itemO=new HtmlFormInput(JArray::getDefaultValue($value, "id",""),JArray::getDefaultValue($value, "label",null),JArray::getDefaultValue($value, "type", "text"),JArray::getDefaultValue($value, "value",""),JArray::getDefaultValue($value, "placeholder",JArray::getDefaultValue($value, "label",null))); |
|
15 | + protected function createItem($value) { |
|
16 | + if (\is_array($value)) { |
|
17 | + $itemO=new HtmlFormInput(JArray::getDefaultValue($value, "id", ""), JArray::getDefaultValue($value, "label", null), JArray::getDefaultValue($value, "type", "text"), JArray::getDefaultValue($value, "value", ""), JArray::getDefaultValue($value, "placeholder", JArray::getDefaultValue($value, "label", null))); |
|
18 | 18 | return $itemO; |
19 | 19 | }else |
20 | 20 | return new HtmlFormInput($value); |
21 | 21 | } |
22 | 22 | |
23 | - public function addInputs($inputs,$fieldslabel=null){ |
|
23 | + public function addInputs($inputs, $fieldslabel=null) { |
|
24 | 24 | $fields=array(); |
25 | - foreach ($inputs as $input){ |
|
25 | + foreach ($inputs as $input) { |
|
26 | 26 | \extract($input); |
27 | - $f=new HtmlFormInput("",""); |
|
27 | + $f=new HtmlFormInput("", ""); |
|
28 | 28 | $f->fromArray($input); |
29 | 29 | $fields[]=$f; |
30 | 30 | } |
31 | - return $this->addFields($fields,$fieldslabel); |
|
31 | + return $this->addFields($fields, $fieldslabel); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | /** |
@@ -39,27 +39,27 @@ discard block |
||
39 | 39 | * @param boolean $multiple |
40 | 40 | * @return \Ajax\common\html\HtmlDoubleElement |
41 | 41 | */ |
42 | - public function addDropdown($identifier,$items=array(), $label=NULL,$value=NULL,$multiple=false){ |
|
43 | - return $this->addItem(new HtmlFormDropdown($identifier,$items,$label,$value,$multiple)); |
|
42 | + public function addDropdown($identifier, $items=array(), $label=NULL, $value=NULL, $multiple=false) { |
|
43 | + return $this->addItem(new HtmlFormDropdown($identifier, $items, $label, $value, $multiple)); |
|
44 | 44 | } |
45 | 45 | |
46 | - public function addInput($identifier, $label=NULL,$type="text",$value=NULL,$placeholder=NULL){ |
|
47 | - return $this->addItem(new HtmlFormInput($identifier,$label,$type,$value,$placeholder)); |
|
46 | + public function addInput($identifier, $label=NULL, $type="text", $value=NULL, $placeholder=NULL) { |
|
47 | + return $this->addItem(new HtmlFormInput($identifier, $label, $type, $value, $placeholder)); |
|
48 | 48 | } |
49 | 49 | |
50 | - public function addPassword($identifier, $label=NULL){ |
|
51 | - return $this->addItem(new HtmlFormInput($identifier,$label,"password","","")); |
|
50 | + public function addPassword($identifier, $label=NULL) { |
|
51 | + return $this->addItem(new HtmlFormInput($identifier, $label, "password", "", "")); |
|
52 | 52 | } |
53 | 53 | |
54 | - public function addButton($identifier,$value,$cssStyle=NULL,$onClick=NULL){ |
|
55 | - return $this->addItem(new HtmlButton($identifier,$value,$cssStyle,$onClick)); |
|
54 | + public function addButton($identifier, $value, $cssStyle=NULL, $onClick=NULL) { |
|
55 | + return $this->addItem(new HtmlButton($identifier, $value, $cssStyle, $onClick)); |
|
56 | 56 | } |
57 | 57 | |
58 | - public function addCheckbox($identifier, $label=NULL,$value=NULL,$type=NULL){ |
|
59 | - return $this->addItem(new HtmlFormCheckbox($identifier,$label,$value,$type)); |
|
58 | + public function addCheckbox($identifier, $label=NULL, $value=NULL, $type=NULL) { |
|
59 | + return $this->addItem(new HtmlFormCheckbox($identifier, $label, $value, $type)); |
|
60 | 60 | } |
61 | 61 | |
62 | - public function addRadio($identifier, $name,$label=NULL,$value=NULL){ |
|
63 | - return $this->addItem(new HtmlFormRadio($identifier,$name,$label,$value)); |
|
62 | + public function addRadio($identifier, $name, $label=NULL, $value=NULL) { |
|
63 | + return $this->addItem(new HtmlFormRadio($identifier, $name, $label, $value)); |
|
64 | 64 | } |
65 | 65 | } |
66 | 66 | \ No newline at end of file |
@@ -22,9 +22,9 @@ discard block |
||
22 | 22 | |
23 | 23 | public function __construct($identifier, $elements=array()) { |
24 | 24 | parent::__construct($identifier, "form", "ui form"); |
25 | - $this->_states=[ State::ERROR,State::SUCCESS,State::WARNING,State::DISABLED ]; |
|
25 | + $this->_states=[State::ERROR, State::SUCCESS, State::WARNING, State::DISABLED]; |
|
26 | 26 | $this->setProperty("name", $this->identifier); |
27 | - $this->_fields=array (); |
|
27 | + $this->_fields=array(); |
|
28 | 28 | $this->addItems($elements); |
29 | 29 | } |
30 | 30 | |
@@ -35,29 +35,29 @@ discard block |
||
35 | 35 | return $this->addItem($header); |
36 | 36 | } |
37 | 37 | |
38 | - public function addDivider($caption=NULL){ |
|
39 | - return $this->addContent(new HtmlDivider("",$caption)); |
|
38 | + public function addDivider($caption=NULL) { |
|
39 | + return $this->addContent(new HtmlDivider("", $caption)); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | public function addFields($fields=NULL, $label=NULL) { |
43 | 43 | if (isset($fields)) { |
44 | 44 | if (!$fields instanceof HtmlFormFields) { |
45 | - if (\is_array($fields) === false) { |
|
45 | + if (\is_array($fields)===false) { |
|
46 | 46 | $fields=\func_get_args(); |
47 | 47 | $end=\end($fields); |
48 | 48 | if (\is_string($end)) { |
49 | 49 | $label=$end; |
50 | 50 | \array_pop($fields); |
51 | - } else |
|
51 | + }else |
|
52 | 52 | $label=NULL; |
53 | 53 | } |
54 | 54 | $this->_fields=\array_merge($this->_fields, $fields); |
55 | - $fields=new HtmlFormFields("fields-" . $this->identifier . "-" . $this->count(), $fields); |
|
55 | + $fields=new HtmlFormFields("fields-".$this->identifier."-".$this->count(), $fields); |
|
56 | 56 | } |
57 | 57 | if (isset($label)) |
58 | 58 | $fields=new HtmlFormField("", $fields, $label); |
59 | - } else { |
|
60 | - $fields=new HtmlFormFields("fields-" . $this->identifier . "-" . $this->count()); |
|
59 | + }else { |
|
60 | + $fields=new HtmlFormFields("fields-".$this->identifier."-".$this->count()); |
|
61 | 61 | } |
62 | 62 | $this->addItem($fields); |
63 | 63 | return $fields; |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | |
66 | 66 | public function addItem($item) { |
67 | 67 | $item=parent::addItem($item); |
68 | - if (\is_subclass_of($item, HtmlFormField::class) === true) { |
|
68 | + if (\is_subclass_of($item, HtmlFormField::class)===true) { |
|
69 | 69 | $this->_fields[]=$item; |
70 | 70 | } |
71 | 71 | return $item; |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | public function getField($index) { |
75 | 75 | if (\is_string($index)) { |
76 | 76 | $field=$this->getElementById($index, $this->_fields); |
77 | - } else { |
|
77 | + }else { |
|
78 | 78 | $field=$this->_fields[$index]; |
79 | 79 | } |
80 | 80 | return $field; |
@@ -7,19 +7,19 @@ |
||
7 | 7 | |
8 | 8 | use Ajax\semantic\html\elements\HtmlIcon; |
9 | 9 | |
10 | -class HtmlPaginationMenu extends HtmlMenu{ |
|
10 | +class HtmlPaginationMenu extends HtmlMenu { |
|
11 | 11 | |
12 | - public function __construct( $identifier, $items=array() ){ |
|
13 | - parent::__construct( $identifier,$items); |
|
12 | + public function __construct($identifier, $items=array()) { |
|
13 | + parent::__construct($identifier, $items); |
|
14 | 14 | } |
15 | 15 | /** |
16 | 16 | * {@inheritDoc} |
17 | 17 | * @see \Ajax\common\html\BaseHtml::compile() |
18 | 18 | */ |
19 | - public function compile(JsUtils $js=NULL,$view=NULL){ |
|
19 | + public function compile(JsUtils $js=NULL, $view=NULL) { |
|
20 | 20 | $this->insertItem(new HtmlIcon("", "left chevron")); |
21 | 21 | $this->addItem(new HtmlIcon("", "right chevron")); |
22 | 22 | $this->asPagination(); |
23 | - return parent::compile($js,$view); |
|
23 | + return parent::compile($js, $view); |
|
24 | 24 | } |
25 | 25 | } |
26 | 26 | \ No newline at end of file |
@@ -17,31 +17,31 @@ discard block |
||
17 | 17 | } |
18 | 18 | protected $mClass="menu"; |
19 | 19 | protected $mTagName="div"; |
20 | - protected $items=array (); |
|
21 | - protected $_params=array("action"=>"nothing","on"=>"hover"); |
|
20 | + protected $items=array(); |
|
21 | + protected $_params=array("action"=>"nothing", "on"=>"hover"); |
|
22 | 22 | protected $input; |
23 | 23 | |
24 | 24 | public function __construct($identifier, $value="", $items=array()) { |
25 | 25 | parent::__construct($identifier, "div"); |
26 | 26 | $this->_template=include dirname(__FILE__).'/../templates/tplDropdown.php'; |
27 | 27 | $this->setProperty("class", "ui dropdown"); |
28 | - $content=new HtmlSemDoubleElement("text-".$this->identifier,"div"); |
|
28 | + $content=new HtmlSemDoubleElement("text-".$this->identifier, "div"); |
|
29 | 29 | $content->setClass("text"); |
30 | 30 | $content->setContent($value); |
31 | - $content->wrap("",new HtmlIcon("", "dropdown")); |
|
31 | + $content->wrap("", new HtmlIcon("", "dropdown")); |
|
32 | 32 | $this->content=array($content); |
33 | 33 | $this->tagName="div"; |
34 | 34 | $this->addItems($items); |
35 | 35 | } |
36 | 36 | |
37 | - public function addItem($item,$value=NULL,$image=NULL){ |
|
38 | - $itemO=$this->beforeAddItem($item,$value,$image); |
|
37 | + public function addItem($item, $value=NULL, $image=NULL) { |
|
38 | + $itemO=$this->beforeAddItem($item, $value, $image); |
|
39 | 39 | $this->items[]=$itemO; |
40 | 40 | return $itemO; |
41 | 41 | } |
42 | 42 | |
43 | - public function addIcon($icon,$before=true,$labeled=false){ |
|
44 | - $this->addIconP($icon,$before,$labeled); |
|
43 | + public function addIcon($icon, $before=true, $labeled=false) { |
|
44 | + $this->addIconP($icon, $before, $labeled); |
|
45 | 45 | return $this->getElementById("text-".$this->identifier, $this->content)->setWrapAfter(""); |
46 | 46 | } |
47 | 47 | /** |
@@ -50,20 +50,20 @@ discard block |
||
50 | 50 | * @param number $position |
51 | 51 | * @return \Ajax\semantic\html\content\HtmlDropdownItem|unknown |
52 | 52 | */ |
53 | - public function insertItem($item,$position=0){ |
|
53 | + public function insertItem($item, $position=0) { |
|
54 | 54 | $itemO=$this->beforeAddItem($item); |
55 | - $start = array_slice($this->items, 0, $position); |
|
56 | - $end = array_slice($this->items, $position); |
|
57 | - $start[] = $item; |
|
55 | + $start=array_slice($this->items, 0, $position); |
|
56 | + $end=array_slice($this->items, $position); |
|
57 | + $start[]=$item; |
|
58 | 58 | $this->items=array_merge($start, $end); |
59 | 59 | return $itemO; |
60 | 60 | } |
61 | 61 | |
62 | - protected function beforeAddItem($item,$value=NULL,$image=NULL){ |
|
62 | + protected function beforeAddItem($item, $value=NULL, $image=NULL) { |
|
63 | 63 | $itemO=$item; |
64 | - if(!$item instanceof HtmlDropdownItem){ |
|
65 | - $itemO=new HtmlDropdownItem("dd-item-".$this->identifier."-".\sizeof($this->items),$item,$value,$image); |
|
66 | - }elseif($itemO instanceof HtmlDropdownItem){ |
|
64 | + if (!$item instanceof HtmlDropdownItem) { |
|
65 | + $itemO=new HtmlDropdownItem("dd-item-".$this->identifier."-".\sizeof($this->items), $item, $value, $image); |
|
66 | + }elseif ($itemO instanceof HtmlDropdownItem) { |
|
67 | 67 | $this->addToProperty("class", "vertical"); |
68 | 68 | } |
69 | 69 | return $itemO; |
@@ -76,76 +76,76 @@ discard block |
||
76 | 76 | $this->addItem($function($object)); |
77 | 77 | } |
78 | 78 | |
79 | - public function addInput($name){ |
|
80 | - if(!isset($name)) |
|
79 | + public function addInput($name) { |
|
80 | + if (!isset($name)) |
|
81 | 81 | $name="input-".$this->identifier; |
82 | 82 | $this->setAction("activate"); |
83 | - $this->input=new HtmlInput($name,"hidden"); |
|
83 | + $this->input=new HtmlInput($name, "hidden"); |
|
84 | 84 | } |
85 | 85 | |
86 | - public function addItems($items){ |
|
87 | - if(JArray::isAssociative($items)){ |
|
88 | - foreach ($items as $k=>$v){ |
|
86 | + public function addItems($items) { |
|
87 | + if (JArray::isAssociative($items)) { |
|
88 | + foreach ($items as $k=>$v) { |
|
89 | 89 | $this->addItem($v)->setData($k); |
90 | 90 | } |
91 | - }else{ |
|
92 | - foreach ($items as $item){ |
|
91 | + }else { |
|
92 | + foreach ($items as $item) { |
|
93 | 93 | $this->addItem($item); |
94 | 94 | } |
95 | 95 | } |
96 | 96 | } |
97 | 97 | |
98 | - public function count(){ |
|
98 | + public function count() { |
|
99 | 99 | return \sizeof($this->items); |
100 | 100 | } |
101 | 101 | /** |
102 | 102 | * @param boolean $dropdown |
103 | 103 | */ |
104 | - public function asDropdown($dropdown){ |
|
105 | - if($dropdown===false){ |
|
104 | + public function asDropdown($dropdown) { |
|
105 | + if ($dropdown===false) { |
|
106 | 106 | $this->_template=include dirname(__FILE__).'/../templates/tplDropdownMenu.php'; |
107 | 107 | $dropdown="menu"; |
108 | - }else{ |
|
108 | + }else { |
|
109 | 109 | $dropdown="dropdown"; |
110 | 110 | $this->mClass="menu"; |
111 | 111 | } |
112 | - return $this->addToPropertyCtrl("class", $dropdown,array("menu","dropdown")); |
|
112 | + return $this->addToPropertyCtrl("class", $dropdown, array("menu", "dropdown")); |
|
113 | 113 | } |
114 | 114 | |
115 | - public function setVertical(){ |
|
116 | - return $this->addToPropertyCtrl("class", "vertical",array("vertical")); |
|
115 | + public function setVertical() { |
|
116 | + return $this->addToPropertyCtrl("class", "vertical", array("vertical")); |
|
117 | 117 | } |
118 | 118 | |
119 | - public function setSimple(){ |
|
120 | - return $this->addToPropertyCtrl("class", "simple",array("simple")); |
|
119 | + public function setSimple() { |
|
120 | + return $this->addToPropertyCtrl("class", "simple", array("simple")); |
|
121 | 121 | } |
122 | 122 | |
123 | - public function asButton($floating=false){ |
|
124 | - if($floating) |
|
123 | + public function asButton($floating=false) { |
|
124 | + if ($floating) |
|
125 | 125 | $this->addToProperty("class", "floating"); |
126 | 126 | return $this->addToProperty("class", "button"); |
127 | 127 | } |
128 | 128 | |
129 | - public function asSelect($name=NULL,$multiple=false,$selection=true){ |
|
130 | - if(isset($name)) |
|
129 | + public function asSelect($name=NULL, $multiple=false, $selection=true) { |
|
130 | + if (isset($name)) |
|
131 | 131 | $this->addInput($name); |
132 | - if($multiple) |
|
132 | + if ($multiple) |
|
133 | 133 | $this->addToProperty("class", "multiple"); |
134 | 134 | if ($selection) |
135 | - $this->addToPropertyCtrl("class", "selection",array("selection")); |
|
135 | + $this->addToPropertyCtrl("class", "selection", array("selection")); |
|
136 | 136 | return $this; |
137 | 137 | } |
138 | 138 | |
139 | - public function asSearch($name=NULL,$multiple=false,$selection=false){ |
|
140 | - $this->asSelect($name,$multiple,$selection); |
|
139 | + public function asSearch($name=NULL, $multiple=false, $selection=false) { |
|
140 | + $this->asSelect($name, $multiple, $selection); |
|
141 | 141 | return $this->addToProperty("class", "search"); |
142 | 142 | } |
143 | 143 | |
144 | - public function setSelect($name=NULL,$multiple=false){ |
|
145 | - if(!isset($name)) |
|
144 | + public function setSelect($name=NULL, $multiple=false) { |
|
145 | + if (!isset($name)) |
|
146 | 146 | $name="select-".$this->identifier; |
147 | 147 | $this->input=null; |
148 | - if($multiple){ |
|
148 | + if ($multiple) { |
|
149 | 149 | $this->setProperty("multiple", true); |
150 | 150 | $this->addToProperty("class", "multiple"); |
151 | 151 | } |
@@ -153,32 +153,32 @@ discard block |
||
153 | 153 | $this->tagName="select"; |
154 | 154 | $this->setProperty("name", $name); |
155 | 155 | $this->content=null; |
156 | - foreach ($this->items as $item){ |
|
156 | + foreach ($this->items as $item) { |
|
157 | 157 | $item->asOption(); |
158 | 158 | } |
159 | 159 | return $this; |
160 | 160 | } |
161 | 161 | |
162 | - public function asSubmenu($pointing=NULL){ |
|
162 | + public function asSubmenu($pointing=NULL) { |
|
163 | 163 | $this->setClass("ui dropdown link item"); |
164 | - if(isset($pointing)){ |
|
164 | + if (isset($pointing)) { |
|
165 | 165 | $this->setPointing($pointing); |
166 | 166 | } |
167 | 167 | return $this; |
168 | 168 | } |
169 | 169 | |
170 | - public function setPointing($value=Direction::NONE){ |
|
171 | - return $this->addToPropertyCtrl("class", $value." pointing",Direction::getConstantValues("pointing")); |
|
170 | + public function setPointing($value=Direction::NONE) { |
|
171 | + return $this->addToPropertyCtrl("class", $value." pointing", Direction::getConstantValues("pointing")); |
|
172 | 172 | } |
173 | 173 | |
174 | - public function setValue($value){ |
|
175 | - if(isset($this->input)){ |
|
174 | + public function setValue($value) { |
|
175 | + if (isset($this->input)) { |
|
176 | 176 | $this->input->setProperty("value", $value); |
177 | - }else{ |
|
177 | + }else { |
|
178 | 178 | $this->setProperty("value", $value); |
179 | 179 | } |
180 | 180 | $textElement=$this->getElementById("text-".$this->identifier, $this->content); |
181 | - if(isset($textElement)) |
|
181 | + if (isset($textElement)) |
|
182 | 182 | $textElement->setContent($value); |
183 | 183 | return $this; |
184 | 184 | } |
@@ -188,23 +188,23 @@ discard block |
||
188 | 188 | * @see BaseHtml::run() |
189 | 189 | */ |
190 | 190 | public function run(JsUtils $js) { |
191 | - if($this->propertyContains("class", "simple")===false){ |
|
192 | - if(isset($this->_bsComponent)===false) |
|
193 | - $this->_bsComponent=$js->semantic()->dropdown("#".$this->identifier,$this->_params); |
|
191 | + if ($this->propertyContains("class", "simple")===false) { |
|
192 | + if (isset($this->_bsComponent)===false) |
|
193 | + $this->_bsComponent=$js->semantic()->dropdown("#".$this->identifier, $this->_params); |
|
194 | 194 | $this->addEventsOnRun($js); |
195 | 195 | return $this->_bsComponent; |
196 | 196 | } |
197 | 197 | } |
198 | 198 | |
199 | - public function setCompact(){ |
|
199 | + public function setCompact() { |
|
200 | 200 | return $this->addToPropertyCtrl("class", "compact", array("compact")); |
201 | 201 | } |
202 | 202 | |
203 | - public function setAction($action){ |
|
203 | + public function setAction($action) { |
|
204 | 204 | $this->_params["action"]=$action; |
205 | 205 | } |
206 | 206 | |
207 | - public function setFullTextSearch($value){ |
|
207 | + public function setFullTextSearch($value) { |
|
208 | 208 | $this->_params["fullTextSearch"]=$value; |
209 | 209 | } |
210 | 210 | } |
211 | 211 | \ No newline at end of file |
@@ -22,8 +22,8 @@ discard block |
||
22 | 22 | /** |
23 | 23 | * JsUtils Class : Service to be injected |
24 | 24 | */ |
25 | -abstract class JsUtils{ |
|
26 | - use JsUtilsEventsTrait,JsUtilsActionsTrait,JsUtilsAjaxTrait; |
|
25 | +abstract class JsUtils { |
|
26 | + use JsUtilsEventsTrait, JsUtilsActionsTrait, JsUtilsAjaxTrait; |
|
27 | 27 | |
28 | 28 | protected $js; |
29 | 29 | protected $cdns; |
@@ -50,19 +50,19 @@ discard block |
||
50 | 50 | protected $config; |
51 | 51 | |
52 | 52 | protected function _setDi($di) { |
53 | - if ($this->js!=null&&$di!=null) |
|
53 | + if ($this->js!=null && $di!=null) |
|
54 | 54 | $this->js->setDi($di); |
55 | 55 | } |
56 | 56 | |
57 | 57 | public abstract function getUrl($url); |
58 | - public abstract function addViewElement($identifier,$content,$view); |
|
58 | + public abstract function addViewElement($identifier, $content, $view); |
|
59 | 59 | /** |
60 | 60 | * render the content of $controller::$action and set the response to the modal content |
61 | 61 | * @param Controller $initialController |
62 | 62 | * @param string $controller a Phalcon controller |
63 | 63 | * @param string $action a Phalcon action |
64 | 64 | */ |
65 | - public abstract function forward($initialController,$controller,$action); |
|
65 | + public abstract function forward($initialController, $controller, $action); |
|
66 | 66 | /** |
67 | 67 | * render the content of an existing view : $controller/$action and set the response to the modal content |
68 | 68 | * @param View $view |
@@ -162,18 +162,18 @@ discard block |
||
162 | 162 | } |
163 | 163 | |
164 | 164 | public function __construct($params=array()) { |
165 | - $defaults=array ( |
|
165 | + $defaults=array( |
|
166 | 166 | 'driver' => 'Jquery', |
167 | 167 | 'debug' => true |
168 | 168 | ); |
169 | - foreach ( $defaults as $key => $val ) { |
|
170 | - if (isset($params[$key])&&$params[$key]!=="") { |
|
169 | + foreach ($defaults as $key => $val) { |
|
170 | + if (isset($params[$key]) && $params[$key]!=="") { |
|
171 | 171 | $defaults[$key]=$params[$key]; |
172 | 172 | } |
173 | 173 | } |
174 | 174 | extract($defaults); |
175 | - $this->js=new Jquery($defaults,$this); |
|
176 | - $this->cdns=array (); |
|
175 | + $this->js=new Jquery($defaults, $this); |
|
176 | + $this->cdns=array(); |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | public function addToCompile($jsScript) { |
@@ -210,11 +210,11 @@ discard block |
||
210 | 210 | */ |
211 | 211 | public function compile($view=NULL, $view_var='script_foot', $script_tags=TRUE) { |
212 | 212 | $bs=$this->_bootstrap; |
213 | - if (isset($bs)&&isset($view)) { |
|
213 | + if (isset($bs) && isset($view)) { |
|
214 | 214 | $bs->compileHtml($this, $view); |
215 | 215 | } |
216 | 216 | $sem=$this->_semantic; |
217 | - if (isset($sem)&&isset($view)) { |
|
217 | + if (isset($sem) && isset($view)) { |
|
218 | 218 | $sem->compileHtml($this, $view); |
219 | 219 | } |
220 | 220 | return $this->js->_compile($view, $view_var, $script_tags); |
@@ -281,27 +281,27 @@ discard block |
||
281 | 281 | $json_result=$result->result_array(); |
282 | 282 | } elseif (is_array($result)) { |
283 | 283 | $json_result=$result; |
284 | - } else { |
|
284 | + }else { |
|
285 | 285 | return $this->_prep_args($result); |
286 | 286 | } |
287 | - } else { |
|
287 | + }else { |
|
288 | 288 | return 'null'; |
289 | 289 | } |
290 | 290 | return $this->_create_json($json_result, $match_array_type); |
291 | 291 | } |
292 | 292 | |
293 | 293 | private function _create_json($json_result, $match_array_type) { |
294 | - $json=array (); |
|
294 | + $json=array(); |
|
295 | 295 | $_is_assoc=TRUE; |
296 | - if (!is_array($json_result)&&empty($json_result)) { |
|
296 | + if (!is_array($json_result) && empty($json_result)) { |
|
297 | 297 | show_error("Generate JSON Failed - Illegal key, value pair."); |
298 | 298 | } elseif ($match_array_type) { |
299 | 299 | $_is_assoc=$this->_is_associative_array($json_result); |
300 | 300 | } |
301 | - foreach ( $json_result as $k => $v ) { |
|
301 | + foreach ($json_result as $k => $v) { |
|
302 | 302 | if ($_is_assoc) { |
303 | 303 | $json[]=$this->_prep_args($k, TRUE).':'.$this->generate_json($v, $match_array_type); |
304 | - } else { |
|
304 | + }else { |
|
305 | 305 | $json[]=$this->generate_json($v, $match_array_type); |
306 | 306 | } |
307 | 307 | } |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | * @return type |
317 | 317 | */ |
318 | 318 | public function _is_associative_array($arr) { |
319 | - foreach ( array_keys($arr) as $key => $val ) { |
|
319 | + foreach (array_keys($arr) as $key => $val) { |
|
320 | 320 | if ($key!==$val) { |
321 | 321 | return TRUE; |
322 | 322 | } |
@@ -335,11 +335,11 @@ discard block |
||
335 | 335 | return 'null'; |
336 | 336 | } elseif (is_bool($result)) { |
337 | 337 | return ($result===TRUE) ? 'true' : 'false'; |
338 | - } elseif (is_string($result)||$is_key) { |
|
339 | - return '"'.str_replace(array ( |
|
340 | - '\\',"\t","\n","\r",'"','/' |
|
341 | - ), array ( |
|
342 | - '\\\\','\\t','\\n',"\\r",'\"','\/' |
|
338 | + } elseif (is_string($result) || $is_key) { |
|
339 | + return '"'.str_replace(array( |
|
340 | + '\\', "\t", "\n", "\r", '"', '/' |
|
341 | + ), array( |
|
342 | + '\\\\', '\\t', '\\n', "\\r", '\"', '\/' |
|
343 | 343 | ), $result).'"'; |
344 | 344 | } elseif (is_scalar($result)) { |
345 | 345 | return $result; |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | |
353 | 353 | public function setCDNs($cdns) { |
354 | 354 | if (is_array($cdns)===false) { |
355 | - $cdns=array ( |
|
355 | + $cdns=array( |
|
356 | 356 | $cdns |
357 | 357 | ); |
358 | 358 | } |
@@ -364,9 +364,9 @@ discard block |
||
364 | 364 | $hasJQueryUI=false; |
365 | 365 | $hasBootstrap=false; |
366 | 366 | $hasSemantic=false; |
367 | - $result=array (); |
|
368 | - foreach ( $this->cdns as $cdn ) { |
|
369 | - switch(get_class($cdn)) { |
|
367 | + $result=array(); |
|
368 | + foreach ($this->cdns as $cdn) { |
|
369 | + switch (get_class($cdn)) { |
|
370 | 370 | case "Ajax\lib\CDNJQuery": |
371 | 371 | $hasJQuery=true; |
372 | 372 | $result[0]=$cdn; |
@@ -376,11 +376,11 @@ discard block |
||
376 | 376 | $result[1]=$cdn; |
377 | 377 | break; |
378 | 378 | case "Ajax\lib\CDNCoreCss": |
379 | - if($cdn->getFramework()==="Bootstrap") |
|
379 | + if ($cdn->getFramework()==="Bootstrap") |
|
380 | 380 | $hasBootstrap=true; |
381 | - elseif($cdn->getFramework()==="Semantic") |
|
381 | + elseif ($cdn->getFramework()==="Semantic") |
|
382 | 382 | $hasSemantic=true; |
383 | - if($hasSemantic || $hasBootstrap) |
|
383 | + if ($hasSemantic || $hasBootstrap) |
|
384 | 384 | $result[2]=$cdn; |
385 | 385 | break; |
386 | 386 | } |
@@ -388,14 +388,14 @@ discard block |
||
388 | 388 | if ($hasJQuery===false) { |
389 | 389 | $result[0]=new CDNJQuery("x"); |
390 | 390 | } |
391 | - if ($hasJQueryUI===false&&isset($this->_ui)) { |
|
391 | + if ($hasJQueryUI===false && isset($this->_ui)) { |
|
392 | 392 | $result[1]=new CDNGuiGen("x", $template); |
393 | 393 | } |
394 | - if ($hasBootstrap===false&&isset($this->_bootstrap)) { |
|
395 | - $result[2]=new CDNCoreCss("Bootstrap","x"); |
|
394 | + if ($hasBootstrap===false && isset($this->_bootstrap)) { |
|
395 | + $result[2]=new CDNCoreCss("Bootstrap", "x"); |
|
396 | 396 | } |
397 | - if ($hasSemantic===false&&isset($this->_semantic)) { |
|
398 | - $result[2]=new CDNCoreCss("Semantic","x"); |
|
397 | + if ($hasSemantic===false && isset($this->_semantic)) { |
|
398 | + $result[2]=new CDNCoreCss("Semantic", "x"); |
|
399 | 399 | } |
400 | 400 | ksort($result); |
401 | 401 | return implode("\n", $result); |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | use Phalcon\Mvc\View; |
8 | 8 | use Phalcon\Mvc\Controller; |
9 | 9 | |
10 | -class JsUtils extends \Ajax\JsUtils implements InjectionAwareInterface{ |
|
10 | +class JsUtils extends \Ajax\JsUtils implements InjectionAwareInterface { |
|
11 | 11 | protected $_di; |
12 | 12 | public function setDi(DiInterface $di) { |
13 | 13 | $this->_di=$di; |
@@ -18,45 +18,45 @@ discard block |
||
18 | 18 | return $this->_di; |
19 | 19 | } |
20 | 20 | |
21 | - public function getUrl($url){ |
|
21 | + public function getUrl($url) { |
|
22 | 22 | return $this->_di->get("url")->get($url); |
23 | 23 | } |
24 | 24 | |
25 | - public function addViewElement($identifier,$content,$view){ |
|
25 | + public function addViewElement($identifier, $content, $view) { |
|
26 | 26 | $controls=$view->getVar("q"); |
27 | - if (isset($controls) === false) { |
|
28 | - $controls=array (); |
|
27 | + if (isset($controls)===false) { |
|
28 | + $controls=array(); |
|
29 | 29 | } |
30 | 30 | $controls[$identifier]=$content; |
31 | 31 | $view->setVar("q", $controls); |
32 | 32 | } |
33 | 33 | |
34 | - public function forward($initialController,$controller,$action){ |
|
35 | - $dispatcher = $initialController->dispatcher; |
|
34 | + public function forward($initialController, $controller, $action) { |
|
35 | + $dispatcher=$initialController->dispatcher; |
|
36 | 36 | $dispatcher->setControllerName($controller); |
37 | 37 | $dispatcher->setActionName($action); |
38 | 38 | $dispatcher->dispatch(); |
39 | - $template=$initialController->view->getRender($dispatcher->getControllerName(), $dispatcher->getActionName(),$dispatcher->getParams(), function ($view) { |
|
39 | + $template=$initialController->view->getRender($dispatcher->getControllerName(), $dispatcher->getActionName(), $dispatcher->getParams(), function($view) { |
|
40 | 40 | $view->setRenderLevel(View::LEVEL_ACTION_VIEW); |
41 | 41 | }); |
42 | 42 | return $template; |
43 | 43 | } |
44 | 44 | |
45 | 45 | public function renderContent($view, $controller, $action, $params=NULL) { |
46 | - $template=$view->getRender($controller, $action, $params, function ($view) { |
|
46 | + $template=$view->getRender($controller, $action, $params, function($view) { |
|
47 | 47 | $view->setRenderLevel(View::LEVEL_ACTION_VIEW); |
48 | 48 | }); |
49 | 49 | return $template; |
50 | 50 | } |
51 | 51 | |
52 | - public function fromDispatcher($dispatcher){ |
|
52 | + public function fromDispatcher($dispatcher) { |
|
53 | 53 | $params=$dispatcher->getParams(); |
54 | 54 | $action=$dispatcher->getActionName(); |
55 | 55 | $items=array($dispatcher->getControllerName()); |
56 | - if(\sizeof($params)>0 || \strtolower($action)!="index" ){ |
|
56 | + if (\sizeof($params)>0 || \strtolower($action)!="index") { |
|
57 | 57 | $items[]=$action; |
58 | - foreach ($params as $p){ |
|
59 | - if(\is_object($p)===false) |
|
58 | + foreach ($params as $p) { |
|
59 | + if (\is_object($p)===false) |
|
60 | 60 | $items[]=$p; |
61 | 61 | } |
62 | 62 | } |
@@ -56,8 +56,9 @@ |
||
56 | 56 | if(\sizeof($params)>0 || \strtolower($action)!="index" ){ |
57 | 57 | $items[]=$action; |
58 | 58 | foreach ($params as $p){ |
59 | - if(\is_object($p)===false) |
|
60 | - $items[]=$p; |
|
59 | + if(\is_object($p)===false) { |
|
60 | + $items[]=$p; |
|
61 | + } |
|
61 | 62 | } |
62 | 63 | } |
63 | 64 | return $items; |