[ Index ]

PHP Cross Reference of Limb3

title

Body

[close]

/cms/src/ -> lmbCmsFileRepositoryBrowser.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  lmb_require('limb/cms/src/model/lmbCmsFileObject.class.php');
  11  lmb_require('limb/cms/src/model/lmbCmsFileFolder.class.php');
  12  
  13  /**

  14   * class lmbCmsFileRepositoryBrowser.

  15   *

  16   * @package cms

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

  18   */
  19  class lmbCmsFileRepositoryBrowser
  20  {
  21    protected $current_folder;
  22  
  23    function setCurrentFolderPath($path)
  24    {
  25      $id = $this->_getLastId($path);
  26      $this->current_folder = $this->_getNode($id);
  27    }
  28  
  29    protected function _getNode($id)
  30    {
  31      if($id)
  32        return new lmbCmsNode($id);
  33  
  34      return lmbCmsNode :: findByPath('/files');
  35    }
  36  
  37    protected function _getLastId($path)
  38    {
  39      $path = rtrim($path, '/');
  40      return (int)end(explode('/', $path));
  41    }
  42  
  43    function renderFolders()
  44    {
  45      $result = '';
  46  
  47      $folders = lmbActiveRecord :: find('lmbCmsFileFolder', 'parent_id = '. $this->current_folder->id);
  48      foreach($folders as $folder)
  49        $result .= "<Folder id='{$folder->id}' name='{$folder->title}' />";
  50  
  51      return $result;
  52    }
  53  
  54    function renderFiles()
  55    {
  56      $result = '';
  57  
  58      $files = lmbCmsFileObject :: findForParentNode($this->current_folder);
  59      foreach($files as $file)
  60      {
  61        $filename = htmlspecialchars($file->getFileName(), ENT_QUOTES);
  62        $title = htmlspecialchars($file->getNode()->getTitle(), ENT_QUOTES);
  63        $result .= "<File id='$file->id' url='/file_object/show/{$file->uid}' name='{$title} ($filename)' size='{$file->size}' />";
  64      }
  65      return $result;
  66    }
  67  }
  68  
  69  ?>


Generated: Tue Oct 14 04:47:40 2008 Cross-referenced by PHPXref 0.7