[ Index ]

PHP Cross Reference of Limb3

title

Body

[close]

/cms/src/ -> lmbCmsTreeBrowser.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  lmb_require('limb/cms/src/model/lmbCmsNode.class.php');
  10  
  11  /**
  12   * class lmbCmsTreeBrowser.
  13   *
  14   * @package cms
  15   * @version $Id: lmbCmsTreeBrowser.class.php 5988 2007-06-13 07:50:57Z tony $
  16   */
  17  class lmbCmsTreeBrowser
  18  {
  19    protected $current_folder;
  20  
  21    function setCurrentFolderPath($path)
  22    {
  23      $id = $this->_getLastId($path);
  24      $this->current_folder = $this->_getNode($id);
  25    }
  26  
  27    protected function _getNode($id)
  28    {
  29      if($id)
  30        return new lmbCmsNode($id);
  31  
  32      return new lmbCmsNode();
  33    }
  34  
  35    protected function _getLastId($path)
  36    {
  37      $path = rtrim($path, '/');
  38      return (int)end(explode('/', $path));
  39    }
  40  
  41    function renderFolders()
  42    {
  43      $result = '';
  44  
  45      if($this->current_folder->getId())
  46         $folders = lmbActiveRecord :: find('lmbCmsNode', 'parent_id = '. $this->current_folder->getId());
  47      else
  48        $folders = $this->current_folder->getRoots();
  49  
  50      foreach($folders as $folder)
  51      {
  52        $title = htmlspecialchars($folder->getTitle(), ENT_QUOTES);
  53        $result .= "<Folder id='{$folder->getId()}' name='{$title}' url='{$folder->getUrlPath()}'/>";
  54      }
  55  
  56      return $result;
  57    }
  58  }
  59  
  60  ?>


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