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 isCheckedOut() { // function to inform us as to whether the current collection is checked out /** @var \Concrete\Core\Database\Connection\Connection $db */ $db = Database::connection(); if (isset($this->isCheckedOutCache)) { return $this->isCheckedOutCache; } $q = "select cIsCheckedOut, cCheckedOutDatetimeLastEdit from Pages where cID = '{$this->cID}'"; $r = $db->executeQuery($q); if ($r) { $row = $r->fetchAssociative(); // If cCheckedOutDatetimeLastEdit is present, get the time span in seconds since it's last edit. if (!empty($row['cCheckedOutDatetimeLastEdit'])) { $dh = Core::make('helper/date'); $timeSinceCheckout = ($dh->getOverridableNow(true) - strtotime($row['cCheckedOutDatetimeLastEdit'])); } if (isset($row['cIsCheckedOut']) && $row['cIsCheckedOut'] == 0) { return false; } if (isset($timeSinceCheckout) && $timeSinceCheckout > CHECKOUT_TIMEOUT) { $this->forceCheckIn(); $this->isCheckedOutCache = false; return false; } $this->isCheckedOutCache = true; return true; } }
Is the page checked out? @return bool|null returns NULL if the page does not exist, a boolean otherwise
isCheckedOut
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function getCollectionCheckedOutUserName() { $db = Database::connection(); $query = 'select cCheckedOutUID from Pages where cID = ?'; $vals = [$this->cID]; $checkedOutId = $db->fetchColumn($query, $vals); if (is_object(UserInfo::getByID($checkedOutId))) { $ui = UserInfo::getByID($checkedOutId); $name = $ui->getUserName(); } else { $name = t('Unknown User'); } return $name; }
Gets the user that is editing the current page. @return string
getCollectionCheckedOutUserName
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function isCheckedOutByMe() { $app = Application::getFacadeApplication(); $u = $app->make(User::class); return $this->getCollectionCheckedOutUserID() > 0 && $this->getCollectionCheckedOutUserID() == $u->getUserID(); }
Checks if the page is checked out by the current user. @return bool
isCheckedOutByMe
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function isGeneratedCollection() { return $this->getCollectionFilename() && !$this->getPageTemplateID(); }
Checks if the page is a single page. Generated collections are collections without templates, that have special cFilename attributes . @return bool
isGeneratedCollection
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function setPermissionsToOverride() { if ($this->cInheritPermissionsFrom != 'OVERRIDE') { $this->setPermissionsToManualOverride(); } }
{@inheritdoc} @see \Concrete\Core\Permission\AssignableObjectInterface::setPermissionsToOverride()
setPermissionsToOverride
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function setChildPermissionsToOverride() { foreach ($this->getCollectionChildren() as $child) { $child->setPermissionsToManualOverride(); } }
{@inheritdoc} @see \Concrete\Core\Permission\AssignableObjectInterface::setChildPermissionsToOverride()
setChildPermissionsToOverride
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function removePermissions($userOrGroup, $permissions = []) { if ($this->cInheritPermissionsFrom != 'OVERRIDE') { return; } if (is_array($userOrGroup)) { $pe = GroupCombinationPermissionAccessEntity::getOrCreate($userOrGroup); // group combination } elseif ($userOrGroup instanceof User || $userOrGroup instanceof \Concrete\Core\User\UserInfo) { $pe = UserPermissionAccessEntity::getOrCreate($userOrGroup); } else { // group; $pe = GroupPermissionAccessEntity::getOrCreate($userOrGroup); } foreach ($permissions as $pkHandle) { $pk = PagePermissionKey::getByHandle($pkHandle); $pk->setPermissionObject($this); $pa = $pk->getPermissionAccessObject(); if (is_object($pa)) { if ($pa->isPermissionAccessInUse()) { $pa = $pa->duplicate(); } $pa->removeListItem($pe); $pt = $pk->getPermissionAssignmentObject(); $pt->assignPermissionAccess($pa); } } }
Remove specific permission keys for a specific access entity (user, group, group combination). @param \Concrete\Core\User\Group\Group|\Concrete\Core\User\Group\Group[]|\Concrete\Core\User\User|\Concrete\Core\User\UserInfo|\Concrete\Core\Entity\User\User $userOrGroup A list of groups for a group combination, or a group or a user @param string[] $permissions the handles of page permission keys to be removed
removePermissions
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public static function getDraftsParentPage(?Site $site = null) { $db = Database::connection(); $site = $site ? $site : \Core::make('site')->getSite(); $cParentID = $db->fetchColumn('select p.cID from PagePaths pp inner join Pages p on pp.cID = p.cID inner join SiteLocales sl on p.siteTreeID = sl.siteTreeID where cPath = ? and sl.siteID = ?', [Config::get('concrete.paths.drafts'), $site->getSiteID()]); return self::getByID($cParentID); }
Get the drafts parent page for a specific site. @param \Concrete\Core\Entity\Site\Site|null $site If not specified, we'll use the default site @return \Concrete\Core\Page\Page
getDraftsParentPage
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public static function getDrafts(Site $site) { $db = Database::connection(); $nc = self::getDraftsParentPage($site); $r = $db->executeQuery('select Pages.cID from Pages inner join Collections c on Pages.cID = c.cID where cParentID = ? order by cDateAdded desc', [$nc->getCollectionID()]); $pages = []; while ($row = $r->fetch()) { $entry = self::getByID($row['cID']); if (is_object($entry)) { $pages[] = $entry; } } return $pages; }
Get the list of draft pages in a specific site. @param \Concrete\Core\Entity\Site\Site $site @return \Concrete\Core\Page\Page[]
getDrafts
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function isPageDraft() { if (isset($this->cIsDraft) && $this->cIsDraft) { return true; } return false; }
Is this a draft page? @return bool
isPageDraft
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function setController($controller) { $this->controller = $controller; }
Set the page controller. @param \Concrete\Core\Page\Controller\PageController|null $controller
setController
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function getController() { return $this->getPageController(); }
@deprecated use the getPageController() method @return \Concrete\Core\Page\Controller\PageController
getController
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function assignPermissionSet($px) { if (isset($px->guests)) { $pkHandles = self::translatePermissionsXMLToKeys($px->guests); $this->assignPermissions(Group::getByID(GUEST_GROUP_ID), $pkHandles); } if (isset($px->registered)) { $pkHandles = self::translatePermissionsXMLToKeys($px->registered); $this->assignPermissions(Group::getByID(REGISTERED_GROUP_ID), $pkHandles); } if (isset($px->administrators)) { $pkHandles = self::translatePermissionsXMLToKeys($px->administrators); $this->assignPermissions(Group::getByID(ADMIN_GROUP_ID), $pkHandles); } if (isset($px->group)) { foreach ($px->group as $g) { $pkHandles = self::translatePermissionsXMLToKeys($px->administrators); $this->assignPermissions(Group::getByID($g['gID']), $pkHandles); } } if (isset($px->user)) { foreach ($px->user as $u) { $pkHandles = self::translatePermissionsXMLToKeys($px->administrators); $this->assignPermissions(UserInfo::getByID($u['uID']), $pkHandles); } } }
This is the legacy function that is called just by xml. We pass these values in as though they were the old ones. @private @param \SimpleXMLElement $px
assignPermissionSet
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function createAlias(Page $parentPage, array $options = []) { $app = Application::getFacadeApplication(); $db = $app->make(Connection::class); $cParentID = $parentPage->getCollectionID(); $uID = empty($options['uID']) ? 0 : (int) $options['uID']; if ($uID === 0) { $u = $app->make(User::class); $uID = $u->getUserID(); } $handle = empty($options['handle']) ? '' : (string) $options['handle']; if ($handle === '') { $handle = (string) $this->getCollectionHandle(); if ($handle === '') { $handle = $app->make('helper/text')->handle($this->getCollectionName()); } } $name = empty($options['name']) ? '' : (string) $options['name']; $cDisplayOrder = $parentPage->getNextSubPageDisplayOrder(); $cPath = $db->fetchColumn( 'SELECT cPath FROM PagePaths WHERE cID = ? ORDER BY ppIsCanonical DESC', [$cParentID] ); $collection = $this->addCollection([ 'handle' => $handle, 'name' => $name, ]); $newCID = $collection->getCollectionID(); $siteTreeID = $parentPage->getSiteTreeID(); $db->insert('Pages', [ 'cID' => $newCID, 'siteTreeID' => $siteTreeID, 'cParentID' => $cParentID, 'uID' => $uID, 'cPointerID' => $this->getCollectionID(), 'cDisplayOrder' => $cDisplayOrder, ]); $db->insert('PagePaths', [ 'cID' => $newCID, 'cPath' => $cPath . '/' . $handle, 'ppIsCanonical' => 1, 'ppGeneratedFromURLSlugs' => 1, ]); PageStatistics::incrementParents($newCID); $newPage = Page::getByID($newCID); $pe = new Event($newPage); Events::dispatch('on_page_alias_add', $pe); return $newPage; }
Make an alias to a page. @param \Concrete\Core\Page\Page $parentPage The page that will contain the alias @param array $options available keys: - name: the name of the alias (default: the original page name) - handle: the handle of the alias to be created (default: the original page handle) - uID: the ID of the user that's creating the alias (default: the ID of the current user) @return \Concrete\Core\Page\Page
createAlias
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function updateCollectionAlias(array $data): void { if (!$this->isAliasPage()) { return; } $app = Application::getFacadeApplication(); $data += [ 'customAliasName' => null, 'aliasHandle' => '', ]; $cSet = []; $cvSet = []; if ((string) $data['aliasHandle'] !== '') { $cSet['cHandle'] = $data['aliasHandle']; $cvSet['cvHandle'] = $data['aliasHandle']; } if ($data['customAliasName'] !== null) { $cvSet['cvName'] = $data['customAliasName']; } $db = $app->make(Connection::class); if ($cSet !== []) { $db->update( 'Collections', $cSet, ['cID' => $this->getCollectionPointerOriginalID()] ); } if ($cvSet !== []) { $db->update( 'CollectionVersions', $cvSet, ['cID' => $this->getCollectionPointerOriginalID()] ); } if ($data['customAliasName'] !== null) { $this->customAliasName = $data['customAliasName']; } if ((string) $data['aliasHandle'] !== '') { $this->aliasHandle = $data['aliasHandle']; $this->rescanCollectionPath(); } $pe = new Event($this); $eventDispatcher = $app->make(EventDispatcher::class); $eventDispatcher->dispatch('on_page_alias_edit', $pe); }
Update the alias details. @param array $data Supported keys: <ul> <li>string <code>customAliasName</code> empty string to use the name of the aliased page</li> <li>string <code>aliasHandle</code> the URL slug of the alias</li> </ul>
updateCollectionAlias
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function updateCollectionAliasExternal($cName, $cLink, $newWindow = 0) { if ($this->isExternalLink()) { $db = Database::connection(); $this->markModified(); if ($newWindow) { $newWindow = 1; } else { $newWindow = 0; } $db->executeQuery('update CollectionVersions set cvName = ? where cID = ?', [$cName, $this->cID]); $db->executeQuery('update Pages set cPointerExternalLink = ?, cPointerExternalLinkNewWindow = ? where cID = ?', [$cLink, $newWindow, $this->cID]); } }
Update the name, link, and to open in a new window for an external link. @param string $cName @param string $cLink @param bool $newWindow
updateCollectionAliasExternal
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function addExternalLink($name, $link, array $options = []) { $app = Application::getFacadeApplication(); $db = $app->make(Connection::class); $link = $app->make('helper/security')->sanitizeURL($link); $newWindow = empty($options['newWindow']) ? 0 : 1; $handle = empty($options['handle']) ? '' : (string) $options['handle']; if ($handle === '') { $handle = $app->make('helper/text')->urlify($name); } $uID = empty($options['uID']) ? 0 : (int) $options['uID']; if ($uID === 0) { $uID = $app->make(User::class)->getUserID(); } $cParentID = $this->getCollectionID(); $siteTreeID = $this->getSiteTreeID() ?: $app->make('site')->getSite()->getSiteTreeID(); $displayOrder = $this->getNextSubPageDisplayOrder(); $collection = $this->addCollection([ 'handle' => $handle, 'name' => $name, ]); $newCID = $collection->getCollectionID(); $db->insert('Pages', [ 'cID' => $newCID, 'siteTreeID' => $siteTreeID, 'cParentID' => $cParentID, 'uID' => $uID, 'cInheritPermissionsFrom' => 'PARENT', 'cInheritPermissionsFromCID' => (int) (int) $this->getPermissionsCollectionID(), 'cPointerExternalLink' => $link, 'cPointerExternalLinkNewWindow' => $newWindow, 'cDisplayOrder' => $displayOrder, ]); PageStatistics::incrementParents($newCID); $newPage = Page::getByID($newCID); return $newPage; }
Add a new external link as a child of this page. @param string $name The name of the link @param string $link The target of the link @param array $options available keys: - newWindow: should the link be opened in a new window (default: false) - handle: the handle of the link to be created (default: derive it from $name) - uID: the ID of the user that's creating the external link (default: the ID of the current user) @return \Concrete\Core\Page\Page The newly created page
addExternalLink
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function isSystemPage() { return (bool) $this->cIsSystemPage; }
Returns true if a page is a system page. A system page is either a page that is outside the site tree (has a site tree ID of 0) or a page that is in the site tree, but whose parent starts at 0. That means its a root level page. Why do we need this separate boolean then? Because we need to easily be able to filter all pages by whether they're a system page even if we don't necessarily know where their starting page is. @return bool
isSystemPage
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function getCollectionIcon() { // returns a fully qualified image link for this page's icon, either based on its collection type or if icon.png appears in its view directory $pe = new Event($this); $pe->setArgument('icon', ''); Events::dispatch('on_page_get_icon', $pe); $icon = $pe->getArgument('icon'); if ($icon) { return $icon; } if (\Core::make('multilingual/detector')->isEnabled()) { $icon = \Concrete\Core\Multilingual\Service\UserInterface\Flag::getDashboardSitemapIconSRC($this); } if ($this->isGeneratedCollection()) { if ($this->getPackageID() > 0) { if (is_dir(DIR_PACKAGES . '/' . $this->getPackageHandle())) { $dirp = DIR_PACKAGES; $url = \Core::getApplicationURL(); } else { $dirp = DIR_PACKAGES_CORE; $url = ASSETS_URL; } $file = $dirp . '/' . $this->getPackageHandle() . '/' . DIRNAME_PAGES . $this->getCollectionPath() . '/' . FILENAME_PAGE_ICON; if (file_exists($file)) { $icon = $url . '/' . DIRNAME_PACKAGES . '/' . $this->getPackageHandle() . '/' . DIRNAME_PAGES . $this->getCollectionPath() . '/' . FILENAME_PAGE_ICON; } } elseif (file_exists(DIR_FILES_CONTENT . $this->getCollectionPath() . '/' . FILENAME_PAGE_ICON)) { $icon = \Core::getApplicationURL() . '/' . DIRNAME_PAGES . $this->getCollectionPath() . '/' . FILENAME_PAGE_ICON; } elseif (file_exists(DIR_FILES_CONTENT_REQUIRED . $this->getCollectionPath() . '/' . FILENAME_PAGE_ICON)) { $icon = ASSETS_URL . '/' . DIRNAME_PAGES . $this->getCollectionPath() . '/' . FILENAME_PAGE_ICON; } } return $icon; }
Gets the icon for a page (also fires the on_page_get_icon event). @return string The path to the icon
getCollectionIcon
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function removeThisAlias() { $pe = new DeletePageEvent($this); Events::dispatch('on_page_alias_delete', $pe); if ($this->isExternalLink()) { $this->delete(); } elseif ($this->isAliasPage()) { $cIDRedir = $this->getCollectionPointerID(); $db = Database::connection(); PageStatistics::decrementParents($this->getCollectionPointerOriginalID()); $args = [$this->getCollectionPointerOriginalID()]; $q = 'delete from Pages where cID = ?'; $db->executeQuery($q, $args); $q = 'delete from Collections where cID = ?'; $db->executeQuery($q, $args); $q = 'delete from CollectionVersions where cID = ?'; $db->executeQuery($q, $args); $q = 'delete from PagePaths where cID = ?'; $db->executeQuery($q, $args); return $cIDRedir; } }
Remove an external link/alias. @return int|null cID of the original page if the page was an alias
removeThisAlias
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function populateRecursivePages($pages, $pageRow, $cParentID, $level, $includeThisPage = true) { $db = Database::connection(); $children = $db->GetAll('select cID, cDisplayOrder from Pages where cParentID = ? order by cDisplayOrder asc', [$pageRow['cID']]); if ($includeThisPage) { $pages[] = [ 'cID' => $pageRow['cID'], 'cDisplayOrder' => isset($pageRow['cDisplayOrder']) ? $pageRow['cDisplayOrder'] : null, 'cParentID' => $cParentID, 'level' => $level, 'total' => count($children), ]; } ++$level; $cParentID = $pageRow['cID']; if (count($children) > 0) { foreach ($children as $pageRow) { $pages = $this->populateRecursivePages($pages, $pageRow, $cParentID, $level); } } return $pages; }
Create an array containing data about child pages. @param array $pages the previously loaded data @param array $pageRow The data of current parent page (it must contain cID and optionally cDisplayOrder) @param int $cParentID The parent page ID @param int $level The current depth level @param bool $includeThisPage Should $pageRow itself be added to the resulting array? @return array Every array item contains the following keys: { @var int $cID @var int $cDisplayOrder @var int $cParentID @var int $level @var int $total }
populateRecursivePages
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public static function queueForDeletionSort($a, $b) { if ($a['level'] > $b['level']) { return -1; } if ($a['level'] < $b['level']) { return 1; } return 0; }
Sort a list of pages, so that the order is correct for the deletion. @param array $a @param array $b @return int
queueForDeletionSort
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public static function queueForDuplicationSort($a, $b) { if ($a['level'] > $b['level']) { return 1; } if ($a['level'] < $b['level']) { return -1; } if ($a['cDisplayOrder'] > $b['cDisplayOrder']) { return 1; } if ($a['cDisplayOrder'] < $b['cDisplayOrder']) { return -1; } if ($a['cID'] > $b['cID']) { return 1; } if ($a['cID'] < $b['cID']) { return -1; } return 0; }
Sort a list of pages, so that the order is correct for the duplication. @param array $a @param array $b @return int
queueForDuplicationSort
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function export($pageNode) { $exporter = $this->getExporter(); $exporter->export($this, $pageNode); }
@deprecated use the \Concrete\Core\Page\Exporter class @param \SimpleXMLElement $pageNode @see \Concrete\Core\Page\Page::getExporter()
export
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function getCollectionCheckedOutUserID() { return $this->cCheckedOutUID; }
Get the uID for a page that is checked out (if any). @return int|null
getCollectionCheckedOutUserID
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function getCollectionPath() { return $this->cPath; }
Get the path of this page. @return string
getCollectionPath
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function getCollectionPathObject() { $em = \ORM::entityManager(); $cID = ($this->getCollectionPointerOriginalID() > 0) ? $this->getCollectionPointerOriginalID() : $this->cID; $path = $em->getRepository('\Concrete\Core\Entity\Page\PagePath')->findOneBy( ['cID' => $cID, 'ppIsCanonical' => true, ]); return $path; }
Returns the PagePath object for the current page. @return \Concrete\Core\Entity\Page\PagePath|null
getCollectionPathObject
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function setCanonicalPagePath($cPath, $isAutoGenerated = false) { $em = \ORM::entityManager(); $path = $this->getCollectionPathObject(); if (is_object($path)) { $path->setPagePath($cPath); } else { $path = new \Concrete\Core\Entity\Page\PagePath(); $path->setPagePath($cPath); $path->setPageObject($this); } $path->setPagePathIsAutoGenerated($isAutoGenerated); $path->setPagePathIsCanonical(true); $em->persist($path); $em->flush(); }
Set the canonical page path for a page. @param string $cPath @param bool $isAutoGenerated is the page path generated from URL slugs?
setCanonicalPagePath
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function getPagePaths() { $em = \ORM::entityManager(); return $em->getRepository('\Concrete\Core\Entity\Page\PagePath')->findBy( ['cID' => $this->getCollectionID()], ['ppID' => 'asc'] ); }
Get all the page paths of this page. @return \Concrete\Core\Entity\Page\PagePath[]
getPagePaths
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function getAdditionalPagePaths() { $em = \ORM::entityManager(); return $em->getRepository('\Concrete\Core\Entity\Page\PagePath')->findBy( ['cID' => $this->getCollectionID(), 'ppIsCanonical' => false, ]); }
Get all the non-canonical page paths of this page. @return \Concrete\Core\Entity\Page\PagePath[]
getAdditionalPagePaths
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function clearPagePaths() { $em = \ORM::entityManager(); $paths = $this->getPagePaths(); foreach ($paths as $path) { $em->remove($path); } $em->flush(); }
Clears all page paths for a page.
clearPagePaths
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function getCollectionLink() { return Core::make('helper/navigation')->getLinkToCollection($this); }
Returns full url for the current page. @return string
getCollectionLink
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function getSiteTreeID() { return $this->cPointerOriginalSiteTreeID ?: $this->siteTreeID; }
{@inheritdoc} @see \Concrete\Core\Site\Tree\TreeInterface::getSiteTreeID()
getSiteTreeID
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function getSite() { $tree = $this->getSiteTreeObject(); if ($tree instanceof SiteTree) { return $tree->getSite(); } }
{@inheritdoc} @see \Concrete\Core\Site\SiteAggregateInterface::getSite()
getSite
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function getSiteTreeObject() { if (!isset($this->siteTree) && $this->getSiteTreeID()) { $em = \ORM::entityManager(); $this->siteTree = $em->find('\Concrete\Core\Entity\Site\Tree', $this->getSiteTreeID()); } return $this->siteTree; }
{@inheritdoc} @see \Concrete\Core\Site\Tree\TreeInterface::getSiteTreeObject()
getSiteTreeObject
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public static function getCollectionPathFromID($cID) { $db = Database::connection(); $path = $db->fetchColumn('select cPath from PagePaths inner join CollectionVersions on (PagePaths.cID = CollectionVersions.cID and CollectionVersions.cvIsApproved = 1) where PagePaths.cID = ? order by PagePaths.ppIsCanonical desc', [$cID]); return $path; }
Returns the path for a page from its cID. @param int cID @param mixed $cID @return @return string|false
getCollectionPathFromID
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function getCollectionUserID() { return $this->uID; }
Get the uID of the page author (if any). @return int|null
getCollectionUserID
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function getCollectionHandle() { if (isset($this->vObj)) { return $this->vObj->cvHandle; } return null; }
Get the page handle. @return string
getCollectionHandle
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function getCollectionTypeName() { return $this->getPageTypeName(); }
@deprecated use the getPageTypeName() method @return string|null
getCollectionTypeName
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function getPageTypeName() { if (!isset($this->pageType)) { $this->pageType = $this->getPageTypeObject(); } if (is_object($this->pageType)) { return $this->pageType->getPageTypeDisplayName(); } }
Get the display name of the page type (if available). @return string|null
getPageTypeName
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function getPageTypeID() { return isset($this->ptID) ? $this->ptID : null; }
Get the Collection Type ID. @return int|null
getPageTypeID
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function getPageTypeObject() { return PageType::getByID($this->getPageTypeID()); }
Get the page type object. @return \Concrete\Core\Page\Type\Type|null
getPageTypeObject
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function getPageTemplateID() { if (isset($this->vObj)) { return $this->vObj->pTemplateID; } return null; }
Get the Page Template ID. @return int
getPageTemplateID
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function getPageTemplateObject() { return PageTemplate::getByID($this->getPageTemplateID()); }
Get the Page Template Object (if available). @return \Concrete\Core\Entity\Page\Template|null
getPageTemplateObject
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function getPageTemplateHandle() { $pt = $this->getPageTemplateObject(); if ($pt instanceof TemplateEntity) { return $pt->getPageTemplateHandle(); } return false; }
Get the handle of the Page Template (if available). @return string|false
getPageTemplateHandle
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function getPageTypeHandle() { if (!isset($this->ptHandle)) { $this->ptHandle = false; $ptID = $this->getPageTypeID(); if ($ptID) { $pt = Type::getByID($ptID); if (is_object($pt)) { $this->ptHandle = $pt->getPageTypeHandle(); } } } return $this->ptHandle; }
Get the handle of the Page Type (if available). @return string|false
getPageTypeHandle
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function getCollectionTypeHandle() { return $this->getPageTypeHandle(); }
@deprecated use the getPageTypeHandle() method @return string|false
getCollectionTypeHandle
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function getCollectionThemeID() { $theme = $this->getCollectionThemeObject(); if (is_object($theme)) { return $theme->getThemeID(); } }
Get the theme ID for the collection (if available). @return int|null
getCollectionThemeID
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function isBlockAliasedFromMasterCollection($b) { if (!$b->isAlias()) { return false; } //Retrieve info for all of this page's blocks at once (and "cache" it) // so we don't have to query the database separately for every block on the page. if ($this->blocksAliasedFromMasterCollection === null) { $db = Database::connection(); $q = 'SELECT cvb.bID FROM CollectionVersionBlocks AS cvb INNER JOIN CollectionVersionBlocks AS cvb2 ON cvb.bID = cvb2.bID AND cvb2.cID = ? WHERE cvb.cID = ? AND cvb.isOriginal = 0 AND cvb.cvID = ? GROUP BY cvb.bID ;'; $v = [$this->getMasterCollectionID(), $this->getCollectionID(), $this->getVersionObject()->getVersionID()]; $this->blocksAliasedFromMasterCollection = $db->GetCol($q, $v); } return in_array($b->getBlockID(), $this->blocksAliasedFromMasterCollection); }
Check if a block is an alias from a page default. @param \Concrete\Core\Block\Block $b @return bool
isBlockAliasedFromMasterCollection
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function getCollectionThemeObject() { if (!isset($this->themeObject)) { $app = Facade::getFacadeApplication(); $tmpTheme = $app->make(ThemeRouteCollection::class) ->getThemeByRoute($this->getCollectionPath()); if (isset($tmpTheme[0])) { switch ($tmpTheme[0]) { case VIEW_CORE_THEME: $this->themeObject = new \Concrete\Theme\Concrete\PageTheme(); break; case 'dashboard': $this->themeObject = new \Concrete\Theme\Dashboard\PageTheme(); break; default: $this->themeObject = PageTheme::getByHandle($tmpTheme[0]); break; } } elseif ($this->vObj->pThemeID < 1) { $this->themeObject = PageTheme::getSiteTheme(); } else { $this->themeObject = PageTheme::getByID($this->vObj->pThemeID); } } if (!$this->themeObject) { $this->themeObject = PageTheme::getSiteTheme(); } return $this->themeObject; }
Get the collection's theme object. @return \Concrete\Core\Page\Theme\Theme
getCollectionThemeObject
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function getCollectionName() { $customAliasName = (string) $this->getCustomAliasName(); if ($customAliasName !== '') { return $customAliasName; } if (isset($this->vObj)) { return isset($this->vObj->cvName) ? $this->vObj->cvName : null; } return isset($this->cvName) ? $this->cvName : null; }
Get the page name. @return string
getCollectionName
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function getCustomAliasName(): ?string { return $this->customAliasName; }
Get the custom name of the alias page. @return string|null NULL if the page is not an alias, empty string if we should use the name of the aliased page, the custom alias name otherwise.
getCustomAliasName
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function getAliasHandle(): ?string { return $this->aliasHandle; }
Get the handle of the alias page @return string|null NULL if the page is not an alias, the alias handle otherwise
getAliasHandle
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function getCollectionPointerID() { return isset($this->cPointerID) ? (int) $this->cPointerID : 0; }
Get the collection ID for the aliased page (returns 0 unless used on an actual alias). @return int
getCollectionPointerID
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function getCollectionPointerExternalLink() { return $this->cPointerExternalLink; }
Get the link for the aliased page. @return string|null
getCollectionPointerExternalLink
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function openCollectionPointerExternalLinkInNewWindow() { return $this->cPointerExternalLinkNewWindow; }
Should the alias link to be opened in a new window? @return bool|int|null
openCollectionPointerExternalLinkInNewWindow
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function isAliasPage() { return $this->getCollectionPointerID() > 0; }
Is this page an alias page of another page? @return bool @since concrete5 8.5.0a2
isAliasPage
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function isAliasPageOrExternalLink() { return $this->isAliasPage() || $this->isExternalLink(); }
Is this page an alias page or an external link? @return bool @since concrete5 8.5.0a2
isAliasPageOrExternalLink
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function isAlias() { return $this->isAliasPageOrExternalLink(); }
@deprecated This method has been replaced with isAliasPageOrExternalLink() in concrete5 8.5.0a2 (same syntax and same result) @return bool
isAlias
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function isExternalLink() { return $this->cPointerExternalLink != null; }
Is this page an external link? @return bool
isExternalLink
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function getCollectionPointerOriginalID() { return $this->cPointerOriginalID; }
Get the original cID of a page (if it's a page alias). @return int
getCollectionPointerOriginalID
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function getCollectionFilename() { return $this->cFilename; }
Get the file name of a page (single pages). @return string
getCollectionFilename
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function getCollectionDatePublic() { if (isset($this->vObj)) { return $this->vObj->cvDatePublic; } return null; }
Get the date/time when the current version was made public (or a falsy value if the current version doesn't have public date). @return string @example 2009-01-01 00:00:00
getCollectionDatePublic
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function getCollectionDatePublicObject() { return Core::make('date')->toDateTime($this->getCollectionDatePublic()); }
Get the date/time when the current version was made public (or NULL value if the current version doesn't have public date). @return \DateTime|null
getCollectionDatePublicObject
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function getCollectionDescription() { if (isset($this->vObj)) { return $this->vObj->cvDescription; } return null; }
Get the description of a page. @return string
getCollectionDescription
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function getCollectionParentID() { return isset($this->cParentID) ? (int) $this->cParentID : null; }
Ges the cID of the parent page. @return int|null
getCollectionParentID
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public static function getCollectionParentIDFromChildID($cID) { $db = Database::connection(); $q = 'select cParentID from Pages where cID = ?'; $cParentID = $db->fetchColumn($q, [$cID]); return $cParentID; }
Get the parent cID of a page given its cID. @param int $cID @return int|null
getCollectionParentIDFromChildID
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function getCollectionParentIDs() { $cIDs = [$this->cParentID]; $db = Database::connection(); $aliasedParents = $db->fetchAll('SELECT cParentID FROM Pages WHERE cPointerID = ?', [$this->cID]); foreach ($aliasedParents as $aliasedParent) { $cIDs[] = $aliasedParent['cParentID']; } return $cIDs; }
Get an array containint this cParentID and aliased parentIDs. @return int[]
getCollectionParentIDs
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function isMasterCollection() { return $this->isMasterCollection; }
Is this page a page default? @return bool|int|null
isMasterCollection
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function overrideTemplatePermissions() { return $this->cOverrideTemplatePermissions; }
Are template permissions overriden? @return bool|int|null
overrideTemplatePermissions
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function getCollectionDisplayOrder() { return $this->cDisplayOrder; }
Get the position of the page in the sitemap, relative to its parent page. @return int|null
getCollectionDisplayOrder
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function setTheme($pl) { $db = Database::connection(); $db->executeQuery('update CollectionVersions set pThemeID = ? where cID = ? and cvID = ?', [$pl ? $pl->getThemeID() : 0, $this->cID, $this->vObj->getVersionID()]); $this->themeObject = $pl; }
Set the theme of this page. @param \Concrete\Core\Page\Theme\Theme $pl
setTheme
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function setThemeSkin(SkinInterface $skin) { $db = Database::connection(); $db->executeQuery('update CollectionVersions set pThemeSkinIdentifier = ? where cID = ? and cvID = ?', [$skin->getIdentifier(), $this->cID, $this->vObj->getVersionID()]); }
Set the theme skin of this page. @param SkinInterface $skin
setThemeSkin
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function setPageType(?\Concrete\Core\Page\Type\Type $type = null) { $ptID = 0; if (is_object($type)) { $ptID = $type->getPageTypeID(); } $db = Database::connection(); $db->executeQuery('update Pages set ptID = ? where cID = ?', [$ptID, $this->cID]); $this->ptID = $ptID; }
Set the theme for a page using the page object. @param \Concrete\Core\Page\Type\Type|null $type
setPageType
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function setPermissionsInheritanceToTemplate() { $db = Database::connection(); if ($this->cID) { $db->executeQuery('update Pages set cOverrideTemplatePermissions = 0 where cID = ?', [$this->cID]); } }
Set the permissions of sub-collections added beneath this permissions to inherit from the template.
setPermissionsInheritanceToTemplate
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function setPermissionsInheritanceToOverride() { $db = Database::connection(); if ($this->cID) { $db->executeQuery('update Pages set cOverrideTemplatePermissions = 1 where cID = ?', [$this->cID]); } }
Set the permissions of sub-collections added beneath this permissions to inherit from the parent.
setPermissionsInheritanceToOverride
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function getPermissionsCollectionID() { return $this->cInheritPermissionsFromCID; }
Get the ID of the page from which this page inherits permissions from. @return int|null
getPermissionsCollectionID
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function getCollectionInheritance() { return $this->cInheritPermissionsFrom; }
Where permissions should be inherited from? 'PARENT' or 'TEMPLATE' or 'OVERRIDE'. @return string|null
getCollectionInheritance
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function getParentPermissionsCollectionID() { $db = Database::connection(); $cParentID = $this->cParentID; if (!$cParentID) { $cParentID = $this->getSiteHomePageID(); } $v = [$cParentID]; $q = 'select cInheritPermissionsFromCID from Pages where cID = ?'; $ppID = $db->fetchColumn($q, $v); return $ppID; }
Get the ID of the page from which the parent page page inherits permissions from. @return int|null
getParentPermissionsCollectionID
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function getPermissionsCollectionObject() { return self::getByID($this->cInheritPermissionsFromCID, 'RECENT'); }
Get the page from which this page inherits permissions from. @return \Concrete\Core\Page\Page
getPermissionsCollectionObject
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function getMasterCollectionID() { $pt = PageType::getByID($this->getPageTypeID()); if (!is_object($pt)) { return 0; } $template = PageTemplate::getByID($this->getPageTemplateID()); if (!is_object($template)) { return 0; } $c = $pt->getPageTypePageTemplateDefaultPageObject($template); return $c->getCollectionID(); }
Get the master page of this page, given its page template and page type. @return int returns 0 if not found
getMasterCollectionID
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function getOriginalCollectionID() { // this is a bit weird...basically, when editing a master collection, we store the // master collection ID in session, along with the collection ID we were looking at before // moving to the master collection. This allows us to get back to that original collection return Session::get('ocID'); }
Get the ID of the original collection. @return int|null
getOriginalCollectionID
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function getNumChildren() { return $this->cChildren; }
Get the number of child pages. @return int|null
getNumChildren
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function getNumChildrenDirect() { // direct children only $db = Database::connection(); $v = [$this->cID]; $num = $db->fetchColumn('select count(cID) as total from Pages where cParentID = ?', $v); if ($num) { return $num; } return 0; }
Get the number of child pages (direct children only). @return int
getNumChildrenDirect
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function getFirstChild($sortColumn = 'cDisplayOrder asc') { $app = Application::getFacadeApplication(); $db = $app->make(Connection::class); $now = $app->make('date')->getOverridableNow(); $cID = $db->fetchColumn( <<<EOT select Pages.cID from Pages inner join CollectionVersions on Pages.cID = CollectionVersions.cID where cParentID = ? and cvIsApproved = 1 and (cvPublishDate is null or cvPublishDate <= ?) and (cvPublishEndDate is null or cvPublishEndDate >= ?) order by {$sortColumn} EOT , [$this->cID, $now, $now] ); if ($cID && $cID != $this->getSiteHomePageID()) { return self::getByID($cID, 'ACTIVE'); } return false; }
Get the first child of the current page, or null if there is no child. @param string $sortColumn the ORDER BY clause @return \Concrete\Core\Page\Page|false
getFirstChild
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function getCollectionChildrenArray($oneLevelOnly = 0) { $this->childrenCIDArray = []; $this->_getNumChildren($this->cID, $oneLevelOnly); return $this->childrenCIDArray; }
Get the list of child page IDs, sorted by their display order. @param bool $oneLevelOnly set to true to return only the direct children, false for all the child pages @return int[]
getCollectionChildrenArray
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function getCollectionChildren($version = 'RECENT') { $children = []; $app = Application::getFacadeApplication(); /** @var Connection $connection */ $connection = $app->make(Connection::class); $r = $connection->createQueryBuilder() ->select('cID') ->from('Pages') ->where('cParentID = :cParentID') ->andWhere('cIsTemplate = 0') ->orderBy('cDisplayOrder', 'asc') ->setParameter('cParentID', $this->getCollectionID()) ->execute(); if ($r) { while ($row = $r->fetchAssociative()) { if ($row['cID'] > 0) { $c = self::getByID($row['cID'], $version); $children[] = $c; } } } return $children; }
Get the immediate children of the this page. @since 9.3.6 Added the $version parameter @param string $version the page 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) @return \Concrete\Core\Page\Page[]
getCollectionChildren
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function canMoveCopyTo($cobj) { $children = $this->getCollectionChildrenArray(); $children[] = $this->getCollectionID(); return !in_array($cobj->getCollectionID(), $children); }
Check if a collection is this page itself or one of its sub-pages. @param \Concrete\Core\Page\Collection\Collection $cobj @return bool
canMoveCopyTo
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function updateCollectionName($name) { $db = Database::connection(); $vo = $this->getVersionObject(); $cvID = $vo->getVersionID(); $this->markModified(); if (is_object($this->vObj)) { $this->vObj->cvName = $name; $app = Application::getFacadeApplication(); $cHandle = $app->make(HandleGenerator::class)->generate($this, ['cName' => $name]); $db->executeQuery('update CollectionVersions set cvName = ?, cvHandle = ? where cID = ? and cvID = ?', [$name, $cHandle, $this->getCollectionID(), $cvID]); $cache = PageCache::getLibrary(); $cache->purge($this); $pe = new Event($this); Events::dispatch('on_page_update', $pe); } }
Update the collection name. @param string $name
updateCollectionName
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function hasPageThemeCustomizations() { $db = Database::connection(); return $db->fetchColumn('select count(cID) from CollectionVersionThemeCustomStyles where cID = ? and cvID = ?', [ $this->cID, $this->getVersionID(), ]) > 0; }
Does this page have theme customizations? @return bool
hasPageThemeCustomizations
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function getPageWrapperClass() { $pt = $this->getPageTypeObject(); $view = $this->getPageController()->getViewObject(); if ($view) { $ptm = $view->getPageTemplate(); } else { $ptm = $this->getPageTemplateObject(); } $classes = ['ccm-page', 'ccm-page-id-' . $this->getCollectionID()]; if (is_object($pt)) { $classes[] = 'page-type-' . str_replace('_', '-', $pt->getPageTypeHandle()); } if (is_object($ptm)) { $classes[] = 'page-template-' . str_replace('_', '-', $ptm->getPageTemplateHandle()); } $config = app('config'); if (in_array($config->get('concrete.security.production.mode'), [Modes::MODE_STAGING, Modes::MODE_DEVELOPMENT])) { $classes[] = 'ccm-production-mode-' . $config->get('concrete.security.production.mode'); } /* * Provide an opportunity for altering the CSS classes in the page wrapper. */ $event = new Event($this); $event->setArgument('classes', $classes); Events::dispatch('on_get_page_wrapper_class', $event); return implode(' ', $event->getArgument('classes')); }
Get the CSS class to be used to wrap the whole page contents. @return string
getPageWrapperClass
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function update($data) { $db = Database::connection(); $vo = $this->getVersionObject(); $cvID = $vo->getVersionID(); $this->markModified(); $cName = $this->getCollectionName(); $cDescription = $this->getCollectionDescription(); $cDatePublic = $this->getCollectionDatePublic(); $uID = $this->getCollectionUserID(); $pkgID = empty($data['pkgID']) ? $this->getPackageID() : $data['pkgID']; $cFilename = $this->getCollectionFilename(); $pTemplateID = $this->getPageTemplateID(); $ptID = $this->getPageTypeID(); $existingPageTemplateID = $pTemplateID; $cCacheFullPageContent = $this->cCacheFullPageContent; $cCacheFullPageContentLifetimeCustom = $this->cCacheFullPageContentLifetimeCustom; $cCacheFullPageContentOverrideLifetime = $this->cCacheFullPageContentOverrideLifetime; if (isset($data['cName'])) { $cName = $data['cName']; } if (isset($data['cCacheFullPageContent'])) { $cCacheFullPageContent = $data['cCacheFullPageContent']; } if (isset($data['cCacheFullPageContentLifetimeCustom'])) { $cCacheFullPageContentLifetimeCustom = (int) ($data['cCacheFullPageContentLifetimeCustom']); } if (isset($data['cCacheFullPageContentOverrideLifetime'])) { $cCacheFullPageContentOverrideLifetime = $data['cCacheFullPageContentOverrideLifetime']; } if (isset($data['cDescription'])) { $cDescription = $data['cDescription']; } if (isset($data['cDatePublic'])) { $cDatePublic = $data['cDatePublic']; } if (isset($data['uID'])) { $uID = $data['uID']; } if (isset($data['pTemplateID'])) { $pTemplateID = $data['pTemplateID']; } if (isset($data['ptID'])) { $ptID = $data['ptID']; } // https://github.com/concrete5/concrete5/issues/10413 if (isset($uID)) { $uID = (int) $uID; } else { $uID = 0; } if (!$cDatePublic) { $cDatePublic = Core::make('helper/date')->getOverridableNow(); } $app = Application::getFacadeApplication(); $txt = $app->make('helper/text'); $cName = $txt->sanitize($cName); $cHandle = $app->make(HandleGenerator::class)->generate($this, $data); if ($this->isGeneratedCollection()) { if (isset($data['cFilename'])) { $cFilename = $data['cFilename']; } // we only update a subset $v = [$cName, $cHandle, $cDescription, $cDatePublic, $cvID, $this->cID]; $q = 'update CollectionVersions set cvName = ?, cvHandle = ?, cvDescription = ?, cvDatePublic = ? where cvID = ? and cID = ?'; $r = $db->prepare($q); $r->execute($v); } else { if ($existingPageTemplateID && $pTemplateID && ($existingPageTemplateID != $pTemplateID) && $this->getPageTypeID() > 0 && $this->isPageDraft()) { // we are changing a page template in this operation. // when that happens, we need to get the new defaults for this page, remove the other blocks // on this page that were set by the old defaults master page $pt = $this->getPageTypeObject(); if (is_object($pt)) { $template = PageTemplate::getbyID($pTemplateID); $existingPageTemplate = PageTemplate::getByID($existingPageTemplateID); $oldMC = $pt->getPageTypePageTemplateDefaultPageObject($existingPageTemplate); $newMC = $pt->getPageTypePageTemplateDefaultPageObject($template); $currentPageBlocks = $this->getBlocks(); $newMCBlocks = $newMC->getBlocks(); $oldMCBlocks = $oldMC->getBlocks(); $oldMCBlockIDs = []; foreach ($oldMCBlocks as $ob) { $oldMCBlockIDs[] = $ob->getBlockID(); } // now, we default all blocks on the current version of the page. $db->executeQuery('delete from CollectionVersionBlocks where cID = ? and cvID = ?', [$this->getCollectionID(), $cvID]); // now, we go back and we alias blocks from the new master collection onto the page. foreach ($newMCBlocks as $b) { $bt = $b->getBlockTypeObject(); if ($bt->getBlockTypeHandle() == BLOCK_HANDLE_PAGE_TYPE_OUTPUT_PROXY) { continue; } if ($bt->isCopiedWhenPropagated()) { $b->duplicate($this, true); } else { $b->alias($this); } } // now, we go back and re-add the blocks we originally had on the page // but only if they're not present in the oldMCBlocks array foreach ($currentPageBlocks as $b) { if (!in_array($b->getBlockID(), $oldMCBlockIDs)) { $newBlockDisplayOrder = $this->getCollectionAreaDisplayOrder($b->getAreaHandle()); $db->executeQuery('insert into CollectionVersionBlocks (cID, cvID, bID, arHandle, cbRelationID, cbDisplayOrder, isOriginal, cbOverrideAreaPermissions, cbIncludeAll) values (?, ?, ?, ?, ?, ?, ?, ?, ?)', [ $this->getCollectionID(), $cvID, $b->getBlockID(), $b->getAreaHandle(), $b->getBlockRelationID(), $newBlockDisplayOrder, (int) ($b->isOriginal()), $b->overrideAreaPermissions(), $b->disableBlockVersioning(), ]); } } // Now, we need to change the default styles on the page, in case we are inheriting any from the // defaults (for areas) if ($template) { $this->acquireAreaStylesFromDefaults($template); } } } $v = [$cName, $cHandle, $pTemplateID, $cDescription, $cDatePublic, $cvID, $this->cID]; $q = 'update CollectionVersions set cvName = ?, cvHandle = ?, pTemplateID = ?, cvDescription = ?, cvDatePublic = ? where cvID = ? and cID = ?'; $r = $db->prepare($q); $r->execute($v); } $db->executeQuery('update Pages set ptID = ?, uID = ?, pkgID = ?, cFilename = ?, cCacheFullPageContent = ?, cCacheFullPageContentLifetimeCustom = ?, cCacheFullPageContentOverrideLifetime = ? where cID = ?', [$ptID, $uID, $pkgID, $cFilename, $cCacheFullPageContent, $cCacheFullPageContentLifetimeCustom, $cCacheFullPageContentOverrideLifetime, $this->cID]); $cache = PageCache::getLibrary(); $cache->purge($this); $this->refreshCache(); // load new version object $this->loadVersionObject($cvID); $pe = new Event($this); Events::dispatch('on_page_update', $pe); }
Update the data of this page. @param array $data Recognized keys are { @var string $cHandle @var string $cName @var string $cDescription @var string $cDatePublic @var int $ptID @var int $pTemplateID @var int $uID @var int $pkgID @var string $cFilename @var int $cCacheFullPageContent -1: use the default settings; 0: no; 1: yes @var int $cCacheFullPageContentLifetimeCustom @var string $cCacheFullPageContentOverrideLifetime }
update
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function inheritPermissionsFromParent() { $db = Database::connection(); $cpID = $this->getParentPermissionsCollectionID(); $this->updatePermissionsCollectionID($this->cID, $cpID); $v = ['PARENT', (int) $cpID, $this->cID]; $q = 'update Pages set cInheritPermissionsFrom = ?, cInheritPermissionsFromCID = ? where cID = ?'; $db->executeQuery($q, $v); $this->cInheritPermissionsFrom = 'PARENT'; $this->cInheritPermissionsFromCID = $cpID; $this->clearPagePermissions(); $this->rescanAreaPermissions(); }
Set this page permissions to be inherited from its parent page.
inheritPermissionsFromParent
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function inheritPermissionsFromDefaults() { $db = Database::connection(); $type = $this->getPageTypeObject(); if (is_object($type)) { $master = $type->getPageTypePageTemplateDefaultPageObject(); if (is_object($master)) { $cpID = $master->getCollectionID(); $this->updatePermissionsCollectionID($this->cID, $cpID); $v = ['TEMPLATE', (int) $cpID, $this->cID]; $q = 'update Pages set cInheritPermissionsFrom = ?, cInheritPermissionsFromCID = ? where cID = ?'; $db->executeQuery($q, $v); $this->cInheritPermissionsFrom = 'TEMPLATE'; $this->cInheritPermissionsFromCID = $cpID; $this->clearPagePermissions(); $this->rescanAreaPermissions(); } } }
Set this page permissions to be inherited from its parent type defaults.
inheritPermissionsFromDefaults
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function setPermissionsToManualOverride() { if ($this->cInheritPermissionsFrom != 'OVERRIDE') { $db = Database::connection(); $this->acquirePagePermissions($this->getPermissionsCollectionID()); $this->acquireAreaPermissions($this->getPermissionsCollectionID()); $cpID = $this->cID; $this->updatePermissionsCollectionID($this->cID, $cpID); $v = ['OVERRIDE', (int) $cpID, $this->cID]; $q = 'update Pages set cInheritPermissionsFrom = ?, cInheritPermissionsFromCID = ? where cID = ?'; $db->executeQuery($q, $v); $this->cInheritPermissionsFrom = 'OVERRIDE'; $this->cInheritPermissionsFromCID = $cpID; $this->rescanAreaPermissions(); } }
Set this page permissions to be manually specified.
setPermissionsToManualOverride
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function rescanAreaPermissions() { $db = Database::connection(); $r = $db->executeQuery('select arHandle, arIsGlobal from Areas where cID = ?', [$this->getCollectionID()]); while ($row = $r->fetch()) { $a = Area::getOrCreate($this, $row['arHandle'], $row['arIsGlobal']); $a->rescanAreaPermissionsChain(); } }
Rescan the page areas ensuring that they are inheriting permissions properly.
rescanAreaPermissions
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function setOverrideTemplatePermissions($cOverrideTemplatePermissions) { $db = Database::connection(); $v = [$cOverrideTemplatePermissions, $this->cID]; $q = 'update Pages set cOverrideTemplatePermissions = ? where cID = ?'; $db->executeQuery($q, $v); $this->cOverrideTemplatePermissions = $cOverrideTemplatePermissions; }
Are template permissions overriden? @param bool|int $cOverrideTemplatePermissions
setOverrideTemplatePermissions
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function updatePermissionsCollectionID($cParentIDString, $npID) { // now we iterate through $db = Database::connection(); $pcID = $this->getPermissionsCollectionID(); $q = "select cID from Pages where cParentID in ({$cParentIDString}) and cInheritPermissionsFromCID = {$pcID}"; $r = $db->query($q); $cList = []; while ($row = $r->fetch()) { $cList[] = $row['cID']; } if (count($cList) > 0) { $cParentIDString = implode(',', $cList); $q2 = "update Pages set cInheritPermissionsFromCID = {$npID} where cID in ({$cParentIDString})"; $db->query($q2); $this->updatePermissionsCollectionID($cParentIDString, $npID); } }
Set the child pages of a list of parent pages to inherit permissions from the specified page (provided that they previouly had the same inheritance page as this page). @param int|string $cParentIDString A comma-separeted list of parent page IDs @param int $newInheritPermissionsFromCID the ID of the new page the child pages should inherit permissions from @param mixed $npID
updatePermissionsCollectionID
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function acquireAreaPermissions($permissionsCollectionID) { $v = [$this->cID]; $db = Database::connection(); $q = 'delete from AreaPermissionAssignments where cID = ?'; $db->executeQuery($q, $v); // ack - we need to copy area permissions from that page as well $v = [$permissionsCollectionID]; $q = 'select cID, arHandle, paID, pkID from AreaPermissionAssignments where cID = ?'; $r = $db->executeQuery($q, $v); while ($row = $r->fetch()) { $v = [$this->cID, $row['arHandle'], $row['paID'], $row['pkID']]; $q = 'insert into AreaPermissionAssignments (cID, arHandle, paID, pkID) values (?, ?, ?, ?)'; $db->executeQuery($q, $v); } // any areas that were overriding permissions on the current page need to be overriding permissions // on the NEW page as well. $v = [$permissionsCollectionID]; $q = 'select * from Areas where cID = ? and arOverrideCollectionPermissions'; $r = $db->executeQuery($q, $v); while ($row = $r->fetch()) { $v = [$this->cID, $row['arHandle'], $row['arOverrideCollectionPermissions'], $row['arInheritPermissionsFromAreaOnCID'], $row['arIsGlobal']]; $q = 'insert into Areas (cID, arHandle, arOverrideCollectionPermissions, arInheritPermissionsFromAreaOnCID, arIsGlobal) values (?, ?, ?, ?, ?)'; $db->executeQuery($q, $v); } }
Acquire the area permissions, copying them from the inherited ones. @param int $permissionsCollectionID the ID of the collection from which the page previously inherited permissions from
acquireAreaPermissions
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT
public function acquirePagePermissions($permissionsCollectionID) { $v = [$this->cID]; $db = Database::connection(); $q = 'delete from PagePermissionAssignments where cID = ?'; $db->executeQuery($q, $v); $v = [$permissionsCollectionID]; $q = 'select cID, paID, pkID from PagePermissionAssignments where cID = ?'; $r = $db->executeQuery($q, $v); while ($row = $r->fetch()) { $v = [$this->cID, $row['paID'], $row['pkID']]; $q = 'insert into PagePermissionAssignments (cID, paID, pkID) values (?, ?, ?)'; $db->executeQuery($q, $v); } }
Acquire the page permissions, copying them from the inherited ones. @param int $permissionsCollectionID the ID of the collection from which the page previously inherited permissions from
acquirePagePermissions
php
concretecms/concretecms
concrete/src/Page/Page.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Page.php
MIT