Changeset 485 for trunk/lib/Navigation.inc.php
- Timestamp:
- Aug 14, 2014 8:29:47 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/Navigation.inc.php
r484 r485 198 198 199 199 /** 200 * Returns the path from root up to the current page as an array. 201 * 202 * @access public 203 * @param string $key Which value to use in the path (usually head_title or body_title or just title). 204 * @return mixed Path (string) or false if path param is not set. 205 */ 206 public function getPathArray($key='title') 207 { 208 $path = array(); 209 if ($this->getParam('path')) { 210 foreach ($this->pages as $page) { 211 $path[] = strip_tags($page[$key]); 212 } 213 } 214 return $path; 215 } 216 217 /** 200 218 * Returns the text path from root up to the current page, separated by the 201 219 * path_delimiter. … … 207 225 public function getPath($key='title') 208 226 { 209 if ($this->getParam('path')) { 210 $path = ''; 211 $pathmark = ''; 227 228 $path = $this->getPathArray(); 229 return empty($path) ? '' : join(oTxt($this->getParam('path_delimiter'), true), $path); 230 } 231 232 /** 233 * Returns the breadcrumbs from the root page to the current page. 234 * Breadcrumbs are the text path with pages titles linked to that page. 235 * 236 * @access public 237 * @return string Breadcrumbs or empty string if breadcrumbs param not set. 238 */ 239 public function getBreadcrumbsArray() 240 { 241 $app =& App::getInstance(); 242 243 if ($this->getParam('breadcrumbs')) { 244 $breadcrumbs = array(); 245 $crumb_count = sizeof($this->pages); 212 246 foreach ($this->pages as $page) { 213 $path .= oTxt($pathmark . strip_tags($page[$key]), true); 214 $pathmark = $this->getParam('path_delimiter'); 215 } 216 return $path; 247 if ($crumb_count <= $this->getParam('chop_breadcrumbs')) { 248 // Stop gathering crumbs. 249 break; 250 } 251 if ($crumb_count <= 1) { 252 // The last crumb. 253 if ('' == trim($page['url']) || $crumb_count <= $this->getParam('chop_breadcrumb_links')) { 254 // A crumb with no link. 255 $breadcrumbs[] = array( 256 'url' => false, 257 'title' => sprintf($this->getParam('last_crumb_format'), $page['title']) 258 ); 259 } else if ($crumb_count > $this->getParam('chop_breadcrumb_links')) { 260 // A normal linked crumb. 261 $breadcrumbs[] = array( 262 'url' => $page['url'], 263 'title' => sprintf($this->getParam('last_crumb_format'), $page['title']) 264 ); 265 } 266 } else { 267 if ('' == trim($page['url'])) { 268 // A crumb with no link. 269 $breadcrumbs[] = array( 270 'url' => false, 271 'title' => $page['title'] 272 ); 273 } else { 274 // A normal linked crumb. 275 $breadcrumbs[] = array( 276 'url' => $page['url'], 277 'title' => $page['title'] 278 ); 279 } 280 } 281 $crumb_count--; 282 } 283 return $breadcrumbs; 217 284 } else { 218 return false;285 return array(); 219 286 } 220 287 } … … 247 314 } else if ($crumb_count > $this->getParam('chop_breadcrumb_links')) { 248 315 // A normal linked crumb. 249 $breadcrumbs[] = '<a href="' . $ app->oHREF($page['url']). '">' . sprintf($this->getParam('last_crumb_format'), oTxt($page['title'], true)) . '</a>';316 $breadcrumbs[] = '<a href="' . $page['url'] . '">' . sprintf($this->getParam('last_crumb_format'), oTxt($page['title'], true)) . '</a>'; 250 317 } 251 318 } else { … … 255 322 } else { 256 323 // A normal linked crumb. 257 $breadcrumbs[] = '<a href="' . $ app->oHREF($page['url']). '">' . oTxt($page['title'], true) . '</a>';324 $breadcrumbs[] = '<a href="' . $page['url'] . '">' . oTxt($page['title'], true) . '</a>'; 258 325 } 259 326 }
Note: See TracChangeset
for help on using the changeset viewer.