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 getThemeURL() { return $this->pThemeURL; }
Get the URL prefix of the assets provided by this theme. @return string
getThemeURL
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 getThemeEditorCSS() { return $this->pThemeURL.'/'.static::FILENAME_TYPOGRAPHY_CSS; }
Get the URL of the theme typography.css file. @return string
getThemeEditorCSS
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 setThemeURL($pThemeURL) { $this->pThemeURL = $pThemeURL; }
Set the URL prefix of the assets provided by this theme. @param string $pThemeURL
setThemeURL
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 setThemeDirectory($pThemeDirectory) { $this->pThemeDirectory = $pThemeDirectory; }
Set the absolute path of the theme folder. @param string $pThemeDirectory
setThemeDirectory
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 setThemeHandle($pThemeHandle) { $this->pThemeHandle = $pThemeHandle; }
Set the handle of this theme. @param string $pThemeHandle
setThemeHandle
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 setStylesheetCachePath($path) { $this->stylesheetCachePath = $path; }
Set the absolute path of a directory where the CSS stylesheet files should be stored. @param string $path
setStylesheetCachePath
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 setStylesheetCacheRelativePath($path) { $this->stylesheetCacheRelativePath = $path; }
Set the path of a directory where the CSS stylesheet files should be stored, relative to the website root directory. @param string $path
setStylesheetCacheRelativePath
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 getStylesheetCachePath() { return $this->stylesheetCachePath; }
Get the absolute path of a directory where the CSS stylesheet files should be stored. @return string
getStylesheetCachePath
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 getStylesheetCacheRelativePath() { return $this->stylesheetCacheRelativePath; }
Get the path of a directory where the CSS stylesheet files should be stored, relative to the website root directory. @return string
getStylesheetCacheRelativePath
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 isUninstallable() { return $this->pThemeDirectory != DIR_FILES_THEMES_CORE.'/'.$this->getThemeHandle(); }
Is this theme uninstallable? @return bool
isUninstallable
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 getThemeThumbnail() { if (file_exists($this->pThemeDirectory.'/'.FILENAME_THEMES_THUMBNAIL)) { $src = $this->pThemeURL.'/'.FILENAME_THEMES_THUMBNAIL; } else { $src = ASSETS_URL_THEMES_NO_THUMBNAIL; } $html = new \HtmlObject\Image(); $img = $html->src($src) ->width(Config::get('concrete.icons.theme_thumbnail.width')) ->height(Config::get('concrete.icons.theme_thumbnail.height')) ->class('ccm-icon-theme'); return $img; }
Get the theme thumbnail image. @return \HtmlObject\Image
getThemeThumbnail
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 applyToSite(?Site $site = null) { if (!is_object($site)) { $site = \Core::make('site')->getSite(); } $entityManager = \Database::connection()->getEntityManager(); $site->setThemeID($this->getThemeID()); $entityManager->persist($site); $entityManager->flush(); $env = Environment::get(); $record = $env->getRecord( DIRNAME_THEMES . DIRECTORY_SEPARATOR . $this->getThemeHandle() . DIRECTORY_SEPARATOR . FILENAME_CONTENT_XML, $this->getPackageHandle() ); if ($record->exists()) { $importer = app(ContentImporter::class); $importer->importContentFile($record->file); } $treeIDs = [0]; foreach($site->getLocales() as $locale) { $tree = $locale->getSiteTree(); if (is_object($tree)) { $treeIDs[] = $tree->getSiteTreeID(); } } $treeIDs = implode(',', $treeIDs); $db = Loader::db(); $r = $db->query( "update CollectionVersions inner join Pages on CollectionVersions.cID = Pages.cID left join Packages on Pages.pkgID = Packages.pkgID set CollectionVersions.pThemeID = ? where cIsTemplate = 0 and siteTreeID in ({$treeIDs}) and (Pages.ptID > 0 or CollectionVersions.pTemplateID > 0)", array($this->pThemeID) ); }
Apply this theme to all the pages of a site. @param \Concrete\Core\Entity\Site\Site|null $site if null, we'll use the current site.
applyToSite
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 getSiteTheme() { $site = \Core::make('site')->getSite(); return static::getByID($site->getThemeID()); }
Get the theme for the current site. @return \Concrete\Core\Page\Theme\Theme|null
getSiteTheme
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 supportsGridFramework() { $handle = $this->getThemeGridFrameworkHandle(); return $handle != false; }
Does this theme support a grid framework? @return bool
supportsGridFramework
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 getThemeGridFrameworkObject() { $handle = $this->getThemeGridFrameworkHandle(); if ($handle) { $framework = Core::make('manager/grid_framework')->driver($handle); return $framework; } }
Get the grid framework supported by this theme. @return \Concrete\Core\Page\Theme\GridFramework\GridFramework|null
getThemeGridFrameworkObject
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 getThemeGridFrameworkHandle() { return $this->pThemeGridFrameworkHandle; }
Get the handle of the grid framework supported by this theme. @return string|NULL|false
getThemeGridFrameworkHandle
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 getThemeSupportedFeatures() { return []; }
Get the handles of the features supported by this theme. @return string[] @see \Concrete\Core\Feature\Feature for a list of features @see \Concrete\Theme\Elemental\PageTheme::getThemeSupportedFeatures() for an example
getThemeSupportedFeatures
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 getThemeBlockClasses() { return []; }
Get the theme-specific CSS classes for every block. @return array array keys are the block type handles, array values are a list of the CSS classes. @see \Concrete\Theme\Elemental\PageTheme::getThemeBlockClasses() for an example
getThemeBlockClasses
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 getThemeAreaClasses() { return []; }
Get the theme-specific CSS classes for every area. @return array array keys are the area names, array values are a list of the CSS classes. @see \Concrete\Theme\Elemental\PageTheme::getThemeAreaClasses() for an example
getThemeAreaClasses
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 getThemeEditorClasses() { return []; }
Get the theme-specific style names to be used in the rich text editor. @return array Every array item is an array with the keys 'title', 'menuClass', 'spanClass', 'forceBlock'. @see \Concrete\Theme\Elemental\PageTheme::getThemeEditorClasses() for an example
getThemeEditorClasses
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 getThemeDefaultBlockTemplates() { return []; }
Get the theme-specific templates for every block. @return array array keys are the block type handles, array values are a list of the block templates. @see \Concrete\Theme\Elemental\PageTheme::getThemeDefaultBlockTemplates() for an example
getThemeDefaultBlockTemplates
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 getThemeResponsiveImageMap() { return []; }
Get the handles of the thumbnail types and related resolution breakpoint. Important: make sure to define these in proper ascending size order, otherwise you might get inconsistencies in certain aspects of the UI that refer to these image types. @return array @see \Concrete\Theme\Elemental\PageTheme::getThemeResponsiveImageMap() for an example
getThemeResponsiveImageMap
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 setThemeByRoute($path, $theme = null, $wrapper = FILENAME_THEMES_VIEW) { $this->themePaths[$path] = array($theme, $wrapper); }
Used by the theme_paths and site_theme_paths files in config/ to hard coded certain paths to various themes. @param $path string @param $theme object, if null site theme is default
setThemeByRoute
php
concretecms/concretecms
concrete/src/Page/Theme/ThemeRouteCollection.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Theme/ThemeRouteCollection.php
MIT
public function getThemeByRoute($path) { $path = (string) $path; if ($path === '') { return false; } $text = new Text(); // there's probably a more efficient way to do this foreach ($this->themePaths as $lp => $layout) { if ($text->fnmatch($lp, $path)) { return $layout; } } return false; }
This grabs the theme for a particular path, if one exists in the themePaths array. Returns an array with the theme handle as the first entry and the wrapper file for views as the second. @param string $path @return array|false
getThemeByRoute
php
concretecms/concretecms
concrete/src/Page/Theme/ThemeRouteCollection.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Theme/ThemeRouteCollection.php
MIT
public function __construct( StyleValueListFactory $styleValueListFactory, NormalizedVariableCollectionFactory $variableCollectionFactory, Connection $db ) { $this->styleValueListFactory = $styleValueListFactory; $this->variableCollectionFactory = $variableCollectionFactory; $this->db = $db; }
@param StyleValueListFactory $styleValueListFactory @param NormalizedVariableCollectionFactory $variableCollectionFactory
__construct
php
concretecms/concretecms
concrete/src/Page/Theme/Command/ApplyCustomizationsToSiteCommandHandler.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Theme/Command/ApplyCustomizationsToSiteCommandHandler.php
MIT
public function __construct( StyleValueListFactory $styleValueListFactory, NormalizedVariableCollectionFactory $variableCollectionFactory, Compiler $compiler, Writer $writer ) { $this->styleValueListFactory = $styleValueListFactory; $this->variableCollectionFactory = $variableCollectionFactory; $this->compiler = $compiler; $this->writer = $writer; }
@param StyleValueListFactory $styleValueListFactory @param NormalizedVariableCollectionFactory $variableCollectionFactory @param Compiler $compiler
__construct
php
concretecms/concretecms
concrete/src/Page/Theme/Command/GenerateCustomSkinStylesheetCommandHandler.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Theme/Command/GenerateCustomSkinStylesheetCommandHandler.php
MIT
public function __construct( EntityManager $entityManager, Application $app, StyleValueListFactory $styleValueListFactory, NormalizedVariableCollectionFactory $variableCollectionFactory ) { $this->entityManager = $entityManager; $this->app = $app; $this->styleValueListFactory = $styleValueListFactory; $this->variableCollectionFactory = $variableCollectionFactory; }
@param EntityManager $entityManager @param Application $app @param StyleValueListFactory $styleValueListFactory @param NormalizedVariableCollectionFactory $variableCollectionFactory
__construct
php
concretecms/concretecms
concrete/src/Page/Theme/Command/UpdateCustomSkinCommandHandler.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Theme/Command/UpdateCustomSkinCommandHandler.php
MIT
public function __construct(string $name, string $contentFile) { $this->name = $name; $this->contentFile = $contentFile; }
@param string $name @param string $contentFile
__construct
php
concretecms/concretecms
concrete/src/Page/Theme/Documentation/BedrockDocumentationPage.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Theme/Documentation/BedrockDocumentationPage.php
MIT
public function __construct(Theme $theme, string $contentFile) { $this->theme = $theme; $this->contentFile = $contentFile; }
@param Theme $theme @param string $contentFile
__construct
php
concretecms/concretecms
concrete/src/Page/Theme/Documentation/CustomThemeDocumentationPage.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Theme/Documentation/CustomThemeDocumentationPage.php
MIT
public function __construct(Theme $theme, Page $page, bool $isActive = false) { $this->theme = $theme; $this->page = $page; $this->name = $page->getCollectionName(); $this->isActive = $isActive; }
Item constructor. @param string $url @param string $name @param bool $isActive
__construct
php
concretecms/concretecms
concrete/src/Page/Theme/Documentation/DocumentationNavigationPageItem.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Theme/Documentation/DocumentationNavigationPageItem.php
MIT
public function clearDocumentation(Theme $theme, DocumentationProviderInterface $provider) { $provider->clearSupportingElements(); $documentationPage = $theme->getThemeDocumentationParentPage(); if ($documentationPage) { $documentationPage->delete(); } }
Clears the documentation for the provided theme. @param Theme $theme
clearDocumentation
php
concretecms/concretecms
concrete/src/Page/Theme/Documentation/Installer.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Theme/Documentation/Installer.php
MIT
public function __construct(Theme $theme, string $name, array $childPages, ?string $contentFile = null) { $this->name = $name; $this->theme = $theme; $this->childPages = $childPages; $this->contentFile = $contentFile; }
@param Theme $theme @param string $name @param string $contentFile
__construct
php
concretecms/concretecms
concrete/src/Page/Theme/Documentation/ThemeCategoryDocumentationPage.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Theme/Documentation/ThemeCategoryDocumentationPage.php
MIT
public function __construct(Theme $theme, string $name, string $contentFile) { $this->name = $name; $this->theme = $theme; $this->contentFile = $contentFile; }
@param Theme $theme @param string $name @param string $contentFile
__construct
php
concretecms/concretecms
concrete/src/Page/Theme/Documentation/ThemeDocumentationPage.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Theme/Documentation/ThemeDocumentationPage.php
MIT
public function getDeviceHideClasses(int $class): string { switch ($class) { case self::DEVICE_CLASSES_HIDE_ON_EXTRA_SMALL: return $this->getPageThemeGridFrameworkHideOnExtraSmallDeviceClass(); case self::DEVICE_CLASSES_HIDE_ON_SMALL: return $this->getPageThemeGridFrameworkHideOnSmallDeviceClass(); case self::DEVICE_CLASSES_HIDE_ON_MEDIUM: return $this->getPageThemeGridFrameworkHideOnMediumDeviceClass(); case self::DEVICE_CLASSES_HIDE_ON_LARGE: return $this->getPageThemeGridFrameworkHideOnLargeDeviceClass(); } return ''; }
@param int $class A const representing a device size @return string
getDeviceHideClasses
php
concretecms/concretecms
concrete/src/Page/Theme/GridFramework/GridFramework.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Theme/GridFramework/GridFramework.php
MIT
public function getPageTypePublishTargetObject() { return $this->ptPublishTargetObject; }
@return \Concrete\Core\Page\Type\PublishTarget\Configuration\Configuration
getPageTypePublishTargetObject
php
concretecms/concretecms
concrete/src/Page/Type/Type.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Type/Type.php
MIT
public static function add($data, $pkg = false) { $data = $data + array( 'defaultTemplate' => null, 'defaultTheme' => null, 'allowedTemplates' => null, 'templates' => null, 'internal' => null, 'ptLaunchInComposer' => null, 'ptIsFrequentlyAdded' => null, ); if (!isset($data['siteType'])) { $data['siteType'] = \Core::make('site/type')->getDefault(); } $ptHandle = $data['handle']; $ptName = $data['name']; $siteTypeID = $data['siteType']->getSiteTypeID(); $ptDefaultPageTemplateID = 0; $ptDefaultThemeID = null; $ptIsFrequentlyAdded = 0; $ptLaunchInComposer = 0; $pkgID = 0; if (is_object($pkg)) { $pkgID = $pkg->getPackageID(); } if (is_object($data['defaultTemplate'])) { $ptDefaultPageTemplateID = $data['defaultTemplate']->getPageTemplateID(); } elseif (!empty($data['defaultTemplate'])) { $ptDefaultPageTemplateID = PageTemplate::getByHandle($data['defaultTemplate'])->getPageTemplateID(); } if (is_object($data['defaultTheme'])) { $ptDefaultThemeID = $data['defaultTheme']->getThemeID(); } $ptAllowedPageTemplates = 'A'; if ($data['allowedTemplates']) { $ptAllowedPageTemplates = $data['allowedTemplates']; } $templates = array(); if (is_array($data['templates'])) { $templates = $data['templates']; } $ptIsInternal = 0; if ($data['internal']) { $ptIsInternal = 1; } if ($data['ptLaunchInComposer']) { $ptLaunchInComposer = 1; } if ($data['ptIsFrequentlyAdded']) { $ptIsFrequentlyAdded = 1; } $db = Loader::db(); $ptDisplayOrder = 0; $count = $db->GetOne('select count(ptID) from PageTypes where ptIsInternal = ?', array($ptIsInternal)); if ($count > 0) { $ptDisplayOrder = $count; } $db->Execute( 'insert into PageTypes (ptName, ptHandle, ptDefaultPageTemplateID, ptDefaultThemeID, ptAllowedPageTemplates, ptIsInternal, ptLaunchInComposer, ptDisplayOrder, ptIsFrequentlyAdded, siteTypeID, pkgID) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', array( $ptName, $ptHandle, $ptDefaultPageTemplateID, $ptDefaultThemeID, $ptAllowedPageTemplates, $ptIsInternal, $ptLaunchInComposer, $ptDisplayOrder, $ptIsFrequentlyAdded, $siteTypeID, $pkgID, ) ); $ptID = $db->Insert_ID(); if ($ptAllowedPageTemplates != 'A') { foreach ($templates as $pt) { if (!is_object($pt)){ $pt = PageTemplate::getByHandle($pt); } $db->Execute( 'insert into PageTypePageTemplates (ptID, pTemplateID) values (?, ?)', array( $ptID, $pt->getPageTemplateID(), ) ); } } $ptt = static::getByID($ptID); // set all type publish target as default $target = PageTypePublishTargetType::getByHandle('all'); if (is_object($target)) { $configuredTarget = $target->configurePageTypePublishTarget($ptt, array()); $ptt->setConfiguredPageTypePublishTargetObject($configuredTarget); } // copy permissions from the defaults to the page type $cpk = PermissionKey::getByHandle('access_page_type_permissions'); $permissions = PermissionKey::getList('page_type'); foreach ($permissions as $pk) { $pk->setPermissionObject($ptt); $pk->copyFromDefaultsToPageType($cpk); } // now we clear the default from edit page drafts $pk = PermissionKey::getByHandle('edit_page_type_drafts'); if (is_object($pk)) { $pk->setPermissionObject($ptt); $pt = $pk->getPermissionAssignmentObject(); if (is_object($pt)) { $pt->clearPermissionAssignment(); } // now we assign the page draft owner access entity $pa = PermissionAccess::create($pk); $pe = PageOwnerPermissionAccessEntity::getOrCreate(); $pa->addListItem($pe); $pt->assignPermissionAccess($pa); return $ptt; } }
Add a page type. @param array $data { @var string $handle A string which can be used to identify the page type @var string $name A user friendly display name @var \PageTemplate $defaultTemplate The default template object or handle @var string $allowedTemplates (A|C|X) A for all, C for selected only, X for non-selected only @var \PageTemplate[] $templates Array or Iterator of selected templates, see `$allowedTemplates`, or Page Template Handles @var bool $internal Is this an internal only page type? Default: `false` @var bool $ptLaunchInComposer Does this launch in composer? Default: `false` @var bool $ptIsFrequentlyAdded Should this always be displayed in the pages panel? Default: `false` } @param bool|Package $pkg This should be false if the type is not tied to a package, or a package object @return static|mixed|null
add
php
concretecms/concretecms
concrete/src/Page/Type/Type.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Type/Type.php
MIT
public function canPublishPageTypeBeneathPage(\Concrete\Core\Page\Page $page) { $target = $this->getPageTypePublishTargetObject(); if (is_object($target)) { return $target->canPublishPageTypeBeneathTarget($this, $page); } }
Returns true if pages of the current type are allowed beneath the passed parent page. @param \Concrete\Core\Page\Page $page
canPublishPageTypeBeneathPage
php
concretecms/concretecms
concrete/src/Page/Type/Type.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Type/Type.php
MIT
public function getPageTypeValidatorObject() { if ($this->ptHandle) { $validator = \Core::make('manager/page_type/validator')->driver($this->ptHandle); $validator->setPageTypeObject($this); return $validator; } }
@return \Concrete\Core\Page\Type\Validator\ValidatorInterface|null
getPageTypeValidatorObject
php
concretecms/concretecms
concrete/src/Page/Type/Type.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Type/Type.php
MIT
public function getPageTypeSaverObject() { if ($this->ptHandle) { $saver = \Core::make('manager/page_type/saver')->driver($this->ptHandle); $saver->setPageTypeObject($this); return $saver; } }
@return \Concrete\Core\Page\Type\Saver\SaverInterface|null
getPageTypeSaverObject
php
concretecms/concretecms
concrete/src/Page/Type/Type.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Type/Type.php
MIT
public function getPageTypeObject() { return PageType::getByID($this->ptID); }
@return \Concrete\Core\Page\Type\Type
getPageTypeObject
php
concretecms/concretecms
concrete/src/Page/Type/Composer/FormLayoutSet.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Type/Composer/FormLayoutSet.php
MIT
public function getPageTypeComposerFormLayoutSetDisplayName($format = 'html') { $value = tc('PageTypeComposerFormLayoutSetName', $this->ptComposerFormLayoutSetName); switch ($format) { case 'html': return h($value); case 'text': default: return $value; } }
Returns the display name for this instance (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
getPageTypeComposerFormLayoutSetDisplayName
php
concretecms/concretecms
concrete/src/Page/Type/Composer/FormLayoutSet.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Type/Composer/FormLayoutSet.php
MIT
public function addToPageTypeComposerFormLayoutSet(PageTypeComposerFormLayoutSet $set) { $db = Loader::db(); $displayOrder = $db->GetOne('select count(ptComposerFormLayoutSetControlID) from PageTypeComposerFormLayoutSetControls where ptComposerFormLayoutSetID = ?', array($set->getPageTypeComposerFormLayoutSetID())); if (!$displayOrder) { $displayOrder = 0; } $ptComposerFormLayoutSetControlRequired = 0; if ($this->isPageTypeComposerControlRequiredByDefault()) { $ptComposerFormLayoutSetControlRequired = 1; } $controlType = $this->getPageTypeComposerControlTypeObject(); $customLabel = $this->getPageTypeComposerControlCustomLabel(); $description = $this->getPageTypeComposerControlDescription(); $db->Execute('insert into PageTypeComposerFormLayoutSetControls (ptComposerFormLayoutSetID, ptComposerControlTypeID, ptComposerControlObject, ptComposerFormLayoutSetControlDisplayOrder, ptComposerFormLayoutSetControlCustomLabel, ptComposerFormLayoutSetControlDescription, ptComposerFormLayoutSetControlRequired) values (?, ?, ?, ?, ?, ?, ?)', array( $set->getPageTypeComposerFormLayoutSetID(), $controlType->getPageTypeComposerControlTypeID(), serialize($this), $displayOrder, $customLabel, $description, $ptComposerFormLayoutSetControlRequired, )); return PageTypeComposerFormLayoutSetControl::getByID($db->Insert_ID()); }
@param PageTypeComposerFormLayoutSet $set @return \Concrete\Core\Page\Type\Composer\FormLayoutSetControl
addToPageTypeComposerFormLayoutSet
php
concretecms/concretecms
concrete/src/Page/Type/Composer/Control/Control.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Type/Composer/Control/Control.php
MIT
public function getDefaultParentPageID() { return $this->getParentPageID(); }
Note: if a configuration contains this method, it is assumed that the configuration will default to this page and can skip composer.
getDefaultParentPageID
php
concretecms/concretecms
concrete/src/Page/Type/PublishTarget/Configuration/ParentPageConfiguration.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Type/PublishTarget/Configuration/ParentPageConfiguration.php
MIT
public function getPageTypePublishTargetTypeDisplayName($format = 'html') { $value = tc('PageTypePublishTargetTypeName', $this->ptPublishTargetTypeName); switch ($format) { case 'html': return h($value); case 'text': default: return $value; } }
Returns the display name for this instance (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
getPageTypePublishTargetTypeDisplayName
php
concretecms/concretecms
concrete/src/Page/Type/PublishTarget/Type/Type.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/Type/PublishTarget/Type/Type.php
MIT
public function isEditingDisabled(): bool { if ($this->controller instanceof PageController) { return $this->controller->isEditingDisabled(); } return false; }
Checks to see if page editing has been manually disabled through code. This does things like hide the toolbar etc...
isEditingDisabled
php
concretecms/concretecms
concrete/src/Page/View/PageView.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Page/View/PageView.php
MIT
public function getTaskURL(string $task = '', array $options = []): string { if ($task === '') { $task = 'save_permission'; } $categoryHandle = $this->getPermissionKeyCategoryHandle(); $pathChunks = [ '/ccm/system/permissions/categories', $categoryHandle, $task ]; $app = app(); $token = $app->make(Token::class); $options += [$token::DEFAULT_TOKEN_NAME => $token->generate("{$task}@{$categoryHandle}")]; return (string) $app->make(ResolverManagerInterface::class)->resolve($pathChunks)->setQuery($options); }
Build the URL of a task (replaces the previous getToolsURL method) @param string $task The task to be executed ('save_permission' if empty) @param array $options Optional arguments (will be added to the query string). @return string
getTaskURL
php
concretecms/concretecms
concrete/src/Permission/Category.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Permission/Category.php
MIT
public function __construct($object = false) { if ($object) { $this->response = PermissionResponse::getResponse($object); $r = $this->response->testForErrors(); if ($r) { $this->error = $r; } } }
@param \Concrete\Core\Permission\ObjectInterface|null|false $object
__construct
php
concretecms/concretecms
concrete/src/Permission/Checker.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Permission/Checker.php
MIT
public function __call($f, $a) { if ($this->response) { switch (count($a)) { case 0: $r = $this->response->{$f}(); break; case 1: $r = $this->response->{$f}($a[0]); break; case 2: $r = $this->response->{$f}($a[0], $a[1]); break; default: $r = call_user_func_array([$this->response, $f], $a); break; } } else { $app = Application::getFacadeApplication(); // handles task permissions $permission = $app->make('helper/text')->uncamelcase($f); $pk = PermissionKey::getByHandle($permission); if (!$pk) { throw new Exception(t('Unable to get permission key for %s', $permission)); } switch (count($a)) { case 0: $r = $pk->validate(); break; case 1: $r = $pk->{$f}($a[0]); break; case 2: $r = $pk->{$f}($a[0], $a[1]); break; default: $r = call_user_func_array([$pk, $f], $a); break; } } if (is_array($r) || is_object($r)) { return $r; } return $r ? 1 : 0; }
We take any permissions function run on the permissions class and send it into the category object. @param string $f The method name @param array $a The method arguments @return array|object|int
__call
php
concretecms/concretecms
concrete/src/Permission/Checker.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Permission/Checker.php
MIT
public function isError() { return $this->error ? true : false; }
Checks to see if there is a fatal error with this particular permission call. @return bool
isError
php
concretecms/concretecms
concrete/src/Permission/Checker.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Permission/Checker.php
MIT
public function getError() { return $this->error; }
Returns the error code if there is one. @return int|null|false
getError
php
concretecms/concretecms
concrete/src/Permission/Checker.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Permission/Checker.php
MIT
public function getOriginalObject() { return $this->response->getPermissionObject(); }
Legacy. @private @return \Concrete\Core\Permission\ObjectInterface
getOriginalObject
php
concretecms/concretecms
concrete/src/Permission/Checker.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Permission/Checker.php
MIT
public function getResponseObject() { return $this->response; }
@return \Concrete\Core\Permission\Response\Response|null
getResponseObject
php
concretecms/concretecms
concrete/src/Permission/Checker.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Permission/Checker.php
MIT
public static function filterByActive($list) { $filteredList = []; foreach ($list as $l) { $pd = $l->getPermissionDurationObject(); if (is_object($pd)) { if ($pd->isActive()) { $filteredList[] = $l; } } else { $filteredList[] = $l; } } return $filteredList; }
@param \Concrete\Core\Permission\Access\ListItem\ListItem[] $list @return \Concrete\Core\Permission\Access\ListItem\ListItem[]
filterByActive
php
concretecms/concretecms
concrete/src/Permission/Duration.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Permission/Duration.php
MIT
public static function getByID($pdID) { $db = Database::connection(); $pdObject = $db->fetchColumn('SELECT pdObject FROM PermissionDurationObjects WHERE pdID = ?', [$pdID]); if ($pdObject) { $pd = unserialize($pdObject); return $pd; } return null; }
@param $pdID @return \Concrete\Core\Permission\Duration
getByID
php
concretecms/concretecms
concrete/src/Permission/Duration.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Permission/Duration.php
MIT
public function __construct(EntityManagerInterface $em, Site $site, IpAccessControlCategory $category, AddressInterface $defaultIpAddress) { $this->em = $em; $this->site = $site; $this->category = $category; $this->defaultIpAddress = $defaultIpAddress; }
Initialize the instance. @param \Doctrine\ORM\EntityManagerInterface $em @param \Concrete\Core\Entity\Site\Site $site @param \Concrete\Core\Entity\Permission\IpAccessControlCategory $category @param \IPLib\Address\AddressInterface $defaultIpAddress
__construct
php
concretecms/concretecms
concrete/src/Permission/IpAccessControlService.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Permission/IpAccessControlService.php
MIT
public function getCategory() { return $this->category; }
Get the IP Access Control Category. @return \Concrete\Core\Entity\Permission\IpAccessControlCategory
getCategory
php
concretecms/concretecms
concrete/src/Permission/IpAccessControlService.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Permission/IpAccessControlService.php
MIT
public function isBlacklisted(?AddressInterface $ipAddress = null) { return $this->isDenylisted($ipAddress); }
@deprecated Check if an IP address is denylisted. @param \IPLib\Address\AddressInterface|null $ipAddress @return bool
isBlacklisted
php
concretecms/concretecms
concrete/src/Permission/IpAccessControlService.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Permission/IpAccessControlService.php
MIT
public function isDenylisted(?AddressInterface $ipAddress = null) { $range = $this->getRange($ipAddress); return $range !== null && ($range->getType() & self::IPRANGEFLAG_BLACKLIST); }
Check if an IP address is denylisted. @param \IPLib\Address\AddressInterface|null $ipAddress @return bool
isDenylisted
php
concretecms/concretecms
concrete/src/Permission/IpAccessControlService.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Permission/IpAccessControlService.php
MIT
public function isWhitelisted(?AddressInterface $ipAddress = null) { return $this->isAllowlisted($ipAddress); }
@deprecated Check if an IP address is allowlisted. @param \IPLib\Address\AddressInterface|null $ipAddress @return bool
isWhitelisted
php
concretecms/concretecms
concrete/src/Permission/IpAccessControlService.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Permission/IpAccessControlService.php
MIT
public function isAllowlisted(?AddressInterface $ipAddress = null) { $range = $this->getRange($ipAddress); return $range !== null && ($range->getType() & self::IPRANGEFLAG_WHITELIST); }
Check if an IP address is allowlisted. @param \IPLib\Address\AddressInterface|null $ipAddress @return bool
isAllowlisted
php
concretecms/concretecms
concrete/src/Permission/IpAccessControlService.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Permission/IpAccessControlService.php
MIT
public function registerEvent(?AddressInterface $ipAddress = null, $evenIfDisabled = false) { return $this->registerEventAt(new DateTime('now'), $ipAddress, $evenIfDisabled ? true : false); }
Create and save an IP Access Control Event. @param \IPLib\Address\AddressInterface|null $ipAddress the IP address to be recorded (if NULL we'll use the current one) @param bool $evenIfDisabled create the event even if the category is disabled? @return \Concrete\Core\Entity\Permission\IpAccessControlEvent|null
registerEvent
php
concretecms/concretecms
concrete/src/Permission/IpAccessControlService.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Permission/IpAccessControlService.php
MIT
public function registerEventAt(DateTime $dateTime, ?AddressInterface $ipAddress = null, bool $evenIfDisabled = false): ?IpAccessControlEvent { if (!$evenIfDisabled && !$this->getCategory()->isEnabled()) { return null; } $event = new IpAccessControlEvent(); $event ->setCategory($this->getCategory()) ->setSite($this->site) ->setIpAddress($ipAddress ?: $this->defaultIpAddress) ->setDateTime($dateTime) ; $this->em->persist($event); $this->em->flush(); return $event; }
Create and save an IP Access Control Event at a specific date/time. @param \DateTime $dateTime the date/time of the event @param \IPLib\Address\AddressInterface|null $ipAddress the IP address to be recorded (if NULL we'll use the current one) @param bool $evenIfDisabled create the event even if the category is disabled? @return \Concrete\Core\Entity\Permission\IpAccessControlEvent|null return NULL if the category is disabled and $evenIfDisabled is false, the created event otherwise
registerEventAt
php
concretecms/concretecms
concrete/src/Permission/IpAccessControlService.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Permission/IpAccessControlService.php
MIT
public function getEventsCount(?AddressInterface $ipAddress = null): int { if ($ipAddress === null) { $ipAddress = $this->defaultIpAddress; } $qb = $this->em->createQueryBuilder(); $x = $qb->expr(); $qb ->from(IpAccessControlEvent::class, 'e') ->select($x->count('e.ipAccessControlEventID')) ->andWhere($x->eq('e.ip', ':ip')) ->andWhere($x->eq('e.category', ':category')) ->setParameter('ip', $ipAddress->getComparableString()) ->setParameter('category', $this->getCategory()->getIpAccessControlCategoryID()) ; if ($this->getCategory()->getTimeWindow() !== null) { $dateTimeLimit = new DateTime('-' . $this->getCategory()->getTimeWindow() . ' seconds'); $qb ->andWhere($x->gt('e.dateTime', ':dateTimeLimit')) ->setParameter('dateTimeLimit', $dateTimeLimit->format($this->em->getConnection()->getDatabasePlatform()->getDateTimeFormatString())) ; } if ($this->getCategory()->isSiteSpecific()) { $qb ->andWhere( $x->orX( $x->isNull('e.site'), $x->eq('e.site', ':site') ) ) ->setParameter('site', $this->site->getSiteID()) ; } return (int) $qb->getQuery()->getSingleScalarResult(); }
Get the number of events registered (in the time window if it's not null, or any events if null). @param \IPLib\Address\AddressInterface|null $ipAddress the IP address to be checked (if null we'll use the current IP address)
getEventsCount
php
concretecms/concretecms
concrete/src/Permission/IpAccessControlService.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Permission/IpAccessControlService.php
MIT
public function getLastEvent(?AddressInterface $ipAddress = null): ?DateTimeImmutable { if ($ipAddress === null) { $ipAddress = $this->defaultIpAddress; } $qb = $this->em->createQueryBuilder(); $x = $qb->expr(); $qb ->from(IpAccessControlEvent::class, 'e') ->select($x->max('e.dateTime')) ->andWhere($x->eq('e.ip', ':ip')) ->andWhere($x->eq('e.category', ':category')) ->setParameter('ip', $ipAddress->getComparableString()) ->setParameter('category', $this->getCategory()->getIpAccessControlCategoryID()) ; if ($this->getCategory()->getTimeWindow() !== null) { $dateTimeLimit = new DateTime('-' . $this->getCategory()->getTimeWindow() . ' seconds'); $qb ->andWhere($x->gt('e.dateTime', ':dateTimeLimit')) ->setParameter('dateTimeLimit', $dateTimeLimit->format($this->em->getConnection()->getDatabasePlatform()->getDateTimeFormatString())) ; } if ($this->getCategory()->isSiteSpecific()) { $qb ->andWhere( $x->orX( $x->isNull('e.site'), $x->eq('e.site', ':site') ) ) ->setParameter('site', $this->site->getSiteID()) ; } $sqlDateTime = $qb->getQuery()->getSingleScalarResult(); if ($sqlDateTime === null) { return null; } return DateTimeImmutable::createFromFormat($this->em->getConnection()->getDatabasePlatform()->getDateTimeFormatString(), $sqlDateTime); }
Get the date/time of the last registered events (in the time window if it's not null, or any events if null). @param \IPLib\Address\AddressInterface|null $ipAddress the IP address to be checked (if null we'll use the current IP address)
getLastEvent
php
concretecms/concretecms
concrete/src/Permission/IpAccessControlService.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Permission/IpAccessControlService.php
MIT
public function isThresholdReached(?AddressInterface $ipAddress = null, $evenIfDisabled = false) { if (!$evenIfDisabled && !$this->getCategory()->isEnabled()) { return false; } if ($ipAddress === null) { $ipAddress = $this->defaultIpAddress; } if ($this->isAllowlisted($ipAddress)) { return false; } $numEvents = $this->getEventsCount($ipAddress); if ($numEvents < $this->getCategory()->getMaxEvents()) { return false; } if ($this->category->getTimeWindow() !== null) { return true; } $banDuration = $this->category->getBanDuration(); if ($banDuration === null) { return true; } // Here: // - the time window is null (which means that we count all events, not only those in a specific time interval) // - the ban duration is not null (which means that we ban the IP only for a specific interval) // So, we need to check if the ban duration is already passed, and we need to reset the recorded events, // otherwise the ban would last forever. $lastEvent = $this->getLastEvent($ipAddress); $now = new DateTimeImmutable(); $elapsedSeconds = $now->getTimestamp() - $lastEvent->getTimestamp(); if ($elapsedSeconds < $banDuration) { return true; } $this->deleteEventsFor($ipAddress); return false; }
Check if the IP address has reached the threshold. @param \IPLib\Address\AddressInterface|null $ipAddress the IP address to be checked (if null we'll use the current IP address) @param bool $evenIfDisabled @return bool
isThresholdReached
php
concretecms/concretecms
concrete/src/Permission/IpAccessControlService.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Permission/IpAccessControlService.php
MIT
public function addToDenylistForThresholdReached(?AddressInterface $ipAddress = null, $evenIfDisabled = false) { if (!$evenIfDisabled && !$this->getCategory()->isEnabled()) { return null; } if ($ipAddress === null) { $ipAddress = $this->defaultIpAddress; } if ($this->getCategory()->getBanDuration() === null) { $banExpiration = null; } else { $banExpiration = new DateTime('+' . $this->getCategory()->getBanDuration() . ' seconds'); } $range = $this->createRange( IPFactory::getRangeFromBoundaries($ipAddress, $ipAddress), static::IPRANGETYPE_BLACKLIST_AUTOMATIC, $banExpiration ); if ($this->getCategory()->getLogChannelHandle() !== '') { $this->logger->warning( t('IP address %1$s added to denylist for the category %2$s.', $ipAddress->toString(), $this->getCategory()->getDisplayName()), [ 'ip_address' => $ipAddress->toString(), 'category' => $this->getCategory()->getHandle(), ] ); } return $range; }
Add an IP address to the list of denylisted IP address when too many events occur. @param \IPLib\Address\AddressInterface|null $ipAddress the IP to add to the denylist (if null, we'll use the current IP address) @param bool $evenIfDisabled if set to true, we'll add the IP address even if the IP ban system is disabled in the configuration @return \Concrete\Core\Entity\Permission\IpAccessControlRange|null
addToDenylistForThresholdReached
php
concretecms/concretecms
concrete/src/Permission/IpAccessControlService.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Permission/IpAccessControlService.php
MIT
public function createRange(RangeInterface $range, $type, ?DateTime $expiration = null) { $result = new IpAccessControlRange(); $result ->setCategory($this->getCategory()) ->setIpRange($range) ->setType($type) ->setExpiration($expiration) ->setSite($this->site) ; $this->em->persist($result); $this->em->flush($result); return $result; }
Add persist an IP address range type. @param \IPLib\Range\RangeInterface $range the IP address range to persist @param int $type The range type (one of the IpAccessControlService::IPRANGETYPE_... constants) @param \DateTime $expiration The optional expiration of the range type @return \Concrete\Core\Entity\Permission\IpAccessControlRange
createRange
php
concretecms/concretecms
concrete/src/Permission/IpAccessControlService.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Permission/IpAccessControlService.php
MIT
public function getRanges($type, $includeExpired = false) { $criteria = new Criteria(); $x = $criteria->expr(); $criteria->andWhere($x->eq('type', (int) $type)); if (!$includeExpired) { $criteria->andWhere( $x->orX( $x->isNull('expiration'), $x->gt('expiration', new DateTime('now')) ) ); } return $this->getCategory()->getRanges()->matching($criteria); }
Get the list of currently available ranges. @param int $type (one of the IPService::IPRANGETYPE_... constants) @param bool $includeExpired Include expired records? @return \Doctrine\Common\Collections\Collection|\Concrete\Core\Entity\Permission\IpAccessControlRange[]
getRanges
php
concretecms/concretecms
concrete/src/Permission/IpAccessControlService.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Permission/IpAccessControlService.php
MIT
public function getRangeByID($id) { if (!$id) { return null; } $entity = $this->em->find(IpAccessControlRange::class, ['ipAccessControlRangeID' => (int) $id]); if ($entity === null) { return null; } if ($entity->getCategory() !== $this->getCategory()) { return null; } return $entity; }
Get a saved range for this category given its ID. @param int $id \Concrete\Core\Entity\Permission\IpAccessControlRange|null
getRangeByID
php
concretecms/concretecms
concrete/src/Permission/IpAccessControlService.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Permission/IpAccessControlService.php
MIT
public function deleteRange($range) { $entity = is_numeric($range) ? $this->getRangeByID($range) : $range; if (!($entity instanceof IpAccessControlRange) || $entity->getCategory() !== $this->getCategory()) { return; } $this->em->remove($entity); $this->em->flush($entity); }
Delete a saved range given its instance or its ID. @param \Concrete\Core\Entity\Permission\IpAccessControlRange|int $range
deleteRange
php
concretecms/concretecms
concrete/src/Permission/IpAccessControlService.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Permission/IpAccessControlService.php
MIT
public function deleteEvents($minAge = null) { return $this->deleteEventsFor(null, $minAge ? (int) $minAge : null); }
Delete the recorded events. @param int|null $minAge the minimum age (in seconds) of the records (specify an empty value to delete all records) @return int the number of records deleted
deleteEvents
php
concretecms/concretecms
concrete/src/Permission/IpAccessControlService.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Permission/IpAccessControlService.php
MIT
public function deleteEventsFor(?AddressInterface $ipAddress = null, ?int $minAge = null): int { $qb = $this->em->createQueryBuilder(); $x = $qb->expr(); $qb ->delete(IpAccessControlEvent::class, 'e') ->andWhere($x->eq('e.category', ':category')) ->setParameter('category', $this->getCategory()->getIpAccessControlCategoryID()) ; if ($ipAddress !== null) { $qb ->andWhere($x->eq('e.ip', ':ip')) ->setParameter('ip', $ipAddress->getComparableString()) ; } if ($minAge !== null) { $dateTimeLimit = new DateTime("-{$minAge} seconds"); $qb ->andWhere($x->lte('e.dateTime', ':dateTimeLimit')) ->setParameter('dateTimeLimit', $dateTimeLimit->format($this->em->getConnection()->getDatabasePlatform()->getDateTimeFormatString())) ; } return (int) $qb->getQuery()->execute(); }
Delete the recorded events. @param \IPLib\Address\AddressInterface|null $ipAddress delete the records for this specific IP address (or for any address if NULL) @param int|null $minAge the minimum age (in seconds) of the records (specify NULL delete all records) @return int the number of records deleted
deleteEventsFor
php
concretecms/concretecms
concrete/src/Permission/IpAccessControlService.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Permission/IpAccessControlService.php
MIT
public function deleteAutomaticDenylist($onlyExpired = true) { $qb = $this->em->createQueryBuilder(); $x = $qb->expr(); $qb ->delete(IpAccessControlRange::class, 'r') ->where($x->eq('r.category', ':category')) ->andWhere($x->eq('r.type', ':type')) ->setParameter('category', $this->getCategory()->getIpAccessControlCategoryID()) ->setParameter('type', self::IPRANGETYPE_BLACKLIST_AUTOMATIC) ; if ($onlyExpired) { $dateTimeLimit = new DateTime('now'); $qb ->andWhere($x->lte('r.expiration', ':dateTimeLimit')) ->setParameter('dateTimeLimit', $dateTimeLimit->format($this->em->getConnection()->getDatabasePlatform()->getDateTimeFormatString())) ; } return (int) $qb->getQuery()->execute(); }
Clear the IP addresses automatically denylisted. @param bool $onlyExpired @return int the number of records deleted
deleteAutomaticDenylist
php
concretecms/concretecms
concrete/src/Permission/IpAccessControlService.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Permission/IpAccessControlService.php
MIT
public function getErrorMessage() { return t('Unable to complete action: your IP address has been banned. Please contact the administrator of this site for more information.'); }
Get the (localized) message telling the users that their IP address has been banned. @return string
getErrorMessage
php
concretecms/concretecms
concrete/src/Permission/IpAccessControlService.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Permission/IpAccessControlService.php
MIT
public function getLoggerChannel() { return $this->getCategory()->getLogChannelHandle(); }
{@inheritdoc} @see \Concrete\Core\Logging\LoggerAwareInterface::getLoggerChannel()
getLoggerChannel
php
concretecms/concretecms
concrete/src/Permission/IpAccessControlService.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Permission/IpAccessControlService.php
MIT
public function getRange(?AddressInterface $ipAddress = null) { if ($ipAddress === null) { $ipAddress = $this->defaultIpAddress; } $qb = $this->em->createQueryBuilder(); $x = $qb->expr(); $qb ->from(IpAccessControlRange::class, 'r') ->select('r') ->andWhere($x->eq('r.category', ':category')) ->andWhere($x->lte('r.ipFrom', ':ip')) ->andWhere($x->gte('r.ipTo', ':ip')) ->andWhere( $x->orX( $x->isNull('r.expiration'), $x->gt('r.expiration', ':now') ) ) ->setParameter('category', $this->getCategory()->getIpAccessControlCategoryID()) ->setParameter('ip', $ipAddress->getComparableString()) ->setParameter('now', date($this->em->getConnection()->getDatabasePlatform()->getDateTimeFormatString())) ; if ($this->getCategory()->isSiteSpecific()) { $qb ->andWhere( $x->orX( $x->isNull('r.site'), $x->eq('r.site', ':site') ) ) ->setParameter('site', $this->site->getSiteID()) ; } $query = $qb->getQuery(); $result = null; foreach ($query->getResult() as $range) { $result = $range; if ($range->getType() & self::IPRANGEFLAG_WHITELIST) { break; } } return $result; }
@param \IPLib\Address\AddressInterface $ipAddress @return \Concrete\Core\Entity\Permission\IpAccessControlRange|null
getRange
php
concretecms/concretecms
concrete/src/Permission/IpAccessControlService.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Permission/IpAccessControlService.php
MIT
public function getID() { return $this->id; }
Get the record identifier. @return int
getID
php
concretecms/concretecms
concrete/src/Permission/IPRange.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Permission/IPRange.php
MIT
public function getIpRange() { return $this->ipRange; }
Get the IP address range. @return \IPLib\Range\RangeInterface
getIpRange
php
concretecms/concretecms
concrete/src/Permission/IPRange.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Permission/IPRange.php
MIT
public function getType() { return $this->type; }
Get the range type. @return int
getType
php
concretecms/concretecms
concrete/src/Permission/IPRange.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Permission/IPRange.php
MIT
public static function createFromRow(array $row, $dateTimeFormat) { $result = new static(); $result->id = empty($row['lcirID']) ? null : (int) $row['lcirID']; $result->ipRange = IPFactory::getRangeFromBoundaries($row['lcirIpFrom'], $row['lcirIpTo']); $result->type = (int) $row['lcirType']; $result->expires = empty($row['lcirExpires']) ? null : DateTime::createFromFormat($dateTimeFormat, $row['lcirExpires']); return $result; }
@param array $row @param mixed $dateTimeFormat @return static
createFromRow
php
concretecms/concretecms
concrete/src/Permission/IPRange.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Permission/IPRange.php
MIT
public static function createFromEntity(IpAccessControlRange $range) { $result = new static(); $result->id = $range->getIpAccessControlRangeID(); $result->ipRange = $range->getIpRange(); $result->type = $range->getType(); $result->expires = $range->getExpiration(); return $result; }
@param \Concrete\Core\Entity\Permission\IpAccessControlRange $range @return static
createFromEntity
php
concretecms/concretecms
concrete/src/Permission/IPRange.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Permission/IPRange.php
MIT
public function __construct(Writer $writer, $type, Date $dateHelper) { $this->writer = $writer; $this->type = $type; $this->dateHelper = $dateHelper; }
@param Writer $writer the writer we use to output @param int $type One of the IpAccessControlService::IPRANGETYPE_... constants @param Date $dateHelper the Date localization service
__construct
php
concretecms/concretecms
concrete/src/Permission/IPRangesCsvWriter.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Permission/IPRangesCsvWriter.php
MIT
public function insertHeaders() { $this->writer->insertOne($this->getHeaders()); }
Insert a header row for this result set.
insertHeaders
php
concretecms/concretecms
concrete/src/Permission/IPRangesCsvWriter.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Permission/IPRangesCsvWriter.php
MIT
public function insertRanges($ranges) { $this->writer->insertAll($this->projectRanges($ranges)); }
Insert a list of IPRange/IpAccessControlRange instances. @param \Concrete\Core\Permission\IPRange[]|\Concrete\Core\Entity\Permission\IpAccessControlRange[]|\Generator $ranges
insertRanges
php
concretecms/concretecms
concrete/src/Permission/IPRangesCsvWriter.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Permission/IPRangesCsvWriter.php
MIT
public function insertRange($range) { $this->writer->insertOne($this->projectRange($range)); }
Insert an IPRange/IpAccessControlRange instance. @param \Concrete\Core\Permission\IPRange|\Concrete\Core\Entity\Permission\IpAccessControlRange $range
insertRange
php
concretecms/concretecms
concrete/src/Permission/IPRangesCsvWriter.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Permission/IPRangesCsvWriter.php
MIT
private function projectRanges($ranges) { foreach ($ranges as $range) { yield $this->projectRange($range); } }
A generator that takes a collection of IPRange/IpAccessControlRange ranges and converts it to CSV rows. @param \Concrete\Core\Permission\IPRange[]|\Concrete\Core\Entity\Permission\IpAccessControlRange[]|\Generator $ranges @return array[]|\Generator
projectRanges
php
concretecms/concretecms
concrete/src/Permission/IPRangesCsvWriter.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Permission/IPRangesCsvWriter.php
MIT
private function projectRange($range) { $ipRange = $range->getIpRange(); $result = [ $ipRange->toString(), $ipRange->getComparableStartString(), $ipRange->getComparableEndString(), ]; if ($this->type === IpAccessControlService::IPRANGETYPE_BLACKLIST_AUTOMATIC) { $dt = $range instanceof IPRange ? $range->getExpires() : $range->getExpiration(); if ($dt === null) { $result[] = ''; } else { $result[] = $this->dateHelper->formatCustom('c', $dt); } } return $result; }
Turn an IPRange/IpAccessControlRange instance into an array. @param \Concrete\Core\Permission\IPRange|\Concrete\Core\Entity\Permission\IpAccessControlRange $range @return string[]
projectRange
php
concretecms/concretecms
concrete/src/Permission/IPRangesCsvWriter.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Permission/IPRangesCsvWriter.php
MIT
private function getHeaders() { $headers = [t('IP Range'), t('Start address'), t('End address')]; if ($this->type === IpAccessControlService::IPRANGETYPE_BLACKLIST_AUTOMATIC) { $headers[] = t('Expiration'); } return $headers; }
Get the headers of the CSV. @return string[]
getHeaders
php
concretecms/concretecms
concrete/src/Permission/IPRangesCsvWriter.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Permission/IPRangesCsvWriter.php
MIT
public function __construct(Repository $config, Connection $connection, Request $request) { $this->config = $config; $this->connection = $connection; $this->request = $request; }
@param \Concrete\Core\Config\Repository\Repository $config @param \Concrete\Core\Database\Connection\Connection $connection @param \Concrete\Core\Http\Request $request
__construct
php
concretecms/concretecms
concrete/src/Permission/IPService.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Permission/IPService.php
MIT
public function getLoggerChannel() { return Channels::CHANNEL_SECURITY; }
{@inheritdoc} @see \Concrete\Core\Logging\LoggerAwareInterface::getLoggerChannel()
getLoggerChannel
php
concretecms/concretecms
concrete/src/Permission/IPService.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Permission/IPService.php
MIT
public function getRequestIPAddress() { return $this->app->make(AddressInterface::class); }
@deprecated Use $app->make(\IPLib\Address\AddressInterface::class) @return \IPLib\Address\AddressInterface
getRequestIPAddress
php
concretecms/concretecms
concrete/src/Permission/IPService.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Permission/IPService.php
MIT
public function isDenylisted(?AddressInterface $ip = null) { return $this->getFailedLoginService()->isDenylisted($ip); }
@deprecated use $app->make('failed_login')->isDenylisted() @param \IPLib\Address\AddressInterface|null $ip @return bool
isDenylisted
php
concretecms/concretecms
concrete/src/Permission/IPService.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Permission/IPService.php
MIT
public function isBlacklisted(?AddressInterface $ip = null) { return $this->getFailedLoginService()->isBlacklisted($ip); }
@deprecated use $app->make('failed_login')->isBlacklisted() @param \IPLib\Address\AddressInterface|null $ip @return bool
isBlacklisted
php
concretecms/concretecms
concrete/src/Permission/IPService.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Permission/IPService.php
MIT
public function isAllowlisted(?AddressInterface $ip = null) { return $this->getFailedLoginService()->isAllowlisted($ip); }
@deprecated use $app->make('failed_login')->isAllowlisted() @param \IPLib\Address\AddressInterface|null $ip @return bool
isAllowlisted
php
concretecms/concretecms
concrete/src/Permission/IPService.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Permission/IPService.php
MIT
public function isWhitelisted(?AddressInterface $ip = null) { return $this->getFailedLoginService()->isWhitelisted($ip); }
@deprecated use $app->make('failed_login')->isWhitelisted() @param \IPLib\Address\AddressInterface|null $ip @return bool
isWhitelisted
php
concretecms/concretecms
concrete/src/Permission/IPService.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Permission/IPService.php
MIT
public function getErrorMessage() { return $this->getFailedLoginService()->getErrorMessage(); }
@deprecated use $app->make('failed_login')->getErrorMessage() @return string
getErrorMessage
php
concretecms/concretecms
concrete/src/Permission/IPService.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Permission/IPService.php
MIT
public function logFailedLogin(?AddressInterface $ip = null, $ignoreConfig = false) { return $this->getFailedLoginService()->registerEvent($ip, $ignoreConfig); }
@deprecated use $app->make('failed_login')->registerEvent() @param \IPLib\Address\AddressInterface|null $ip @param bool $ignoreConfig
logFailedLogin
php
concretecms/concretecms
concrete/src/Permission/IPService.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Permission/IPService.php
MIT
public function failedLoginsThresholdReached(?AddressInterface $ip = null, $ignoreConfig = false) { return $this->getFailedLoginService()->isThresholdReached($ip, $ignoreConfig); }
@deprecated use $app->make('failed_login')->isThresholdReached() @param \IPLib\Address\AddressInterface|null $ip @param bool $ignoreConfig @return bool
failedLoginsThresholdReached
php
concretecms/concretecms
concrete/src/Permission/IPService.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Permission/IPService.php
MIT
public function addToDenylistForThresholdReached(?AddressInterface $ip = null, $ignoreConfig = false) { $this->getFailedLoginService()->addToDenylistForThresholdReached($ip, $ignoreConfig); }
@deprecated use $app->make('failed_login')->addToDenylistForThresholdReached() @param \IPLib\Address\AddressInterface $ip @param bool $ignoreConfig
addToDenylistForThresholdReached
php
concretecms/concretecms
concrete/src/Permission/IPService.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Permission/IPService.php
MIT
public function createRange(RangeInterface $range, $type, ?DateTime $expiration = null) { $rangeEntity = $this->getFailedLoginService()->createRange($range, $type, $expiration); return IPRange::createFromEntity($rangeEntity); }
@deprecated use $app->make('failed_login')->createRange() @param \IPLib\Range\RangeInterface $range @param int $type @param \DateTime|null $expiration @return \Concrete\Core\Permission\IPRange
createRange
php
concretecms/concretecms
concrete/src/Permission/IPService.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Permission/IPService.php
MIT