[ Index ]

PHP Cross Reference of Limb3

title

Body

[close]

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

  14   * class lmbCmsImageRepositoryBrowser.

  15   *

  16   * @package cms

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

  18   */
  19  class lmbCmsImageRepositoryBrowser
  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('/images');
  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('lmbCmsImageFolder', '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 = lmbCmsImage :: findForParentNode($this->current_folder);
  59      foreach($files as $file)
  60      {
  61        $title = htmlspecialchars($file->getNode()->getTitle(), ENT_QUOTES);
  62        $result .= "<File id='$file->id' thumbnail_url='/file_object/show/{$file->thumbnail->uid}' ";
  63        $result .= "icon_url='/file_object/show/{$file->icon->uid}' ";
  64        $result .= "original_url='/file_object/show/{$file->original->uid}' ";
  65        $result .= "name='{$title}' size='{$file->thumbnail->size}'/>";
  66      }
  67      return $result;
  68    }
  69  }
  70  
  71  ?>


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