_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q243600
TokenChecker.isPreviewMode
validation
public function isPreviewMode(): bool { $token = $this->getToken(FrontendUser::SECURITY_SESSION_KEY); return $token instanceof FrontendPreviewToken && $token->showUnpublished(); }
php
{ "resource": "" }
q243601
MemberGroupModel.findPublishedById
validation
public static function findPublishedById($intId, array $arrOptions=array()) { $t = static::$strTable; $arrColumns = array("$t.id=?"); if (!static::isPreviewMode($arrOptions)) { $time = Date::floorToMinute(); $arrColumns[] = "($t.start='' OR $t.start<='$time') AND ($t.stop='' OR $t.stop>'" . ($time + 60)...
php
{ "resource": "" }
q243602
MemberGroupModel.findAllActive
validation
public static function findAllActive(array $arrOptions=array()) { $t = static::$strTable; $time = Date::floorToMinute(); return static::findBy(array("$t.disable='' AND ($t.start='' OR $t.start<='$time') AND ($t.stop='' OR $t.stop>'" . ($time + 60) . "')"), null, $arrOptions); }
php
{ "resource": "" }
q243603
MemberGroupModel.findFirstActiveWithJumpToByIds
validation
public static function findFirstActiveWithJumpToByIds($arrIds) { @trigger_error('Using MemberGroupModel::findFirstActiveWithJumpToByIds() has been deprecated and will no longer work in Contao 5.0. Use PageModel::findFirstActiveByMemberGroups() instead.', E_USER_DEPRECATED); if (empty($arrIds) || !\is_array($arrId...
php
{ "resource": "" }
q243604
StringUtil.decodeEntities
validation
public static function decodeEntities($strString, $strQuoteStyle=ENT_COMPAT, $strCharset=null) { if ($strString == '') { return ''; } if ($strCharset === null) { $strCharset = Config::get('characterSet'); } $strString = preg_replace('/(&#*\w+)[\x00-\x20]+;/i', '$1;', $strString); $strString = p...
php
{ "resource": "" }
q243605
StringUtil.generateAlias
validation
public static function generateAlias($strString) { $strString = static::decodeEntities($strString); $strString = static::restoreBasicEntities($strString); $strString = static::standardize(strip_tags($strString)); // Remove the prefix if the alias is not numeric (see #707) if (strncmp($strString, 'id-', 3) =...
php
{ "resource": "" }
q243606
StringUtil.prepareSlug
validation
public static function prepareSlug($strSlug) { $strSlug = static::stripInsertTags($strSlug); $strSlug = static::restoreBasicEntities($strSlug); $strSlug = static::decodeEntities($strSlug); return $strSlug; }
php
{ "resource": "" }
q243607
StringUtil.censor
validation
public static function censor($strString, $varWords, $strReplace='') { foreach ((array) $varWords as $strWord) { $strString = preg_replace('/\b(' . str_replace('\*', '\w*?', preg_quote($strWord, '/')) . ')\b/i', $strReplace, $strString); } return $strString; }
php
{ "resource": "" }
q243608
StringUtil.encodeEmail
validation
public static function encodeEmail($strString) { if (strpos($strString, '@') === false) { return $strString; } $arrEmails = static::extractEmail($strString, Config::get('allowedTags')); foreach ($arrEmails as $strEmail) { $strEncoded = ''; $arrCharacters = Utf8::str_split($strEmail); foreach...
php
{ "resource": "" }
q243609
StringUtil.extractEmail
validation
public static function extractEmail($strString, $strAllowedTags='') { $arrEmails = array(); if (strpos($strString, '@') === false) { return $arrEmails; } // Find all mailto: addresses preg_match_all('/mailto:(?:[^\x00-\x20\x22\x40\x7F]{1,64}+|\x22[^\x00-\x1F\x7F]{1,64}?\x22)@(?:\[(?:IPv)?[a-f0-9.:]{1,...
php
{ "resource": "" }
q243610
StringUtil.splitFriendlyEmail
validation
public static function splitFriendlyEmail($strEmail) { if (strpos($strEmail, '<') !== false) { return array_map('trim', explode(' <', str_replace('>', '', $strEmail))); } elseif (strpos($strEmail, '[') !== false) { return array_map('trim', explode(' [', str_replace(']', '', $strEmail))); } else {...
php
{ "resource": "" }
q243611
StringUtil.highlight
validation
public static function highlight($strString, $strPhrase, $strOpeningTag='<strong>', $strClosingTag='</strong>') { if ($strString == '' || $strPhrase == '') { return $strString; } return preg_replace('/(' . preg_quote($strPhrase, '/') . ')/i', $strOpeningTag . '\\1' . $strClosingTag, $strString); }
php
{ "resource": "" }
q243612
StringUtil.splitCsv
validation
public static function splitCsv($strString, $strDelimiter=',') { $arrValues = preg_split('/'.$strDelimiter.'(?=(?:[^"]*"[^"]*")*(?![^"]*"))/', $strString); foreach ($arrValues as $k=>$v) { $arrValues[$k] = trim($v, ' "'); } return $arrValues; }
php
{ "resource": "" }
q243613
StringUtil.toXhtml
validation
public static function toXhtml($strString) { $arrPregReplace = array ( '/<(br|hr|img)([^>]*)>/i' => '<$1$2 />', // Close stand-alone tags '/ border="[^"]*"/' => '' // Remove deprecated attributes ); $arrStrReplace = array ( '/ />' => ' />', // Fix incorrectly close...
php
{ "resource": "" }
q243614
StringUtil.toHtml5
validation
public static function toHtml5($strString) { $arrPregReplace = array ( '/<(br|hr|img)([^>]*) \/>/i' => '<$1$2>', // Close stand-alone tags '/ (cellpadding|cellspacing|border)="[^"]*"/' => '', // Remove deprecated attributes '/ rel="lightbox(\[([^\]]+)\])?"/' ...
php
{ "resource": "" }
q243615
StringUtil.srcToInsertTag
validation
public static function srcToInsertTag($data) { $return = ''; $paths = preg_split('/((src|href)="([^"]+)")/i', $data, -1, PREG_SPLIT_DELIM_CAPTURE); for ($i=0, $c=\count($paths); $i<$c; $i+=4) { $return .= $paths[$i]; if (!isset($paths[$i+1])) { continue; } $file = FilesModel::findByPath($...
php
{ "resource": "" }
q243616
StringUtil.insertTagToSrc
validation
public static function insertTagToSrc($data) { $return = ''; $paths = preg_split('/((src|href)="([^"]*)\{\{file::([^"\}]+)\}\}")/i', $data, -1, PREG_SPLIT_DELIM_CAPTURE); for ($i=0, $c=\count($paths); $i<$c; $i+=5) { $return .= $paths[$i]; if (!isset($paths[$i+1])) { continue; } $file = F...
php
{ "resource": "" }
q243617
StringUtil.sanitizeFileName
validation
public static function sanitizeFileName($strName) { // Remove invisible control characters and unused code points $strName = preg_replace('/[\pC]/u', '', $strName); if ($strName === null) { throw new \InvalidArgumentException('The file name could not be sanitzied'); } // Remove special characters not ...
php
{ "resource": "" }
q243618
StringUtil.convertEncoding
validation
public static function convertEncoding($str, $to, $from=null) { if ($str == '') { return ''; } if (!$from) { $from = mb_detect_encoding($str, 'ASCII,ISO-2022-JP,UTF-8,EUC-JP,ISO-8859-1'); } if ($from == $to) { return $str; } if ($from == 'UTF-8' && $to == 'ISO-8859-1') { return utf...
php
{ "resource": "" }
q243619
StringUtil.specialchars
validation
public static function specialchars($strString, $blnStripInsertTags=false, $blnDoubleEncode=false) { if ($blnStripInsertTags) { $strString = static::stripInsertTags($strString); } // Use ENT_COMPAT here (see #4889) return htmlspecialchars($strString, ENT_COMPAT, Config::get('characterSet'), $blnDoubleEnc...
php
{ "resource": "" }
q243620
StringUtil.deserialize
validation
public static function deserialize($varValue, $blnForceArray=false) { // Already an array if (\is_array($varValue)) { return $varValue; } // Null if ($varValue === null) { return $blnForceArray ? array() : null; } // Not a string if (!\is_string($varValue)) { return $blnForceArray ? ar...
php
{ "resource": "" }
q243621
StringUtil.trimsplit
validation
public static function trimsplit($strPattern, $strString) { // Split if (\strlen($strPattern) == 1) { $arrFragments = array_map('trim', explode($strPattern, $strString)); } else { $arrFragments = array_map('trim', preg_split('/'.$strPattern.'/ui', $strString)); } // Empty array if (\count($arr...
php
{ "resource": "" }
q243622
StringUtil.stripRootDir
validation
public static function stripRootDir($path) { $rootDir = System::getContainer()->getParameter('kernel.project_dir'); $length = \strlen($rootDir); if (strncmp($path, $rootDir, $length) !== 0 || \strlen($path) <= $length || ($path[$length] !== '/' && $path[$length] !== '\\')) { throw new \InvalidArgumentExcep...
php
{ "resource": "" }
q243623
FaqModel.findPublishedByParentAndIdOrAlias
validation
public static function findPublishedByParentAndIdOrAlias($varId, $arrPids, array $arrOptions=array()) { if (empty($arrPids) || !\is_array($arrPids)) { return null; } $t = static::$strTable; $arrColumns = !preg_match('/^[1-9]\d*$/', $varId) ? array("$t.alias=?") : array("$t.id=?"); $arrColumns[] = "$t.p...
php
{ "resource": "" }
q243624
RefererIdListener.onKernelRequest
validation
public function onKernelRequest(GetResponseEvent $event): void { if (!$this->scopeMatcher->isBackendMasterRequest($event)) { return; } $request = $event->getRequest(); if (null === $this->token) { $this->token = $this->tokenManager->refreshToken('contao_refe...
php
{ "resource": "" }
q243625
ResponseExceptionListener.onKernelException
validation
public function onKernelException(GetResponseForExceptionEvent $event): void { $exception = $event->getException(); if (!$exception instanceof ResponseException) { return; } $event->allowCustomResponseCode(); $event->setResponse($exception->getResponse()); }
php
{ "resource": "" }
q243626
PaletteManipulator.addLegend
validation
public function addLegend(string $name, $parent, string $position = self::POSITION_AFTER, $hide = false): self { $this->validatePosition($position); $this->legends[] = [ 'name' => $name, 'parents' => (array) $parent, 'position' => $position, 'hide' =>...
php
{ "resource": "" }
q243627
PaletteManipulator.removeField
validation
public function removeField($name, string $legend = null): self { $this->removes[] = [ 'fields' => (array) $name, 'parents' => (array) $legend, ]; return $this; }
php
{ "resource": "" }
q243628
PaletteManipulator.explode
validation
private function explode(string $palette): array { if ('' === $palette) { return []; } $legendCount = 0; $legendMap = []; $groups = StringUtil::trimsplit(';', $palette); foreach ($groups as $group) { if ('' === $group) { conti...
php
{ "resource": "" }
q243629
PaletteManipulator.implode
validation
private function implode(array $config): string { $palette = ''; foreach ($config as $legend => $group) { if (\count($group['fields']) < 1) { continue; } if ('' !== $palette) { $palette .= ';'; } if (!\is_...
php
{ "resource": "" }
q243630
PaletteManipulator.applyFallback
validation
private function applyFallback(array &$config, array $action, bool $skipLegends = false): void { if (\is_callable($action['fallback'])) { $action['fallback']($config, $action, $skipLegends); } else { $this->applyFallbackPalette($config, $action); } }
php
{ "resource": "" }
q243631
PaletteManipulator.findLegendForField
validation
private function findLegendForField(array &$config, string $field) { foreach ($config as $legend => $group) { if (\in_array($field, $group['fields'], true)) { return $legend; } } return false; }
php
{ "resource": "" }
q243632
tl_calendar_feed.adjustPermissions
validation
public function adjustPermissions($insertId) { // The oncreate_callback passes $insertId as second argument if (\func_num_args() == 4) { $insertId = func_get_arg(1); } if ($this->User->isAdmin) { return; } // Set root IDs if (empty($this->User->calendarfeeds) || !\is_array($this->User->calend...
php
{ "resource": "" }
q243633
tl_calendar_feed.getAllowedCalendars
validation
public function getAllowedCalendars() { if ($this->User->isAdmin) { $objCalendar = Contao\CalendarModel::findAll(); } else { $objCalendar = Contao\CalendarModel::findMultipleByIds($this->User->calendars); } $return = array(); if ($objCalendar !== null) { while ($objCalendar->next()) { ...
php
{ "resource": "" }
q243634
ZipWriter.addFile
validation
public function addFile($strFile, $strName=null) { if (!file_exists($this->strRootDir . '/' . $strFile)) { throw new \Exception("File $strFile does not exist"); } // Remove leading slashes (see #4502) if (strncmp($strName, '/', 1) === 0) { $strName = substr($strName, 1); } $this->addString(file...
php
{ "resource": "" }
q243635
ZipWriter.addString
validation
public function addString($strData, $strName, $intTime=0) { ++$this->intCount; $strName = strtr($strName, '\\', '/'); // Start file $arrFile['file_signature'] = self::FILE_SIGNATURE; $arrFile['version_needed_to_extract'] = "\x14\x00"; $arrFile['general_purpose_bit_flag'] = "\x00\x00"; $arrFi...
php
{ "resource": "" }
q243636
ZipWriter.close
validation
public function close() { // Add archive header $arrArchive['archive_signature'] = self::CENTRAL_DIR_END; $arrArchive['number_of_this_disk'] = "\x00\x00"; $arrArchive['number_of_disk_with_cd'] = "\x00\x00"; $arrArchive['total_cd_entries_disk'] = pack('v', $this->intCount); $arrArchive['total_cd_en...
php
{ "resource": "" }
q243637
ZipWriter.unixToHex
validation
protected function unixToHex($intTime=0) { $arrTime = $intTime ? getdate($intTime) : getdate(); $hexTime = dechex ( (($arrTime['year'] - 1980) << 25) | ($arrTime['mon'] << 21) | ($arrTime['mday'] << 16) | ($arrTime['hours'] << 11) | ($arrTime['minutes'] << 5) | ($arrTime['seconds'] >> 1) ...
php
{ "resource": "" }
q243638
Comments.parseBbCode
validation
public function parseBbCode($strComment) { $arrSearch = array ( '@\[b\](.*)\[/b\]@Uis', '@\[i\](.*)\[/i\]@Uis', '@\[u\](.*)\[/u\]@Uis', '@\s*\[code\](.*)\[/code\]\s*@Uis', '@\[color=([^\]" ]+)\](.*)\[/color\]@Uis', '@\s*\[quote\](.*)\[/quote\]\s*@Uis', '@\s*\[quote=([^\]]+)\](.*)\[/quote\]\s*@...
php
{ "resource": "" }
q243639
Comments.changeSubscriptionStatus
validation
public static function changeSubscriptionStatus(FrontendTemplate $objTemplate) { if (strncmp(Input::get('token'), 'com-', 4) === 0) { /** @var OptIn $optIn */ $optIn = System::getContainer()->get('contao.opt-in'); // Find an unconfirmed token with only one related record if ((!$optInToken = $optIn->fi...
php
{ "resource": "" }
q243640
Comments.notifyCommentsSubscribers
validation
public static function notifyCommentsSubscribers(CommentsModel $objComment) { // Notified already if ($objComment->notified) { return; } $objNotify = CommentsNotifyModel::findActiveBySourceAndParent($objComment->source, $objComment->parent); if ($objNotify !== null) { while ($objNotify->next()) ...
php
{ "resource": "" }
q243641
Template.output
validation
public function output() { @trigger_error('Using Template::output() has been deprecated and will no longer work in Contao 5.0. Use Template::getResponse() instead.', E_USER_DEPRECATED); $this->compile(); header('Content-Type: ' . $this->strContentType . '; charset=' . Config::get('characterSet')); echo $thi...
php
{ "resource": "" }
q243642
Template.route
validation
public function route($strName, $arrParams=array()) { $strUrl = System::getContainer()->get('router')->generate($strName, $arrParams); $strUrl = substr($strUrl, \strlen(Environment::get('path')) + 1); return ampersand($strUrl); }
php
{ "resource": "" }
q243643
Template.previewRoute
validation
public function previewRoute($strName, $arrParams=array()) { $objRouter = System::getContainer()->get('router'); $objContext = $objRouter->getContext(); $objPreviewContext = clone $objContext; $objPreviewContext->setBaseUrl('/preview.php'); $objRouter->setContext($objPreviewContext); $strUrl = $objRoute...
php
{ "resource": "" }
q243644
Template.trans
validation
public function trans($strId, array $arrParams=array(), $strDomain='contao_default') { return System::getContainer()->get('translator')->trans($strId, $arrParams, $strDomain); }
php
{ "resource": "" }
q243645
Template.asset
validation
public function asset($path, $packageName = null) { $url = System::getContainer()->get('assets.packages')->getUrl($path, $packageName); // Contao paths are relative to the <base> tag, so remove leading slashes return ltrim($url, '/'); }
php
{ "resource": "" }
q243646
Template.minifyHtml
validation
public function minifyHtml($strHtml) { if (Config::get('debugMode')) { return $strHtml; } // Split the markup based on the tags that shall be preserved $arrChunks = preg_split('@(</?pre[^>]*>)|(</?script[^>]*>)|(</?style[^>]*>)|( ?</?textarea[^>]*>)@i', $strHtml, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_N...
php
{ "resource": "" }
q243647
Template.generateStyleTag
validation
public static function generateStyleTag($href, $media=null, $mtime=false) { // Add the filemtime if not given and not an external file if ($mtime === null && !preg_match('@^https?://@', $href)) { $container = System::getContainer(); $rootDir = $container->getParameter('kernel.project_dir'); if (file_ex...
php
{ "resource": "" }
q243648
Template.generateScriptTag
validation
public static function generateScriptTag($src, $async=false, $mtime=false, $hash=null, $crossorigin=null) { // Add the filemtime if not given and not an external file if ($mtime === null && !preg_match('@^https?://@', $src)) { $container = System::getContainer(); $rootDir = $container->getParameter('kernel...
php
{ "resource": "" }
q243649
Template.flushAllData
validation
public function flushAllData() { @trigger_error('Using Template::flushAllData() has been deprecated and will no longer work in Contao 5.0.', E_USER_DEPRECATED); if (\function_exists('fastcgi_finish_request')) { fastcgi_finish_request(); } elseif (PHP_SAPI !== 'cli') { $status = ob_get_status(true); ...
php
{ "resource": "" }
q243650
DcaExtractor.getInstance
validation
public static function getInstance($strTable) { if (!isset(static::$arrInstances[$strTable])) { static::$arrInstances[$strTable] = new static($strTable); } return static::$arrInstances[$strTable]; }
php
{ "resource": "" }
q243651
DcaExtractor.getDbInstallerArray
validation
public function getDbInstallerArray() { $return = array(); // Fields foreach ($this->arrFields as $k=>$v) { if (\is_array($v)) { if (!isset($v['name'])) { $v['name'] = $k; } $return['SCHEMA_FIELDS'][$k] = $v; } else { $return['TABLE_FIELDS'][$k] = '`' . $k . '` ' . $v;...
php
{ "resource": "" }
q243652
Theme.exportTheme
validation
public function exportTheme(DataContainer $dc) { // Get the theme meta data $objTheme = $this->Database->prepare("SELECT * FROM tl_theme WHERE id=?") ->limit(1) ->execute($dc->id); if ($objTheme->numRows < 1) { return; } // Romanize the name $strName = Utf8::toAscii($objTheme->...
php
{ "resource": "" }
q243653
Theme.addTableTlTheme
validation
protected function addTableTlTheme(\DOMDocument $xml, \DOMNode $tables, Result $objTheme) { // Add the table $table = $xml->createElement('table'); $table->setAttribute('name', 'tl_theme'); $table = $tables->appendChild($table); // Load the DCA $this->loadDataContainer('tl_theme'); // Get the order fie...
php
{ "resource": "" }
q243654
Theme.addTableTlStyleSheet
validation
protected function addTableTlStyleSheet(\DOMDocument $xml, \DOMNode $tables, Result $objTheme) { // Add the table $table = $xml->createElement('table'); $table->setAttribute('name', 'tl_style_sheet'); $table = $tables->appendChild($table); // Load the DCA $this->loadDataContainer('tl_style_sheet'); // ...
php
{ "resource": "" }
q243655
Theme.addTableTlModule
validation
protected function addTableTlModule(\DOMDocument $xml, \DOMNode $tables, Result $objTheme) { // Add the table $table = $xml->createElement('table'); $table->setAttribute('name', 'tl_module'); $table = $tables->appendChild($table); // Load the DCA $this->loadDataContainer('tl_module'); // Get the order ...
php
{ "resource": "" }
q243656
Theme.addTableTlImageSize
validation
protected function addTableTlImageSize(\DOMDocument $xml, \DOMNode $tables, Result $objTheme) { // Add the tables $imageSizeTable = $xml->createElement('table'); $imageSizeTable->setAttribute('name', 'tl_image_size'); $imageSizeTable = $tables->appendChild($imageSizeTable); $imageSizeItemTable = $xml->creat...
php
{ "resource": "" }
q243657
Theme.addTableTlFiles
validation
protected function addTableTlFiles(\DOMDocument $xml, \DOMElement $tables, Result $objTheme, ZipWriter $objArchive) { // Add the table $table = $xml->createElement('table'); $table->setAttribute('name', 'tl_files'); $table = $tables->appendChild($table); // Load the DCA $this->loadDataContainer('tl_files'...
php
{ "resource": "" }
q243658
Theme.addDataRow
validation
protected function addDataRow(\DOMDocument $xml, \DOMElement $table, array $arrRow, array $arrOrder=array()) { $t = $table->getAttribute('name'); $row = $xml->createElement('row'); $row = $table->appendChild($row); foreach ($arrRow as $k=>$v) { $field = $xml->createElement('field'); $field->setAttrib...
php
{ "resource": "" }
q243659
Theme.addFolderToArchive
validation
protected function addFolderToArchive(ZipWriter $objArchive, $strFolder, \DOMDocument $xml, \DOMElement $table, array $arrOrder=array()) { // Strip the custom upload folder name $strFolder = preg_replace('@^'.preg_quote(Config::get('uploadPath'), '@').'/@', '', $strFolder); // Add the default upload folder name...
php
{ "resource": "" }
q243660
Theme.addTemplatesToArchive
validation
protected function addTemplatesToArchive(ZipWriter $objArchive, $strFolder) { // Strip the templates folder name $strFolder = preg_replace('@^templates/@', '', $strFolder); // Re-add the templates folder name if ($strFolder == '') { $strFolder = 'templates'; } else { $strFolder = 'templates/' . ...
php
{ "resource": "" }
q243661
Dbafs.moveResource
validation
public static function moveResource($strSource, $strDestination) { $objFile = FilesModel::findByPath($strSource); // If there is no entry, directly add the destination if ($objFile === null) { $objFile = static::addResource($strDestination); } $strFolder = \dirname($strDestination); // Set the new ...
php
{ "resource": "" }
q243662
Dbafs.copyResource
validation
public static function copyResource($strSource, $strDestination) { $objDatabase = Database::getInstance(); $objFile = FilesModel::findByPath($strSource); // Add the source entry if ($objFile === null) { $objFile = static::addResource($strSource); } $strFolder = \dirname($strDestination); /** @var...
php
{ "resource": "" }
q243663
Dbafs.deleteResource
validation
public static function deleteResource($strResource) { $objModel = FilesModel::findByPath($strResource); // Remove the resource if ($objModel !== null) { $objModel->delete(); } // Look for subfolders and files $objFiles = FilesModel::findMultipleByBasepath($strResource . '/'); // Remove subfolders...
php
{ "resource": "" }
q243664
Dbafs.updateFolderHashes
validation
public static function updateFolderHashes($varResource) { $arrPaths = array(); if (!\is_array($varResource)) { $varResource = array($varResource); } $rootDir = System::getContainer()->getParameter('kernel.project_dir'); foreach ($varResource as $strResource) { $arrChunks = explode('/', $strReso...
php
{ "resource": "" }
q243665
Dbafs.getFolderHash
validation
public static function getFolderHash($strPath) { $strPath = str_replace(array('\\', '%', '_'), array('\\\\', '\\%', '\\_'), $strPath); $arrHash = array(); $objChildren = Database::getInstance() ->prepare("SELECT hash, name FROM tl_files WHERE path LIKE ? AND path NOT LIKE ? ORDER BY name") ->execute($strP...
php
{ "resource": "" }
q243666
Dbafs.shouldBeSynchronized
validation
public static function shouldBeSynchronized($strPath) { if (!isset(static::$arrShouldBeSynchronized[$strPath]) || !\is_bool(static::$arrShouldBeSynchronized[$strPath])) { static::$arrShouldBeSynchronized[$strPath] = !static::isFileSyncExclude($strPath); } return static::$arrShouldBeSynchronized[$strPath]; ...
php
{ "resource": "" }
q243667
Dbafs.isFileSyncExclude
validation
protected static function isFileSyncExclude($strPath) { if (Config::get('uploadPath') == 'templates') { return true; } $rootDir = System::getContainer()->getParameter('kernel.project_dir'); // Look for an existing parent folder (see #410) while ($strPath != '.' && !is_dir($rootDir . '/' . $strPath)) ...
php
{ "resource": "" }
q243668
BackendMenuListener.onBuild
validation
public function onBuild(MenuEvent $event): void { if (null === $this->managerPath || !$this->isAdminUser()) { return; } $categoryNode = $event->getTree()->getChild('system'); if (null === $categoryNode) { return; } $item = $event->getFactory...
php
{ "resource": "" }
q243669
FrontendCron.hasToWait
validation
protected function hasToWait() { $return = true; // Get the timestamp without seconds (see #5775) $time = strtotime(date('Y-m-d H:i')); // Lock the table $this->Database->lockTables(array('tl_cron'=>'WRITE')); // Get the last execution date $objCron = $this->Database->prepare("SELECT * FROM tl_cron WH...
php
{ "resource": "" }
q243670
ScriptHandler.initializeApplication
validation
public static function initializeApplication(Event $event): void { $webDir = self::getWebDir($event); static::purgeCacheFolder(); static::addAppDirectory(); static::executeCommand('contao:install-web-dir', $event); static::executeCommand('cache:clear --no-warmup', $event); ...
php
{ "resource": "" }
q243671
tl_style_sheet.listStyleSheet
validation
public function listStyleSheet($row) { $cc = ''; $media = Contao\StringUtil::deserialize($row['media']); if ($row['cc'] != '') { $cc = ' &lt;!--['. $row['cc'] .']&gt;'; } if ($row['mediaQuery'] != '') { return '<div class="tl_content_left">'. $row['name'] .' <span style="color:#999;padding-left:3...
php
{ "resource": "" }
q243672
tl_style.checkCategory
validation
public function checkCategory($varValue) { // Do not change the value if it has been set already if (\strlen($varValue) || Contao\Input::post('FORM_SUBMIT') == 'tl_style') { return $varValue; } /** @var Symfony\Component\HttpFoundation\Session\Attribute\AttributeBagInterface $objSessionBag */ $objSessi...
php
{ "resource": "" }
q243673
tl_style.updateAfterRestore
validation
public function updateAfterRestore($id, $table, $data) { if ($table != 'tl_style') { return; } // Update the timestamp of the style sheet $this->Database->prepare("UPDATE tl_style_sheet SET tstamp=? WHERE id=?") ->execute(time(), $data['pid']); // Update the CSS file $this->import('Contao\St...
php
{ "resource": "" }
q243674
Session.get
validation
public function get($strKey) { // Map the referer (see #281) if (\in_array($strKey, $this->mappedKeys)) { return $this->session->get($strKey); } return $this->sessionBag->get($strKey); }
php
{ "resource": "" }
q243675
Session.set
validation
public function set($strKey, $varValue) { // Map the referer (see #281) if (\in_array($strKey, $this->mappedKeys)) { $this->session->set($strKey, $varValue); } else { $this->sessionBag->set($strKey, $varValue); } }
php
{ "resource": "" }
q243676
Session.remove
validation
public function remove($strKey) { // Map the referer (see #281) if (\in_array($strKey, $this->mappedKeys)) { $this->session->remove($strKey); } else { $this->sessionBag->remove($strKey); } }
php
{ "resource": "" }
q243677
Session.getData
validation
public function getData() { $data = $this->sessionBag->all(); // Map the referer (see #281) foreach ($this->mappedKeys as $strKey) { unset($data[$strKey]); if ($this->session->has($strKey)) { $data[$strKey] = $this->session->get($strKey); } } return $data; }
php
{ "resource": "" }
q243678
Session.setData
validation
public function setData($arrData) { if (!\is_array($arrData)) { throw new \Exception('Array required to set session data'); } // Map the referer (see #281) foreach ($this->mappedKeys as $strKey) { if (isset($arrData[$strKey])) { $this->session->set($strKey, $arrData[$strKey]); unset($arrD...
php
{ "resource": "" }
q243679
Session.appendData
validation
public function appendData($varData) { if (\is_object($varData)) { $varData = get_object_vars($varData); } if (!\is_array($varData)) { throw new \Exception('Array or object required to append session data'); } foreach ($varData as $k=>$v) { // Map the referer (see #281) if (\in_array($k, ...
php
{ "resource": "" }
q243680
PickerConfig.cloneForCurrent
validation
public function cloneForCurrent(string $current): self { return new self($this->context, $this->extras, $this->value, $current); }
php
{ "resource": "" }
q243681
PickerConfig.urlEncode
validation
public function urlEncode(): string { $data = json_encode($this); if (\function_exists('gzencode') && false !== ($encoded = @gzencode($data))) { $data = $encoded; } return strtr(base64_encode($data), '+/=', '-_,'); }
php
{ "resource": "" }
q243682
PickerConfig.urlDecode
validation
public static function urlDecode(string $data): self { $decoded = base64_decode(strtr($data, '-_,', '+/='), true); if (\function_exists('gzdecode') && false !== ($uncompressed = @gzdecode($decoded))) { $decoded = $uncompressed; } $json = @json_decode($decoded, true); ...
php
{ "resource": "" }
q243683
AbstractPickerProvider.getUser
validation
protected function getUser(): BackendUser { if (null === $this->tokenStorage) { throw new \RuntimeException('No token storage provided'); } $token = $this->tokenStorage->getToken(); if (null === $token) { throw new \RuntimeException('No token provided'); ...
php
{ "resource": "" }
q243684
Encryption.encrypt
validation
public static function encrypt($varValue, $strKey=null) { // Recursively encrypt arrays if (\is_array($varValue)) { foreach ($varValue as $k=>$v) { $varValue[$k] = static::encrypt($v); } return $varValue; } elseif ($varValue == '') { return ''; } // Initialize the module if (stat...
php
{ "resource": "" }
q243685
Encryption.decrypt
validation
public static function decrypt($varValue, $strKey=null) { // Recursively decrypt arrays if (\is_array($varValue)) { foreach ($varValue as $k=>$v) { $varValue[$k] = static::decrypt($v); } return $varValue; } elseif ($varValue == '') { return ''; } // Initialize the module if (stat...
php
{ "resource": "" }
q243686
Encryption.initialize
validation
protected static function initialize() { if (!\in_array('mcrypt', get_loaded_extensions())) { throw new \Exception('The PHP mcrypt extension is not installed'); } if (!self::$resTd = mcrypt_module_open(Config::get('encryptionCipher'), '', Config::get('encryptionMode'), '')) { throw new \Exception('Err...
php
{ "resource": "" }
q243687
tl_comments.checkPermission
validation
public function checkPermission() { switch (Contao\Input::get('act')) { case 'select': case 'show': // Allow break; case 'edit': case 'delete': case 'toggle': $objComment = $this->Database->prepare("SELECT id, parent, source FROM tl_comments WHERE id=?") ->limit(1) ...
php
{ "resource": "" }
q243688
tl_comments.notifyOfReply
validation
public function notifyOfReply(Contao\DataContainer $dc) { // Return if there is no active record (override all) or no reply or the notification has been sent already if (!$dc->activeRecord || !$dc->activeRecord->addReply || $dc->activeRecord->notifyReply) { return; } $objNotify = Contao\CommentsNotifyMod...
php
{ "resource": "" }
q243689
tl_comments.sendNotifications
validation
public function sendNotifications($varValue) { if ($varValue) { Contao\Comments::notifyCommentsSubscribers(Contao\CommentsModel::findByPk(Contao\Input::get('id'))); } return $varValue; }
php
{ "resource": "" }
q243690
tl_comments.editComment
validation
public function editComment($row, $href, $label, $title, $icon, $attributes) { return $this->isAllowedToEditComment($row['parent'], $row['source']) ? '<a href="'.$this->addToUrl($href.'&amp;id='.$row['id']).'" title="'.Contao\StringUtil::specialchars($title).'"'.$attributes.'>'.Contao\Image::getHtml($icon, $label).'...
php
{ "resource": "" }
q243691
tl_comments.invalidateSourceCacheTag
validation
public function invalidateSourceCacheTag(Contao\DataContainer $dc, array $tags) { $commentModel = Contao\CommentsModel::findByPk($dc->id); if (null !== $commentModel) { $tags[] = sprintf('contao.comments.%s.%s', $commentModel->source, $commentModel->parent); } return $tags; }
php
{ "resource": "" }
q243692
LocaleListener.onKernelRequest
validation
public function onKernelRequest(GetResponseEvent $event): void { if (!$this->scopeMatcher->isContaoRequest($event->getRequest())) { return; } $request = $event->getRequest(); $request->attributes->set('_locale', $this->getLocale($request)); }
php
{ "resource": "" }
q243693
LocaleListener.getLocale
validation
private function getLocale(Request $request): string { if (null !== $request->attributes->get('_locale')) { return $this->formatLocaleId($request->attributes->get('_locale')); } return $request->getPreferredLanguage($this->availableLocales); }
php
{ "resource": "" }
q243694
NewsletterBlacklistModel.findByHashAndPid
validation
public static function findByHashAndPid($strHash, $intPid, array $arrOptions=array()) { $t = static::$strTable; return static::findOneBy(array("($t.hash=? AND $t.pid=?)"), array($strHash, $intPid), $arrOptions); }
php
{ "resource": "" }
q243695
DC_Table.showAll
validation
public function showAll() { $return = ''; $this->limit = ''; /** @var Session $objSession */ $objSession = System::getContainer()->get('session'); $undoPeriod = (int) Config::get('undoPeriod'); $logPeriod = (int) Config::get('logPeriod'); // Clean up old tl_undo and tl_log entries if ($this->strTabl...
php
{ "resource": "" }
q243696
DC_Table.copyAll
validation
public function copyAll() { if ($GLOBALS['TL_DCA'][$this->strTable]['config']['notCopyable']) { throw new InternalServerErrorException('Table "' . $this->strTable . '" is not copyable.'); } /** @var Session $objSession */ $objSession = System::getContainer()->get('session'); $arrClipboard = $objSessio...
php
{ "resource": "" }
q243697
DC_Table.deleteAll
validation
public function deleteAll() { if ($GLOBALS['TL_DCA'][$this->strTable]['config']['notDeletable']) { throw new InternalServerErrorException('Table "' . $this->strTable . '" is not deletable.'); } /** @var Session $objSession */ $objSession = System::getContainer()->get('session'); $session = $objSession...
php
{ "resource": "" }
q243698
DC_Table.deleteChilds
validation
public function deleteChilds($table, $id, &$delete) { $cctable = array(); $ctable = $GLOBALS['TL_DCA'][$table]['config']['ctable']; if (!\is_array($ctable)) { return; } // Walk through each child table foreach ($ctable as $v) { $this->loadDataContainer($v); $cctable[$v] = $GLOBALS['TL_DCA'][...
php
{ "resource": "" }
q243699
DC_Table.undo
validation
public function undo() { $objRecords = $this->Database->prepare("SELECT * FROM " . $this->strTable . " WHERE id=?") ->limit(1) ->execute($this->intId); // Check whether there is a record if ($objRecords->numRows < 1) { $this->redirect($this->getReferer()); } $error = false; $quer...
php
{ "resource": "" }