protected static function createPage($name, $parent = false, $type = false, $template = false) { if ($parent === false) { $parent = Page::getByID(HOME_CID); } else { if (is_string($parent)) { $parent = Page::getByPath($parent); } } if ($type === false) { $type = 1; } if (is_string($type)) { $pt = PageType::getByHandle($type); } else { $pt = PageType::getByID($type); } if ($template === false) { $template = 1; } if (is_string($template)) { $template = PageTemplate::getByHandle($template); } else { $template = PageTemplate::getByID($template); } $page = $parent->add($pt, array('cName' => $name, 'pTemplateID' => $template->getPageTemplateID())); return $page; }
public function action_post() { // happens through ajax $pagetype = PageType::getByID($this->ptID); if (is_object($pagetype) && $this->enableNewTopics) { $ccp = new Permissions($pagetype); if ($ccp->canAddPageType()) { $pagetypes = $pagetype->getPageTypeComposerPageTypeObjects(); $ctTopic = $pagetypes[0]; $c = Page::getCurrentPage(); $e = $pagetype->validatePublishRequest($ctTopic, $c); $r = new PageTypePublishResponse($e); if (!$e->has()) { $d = $pagetype->createDraft($ctTopic); $d->setPageDraftTargetParentPageID($c->getCollectionID()); $d->saveForm(); $d->publish(); $nc = Page::getByID($d->getCollectionID(), 'RECENT'); $link = Loader::helper('navigation')->getLinkToCollection($nc, true); $r->setRedirectURL($link); } $r->outputJSON(); } } exit; }
protected function addPage2() { $home = Page::getByID(HOME_CID); PageType::add(array('handle' => 'alternate', 'name' => 'Alternate')); $pt = PageType::getByID(2); $template = PageTemplate::getByID(1); $page = $home->add($pt, array('uID' => 1, 'cName' => 'Test page', 'pTemplateID' => $template->getPageTemplateID())); return $page; }
public function create_new() { $pr = new PageEditResponse(); $ms = Section::getByID($this->request->request->get('section')); // we get the related parent id if ($this->page->isPageDraft()) { $cParentID = $this->page->getPageDraftTargetParentPageID(); } else { $cParentID = $this->page->getCollectionParentID(); } $cParent = \Page::getByID($cParentID); $cParentRelatedID = $ms->getTranslatedPageID($cParent); if ($cParentRelatedID > 0) { // we copy the page underneath it and store it $ct = \PageType::getByID($this->page->getPageTypeID()); if ($this->page->isPageDraft()) { $ptp = new \Permissions($ct); if (!$ptp->canAddPageType()) { throw new \Exception(t('You do not have permission to add a page of this type.')); } } $newParent = \Page::getByID($cParentRelatedID); $cp = new \Permissions($newParent); if ($cp->canAddSubCollection($ct)) { if ($this->page->isPageDraft()) { $targetParent = \Page::getByPath(\Config::get('concrete.paths.drafts')); } else { $targetParent = $newParent; } $newPage = $this->page->duplicate($targetParent); if (is_object($newPage)) { if ($this->page->isPageDraft()) { $newPage->setPageDraftTargetParentPageID($newParent->getCollectionID()); Section::relatePage($this->page, $newPage, $ms->getLocale()); $pr->setMessage(t('New draft created.')); } else { // grab the approved version and unapprove it $v = Version::get($newPage, 'ACTIVE'); if (is_object($v)) { $v->deny(); } $pr->setMessage(t('Unapproved page created. You must publish this page before it is live.')); } $ih = Core::make('multilingual/interface/flag'); $icon = (string) $ih->getSectionFlagIcon($ms); $pr->setAdditionalDataAttribute('name', $newPage->getCollectionName()); $pr->setAdditionalDataAttribute('link', $newPage->getCollectionLink()); $pr->setAdditionalDataAttribute('icon', $icon); } } else { throw new \Exception(t('You do not have permission to add this page to this section of the tree.')); } } $pr->outputJSON(); }
public function create_new() { $pr = new PageEditResponse(); $ms = Section::getByID($this->request->request->get('section')); // we get the related parent id $cParentID = $this->page->getCollectionParentID(); $cParent = \Page::getByID($cParentID); $cParentRelatedID = $ms->getTranslatedPageID($cParent); if ($cParentRelatedID > 0) { // we copy the page underneath it and store it $newParent = \Page::getByID($cParentRelatedID); $ct = \PageType::getByID($this->page->getPageTypeID()); $cp = new \Permissions($newParent); if ($cp->canAddSubCollection($ct) && $this->page->canMoveCopyTo($newParent)) { $newPage = $this->page->duplicate($newParent); if (is_object($newPage)) { // grab the approved version and unapprove it $v = Version::get($newPage, 'ACTIVE'); if (is_object($v)) { $v->deny(); $pkr = new ApprovePageRequest(); $pkr->setRequestedPage($newPage); $u = new \User(); $pkr->setRequestedVersionID($v->getVersionID()); $pkr->setRequesterUserID($u->getUserID()); $response = $pkr->trigger(); if (!$response instanceof Response) { // we are deferred $pr->setMessage(t('<strong>Request Saved.</strong> You must complete the workflow before this change is active.')); } else { $ih = Core::make('multilingual/interface/flag'); $icon = $ih->getSectionFlagIcon($ms); $pr->setAdditionalDataAttribute('name', $newPage->getCollectionName()); $pr->setAdditionalDataAttribute('link', $newPage->getCollectionLink()); $pr->setAdditionalDataAttribute('icon', $icon); $pr->setMessage(t('Page created.')); } } } } else { throw new \Exception(t('You do not have permission to add this page to this section of the tree.')); } } $pr->outputJSON(); }
$canMoveCopyPages = true; if (isset($_REQUEST['origCID']) && strpos($_REQUEST['origCID'], ',') > -1) { $ocs = explode(',', $_REQUEST['origCID']); foreach ($ocs as $ocID) { $originalPages[] = Page::getByID($ocID); } } foreach ($originalPages as $oc) { $ocp = new Permissions($oc); if (!$ocp->canRead()) { $canReadSource = false; } if (!$ocp->canMoveOrCopyPage()) { $canMoveCopyPages = false; } $ct = PageType::getByID($oc->getPageTypeID()); if (!$dcp->canAddSubpage($ct)) { $canAddSubContent = false; } if (!$oc->canMoveCopyTo($dc)) { $canMoveCopyTo = false; } if (!$u->isSuperUser() || $oc->getCollectionPointerID() > 0) { $canCopyChildren = false; } } if (is_object($dc) && !$dc->isError() && $dc->isAlias()) { $canMoveCopyTo = false; } $valt = Loader::helper('validation/token'); $json = array();
<div class="small"> <?php foreach ($publishErrors->getList() as $error) { ?> <div class="text-warning"><strong><i class="fa fa-warning"></i> <?php echo $error; ?> </strong></div> <br/> <?php } ?> </div> <?php $pagetype = PageType::getByID($c->getPageTypeID()); if (is_object($pagetype)) { ?> <div class="small"> <div class="text-info"><strong><i class="fa fa-question-circle"></i> <?php echo t('You can specify page name, page location and attributes from the <a href="#" data-launch-panel-detail="page-composer" data-panel-detail-url="%s" data-panel-transition="fade">Page Compose interface</a>.', URL::to('/ccm/system/panels/details/page/composer')); ?> </strong></div> <br/> </div> <?php } ?> <?php }
<?php defined('C5_EXECUTE') or die("Access Denied."); $ch = Page::getByPath('/dashboard/pages/types', 'RECENT'); $chp = new Permissions($ch); if ($_REQUEST['ptID'] > 0) { $pt = PageType::getByID($_REQUEST['ptID']); $fsp = new Permissions($fs); if ($chp->canViewPage()) { Loader::element('permission/details/page_type', array("pagetype" => $pt)); } }
public function testDelete() { $db = Database::get(); $page1 = self::createPage('Awesome Page'); $page2 = self::createPage('Awesome Page 2'); $this->assertEquals(3, $page2->getCollectionID()); $page2->delete(); $np = Page::getByID(3); $this->assertEquals($np->getCollectionID(), null); $pt = PageType::getByID(1); $template = PageTemplate::getByID(1); $newpage = $page1->add($pt, array('uID' => 1, 'cName' => 'Test Sub-page', 'pTemplateID' => $template->getPageTemplateID())); $page1->delete(); $this->assertEquals(1, $db->GetOne('select count(cID) from Pages')); $np1 = Page::getByID(2); $np2 = Page::getByID(4); $this->assertEquals($np1->getCollectionID(), null); $this->assertEquals($np2->getCollectionID(), null); }
public function testPagePathUpdate() { $home = Page::getByID(HOME_CID); $pt = PageType::getByID(1); $template = PageTemplate::getByID(1); $page = $home->add($pt, array('uID' => 1, 'cName' => 'Here\'s a twist', 'pTemplateID' => $template->getPageTemplateID())); $nc = $page->getVersionToModify(); $nc->addAdditionalPagePath('/something/cool', false); $nc->addAdditionalPagePath('/something/rad', true); $nc->update(array('cName' => 'My new name', 'cHandle' => false)); $nv = $nc->getVersionObject(); $nv->approve(); $nc2 = Page::getByID(2); $this->assertEquals('/my-new-name', $nc2->getCollectionPath()); $this->assertEquals('my-new-name', $nc2->getCollectionHandle()); $this->assertEquals(2, $nc2->getVersionID()); $path = $nc2->getCollectionPathObject(); $this->assertInstanceOf('\\Concrete\\Core\\Page\\PagePath', $path); $this->assertEquals('/my-new-name', $path->getPagePath()); $this->assertEquals(true, $path->isPagePathAutoGenerated()); $this->assertEquals(true, $path->isPagePathCanonical()); $additionalPaths = $nc2->getAdditionalPagePaths(); $this->assertEquals(2, count($additionalPaths)); $this->assertEquals('/something/rad', $additionalPaths[1]->getPagePath()); $this->assertEquals(false, $additionalPaths[1]->isPagePathAutoGenerated()); $this->assertEquals(false, $additionalPaths[1]->isPagePathCanonical()); }
public function view() { if ($this->gaID) { $gathering = Gathering::getByID($this->gaID); if (is_object($gathering)) { Core::make('helper/overlay')->init(false); if ($this->enablePostingFromGathering && $this->ptID) { $pt = PageType::getByID($this->ptID); Core::make('helper/concrete/composer')->addAssetsToRequest($pt, $this); $p = new Permissions($pt); if ($p->canEditPageTypeInComposer()) { $this->set('pagetype', $pt); } } $list = new GatheringItemList($gathering); $list->sortByDateDescending(); $list->setItemsPerPage($this->itemsPerPage); $this->set('gathering', $gathering); $this->set('itemList', $list); } } }
<?php defined('C5_EXECUTE') or die("Access Denied."); $u = new User(); $form = Loader::helper('form'); $sh = Loader::helper('concrete/dashboard/sitemap'); if (!$sh->canRead()) { die(t('Access Denied')); } if ($_POST['task'] == 'design_pages') { $json['error'] = false; if ($_POST['plID'] > 0) { $pl = PageTheme::getByID($_POST['plID']); } if ($_POST['ptID'] > 0) { $ct = PageType::getByID($_POST['ptID']); } if (is_array($_POST['item'])) { foreach ($_POST['item'] as $cID) { $c = Page::getByID($cID); $cp = new Permissions($c); if ($cp->canEditPageTheme($pl)) { if ($_POST['plID'] > 0) { $c->setTheme($pl); } if ($_POST['ptID'] > 0 && (!$c->isMasterCollection() && !$c->isGeneratedCollection())) { $parentC = Page::getByID($c->getCollectionParentID()); $parentCP = new Permissions($parentC); if ($c->getCollectionID() == HOME_CID || $parentCP->canAddSubCollection($ct)) { $data = array('ptID' => $_POST['ptID']); $c->update($data);
function save_settings() { if ($_POST['optional_attributes']) { $forumAttributes = serialize($_POST['optional_attributes']); /* Get blog_post page template */ $pageType = \PageType::getByID($_POST['page_type']); $ctTemplate = $pageType->getPageTypeDefaultPageTemplateObject(); $blogPostTemplate = $pageType->getPageTypePageTemplateDefaultPageObject($ctTemplate); // Drop the Optional Attribute Composer Layout $db = Loader::db(); $db->Execute('delete from PageTypeComposerFormLayoutSets where ptComposerFormLayoutSetName = ?', array('Optional Attributes')); /* Add Composer Layouts */ $post = $pageType->addPageTypeComposerFormLayoutSet('Optional Attributes', 'Optional Attributes'); /* Add Optional Attributes */ $cct = ComposerControlType::getByHandle('collection_attribute'); foreach ($_POST['optional_attributes'] as $oa) { $control = $cct->getPageTypeComposerControlByIdentifier($oa); $control->addToPageTypeComposerFormLayoutSet($post); } } $db = Loader::db(); // Drop database row $db->Execute('DELETE FROM btWebliForums WHERE cID= ?', $_POST['cID']); $db->Execute('insert into btWebliForums ( cID, display_title, display_date, date_format, display_author, display_tags, enable_comments, enable_breadcrumb, mod_approval, display_image, crop_image, image_height, image_width, add_this, add_this_script, add_this_share_html, add_this_follow_html, add_this_recommend_html, share_this, share_this_script, share_this_html, twitter_post, twitter_api_key, twitter_api_secret, twitter_token, twitter_token_secret, twitter_select, twitter_image, anonymous_posts, captcha, forum_search_block, forum_archive_block, forum_tags_block, display_avatars, notification, email_addresses, page_template, page_type, optional_attributes, rich_text) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)', array($_POST['cID'], $_POST['display_title'], $_POST['display_date'], $_POST['date_format'], $_POST['display_author'], $_POST['display_tags'], $_POST['enable_comments'], $_POST['enable_breadcrumb'], $_POST['mod_approval'], $_POST['display_image'], $_POST['crop_image'], $_POST['image_height'], $_POST['image_width'], $_POST['add_this'], $_POST['add_this'] ? $_POST['add_this_script'] : null, $_POST['add_this'] ? $_POST['add_this_share_html'] : null, $_POST['add_this'] ? $_POST['add_this_follow_html'] : null, $_POST['add_this'] ? $_POST['add_this_recommend_html'] : null, $_POST['share_this'], $_POST['share_this'] ? $_POST['share_this_script'] : null, $_POST['share_this'] ? $_POST['share_this_html'] : null, $_POST['twitter_post'], $_POST['twitter_api_key'], $_POST['twitter_api_secret'], $_POST['twitter_token'], $_POST['twitter_token_secret'], $_POST['twitter_select'], $_POST['twitter_image'], $_POST['anonymous_posts'], $_POST['captcha'], $_POST['forum_search_block'], $_POST['forum_archive_block'], $_POST['forum_tags_block'], $_POST['display_avatars'], $_POST['notification'], $_POST['email_addresses'], $_POST['page_template'], $_POST['page_type'], $forumAttributes, $_POST['rich_text'])); $this->save_active_category($_POST['cID']); $this->save_active_tab($_POST['activeTab']); $this->redirect(Page::getCurrentPage()->getCollectionPath()); }
<?php exit; defined('C5_EXECUTE') or die("Access Denied."); if (isset($_POST['ttask']) && $_POST['ttask'] == 'preview_theme_customization') { Core::make('cache')->getItem('preview_theme_style/' . $_REQUEST['themeID'])->set($_POST, 30); } $previewCID = intval($_REQUEST['previewCID']); $themeID = intval($_REQUEST['themeID']); $ptID = intval($_REQUEST['ptID']); $collectionType = PageType::getByID($ptID); $c = Page::getByID($previewCID, 'RECENT'); //,"ACTIVE" $cp = new Permissions($c); if (!$cp->canEditPageTheme()) { throw new Exception(t('Access Denied')); } $v = View::getInstance(); if ($themeID > 0) { $th = PageTheme::getByID($themeID); if (!file_exists($th->getThemeDirectory())) { throw new Exception(t('Theme not found in %s', $th->getThemeDirectory())); } $v->setTheme($th); } $v->render($c);