_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q243400
Updater.run210Update
validation
public function run210Update() { $this->Database->query("ALTER TABLE `tl_style` ADD `positioning` char(1) NOT NULL default ''"); $this->Database->query("UPDATE `tl_style` SET `positioning`=`size`"); $this->Database->query("UPDATE `tl_module` SET `guests`=1 WHERE `type`='lostPassword' OR `type`='registration'"); ...
php
{ "resource": "" }
q243401
Updater.run32Update
validation
public function run32Update() { // Adjust the custom layout sections (see #2885) $this->Database->query("ALTER TABLE `tl_layout` CHANGE `sections` `sections` varchar(1022) NOT NULL default ''"); $objLayout = $this->Database->query("SELECT id, sections FROM tl_layout WHERE sections!=''"); while ($objLayout->ne...
php
{ "resource": "" }
q243402
Updater.run33Update
validation
public function run33Update() { $objLayout = $this->Database->query("SELECT id, framework FROM tl_layout WHERE framework!=''"); while ($objLayout->next()) { $strFramework = ''; $tmp = StringUtil::deserialize($objLayout->framework); if (!empty($tmp) && \is_array($tmp)) { if (($key = array_search...
php
{ "resource": "" }
q243403
Updater.run35Update
validation
public function run35Update() { $this->Database->query("ALTER TABLE `tl_member` CHANGE `username` `username` varchar(64) COLLATE utf8_bin NULL"); $this->Database->query("UPDATE `tl_member` SET username=NULL WHERE username=''"); $this->Database->query("ALTER TABLE `tl_member` DROP INDEX `username`, ADD UNIQUE KEY...
php
{ "resource": "" }
q243404
Updater.run40Update
validation
public function run40Update() { // Adjust the framework agnostic scripts $this->Database->query("ALTER TABLE `tl_layout` ADD `scripts` text NULL"); $objLayout = $this->Database->query("SELECT id, addJQuery, jquery, addMooTools, mootools FROM tl_layout WHERE framework!=''"); while ($objLayout->next()) { $...
php
{ "resource": "" }
q243405
Updater.convertSingleField
validation
public static function convertSingleField($table, $field) { $objDatabase = Database::getInstance(); // Get the non-empty rows $objRow = $objDatabase->query("SELECT id, $field FROM $table WHERE $field!=''"); // Check the column type $objDesc = $objDatabase->query("DESC $table $field"); // Change the colu...
php
{ "resource": "" }
q243406
Updater.convertMultiField
validation
public static function convertMultiField($table, $field) { $objDatabase = Database::getInstance(); // Get the non-empty rows $objRow = $objDatabase->query("SELECT id, $field FROM $table WHERE $field!=''"); // Check the column type $objDesc = $objDatabase->query("DESC $table $field"); // Change the colum...
php
{ "resource": "" }
q243407
Updater.convertOrderField
validation
public static function convertOrderField($table, $field) { $objDatabase = Database::getInstance(); // Get the non-empty rows $objRow = $objDatabase->query("SELECT id, $field FROM $table WHERE $field LIKE '%,%'"); // Convert the comma separated lists into serialized arrays while ($objRow->next()) { $ob...
php
{ "resource": "" }
q243408
Updater.generateHelperObject
validation
protected static function generateHelperObject($value) { $return = new \stdClass(); if (!\is_array($value)) { $return->value = rtrim($value, "\x00"); $return->isUuid = (\strlen($value) == 16 && !is_numeric($return->value) && strncmp($return->value, Config::get('uploadPath') . '/', \strlen(Config::get('upl...
php
{ "resource": "" }
q243409
Updater.createContentElement
validation
protected function createContentElement(Result $objElement, $strPtable, $strField) { $set = array ( 'pid' => $objElement->id, 'ptable' => $strPtable, 'sorting' => 128, 'tstamp' => $objElement->tstamp, 'type' => 'text', 'text' => $objElement->$strField, 'addI...
php
{ "resource": "" }
q243410
InstallationController.acceptLicense
validation
private function acceptLicense(): Response { $request = $this->container->get('request_stack')->getCurrentRequest(); if (null === $request) { throw new \RuntimeException('The request stack did not contain a request'); } if ('tl_license' !== $request->request->get('FORM_...
php
{ "resource": "" }
q243411
InstallationController.setPassword
validation
private function setPassword(): Response { $request = $this->container->get('request_stack')->getCurrentRequest(); if (null === $request) { throw new \RuntimeException('The request stack did not contain a request'); } if ('tl_password' !== $request->request->get('FORM_S...
php
{ "resource": "" }
q243412
InstallationController.login
validation
private function login(): Response { $request = $this->container->get('request_stack')->getCurrentRequest(); if (null === $request) { throw new \RuntimeException('The request stack did not contain a request'); } if ('tl_login' !== $request->request->get('FORM_SUBMIT')) ...
php
{ "resource": "" }
q243413
InstallationController.purgeSymfonyCache
validation
private function purgeSymfonyCache(): void { $filesystem = new Filesystem(); $cacheDir = $this->getContainerParameter('kernel.cache_dir'); $ref = new \ReflectionObject($this->container); $containerDir = basename(\dirname($ref->getFileName())); /** @var SplFileInfo[] $finder ...
php
{ "resource": "" }
q243414
InstallationController.warmUpSymfonyCache
validation
private function warmUpSymfonyCache(): void { $cacheDir = $this->getContainerParameter('kernel.cache_dir'); if (file_exists($cacheDir.'/contao/config/config.php')) { return; } $warmer = $this->container->get('cache_warmer'); if (!$this->getContainerParameter('k...
php
{ "resource": "" }
q243415
InstallationController.setUpDatabaseConnection
validation
private function setUpDatabaseConnection(): Response { $request = $this->container->get('request_stack')->getCurrentRequest(); if (null === $request) { throw new \RuntimeException('The request stack did not contain a request'); } // Only warn the user if the connection ...
php
{ "resource": "" }
q243416
InstallationController.adjustDatabaseTables
validation
private function adjustDatabaseTables(): ?RedirectResponse { $this->container->get('contao.install_tool')->handleRunOnce(); $installer = $this->container->get('contao.installer'); $this->context['sql_form'] = $installer->getCommands(); $request = $this->container->get('request_sta...
php
{ "resource": "" }
q243417
InstallationController.importExampleWebsite
validation
private function importExampleWebsite(): ?RedirectResponse { $installTool = $this->container->get('contao.install_tool'); $templates = $installTool->getTemplates(); $this->context['templates'] = $templates; if ($installTool->getConfig('exampleWebsite')) { $this->context...
php
{ "resource": "" }
q243418
InstallationController.getRedirectResponse
validation
private function getRedirectResponse(): RedirectResponse { $request = $this->container->get('request_stack')->getCurrentRequest(); if (null === $request) { throw new \RuntimeException('The request stack did not contain a request'); } return new RedirectResponse($request...
php
{ "resource": "" }
q243419
InstallationController.addDefaultsToContext
validation
private function addDefaultsToContext(array $context): array { $context = array_merge($this->context, $context); if (!isset($context['request_token'])) { $context['request_token'] = $this->getRequestToken(); } if (!isset($context['language'])) { $context['la...
php
{ "resource": "" }
q243420
SymlinksCommand.generateSymlinks
validation
private function generateSymlinks(): void { $fs = new Filesystem(); // Remove the base folders in the document root $fs->remove($this->rootDir.'/'.$this->webDir.'/'.$this->uploadPath); $fs->remove($this->rootDir.'/'.$this->webDir.'/system/modules'); $fs->remove($this->rootDi...
php
{ "resource": "" }
q243421
SymlinksCommand.findIn
validation
private function findIn(string $path): Finder { return Finder::create() ->ignoreDotFiles(false) ->sort( static function (SplFileInfo $a, SplFileInfo $b): int { $countA = substr_count(strtr($a->getRelativePath(), '\\', '/'), '/'); ...
php
{ "resource": "" }
q243422
SymlinksCommand.filterNestedPaths
validation
private function filterNestedPaths(Finder $finder, string $prepend): array { $parents = []; $files = iterator_to_array($finder); foreach ($files as $key => $file) { $path = rtrim(strtr($prepend.'/'.$file->getRelativePath(), '\\', '/'), '/'); if (!empty($parents)) { ...
php
{ "resource": "" }
q243423
tl_image_size_item.listImageSizeItem
validation
public function listImageSizeItem($row) { $html = '<div class="tl_content_left">'; $html .= $row['media']; if ($row['width'] || $row['height']) { $html .= ' <span style="padding-left:3px">' . $row['width'] . 'x' . $row['height'] . '</span>'; } if ($row['zoom']) { $html .= ' <span style="color:#99...
php
{ "resource": "" }
q243424
BackendMenuBuilder.create
validation
public function create(): ItemInterface { $tree = $this->factory->createItem('root'); $this->eventDispatcher->dispatch(ContaoCoreEvents::BACKEND_MENU_BUILD, new MenuEvent($this->factory, $tree)); return $tree; }
php
{ "resource": "" }
q243425
Events.getAllEvents
validation
protected function getAllEvents($arrCalendars, $intStart, $intEnd) { if (!\is_array($arrCalendars)) { return array(); } $this->arrEvents = array(); foreach ($arrCalendars as $id) { // Get the events of the current period $objEvents = CalendarEventsModel::findCurrentByPid($id, $intStart, $intEnd)...
php
{ "resource": "" }
q243426
InitializeApplicationListener.onInitialize
validation
public function onInitialize(InitializeApplicationEvent $event): void { $this->installAssets($event); $this->installContao($event); $this->createSymlinks($event); }
php
{ "resource": "" }
q243427
Registry.fetch
validation
public function fetch($strTable, $varKey, $strAlias=null) { /** @var Model $strClass */ $strClass = Model::getClassFromTable($strTable); $strPk = $strClass::getPk(); // Search by PK (most common case) if ($strAlias === null || $strAlias == $strPk) { if (isset($this->arrRegistry[$strTable][$varKey])) ...
php
{ "resource": "" }
q243428
Registry.fetchByAlias
validation
public function fetchByAlias($strTable, $strAlias, $varValue) { if (isset($this->arrAliases[$strTable][$strAlias][$varValue])) { $strPk = $this->arrAliases[$strTable][$strAlias][$varValue]; if (isset($this->arrRegistry[$strTable][$strPk])) { return $this->arrRegistry[$strTable][$strPk]; } } r...
php
{ "resource": "" }
q243429
Registry.register
validation
public function register(Model $objModel) { $intObjectId = spl_object_hash($objModel); // The model has been registered already if (isset($this->arrIdentities[$intObjectId])) { return; } $strTable = $objModel->getTable(); if (!\is_array($this->arrAliases[$strTable])) { $this->arrAliases[$strTa...
php
{ "resource": "" }
q243430
Registry.unregister
validation
public function unregister(Model $objModel) { $intObjectId = spl_object_hash($objModel); // The model is not registered if (!isset($this->arrIdentities[$intObjectId])) { return; } $strTable = $objModel->getTable(); $strPk = $objModel->getPk(); $intPk = $objModel->$strPk; unset($this->arrI...
php
{ "resource": "" }
q243431
Registry.isRegistered
validation
public function isRegistered(Model $objModel) { $intObjectId = spl_object_hash($objModel); return isset($this->arrIdentities[$intObjectId]); }
php
{ "resource": "" }
q243432
Registry.registerAlias
validation
public function registerAlias(Model $objModel, $strAlias, $varValue) { $strTable = $objModel->getTable(); $strPk = $objModel->getPk(); $varPk = $objModel->$strPk; if (isset($this->arrAliases[$strTable][$strAlias][$varValue])) { throw new \RuntimeException("The registry already contains an alias for...
php
{ "resource": "" }
q243433
Registry.isRegisteredAlias
validation
public function isRegisteredAlias(Model $objModel, $strAlias, $varValue) { $strTable = $objModel->getTable(); return isset($this->arrAliases[$strTable][$strAlias][$varValue]); }
php
{ "resource": "" }
q243434
ModuleRegistration.sendActivationMail
validation
protected function sendActivationMail($arrData) { /** @var OptIn $optIn */ $optIn = System::getContainer()->get('contao.opt-in'); $optInToken = $optIn->create('reg', $arrData['email'], array('tl_member'=>array($arrData['id']))); // Prepare the simple token data $arrTokenData = $arrData; $arrTokenData['act...
php
{ "resource": "" }
q243435
ModuleRegistration.activateAcount
validation
protected function activateAcount() { $this->strTemplate = 'mod_message'; $this->Template = new FrontendTemplate($this->strTemplate); /** @var OptIn $optIn */ $optIn = System::getContainer()->get('contao.opt-in'); // Find an unconfirmed token with only one related record if ((!$optInToken = $optIn->find(...
php
{ "resource": "" }
q243436
ModuleRegistration.resendActivationMail
validation
protected function resendActivationMail(MemberModel $objMember) { if ($objMember->disable == '') { return; } $this->strTemplate = 'mod_message'; $this->Template = new FrontendTemplate($this->strTemplate); /** @var OptIn $optIn */ $optIn = System::getContainer()->get('contao.opt-in'); $optInToken =...
php
{ "resource": "" }
q243437
ModuleRegistration.sendAdminNotification
validation
protected function sendAdminNotification($intId, $arrData) { $objEmail = new Email(); $objEmail->from = $GLOBALS['TL_ADMIN_EMAIL']; $objEmail->fromName = $GLOBALS['TL_ADMIN_NAME']; $objEmail->subject = sprintf($GLOBALS['TL_LANG']['MSC']['adminSubject'], Idna::decode(Environment::get('host'))); $strData = "\...
php
{ "resource": "" }
q243438
AuthenticationSuccessHandler.onAuthenticationSuccess
validation
public function onAuthenticationSuccess(Request $request, TokenInterface $token): RedirectResponse { $this->user = $token->getUser(); if (!$this->user instanceof User) { return $this->getRedirectResponse($request); } $this->user->lastLogin = $this->user->currentLogin; ...
php
{ "resource": "" }
q243439
ArticleModel.findByIdOrAliasAndPid
validation
public static function findByIdOrAliasAndPid($varId, $intPid, array $arrOptions=array()) { $t = static::$strTable; $arrColumns = !preg_match('/^[1-9]\d*$/', $varId) ? array("$t.alias=?") : array("$t.id=?"); $arrValues = array($varId); if ($intPid) { $arrColumns[] = "$t.pid=?"; $arrValues[] = $intPid; ...
php
{ "resource": "" }
q243440
ArticleModel.findPublishedByIdOrAliasAndPid
validation
public static function findPublishedByIdOrAliasAndPid($varId, $intPid, array $arrOptions=array()) { $t = static::$strTable; $arrColumns = !preg_match('/^[1-9]\d*$/', $varId) ? array("$t.alias=?") : array("$t.id=?"); $arrValues = array($varId); if ($intPid) { $arrColumns[] = "$t.pid=?"; $arrValues[] = ...
php
{ "resource": "" }
q243441
ArticleModel.findPublishedByPidAndColumn
validation
public static function findPublishedByPidAndColumn($intPid, $strColumn, array $arrOptions=array()) { $t = static::$strTable; $arrColumns = array("$t.pid=? AND $t.inColumn=?"); $arrValues = array($intPid, $strColumn); if (!static::isPreviewMode($arrOptions)) { $time = Date::floorToMinute(); $arrColumns...
php
{ "resource": "" }
q243442
Input.initialize
validation
public static function initialize() { $_GET = static::cleanKey($_GET); $_POST = static::cleanKey($_POST); $_COOKIE = static::cleanKey($_COOKIE); }
php
{ "resource": "" }
q243443
Input.stripTags
validation
public static function stripTags($varValue, $strAllowedTags='') { if ($varValue === null || $varValue == '') { return $varValue; } // Recursively clean arrays if (\is_array($varValue)) { foreach ($varValue as $k=>$v) { $varValue[$k] = static::stripTags($v, $strAllowedTags); } return $v...
php
{ "resource": "" }
q243444
Input.decodeEntities
validation
public static function decodeEntities($varValue) { if ($varValue === null || $varValue == '') { return $varValue; } // Recursively clean arrays if (\is_array($varValue)) { foreach ($varValue as $k=>$v) { $varValue[$k] = static::decodeEntities($v); } return $varValue; } // Preserve...
php
{ "resource": "" }
q243445
Input.encodeSpecialChars
validation
public static function encodeSpecialChars($varValue) { if ($varValue === null || $varValue == '') { return $varValue; } // Recursively clean arrays if (\is_array($varValue)) { foreach ($varValue as $k=>$v) { $varValue[$k] = static::encodeSpecialChars($v); } return $varValue; } $ar...
php
{ "resource": "" }
q243446
Input.findPost
validation
public static function findPost($strKey) { if (isset($_POST[$strKey])) { return $_POST[$strKey]; } $request = System::getContainer()->get('request_stack')->getMasterRequest(); // Return if the session has not been started before if ($request === null || !$request->hasPreviousSession()) { return n...
php
{ "resource": "" }
q243447
ModuleLogout.generate
validation
public function generate() { if (TL_MODE == 'BE') { $objTemplate = new BackendTemplate('be_wildcard'); $objTemplate->wildcard = '### ' . Utf8::strtoupper($GLOBALS['TL_LANG']['FMD']['logout'][0]) . ' ###'; $objTemplate->title = $this->headline; $objTemplate->id = $this->id; $objTemplate->link = $this...
php
{ "resource": "" }
q243448
ModuleEventMenu.compileYearlyMenu
validation
protected function compileYearlyMenu() { $arrData = array(); $arrAllEvents = $this->getAllEvents($this->cal_calendar, 0, 2145913200); foreach ($arrAllEvents as $intDay=>$arrDay) { foreach ($arrDay as $arrEvents) { $arrData[substr($intDay, 0, 4)] += \count($arrEvents); } } // Sort data ($th...
php
{ "resource": "" }
q243449
Result.__isset
validation
public function __isset($strKey) { if (empty($this->arrCache)) { $this->next(); } return isset($this->arrCache[$strKey]); }
php
{ "resource": "" }
q243450
Result.fetchRow
validation
public function fetchRow() { if ($this->intIndex >= $this->count() - 1) { return false; } $this->arrCache = array_values($this->resultSet[++$this->intIndex]); return $this->arrCache; }
php
{ "resource": "" }
q243451
Result.fetchAssoc
validation
public function fetchAssoc() { if ($this->intIndex >= $this->count() - 1) { return false; } $this->arrCache = $this->resultSet[++$this->intIndex]; return $this->arrCache; }
php
{ "resource": "" }
q243452
Result.fetchEach
validation
public function fetchEach($strKey) { $this->reset(); $arrReturn = array(); while (($arrRow = $this->fetchAssoc()) !== false) { if ($strKey != 'id' && isset($arrRow['id'])) { $arrReturn[$arrRow['id']] = $arrRow[$strKey]; } else { $arrReturn[] = $arrRow[$strKey]; } } return $arrRe...
php
{ "resource": "" }
q243453
Result.fetchField
validation
public function fetchField($intOffset=0) { $arrFields = array_values($this->resultSet[$this->intIndex]); return $arrFields[$intOffset]; }
php
{ "resource": "" }
q243454
Result.first
validation
public function first() { $this->intIndex = 0; $this->blnDone = false; $this->arrCache = $this->resultSet[$this->intIndex]; return $this; }
php
{ "resource": "" }
q243455
Result.prev
validation
public function prev() { if ($this->intIndex < 1) { return false; } $this->blnDone = false; $this->arrCache = $this->resultSet[--$this->intIndex]; return $this; }
php
{ "resource": "" }
q243456
Result.next
validation
public function next() { if ($this->blnDone) { return false; } if ($this->fetchAssoc() !== false) { return $this; } $this->blnDone = true; return false; }
php
{ "resource": "" }
q243457
Result.last
validation
public function last() { $this->intIndex = $this->count() - 1; $this->blnDone = true; $this->arrCache = $this->resultSet[$this->intIndex]; return $this; }
php
{ "resource": "" }
q243458
tl_module_newsletter.getChannels
validation
public function getChannels() { if (!$this->User->isAdmin && !\is_array($this->User->newsletters)) { return array(); } $arrChannels = array(); $objChannels = $this->Database->execute("SELECT id, title FROM tl_newsletter_channel ORDER BY title"); while ($objChannels->next()) { if ($this->User->has...
php
{ "resource": "" }
q243459
tl_form_field.getFields
validation
public function getFields() { $arrFields = $GLOBALS['TL_FFL']; // Add the translation foreach (array_keys($arrFields) as $key) { $arrFields[$key] = $GLOBALS['TL_LANG']['FFL'][$key][0]; } return $arrFields; }
php
{ "resource": "" }
q243460
NewsModel.countPublishedByPids
validation
public static function countPublishedByPids($arrPids, $blnFeatured=null, array $arrOptions=array()) { if (empty($arrPids) || !\is_array($arrPids)) { return 0; } $t = static::$strTable; $arrColumns = array("$t.pid IN(" . implode(',', array_map('\intval', $arrPids)) . ")"); if ($blnFeatured === true) ...
php
{ "resource": "" }
q243461
NewsModel.findPublishedDefaultByPid
validation
public static function findPublishedDefaultByPid($intPid, array $arrOptions=array()) { $t = static::$strTable; $arrColumns = array("$t.pid=? AND $t.source='default'"); if (!static::isPreviewMode($arrOptions)) { $time = Date::floorToMinute(); $arrColumns[] = "($t.start='' OR $t.start<='$time') AND ($t.st...
php
{ "resource": "" }
q243462
NewsModel.findPublishedFromToByPids
validation
public static function findPublishedFromToByPids($intFrom, $intTo, $arrPids, $intLimit=0, $intOffset=0, array $arrOptions=array()) { if (empty($arrPids) || !\is_array($arrPids)) { return null; } $t = static::$strTable; $arrColumns = array("$t.date>=? AND $t.date<=? AND $t.pid IN(" . implode(',', array_ma...
php
{ "resource": "" }
q243463
NewsModel.countPublishedFromToByPids
validation
public static function countPublishedFromToByPids($intFrom, $intTo, $arrPids, array $arrOptions=array()) { if (empty($arrPids) || !\is_array($arrPids)) { return null; } $t = static::$strTable; $arrColumns = array("$t.date>=? AND $t.date<=? AND $t.pid IN(" . implode(',', array_map('\intval', $arrPids)) . ...
php
{ "resource": "" }
q243464
tl_theme.doGetTemplateFolders
validation
protected function doGetTemplateFolders($path, $level=0) { $return = array(); $rootDir = Contao\System::getContainer()->getParameter('kernel.project_dir'); foreach (scan($rootDir . '/' . $path) as $file) { if (is_dir($rootDir . '/' . $path . '/' . $file)) { $return[$path . '/' . $file] = str_repeat(...
php
{ "resource": "" }
q243465
tl_theme.editCss
validation
public function editCss($row, $href, $label, $title, $icon, $attributes) { return $this->User->hasAccess('css', 'themes') ? '<a href="'.$this->addToUrl($href.'&amp;id='.$row['id']).'" title="'.Contao\StringUtil::specialchars($title).'"'.$attributes.'>'.Contao\Image::getHtml($icon, $label).'</a> ' : Contao\Image::get...
php
{ "resource": "" }
q243466
PrettyErrorScreenListener.onKernelException
validation
public function onKernelException(GetResponseForExceptionEvent $event): void { if (!$event->isMasterRequest()) { return; } $request = $event->getRequest(); if ('html' !== $request->getRequestFormat()) { return; } if (!AcceptHeader::fromStrin...
php
{ "resource": "" }
q243467
PrettyErrorScreenListener.renderErrorScreenByException
validation
private function renderErrorScreenByException(GetResponseForExceptionEvent $event): void { $exception = $event->getException(); $statusCode = $this->getStatusCodeForException($exception); $template = null; $this->logException($exception); // Look for a template do {...
php
{ "resource": "" }
q243468
tl_faq_category.editHeader
validation
public function editHeader($row, $href, $label, $title, $icon, $attributes) { return $this->User->canEditFieldsOf('tl_faq_category') ? '<a href="'.$this->addToUrl($href.'&amp;id='.$row['id']).'" title="'.Contao\StringUtil::specialchars($title).'"'.$attributes.'>'.Contao\Image::getHtml($icon, $label).'</a> ' : Contao...
php
{ "resource": "" }
q243469
tl_templates.addBreadcrumb
validation
public function addBreadcrumb() { /** @var Symfony\Component\HttpFoundation\Session\Attribute\AttributeBagInterface $objSessionBag */ $objSessionBag = Contao\System::getContainer()->get('session')->getBag('contao_backend'); // Set a new node if (isset($_GET['fn'])) { // Check the path (thanks to Arnaud B...
php
{ "resource": "" }
q243470
tl_templates.dragFile
validation
public function dragFile($row, $href, $label, $title, $icon, $attributes) { return '<button type="button" title="'.Contao\StringUtil::specialchars($title).'" '.$attributes.'>'.Contao\Image::getHtml($icon, $label).'</button> '; }
php
{ "resource": "" }
q243471
tl_templates.getTargetFolders
validation
protected function getTargetFolders($strFolder, $intLevel=1) { $strFolders = ''; $strPath = Contao\System::getContainer()->getParameter('kernel.project_dir') .'/'. $strFolder; foreach (scan($strPath) as $strFile) { if (!is_dir($strPath .'/'. $strFile) || strncmp($strFile, '.', 1) === 0) { continue; ...
php
{ "resource": "" }
q243472
UserAwareTrait.hasUser
validation
protected function hasUser(): bool { $user = $this->tokenStorage->getToken(); if (null === $user) { return false; } return !($user instanceof AnonymousToken); }
php
{ "resource": "" }
q243473
BackendSwitch.getDatalistOptions
validation
protected function getDatalistOptions() { $strGroups = ''; if (!$this->User->isAdmin) { // No allowed member groups if (empty($this->User->amg) || !\is_array($this->User->amg)) { header('Content-type: application/json'); die(json_encode(array())); } $arrGroups = array(); foreach ($th...
php
{ "resource": "" }
q243474
tl_undo.checkPermission
validation
public function checkPermission() { if ($this->User->isAdmin) { return; } // Show only own undo steps $objSteps = $this->Database->prepare("SELECT id FROM tl_undo WHERE pid=?") ->execute($this->User->id); // Restrict the list $GLOBALS['TL_DCA']['tl_undo']['list']['sorting']['root'] = $obj...
php
{ "resource": "" }
q243475
tl_undo.showDeletedRecords
validation
public function showDeletedRecords($data, $row) { $arrData = Contao\StringUtil::deserialize($row['data']); foreach ($arrData as $strTable=>$arrTableData) { Contao\System::loadLanguageFile($strTable); Contao\Controller::loadDataContainer($strTable); foreach ($arrTableData as $arrRow) { $arrBuffe...
php
{ "resource": "" }
q243476
GeneratePageListener.onGeneratePage
validation
public function onGeneratePage(PageModel $pageModel, LayoutModel $layoutModel): void { $calendarfeeds = StringUtil::deserialize($layoutModel->calendarfeeds); if (empty($calendarfeeds) || !\is_array($calendarfeeds)) { return; } $this->framework->initialize(); /*...
php
{ "resource": "" }
q243477
ModuleArticle.generate
validation
public function generate($blnNoMarkup=false) { if (TL_MODE == 'FE' && !BE_USER_LOGGED_IN && (!$this->published || ($this->start != '' && $this->start > time()) || ($this->stop != '' && $this->stop < time()))) { return ''; } $this->type = 'article'; $this->blnNoMarkup = $blnNoMarkup; // Tag response ...
php
{ "resource": "" }
q243478
ModuleArticle.generatePdf
validation
public function generatePdf() { $this->headline = $this->title; $this->printable = false; // Generate article $strArticle = $this->replaceInsertTags($this->generate(), false); $strArticle = html_entity_decode($strArticle, ENT_QUOTES, Config::get('characterSet')); $strArticle = $this->convertRelativeUrls($...
php
{ "resource": "" }
q243479
Plugin.handlePrependLocale
validation
private function handlePrependLocale(array $extensionConfigs, ContainerBuilder $container): array { if (!$container->hasParameter('prepend_locale')) { return $extensionConfigs; } foreach ($extensionConfigs as $extensionConfig) { if (isset($extensionConfig['prepend_lo...
php
{ "resource": "" }
q243480
Plugin.addDefaultServerVersion
validation
private function addDefaultServerVersion(array $extensionConfigs, ContainerBuilder $container): array { $params = []; foreach ($extensionConfigs as $extensionConfig) { if (isset($extensionConfig['dbal']['connections']['default'])) { $params[] = $extensionConfig['dbal']['...
php
{ "resource": "" }
q243481
Controller.getTemplateGroup
validation
public static function getTemplateGroup($strPrefix) { $arrTemplates = array(); // Get the default templates foreach (TemplateLoader::getPrefixedFiles($strPrefix) as $strTemplate) { $arrTemplates[$strTemplate][] = 'root'; } $rootDir = System::getContainer()->getParameter('kernel.project_dir'); $arrCu...
php
{ "resource": "" }
q243482
Controller.getArticle
validation
public static function getArticle($varId, $blnMultiMode=false, $blnIsInsertTag=false, $strColumn='main') { /** @var PageModel $objPage */ global $objPage; if (\is_object($varId)) { $objRow = $varId; } else { if (!$varId) { return ''; } $objRow = ArticleModel::findByIdOrAliasAndPid($v...
php
{ "resource": "" }
q243483
Controller.getContentElement
validation
public static function getContentElement($intId, $strColumn='main') { if (\is_object($intId)) { $objRow = $intId; } else { if (!\strlen($intId) || $intId < 1) { return ''; } $objRow = ContentModel::findByPk($intId); if ($objRow === null) { return ''; } } // Check the vi...
php
{ "resource": "" }
q243484
Controller.getForm
validation
public static function getForm($varId, $strColumn='main', $blnModule=false) { if (\is_object($varId)) { $objRow = $varId; } else { if ($varId == '') { return ''; } $objRow = FormModel::findByIdOrAlias($varId); if ($objRow === null) { return ''; } } $strClass = $blnModul...
php
{ "resource": "" }
q243485
Controller.getSpellcheckerString
validation
protected function getSpellcheckerString() { System::loadLanguageFile('languages'); $return = array(); $langs = scan(__DIR__ . '/../../languages'); array_unshift($langs, $GLOBALS['TL_LANGUAGE']); foreach ($langs as $lang) { $lang = substr($lang, 0, 2); if (isset($GLOBALS['TL_LANG']['LNG'][$lang]))...
php
{ "resource": "" }
q243486
Controller.getPageStatusIcon
validation
public static function getPageStatusIcon($objPage) { $sub = 0; $image = $objPage->type.'.svg'; // Page not published or not active if (!$objPage->published || ($objPage->start != '' && $objPage->start > time()) || ($objPage->stop != '' && $objPage->stop < time())) { ++$sub; } // Page hidden from men...
php
{ "resource": "" }
q243487
Controller.isVisibleElement
validation
public static function isVisibleElement(Model $objElement) { $blnReturn = true; // Only apply the restrictions in the front end if (TL_MODE == 'FE') { // Protected element if ($objElement->protected) { if (!FE_USER_LOGGED_IN) { $blnReturn = false; } else { $objUser = Fro...
php
{ "resource": "" }
q243488
Controller.generateMargin
validation
public static function generateMargin($arrValues, $strType='margin') { // Initialize an empty array (see #5217) if (!\is_array($arrValues)) { $arrValues = array('top'=>'', 'right'=>'', 'bottom'=>'', 'left'=>'', 'unit'=>''); } $top = $arrValues['top']; $right = $arrValues['right']; $bottom = $arrValue...
php
{ "resource": "" }
q243489
Controller.addToUrl
validation
public static function addToUrl($strRequest, $blnAddRef=true, $arrUnset=array()) { /** @var Query $query */ $query = new Query(Environment::get('queryString')); // Remove the request token and referer ID $query = $query->withoutPairs(array_merge(array('rt', 'ref'), $arrUnset)); // Merge the request string ...
php
{ "resource": "" }
q243490
Controller.redirect
validation
public static function redirect($strLocation, $intStatus=303) { $strLocation = str_replace('&amp;', '&', $strLocation); $strLocation = static::replaceOldBePaths($strLocation); // Make the location an absolute URL if (!preg_match('@^https?://@i', $strLocation)) { $strLocation = Environment::get('base') . ...
php
{ "resource": "" }
q243491
Controller.replaceOldBePaths
validation
protected static function replaceOldBePaths($strContext) { $router = System::getContainer()->get('router'); $generate = function ($route) use ($router) { return substr($router->generate($route), \strlen(Environment::get('path')) + 1); }; $arrMapper = array ( 'contao/confirm.php' => $generate('con...
php
{ "resource": "" }
q243492
Controller.convertRelativeUrls
validation
public static function convertRelativeUrls($strContent, $strBase='', $blnHrefOnly=false) { if ($strBase == '') { $strBase = Environment::get('base'); } $search = $blnHrefOnly ? 'href' : 'href|src'; $arrUrls = preg_split('/(('.$search.')="([^"]+)")/i', $strContent, -1, PREG_SPLIT_DELIM_CAPTURE); $strCon...
php
{ "resource": "" }
q243493
Controller.redirectToFrontendPage
validation
protected function redirectToFrontendPage($intPage, $strArticle=null, $blnReturn=false) { if (($intPage = (int) $intPage) <= 0) { return ''; } $objPage = PageModel::findWithDetails($intPage); if ($objPage === null) { return ''; } $strParams = null; // Add the /article/ fragment (see #673) ...
php
{ "resource": "" }
q243494
Controller.getParentEntries
validation
protected function getParentEntries($strTable, $intId) { // No parent table if (!isset($GLOBALS['TL_DCA'][$strTable]['config']['ptable'])) { return ''; } $arrParent = array(); do { // Get the pid $objParent = $this->Database->prepare("SELECT pid FROM " . $strTable . " WHERE id=?") ->...
php
{ "resource": "" }
q243495
Controller.eliminateNestedPaths
validation
protected function eliminateNestedPaths($arrPaths) { $arrPaths = array_filter($arrPaths); if (empty($arrPaths) || !\is_array($arrPaths)) { return array(); } $nested = array(); foreach ($arrPaths as $path) { $nested[] = preg_grep('/^' . preg_quote($path, '/') . '\/.+/', $arrPaths); } if (!em...
php
{ "resource": "" }
q243496
Controller.eliminateNestedPages
validation
protected function eliminateNestedPages($arrPages, $strTable=null, $blnSorting=false) { if (empty($arrPages) || !\is_array($arrPages)) { return array(); } if (!$strTable) { $strTable = 'tl_page'; } // Thanks to Andreas Schempp (see #2475 and #3423) $arrPages = array_intersect($arrPages, $this->...
php
{ "resource": "" }
q243497
Controller.setStaticUrls
validation
public static function setStaticUrls() { if (\defined('TL_FILES_URL')) { return; } if (\func_num_args() > 0) { @trigger_error('Using Controller::setStaticUrls() has been deprecated and will no longer work in Contao 5.0. Use the asset contexts instead.', E_USER_DEPRECATED); if (!isset($GLOBALS['obj...
php
{ "resource": "" }
q243498
Controller.addStaticUrlTo
validation
public static function addStaticUrlTo($script, ContaoContext $context = null) { // Absolute URLs if (preg_match('@^https?://@', $script)) { return $script; } if ($context === null) { $context = System::getContainer()->get('contao.assets.assets_context'); } if ($strStaticUrl = $context->getStati...
php
{ "resource": "" }
q243499
Controller.prepareForWidget
validation
protected function prepareForWidget($arrData, $strName, $varValue=null, $strField='', $strTable='') { @trigger_error('Using Controller::prepareForWidget() has been deprecated and will no longer work in Contao 5.0. Use Widget::getAttributesFromDca() instead.', E_USER_DEPRECATED); return Widget::getAttributesFromDc...
php
{ "resource": "" }