public function activate_files($ptID) { try { Loader::model("collection_types"); $pt = PageTheme::getByID($ptID); $txt = Loader::helper('text'); if (!is_array($this->post('pageTypes'))) { throw new Exception(t("You must specify at least one template to make into a page type.")); } $pkg = false; $pkgHandle = $pt->getPackageHandle(); if ($pkgHandle) { $pkg = Package::getByHandle($pkgHandle); } foreach ($this->post('pageTypes') as $ptHandle) { $data['ctName'] = $txt->unhandle($ptHandle); $data['ctHandle'] = $ptHandle; $ct = CollectionType::add($data, $pkg); } $this->set('message', t('Files in the theme were activated successfully.')); } catch (Exception $e) { $this->set('error', $e); } $this->view($ptID); }
public function do_add() { $ctName = $_POST['ctName']; $ctHandle = $_POST['ctHandle']; $error = array(); if (!$ctHandle) { $this->error->add(t("Handle required.")); } if (!$ctName) { $this->error->add(t("Name required.")); } $valt = Loader::helper('validation/token'); if (!$valt->validate('add_page_type')) { $this->error->add($valt->getErrorMessage()); } $akIDArray = $_POST['akID']; if (!is_array($akIDArray)) { $akIDArray = array(); } if (!$this->error->has()) { try { if ($_POST['task'] == 'add') { $nCT = CollectionType::add($_POST); $this->redirect('/dashboard/pages/types', 'page_type_added'); } exit; } catch (Exception $e1) { $this->error->add($e1->getMessage()); } } }
public function run() { BlockType::installBlockType('tags'); BlockType::installBlockType('next_previous'); BlockType::installBlockType('date_nav'); Loader::model('collection_types'); $blogEntry = CollectionType::getByHandle('blog_entry'); if (!$blogEntry || !intval($blogEntry->getCollectionTypeID())) { $data['ctHandle'] = 'blog_entry'; $data['ctName'] = t('Blog Entry'); $blogEntry = CollectionType::add($data); } }
public function install() { Loader::model('collection_types'); $pkg = parent::install(); PageTheme::add('casual', $pkg); $pagetypearray = array(array("left_sidebar", "Left Sidebar"), array("right_sidebar", "Right Sidebar"), array("full", "One Column"), array("three_column", "Three Column Layout")); foreach ($pagetypearray as $value) { $pageType = CollectionType::getByHandle($value[0]); if (!$pageType) { $pkg = Package::getByHandle('casual'); $newPageType = CollectionType::add(array('ctHandle' => $value[0], 'ctName' => t($value[1])), $pkg); } else { $newPageType = $pageType; } } }
public function do_add() { $ctName = $_POST['ctName']; $ctHandle = $_POST['ctHandle']; $vs = Loader::helper('validation/strings'); $error = array(); if (!$ctHandle) { $this->error->add(t("Handle required.")); } else { if (!$vs->handle($ctHandle)) { $this->error->add(t('Handles must contain only letters, numbers or the underscore symbol.')); } } if (CollectionType::getByHandle($ctHandle)) { $this->error->add(t('Handle already exists.')); } if (!$ctName) { $this->error->add(t("Name required.")); } else { if (preg_match('/[<>{};?"`]/i', $ctName)) { $this->error->add(t('Invalid characters in page type name.')); } } $valt = Loader::helper('validation/token'); if (!$valt->validate('add_page_type')) { $this->error->add($valt->getErrorMessage()); } $akIDArray = $_POST['akID']; if (!is_array($akIDArray)) { $akIDArray = array(); } if (!$this->error->has()) { try { if ($_POST['task'] == 'add') { $nCT = CollectionType::add($_POST); $this->redirect('/dashboard/pages/types', 'page_type_added'); } exit; } catch (Exception $e1) { $this->error->add($e1->getMessage()); } } }
private function installPageTypes($pkg) { // // Often page types are needed by packages. // $boilerplate = CollectionType::getByHandle('boilerplate'); if (!is_object($boilerplate)) { /* * Other arguments you can pass in: * * ctIsInternal boolean - will prevent page type from showing up * in the add page dialog and page_types dashboard page * * ctIcon - filename for the icon in the add page dialog, not sure * if this has to exist somewhere, or if it can be a full http:// * path. the system just has filenames * * cDescription - self explanatory * * akID = array - each element would be the id of an attribute that * you would like to be associated with the page on the add screen * * this is how to get the id of the attribute you want * $ak = CollectionAttributeKey::getByHandle('your_handle'); * $akID = $ak->getAttributeKeyID(); * */ $data = array('ctHandle' => 'boilerplate', 'ctName' => t('Boilerplate Page')); $boilerplate = CollectionType::add($data, $pkg); } /* * Now that we have the boilerplate page type, we want to grab the master * collection and add a block to it */ $bpMC = $boilerplate->getMasterTemplate(); $bt = BlockType::getByHandle('content'); $data = array('content' => t("Sample Boilerplate Content")); $bpMC->addBlock($bt, 'Boilerplate Content', $data); /* * If you want to assign all the blocks from another page type to your * custom page type, this is the syntax: */ // $mc1 = CollectionType::getByHandle('left_sidebar'); // $mc2 = CollectionType::getByHandle('page'); // if (is_object($mc1) && is_object($bpMC)) { // $dm = $mc1->getMasterTemplate(); // $blocks = $dm->getBlocks(); // // // alias these blocks to the new event calendar page // foreach ($blocks as $b) { // $b->alias($bpMC); // } // } else { // if (is_object($mc2) && is_object($bpMC)) { // $dm = $mc2->getMasterTemplate(); // $blocks = $dm->getBlocks(); // // alias these blocks to the new event calendar page // foreach ($blocks as $b) { // $b->alias($bpMC); // } // } // } }
$error[] = t("Name required."); } if (!$valt->validate('add_or_update_page_type')) { $error[] = $valt->getErrorMessage(); } $akIDArray = $_POST['akID']; if (!is_array($akIDArray)) { $akIDArray = array(); } if (count($error) == 0) { try { if ($_POST['task'] == 'add') { $nCT = CollectionType::add($_POST); $this->controller->redirect('/dashboard/pages/types?created=1'); } else if (is_object($ct)) { $ct->update($_POST); $this->controller->redirect('/dashboard/pages/types?updated=1'); } exit; } catch(Exception $e1) { $error[] = $e1->getMessage(); } } } if ($_REQUEST['created']) { $message = t('Page Type added.'); } else if ($_REQUEST['updated']) {
flush(); ob_flush(); } // install page types $page_type_handles = array(array('ctHandle' => 'home', 'ctName' => 'HOME'), array('ctHandle' => 'localized_home', 'ctName' => 'Localized Home'), array('ctHandle' => 'localized_projects', 'ctName' => 'Localized Projects'), array('ctHandle' => 'localized_engineers', 'ctName' => 'Localized Engineers'), array('ctHandle' => 'personal_homepage', 'ctName' => 'Personal Home'), array('ctHandle' => 'project_arena_homepage', 'ctName' => 'Arena Home'), array('ctHandle' => 'project_arena', 'ctName' => 'Arena'), array('ctHandle' => 'project_arena_subject', 'ctName' => 'Arena Subject'), array('ctHandle' => 'project_arena_zone', 'ctName' => 'Arena Zone'), array('ctHandle' => 'project_comm_forum_area', 'ctName' => 'Forum Area'), array('ctHandle' => 'project_comm_forum', 'ctName' => 'Forum'), array('ctHandle' => 'project_comm_homepage', 'ctName' => 'Community Home'), array('ctHandle' => 'project_comm_thread', 'ctName' => 'Forum Thread'), array('ctHandle' => 'project_contribute_default', 'ctName' => 'Default for Contribute'), array('ctHandle' => 'project_contribute_homepage', 'ctName' => 'Contribute Home'), array('ctHandle' => 'project_doc_homepage', 'ctName' => 'Document Home'), array('ctHandle' => 'project_doc_volume', 'ctName' => 'Document Volume'), array('ctHandle' => 'project_doc_part', 'ctName' => 'Documnet Part'), array('ctHandle' => 'project_doc_chapter', 'ctName' => 'Chapter'), array('ctHandle' => 'project_doc_all_blogs', 'ctName' => 'All Blogs'), array('ctHandle' => 'project_doc_fse_blogs', 'ctName' => 'Blog Zone'), array('ctHandle' => 'project_doc_blog', 'ctName' => 'Blog'), array('ctHandle' => 'project_download_default', 'ctName' => 'Default for Download'), array('ctHandle' => 'project_download_homepage', 'ctName' => 'Download Home'), array('ctHandle' => 'project_homepage', 'ctName' => 'Project Home'), array('ctHandle' => 'project_misc_homepage', 'ctName' => 'About'), array('ctHandle' => 'project_misc_faqs', 'ctName' => 'FAQs'), array('ctHandle' => 'project_misc_default', 'ctName' => 'Default for Misc')); $nocache_pths = array('project_arena_homepage', 'project_arena', 'project_arena_subject', 'project_arena_zone', 'project_comm_forum_area', 'project_comm_forum', 'project_comm_homepage', 'project_comm_thread'); $short_cache_pths = array('localized_home', 'personal_homepage'); echo '<br/>'; echo 'Installing page types... <br/>'; foreach ($page_type_handles as $pth) { echo ' installing ' . $pth['ctHandle'] . ': '; $page_type = CollectionType::getByHandle($pth['ctHandle']); if ($page_type instanceof CollectionType) { echo $pth['ctHandle'] . ' had been installed; skip installing. <br/>'; } else { $page_type = CollectionType::add($pth, $pkg); echo $pth['ctHandle'] . ' newly installed. <br/>'; $masterCID = $page_type->getMasterCollectionID(); $masterCollection = Page::getByID($masterCID); if (in_array($pth['ctHandle'], $nocache_pths)) { // disable full page cache for specific page types $masterCollection->update(array('cCacheFullPageContent' => 0)); } else { if (in_array($pth['ctHandle'], $short_cache_pths)) { // set full page cache for specific page types $masterCollection->update(array('cCacheFullPageContent' => 1, 'cCacheFullPageContentOverrideLifetime' => 'custom', 'cCacheFullPageContentLifetimeCustom' => 10)); } else { // follow system default for other page types $masterCollection->update(array('cCacheFullPageContent' => -1, 'cCacheFullPageContentOverrideLifetime' => '0', 'cCacheFullPageContentLifetimeCustom' => 0)); } }
protected function importPageTypesBase(SimpleXMLElement $sx) { if (isset($sx->pagetypes)) { foreach($sx->pagetypes->pagetype as $ct) { $pkg = ContentImporter::getPackageObject($ct['package']); $ctt = CollectionType::getByHandle($ct['handle']); if (!is_object($ctt)) { $ctr = CollectionType::add(array( 'ctHandle' => $ct['handle'], 'ctName' => $ct['name'], 'ctIcon' => $ct['icon'], 'ctIsInternal' => (string) $ct['internal'] ), $pkg); } } } }