includes/pageprocess.php
changeset 473 518bc2b214f1
parent 472 bc4b58034f4d
child 481 07bf15b066bc
equal deleted inserted replaced
472:bc4b58034f4d 473:518bc2b214f1
  1692    */
  1692    */
  1693   
  1693   
  1694   function do_breadcrumbs()
  1694   function do_breadcrumbs()
  1695   {
  1695   {
  1696     global $db, $session, $paths, $template, $plugins; // Common objects
  1696     global $db, $session, $paths, $template, $plugins; // Common objects
       
  1697     global $lang;
       
  1698     
  1697     if ( strpos($this->text_cache, '__NOBREADCRUMBS__') !== false )
  1699     if ( strpos($this->text_cache, '__NOBREADCRUMBS__') !== false )
  1698       return false;
  1700       return false;
       
  1701     
       
  1702     $mode = getConfig('breadcrumb_mode');
       
  1703     
       
  1704     if ( $mode == 'never' )
       
  1705       // Breadcrumbs are disabled
       
  1706       return true;
       
  1707       
       
  1708     // Minimum depth for breadcrumb display
       
  1709     $threshold = ( $mode == 'always' ) ? 0 : 1;
       
  1710     
  1699     $breadcrumb_data = explode('/', $this->page_id);
  1711     $breadcrumb_data = explode('/', $this->page_id);
  1700     if ( count($breadcrumb_data) > 1 )
  1712     if ( count($breadcrumb_data) > $threshold )
  1701     {
  1713     {
       
  1714       // If we're not on a subpage of the main page, add "Home" to the list
       
  1715       $show_home = false;
       
  1716       if ( $mode == 'always' )
       
  1717       {
       
  1718         $show_home = true;
       
  1719       }
  1702       echo '<!-- Start breadcrumbs -->
  1720       echo '<!-- Start breadcrumbs -->
  1703             <div class="breadcrumbs">
  1721             <div class="breadcrumbs">
  1704               ';
  1722               ';
       
  1723       if ( $show_home )
       
  1724       {
       
  1725         if ( count($breadcrumb_data) > 1 )
       
  1726         {
       
  1727           echo '<a href="' . makeUrl(getConfig('main_page'), false, true) . '">' . $lang->get('onpage_btn_breadcrumbs_home') . '</a> &raquo;';
       
  1728         }
       
  1729         else
       
  1730         {
       
  1731           echo $lang->get('onpage_btn_breadcrumbs_home');
       
  1732         }
       
  1733       }
  1705       foreach ( $breadcrumb_data as $i => $higherpage )
  1734       foreach ( $breadcrumb_data as $i => $higherpage )
  1706       {
  1735       {
  1707         $higherpage = $paths->nslist[$this->namespace] . sanitize_page_id(implode('/', array_slice($breadcrumb_data, 0, ($i+1))));
  1736         $higherpage = $paths->nslist[$this->namespace] . sanitize_page_id(implode('/', array_slice($breadcrumb_data, 0, ($i+1))));
       
  1737         if ( $higherpage === getConfig('main_page') )
       
  1738           continue;
  1708         if ( ($i + 1) == count($breadcrumb_data) )
  1739         if ( ($i + 1) == count($breadcrumb_data) )
  1709         {
  1740         {
  1710           $title = get_page_title($higherpage, false);
  1741           $title = ( $higherpage === getConfig('main_page') ) ? $lang->get('onpage_btn_breadcrumbs_home') : get_page_title($higherpage, false);
  1711           if ( !$this->page_exists )
  1742           if ( !$this->page_exists )
  1712           {
  1743           {
  1713             $title = explode('/', $title);
  1744             $title = explode('/', $title);
  1714             $title = array_reverse($title);
  1745             $title = array_reverse($title);
  1715             $title = $title[0];
  1746             $title = $title[0];