@@ -87,6 +87,9 @@ |
||
| 87 | 87 | $this->addItem($function($object)); |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | + /** |
|
| 91 | + * @param \Closure $callBack |
|
| 92 | + */ |
|
| 90 | 93 | public function apply($callBack){ |
| 91 | 94 | foreach ($this->content as $item){ |
| 92 | 95 | $callBack($item); |
@@ -21,6 +21,11 @@ discard block |
||
| 21 | 21 | protected $_contentSeparator=""; |
| 22 | 22 | |
| 23 | 23 | |
| 24 | + /** |
|
| 25 | + * @param string $identifier |
|
| 26 | + * @param string $tagName |
|
| 27 | + * @param string $baseClass |
|
| 28 | + */ |
|
| 24 | 29 | public function __construct($identifier,$tagName,$baseClass){ |
| 25 | 30 | parent::__construct($identifier,$tagName,$baseClass); |
| 26 | 31 | $this->root=""; |
@@ -31,8 +36,7 @@ discard block |
||
| 31 | 36 | * Associate an ajax get to the elements, displayed in $targetSelector |
| 32 | 37 | * $attr member is used to build each element url |
| 33 | 38 | * @param string $targetSelector the target of the get |
| 34 | - * @param string $attr the html attribute used to build the elements url |
|
| 35 | - * @return HtmlNavElement |
|
| 39 | + * @return HtmlSemNavElement |
|
| 36 | 40 | */ |
| 37 | 41 | public function autoGetOnClick($targetSelector){ |
| 38 | 42 | return $this->getOnClick($this->root, $targetSelector,array("attr"=>$this->attr)); |
@@ -64,7 +68,7 @@ discard block |
||
| 64 | 68 | /** |
| 65 | 69 | * Define the html attribute for each element url in ajax |
| 66 | 70 | * @param string $attr html attribute |
| 67 | - * @return HtmlNavElement |
|
| 71 | + * @return HtmlSemNavElement |
|
| 68 | 72 | */ |
| 69 | 73 | public function setAttr($attr) { |
| 70 | 74 | $this->attr = $attr; |
@@ -55,8 +55,7 @@ discard block |
||
| 55 | 55 | * Associate an ajax get to the breadcrumb elements, displayed in $targetSelector |
| 56 | 56 | * $attr member is used to build each element url |
| 57 | 57 | * @param string $targetSelector the target of the get |
| 58 | - * @param string $attr the html attribute used to build the elements url |
|
| 59 | - * @return HtmlBreadcrumbs |
|
| 58 | + * @return HtmlBreadcrumb |
|
| 60 | 59 | */ |
| 61 | 60 | public function autoGetOnClick($targetSelector){ |
| 62 | 61 | return $this->getOnClick($this->root, $targetSelector,array("attr"=>$this->attr)); |
@@ -118,7 +117,7 @@ discard block |
||
| 118 | 117 | /** |
| 119 | 118 | * sets the function who generates the href elements. default : function($element){return $element->getContent()} |
| 120 | 119 | * @param function $_hrefFunction |
| 121 | - * @return \Ajax\bootstrap\html\HtmlBreadcrumbs |
|
| 120 | + * @return HtmlBreadcrumb |
|
| 122 | 121 | */ |
| 123 | 122 | public function setHrefFunction($_hrefFunction) { |
| 124 | 123 | $this->_hrefFunction = $_hrefFunction; |
@@ -91,8 +91,9 @@ discard block |
||
| 91 | 91 | if(\sizeof($params)>0 || \strtolower($action)!="index" ){ |
| 92 | 92 | $items[]=$action; |
| 93 | 93 | foreach ($params as $p){ |
| 94 | - if(\is_object($p)===false) |
|
| 95 | - $items[]=$p; |
|
| 94 | + if(\is_object($p)===false) { |
|
| 95 | + $items[]=$p; |
|
| 96 | + } |
|
| 96 | 97 | } |
| 97 | 98 | } |
| 98 | 99 | return $this->addItems($items); |
@@ -110,7 +111,7 @@ discard block |
||
| 110 | 111 | } |
| 111 | 112 | if($this->absolutePaths===true){ |
| 112 | 113 | return $this->_hrefFunction($this->content[$index]); |
| 113 | - }else{ |
|
| 114 | + } else{ |
|
| 114 | 115 | return $this->root.implode($separator, array_slice(array_map(function($e){return $this->_hrefFunction($e);}, $this->content),$this->startIndex,$index+1)); |
| 115 | 116 | } |
| 116 | 117 | } |
@@ -176,9 +177,9 @@ discard block |
||
| 176 | 177 | protected function createItem($value) { |
| 177 | 178 | $count=$this->count(); |
| 178 | 179 | $itemO=new HtmlSemDoubleElement("item-".$this->identifier."-".$count,"a","section"); |
| 179 | - if(\is_array($value)) |
|
| 180 | - $itemO->fromArray($value); |
|
| 181 | - else{ |
|
| 180 | + if(\is_array($value)) { |
|
| 181 | + $itemO->fromArray($value); |
|
| 182 | + } else{ |
|
| 182 | 183 | $itemO->setContent($value); |
| 183 | 184 | $itemO->setProperty($this->attr, $this->getHref($count)); |
| 184 | 185 | } |
@@ -50,9 +50,9 @@ discard block |
||
| 50 | 50 | $item=$itemO; |
| 51 | 51 | } |
| 52 | 52 | $item=parent::addItem($item); |
| 53 | - if(!$item instanceof HtmlMenu) |
|
| 54 | - $item->addToPropertyCtrl("class", "item",array("item")); |
|
| 55 | - else{ |
|
| 53 | + if(!$item instanceof HtmlMenu) { |
|
| 54 | + $item->addToPropertyCtrl("class", "item",array("item")); |
|
| 55 | + } else{ |
|
| 56 | 56 | $this->setSecondary(); |
| 57 | 57 | } |
| 58 | 58 | } |
@@ -102,8 +102,9 @@ discard block |
||
| 102 | 102 | |
| 103 | 103 | public function asTab($vertical=false){ |
| 104 | 104 | $this->apply(function(HtmlDoubleElement &$item){$item->setTagName("a");}); |
| 105 | - if($vertical===true) |
|
| 106 | - $this->setVertical(); |
|
| 105 | + if($vertical===true) { |
|
| 106 | + $this->setVertical(); |
|
| 107 | + } |
|
| 107 | 108 | return $this->addToProperty("class", "tabular"); |
| 108 | 109 | } |
| 109 | 110 | |
@@ -129,9 +130,10 @@ discard block |
||
| 129 | 130 | */ |
| 130 | 131 | public function fromDatabaseObject($object, $function) { |
| 131 | 132 | $return=$function($object); |
| 132 | - if(\is_array($return)) |
|
| 133 | - $this->addItems($return); |
|
| 134 | - else |
|
| 135 | - $this->addItem($return); |
|
| 133 | + if(\is_array($return)) { |
|
| 134 | + $this->addItems($return); |
|
| 135 | + } else { |
|
| 136 | + $this->addItem($return); |
|
| 137 | + } |
|
| 136 | 138 | } |
| 137 | 139 | } |
| 138 | 140 | \ No newline at end of file |