code
stringlengths 31
1.39M
| docstring
stringlengths 23
16.8k
| func_name
stringlengths 1
126
| language
stringclasses 1
value | repo
stringlengths 7
63
| path
stringlengths 7
166
| url
stringlengths 50
220
| license
stringclasses 7
values |
---|---|---|---|---|---|---|---|
public function updateGroupsSubCollection($cParentIDString)
{
// now we iterate through
$db = Database::connection();
$this->getPermissionsCollectionID();
$q = "select cID from Pages where cParentID in ({$cParentIDString}) and cInheritPermissionsFrom = 'PARENT'";
$r = $db->query($q);
$cList = [];
while ($row = $r->fetch()) {
$cList[] = $row['cID'];
}
if (count($cList) > 0) {
$cParentIDString = implode(',', $cList);
$q2 = "update Pages set cInheritPermissionsFromCID = {$this->cID} where cID in ({$cParentIDString})";
$db->query($q2);
$this->updateGroupsSubCollection($cParentIDString);
}
}
|
@deprecated is this function still useful? There's no reference to it in the core
@param int|string $cParentIDString
|
updateGroupsSubCollection
|
php
|
concretecms/concretecms
|
concrete/src/Page/Page.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
|
MIT
|
public function addBlock($bt, $a, $data)
{
if (is_string($a) && $a !== '') {
$a = Area::getOrCreate($this, $a);
}
$b = parent::addBlock($bt, $a, $data);
$btHandle = $bt->getBlockTypeHandle();
if ($b->getBlockTypeHandle() == BLOCK_HANDLE_PAGE_TYPE_OUTPUT_PROXY) {
$bi = $b->getInstance();
$output = $bi->getComposerOutputControlObject();
$control = FormLayoutSetControl::getByID($output->getPageTypeComposerFormLayoutSetControlID());
$object = $control->getPageTypeComposerControlObject();
if ($object instanceof BlockControl) {
$_bt = $object->getBlockTypeObject();
$btHandle = $_bt->getBlockTypeHandle();
}
}
$theme = $this->getCollectionThemeObject();
if ($btHandle && $theme) {
$pageTypeTemplates = [];
$areaTemplates = is_object($a) ? $a->getAreaCustomTemplates() : [];
$themeTemplates = $theme->getThemeDefaultBlockTemplates();
if (!is_array($themeTemplates)) {
$themeTemplates = [];
} else {
foreach ($themeTemplates as $key => $template) {
$pt = ($this->getPageTemplateHandle()) ? $this->getPageTemplateHandle() : 'default';
if (is_array($template) && $key == $pt) {
$pageTypeTemplates = $template;
unset($themeTemplates[$key]);
}
}
}
$templates = array_merge($pageTypeTemplates, $themeTemplates, $areaTemplates);
if (count($templates) && isset($templates[$btHandle])) {
$template = $templates[$btHandle];
$b->updateBlockInformation(['bFilename' => $template]);
}
}
return $b;
}
|
Add a new block to a specific area of the page.
@param \Concrete\Core\Entity\Block\BlockType\BlockType $bt the type of block to be added
@param \Concrete\Core\Area\Area|string $a the area instance (or its handle) to which the block should be added to
@param array $data The data of the block. This data depends on the specific block type
@return \Concrete\Core\Block\Block
|
addBlock
|
php
|
concretecms/concretecms
|
concrete/src/Page/Page.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
|
MIT
|
public function getPageRelations()
{
$em = \Database::connection()->getEntityManager();
$r = $em->getRepository('Concrete\Core\Entity\Page\Relation\SiblingRelation');
$relation = $r->findOneBy(['cID' => $this->getCollectionID()]);
$relations = [];
if (is_object($relation)) {
$allRelations = $r->findBy(['mpRelationID' => $relation->getPageRelationID()]);
foreach ($allRelations as $relation) {
if ($relation->getPageID() != $this->getCollectionID() && $relation->getPageObject()->getSiteTreeObject() instanceof SiteTree) {
$relations[] = $relation;
}
}
}
return $relations;
}
|
Get the relations of this page.
@return \Concrete\Core\Entity\Page\Relation\SiblingRelation[]
|
getPageRelations
|
php
|
concretecms/concretecms
|
concrete/src/Page/Page.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
|
MIT
|
public function move($nc)
{
$db = Database::connection();
$newCParentID = $nc->getCollectionID();
$dh = Core::make('helper/date');
$cID = ($this->getCollectionPointerOriginalID() > 0) ? $this->getCollectionPointerOriginalID() : $this->cID;
PageStatistics::decrementParents($cID);
$cDateModified = $dh->getOverridableNow();
// if ($this->getPermissionsCollectionID() != $this->getCollectionID() && $this->getPermissionsCollectionID() != $this->getMasterCollectionID()) {
if ($this->getPermissionsCollectionID() != $cID) {
// implicitly, we're set to inherit the permissions of wherever we are in the site.
// as such, we'll change to inherit whatever permissions our new parent has
$npID = $nc->getPermissionsCollectionID();
if ($npID != $this->getPermissionsCollectionID()) {
//we have to update the existing collection with the info for the new
//as well as all collections beneath it that are set to inherit from this parent
// first we do this one
$q = 'update Pages set cInheritPermissionsFromCID = ? where cID = ?';
$r = $db->executeQuery($q, [(int) $npID, $cID]);
$this->updatePermissionsCollectionID($cID, $npID);
}
}
$oldParent = self::getByID($this->getCollectionParentID(), 'RECENT');
$db->executeQuery('update Collections set cDateModified = ? where cID = ?', [$cDateModified, $cID]);
$v = [$newCParentID, $cID];
$q = 'update Pages set cParentID = ? where cID = ?';
$r = $db->prepare($q);
$r->execute($v);
PageStatistics::incrementParents($cID);
if (!$this->isActive()) {
$this->activate();
// if we're moving from the trash, we have to activate recursively
if ($this->isInTrash()) {
$childPages = $this->populateRecursivePages([], ['cID' => $cID], $this->getCollectionParentID(), 0, false);
foreach ($childPages as $page) {
$db->executeQuery('update Pages set cIsActive = 1 where cID = ?', [$page['cID']]);
}
}
}
if ($nc->getSiteTreeID() != $this->getSiteTreeID()) {
$db->executeQuery('update Pages set siteTreeID = ? where cID = ?', [$nc->getSiteTreeID(), $cID]);
if (!isset($childPages)) {
$childPages = $this->populateRecursivePages([], ['cID' => $cID], $this->getCollectionParentID(), 0, false);
}
foreach ($childPages as $page) {
$db->executeQuery('update Pages set siteTreeID = ? where cID = ?', [$nc->getSiteTreeID(), $page['cID']]);
}
}
$this->siteTreeID = $nc->getSiteTreeID();
$this->siteTree = null; // in case we need to get the updated one
$this->cParentID = $newCParentID;
$this->movePageDisplayOrderToBottom();
// run any event we have for page move. Arguments are
// 1. current page being moved
// 2. former parent
// 3. new parent
$newParent = self::getByID($newCParentID, 'RECENT');
$pe = new MovePageEvent($this);
$pe->setOldParentPageObject($oldParent);
$pe->setNewParentPageObject($newParent);
Events::dispatch('on_page_move', $pe);
$multilingual = \Core::make('multilingual/detector');
if ($multilingual->isEnabled()) {
Section::registerMove($this, $oldParent, $newParent);
}
// now that we've moved the collection, we rescan its path
$this->rescanCollectionPath();
}
|
Move this page under a new parent page.
@param \Concrete\Core\Page\Page $newParentPage
@param mixed $nc
|
move
|
php
|
concretecms/concretecms
|
concrete/src/Page/Page.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
|
MIT
|
public function duplicateAll($nc = null, $preserveUserID = false, ?Site $site = null)
{
$nc2 = $this->duplicate($nc, $preserveUserID, $site);
self::_duplicateAll($this, $nc2, $preserveUserID, $site);
return $nc2;
}
|
Duplicate this page and all its child pages and return the new Page created.
@param \Concrete\Core\Page\Page|null $toParentPage The page under which this page should be copied to
@param bool $preserveUserID Set to true to preserve the original page author IDs
@param \Concrete\Core\Entity\Site\Site|null $site the destination site (used if $toParentPage is NULL)
@param null|mixed $nc
@return \Concrete\Core\Page\Page
|
duplicateAll
|
php
|
concretecms/concretecms
|
concrete/src/Page/Page.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
|
MIT
|
public function duplicate($nc = null, $preserveUserID = false, ?TreeInterface $site = null)
{
$app = Application::getFacadeApplication();
$cloner = $app->make(Cloner::class);
$clonerOptions = $app->build(ClonerOptions::class)
->setKeepOriginalAuthor($preserveUserID)
;
return $cloner->clonePage($this, $clonerOptions, $nc ? $nc : null, $site);
}
|
Duplicate this page and return the new Page created.
@param \Concrete\Core\Page\Page|null $toParentPage The page under which this page should be copied to
@param bool $preserveUserID Set to true to preserve the original page author IDs
@param \Concrete\Core\Site\Tree\TreeInterface|null $site the destination site (used if $toParentPage is NULL)
@param null|mixed $nc
@return \Concrete\Core\Page\Page
|
duplicate
|
php
|
concretecms/concretecms
|
concrete/src/Page/Page.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
|
MIT
|
public function delete()
{
$cID = $this->getCollectionID();
if ($this->isAliasPage() && !$this->isExternalLink()) {
$this->removeThisAlias();
return;
}
if ($cID < 1 || $cID == static::getHomePageID()) {
return false;
}
$db = Database::connection();
// run any internal event we have for page deletion
$pe = new DeletePageEvent($this);
Events::dispatch('on_page_delete', $pe);
if (!$pe->proceed()) {
return false;
}
$app = Facade::getFacadeApplication();
$logger = $app->make('log/factory')->createLogger(Channels::CHANNEL_SITE_ORGANIZATION);
$logger->notice(t('Page "%s" at path "%s" deleted',
$this->getCollectionName(),
$this->getCollectionPath()
));
parent::delete();
$cID = $this->getCollectionID();
// Now that all versions are gone, we can delete the collection information
$q = "delete from PagePaths where cID = '{$cID}'";
$r = $db->query($q);
// remove all pages where the pointer is this cID
$r = $db->executeQuery('select cID from Pages where cPointerID = ?', [$cID]);
while ($row = $r->fetch()) {
PageStatistics::decrementParents($row['cID']);
$db->executeQuery('DELETE FROM PagePaths WHERE cID=?', [$row['cID']]);
}
// Update cChildren for cParentID
PageStatistics::decrementParents($cID);
$db->executeQuery('delete from PagePermissionAssignments where cID = ?', [$cID]);
$db->executeQuery('delete from Pages where cID = ?', [$cID]);
$db->executeQuery('delete from MultilingualPageRelations where cID = ?', [$cID]);
$db->executeQuery('delete from SiblingPageRelations where cID = ?', [$cID]);
$db->executeQuery('delete from Pages where cPointerID = ?', [$cID]);
$db->executeQuery('delete from Areas WHERE cID = ?', [$cID]);
$db->executeQuery('delete from PageSearchIndex where cID = ?', [$cID]);
$r = $db->executeQuery('select cID from Pages where cParentID = ?', [$cID]);
if ($r) {
while ($row = $r->fetch()) {
if ($row['cID'] > 0) {
$nc = self::getByID($row['cID']);
$nc->delete();
}
}
}
if (\Core::make('multilingual/detector')->isEnabled()) {
Section::unregisterPage($this);
}
$indexer = $app->make(IndexManagerInterface::class);
$indexer->forget(Page::class, $this->getCollectionID());
$cache = PageCache::getLibrary();
$cache->purge($this);
}
|
Delete this page and all its child pages.
@return null|false return false if it's not possible to delete this page (for instance because it's the main homepage)
|
delete
|
php
|
concretecms/concretecms
|
concrete/src/Page/Page.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
|
MIT
|
public function moveToTrash()
{
// run any internal event we have for page trashing
$pe = new Event($this);
Events::dispatch('on_page_move_to_trash', $pe);
$trash = self::getByPath(Config::get('concrete.paths.trash'));
$app = Facade::getFacadeApplication();
$logger = $app->make('log/factory')->createLogger(Channels::CHANNEL_SITE_ORGANIZATION);
$logger->notice(t('Page "%s" at path "%s" Moved to trash',
$this->getCollectionName(),
$this->getCollectionPath()
));
$this->move($trash);
$this->deactivate();
$indexer = $app->make(IndexManagerInterface::class);
$indexer->forget(Page::class, $this->getCollectionID());
// if this page has a custom canonical path we need to clear it
$path = $this->getCollectionPathObject();
if (!$path->isPagePathAutoGenerated()) {
$path = $this->getAutoGeneratedPagePathObject();
$this->setCanonicalPagePath($path->getPagePath(), true);
$this->rescanCollectionPath();
}
$cID = ($this->getCollectionPointerOriginalID() > 0) ? $this->getCollectionPointerOriginalID() : $this->cID;
$pages = [];
$pages = $this->populateRecursivePages($pages, ['cID' => $cID], $this->getCollectionParentID(), 0, false);
$db = Database::connection();
foreach ($pages as $page) {
$db->executeQuery('update Pages set cIsActive = 0 where cID = ?', [$page['cID']]);
$indexer->forget(Page::class, $page['cID']);
}
}
|
Move this page and all its child pages to the trash.
|
moveToTrash
|
php
|
concretecms/concretecms
|
concrete/src/Page/Page.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
|
MIT
|
public function rescanChildrenDisplayOrder()
{
$db = Database::connection();
// this should be re-run every time a new page is added, but i don't think it is yet - AE
//$oneLevelOnly=1;
//$children_array = $this->getCollectionChildrenArray( $oneLevelOnly );
$q = 'SELECT cID FROM Pages WHERE cParentID = ? ORDER BY cDisplayOrder';
$children_array = $db->getCol($q, [$this->getCollectionID()]);
$current_count = 0;
foreach ($children_array as $newcID) {
$q = 'update Pages set cDisplayOrder = ? where cID = ?';
$db->executeQuery($q, [$current_count, $newcID]);
++$current_count;
}
}
|
Regenerate the display order of the child pages.
|
rescanChildrenDisplayOrder
|
php
|
concretecms/concretecms
|
concrete/src/Page/Page.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
|
MIT
|
public function isHomePage()
{
return $this->getSiteHomePageID() == $this->getCollectionID();
}
|
Is this the homepage for the site tree this page belongs to?
@return bool
|
isHomePage
|
php
|
concretecms/concretecms
|
concrete/src/Page/Page.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
|
MIT
|
public function getSiteHomePageID()
{
return static::getHomePageID($this);
}
|
Get the ID of the homepage for the site tree this page belongs to.
@return int|null Returns NULL if there's no default locale
|
getSiteHomePageID
|
php
|
concretecms/concretecms
|
concrete/src/Page/Page.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
|
MIT
|
public function isLocaleHomePage()
{
return $this->getCollectionID() > 0 && $this->getSiteHomePageID() == $this->getCollectionID();
}
|
@deprecated use the isHomePage() method
@return bool
|
isLocaleHomePage
|
php
|
concretecms/concretecms
|
concrete/src/Page/Page.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
|
MIT
|
public static function getHomePageID($page = null)
{
if ($page) {
if (!$page instanceof self) {
$page = self::getByID($page);
}
if ($page instanceof self) {
$siteTree = $page->getSiteTreeObject();
if ($siteTree !== null) {
return $siteTree->getSiteHomePageID();
}
}
}
$locale = Application::getFacadeApplication()->make(LocaleService::class)->getDefaultLocale();
if ($locale !== null) {
$siteTree = $locale->getSiteTreeObject();
if ($siteTree != null) {
return $siteTree->getSiteHomePageID();
}
}
$entityManager = Application::getFacadeApplication()->make(EntityManagerInterface::class);
try {
$site = $entityManager->getRepository('Concrete\Core\Entity\Site\Site')
->findOneBy(['siteIsDefault' => true]);
if ($site !== null) {
return $site->getSiteHomePageID();
}
} catch (\Exception $e) {
return null;
}
return null;
}
|
Get the ID of the home page.
@param Page|int $page the page (or its ID) for which you want the home (if not specified, we'll use the default locale site tree)
@return int|null returns NULL if $page is null (or it doesn't have a SiteTree associated) and if there's no default locale
|
getHomePageID
|
php
|
concretecms/concretecms
|
concrete/src/Page/Page.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
|
MIT
|
public function getAutoGeneratedPagePathObject()
{
$path = new PagePath();
$path->setPagePathIsAutoGenerated(true);
//if (!$this->isHomePage()) {
$path->setPagePath($this->computeCanonicalPagePath());
//}
return $path;
}
|
Get a new PagePath object with the computed canonical page path.
@return \Concrete\Core\Entity\Page\PagePath
|
getAutoGeneratedPagePathObject
|
php
|
concretecms/concretecms
|
concrete/src/Page/Page.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
|
MIT
|
public function getNextSubPageDisplayOrder()
{
$db = Database::connection();
$max = $db->fetchColumn('select max(cDisplayOrder) from Pages where cParentID = ?', [$this->getCollectionID()]);
return is_numeric($max) ? ($max + 1) : 0;
}
|
Get the next available display order of child pages.
@return int
|
getNextSubPageDisplayOrder
|
php
|
concretecms/concretecms
|
concrete/src/Page/Page.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
|
MIT
|
public function generatePagePath()
{
$newPath = '';
//if ($this->cParentID > 0) {
/**
* @var Connection
*/
$db = \Database::connection();
/* @var $em \Doctrine\ORM\EntityManager */
$pathObject = $this->getCollectionPathObject();
if (is_object($pathObject) && !$pathObject->isPagePathAutoGenerated()) {
$pathString = $pathObject->getPagePath();
} else {
$pathString = $this->computeCanonicalPagePath();
}
if (!$pathString) {
return ''; // We are allowed to pass in a blank path in the event of the home page being scanned.
}
// ensure that the path is unique
$suffix = 0;
$cID = ($this->getCollectionPointerOriginalID() > 0) ? $this->getCollectionPointerOriginalID() : $this->cID;
$pagePathSeparator = Config::get('concrete.seo.page_path_separator');
while (true) {
$newPath = ($suffix === 0) ? $pathString : $pathString . $pagePathSeparator . $suffix;
$result = $db->fetchColumn('select p.cID from PagePaths pp inner join Pages p on pp.cID = p.cID where pp.cPath = ? and pp.cID <> ? and p.siteTreeID = ?',
[
$newPath,
$cID,
$this->getSiteTreeID(),
]
);
if (empty($result)) {
break;
}
++$suffix;
}
//}
return $newPath;
}
|
Get the URL-slug-based path to the current page (including any suffixes) in a string format. Does so in real time.
@return string
|
generatePagePath
|
php
|
concretecms/concretecms
|
concrete/src/Page/Page.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
|
MIT
|
public function rescanCollectionPath()
{
//if ($this->cParentID > 0) {
$newPath = $this->generatePagePath();
$pathObject = $this->getCollectionPathObject();
$ppIsAutoGenerated = true;
if (is_object($pathObject) && !$pathObject->isPagePathAutoGenerated()) {
$ppIsAutoGenerated = false;
}
$this->setCanonicalPagePath($newPath, $ppIsAutoGenerated);
$this->rescanSystemPageStatus();
$this->cPath = $newPath;
$this->refreshCache();
$children = $this->getCollectionChildren();
if (count($children) > 0) {
$myCollectionID = $this->getCollectionID();
foreach ($children as $child) {
// Let's avoid recursion caused by potentially malformed data
if ($child->getCollectionID() !== $myCollectionID) {
$child->rescanCollectionPath();
}
}
}
//}
}
|
Recalculate the canonical page path for the current page and its sub-pages, based on its current version, URL slug, etc.
|
rescanCollectionPath
|
php
|
concretecms/concretecms
|
concrete/src/Page/Page.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
|
MIT
|
public function updateDisplayOrder($displayOrder, $cID = 0)
{
$displayOrder = (int) $displayOrder;
//this line was added to allow changing the display order of aliases
if (!(int) $cID) {
$cID = ($this->getCollectionPointerOriginalID() > 0) ? $this->getCollectionPointerOriginalID() : $this->cID;
}
$app = Application::getFacadeApplication();
$db = $app->make(Connection::class);
$oldDisplayOrder = $db->fetchColumn('SELECT cDisplayOrder FROM Pages WHERE cID = ?', [$cID]);
// Exit out if the display order for this page doesn't change.
if ($oldDisplayOrder === null || $displayOrder === (int) $oldDisplayOrder) {
return;
}
// Store the new display order.
$db->executeQuery('update Pages set cDisplayOrder = ? where cID = ?', [$displayOrder, $cID]);
// Because the display order of another page can be changed,
// the page object is retrieved first in order to pass it to the event.
$page = $this;
if ($cID && (int) $cID !== (int) $this->getCollectionID()) {
$page = static::getByID($cID);
}
if ($page->isError()) {
return;
}
// Fire an event that the page display order has changed.
$event = new DisplayOrderUpdateEvent($page);
$event->setOldDisplayOrder($oldDisplayOrder);
$event->setNewDisplayOrder($displayOrder);
Events::dispatch('on_page_display_order_update', $event);
}
|
Set a new display order for this page (or for another page given its ID).
@param int $displayOrder
@param int|null $cID The page ID to set the display order for (if empty, we'll use this page)
|
updateDisplayOrder
|
php
|
concretecms/concretecms
|
concrete/src/Page/Page.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
|
MIT
|
public function movePageDisplayOrderToTop()
{
// first, we take the current collection, stick it at the beginning of an array, then get all other items from the current level that aren't that cID, order by display order, and then update
$db = Database::connection();
$nodes = [];
$nodes[] = $this->getCollectionID();
$r = $db->GetCol('select cID from Pages where cParentID = ? and cID <> ? order by cDisplayOrder asc', [$this->getCollectionParentID(), $this->getCollectionID()]);
$nodes = array_merge($nodes, $r);
$displayOrder = 0;
foreach ($nodes as $do) {
$co = self::getByID($do);
$co->updateDisplayOrder($displayOrder);
++$displayOrder;
}
}
|
Make this page the first child of its parent.
|
movePageDisplayOrderToTop
|
php
|
concretecms/concretecms
|
concrete/src/Page/Page.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
|
MIT
|
public function movePageDisplayOrderToBottom()
{
// find the highest cDisplayOrder and increment by 1
$db = Database::connection();
$mx = $db->fetchAssoc('select max(cDisplayOrder) as m from Pages where cParentID = ?', [$this->getCollectionParentID()]);
$max = $mx ? $mx['m'] : 0;
++$max;
$this->updateDisplayOrder($max);
}
|
Make this page the first child of its parent.
|
movePageDisplayOrderToBottom
|
php
|
concretecms/concretecms
|
concrete/src/Page/Page.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
|
MIT
|
public function movePageDisplayOrderToSibling(Page $c, $position = 'before')
{
$myCID = $this->getCollectionPointerOriginalID() ?: $this->getCollectionID();
$relatedCID = $c->getCollectionPointerOriginalID() ?: $c->getCollectionID();
$pageIDs = [];
$db = Database::connection();
$r = $db->executeQuery('select cID from Pages where cParentID = ? and cID <> ? order by cDisplayOrder asc', [$this->getCollectionParentID(), $myCID]);
while (($cID = $r->fetchColumn()) !== false) {
if ($cID == $relatedCID && $position == 'before') {
$pageIDs[] = $myCID;
}
$pageIDs[] = $cID;
if ($cID == $relatedCID && $position == 'after') {
$pageIDs[] = $myCID;
}
}
$displayOrder = 0;
foreach ($pageIDs as $cID) {
$co = self::getByID($cID);
$co->updateDisplayOrder($displayOrder);
++$displayOrder;
}
}
|
Move this page before of after another page.
@param \Concrete\Core\Page\Page $referencePage The reference page
@param string $position 'before' or 'after'
@param Page $c
|
movePageDisplayOrderToSibling
|
php
|
concretecms/concretecms
|
concrete/src/Page/Page.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
|
MIT
|
public function rescanSystemPageStatus()
{
$systemPage = false;
$db = Database::connection();
$cID = $this->getCollectionID();
if (!$this->isHomePage()) {
if ($this->getSiteTreeID() == 0) {
$systemPage = true;
} else {
$cID = ($this->getCollectionPointerOriginalID() > 0) ? $this->getCollectionPointerOriginalID() : $this->getCollectionID();
$db = Database::connection();
$path = $db->fetchColumn('select cPath from PagePaths where cID = ? and ppIsCanonical = 1', [$cID]);
if ($path) {
// Grab the top level parent
$fragments = explode('/', $path);
$topPath = '/' . $fragments[1];
$c = \Page::getByPath($topPath);
if (is_object($c) && !$c->isError()) {
if ($c->getCollectionParentID() == 0 && !$c->isHomePage()) {
$systemPage = true;
}
}
}
}
}
if ($systemPage) {
$db->executeQuery('update Pages set cIsSystemPage = 1 where cID = ?', [$cID]);
$this->cIsSystemPage = true;
} else {
$db->executeQuery('update Pages set cIsSystemPage = 0 where cID = ?', [$cID]);
$this->cIsSystemPage = false;
}
}
|
Recalculate the "is a system page" state.
Looks at the current page. If the site tree ID is 0, sets system page to true.
If the site tree is not user, looks at where the page falls in the hierarchy. If it's inside a page
at the top level that has 0 as its parent, then it is considered a system page.
|
rescanSystemPageStatus
|
php
|
concretecms/concretecms
|
concrete/src/Page/Page.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
|
MIT
|
public function isInTrash()
{
return $this->getCollectionPath() != Config::get('concrete.paths.trash') && strpos($this->getCollectionPath(), Config::get('concrete.paths.trash')) === 0;
}
|
Is this page in the trash?
@return bool
|
isInTrash
|
php
|
concretecms/concretecms
|
concrete/src/Page/Page.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
|
MIT
|
public function moveToRoot()
{
$db = Database::connection();
$db->executeQuery('update Pages set cParentID = 0 where cID = ?', [$this->getCollectionID()]);
$this->cParentID = 0;
$this->rescanSystemPageStatus();
}
|
Make this page child of nothing, thus moving it to the root level.
|
moveToRoot
|
php
|
concretecms/concretecms
|
concrete/src/Page/Page.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
|
MIT
|
public function deactivate()
{
$db = Database::connection();
$db->executeQuery('update Pages set cIsActive = 0 where cID = ?', [$this->getCollectionID()]);
}
|
Mark this page as non active.
|
deactivate
|
php
|
concretecms/concretecms
|
concrete/src/Page/Page.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
|
MIT
|
public function setPageToDraft()
{
$db = Database::connection();
$db->executeQuery('update Pages set cIsDraft = 1 where cID = ?', [$this->getCollectionID()]);
$this->cIsDraft = true;
}
|
Mark this page as non draft.
|
setPageToDraft
|
php
|
concretecms/concretecms
|
concrete/src/Page/Page.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
|
MIT
|
public function isActive()
{
if (isset($this->cIsActive)) {
return (bool) $this->cIsActive;
}
return false;
}
|
Is this page marked as active?
@return bool
|
isActive
|
php
|
concretecms/concretecms
|
concrete/src/Page/Page.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
|
MIT
|
public function setPageIndexScore($score)
{
$this->cIndexScore = $score;
}
|
Set the page index score (used by a PageList for instance).
@param float $score
|
setPageIndexScore
|
php
|
concretecms/concretecms
|
concrete/src/Page/Page.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
|
MIT
|
public function getPageIndexScore()
{
return round($this->cIndexScore??0, 2);
}
|
Get the page index score (as set by a PageList for instance).
@return float
|
getPageIndexScore
|
php
|
concretecms/concretecms
|
concrete/src/Page/Page.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
|
MIT
|
public function getPageIndexContent()
{
$db = Database::connection();
return $db->fetchColumn('select content from PageSearchIndex where cID = ?', [$this->cID]);
}
|
Get the indexed content of this page.
@return string
|
getPageIndexContent
|
php
|
concretecms/concretecms
|
concrete/src/Page/Page.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
|
MIT
|
public static function addHomePage(?TreeInterface $siteTree = null)
{
$app = Application::getFacadeApplication();
// creates the home page of the site
$db = $app->make(Connection::class);
$cParentID = 0;
$uID = HOME_UID;
$data = [
'name' => HOME_NAME,
'uID' => $uID,
];
$cobj = parent::createCollection($data);
$cID = $cobj->getCollectionID();
if (!is_object($siteTree)) {
$site = \Core::make('site')->getSite();
$siteTree = $site->getSiteTreeObject();
}
$siteTreeID = $siteTree->getSiteTreeID();
$v = [$cID, $siteTreeID, $cParentID, $uID, 'OVERRIDE', 1, (int) $cID, 0];
$q = 'insert into Pages (cID, siteTreeID, cParentID, uID, cInheritPermissionsFrom, cOverrideTemplatePermissions, cInheritPermissionsFromCID, cDisplayOrder) values (?, ?, ?, ?, ?, ?, ?, ?)';
$r = $db->prepare($q);
$r->execute($v);
if (!$siteTree->getSiteHomePageID()) {
$siteTree->setSiteHomePageID($cID);
$em = $app->make(EntityManagerInterface::class);
$em->flush($siteTree);
}
$pc = self::getByID($cID, 'RECENT');
return $pc;
}
|
Add the home page to the system. Typically used only by the installation program.
@param \Concrete\Core\Site\Tree\TreeInterface|null $siteTree
@return \Concrete\Core\Page\Page
|
addHomePage
|
php
|
concretecms/concretecms
|
concrete/src/Page/Page.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
|
MIT
|
public function add($pt, $data, $template = false)
{
$data += [
'cHandle' => null,
];
$app = Application::getFacadeApplication();
$db = Database::connection();
$txt = Core::make('helper/text');
$theme = false;
// the passed collection is the parent collection
$cParentID = $this->getCollectionID();
$u = $app->make(User::class);
if (isset($data['uID'])) {
$uID = $data['uID'];
} else {
$uID = $u->getUserID();
$data['uID'] = $uID;
}
// https://github.com/concrete5/concrete5/issues/10149
$data['uID'] = (int) $uID;
$uID = (int) $uID;
if (isset($data['pkgID'])) {
$pkgID = $data['pkgID'];
} else {
$pkgID = 0;
}
$cIsActive = 1;
if (isset($data['cIsActive']) && !$data['cIsActive']) {
$cIsActive = 0;
}
$cIsDraft = 0;
if (isset($data['cIsDraft']) && $data['cIsDraft']) {
$cIsDraft = 1;
}
if (isset($data['cName'])) {
$data['name'] = $data['cName'];
} elseif (!isset($data['name'])) {
$data['name'] = '';
}
if (!$data['cHandle']) {
// make the handle out of the title
$handle = $txt->urlify($data['name']);
} else {
$handle = $txt->slugSafeString($data['cHandle']); // we take it as it comes.
}
$handle = str_replace('-', Config::get('concrete.seo.page_path_separator'), $handle);
$data['handle'] = $handle;
$ptID = 0;
$masterCIDBlocks = null;
$masterCID = null;
if ($pt instanceof \Concrete\Core\Page\Type\Type) {
if ($pt->getPageTypeHandle() == STACKS_PAGE_TYPE) {
$data['cvIsNew'] = 0;
}
if ($pt->getPackageID() > 0) {
$pkgID = $pt->getPackageID();
}
// if we have a page type and we don't have a template,
// then we use the page type's default template
if ($pt->getPageTypeDefaultPageTemplateID() > 0 && !$template) {
$template = $pt->getPageTypeDefaultPageTemplateObject();
}
if ($pt->getPageTypeDefaultThemeID()) {
$theme = $pt->getPageTypeDefaultThemeObject();
}
$ptID = $pt->getPageTypeID();
if ($template) {
$mc1 = $pt->getPageTypePageTemplateDefaultPageObject($template);
$mc2 = $pt->getPageTypePageTemplateDefaultPageObject();
$masterCIDBlocks = $mc1->getCollectionID();
if ($mc2) {
$masterCID = $mc2->getCollectionID();
}
}
}
if ($template instanceof TemplateEntity) {
$data['pTemplateID'] = $template->getPageTemplateID();
}
$cobj = parent::addCollection($data);
$cID = $cobj->getCollectionID();
//$this->rescanChildrenDisplayOrder();
$cDisplayOrder = $this->getNextSubPageDisplayOrder();
$siteTreeID = $this->getSiteTreeID();
$cInheritPermissionsFromCID = ($this->overrideTemplatePermissions()) ? $this->getPermissionsCollectionID() : $masterCID;
$cInheritPermissionsFrom = ($this->overrideTemplatePermissions()) ? 'PARENT' : 'TEMPLATE';
$v = [$cID, $siteTreeID, $ptID, $cParentID, $uID, $cInheritPermissionsFrom, $this->overrideTemplatePermissions(), (int) $cInheritPermissionsFromCID, $cDisplayOrder, $pkgID, $cIsActive, $cIsDraft];
$q = 'insert into Pages (cID, siteTreeID, ptID, cParentID, uID, cInheritPermissionsFrom, cOverrideTemplatePermissions, cInheritPermissionsFromCID, cDisplayOrder, pkgID, cIsActive, cIsDraft) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)';
$r = $db->prepare($q);
$res = $r->execute($v);
$newCID = $cID;
if ($res) {
// Collection added with no problem -- update cChildren on parrent
PageStatistics::incrementParents($newCID);
if ($r) {
$cAcquireComposerOutputControls = false;
if (isset($data['cAcquireComposerOutputControls']) && $data['cAcquireComposerOutputControls']) {
$cAcquireComposerOutputControls = true;
}
// now that we know the insert operation was a success, we need to see if the collection type we're adding has a master collection associated with it
if ($masterCIDBlocks) {
$this->_associateMasterCollectionBlocks($newCID, $masterCIDBlocks, $cAcquireComposerOutputControls);
}
if ($masterCID) {
$this->_associateMasterCollectionAttributes($newCID, $masterCID);
}
}
$pc = self::getByID($newCID, 'RECENT');
// if we are in the drafts area of the site, then we don't check multilingual status. Otherwise
// we do
if ($this->getCollectionPath() != Config::get('concrete.paths.drafts')) {
Section::registerPage($pc);
}
if ($template) {
$pc->acquireAreaStylesFromDefaults($template);
}
// run any internal event we have for page addition
$pe = new Event($pc);
Events::dispatch('on_page_add', $pe);
$pc->rescanCollectionPath();
}
$entities = $u->getUserAccessEntityObjects();
$hasAuthor = false;
foreach ($entities as $obj) {
if ($obj instanceof PageOwnerEntity) {
$hasAuthor = true;
}
}
if (!$hasAuthor) {
$u->refreshUserGroups();
}
if ($theme) {
$pc->setTheme($theme);
}
return $pc;
}
|
Add a new page, child of this page.
@param \Concrete\Core\Page\Type\Type|null $pageType
@param array $data Supported keys: {
@var int|null $uID The ID of the page author (if unspecified or NULL: current user)
@var int|null $pkgID the ID of the package that creates this page
@var string $cName The page name
@var string $name (used if cName is not specified)
@var int|null $cID The ID of the page to create (if unspecified or NULL: database autoincrement value)
@var int|bool $cIsActive Is the page to be considered as active?
@var int|bool $cIsDraft Is the page to be considered as draft?
@var string $cHandle The page handle
@var string $cDescription The page description (default: NULL)
@var string $cDatePublic The page publish date/time in format 'YYYY-MM-DD hh:mm:ss' (default: now)
@var bool $cvIsApproved Is the page version approved (default: true)
@var bool $cvIsNew Is the page to be considered "new"? (default: true if $cvIsApproved is false, false if $cvIsApproved is true)
@var bool $cAcquireComposerOutputControls
}
@param \Concrete\Core\Entity\Page\Template|null $pageTemplate
@param mixed $pt
@param mixed $template
@return \Concrete\Core\Page\Page
|
add
|
php
|
concretecms/concretecms
|
concrete/src/Page/Page.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
|
MIT
|
public function getCustomStyleObject()
{
$db = Database::connection();
$row = $db->FetchAssoc('select * from CollectionVersionThemeCustomStyles where cID = ? and cvID = ?', [$this->getCollectionID(), $this->getVersionID()]);
if (isset($row['cID'])) {
$o = new \Concrete\Core\Page\CustomStyle();
$o->setThemeID($row['pThemeID']);
$o->setValueListID($row['scvlID']);
$o->setPresetHandle($row['preset']);
$o->setCustomCssRecordID($row['sccRecordID']);
return $o;
}
}
|
Get the custom style for the currently loaded page version (if any).
@return \Concrete\Core\Page\CustomStyle|null
|
getCustomStyleObject
|
php
|
concretecms/concretecms
|
concrete/src/Page/Page.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
|
MIT
|
public function getCollectionFullPageCaching()
{
return $this->cCacheFullPageContent;
}
|
Get the full-page cache flag (-1: use global setting; 0: no; 1: yes - NULL if page is not loaded).
@return int|null
|
getCollectionFullPageCaching
|
php
|
concretecms/concretecms
|
concrete/src/Page/Page.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
|
MIT
|
public function getCollectionFullPageCachingLifetime()
{
return $this->cCacheFullPageContentOverrideLifetime;
}
|
Get the full-page cache lifetime criteria ('default': use default lifetime; 'forever': no expiration; 'custom': custom lifetime value - see getCollectionFullPageCachingLifetimeCustomValue(); other: use the default lifetime - NULL if page is not loaded).
@return string|null
|
getCollectionFullPageCachingLifetime
|
php
|
concretecms/concretecms
|
concrete/src/Page/Page.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
|
MIT
|
public function getCollectionFullPageCachingLifetimeCustomValue()
{
return $this->cCacheFullPageContentLifetimeCustom;
}
|
Get the full-page cache custom lifetime in minutes (to be used if getCollectionFullPageCachingLifetime() is 'custom').
@return int|null returns NULL if page is not loaded
|
getCollectionFullPageCachingLifetimeCustomValue
|
php
|
concretecms/concretecms
|
concrete/src/Page/Page.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
|
MIT
|
public function getCollectionFullPageCachingLifetimeValue()
{
$app = Application::getFacadeApplication();
if ($this->cCacheFullPageContentOverrideLifetime == 'default') {
$lifetime = $app['config']->get('concrete.cache.lifetime');
} elseif ($this->cCacheFullPageContentOverrideLifetime == 'custom') {
$lifetime = $this->cCacheFullPageContentLifetimeCustom * 60;
} elseif ($this->cCacheFullPageContentOverrideLifetime == 'forever') {
$lifetime = 31536000; // 1 year
} else {
if ($app['config']->get('concrete.cache.full_page_lifetime') == 'custom') {
$lifetime = $app['config']->get('concrete.cache.full_page_lifetime_value') * 60;
} elseif ($app['config']->get('concrete.cache.full_page_lifetime') == 'forever') {
$lifetime = 31536000; // 1 year
} else {
$lifetime = $app['config']->get('concrete.cache.lifetime');
}
}
if (!$lifetime) {
// we have no value, which means forever, but we need a numerical value for page caching
$lifetime = 31536000;
}
/** @var Date $date */
$date = $app->make(Date::class);
$now = $date->getOverridableNow();
/** @var Connection $connection */
$connection = $app->make(Connection::class);
// Get upcoming publish date
$upcomingPublishDate = $connection->createQueryBuilder()
->select('cv.cvPublishDate')
->from('CollectionVersions', 'cv')
->where('cv.cID = :cID')
->andWhere('cv.cvIsApproved = :cvIsApproved')
->andWhere('cv.cvPublishDate > :now')
->orderBy('cv.cvPublishDate', 'asc')
->setParameter('cID', $this->getCollectionID())
->setParameter('cvIsApproved', true)
->setParameter('now', $now)
->execute()->fetchOne();
// Get upcoming publish end date
$upcomingPublishEndDate = $connection->createQueryBuilder()
->select('cv.cvPublishEndDate')
->from('CollectionVersions', 'cv')
->where('cv.cID = :cID')
->andWhere('cv.cvIsApproved = :cvIsApproved')
->andWhere('cv.cvPublishEndDate > :now')
->orderBy('cv.cvPublishEndDate', 'asc')
->setParameter('cID', $this->getCollectionID())
->setParameter('cvIsApproved', true)
->setParameter('now', $now)
->execute()->fetchOne();
// Get upcoming scheduled date (start or end)
$upcomingScheduledDate = false;
if ($upcomingPublishDate && $upcomingPublishEndDate) {
$upcomingPublishDateObject = new \DateTime($upcomingPublishDate);
$upcomingPublishEndDateObject = new \DateTime($upcomingPublishEndDate);
if ($upcomingPublishDateObject > $upcomingPublishEndDateObject) {
$upcomingScheduledDate = $upcomingPublishEndDate;
} else {
$upcomingScheduledDate = $upcomingPublishDate;
}
} elseif ($upcomingPublishDate) {
$upcomingScheduledDate = $upcomingPublishDate;
} elseif ($upcomingPublishEndDate) {
$upcomingScheduledDate = $upcomingPublishEndDate;
}
// Use the upcoming scheduled date if it will come earlier than the original lifetime
if ($upcomingScheduledDate) {
$upcomingScheduledDateObject = new \DateTime($upcomingScheduledDate);
$upcomingScheduledDateInSeconds = $upcomingScheduledDateObject->getTimestamp() - $date->getOverridableNow(true);
if ($lifetime > $upcomingScheduledDateInSeconds) {
$lifetime = $upcomingScheduledDateInSeconds;
}
}
// Let's check block output lifetime
if ($app['config']->get('concrete.cache.full_page_lifetime_block')) {
$blocks = $this->getBlocks();
$blocks = array_merge($this->getGlobalBlocks(), $blocks);
foreach ($blocks as $b) {
if ($b->cacheBlockOutput()) {
$blockLifetime = $b->getBlockOutputCacheLifetime();
// We should ignore 0 because it means forever
if ($blockLifetime > 0 && $lifetime > $blockLifetime) {
$lifetime = $blockLifetime;
}
}
}
}
return $lifetime;
}
|
Get the actual full-page cache lifespan (in seconds).
@return int
|
getCollectionFullPageCachingLifetimeValue
|
php
|
concretecms/concretecms
|
concrete/src/Page/Page.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
|
MIT
|
public static function addStatic($data, ?TreeInterface $parent = null)
{
$db = Database::connection();
if ($parent instanceof self) {
$cParentID = $parent->getCollectionID();
$parent->rescanChildrenDisplayOrder();
$cDisplayOrder = $parent->getNextSubPageDisplayOrder();
$cInheritPermissionsFromCID = $parent->getPermissionsCollectionID();
$cOverrideTemplatePermissions = $parent->overrideTemplatePermissions();
} else {
$cParentID = static::getHomePageID();
$cDisplayOrder = 0;
$cInheritPermissionsFromCID = $cParentID;
$cOverrideTemplatePermissions = 1;
}
if (isset($data['pkgID'])) {
$pkgID = $data['pkgID'];
} else {
$pkgID = 0;
}
$cFilename = $data['filename'];
$uID = USER_SUPER_ID;
$data['uID'] = $uID;
$cobj = parent::createCollection($data);
$cID = $cobj->getCollectionID();
// These get set to parent by default here, but they can be overridden later
$cInheritPermissionsFrom = 'PARENT';
$siteTreeID = 0;
if (is_object($parent)) {
$siteTreeID = $parent->getSiteTreeID();
}
$v = [$cID, $siteTreeID, $cFilename, $cParentID, $cInheritPermissionsFrom, $cOverrideTemplatePermissions, (int) $cInheritPermissionsFromCID, $cDisplayOrder, $uID, $pkgID];
$q = 'insert into Pages (cID, siteTreeID, cFilename, cParentID, cInheritPermissionsFrom, cOverrideTemplatePermissions, cInheritPermissionsFromCID, cDisplayOrder, uID, pkgID) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)';
$r = $db->prepare($q);
$res = $r->execute($v);
if ($res) {
// Collection added with no problem -- update cChildren on parrent
PageStatistics::incrementParents($cID);
}
$pc = self::getByID($cID);
$pc->rescanCollectionPath();
return $pc;
}
|
Create a new page.
@param array $data The data to be used to create the page. See Collection::createCollection() for the supported keys, plus 'pkgID' and 'filename'.
@param \Concrete\Core\Site\Tree\TreeInterface|null $parent the parent page (or the site) that will contain the new page
@return \Concrete\Core\Page\Page
@see \Concrete\Core\Page\Collection\Collection::createCollection()
|
addStatic
|
php
|
concretecms/concretecms
|
concrete/src/Page/Page.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
|
MIT
|
public static function getCurrentPage()
{
$req = Request::getInstance();
$current = $req->getCurrentPage();
return $current;
}
|
Get the currently requested page.
@return \Concrete\Core\Page\Page|null
|
getCurrentPage
|
php
|
concretecms/concretecms
|
concrete/src/Page/Page.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
|
MIT
|
public function getPageDraftTargetParentPageID()
{
$db = Database::connection();
return $db->fetchColumn('select cDraftTargetParentPageID from Pages where cID = ?', [$this->cID]);
}
|
Get the ID of the draft parent page ID.
@return int
|
getPageDraftTargetParentPageID
|
php
|
concretecms/concretecms
|
concrete/src/Page/Page.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
|
MIT
|
public function setPageDraftTargetParentPageID($cParentID)
{
if ($cParentID != $this->getPageDraftTargetParentPageID()) {
Section::unregisterPage($this);
}
$db = Database::connection();
$cParentID = (int) $cParentID;
$db->executeQuery('update Pages set cDraftTargetParentPageID = ? where cID = ?', [$cParentID, $this->cID]);
$this->cDraftTargetParentPageID = $cParentID;
Section::registerPage($this);
}
|
Set the ID of the draft parent page ID.
@param int $cParentID
|
setPageDraftTargetParentPageID
|
php
|
concretecms/concretecms
|
concrete/src/Page/Page.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
|
MIT
|
protected function populatePage($cInfo, $where, $cvID)
{
$app = Application::getFacadeApplication();
/** @var \Concrete\Core\Cache\Level\RequestCache $requestCache */
$requestCache = $app->make('cache/request');
$identifier = '/page/info/' . $cInfo;
$item = $requestCache->getItem($identifier);
if ($item->isHit()) {
$pageInfo = $item->get();
} else {
/** @var Connection $db */
$db = $app->make(Connection::class);
$fields = 'Pages.cID, Pages.pkgID, Pages.siteTreeID, Pages.cPointerID, Pages.cPointerExternalLink, Pages.cIsDraft, Pages.cIsActive, Pages.cIsSystemPage, Pages.cPointerExternalLinkNewWindow, Pages.cFilename, Pages.ptID, Collections.cDateAdded, Pages.cDisplayOrder, Collections.cDateModified, cInheritPermissionsFromCID, cInheritPermissionsFrom, cOverrideTemplatePermissions, cCheckedOutUID, cIsTemplate, uID, cPath, cParentID, cChildren, cCacheFullPageContent, cCacheFullPageContentOverrideLifetime, cCacheFullPageContentLifetimeCustom, Collections.cHandle';
$from = 'Pages INNER JOIN Collections ON Pages.cID = Collections.cID LEFT JOIN PagePaths ON (Pages.cID = PagePaths.cID AND PagePaths.ppIsCanonical = 1)';
$row = $db->fetchAssociative("SELECT {$fields} FROM {$from} {$where}", [$cInfo]);
if ($row !== false && $row['cPointerID'] > 0) {
$originalRow = $row;
$row = $db->fetchAssociative("SELECT {$fields}, CollectionVersions.cvName FROM {$from} LEFT JOIN CollectionVersions ON CollectionVersions.cID = ? WHERE Pages.cID = ? LIMIT 1", [$row['cID'], $row['cPointerID']]);
} else {
$originalRow = null;
}
$pageInfo = [];
if ($row !== false) {
if ($originalRow !== null) {
$pageInfo['customAliasName'] = (string) $row['cvName'];
unset($row['cvName']);
}
foreach ($row as $key => $value) {
$pageInfo[$key] = $value;
}
if ($originalRow !== null) {
$pageInfo['cPointerID'] = $originalRow['cPointerID'];
$pageInfo['cIsActive'] = $originalRow['cIsActive'];
$pageInfo['cPointerOriginalID'] = $originalRow['cID'];
$pageInfo['cPointerOriginalSiteTreeID'] = $originalRow['siteTreeID'];
$pageInfo['cPath'] = $originalRow['cPath'];
$pageInfo['cParentID'] = $originalRow['cParentID'];
$pageInfo['cDisplayOrder'] = $originalRow['cDisplayOrder'];
$pageInfo['aliasHandle'] = (string) $originalRow['cHandle'];
}
$pageInfo['isMasterCollection'] = $row['cIsTemplate'];
}
}
if ($pageInfo) {
foreach ($pageInfo as $key => $value) {
$this->{$key} = $value;
}
$this->loadError(false);
if ($cvID != false) {
$this->loadVersionObject($cvID);
}
$item->set($pageInfo);
$requestCache->save($item);
} else {
// there was no record of this particular collection in the database
$this->loadError(COLLECTION_NOT_FOUND);
}
}
|
Read the data from the database.
@param mixed $cInfo The argument of the $where condition
@param string $where The SQL 'WHERE' part
@param string|int $cvID
|
populatePage
|
php
|
concretecms/concretecms
|
concrete/src/Page/Page.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
|
MIT
|
protected function _getNumChildren($cID, $oneLevelOnly = 0, $sortColumn = 'cDisplayOrder asc')
{
$db = Database::connection();
$q = "select cID from Pages where cParentID = {$cID} and cIsTemplate = 0 order by {$sortColumn}";
$r = $db->query($q);
if ($r) {
while ($row = $r->fetch()) {
if ($row['cID'] > 0) {
$this->childrenCIDArray[] = $row['cID'];
if (!$oneLevelOnly) {
$this->_getNumChildren($row['cID']);
}
}
}
}
}
|
Populate the childrenCIDArray property (called by the getCollectionChildrenArray() method).
@param int $cID
@param bool $oneLevelOnly
@param string $sortColumn
|
_getNumChildren
|
php
|
concretecms/concretecms
|
concrete/src/Page/Page.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
|
MIT
|
protected function _duplicateAll($cParent, $cNewParent, $preserveUserID = false, ?Site $site = null)
{
$db = Database::connection();
$cID = $cParent->getCollectionID();
$q = 'select cID, ptHandle from Pages p left join PageTypes pt on p.ptID = pt.ptID where cParentID = ? order by cDisplayOrder asc';
$r = $db->executeQuery($q, [$cID]);
if ($r) {
while ($row = $r->fetch()) {
// This is a terrible hack.
if ($row['ptHandle'] === STACKS_PAGE_TYPE) {
$tc = Stack::getByID($row['cID']);
} else {
$tc = self::getByID($row['cID']);
}
$nc = $tc->duplicate($cNewParent, $preserveUserID, $site);
$tc->_duplicateAll($tc, $nc, $preserveUserID, $site);
}
}
}
|
Duplicate all the child pages of a specific page which has already have been duplicated.
@param \Concrete\Core\Page\Page $originalParentPage The original parent page
@param \Concrete\Core\Page\Page $newParentPage The duplicated parent page
@param bool $preserveUserID Set to true to preserve the original page author IDs
@param \Concrete\Core\Entity\Site\Site|null $site the destination site
@param mixed $cParent
@param mixed $cNewParent
|
_duplicateAll
|
php
|
concretecms/concretecms
|
concrete/src/Page/Page.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
|
MIT
|
protected function computeCanonicalPagePath()
{
$parent = self::getByID($this->cParentID);
$parentPath = $parent->getCollectionPathObject();
$path = '';
if ($parentPath instanceof PagePath) {
$path = $parentPath->getPagePath();
}
$path .= '/';
$cID = ($this->getCollectionPointerOriginalID() > 0) ? $this->getCollectionPointerOriginalID() : $this->cID;
/** @var \Concrete\Core\Utility\Service\Validation\Strings $stringValidator */
$stringValidator = Core::make('helper/validation/strings');
if ($stringValidator->notempty($this->getAliasHandle())) {
$path .= $this->getAliasHandle();
} elseif ($stringValidator->notempty($this->getCollectionHandle())) {
$path .= $this->getCollectionHandle();
} elseif (!$this->isHomePage()) {
$path .= $cID;
} else {
$path = ''; // This is computing the path for the home page, which has no handle, and so shouldn't have a segment.
}
$event = new PagePathEvent($this);
$event->setPagePath($path);
$event = Events::dispatch('on_compute_canonical_page_path', $event);
return $event->getPagePath();
}
|
Get the canonical path string of this page .
This happens before any uniqueness checks get run.
@return string
|
computeCanonicalPagePath
|
php
|
concretecms/concretecms
|
concrete/src/Page/Page.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
|
MIT
|
protected function _associateMasterCollectionBlocks($newCID, $masterCID, $cAcquireComposerOutputControls)
{
$mc = self::getByID($masterCID, 'ACTIVE');
$nc = self::getByID($newCID, 'RECENT');
$db = Database::connection();
$mcID = $mc->getCollectionID();
$mcvID = $mc->getVersionID();
$q = "select CollectionVersionBlocks.arHandle, BlockTypes.btCopyWhenPropagate, CollectionVersionBlocks.cbOverrideAreaPermissions, CollectionVersionBlocks.bID from CollectionVersionBlocks inner join Blocks on Blocks.bID = CollectionVersionBlocks.bID inner join BlockTypes on Blocks.btID = BlockTypes.btID where CollectionVersionBlocks.cID = '$mcID' and CollectionVersionBlocks.cvID = '{$mcvID}' order by CollectionVersionBlocks.cbDisplayOrder asc";
// ok. This function takes two IDs, the ID of the newly created virgin collection, and the ID of the crusty master collection
// who will impart his wisdom to the his young learner, by duplicating his various blocks, as well as their permissions, for the
// new collection
//$q = "select CollectionBlocks.cbAreaName, Blocks.bID, Blocks.bName, Blocks.bFilename, Blocks.btID, Blocks.uID, BlockTypes.btClassname, BlockTypes.btTablename from CollectionBlocks left join BlockTypes on (Blocks.btID = BlockTypes.btID) inner join Blocks on (CollectionBlocks.bID = Blocks.bID) where CollectionBlocks.cID = '$masterCID' order by CollectionBlocks.cbDisplayOrder asc";
//$q = "select CollectionVersionBlocks.cbAreaName, Blocks.bID, Blocks.bName, Blocks.bFilename, Blocks.btID, Blocks.uID, BlockTypes.btClassname, BlockTypes.btTablename from CollectionBlocks left join BlockTypes on (Blocks.btID = BlockTypes.btID) inner join Blocks on (CollectionBlocks.bID = Blocks.bID) where CollectionBlocks.cID = '$masterCID' order by CollectionBlocks.cbDisplayOrder asc";
$r = $db->query($q);
if ($r) {
while ($row = $r->fetch()) {
$b = Block::getByID($row['bID'], $mc, $row['arHandle']);
if ($cAcquireComposerOutputControls || !in_array($b->getBlockTypeHandle(), ['core_page_type_composer_control_output'])) {
if ($row['btCopyWhenPropagate']) {
$b->duplicate($nc, 'duplicate_master');
} else {
$b->alias($nc);
}
}
}
}
}
|
Duplicate the master collection blocks/permissions to a newly created page.
@param int $newCID the ID of the newly created page
@param int $mcID the ID of the master collection
@param bool $cAcquireComposerOutputControls
@param mixed $masterCID
|
_associateMasterCollectionBlocks
|
php
|
concretecms/concretecms
|
concrete/src/Page/Page.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
|
MIT
|
protected function _associateMasterCollectionAttributes($newCID, $masterCID)
{
$mc = self::getByID($masterCID, 'ACTIVE');
$nc = self::getByID($newCID, 'RECENT');
$attributes = CollectionKey::getAttributeValues($mc);
foreach ($attributes as $attribute) {
$value = $attribute->getValueObject();
if ($value) {
$value = clone $value;
$nc->setAttribute($attribute->getAttributeKey(), $value);
}
}
}
|
Duplicate the master collection attributes to a newly created page.
@param int $newCID the ID of the newly created page
@param int $mcID the ID of the master collection
@param mixed $masterCID
|
_associateMasterCollectionAttributes
|
php
|
concretecms/concretecms
|
concrete/src/Page/Page.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
|
MIT
|
protected function acquireAreaStylesFromDefaults(\Concrete\Core\Entity\Page\Template $template)
{
$pt = $this->getPageTypeObject();
if (is_object($pt)) {
$mc = $pt->getPageTypePageTemplateDefaultPageObject($template);
$db = Database::connection();
// first, we delete any styles we currently have
$db->delete('CollectionVersionAreaStyles', ['cID' => $this->getCollectionID(), 'cvID' => $this->getVersionID()]);
// now we acquire
$q = 'select issID, arHandle from CollectionVersionAreaStyles where cID = ?';
$r = $db->executeQuery($q, [$mc->getCollectionID()]);
while ($row = $r->fetch()) {
$db->executeQuery(
'insert into CollectionVersionAreaStyles (cID, cvID, arHandle, issID) values (?, ?, ?, ?)',
[
$this->getCollectionID(),
$this->getVersionID(),
$row['arHandle'],
$row['issID'],
]
);
}
}
}
|
Copy the area styles from a page template.
@param \Concrete\Core\Entity\Page\Template $pageTemplate
@param \Concrete\Core\Entity\Page\Template $template
|
acquireAreaStylesFromDefaults
|
php
|
concretecms/concretecms
|
concrete/src/Page/Page.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
|
MIT
|
public function getResult($queryRow)
{
$permissionsDisabled = isset($this->permissionsChecker) && $this->permissionsChecker === -1;
$c = Page::getByID($queryRow['cID']);
if (is_object($c) && $this->checkPermissions($c)) {
if ($this->pageVersionToRetrieve == self::PAGE_VERSION_RECENT) {
$cp = new \Permissions($c);
if ($cp->canViewPageVersions() || $permissionsDisabled) {
$c->loadVersionObject('RECENT');
}
} elseif ($this->pageVersionToRetrieve == self::PAGE_VERSION_SCHEDULED) {
$cp = new \Permissions($c);
if ($cp->canViewPageVersions() || $permissionsDisabled) {
$c->loadVersionObject('SCHEDULED');
}
} elseif ($this->pageVersionToRetrieve == self::PAGE_VERSION_RECENT_UNAPPROVED) {
$cp = new \Permissions($c);
if ($cp->canViewPageVersions() || $permissionsDisabled) {
$c->loadVersionObject('RECENT_UNAPPROVED');
}
} else {
$c->loadVersionObject('ACTIVE');
}
if (isset($queryRow['cIndexScore'])) {
$c->setPageIndexScore($queryRow['cIndexScore']);
}
$vo = $c->getVersionObject();
if ($vo && $vo->getVersionID()) {
return $c;
}
}
}
|
@param $queryRow
@return \Concrete\Core\Page\Page
|
getResult
|
php
|
concretecms/concretecms
|
concrete/src/Page/PageList.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/PageList.php
|
MIT
|
public function filterByPageTypeHandle($ptHandle)
{
$db = \Database::get();
if (is_array($ptHandle)) {
$this->query->andWhere(
$this->query->expr()->in('ptHandle', array_map([$db, 'quote'], $ptHandle))
);
} else {
$this->query->andWhere('pt.ptHandle = :ptHandle');
$this->query->setParameter('ptHandle', $ptHandle);
}
}
|
Filters by type of collection (using the handle field).
@param mixed $ptHandle
|
filterByPageTypeHandle
|
php
|
concretecms/concretecms
|
concrete/src/Page/PageList.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/PageList.php
|
MIT
|
public function filterByPageTemplate(TemplateEntity $template)
{
$this->query->andWhere('cv.pTemplateID = :pTemplateID');
$this->query->setParameter('pTemplateID', $template->getPageTemplateID());
}
|
Filters by page template.
@param mixed $ptHandle
@param TemplateEntity $template
|
filterByPageTemplate
|
php
|
concretecms/concretecms
|
concrete/src/Page/PageList.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/PageList.php
|
MIT
|
public function filterByDateAdded($date, $comparison = '=')
{
$this->query->andWhere($this->query->expr()->comparison('c.cDateAdded', $comparison, $this->query->createNamedParameter($date)));
}
|
Filters by date added.
@param string $date
@param mixed $comparison
|
filterByDateAdded
|
php
|
concretecms/concretecms
|
concrete/src/Page/PageList.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/PageList.php
|
MIT
|
public function filterByNumberOfChildren($number, $comparison = '>')
{
$number = (int) $number;
if ($this->includeAliases) {
$this->query->andWhere(
$this->query->expr()->orX(
$this->query->expr()->comparison('p.cChildren', $comparison, ':cChildren'),
$this->query->expr()->comparison('pa.cChildren', $comparison, ':cChildren')
)
);
} else {
$this->query->andWhere($this->query->expr()->comparison('p.cChildren', $comparison, ':cChildren'));
}
$this->query->setParameter('cChildren', $number);
}
|
Filter by number of children.
@param $number
@param string $comparison
|
filterByNumberOfChildren
|
php
|
concretecms/concretecms
|
concrete/src/Page/PageList.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/PageList.php
|
MIT
|
public function filterByDateLastModified($date, $comparison = '=')
{
$this->query->andWhere($this->query->expr()->comparison('c.cDateModified', $comparison, $this->query->createNamedParameter($date)));
}
|
Filter by last modified date.
@param $date
@param string $comparison
|
filterByDateLastModified
|
php
|
concretecms/concretecms
|
concrete/src/Page/PageList.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/PageList.php
|
MIT
|
public function filterByPublicDate($date, $comparison = '=')
{
$this->query->andWhere($this->query->expr()->comparison('cv.cvDatePublic', $comparison, $this->query->createNamedParameter($date)));
}
|
Filters by public date.
@param string $date
@param mixed $comparison
|
filterByPublicDate
|
php
|
concretecms/concretecms
|
concrete/src/Page/PageList.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/PageList.php
|
MIT
|
public function filterByPackage(Package $package)
{
$this->query->andWhere('p.pkgID = :pkgID');
$this->query->setParameter('pkgID', $package->getPackageID());
}
|
Filters by package.
@param Package $package
|
filterByPackage
|
php
|
concretecms/concretecms
|
concrete/src/Page/PageList.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/PageList.php
|
MIT
|
public function filterByPagesWithCustomStyles()
{
if ($this->queryHasAlias('cvStyles')) {
return;
}
$this->query->innerJoin(
'cv',
'CollectionVersionThemeCustomStyles',
'cvStyles',
'cv.cID = cvStyles.cID'
);
}
|
Displays only those pages that have style customizations.
|
filterByPagesWithCustomStyles
|
php
|
concretecms/concretecms
|
concrete/src/Page/PageList.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/PageList.php
|
MIT
|
public function filterByUserID($uID)
{
$this->query->andWhere('p.uID = :uID');
$this->query->setParameter('uID', $uID);
}
|
Filters by user ID).
@param mixed $uID
|
filterByUserID
|
php
|
concretecms/concretecms
|
concrete/src/Page/PageList.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/PageList.php
|
MIT
|
public function filterByPageTypeID($ptID)
{
$db = \Database::get();
if (is_array($ptID)) {
$this->query->andWhere(
$this->query->expr()->in('pt.ptID', array_map([$db, 'quote'], $ptID))
);
} else {
$this->query->andWhere($this->query->expr()->comparison('pt.ptID', '=', ':ptID'));
$this->query->setParameter('ptID', $ptID, \PDO::PARAM_INT);
}
}
|
Filters by page type ID.
@param array | integer $ptID
|
filterByPageTypeID
|
php
|
concretecms/concretecms
|
concrete/src/Page/PageList.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/PageList.php
|
MIT
|
public function filterByParentID($cParentID)
{
$db = \Database::get();
if (is_array($cParentID)) {
$this->query->andWhere(
$this->query->expr()->in('p.cParentID', array_map([$db, 'quote'], $cParentID))
);
} else {
$this->query->andWhere('p.cParentID = :cParentID');
$this->query->setParameter('cParentID', $cParentID, \PDO::PARAM_INT);
}
}
|
Filters by parent ID.
@param array | integer $cParentID
|
filterByParentID
|
php
|
concretecms/concretecms
|
concrete/src/Page/PageList.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/PageList.php
|
MIT
|
public function filterByName($name, $exact = false)
{
if ($exact) {
$this->query->andWhere('cv.cvName = :cvName');
$this->query->setParameter('cvName', $name);
} else {
$this->query->andWhere(
$this->query->expr()->like('cv.cvName', ':cvName')
);
$this->query->setParameter('cvName', '%' . $name . '%');
}
}
|
Filters a list by page name.
@param $name
@param bool $exact
|
filterByName
|
php
|
concretecms/concretecms
|
concrete/src/Page/PageList.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/PageList.php
|
MIT
|
public function filterByPath($path, $includeAllChildren = true)
{
if (!is_string($path)) {
return;
}
if (!$this->queryHasAlias('pp')) {
$this->query->leftJoin('p', 'PagePaths', 'pp', 'p.cID = pp.cID and pp.ppIsCanonical = true');
}
if (!$includeAllChildren) {
$this->query->andWhere('pp.cPath = :cPath');
$this->query->setParameter('cPath', $path);
} else {
$this->query->andWhere(
$this->query->expr()->like('pp.cPath', ':cPath')
);
$this->query->setParameter('cPath', $path . '/%');
}
$this->query->andWhere('pp.ppIsCanonical = 1');
}
|
Filter a list by page path.
@param $path
@param bool $includeAllChildren
|
filterByPath
|
php
|
concretecms/concretecms
|
concrete/src/Page/PageList.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/PageList.php
|
MIT
|
public function filterByKeywords($keywords)
{
$expressions = [
$this->query->expr()->like('psi.cName', ':keywords'),
$this->query->expr()->like('psi.cDescription', ':keywords'),
$this->query->expr()->like('psi.content', ':keywords'),
];
$keys = \CollectionAttributeKey::getSearchableIndexedList();
foreach ($keys as $ak) {
$cnt = $ak->getController();
$expressions[] = $cnt->searchKeywords($keywords, $this->query);
}
$expr = $this->query->expr();
$this->query->andWhere(call_user_func_array([$expr, 'orX'], $expressions));
$this->query->setParameter('keywords', '%' . $keywords . '%');
}
|
Filters keyword fields by keywords (including name, description, content, and attributes.
@param $keywords
|
filterByKeywords
|
php
|
concretecms/concretecms
|
concrete/src/Page/PageList.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/PageList.php
|
MIT
|
public function filterByBlockType(BlockType $bt)
{
$btID = $bt->getBlockTypeID();
$query = $this->query->getConnection()->createQueryBuilder();
$query->select('distinct p2.cID')
->from('Pages', 'p2')
->innerJoin('p2', 'CollectionVersions', 'cv2', 'cv2.cID = p2.cID')
->innerJoin(
'cv2',
'CollectionVersionBlocks',
'cvb2',
'cv2.cID = cvb2.cID and cv2.cvID = cvb2.cvID'
)
->innerJoin('cvb2', 'Blocks', 'b', 'cvb2.bID = b.bID')
->andWhere('b.btID = :btID');
$this->query->andWhere(
$this->query->expr()->in('p.cID', $query->getSQL())
);
$this->query->setParameter('btID', $btID);
}
|
Filters a page list by a particular block type occurring in the version of a page.
@param BlockType $bt
|
filterByBlockType
|
php
|
concretecms/concretecms
|
concrete/src/Page/PageList.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/PageList.php
|
MIT
|
public function filterByContainer(Container $container)
{
$containerID = $container->getContainerID();
$query = $this->query->getConnection()->createQueryBuilder();
$query->select('distinct p2.cID')
->from('Pages', 'p2')
->innerJoin('p2', 'CollectionVersions', 'cv2', 'cv2.cID = p2.cID')
->innerJoin(
'cv2',
'CollectionVersionBlocks',
'cvb2',
'cv2.cID = cvb2.cID and cv2.cvID = cvb2.cvID'
)
->innerJoin('cvb2', 'btCoreContainer', 'bcc', 'cvb2.bID = bcc.bID')
->innerJoin('bcc', 'PageContainerInstances', 'pci', 'bcc.containerInstanceID = pci.containerInstanceID')
->andWhere('pci.containerID = :containerID');
$this->query->andWhere(
$this->query->expr()->in('p.cID', $query->getSQL())
);
$this->query->setParameter('containerID', $containerID);
}
|
Filters a page list by a particular container occurring in a page
@param Container $container
|
filterByContainer
|
php
|
concretecms/concretecms
|
concrete/src/Page/PageList.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/PageList.php
|
MIT
|
public function sortByDisplayOrder()
{
$this->query->orderBy('p.cDisplayOrder', 'asc');
}
|
Sorts this list by display order.
|
sortByDisplayOrder
|
php
|
concretecms/concretecms
|
concrete/src/Page/PageList.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/PageList.php
|
MIT
|
public function sortByDisplayOrderDescending()
{
$this->query->orderBy('p.cDisplayOrder', 'desc');
}
|
Sorts this list by display order descending.
|
sortByDisplayOrderDescending
|
php
|
concretecms/concretecms
|
concrete/src/Page/PageList.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/PageList.php
|
MIT
|
public function sortByDateModified()
{
$this->query->orderBy('c.cDateModified', 'asc');
}
|
Sorts this list by date modified ascending.
|
sortByDateModified
|
php
|
concretecms/concretecms
|
concrete/src/Page/PageList.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/PageList.php
|
MIT
|
public function sortByDateModifiedDescending()
{
$this->query->orderBy('c.cDateModified', 'desc');
}
|
Sorts this list by date modified descending.
|
sortByDateModifiedDescending
|
php
|
concretecms/concretecms
|
concrete/src/Page/PageList.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/PageList.php
|
MIT
|
public function sortByCollectionIDAscending()
{
$this->query->orderBy('p.cID', 'asc');
}
|
Sorts by ID in ascending order.
|
sortByCollectionIDAscending
|
php
|
concretecms/concretecms
|
concrete/src/Page/PageList.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/PageList.php
|
MIT
|
public function sortByPublicDate()
{
$this->query->orderBy('cv.cvDatePublic', 'asc');
}
|
Sorts this list by public date ascending order.
|
sortByPublicDate
|
php
|
concretecms/concretecms
|
concrete/src/Page/PageList.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/PageList.php
|
MIT
|
public function sortByName()
{
$this->sortBy('cv.cvName', 'asc');
}
|
Sorts by name in ascending order.
|
sortByName
|
php
|
concretecms/concretecms
|
concrete/src/Page/PageList.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/PageList.php
|
MIT
|
public function sortByNameDescending()
{
$this->sortBy('cv.cvName', 'desc');
}
|
Sorts by name in descending order.
|
sortByNameDescending
|
php
|
concretecms/concretecms
|
concrete/src/Page/PageList.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/PageList.php
|
MIT
|
public function sortByPublicDateDescending()
{
$this->sortBy('cv.cvDatePublic', 'desc');
}
|
Sorts this list by public date descending order.
|
sortByPublicDateDescending
|
php
|
concretecms/concretecms
|
concrete/src/Page/PageList.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/PageList.php
|
MIT
|
public function sortByRelevance()
{
if ($this->isFulltextSearch) {
$this->sortBy('cIndexScore', 'desc');
}
}
|
Sorts by fulltext relevance (requires that the query be fulltext-based.
|
sortByRelevance
|
php
|
concretecms/concretecms
|
concrete/src/Page/PageList.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/PageList.php
|
MIT
|
protected function queryHasAlias($alias): bool
{
$queryParts = $this->query->getQueryPart('join');
foreach ($queryParts as $tableJoins) {
foreach ($tableJoins as $join) {
$value = $join['joinAlias'] ?? null;
if ($value === $alias) {
return true;
}
}
}
return false;
}
|
Checks whether the query already contains the given alias.
This avoids the following kind of query exceptions in case the join would
be added multiple times:
The given alias 'pp' is not unique in FROM and JOIN clause table.
This can happen e.g. at Concrete\Block\Search\Controller due to the
`filterByPath` method potentially called multiple times.
@property string $alias The alias to look for in the join statements.
@example <code><pre>
$this->queryHasAlias('pp');
</code></pre>
|
queryHasAlias
|
php
|
concretecms/concretecms
|
concrete/src/Page/PageList.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/PageList.php
|
MIT
|
public function transform(Page $page)
{
return (array) $page->getJSONObject();
}
|
Basic transforming of a page object into an array
@param Page $page
@return array
|
transform
|
php
|
concretecms/concretecms
|
concrete/src/Page/PageTransformer.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/PageTransformer.php
|
MIT
|
public static function addGlobal($cPath, $pkg = null)
{
$pathToFile = static::getPathToNode($cPath, $pkg);
$txt = Loader::helper('text');
$c = CorePage::getByPath($cPath);
if ($c->isError() && $c->getError() == COLLECTION_NOT_FOUND) {
// create the page at that point in the tree
$data = array();
$data['handle'] = trim($cPath, '/');
$data['name'] = $txt->unhandle($data['handle']);
$data['filename'] = $pathToFile;
$data['uID'] = USER_SUPER_ID;
if ($pkg != null) {
$data['pkgID'] = $pkg->getPackageID();
}
$c = Page::addStatic($data, null);
$c->moveToRoot();
return $c;
}
}
|
Adds a single page outside of any site trees. The global=true declaration in content importer XML must come at
on the first URL segment, so we don't have to be smart and check to see if the parents already eixst.
@param $cPath
@param null $pkg
@return mixed
|
addGlobal
|
php
|
concretecms/concretecms
|
concrete/src/Page/Single.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Single.php
|
MIT
|
public static function getTotalPageVersions()
{
$db = Loader::db();
return $db->GetOne("select count(cvID) from CollectionVersions");
}
|
Gets the total number of versions across all pages. Used in the dashboard.
@todo It might be nice if this were a little more generalized
@return int
|
getTotalPageVersions
|
php
|
concretecms/concretecms
|
concrete/src/Page/Statistics.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Statistics.php
|
MIT
|
public static function getSiteLastEdit($type = 'system')
{
return Loader::db()->GetOne("select max(Collections.cDateModified) from Collections");
}
|
Returns the datetime of the last edit to the site. Used in the dashboard.
@return string date formated like: 2009-01-01 00:00:00
|
getSiteLastEdit
|
php
|
concretecms/concretecms
|
concrete/src/Page/Statistics.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Statistics.php
|
MIT
|
public static function getTotalPagesCheckedOut()
{
$db = Loader::db();
return $db->GetOne("select count(cID) from Pages where cIsCheckedOut = 1");
}
|
Gets the total number of pages currently in edit mode.
@return int
|
getTotalPagesCheckedOut
|
php
|
concretecms/concretecms
|
concrete/src/Page/Statistics.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Statistics.php
|
MIT
|
public static function incrementParents($cID)
{
$db = Loader::db();
$cParentID = $db->GetOne("select cParentID from Pages where cID = ?", array($cID));
$q = "update Pages set cChildren = cChildren+1 where cID = ?";
$cpc = Page::getByID($cParentID);
$cpc->refreshCache();
$r = $db->query($q, array($cParentID));
}
|
For a particular page ID, grabs all the pages of this page, and increments the cTotalChildren number for them.
|
incrementParents
|
php
|
concretecms/concretecms
|
concrete/src/Page/Statistics.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Statistics.php
|
MIT
|
public static function decrementParents($cID)
{
$db = Loader::db();
$cParentID = $db->GetOne("select cParentID from Pages where cID = ?", array($cID));
$cChildren = (int) $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));
}
|
For a particular page ID, grabs all the pages of this page, and decrements the cTotalChildren number for them.
|
decrementParents
|
php
|
concretecms/concretecms
|
concrete/src/Page/Statistics.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Statistics.php
|
MIT
|
public static function getTotalPagesCreated($date)
{
$db = Loader::db();
$num = $db->GetOne('select count(Pages.cID) from Pages inner join Collections on Pages.cID = Collections.cID where cDateAdded >= ? and cDateAdded <= ? and siteTreeID > 0 and cIsTemplate = 0', array($date . ' 00:00:00', $date . ' 23:59:59'));
return $num;
}
|
Returns the total number of pages created for a given date.
|
getTotalPagesCreated
|
php
|
concretecms/concretecms
|
concrete/src/Page/Statistics.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Statistics.php
|
MIT
|
public static function getByID($cID, $version = 'RECENT')
{
$app = Application::getFacadeApplication();
/** @var Connection $db */
$db = $app->make(Connection::class);
$qb = $db->createQueryBuilder();
$qb->select('c.cDateAdded', 'c.cDateModified', 'c.cID')
->from('Collections', 'c')
->where('c.cID = :cID')
->setParameter('cID', $cID);
$row = $qb->execute()->fetch();
$c = new self();
if ($row !== false) {
$c->setPropertiesFromArray($row);
if ($version != false) {
// we don't do this on the front page
$c->loadVersionObject($version);
}
}
return $c;
}
|
Get a collection by ID.
@param int $cID The collection ID
@param string|int|false $version the collection version ('RECENT' for the most recent version, 'ACTIVE' for the currently published version, 'SCHEDULED' for the currently scheduled version, a falsy value to not load the collection version, or an integer to retrieve a specific version ID)
@return \Concrete\Core\Page\Collection\Collection If the collection is not found, you'll get an empty Collection instance
|
getByID
|
php
|
concretecms/concretecms
|
concrete/src/Page/Collection/Collection.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Collection/Collection.php
|
MIT
|
public static function getByHandle($handle)
{
$app = Application::getFacadeApplication();
/** @var Connection $db */
$db = $app->make(Connection::class);
$qb = $db->createQueryBuilder();
$qb->select('c.cID', 'p.cID AS pcID')
->from('Collections', 'c')
->leftJoin('c', 'Pages', 'p', 'c.cID = p.cID')
->where('c.cHandle = :cHandle')
->setParameter('cHandle', $handle);
// first we ensure that this does NOT appear in the Pages table. This is not a page. It is more basic than that
/** @var PDOStatement $r */
$r = $qb->execute();
if ($r->rowCount() === 0) {
// there is nothing in the collections table for this page, so we create and grab
$data = [
'handle' => $handle,
];
$cObj = self::createCollection($data);
} else {
$row = $r->fetch();
if ($row['cID'] > 0 && $row['pcID'] === null) {
// there is a collection, but it is not a page. so we grab it
$cObj = self::getByID($row['cID']);
}
}
return $cObj ?? null;
}
|
Get a Collection by handle (provided that it's not a Page handle).
If there's there's no collection with the specified handle, a new Collection will be created.
@param string $handle the collection handle
@return \Concrete\Core\Page\Collection\Collection|null return NULL if $handle is the handle of an existing page
|
getByHandle
|
php
|
concretecms/concretecms
|
concrete/src/Page/Collection/Collection.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Collection/Collection.php
|
MIT
|
public static function reindexPendingPages()
{
$app = Application::getFacadeApplication();
$indexStack = $app->make(IndexManagerInterface::class);
$num = 0;
/** @var Connection $db */
$db = $app->make(Connection::class);
$qb = $db->createQueryBuilder();
$r = $qb->select('cID')
->from('PageSearchIndex')
->where('cRequiresReindex = 1')
->execute();
while ($id = $r->fetchColumn()) {
$indexStack->index(\Concrete\Core\Page\Page::class, $id);
$num++;
}
Config::save('concrete.misc.do_page_reindex_check', false);
return $num;
}
|
(Re)Index all the collections that are marked as to be (re)indexed.
@return int returns the number of reindexed pages
|
reindexPendingPages
|
php
|
concretecms/concretecms
|
concrete/src/Page/Collection/Collection.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Collection/Collection.php
|
MIT
|
public static function createCollection($data)
{
$app = Application::getFacadeApplication();
/** @var Connection $db */
$db = $app->make(Connection::class);
$dh = Loader::helper('date');
$cDate = $dh->getOverridableNow();
$data = array_merge(
[
'name' => '',
'pTemplateID' => 0,
'handle' => null,
'uID' => null,
'cDatePublic' => $cDate,
'cDescription' => null,
],
$data
);
$cDatePublic = ($data['cDatePublic']) ? $data['cDatePublic'] : $cDate;
if (isset($data['cID'])) {
$res = $db->insert('Collections', [
'cID' => $data['cID'],
'cHandle' => $data['handle'],
'cDateAdded' => $cDate,
'cDateModified' => $cDate
]);
$newCID = $data['cID'];
} else {
$res = $db->insert('Collections', [
'cHandle' => $data['handle'],
'cDateAdded' => $cDate,
'cDateModified' => $cDate
]);
$newCID = $db->lastInsertId();
}
$cvIsApproved = (isset($data['cvIsApproved']) && $data['cvIsApproved'] == 0) ? 0 : 1;
$cvIsNew = 1;
if ($cvIsApproved) {
$cvIsNew = 0;
}
if (isset($data['cvIsNew'])) {
$cvIsNew = $data['cvIsNew'];
}
$data['name'] = Loader::helper('text')->sanitize($data['name']);
$pThemeID = 0;
if (isset($data['pThemeID']) && $data['pThemeID']) {
$pThemeID = $data['pThemeID'];
}
$pTemplateID = 0;
if ($data['pTemplateID']) {
$pTemplateID = $data['pTemplateID'];
}
if ($res) {
// now we add a pending version to the collectionversions table
$db->insert('CollectionVersions', [
'cID' => $newCID,
'cvID' => 1,
'pTemplateID' => $pTemplateID,
'cvName' => $data['name'],
'cvHandle' => $data['handle'],
'cvDescription' => $data['cDescription'],
'cvDatePublic' => $cDatePublic,
'cvDateCreated' => $cDate,
'cvComments' => t(VERSION_INITIAL_COMMENT),
'cvAuthorUID' => $data['uID'],
'cvIsApproved' => $cvIsApproved,
'cvIsNew' => $cvIsNew,
'pThemeID' => $pThemeID,
]);
}
return self::getByID($newCID);
}
|
Create a new Collection instance.
@param array $data {
@var int|null $cID The ID of the collection to create (if unspecified or NULL: database autoincrement value)
@var string $handle The collection handle (default: NULL)
@var string $name The collection name (default: empty string)
@var string $cDescription The collection description (default: NULL)
@var string $cDatePublic The collection publish date/time in format 'YYYY-MM-DD hh:mm:ss' (default: now)
@var bool $cvIsApproved Is the collection version approved (default: true)
@var bool $cvIsNew Is the collection to be considered "new"? (default: true if $cvIsApproved is false, false if $cvIsApproved is true)
@var int|null $pThemeID The collection theme ID (default: NULL)
@var int|null $pTemplateID The collection template ID (default: NULL)
@var int|null $uID The ID of the collection author (default: NULL)
}
@return \Concrete\Core\Page\Collection\Collection
|
createCollection
|
php
|
concretecms/concretecms
|
concrete/src/Page/Collection/Collection.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Collection/Collection.php
|
MIT
|
public function getCollectionID()
{
return $this->cID ? (int) $this->cID : null;
}
|
Get the collection ID.
@return int|null
|
getCollectionID
|
php
|
concretecms/concretecms
|
concrete/src/Page/Collection/Collection.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Collection/Collection.php
|
MIT
|
public function getCollectionHandle()
{
return $this->cHandle;
}
|
Get the collection handle.
@return string|null
|
getCollectionHandle
|
php
|
concretecms/concretecms
|
concrete/src/Page/Collection/Collection.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Collection/Collection.php
|
MIT
|
public function getCollectionDateLastModified()
{
return $this->cDateModified;
}
|
Get the date/time when the collection was last modified.
@return string|null
@example 2017-12-31 23:59:59
|
getCollectionDateLastModified
|
php
|
concretecms/concretecms
|
concrete/src/Page/Collection/Collection.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Collection/Collection.php
|
MIT
|
public function getCollectionDateAdded()
{
return $this->cDateAdded;
}
|
Get the date/time when the collection has been created.
@return string|null
@example 2017-12-31 23:59:59
|
getCollectionDateAdded
|
php
|
concretecms/concretecms
|
concrete/src/Page/Collection/Collection.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Collection/Collection.php
|
MIT
|
public function getVersionID()
{
return $this->vObj->cvID;
}
|
Get the ID of the currently loaded version.
@return int
|
getVersionID
|
php
|
concretecms/concretecms
|
concrete/src/Page/Collection/Collection.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Collection/Collection.php
|
MIT
|
public function getVersionObject()
{
return $this->vObj;
}
|
Get the currently loaded version object.
@return \Concrete\Core\Page\Collection\Version\Version|null
|
getVersionObject
|
php
|
concretecms/concretecms
|
concrete/src/Page/Collection/Collection.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Collection/Collection.php
|
MIT
|
public function addCollection($data)
{
$data['pThemeID'] = 0;
if (isset($this) && $this instanceof Page) {
$data['pThemeID'] = $this->getCollectionThemeID();
}
return static::createCollection($data);
}
|
Create a new Collection instance, using the same theme as this instance (if it's a Page instance).
@param array $data {
@var int|null $cID The ID of the collection to create (if unspecified or NULL: database autoincrement value)
@var string $handle The collection handle (default: NULL)
@var string $name The collection name (default: empty string)
@var string $cDescription The collection description (default: NULL)
@var string $cDatePublic The collection publish date/time in format 'YYYY-MM-DD hh:mm:ss' (default: now)
@var bool $cvIsApproved Is the collection version approved (default: true)
@var bool $cvIsNew Is the collection to be considered "new"? (default: true if $cvIsApproved is false, false if $cvIsApproved is true)
@var int|null $pTemplateID The collection template ID (default: NULL)
@var int|null $uID The ID of the collection author (default: NULL)
}
@return \Concrete\Core\Page\Collection\Collection
|
addCollection
|
php
|
concretecms/concretecms
|
concrete/src/Page/Collection/Collection.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Collection/Collection.php
|
MIT
|
public function loadVersionObject($cvID = 'ACTIVE')
{
$this->vObj = CollectionVersion::get($this, $cvID);
}
|
Load a specific collection version (you can retrieve it with the getVersionObject() method).
@param string|int $cvID the collection version ('RECENT' for the most recent version, 'ACTIVE' for the currently published version, 'SCHEDULED' for the currently scheduled version, or an integer to retrieve a specific version ID)
|
loadVersionObject
|
php
|
concretecms/concretecms
|
concrete/src/Page/Collection/Collection.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Collection/Collection.php
|
MIT
|
public function getVersionToModify()
{
$vObj = $this->getVersionObject();
if ($this->isMasterCollection() || ($vObj->isNew())) {
return $this;
} else {
$nc = $this->cloneVersion(null);
return $nc;
}
}
|
Get the Collection instance to be modified (this instance if it's a new or master Collection, a clone otherwise).
@return $this|\Concrete\Core\Page\Page
|
getVersionToModify
|
php
|
concretecms/concretecms
|
concrete/src/Page/Collection/Collection.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Collection/Collection.php
|
MIT
|
public function getNextVersionComments()
{
$c = Page::getByID($this->getCollectionID(), 'ACTIVE');
$cvID = $c->getVersionID();
return t('Version %d', $cvID + 1);
}
|
Get the automatic comment for the next collection version.
@return string Example: 'Version 2'
|
getNextVersionComments
|
php
|
concretecms/concretecms
|
concrete/src/Page/Collection/Collection.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Collection/Collection.php
|
MIT
|
public function setAttribute($ak, $value, $doReindexImmediately = true)
{
return $this->vObj->setAttribute($ak, $value, $doReindexImmediately);
}
|
Set the attribute value for the currently loaded collection version.
@param string|\Concrete\Core\Attribute\Key\CollectionKey $ak the attribute key (or its handle)
@param \Concrete\Core\Entity\Attribute\Value\Value\AbstractValue|mixed $value an attribute value object, or the data needed by the attribute controller to create the attribute value object
@param bool $doReindexImmediately
@return \Concrete\Core\Entity\Attribute\Value\PageValue
|
setAttribute
|
php
|
concretecms/concretecms
|
concrete/src/Page/Collection/Collection.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Collection/Collection.php
|
MIT
|
public function getAttribute($akHandle, $displayMode = false)
{
if (is_object($this->vObj)) {
return $this->vObj->getAttribute($akHandle, $displayMode);
}
}
|
Return the value of the attribute with the handle $akHandle of the currently loaded version (if it's loaded).
@param string|\Concrete\Core\Attribute\Key\CollectionKey $akHandle the attribute key (or its handle)
@param string|false $displayMode makes The format of the attribute value
@return mixed|null
@example When you need the raw attribute value or object, use this:
<code>
$c = Page::getCurrentPage();
$attributeValue = $c->getAttribute('attribute_handle');
</code>
@example If you need the formatted output supported by some attribute, use this:
<code>
$c = Page::getCurrentPage();
$attributeValue = $c->getAttribute('attribute_handle', 'display');
</code>
@example An attribute type like "date" will then return the date in the correct format just like other attributes will show you a nicely formatted output and not just a simple value or object.
|
getAttribute
|
php
|
concretecms/concretecms
|
concrete/src/Page/Collection/Collection.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Collection/Collection.php
|
MIT
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.