phpMv
-UI toolkit 2.4.12
jQuery, jQuery UI, Twitter Bootstrap and Semantic-UI library for php & php MVC Frameworks
Loading...
Searching...
No Matches
HtmlNavbar.php
Go to the documentation of this file.
1
<?php
2
3
namespace
Ajax\bootstrap\html
;
4
5
use
Ajax\JsUtils
;
6
use
Ajax\bootstrap\components\Scrollspy
;
7
use
Ajax\bootstrap\html\content\HtmlNavzone
;
8
use
Ajax\bootstrap\html\base\CssNavbar
;
9
use
Ajax\common\html\BaseHtml
;
10
use
Ajax\common\html\html5\HtmlImg
;
16
class
HtmlNavbar
extends
BaseHtml
{
17
protected
$navZones
;
18
protected
$class
=
"navbar-default"
;
19
protected
$brand
=
"Brand"
;
20
protected
$brandHref
=
"#"
;
21
protected
$brandTarget
=
"_self"
;
22
protected
$brandImage
=
""
;
23
protected
$scrollspy
;
24
protected
$hasScrollspy
=
false
;
25
protected
$scrollspyId
=
"body"
;
26
protected
$fluid
=
"container-fluid"
;
27
32
public
function
__construct
(
$identifier
,
$brand
=
"Brand"
,
$brandHref
=
"#"
) {
33
parent::__construct(
$identifier
);
34
$this->_template=include
'templates/tplNavbar.php'
;
35
$this->navZones=array ();
36
$this->
class
=
"navbar-default"
;
37
$this->brand=
$brand
;
38
$this->brandHref=
$brandHref
;
39
40
}
41
42
public
function
setClass
(
$class
) {
43
$this->
class
=
$class
;
44
return
$this;
45
}
46
47
public
function
setBrand
(
$brand
) {
48
$this->brand=
$brand
;
49
return
$this;
50
}
51
52
public
function
setBrandHref
(
$brandHref
) {
53
$this->brandHref=
$brandHref
;
54
return
$this;
55
}
56
57
public
function
setBrandTarget
(
$brandTarget
) {
58
$this->brandTarget=
$brandTarget
;
59
return
$this;
60
}
61
62
public
function
setBrandImage
($imageSrc) {
63
$this->brandImage=
new
HtmlImg
(
"brand-img-"
.$this->_identifier,$imageSrc,$this->brand);
64
$this->brand=
""
;
65
return
$this;
66
}
67
74
public
function
addZone
($type=
"nav"
,
$identifier
=NULL) {
75
if
(!isset(
$identifier
)) {
76
$nb=
sizeof
(
$this->navZones
)+1;
77
$identifier
=$this->identifier.
"-navzone-"
.$nb;
78
}
79
$zone=HtmlNavzone::$type(
$identifier
);
80
$this->navZones []=$zone;
81
return
$zone;
82
}
83
84
public
function
addElement
($element,
HtmlNavzone
$zone=NULL) {
85
$zone=$this->
getZoneToInsertIn
($zone);
86
if
($element instanceof
HtmlDropdown
)
87
$element->setMTagName(
"li"
);
88
$zone->addElement($element);
89
}
90
91
public
function
addElements
($elements,
HtmlNavzone
$zone=NULL) {
92
$zone=$this->
getZoneToInsertIn
($zone);
93
$zone->addElements($elements);
94
return
$zone;
95
}
96
101
public
function
fromArray
($array) {
102
return
parent::fromArray($array);
103
}
104
105
public
function
setNavZones
(
$navZones
) {
106
if
(\is_array(
$navZones
)) {
107
foreach
(
$navZones
as $zoneType => $zoneArray ) {
108
if
(is_string($zoneType)) {
109
$zone=$this->
addZone
($zoneType);
110
$zone->fromArray($zoneArray);
111
}
else
if
(is_string($zoneArray))
112
$this->
addElement
($zoneArray);
113
else
114
$this->
addElements
($zoneArray);
115
}
116
}
117
}
118
124
public
function
getZoneToInsertIn
($zone=NULL) {
125
if
(!isset($zone)) {
126
$nb=
sizeof
(
$this->navZones
);
127
if
($nb<1)
128
$zone=$this->
addZone
();
129
else
130
$zone=$this->navZones [$nb-1];
131
}
132
return
$zone;
133
}
134
140
public
function
getZone
($index) {
141
$zone=
null
;
142
$nb=
sizeof
(
$this->navZones
);
143
if
(is_int($index)) {
144
if
($index<$nb)
145
$zone=$this->navZones [$index];
146
}
else
{
147
for
($i=0; $i<$nb; $i++) {
148
if
($this->navZones [$i]->
getIdentifier
()===$index) {
149
$zone=$this->navZones [$i];
150
break
;
151
}
152
}
153
}
154
return
$zone;
155
}
156
157
public
function
run
(
JsUtils
$js) {
158
foreach
( $this->navZones as $zone ) {
159
$zone->run($js);
160
}
161
if
($this->hasScrollspy) {
162
$this->
scrollspy
=
new
Scrollspy
($js);
163
$this->
scrollspy
->attach($this->scrollspyId);
164
$this->
scrollspy
->setTarget(
"#"
.$this->identifier);
165
$this->
scrollspy
->compile($js);
166
}
167
}
168
169
public
function
cssInverse
() {
170
$this->
addToMember
($this->
class
,
CssNavbar::NAVBAR_INVERSE
);
171
return
$this;
172
}
173
174
public
function
scrollspy
($attachTo=
"body"
) {
175
$this->hasScrollspy=
true
;
176
$this->scrollspyId=$attachTo;
177
}
178
179
public
function
setFluid
(
$fluid
) {
180
if
(
$fluid
===
true
){
181
$this->fluid=
"container-fluid"
;
182
}
else
{
183
$this->fluid=
"container"
;
184
}
185
return
$this;
186
}
187
188
/* (non-PHPdoc)
189
* @see \Ajax\bootstrap\html\base\BaseHtml::fromDatabaseObject()
190
*/
191
public
function
fromDatabaseObject
($object, $function) {
192
$this->
addElement
($function($object));
193
}
194
195
}
Ajax\JsUtils
JQuery PHP library.
Definition
JsUtils.php:23
Ajax\bootstrap\components\Scrollspy
Composant Twitter Bootstrap Scrollspy.
Definition
Scrollspy.php:13
Ajax\bootstrap\html\HtmlDropdown
Twitter Bootstrap HTML Dropdown component.
Definition
HtmlDropdown.php:16
Ajax\bootstrap\html\HtmlNavbar
Twitter Bootstrap HTML Navbar component.
Definition
HtmlNavbar.php:16
Ajax\bootstrap\html\HtmlNavbar\addZone
addZone($type="nav", $identifier=NULL)
adds a new zone of type $type
Definition
HtmlNavbar.php:74
Ajax\bootstrap\html\HtmlNavbar\setNavZones
setNavZones($navZones)
Definition
HtmlNavbar.php:105
Ajax\bootstrap\html\HtmlNavbar\$navZones
$navZones
Definition
HtmlNavbar.php:17
Ajax\bootstrap\html\HtmlNavbar\setBrand
setBrand($brand)
Definition
HtmlNavbar.php:47
Ajax\bootstrap\html\HtmlNavbar\$brandImage
$brandImage
Definition
HtmlNavbar.php:22
Ajax\bootstrap\html\HtmlNavbar\run
run(JsUtils $js)
Definition
HtmlNavbar.php:157
Ajax\bootstrap\html\HtmlNavbar\$class
$class
Definition
HtmlNavbar.php:18
Ajax\bootstrap\html\HtmlNavbar\$hasScrollspy
$hasScrollspy
Definition
HtmlNavbar.php:24
Ajax\bootstrap\html\HtmlNavbar\addElements
addElements($elements, HtmlNavzone $zone=NULL)
Definition
HtmlNavbar.php:91
Ajax\bootstrap\html\HtmlNavbar\addElement
addElement($element, HtmlNavzone $zone=NULL)
Definition
HtmlNavbar.php:84
Ajax\bootstrap\html\HtmlNavbar\getZone
getZone($index)
Definition
HtmlNavbar.php:140
Ajax\bootstrap\html\HtmlNavbar\fromArray
fromArray($array)
/* (non-PHPdoc)
Definition
HtmlNavbar.php:101
Ajax\bootstrap\html\HtmlNavbar\setBrandHref
setBrandHref($brandHref)
Definition
HtmlNavbar.php:52
Ajax\bootstrap\html\HtmlNavbar\setClass
setClass($class)
Definition
HtmlNavbar.php:42
Ajax\bootstrap\html\HtmlNavbar\scrollspy
scrollspy($attachTo="body")
Definition
HtmlNavbar.php:174
Ajax\bootstrap\html\HtmlNavbar\getZoneToInsertIn
getZoneToInsertIn($zone=NULL)
Definition
HtmlNavbar.php:124
Ajax\bootstrap\html\HtmlNavbar\$brand
$brand
Definition
HtmlNavbar.php:19
Ajax\bootstrap\html\HtmlNavbar\setBrandImage
setBrandImage($imageSrc)
Definition
HtmlNavbar.php:62
Ajax\bootstrap\html\HtmlNavbar\$scrollspyId
$scrollspyId
Definition
HtmlNavbar.php:25
Ajax\bootstrap\html\HtmlNavbar\__construct
__construct($identifier, $brand="Brand", $brandHref="#")
Definition
HtmlNavbar.php:32
Ajax\bootstrap\html\HtmlNavbar\$brandTarget
$brandTarget
Definition
HtmlNavbar.php:21
Ajax\bootstrap\html\HtmlNavbar\setBrandTarget
setBrandTarget($brandTarget)
Definition
HtmlNavbar.php:57
Ajax\bootstrap\html\HtmlNavbar\$fluid
$fluid
Definition
HtmlNavbar.php:26
Ajax\bootstrap\html\HtmlNavbar\$brandHref
$brandHref
Definition
HtmlNavbar.php:20
Ajax\bootstrap\html\HtmlNavbar\cssInverse
cssInverse()
Definition
HtmlNavbar.php:169
Ajax\bootstrap\html\HtmlNavbar\fromDatabaseObject
fromDatabaseObject($object, $function)
Definition
HtmlNavbar.php:191
Ajax\bootstrap\html\HtmlNavbar\$scrollspy
$scrollspy
Definition
HtmlNavbar.php:23
Ajax\bootstrap\html\HtmlNavbar\setFluid
setFluid($fluid)
Definition
HtmlNavbar.php:179
Ajax\bootstrap\html\base\CssNavbar
Definition
CssNavbar.php:5
Ajax\bootstrap\html\base\CssNavbar\NAVBAR_INVERSE
const NAVBAR_INVERSE
Definition
CssNavbar.php:6
Ajax\bootstrap\html\content\HtmlNavzone
Inner element for Twitter Bootstrap HTML Navbar component.
Definition
HtmlNavzone.php:18
Ajax\common\html\BaseHtml
BaseHtml for HTML components.
Definition
BaseHtml.php:17
Ajax\common\html\BaseHtml\addToMember
addToMember(&$name, $value, $separator=' ')
Definition
BaseHtml.php:98
Ajax\common\html\BaseWidget\getIdentifier
getIdentifier()
Definition
BaseWidget.php:25
Ajax\common\html\BaseWidget\$identifier
$identifier
Definition
BaseWidget.php:14
Ajax\common\html\html5\HtmlImg
Definition
HtmlImg.php:8
Ajax\bootstrap\html
Ajax
bootstrap
html
HtmlNavbar.php
Generated on Sun Dec 10 2023 16:15:54 for
phpMv-UI
by
doxygen
1.9.8