Source for file LCell.php
Documentation is available at LCell.php
* @license http://opensource.org/licenses/mozilla1.1.php Mozilla Public License
* @copyright 2005, diemeisterei GmbH. All rights reserved.
* @author $Author: schmunk $
* @version $Revision: 601 $ $Date: 2007-02-24 23:49:30 +0100 (Sa, 24 Feb 2007) $
* @package Phundament.Packages
* This is a container component for controls implementing the brick interface
* @package System.Web.UI.WebControls
* @subpackage CMS.Support
Prado :: setPathOfAlias("LContainer", dirname(__FILE__ ));
Prado :: using("LContainer.db.propel.*");
Prado :: using("LContainer.db.propel.l_container.*");
class LCell extends TPanel
const SN_PREFIX= "SNID_";
* sets the style string for all divs surrounding a brick
$this->setViewState("BrickStyle", $value);
* returns the style string for all divs surrounding a brick
return $this->getViewState("BrickStyle", "none");
* sets the class string for all divs surrounding a brick
$this->setViewState("BrickCssClass", $value);
* returns the class string for all divs surrounding a brick
return $this->getViewState("BrickCssClass", "none");
$this->setViewState("IgnoreCulture", $value);
* returns the class string for all divs surrounding a brick
return TPropertyValue :: ensureBoolean($this->getViewState("IgnoreCulture", false));
* prepares the bricks. Data querying, creation of the compontents defined in the database.
public function onInit($param)
parent :: onInit($param);
#var_dump($this->Service->CurrentNode);
if (LRightsManager :: getRights($this->Service->CurrentNode) & LPermissions :: USAGE)
$this->addCellAdminPanel();
private function queryBricks()
$db= $this->Application->getModule("database");
$this->conn= $db->getConnection("l_container", "propel");
#echo $this->Service->getServicePage()."---";
$c->add(LContainerBrickPeer :: PAGE, $this->Service->getServicePage());
$c->addAnd(LContainerBrickPeer :: CELL, $this->getId());
$c->addAnd(LContainerBrickPeer :: CULTURE, "");
$_add= " (ignores culture setting)";
$c->addAnd(LContainerBrickPeer :: CULTURE, $this->Application->Globalization->Culture);
// show all or only active, depending on permissions
if (!(LRightsManager :: getRights($this->Service->CurrentNode) & LPermissions :: USAGE))
$c->addAnd(LContainerBrickPeer :: STATUS, 1);
$header= "<div class='AdminCellHeader' align=center>" . $this->Id . $_add . "</div>";
$this->Controls[]= $header;
$c->addAscendingOrderByColumn(LContainerBrickPeer :: RANK);
$this->Bricks= LContainerBrickPeer :: doSelect($c, $this->conn);
Prado :: log("Queried" . count($this->Bricks) . " brick(s) for [". $this->Service->getServicePage(). "," . $this->getId() . "]", 1, "Lithron.LCell");
$this->BrickSpace= new TContentPlaceholder();
$this->Controls[]= $this->BrickSpace;
// create bricks (controls)
foreach ($this->Bricks as $brick)
$brick->setRank($autorank);
// skip, if no control available XEC
if (!$brick->getControl())
// try to create the brick
$class= $brick->getControl();
$instance= Prado :: createComponent($class);
$instance->BrickObject= $brick;
$instance->setId("brick" . $brick->getId());
$instance->setCell($this);
// show only if params available or if admin
if ($instance->Parameters instanceof TMap || LRightsManager :: getRights($this->Service->CurrentNode) & LPermissions :: CREATE)
Prado :: log("$class [" . $instance->getId() . "] added to LCell [" . $this->getId() . "]", 1, "Lithron.LCell");
$this->BrickSpace->Controls[]= $instance;
Prado :: log("No parameters for " . $instance->getId() . " ($class) in LCell (" . $this->getId() . ")", 5, "Lithron.LCell");
Prado :: log("No class found for $class in LCell (" . $this->getId() . ")", 2, "Lithron.LCell");
Prado :: log("Exception message: " . $e->getMessage() . " ", 8, "Lithron.LCell");
$instance= Prado :: createComponent("LDummyBrick");
$instance->BrickObject= $brick;
$this->BrickSpace->Controls[]= '<div class="Error">';
$this->BrickSpace->Controls[]= $instance;
$this->BrickSpace->Controls[]= $e->getMessage();
$this->BrickSpace->Controls[]= '</div>';
* returns all available bricks from config
* Descriptive names are read if possible
static $brick_config= null;
if ($brick_config !== null)
$val= $this->Application->getParameters()->itemAt("AvailableBricks");
$bricks= split(",", $val);
foreach ($bricks as $brick)
#Prado :: trace("Analyzing {$num}. brick from config, type is {$brick}", "Lithron.LContainer");
throw new Exception("BrickObject is empty");
$namedBricks[$brick]= $dummy->getDescriptiveName();
$namedBricks[$brick]= $brick;
Prado :: log("Unable to analyze $brick: " . $e->getMessage(), 16, "Lithron.LContainer");
$cache->set("LCell:AvailableBricks", Prado :: serialize($namedBricks), 60);
$cache->set("LCell:AvailableBricksHash", $val);
Prado :: log("No AvailableBricks found in application.xml", 8, "Lithron.LContainer");
$brick_config= $namedBricks;
* adds admin menu for this cell
* @todo cleanup button adding
private function addCellAdminPanel()
$this->Controls[]= "<div class='AdminCellMenu' style='float:left'><div class='Menu'>";
$this->Controls[]= "<table width='100%'><tr><td align=right width='95%'>";
$this->TypeSelector= new TDropDownList();
$this->TypeSelector->setWidth("100%");
$this->TypeSelector->setDataSource($ds);
$this->TypeSelector->dataBind();
$this->Controls[]= $this->TypeSelector;
$button->ImageUrl= $this->publishAsset("icons/plus.png");
$button->onClick= array (
$button->SkinID= "BrickAdminMenu";
$button->ToolTip= "Add selected Brick";
$this->Controls[]= "</td><td>";
$this->Controls[]= $button;
$this->Controls[]= "</td></tr></table>";
$this->Controls[]= "</div></div>";
* adds a new brick to the cell, by adding a record to the database
$class= $this->TypeSelector->getSelectedValue();
$brick= new LContainerBrick();
// set culture, depending if this is an IgnoreCultureCell
$brick->setCulture($this->Application->Globalization->Culture);
$brick->setPage($this->Service->getServicePage());
$brick->setCell($this->getId());
$brick->setControl($class);
LRightsManager :: setRights($brick);
$brick->save($this->conn);
$this->Service->reload();
* moves a brick up, by changing two bricks rank
$this->Bricks[$num]->setRank($num - 1);
$this->Bricks[$num]->save();
$this->Bricks[$num - 1]->setRank($num);
$this->Bricks[$num - 1]->save();
$this->Service->reload();
* moves a brick down, by changing two bricks rank
if ($num == count($this->Bricks) - 1)
$this->Bricks[$num]->setRank($num + 1);
$this->Bricks[$num]->save();
$this->Bricks[$num + 1]->setRank($num);
$this->Bricks[$num + 1]->save();
$this->Service->reload();
|