Phundament-Packages
[ class tree: Phundament-Packages ] [ index: Phundament-Packages ] [ all elements ]

Source for file LMediaBrick.php

Documentation is available at LMediaBrick.php

  1. <?php
  2.  
  3.  
  4. /**
  5.  * Class file.
  6.  *
  7.  * @license http://opensource.org/licenses/mozilla1.1.php Mozilla Public License
  8.  * @copyright 2005, diemeisterei GmbH. All rights reserved.
  9.  * @author $Author: schmunk $
  10.  * @version $Revision: 601 $  $Date: 2007-02-24 23:49:30 +0100 (Sa, 24 Feb 2007) $
  11.  * @package Phundament.Packages
  12.  * @subpackage LMediaManager
  13.  */
  14.  
  15. /**
  16.  * Displays a media file
  17.  *
  18.  * @package System.Web.UI.WebControls
  19.  * @subpackage CMS
  20.  */
  21.  
  22. class LMediaBrick extends LBrick
  23. {
  24.     private $CC;
  25.     public $ContentObject;
  26.  
  27.     /**
  28.      * @return string with the name
  29.      */
  30.     public function getDescriptiveName()
  31.     {
  32.         return "Media File (basic)";
  33.     }
  34.  
  35.     /**
  36.      * @return Page path for admin page
  37.      */
  38.     public function getAdministrationPage()
  39.     {
  40.         return "packages.LMediaManager.Administration";
  41.     }
  42.  
  43.     /**
  44.      * Adds admin snippets
  45.      */
  46.     public function __construct()
  47.     {
  48.         parent :: __construct();
  49.         //use same size like in Administration.page
  50.         $admin'<h4>Record</h4>' .
  51.         '<com:TTextBox ID="SearchString" /> <com:TButton Text="Search" /> enter " " to show all' .
  52.         '<div class="AdminBrickList">' .
  53.         '<com:TRepeater ID="MediaId">' .
  54.         '    <prop:itemTemplate>' .
  55.         '        <div style="float:left; height: 200px;" class="AdminBrickListItem">' .
  56.         '            <com:LImage SkinId="Icon128" ImageUrl=<%# $this->DataItem->getDirectory()."/".$this->DataItem->getFileName() %> />' .
  57.         '        <com:TPanel Id="Box">' .
  58.         '            <br/><com:TRadioButton Id="Checker" UniqueGroupName="MediaId" Value="<%#$this->DataItem->getId()%>"/>' .
  59.         '            <b><%#$this->DataItem->getId()%></b>' .
  60.         '            <br/><%# str_replace(LMediaManagerCore::getMediaDir(),"",$this->DataItem->getDirectory())%>' .
  61.         '            <br/><%#$this->DataItem->getFileName()%>' .
  62.         '            <br/><b><%#$this->DataItem->getDescription()%></b>' .
  63.         '        </com:TPanel>' .
  64.         '        </div>' .
  65.         '    </prop:itemTemplate>' .
  66.         '</com:TRepeater>' .
  67.         '</div>';
  68.         $this->addAdminSnippet($admin);
  69.     }
  70.  
  71.     /**
  72.      * @todo
  73.      */
  74.     public function onPreRender($param)
  75.     {
  76.         parent :: onPreRender($param);
  77.         if ($this->ShowAdminPanel)
  78.         {
  79.             $this->prepareAdmin();
  80.             $this->autoselectAdmin();
  81.         }
  82.         else
  83.             $this->prepareContent();
  84.  
  85.     }
  86.  
  87.     /**
  88.      * parses descriptions for selection
  89.      */
  90.     protected function prepareAdmin()
  91.     {
  92.         $this->CCLithron :: singleton("LMediaManagerCore");
  93.  
  94.         $mcnew LMediaCriteria;
  95.         $mc->setActive(true);
  96.  
  97.         // TODO - could be nicer :)
  98.         try
  99.         {
  100.             if (!$this->AdminControls->SearchString->Text)
  101.                 return;
  102.             $mc->setSearchString($this->AdminControls->SearchString->Text);
  103.         }
  104.         catch (Exception $e)
  105.         {
  106.             Prado :: log($e->getMessage()4"Lithron.LMediaManager");
  107.         }
  108.  
  109.         $c$mc->build();
  110.         LRightsManager :: restrictCriteria($c"LMediaManagerFilesPeer"LPermissions :: USAGE);
  111.         $itemsLMediaManagerCore :: queryRecords($c);
  112.         $dsarray ();
  113.         if (is_array($items))
  114.             foreach ($items as $item)
  115.             {
  116.                 $ds[$item->getId()]$item;
  117.             }
  118.  
  119.         try
  120.         {
  121.             $this->AdminControls->MediaId->setDataSource($ds);
  122.             $this->AdminControls->MediaId->dataBind();
  123.             Prado :: trace("MediaBrick databound [admin]""Lithron.LMediaManager");
  124.         }
  125.         catch (Exception $e)
  126.         {
  127.             Prado :: trace("Error while databinding MediaBrick [admin] ""Lithron.LMediaManager");
  128.             Prado :: trace($e->getMessage()"Lithron.LMediaManager");
  129.         }
  130.     }
  131.  
  132.     /**
  133.      * created content object
  134.      */
  135.     protected function prepareContent()
  136.     {
  137.         $parm$this->getParameters();
  138.  
  139.         if ($parm instanceof TMap && isset ($parm["MediaId"]))
  140.             $this->ContentObjectLMediaManagerCore :: queryRecords($parm["MediaId"]);
  141.         if (!is_object($this->ContentObject))
  142.             $this->ContentObjectnew LMediaManagerFiles();
  143.     }
  144.  
  145. }
  146. ?>

Documentation generated on Sun, 25 Feb 2007 16:10:48 +0100 by phpDocumentor 1.3.1