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

Source for file LContentBrick.php

Documentation is available at LContentBrick.php

  1. <?php
  2.  
  3.  
  4. /**
  5.  * LContentBrick 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 LContent
  13.  */
  14.  
  15. /**
  16.  * Displays a brick with one item from LContent
  17.  *
  18.  * @package System.Web.UI.WebControls
  19.  * @subpackage CMS
  20.  */
  21.  
  22. class LContentBrick extends LBrick
  23. {
  24.     /**
  25.      * content for brick (propel object)
  26.      */
  27.     public $ContentObject;
  28.  
  29.     /**
  30.      * Prepares core, adds admin snippets
  31.      */
  32.     public function __construct()
  33.     {
  34.         parent :: __construct();
  35.         Prado :: using("Lithron.LContent.LContentCore");
  36.         $admin '<h4>Record</h4>' .
  37.                 '<com:TListBox ID="ContentId" Width="100%" Rows="10"/>';
  38.         $admin .= '<com:TRequiredFieldValidator ' .
  39.                 'Display="Dynamic" ' .
  40.                 'ValidationGroup="' $this->getUniqueValidationGroup('" ' .
  41.                 'ControlToValidate="ContentId" ErrorMessage="Select a record!" />';
  42.         $this->addAdminSnippet($admin);
  43.     }
  44.  
  45.     /**
  46.      * @return id for selecting records
  47.      */
  48.     public function getClassId()
  49.     {
  50.         return "LContentBrick";
  51.     }
  52.  
  53.     /**
  54.      * @ignore
  55.      */
  56.     public function getDescriptiveName()
  57.     {
  58.         return "Content Record (basic)";
  59.     }
  60.  
  61.     /**
  62.      * @ignore
  63.      */
  64.     public function getHasAdministrationPage()
  65.     {
  66.         return true;
  67.     }
  68.  
  69.     /**
  70.      * @ignore
  71.      */
  72.     public function getAdministrationPage()
  73.     {
  74.         if ($this->getParameters(instanceof TMap)
  75.         {
  76.             $id$this->getParameters()->itemAt("ContentId");
  77.         }
  78.         else
  79.             $id"";
  80.         return "packages.LContent.AdminRecord&l_content_id={$id}&back_url=$this->Service->getServicePage(true);
  81.     }
  82.  
  83.     /**
  84.      * prepares admin or content, depending on panel
  85.      */
  86.     public function onLoad($param)
  87.     {
  88.         parent :: onLoad($param);
  89.         #$this->prepareAdmin(); // VERY UGLY! FIX ME, TODO, but works :(
  90.     }
  91.     public function onPreRender($param)
  92.     {
  93.         Prado :: log("OnPreRender() LContentBrick ..."1"Lithron.LContent");
  94.         if ($this->getShowAdminPanel())
  95.         {
  96.             $this->prepareAdmin();
  97.         }
  98.         else
  99.         {
  100.             $this->prepareContent();
  101.         }
  102.         parent :: onPreRender($param)// important !
  103.     }
  104.  
  105.     /**
  106.      * gets data and performs databBind
  107.      */
  108.     protected function prepareAdmin()
  109.     {
  110.         // get content records
  111.         $ccnew LContentCriteria;
  112.         $cc->setType($this->getClassId());
  113.         $cc->setStatus(LContentCore::STATUS_PUBLISHED);
  114.         $c $cc->build();
  115.         $c->addAscendingOrderByColumn(LContentPeer::ALIAS);
  116.         LRightsManager::restrictCriteria($c"LContentPeer"LPermissions::USAGE);
  117.         $itemsLContentCore :: queryRecords($c);
  118.         Prado :: log("Queried " count($items" record(s)"1"Lithron.LContent");
  119.  
  120.         $dsarray ();
  121.         if (is_array($items))
  122.             foreach ($items as $item)
  123.             {
  124.                 // parse the headlines
  125.                 if ($item->getAlias())
  126.                     $ds[$item->getId()]$item->getAlias();
  127.                 else
  128.                     $ds[$item->getId()]$item->getHeadline()// TODO - backward comp.
  129.             }
  130.  
  131.         // set the data source
  132.         try
  133.         {
  134.             $this->AdminControls->ContentId->setDataSource($ds);
  135.             $this->AdminControls->ContentId->dataBind();
  136.             Prado :: log("Admin Datasource set!"1"Lithron.LContent");
  137.         }
  138.         catch (Exception $e)
  139.         {
  140.             Prado :: log("Error while databinding admin controls in brick: " $e->getMessage()8"Lithron.LContent");
  141.         }
  142.     }
  143.  
  144.     /**
  145.      * gets data and performs databBind
  146.      */
  147.     protected function prepareContent()
  148.     {
  149.         $p$this->getParameters();
  150.         if ($p !== null)
  151.         {
  152.             $this->ContentObjectLContentCore :: queryRecords($p->itemAt("ContentId"));
  153.         }
  154.         if (!is_object($this->ContentObject))
  155.         {
  156.             $this->ContentObjectnew LContent();
  157.         }
  158.     }
  159. }
  160. ?>

Documentation generated on Sun, 25 Feb 2007 16:09:59 +0100 by phpDocumentor 1.3.1