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 getAttributeValueObject($akHandle, $createIfNotExists = false)
{
if (is_object($this->vObj)) {
return $this->vObj->getAttributeValueObject($akHandle, $createIfNotExists);
}
}
|
Return the attribute value object 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 bool $createIfNotExists
@return \Concrete\Core\Entity\Attribute\Value\PageValue|null
|
getAttributeValueObject
|
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 clearCollectionAttributes($retainAKIDs = [])
{
$app = Application::getFacadeApplication();
/** @var Connection $db */
$db = $app->make(Connection::class);
$qb = $db->createQueryBuilder();
if (count($retainAKIDs) > 0) {
$cleanAKIDs = [];
foreach ($retainAKIDs as $akID) {
$cleanAKIDs[] = (int) $akID;
}
$qb->delete('CollectionAttributeValues')
->where('cID = :cID')
->andWhere('cvID = :cvID')
->andWhere($qb->expr()->notIn('akID', $cleanAKIDs))
->setParameter('cID', $this->getCollectionID())
->setParameter('cvID', $this->getVersionID())
->execute();
} else {
$qb->delete('CollectionAttributeValues')
->where('cID = :cID')
->andWhere('cvID = :cvID')
->setParameter('cID', $this->getCollectionID())
->setParameter('cvID', $this->getVersionID())
->execute();
}
$this->reindex();
}
|
Delete the values of the attributes associated to the currently loaded collection version.
@param int[] $retainAKIDs a list of attribute key IDs to keep (their values won't be deleted)
|
clearCollectionAttributes
|
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 clearAttribute($ak, bool $doReindexImmediately = true)
{
$this->vObj->clearAttribute($ak, $doReindexImmediately);
}
|
Delete the value of a specific attribute key associated to the currently loaded collection version.
@param string|\Concrete\Core\Attribute\Key\CollectionKey $ak the attribute key (or its handle)
@param bool $doReindexImmediately
|
clearAttribute
|
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 getSetCollectionAttributes()
{
$category = $this->vObj->getObjectAttributeCategory();
$values = $category->getAttributeValues($this->vObj);
$attribs = [];
foreach ($values as $value) {
$attribs[] = $value->getAttributeKey();
}
return $attribs;
}
|
Get the list of attribute keys for which the currently loaded collection version has values.
@return \Concrete\Core\Entity\Attribute\Key\PageKey[]
|
getSetCollectionAttributes
|
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 getArea($arHandle)
{
return Area::get($this, $arHandle);
}
|
Get an existing area associated to this collection.
@param string $arHandle the handle of the area
@return \Concrete\Core\Area\Area|null
|
getArea
|
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 hasAliasedContent()
{
$app = Application::getFacadeApplication();
/** @var Connection $db */
$db = $app->make(Connection::class);
$qb = $db->createQueryBuilder();
// aliased content is content on the particular page that is being
// used elsewhere - but the content on the PAGE is the original version
$r = $qb->select('bID')
->from('CollectionVersionBlocks')
->where('cID = :cID')
->andWhere('isOriginal = 1')
->setParameter('cID', $this->getCollectionID())
->execute();
$bIDArray = [];
if ($r) {
while ($row = $r->fetch()) {
$bIDArray[] = $row['bID'];
}
if (count($bIDArray) > 0) {
$qb2 = $db->createQueryBuilder();
$qb2->select('cID')
->from('CollectionVersionBlocks')
->where($qb2->expr()->in('bID', $bIDArray))
->andWhere($qb2->expr()->neq('cID', ':cID'))
->setParameter('cID', $this->getCollectionID())
->setMaxResults(1);
$aliasedCID = $qb2->execute()->fetchColumn();
if ($aliasedCID > 0) {
return true;
}
}
}
return false;
}
|
Does this collection contain blocks that are aliased in other pages?
@return bool
|
hasAliasedContent
|
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 getAreaCustomStyle($area, $force = false)
{
$areac = $area->getAreaCollectionObject();
if ($areac instanceof Stack) {
// this fixes the problem of users applying design to the main area on the page, and then that trickling into any
// stacks that have been added to other areas of the page.
return null;
}
$result = null;
$styleSet = null;
$areaHandle = $area->getAreaHandle();
if ($area->isGlobalArea()) {
/**
* @var $area GlobalArea
*/
$stack = Stack::getGlobalAreaStackFromName($this, $area->getAreaHandle());
if ($stack) {
$styles = $stack->getVersionObject()->getCustomAreaStyles();
if (isset($styles[STACKS_AREA_NAME])) {
$styleSet = StyleSet::getByID($styles[STACKS_AREA_NAME]);
}
}
} else {
$styles = $this->vObj->getCustomAreaStyles();
if (isset($styles[$areaHandle])) {
$styleSet = StyleSet::getByID($styles[$areaHandle]);
}
}
if ($styleSet || $force) {
$result = new AreaCustomStyle($styleSet, $area, $this->getCollectionThemeObject());
}
return $result;
}
|
Get the custom style of an area in the currently loaded collection version.
@param \Concrete\Core\Area\Area $area the area for which you want the custom styles
@param bool $force Set to true to retrieve a CustomStyle even if the area does not define any custom style
@return \Concrete\Core\Area\CustomStyle|null return NULL if the area does not have any custom style and $force is false, a CustomStyle instance otherwise
|
getAreaCustomStyle
|
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 setCustomStyleSet($area, $set)
{
$app = Application::getFacadeApplication();
/** @var Connection $db */
$db = $app->make(Connection::class);
$qb = $db->createQueryBuilder();
$r = $qb->select('cID')
->from('CollectionVersionAreaStyles')
->where('cID = :cID')
->andWhere('cvID = :cvID')
->andWhere('arHandle = :arHandle')
->setParameter('cID', $this->getCollectionID())
->setParameter('cvID', $this->getVersionID())
->setParameter('arHandle', $area->getAreaHandle())
->execute()->fetch();
$qb2 = $db->createQueryBuilder();
if ($r !== false) {
$qb2->update('CollectionVersionAreaStyles')
->set('issID', ':issID')
->where('cID = :cID')
->andWhere('cvID = :cvID')
->andWhere('arHandle = :arHandle');
} else {
$qb2->insert('CollectionVersionAreaStyles')
->setValue('cID', ':cID')
->setValue('cvID', ':cvID')
->setValue('arHandle', ':arHandle')
->setValue('issID', ':issID');
}
$qb2->setParameter('cID', $this->getCollectionID())
->setParameter('cvID', $this->getVersionID())
->setParameter('arHandle', $area->getAreaHandle())
->setParameter('issID', $set->getID())
->execute();
}
|
Set the custom style of an area in the currently loaded collection version.
@param \Concrete\Core\Area\Area $area
@param \Concrete\Core\Entity\StyleCustomizer\Inline\StyleSet $set
|
setCustomStyleSet
|
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 resetAreaCustomStyle($area)
{
$app = Application::getFacadeApplication();
/** @var Connection $db */
$db = $app->make(Connection::class);
$qb = $db->createQueryBuilder();
$qb->delete('CollectionVersionAreaStyles')
->where('cID = :cID')
->andWhere('cvID = :cvID')
->andWhere('arHandle = :arHandle')
->setParameter('cID', $this->getCollectionID())
->setParameter('cvID', $this->getVersionID())
->setParameter('arHandle', $area->isGlobalArea() ? STACKS_AREA_NAME : $area->getAreaHandle())
->execute();
}
|
Delete all the custom styles of an area of the currently loaded collection version.
@param \Concrete\Core\Area\Area $area
|
resetAreaCustomStyle
|
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 outputCustomStyleHeaderItems($return = false)
{
$app = Application::getFacadeApplication();
if (!$app['config']->get('concrete.design.enable_custom')) {
return $return ? '' : null;
}
$psss = [];
/** @var BlockCustomStyleRepository $blockCustomStyleRepository */
$blockCustomStyleRepository = $app->make(BlockCustomStyleRepository::class);
/** @var AreaCustomStyleRepository $areaCustomStyleRepository */
$areaCustomStyleRepository = $app->make(AreaCustomStyleRepository::class);
foreach ($blockCustomStyleRepository->getCollectionVersionBlockStyles($this) as $blockStyle) {
$psss[] = $blockStyle;
}
foreach ($areaCustomStyleRepository->getCollectionVersionAreaStyles($this) as $areaStyle) {
$psss[] = $areaStyle;
}
// grab all the header block style rules for items in global areas on this page
$applicableStacks = $this->getGlobalStacksForCollection();
foreach ($applicableStacks as $s) {
foreach ($blockCustomStyleRepository->getStackBlockStyles($s, $this->getCollectionThemeObject()) as $blockStyle) {
$psss[] = $blockStyle;
}
foreach ($areaCustomStyleRepository->getStackAreaStyles($s, $this->getCollectionThemeObject()) as $areaStyle) {
$psss[] = $areaStyle;
}
}
$styleHeader = '';
foreach ($psss as $st) {
$css = $st->getCSS();
if ($css !== '') {
$styleHeader .= $st->getStyleWrapper($css);
}
}
if (strlen(trim($styleHeader))) {
if ($return == true) {
return $styleHeader;
} else {
$v = \View::getInstance();
$v->addHeaderItem($styleHeader);
}
}
}
|
Retrieve all custom style rules that should be inserted into the header on a page, whether they are defined in areas or blocks.
@param bool $return set to true to return the HTML that defines the styles, false to add it to the current View instance
@return string|null
|
outputCustomStyleHeaderItems
|
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 relateVersionEdits($oc)
{
$app = Application::getFacadeApplication();
/** @var Connection $db */
$db = $app->make(Connection::class);
$qb = $db->createQueryBuilder();
$r = (int) $qb = $qb->select('count(*)')
->from('CollectionVersionRelatedEdits')
->where('cID = :cID')
->andWhere('cvID = :cvID')
->andWhere('cRelationID = :cRelationID')
->andWhere('cvRelationID = :cvRelationID')
->setParameter('cID', $this->getCollectionID())
->setParameter('cvID', $this->getVersionID())
->setParameter('cRelationID', $oc->getCollectionID())
->setParameter('cvRelationID', $oc->getVersionID())
->execute()->fetchColumn();
if ($r > 0) {
return false;
} else {
$qb2 = $db->createQueryBuilder();
$qb2->insert('CollectionVersionRelatedEdits')
->setValue('cID', $this->getCollectionID())
->setValue('cvID', $this->getVersionID())
->setValue('cRelationID', $oc->getCollectionID())
->setValue('cvRelationID', $oc->getVersionID())
->execute();
}
}
|
Associate the edits of another collection to this collection.
@param \Concrete\Core\Page\Collection\Collection $oc the collection that has been modified
@return null|false return false if the other collection is already associated to this collection, NULL otherwise
@example If a global area is modified inside this collection, you need to call $page->relateVersionEdits($globalArea)
|
relateVersionEdits
|
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 getPageTypeID()
{
return false;
}
|
Returns the ID of the page/collection type.
@return int|false
|
getPageTypeID
|
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 getGlobalBlocks()
{
$stacks = $this->getGlobalStacksForCollection();
$blocks = [];
foreach($stacks as $s) {
$blocksTmp = $s->getBlocks(STACKS_AREA_NAME);
$blocks = array_merge($blocks, $blocksTmp);
}
return $blocks;
}
|
Get the blocks contained in all the global areas in this collection.
@return \Concrete\Core\Block\Block[]
|
getGlobalBlocks
|
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 getGlobalBlockIDs()
{
$stacks = $this->getGlobalStacksForCollection();
$blockIDs = [];
foreach ($stacks as $s) {
$blockIDsTmp = $s->getBlockIDs(STACKS_AREA_NAME);
$blockIDs = array_merge($blockIDs, $blockIDsTmp);
}
return $blockIDs;
}
|
Get the IDs for blocks contained in all the global areas in this collection.
@return array Return a list of arrays, each one is a dictionary like ['bID' => <block ID>, 'arHandle' => <area handle>]
|
getGlobalBlockIDs
|
php
|
concretecms/concretecms
|
concrete/src/Page/Collection/Collection.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Collection/Collection.php
|
MIT
|
protected function getGlobalStacksForCollection()
{
if ($this->globalStacks === null) {
$app = Application::getFacadeApplication();
/** @var Connection $db */
$db = $app->make(Connection::class);
$qb = $db->createQueryBuilder();
$rs = $qb->select('stName')
->from('Stacks', 's')
->innerJoin('s', 'Areas', 'a', 'a.arHandle = s.stName')
->andWhere('a.arIsGlobal = 1')
->andWhere('a.cID = :cID')
->andWhere('s.stType = :stType')
->setParameter('cID', $this->getCollectionID())
->setParameter('stType', Stack::ST_TYPE_GLOBAL_AREA)
->execute()->fetchAll(FetchMode::COLUMN);
$stacks = [];
if (count($rs) > 0) {
foreach ($rs as $garHandle) {
$s = Stack::getGlobalAreaStackFromName($this, $garHandle);
if (is_object($s)) {
$stacks[] = $s;
}
}
}
$this->globalStacks = $stacks;
}
return $this->globalStacks;
}
|
Get all the global stacks loaded in this collection.
@return \Concrete\Core\Page\Stack\Stack[]
|
getGlobalStacksForCollection
|
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 getBlocks($arHandle = false)
{
$blockIDs = $this->getBlockIDs($arHandle);
$blocks = [];
if (is_array($blockIDs)) {
foreach ($blockIDs as $row) {
$ab = Block::getByID($row['bID'], $this, $row['arHandle']);
if (is_object($ab)) {
$blocks[] = $ab;
}
}
}
return $blocks;
}
|
List the blocks in the currently loaded collection version (or in a specific area within it).
@param string|false $arHandle The handle if the area (or falsy to get all the blocks in the collection)
@return \Concrete\Core\Block\Block[]
|
getBlocks
|
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 getBlockIDs($arHandle = false)
{
$blockIDs = CacheLocal::getEntry(
'collection_block_ids',
$this->getCollectionID() . ':' . $this->getVersionID()
);
if (!is_array($blockIDs)) {
$app = Application::getFacadeApplication();
/** @var Connection $db */
$db = $app->make(Connection::class);
$qb = $db->createQueryBuilder();
$r = $qb->select('b.bID', 'cvb.arHandle')
->from('CollectionVersionBlocks', 'cvb')
->innerJoin('cvb', 'Blocks', 'b', 'cvb.bID = b.bID')
->where('cvb.cID = :cID')
->andWhere($qb->expr()->orX(
'cvb.cvID = :cvID',
'cvb.cbIncludeAll = 1'
))
->orderBy('cvb.cbDisplayOrder', 'asc')
->setParameter('cID', $this->getCollectionID())
->setParameter('cvID', $this->getVersionID())
->execute()->fetchAll();
$blockIDs = [];
if (is_array($r)) {
foreach ($r as $bl) {
$blockIDs[strtolower($bl['arHandle'])][] = $bl;
}
}
CacheLocal::set('collection_block_ids', $this->getCollectionID() . ':' . $this->getVersionID(), $blockIDs);
}
$result = [];
if ($arHandle != false) {
$key = strtolower($arHandle);
if (isset($blockIDs[$key])) {
$result = $blockIDs[$key];
}
} else {
foreach ($blockIDs as $arHandle => $row) {
foreach ($row as $brow) {
if (!in_array($brow, $blockIDs)) {
$result[] = $brow;
}
}
}
}
return $result;
}
|
List the block IDs and the associated area handles in the currently loaded collection version (or in a specific area within it).
@param string|false $arHandle The handle if the area (or falsy to get all the blocks in the collection version)
@return array Return a list of arrays, each one is a dictionary like ['bID' => <block ID>, 'arHandle' => <area handle>]
|
getBlockIDs
|
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 addBlock($bt, $a, $data)
{
$app = Application::getFacadeApplication();
/** @var Connection $db */
$db = $app->make(Connection::class);
// first we add the block to the system
$nb = $bt->add($data, $this, $a);
// now that we have a block, we add it to the collectionversions table
$arHandle = (is_object($a)) ? $a->getAreaHandle() : $a;
$cID = $this->getCollectionID();
$vObj = $this->getVersionObject();
if ($bt->includeAll()) {
// normally, display order is dependant on a per area, per version basis. However, since this block
// is not aliased across versions, then we want to get display order simply based on area, NOT based
// on area + version
$newBlockDisplayOrder = $this->getCollectionAreaDisplayOrder(
$arHandle,
true
); // second argument is "ignoreVersions"
} else {
$newBlockDisplayOrder = $this->getCollectionAreaDisplayOrder($arHandle);
}
$qb = $db->createQueryBuilder();
$cbRelationID = (int) $qb->select('max(cbRelationID)')->from('CollectionVersionBlocks')
->execute()->fetchColumn();
if (!$cbRelationID) {
$cbRelationID = 1;
} else {
++$cbRelationID;
}
$qb2 = $db->createQueryBuilder();
$res = $qb2->insert('CollectionVersionBlocks')
->setValue('cID', ':cID')
->setValue('cvID', ':cvID')
->setValue('bID', ':bID')
->setValue('arHandle', ':arHandle')
->setValue('cbRelationID', ':cbRelationID')
->setValue('cbDisplayOrder', ':cbDisplayOrder')
->setValue('isOriginal', 1)
->setValue('cbIncludeAll', ':cbIncludeAll')
->setParameter('cID', $cID)
->setParameter('cvID', $vObj->getVersionID())
->setParameter('bID', $nb->getBlockID())
->setParameter('arHandle', $arHandle)
->setParameter('cbRelationID', $cbRelationID)
->setParameter('cbDisplayOrder', $newBlockDisplayOrder)
->setParameter('cbIncludeAll', (int) ($bt->includeAll()))
->execute();
return Block::getByID($nb->getBlockID(), $this, $a);
}
|
Add a new block to a specific area of the currently loaded collection version.
@param \Concrete\Core\Entity\Block\BlockType\BlockType $bt the type of block to be added
@param string|\Concrete\Core\Area\Area $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. Common values are: 'uID' to specify the ID of the author (if not specified: we'll use the current user), 'bName' to specify the block name.
@return \Concrete\Core\Block\Block
|
addBlock
|
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 getCollectionAreaDisplayOrder($arHandle, $ignoreVersions = false)
{
$app = Application::getFacadeApplication();
/** @var Connection $db */
$db = $app->make(Connection::class);
$qb = $db->createQueryBuilder();
$cID = $this->cID;
$cvID = $this->vObj->cvID;
if ($ignoreVersions) {
$qb->select('max(cbDisplayOrder) as cbdis')
->from('CollectionVersionBlocks')
->where('cID = :cID')
->andWhere('arHandle = :arHandle')
->setParameter('cID', $cID)
->setParameter('arHandle', $arHandle);
} else {
$qb->select('max(cbDisplayOrder) as cbdis')
->from('CollectionVersionBlocks')
->where('cID = :cID')
->andWhere('cvID = :cvID')
->andWhere('arHandle = :arHandle')
->setParameter('cID', $cID)
->setParameter('cvID', $cvID)
->setParameter('arHandle', $arHandle);
}
/** @var PDOStatement $r */
$r = $qb->execute();
if ($r) {
if ($r->rowCount() > 0) {
// then we know we got a value; we increment it and return
$res = $r->fetchAssociative();
$displayOrder = $res['cbdis'];
if ($displayOrder === null) {
return 0;
}
++$displayOrder;
return $displayOrder;
} else {
// we didn't get anything, so we return a zero
return 0;
}
}
}
|
Get the next value of the display order (to be used when adding new blocks to an area).
@param string $arHandle The handle of the area
@param bool $ignoreVersions Set to true to ignore the collection version
@return int
|
getCollectionAreaDisplayOrder
|
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 rescanDisplayOrder($arHandle)
{
// this collection function f
$cID = $this->cID;
$cvID = $this->vObj->cvID;
$app = Application::getFacadeApplication();
/** @var Connection $db */
$db = $app->make(Connection::class);
$qb = $db->createQueryBuilder();
$r = $qb->select('bID')
->from('CollectionVersionBlocks')
->where('cID = :cID')
->andWhere('cvID = :cvID')
->andWhere('arHandle = :arHandle')
->orderBy('cbDisplayOrder', 'asc')
->setParameter('cID', $cID)
->setParameter('cvID', $cvID)
->setParameter('arHandle', $arHandle)
->execute();
if ($r) {
$displayOrder = 0;
while ($row = $r->fetch()) {
$qb2 = $db->createQueryBuilder();
$qb2->update('CollectionVersionBlocks')
->set('cbDisplayOrder', ':cbDisplayOrder')
->where('cID = :cID')
->andWhere('cvID = :cvID')
->andWhere('arHandle = :arHandle')
->andWhere('bID = :bID')
->setParameter('cbDisplayOrder', $displayOrder)
->setParameter('cID', $cID)
->setParameter('cvID', $cvID)
->setParameter('arHandle', $arHandle)
->setParameter('bID', $row['bID'])
->execute();
++$displayOrder;
}
}
}
|
Fix the display order properties for all the blocks within the collection/area.
@param string $arHandle the handle of the area to be processed
|
rescanDisplayOrder
|
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 rescanDisplayOrderFromBlock(Block $block, string $arHandle, ?int $fromDisplay = null)
{
/** This block doesnt have a display order */
if ($block->getBlockDisplayOrder() === null) {
return $this->rescanDisplayOrder($arHandle);
}
$fromDisplay = $fromDisplay ?? $block->getBlockDisplayOrder();
$cID = $this->cID;
$cvID = $this->vObj->cvID;
$app = Application::getFacadeApplication();
/** @var Connection $db */
$db = $app->make(Connection::class);
$qb = $db->createQueryBuilder();
$r =$qb->select('bID')
->from('CollectionVersionBlocks')
->where('cID = :cID')
->andWhere('cvID = :cvID')
->andWhere('bID != :bID')
->andWhere('cbDisplayOrder >= :cbDisplay')
->andWhere('arHandle = :arHandle')
->orderBy('cbDisplayOrder', 'asc')
->setParameter('cbDisplay', $fromDisplay)
->setParameter('bID', $block->getBlockID())
->setParameter('cID', $cID)
->setParameter('cvID', $cvID)
->setParameter('arHandle', $arHandle)
->execute();
if ($r) {
$currentDisplayOrder = $block->getBlockDisplayOrder();
$displayOrder = $fromDisplay;
while ($row = $r->fetchAssociative()) {
if ($displayOrder === $currentDisplayOrder) {
// Skip our blocks display order
$displayOrder++;
}
$qb2 = $db->createQueryBuilder();
$qb2->update('CollectionVersionBlocks')
->set('cbDisplayOrder', ':cbDisplayOrder')
->where('cID = :cID')
->andWhere('cvID = :cvID')
->andWhere('arHandle = :arHandle')
->andWhere('bID = :bID')
->setParameter('cbDisplayOrder', $displayOrder)
->setParameter('cID', $cID)
->setParameter('cvID', $cvID)
->setParameter('arHandle', $arHandle)
->setParameter('bID', $row['bID'])
->execute();
++$displayOrder;
}
}
}
|
Fix the display order properties for all the blocks after this block in this area.
This is useful for forcing a certain block order.
@param Block $block the block to begin the display order rescan from
@param string $arHandle the handle of the area to be processed
@param int|null $fromDisplay an optional integer to override the starting number,
i.e start from 0 even though our block is 8
@return void
@throws \Doctrine\DBAL\Driver\Exception|\Doctrine\DBAL\Exception
@throws \Illuminate\Contracts\Container\BindingResolutionException
|
rescanDisplayOrderFromBlock
|
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 markModified()
{
// marks this collection as newly modified
$app = Application::getFacadeApplication();
/** @var Connection $db */
$db = $app->make(Connection::class);
$dh = Loader::helper('date');
$cDateModified = $dh->getOverridableNow();
$qb = $db->createQueryBuilder();
$res = $qb->update('Collections')
->set('cDateModified', ':cDateModified')
->where('cID = :cID')
->setParameter('cDateModified', $cDateModified)
->setParameter('cID', $this->getCollectionID())
->execute();
}
|
Update the last edit date/time.
|
markModified
|
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 delete()
{
if ($this->cID > 0) {
$app = Application::getFacadeApplication();
/** @var Connection $db */
$db = $app->make(Connection::class);
// First we delete all versions
$vl = new VersionList($this);
$vl->setItemsPerPage(-1);
$vlArray = $vl->getPage();
foreach ($vlArray as $v) {
$v->delete();
}
$cID = $this->getCollectionID();
$qb = $db->createQueryBuilder();
$qb->delete('CollectionAttributeValues')
->where('cID = :cID')
->setParameter('cID', $cID)
->execute();
$qb = $db->createQueryBuilder();
$qb->delete('Collections')
->where('cID = :cID')
->setParameter('cID', $cID)
->execute();
try {
$qb = $db->createQueryBuilder();
$qb->delete('CollectionSearchIndexAttributes')
->where('cID = :cID')
->setParameter('cID', $cID)
->execute();
} catch (\Exception $e) {
}
}
}
|
Delete this collection, and all its versions, contents and attributes.
|
delete
|
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 duplicateCollection()
{
$app = Application::getFacadeApplication();
$cloner = $app->make(Cloner::class);
$clonerOptions = $app->build(ClonerOptions::class)->setKeepOriginalAuthor(true);
$newCollection = $cloner->cloneCollection($this, $clonerOptions);
return $newCollection;
}
|
Create a clone of this collection, and all its versions, contents and attributes.
@return \Concrete\Core\Page\Collection\Collection
|
duplicateCollection
|
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 cloneVersion($versionComments, $createEmpty = false)
{
$app = Application::getFacadeApplication();
$cloner = $app->make(Cloner::class);
$clonerOptions = $app->make(ClonerOptions::class)
->setVersionComments($versionComments)
->setCopyContents($createEmpty ? false : true)
;
$newVersion = $cloner->cloneCollectionVersion($this->getVersionObject(), $this, $clonerOptions);
return Page::getByID($newVersion->getCollectionID(), $newVersion->getVersionID());
}
|
Clone the currently loaded version and returns a Page instance containing the new version.
@param string|null $versionComments the comments to be associated to the new Version
@param bool $createEmpty set to true to create a Version without any blocks/area styles, false to clone them too
@return \Concrete\Core\Page\Page
|
cloneVersion
|
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 getAttributeValue($ak)
{
return $this->getAttributeValueObject($ak);
}
|
@deprecated Use of getAttributeValueObject()
@param string|\Concrete\Core\Attribute\Key\CollectionKey $ak
@return \Concrete\Core\Entity\Attribute\Value\PageValue|null
|
getAttributeValue
|
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 getCollectionAttributeValue($akHandle)
{
return $this->getAttribute($akHandle);
}
|
@deprecated use the getAttribute() method
@param string|\Concrete\Core\Attribute\Key\CollectionKey $akHandle
@return mixed|null
|
getCollectionAttributeValue
|
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 __construct(?StickyRequest $req = null)
{
parent::__construct($req);
}
|
@param \Concrete\Core\Search\StickyRequest|null $req
|
__construct
|
php
|
concretecms/concretecms
|
concrete/src/Page/Collection/Version/GlobalVersionList.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Collection/Version/GlobalVersionList.php
|
MIT
|
public function getResult($queryRow)
{
$version = new Version();
$version->setPropertiesFromArray($queryRow);
return $version;
}
|
@param array $queryRow
@return \Concrete\Core\Page\Collection\Version\Version
|
getResult
|
php
|
concretecms/concretecms
|
concrete/src/Page/Collection/Version/GlobalVersionList.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Collection/Version/GlobalVersionList.php
|
MIT
|
public function filterByApprovedAfter(\DateTime $date)
{
$this->query->andWhere(
'cv.cvDateApproved >= ' . $this->query->createNamedParameter($date->format('Y-m-d H:i-s'))
);
}
|
Filter versions that are approved after a certain date.
@param \DateTime $date
|
filterByApprovedAfter
|
php
|
concretecms/concretecms
|
concrete/src/Page/Collection/Version/GlobalVersionList.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Collection/Version/GlobalVersionList.php
|
MIT
|
public function filterByApprovedBefore(\DateTime $date)
{
$this->query->andWhere(
'cv.cvDateApproved <= ' . $this->query->createNamedParameter($date->format('Y-m-d H:i-s'))
);
}
|
Filter versions that are approved before a certain date.
@param \DateTime $date
|
filterByApprovedBefore
|
php
|
concretecms/concretecms
|
concrete/src/Page/Collection/Version/GlobalVersionList.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Collection/Version/GlobalVersionList.php
|
MIT
|
public function sortByDateApprovedDesc()
{
$this->sortBy('cv.cvDateApproved', 'desc');
}
|
Sort by approval date in descending order.
|
sortByDateApprovedDesc
|
php
|
concretecms/concretecms
|
concrete/src/Page/Collection/Version/GlobalVersionList.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Collection/Version/GlobalVersionList.php
|
MIT
|
public function getPermissionObjectIdentifier()
{
return $this->getCollectionID() . ':' . $this->getVersionID();
}
|
{@inheritdoc}
@see \Concrete\Core\Permission\ObjectInterface::getPermissionObjectIdentifier()
|
getPermissionObjectIdentifier
|
php
|
concretecms/concretecms
|
concrete/src/Page/Collection/Version/Version.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Collection/Version/Version.php
|
MIT
|
public function getPermissionResponseClassName()
{
return '\\Concrete\\Core\\Permission\\Response\\CollectionVersionResponse';
}
|
{@inheritdoc}
@see \Concrete\Core\Permission\ObjectInterface::getPermissionResponseClassName()
|
getPermissionResponseClassName
|
php
|
concretecms/concretecms
|
concrete/src/Page/Collection/Version/Version.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Collection/Version/Version.php
|
MIT
|
public function getPermissionAssignmentClassName()
{
return '\\Concrete\\Core\\Permission\\Assignment\\PageAssignment';
}
|
{@inheritdoc}
@see \Concrete\Core\Permission\ObjectInterface::getPermissionAssignmentClassName()
|
getPermissionAssignmentClassName
|
php
|
concretecms/concretecms
|
concrete/src/Page/Collection/Version/Version.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Collection/Version/Version.php
|
MIT
|
public function getPermissionObjectKeyCategoryHandle()
{
return 'page';
}
|
{@inheritdoc}
@see \Concrete\Core\Permission\ObjectInterface::getPermissionObjectKeyCategoryHandle()
|
getPermissionObjectKeyCategoryHandle
|
php
|
concretecms/concretecms
|
concrete/src/Page/Collection/Version/Version.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Collection/Version/Version.php
|
MIT
|
public function refreshCache()
{
$app = Facade::getFacadeApplication();
$cache = $app->make('cache/request');
if ($cache->isEnabled()) {
$cache->delete('page/'.$this->getCollectionID());
}
}
|
Clear the cache for this collection.
|
refreshCache
|
php
|
concretecms/concretecms
|
concrete/src/Page/Collection/Version/Version.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Collection/Version/Version.php
|
MIT
|
public static function get($c, $cvID)
{
$app = Facade::getFacadeApplication();
/** @var RequestCache $cache */
$cache = $app->make('cache/request');
$key = '/Page/Collection/' . $c->getCollectionID() . '/Version/' . $cvID;
if ($cache->isEnabled()) {
$item = $cache->getItem($key);
if ($item->isHit()) {
return $item->get();
}
}
$db = $app->make('database')->connection();
$now = $app->make('date')->getOverridableNow();
$cID = false;
if ($c instanceof \Concrete\Core\Page\Page) {
$cID = $c->getCollectionPointerID();
}
if (!$cID) {
$cID = $c->getCollectionID();
}
$v = array($cID);
$q = "select * from CollectionVersions where cID = ?";
switch ($cvID) {
case 'ACTIVE':
$q .= ' and cvIsApproved = 1 and (cvPublishDate is null or cvPublishDate <= ?) and (cvPublishEndDate is null or cvPublishEndDate >= ?) order by cvPublishDate desc limit 1';
$v[] = $now;
$v[] = $now;
break;
case 'SCHEDULED':
$q .= ' and cvIsApproved = 1 and (cvPublishDate is not null and cvPublishDate > ?) order by cvPublishDate limit 1';
$v[] = $now;
break;
case 'RECENT':
$q .= ' order by cvID desc limit 1';
break;
case 'RECENT_UNAPPROVED':
$q .= 'and (cvIsApproved = 0 or cvIsApproved IS NULL) order by cvID desc limit 1';
break;
default:
$v[] = $cvID;
$q .= ' and cvID = ?';
break;
}
$row = $db->fetchAssoc($q, $v);
$cv = new static();
if ($row !== false) {
$cv->setPropertiesFromArray($row);
} else {
$cv->loadError(VERSION_NOT_FOUND);
}
$cv->cID = $c->getCollectionID();
if (isset($item) && $item->isMiss()) {
$item->set($cv);
$cache->save($item);
}
return $cv;
}
|
Get a Version instance given the Collection and a version identifier.
@param \Concrete\Core\Page\Collection\Collection $c the collection for which you want the version
@param int|string $cvID the specific version ID (or 'ACTIVE', 'SCHEDULED', 'RECENT')
@return static
|
get
|
php
|
concretecms/concretecms
|
concrete/src/Page/Collection/Version/Version.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Collection/Version/Version.php
|
MIT
|
public function getObjectAttributeCategory()
{
$app = Facade::getFacadeApplication();
return $app->make('\Concrete\Core\Attribute\Category\PageCategory');
}
|
{@inheritdoc}
@see \Concrete\Core\Attribute\ObjectInterface::getObjectAttributeCategory()
@return \Concrete\Core\Attribute\Category\PageCategory
|
getObjectAttributeCategory
|
php
|
concretecms/concretecms
|
concrete/src/Page/Collection/Version/Version.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Collection/Version/Version.php
|
MIT
|
public function getAttributeValueObject($ak, $createIfNotExists = false)
{
if (!is_object($ak)) {
$ak = CollectionKey::getByHandle($ak);
}
$value = false;
if (is_object($ak)) {
$value = $this->getObjectAttributeCategory()->getAttributeValue($ak, $this);
}
if ($value) {
return $value;
} elseif ($createIfNotExists) {
$attributeValue = new PageValue();
$attributeValue->setPageID($this->getCollectionID());
$attributeValue->setVersionID($this->getVersionID());
$attributeValue->setAttributeKey($ak);
return $attributeValue;
}
}
|
{@inheritdoc}
@see \Concrete\Core\Attribute\ObjectInterface::getAttributeValueObject()
@return \Concrete\Core\Entity\Attribute\Value\PageValue|null
|
getAttributeValueObject
|
php
|
concretecms/concretecms
|
concrete/src/Page/Collection/Version/Version.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Collection/Version/Version.php
|
MIT
|
public function isApproved()
{
return $this->cvIsApproved;
}
|
Is this version approved?
@return bool|int|string
@see isApprovedNow()
|
isApproved
|
php
|
concretecms/concretecms
|
concrete/src/Page/Collection/Version/Version.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Collection/Version/Version.php
|
MIT
|
public function isApprovedNow($when = null)
{
if (!$this->isApproved()) {
return false;
}
$start = $this->getPublishDate();
$end = $this->getPublishEndDate();
if (!$start && !$end) {
return true;
}
$dh = Facade::getFacadeApplication()->make('date');
if ($when) {
$when = $dh->toDB($when);
}
if (!$when) {
$when = $dh->getOverridableNow();
}
if ($start && $start > $when) {
return false;
}
if ($end && $end < $when) {
return false;
}
return true;
}
|
Is this version approved and in the publish interval?
@var string|int|\DateTime|null $when a date/time representation (empty: now)
@return bool
|
isApprovedNow
|
php
|
concretecms/concretecms
|
concrete/src/Page/Collection/Version/Version.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Collection/Version/Version.php
|
MIT
|
public function getPublishDate()
{
return $this->cvPublishDate;
}
|
Get the scheduled date/time when the collection is published: start.
@return string|null
@example '2018-21-31 23:59:59'
|
getPublishDate
|
php
|
concretecms/concretecms
|
concrete/src/Page/Collection/Version/Version.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Collection/Version/Version.php
|
MIT
|
public function getPublishEndDate()
{
return $this->cvPublishEndDate;
}
|
Get the scheduled date/time when the collection is published: end.
@return string|null
@example '2018-21-31 23:59:59'
|
getPublishEndDate
|
php
|
concretecms/concretecms
|
concrete/src/Page/Collection/Version/Version.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Collection/Version/Version.php
|
MIT
|
public function isMostRecent()
{
if (!isset($this->isMostRecent)) {
$app = Facade::getFacadeApplication();
$db = $app->make('database')->connection();
$cvID = $db->fetchColumn('select cvID from CollectionVersions where cID = ? order by cvID desc', array($this->cID));
$this->isMostRecent = ($cvID == $this->cvID);
}
return $this->isMostRecent;
}
|
Is this the most recent version?
@return bool
|
isMostRecent
|
php
|
concretecms/concretecms
|
concrete/src/Page/Collection/Version/Version.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Collection/Version/Version.php
|
MIT
|
public function isNew()
{
return $this->cvIsNew;
}
|
Is this a new version?
@return bool|number|string
|
isNew
|
php
|
concretecms/concretecms
|
concrete/src/Page/Collection/Version/Version.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Collection/Version/Version.php
|
MIT
|
public function getVersionID()
{
return $this->cvID;
}
|
Get the collection version ID.
@return int|string
|
getVersionID
|
php
|
concretecms/concretecms
|
concrete/src/Page/Collection/Version/Version.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Collection/Version/Version.php
|
MIT
|
public function getCollectionID()
{
return $this->cID;
}
|
Get the collection ID.
@return int
|
getCollectionID
|
php
|
concretecms/concretecms
|
concrete/src/Page/Collection/Version/Version.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Collection/Version/Version.php
|
MIT
|
public function getVersionName()
{
return $this->cvName;
}
|
The collection version name.
@return string|null
|
getVersionName
|
php
|
concretecms/concretecms
|
concrete/src/Page/Collection/Version/Version.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Collection/Version/Version.php
|
MIT
|
public function getVersionComments($sanitize = true)
{
return $sanitize ? h($this->cvComments) : $this->cvComments;
}
|
Get the collection version comments.
@return string|null
|
getVersionComments
|
php
|
concretecms/concretecms
|
concrete/src/Page/Collection/Version/Version.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Collection/Version/Version.php
|
MIT
|
public function getVersionAuthorUserID()
{
return $this->cvAuthorUID;
}
|
Get the ID of the user that created this collection version.
@return int|string|null
|
getVersionAuthorUserID
|
php
|
concretecms/concretecms
|
concrete/src/Page/Collection/Version/Version.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Collection/Version/Version.php
|
MIT
|
public function getVersionApproverUserID()
{
return $this->cvApproverUID;
}
|
Get the ID of the user that approved this collection version.
@return int|string|null
|
getVersionApproverUserID
|
php
|
concretecms/concretecms
|
concrete/src/Page/Collection/Version/Version.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Collection/Version/Version.php
|
MIT
|
public function getVersionAuthorUserName()
{
if ($this->cvAuthorUID > 0) {
$app = Facade::getFacadeApplication();
$db = $app->make('database')->connection();
return $db->fetchColumn('select uName from Users where uID = ?', array(
$this->cvAuthorUID,
));
}
}
|
Get the name of the user that approved this collection version.
@return string|null|false return NULL if there's no author, false if it has been deleted, or a string otherwise
|
getVersionAuthorUserName
|
php
|
concretecms/concretecms
|
concrete/src/Page/Collection/Version/Version.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Collection/Version/Version.php
|
MIT
|
public function getVersionApproverUserName()
{
if ($this->cvApproverUID > 0) {
$app = Facade::getFacadeApplication();
$db = $app->make('database')->connection();
return $db->fetchColumn('select uName from Users where uID = ?', array(
$this->cvApproverUID,
));
}
}
|
Get the name of the user that approved this collection version.
@return string|null|false return NULL if there's no author, false if it has been deleted, or a string otherwise
|
getVersionApproverUserName
|
php
|
concretecms/concretecms
|
concrete/src/Page/Collection/Version/Version.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Collection/Version/Version.php
|
MIT
|
public function getCustomAreaStyles()
{
if (!isset($this->customAreaStyles)) {
$app = Facade::getFacadeApplication();
/** @var AreaCustomStyleRepository $customAreaStyleRepository */
$customAreaStyleRepository = $app->make(AreaCustomStyleRepository::class);
$this->customAreaStyles = $customAreaStyleRepository->getCollectionVersionAreaStyleIDs($this);
}
return $this->customAreaStyles;
}
|
Get the custom area style IDs.
@return array key: area handle, value: the inline stle set ID
|
getCustomAreaStyles
|
php
|
concretecms/concretecms
|
concrete/src/Page/Collection/Version/Version.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Collection/Version/Version.php
|
MIT
|
public function getVersionDateCreated()
{
return $this->cvDateCreated;
}
|
Get the date/time when the collection version was created.
@return string|null
@example '2018-21-31 23:59:59'
|
getVersionDateCreated
|
php
|
concretecms/concretecms
|
concrete/src/Page/Collection/Version/Version.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Collection/Version/Version.php
|
MIT
|
public function getVersionDateApproved()
{
return $this->cvDateApproved;
}
|
Get the date the collection version was approved.
@return string|null
@example '2018-21-31 23:59:59'
|
getVersionDateApproved
|
php
|
concretecms/concretecms
|
concrete/src/Page/Collection/Version/Version.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Collection/Version/Version.php
|
MIT
|
public function setComment($comment)
{
$thisCVID = $this->getVersionID();
$comment = ($comment != null) ? $comment : "Version {$thisCVID}";
$v = array(
$comment,
$thisCVID,
$this->cID,
);
$app = Facade::getFacadeApplication();
$db = $app->make('database')->connection();
$q = "update CollectionVersions set cvComments = ? where cvID = ? and cID = ?";
$db->executeQuery($q, $v);
$this->cvComments = $comment;
}
|
Set the collection version comments.
@param string $comment
|
setComment
|
php
|
concretecms/concretecms
|
concrete/src/Page/Collection/Version/Version.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Collection/Version/Version.php
|
MIT
|
public function setPublishDate($publishDate)
{
$this->setPublishInterval($publishDate, $this->getPublishEndDate());
}
|
Set the scheduled date/time when the collection is published: start.
@param string|\DateTime|int|null $publishDate the scheduled date/time when the collection is published (start)
@throws \Concrete\Core\Error\UserMessageException if the start of the publish date/time is its end.
|
setPublishDate
|
php
|
concretecms/concretecms
|
concrete/src/Page/Collection/Version/Version.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Collection/Version/Version.php
|
MIT
|
public function setPublishEndDate($publishEndDate)
{
$this->setPublishInterval($this->getPublishDate(), $publishEndDate);
}
|
Set the scheduled date/time when the collection is published: end.
@param string|\DateTime|int|null $publishEndDate the scheduled date/time when the collection is published (end)
@throws \Concrete\Core\Error\UserMessageException if the start of the publish date/time is its end.
|
setPublishEndDate
|
php
|
concretecms/concretecms
|
concrete/src/Page/Collection/Version/Version.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Collection/Version/Version.php
|
MIT
|
public function setPublishInterval($startDateTime, $endDateTime)
{
$app = Facade::getFacadeApplication();
$dh = $app->make('helper/date');
$startDateTime = $dh->toDB($startDateTime) ?: null;
$endDateTime = $dh->toDB($endDateTime) ?: null;
if ($startDateTime && $endDateTime && $startDateTime > $endDateTime) {
throw new UserMessageException(t('The initial date/time must be before the final date/time.'));
}
$db = $app->make(Connection::class);
$db->update(
'CollectionVersions',
[
'cvPublishDate' => $startDateTime,
'cvPublishEndDate' => $endDateTime,
],
[
'cID' => $this->getCollectionID(),
'cvID' => $this->getVersionID(),
]
);
$this->cvPublishDate = $startDateTime;
$this->cvPublishEndDate = $endDateTime;
}
|
Set the scheduled date/time when the collection is published.
@param string|\DateTime|int|null $startDateTime the scheduled date/time when the collection is published (start)
@param string|\DateTime|int|null $endDateTime the scheduled date/time when the collection is published (end)
@throws \Concrete\Core\Error\UserMessageException if the start of the publish date/time is its end.
|
setPublishInterval
|
php
|
concretecms/concretecms
|
concrete/src/Page/Collection/Version/Version.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Collection/Version/Version.php
|
MIT
|
public function createNew($versionComments)
{
$app = Facade::getFacadeApplication();
$cloner = $app->make(Cloner::class);
$clonerOptions = $app->build(ClonerOptions::class)
->setCopyContents(false)
->setVersionComments($versionComments)
;
$myCollection = Page::getByID($this->getCollectionID());
$newVersion = $cloner->cloneCollectionVersion($this, $myCollection, $clonerOptions);
return $newVersion;
}
|
Create a new version for the same collection as this collection version.
@param string $versionComments the new collection version comments
@return \Concrete\Core\Page\Collection\Version\Version
|
createNew
|
php
|
concretecms/concretecms
|
concrete/src/Page/Collection/Version/Version.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Collection/Version/Version.php
|
MIT
|
public function approve($doReindexImmediately = true, $cvPublishDate = null, $cvPublishEndDate = null, bool $keepOtherScheduling = false)
{
$app = Facade::getFacadeApplication();
/** @var Connection $db */
$db = $app->make(Connection::class);
/** @var Date $dh */
$dh = $app->make('helper/date');
$u = $app->make(User::class);
$uID = $u->getUserID();
$cvID = $this->getVersionID();
$cID = $this->getCollectionID();
$now = $dh->getOverridableNow();
$cvPublishDate = $dh->toDB($cvPublishDate) ?: null;
$cvPublishEndDate = $dh->toDB($cvPublishEndDate) ?: null;
if ($cvPublishDate !== null && $cvPublishEndDate !== null && $cvPublishDate > $cvPublishEndDate) {
throw new UserMessageException(t('The initial date/time must be before the final date/time.'));
}
$pageWithActiveVersion = Page::getByID($cID, 'ACTIVE');
$oldHandle = $pageWithActiveVersion->getCollectionHandle();
$newHandle = $this->cvHandle;
// update a collection updated record
$this->updateCollectionDateModified();
// disapprove other versions
$disapproveVersionsQuery = $db->createQueryBuilder();
$disapproveVersionsQuery->update('CollectionVersions')
->set('cvIsApproved', ':cvIsApproved')
->where('cID = :cID')
->andWhere('cvIsApproved = 1')
->setParameter('cvIsApproved', 0)
->setParameter('cID', $cID);
if ($keepOtherScheduling && ($cvPublishDate || $cvPublishEndDate)) {
// We can disapprove live versions only their scheduling is already end
$expr = $disapproveVersionsQuery->expr();
$disapproveVersionsQuery->andWhere($expr->and($expr->isNotNull('cvPublishEndDate'), $expr->lte('cvPublishEndDate', ':now')));
$disapproveVersionsQuery->setParameter(':now', $dh->getOverridableNow());
}
$disapproveVersionsQuery->execute();
$pageWithActiveVersion->refreshCache();
// now we approve our version
$db->update(
'CollectionVersions',
[
'cvIsNew' => 0,
'cvIsApproved' => 1,
'cvApproverUID' => $uID,
'cvDateApproved' => $now,
'cvPublishDate' => $cvPublishDate,
'cvPublishEndDate' => $cvPublishEndDate,
],
[
'cID' => $cID,
'cvID' => $cvID,
]
);
$this->cvIsNew = 0;
$this->cvIsApproved = 1;
$this->cvApproverUID = $uID;
$this->cvDateApproved = $now;
$this->cvPublishDate = $cvPublishDate;
$this->cvPublishEndDate = $cvPublishEndDate;
$c = Page::getByID($cID, $cvID);
// next, we rescan our collection paths for the particular collection, but only if this isn't a generated collection
if ($oldHandle != $newHandle && !$c->isGeneratedCollection()) {
$c->rescanCollectionPath();
}
// check for related version edits. This only gets applied when we edit global areas.
$r = $db->executeQuery(
'select cRelationID, cvRelationID from CollectionVersionRelatedEdits where cID = ? and cvID = ?',
[$cID, $cvID]
);
while (($row = $r->fetch()) !== false) {
$cn = Page::getByID($row['cRelationID'], $row['cvRelationID']);
$cnp = new Checker($cn);
if ($cnp->canApprovePageVersions()) {
$v = $cn->getVersionObject();
$v->approve();
$db->delete(
'CollectionVersionRelatedEdits',
[
'cID' => $cID,
'cvID' => $cvID,
'cRelationID' => $row['cRelationID'],
'cvRelationID' => $row['cvRelationID'],
]
);
}
}
if ($c->getCollectionInheritance() == 'TEMPLATE') {
// we make sure to update the cInheritPermissionsFromCID value
$pType = PageType::getByID($c->getPageTypeID());
$masterC = $pType->getPageTypePageTemplateDefaultPageObject();
$db->executeQuery(
'update Pages set cInheritPermissionsFromCID = ? where cID = ?',
[(int) $masterC->getCollectionID(), $c->getCollectionID()]
);
}
if ($pageWithActiveVersion && $pageWithActiveVersion->getVersionObject() && !$pageWithActiveVersion->getVersionObject()->isError()) {
$c->reindex($doReindexImmediately);
$app->executeCommand(new RefreshRelevantBoardInstancesCommand('page', $c));
} else {
// This is a new page
$c->reindex(true); // We must reindex immediately so that summary templates are available for boards.
$app->executeCommand(new RegenerateRelevantBoardInstancesCommand('page', $c));
}
$ev = new Event($c);
$ev->setUser($u);
$ev->setCollectionVersionObject($this);
$app->make('director')->dispatch('on_page_version_approve', $ev);
$this->refreshCache();
}
|
Approve this collection version.
@param bool $doReindexImmediately reindex the collection contents now? Otherwise it's reindexing will just be scheduled
@param string|\DateTime|int|null $cvPublishDate the scheduled date/time when the collection is published (start)
@param string|\DateTime|int|null $cvPublishEndDate the scheduled date/time when the collection is published (end)
@param bool $keepOtherScheduling Set to true to keep scheduling of other versions
(e.g., users can view the current live version until the publish date of this version).
Set to false (default) to disapprove all other versions
(e.g., users can't see this page until the publish date of this version, even if this page is live now).
@since 9.0.0 Added $keepOtherScheduling argument
@throws \Concrete\Core\Error\UserMessageException if the start of the publish date/time is its end.
|
approve
|
php
|
concretecms/concretecms
|
concrete/src/Page/Collection/Version/Version.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Collection/Version/Version.php
|
MIT
|
public function discard()
{
if ($this->isNew()) {
$app = Facade::getFacadeApplication();
$db = $app->make('database')->connection();
// check for related version edits. This only gets applied when we edit global areas.
$r = $db->executeQuery('select cRelationID, cvRelationID from CollectionVersionRelatedEdits where cID = ? and cvID = ?', array(
$this->cID,
$this->cvID,
));
while ($row = $r->fetch()) {
$cn = Page::getByID($row['cRelationID'], $row['cvRelationID']);
$cnp = new Permissions($cn);
if ($cnp->canApprovePageVersions()) {
$v = $cn->getVersionObject();
$v->delete();
$db->executeQuery('delete from CollectionVersionRelatedEdits where cID = ? and cvID = ? and cRelationID = ? and cvRelationID = ?', array(
$this->cID,
$this->cvID,
$row['cRelationID'],
$row['cvRelationID'],
));
}
}
$this->delete();
}
$this->refreshCache();
}
|
Discard my most recent edit that is pending.
|
discard
|
php
|
concretecms/concretecms
|
concrete/src/Page/Collection/Version/Version.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Collection/Version/Version.php
|
MIT
|
public function canDiscard()
{
$result = false;
if ($this->isNew()) {
$app = Facade::getFacadeApplication();
$db = $app->make('database')->connection();
$total = $db->fetchColumn('select count(cvID) from CollectionVersions where cID = ?', array(
$this->cID,
));
if ($total > 1) {
$result = true;
}
}
return $result;
}
|
Check if this collection version can be discarded.
@return bool
|
canDiscard
|
php
|
concretecms/concretecms
|
concrete/src/Page/Collection/Version/Version.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Collection/Version/Version.php
|
MIT
|
public function removeNewStatus()
{
$app = Facade::getFacadeApplication();
$db = $app->make('database')->connection();
$db->executeQuery("update CollectionVersions set cvIsNew = 0 where cID = ? and cvID = ?", array(
$this->cID,
$this->cvID,
));
$this->refreshCache();
}
|
Mark this collection version as not new.
|
removeNewStatus
|
php
|
concretecms/concretecms
|
concrete/src/Page/Collection/Version/Version.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Collection/Version/Version.php
|
MIT
|
public function deny(): void
{
$app = Facade::getFacadeApplication();
$cvID = $this->getVersionID();
$cID = $this->getCollectionID();
// first we update a collection updated record
$this->updateCollectionDateModified();
// now we deny our version
/** @var QueryBuilder $qb */
$qb = $app->make(Connection::class)->createQueryBuilder();
$qb->update('CollectionVersions')
->set('cvIsApproved', ':cvIsApproved')
->set('cvApproverUID', ':cvApproverUID')
->where('cID = :cID')
->andWhere('cvID = :cvID')
->setParameter('cvIsApproved', 0)
->setParameter('cvApproverUID', 0)
->setParameter('cID', $cID)
->setParameter('cvID', $cvID)
->execute();
$this->refreshCache();
}
|
Mark this collection version as not approved.
|
deny
|
php
|
concretecms/concretecms
|
concrete/src/Page/Collection/Version/Version.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Collection/Version/Version.php
|
MIT
|
public function delete()
{
$app = Facade::getFacadeApplication();
$db = $app->make('database')->connection();
$cvID = $this->cvID;
$c = Page::getByID($this->cID, $cvID);
$cID = $c->getCollectionID();
$u = $app->make(User::class);
$q = "select bID, arHandle from CollectionVersionBlocks where cID = ? and cvID = ?";
$r = $db->executeQuery($q, array(
$cID,
$cvID,
));
while ($row = $r->fetch()) {
if ($row['bID']) {
$b = Block::getByID($row['bID'], $c, $row['arHandle']);
if (is_object($b)) {
$b->deleteBlock();
}
unset($b);
}
}
$category = $app->make('Concrete\Core\Attribute\Category\PageCategory');
$attributes = $category->getAttributeValues($this);
foreach ($attributes as $attribute) {
$category->deleteValue($attribute);
}
$db->executeQuery('delete from CollectionVersionBlockStyles where cID = ? and cvID = ?', array(
$cID,
$cvID,
));
$db->executeQuery('delete from CollectionVersionThemeCustomStyles where cID = ? and cvID = ?', array(
$cID,
$cvID,
));
$db->executeQuery('delete from CollectionVersionRelatedEdits where cID = ? and cvID = ?', array(
$cID,
$cvID,
));
$db->executeQuery('delete from CollectionVersionAreaStyles where cID = ? and cvID = ?', array(
$cID,
$cvID,
));
$db->executeQuery('delete from PageTypeComposerOutputBlocks where cID = ? and cvID = ?', array(
$cID,
$cvID,
));
$db->executeQuery('delete from CollectionVersionBlocks where cID = ? and cvID = ?', array(
$cID,
$cvID,
));
$q = "delete from CollectionVersions where cID = '{$cID}' and cvID='{$cvID}'";
$db->executeQuery($q);
$this->refreshCache();
$ev = new Event($c);
$ev->setUser($u);
$ev->setCollectionVersionObject($this);
$app->make('director')->dispatch('on_page_version_delete', $ev);
}
|
Delete this version and its related data (blocks, attributes, custom styles, ...).
|
delete
|
php
|
concretecms/concretecms
|
concrete/src/Page/Collection/Version/Version.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Collection/Version/Version.php
|
MIT
|
private function avoidApprovalOverlapping()
{
if (!$this->isApproved()) {
return;
}
$app = Facade::getFacadeApplication();
$db = $app->make('database')->connection();
$dh = $app->make('helper/date');
$qbBase = $db->createQueryBuilder();
$x = $qbBase->expr();
$qbBase->update('CollectionVersions', 'cv')
->andWhere($x->eq('cv.cvIsApproved', 1))
->andWhere($x->eq('cv.cID', $qbBase->createNamedParameter($this->getCollectionID())))
->andWhere($x->neq('cv.cvID', $qbBase->createNamedParameter($this->getVersionID())))
;
$startDate = $this->getPublishDate() ?: null;
$endDate = $this->getPublishEndDate() ?: null;
$changes = [];
// Let's unapprove other approved collection versions whose approval time is all within this collection version
if ($startDate !== null && $endDate !== null) {
// This collection version is published from $startDate until $endDate:
// let's unapprove the other collection versions that start at or after $startDate and end at or before $endDate
$qb = clone $qbBase;
$changes[] = $qb
->set('cv.cvIsApproved', 0)
->andWhere($x->isNotNull('cv.cvPublishDate'))
->andWhere($x->gte('cv.cvPublishDate', $qb->createNamedParameter($startDate)))
->andWhere($x->isNotNull('cv.cvPublishEndDate'))
->andWhere($x->lte('cv.cvPublishEndDate', $qb->createNamedParameter($endDate)))
->execute()
;
} elseif ($startDate !== null) {
// This collection version is published from $startDate until forever:
// let's unapprove the other collection versions that start at or after $startDate
$qb = clone $qbBase;
$changes[] = $qb
->set('cv.cvIsApproved', 0)
->andWhere($x->isNotNull('cv.cvPublishDate'))
->andWhere($x->gte('cv.cvPublishDate', $qb->createNamedParameter($startDate)))
->execute()
;
} elseif ($endDate !== null) {
// This collection version is published from ever until $endDate:
// let's unapprove the other collection versions that end at or before $endDate
$qb = clone $qbBase;
$changes[] = $qb
->set('cv.cvIsApproved', 0)
->andWhere($x->isNotNull('cv.cvPublishEndDate'))
->andWhere($x->lte('cv.cvPublishEndDate', $qb->createNamedParameter($endDate)))
->execute()
;
} else {
// This collection version is published from ever and until forever:
// let's unapprove all the other collection versions
$qb = clone $qbBase;
$changes[] = $qb
->set('cv.cvIsApproved', 0)
->execute()
;
}
if ($endDate != null) {
// This collection version is published until $endDate:
// set the initial date/time of the other collection versions that start and end at or before $endDate
$minOthersStartDate = $endDate ? $dh->toDB(strtotime($endDate) + 1) : null;
$qb = clone $qbBase;
$changes[] = $qb
->set('cv.cvPublishDate', $qb->createNamedParameter($minOthersStartDate))
->andWhere($x->orX(
$x->isNull('cv.cvPublishDate'),
$x->lte('cv.cvPublishDate', $qb->createNamedParameter($endDate))
))
->andWhere($x->orX(
$x->isNull('cv.cvPublishEndDate'),
$x->gte('cv.cvPublishEndDate', $qb->createNamedParameter($minOthersStartDate))
))
->execute()
;
}
if ($startDate !== null) {
// This collection version is published from $startDate
// set the final date/time of the other collection versions that end at or after $startDate
$maxOthersEndDate = $startDate ? $dh->toDB(strtotime($startDate) - 1) : null;
$qb = clone $qbBase;
$changes[] = $qb
->set('cv.cvPublishEndDate', $qb->createNamedParameter($maxOthersEndDate))
->andWhere($x->orX(
$x->isNull('cv.cvPublishEndDate'),
$x->gte('cv.cvPublishEndDate', $qb->createNamedParameter($startDate))
))
->andWhere($x->orX(
$x->isNull('cv.cvPublishDate'),
$x->lte('cv.cvPublishDate', $qb->createNamedParameter($maxOthersEndDate))
))
->execute()
;
}
if (count(array_filter($changes)) > 0) {
$this->refreshCache();
}
}
|
Make sure that other collection versions aren't approved and valid at the same time as this version.
|
avoidApprovalOverlapping
|
php
|
concretecms/concretecms
|
concrete/src/Page/Collection/Version/Version.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Collection/Version/Version.php
|
MIT
|
public function startRender()
{
return;
}
|
Runs when the file is about to be included.
|
startRender
|
php
|
concretecms/concretecms
|
concrete/src/Page/Container/ContainerBlockInstance.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Container/ContainerBlockInstance.php
|
MIT
|
public function endRender()
{
return;
}
|
Runs when render is completed. This way we can trigger area recompute in a performant way.
|
endRender
|
php
|
concretecms/concretecms
|
concrete/src/Page/Container/ContainerBlockInstance.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Container/ContainerBlockInstance.php
|
MIT
|
public function export($instance, \SimpleXMLElement $element)
{
$container = $instance->getContainer();
if ($container) {
$containerNode = $element->addChild('container');
$containerNode->addAttribute('handle', $container->getContainerHandle());
// Retrieve all the areas within this container.
$instanceAreas = $instance->getInstanceAreas();
foreach($instanceAreas as $instanceArea) {
$arHandle = Area::getAreaHandleFromID($instanceArea->getAreaID());
if ($arHandle) {
$containerAreaNode = $containerNode->addChild('containerarea');
$containerAreaNode->addAttribute('name', $instanceArea->getContainerAreaName());
$area = Area::get($this->page, $arHandle);
if ($area) {
$area->export($containerAreaNode, $this->page);
}
}
}
}
}
|
@param Instance $instance
@param \SimpleXMLElement $element
|
export
|
php
|
concretecms/concretecms
|
concrete/src/Page/Container/ContainerExporter.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Container/ContainerExporter.php
|
MIT
|
public function getFileToRender(Page $page, Container $container)
{
$theme = $page->getCollectionThemeObject();
if ($theme) {
$handle = $container->getContainerHandle();
if ($handle) {
$filename = DIRNAME_ELEMENTS . '/' . DIRNAME_CONTAINERS . '/' . $handle . '.php';
$this->themeLocation->setTheme($theme);
$this->fileLocator->addLocation($this->themeLocation);
$record = $this->fileLocator->getRecord($filename);
if ($record->exists()) {
return $record->getFile();
}
}
}
return null;
}
|
@param Page $page
@param Container $container
@return string file
|
getFileToRender
|
php
|
concretecms/concretecms
|
concrete/src/Page/Container/TemplateLocator.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Container/TemplateLocator.php
|
MIT
|
public function useUserLocale()
{
return true;
}
|
{@inheritdoc}
@see \Concrete\Core\Page\Controller\PageController::useUserLocale()
|
useUserLocale
|
php
|
concretecms/concretecms
|
concrete/src/Page/Controller/AccountPageController.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Controller/AccountPageController.php
|
MIT
|
public function renderList()
{
$entity = $this->getCategoryObject();
$category = $entity->getAttributeKeyCategory();
$list = $this->elementManager->get('attribute/key_list');
/**
* @var \Concrete\Controller\Element\Attribute\KeyList $controller
*/
$controller = $list->getElementController();
$controller->setAttributeSets($category->getSetManager()->getAttributeSets());
$controller->setUnassignedAttributeKeys($category->getSetManager()->getUnassignedAttributeKeys());
$controller->setAttributeTypes($category->getAttributeTypes());
$controller->setDashboardPagePath($this->getPageObject()->getCollectionPath());
$controller->setDashboardPageParameters($this->getRequestActionParameters());
if (!$category->getSetManager()->allowAttributeSets()) {
$controller->setEnableSorting(false);
}
$this->set('headerMenu', $this->getHeaderMenu($entity));
$this->set('attributeView', $list);
}
|
Configure the data for the view so that it can render the list of the attributes.
|
renderList
|
php
|
concretecms/concretecms
|
concrete/src/Page/Controller/DashboardAttributesPageController.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Controller/DashboardAttributesPageController.php
|
MIT
|
public function renderAdd($type, $backURL)
{
$add = $this->elementManager->get('attribute/form', ['type' => $type]);
/**
* @var \Concrete\Controller\Element\Attribute\Form $controller
*/
$controller = $add->getElementController();
$controller->setBackButtonURL($backURL);
$controller->setCategory($this->getCategoryObject());
$controller->setDashboardPageParameters($this->getRequestActionParameters());
$this->set('attributeView', $add);
$this->set('pageTitle', t('Add Attribute'));
}
|
Configure the data for the view so that it can render the "Add Attribute" page.
@param \Concrete\Core\Entity\Attribute\Type $type The type of the new attribute
@param \League\Url\UrlInterface|string $backURL the URL to be used when users hit the "Cancel Add" button
|
renderAdd
|
php
|
concretecms/concretecms
|
concrete/src/Page/Controller/DashboardAttributesPageController.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Controller/DashboardAttributesPageController.php
|
MIT
|
public function renderEdit($key, $backURL)
{
$edit = $this->elementManager->get('attribute/edit_key', ['key' => $key]);
/**
* @var \Concrete\Controller\Element\Attribute\EditKey $controller
*/
$controller = $edit->getElementController();
$controller->setBackButtonURL($backURL);
$controller->setCategory($this->getCategoryObject());
$controller->setDashboardPageParameters($this->getRequestActionParameters());
$this->set('attributeView', $edit);
$this->set('pageTitle', t('Edit Attribute'));
$header = $this->elementManager->get('attribute/key_header', ['key' => $key]);
/**
* @var \Concrete\Controller\Element\Attribute\EditKey $headerController
*/
$headerController = $header->getElementController();
$headerController->setDashboardPageParameters($this->getRequestActionParameters());
$this->set('headerMenu', $headerController);
}
|
Configure the data for the view so that it can render the "Edit Attribute" page.
@param \Concrete\Core\Attribute\AttributeKeyInterface $key the key to be modified
@param \League\Url\UrlInterface|string $backURL the URL to be used when users hit the "Cancel Add" button
|
renderEdit
|
php
|
concretecms/concretecms
|
concrete/src/Page/Controller/DashboardAttributesPageController.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Controller/DashboardAttributesPageController.php
|
MIT
|
public function sort_attribute_set()
{
$entity = $this->getCategoryObject();
$category = $entity->getAttributeKeyCategory();
if ($category->getSetManager()->allowAttributeSets()) {
$keys = [];
foreach ((array) $this->request->request->get('akID') as $akID) {
$key = $category->getAttributeKeyByID($akID);
if (is_object($key)) {
$keys[] = $key;
}
}
foreach ($category->getSetManager()->getAttributeSets() as $set) {
if ($set->getAttributeSetID() == $this->request->request->get('asID') && count($keys)) {
// Clear the keys
foreach ($set->getAttributeKeyCollection() as $setKey) {
$this->entityManager->remove($setKey);
}
$this->entityManager->flush();
$i = 0;
foreach ($keys as $key) {
$setKey = new SetKey();
$setKey->setAttributeKey($key);
$setKey->setAttributeSet($set);
$setKey->setDisplayOrder($i);
$set->getAttributeKeyCollection()->add($setKey);
$i++;
}
break;
}
}
$this->entityManager->persist($set);
$this->entityManager->flush();
return new JsonResponse($set);
}
}
|
Sort the attributes belinging to a set, reading the data from the request.
@return \Symfony\Component\HttpFoundation\JsonResponse
|
sort_attribute_set
|
php
|
concretecms/concretecms
|
concrete/src/Page/Controller/DashboardAttributesPageController.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Controller/DashboardAttributesPageController.php
|
MIT
|
protected function getHeaderMenu(CategoryObjectInterface $category)
{
return $this->elementManager->get('attribute/standard_list_header', ['category' => $category])->getElementController();
}
|
Get the controller of the element to be placed in the header of the "Attribute List" page.
@param \Concrete\Core\Attribute\CategoryObjectInterface $category
@return \Concrete\Core\Controller\ElementController|null
|
getHeaderMenu
|
php
|
concretecms/concretecms
|
concrete/src/Page/Controller/DashboardAttributesPageController.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Controller/DashboardAttributesPageController.php
|
MIT
|
protected function executeAdd(Type $type, $successURL, $onComplete = null)
{
$entity = $this->getCategoryObject();
$category = $entity->getAttributeKeyCategory();
$validator = $type->getController()->getValidator();
$response = $validator->validateAddKeyRequest($category, $type, $this->request);
if (!$response->isValid()) {
$this->error = $response->getErrorObject();
} else {
$key = $category->addFromRequest($type, $this->request);
$this->assignToSetFromRequest($key);
if ($onComplete instanceof \Closure) {
$onComplete();
}
$this->flash('success', t('Attribute created successfully.'));
$this->buildRedirect($successURL)->send();
$this->app->shutdown();
}
}
|
Create a new attribute key for the specified type, reading the type-specific data from the current request.
@param \Concrete\Core\Entity\Attribute\Type $type the type of the attribute to be created
@param \League\Url\UrlInterface|string $successURL where to redirect the users when the operation succeedes
@param callable|null $onComplete a callback function that's called right after the new attribute key is created
|
executeAdd
|
php
|
concretecms/concretecms
|
concrete/src/Page/Controller/DashboardAttributesPageController.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Controller/DashboardAttributesPageController.php
|
MIT
|
protected function assignToSetFromRequest(AttributeKeyInterface $key)
{
$request = $this->request;
$entity = $this->getCategoryObject();
$category = $entity->getAttributeKeyCategory();
$set = null;
if ($category->getSetManager()->allowAttributeSets()) {
if ($request->request->has('asID')) {
$set = Set::getByID($request->request->get('asID'));
$setKeys = Set::getByAttributeKey($key);
if (in_array($set, $setKeys)) {
// The set is already a part of this key, so we return.
return;
}
}
if ($category->getSetManager()->allowAttributeSets() == StandardSetManager::ASET_ALLOW_SINGLE || !is_object($set)) {
$query = $this->entityManager->createQuery(
'delete from \Concrete\Core\Entity\Attribute\SetKey sk where sk.attribute_key = :attribute_key'
);
$query->setParameter('attribute_key', $key);
$query->execute();
}
if (is_object($set)) {
$this->entityManager->refresh($set);
// Refresh display order just in case.
$displayOrder = 0;
foreach ($set->getAttributeKeyCollection() as $setKey) {
$setKey->setDisplayOrder($displayOrder);
$this->entityManager->persist($setKey);
$displayOrder++;
}
$setKey = new SetKey();
$setKey->setAttributeKey($key);
$setKey->setAttributeSet($set);
$setKey->setDisplayOrder($displayOrder);
$this->entityManager->persist($setKey);
}
}
$this->entityManager->flush();
}
|
Assign an attribute key to the set (which is read from the request).
@param \Concrete\Core\Attribute\AttributeKeyInterface $key
|
assignToSetFromRequest
|
php
|
concretecms/concretecms
|
concrete/src/Page/Controller/DashboardAttributesPageController.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Controller/DashboardAttributesPageController.php
|
MIT
|
protected function executeUpdate(AttributeKeyInterface $key, $successURL, $onComplete = null)
{
$entity = $this->getCategoryObject();
$category = $entity->getAttributeKeyCategory();
$validator = $key->getController()->getValidator();
$response = $validator->validateUpdateKeyRequest($category, $key, $this->request);
if (!$response->isValid()) {
$this->error = $response->getErrorObject();
} else {
$category->updateFromRequest($key, $this->request);
$this->assignToSetFromRequest($key);
if ($onComplete instanceof \Closure) {
$onComplete();
}
$this->flash('success', t('Attribute updated successfully.'));
$this->buildRedirect($successURL)->send();
$this->app->shutdown();
}
}
|
Update an existing attribute key, reading the type-specific data from the current request.
@param \Concrete\Core\Attribute\AttributeKeyInterface $key the attribute key to be updated
@param \League\Url\UrlInterface|string $successURL where to redirect the users when the operation succeedes
@param callable|null $onComplete a callback function that's called right after the attribute key is updated
|
executeUpdate
|
php
|
concretecms/concretecms
|
concrete/src/Page/Controller/DashboardAttributesPageController.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Controller/DashboardAttributesPageController.php
|
MIT
|
protected function executeDelete(AttributeKeyInterface $key, $successURL, $onComplete = null)
{
try {
if (!$this->token->validate('delete_attribute')) {
throw new UserMessageException($this->token->getErrorMessage());
}
$this->entityManager->remove($key);
$this->entityManager->flush();
if ($onComplete instanceof \Closure) {
$onComplete();
}
$this->flash('success', t('Attribute deleted successfully.'));
$this->buildRedirect($successURL)->send();
$this->app->shutdown();
} catch (UserMessageException $e) {
$this->error = $e;
}
}
|
Delete an existing attribute key.
@param \Concrete\Core\Attribute\AttributeKeyInterface $key the attribute key to be deleted
@param \League\Url\UrlInterface|string $successURL where to redirect the users when the operation succeedes
@param callable|null $onComplete a callback function that's called right after the attribute key is deleted
|
executeDelete
|
php
|
concretecms/concretecms
|
concrete/src/Page/Controller/DashboardAttributesPageController.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Controller/DashboardAttributesPageController.php
|
MIT
|
public function enableNativeMobile()
{
$md = new Mobile_Detect();
if ($md->isMobile()) {
$this->addHeaderItem('<meta name="viewport" content="width=device-width,initial-scale=1">');
}
}
|
Check if the current user is using a mobile device: if so, configure the dashboard page accordingly.
|
enableNativeMobile
|
php
|
concretecms/concretecms
|
concrete/src/Page/Controller/DashboardPageController.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Controller/DashboardPageController.php
|
MIT
|
public function on_start()
{
$cookieJar = $this->app->make(CookieJar::class);
$this->token = $this->app->make('token');
$this->error = $this->app->make('error');
$this->entityManager = $this->app->make(EntityManagerInterface::class);
$this->elementManager = $this->app->make(ElementManager::class);
$this->set('interface', $this->app->make('helper/concrete/ui'));
$this->set('dashboard', $this->app->make('helper/concrete/dashboard'));
$this->set('hideDashboardPanel', $cookieJar->get('dashboardPanelStatus') === 'closed');
$favorites = $this->app->make(FavoritesNavigationFactory::class)->createNavigation();
if ($favorites->has(new PageItem($this->getPageObject()))) {
$this->set('_bookmarked', true);
} else {
$this->set('_bookmarked', false);
}
}
|
{@inheritdoc}
@see \Concrete\Core\Controller\AbstractController::on_start()
|
on_start
|
php
|
concretecms/concretecms
|
concrete/src/Page/Controller/DashboardPageController.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Controller/DashboardPageController.php
|
MIT
|
public function on_before_render()
{
$pageTitle = $this->get('pageTitle');
if (!$pageTitle) {
$this->set('pageTitle', t($this->c->getCollectionName()));
}
$breadcrumb = $this->getBreadcrumb();
if (!$breadcrumb) {
$breadcrumb = $this->createBreadcrumb();
}
$_breadcrumb = $this->elementManager->get($this->getBreadcrumbElement(), [
'breadcrumb' => $breadcrumb
]);
$dbConfig = $this->app->make('config/database');
$this->set('showPrivacyPolicyNotice', !$dbConfig->get('app.privacy_policy_accepted'));
$this->set('token', $this->token);
$this->set('error', $this->error);
$this->set('_breadcrumb', $_breadcrumb);
}
|
{@inheritdoc}
@see \Concrete\Core\Controller\AbstractController::on_before_render()
|
on_before_render
|
php
|
concretecms/concretecms
|
concrete/src/Page/Controller/DashboardPageController.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Controller/DashboardPageController.php
|
MIT
|
public function getEntityManager()
{
return $this->entityManager;
}
|
Get the EntityManager instance (available after the on_start method has been called).
@return \Doctrine\ORM\EntityManagerInterface|null
|
getEntityManager
|
php
|
concretecms/concretecms
|
concrete/src/Page/Controller/DashboardPageController.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Controller/DashboardPageController.php
|
MIT
|
public function useUserLocale()
{
return true;
}
|
{@inheritdoc}
@see \Concrete\Core\Page\Controller\PageController::useUserLocale()
|
useUserLocale
|
php
|
concretecms/concretecms
|
concrete/src/Page/Controller/DashboardPageController.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Controller/DashboardPageController.php
|
MIT
|
public function view_detail(): void
{
throw new \RuntimeException('Please migrate to the new marketplace.');
}
|
@deprecated This will be removed in version 10
|
view_detail
|
php
|
concretecms/concretecms
|
concrete/src/Page/Controller/MarketplaceDashboardPageController.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Controller/MarketplaceDashboardPageController.php
|
MIT
|
public function getMarketplaceType()
{
throw new \RuntimeException('Please migrate to the new marketplace.');
}
|
@deprecated This will be removed in version 10
|
getMarketplaceType
|
php
|
concretecms/concretecms
|
concrete/src/Page/Controller/MarketplaceDashboardPageController.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Controller/MarketplaceDashboardPageController.php
|
MIT
|
public function getMarketplaceDefaultHeading()
{
throw new \RuntimeException('Please migrate to the new marketplace.');
}
|
@deprecated This will be removed in version 10
|
getMarketplaceDefaultHeading
|
php
|
concretecms/concretecms
|
concrete/src/Page/Controller/MarketplaceDashboardPageController.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Controller/MarketplaceDashboardPageController.php
|
MIT
|
public function setCustomRequestPath($requestPath)
{
$this->customRequestPath = ($requestPath === null) ? null : (string) $requestPath;
}
|
Set the custom request path (useful when replacing controllers).
@param string|null $requestPath Set to null to use the default request path
|
setCustomRequestPath
|
php
|
concretecms/concretecms
|
concrete/src/Page/Controller/PageController.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Controller/PageController.php
|
MIT
|
public function getCustomRequestPath()
{
return $this->customRequestPath;
}
|
Get the custom request path (useful when replacing controllers).
@return string|null Returns null if no custom request path, a string otherwise
|
getCustomRequestPath
|
php
|
concretecms/concretecms
|
concrete/src/Page/Controller/PageController.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Controller/PageController.php
|
MIT
|
public function getSets()
{
// Check if we've already looked at the session flashbag, if so just move on
if ($this->hasCheckedSessionMessages === false) {
$this->hasCheckedSessionMessages = true;
$app = $this->app;
$validator = $app->make(SessionValidator::class);
$session = Application::getFacadeApplication()->make('session');
// Check if we have an active session and our expected flash message
if ($validator->hasActiveSession() && $session->getFlashBag()->has('page_message')) {
$value = $session->getFlashBag()->get('page_message');
// Add each page_message item to the sets for the page
foreach ($value as $message) {
$this->set($message[0], $message[1]);
// Also set a `{$key}IsHTML` helper boolean to tell whether the set value is supposed to be HTML
$this->set($message[0] . 'IsHTML', isset($message[2]) && $message[2]);
}
}
}
return parent::getSets();
}
|
Get the things "set" against this controller with `$this->set(...)`
This output array may also contain items set with `$this->flash(...)` like `message` `error` `success` or other
custom keys
@return array Associative array of things set against this controller
|
getSets
|
php
|
concretecms/concretecms
|
concrete/src/Page/Controller/PageController.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Controller/PageController.php
|
MIT
|
public function render($path, $pkgHandle = null)
{
$view = $this->getViewObject();
$env = Environment::get();
$path = trim($path, '/');
$a = $path . '/' . FILENAME_COLLECTION_VIEW;
$b = $path . '.php';
$r = $env->getRecord(DIRNAME_PAGES . '/' . $a);
if ($r->exists()) {
$view->renderSinglePageByFilename($a, $pkgHandle);
} else {
$view->renderSinglePageByFilename($b, $pkgHandle);
}
}
|
Given a path to a single page, this command uses the CURRENT controller and renders
the contents of the single page within this request. The current controller is not
replaced, and has already fired (since it is meant to be called from within a view() or
similar method).
@param @string
|
render
|
php
|
concretecms/concretecms
|
concrete/src/Page/Controller/PageController.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Controller/PageController.php
|
MIT
|
public function setBlockController(Block $block, BlockController $controller)
{
$this->blocks[$block->getBlockID()] = $controller;
}
|
@since 9.0.3
@param Block $block
@param BlockController $controller
@return void
|
setBlockController
|
php
|
concretecms/concretecms
|
concrete/src/Page/Controller/PageController.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Controller/PageController.php
|
MIT
|
public function getBlockController(Block $block): ?BlockController
{
$bID = $block->getBlockID();
return $this->blocks[$bID] ?? null;
}
|
@since 9.0.3
@param Block $block
@return BlockController|null
|
getBlockController
|
php
|
concretecms/concretecms
|
concrete/src/Page/Controller/PageController.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Controller/PageController.php
|
MIT
|
public function useUserLocale()
{
return false;
}
|
Should this page be displayed using the user's language?
@return bool
|
useUserLocale
|
php
|
concretecms/concretecms
|
concrete/src/Page/Controller/PageController.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Controller/PageController.php
|
MIT
|
public function getSearchableContent()
{
return;
}
|
Override this method to send content created by the page controller to the indexer
|
getSearchableContent
|
php
|
concretecms/concretecms
|
concrete/src/Page/Controller/PageController.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Controller/PageController.php
|
MIT
|
public function buildRedirectToFirstAccessibleChildPage()
{
$myPage = $this->getPageObject();
if ($myPage && !$myPage->isError()) {
$firstChildPage = $myPage->getFirstChild();
if ($firstChildPage && !$firstChildPage->isError() && (new Checker($firstChildPage))->canRead()) {
return $this->buildRedirect([$firstChildPage]);
}
foreach ($myPage->getCollectionChildren() as $childPage) {
if (!$childPage->isError() && (new Checker($childPage))->canRead()) {
return $this->buildRedirect([$childPage]);
}
}
}
return $this->app->make(ResponseFactoryInterface::class)->forbidden($this->request->getUri());
}
|
Build a Redirect Response that instruct the browser to load the first accessible child page of this page.
@return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response Return a RedirectResponse if an accessible child page is found, a forbidden Response otherwise
|
buildRedirectToFirstAccessibleChildPage
|
php
|
concretecms/concretecms
|
concrete/src/Page/Controller/PageController.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Controller/PageController.php
|
MIT
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.