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 setSkip($skip) { $this->skip = (bool) $skip; return $this; }
Should this alternative be skipped? @param bool $skip @return $this
setSkip
php
concretecms/concretecms
concrete/src/Page/Sitemap/Element/SitemapPageAlternativeLanguage.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Sitemap/Element/SitemapPageAlternativeLanguage.php
MIT
public function getOverriddenHrefLang() { return $this->overriddenHrefLang; }
Get the overridden hreflang value. @return string
getOverriddenHrefLang
php
concretecms/concretecms
concrete/src/Page/Sitemap/Element/SitemapPageAlternativeLanguage.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Sitemap/Element/SitemapPageAlternativeLanguage.php
MIT
public function setOverriddenHrefLang($overriddenHrefLang) { $this->overriddenHrefLang = (string) $overriddenHrefLang; return $this; }
Set the overridden hreflang value. @param string $overriddenHrefLang @return $this
setOverriddenHrefLang
php
concretecms/concretecms
concrete/src/Page/Sitemap/Element/SitemapPageAlternativeLanguage.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Sitemap/Element/SitemapPageAlternativeLanguage.php
MIT
public function toXmlLines($indenter = ' ') { if ($this->isSkip()) { $result = null; } else { $nsn = static::MULTILINGUAL_NAMESPACE_NAME; $hreflang = h($this->getFinalHrefLang()); $href = h((string) $this->getUrl()); $result = [ "{$indenter}{$indenter}<{$nsn}:link rel=\"alternate\" hreflang=\"{$hreflang}\" href=\"{$href}\" />", ]; } return $result; }
{@inheritdoc} @see \Concrete\Core\Page\Sitemap\Element\SitemapElement::toXmlLines()
toXmlLines
php
concretecms/concretecms
concrete/src/Page/Sitemap/Element/SitemapPageAlternativeLanguage.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Sitemap/Element/SitemapPageAlternativeLanguage.php
MIT
public function toXmlElement(?SimpleXMLElement $parentElement = null) { if ($parentElement === null) { throw new UserMessageException(t('The sitemap XML link should not be the first element.')); } if ($this->isSkip()) { $result = null; } else { $result = $parentElement->addChild('link', null, static::MULTILINGUAL_NAMESPACE); $result->addAttribute('rel', 'alternate'); $result->addAttribute('hreflang', $this->getFinalHrefLang()); $result->addAttribute('href', (string) $this->getUrl()); } return $result; }
{@inheritdoc} @see \Concrete\Core\Page\Sitemap\Element\SitemapElement::toXmlElement()
toXmlElement
php
concretecms/concretecms
concrete/src/Page/Sitemap/Element/SitemapPageAlternativeLanguage.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Sitemap/Element/SitemapPageAlternativeLanguage.php
MIT
protected function getFinalHrefLang() { $result = $this->getOverriddenHrefLang(); if ($result === '') { $result = strtolower(str_replace('_', '-', $this->getSection()->getLocale())); } return $result; }
Get the final value of the href lang. @return string
getFinalHrefLang
php
concretecms/concretecms
concrete/src/Page/Sitemap/Element/SitemapPageAlternativeLanguage.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Sitemap/Element/SitemapPageAlternativeLanguage.php
MIT
public function __construct(Page $page, SimpleXMLElement $node) { $this->page = $page; $this->node = $node; }
Initialize the instance. @param \Concrete\Core\Page\Page $page the page for which we are building the sitemap node @param \SimpleXMLElement $node the sitemap XML node
__construct
php
concretecms/concretecms
concrete/src/Page/Sitemap/Event/DeprecatedPageReadyEvent.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Sitemap/Event/DeprecatedPageReadyEvent.php
MIT
public function getSubject() { return ['page' => $this->getPage(), 'xmlNode' => $this->getNode()]; }
{@inheritdoc} @see \Symfony\Component\EventDispatcher\GenericEvent::getSubject()
getSubject
php
concretecms/concretecms
concrete/src/Page/Sitemap/Event/DeprecatedPageReadyEvent.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Sitemap/Event/DeprecatedPageReadyEvent.php
MIT
public function getPage() { return $this->page; }
Get the page for which we are building the sitemap node. @return \Concrete\Core\Page\Page
getPage
php
concretecms/concretecms
concrete/src/Page/Sitemap/Event/DeprecatedPageReadyEvent.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Sitemap/Event/DeprecatedPageReadyEvent.php
MIT
public function getNode() { return $this->node; }
Get the sitemap XML node (may be set to null by an event listener). @return \SimpleXMLElement|null
getNode
php
concretecms/concretecms
concrete/src/Page/Sitemap/Event/DeprecatedPageReadyEvent.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Sitemap/Event/DeprecatedPageReadyEvent.php
MIT
public function setNode(?SimpleXMLElement $newNode = null) { $this->node = $newNode; }
Replace the sitemap XML node (use NULL to skip this node). @param \SimpleXMLElement|null $newNode
setNode
php
concretecms/concretecms
concrete/src/Page/Sitemap/Event/DeprecatedPageReadyEvent.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Sitemap/Event/DeprecatedPageReadyEvent.php
MIT
public function __construct(SitemapElement $element) { $this->element = $element; }
Initialize the instance. @param \Concrete\Core\Page\Sitemap\Element\SitemapElement $element
__construct
php
concretecms/concretecms
concrete/src/Page/Sitemap/Event/ElementReadyEvent.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Sitemap/Event/ElementReadyEvent.php
MIT
public function getSubject() { return ['sitemapPage' => $this->element]; }
{@inheritdoc} @see \Symfony\Component\EventDispatcher\GenericEvent::getSubject()
getSubject
php
concretecms/concretecms
concrete/src/Page/Sitemap/Event/ElementReadyEvent.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Sitemap/Event/ElementReadyEvent.php
MIT
public function getElement() { return $this->element; }
Get the sitemap element (may be set to null by an event listener). @return \Concrete\Core\Page\Sitemap\Element\SitemapElement|null
getElement
php
concretecms/concretecms
concrete/src/Page/Sitemap/Event/ElementReadyEvent.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Sitemap/Event/ElementReadyEvent.php
MIT
public function setElement(?SitemapElement $newElement = null) { if ($newElement === null) { if ($this->element instanceof SitemapHeader) { throw new InvalidArgumentException(t("Sitemap headers can't be omitted.")); } if ($this->element instanceof SitemapFooter) { throw new InvalidArgumentException(t("Sitemap footers can't be omitted.")); } } $this->element = $newElement; return $this; }
Replace the sitemap element (use NULL to skip a page). @param \Concrete\Core\Page\Sitemap\Element\SitemapElement|null $newElement @throws \InvalidArgumentException throws an InvalidArgumentException exception if you are setting to NULL the sitemap header or footer (just sitemap pages can be set to NULL) @return $this
setElement
php
concretecms/concretecms
concrete/src/Page/Sitemap/Event/ElementReadyEvent.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Sitemap/Event/ElementReadyEvent.php
MIT
public function __construct(SimpleXMLElement $document) { $this->document = $document; }
Initialize the instance. @param \SimpleXMLElement $document the sitemap XML document
__construct
php
concretecms/concretecms
concrete/src/Page/Sitemap/Event/XmlReadyEvent.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Sitemap/Event/XmlReadyEvent.php
MIT
public function getSubject() { return ['xmlDoc' => $this->document]; }
{@inheritdoc} @see \Symfony\Component\EventDispatcher\GenericEvent::getSubject()
getSubject
php
concretecms/concretecms
concrete/src/Page/Sitemap/Event/XmlReadyEvent.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Sitemap/Event/XmlReadyEvent.php
MIT
public function getDocument() { return $this->document; }
Get the sitemap XML document. @return \SimpleXMLElement
getDocument
php
concretecms/concretecms
concrete/src/Page/Sitemap/Event/XmlReadyEvent.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Sitemap/Event/XmlReadyEvent.php
MIT
public function setDocument(SimpleXMLElement $newDocument) { $this->document = $newDocument; return $this; }
Replace the sitemap XML document. @param \SimpleXMLElement $newDocument @return $this
setDocument
php
concretecms/concretecms
concrete/src/Page/Sitemap/Event/XmlReadyEvent.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Sitemap/Event/XmlReadyEvent.php
MIT
public static function getGlobalAreaStackFromName(Collection $collection, string $arHandle): ?Stack { $app = Application::getFacadeApplication(); $db = $app->make(Connection::class); $checker = new Checker($collection); /** @var \Concrete\Core\Cache\Level\RequestCache $requestCache */ $requestCache = $app->make('cache/request'); $identifier = sprintf('/stack/global_area/%s/cID', $arHandle); $item = $requestCache->getItem($identifier); if ($item->isHit()) { $stackID = $item->get(); } else { $stackID = $db->executeQuery('select cID from Stacks where stName = ? and stType = ?', [ $arHandle, self::ST_TYPE_GLOBAL_AREA ])->fetchOne(); $requestCache->save($item->set($stackID)); } if (!$stackID) { return null; } $cvID = $checker->canViewPageVersions() ? 'RECENT': 'ACTIVE'; $s = Stack::getByID($stackID, $cvID); if (!$s) { return null; } if ($app->make('multilingual/detector')->isEnabled() && $collection instanceof Page) { $section = Section::getBySectionOfSite($collection); if ($section) { $s = $s->getLocalizedStack($section, $cvID) ?: $s; } } return $s; }
Given an original collection that we're currently rendering, return a stack corresponding to a global area on that collection. (Note: the original collection is required because we check its permissions to determine what version of the stack to load.) @param Collection $collection @param string $arHandle @return Stack|null @throws \Exception
getGlobalAreaStackFromName
php
concretecms/concretecms
concrete/src/Page/Stack/Stack.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Stack/Stack.php
MIT
public static function getByPath($path, $version = 'RECENT', ?TreeInterface $siteTree = null) { $c = parent::getByPath(STACKS_PAGE_PATH . '/' . trim($path, '/'), $version, $siteTree); if (static::isValidStack($c)) { return $c; } return false; }
@param string $path @param string $version \Concrete\Core\Site\Tree\TreeInterface|null $siteTree @return bool|\Concrete\Core\Page\Page
getByPath
php
concretecms/concretecms
concrete/src/Page/Stack/Stack.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Stack/Stack.php
MIT
public static function getByName($stackName, $cvID = 'RECENT', ?TreeInterface $site = null, $multilingualContentSource = self::MULTILINGUAL_CONTENT_SOURCE_CURRENT) { $c = Page::getCurrentPage(); if (is_object($c) && (!$c->isError())) { $identifier = sprintf('/stack/name/%s/%s/%s', $stackName, $c->getCollectionID(), $multilingualContentSource); $cache = Core::make('cache/request'); $item = $cache->getItem($identifier); if (!$item->isMiss()) { $cID = $item->get(); } else { $item->lock(); $db = Database::connection(); $ms = false; $detector = Core::make('multilingual/detector'); if ($detector->isEnabled()) { $ms = self::getMultilingualSectionFromType($multilingualContentSource); } $sql = 'select cID from Stacks where stName = ?'; $q = [$stackName]; if ($ms) { $sql .= ' and (stMultilingualSection = ? or stMultilingualSection = 0)'; $q[] = $ms->getCollectionID(); } else { $sql .= ' and stMultilingualSection = 0'; } //$sql .= ' and siteTreeID = ?'; if ($ms) { $sql .= ' order by stMultilingualSection desc'; } $sql .= ' limit 1'; /*if (!is_object($site)) { $site = \Core::make('site')->getSite(); } if ($site instanceof Site) { $q[] = $site->getDefaultLocale()->getSiteTree()->getSiteTreeID(); } else { $q[] = $site->getSiteTreeID(); }*/ $cID = $db->fetchColumn($sql, $q); $cache->save($item->set($cID)); } } else { $db = Database::connection(); $cID = $db->fetchColumn( 'select cID from Stacks where stName = ? and stMultilingualSection = 0', [$stackName] ); } return $cID ? static::getByID($cID, $cvID) : null; }
@param string $stackName @param string $cvID \Concrete\Core\Site\Tree\TreeInterface|null $site @param int $multilingualContentSource @return self|false|null
getByName
php
concretecms/concretecms
concrete/src/Page/Stack/Stack.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Stack/Stack.php
MIT
public static function getByID($cID, $cvID = 'RECENT') { $c = parent::getByID($cID, $cvID); if (static::isValidStack($c)) { return $c; } return null; }
@param int $cID @param string $cvID @return \Concrete\Core\Page\Page|self|false
getByID
php
concretecms/concretecms
concrete/src/Page/Stack/Stack.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Stack/Stack.php
MIT
protected static function isValidStack($stack) { return $stack->getPageTypeHandle() == STACKS_PAGE_TYPE; }
@param \Concrete\Core\Page\Stack\Stack $stack @return bool
isValidStack
php
concretecms/concretecms
concrete/src/Page/Stack/Stack.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Stack/Stack.php
MIT
private static function addStackToCategory(\Concrete\Core\Page\Page $parent, $name, $type = 0) { $data = []; $data['name'] = $name; if (!$name) { $data['name'] = t('No Name'); } $pagetype = PageType::getByHandle(STACKS_PAGE_TYPE); $page = $parent->add($pagetype, $data); // we have to do this because we need the area to exist before we try and add something to it. Area::getOrCreate($page, STACKS_AREA_NAME); // finally we add the row to the stacks table $db = Database::connection(); $stackCID = $page->getCollectionID(); //$siteTreeID = $parent->getSiteTreeObject()->getSiteTreeID(); //$v = array($name, $stackCID, $type, $siteTreeID); $v = [$name, $stackCID, $type]; $db->Execute('insert into Stacks (stName, cID, stType) values (?, ?, ?)', $v); $stack = static::getByID($stackCID); return $stack; }
@param \Concrete\Core\Page\Page $parent @param $name @param int $type @return self|false
addStackToCategory
php
concretecms/concretecms
concrete/src/Page/Stack/Stack.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Stack/Stack.php
MIT
protected static function getMultilingualSectionFromType($type) { $detector = Core::make('multilingual/detector'); if ($type == self::MULTILINGUAL_CONTENT_SOURCE_DEFAULT) { $ms = Section::getDefaultSection(); } else { $c = \Page::getCurrentPage(); $ms = Section::getBySectionOfSite($c); if (!is_object($ms)) { $ms = $detector->getPreferredSection(); } } return $ms; }
@param $type @return \Concrete\Core\Multilingual\Page\Section\Section|false|null
getMultilingualSectionFromType
php
concretecms/concretecms
concrete/src/Page/Stack/Stack.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Stack/Stack.php
MIT
public static function addStack($stack, ?Folder $folder = null) { $parent = \Page::getByPath(STACKS_PAGE_PATH); if ($folder) { $parent = $folder->getPage(); } return self::addStackToCategory($parent, $stack, static::ST_TYPE_USER_ADDED); }
@param $stack @param \Concrete\Core\Page\Stack\Folder\Folder|null $folder @return self|false
addStack
php
concretecms/concretecms
concrete/src/Page/Stack/Stack.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Stack/Stack.php
MIT
public function getExporter() { return new \Concrete\Core\Export\Item\Stack(); }
@return \Concrete\Core\Export\Item\ItemInterface|\Concrete\Core\Export\Item\Stack|\Concrete\Core\Page\Exporter
getExporter
php
concretecms/concretecms
concrete/src/Page/Stack/Stack.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Stack/Stack.php
MIT
public function getMultilingualSectionID() { if (!isset($this->multilingualSectionID)) { $db = Database::connection(); $cID = $db->GetOne('select stMultilingualSection from Stacks where cID = ?', [$this->getCollectionID()]); $this->multilingualSectionID = $cID ? (int) $cID : 0; } return $this->multilingualSectionID; }
Returns the ID of the multilingual section associated to this stack (or 0 if it's the language-neutral version). @return int
getMultilingualSectionID
php
concretecms/concretecms
concrete/src/Page/Stack/Stack.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Stack/Stack.php
MIT
public function getMultilingualSection() { $result = null; $msID = $this->getMultilingualSectionID(); if ($msID !== 0) { $s = Section::getByID($msID); if ($s) { $result = $s; } } return $result; }
Returns the multilingual section associated to this stack (or null if it's the language-neutral version). @return \Concrete\Core\Multilingual\Page\Section\Section|null
getMultilingualSection
php
concretecms/concretecms
concrete/src/Page/Stack/Stack.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Stack/Stack.php
MIT
protected function getNeutralStackID() { return ($this->getMultilingualSectionID() === 0) ? null : (int) $this->getCollectionParentID(); }
Returns the collection ID of the locale.neutral version of this stack (or null if this instance is already the neutral version). @return int|null
getNeutralStackID
php
concretecms/concretecms
concrete/src/Page/Stack/Stack.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Stack/Stack.php
MIT
public function isNeutralStack() { return $this->getMultilingualSectionID() === 0; }
Checks if this instance is the locale-neutral version of the stack. @return bool
isNeutralStack
php
concretecms/concretecms
concrete/src/Page/Stack/Stack.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Stack/Stack.php
MIT
public function getNeutralStack($cvID = 'RECENT') { $result = null; $cID = $this->getNeutralStackID(); if ($cID !== null) { $result = static::getByID($cID, $cvID); } return $result; }
Returns the locale-neutral version of this stack (or null if this instance is already the neutral version). @param string|int $cvID @return self|null
getNeutralStack
php
concretecms/concretecms
concrete/src/Page/Stack/Stack.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Stack/Stack.php
MIT
public function getLocalizedStack(Section $section, $cvID = 'RECENT') { $result = null; $mySectionID = $this->getMultilingualSectionID(); if ($mySectionID !== 0 && $section->getCollectionID() == $mySectionID) { $result = $this; } else { $neutralID = ($mySectionID === 0) ? $this->getCollectionID() : $this->getNeutralStackID(); $db = Database::connection(); $localizedID = $db->fetchColumn( ' select Stacks.cID from Stacks inner join Pages on Stacks.cID = Pages.cID where Pages.cParentID = ? and Stacks.stMultilingualSection = ? limit 1 ', [$neutralID, $section->getCollectionID()] ); if ($localizedID) { $localized = static::getByID($localizedID, $cvID); if ($localized) { $result = $localized; } } } return $result; }
Returns the localized version of this stack. @param \Concrete\Core\Multilingual\Page\Section\Section $section @param string|int $cvID @return self|null
getLocalizedStack
php
concretecms/concretecms
concrete/src/Page/Stack/Stack.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Stack/Stack.php
MIT
public function addLocalizedStack(Section $section, array $options = []) { $neutralStack = $this->getNeutralStack(); if ($neutralStack === null) { $neutralStack = $this; } $name = $neutralStack->getCollectionName(); $neutralStackPage = Page::getByID($neutralStack->getCollectionID()); $cloner = app(Cloner::class); $clonerOptions = app(ClonerOptions::class); $clonerOptions ->setCopyContents($options['copyContents'] ?? true) ; $localizedStackPage = $cloner->clonePage($neutralStackPage, $clonerOptions, $neutralStackPage); $localizedStackPage->update([ 'cName' => $name, ]); //$siteTreeID = $neutralStack->getSiteTreeID(); // we have to do this because we need the area to exist before we try and add something to it. Area::getOrCreate($localizedStackPage, STACKS_AREA_NAME); $localizedStackCID = $localizedStackPage->getCollectionID(); $localizedStack = static::getByID($localizedStackCID); $localizedStack->setMultilingualSection($section, $name); return $localizedStack; }
@param \Concrete\Core\Multilingual\Page\Section\Section $section @param array{copyContents: bool = true} $options @return self
addLocalizedStack
php
concretecms/concretecms
concrete/src/Page/Stack/Stack.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Stack/Stack.php
MIT
public function setMultilingualSection(Section $section, $stackName = '') { if ($stackName == '') { $stackName = $this->getStackName(); } /** @var Connection $db */ $db = Database::connection(); $db->update( 'Stacks', [ 'stMultilingualSection' => $section->getCollectionID(), 'stName' => $stackName, ], [ 'cID' => $this->getCollectionID(), ] ); }
Mark this stack as a localized version. @param Section $section Multilingual Section @param string $stackName Optional
setMultilingualSection
php
concretecms/concretecms
concrete/src/Page/Stack/Stack.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Stack/Stack.php
MIT
public function copyLocalizedStacksFrom(Stack $original) { // Create localized stacks only this is a neutral stack if ($this->isNeutralStack()) { foreach (Section::getList() as $section) { $localized = $this->getLocalizedStack($section); // We should skip if localized stack is already created if ($localized === null) { $originalLocalized = $original->getLocalizedStack($section); if ($originalLocalized !== null) { $copiedLocalized = $originalLocalized->duplicate($this); $copiedLocalized->update(['cName' => $this->getStackName()]); $copiedLocalized->setMultilingualSection($section, $this->getStackName()); } } } } }
Copy localized versions from an another neutral stack. @param Stack $original The Stack that has original localized versions
copyLocalizedStacksFrom
php
concretecms/concretecms
concrete/src/Page/Stack/Stack.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Stack/Stack.php
MIT
public function setFoldersFirst($value) { $this->foldersFirst = (bool) $value; }
Should we list stack folders first? @param bool $value
setFoldersFirst
php
concretecms/concretecms
concrete/src/Page/Stack/StackList.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Stack/StackList.php
MIT
public function getFoldersFirst() { return $this->foldersFirst; }
Should we list stack folders first? @return bool
getFoldersFirst
php
concretecms/concretecms
concrete/src/Page/Stack/StackList.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Stack/StackList.php
MIT
public function filterByGlobalAreas() { $this ->setIncludeFolders(false) ->setIncludeGlobalAreas(true) ->setIncludeStacks(false) ; }
@deprecated use setIncludeGlobalAreas(true) + setIncludeStacks(false) + setIncludeFolders(false)
filterByGlobalAreas
php
concretecms/concretecms
concrete/src/Page/Stack/StackList.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Stack/StackList.php
MIT
public function getRootItemsOnly(): bool { return $this->folder === false; }
List only the root stacks/folders? @return bool
getRootItemsOnly
php
concretecms/concretecms
concrete/src/Page/Stack/StackList.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Stack/StackList.php
MIT
public function setRootItemsOnly(bool $value): self { if ($value) { $this->folder = false; } return $this; }
List only the root stacks/folders? @return $this
setRootItemsOnly
php
concretecms/concretecms
concrete/src/Page/Stack/StackList.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Stack/StackList.php
MIT
public function deliverQueryObject() { $this->applyFolderFilter(); return parent::deliverQueryObject(); }
{@inheritdoc} @see \Concrete\Core\Search\ItemList\Database\ItemList::deliverQueryObject()
deliverQueryObject
php
concretecms/concretecms
concrete/src/Page/Stack/StackList.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Stack/StackList.php
MIT
public function finalizeQuery(QueryBuilder $query) { $query = parent::finalizeQuery($query); $languageSection = $this->getLanguageSection(); if ($languageSection === null) { $query->andWhere('s.stMultilingualSection IS NULL OR s.stMultilingualSection = 0'); } else { $query->andWhere('s.stMultilingualSection = ' . $query->createNamedParameter($languageSection->getCollectionID())); } $this->applyTypeFilter($query); return $query; }
{@inheritdoc} @see \Concrete\Core\Page\PageList::finalizeQuery()
finalizeQuery
php
concretecms/concretecms
concrete/src/Page/Stack/StackList.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Stack/StackList.php
MIT
public function getResult($queryRow) { $stack = Stack::getByID($queryRow['cID'], 'ACTIVE'); return $stack ?: parent::getResult($queryRow); }
{@inheritdoc} @see \Concrete\Core\Page\PageList::getResult() @return \Concrete\Core\Page\Stack\Stack|\Concrete\Core\Page\Page|null returns a Page in case of folders
getResult
php
concretecms/concretecms
concrete/src/Page/Stack/StackList.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Stack/StackList.php
MIT
public function track(TrackableInterface $trackable) { if ($trackable instanceof Collection) { $this->trackCollection($trackable); } if ($trackable instanceof PageController) { $this->trackCollection($trackable->getPageObject()); } if ($trackable instanceof Controller) { $this->trackBlocks($trackable->getCollectionObject(), [$trackable]); } }
Track a trackable object Any object could be passed to this method so long as it implements TrackableInterface @param \Concrete\Core\Statistics\UsageTracker\TrackableInterface $trackable @return static|TrackerInterface
track
php
concretecms/concretecms
concrete/src/Page/Stack/UsageTracker.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Stack/UsageTracker.php
MIT
public function forget(TrackableInterface $trackable) { if ($trackable instanceof Collection) { $this->forgetCollection($trackable); } if ($trackable instanceof PageController) { $this->forgetCollection($trackable->getPageObject()); } if ($trackable instanceof Controller) { // Delete all blocks with this id $this->manager->createQueryBuilder() ->delete(StackUsageRecord::class, 'r') ->where('r.block_id = :block_id') ->setParameter('block_id', $trackable->getBlockObject()->getBlockID()) ->getQuery()->execute(); } }
Forget a trackable object Any object could be passed to this method so long as it implements TrackableInterface @param \Concrete\Core\Statistics\UsageTracker\TrackableInterface $trackable @return static|TrackerInterface
forget
php
concretecms/concretecms
concrete/src/Page/Stack/UsageTracker.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Stack/UsageTracker.php
MIT
private function trackCollection(Collection $collection) { $blocks = $collection->getBlocks(); $this->trackBlocks($collection, $blocks); }
Track a collection object @param \Concrete\Core\Page\Collection\Collection $collection
trackCollection
php
concretecms/concretecms
concrete/src/Page/Stack/UsageTracker.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Stack/UsageTracker.php
MIT
private function forgetCollection(Collection $collection) { $query_builder = $this->manager->createQueryBuilder(); $query_builder ->delete(StackUsageRecord::class, 'r') ->where('r.collection_id = :collection_id') ->setParameter('collection_id', $collection->getCollectionID()) ->getQuery()->execute(); }
Forget about a collection object @param \Concrete\Core\Page\Collection\Collection $collection
forgetCollection
php
concretecms/concretecms
concrete/src/Page/Stack/UsageTracker.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Stack/UsageTracker.php
MIT
private function trackBlocks(Collection $collection, array $blocks) { $version = $collection->getVersionID(); $buffer = 0; foreach ($blocks as $block) { // Reset controller and php8+ warning fix $controller = null; if ($block instanceof Controller) { $controller = $block; $block = $controller->getBlockObject(); } if ($block->getBlockTypeHandle() == BLOCK_HANDLE_STACK_PROXY) { if (!$controller) { $controller = $block->getController(); } $this->persist( $controller->getStackID(), $collection->getCollectionID(), $version, $block->getBlockID()); $buffer++; } if ($buffer > 2) { $this->manager->flush(); $buffer = 0; } } if ($buffer) { // Sometimes you just need an extra flush... $this->manager->flush(); } }
Track a list of blocks for a collection @param \Concrete\Core\Page\Collection\Collection $collection @param Block[]|BlockController[] $blocks
trackBlocks
php
concretecms/concretecms
concrete/src/Page/Stack/UsageTracker.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Stack/UsageTracker.php
MIT
public function inPile($obj) { $db = Loader::db(); $v = array(); $class = strtoupper(get_class($obj)); switch ($class) { case "COLLECTION": $v = array("COLLECTION", $obj->getCollectionID()); break; case "BLOCK": $v = array("BLOCK", $obj->getBlockID()); break; } $v[] = $this->getPileID(); $q = "select pcID from PileContents where itemType = ? and itemID = ? and pID = ?"; $pcID = $db->getOne($q, $v); return $pcID > 0; }
@param Collection|Block $obj @return bool
inPile
php
concretecms/concretecms
concrete/src/Page/Stack/Pile/Pile.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Stack/Pile/Pile.php
MIT
public function add(&$obj, $quantity = 1) { $db = Loader::db(); $existingPCID = $this->getPileContentID($obj); $v1 = array($this->pID); $q1 = "select max(displayOrder) as displayOrder from PileContents where pID = ?"; $currentDO = $db->getOne($q1, $v1); $displayOrder = $currentDO + 1; if (!$existingPCID) { $v = array($this->pID, $obj->getBlockID(), "BLOCK", $quantity, $displayOrder); $q = "insert into PileContents (pID, itemID, itemType, quantity, displayOrder) values (?, ?, ?, ?, ?)"; $r = $db->query($q, $v); if ($r) { $pcID = $db->Insert_ID(); return $pcID; } } else { return $existingPCID; } }
@param Page|Block|PileContent $obj @param int $quantity @return mixed
add
php
concretecms/concretecms
concrete/src/Page/Stack/Pile/Pile.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Stack/Pile/Pile.php
MIT
public function remove(&$obj, $quantity = 1) { $db = Loader::db(); switch (strtolower(get_class($obj))) { case "page": $v = array($this->pID, $obj->getCollectionID(), "COLLECTION"); break; case "block": $v = array($this->pID, $obj->getBlockID(), "BLOCK"); break; case "pilecontent": $v = array($this->pID, $obj->getItemID(), $obj->getItemType()); break; } $q = "select quantity from PileContents where pID = ? and itemID = ? and itemType = ?"; $exQuantity = $db->getOne($q, $v); if ($exQuantity > $quantity) { $db->query( "update PileContent set quantity = quantity - {$quantity} where pID = ? and itemID = ? and itemType = ?", $v); } else { $db->query("delete from PileContents where pID = ? and itemID = ? and itemType = ?", $v); } }
@param Page|Block|PileContent $obj @param int $quantity
remove
php
concretecms/concretecms
concrete/src/Page/Stack/Pile/Pile.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Stack/Pile/Pile.php
MIT
public function setFilename($filename) { $this->filename = $filename; }
Sets the filename of this object to the passed parameter. @params string $filename
setFilename
php
concretecms/concretecms
concrete/src/Page/Theme/File.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Theme/File.php
MIT
public function setType($type) { $this->type = $type; }
Sets the type of file for this object to one of the constants. @params string $type
setType
php
concretecms/concretecms
concrete/src/Page/Theme/File.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Theme/File.php
MIT
public function getFilename() { return $this->filename; }
Gets the filename for this theme file object. @return string $filename
getFilename
php
concretecms/concretecms
concrete/src/Page/Theme/File.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Theme/File.php
MIT
public function getType() { return $this->type; }
Gets the type of file for this object. @return string $type
getType
php
concretecms/concretecms
concrete/src/Page/Theme/File.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Theme/File.php
MIT
public function getHandle() { return substr($this->filename, 0, strpos($this->filename, '.')); }
Returns just the part of the filename prior to the extension. @return string $handle
getHandle
php
concretecms/concretecms
concrete/src/Page/Theme/File.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Theme/File.php
MIT
public static function getGlobalList() { return static::getList('pkgID > 0'); }
Get the installed themes provided by packages. @return \Concrete\Core\Page\Theme\Theme[]
getGlobalList
php
concretecms/concretecms
concrete/src/Page/Theme/Theme.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Theme/Theme.php
MIT
public static function getLocalList() { return static::getList('pkgID = 0'); }
Get the installed themes provided by the core. @return \Concrete\Core\Page\Theme\Theme[]
getLocalList
php
concretecms/concretecms
concrete/src/Page/Theme/Theme.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Theme/Theme.php
MIT
public static function getListByPackage($pkg) { return static::getList('pkgID = ' . $pkg->getPackageID()); }
Get the installed themes provided by a package. @return \Concrete\Core\Page\Theme\Theme[] @var \Concrete\Core\Entity\Package|\Concrete\Core\Package\Package $pkg
getListByPackage
php
concretecms/concretecms
concrete/src/Page/Theme/Theme.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Theme/Theme.php
MIT
public static function getList($where = null) { if ($where != null) { $where = ' where ' . $where; } $db = Loader::db(); $r = $db->query('select pThemeID from PageThemes' . $where); $themes = []; while ($row = $r->fetch()) { $pl = static::getByID($row['pThemeID']); $themes[] = $pl; } return $themes; }
Get the installed themes. @param string|null $where a custom SQL criteria to filter the installed themes. @return \Concrete\Core\Page\Theme\Theme[]
getList
php
concretecms/concretecms
concrete/src/Page/Theme/Theme.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Theme/Theme.php
MIT
public static function getInstalledHandles() { $db = Loader::db(); return $db->GetCol('select pThemeHandle from PageThemes'); }
Get the handles of all the installed themes. @return string[]
getInstalledHandles
php
concretecms/concretecms
concrete/src/Page/Theme/Theme.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Theme/Theme.php
MIT
public function providesAsset($assetType, $assetHandle = null) { $r = ResponseAssetGroup::get(); $r->markAssetAsIncluded($assetType, $assetHandle); }
Mark an asset as provided by this theme. @param string $assetType E.g. 'css' or 'javascript' (or an asset group identifier like 'jquery/ui') @param string|false $assetHandle E.g. 'core/colorpicker'.
providesAsset
php
concretecms/concretecms
concrete/src/Page/Theme/Theme.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Theme/Theme.php
MIT
public function requireAsset() { $r = ResponseAssetGroup::get(); $args = func_get_args(); call_user_func_array([$r, 'requireAsset'], $args); }
Mark an asset as reuired by this theme. Accepts the same arguments as \Concrete\Core\Http\ResponseAssetGroup::requireAsset(). @see \Concrete\Core\Http\ResponseAssetGroup::requireAsset()
requireAsset
php
concretecms/concretecms
concrete/src/Page/Theme/Theme.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Theme/Theme.php
MIT
public static function getAvailableThemes($filterInstalled = true) { $db = Loader::db(); $dh = Loader::helper('file'); $themes = $dh->getDirectoryContents(DIR_FILES_THEMES); if ($filterInstalled) { // strip out themes we've already installed $handles = $db->GetCol('select pThemeHandle from PageThemes'); $themesTemp = []; foreach ($themes as $t) { if (!in_array($t, $handles)) { $themesTemp[] = $t; } } $themes = $themesTemp; } if (count($themes) > 0) { $themesTemp = []; // get theme objects from the file system foreach ($themes as $t) { $th = static::getByFileHandle($t); if (!empty($th)) { $themesTemp[] = $th; } } $themes = $themesTemp; } return $themes; }
Get the all the themes available in the /application/themes directory. @param bool $filterInstalled true (default) to exclude the already installed themes, false to include them. @return \Concrete\Core\Page\Theme\Theme[]
getAvailableThemes
php
concretecms/concretecms
concrete/src/Page/Theme/Theme.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Theme/Theme.php
MIT
public static function getByFileHandle($handle, $dir = DIR_FILES_THEMES, $pkgHandle = '') { $dirt = $dir . '/' . $handle; if (is_dir($dirt)) { $res = static::getThemeNameAndDescription($dirt, $handle, $pkgHandle); $th = new static(); $th->pThemeHandle = $handle; $th->pThemeDirectory = $dirt; $th->pThemeName = $res->pThemeName; $th->pThemeDescription = $res->pThemeDescription; if (strlen($res->pError) > 0) { $th->error = $res->pError; } switch ($dir) { case DIR_FILES_THEMES: $th->pThemeURL = DIR_REL . '/' . DIRNAME_APPLICATION . '/' . DIRNAME_THEMES . '/' . $handle; break; } return $th; } }
Get a theme from the file system. @param string $handle the theme handle @param string $dir the parent directory that contains the theme directory @param string $pkgHandle the handle of the package providing the theme @return \Concrete\Core\Page\Theme\Theme|null
getByFileHandle
php
concretecms/concretecms
concrete/src/Page/Theme/Theme.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Theme/Theme.php
MIT
public function hasSkins(): bool { return $this->hasPresetSkins(); }
Returns true if theme or user preset skins are available @return bool
hasSkins
php
concretecms/concretecms
concrete/src/Page/Theme/Theme.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Theme/Theme.php
MIT
public function hasPresetSkins(): bool { $r = $this->getSkinDirectoryRecord(); return $r->exists(); }
Checks the filesystem and returns true if custom skins are available for the theme. @return bool
hasPresetSkins
php
concretecms/concretecms
concrete/src/Page/Theme/Theme.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Theme/Theme.php
MIT
public function getThemeDefaultSkin(): ?SkinInterface { return $this->getSkinByIdentifier(SkinInterface::SKIN_DEFAULT); }
Gets the default skin for this theme @return SkinInterface|null
getThemeDefaultSkin
php
concretecms/concretecms
concrete/src/Page/Theme/Theme.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Theme/Theme.php
MIT
public function getSkinByIdentifier(string $skinIdentifier): ?SkinInterface { if ($this->hasSkins()) { $skins = $this->getSkins(); foreach ($skins as $skin) { if ($skin->getIdentifier() == $skinIdentifier) { return $skin; } } } return null; }
Returns a skin object when passed a string identifier @param string $skinIdentifier @return SkinInterface|null
getSkinByIdentifier
php
concretecms/concretecms
concrete/src/Page/Theme/Theme.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Theme/Theme.php
MIT
public function enablePreviewRequest() { $this->setStylesheetCacheRelativePath(REL_DIR_FILES_CACHE.'/preview'); $this->setStylesheetCachePath(Config::get('concrete.cache.directory').'/preview'); $this->pThemeIsPreview = true; }
@deprecated but still required by the legacy theme customizer Set this instance to be a preview for the current request.
enablePreviewRequest
php
concretecms/concretecms
concrete/src/Page/Theme/Theme.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Theme/Theme.php
MIT
public function getThemeCustomizableStyleSheets() { $sheets = []; $env = Environment::get(); if ($this->isThemeCustomizable()) { $directory = $env->getPath( DIRNAME_THEMES.'/'.$this->getThemeHandle().'/'.DIRNAME_CSS, $this->getPackageHandle() ); $dh = Loader::helper('file'); $files = $dh->getDirectoryContents($directory); foreach ($files as $f) { if (strrchr($f, '.') == '.less') { $sheets[] = $this->getStylesheetObject($f); } } } return $sheets; }
Get all the customizable LESS stylesheets. @deprecated @return \Concrete\Core\StyleCustomizer\Stylesheet[]
getThemeCustomizableStyleSheets
php
concretecms/concretecms
concrete/src/Page/Theme/Theme.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Theme/Theme.php
MIT
public function isThemePreviewRequest() { return $this->pThemeIsPreview; }
@deprecated Is this instance a preview for the current request? @return bool
isThemePreviewRequest
php
concretecms/concretecms
concrete/src/Page/Theme/Theme.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Theme/Theme.php
MIT
public function getStylesheetObject($stylesheet) { $env = Environment::get(); $output = $this->getStylesheetCachePath() . '/' . DIRNAME_CSS . '/' . $this->getThemeHandle(); $relative = $this->getStylesheetCacheRelativePath() . '/' . DIRNAME_CSS . '/' . $this->getThemeHandle(); $r = $env->getRecord( DIRNAME_THEMES . '/' . $this->getThemeHandle() . '/' . DIRNAME_CSS . '/' . $stylesheet, $this->getPackageHandle() ); $stylesheet = new \Concrete\Core\StyleCustomizer\Stylesheet($stylesheet, $r->file, $r->url, $output, $relative); return $stylesheet; }
@param string $stylesheet @return \Concrete\Core\StyleCustomizer\Stylesheet @deprecated Get a customizable LESS stylesheet given the stylesheed base file name.
getStylesheetObject
php
concretecms/concretecms
concrete/src/Page/Theme/Theme.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Theme/Theme.php
MIT
public function getStylesheet($stylesheet) { $stylesheet = $this->getStylesheetObject($stylesheet); $style = $this->getThemeCustomStyleObject(); if (is_object($style)) { $style = $this->getThemeCustomStyleObject(); if (is_object($style)) { $valueList = $style->getValueList(); $factory = app(NormalizedVariableCollectionFactory::class); $collection = $factory->createFromStyleValueList($valueList); } } if (isset($collection) && $collection instanceof NormalizedVariableCollection) { $stylesheet->setVariableCollection($collection); } if (!$this->isThemePreviewRequest()) { if (!$stylesheet->outputFileExists() || !Config::get('concrete.cache.theme_css')) { $stylesheet->output(); } } $path = $stylesheet->getOutputRelativePath(); if ($this->isThemePreviewRequest()) { $path .= '?ts='.time(); } else { $path .= '?ts='.filemtime($stylesheet->getOutputPath()); } return $path; }
@param string $stylesheet The LESS stylesheet to compile @return string The path to the stylesheet @deprecated Look into the current CSS directory and return a fully compiled stylesheet when passed a LESS stylesheet. Also serves up custom value list values for the stylesheet if they exist.
getStylesheet
php
concretecms/concretecms
concrete/src/Page/Theme/Theme.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Theme/Theme.php
MIT
public function getThemeCustomStyleObject() { $db = Loader::db(); $row = $db->FetchAssoc('select * from PageThemeCustomStyles where pThemeID = ?', [$this->getThemeID()]); if (isset($row['pThemeID'])) { $o = new \Concrete\Core\Page\CustomStyle(); $o->setThemeID($this->getThemeID()); $o->setValueListID($row['scvlID']); $o->setPresetHandle($row['preset']); $o->setCustomCssRecordID($row['sccRecordID']); return $o; } }
@return \Concrete\Core\Page\CustomStyle|null @deprecated Get a CustomStyle object for the theme if one exists.
getThemeCustomStyleObject
php
concretecms/concretecms
concrete/src/Page/Theme/Theme.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Theme/Theme.php
MIT
public static function getByHandle($pThemeHandle) { /** @var RequestCache $cache */ $cache = Facade::getFacadeApplication()->make('cache/request'); $key = '/PageTheme/handle/' . $pThemeHandle; if ($cache->isEnabled()) { $item = $cache->getItem($key); if ($item->isHit()) { return $item->get(); } } $where = 'pThemeHandle = ?'; $args = [$pThemeHandle]; $pt = static::populateThemeQuery($where, $args); if (isset($item) && $item->isMiss()) { $item->set($pt); $cache->save($item); } return $pt; }
Get an installed theme given its handle. @param string $pThemeHandle @return \Concrete\Core\Page\Theme\Theme|null
getByHandle
php
concretecms/concretecms
concrete/src/Page/Theme/Theme.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Theme/Theme.php
MIT
public static function getByID($pThemeID) { /** @var RequestCache $cache */ $cache = Facade::getFacadeApplication()->make('cache/request'); $key = '/PageTheme/' . $pThemeID; if ($cache->isEnabled()) { $item = $cache->getItem($key); if ($item->isHit()) { return $item->get(); } } $where = 'pThemeID = ?'; $args = [$pThemeID]; $pt = static::populateThemeQuery($where, $args); if (isset($item) && $item->isMiss()) { $item->set($pt); $cache->save($item); } return $pt; }
Get an installed theme given its ID. @param int $pThemeID @return \Concrete\Core\Page\Theme\Theme|null
getByID
php
concretecms/concretecms
concrete/src/Page/Theme/Theme.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Theme/Theme.php
MIT
protected static function populateThemeQuery($where, $args) { $db = Loader::db(); $row = $db->GetRow( "select pThemeID, pThemeHandle, pThemeDescription, pkgID, pThemeName, pThemeHasCustomClass from PageThemes where {$where}", $args ); $env = Environment::get(); $pl = null; if (!empty($row)) { $standardClass = '\\Concrete\Core\\Page\\Theme\\Theme'; if ($row['pThemeHasCustomClass']) { $pkgHandle = PackageList::getHandle($row['pkgID']); $r = $env->getRecord( DIRNAME_THEMES . '/' . $row['pThemeHandle'] . '/' . FILENAME_THEMES_CLASS, $pkgHandle ); $prefix = $r->override ? true : $pkgHandle; $customClass = core_class( 'Theme\\' . Loader::helper('text')->camelcase($row['pThemeHandle']) . '\\PageTheme', $prefix ); try { $pl = Core::make($customClass); } catch (\ReflectionException $e) { $pl = Core::make($standardClass); } } else { $pl = Core::make($standardClass); } $pl->setPropertiesFromArray($row); $pkgHandle = $pl->getPackageHandle(); $pl->pThemeDirectory = $env->getPath(DIRNAME_THEMES . '/' . $row['pThemeHandle'], $pkgHandle); $pl->pThemeURL = $env->getURL(DIRNAME_THEMES . '/' . $row['pThemeHandle'], $pkgHandle); } return $pl; }
Get the instance representing an installed theme. @param string $where the SQL part used in the SELECT query @param array $args the parameters of the SQL query @return \Concrete\Core\Page\Theme\Theme|null
populateThemeQuery
php
concretecms/concretecms
concrete/src/Page/Theme/Theme.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Theme/Theme.php
MIT
public static function add($pThemeHandle, $pkg = null) { if (is_object($pkg)) { if (is_dir(DIR_PACKAGES . '/' . $pkg->getPackageHandle())) { $dir = DIR_PACKAGES . '/' . $pkg->getPackageHandle() . '/' . DIRNAME_THEMES . '/' . $pThemeHandle; } else { $dir = DIR_PACKAGES_CORE . '/' . $pkg->getPackageHandle() . '/' . DIRNAME_THEMES . '/' . $pThemeHandle; } $pkgID = $pkg->getPackageID(); } else { if (is_dir(DIR_FILES_THEMES . '/' . $pThemeHandle)) { $dir = DIR_FILES_THEMES . '/' . $pThemeHandle; $pkgID = 0; } else { $dir = DIR_FILES_THEMES_CORE . '/' . $pThemeHandle; $pkgID = 0; } } $l = static::install($dir, $pThemeHandle, $pkgID); return $l; }
Install a theme given its handle. @param string $pThemeHandle the handle of the theme to be installed. @param \Concrete\Core\Entity\Package|\Concrete\Core\Package\Package|null $pkg @return \Concrete\Core\Page\Theme\Theme|null returns NULL if the directory containing the theme could not be found @throws \Exception in case of errors.
add
php
concretecms/concretecms
concrete/src/Page/Theme/Theme.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Theme/Theme.php
MIT
public function getFilesInTheme() { $dh = Loader::helper('file'); $templateList = PageTemplate::getList(); $pts = []; foreach ($templateList as $pt) { $pts[] = $pt->getPageTemplateHandle(); } $files = []; $filesTmp = $dh->getDirectoryContents($this->pThemeDirectory); foreach ($filesTmp as $f) { if (strrchr($f, '.') == static::THEME_EXTENSION) { $fHandle = substr($f, 0, strpos($f, '.')); if ($f == FILENAME_THEMES_VIEW) { $type = PageThemeFile::TFTYPE_VIEW; } elseif ($f == FILENAME_THEMES_CLASS) { $type = PageThemeFile::TFTYPE_PAGE_CLASS; } else { if ($f == FILENAME_THEMES_DEFAULT) { $type = PageThemeFile::TFTYPE_DEFAULT; } else { if (in_array($f, SinglePage::getThemeableCorePages())) { $type = PageThemeFile::TFTYPE_SINGLE_PAGE; } else { if (in_array($fHandle, $pts)) { $type = PageThemeFile::TFTYPE_PAGE_TEMPLATE_EXISTING; } else { $type = PageThemeFile::TFTYPE_PAGE_TEMPLATE_NEW; } } } } $pf = new PageThemeFile(); $pf->setFilename($f); $pf->setType($type); $files[] = $pf; } } return $files; }
Grab all files in theme that are PHP based (or html if we go that route) and then lists them out, by type, allowing people to install them as page type, etc... @return \Concrete\Core\Page\Theme\File[]
getFilesInTheme
php
concretecms/concretecms
concrete/src/Page/Theme/Theme.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Theme/Theme.php
MIT
private static function getThemeNameAndDescription($dir, $pThemeHandle, $pkgHandle = '') { $res = new \stdClass(); $res->pThemeName = ''; $res->pThemeDescription = ''; $res->pError = ''; if (file_exists($dir . '/' . FILENAME_THEMES_DESCRIPTION)) { $con = file($dir . '/' . FILENAME_THEMES_DESCRIPTION); $res->pThemeName = trim($con[0]); $res->pThemeDescription = trim($con[1]); } $pageThemeFile = $dir . '/' . FILENAME_THEMES_CLASS; if (is_file($pageThemeFile)) { try { $cn = '\\Theme\\' . camelcase($pThemeHandle) . '\\PageTheme'; $classNames = []; if (strlen($pkgHandle)) { $classNames[] = '\\Concrete\\Package\\' . camelcase($pkgHandle) . $cn; } else { $classNames[] = '\\Application' . $cn; $classNames[] = '\\Concrete' . $cn; } $className = null; foreach ($classNames as $cn) { if (class_exists($cn, false)) { $className = $cn; break; } } if (is_null($className)) { include_once $pageThemeFile; foreach ($classNames as $cn) { if (class_exists($cn, false)) { $className = $cn; break; } } } if (is_null($className)) { $res->pError = t(/*i18n: %1$s is a filename, %2$s is a PHP class name */ 'The theme file %1$s does not define the class %2$s', FILENAME_THEMES_CLASS, ltrim($classNames[0], '\\') ); } else { $instance = new $className(); $extensionOf = '\\Concrete\\Core\\Page\\Theme\\Theme'; if (!is_a($instance, $extensionOf)) { $res->pError = t(/*i18n: %1$s is a filename, %2$s and %3$s are PHP class names */ 'The theme file %1$s should define a %2$s class that extends the class %3$s', FILENAME_THEMES_CLASS, ltrim($className, '\\'), ltrim($extensionOf, '\\') ); } else { if (method_exists($instance, 'getThemeName')) { $s = $instance->getThemeName(); if (strlen($s) > 0) { $res->pThemeName = $s; } } if (method_exists($instance, 'getThemeDescription')) { $s = $instance->getThemeDescription(); if (strlen($s) > 0) { $res->pThemeDescription = $s; } } } } } catch (\Exception $x) { $res->pError = $x->getMessage(); } } return $res; }
Get the theme details by reading a directory containing the theme. @param string $dir @param string $pThemeHandle @param string $pkgHandle @return \stdClass
getThemeNameAndDescription
php
concretecms/concretecms
concrete/src/Page/Theme/Theme.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Theme/Theme.php
MIT
public function export($node) { $pst = static::getSiteTheme(); $activated = 0; if ($pst->getThemeID() == $this->getThemeID()) { $activated = 1; } $type = $node->addChild('theme'); $type->addAttribute('handle', $this->getThemeHandle()); $type->addAttribute('package', $this->getPackageHandle()); $type->addAttribute('activated', $activated); }
Export this theme by creating the XML nodes under the provided XML node. @param \SimpleXMLElement $node
export
php
concretecms/concretecms
concrete/src/Page/Theme/Theme.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Theme/Theme.php
MIT
public static function exportList($xml) { $nxml = $xml->addChild('themes'); $list = static::getList(); foreach ($list as $pt) { $pt->export($nxml); } }
Export all the installed themes by creating the XML nodes under the provided XML node. @param \SimpleXMLElement $xml
exportList
php
concretecms/concretecms
concrete/src/Page/Theme/Theme.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Theme/Theme.php
MIT
protected static function install($dir, $pThemeHandle, $pkgID) { $result = null; if (is_dir($dir)) { $pkg = null; if ($pkgID) { $pkg = \Concrete\Core\Package\Package::getByID($pkgID); } $db = Loader::db(); $cnt = $db->getOne('select count(pThemeID) from PageThemes where pThemeHandle = ?', [$pThemeHandle]); if ($cnt > 0) { throw new \Exception(static::E_THEME_INSTALLED); } $loc = Localization::getInstance(); $loc->pushActiveContext(Localization::CONTEXT_SYSTEM); try { $res = static::getThemeNameAndDescription( $dir, $pThemeHandle, is_object($pkg) ? $pkg->getPackageHandle() : '' ); } catch (\Exception $x) { $loc->popActiveContext(); throw $x; } $loc->popActiveContext(); if (strlen($res->pError) === 0) { $pThemeName = $res->pThemeName; $pThemeDescription = $res->pThemeDescription; $db->query( 'insert into PageThemes (pThemeHandle, pThemeName, pThemeDescription, pkgID) values (?, ?, ?, ?)', [$pThemeHandle, $pThemeName, $pThemeDescription, $pkgID] ); $env = Environment::get(); $env->clearOverrideCache(); $pt = static::getByID($db->Insert_ID()); $pt->updateThemeCustomClass(); $result = $pt; } else { throw new \Exception($res->pError); } } return $result; }
Install a theme. @param string $dir @param string $pThemeHandle @param int|null $pkgID @return \Concrete\Core\Page\Theme\Theme|null returns NULL if $dir does not exist @throws \Exception in case of errors.
install
php
concretecms/concretecms
concrete/src/Page/Theme/Theme.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Theme/Theme.php
MIT
public function supportsThemeDocumentation(): bool { $provider = $this->getDocumentationProvider(); if ($provider instanceof DocumentationProviderInterface) { return true; } return false; }
Checks to see whether the capability of theme documentation exists for this theme. @return bool
supportsThemeDocumentation
php
concretecms/concretecms
concrete/src/Page/Theme/Theme.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Theme/Theme.php
MIT
public function hasThemeDocumentation(): bool { $documentationPage = $this->getThemeDocumentationParentPage(); return !is_null($documentationPage); }
Checks to see if theme documentation has been installed @return bool
hasThemeDocumentation
php
concretecms/concretecms
concrete/src/Page/Theme/Theme.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Theme/Theme.php
MIT
public function getThemeDocumentationPages(): array { $parentPage = Page::getByPath(THEME_DOCUMENTATION_PAGE_PATH . '/' . $this->getThemeHandle()); if ($parentPage && !$parentPage->isError()) { $documentationList = new PageList(); $documentationList->setSiteTreeToAll(); $documentationList->includeSystemPages(); $documentationList->filterByPath($parentPage->getCollectionPath()); $documentationList->sortByDisplayOrder(); $themeDocumentationPages = $documentationList->getResults(); return $themeDocumentationPages; } return []; }
Returns an array of documentation pages for this theme @return array
getThemeDocumentationPages
php
concretecms/concretecms
concrete/src/Page/Theme/Theme.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Theme/Theme.php
MIT
public function updateThemeCustomClass() { $env = Environment::get(); $db = Loader::db(); $r = $env->getRecord( DIRNAME_THEMES.'/'.$this->pThemeHandle.'/'.FILENAME_THEMES_CLASS, $this->getPackageHandle() ); if ($r->exists()) { $db->Execute('update PageThemes set pThemeHasCustomClass = 1 where pThemeID = ?', [$this->pThemeID]); $this->pThemeHasCustomClass = true; } else { $db->Execute('update PageThemes set pThemeHasCustomClass = 0 where pThemeID = ?', [$this->pThemeID]); $this->pThemeHasCustomClass = false; } }
(Re)Scan the theme folder to check if it contains the page_theme.php file: if so, marks the theme as having a controller.
updateThemeCustomClass
php
concretecms/concretecms
concrete/src/Page/Theme/Theme.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Theme/Theme.php
MIT
public function getThemeID() { return $this->pThemeID; }
Get the ID of the installed theme (if available). @return int|null
getThemeID
php
concretecms/concretecms
concrete/src/Page/Theme/Theme.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Theme/Theme.php
MIT
public function getThemeName() { return $this->pThemeName; }
Get the (English) name of the theme. @return string
getThemeName
php
concretecms/concretecms
concrete/src/Page/Theme/Theme.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Theme/Theme.php
MIT
public function getThemeDisplayName($format = 'html') { $value = $this->getThemeName(); if (strlen($value)) { $value = t($value); } else { $value = t('(No Name)'); } switch ($format) { case 'html': return h($value); case 'text': default: return $value; } }
Get the localized name for this theme (escaped accordingly to $format). @param string $format Escape the result in html format (if $format is 'html'); if $format is 'text' or any other value, the display name won't be escaped @return string
getThemeDisplayName
php
concretecms/concretecms
concrete/src/Page/Theme/Theme.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Theme/Theme.php
MIT
public function getPackageID() { return $this->pkgID; }
Get the ID of the package providing this theme (if available). @return int|null
getPackageID
php
concretecms/concretecms
concrete/src/Page/Theme/Theme.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Theme/Theme.php
MIT
public function getPackageHandle() { return \Concrete\Core\Package\PackageList::getHandle($this->pkgID); }
Get the handle of the package providing this theme (if available). @return string|false|null
getPackageHandle
php
concretecms/concretecms
concrete/src/Page/Theme/Theme.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Theme/Theme.php
MIT
public function hasCustomClass() { return $this->pThemeHasCustomClass; }
Returns whether a theme has a custom class.
hasCustomClass
php
concretecms/concretecms
concrete/src/Page/Theme/Theme.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Theme/Theme.php
MIT
public function getThemeHandle() { return $this->pThemeHandle; }
Get the handle of this theme. @return string
getThemeHandle
php
concretecms/concretecms
concrete/src/Page/Theme/Theme.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Theme/Theme.php
MIT
public function getThemeDescription() { return $this->pThemeDescription; }
Get the (English) description of this theme. @return string
getThemeDescription
php
concretecms/concretecms
concrete/src/Page/Theme/Theme.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Theme/Theme.php
MIT
public function getThemeDisplayDescription($format = 'html') { $value = $this->getThemeDescription(); if (strlen($value)) { $value = t($value); } else { $value = t('(No Description)'); } switch ($format) { case 'html': return h($value); case 'text': default: return $value; } }
Get the localized description for this theme (escaped accordingly to $format). @param string $format Escape the result in html format (if $format is 'html'); if $format is 'text' or any other value, the display name won't be escaped @return string
getThemeDisplayDescription
php
concretecms/concretecms
concrete/src/Page/Theme/Theme.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Theme/Theme.php
MIT
public function getThemeDirectory() { return $this->pThemeDirectory; }
Get the directory containing this theme. @return string
getThemeDirectory
php
concretecms/concretecms
concrete/src/Page/Theme/Theme.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Theme/Theme.php
MIT