- <?php
-
-
- /**
- * LContentBrick class file.
- *
- * @license http://opensource.org/licenses/mozilla1.1.php Mozilla Public License
- * @copyright 2005, diemeisterei GmbH. All rights reserved.
- * @author $Author: schmunk $
- * @version $Revision: 270 $ $Date: 2006-06-12 23:41:45 +0200 (Mo, 12 Jun 2006) $
- * @package Lithron.LContent
- * @subpackage Controls
- */
-
- /**
- * Displays a brick with one item from LContent
- *
- * @package System.Web.UI.WebControls
- * @subpackage Bricks
- */
-
- class LContentBrick extends LBrick
- {
- /**
- * content for brick (propel object)
- */
- public $ContentObject;
-
- /**
- * Prepares core, adds admin snippets
- */
- public function __construct()
- {
- parent :: __construct();
- Prado :: using("Lithron.LContent.LContentCore");
- $admin = '<div>';
- $admin .= '<com:TListBox ID="ContentId" Width="100%" Rows="10"/>';
- $admin .= '<com:TRequiredFieldValidator
- ValidationGroup="' . $this->getUniqueValidationGroup() . '"
- ControlToValidate="ContentId" ErrorMessage="Select a record!" />';
- $admin .= '</div>';
- $this->addAdminSnippet($admin);
- }
-
- /**
- * @return id for selecting records
- */
- public function getClassId()
- {
- return "LContentBrick";
- }
-
- /**
- * @ignore
- */
- public function getDescriptiveName()
- {
- return "Content Record (basic)";
- }
-
- /**
- * @ignore
- */
- public function getHasAdministrationPage()
- {
- return true;
- }
-
- /**
- * @ignore
- */
- public function getAdministrationPage()
- {
- if ($this->getParameters() instanceof TMap)
- {
- $id= $this->getParameters()->itemAt("ContentId");
- }
- else
- $id= "";
- return "packages.LContent.AdminRecord&l_content_id={$id}&back_url=" . $this->Service->getServicePage();
- }
-
- /**
- * prepares admin or content, depending on panel
- */
- public function onPreRender($param)
- {
- if ($this->getShowAdminPanel())
- {
- $this->prepareAdmin();
- }
- else
- {
- $this->prepareContent();
- }
- parent :: onPreRender($param);
- }
-
- /**
- * gets data and performs databBind
- */
- protected function prepareAdmin()
- {
- // get content records
- $crit= new LContentCriteria;
- $crit->setType($this->getClassId());
- $crit->setStatus(LContentCore::STATUS_PUBLISHED);
- $items= LContentCore :: queryRecords($crit->build());
- Prado :: log("Queried " . count($items) . " record(s)", 1, "Lithron.LContent");
-
- $ds= array ();
- if (is_array($items))
- foreach ($items as $item)
- {
- // parse the headlines
- $ds[$item->getId()]= $item->getHeadline();
- }
- // set the data source
- try
- {
- $this->AdminControls->ContentId->setDataSource($ds);
- $this->AdminControls->ContentId->dataBind();
- Prado :: log("Admin Datasource set!", 1, "Lithron.LContent");
- }
- catch (Exception $e)
- {
- Prado :: log("Error (!!!!) while databinding admin controls in brick: " . $e->getMessage(), 8, "Lithron.LContent");
- }
- }
-
- /**
- * gets data and performs databBind
- */
- protected function prepareContent()
- {
- $p= $this->getParameters();
- if ($p !== null)
- {
- $this->ContentObject= LContentCore :: queryRecords($p->itemAt("ContentId"));
- }
- if (!is_object($this->ContentObject))
- $this->ContentObject= new LContent();
- }
- }
- ?>