Completed
Push — master ( 06f62d...424d4e )
by Jean-Christophe
03:13
created
Ajax/semantic/html/collections/HtmlBreadcrumb.php 1 patch
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
  * @author jc
14 14
  * @version 1.001
15 15
  */
16
-class HtmlBreadcrumb extends HtmlSemNavElement{
16
+class HtmlBreadcrumb extends HtmlSemNavElement {
17 17
 	/**
18 18
 	 * @var integer the start index for href generation
19 19
 	 */
@@ -39,13 +39,13 @@  discard block
 block discarded – undo
39 39
 	 * @param boolean $autoActive sets the last element's class to <b>active</b> if true
40 40
 	 * @param function $hrefFunction the function who generates the href elements. default : function($e){return $e->getContent()}
41 41
 	 */
42
-	public function __construct( $identifier,$items=array(),$autoActive=true,$startIndex=0,$hrefFunction=NULL){
43
-		parent::__construct( $identifier, "div", "ui breadcrumb");
42
+	public function __construct($identifier, $items=array(), $autoActive=true, $startIndex=0, $hrefFunction=NULL) {
43
+		parent::__construct($identifier, "div", "ui breadcrumb");
44 44
 		$this->startIndex=$startIndex;
45 45
 		$this->autoActive=$autoActive;
46 46
 		$this->_contentSeparator="<div class='divider'> / </div>";
47
-		$this->_hrefFunction=function ($e){return $e->getContent();};
48
-		if(isset($hrefFunction)){
47
+		$this->_hrefFunction=function($e) {return $e->getContent(); };
48
+		if (isset($hrefFunction)) {
49 49
 			$this->_hrefFunction=$hrefFunction;
50 50
 		}
51 51
 		$this->addItems($items);
@@ -58,23 +58,23 @@  discard block
 block discarded – undo
58 58
 	 * @param string $attr the html attribute used to build the elements url
59 59
 	 * @return HtmlBreadcrumbs
60 60
 	 */
61
-	public function autoGetOnClick($targetSelector){
62
-		return $this->getOnClick($this->root, $targetSelector,array("attr"=>$this->attr));
61
+	public function autoGetOnClick($targetSelector) {
62
+		return $this->getOnClick($this->root, $targetSelector, array("attr"=>$this->attr));
63 63
 	}
64 64
 
65
-	public function contentAsString(){
66
-		if($this->autoActive){
65
+	public function contentAsString() {
66
+		if ($this->autoActive) {
67 67
 			$this->setActive();
68 68
 		}
69 69
 		return parent::contentAsString();
70 70
 	}
71 71
 
72
-	public function setActive($index=null){
73
-		if(!isset($index)){
72
+	public function setActive($index=null) {
73
+		if (!isset($index)) {
74 74
 			$index=sizeof($this->content)-1;
75 75
 		}
76 76
 		$activeItem=$this->content[$index];
77
-		$activeItem->addToProperty("class","active");
77
+		$activeItem->addToProperty("class", "active");
78 78
 		$activeItem->setTagName("div");
79 79
 	}
80 80
 
@@ -83,15 +83,15 @@  discard block
 block discarded – undo
83 83
 	 * @param Dispatcher $dispatcher the request dispatcher
84 84
 	 * @return \Ajax\bootstrap\html\HtmlBreadcrumbs
85 85
 	 */
86
-	public function fromDispatcher($dispatcher,$startIndex=0){
86
+	public function fromDispatcher($dispatcher, $startIndex=0) {
87 87
 		$this->startIndex=$startIndex;
88 88
 		$params=$dispatcher->getParams();
89 89
 		$action=$dispatcher->getActionName();
90 90
 		$items=array($dispatcher->getControllerName());
91
-		if(\sizeof($params)>0 || \strtolower($action)!="index" ){
91
+		if (\sizeof($params)>0 || \strtolower($action)!="index") {
92 92
 			$items[]=$action;
93
-			foreach ($params as $p){
94
-				if(\is_object($p)===false)
93
+			foreach ($params as $p) {
94
+				if (\is_object($p)===false)
95 95
 					$items[]=$p;
96 96
 			}
97 97
 		}
@@ -104,14 +104,14 @@  discard block
 block discarded – undo
104 104
 	 * @param string $separator
105 105
 	 * @return string
106 106
 	 */
107
-	public function getHref($index=null,$separator="/"){
108
-		if(!isset($index)){
107
+	public function getHref($index=null, $separator="/") {
108
+		if (!isset($index)) {
109 109
 			$index=sizeof($this->content);
110 110
 		}
111
-		if($this->absolutePaths===true){
111
+		if ($this->absolutePaths===true) {
112 112
 			return $this->_hrefFunction($this->content[$index]);
113
-		}else{
114
-			return $this->root.implode($separator, array_slice(array_map(function($e){return $this->_hrefFunction($e);}, $this->content),$this->startIndex,$index+1));
113
+		}else {
114
+			return $this->root.implode($separator, array_slice(array_map(function($e) {return $this->_hrefFunction($e); }, $this->content), $this->startIndex, $index+1));
115 115
 		}
116 116
 	}
117 117
 
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 	 * @return \Ajax\bootstrap\html\HtmlBreadcrumbs
122 122
 	 */
123 123
 	public function setHrefFunction($_hrefFunction) {
124
-		$this->_hrefFunction = $_hrefFunction;
124
+		$this->_hrefFunction=$_hrefFunction;
125 125
 		return $this;
126 126
 	}
127 127
 
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 	}
132 132
 
133 133
 	public function setAutoActive($autoActive) {
134
-		$this->autoActive = $autoActive;
134
+		$this->autoActive=$autoActive;
135 135
 		return $this;
136 136
 	}
137 137
 
@@ -140,11 +140,11 @@  discard block
 block discarded – undo
140 140
 	 * @see \Ajax\bootstrap\html\BaseHtml::compile()
141 141
 	 */
142 142
 	public function compile(JsUtils $js=NULL, View $view=NULL) {
143
-		if($this->autoActive){
143
+		if ($this->autoActive) {
144 144
 			$this->setActive();
145 145
 		}
146 146
 		$count=$this->count();
147
-		for($i=1;$i<$count;$i++){
147
+		for ($i=1; $i<$count; $i++) {
148 148
 			$this->content[$i]->wrap($this->_contentSeparator);
149 149
 		}
150 150
 		return parent::compile($js, $view);
@@ -155,15 +155,15 @@  discard block
 block discarded – undo
155 155
 	 * @see \Ajax\bootstrap\html\base\BaseHtml::on()
156 156
 	 */
157 157
 	public function on($event, $jsCode, $stopPropagation=false, $preventDefault=false) {
158
-		foreach ($this->content as $element){
159
-			$element->on($event,$jsCode,$stopPropagation,$preventDefault);
158
+		foreach ($this->content as $element) {
159
+			$element->on($event, $jsCode, $stopPropagation, $preventDefault);
160 160
 		}
161 161
 		return $this;
162 162
 	}
163 163
 
164 164
 
165 165
 	public function _ajaxOn($operation, $event, $url, $responseElement="", $parameters=array()) {
166
-		foreach ($this->content as $element){
166
+		foreach ($this->content as $element) {
167 167
 			$element->_ajaxOn($operation, $event, $url, $responseElement, $parameters);
168 168
 		}
169 169
 		return $this;
@@ -175,19 +175,19 @@  discard block
 block discarded – undo
175 175
 	 */
176 176
 	protected function createItem($value) {
177 177
 		$count=$this->count();
178
-		$itemO=new HtmlSemDoubleElement("item-".$this->identifier."-".$count,"a","section");
179
-		if(\is_array($value))
178
+		$itemO=new HtmlSemDoubleElement("item-".$this->identifier."-".$count, "a", "section");
179
+		if (\is_array($value))
180 180
 			$itemO->fromArray($value);
181
-		else{
181
+		else {
182 182
 			$itemO->setContent($value);
183 183
 			$itemO->setProperty($this->attr, $this->getHref($count));
184 184
 		}
185 185
 		return $itemO;
186 186
 	}
187 187
 
188
-	public function addIcon($icon,$index){
188
+	public function addIcon($icon, $index) {
189 189
 		$item=$this->getItem($index);
190
-		if(isset($item)){
190
+		if (isset($item)) {
191 191
 			$icon=new HtmlIcon("icon-".$this->identifier, $icon);
192 192
 			$item->wrapContent($icon);
193 193
 		}
Please login to merge, or discard this patch.
Ajax/semantic/html/elements/HtmlSegmentGroups.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -6,20 +6,20 @@  discard block
 block discarded – undo
6 6
 use Ajax\semantic\html\base\HtmlSemCollection;
7 7
 use Ajax\semantic\html\base\constants\Sens;
8 8
 
9
-class HtmlSegmentGroups extends HtmlSemCollection{
9
+class HtmlSegmentGroups extends HtmlSemCollection {
10 10
 
11 11
 
12
-	public function __construct( $identifier, $items=array()){
13
-		parent::__construct( $identifier, "div","ui segments");
12
+	public function __construct($identifier, $items=array()) {
13
+		parent::__construct($identifier, "div", "ui segments");
14 14
 		$this->addItems($items);
15 15
 	}
16 16
 
17 17
 
18
-	protected function createItem($value){
19
-		return new HtmlSegment("segment-".$this->count(),$value);
18
+	protected function createItem($value) {
19
+		return new HtmlSegment("segment-".$this->count(), $value);
20 20
 	}
21 21
 
22
-	protected function createCondition($value){
22
+	protected function createCondition($value) {
23 23
 		return !($value instanceof HtmlSegment);
24 24
 	}
25 25
 
@@ -28,16 +28,16 @@  discard block
 block discarded – undo
28 28
 	 * @param string $type one of "raised","stacked","piled" default : ""
29 29
 	 * @return \Ajax\semantic\html\elements\HtmlSegmentGroups
30 30
 	 */
31
-	public function setType($type){
31
+	public function setType($type) {
32 32
 		return $this->addToPropertyCtrl("class", $type, SegmentType::getConstants());
33 33
 	}
34 34
 
35
-	public function setSens($sens=Sens::VERTICAL){
35
+	public function setSens($sens=Sens::VERTICAL) {
36 36
 		return $this->addToPropertyCtrl("class", $sens, Sens::getConstants());
37 37
 	}
38 38
 
39
-	public static function group($identifier,$items=array(),$type="",$sens=Sens::VERTICAL){
40
-		$group=new HtmlSegmentGroups($identifier,$items);
39
+	public static function group($identifier, $items=array(), $type="", $sens=Sens::VERTICAL) {
40
+		$group=new HtmlSegmentGroups($identifier, $items);
41 41
 		$group->setSens($sens);
42 42
 		return $group->setType($type);
43 43
 	}
Please login to merge, or discard this patch.
Ajax/semantic/html/modules/HtmlDropdown.php 1 patch
Spacing   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -13,28 +13,28 @@  discard block
 block discarded – undo
13 13
 class HtmlDropdown extends HtmlSemDoubleElement {
14 14
 	protected $mClass="menu";
15 15
 	protected $mTagName="div";
16
-	protected $items=array ();
17
-	protected $params=array("action"=>"auto","on"=>"hover");
16
+	protected $items=array();
17
+	protected $params=array("action"=>"auto", "on"=>"hover");
18 18
 	protected $input;
19 19
 
20 20
 	public function __construct($identifier, $value="", $items=array()) {
21 21
 		parent::__construct($identifier, "div");
22 22
 		$this->_template=include dirname(__FILE__).'/../templates/tplDropdown.php';
23 23
 		$this->setProperty("class", "ui dropdown");
24
-		$content=new HtmlSemDoubleElement("text-".$this->identifier,"div");
24
+		$content=new HtmlSemDoubleElement("text-".$this->identifier, "div");
25 25
 		$content->setClass("text");
26 26
 		$content->setContent($value);
27
-		$content->wrap("",new HtmlIcon("", "dropdown"));
27
+		$content->wrap("", new HtmlIcon("", "dropdown"));
28 28
 		$this->content=array($content);
29 29
 		$this->tagName="div";
30 30
 		$this->addItems($items);
31 31
 	}
32 32
 
33
-	public function addItem($item,$value=NULL,$image=NULL){
33
+	public function addItem($item, $value=NULL, $image=NULL) {
34 34
 		$itemO=$item;
35
-		if(\is_object($item)===false){
36
-			$itemO=new HtmlDropdownItem("dd-item-".$this->identifier."-".\sizeof($this->items),$item,$value,$image);
37
-		}elseif($itemO instanceof HtmlDropdownItem){
35
+		if (\is_object($item)===false) {
36
+			$itemO=new HtmlDropdownItem("dd-item-".$this->identifier."-".\sizeof($this->items), $item, $value, $image);
37
+		}elseif ($itemO instanceof HtmlDropdownItem) {
38 38
 			$this->addToProperty("class", "vertical");
39 39
 		}
40 40
 		$this->items[]=$itemO;
@@ -48,20 +48,20 @@  discard block
 block discarded – undo
48 48
 		$this->addItem($function($object));
49 49
 	}
50 50
 
51
-	public function addInput($name){
52
-		if(!isset($name))
51
+	public function addInput($name) {
52
+		if (!isset($name))
53 53
 			$name="input-".$this->identifier;
54 54
 		$this->setAction("activate");
55
-		$this->input=new HtmlInput($name,"hidden");
55
+		$this->input=new HtmlInput($name, "hidden");
56 56
 	}
57 57
 
58
-	public function addItems($items){
59
-		if(JArray::isAssociative($items)){
60
-			foreach ($items as $k=>$v){
58
+	public function addItems($items) {
59
+		if (JArray::isAssociative($items)) {
60
+			foreach ($items as $k=>$v) {
61 61
 				$this->addItem($v)->setData($k);
62 62
 			}
63
-		}else{
64
-			foreach ($items as $item){
63
+		}else {
64
+			foreach ($items as $item) {
65 65
 				$this->addItem($item);
66 66
 			}
67 67
 		}
@@ -70,51 +70,51 @@  discard block
 block discarded – undo
70 70
 	/**
71 71
 	 * @param boolean $dropdown
72 72
 	 */
73
-	public function asDropdown($dropdown){
74
-		if($dropdown===false){
73
+	public function asDropdown($dropdown) {
74
+		if ($dropdown===false) {
75 75
 			$this->_template=include dirname(__FILE__).'/../templates/tplDropdownMenu.php';
76 76
 			$dropdown="menu";
77
-		}else{
77
+		}else {
78 78
 			$dropdown="dropdown";
79 79
 			$this->mClass="menu";
80 80
 		}
81
-		return $this->addToPropertyCtrl("class", $dropdown,array("menu","dropdown"));
81
+		return $this->addToPropertyCtrl("class", $dropdown, array("menu", "dropdown"));
82 82
 	}
83 83
 
84
-	public function setVertical(){
85
-		return $this->addToPropertyCtrl("class", "vertical",array("vertical"));
84
+	public function setVertical() {
85
+		return $this->addToPropertyCtrl("class", "vertical", array("vertical"));
86 86
 	}
87 87
 
88
-	public function setSimple(){
89
-		return $this->addToPropertyCtrl("class", "simple",array("simple"));
88
+	public function setSimple() {
89
+		return $this->addToPropertyCtrl("class", "simple", array("simple"));
90 90
 	}
91 91
 
92
-	public function asButton($floating=false){
93
-		if($floating)
92
+	public function asButton($floating=false) {
93
+		if ($floating)
94 94
 			$this->addToProperty("class", "floating");
95 95
 		return $this->addToProperty("class", "button");
96 96
 	}
97 97
 
98
-	public function asSelect($name=NULL,$multiple=false,$selection=true){
99
-		if(isset($name))
98
+	public function asSelect($name=NULL, $multiple=false, $selection=true) {
99
+		if (isset($name))
100 100
 			$this->addInput($name);
101
-		if($multiple)
101
+		if ($multiple)
102 102
 			$this->addToProperty("class", "multiple");
103 103
 		if ($selection)
104
-			$this->addToPropertyCtrl("class", "selection",array("selection"));
104
+			$this->addToPropertyCtrl("class", "selection", array("selection"));
105 105
 		return $this;
106 106
 	}
107 107
 
108
-	public function asSearch($name=NULL,$multiple=false,$selection=false){
109
-		$this->asSelect($name,$multiple,$selection);
108
+	public function asSearch($name=NULL, $multiple=false, $selection=false) {
109
+		$this->asSelect($name, $multiple, $selection);
110 110
 		return $this->addToProperty("class", "search");
111 111
 	}
112 112
 
113
-	public function setSelect($name=NULL,$multiple=false){
114
-		if(!isset($name))
113
+	public function setSelect($name=NULL, $multiple=false) {
114
+		if (!isset($name))
115 115
 			$name="select-".$this->identifier;
116 116
 		$this->input=null;
117
-		if($multiple){
117
+		if ($multiple) {
118 118
 			$this->setProperty("multiple", true);
119 119
 			$this->addToProperty("class", "multiple");
120 120
 		}
@@ -122,32 +122,32 @@  discard block
 block discarded – undo
122 122
 		$this->tagName="select";
123 123
 		$this->setProperty("name", $name);
124 124
 		$this->content=null;
125
-		foreach ($this->items as $item){
125
+		foreach ($this->items as $item) {
126 126
 			$item->asOption();
127 127
 		}
128 128
 		return $this;
129 129
 	}
130 130
 
131
-	public function asSubmenu($pointing=NULL){
131
+	public function asSubmenu($pointing=NULL) {
132 132
 		$this->setClass("ui dropdown link item");
133
-		if(isset($pointing)){
133
+		if (isset($pointing)) {
134 134
 			$this->setPointing($pointing);
135 135
 		}
136 136
 		return $this;
137 137
 	}
138 138
 
139
-	public function setPointing($value=Direction::NONE){
140
-		return $this->addToPropertyCtrl("class", $value." pointing",Direction::getConstantValues("pointing"));
139
+	public function setPointing($value=Direction::NONE) {
140
+		return $this->addToPropertyCtrl("class", $value." pointing", Direction::getConstantValues("pointing"));
141 141
 	}
142 142
 
143
-	public function setValue($value){
144
-		if(isset($this->input)){
143
+	public function setValue($value) {
144
+		if (isset($this->input)) {
145 145
 			$this->input->setProperty("value", $value);
146
-		}else{
146
+		}else {
147 147
 			$this->setProperty("value", $value);
148 148
 		}
149 149
 		$textElement=$this->getElementById("text-".$this->identifier, $this->content);
150
-		if(isset($textElement))
150
+		if (isset($textElement))
151 151
 			$textElement->setContent($value);
152 152
 		return $this;
153 153
 	}
@@ -157,15 +157,15 @@  discard block
 block discarded – undo
157 157
 	 * @see BaseHtml::run()
158 158
 	 */
159 159
 	public function run(JsUtils $js) {
160
-		if($this->propertyContains("class", "simple")===false){
161
-			if(isset($this->_bsComponent)===false)
162
-				$this->_bsComponent=$js->semantic()->dropdown("#".$this->identifier,$this->params);
160
+		if ($this->propertyContains("class", "simple")===false) {
161
+			if (isset($this->_bsComponent)===false)
162
+				$this->_bsComponent=$js->semantic()->dropdown("#".$this->identifier, $this->params);
163 163
 			$this->addEventsOnRun($js);
164 164
 			return $this->_bsComponent;
165 165
 		}
166 166
 	}
167 167
 
168
-	public function setAction($action){
168
+	public function setAction($action) {
169 169
 		$this->params["action"]=$action;
170 170
 	}
171 171
 }
172 172
\ No newline at end of file
Please login to merge, or discard this patch.
Ajax/common/html/HtmlCollection.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -13,29 +13,29 @@  discard block
 block discarded – undo
13 13
  */
14 14
 abstract class HtmlCollection extends HtmlDoubleElement {
15 15
 
16
-	public function __construct($identifier,$tagName="div"){
17
-		parent::__construct($identifier,$tagName);
16
+	public function __construct($identifier, $tagName="div") {
17
+		parent::__construct($identifier, $tagName);
18 18
 		$this->content=array();
19 19
 	}
20 20
 
21
-	public function addItems($items){
22
-		if(JArray::isAssociative($items)){
23
-			foreach ($items as $k=>$v){
24
-				$this->addItem([$k,$v]);
21
+	public function addItems($items) {
22
+		if (JArray::isAssociative($items)) {
23
+			foreach ($items as $k=>$v) {
24
+				$this->addItem([$k, $v]);
25 25
 			}
26
-		}else{
27
-			foreach ($items as $item){
26
+		}else {
27
+			foreach ($items as $item) {
28 28
 				$this->addItem($item);
29 29
 			}
30 30
 		}
31 31
 	}
32 32
 
33
-	public function setItems($items){
33
+	public function setItems($items) {
34 34
 		$this->content=$items;
35 35
 		return $this;
36 36
 	}
37 37
 
38
-	public function getItems(){
38
+	public function getItems() {
39 39
 		return $this->content;
40 40
 	}
41 41
 
@@ -44,9 +44,9 @@  discard block
 block discarded – undo
44 44
 	 * @param HtmlDoubleElement|string $item
45 45
 	 * @return \Ajax\common\html\HtmlDoubleElement
46 46
 	 */
47
-	public function addItem($item){
47
+	public function addItem($item) {
48 48
 		$itemO=$item;
49
-		if($this->createCondition($item)===true){
49
+		if ($this->createCondition($item)===true) {
50 50
 			$itemO=$this->createItem($item);
51 51
 		}
52 52
 		$this->addContent($itemO);
@@ -72,11 +72,11 @@  discard block
 block discarded – undo
72 72
 		return $this;
73 73
 	}
74 74
 
75
-	public function removeItem($index){
75
+	public function removeItem($index) {
76 76
 		return array_splice($this->content, $index, 1);
77 77
 	}
78 78
 
79
-	public function count(){
79
+	public function count() {
80 80
 		return \sizeof($this->content);
81 81
 	}
82 82
 
@@ -87,8 +87,8 @@  discard block
 block discarded – undo
87 87
 		$this->addItem($function($object));
88 88
 	}
89 89
 
90
-	public function apply($callBack){
91
-		foreach ($this->content as $item){
90
+	public function apply($callBack) {
91
+		foreach ($this->content as $item) {
92 92
 			$callBack($item);
93 93
 		}
94 94
 	}
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 	 */
107 107
 	protected abstract function createItem($value);
108 108
 
109
-	protected function createCondition($value){
109
+	protected function createCondition($value) {
110 110
 		return \is_object($value)===false;
111 111
 	}
112 112
 
Please login to merge, or discard this patch.