_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q242900
Suggestion.create
validation
public static function create($reply = null) { $suggestion = new self(); if ($reply) { $suggestion->reply($reply); } return $suggestion; }
php
{ "resource": "" }
q242901
Suggestion.reply
validation
public function reply($reply) { if (is_string($reply)) { $this->replies = [$reply]; } elseif (is_array($reply)) { $this->replies = $reply; } return $this; }
php
{ "resource": "" }
q242902
MediaObject.render
validation
public function render() { $mediaObject = []; $mediaObject['contentUrl'] = $this->url; if ($this->name) { $mediaObject['name'] = $this->name; } if ($this->description) { $mediaObject['description'] = $this->description; } if ($this->...
php
{ "resource": "" }
q242903
WebhookClient.reply
validation
public function reply($message) { if (is_string($message)) { $this->messages[] = Text::create() ->text($message) ->setAgentVersion($this->agentVersion) ->setRequestSource($this->requestSource); if (! $this->doesSupportRichMessage()) { ...
php
{ "resource": "" }
q242904
BasicCard.image
validation
public function image($imageUrl, $accessibilityText = null) { $this->imageUrl = $imageUrl; $this->accessibilityText = $accessibilityText; return $this; }
php
{ "resource": "" }
q242905
Countries.getCountries
validation
protected function getCountries() { //Get the countries from the JSON file if (sizeof($this->countries) == 0) { $this->countries = json_decode(file_get_contents(__DIR__ . '/Models/countries.json'), true); } //Return the countries return $this->countries; ...
php
{ "resource": "" }
q242906
Countries.getListForSelect
validation
public function getListForSelect($display = 'name') { foreach ($this->getList($display) as $key => $value) { $countries[$key] = $value[$display]; } //return the array return $countries; }
php
{ "resource": "" }
q242907
ModuleTwoFactor.enableTwoFactor
validation
protected function enableTwoFactor(BackendUser $user, $return) { // Return if 2FA is enabled already if ($user->useTwoFactor) { return; } $container = System::getContainer(); $verifyHelp = $GLOBALS['TL_LANG']['MSC']['twoFactorVerificationHelp']; /** @var Authenticator $authenticator */ $authentica...
php
{ "resource": "" }
q242908
ModuleTwoFactor.disableTwoFactor
validation
protected function disableTwoFactor(BackendUser $user, $return) { // Return if 2FA is disabled already if (!$user->useTwoFactor) { return; } $user->secret = null; $user->useTwoFactor = ''; $user->save(); throw new RedirectResponseException($return); }
php
{ "resource": "" }
q242909
Folder.purge
validation
public function purge() { $this->Files->rrdir($this->strFolder, true); // Update the database if (Dbafs::shouldBeSynchronized($this->strFolder)) { $objFiles = FilesModel::findMultipleByBasepath($this->strFolder . '/'); if ($objFiles !== null) { while ($objFiles->next()) { $objFiles->del...
php
{ "resource": "" }
q242910
Folder.delete
validation
public function delete() { $this->Files->rrdir($this->strFolder); // Update the database if (Dbafs::shouldBeSynchronized($this->strFolder)) { Dbafs::deleteResource($this->strFolder); } }
php
{ "resource": "" }
q242911
Folder.renameTo
validation
public function renameTo($strNewName) { $strParent = \dirname($strNewName); // Create the parent folder if it does not exist if (!is_dir($this->strRootDir . '/' . $strParent)) { new self($strParent); } $return = $this->Files->rename($this->strFolder, $strNewName); // Update the database AFTER the f...
php
{ "resource": "" }
q242912
Folder.copyTo
validation
public function copyTo($strNewName) { $strParent = \dirname($strNewName); // Create the parent folder if it does not exist if (!is_dir($this->strRootDir . '/' . $strParent)) { new self($strParent); } $this->Files->rcopy($this->strFolder, $strNewName); // Update the database AFTER the folder has bee...
php
{ "resource": "" }
q242913
Folder.protect
validation
public function protect() { if (!$this->isUnprotected()) { return; } // Check if the .public file exists if (!file_exists($this->strRootDir . '/' . $this->strFolder . '/.public')) { throw new \RuntimeException(sprintf('Cannot protect folder "%s" because one of its parent folders is public', $this->s...
php
{ "resource": "" }
q242914
Folder.isUnprotected
validation
public function isUnprotected() { $path = $this->strFolder; do { if (file_exists($this->strRootDir . '/' . $path . '/.public')) { return true; } $path = \dirname($path); } while ($path != '.'); return false; }
php
{ "resource": "" }
q242915
Folder.synchronize
validation
public function synchronize() { if (!$this->isUnsynchronized()) { return; } // Check if the .nosync file exists if (!file_exists($this->strRootDir . '/' . $this->strFolder . '/.nosync')) { throw new \RuntimeException(sprintf('Cannot synchronize the folder "%s" because one of its parent folders is un...
php
{ "resource": "" }
q242916
Folder.unsynchronize
validation
public function unsynchronize() { if (!file_exists($this->strRootDir . '/' . $this->strFolder . '/.nosync')) { System::getContainer()->get('filesystem')->touch($this->strRootDir . '/' . $this->strFolder . '/.nosync'); } }
php
{ "resource": "" }
q242917
Folder.getModel
validation
public function getModel() { if ($this->objModel === null && Dbafs::shouldBeSynchronized($this->strFolder)) { $this->objModel = FilesModel::findByPath($this->strFolder); } return $this->objModel; }
php
{ "resource": "" }
q242918
Folder.getHash
validation
protected function getHash() { @trigger_error('Using Folder::getHash() has been deprecated and will no longer work in Contao 5.0. Use Dbafs::getFolderHash() instead.', E_USER_DEPRECATED); $arrFiles = array(); /** @var \SplFileInfo[] $it */ $it = new \RecursiveIteratorIterator( new \RecursiveDirectoryItera...
php
{ "resource": "" }
q242919
Folder.getSize
validation
protected function getSize() { $intSize = 0; foreach (scan($this->strRootDir . '/' . $this->strFolder, true) as $strFile) { if (strncmp($strFile, '.', 1) === 0) { continue; } if (is_dir($this->strRootDir . '/' . $this->strFolder . '/' . $strFile)) { $objFolder = new self($this->strFolder...
php
{ "resource": "" }
q242920
tl_user.checkPermission
validation
public function checkPermission() { if ($this->User->isAdmin) { return; } // Check current action switch (Contao\Input::get('act')) { case 'create': case 'select': case 'show': // Allow break; case 'delete': if (Contao\Input::get('id') == $this->User->id) { throw new C...
php
{ "resource": "" }
q242921
tl_user.handleUserProfile
validation
public function handleUserProfile(Contao\DataContainer $dc) { if (Contao\Input::get('do') != 'login') { return; } // Should not happen because of the redirect but better safe than sorry if (Contao\BackendUser::getInstance()->id != Contao\Input::get('id') || Contao\Input::get('act') != 'edit') { thro...
php
{ "resource": "" }
q242922
tl_user.copyUser
validation
public function copyUser($row, $href, $label, $title, $icon, $attributes, $table) { if ($GLOBALS['TL_DCA'][$table]['config']['closed']) { return ''; } return ($this->User->isAdmin || !$row['admin']) ? '<a href="'.$this->addToUrl($href.'&amp;id='.$row['id']).'" title="'.Contao\StringUtil::specialchars($titl...
php
{ "resource": "" }
q242923
tl_user.sessionField
validation
public function sessionField(Contao\DataContainer $dc) { if (Contao\Input::post('FORM_SUBMIT') == 'tl_user') { $arrPurge = Contao\Input::post('purge'); if (\is_array($arrPurge)) { $this->import('Contao\Automator', 'Automator'); if (\in_array('purge_session', $arrPurge)) { /** @var Symfo...
php
{ "resource": "" }
q242924
tl_user.getModules
validation
public function getModules() { $arrModules = array(); foreach ($GLOBALS['BE_MOD'] as $k=>$v) { if (!empty($v)) { if ($k == 'accounts') { unset($v['login']); } if ($k == 'system') { unset($v['undo']); } $arrModules[$k] = array_keys($v); } } return $arrModules...
php
{ "resource": "" }
q242925
tl_user.checkAdminStatus
validation
public function checkAdminStatus($varValue, Contao\DataContainer $dc) { if ($varValue == '' && $this->User->id == $dc->id) { $varValue = 1; } return $varValue; }
php
{ "resource": "" }
q242926
tl_user.checkAdminDisable
validation
public function checkAdminDisable($varValue, Contao\DataContainer $dc) { if ($varValue == 1 && $this->User->id == $dc->id) { $varValue = ''; } return $varValue; }
php
{ "resource": "" }
q242927
tl_user.updateCurrentUser
validation
public function updateCurrentUser(Contao\DataContainer $dc) { if ($this->User->id == $dc->id) { $this->User->findBy('id', $this->User->id); } }
php
{ "resource": "" }
q242928
FrontendController.loginAction
validation
public function loginAction(): Response { $this->get('contao.framework')->initialize(); if (!isset($GLOBALS['TL_PTY']['error_401']) || !class_exists($GLOBALS['TL_PTY']['error_401'])) { throw new UnauthorizedHttpException('', 'Not authorized'); } /** @var PageError401 $p...
php
{ "resource": "" }
q242929
StyleSheets.updateStyleSheet
validation
public function updateStyleSheet($intId) { $objStyleSheet = $this->Database->prepare("SELECT * FROM tl_style_sheet WHERE id=?") ->limit(1) ->execute($intId); if ($objStyleSheet->numRows < 1) { return; } // Delete the CSS file if (Input::get('act') == 'delete') { $this->import(...
php
{ "resource": "" }
q242930
StyleSheets.updateStyleSheets
validation
public function updateStyleSheets() { $objStyleSheets = $this->Database->execute("SELECT * FROM tl_style_sheet"); $arrStyleSheets = $objStyleSheets->fetchEach('name'); // Make sure the dcaconfig.php file is loaded if (file_exists($this->strRootDir . '/system/config/dcaconfig.php')) { @trigger_error('Usin...
php
{ "resource": "" }
q242931
StyleSheets.writeStyleSheet
validation
protected function writeStyleSheet($row) { if ($row['id'] == '' || $row['name'] == '') { return; } $row['name'] = basename($row['name']); // Check whether the target file is writeable if (file_exists($this->strRootDir . '/assets/css/' . $row['name'] . '.css') && !$this->Files->is_writeable('assets/css...
php
{ "resource": "" }
q242932
StyleSheets.compileColor
validation
protected function compileColor($color, $blnWriteToFile=false, $vars=array()) { if (!\is_array($color)) { return '#' . $this->shortenHexColor($color); } elseif (!isset($color[1]) || empty($color[1])) { return '#' . $this->shortenHexColor($color[0]); } else { return 'rgba(' . implode(',', $this...
php
{ "resource": "" }
q242933
StyleSheets.shortenHexColor
validation
protected function shortenHexColor($color) { if ($color[0] == $color[1] && $color[2] == $color[3] && $color[4] == $color[5]) { return $color[0] . $color[2] . $color[4]; } return $color; }
php
{ "resource": "" }
q242934
StyleSheets.convertHexColor
validation
protected function convertHexColor($color, $blnWriteToFile=false, $vars=array()) { // Support global variables if (strncmp($color, '$', 1) === 0) { if (!$blnWriteToFile) { return array($color); } else { $color = str_replace(array_keys($vars), $vars, $color); } } $rgb = array(); ...
php
{ "resource": "" }
q242935
StyleSheets.exportStyleSheet
validation
public function exportStyleSheet(DataContainer $dc) { $objStyleSheet = $this->Database->prepare("SELECT * FROM tl_style_sheet WHERE id=?") ->limit(1) ->execute($dc->id); if ($objStyleSheet->numRows < 1) { throw new \Exception("Invalid style sheet ID {$dc->id}"); } $vars = array(); ...
php
{ "resource": "" }
q242936
StyleSheets.checkStyleSheetName
validation
public function checkStyleSheetName($strName) { $objStyleSheet = $this->Database->prepare("SELECT COUNT(*) AS count FROM tl_style_sheet WHERE name=?") ->limit(1) ->execute($strName); if ($objStyleSheet->count < 1) { return $strName; } $chunks = explode('-', $strName); $i = (\count(...
php
{ "resource": "" }
q242937
StyleSheetModel.findByIds
validation
public static function findByIds($arrIds) { if (empty($arrIds) || !\is_array($arrIds)) { return null; } $objDatabase = Database::getInstance(); $arrIds = array_map('\intval', $arrIds); $objResult = $objDatabase->execute("SELECT *, (SELECT tstamp FROM tl_theme WHERE tl_theme.id=tl_style_sheet.pid) AS t...
php
{ "resource": "" }
q242938
FrontendPreviewAuthenticator.removeFrontendAuthentication
validation
public function removeFrontendAuthentication(): bool { if (!$this->session->isStarted() || !$this->session->has(FrontendUser::SECURITY_SESSION_KEY)) { return false; } $this->session->remove(FrontendUser::SECURITY_SESSION_KEY); return true; }
php
{ "resource": "" }
q242939
FrontendPreviewAuthenticator.loadFrontendUser
validation
private function loadFrontendUser(string $username, BackendUser $backendUser): ?FrontendUser { try { $frontendUser = $this->userProvider->loadUserByUsername($username); // Make sure the user provider returned a front end user if (!$frontendUser instanceof FrontendUser) {...
php
{ "resource": "" }
q242940
ZipReader.getFile
validation
public function getFile($strName) { foreach ($this->arrFiles as $k=>$v) { if ($strName == $v['file_name']) { $this->intIndex = $k; return true; } } return false; }
php
{ "resource": "" }
q242941
ZipReader.unzip
validation
public function unzip() { if ($this->intIndex < 0) { $this->first(); } $strName = $this->arrFiles[$this->intIndex]['file_name']; // Encrypted files are not supported if ($this->arrFiles[$this->intIndex]['general_purpose_bit_flag'] & 0x0001) { throw new \Exception("File $strName is encrypted"); ...
php
{ "resource": "" }
q242942
ZipReader.decToUnix
validation
protected function decToUnix($intTime, $intDate) { return mktime ( ($intTime & 0xf800) >> 11, ($intTime & 0x07e0) >> 5, ($intTime & 0x001f) << 1, ($intDate & 0x01e0) >> 5, ($intDate & 0x001f), (($intDate & 0xfe00) >> 9) + 1980 ); }
php
{ "resource": "" }
q242943
News.getSearchablePages
validation
public function getSearchablePages($arrPages, $intRoot=0, $blnIsSitemap=false) { $arrRoot = array(); if ($intRoot > 0) { $arrRoot = $this->Database->getChildRecords($intRoot, 'tl_page'); } $arrProcessed = array(); $time = Date::floorToMinute(); // Get all news archives $objArchive = NewsArchiveMo...
php
{ "resource": "" }
q242944
News.getLink
validation
protected function getLink($objItem, $strUrl, $strBase='') { switch ($objItem->source) { // Link to an external page case 'external': return $objItem->url; break; // Link to an internal page case 'internal': if (($objTarget = $objItem->getRelated('jumpTo')) instanceof PageModel) { ...
php
{ "resource": "" }
q242945
News.purgeOldFeeds
validation
public function purgeOldFeeds() { $arrFeeds = array(); $objFeeds = NewsFeedModel::findAll(); if ($objFeeds !== null) { while ($objFeeds->next()) { $arrFeeds[] = $objFeeds->alias ?: 'news' . $objFeeds->id; } } return $arrFeeds; }
php
{ "resource": "" }
q242946
JwtManager.addResponseCookie
validation
public function addResponseCookie(Response $response, array $payload = []): void { if ($this->hasCookie($response)) { return; } $payload['iat'] = time(); $payload['exp'] = strtotime('+30 minutes'); if (method_exists(Cookie::class, 'create')) { $cooki...
php
{ "resource": "" }
q242947
JwtManager.clearResponseCookie
validation
public function clearResponseCookie(Response $response): Response { $response->headers->clearCookie(self::COOKIE_NAME); return $response; }
php
{ "resource": "" }
q242948
JwtManager.hasCookie
validation
private function hasCookie(Response $response): bool { /** @var Cookie[] $cookies */ $cookies = $response->headers->getCookies(); foreach ($cookies as $cookie) { if (self::COOKIE_NAME === $cookie->getName()) { return true; } } return ...
php
{ "resource": "" }
q242949
Search.removeEntry
validation
public static function removeEntry($strUrl) { $objDatabase = Database::getInstance(); $objResult = $objDatabase->prepare("SELECT id FROM tl_search WHERE url=?") ->execute($strUrl); while ($objResult->next()) { $objDatabase->prepare("DELETE FROM tl_search WHERE id=?") ->execute($objResult->i...
php
{ "resource": "" }
q242950
ContaoTemplateExtension.renderContaoBackendTemplate
validation
public function renderContaoBackendTemplate(array $blocks = []): string { $request = $this->requestStack->getCurrentRequest(); if (null === $request || !$this->scopeMatcher->isBackendRequest($request)) { return ''; } /** @var BackendCustom $controller */ $contro...
php
{ "resource": "" }
q242951
InsertTagsListener.onReplaceInsertTags
validation
public function onReplaceInsertTags(string $tag, bool $useCache, $cacheValue, array $flags) { static $supportedTags = [ 'faq', 'faq_open', 'faq_url', 'faq_title', ]; $elements = explode('::', $tag); $key = strtolower($elements[0]); ...
php
{ "resource": "" }
q242952
tl_calendar_events.setEmptyEndTime
validation
public function setEmptyEndTime($varValue, Contao\DataContainer $dc) { if ($varValue === null) { $varValue = $dc->activeRecord->startTime; } return $varValue; }
php
{ "resource": "" }
q242953
tl_calendar_events.getArticleAlias
validation
public function getArticleAlias(Contao\DataContainer $dc) { $arrPids = array(); $arrAlias = array(); if (!$this->User->isAdmin) { foreach ($this->User->pagemounts as $id) { $arrPids[] = array($id); $arrPids[] = $this->Database->getChildRecords($id, 'tl_page'); } if (!empty($arrPids)) {...
php
{ "resource": "" }
q242954
Ajax.executePostActionsHook
validation
protected function executePostActionsHook(DataContainer $dc) { if (isset($GLOBALS['TL_HOOKS']['executePostActions']) && \is_array($GLOBALS['TL_HOOKS']['executePostActions'])) { foreach ($GLOBALS['TL_HOOKS']['executePostActions'] as $callback) { $this->import($callback[0]); $this->{$callback[0]}->{$ca...
php
{ "resource": "" }
q242955
BackendUser.getInstance
validation
public static function getInstance() { if (static::$objInstance !== null) { return static::$objInstance; } $objToken = System::getContainer()->get('security.token_storage')->getToken(); // Load the user from the security storage if ($objToken !== null && is_a($objToken->getUser(), static::class)) { ...
php
{ "resource": "" }
q242956
BackendUser.hasAccess
validation
public function hasAccess($field, $array) { if ($this->isAdmin) { return true; } if (!\is_array($field)) { $field = array($field); } if (\is_array($this->$array) && array_intersect($field, $this->$array)) { return true; } elseif ($array == 'filemounts') { // Check the subfolders (fi...
php
{ "resource": "" }
q242957
BackendUser.isAllowed
validation
public function isAllowed($int, $row) { if ($this->isAdmin) { return true; } // Inherit CHMOD settings if (!$row['includeChmod']) { $pid = $row['pid']; $row['chmod'] = false; $row['cuser'] = false; $row['cgroup'] = false; $objParentPage = PageModel::findById($pid); while ($objParen...
php
{ "resource": "" }
q242958
BackendUser.canEditFieldsOf
validation
public function canEditFieldsOf($table) { if ($this->isAdmin) { return true; } return \count(preg_grep('/^' . preg_quote($table, '/') . '::/', $this->alexf)) > 0; }
php
{ "resource": "" }
q242959
BackendLocaleListener.onKernelRequest
validation
public function onKernelRequest(GetResponseEvent $event): void { $token = $this->tokenStorage->getToken(); if (!$token instanceof TokenInterface) { return; } $user = $token->getUser(); if (!$user instanceof BackendUser || !$user->language) { return;...
php
{ "resource": "" }
q242960
tl_module_news.getNewsArchives
validation
public function getNewsArchives() { if (!$this->User->isAdmin && !\is_array($this->User->news)) { return array(); } $arrArchives = array(); $objArchives = $this->Database->execute("SELECT id, title FROM tl_news_archive ORDER BY title"); while ($objArchives->next()) { if ($this->User->hasAccess($o...
php
{ "resource": "" }
q242961
XliffFileLoader.getChunksFromUnit
validation
private function getChunksFromUnit(\DOMElement $unit): array { $chunks = explode('.', $unit->getAttribute('id')); // Handle keys with dots if (preg_match('/tl_layout\.[a-z]+\.css\./', $unit->getAttribute('id'))) { $chunks = [$chunks[0], $chunks[1].'.'.$chunks[2], $chunks[3]]; ...
php
{ "resource": "" }
q242962
XliffFileLoader.getStringRepresentation
validation
private function getStringRepresentation(array $chunks, $value): string { switch (\count($chunks)) { case 2: return sprintf( "\$GLOBALS['TL_LANG']['%s'][%s] = %s;\n", $chunks[0], $this->quoteKey($chunks[1]), ...
php
{ "resource": "" }
q242963
XliffFileLoader.addGlobal
validation
private function addGlobal(array $chunks, $value): void { if (false === $this->addToGlobals) { return; } $data = &$GLOBALS['TL_LANG']; foreach ($chunks as $key) { if (null === $data || !\is_array($data)) { $data = []; } ...
php
{ "resource": "" }
q242964
FileTree.getPreviewImage
validation
protected function getPreviewImage(File $objFile, $strInfo, $strClass='gimage') { if (($objFile->isSvgImage || ($objFile->height <= Config::get('gdMaxImgHeight') && $objFile->width <= Config::get('gdMaxImgWidth'))) && $objFile->viewWidth && $objFile->viewHeight) { // Inline the image if no preview image will be...
php
{ "resource": "" }
q242965
ScriptHandler.generateRandomSecret
validation
public static function generateRandomSecret(Event $event): void { $extra = $event->getComposer()->getPackage()->getExtra(); if (!isset($extra['incenteev-parameters']) || !self::canGenerateSecret($extra['incenteev-parameters'])) { return; } if (!\function_exists('random_...
php
{ "resource": "" }
q242966
ScriptHandler.canGenerateSecret
validation
private static function canGenerateSecret(array $config): bool { if (isset($config['file'])) { return !is_file($config['file']); } foreach ($config as $v) { if (\is_array($v) && isset($v['file']) && is_file($v['file'])) { return false; } ...
php
{ "resource": "" }
q242967
User.checkAccountStatus
validation
protected function checkAccountStatus() { @trigger_error('Using User::checkAccountStatus() has been deprecated and will no longer work in Contao 5.0. Use Symfony security instead.', E_USER_DEPRECATED); try { $userChecker = System::getContainer()->get('contao.security.user_checker'); $userChecker->checkPre...
php
{ "resource": "" }
q242968
User.findBy
validation
public function findBy($strColumn, $varValue) { $objResult = $this->Database->prepare("SELECT * FROM " . $this->strTable . " WHERE " . Database::quoteIdentifier($strColumn) . "=?") ->limit(1) ->execute($varValue); if ($objResult->numRows > 0) { $this->arrData = $objResult->row(); return...
php
{ "resource": "" }
q242969
User.save
validation
public function save() { $arrFields = $this->Database->getFieldNames($this->strTable); $arrSet = array_intersect_key($this->arrData, array_flip($arrFields)); $this->Database->prepare("UPDATE " . $this->strTable . " %s WHERE id=?") ->set($arrSet) ->execute($this->id); }
php
{ "resource": "" }
q242970
User.regenerateSessionId
validation
protected function regenerateSessionId() { @trigger_error('Using User::regenerateSessionId() has been deprecated and will no longer work in Contao 5.0. Use Symfony authentication instead.', E_USER_DEPRECATED); $container = System::getContainer(); $strategy = $container->getParameter('security.authentication.ses...
php
{ "resource": "" }
q242971
User.isMemberOf
validation
public function isMemberOf($id) { // ID not numeric if (!is_numeric($id)) { return false; } $groups = StringUtil::deserialize($this->groups); // No groups assigned if (empty($groups) || !\is_array($groups)) { return false; } // Group ID found if (\in_array($id, $groups)) { return tr...
php
{ "resource": "" }
q242972
User.triggerImportUserHook
validation
public static function triggerImportUserHook($username, $password, $strTable) { $self = new static(); if (empty($GLOBALS['TL_HOOKS']['importUser']) || !\is_array($GLOBALS['TL_HOOKS']['importUser'])) { return false; } @trigger_error('Using the "importUser" hook has been deprecated and will no longer work...
php
{ "resource": "" }
q242973
ContentTeaser.generate
validation
public function generate() { $objArticle = ArticleModel::findPublishedById($this->article); if ($objArticle === null) { return ''; } // Use findPublished() instead of getRelated() $objParent = PageModel::findPublishedById($objArticle->pid); if ($objParent === null) { return ''; } $this->o...
php
{ "resource": "" }
q242974
ModuleBooknav.getBookPages
validation
protected function getBookPages($intParentId, $groups, $time) { $objPages = PageModel::findPublishedSubpagesWithoutGuestsByPid($intParentId, $this->showHidden); if ($objPages === null) { return; } foreach ($objPages as $objPage) { $_groups = StringUtil::deserialize($objPage->groups); // Do not ...
php
{ "resource": "" }
q242975
Authenticator.validateCode
validation
public function validateCode(User $user, string $code): bool { $totp = TOTP::create($this->getUpperUnpaddedSecretForUser($user)); return $totp->verify($code); }
php
{ "resource": "" }
q242976
Authenticator.getProvisionUri
validation
public function getProvisionUri(User $user, Request $request): string { $issuer = rawurlencode($request->getSchemeAndHttpHost()); return sprintf( 'otpauth://totp/%s:%s?secret=%s&issuer=%s', $issuer, rawurlencode($user->getUsername()).'@'.$issuer, ...
php
{ "resource": "" }
q242977
Authenticator.getQrCode
validation
public function getQrCode(User $user, Request $request): string { $renderer = new ImageRenderer( new RendererStyle(180, 0), new SvgImageBackEnd() ); $writer = new Writer($renderer); return $writer->writeString($this->getProvisionUri($user, $request)); }
php
{ "resource": "" }
q242978
RouteLoader.loadFromPlugins
validation
public function loadFromPlugins(): RouteCollection { $collection = array_reduce( $this->pluginLoader->getInstancesOf(PluginLoader::ROUTING_PLUGINS, true), function (RouteCollection $collection, RoutingPluginInterface $plugin): RouteCollection { $routes = $plugin->getR...
php
{ "resource": "" }
q242979
ContentDownload.generate
validation
public function generate() { // Return if there is no file if ($this->singleSRC == '') { return ''; } $objFile = FilesModel::findByUuid($this->singleSRC); if ($objFile === null) { return ''; } $allowedDownload = StringUtil::trimsplit(',', strtolower(Config::get('allowedDownload'))); // Re...
php
{ "resource": "" }
q242980
ModuleLogin.generate
validation
public function generate() { if (TL_MODE == 'BE') { $objTemplate = new BackendTemplate('be_wildcard'); $objTemplate->wildcard = '### ' . Utf8::strtoupper($GLOBALS['TL_LANG']['FMD']['login'][0]) . ' ###'; $objTemplate->title = $this->headline; $objTemplate->id = $this->id; $objTemplate->link = $this-...
php
{ "resource": "" }
q242981
tl_files.checkImportantPart
validation
public function checkImportantPart(Contao\DataContainer $dc) { if (!$dc->id) { return; } $rootDir = Contao\System::getContainer()->getParameter('kernel.project_dir'); if (is_dir($rootDir . '/' . $dc->id) || !\in_array(strtolower(substr($dc->id, strrpos($dc->id, '.') + 1)), Contao\StringUtil::trimsplit('...
php
{ "resource": "" }
q242982
tl_files.checkFilename
validation
public function checkFilename($varValue, Contao\DataContainer $dc) { $varValue = str_replace('"', '', $varValue); if (strpos($varValue, '/') !== false || preg_match('/\.$/', $varValue)) { throw new Exception($GLOBALS['TL_LANG']['ERR']['invalidName']); } // Check the length without the file extension i...
php
{ "resource": "" }
q242983
tl_files.syncFiles
validation
public function syncFiles($href, $label, $title, $class, $attributes) { return $this->User->hasAccess('f6', 'fop') ? '<a href="'.$this->addToUrl($href).'" title="'.Contao\StringUtil::specialchars($title).'" class="'.$class.'"'.$attributes.'>'.$label.'</a> ' : ''; }
php
{ "resource": "" }
q242984
tl_files.uploadFile
validation
public function uploadFile($row, $href, $label, $title, $icon, $attributes) { if (!$GLOBALS['TL_DCA']['tl_files']['config']['closed'] && !$GLOBALS['TL_DCA']['tl_files']['config']['notCreatable'] && Contao\Input::get('act') != 'select' && isset($row['type']) && $row['type'] == 'folder') { return '<a href="'.$thi...
php
{ "resource": "" }
q242985
tl_files.deleteFile
validation
public function deleteFile($row, $href, $label, $title, $icon, $attributes) { $rootDir = Contao\System::getContainer()->getParameter('kernel.project_dir'); $path = $rootDir . '/' . urldecode($row['id']); if (!is_dir($path)) { return ($this->User->hasAccess('f3', 'fop') || $this->User->hasAccess('f4', 'fop'...
php
{ "resource": "" }
q242986
tl_files.showFile
validation
public function showFile($row, $href, $label, $title, $icon, $attributes) { if (Contao\Input::get('popup')) { return ''; } else { return '<a href="contao/popup.php?src=' . base64_encode($row['id']) . '" title="'.Contao\StringUtil::specialchars($title).'"'.$attributes.' onclick="Backend.openModalIframe(...
php
{ "resource": "" }
q242987
FeedItem.addEnclosure
validation
public function addEnclosure($strFile, $strUrl=null, $strMedia='enclosure') { if ($strFile == '' || !file_exists(System::getContainer()->getParameter('kernel.project_dir') . '/' . $strFile)) { return; } if ($strUrl === null) { $strUrl = Environment::get('base'); } $objFile = new File($strFile); ...
php
{ "resource": "" }
q242988
tl_module_calendar.getCalendars
validation
public function getCalendars() { if (!$this->User->isAdmin && !\is_array($this->User->calendars)) { return array(); } $arrCalendars = array(); $objCalendars = $this->Database->execute("SELECT id, title FROM tl_calendar ORDER BY title"); while ($objCalendars->next()) { if ($this->User->hasAccess($...
php
{ "resource": "" }
q242989
ModuleListing.listSingleRecord
validation
protected function listSingleRecord($id) { // Fallback template if (!\strlen($this->list_info_layout)) { $this->list_info_layout = 'info_default'; } $this->Template = new FrontendTemplate($this->list_info_layout); $this->Template->record = array(); $this->Template->referer = 'javascript:history.go(-1...
php
{ "resource": "" }
q242990
System.import
validation
protected function import($strClass, $strKey=null, $blnForce=false) { $strKey = $strKey ?: $strClass; if (\is_object($strKey)) { $strKey = \get_class($strClass); } if ($blnForce || !isset($this->arrObjects[$strKey])) { $container = static::getContainer(); if (\is_object($strClass)) { $th...
php
{ "resource": "" }
q242991
System.log
validation
public static function log($strText, $strFunction, $strCategory) { @trigger_error('Using System::log() has been deprecated and will no longer work in Contao 5.0. Use the logger service instead.', E_USER_DEPRECATED); $level = 'ERROR' === $strCategory ? LogLevel::ERROR : LogLevel::INFO; $logger = static::getConta...
php
{ "resource": "" }
q242992
System.getReferer
validation
public static function getReferer($blnEncodeAmpersands=false, $strTable=null) { /** @var Session $objSession */ $objSession = static::getContainer()->get('session'); $ref = Input::get('ref'); $key = Input::get('popup') ? 'popupReferer' : 'referer'; $session = $objSession->get($key); // Unique referer ID ...
php
{ "resource": "" }
q242993
System.isInstalledLanguage
validation
public static function isInstalledLanguage($strLanguage) { if (!isset(static::$arrLanguages[$strLanguage])) { $rootDir = self::getContainer()->getParameter('kernel.project_dir'); if (is_dir($rootDir . '/vendor/contao/core-bundle/src/Resources/contao/languages/' . $strLanguage)) { static::$arrLanguage...
php
{ "resource": "" }
q242994
System.getCountries
validation
public static function getCountries() { $return = array(); $countries = array(); $arrAux = array(); static::loadLanguageFile('countries'); include __DIR__ . '/../../config/countries.php'; foreach ($countries as $strKey=>$strName) { $arrAux[$strKey] = isset($GLOBALS['TL_LANG']['CNT'][$strKey]) ? Utf8...
php
{ "resource": "" }
q242995
System.getLanguages
validation
public static function getLanguages($blnInstalledOnly=false) { $return = array(); $languages = array(); $arrAux = array(); $langsNative = array(); static::loadLanguageFile('languages'); include __DIR__ . '/../../config/languages.php'; foreach ($languages as $strKey=>$strName) { $arrAux[$strKey] = ...
php
{ "resource": "" }
q242996
System.getTimeZones
validation
public static function getTimeZones() { $arrReturn = array(); $timezones = array(); require __DIR__ . '/../../config/timezones.php'; foreach ($timezones as $strGroup=>$arrTimezones) { foreach ($arrTimezones as $strTimezone) { $arrReturn[$strGroup][] = $strTimezone; } } return $arrReturn; ...
php
{ "resource": "" }
q242997
System.setCookie
validation
public static function setCookie($strName, $varValue, $intExpires, $strPath=null, $strDomain=null, $blnSecure=false, $blnHttpOnly=false) { if ($strPath == '') { $strPath = Environment::get('path') ?: '/'; // see #4390 } $objCookie = new \stdClass(); $objCookie->strName = $strName; $objCookie->varV...
php
{ "resource": "" }
q242998
System.getReadableSize
validation
public static function getReadableSize($intSize, $intDecimals=1) { for ($i=0; $intSize>=1024; $i++) { $intSize /= 1024; } return static::getFormattedNumber($intSize, $intDecimals) . ' ' . $GLOBALS['TL_LANG']['UNITS'][$i]; }
php
{ "resource": "" }
q242999
System.getFormattedNumber
validation
public static function getFormattedNumber($varNumber, $intDecimals=2) { return number_format(round($varNumber, $intDecimals), $intDecimals, $GLOBALS['TL_LANG']['MSC']['decimalSeparator'], $GLOBALS['TL_LANG']['MSC']['thousandsSeparator']); }
php
{ "resource": "" }