/** * Returns the Page Template ID. * * @return int */ public function getPageTemplateID() { return parent::getPageTemplateID(); }
public function publishToPage(Page $c, $data, $controls) { // for blocks, we need to also grab their output $bt = $this->getBlockTypeObject(); $pt = PageTemplate::getByID($c->getPageTemplateID()); $setControl = $this->getPageTypeComposerFormLayoutSetControlObject(); $b = $this->getPageTypeComposerControlBlockObject($c); if (!is_object($b)) { return; } // delete the block that this set control has placed on this version, because // we are going to replace it with a new one. $app = Application::getFacadeApplication(); $db = $app->make('database')->connection(); $q = 'select cvb.arHandle, cdb.bID, cdb.cbDisplayOrder from PageTypeComposerOutputBlocks cdb inner join CollectionVersionBlocks cvb on (cdb.bID = cvb.bID and cvb.cID = cdb.cID and cvb.cvID = ?) where cdb.ptComposerFormLayoutSetControlID = ? and cdb.cID = ?'; $v = [$c->getVersionID(), $setControl->getPageTypeComposerFormLayoutSetControlID(), $c->getCollectionID()]; $row = $db->fetchAssoc($q, $v); if ($row && $row['bID'] && $row['arHandle']) { $db->executeQuery('delete from PageTypeComposerOutputBlocks where ptComposerFormLayoutSetControlID = ? and cID = ?', [$setControl->getPageTypeComposerFormLayoutSetControlID(), $c->getCollectionID()]); } $arHandle = $b->getAreaHandle(); $blockDisplayOrder = $b->getBlockDisplayOrder(); $bFilename = $b->getBlockFilename(); $defaultStyles = $b->getCustomStyle(); $b->deleteBlock(); $ax = Area::getOrCreate($c, $arHandle); $b = $c->addBlock($bt, $ax, $data); $this->setPageTypeComposerControlBlockObject($b); $b->setAbsoluteBlockDisplayOrder($blockDisplayOrder); if ($bFilename) { $b->setCustomTemplate($bFilename); } if ($defaultStyles) { $b->setCustomStyleSet($defaultStyles->getStyleSet()); } // make a reference to the new block $this->recordPageTypeComposerOutputBlock($b); }