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 |
---|---|---|---|---|---|---|---|
private function createTag(string $property, string $content): Element
{
$element = new Element('meta');
$element->setIsSelfClosing(true);
$element->property($property);
$element->content(htmlspecialchars($content, ENT_QUOTES, APP_CHARSET));
return $element;
}
|
@param string $property
@param string $content
@return Element
|
createTag
|
php
|
concretecms/concretecms
|
concrete/src/Sharing/OpenGraph/OpenGraph.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Sharing/OpenGraph/OpenGraph.php
|
MIT
|
private function createTagFromConfig(Page $page, $configField, $ogField): ?Element
{
$field = $this->config->get('social.opengraph.' . $configField);
if (is_string($field) && !empty($field)) {
return $this->createTag($ogField, $field);
}
$valueFrom = $field['value_from'] ?? null;
$content = null;
if ($valueFrom) {
switch ($valueFrom) {
case 'page_attribute':
$content = (string) $page->getAttribute($field['attribute']);
break;
case 'page_property':
switch ($field['property']) {
case 'title':
$content = $page->getCollectionName();
break;
case 'description':
$content = $page->getCollectionDescription();
break;
}
break;
default: // value;
$content = $field['value'] ?? '';
break;
}
}
if (!empty($content)) {
return $this->createTag($ogField, $content);
}
return null;
}
|
@param Page $page
@param $configField
@param $ogField
@return Element|null
|
createTagFromConfig
|
php
|
concretecms/concretecms
|
concrete/src/Sharing/OpenGraph/OpenGraph.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Sharing/OpenGraph/OpenGraph.php
|
MIT
|
public function createEntity(?Site $site = null)
{
if (!$site) {
$site = new Site($this->config);
} else {
$site->updateSiteConfigRepository($this->config);
}
return $site;
}
|
Either creates a completely new entity, or ensures that the passed entity has all the items it
needs to function (e.g. a config repository)
@param Site|null $site
|
createEntity
|
php
|
concretecms/concretecms
|
concrete/src/Site/Factory.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Site/Factory.php
|
MIT
|
private function createDefaultNotificationSubscriptions()
{
$sitesGroupEntity = GroupEntity::getOrCreate($this->userGroupService->getSiteParentGroup());
$pk = Key::getByHandle('notify_in_notification_center');
$pa = $pk->getPermissionAccessObject();
$pa->addListItem($sitesGroupEntity);
$pt = $pk->getPermissionAssignmentObject();
$pt->assignPermissionAccess($pa);
// This is a hack.
$db = $this->entityManager->getConnection();
$db->delete('NotificationPermissionSubscriptionList', [
'paID' => $pa->getPermissionAccessID(),
'peID' => $sitesGroupEntity->getAccessEntityID()
]);
$db->delete('NotificationPermissionSubscriptionListCustom', [
'paID' => $pa->getPermissionAccessID(),
'peID' => $sitesGroupEntity->getAccessEntityID()
]);
$db->insert('NotificationPermissionSubscriptionList', [
'paID' => $pa->getPermissionAccessID(),
'peID' => $sitesGroupEntity->getAccessEntityID(),
'permission' => 'C'
]);
$db->insert('NotificationPermissionSubscriptionListCustom', [
'paID' => $pa->getPermissionAccessID(),
'peID' => $sitesGroupEntity->getAccessEntityID(),
'nSubscriptionIdentifier' => 'workflow_progress'
]);
}
|
Takes care of adding "/Sites" to workflow notifications
|
createDefaultNotificationSubscriptions
|
php
|
concretecms/concretecms
|
concrete/src/Site/InstallationService.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Site/InstallationService.php
|
MIT
|
public function getByHandle($handle)
{
$item = $this->cache->getItem(sprintf('/site/handle/%s', $handle));
if (!$item->isMiss()) {
$site = $item->get();
} else {
$site = $this->entityManager->getRepository('Concrete\Core\Entity\Site\Site')
->findOneBy(['siteHandle' => $handle]);
$factory = new Factory($this->config);
if (is_object($site)) {
$site = $factory->createEntity($site);
}
$this->cache->save($item->set($site));
}
return $site;
}
|
@param string $handle
@return Site|null
|
getByHandle
|
php
|
concretecms/concretecms
|
concrete/src/Site/Service.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Site/Service.php
|
MIT
|
public function add(Type $type, Theme $theme, $handle, $name, $locale, $default = false)
{
$factory = new Factory($this->config);
$site = $factory->createEntity();
$site->setSiteHandle($handle);
$site->setIsDefault($default);
$site->setType($type);
$site->setThemeID($theme->getThemeID());
$site->getConfigRepository()->save('name', $name);
$this->entityManager->persist($site);
$this->entityManager->flush();
$data = explode('_', $locale);
$locale = new Locale();
$locale->setSite($site);
$locale->setIsDefault(true);
$locale->setLanguage($data[0]);
$locale->setCountry($data[1]);
$localeService = new \Concrete\Core\Localization\Locale\Service($this->entityManager);
$localeService->updatePluralSettings($locale);
$this->entityManager->persist($locale);
$this->entityManager->flush();
$this->entityManager->refresh($site);
$skeletonService = $this->siteTypeService->getSkeletonService();
$skeleton = $skeletonService->getSkeleton($type);
if ($skeleton) {
$skeletonService->publishSkeletonToSite($skeleton, $site);
}
// Add the default groups
$groupService = $this->siteTypeService->getGroupService();
$parent = $groupService->createSiteGroup($site);
$groups = $groupService->getSiteTypeGroups($type);
if ($groups) {
foreach ($groups as $group) {
/**
* @var $group \Concrete\Core\Entity\Site\Group\Group
*/
$siteGroup = $groupService->createInstanceGroup($group, $parent);
$relation = new Relation();
$relation->setSite($site);
$relation->setInstanceGroupID($siteGroup->getGroupID());
$relation->setSiteGroup($group);
$group->getSiteGroupRelations()->add($relation);
$this->entityManager->persist($group);
}
}
// Add the default attributes
if ($skeleton) {
$attributes = $skeletonService->getAttributeValues($skeleton);
foreach ($attributes as $attribute) {
/**
* @var $attribute SiteTypeValue
*/
$site->setAttribute($attribute->getAttributeKey(), $attribute->getValueObject());
}
}
$this->entityManager->flush();
// Populate all the config values from the default site into this new site.
// This is not ideal since it will fail if we don't update it after we add new
// config values, but this will have to do for now
// This code is not great, let's find a better solution
/*
$defaultSite = $this->getDefault();
$defaultSiteConfig = $defaultSite->getConfigRepository();
$config = $site->getConfigRepository();
if ($defaultSiteConfig) {
foreach (['user', 'editor'] as $key) {
$config->save($key, $defaultSiteConfig->get($key));
}
}
*/
/**
* @var $manager Manager;
*/
$request = Request::createFromGlobals();
$controller = $this->getController($site);
$site = $controller->add($site, $request);
return $site;
}
|
@param Type $type
@param Theme $theme
@param string $handle
@param string $name
@param string $locale
@param bool $default
@return Site
|
add
|
php
|
concretecms/concretecms
|
concrete/src/Site/Service.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Site/Service.php
|
MIT
|
public function getSiteTreeByID($siteTreeID)
{
return $this->entityManager->getRepository('Concrete\Core\Entity\Site\Tree')
->find($siteTreeID);
}
|
@param int $siteTreeID
@return \Concrete\Core\Entity\Site\Tree|null
|
getSiteTreeByID
|
php
|
concretecms/concretecms
|
concrete/src/Site/Service.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Site/Service.php
|
MIT
|
public function getByID($id)
{
$site = $this->entityManager->getRepository('Concrete\Core\Entity\Site\Site')
->find($id);
$factory = new Factory($this->config);
if (is_object($site)) {
return $factory->createEntity($site);
}
}
|
@param int $id
@return Site|null
|
getByID
|
php
|
concretecms/concretecms
|
concrete/src/Site/Service.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Site/Service.php
|
MIT
|
public function getList($sort = 'name')
{
$sites = $this->entityManager->getRepository('Concrete\Core\Entity\Site\Site')
->findAll();
$list = [];
$factory = new Factory($this->config);
foreach ($sites as $site) {
$list[] = $factory->createEntity($site);
}
switch ($sort) {
case 'name':
$comparer = new Comparer();
usort($list, function ($siteA, $siteB) use ($comparer) {
return $comparer->compare($siteA->getSiteName(), $siteB->getSiteName());
});
break;
}
return $list;
}
|
Returns a list of sites. If $sort = 'name' then the sites will be sorted by site name. If sort is false it will
not be sorted. Only name is supported for now.
@param string $sort
@return Site[]
|
getList
|
php
|
concretecms/concretecms
|
concrete/src/Site/Service.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Site/Service.php
|
MIT
|
public function installDefault($locale = null)
{
if (!$locale) {
$locale = Localization::BASE_LOCALE;
}
$siteConfig = $this->config->get('site');
$defaultSite = array_get($siteConfig, 'default');
$factory = new Factory($this->config);
$site = $factory->createEntity();
$site->setSiteHandle(array_get($siteConfig, "sites.{$defaultSite}.handle"));
$site->setIsDefault(true);
$data = explode('_', $locale);
$locale = new Locale();
$locale->setSite($site);
$locale->setIsDefault(true);
$locale->setLanguage($data[0]);
$locale->setCountry($data[1]);
$tree = new SiteTree();
$cID = false;
$connection = $this->entityManager->getConnection();
if ($connection && $connection->tableExists('MultilingualSections')) {
$cID = $connection->fetchColumn('select cID from MultilingualSections where msLanguage = ? and msCountry = ?', [$data[0], $data[1]]);
}
if (!$cID) {
$cID = (int) Page::getHomePageID();
if ($cID === 0) {
$cID = HOME_CID;
}
}
$tree->setSiteHomePageID($cID);
$tree->setLocale($locale);
$locale->setSiteTree($tree);
$site->getLocales()->add($locale);
$service = $this->siteTypeService;
$type = $service->getDefault();
$site->setType($type);
$localeService = new \Concrete\Core\Localization\Locale\Service($this->entityManager);
$localeService->updatePluralSettings($locale);
$this->entityManager->persist($site);
$this->entityManager->persist($tree);
$this->entityManager->persist($locale);
$this->entityManager->flush();
$this->cache->delete('site');
return $site;
}
|
@param string|null $locale
@return Site
|
installDefault
|
php
|
concretecms/concretecms
|
concrete/src/Site/Service.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Site/Service.php
|
MIT
|
public function getSite()
{
$item = $this->cache->getItem('site');
if (!$item->isMiss()) {
$site = $item->get();
} else {
$site = $this->resolverFactory->createResolver($this)->getSite();
$this->cache->save($item->set($site));
}
return $site;
}
|
Resolve the active site
This method MUST be treated as `final` by extending drivers, but MAY be replaced by a complete override.
@return Site|null
|
getSite
|
php
|
concretecms/concretecms
|
concrete/src/Site/Service.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Site/Service.php
|
MIT
|
public function getActiveSiteForEditing()
{
return $this->resolverFactory->createResolver($this)->getActiveSiteForEditing();
}
|
Resolve the active site for editing
This method MUST be treated as `final` by extending drivers, but MAY be replaced by a complete override.
@return Site|null
|
getActiveSiteForEditing
|
php
|
concretecms/concretecms
|
concrete/src/Site/Service.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Site/Service.php
|
MIT
|
public function getSiteByExpressResultsNodeID(int $resultsNodeID): ?Site
{
/** @TODO Use an overridable way to resolve results nodes */
$siteResultsNode = Node::getByID($resultsNodeID);
if ($siteResultsNode instanceof ExpressEntrySiteResults) {
return $this->getSiteByExpressResultsNode($siteResultsNode);
}
return null;
}
|
Resolve the site instance associated with a given results node ID
This is usually useful when resolving a site object from an express entry.
You'd do `$service->getByExpressNodeID($entry->getResultsNodeID());`
@param int $resultsNodeID
@return Site|null
|
getSiteByExpressResultsNodeID
|
php
|
concretecms/concretecms
|
concrete/src/Site/Service.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Site/Service.php
|
MIT
|
public function getSiteByExpressResultsNode(ExpressEntrySiteResults $siteResultsNode): ?Site
{
return $this->getByID($siteResultsNode->getSiteID());
}
|
Resolve a site instance using an express results node
This is typically useful when resolving the site from an express entry.
@see Service::getSiteByExpressResultsNodeID()
@param ExpressEntrySiteResults $siteResultsNode
@return Site|null
|
getSiteByExpressResultsNode
|
php
|
concretecms/concretecms
|
concrete/src/Site/Service.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Site/Service.php
|
MIT
|
public function getTotalResults()
{
$query = $this->deliverQueryObject();
return $query->resetQueryParts(['groupBy', 'orderBy'])->select('count(distinct s.siteID)')->setMaxResults(1)->execute()->fetchColumn();
}
|
The total results of the query.
@return int
|
getTotalResults
|
php
|
concretecms/concretecms
|
concrete/src/Site/SiteList.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Site/SiteList.php
|
MIT
|
protected function createPaginationObject()
{
$adapter = new DoctrineDbalAdapter($this->deliverQueryObject(), function ($query) {
$query->resetQueryParts(['groupBy', 'orderBy'])->select('count(distinct s.siteID)')->setMaxResults(1);
});
$pagination = new Pagination($this, $adapter);
return $pagination;
}
|
Gets the pagination object for the query.
@return Pagination
|
createPaginationObject
|
php
|
concretecms/concretecms
|
concrete/src/Site/SiteList.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Site/SiteList.php
|
MIT
|
protected function transformKey($key)
{
$key = sprintf('site.sites.%s.%s', $this->site->getSiteHandle(), $key);
return parent::transformKey($key);
}
|
Prepend the "site" config group and the current site handle
@param $key
@return string
|
transformKey
|
php
|
concretecms/concretecms
|
concrete/src/Site/Config/Liaison.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Site/Config/Liaison.php
|
MIT
|
private function fixMultilingualPageRelations(Connection $cn, $updateMultilingualRelation, array $pageIDs)
{
$pageIDsJoined = implode(',', $pageIDs);
$cn->query(str_replace(':cIDs:', $pageIDsJoined, $updateMultilingualRelation));
$childPageIDs = $cn->query('SELECT cID FROM Pages WHERE cParentID IN (' . $pageIDsJoined . ')')->fetchAll();
if (!empty($childPageIDs)) {
$tempChildPageIDs = array();
foreach ($childPageIDs as $oneChildPage) {
$tempChildPageIDs[] = intval($oneChildPage['cID']);
}
$childPageIDs = $tempChildPageIDs;
foreach (array_chunk($childPageIDs, 500) as $chunk) {
$this->fixMultilingualPageRelations($cn, $updateMultilingualRelation, $chunk);
}
}
}
|
@param Connection $cn
@param string $selectChildren
@param string $updateMultilingualRelation
@param int[] $pageIDs
|
fixMultilingualPageRelations
|
php
|
concretecms/concretecms
|
concrete/src/Site/Locale/Listener.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Site/Locale/Listener.php
|
MIT
|
public function displayItem()
{
return count($this->service->getList()) > 1 && $this->page->getPageController() instanceof DashboardPageController;
}
|
Determine whether item should be displayed
@return bool
|
displayItem
|
php
|
concretecms/concretecms
|
concrete/src/Site/Menu/Item/SiteListController.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Site/Menu/Item/SiteListController.php
|
MIT
|
public function getTreeIdsForQuery(Site $site): string
{
$treeIDs = [0];
foreach($site->getLocales() as $locale) {
$tree = $locale->getSiteTree();
if (is_object($tree)) {
$treeIDs[] = $tree->getSiteTreeID();
}
}
$treeIDs = implode(',', $treeIDs);
return $treeIDs;
}
|
A helper method for getting tree IDs for use in a query. Includes "0" in the query out of simplicity
@param Site $site
@return array
|
getTreeIdsForQuery
|
php
|
concretecms/concretecms
|
concrete/src/Site/Tree/Traits/GetTreeIdsForQueryTrait.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Site/Tree/Traits/GetTreeIdsForQueryTrait.php
|
MIT
|
public function getByPackage(Package $package): array
{
return $this->entityManager->getRepository(Type::class)->findByPackage($package);
}
|
@return \Concrete\Core\Entity\Site\Type[]
|
getByPackage
|
php
|
concretecms/concretecms
|
concrete/src/Site/Type/Service.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Site/Type/Service.php
|
MIT
|
public function getList(): array
{
return $this->entityManager->getRepository(Type::class)->findAll();
}
|
@return \Concrete\Core\Entity\Site\Type[]
|
getList
|
php
|
concretecms/concretecms
|
concrete/src/Site/Type/Service.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Site/Type/Service.php
|
MIT
|
public function getUserAddedList(): Collection
{
$criteria = Criteria::create()
->where(Criteria::expr()->neq('siteTypeHandle', 'default'))
;
return $this->entityManager->getRepository(Type::class)->matching($criteria)
;
}
|
@return \Doctrine\Common\Collections\Collection|\Concrete\Core\Entity\Site\Type[]
|
getUserAddedList
|
php
|
concretecms/concretecms
|
concrete/src/Site/Type/Service.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Site/Type/Service.php
|
MIT
|
public function driver($driver = null)
{
if (!isset($this->customCreators[$driver]) && !isset($this->drivers[$driver])) {
return $this->getStandardController();
}
return parent::driver($driver);
}
|
{@inheritdoc}
@see \Illuminate\Support\Manager::driver()
@throws \InvalidArgumentException
@return \Concrete\Core\Site\Type\Controller\ControllerInterface
|
driver
|
php
|
concretecms/concretecms
|
concrete/src/Site/Type/Controller/Manager.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Site/Type/Controller/Manager.php
|
MIT
|
public function add(Site $site, Request $request): Site
{
$this->addSiteFolder($site, $request);
return $site;
}
|
{@inheritdoc}
@see \Concrete\Core\Site\Type\Controller\ControllerInterface::add()
|
add
|
php
|
concretecms/concretecms
|
concrete/src/Site/Type/Controller/StandardController.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Site/Type/Controller/StandardController.php
|
MIT
|
public function update(Site $site, Request $request): Site
{
return $site;
}
|
{@inheritdoc}
@see \Concrete\Core\Site\Type\Controller\ControllerInterface::update()
|
update
|
php
|
concretecms/concretecms
|
concrete/src/Site/Type/Controller/StandardController.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Site/Type/Controller/StandardController.php
|
MIT
|
public function delete(Site $site): bool
{
return false;
}
|
{@inheritdoc}
@see \Concrete\Core\Site\Type\Controller\ControllerInterface::delete()
|
delete
|
php
|
concretecms/concretecms
|
concrete/src/Site/Type/Controller/StandardController.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Site/Type/Controller/StandardController.php
|
MIT
|
public function addType(Type $type): Type
{
$home = $this->skeletonService->getHomePage($type);
$this->permissionsApplier->applyAssignment(
new ObjectAssignment(
new \Concrete\Core\Permission\Registry\Entry\Object\Object\Page($home),
new DefaultHomePageAccessRegistry()
)
);
return $type;
}
|
{@inheritdoc}
@see \Concrete\Core\Site\Type\Controller\ControllerInterface::addType()
|
addType
|
php
|
concretecms/concretecms
|
concrete/src/Site/Type/Controller/StandardController.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Site/Type/Controller/StandardController.php
|
MIT
|
public function getFormatter(Type $type): FormatterInterface
{
return new DefaultFormatter($type);
}
|
{@inheritdoc}
@see \Concrete\Core\Site\Type\Controller\ControllerInterface::getFormatter()
|
getFormatter
|
php
|
concretecms/concretecms
|
concrete/src/Site/Type/Controller/StandardController.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Site/Type/Controller/StandardController.php
|
MIT
|
public function getSiteTypeDescription(): string
{
return '';
}
|
{@inheritdoc}
@see \Concrete\Core\Site\Type\Formatter\FormatterInterface::getSiteTypeDescription()
|
getSiteTypeDescription
|
php
|
concretecms/concretecms
|
concrete/src/Site/Type/Formatter/DefaultFormatter.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Site/Type/Formatter/DefaultFormatter.php
|
MIT
|
public function getSiteTypeIconElement(): Element
{
return (new Element('i'))
->addClass('fas fa-file')
;
}
|
{@inheritdoc}
@see \Concrete\Core\Site\Type\Formatter\FormatterInterface::getSiteTypeIconElement()
|
getSiteTypeIconElement
|
php
|
concretecms/concretecms
|
concrete/src/Site/Type/Formatter/DefaultFormatter.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Site/Type/Formatter/DefaultFormatter.php
|
MIT
|
public function createSiteGroup(Site $site)
{
$name = $site->getSiteName();
return Group::add($site->getSiteName(), '', $this->getSiteParentGroup());
}
|
Creates the concrete5 user group that will hold instance groups for this site.
|
createSiteGroup
|
php
|
concretecms/concretecms
|
concrete/src/Site/User/Group/Service.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Site/User/Group/Service.php
|
MIT
|
public function track(TrackableInterface $trackable)
{
foreach ($this->getTrackerGenerator() as $tracker) {
$tracker->track($trackable);
}
return $this;
}
|
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/Statistics/UsageTracker/AggregateTracker.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Statistics/UsageTracker/AggregateTracker.php
|
MIT
|
public function forget(TrackableInterface $trackable)
{
foreach ($this->getTrackerGenerator() as $tracker) {
$tracker->forget($trackable);
}
return $this;
}
|
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/Statistics/UsageTracker/AggregateTracker.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Statistics/UsageTracker/AggregateTracker.php
|
MIT
|
public function addTracker($tracker, callable $creator)
{
$this->creators[$tracker] = $creator;
$this->map[] = $tracker;
if (isset($this->trackers[$tracker])) {
unset($this->trackers[$tracker]);
}
return $this;
}
|
Register a custom tracker creator Closure.
@param string $tracker The handle of the tracker
@param callable $creator The closure responsible for returning the new tracker instance
@return static
|
addTracker
|
php
|
concretecms/concretecms
|
concrete/src/Statistics/UsageTracker/AggregateTracker.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Statistics/UsageTracker/AggregateTracker.php
|
MIT
|
public function tracker($tracker)
{
// We've already made this tracker, so just return it.
if ($cached = array_get($this->trackers, $tracker)) {
return $cached;
}
// We've got a creator, lets create the tracker
if ($creator = array_get($this->creators, $tracker)) {
// Create through Container
$created = $this->app->call($creator);
$this->trackers[$tracker] = $created;
unset($this->creators[$tracker]);
return $created;
}
throw new InvalidArgumentException("Tracker [$tracker] not supported.");
}
|
Get a tracker by handle
@param $tracker
@return TrackerInterface
|
tracker
|
php
|
concretecms/concretecms
|
concrete/src/Statistics/UsageTracker/AggregateTracker.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Statistics/UsageTracker/AggregateTracker.php
|
MIT
|
public function register()
{
// Make the main tracker manager a singleton
$this->app->singleton(AggregateTracker::class, function($app) {
/** @var AggregateTracker $tracker */
$tracker = $app->build(AggregateTracker::class);
if ($trackers = $app['config']['statistics.trackers']) {
foreach ($trackers as $key => $tracker_string) {
$tracker->addTracker($key, function (Application $app) use ($tracker_string) {
return $app->make($tracker_string);
});
}
}
return $tracker;
});
// Bind the manager interface to the tracker singleton
$this->app->bind(TrackerManagerInterface::class, AggregateTracker::class);
// Bind a useful abstract string
$this->app->bind('statistics/tracker', AggregateTracker::class);
}
|
Registers the services provided by this provider.
|
register
|
php
|
concretecms/concretecms
|
concrete/src/Statistics/UsageTracker/ServiceProvider.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Statistics/UsageTracker/ServiceProvider.php
|
MIT
|
public static function getByID($id)
{
if (!$id) {
return null;
}
$app = Application::getFacadeApplication();
$em = $app->make(EntityManagerInterface::class);
return $em->find(CustomCssRecordEntity::class, $id);
}
|
Get a CustomCssRecord entity given its ID.
@param int|mixed $id
@return \Concrete\Core\Entity\StyleCustomizer\CustomCssRecord|null
|
getByID
|
php
|
concretecms/concretecms
|
concrete/src/StyleCustomizer/CustomCssRecord.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/StyleCustomizer/CustomCssRecord.php
|
MIT
|
public function setName($name)
{
$this->name = $name;
}
|
Set the name of the style customizer set.
@param string $name
|
setName
|
php
|
concretecms/concretecms
|
concrete/src/StyleCustomizer/Set.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/StyleCustomizer/Set.php
|
MIT
|
public function getName()
{
return $this->name;
}
|
Get the name of the style customizer set.
@return string
|
getName
|
php
|
concretecms/concretecms
|
concrete/src/StyleCustomizer/Set.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/StyleCustomizer/Set.php
|
MIT
|
public function getDisplayName($format = 'html')
{
$value = tc('StyleSetName', $this->getName());
switch ($format) {
case 'html':
return h($value);
case 'text':
default:
return $value;
}
}
|
Get the display name for this style set (localized and escaped accordingly to $format).
@param string $format = 'html'
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
|
getDisplayName
|
php
|
concretecms/concretecms
|
concrete/src/StyleCustomizer/Set.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/StyleCustomizer/Set.php
|
MIT
|
public function addStyle(Style $style)
{
$this->styles[] = $style;
}
|
Add a style to this set.
@param \Concrete\Core\StyleCustomizer\Style\Style $style
|
addStyle
|
php
|
concretecms/concretecms
|
concrete/src/StyleCustomizer/Set.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/StyleCustomizer/Set.php
|
MIT
|
public function getStyles()
{
return $this->styles;
}
|
Get the list of styles associated to this set.
@return \Concrete\Core\StyleCustomizer\Style\Style[]
|
getStyles
|
php
|
concretecms/concretecms
|
concrete/src/StyleCustomizer/Set.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/StyleCustomizer/Set.php
|
MIT
|
public function addSet($name)
{
$s = new Set();
$s->setName($name);
$this->sets[] = $s;
return $s;
}
|
Add a new empty style set.
@param string $name the name of the style set
@return \Concrete\Core\StyleCustomizer\Set
|
addSet
|
php
|
concretecms/concretecms
|
concrete/src/StyleCustomizer/StyleList.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/StyleCustomizer/StyleList.php
|
MIT
|
public function getSets()
{
return $this->sets;
}
|
Get the list of the style sets.
@return \Concrete\Core\StyleCustomizer\Set[]
|
getSets
|
php
|
concretecms/concretecms
|
concrete/src/StyleCustomizer/StyleList.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/StyleCustomizer/StyleList.php
|
MIT
|
public function getAllStyles(): iterable
{
foreach ($this->getSets() as $set) {
foreach ($set->getStyles() as $style) {
yield $style;
}
}
}
|
Traverses all sets and retrieves all styles. Basically a shortcut to allow developers not to have to traverse
the sets themselves when working with the basic values in a style list.
@return Style[]
|
getAllStyles
|
php
|
concretecms/concretecms
|
concrete/src/StyleCustomizer/StyleList.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/StyleCustomizer/StyleList.php
|
MIT
|
public function getCss()
{
$parser = new \Less_Parser(
array(
'cache_dir' => Config::get('concrete.cache.directory'),
'compress' => (bool) Config::get('concrete.theme.compress_preprocessor_output'),
'sourceMap' => !Config::get('concrete.theme.compress_preprocessor_output') && (bool) Config::get('concrete.theme.generate_less_sourcemap'),
)
);
$parser = $parser->parseFile($this->file, $this->sourceUriRoot);
if (isset($this->variableCollection) && $this->variableCollection instanceof NormalizedVariableCollection) {
$variables = [];
foreach ($this->variableCollection->getValues() as $variable) {
$variables[$variable->getName()] = (string) $variable->getValue();
}
$parser->ModifyVars($variables);
}
$css = $parser->getCss();
return $css;
}
|
Compiles the stylesheet using LESS. If a ValueList is provided they are
injected into the stylesheet.
@return string CSS
|
getCss
|
php
|
concretecms/concretecms
|
concrete/src/StyleCustomizer/Stylesheet.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/StyleCustomizer/Stylesheet.php
|
MIT
|
public function compileFromPreset(
Customizer $customizer,
PresetInterface $preset,
NormalizedVariableCollection $collection
): string {
$collection = $this->addCustomizerVariablesToCollection($customizer, $collection);
$customizerType = $customizer->getType();
$presetType = $customizerType->getPresetType();
$processor = $customizerType->getStyleProcessor();
$file = $presetType->getEntryPointFile($preset);
$css = $processor->compileFileToString($file, $collection);
return $css;
}
|
@param Customizer $customizer
@param PresetInterface $preset
@param NormalizedVariableCollection $collection
@return string
|
compileFromPreset
|
php
|
concretecms/concretecms
|
concrete/src/StyleCustomizer/Compiler/Compiler.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/StyleCustomizer/Compiler/Compiler.php
|
MIT
|
public static function getByID($issID)
{
if (!$issID) {
return null;
}
$app = Application::getFacadeApplication();
$em = $app->make(EntityManagerInterface::class);
return $em->find(StyleSetEntity::class, $issID);
}
|
Get a StyleSet entity given its ID.
@param int $issID
@return \Concrete\Core\Entity\StyleCustomizer\Inline\StyleSet|null
|
getByID
|
php
|
concretecms/concretecms
|
concrete/src/StyleCustomizer/Inline/StyleSet.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/StyleCustomizer/Inline/StyleSet.php
|
MIT
|
public static function import(SimpleXMLElement $node)
{
$o = new StyleSetEntity();
$o->setBackgroundColor((string) $node->backgroundColor);
$filename = (string) $node->backgroundImage;
if ($filename) {
$app = Application::getFacadeApplication();
$inspector = $app->make('import/value_inspector');
$result = $inspector->inspect($filename);
$fID = $result->getReplacedValue();
if ($fID) {
$o->setBackgroundImageFileID($fID);
}
}
$xmlService = app(Xml::class);
$o->setBackgroundRepeat((string) $node->backgroundRepeat);
$o->setBackgroundSize((string) $node->backgroundSize);
$o->setBackgroundPosition((string) $node->backgroundPosition);
$o->setBorderWidth((string) $node->borderWidth);
$o->setBorderColor((string) $node->borderColor);
$o->setBorderStyle((string) $node->borderStyle);
$o->setBorderRadius((string) $node->borderRadius);
$o->setBaseFontSize((string) $node->baseFontSize);
$o->setAlignment((string) $node->alignment);
$o->setTextColor((string) $node->textColor);
$o->setLinkColor((string) $node->linkColor);
$o->setPaddingTop((string) $node->paddingTop);
$o->setPaddingBottom((string) $node->paddingBottom);
$o->setPaddingLeft((string) $node->paddingLeft);
$o->setPaddingRight((string) $node->paddingRight);
$o->setMarginTop((string) $node->marginTop);
$o->setMarginBottom((string) $node->marginBottom);
$o->setMarginLeft((string) $node->marginLeft);
$o->setMarginRight((string) $node->marginRight);
$o->setRotate((string) $node->rotate);
$o->setBoxShadowHorizontal((string) $node->boxShadowHorizontal);
$o->setBoxShadowVertical((string) $node->boxShadowVertical);
$o->setBoxShadowBlur((string) $node->boxShadowBlur);
$o->setBoxShadowSpread((string) $node->boxShadowSpread);
$o->setBoxShadowColor((string) $node->boxShadowColor);
$o->setBoxShadowInset($xmlService->getBool($node->boxShadowInset));
$o->setCustomClass((string) $node->customClass);
$o->setCustomID((string) $node->customID);
$o->setCustomElementAttribute((string) $node->customElementAttribute);
$o->setHideOnExtraSmallDevice($xmlService->getBool($node->hideOnExtraSmallDevice));
$o->setHideOnSmallDevice($xmlService->getBool($node->hideOnSmallDevice));
$o->setHideOnMediumDevice($xmlService->getBool($node->hideOnMediumDevice));
$o->setHideOnLargeDevice($xmlService->getBool($node->hideOnLargeDevice));
$o->save();
return $o;
}
|
Import a StyleSet entity from an XML node.
@param \SimpleXMLElement $node
@return \Concrete\Core\Entity\StyleCustomizer\Inline\StyleSet
|
import
|
php
|
concretecms/concretecms
|
concrete/src/StyleCustomizer/Inline/StyleSet.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/StyleCustomizer/Inline/StyleSet.php
|
MIT
|
public static function populateFromRequest(Request $request)
{
$post = $request->request;
$set = new StyleSetEntity();
$return = false;
if ($post->has('backgroundColor') && trim($post->get('backgroundColor')) !== '') {
$set->setBackgroundColor($post->get('backgroundColor'));
$set->setBackgroundRepeat($post->get('backgroundRepeat'));
$set->setBackgroundSize($post->get('backgroundSize'));
$set->setBackgroundPosition($post->get('backgroundPosition'));
$return = true;
}
$fID = (int) $post->get('backgroundImageFileID');
if ($fID > 0) {
$set->setBackgroundImageFileID($fID);
$set->setBackgroundRepeat($post->get('backgroundRepeat'));
$set->setBackgroundSize($post->get('backgroundSize'));
$set->setBackgroundPosition($post->get('backgroundPosition'));
$return = true;
}
$hod = $post->get('hideOnDevice');
if (is_array($hod)) {
if (!empty($hod[GridFramework::DEVICE_CLASSES_HIDE_ON_EXTRA_SMALL])) {
$set->setHideOnExtraSmallDevice(true);
$return = true;
}
if (!empty($hod[GridFramework::DEVICE_CLASSES_HIDE_ON_SMALL])) {
$set->setHideOnSmallDevice(true);
$return = true;
}
if (!empty($hod[GridFramework::DEVICE_CLASSES_HIDE_ON_MEDIUM])) {
$set->setHideOnMediumDevice(true);
$return = true;
}
if (!empty($hod[GridFramework::DEVICE_CLASSES_HIDE_ON_LARGE])) {
$set->setHideOnLargeDevice(true);
$return = true;
}
}
$v = trim($post->get('linkColor', ''));
if ($v !== '') {
$set->setLinkColor($v);
$return = true;
}
$v = trim($post->get('textColor', ''));
if ($v !== '') {
$set->setTextColor($v);
$return = true;
}
$v = trim($post->get('baseFontSize', ''));
if (!in_array($v, ['', '0px'], true)) {
$set->setBaseFontSize($v);
$return = true;
}
$v = trim($post->get('marginTop', ''));
if (!in_array($v, ['', '0px'], true)) {
$set->setMarginTop($v);
$return = true;
}
$v = trim($post->get('marginRight', ''));
if (!in_array($v, ['', '0px'], true)) {
$set->setMarginRight($v);
$return = true;
}
$v = trim($post->get('marginBottom', ''));
if (!in_array($v, ['', '0px'], true)) {
$set->setMarginBottom($v);
$return = true;
}
$v = trim($post->get('marginLeft', ''));
if (!in_array($v, ['', '0px'], true)) {
$set->setMarginLeft($v);
$return = true;
}
$v = trim($post->get('paddingTop', ''));
if (!in_array($v, ['', '0px'], true)) {
$set->setPaddingTop($v);
$return = true;
}
$v = trim($post->get('paddingRight', ''));
if (!in_array($v, ['', '0px'], true)) {
$set->setPaddingRight($v);
$return = true;
}
$v = trim($post->get('paddingBottom', ''));
if (!in_array($v, ['', '0px'], true)) {
$set->setPaddingBottom($v);
$return = true;
}
$v = trim($post->get('paddingLeft', ''));
if (!in_array($v, ['', '0px'], true)) {
$set->setPaddingLeft($v);
$return = true;
}
$v = trim($post->get('borderWidth', ''));
if (!in_array($v, ['', '0px'], true)) {
$set->setBorderWidth($v);
$set->setBorderStyle($post->get('borderStyle'));
$set->setBorderColor($post->get('borderColor'));
$return = true;
}
$v = trim($post->get('borderRadius', ''));
if (!in_array($v, ['', '0px'], true)) {
$set->setBorderRadius($v);
$return = true;
}
$v = trim($post->get('alignment', ''));
if ($v !== '') {
$set->setAlignment($v);
$return = true;
}
$v = $post->get('rotate');
if ($v) {
$set->setRotate($v);
$return = true;
}
if ($post->has('boxShadowColor')) {
$boxShadowHorizontal = trim($post->get('boxShadowHorizontal', '')) ?: '0px';
$boxShadowVertical = trim($post->get('boxShadowVertical', '')) ?: '0px';
$boxShadowBlur = trim($post->get('boxShadowBlur', '')) ?: '0px';
$boxShadowSpread = trim($post->get('boxShadowSpread', '')) ?: '0px';
$boxShadowInset = (bool) $post->get('boxShadowInset');
if ($boxShadowHorizontal !== '0px' || $boxShadowVertical !== '0px' || $boxShadowBlur !== '0px' || $boxShadowSpread !== '0px') {
$set->setBoxShadowColor($post->get('boxShadowColor'));
$set->setBoxShadowBlur($boxShadowBlur);
$set->setBoxShadowHorizontal($boxShadowHorizontal);
$set->setBoxShadowVertical($boxShadowVertical);
$set->setBoxShadowSpread($boxShadowSpread);
$set->setBoxShadowInset($boxShadowInset);
$return = true;
}
}
$v = $post->get('customClass');
if (is_array($v)) {
$customClasses = self::sanitizeCssClasses($v);
if ($customClasses !== null) {
$set->setCustomClass($customClasses);
$return = true;
}
}
$v = trim($post->get('customID', ''));
if ($v) {
$set->setCustomID($v);
$return = true;
}
$v = trim($post->get('customElementAttribute', ''));
if ($v !== '') {
// strip class attributes
$pattern = '/(class\s*=\s*["\'][^\'"]*["\'])/i';
$customElementAttribute = preg_replace($pattern, '', $v);
// strip ID attributes
$pattern = '/(id\s*=\s*["\'][^\'"]*["\'])/i';
$customElementAttribute = preg_replace($pattern, '', $customElementAttribute);
// don't save if there are odd numbers of single/double quotes
$singleQuoteCount = preg_match_all('/([\'])/i', $customElementAttribute);
$doubleQuoteCount = preg_match_all('/(["])/i', $customElementAttribute);
if ($singleQuoteCount % 2 !== 0 || $doubleQuoteCount % 2 !== 0) {
throw new UserMessageException(t('Custom Element Attribute input: unclosed quote(s)'));
}
$set->setCustomElementAttribute(trim($customElementAttribute));
$return = true;
}
return $return ? $set : null;
}
|
If the request contains any fields that are valid to save as a style set, we return the style set object
pre-save. If it's not (e.g. there's a background repeat but no actual background image, empty strings, etc...)
then we return null.
@param \Symfony\Component\HttpFoundation\Request $request
@return \Concrete\Core\Entity\StyleCustomizer\Inline\StyleSet|null
|
populateFromRequest
|
php
|
concretecms/concretecms
|
concrete/src/StyleCustomizer/Inline/StyleSet.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/StyleCustomizer/Inline/StyleSet.php
|
MIT
|
public function __construct($name, $r, $g, $b, $a = 1)
{
$this->name = $name;
$this->r = $r;
$this->g = $g;
$this->b = $b;
$this->a = $a;
if ($a === null) {
$this->a = 1;
}
}
|
NumberVariable constructor.
@param $r
@param $g
@param $b
@param $a
|
__construct
|
php
|
concretecms/concretecms
|
concrete/src/StyleCustomizer/Normalizer/ColorVariable.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/StyleCustomizer/Normalizer/ColorVariable.php
|
MIT
|
public function add($element)
{
return parent::add($element);
}
|
@param VariableInterface $element
@return bool|true
|
add
|
php
|
concretecms/concretecms
|
concrete/src/StyleCustomizer/Normalizer/NormalizedVariableCollection.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/StyleCustomizer/Normalizer/NormalizedVariableCollection.php
|
MIT
|
public function __construct(ScssNormalizerCompiler $compiler, Filesystem $fileSystem)
{
$this->compiler = $compiler;
$this->fileSystem = $fileSystem;
}
|
ScssNormalizer constructor.
@param ScssNormalizerCompiler $compiler
@param Filesystem $fileSystem
|
__construct
|
php
|
concretecms/concretecms
|
concrete/src/StyleCustomizer/Normalizer/ScssNormalizer.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/StyleCustomizer/Normalizer/ScssNormalizer.php
|
MIT
|
public function __construct(string $name, $value)
{
$this->name = $name;
$this->value = $value;
}
|
Variable constructor.
@param string $name
@param mixed $value
|
__construct
|
php
|
concretecms/concretecms
|
concrete/src/StyleCustomizer/Normalizer/Variable.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/StyleCustomizer/Normalizer/Variable.php
|
MIT
|
public function createFromTheme(Theme $theme, TypeInterface $type): array
{
if ($theme->getPackageHandle()) {
$this->fileLocator->addPackageLocation($theme->getPackageHandle());
}
$r = $this->fileLocator->getRecord(
DIRNAME_THEMES .
DIRECTORY_SEPARATOR .
$theme->getThemeHandle() .
DIRECTORY_SEPARATOR .
DIRNAME_CSS .
DIRECTORY_SEPARATOR .
DIRNAME_STYLE_CUSTOMIZER_PRESETS
);
$presets = [];
$entries = $this->filesystem->directories($r->file);
$entries = array_merge($entries, $this->filesystem->files($r->file));
foreach ($entries as $path) {
$preset = $type->createPresetFromPath($path, $theme);
if ($preset) {
$presets[] = $preset;
}
}
usort($presets, function (PresetInterface $a, PresetInterface $b) {
if ($a->getIdentifier() === 'default') {
return -1;
}
if ($b->getIdentifier() === 'default') {
return 1;
}
return strcmp($a->getName(), $b->getName()); // Sort by name
});
return $presets;
}
|
Returns an array of SkinInterface objects found in the path.
@param string $path
|
createFromTheme
|
php
|
concretecms/concretecms
|
concrete/src/StyleCustomizer/Preset/PresetFactory.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/StyleCustomizer/Preset/PresetFactory.php
|
MIT
|
public function getCustomStylePreviewResponse(Customizer $customizer, Page $page, CustomStyle $customStyle): Response
{
$collection = $this->variableCollectionFactory->createFromStyleValueList($customStyle->getValueList());
return $this->deliverResponse($customizer, $page, $collection);
}
|
Used when a page level or custom theme customizer set has been saved and now needs to be re-previewed.
|
getCustomStylePreviewResponse
|
php
|
concretecms/concretecms
|
concrete/src/StyleCustomizer/Preview/LegacyStylesheetPreviewHandler.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/StyleCustomizer/Preview/LegacyStylesheetPreviewHandler.php
|
MIT
|
public function createMultipleFromDirectory(string $path, Theme $theme): array
{
$skins = [];
foreach($this->filesystem->directories($path) as $skin) {
$skin = $this->createFromPath($skin, $theme);
if ($skin) {
$skins[] = $skin;
}
}
foreach($this->filesystem->files($path) as $skin) {
$skin = $this->createFromPath($skin, $theme);
if ($skin) {
$skins[] = $skin;
}
}
return $skins;
}
|
Returns an array of SkinInterface objects found in the path.
@param string $path
|
createMultipleFromDirectory
|
php
|
concretecms/concretecms
|
concrete/src/StyleCustomizer/Skin/SkinFactory.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/StyleCustomizer/Skin/SkinFactory.php
|
MIT
|
public function createVariableFromValue(ValueInterface $value): ?VariableInterface
{
$variableValue = sprintf(
'rgba(%s, %s, %s, %s)',
$value->getRed(),
$value->getGreen(),
$value->getBlue(),
$value->getAlpha()
);
$variable = new Variable($this->getVariableToInspect(), $variableValue);
return $variable;
}
|
@param ColorValue $value
@return VariableInterface|null
|
createVariableFromValue
|
php
|
concretecms/concretecms
|
concrete/src/StyleCustomizer/Style/ColorStyle.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/StyleCustomizer/Style/ColorStyle.php
|
MIT
|
public function add($variable)
{
return parent::add($variable);
}
|
@param CustomizerVariable $variable
@return bool|true
|
add
|
php
|
concretecms/concretecms
|
concrete/src/StyleCustomizer/Style/CustomizerVariableCollection.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/StyleCustomizer/Style/CustomizerVariableCollection.php
|
MIT
|
public function createVariableFromValue(ValueInterface $value): ?VariableInterface
{
$variable = new Variable($this->getVariable(), $value->getFontFamily());
return $variable;
}
|
@param FontFamilyValue $value
@return VariableInterface|null
|
createVariableFromValue
|
php
|
concretecms/concretecms
|
concrete/src/StyleCustomizer/Style/FontFamilyStyle.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/StyleCustomizer/Style/FontFamilyStyle.php
|
MIT
|
public function createVariableFromValue(ValueInterface $value): ?VariableInterface
{
$variable = new Variable($this->getVariable(), $value->getFontStyle());
return $variable;
}
|
@param FontStyleValue $value
@return VariableInterface|null
|
createVariableFromValue
|
php
|
concretecms/concretecms
|
concrete/src/StyleCustomizer/Style/FontStyleStyle.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/StyleCustomizer/Style/FontStyleStyle.php
|
MIT
|
public function createVariableFromValue(ValueInterface $value): ?VariableInterface
{
$variable = new Variable($this->getVariable(), $value->getFontWeight());
return $variable;
}
|
@param FontWeightValue $value
@return VariableInterface|null
|
createVariableFromValue
|
php
|
concretecms/concretecms
|
concrete/src/StyleCustomizer/Style/FontWeightStyle.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/StyleCustomizer/Style/FontWeightStyle.php
|
MIT
|
public function getDisplayName(string $format = 'html'): string
{
$value = tc('StyleSetName', $this->getName());
switch ($format) {
case 'html':
return h($value);
case 'text':
default:
return $value;
}
}
|
Get the display name for this style set (localized and escaped accordingly to $format).
@param string $format = 'html'
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.
|
getDisplayName
|
php
|
concretecms/concretecms
|
concrete/src/StyleCustomizer/Style/GroupedStyleValueListSet.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/StyleCustomizer/Style/GroupedStyleValueListSet.php
|
MIT
|
public function createVariableFromValue(ValueInterface $value): ?VariableInterface
{
$url = null;
$fID = null;
if ($value->getImageFileID()) {
// An editor/admin has set the background image using the customizer, so it takes precedence
$file = File::getByID($value->getImageFileID());
if ($file) {
$fID = $file->getFileID();
}
}
if (!$fID) {
if ($value->getImageURL()) {
$url = $value->getImageURL();
}
}
$variable = $this->createImageVariable($this->getVariableToInspect(), $url);
if ($fID) {
$variable->setFileID($fID);
}
return $variable;
}
|
@param ImageValue $value
@return VariableInterface|null
|
createVariableFromValue
|
php
|
concretecms/concretecms
|
concrete/src/StyleCustomizer/Style/ImageStyle.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/StyleCustomizer/Style/ImageStyle.php
|
MIT
|
public function createVariableFromValue(ValueInterface $value): ?VariableInterface
{
$variable = new Variable('preset-fonts-file', $value->getValue());
return $variable;
}
|
@param PresetFontsFileValue $value
@return VariableInterface|null
|
createVariableFromValue
|
php
|
concretecms/concretecms
|
concrete/src/StyleCustomizer/Style/PresetFontsFileStyle.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/StyleCustomizer/Style/PresetFontsFileStyle.php
|
MIT
|
public function createVariableFromValue(ValueInterface $value): ?VariableInterface
{
$variable = new NumberVariable($this->getVariableToInspect(), $value->getSize(), $value->getUnit());
return $variable;
}
|
@param SizeValue $value
@return VariableInterface|null
|
createVariableFromValue
|
php
|
concretecms/concretecms
|
concrete/src/StyleCustomizer/Style/SizeStyle.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/StyleCustomizer/Style/SizeStyle.php
|
MIT
|
protected static function getTypeFromClass($class, $suffix = 'Style')
{
$class = get_class($class);
$class = substr($class, strrpos($class, '\\') + 1);
$type = uncamelcase(substr($class, 0, strrpos($class, $suffix)));
return $type;
}
|
Get the type handle of a given Style instance.
@param \Concrete\Core\StyleCustomizer\Style\Style|object $class
@param string $suffix
@return string
|
getTypeFromClass
|
php
|
concretecms/concretecms
|
concrete/src/StyleCustomizer/Style/Style.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/StyleCustomizer/Style/Style.php
|
MIT
|
public function setName($name)
{
$this->name = (string) $name;
return $this;
}
|
Set the name of this style.
@param string $name
@return $this
|
setName
|
php
|
concretecms/concretecms
|
concrete/src/StyleCustomizer/Style/Style.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/StyleCustomizer/Style/Style.php
|
MIT
|
public function getName()
{
return $this->name;
}
|
Get the name of this style.
@return string
|
getName
|
php
|
concretecms/concretecms
|
concrete/src/StyleCustomizer/Style/Style.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/StyleCustomizer/Style/Style.php
|
MIT
|
public function getDisplayName($format = 'html')
{
$value = tc('StyleName', $this->getName());
switch ($format) {
case 'html':
return h($value);
case 'text':
default:
return $value;
}
}
|
Get the display name for this style (localized and escaped accordingly to $format).
@param string $format = 'html'
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
|
getDisplayName
|
php
|
concretecms/concretecms
|
concrete/src/StyleCustomizer/Style/Style.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/StyleCustomizer/Style/Style.php
|
MIT
|
public function setVariable($variable)
{
$this->variable = (string) $variable;
return $this;
}
|
Set the name of the associated CSS variable.
@param string $variable
@return $this
|
setVariable
|
php
|
concretecms/concretecms
|
concrete/src/StyleCustomizer/Style/Style.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/StyleCustomizer/Style/Style.php
|
MIT
|
public function getVariable()
{
return $this->variable;
}
|
Get the name of the associated CSS variable.
@return string
|
getVariable
|
php
|
concretecms/concretecms
|
concrete/src/StyleCustomizer/Style/Style.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/StyleCustomizer/Style/Style.php
|
MIT
|
public function __construct(StyleInterface $style, ValueInterface $value)
{
$this->style = $style;
$this->value = $value;
}
|
StyleValue constructor.
@param StyleInterface $style
@param ValueInterface $value
|
__construct
|
php
|
concretecms/concretecms
|
concrete/src/StyleCustomizer/Style/StyleValue.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/StyleCustomizer/Style/StyleValue.php
|
MIT
|
public function createFromVariableCollection(StyleList $styleList, NormalizedVariableCollection $variableCollection): StyleValueList
{
$valueList = new StyleValueList();
foreach ($styleList->getAllStyles() as $style) {
$value = $style->createValueFromVariableCollection($variableCollection);
if ($value) {
$valueList->addValue($style, $value);
}
}
return $valueList;
}
|
@param StyleList $styleList
@param NormalizedVariableCollection $variableCollection
@return StyleValueList
|
createFromVariableCollection
|
php
|
concretecms/concretecms
|
concrete/src/StyleCustomizer/Style/StyleValueListFactory.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/StyleCustomizer/Style/StyleValueListFactory.php
|
MIT
|
public function createFromRequestArray(StyleList $styleList, array $styles): StyleValueList
{
$valueList = new StyleValueList();
foreach ($styleList->getAllStyles() as $style) {
$value = $style->createValueFromRequestDataCollection($styles);
if ($value) {
$valueList->addValue($style, $value);
}
}
return $valueList;
}
|
@param StyleList $styleList
@param array $styles
@return StyleValueList
|
createFromRequestArray
|
php
|
concretecms/concretecms
|
concrete/src/StyleCustomizer/Style/StyleValueListFactory.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/StyleCustomizer/Style/StyleValueListFactory.php
|
MIT
|
public function createVariableFromValue(ValueInterface $value): ?VariableInterface
{
$variable = new Variable($this->getVariable(), $value->getTextDecoration());
return $variable;
}
|
@param TextDecorationValue $value
@return VariableInterface|null
|
createVariableFromValue
|
php
|
concretecms/concretecms
|
concrete/src/StyleCustomizer/Style/TextDecorationStyle.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/StyleCustomizer/Style/TextDecorationStyle.php
|
MIT
|
public function createVariableFromValue(ValueInterface $value): ?VariableInterface
{
$variable = new Variable($this->getVariable(), $value->getTextTransform());
return $variable;
}
|
@param TextTransformValue $value
@return VariableInterface|null
|
createVariableFromValue
|
php
|
concretecms/concretecms
|
concrete/src/StyleCustomizer/Style/TextTransformStyle.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/StyleCustomizer/Style/TextTransformStyle.php
|
MIT
|
public function setRed($r)
{
$this->r = $r;
return $this;
}
|
Set the value of the red channel.
@param mixed $r
@return $this
|
setRed
|
php
|
concretecms/concretecms
|
concrete/src/StyleCustomizer/Style/Value/ColorValue.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/StyleCustomizer/Style/Value/ColorValue.php
|
MIT
|
public function setGreen($g)
{
$this->g = $g;
return $this;
}
|
Set the value of the green channel.
@param mixed $g
@return $this
|
setGreen
|
php
|
concretecms/concretecms
|
concrete/src/StyleCustomizer/Style/Value/ColorValue.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/StyleCustomizer/Style/Value/ColorValue.php
|
MIT
|
public function setBlue($b)
{
$this->b = $b;
return $this;
}
|
Set the value of the blue channel.
@param mixed $b
@return $this
|
setBlue
|
php
|
concretecms/concretecms
|
concrete/src/StyleCustomizer/Style/Value/ColorValue.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/StyleCustomizer/Style/Value/ColorValue.php
|
MIT
|
public function setAlpha($a)
{
$this->a = $a;
return $this;
}
|
Set the value of the alpha channel.
@param mixed $a
@return $this
|
setAlpha
|
php
|
concretecms/concretecms
|
concrete/src/StyleCustomizer/Style/Value/ColorValue.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/StyleCustomizer/Style/Value/ColorValue.php
|
MIT
|
public function getRed()
{
return $this->r;
}
|
Get the value of the red channel.
@return mixed
|
getRed
|
php
|
concretecms/concretecms
|
concrete/src/StyleCustomizer/Style/Value/ColorValue.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/StyleCustomizer/Style/Value/ColorValue.php
|
MIT
|
public function getGreen()
{
return $this->g;
}
|
Get the value of the green channel.
@return mixed
|
getGreen
|
php
|
concretecms/concretecms
|
concrete/src/StyleCustomizer/Style/Value/ColorValue.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/StyleCustomizer/Style/Value/ColorValue.php
|
MIT
|
public function getBlue()
{
return $this->b;
}
|
Get the value of the blue channel.
@return mixed
|
getBlue
|
php
|
concretecms/concretecms
|
concrete/src/StyleCustomizer/Style/Value/ColorValue.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/StyleCustomizer/Style/Value/ColorValue.php
|
MIT
|
public function getAlpha()
{
return $this->a;
}
|
Get the value of the alpha channel.
@return mixed
|
getAlpha
|
php
|
concretecms/concretecms
|
concrete/src/StyleCustomizer/Style/Value/ColorValue.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/StyleCustomizer/Style/Value/ColorValue.php
|
MIT
|
public function hasAlpha()
{
return (string) $this->a !== '';
}
|
Is the alpha channel set?
@return bool
|
hasAlpha
|
php
|
concretecms/concretecms
|
concrete/src/StyleCustomizer/Style/Value/ColorValue.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/StyleCustomizer/Style/Value/ColorValue.php
|
MIT
|
public function __construct($size, string $unit)
{
$this->size = $size;
$this->unit = $unit;
}
|
SizeValue constructor.
@param mixed $size
@param string $unit
|
__construct
|
php
|
concretecms/concretecms
|
concrete/src/StyleCustomizer/Style/Value/SizeValue.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/StyleCustomizer/Style/Value/SizeValue.php
|
MIT
|
public function setSize($size)
{
$this->size = $size;
return $this;
}
|
Set the numeric amount of the size.
@param mixed $size
@return $this
|
setSize
|
php
|
concretecms/concretecms
|
concrete/src/StyleCustomizer/Style/Value/SizeValue.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/StyleCustomizer/Style/Value/SizeValue.php
|
MIT
|
public function setUnit($unit)
{
$this->unit = (string) $unit;
return $this;
}
|
Set the unit of the size.
@param string $unit
@return $this
|
setUnit
|
php
|
concretecms/concretecms
|
concrete/src/StyleCustomizer/Style/Value/SizeValue.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/StyleCustomizer/Style/Value/SizeValue.php
|
MIT
|
public function getSize()
{
return $this->size;
}
|
Get the numeric amount of the size.
@return mixed
|
getSize
|
php
|
concretecms/concretecms
|
concrete/src/StyleCustomizer/Style/Value/SizeValue.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/StyleCustomizer/Style/Value/SizeValue.php
|
MIT
|
public function getUnit()
{
return $this->unit;
}
|
Get the unit of the size.
@return string
|
getUnit
|
php
|
concretecms/concretecms
|
concrete/src/StyleCustomizer/Style/Value/SizeValue.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/StyleCustomizer/Style/Value/SizeValue.php
|
MIT
|
public function loadCustomizer(Customizer $customizer, PresetInterface $preset, $mixed = null)
{
$styleList = $customizer->getThemeCustomizableStyleList($preset);
$styleValueListFactory = $this->app->make(StyleValueListFactory::class);
$variableCollectionFactory = $this->app->make(NormalizedVariableCollectionFactory::class);
$customizerVariableCollectionFactory = $this->app->make(CustomizerVariableCollectionFactory::class);
$customCss = null;
if ($mixed instanceof CustomSkin) {
$variableCollection = $variableCollectionFactory->createFromCustomSkin($mixed);
$customCss = $mixed->getCustomCss();
} else if ($mixed instanceof CustomStyle) {
// legacy page customizer support.
$valueList = $mixed->getValueList();
if ($valueList) {
$variableCollection = $variableCollectionFactory->createFromStyleValueList($valueList);
}
$customCssRecord = $mixed->getCustomCssRecord();
if ($customCssRecord) {
$customCss = $customCssRecord->getValue();
}
} else {
$variableCollection = $variableCollectionFactory->createFromPreset($customizer, $preset);
}
$valueList = $styleValueListFactory->createFromVariableCollection($styleList, $variableCollection);
$groupedStyleValueList = $valueList->createGroupedStyleValueList($styleList);
$this->requireAsset('ace');
$this->set('styleList', $groupedStyleValueList);
$this->set('styles', $customizerVariableCollectionFactory->createFromStyleValueList($valueList));
$this->set('preset', $preset);
$this->set('customizer', $customizer);
$this->set('customCss', $customCss);
}
|
@param Customizer $customizer
@param PresetInterface $preset
@param CustomStyle|SkinInterface|null $mixed
|
loadCustomizer
|
php
|
concretecms/concretecms
|
concrete/src/StyleCustomizer/Traits/CustomizeControllerTrait.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/StyleCustomizer/Traits/CustomizeControllerTrait.php
|
MIT
|
public function __construct(string $name, string $type)
{
$this->name = $name;
$this->type = $type;
}
|
WebFont constructor.
@param string $name
@param string $type
|
__construct
|
php
|
concretecms/concretecms
|
concrete/src/StyleCustomizer/WebFont/WebFont.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/StyleCustomizer/WebFont/WebFont.php
|
MIT
|
public function add($font)
{
return parent::add($font);
}
|
@param WebFont $font
@return bool|true
|
add
|
php
|
concretecms/concretecms
|
concrete/src/StyleCustomizer/WebFont/WebFontCollection.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/StyleCustomizer/WebFont/WebFontCollection.php
|
MIT
|
public function containsField($field)
{
$field = $field instanceof FieldInterface ? $field->getFieldIdentifier() : $field;
$containsKey = $this->collection->containsKey($field);
return $containsKey;
}
|
@param $field FieldInterface|string
@return bool
|
containsField
|
php
|
concretecms/concretecms
|
concrete/src/Summary/Data/Collection.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Summary/Data/Collection.php
|
MIT
|
public function extractData(CategoryMemberInterface $mixed): Collection
{
$collection = new Collection();
if ($mixed instanceof CalendarEvent) {
$version = $mixed->getApprovedVersion();
$event = $mixed;
} else {
$version = $mixed->getVersion();
$event = $version->getEvent();
}
if ($version) {
$this->entityManager->refresh($version);
$collection->addField(new DataField(FieldInterface::FIELD_TITLE, $version->getName()));
$link = $this->linkFormatter->getEventFrontendViewLink($event);
if ($link) {
$collection->addField(new DataField(FieldInterface::FIELD_LINK, $link));
}
$description = $version->getDescription();
if ($description) {
$collection->addField(new DataField(FieldInterface::FIELD_DESCRIPTION, $description));
}
$author = $version->getAuthor();
if ($author) {
$collection->addField(new DataField(FieldInterface::FIELD_AUTHOR, new AuthorDataFieldData($author->getUserInfoObject())));
}
$collection->addField(new DataField(FieldInterface::FIELD_LINK, new LazyEventOccurrenceLinkDataFieldData()));
$collection->addField(new DataField(FieldInterface::FIELD_DATE, new LazyEventOccurrenceStartDatetimeDataFieldData()));
$collection->addField(new DataField(FieldInterface::FIELD_DATE_START, new LazyEventOccurrenceStartDatetimeDataFieldData()));
$collection->addField(new DataField(FieldInterface::FIELD_DATE_END, new LazyEventOccurrenceEndDatetimeDataFieldData()));
$thumbnail = $this->getThumbnailDataField($event);
if ($thumbnail) {
$collection->addField($thumbnail);
}
$categories = $this->getCategoriesDataField($event);
if ($categories) {
$collection->addField($categories);
}
}
return $collection;
}
|
@param $mixed CalendarEvent|CalendarEventVersionOccurrence
@return Collection
|
extractData
|
php
|
concretecms/concretecms
|
concrete/src/Summary/Data/Extractor/Driver/BasicCalendarEventDriver.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Summary/Data/Extractor/Driver/BasicCalendarEventDriver.php
|
MIT
|
public function register(string $class, $priority = self::PRIORITY_DEFAULT)
{
$this->drivers[] = new RegisteredDriver($class, $priority);
}
|
@param string $class
@param int $priority
|
register
|
php
|
concretecms/concretecms
|
concrete/src/Summary/Data/Extractor/Driver/DriverManager.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Summary/Data/Extractor/Driver/DriverManager.php
|
MIT
|
public function getDriverCollection($object) : DriverCollection
{
$drivers = $this->getDrivers();
$collection = new DriverCollection();
foreach($drivers as $driver) {
$inflatedDriver = $driver->inflateClass($this->app);
if ($inflatedDriver->isValidForObject($object)) {
$collection->addDriver($inflatedDriver);
}
}
return $collection;
}
|
@param string $category
@param $object
@return DriverCollection
|
getDriverCollection
|
php
|
concretecms/concretecms
|
concrete/src/Summary/Data/Extractor/Driver/DriverManager.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Summary/Data/Extractor/Driver/DriverManager.php
|
MIT
|
public function __construct(string $fieldIdentifier, $data)
{
$this->fieldIdentifier = $fieldIdentifier;
if (!($data instanceof DataFieldDataInterface)) {
$data = new DataFieldData($data);
}
$this->data = $data;
}
|
DataField constructor.
@param string $fieldIdentifier
@param string|int|bool|DataFieldDataInterface $data
|
__construct
|
php
|
concretecms/concretecms
|
concrete/src/Summary/Data/Field/DataField.php
|
https://github.com/concretecms/concretecms/blob/master/concrete/src/Summary/Data/Field/DataField.php
|
MIT
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.