_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q243000
System.getSessionHash
validation
public static function getSessionHash($strCookie) { @trigger_error('Using System::getSessionHash() has been deprecated and will no longer work in Contao 5.0. Use Symfony authentication instead.', E_USER_DEPRECATED); $session = static::getContainer()->get('session'); if (!$session->isStarted()) { $session-...
php
{ "resource": "" }
q243001
System.anonymizeIp
validation
public static function anonymizeIp($strIp) { // Localhost if ($strIp == '127.0.0.1' || $strIp == '::1') { return $strIp; } // IPv6 if (strpos($strIp, ':') !== false) { return substr_replace($strIp, ':0000', strrpos($strIp, ':')); } // IPv4 else { return substr_replace($strIp, '.0', strr...
php
{ "resource": "" }
q243002
System.readPhpFileWithoutTags
validation
protected static function readPhpFileWithoutTags($strName) { @trigger_error('Using System::readPhpFileWithoutTags() has been deprecated and will no longer work in Contao 5.0. Use the Contao\CoreBundle\Config\Loader\PhpFileLoader instead.', E_USER_DEPRECATED); $rootDir = self::getContainer()->getParameter('kernel....
php
{ "resource": "" }
q243003
System.convertXlfToPhp
validation
public static function convertXlfToPhp($strName, $strLanguage, $blnLoad=false) { @trigger_error('Using System::convertXlfToPhp() has been deprecated and will no longer work in Contao 5.0. Use the Contao\CoreBundle\Config\Loader\XliffFileLoader instead.', E_USER_DEPRECATED); $rootDir = self::getContainer()->getPar...
php
{ "resource": "" }
q243004
CommandSchedulerListener.onKernelTerminate
validation
public function onKernelTerminate(PostResponseEvent $event): void { if (!$this->framework->isInitialized() || !$this->canRunController($event->getRequest())) { return; } /** @var FrontendCron $controller */ $controller = $this->framework->createInstance(FrontendCron::cla...
php
{ "resource": "" }
q243005
CommandSchedulerListener.canRunDbQuery
validation
private function canRunDbQuery(): bool { try { return $this->connection->isConnected() && $this->connection->getSchemaManager()->tablesExist(['tl_cron']); } catch (DriverException $e) { return false; } }
php
{ "resource": "" }
q243006
tl_log.colorize
validation
public function colorize($row, $label) { switch ($row['action']) { case 'CONFIGURATION': case 'REPOSITORY': $label = preg_replace('@^(.*</span> )(.*)$@U', '$1 <span class="tl_blue">$2</span>', $label); break; case 'CRON': $label = preg_replace('@^(.*</span> )(.*)$@U', '$1 <span class="tl_gree...
php
{ "resource": "" }
q243007
StoreRefererListener.onKernelResponse
validation
public function onKernelResponse(FilterResponseEvent $event): void { if (!$this->scopeMatcher->isContaoMasterRequest($event)) { return; } $request = $event->getRequest(); if (!$request->isMethod(Request::METHOD_GET)) { return; } $response = ...
php
{ "resource": "" }
q243008
StoreRefererListener.getRelativeRequestUri
validation
private function getRelativeRequestUri(Request $request): string { return (string) substr($request->getRequestUri(), \strlen($request->getBasePath()) + 1); }
php
{ "resource": "" }
q243009
tl_news.listNewsArticles
validation
public function listNewsArticles($arrRow) { return '<div class="tl_content_left">' . $arrRow['headline'] . ' <span style="color:#999;padding-left:3px">[' . Contao\Date::parse(Contao\Config::get('datimFormat'), $arrRow['date']) . ']</span></div>'; }
php
{ "resource": "" }
q243010
Widget.__isset
validation
public function __isset($strKey) { switch ($strKey) { case 'id': return isset($this->strId); break; case 'name': return isset($this->strName); break; case 'label': return isset($this->strLabel); break; case 'value': return isset($this->varValue); break; case 'clas...
php
{ "resource": "" }
q243011
Widget.getErrorsAsString
validation
public function getErrorsAsString($strSeparator=null) { if ($strSeparator === null) { $strSeparator = '<br' . $this->strTagEnding . "\n"; } return $this->hasErrors() ? implode($strSeparator, $this->arrErrors) : ''; }
php
{ "resource": "" }
q243012
Widget.generateWithError
validation
public function generateWithError($blnSwitchOrder=false) { $strWidget = $this->generate(); $strError = $this->getErrorAsHTML(); return $blnSwitchOrder ? $strWidget . $strError : $strError . $strWidget; }
php
{ "resource": "" }
q243013
Widget.getAttribute
validation
public function getAttribute($strKey) { if (!isset($this->arrAttributes[$strKey])) { return ''; } $varValue = $this->arrAttributes[$strKey]; // Prevent the autofocus attribute from being added multiple times (see #8281) if ($strKey == 'autofocus') { unset($this->arrAttributes[$strKey]); } if...
php
{ "resource": "" }
q243014
Widget.validate
validation
public function validate() { $varValue = $this->validator($this->getPost($this->strName)); if ($this->hasErrors()) { $this->class = 'error'; } $this->varValue = $varValue; }
php
{ "resource": "" }
q243015
Widget.addAttributes
validation
public function addAttributes($arrAttributes) { if (!\is_array($arrAttributes)) { return; } foreach ($arrAttributes as $k=>$v) { $this->$k = $v; } }
php
{ "resource": "" }
q243016
Widget.isChecked
validation
protected function isChecked($arrOption) { if (empty($this->varValue) && empty($_POST) && $arrOption['default']) { return static::optionChecked(1, 1); } return static::optionChecked($arrOption['value'], $this->varValue); }
php
{ "resource": "" }
q243017
Widget.isSelected
validation
protected function isSelected($arrOption) { if (empty($this->varValue) && empty($_POST) && $arrOption['default']) { return static::optionSelected(1, 1); } return static::optionSelected($arrOption['value'], $this->varValue); }
php
{ "resource": "" }
q243018
Widget.optionSelected
validation
public static function optionSelected($strOption, $varValues) { if ($strOption === '') { return ''; } return (\is_array($varValues) ? \in_array($strOption, $varValues) : $strOption == $varValues) ? ' selected' : ''; }
php
{ "resource": "" }
q243019
Widget.optionChecked
validation
public static function optionChecked($strOption, $varValues) { if ($strOption === '') { return ''; } return (\is_array($varValues) ? \in_array($strOption, $varValues) : $strOption == $varValues) ? ' checked' : ''; }
php
{ "resource": "" }
q243020
Widget.getEmptyStringOrNull
validation
public function getEmptyStringOrNull() { if (!isset($GLOBALS['TL_DCA'][$this->strTable]['fields'][$this->strField]['sql'])) { return ''; } return static::getEmptyStringOrNullByFieldType($GLOBALS['TL_DCA'][$this->strTable]['fields'][$this->strField]['sql']); }
php
{ "resource": "" }
q243021
ModuleCalendar.generate
validation
public function generate() { if (TL_MODE == 'BE') { $objTemplate = new BackendTemplate('be_wildcard'); $objTemplate->wildcard = '### ' . Utf8::strtoupper($GLOBALS['TL_LANG']['FMD']['calendar'][0]) . ' ###'; $objTemplate->title = $this->headline; $objTemplate->id = $this->id; $objTemplate->link = $th...
php
{ "resource": "" }
q243022
Validator.isInsecurePath
validation
public static function isInsecurePath($strPath) { // Normalize backslashes $strPath = strtr($strPath, '\\', '/'); $strPath = preg_replace('#//+#', '/', $strPath); // Equals .. if ($strPath == '..') { return true; } // Begins with ./ if (substr($strPath, 0, 2) == './') { return true; } ...
php
{ "resource": "" }
q243023
Validator.isValidFileName
validation
public static function isValidFileName($strName) { if ($strName == '') { return false; } // Special characters not supported on e.g. Windows if (preg_match('@[\\\\/:*?"<>|]@', $strName)) { return false; } // Invisible control characters or unused code points if (preg_match('/[\pC]/u', $strNam...
php
{ "resource": "" }
q243024
ModuleNewsList.countItems
validation
protected function countItems($newsArchives, $blnFeatured) { // HOOK: add custom logic if (isset($GLOBALS['TL_HOOKS']['newsListCountItems']) && \is_array($GLOBALS['TL_HOOKS']['newsListCountItems'])) { foreach ($GLOBALS['TL_HOOKS']['newsListCountItems'] as $callback) { if (($intResult = System::importSt...
php
{ "resource": "" }
q243025
ModuleNewsList.fetchItems
validation
protected function fetchItems($newsArchives, $blnFeatured, $limit, $offset) { // HOOK: add custom logic if (isset($GLOBALS['TL_HOOKS']['newsListFetchItems']) && \is_array($GLOBALS['TL_HOOKS']['newsListFetchItems'])) { foreach ($GLOBALS['TL_HOOKS']['newsListFetchItems'] as $callback) { if (($objCollecti...
php
{ "resource": "" }
q243026
ContaoCache.isRequestPrivate
validation
private function isRequestPrivate(Request $request): bool { if ($request->headers->has('Authorization')) { return true; } if (\count($request->cookies->all())) { return true; } return false; }
php
{ "resource": "" }
q243027
tl_article.generateAlias
validation
public function generateAlias($varValue, Contao\DataContainer $dc) { $aliasExists = function (string $alias) use ($dc): bool { if (\in_array($alias, array('top', 'wrapper', 'header', 'container', 'main', 'left', 'right', 'footer'), true)) { return true; } return $this->Database->prepare("SELECT id...
php
{ "resource": "" }
q243028
tl_article.getActiveLayoutSections
validation
public function getActiveLayoutSections(Contao\DataContainer $dc) { // Show only active sections if ($dc->activeRecord->pid) { $arrSections = array(); $objPage = Contao\PageModel::findWithDetails($dc->activeRecord->pid); // Get the layout sections if ($objPage->layout) { $objLayout = Contao\L...
php
{ "resource": "" }
q243029
tl_article.editArticle
validation
public function editArticle($row, $href, $label, $title, $icon, $attributes) { $objPage = Contao\PageModel::findById($row['pid']); return $this->User->isAllowed(Contao\BackendUser::CAN_EDIT_ARTICLES, $objPage->row()) ? '<a href="'.$this->addToUrl($href.'&amp;id='.$row['id']).'" title="'.Contao\StringUtil::special...
php
{ "resource": "" }
q243030
tl_article.pasteArticle
validation
public function pasteArticle(Contao\DataContainer $dc, $row, $table, $cr, $arrClipboard=null) { $imagePasteAfter = Contao\Image::getHtml('pasteafter.svg', sprintf($GLOBALS['TL_LANG'][$dc->table]['pasteafter'][1], $row['id'])); $imagePasteInto = Contao\Image::getHtml('pasteinto.svg', sprintf($GLOBALS['TL_LANG'][$dc...
php
{ "resource": "" }
q243031
UrlGenerator.prepareAlias
validation
private function prepareAlias(string $alias, array &$parameters): void { if ('index' === $alias) { return; } $hasAutoItem = false; $autoItems = $this->getAutoItems($parameters); /** @var Config $config */ $config = $this->framework->getAdapter(Config::cl...
php
{ "resource": "" }
q243032
UrlGenerator.prepareDomain
validation
private function prepareDomain(RequestContext $context, array &$parameters, int &$referenceType): void { if (isset($parameters['_ssl'])) { $context->setScheme(true === $parameters['_ssl'] ? 'https' : 'http'); } if (isset($parameters['_domain']) && '' !== $parameters['_domain']) ...
php
{ "resource": "" }
q243033
UrlGenerator.addHostToContext
validation
private function addHostToContext(RequestContext $context, array $parameters, int &$referenceType): void { [$host, $port] = $this->getHostAndPort($parameters['_domain']); if ($context->getHost() === $host) { return; } $context->setHost($host); $referenceType = U...
php
{ "resource": "" }
q243034
UrlGenerator.getHostAndPort
validation
private function getHostAndPort(string $domain): array { if (false !== strpos($domain, ':')) { return explode(':', $domain, 2); } return [$domain, null]; }
php
{ "resource": "" }
q243035
UrlGenerator.getAutoItems
validation
private function getAutoItems(array $parameters): array { if (isset($parameters['auto_item'])) { return [$parameters['auto_item']]; } if (isset($GLOBALS['TL_AUTO_ITEM']) && \is_array($GLOBALS['TL_AUTO_ITEM'])) { return $GLOBALS['TL_AUTO_ITEM']; } ret...
php
{ "resource": "" }
q243036
FrontendLoader.addFrontendRoute
validation
private function addFrontendRoute(RouteCollection $routes, array $defaults): void { $route = new Route('/{alias}'.$this->urlSuffix, $defaults, ['alias' => '.+']); $this->addLocaleToRoute($route); $routes->add('contao_frontend', $route); }
php
{ "resource": "" }
q243037
FrontendLoader.addIndexRoute
validation
private function addIndexRoute(RouteCollection $routes, array $defaults): void { $route = new Route('/', $defaults); $this->addLocaleToRoute($route); $routes->add('contao_index', $route); }
php
{ "resource": "" }
q243038
FrontendLoader.addLocaleToRoute
validation
private function addLocaleToRoute(Route $route): void { if (!$this->prependLocale) { return; } $route->setPath('/{_locale}'.$route->getPath()); $route->addRequirements(['_locale' => '[a-z]{2}(\-[A-Z]{2})?']); }
php
{ "resource": "" }
q243039
ContentElement.findClass
validation
public static function findClass($strName) { foreach ($GLOBALS['TL_CTE'] as $v) { foreach ($v as $kk=>$vv) { if ($kk == $strName) { return $vv; } } } return ''; }
php
{ "resource": "" }
q243040
DataContainer.help
validation
public function help($strClass='') { $return = $GLOBALS['TL_DCA'][$this->strTable]['fields'][$this->strField]['label'][1]; if (!Config::get('showHelp') || $GLOBALS['TL_DCA'][$this->strTable]['fields'][$this->strField]['inputType'] == 'password' || $return == '') { return ''; } return ' <p class="tl_he...
php
{ "resource": "" }
q243041
DataContainer.combiner
validation
protected function combiner($names) { $return = array(''); $names = array_values($names); for ($i=0, $c=\count($names); $i<$c; $i++) { $buffer = array(); foreach ($return as $k=>$v) { $buffer[] = ($k%2 == 0) ? $v : $v.$names[$i]; $buffer[] = ($k%2 == 0) ? $v.$names[$i] : $v; } $return...
php
{ "resource": "" }
q243042
DataContainer.switchToEdit
validation
protected function switchToEdit($id) { $arrKeys = array(); $arrUnset = array('act', 'id', 'table'); foreach (array_keys($_GET) as $strKey) { if (!\in_array($strKey, $arrUnset)) { $arrKeys[$strKey] = $strKey . '=' . Input::get($strKey); } } $strUrl = TL_SCRIPT . '?' . implode('&', $arrKeys); ...
php
{ "resource": "" }
q243043
DataContainer.initPicker
validation
public function initPicker(PickerInterface $picker) { if (!empty($_GET['act'])) { return null; } $provider = $picker->getCurrentProvider(); if (!$provider instanceof DcaPickerProviderInterface || $provider->getDcaTable() != $this->strTable) { return null; } $attributes = $provider->getDcaAttri...
php
{ "resource": "" }
q243044
DataContainer.getPickerInputField
validation
protected function getPickerInputField($value, $attributes='') { $id = is_numeric($value) ? $value : md5($value); switch ($this->strPickerFieldType) { case 'checkbox': return ' <input type="checkbox" name="picker[]" id="picker_'.$id.'" class="tl_tree_checkbox" value="'.StringUtil::specialchars(\call_user...
php
{ "resource": "" }
q243045
DataContainer.invalidateCacheTags
validation
protected function invalidateCacheTags(self $dc) { if (!System::getContainer()->has('fos_http_cache.cache_manager')) { return; } $ns = 'contao.db.'; $tags = array($ns . $dc->table, $ns . $dc->table . '.' . $dc->id); if ($dc->ptable && $dc->activeRecord && $dc->activeRecord->pid > 0) { $tags[] = $...
php
{ "resource": "" }
q243046
tl_member.getActiveGroups
validation
public function getActiveGroups() { $arrGroups = array(); $objGroup = Contao\MemberGroupModel::findAllActive(); if ($objGroup !== null) { while ($objGroup->next()) { $arrGroups[$objGroup->id] = $objGroup->name; } } return $arrGroups; }
php
{ "resource": "" }
q243047
tl_member.setNewPassword
validation
public function setNewPassword($strPassword, $user) { // Return if there is no user (e.g. upon registration) if (!$user) { return $strPassword; } $objUser = $this->Database->prepare("SELECT * FROM tl_member WHERE id=?") ->limit(1) ->execute($user->id); // HOOK: set new password cal...
php
{ "resource": "" }
q243048
tl_member.storeDateAdded
validation
public function storeDateAdded($dc) { // Front end call if (!$dc instanceof Contao\DataContainer) { return; } // Return if there is no active record (override all) if (!$dc->activeRecord || $dc->activeRecord->dateAdded > 0) { return; } // Fallback solution for existing accounts if ($dc->act...
php
{ "resource": "" }
q243049
tl_content.getContentElements
validation
public function getContentElements() { $groups = array(); foreach ($GLOBALS['TL_CTE'] as $k=>$v) { foreach (array_keys($v) as $kk) { $groups[$k][] = $kk; } } return $groups; }
php
{ "resource": "" }
q243050
tl_content.getContentElementGroup
validation
public function getContentElementGroup($element) { foreach ($GLOBALS['TL_CTE'] as $k=>$v) { foreach (array_keys($v) as $kk) { if ($kk == $element) { return $k; } } } return null; }
php
{ "resource": "" }
q243051
tl_content.adjustDcaByType
validation
public function adjustDcaByType($dc) { $objCte = Contao\ContentModel::findByPk($dc->id); if ($objCte === null) { return; } switch ($objCte->type) { case 'hyperlink': unset($GLOBALS['TL_DCA']['tl_content']['fields']['imageUrl']); break; case 'image': $GLOBALS['TL_DCA']['tl_content'][...
php
{ "resource": "" }
q243052
tl_content.addCteType
validation
public function addCteType($arrRow) { $key = $arrRow['invisible'] ? 'unpublished' : 'published'; $type = $GLOBALS['TL_LANG']['CTE'][$arrRow['type']][0] ?: '&nbsp;'; $class = 'limit_height'; // Remove the class if it is a wrapper element if (\in_array($arrRow['type'], $GLOBALS['TL_WRAPPERS']['start']) || \in...
php
{ "resource": "" }
q243053
tl_content.getForms
validation
public function getForms() { if (!$this->User->isAdmin && !\is_array($this->User->forms)) { return array(); } $arrForms = array(); $objForms = $this->Database->execute("SELECT id, title FROM tl_form ORDER BY title"); while ($objForms->next()) { if ($this->User->hasAccess($objForms->id, 'forms')) ...
php
{ "resource": "" }
q243054
tl_content.setRteSyntax
validation
public function setRteSyntax($varValue, Contao\DataContainer $dc) { switch ($dc->activeRecord->highlight) { case 'C': case 'CSharp': $syntax = 'c_cpp'; break; case 'CSS': case 'Diff': case 'Groovy': case 'HTML': case 'Java': case 'JavaScript': case 'Perl': case 'PHP': case...
php
{ "resource": "" }
q243055
tl_content.listImportWizard
validation
public function listImportWizard() { return ' <a href="' . $this->addToUrl('key=list') . '" title="' . Contao\StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['lw_import'][1]) . '" onclick="Backend.getScrollOffset()">' . Contao\Image::getHtml('tablewizard.svg', $GLOBALS['TL_LANG']['MSC']['tw_import'][0]) . '</a>'...
php
{ "resource": "" }
q243056
tl_content.tableImportWizard
validation
public function tableImportWizard() { return ' <a href="' . $this->addToUrl('key=table') . '" title="' . Contao\StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['tw_import'][1]) . '" onclick="Backend.getScrollOffset()">' . Contao\Image::getHtml('tablewizard.svg', $GLOBALS['TL_LANG']['MSC']['tw_import'][0]) . '</a...
php
{ "resource": "" }
q243057
tl_content.pagePicker
validation
public function pagePicker(Contao\DataContainer $dc) { @trigger_error('Using tl_content::pagePicker() has been deprecated and will no longer work in Contao 5.0. Set the "dcaPicker" eval attribute instead.', E_USER_DEPRECATED); return Contao\Backend::getDcaPickerWizard(true, $dc->table, $dc->field, $dc->inputName)...
php
{ "resource": "" }
q243058
tl_content.deleteElement
validation
public function deleteElement($row, $href, $label, $title, $icon, $attributes) { $objElement = $this->Database->prepare("SELECT id FROM tl_content WHERE cteAlias=? AND type='alias'") ->limit(1) ->execute($row['id']); return $objElement->numRows ? Contao\Image::getHtml(preg_replace('/\.svg$/i',...
php
{ "resource": "" }
q243059
tl_content.setSingleSrcFlags
validation
public function setSingleSrcFlags($varValue, Contao\DataContainer $dc) { if ($dc->activeRecord) { switch ($dc->activeRecord->type) { case 'text': case 'hyperlink': case 'image': case 'accordionSingle': $GLOBALS['TL_DCA'][$dc->table]['fields'][$dc->field]['eval']['extensions'] = Contao\Co...
php
{ "resource": "" }
q243060
tl_content.extractYouTubeId
validation
public function extractYouTubeId($varValue, Contao\DataContainer $dc) { if ($dc->activeRecord->youtube != $varValue) { $matches = array(); if (preg_match('%(?:youtube(?:-nocookie)?\.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?)/|.*[?&]v=)|youtu\.be/)([^"&?/ ]{11})%i', $varValue, $matches)) { $varValue = $matches...
php
{ "resource": "" }
q243061
tl_content.extractVimeoId
validation
public function extractVimeoId($varValue, Contao\DataContainer $dc) { if ($dc->activeRecord->vimeo != $varValue) { $matches = array(); if (preg_match('%vimeo\.com/(?:channels/(?:\w+/)?|groups/(?:[^/]+)/videos/|album/(?:\d+)/video/)?(\d+)(?:$|/|\?)%i', $varValue, $matches)) { $varValue = $matches[1]; ...
php
{ "resource": "" }
q243062
ModuleQuicknav.getQuicknavPages
validation
protected function getQuicknavPages($pid, $level=1, $host=null) { /** @var PageModel $objPage */ global $objPage; $groups = array(); $arrPages = array(); // Get all groups of the current front end user if (FE_USER_LOGGED_IN) { $this->import(FrontendUser::class, 'User'); $groups = $this->User->gro...
php
{ "resource": "" }
q243063
tl_image_size.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 the image sizes if (empty($this->User->imageSizes) || !\is_array($this->User->im...
php
{ "resource": "" }
q243064
tl_image_size.listImageSize
validation
public function listImageSize($row) { $html = '<div class="tl_content_left">'; $html .= $row['name']; if ($row['width'] || $row['height']) { $html .= ' <span style="color:#999;padding-left:3px">' . $row['width'] . 'x' . $row['height'] . '</span>'; } if ($row['zoom']) { $html .= ' <span style="col...
php
{ "resource": "" }
q243065
Model.originalRow
validation
public function originalRow() { $row = $this->row(); if (!$this->isModified()) { return $row; } $originalRow = array(); foreach ($row as $k=>$v) { $originalRow[$k] = $this->arrModified[$k] ?? $v; } return $originalRow; }
php
{ "resource": "" }
q243066
Model.setRow
validation
public function setRow(array $arrData) { foreach ($arrData as $k=>$v) { if (strpos($k, '__') !== false) { unset($arrData[$k]); } } $this->arrData = $arrData; return $this; }
php
{ "resource": "" }
q243067
Model.mergeRow
validation
public function mergeRow(array $arrData) { foreach ($arrData as $k=>$v) { if (strpos($k, '__') !== false) { continue; } if (!isset($this->arrModified[$k])) { $this->arrData[$k] = $v; } } return $this; }
php
{ "resource": "" }
q243068
Model.markModified
validation
public function markModified($strKey) { if (!isset($this->arrModified[$strKey])) { $this->arrModified[$strKey] = $this->arrData[$strKey] ?? null; } }
php
{ "resource": "" }
q243069
Model.save
validation
public function save() { // Deprecated call if (\count(\func_get_args())) { throw new \InvalidArgumentException('The $blnForceInsert argument has been removed (see system/docs/UPGRADE.md)'); } // The instance cannot be saved if ($this->blnPreventSaving) { throw new \RuntimeException('The model ins...
php
{ "resource": "" }
q243070
Model.delete
validation
public function delete() { $intPk = $this->{static::$strPk}; // Track primary key changes if (isset($this->arrModified[static::$strPk])) { $intPk = $this->arrModified[static::$strPk]; } // Delete the row $intAffected = Database::getInstance()->prepare("DELETE FROM " . static::$strTable . " WHERE " ....
php
{ "resource": "" }
q243071
Model.refresh
validation
public function refresh() { $intPk = $this->{static::$strPk}; // Track primary key changes if (isset($this->arrModified[static::$strPk])) { $intPk = $this->arrModified[static::$strPk]; } // Reload the database record $res = Database::getInstance()->prepare("SELECT * FROM " . static::$strTable . " WH...
php
{ "resource": "" }
q243072
Model.detach
validation
public function detach($blnKeepClone=true) { $registry = Registry::getInstance(); if (!$registry->isRegistered($this)) { return; } $registry->unregister($this); if ($blnKeepClone) { $this->cloneOriginal()->attach(); } }
php
{ "resource": "" }
q243073
Model.onRegister
validation
public function onRegister(Registry $registry) { // Register aliases to unique fields foreach (static::getUniqueFields() as $strColumn) { $varAliasValue = $this->{$strColumn}; if (!$registry->isRegisteredAlias($this, $strColumn, $varAliasValue)) { $registry->registerAlias($this, $strColumn, $varAli...
php
{ "resource": "" }
q243074
Model.onUnregister
validation
public function onUnregister(Registry $registry) { // Unregister aliases to unique fields foreach (static::getUniqueFields() as $strColumn) { $varAliasValue = $this->{$strColumn}; if ($registry->isRegisteredAlias($this, $strColumn, $varAliasValue)) { $registry->unregisterAlias($this, $strColumn, $v...
php
{ "resource": "" }
q243075
Model.findByPk
validation
public static function findByPk($varValue, array $arrOptions=array()) { // Try to load from the registry if (empty($arrOptions)) { $objModel = Registry::getInstance()->fetch(static::$strTable, $varValue); if ($objModel !== null) { return $objModel; } } $arrOptions = array_merge ( array...
php
{ "resource": "" }
q243076
Model.findByIdOrAlias
validation
public static function findByIdOrAlias($varId, array $arrOptions=array()) { $isAlias = !preg_match('/^[1-9]\d*$/', $varId); // Try to load from the registry if (!$isAlias && empty($arrOptions)) { $objModel = Registry::getInstance()->fetch(static::$strTable, $varId); if ($objModel !== null) { ret...
php
{ "resource": "" }
q243077
Model.findMultipleByIds
validation
public static function findMultipleByIds($arrIds, array $arrOptions=array()) { if (empty($arrIds) || !\is_array($arrIds)) { return null; } $arrRegistered = array(); $arrUnregistered = array(); // Search for registered models foreach ($arrIds as $intId) { if (empty($arrOptions)) { $arrReg...
php
{ "resource": "" }
q243078
Model.findOneBy
validation
public static function findOneBy($strColumn, $varValue, array $arrOptions=array()) { $arrOptions = array_merge ( array ( 'limit' => 1, 'column' => $strColumn, 'value' => $varValue, 'return' => 'Model' ), $arrOptions ); return static::find($arrOptions); }
php
{ "resource": "" }
q243079
Model.findBy
validation
public static function findBy($strColumn, $varValue, array $arrOptions=array()) { $blnModel = false; $arrColumn = (array) $strColumn; if (\count($arrColumn) == 1 && ($arrColumn[0] === static::getPk() || \in_array($arrColumn[0], static::getUniqueFields()))) { $blnModel = true; } $arrOptions = array_mer...
php
{ "resource": "" }
q243080
Model.find
validation
protected static function find(array $arrOptions) { if (static::$strTable == '') { return null; } // Try to load from the registry if ($arrOptions['return'] == 'Model') { $arrColumn = (array) $arrOptions['column']; if (\count($arrColumn) == 1) { // Support table prefixes $arrColumn[0]...
php
{ "resource": "" }
q243081
Model.countBy
validation
public static function countBy($strColumn=null, $varValue=null, array $arrOptions=array()) { if (static::$strTable == '') { return 0; } $arrOptions = array_merge ( array ( 'table' => static::$strTable, 'column' => $strColumn, 'value' => $varValue ), $arrOptions ); $strQuer...
php
{ "resource": "" }
q243082
SqlFileParser.parse
validation
public static function parse($file) { if (!file_exists($file)) { throw new \InvalidArgumentException('Invalid file ' . $file); } $table = ''; $return = array(); $data = file($file); foreach ($data as $k=>$v) { $key_name = array(); $subpatterns = array(); // Unset comments and empty line...
php
{ "resource": "" }
q243083
RegisterFragmentsPass.process
validation
public function process(ContainerBuilder $container): void { if (!$container->has('contao.fragment.registry')) { return; } $this->registerFragments($container, ContentElementReference::TAG_NAME); $this->registerFragments($container, FrontendModuleReference::TAG_NAME); ...
php
{ "resource": "" }
q243084
RegisterFragmentsPass.getControllerName
validation
protected function getControllerName(Reference $reference, array $attributes): string { $controller = (string) $reference; // Support a specific method on the controller if (isset($attributes['method'])) { $controller .= ':'.$attributes['method']; } return $cont...
php
{ "resource": "" }
q243085
Calendar.generateFeedsByCalendar
validation
public function generateFeedsByCalendar($intId) { $objFeed = CalendarFeedModel::findByCalendar($intId); if ($objFeed !== null) { while ($objFeed->next()) { $objFeed->feedName = $objFeed->alias ?: 'calendar' . $objFeed->id; // Update the XML file $this->generateFiles($objFeed->row()); $thi...
php
{ "resource": "" }
q243086
Calendar.getSearchablePages
validation
public function getSearchablePages($arrPages, $intRoot=0, $blnIsSitemap=false) { $arrRoot = array(); if ($intRoot > 0) { $arrRoot = $this->Database->getChildRecords($intRoot, 'tl_page'); } $arrProcessed = array(); $time = Date::floorToMinute(); // Get all calendars $objCalendar = CalendarModel::f...
php
{ "resource": "" }
q243087
Calendar.unixToJd
validation
public static function unixToJd($tstamp) { list($year, $month, $day) = explode(',', date('Y,m,d', $tstamp)); // Make year a positive number $year += ($year < 0 ? 4801 : 4800); // Adjust the start of the year if ($month > 2) { $month -= 3; } else { $month += 9; --$year; } $sdn = floor...
php
{ "resource": "" }
q243088
ModuleNews.parseArticles
validation
protected function parseArticles($objArticles, $blnAddArchive=false) { $limit = $objArticles->count(); if ($limit < 1) { return array(); } $count = 0; $arrArticles = array(); while ($objArticles->next()) { /** @var NewsModel $objArticle */ $objArticle = $objArticles->current(); $arrArti...
php
{ "resource": "" }
q243089
ModuleNews.getMetaFields
validation
protected function getMetaFields($objArticle) { $meta = StringUtil::deserialize($this->news_metaFields); if (!\is_array($meta)) { return array(); } /** @var PageModel $objPage */ global $objPage; $return = array(); foreach ($meta as $field) { switch ($field) { case 'date': $retu...
php
{ "resource": "" }
q243090
ModuleNews.generateLink
validation
protected function generateLink($strLink, $objArticle, $blnAddArchive=false, $blnIsReadMore=false) { // Internal link if ($objArticle->source != 'external') { return sprintf('<a href="%s" title="%s" itemprop="url"><span itemprop="headline">%s</span>%s</a>', News::generateNewsUrl($objArticle, $blnAddArc...
php
{ "resource": "" }
q243091
FragmentHandler.preHandleFragment
validation
private function preHandleFragment(FragmentReference $uri, FragmentConfig $config): void { if (!isset($uri->attributes['pageModel']) && $this->hasGlobalPageObject()) { $uri->attributes['pageModel'] = $GLOBALS['objPage']->id; } if ($this->preHandlers->has($uri->controller)) { ...
php
{ "resource": "" }
q243092
PageRoot.generate
validation
public function generate($rootPageId, $blnReturn=false, $blnPreferAlias=false) { if (!$blnReturn) { $this->redirect($this->getRedirectUrl($rootPageId), 302); } $objNextPage = $this->getNextPage($rootPageId); return ($blnPreferAlias && $objNextPage->alias != '') ? $objNextPage->alias : $objNextPage->id; ...
php
{ "resource": "" }
q243093
PageRoot.getNextPage
validation
protected function getNextPage($rootPageId) { $objNextPage = PageModel::findFirstPublishedByPid($rootPageId); // No published pages yet if (null === $objNextPage) { $this->log('No active page found under root page "' . $rootPageId . '")', __METHOD__, TL_ERROR); throw new NoActivePageFoundException('No a...
php
{ "resource": "" }
q243094
TranslationListener.onReplaceInsertTags
validation
public function onReplaceInsertTags(string $tag) { $chunks = explode('::', $tag); if ('trans' !== $chunks[0]) { return false; } $parameters = isset($chunks[3]) ? explode(':', $chunks[3]) : []; return $this->translator->trans($chunks[1], $parameters, $chunks[2] ...
php
{ "resource": "" }
q243095
CalendarEventsModel.findCurrentByPid
validation
public static function findCurrentByPid($intPid, $intStart, $intEnd, array $arrOptions=array()) { $t = static::$strTable; $intStart = (int) $intStart; $intEnd = (int) $intEnd; $arrColumns = array("$t.pid=? AND (($t.startTime>=$intStart AND $t.startTime<=$intEnd) OR ($t.endTime>=$intStart AND $t.endTime<=$intE...
php
{ "resource": "" }
q243096
CalendarEventsModel.findUpcomingByPids
validation
public static function findUpcomingByPids($arrIds, $intLimit=0, array $arrOptions=array()) { if (empty($arrIds) || !\is_array($arrIds)) { return null; } $t = static::$strTable; $time = Date::floorToMinute(); // Get upcoming events using endTime instead of startTime (see #3917) $arrColumns = array("(...
php
{ "resource": "" }
q243097
PageRegular.getPageLayout
validation
protected function getPageLayout($objPage) { $objLayout = LayoutModel::findByPk($objPage->layout); // Die if there is no layout if (null === $objLayout) { $this->log('Could not find layout ID "' . $objPage->layout . '"', __METHOD__, TL_ERROR); throw new NoLayoutSpecifiedException('No layout specified');...
php
{ "resource": "" }
q243098
Files.fopen
validation
public function fopen($strFile, $strMode) { $this->validate($strFile); return fopen($this->strRootDir . '/' . $strFile, $strMode); }
php
{ "resource": "" }
q243099
Files.rename
validation
public function rename($strOldName, $strNewName) { // Source file == target file if ($strOldName == $strNewName) { return true; } $this->validate($strOldName, $strNewName); // Windows fix: delete the target file if (\defined('PHP_WINDOWS_VERSION_BUILD') && file_exists($this->strRootDir . '/' . $strN...
php
{ "resource": "" }