/** * Instantiates the block controller. * * @param BlockType $obj |Block $obj */ public function __construct($obj = null) { parent::__construct(); if ($obj instanceof BlockType) { $this->identifier = 'BLOCKTYPE_' . $obj->getBlockTypeID(); $this->btHandle = $obj->getBlockTypeHandle(); } else { if ($obj instanceof Block) { $b = $obj; $this->identifier = 'BLOCK_' . $obj->getBlockID(); $this->bID = $b->getBlockID(); $this->btHandle = $obj->getBlockTypeHandle(); $this->btCachedBlockRecord = $obj->getBlockCachedRecord(); $this->setBlockObject($b); $this->load(); } } $this->set('controller', $this); }
public function filterByBlockType(BlockType $bt) { $this->query->select('distinct p.cID'); $btID = $bt->getBlockTypeID(); $this->query->innerJoin('cv', 'CollectionVersionBlocks', 'cvb', 'cv.cID = cvb.cID and cv.cvID = cvb.cvID'); $this->query->innerJoin('cvb', 'Blocks', 'b', 'cvb.bID = b.bID'); $this->query->andWhere('b.btID = :btID'); $this->query->setParameter('btID', $btID); }
public function addBlockType(BlockTypeEntity $bt) { $db = Loader::db(); $no = $db->GetOne("select count(btID) from BlockTypeSetBlockTypes where btID = ? and btsID = ?", array($bt->getBlockTypeID(), $this->getBlockTypeSetID())); if ($no < 1) { $types = $db->GetOne('select count(btID) from BlockTypeSetBlockTypes where btsID = ?', array($this->getBlockTypeSetID())); $displayOrder = 0; if ($types > 0) { $displayOrder = $db->GetOne('select max(displayOrder) from BlockTypeSetBlockTypes where btsID = ?', array($this->getBlockTypeSetID())); ++$displayOrder; } $db->Execute('insert into BlockTypeSetBlockTypes (btsID, btID, displayOrder) values (?, ?, ?)', array($this->getBlockTypeSetID(), $bt->getBlockTypeID(), $displayOrder)); } }