_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q243500
Controller.createInitialVersion
validation
protected function createInitialVersion($strTable, $intId) { @trigger_error('Using Controller::createInitialVersion() has been deprecated and will no longer work in Contao 5.0. Use Versions->initialize() instead.', E_USER_DEPRECATED); $objVersions = new Versions($strTable, $intId); $objVersions->initialize(); ...
php
{ "resource": "" }
q243501
Controller.braceGlob
validation
protected static function braceGlob($pattern) { // Use glob() if possible if (false === strpos($pattern, '/**/') && (\defined('GLOB_BRACE') || false === strpos($pattern, '{'))) { return glob($pattern, \defined('GLOB_BRACE') ? GLOB_BRACE : 0); } $finder = new Finder(); $regex = Glob::toRegex($pattern); ...
php
{ "resource": "" }
q243502
Database.prepare
validation
public function prepare($strQuery) { $objStatement = new Statement($this->resConnection, $this->blnDisableAutocommit); return $objStatement->prepare($strQuery); }
php
{ "resource": "" }
q243503
Database.query
validation
public function query($strQuery) { $objStatement = new Statement($this->resConnection, $this->blnDisableAutocommit); return $objStatement->query($strQuery); }
php
{ "resource": "" }
q243504
Database.listTables
validation
public function listTables($strDatabase=null, $blnNoCache=false) { if ($blnNoCache || !isset($this->arrCache[$strDatabase])) { $strOldDatabase = $this->resConnection->getDatabase(); // Change the database if ($strDatabase !== null && $strDatabase != $strOldDatabase) { $this->setDatabase($strDataba...
php
{ "resource": "" }
q243505
Database.tableExists
validation
public function tableExists($strTable, $strDatabase=null, $blnNoCache=false) { if ($strTable == '') { return false; } return \in_array($strTable, $this->listTables($strDatabase, $blnNoCache)); }
php
{ "resource": "" }
q243506
Database.fieldExists
validation
public function fieldExists($strField, $strTable, $blnNoCache=false) { if ($strField == '' || $strTable == '') { return false; } foreach ($this->listFields($strTable, $blnNoCache) as $arrField) { if ($arrField['name'] == $strField && $arrField['type'] != 'index') { return true; } } retu...
php
{ "resource": "" }
q243507
Database.indexExists
validation
public function indexExists($strName, $strTable, $blnNoCache=false) { if ($strName == '' || $strTable == '') { return false; } foreach ($this->listFields($strTable, $blnNoCache) as $arrField) { if ($arrField['name'] == $strName && $arrField['type'] == 'index') { return true; } } return ...
php
{ "resource": "" }
q243508
Database.getFieldNames
validation
public function getFieldNames($strTable, $blnNoCache=false) { $arrNames = array(); $arrFields = $this->listFields($strTable, $blnNoCache); foreach ($arrFields as $arrField) { if ($arrField['type'] != 'index') { $arrNames[] = $arrField['name']; } } return $arrNames; }
php
{ "resource": "" }
q243509
Database.isUniqueValue
validation
public function isUniqueValue($strTable, $strField, $varValue, $intId=null) { $strQuery = "SELECT * FROM $strTable WHERE " . static::quoteIdentifier($strField) . "=?"; if ($intId !== null) { $strQuery .= " AND id!=?"; } $objUnique = $this->prepare($strQuery) ->limit(1) ->execute($varValu...
php
{ "resource": "" }
q243510
Database.lockTables
validation
public function lockTables($arrTables) { $arrLocks = array(); foreach ($arrTables as $table=>$mode) { $arrLocks[] = $this->resConnection->quoteIdentifier($table) . ' ' . $mode; } $this->resConnection->exec('LOCK TABLES ' . implode(', ', $arrLocks) . ';'); }
php
{ "resource": "" }
q243511
Database.getSizeOf
validation
public function getSizeOf($strTable) { $statement = $this->resConnection->executeQuery('SHOW TABLE STATUS LIKE ' . $this->resConnection->quote($strTable)); $status = $statement->fetch(\PDO::FETCH_ASSOC); return $status['Data_length'] + $status['Index_length']; }
php
{ "resource": "" }
q243512
Database.getUuid
validation
public function getUuid() { static $ids; if (empty($ids)) { $statement = $this->resConnection->executeQuery(implode(' UNION ALL ', array_fill(0, 10, "SELECT UNHEX(REPLACE(UUID(), '-', '')) AS uuid"))); $ids = $statement->fetchAll(\PDO::FETCH_COLUMN); } return array_pop($ids); }
php
{ "resource": "" }
q243513
Database.quoteIdentifier
validation
public static function quoteIdentifier($strName) { static $strQuoteCharacter = null; if ($strQuoteCharacter === null) { $strQuoteCharacter = System::getContainer()->get('database_connection')->getDatabasePlatform()->getIdentifierQuoteCharacter(); } // The identifier is quoted already if (strncmp($strN...
php
{ "resource": "" }
q243514
tl_module.getModules
validation
public function getModules() { $groups = array(); foreach ($GLOBALS['FE_MOD'] as $k=>$v) { foreach (array_keys($v) as $kk) { $groups[$k][] = $kk; } } return $groups; }
php
{ "resource": "" }
q243515
tl_module.getEditableMemberProperties
validation
public function getEditableMemberProperties() { $return = array(); Contao\System::loadLanguageFile('tl_member'); $this->loadDataContainer('tl_member'); foreach ($GLOBALS['TL_DCA']['tl_member']['fields'] as $k=>$v) { if ($v['eval']['feEditable']) { $return[$k] = $GLOBALS['TL_DCA']['tl_member']['fi...
php
{ "resource": "" }
q243516
tl_module.getLayoutSections
validation
public function getLayoutSections() { $arrSections = array('header', 'left', 'right', 'main', 'footer'); // Check for custom layout sections $objLayout = $this->Database->query("SELECT sections FROM tl_layout WHERE sections!=''"); while ($objLayout->next()) { $arrCustom = Contao\StringUtil::deserialize(...
php
{ "resource": "" }
q243517
tl_module.getActivationDefault
validation
public function getActivationDefault($varValue) { if (!trim($varValue)) { $varValue = (\is_array($GLOBALS['TL_LANG']['tl_module']['emailText']) ? $GLOBALS['TL_LANG']['tl_module']['emailText'][1] : $GLOBALS['TL_LANG']['tl_module']['emailText']); } return $varValue; }
php
{ "resource": "" }
q243518
tl_module.getPasswordDefault
validation
public function getPasswordDefault($varValue) { if (!trim($varValue)) { $varValue = (\is_array($GLOBALS['TL_LANG']['tl_module']['passwordText']) ? $GLOBALS['TL_LANG']['tl_module']['passwordText'][1] : $GLOBALS['TL_LANG']['tl_module']['passwordText']); } return $varValue; }
php
{ "resource": "" }
q243519
tl_module.setPagesFlags
validation
public function setPagesFlags($varValue, Contao\DataContainer $dc) { if ($dc->activeRecord && $dc->activeRecord->type == 'search') { $GLOBALS['TL_DCA'][$dc->table]['fields'][$dc->field]['eval']['mandatory'] = false; unset($GLOBALS['TL_DCA'][$dc->table]['fields'][$dc->field]['eval']['orderField']); } ret...
php
{ "resource": "" }
q243520
Environment.get
validation
public static function get($strKey) { if (isset(static::$arrCache[$strKey])) { return static::$arrCache[$strKey]; } if (\in_array($strKey, get_class_methods(__CLASS__))) { static::$arrCache[$strKey] = static::$strKey(); } else { $arrChunks = preg_split('/([A-Z][a-z]*)/', $strKey, -1, PREG_SPL...
php
{ "resource": "" }
q243521
Environment.httpAcceptLanguage
validation
protected static function httpAcceptLanguage() { $arrAccepted = array(); $arrLanguages = array(); // The implementation differs from the original implementation and also works with .jp browsers preg_match_all('/([a-z]{1,8}(-[a-z]{1,8})?)\s*(;\s*q\s*=\s*(1|0\.[0-9]+))?/i', $_SERVER['HTTP_ACCEPT_LANGUAGE'], $ar...
php
{ "resource": "" }
q243522
Environment.httpHost
validation
protected static function httpHost() { if (!empty($_SERVER['HTTP_HOST'])) { $host = $_SERVER['HTTP_HOST']; } else { $host = $_SERVER['SERVER_NAME']; if ($_SERVER['SERVER_PORT'] != 80) { $host .= ':' . $_SERVER['SERVER_PORT']; } } return preg_replace('/[^A-Za-z0-9[\].:-]/', '', $host)...
php
{ "resource": "" }
q243523
Environment.ssl
validation
protected static function ssl() { $request = System::getContainer()->get('request_stack')->getCurrentRequest(); if ($request === null) { return false; } return $request->isSecure(); }
php
{ "resource": "" }
q243524
Environment.url
validation
protected static function url() { $host = static::get('httpHost'); $xhost = static::get('httpXForwardedHost'); // SSL proxy if ($xhost != '' && $xhost == Config::get('sslProxyDomain')) { return 'https://' . $xhost . '/' . $host; } return (static::get('ssl') ? 'https://' : 'http://') . $host; }
php
{ "resource": "" }
q243525
Environment.ip
validation
protected static function ip() { $request = System::getContainer()->get('request_stack')->getCurrentRequest(); if ($request === null) { return ''; } return $request->getClientIp(); }
php
{ "resource": "" }
q243526
Environment.server
validation
protected static function server() { $strServer = !empty($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : $_SERVER['LOCAL_ADDR']; // Special workaround for Strato users if (empty($strServer)) { $strServer = @gethostbyname($_SERVER['SERVER_NAME']); } return $strServer; }
php
{ "resource": "" }
q243527
Environment.agent
validation
protected static function agent() { $ua = static::get('httpUserAgent'); $return = new \stdClass(); $return->string = $ua; $os = 'unknown'; $mobile = false; $browser = 'other'; $shorty = ''; $version = ''; $engine = ''; // Operating system foreach (Config::get('os') as $k=>$v) { if (stripo...
php
{ "resource": "" }
q243528
MemberModel.findActiveByEmailAndUsername
validation
public static function findActiveByEmailAndUsername($strEmail, $strUsername=null, array $arrOptions=array()) { $t = static::$strTable; $time = Date::floorToMinute(); $arrColumns = array("$t.email=? AND $t.login='1' AND ($t.start='' OR $t.start<='$time') AND ($t.stop='' OR $t.stop>'" . ($time + 60) . "') AND $t....
php
{ "resource": "" }
q243529
MemberModel.findUnactivatedByEmail
validation
public static function findUnactivatedByEmail($strEmail, array $arrOptions=array()) { $t = static::$strTable; $objDatabase = Database::getInstance(); $objResult = $objDatabase->prepare("SELECT * FROM $t WHERE email=? AND disable='1' AND EXISTS (SELECT * FROM tl_opt_in_related r LEFT JOIN tl_opt_in o ON r.pid=o....
php
{ "resource": "" }
q243530
ModuleSubscribe.activateRecipient
validation
protected function activateRecipient() { $this->Template = new FrontendTemplate('mod_newsletter'); /** @var OptIn $optIn */ $optIn = System::getContainer()->get('contao.opt-in'); // Find an unconfirmed token if ((!$optInToken = $optIn->find(Input::get('token'))) || !$optInToken->isValid() || \count($arrRel...
php
{ "resource": "" }
q243531
ModuleSubscribe.addRecipient
validation
protected function addRecipient($strEmail, $arrNew) { // Remove old subscriptions that have not been activated yet if (($objOld = NewsletterRecipientsModel::findOldSubscriptionsByEmailAndPids($strEmail, $arrNew)) !== null) { while ($objOld->next()) { $objOld->delete(); } } $time = time(); $ar...
php
{ "resource": "" }
q243532
AddToSearchIndexListener.onKernelTerminate
validation
public function onKernelTerminate(PostResponseEvent $event): void { if (!$this->framework->isInitialized()) { return; } $request = $event->getRequest(); // Only index GET requests (see #1194) if (!$request->isMethod(Request::METHOD_GET)) { return; ...
php
{ "resource": "" }
q243533
Backend.getTheme
validation
public static function getTheme() { $theme = Config::get('backendTheme'); $rootDir = System::getContainer()->getParameter('kernel.project_dir'); if ($theme != '' && $theme != 'flexible' && is_dir($rootDir . '/system/themes/' . $theme)) { return $theme; } return 'flexible'; }
php
{ "resource": "" }
q243534
Backend.getThemes
validation
public static function getThemes() { $arrReturn = array(); $rootDir = System::getContainer()->getParameter('kernel.project_dir'); $arrThemes = scan($rootDir . '/system/themes'); foreach ($arrThemes as $strTheme) { if (strncmp($strTheme, '.', 1) === 0 || !is_dir($rootDir . '/system/themes/' . $strTheme)) ...
php
{ "resource": "" }
q243535
Backend.getTinyMceLanguage
validation
public static function getTinyMceLanguage() { $lang = $GLOBALS['TL_LANGUAGE']; if ($lang == '') { return 'en'; } $lang = str_replace('-', '_', $lang); $rootDir = System::getContainer()->getParameter('kernel.project_dir'); // The translation exists if (file_exists($rootDir . '/assets/tinymce4/js/l...
php
{ "resource": "" }
q243536
Backend.getTinyTemplates
validation
public static function getTinyTemplates() { $strDir = Config::get('uploadPath') . '/tiny_templates'; $rootDir = System::getContainer()->getParameter('kernel.project_dir'); if (!is_dir($rootDir . '/' . $strDir)) { return ''; } $arrFiles = array(); $arrTemplates = scan($rootDir . '/' . $strDir); fo...
php
{ "resource": "" }
q243537
Backend.addToUrl
validation
public static function addToUrl($strRequest, $blnAddRef=true, $arrUnset=array()) { // Unset the "no back button" flag $arrUnset[] = 'nb'; return parent::addToUrl($strRequest . (($strRequest != '') ? '&amp;' : '') . 'rt=' . REQUEST_TOKEN, $blnAddRef, $arrUnset); }
php
{ "resource": "" }
q243538
Backend.handleRunOnce
validation
public static function handleRunOnce() { try { $files = System::getContainer()->get('contao.resource_locator')->locate('config/runonce.php', null, false); } catch (\InvalidArgumentException $e) { return; } foreach ($files as $file) { try { include $file; } catch (\Exception $e) {...
php
{ "resource": "" }
q243539
Backend.findSearchablePages
validation
public static function findSearchablePages($pid=0, $domain='', $blnIsSitemap=false) { $objPages = PageModel::findPublishedByPid($pid, array('ignoreFePreview'=>true)); if ($objPages === null) { return array(); } $arrPages = array(); // Recursively walk through all subpages foreach ($objPages as $obj...
php
{ "resource": "" }
q243540
Backend.addFileMetaInformationToRequest
validation
public static function addFileMetaInformationToRequest($strUuid, $strPtable, $intPid) { @trigger_error('Using Backend::addFileMetaInformationToRequest() has been deprecated and will no longer work in Contao 5.0.', E_USER_DEPRECATED); $objFile = FilesModel::findByUuid($strUuid); if ($objFile === null) { re...
php
{ "resource": "" }
q243541
Backend.getSystemMessages
validation
public static function getSystemMessages() { $strMessages = ''; // HOOK: add custom messages if (isset($GLOBALS['TL_HOOKS']['getSystemMessages']) && \is_array($GLOBALS['TL_HOOKS']['getSystemMessages'])) { $arrMessages = array(); foreach ($GLOBALS['TL_HOOKS']['getSystemMessages'] as $callback) { ...
php
{ "resource": "" }
q243542
Backend.convertLayoutSectionIdsToAssociativeArray
validation
public static function convertLayoutSectionIdsToAssociativeArray($arrSections) { $arrSections = array_flip(array_values(array_unique($arrSections))); foreach (array_keys($arrSections) as $k) { $arrSections[$k] = $GLOBALS['TL_LANG']['COLS'][$k]; } asort($arrSections); return $arrSections; }
php
{ "resource": "" }
q243543
Backend.getDcaPickerWizard
validation
public static function getDcaPickerWizard($extras, $table, $field, $inputName) { $context = 'link'; $extras = \is_array($extras) ? $extras : array(); $providers = (isset($extras['providers']) && \is_array($extras['providers'])) ? $extras['providers'] : null; if (isset($extras['context'])) { $context = $e...
php
{ "resource": "" }
q243544
Backend.addCustomLayoutSectionReferences
validation
public function addCustomLayoutSectionReferences() { $objLayout = $this->Database->getInstance()->query("SELECT sections FROM tl_layout WHERE sections!=''"); while ($objLayout->next()) { $arrCustom = StringUtil::deserialize($objLayout->sections); // Add the custom layout sections if (!empty($arrCustom...
php
{ "resource": "" }
q243545
Backend.createPageList
validation
public function createPageList() { $this->import(BackendUser::class, 'User'); if ($this->User->isAdmin) { return $this->doCreatePageList(); } $return = ''; $processed = array(); foreach ($this->eliminateNestedPages($this->User->pagemounts) as $page) { $objPage = PageModel::findWithDetails($pag...
php
{ "resource": "" }
q243546
Backend.doCreatePageList
validation
protected function doCreatePageList($intId=0, $level=-1) { $objPages = $this->Database->prepare("SELECT id, title, type, dns FROM tl_page WHERE pid=? ORDER BY sorting") ->execute($intId); if ($objPages->numRows < 1) { return ''; } ++$level; $strOptions = ''; while ($objPages->next()) {...
php
{ "resource": "" }
q243547
Backend.createFileList
validation
public function createFileList($strFilter='', $filemount=false) { // Deprecated since Contao 4.0, to be removed in Contao 5.0 if ($strFilter === true) { @trigger_error('Passing "true" to Backend::createFileList() has been deprecated and will no longer work in Contao 5.0.', E_USER_DEPRECATED); $strFilter =...
php
{ "resource": "" }
q243548
Backend.doCreateFileList
validation
protected function doCreateFileList($strFolder=null, $level=-1, $strFilter='') { // Deprecated since Contao 4.0, to be removed in Contao 5.0 if ($strFilter === true) { @trigger_error('Passing "true" to Backend::doCreateFileList() has been deprecated and will no longer work in Contao 5.0.', E_USER_DEPRECATED);...
php
{ "resource": "" }
q243549
Image.setImportantPart
validation
public function setImportantPart(array $importantPart = null) { if ($importantPart !== null) { if (!isset($importantPart['x']) || !isset($importantPart['y']) || !isset($importantPart['width']) || !isset($importantPart['height'])) { throw new \InvalidArgumentException('Malformed array for setting the impo...
php
{ "resource": "" }
q243550
Image.getImportantPart
validation
public function getImportantPart() { if ($this->importantPart) { return $this->importantPart; } return array('x'=>0, 'y'=>0, 'width'=>$this->fileObj->viewWidth, 'height'=>$this->fileObj->viewHeight); }
php
{ "resource": "" }
q243551
Image.setZoomLevel
validation
public function setZoomLevel($zoomLevel) { $zoomLevel = (int) $zoomLevel; if ($zoomLevel < 0 || $zoomLevel > 100) { throw new \InvalidArgumentException('Zoom level must be between 0 and 100!'); } $this->zoomLevel = $zoomLevel; return $this; }
php
{ "resource": "" }
q243552
Image.getResizedPath
validation
public function getResizedPath() { $path = $this->resizedPath; $webDir = StringUtil::stripRootDir(System::getContainer()->getParameter('contao.web_dir')); // Strip the web/ prefix (see #337) if (strncmp($path, $webDir . '/', \strlen($webDir) + 1) === 0) { $path = substr($path, \strlen($webDir) + 1); } ...
php
{ "resource": "" }
q243553
Image.getCacheName
validation
public function getCacheName() { $importantPart = $this->getImportantPart(); $strCacheKey = substr(md5 ( '-w' . $this->getTargetWidth() . '-h' . $this->getTargetHeight() . '-o' . $this->getOriginalPath() . '-m' . $this->getResizeMode() . '-z' . $this->getZoomLevel() . '-x' . $importantPart['...
php
{ "resource": "" }
q243554
Image.executeResize
validation
public function executeResize() { $image = $this->prepareImage(); $resizeConfig = $this->prepareResizeConfig(); if (!System::getContainer()->getParameter('contao.image.bypass_cache') && $this->getTargetPath() && !$this->getForceOverride() && file_exists($this->strRootDir . '/' . $this->getTargetPath())...
php
{ "resource": "" }
q243555
Image.prepareImage
validation
protected function prepareImage() { if ($this->fileObj->isSvgImage) { $imagine = System::getContainer()->get('contao.image.imagine_svg'); } else { $imagine = System::getContainer()->get('contao.image.imagine'); } $image = new NewImage($this->strRootDir . '/' . $this->fileObj->path, $imagine, Syste...
php
{ "resource": "" }
q243556
Image.prepareImportantPart
validation
protected function prepareImportantPart() { $importantPart = $this->getImportantPart(); if (substr_count($this->resizeMode, '_') === 1) { $importantPart = array ( 'x' => 0, 'y' => 0, 'width' => $this->fileObj->viewWidth, 'height' => $this->fileObj->viewHeight, ); $mode = explode('_'...
php
{ "resource": "" }
q243557
Image.prepareResizeConfig
validation
protected function prepareResizeConfig() { $resizeConfig = new ResizeConfiguration(); $resizeConfig->setWidth($this->targetWidth); $resizeConfig->setHeight($this->targetHeight); $resizeConfig->setZoomLevel($this->zoomLevel); if (substr_count($this->resizeMode, '_') === 1) { $resizeConfig->setMode(Resiz...
php
{ "resource": "" }
q243558
Image.computeResize
validation
public function computeResize() { $resizeCoordinates = System::getContainer() ->get('contao.image.resize_calculator') ->calculate( $this->prepareResizeConfig(), new ImageDimensions( new Box($this->fileObj->viewWidth, $this->fileObj->viewHeight), $this->fileObj->viewWidth !== $this->fileObj->w...
php
{ "resource": "" }
q243559
Image.getPath
validation
public static function getPath($src) { if ($src == '') { return ''; } $src = rawurldecode($src); if (strpos($src, '/') !== false) { return $src; } $rootDir = System::getContainer()->getParameter('kernel.project_dir'); if (strncmp($src, 'icon', 4) === 0) { if (pathinfo($src, PATHINFO_EX...
php
{ "resource": "" }
q243560
Image.resize
validation
public static function resize($image, $width, $height, $mode='') { @trigger_error('Using Image::resize() has been deprecated and will no longer work in Contao 5.0. Use the contao.image.image_factory service instead.', E_USER_DEPRECATED); return static::get($image, $width, $height, $mode, $image, true) ? true : fa...
php
{ "resource": "" }
q243561
Image.create
validation
public static function create($image, $size=null) { @trigger_error('Using Image::create() has been deprecated and will no longer work in Contao 5.0. Use the contao.image.image_factory service instead.', E_USER_DEPRECATED); if (\is_string($image)) { $image = new File(rawurldecode($image)); } /** @var Ima...
php
{ "resource": "" }
q243562
Image.get
validation
public static function get($image, $width, $height, $mode='', $target=null, $force=false) { @trigger_error('Using Image::get() has been deprecated and will no longer work in Contao 5.0. Use the contao.image.image_factory service instead.', E_USER_DEPRECATED); if ($image == '') { return null; } try { ...
php
{ "resource": "" }
q243563
Image.getPixelValue
validation
public static function getPixelValue($size) { @trigger_error('Using Image::getPixelValue() has been deprecated and will no longer work in Contao 5.0.', E_USER_DEPRECATED); $value = preg_replace('/[^0-9.-]+/', '', $size); $unit = preg_replace('/[^acehimnprtvwx%]/', '', $size); // Convert 16px = 1em = 2ex = 12...
php
{ "resource": "" }
q243564
RequestToken.get
validation
public static function get() { $container = System::getContainer(); return $container->get('contao.csrf.token_manager')->getToken($container->getParameter('contao.csrf_token_name'))->getValue(); }
php
{ "resource": "" }
q243565
RequestToken.validate
validation
public static function validate($strToken) { // The feature has been disabled if (Config::get('disableRefererCheck') || \defined('BYPASS_TOKEN_CHECK')) { return true; } // Check against the whitelist (thanks to Tristan Lins) (see #3164) if (Config::get('requestTokenWhitelist')) { $strHostname = ge...
php
{ "resource": "" }
q243566
Collection.__isset
validation
public function __isset($strKey) { if ($this->intIndex < 0) { $this->first(); } return isset($this->arrModels[$this->intIndex]->$strKey); }
php
{ "resource": "" }
q243567
Collection.createFromDbResult
validation
public static function createFromDbResult(Result $objResult, $strTable) { $arrModels = array(); $strClass = Model::getClassFromTable($strTable); while ($objResult->next()) { /** @var Model $strClass */ $objModel = Registry::getInstance()->fetch($strTable, $objResult->{$strClass::getPk()}); if ($objM...
php
{ "resource": "" }
q243568
Collection.setRow
validation
public function setRow(array $arrData) { if ($this->intIndex < 0) { $this->first(); } $this->arrModels[$this->intIndex]->setRow($arrData); return $this; }
php
{ "resource": "" }
q243569
Collection.save
validation
public function save() { if ($this->intIndex < 0) { $this->first(); } $this->arrModels[$this->intIndex]->save(); return $this; }
php
{ "resource": "" }
q243570
Collection.delete
validation
public function delete() { if ($this->intIndex < 0) { $this->first(); } return $this->arrModels[$this->intIndex]->delete(); }
php
{ "resource": "" }
q243571
Collection.next
validation
public function next() { if (!isset($this->arrModels[$this->intIndex + 1])) { return false; } ++$this->intIndex; return $this; }
php
{ "resource": "" }
q243572
Collection.fetchEach
validation
public function fetchEach($strKey) { $this->reset(); $return = array(); while ($this->next()) { $strPk = $this->current()->getPk(); if ($strKey != 'id' && isset($this->$strPk)) { $return[$this->$strPk] = $this->$strKey; } else { $return[] = $this->$strKey; } } return $return...
php
{ "resource": "" }
q243573
MetaWizard.validator
validation
public function validator($varInput) { if (!\is_array($varInput)) { return null; // see #382 } foreach ($varInput as $k=>$v) { if ($k != 'language') { $varInput[$k] = array_map('trim', $v); } else { if ($v != '') { // Take the fields from the DCA (see #4327) $varInput...
php
{ "resource": "" }
q243574
BypassMaintenanceListener.onKernelRequest
validation
public function onKernelRequest(GetResponseEvent $event): void { if (!$this->tokenChecker->hasBackendUser()) { return; } $request = $event->getRequest(); $request->attributes->set($this->requestAttribute, true); }
php
{ "resource": "" }
q243575
SwitchUserListener.onSwitchUser
validation
public function onSwitchUser(SwitchUserEvent $event): void { $token = $this->tokenStorage->getToken(); if (null === $token) { throw new \RuntimeException('The token storage did not contain a token.'); } $sourceUser = $token->getUser(); if ($sourceUser instanceo...
php
{ "resource": "" }
q243576
CsrfTokenCookieListener.onKernelRequest
validation
public function onKernelRequest(GetResponseEvent $event): void { if (!$event->isMasterRequest()) { return; } $this->tokenStorage->initialize($this->getTokensFromCookies($event->getRequest()->cookies)); }
php
{ "resource": "" }
q243577
CsrfTokenCookieListener.onKernelResponse
validation
public function onKernelResponse(FilterResponseEvent $event): void { if (!$event->isMasterRequest()) { return; } $request = $event->getRequest(); $response = $event->getResponse(); $isSecure = $request->isSecure(); $basePath = $request->getBasePath() ?: '...
php
{ "resource": "" }
q243578
Installer.setLegacyOptions
validation
private function setLegacyOptions(Table $table): void { if (!$table->hasOption('engine')) { $table->addOption('engine', 'MyISAM'); } if (!$table->hasOption('charset')) { $table->addOption('charset', 'utf8'); } if (!$table->hasOption('collate')) { ...
php
{ "resource": "" }
q243579
Versions.initialize
validation
public function initialize() { if (!$GLOBALS['TL_DCA'][$this->strTable]['config']['enableVersioning']) { return; } $objVersion = $this->Database->prepare("SELECT COUNT(*) AS count FROM tl_version WHERE fromTable=? AND pid=?") ->limit(1) ->execute($this->strTable, $this->intPid); if (...
php
{ "resource": "" }
q243580
Versions.renderDropdown
validation
public function renderDropdown() { $objVersion = $this->Database->prepare("SELECT tstamp, version, username, active FROM tl_version WHERE fromTable=? AND pid=? ORDER BY version DESC") ->execute($this->strTable, $this->intPid); if ($objVersion->numRows < 2) { return ''; } $versions = ''; ...
php
{ "resource": "" }
q243581
Versions.getEditUrl
validation
protected function getEditUrl() { if ($this->strEditUrl !== null) { return sprintf($this->strEditUrl, $this->intPid); } $strUrl = Environment::get('request'); // Save the real edit URL if the visibility is toggled via Ajax if (preg_match('/&(amp;)?state=/', $strUrl)) { $strUrl = preg_replace (...
php
{ "resource": "" }
q243582
Versions.getUsername
validation
protected function getUsername() { if ($this->strUsername !== null) { return $this->strUsername; } $this->import(BackendUser::class, 'User'); return $this->User->username; }
php
{ "resource": "" }
q243583
Versions.getUserId
validation
protected function getUserId() { if ($this->intUserId !== null) { return $this->intUserId; } $this->import(BackendUser::class, 'User'); return $this->User->id; }
php
{ "resource": "" }
q243584
Versions.implodeRecursive
validation
protected function implodeRecursive($var, $binary=false) { if (!\is_array($var)) { return $binary ? StringUtil::binToUuid($var) : $var; } elseif (!\is_array(current($var))) { if ($binary) { $var = array_map(function ($v) { return $v ? StringUtil::binToUuid($v) : ''; }, $var); } return imp...
php
{ "resource": "" }
q243585
File.createIfNotExists
validation
protected function createIfNotExists() { // The file exists if (file_exists($this->strRootDir . '/' . $this->strFile)) { return; } // Handle open_basedir restrictions if (($strFolder = \dirname($this->strFile)) == '.') { $strFolder = ''; } // Create the folder if (!is_dir($this->strRootDir ...
php
{ "resource": "" }
q243586
File.truncate
validation
public function truncate() { if (\is_resource($this->resFile)) { ftruncate($this->resFile, 0); rewind($this->resFile); } return $this->write(''); }
php
{ "resource": "" }
q243587
File.close
validation
public function close() { if (\is_resource($this->resFile)) { $this->Files->fclose($this->resFile); } // Create the file path if (!file_exists($this->strRootDir . '/' . $this->strFile)) { // Handle open_basedir restrictions if (($strFolder = \dirname($this->strFile)) == '.') { $strFolder =...
php
{ "resource": "" }
q243588
File.getContent
validation
public function getContent() { $strContent = file_get_contents($this->strRootDir . '/' . ($this->strTmp ?: $this->strFile)); // Remove BOMs (see #4469) if (strncmp($strContent, "\xEF\xBB\xBF", 3) === 0) { $strContent = substr($strContent, 3); } elseif (strncmp($strContent, "\xFF\xFE", 2) === 0) { ...
php
{ "resource": "" }
q243589
File.putContent
validation
public static function putContent($strFile, $strContent) { $objFile = new static($strFile); $objFile->write($strContent); $objFile->close(); }
php
{ "resource": "" }
q243590
File.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 Folder($strParent); } $return = $this->Files->rename($this->strFile, $strNewName); // Update the database AFTER the f...
php
{ "resource": "" }
q243591
File.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 Folder($strParent); } $return = $this->Files->copy($this->strFile, $strNewName); // Update the database AFTER the file ...
php
{ "resource": "" }
q243592
File.resizeTo
validation
public function resizeTo($width, $height, $mode='') { if (!$this->isImage) { return false; } $return = System::getContainer() ->get('contao.image.image_factory') ->create($this->strRootDir . '/' . $this->strFile, array($width, $height, $mode), $this->strRootDir . '/' . $this->strFile) ->getUrl($th...
php
{ "resource": "" }
q243593
File.sendToBrowser
validation
public function sendToBrowser($filename='', $inline=false) { $response = new BinaryFileResponse($this->strRootDir . '/' . $this->strFile); $response->setContentDisposition ( $inline ? ResponseHeaderBag::DISPOSITION_INLINE : ResponseHeaderBag::DISPOSITION_ATTACHMENT, $filename, Utf8::toAscii($this->base...
php
{ "resource": "" }
q243594
File.fputs
validation
protected function fputs($varData, $strMode) { if (!\is_resource($this->resFile)) { $this->strTmp = 'system/tmp/' . md5(uniqid(mt_rand(), true)); // Copy the contents of the original file to append data if (strncmp($strMode, 'a', 1) === 0 && file_exists($this->strRootDir . '/' . $this->strFile)) { ...
php
{ "resource": "" }
q243595
PageLogout.getResponse
validation
public function getResponse($objPage) { // Set last page visited if ($objPage->redirectBack) { $_SESSION['LAST_PAGE_VISITED'] = $this->getReferer(); } $strLogoutUrl = System::getContainer()->get('security.logout_url_generator')->getLogoutUrl(); $strRedirect = Environment::get('base'); // Redirect to...
php
{ "resource": "" }
q243596
TokenChecker.hasFrontendUser
validation
public function hasFrontendUser(): bool { $token = $this->getToken(FrontendUser::SECURITY_SESSION_KEY); return null !== $token && $token->getUser() instanceof FrontendUser; }
php
{ "resource": "" }
q243597
TokenChecker.hasBackendUser
validation
public function hasBackendUser(): bool { $token = $this->getToken(BackendUser::SECURITY_SESSION_KEY); return null !== $token && $token->getUser() instanceof BackendUser; }
php
{ "resource": "" }
q243598
TokenChecker.getFrontendUsername
validation
public function getFrontendUsername(): ?string { $token = $this->getToken(FrontendUser::SECURITY_SESSION_KEY); if (null === $token || !$token->getUser() instanceof FrontendUser) { return null; } return $token->getUser()->getUsername(); }
php
{ "resource": "" }
q243599
TokenChecker.getBackendUsername
validation
public function getBackendUsername(): ?string { $token = $this->getToken(BackendUser::SECURITY_SESSION_KEY); if (null === $token || !$token->getUser() instanceof BackendUser) { return null; } return $token->getUser()->getUsername(); }
php
{ "resource": "" }