[ Index ]

PHP Cross Reference of Limb3

title

Body

[close]

/cms/src/fetcher/ -> lmbCmsBreadcrumbsFetcher.class.php (source)

   1  <?php
   2  /*
   3   * Limb PHP Framework
   4   *
   5   * @link http://limb-project.com 
   6   * @copyright  Copyright &copy; 2004-2007 BIT(http://bit-creative.com)
   7   * @license    LGPL http://www.gnu.org/copyleft/lesser.html 
   8   */
   9  
  10  lmb_require('limb/core/src/lmbCollection.class.php');
  11  lmb_require('limb/web_app/src/fetcher/lmbFetcher.class.php');
  12  
  13  /**

  14   * class lmbCmsBreadcrumbsFetcher.

  15   *

  16   * @package cms

  17   * @version $Id: lmbCmsBreadcrumbsFetcher.class.php 5945 2007-06-06 08:31:43Z pachanga $

  18   */
  19  class lmbCmsBreadcrumbsFetcher extends lmbFetcher
  20  {
  21    static protected $breadcrumbs;
  22    protected $handlers = array();
  23    protected $toolkit;
  24  
  25    function __construct()
  26    {
  27      $this->toolkit = lmbToolkit :: instance();
  28      parent :: __construct();
  29    }
  30  
  31    function addRoute($title, $params = array(), $route = '')
  32    {
  33      $this->addUrl($title, $this->_getRoutePath($params, $route));
  34    }
  35  
  36    function addUrl($title, $path)
  37    {
  38      self :: $breadcrumbs[] = array('title' => $title, 'path' => $path);
  39    }
  40  
  41    function need($controller, $action, $params = array())
  42    {
  43      $handle = 'crumb_for_' . $controller . '_' . $action;
  44      array_push($this->handlers, array($controller, $action));
  45      if(is_callable($handle))
  46        $handle($this, $params);
  47      array_pop($this->handlers);
  48    }
  49  
  50    function _createDataSet()
  51    {
  52      $this->_makeCrumbs();
  53      return new lmbCollection(self :: $breadcrumbs);
  54    }
  55  
  56    function _getRoutePath($params = array(), $route = '')
  57    {
  58      $item = end($this->handlers);
  59      $params['controller'] = $item[0];
  60      $params['action'] = $item[1];
  61  
  62      return $this->toolkit->getRoutesUrl($params, $route);
  63    }
  64  
  65    function _makeCrumbs()
  66    {
  67      if(!is_null(self :: $breadcrumbs))
  68        return;
  69  
  70      self :: $breadcrumbs = array();
  71  
  72      $this->toolkit->getConf('crumbs');
  73  
  74      $request = $this->toolkit->getRequest();
  75      $controller = $this->toolkit->getDispatchedController();
  76  
  77      $this->need(lmb_under_scores($controller->getName()),
  78                  lmb_under_scores($controller->getCurrentAction()),
  79                  $request);
  80      self :: $breadcrumbs[count(self :: $breadcrumbs) - 1]['is_last'] = true;
  81    }
  82  }
  83  
  84  ?>


Generated: Tue Oct 7 05:02:03 2008 Cross-referenced by PHPXref 0.7