48 $this->content=array();
52 if(isset($hrefFunction)){
53 $this->_hrefFunction=$hrefFunction;
63 public function addElement($element,$href=
"",$glyph=NULL){
65 if(\is_array($element)){
66 $elm=
new HtmlLink(
"lnk-".$this->identifier.
"-".$size);
67 $elm->fromArray($element);
68 }
else if($element instanceof
HtmlLink){
71 $elm=
new HtmlLink(
"lnk-".$this->identifier.
"-".$size,$href,$element);
73 $elm->wrapContentWithGlyph($glyph);
76 $elm->wrap(
"<li>",
"</li>");
77 $this->content[]=$elm;
78 $elm->setProperty($this->attr, $this->
getHref($size));
87 $li->setClass(
"active");
88 $li->setContent($this->content[$index]->
getContent());
89 $this->content[$index]=$li;
93 foreach ( $elements as $element ) {
100 $array=parent::fromArray($array);
111 public function getHref($index=
null,$separator=
"/"){
115 if($this->absolutePaths===
true){
116 return $this->_hrefFunction($this->content[$index]);
118 return $this->root.implode($separator, array_slice(array_map(
function($e){
return $this->_hrefFunction($e);},
$this->content),$this->startIndex,$index+1));
127 if($this->autoActive){
130 return parent::compile($js, $view);
144 public function on($event, $jsCode, $stopPropagation=
false, $preventDefault=
false) {
145 foreach ($this->content as $element){
146 $element->on($event,$jsCode,$stopPropagation,$preventDefault);
156 public function _ajaxOn($operation, $event, $url, $responseElement=
"", $parameters=array()) {
157 foreach ($this->content as $element){
158 $element->_ajaxOn($operation, $event, $url, $responseElement, $parameters);
170 return $this->
getOnClick($this->root, $targetSelector,array(
"attr"=>$this->attr));
174 if($this->autoActive){
177 return parent::contentAsString();
181 return $this->content[$index];
191 return $elm->wrapContentWithGlyph($glyph);
fromDispatcher($dispatcher)
Collects url parts from the request dispatcher : controllerName, actionName, parameters Used internal...
Twitter Bootstrap Breadcrumbs component.
addElement($element, $href="", $glyph=NULL)
addGlyph($glyph, $index=0)
Add a glyphicon to the element at index $index.
setStartIndex($startIndex)
setAutoActive($autoActive)
fromDispatcher(JsUtils $js, $dispatcher, $startIndex=0)
Add new elements in breadcrumbs corresponding to request dispatcher : controllerName,...
autoGetOnClick($targetSelector)
Associate an ajax get to the breadcrumbs elements, displayed in $targetSelector $attr member is used ...
setHrefFunction($_hrefFunction)
sets the function who generates the href elements.
__construct($identifier, $elements=array(), $autoActive=true, $startIndex=0, $hrefFunction=NULL)
compile(JsUtils $js=NULL, &$view=NULL)
_ajaxOn($operation, $event, $url, $responseElement="", $parameters=array())
getHref($index=null, $separator="/")
Return the url of the element at $index or the breadcrumbs url if $index is ommited.
on($event, $jsCode, $stopPropagation=false, $preventDefault=false)
fromDatabaseObject($object, $function)
Bs class for navigation elements : Breadcrumbs and Pagination.
getOnClick($url, $responseElement="", $parameters=array())
Performs a get to $url on the click event on $element and display it in $responseElement.
setProperty($name, $value)