本文整理匯總了PHP中Concrete\Core\Page\Page::getByID方法的典型用法代碼示例。如果您正苦於以下問題:PHP Page::getByID方法的具體用法?PHP Page::getByID怎麽用?PHP Page::getByID使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Concrete\Core\Page\Page
的用法示例。
在下文中一共展示了Page::getByID方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: import
public function import(\SimpleXMLElement $sx)
{
$siteTree = null;
if (isset($this->home)) {
$siteTree = $this->home->getSiteTreeObject();
}
if (isset($sx->pages)) {
foreach ($sx->pages->page as $px) {
if ($px['path'] != '') {
$page = Page::getByPath($px['path'], 'RECENT', $siteTree);
} else {
if (isset($this->home)) {
$page = $this->home;
} else {
$page = Page::getByID(HOME_CID, 'RECENT');
}
}
if (isset($px->area)) {
$this->importPageAreas($page, $px);
}
if (isset($px->attributes)) {
foreach ($px->attributes->children() as $attr) {
$handle = (string) $attr['handle'];
$ak = CollectionKey::getByHandle($handle);
if (is_object($ak)) {
$value = $ak->getController()->importValue($attr);
$page->setAttribute($handle, $value);
}
}
}
$page->reindex();
}
}
}
示例2: getContentObject
public function getContentObject()
{
if ($this->getReference() == '/' || $this->getReference() == '') {
return Page::getByID(HOME_CID, 'ACTIVE');
}
$c = Page::getByPath($this->getReference(), 'ACTIVE');
if (is_object($c) && !$c->isError()) {
return $c;
}
}
示例3: export
public function export($cxml)
{
$target = parent::export($cxml);
if ($this->getStartingPointPageID()) {
$c = Page::getByID($this->getStartingPointPageID(), 'ACTIVE');
if (is_object($c) && !$c->isError()) {
$target->addAttribute('path', $c->getCollectionPath());
}
}
$target->addAttribute('form-factor', $this->getSelectorFormFactor());
}
示例4: getCommentsByParentIDs
public function getCommentsByParentIDs($IDs)
{
$db = Loader::db();
$child_pages = array();
$blogList = new PageList();
$blogList->sortBy('cDateAdded', 'desc');
//$blogList->filter(false,"(CHAR_LENGTH(cv.cvName) > 4 OR cv.cvName NOT REGEXP '^[0-9]')");
$blogList->filter(false, "ak_is_canonical_page < 1");
if (!$IDs) {
$r = $db->EXECUTE("SELECT DISTINCT cnv.cID FROM ConversationMessages cnvm LEFT JOIN Conversations cnv ON cnvm.cnvID = cnv.cnvID ORDER BY cnvMessageDateCreated DESC");
while ($row = $r->fetchrow()) {
$IDs[] = $row['cID'];
}
}
if (is_array($IDs)) {
foreach ($IDs as $id) {
if ($fs) {
$fs .= ' OR ';
}
$path = Page::getByID($id)->getCollectionPath() . '/';
$fs .= "pp.cPath LIKE '{$path}%'";
}
$blogList->filter(false, "({$fs})");
}
//$blogList->filter(false,"(CHAR_LENGTH(cv.cvName) > 4 OR cv.cvName NOT REGEXP '^[0-9]')");
$blogList->filter(false, "ak_is_canonical_page < 1");
$blogResults = $blogList->get();
foreach ($blogResults as $result) {
$child_pages[] = $result->getCollectionID();
}
$filter = '';
if ($this->request('comment_todo')) {
$this->set('comment_todo', $this->request('comment_todo'));
switch ($this->request('comment_todo')) {
case 'approves':
$filter = "WHERE cnvm.cnvIsMessageApproved = 1";
break;
case 'unapproves':
$filter = "WHERE cnvm.cnvIsMessageDeleted = 1";
break;
}
}
$r = $db->EXECUTE("SELECT * FROM ConversationMessages cnvm LEFT JOIN Conversations cnv ON cnvm.cnvID = cnv.cnvID {$filter} ORDER BY cnvMessageDateCreated DESC");
$comments = array();
while ($row = $r->fetchrow()) {
$ccObj = Page::getByID($row['cID']);
$pID = $ccObj->getCollectionID();
//var_dump($pID.' - '.print_r($child_pages));
if (in_array($pID, $child_pages)) {
$comments[] = $row;
}
}
return $comments;
}
示例5: saveForm
public function saveForm(Page $c)
{
$controls = Control::getList($this->type);
$outputControls = array();
foreach ($controls as $cn) {
$data = $cn->getRequestValue();
$cn->publishToPage($c, $data, $controls);
$outputControls[] = $cn;
}
// set page name from controls
// now we see if there's a page name field in there
$containsPageNameControl = false;
foreach ($outputControls as $cn) {
if ($cn instanceof NameCorePageProperty) {
$containsPageNameControl = true;
break;
}
}
if (!$containsPageNameControl) {
foreach ($outputControls as $cn) {
if ($cn->canPageTypeComposerControlSetPageName()) {
$pageName = $cn->getPageTypeComposerControlPageNameValue($c);
$c->updateCollectionName($pageName);
}
}
}
// remove all but the most recent X drafts.
if ($c->isPageDraft()) {
$vl = new VersionList($c);
$vl->setItemsPerPage(-1);
// this will ensure that we only ever keep X versions.
$vArray = $vl->getPage();
if (count($vArray) > $this->ptDraftVersionsToSave) {
for ($i = $this->ptDraftVersionsToSave; $i < count($vArray); ++$i) {
$v = $vArray[$i];
@$v->delete();
}
}
}
$c = Page::getByID($c->getCollectionID(), 'RECENT');
$controls = array();
foreach ($outputControls as $oc) {
$oc->setPageObject($c);
$controls[] = $oc;
}
$ev = new Event($c);
$ev->setPageType($this->type);
$ev->setArgument('controls', $controls);
\Events::dispatch('on_page_type_save_composer_form', $ev);
return $controls;
}
示例6: execute
public function execute(ActionInterface $action)
{
$target = $action->getTarget();
$subject = $action->getSubject();
\Cache::disableAll();
$c = Page::getByID($subject['cID']);
$db = \Database::connection();
if (is_object($c) && !$c->isError()) {
$blocks = $c->getBlocks();
$nvc = $c->getVersionToModify();
$isApproved = $c->getVersionObject()->isApproved();
foreach ($blocks as $b) {
$controller = $b->getController();
$pageColumns = $controller->getBlockTypeExportPageColumns();
if (count($pageColumns)) {
$columns = $db->MetaColumnNames($controller->getBlockTypeDatabaseTable());
$data = array();
$record = $controller->getBlockControllerData();
foreach ($columns as $key) {
$data[$key] = $record->{$key};
}
foreach ($pageColumns as $column) {
$cID = $data[$column];
if ($cID > 0) {
$link = Page::getByID($cID, 'ACTIVE');
$section = $target->getSection();
if (is_object($section)) {
$relatedID = $section->getTranslatedPageID($link);
if ($relatedID) {
$data[$column] = $relatedID;
}
}
}
}
unset($data['bID']);
$ob = $b;
// replace the block with the version of the block in the later version (if applicable)
$b2 = \Block::getByID($b->getBlockID(), $nvc, $b->getAreaHandle());
if ($b2->isAlias()) {
$nb = $ob->duplicate($nvc);
$b2->deleteBlock();
$b2 = clone $nb;
}
$b2->update($data);
}
}
if ($isApproved) {
$nvc->getVersionObject()->approve();
}
}
}
示例7: swapContent
/**
* Removes any existing pages, files, stacks, block and page types and installs content from the package.
*
* @param $options
*/
public function swapContent(Package $package, $options)
{
if ($this->validateClearSiteContents($options)) {
\Core::make('cache/request')->disable();
$pl = new PageList();
$pages = $pl->getResults();
foreach ($pages as $c) {
$c->delete();
}
$fl = new FileList();
$files = $fl->getResults();
foreach ($files as $f) {
$f->delete();
}
// clear stacks
$sl = new StackList();
foreach ($sl->get() as $c) {
$c->delete();
}
$home = \Page::getByID(HOME_CID);
$blocks = $home->getBlocks();
foreach ($blocks as $b) {
$b->deleteBlock();
}
$pageTypes = Type::getList();
foreach ($pageTypes as $ct) {
$ct->delete();
}
// Set the page type of the home page to 0, because
// if it has a type the type will be gone since we just
// deleted it
$home = Page::getByID(HOME_CID);
$home->setPageType(null);
// now we add in any files that this package has
if (is_dir($package->getPackagePath() . '/content_files')) {
$ch = new ContentImporter();
$computeThumbnails = true;
if ($package->contentProvidesFileThumbnails()) {
$computeThumbnails = false;
}
$ch->importFiles($package->getPackagePath() . '/content_files', $computeThumbnails);
}
// now we parse the content.xml if it exists.
$ci = new ContentImporter();
$ci->importContentFile($package->getPackagePath() . '/content.xml');
\Core::make('cache/request')->enable();
}
}
示例8: get
public function get($itemsToGet = 0, $offset = 0)
{
$_pages = DatabaseItemList::get($itemsToGet, $offset);
$pages = array();
foreach ($_pages as $row) {
$c = ConcretePage::getByID($row['cID']);
$cp = new Permissions($c);
if ($cp->canViewPageVersions()) {
$c->loadVersionObject('RECENT');
} else {
$c->loadVersionObject('ACTIVE');
}
$wp = PageWorkflowProgress::getByID($row['wpID']);
$pages[] = new Page($c, $wp);
}
return $pages;
}
示例9: importPageAreas
public function importPageAreas(Page $page, \SimpleXMLElement $px)
{
foreach ($px->area as $ax) {
if (isset($ax->blocks)) {
foreach ($ax->blocks->block as $bx) {
if ($bx['type'] != '') {
// we check this because you might just get a block node with only an mc-block-id, if it's an alias
$bt = BlockType::getByHandle((string) $bx['type']);
if (!is_object($bt)) {
throw new \Exception(t('Invalid block type handle: %s', strval($bx['type'])));
}
$btc = $bt->getController();
$btc->import($page, (string) $ax['name'], $bx);
} else {
if ($bx['mc-block-id'] != '') {
// we find that block in the master collection block pool and alias it out
$bID = array_search((string) $bx['mc-block-id'], ContentImporter::getMasterCollectionTemporaryBlockIDs());
if ($bID) {
$mc = Page::getByID($page->getMasterCollectionID(), 'RECENT');
$block = Block::getByID($bID, $mc, (string) $ax['name']);
$block->alias($page);
if ($block->getBlockTypeHandle() == BLOCK_HANDLE_LAYOUT_PROXY) {
// we have to go get the blocks on that page in this layout.
$btc = $block->getController();
$arLayout = $btc->getAreaLayoutObject();
$columns = $arLayout->getAreaLayoutColumns();
foreach ($columns as $column) {
$area = $column->getAreaObject();
$blocks = $area->getAreaBlocksArray($mc);
foreach ($blocks as $_b) {
$_b->alias($page);
}
}
}
}
}
}
}
}
if (isset($ax->style)) {
$area = \Area::get($page, (string) $ax['name']);
$set = StyleSet::import($ax->style);
$page->setCustomStyleSet($area, $set);
}
}
}
示例10: execute
public function execute(ActionInterface $action)
{
$target = $action->getTarget();
$subject = $action->getSubject();
\Cache::disableAll();
$c = Page::getByID($subject['cID']);
if (is_object($c) && !$c->isError()) {
$blocks = $c->getBlocks();
$nvc = $c->getVersionToModify();
$isApproved = $c->getVersionObject()->isApproved();
foreach ($blocks as $b) {
if ($b->getBlockTypeHandle() == 'content') {
$content = $b->getController()->content;
$content = preg_replace_callback('/{CCM:CID_([0-9]+)}/i', function ($matches) use($subject, $target) {
$cID = $matches[1];
if ($cID > 0) {
$link = Page::getByID($cID, 'ACTIVE');
$section = $target->getSection();
if (is_object($section)) {
$relatedID = $section->getTranslatedPageID($link);
if ($relatedID) {
return sprintf('{CCM:CID_%s}', $relatedID);
}
}
}
}, $content);
$ob = $b;
// replace the block with the version of the block in the later version (if applicable)
$b2 = \Block::getByID($b->getBlockID(), $nvc, $b->getAreaHandle());
if ($b2->isAlias()) {
$nb = $ob->duplicate($nvc);
$b2->deleteBlock();
$b2 = clone $nb;
}
$data = array('content' => $content);
$b2->update($data);
}
}
if ($isApproved) {
$nvc->getVersionObject()->approve();
}
}
}
示例11: getJSONObject
public function getJSONObject()
{
$o = parent::getBaseJSONObject();
if ($this->cID > 0) {
$o->cID = $this->cID;
} else {
if (count($this->cIDs) > 0) {
foreach ($this->cIDs as $cID) {
$o->cID[] = $cID;
}
}
}
if (!is_array($o->cID)) {
$o->pages[] = Page::getByID($o->cID)->getJSONObject();
} else {
foreach ($o->cID as $cID) {
$o->pages[] = Page::getByID($cID)->getJSONObject();
}
}
return $o;
}
示例12: installLocales
protected function installLocales()
{
$this->output(t('Updating locales and multilingual sections...'));
// Update home page so it has no handle. This way we won't make links like /home/services unless
// people really want that.
$home = Page::getByID(HOME_CID, 'RECENT');
$home->update(['cHandle' => '']);
// Loop through all multilingual sections
$r = $this->connection->executeQuery('select * from MultilingualSections');
$sections = array();
while ($row = $r->fetch()) {
$sections[] = $row;
}
$em = $this->connection->getEntityManager();
$service = new \Concrete\Core\Localization\Locale\Service($em);
$site = \Core::make('site')->getSite();
$redirectToDefaultLocale = \Config::get('concrete.multilingual.redirect_home_to_default_locale');
$defaultLocale = \Config::get('concrete.multilingual.default_locale');
$sectionsIncludeHome = false;
foreach ($sections as $section) {
if ($section['cID'] == 1) {
$sectionsIncludeHome = true;
}
}
// Now we have a valid locale object.
// Case 1: Home Page redirects to default locale, default locale inside the home page. 99% of sites.
if (!$sectionsIncludeHome && $redirectToDefaultLocale) {
// Move the home page outside site trees.
$this->output(t('Moving home page to outside of site trees...'));
$this->connection->executeQuery('update Pages set siteTreeID = 0 where cID = 1');
}
foreach ($sections as $section) {
$sectionPage = \Page::getByID($section['cID']);
$this->output(t('Migrating multilingual section: %s...', $sectionPage->getCollectionName()));
// Create a locale for this section
if ($site->getDefaultLocale()->getLocale() != $section['msLanguage'] . '_' . $section['msCountry']) {
// We don't create the locale if it's the default, because we've already created it.
$locale = $service->add($site, $section['msLanguage'], $section['msCountry']);
} else {
$locale = $em->getRepository('Concrete\\Core\\Entity\\Site\\Locale')->findOneBy(['msLanguage' => $section['msLanguage'], 'msCountry' => $section['msCountry']]);
}
// Now that we have the locale, let's take the multilingual section and make it the
// home page for the newly created site tree
if ($section['cID'] != 1) {
$tree = $locale->getSiteTree();
if (!$redirectToDefaultLocale && $locale->getLocale() == $site->getDefaultLocale()->getLocale()) {
// Case 2: This is our default locale (/en perhaps) but it is contained within a home
// page that we do not redirect from. So we want to actually make the HOME page
// the multilingual section – which is already is automatically.
// We actually do nothing in this case since this is all already set up automatically earlier.
} else {
$this->output(t('Setting pages for section %s to site tree %s...', $sectionPage->getCollectionName(), $tree->getSiteTreeID()));
$tree->setSiteHomePageID($section['cID']);
$em->persist($tree);
$em->flush();
$this->connection->executeQuery('update Pages set cParentID = 0, siteTreeID = ? where cID = ?', [$tree->getSiteTreeID(), $section['cID']]);
// Now we set all pages in this site tree to the new site tree ID.
$children = $sectionPage->getCollectionChildrenArray();
foreach ($children as $cID) {
$this->connection->executeQuery('update Pages set siteTreeID = ? where cID = ?', [$tree->getSiteTreeID(), $cID]);
}
}
}
}
// Case 3 - Home page is the default locale.
// We don't have to do anything to fulfill this since it's already been taken care of by the previous migrations.
}
示例13: decrementParents
/**
* For a particular page ID, grabs all the pages of this page, and decrements the cTotalChildren number for them.
*/
public static function decrementParents($cID)
{
$db = Loader::db();
$cParentID = $db->GetOne("select cParentID from Pages where cID = ?", array($cID));
$cChildren = $db->GetOne("select cChildren from Pages where cID = ?", array($cParentID));
--$cChildren;
if ($cChildren < 0) {
$cChildren = 0;
}
$q = "update Pages set cChildren = ? where cID = ?";
$cpc = Page::getByID($cParentID);
$cpc->refreshCache();
$r = $db->query($q, array($cChildren, $cParentID));
}
示例14: collectionNotFound
private function collectionNotFound(Collection $collection, Request $request, array $headers)
{
// if we don't have a path and we're doing cID, then this automatically fires a 404.
if (!$request->getPath() && $request->get('cID')) {
return $this->notFound('', Response::HTTP_NOT_FOUND, $headers);
}
// let's test to see if this is, in fact, the home page,
// and we're routing arguments onto it (which is screwing up the path.)
$home = Page::getByID(HOME_CID);
$request->setCurrentPage($home);
$homeController = $home->getPageController();
$homeController->setupRequestActionAndParameters($request);
$response = $homeController->validateRequest();
if ($response instanceof \Symfony\Component\HttpFoundation\Response) {
return $response;
} elseif ($response === true) {
return $this->controller($homeController);
} else {
return $this->notFound('', Response::HTTP_NOT_FOUND, $headers);
}
}
示例15: addLocalizedStack
/**
* @param Section $section
*
* @return self
*/
public function addLocalizedStack(Section $section)
{
$neutralStack = $this->getNeutralStack();
if ($neutralStack === null) {
$neutralStack = $this;
}
$name = $neutralStack->getCollectionName();
$neutralStackPage = Page::getByID($neutralStack->getCollectionID());
$localizedStackPage = $neutralStackPage->duplicate($neutralStackPage);
$localizedStackPage->update(['cName' => $name]);
$siteTreeID = $neutralStack->getSiteTreeID();
// we have to do this because we need the area to exist before we try and add something to it.
Area::getOrCreate($localizedStackPage, STACKS_AREA_NAME);
$localizedStackCID = $localizedStackPage->getCollectionID();
$db = Database::connection();
$db->executeQuery('
insert into Stacks (stName, cID, stType, stMultilingualSection, siteTreeID) values (?, ?, ?, ?, ?)', [$name, $localizedStackCID, $this->getStackType(), $section->getCollectionID(), $siteTreeID]);
$localizedStack = static::getByID($localizedStackCID);
return $localizedStack;
}