_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q245100
ItemList.addFilterRule
validation
public function addFilterRule($objFilterRule) { if (!$this->objFilter) { $this->objFilter = $this->objMetaModel->getEmptyFilter(); } $this->objFilter->addFilterRule($objFilterRule); return $this; }
php
{ "resource": "" }
q245101
ItemList.getAttributeNames
validation
protected function getAttributeNames() { $arrAttributes = $this->objView->getSettingNames(); // Get the right jumpTo. $strDesiredLanguage = $this->getMetaModel()->getActiveLanguage(); $strFallbackLanguage = $this->getMetaModel()->getFallbackLanguage(); $intFilterSettings = 0; foreach ((array) $this->getView()->get('jumpTo') as $arrJumpTo) { // If either desired language or fallback, keep the result. if (!$this->getMetaModel()->isTranslated() || $arrJumpTo['langcode'] == $strDesiredLanguage || $arrJumpTo['langcode'] == $strFallbackLanguage) { $intFilterSettings = $arrJumpTo['filter']; // If the desired language, break. Otherwise try to get the desired one until all have been evaluated. if ($strDesiredLanguage == $arrJumpTo['langcode']) { break; } } } if ($intFilterSettings) { $objFilterSettings = $this->getFilterFactory()->createCollection($intFilterSettings); $arrAttributes = array_merge($objFilterSettings->getReferencedAttributes(), $arrAttributes); } return $arrAttributes; }
php
{ "resource": "" }
q245102
ItemList.prepare
validation
public function prepare() { if ($this->objItems) { return $this; } // Create an empty filter object if not done before. if (!$this->objFilter) { $this->objFilter = $this->objMetaModel->getEmptyFilter(); } if ($this->objFilterSettings) { $this->objFilterSettings->addRules($this->objFilter, $this->arrParam); } $this->modifyFilter(); $intTotal = $this->objMetaModel->getCount($this->objFilter); $calculator = $this->paginationLimitCalculator; $calculator->setTotalAmount($intTotal); $curPage = (int) \Input::get('page'); if ($curPage > 1) { $calculator->setCurrentPage($curPage); } $this->objTemplate->total = $intTotal; $this->objItems = $this->objMetaModel->findByFilter( $this->objFilter, $this->strSortBy, $calculator->getCalculatedOffset(), $calculator->getCalculatedLimit(), $this->strSortDirection, $this->getAttributeNames() ); return $this; }
php
{ "resource": "" }
q245103
ItemList.getOutputFormat
validation
public function getOutputFormat() { if (isset($this->strOutputFormat)) { return $this->strOutputFormat; } if (isset($this->objView) && $this->objView->get('format')) { return $this->objView->get('format'); } $page = $this->getPage(); if ($page && $page->outputFormat) { return $page->outputFormat; } return 'text'; }
php
{ "resource": "" }
q245104
ItemList.getCaptionText
validation
private function getCaptionText($langKey) { $tableName = $this->getMetaModel()->getTableName(); if (isset($this->objView) && isset($GLOBALS['TL_LANG']['MSC'][$tableName][$this->objView->get('id')][$langKey]) ) { return $GLOBALS['TL_LANG']['MSC'][$tableName][$this->objView->get('id')][$langKey]; } elseif (isset($GLOBALS['TL_LANG']['MSC'][$tableName][$langKey])) { return $GLOBALS['TL_LANG']['MSC'][$tableName][$langKey]; } return $GLOBALS['TL_LANG']['MSC'][$langKey]; }
php
{ "resource": "" }
q245105
ItemList.setTitleAndDescription
validation
private function setTitleAndDescription() { $page = $this->getPage(); if ($page && $this->objItems->getCount()) { // Add title if needed. if (!empty($this->strTitleAttribute)) { while ($this->objItems->next()) { /** @var IItem $objCurrentItem */ $objCurrentItem = $this->objItems->current(); $arrTitle = $objCurrentItem->parseAttribute( $this->strTitleAttribute, 'text', $this->getView() ); if (!empty($arrTitle['text'])) { $page->pageTitle = strip_tags($arrTitle['text']); break; } } $this->objItems->reset(); } // Add description if needed. if (!empty($this->strDescriptionAttribute)) { while ($this->objItems->next()) { $objCurrentItem = $this->objItems->current(); $arrDescription = $objCurrentItem->parseAttribute( $this->strDescriptionAttribute, 'text', $this->getView() ); if (!empty($arrDescription['text'])) { $page->description = StringUtil::substr($arrDescription['text'], 160); break; } } $this->objItems->reset(); } } }
php
{ "resource": "" }
q245106
ItemList.render
validation
public function render($blnNoNativeParsing, $objCaller) { $event = new RenderItemListEvent($this, $this->objTemplate, $objCaller); $this->getEventDispatcher()->dispatch(MetaModelsEvents::RENDER_ITEM_LIST, $event); $this->objTemplate->noItemsMsg = $this->getNoItemsCaption(); $this->objTemplate->details = $this->getCaptionText('details'); $this->prepare(); $strOutputFormat = $this->getOutputFormat(); if ($this->objItems->getCount() && !$blnNoNativeParsing) { $this->objTemplate->data = $this->objItems->parseAll($strOutputFormat, $this->objView); } else { $this->objTemplate->data = array(); } $this->setTitleAndDescription(); $this->objTemplate->caller = $objCaller; $this->objTemplate->items = $this->objItems; $this->objTemplate->filterParams = $this->arrParam; return $this->objTemplate->parse($strOutputFormat); }
php
{ "resource": "" }
q245107
BasicDefinitionBuilder.getOrCreateBasicDefinition
validation
private function getOrCreateBasicDefinition(IMetaModelDataDefinition $container) { if ($container->hasBasicDefinition()) { return $container->getBasicDefinition(); } $config = new DefaultBasicDefinition(); $container->setBasicDefinition($config); return $config; }
php
{ "resource": "" }
q245108
TlClassWizardListener.handle
validation
public function handle(ManipulateWidgetEvent $event) { if (!($this->wantToHandle($event) && ('tl_class' === $event->getProperty()->getName()))) { return; } $link = ' <a href="%1$s" onclick="Backend.getScrollOffset();Backend.openModalIframe({' . '\'width\':765,' . '\'title\':\'%2$s\',' . '\'url\':this.href,' . '\'id\':\'%3$s\'' . '});return false">%4$s</a>'; $image = $this->iconBuilder->getBackendIconImageTag( 'bundles/metamodelscore/images/icons/dca_wizard.png', $event->getEnvironment()->getTranslator()->translate('stylepicker', 'tl_metamodel_dca'), 'style="vertical-align:top;"' ); $event->getWidget()->wizard = sprintf( $link, $this->urlGenerator->generate('metamodels.picker', [ 'tbl' => $event->getEnvironment()->getDataDefinition()->getName(), 'fld' => $event->getProperty()->getName(), 'inputName' => 'ctrl_' . $event->getProperty()->getName(), 'id' => $event->getModel()->getId(), 'item' => 'PALETTE_STYLE_PICKER', ]), addslashes($event->getEnvironment()->getTranslator()->translate('stylepicker', 'tl_metamodel_dca')), $event->getModel()->getId(), $image ); }
php
{ "resource": "" }
q245109
SearchablePages.getConfigs
validation
protected function getConfigs() { if (!count($this->configs)) { // Init the config from database. $statement = $this->connection->query('SELECT * FROM tl_metamodel_searchable_pages'); $this->configs = $statement->fetchAll(\PDO::FETCH_ASSOC); } return $this->configs; }
php
{ "resource": "" }
q245110
SearchablePages.getMetaModel
validation
protected function getMetaModel($identifier, $ignoreError) { // Get the factory. $factory = $this->getMetaModelsFactory(); // Id to name. if (is_numeric($identifier)) { $identifier = $factory->translateIdToMetaModelName($identifier); } // Create mm, if yowl is true check if we have really a mm . $metaModels = $factory->getMetaModel($identifier); // If $ignoreError is off and we have no mm throw a new exception. if (!$ignoreError && $metaModels == null) { throw new \RuntimeException('Could not find the MetaModels with the name ' . $identifier); } return $metaModels; }
php
{ "resource": "" }
q245111
SearchablePages.getView
validation
protected function getView($identifier, $view) { $metaModels = $this->getMetaModel($identifier, false); return $metaModels->getView($view); }
php
{ "resource": "" }
q245112
SearchablePages.getLanguage
validation
protected function getLanguage($singleLanguage, $metaModels) { if (!empty($singleLanguage)) { return array($singleLanguage); } elseif ($metaModels->isTranslated() && $metaModels->getAvailableLanguages()) { return $metaModels->getAvailableLanguages(); } return array($GLOBALS['TL_LANGUAGE']); }
php
{ "resource": "" }
q245113
SearchablePages.getJumpTosFor
validation
protected function getJumpTosFor($metaModels, $filter, $view, $rootPage = null) { $entries = array(); // Get the object. $items = $metaModels->findByFilter($filter); /** @var Item $item */ foreach ($items as $item) { $jumpTo = $item->buildJumpToLink($view); $event = new GetPageDetailsEvent($jumpTo['page']); $this->getEventDispatcher()->dispatch(ContaoEvents::CONTROLLER_GET_PAGE_DETAILS, $event); $pageDetails = $event->getPageDetails(); // If there is a root page check the context or if we have no page continue. if ($pageDetails === null || ($rootPage !== null && $pageDetails['rootId'] != $rootPage)) { continue; } // Build the url. $url = $this->getBaseUrl( $pageDetails, $jumpTo['url'] ); $entries[] = $url->getUrl(); } return $entries; }
php
{ "resource": "" }
q245114
SearchablePages.getBaseUrl
validation
private function getBaseUrl($pageDetails, $path = null, $ignoreSSL = false) { $url = new UrlBuilder(); // Set the domain (see contao/core#6421) if ($pageDetails['domain']) { $url->setHost($pageDetails['domain']); } else { $url->setHost(\Environment::get('host')); } if ($pageDetails['rootUseSSL'] && !$ignoreSSL) { $url->setScheme('https'); } else { $url->setScheme('http'); } // Make a array for the parts. $fullPath = array(); $fullPath[] = TL_PATH; // Get the path. if ($path === null) { $event = new GenerateFrontendUrlEvent($pageDetails, null, $pageDetails['language'], true); $this->getEventDispatcher()->dispatch(ContaoEvents::CONTROLLER_GENERATE_FRONTEND_URL, $event); $fullPath[] = $event->getUrl(); } else { $fullPath[] = $path; } $url->setPath(implode('/', $fullPath)); return $url; }
php
{ "resource": "" }
q245115
SearchablePages.removeEmptyDetailPages
validation
protected function removeEmptyDetailPages($jumpTos) { // Remove the detail pages. foreach ($jumpTos as $jumpTo) { // Get the page from the url. $event = new GetPageDetailsEvent($jumpTo['value']); $this->getEventDispatcher()->dispatch(ContaoEvents::CONTROLLER_GET_PAGE_DETAILS, $event); $pageDetails = $event->getPageDetails(); // Check if we have a page If not go to the next one. if ($pageDetails === null) { continue; } // Make a full url from it. $baseUrl = $this->getBaseUrl($pageDetails); if (($strKey = array_search($baseUrl->getUrl(), $this->foundPages)) !== false) { unset($this->foundPages[$strKey]); } // Make a full url from it without the https. $baseUrl = $this->getBaseUrl($pageDetails, null, true); if (($strKey = array_search($baseUrl->getUrl(), $this->foundPages)) !== false) { unset($this->foundPages[$strKey]); } } }
php
{ "resource": "" }
q245116
SearchablePages.addPages
validation
public function addPages($pages, $rootPage = null, $fromSiteMap = false, $language = null) { // Save the pages. $this->foundPages = $pages; unset($pages); // Run each entry in the published config array. foreach ($this->getConfigs() as $config) { if (!$config['published']) { continue; } $this->getMetaModelsPages( $config, $rootPage, $language ); } asort($this->foundPages); // Return the new list. return $this->foundPages; }
php
{ "resource": "" }
q245117
SearchablePages.getMetaModelsPages
validation
private function getMetaModelsPages( $config, $rootPage = null, $language = null ) { $metaModelsIdentifier = $config['pid']; $filterIdentifier = $config['filter']; $presetParams = StringUtil::deserialize($config['filterparams'], true); $renderSettingId = $config['rendersetting']; // Get the MetaModels. $metaModels = $this->getMetaModel($metaModelsIdentifier, false); $availableLanguages = $this->getLanguage($language, $metaModels); $currentLanguage = $GLOBALS['TL_LANGUAGE']; foreach ($availableLanguages as $newLanguage) { // Change language. $GLOBALS['TL_LANGUAGE'] = $newLanguage; // Get the view. $view = $this->getView($metaModelsIdentifier, $renderSettingId); $jumpTos = $view->get('jumpTo'); // Set the filter. $processed = $this->setFilterParameters($filterIdentifier, $presetParams, array()); // Create a new filter for the search. $filter = $metaModels->getEmptyFilter(); $filterSetting = $this->getFilterSettings($filterIdentifier); $filterSetting->addRules($filter, $processed); // Get all jumpTos. $newEntries = $this->getJumpTosFor($metaModels, $filter, $view, $rootPage); // Remove all empty page details. $this->removeEmptyDetailPages($jumpTos); // Reset language. $GLOBALS['TL_LANGUAGE'] = $currentLanguage; // Merge all results. $this->foundPages = array_merge($this->foundPages, $newEntries); } // Reset the language. $GLOBALS['TL_LANGUAGE'] = $currentLanguage; }
php
{ "resource": "" }
q245118
FilterBuilderSql.build
validation
public function build() { if (!$this->isEmpty()) { return new SimpleQuery( sprintf('SELECT id FROM %s WHERE %s', $this->tableName, $this->getProcedure()), $this->getParameters(), 'id', $this->connection ); } return null; }
php
{ "resource": "" }
q245119
FilterBuilderSql.addChild
validation
public function addChild($child) { if (!\is_array($child)) { throw new \RuntimeException('Error Processing sub filter: ' . var_export($child, true), 1); } switch (strtoupper($child['operation'])) { case '=': case '>': case '<': return $this->getFilterForComparingOperator($child); case 'IN': return $this->getFilterForInList($child); case 'LIKE': return $this->getFilterForLike($child); default: } throw new \RuntimeException('Error processing filter array ' . var_export($child, true), 1); }
php
{ "resource": "" }
q245120
FilterBuilderSql.addSubProcedure
validation
public function addSubProcedure(FilterBuilderSql $subProcedure) { $this->procedures[] = $subProcedure->getProcedure(); $this->parameter = array_merge($this->parameter, $subProcedure->getParameters()); return $this; }
php
{ "resource": "" }
q245121
Collection.getJumpToLabel
validation
private function getJumpToLabel() { $tableName = $this->metaModel->getTableName(); if (isset($GLOBALS['TL_LANG']['MSC'][$tableName][$this->get('id')]['details'])) { return $GLOBALS['TL_LANG']['MSC'][$tableName][$this->get('id')]['details']; } elseif (isset($GLOBALS['TL_LANG']['MSC'][$tableName]['details'])) { return $GLOBALS['TL_LANG']['MSC'][$tableName]['details']; } return $GLOBALS['TL_LANG']['MSC']['details']; }
php
{ "resource": "" }
q245122
Collection.getPageDetails
validation
private function getPageDetails($pageId) { if (empty($pageId)) { return array(); } $event = new GetPageDetailsEvent($pageId); $this->getEventDispatcher()->dispatch(ContaoEvents::CONTROLLER_GET_PAGE_DETAILS, $event); return $event->getPageDetails(); }
php
{ "resource": "" }
q245123
Collection.determineJumpToInformation
validation
private function determineJumpToInformation() { // Get the right jumpto. $translated = $this->metaModel->isTranslated(); $desiredLanguage = $this->metaModel->getActiveLanguage(); $fallbackLanguage = $this->metaModel->getFallbackLanguage(); $jumpToPageId = ''; $filterSettingId = ''; if (!isset($this->jumpToCache[$desiredLanguage . '.' . $fallbackLanguage])) { foreach ((array) $this->get('jumpTo') as $jumpTo) { $langCode = $jumpTo['langcode']; // If either desired language or fallback, keep the result. if (!$translated || ($langCode == $desiredLanguage) || ($langCode == $fallbackLanguage)) { $jumpToPageId = $jumpTo['value']; $filterSettingId = $jumpTo['filter']; // If the desired language, break. // Otherwise try to get the desired one until all have been evaluated. if ($desiredLanguage == $jumpTo['langcode']) { break; } } } $pageDetails = $this->getPageDetails($jumpToPageId); $filterSetting = $filterSettingId ? $this->getFilterFactory()->createCollection($filterSettingId) : null; $this->jumpToCache[$desiredLanguage . '.' . $fallbackLanguage] = array( 'page' => $jumpToPageId, 'pageDetails' => $pageDetails, 'filter' => $filterSettingId, 'filterSetting' => $filterSetting, // Mask out the "all languages" language key (See #687). 'language' => $pageDetails['language'], 'label' => $this->getJumpToLabel() ); } return $this->jumpToCache[$desiredLanguage . '.' . $fallbackLanguage]; }
php
{ "resource": "" }
q245124
IconBuilder.getBackendIcon
validation
public function getBackendIcon($icon, $defaultIcon = 'bundles/metamodelscore/images/icons/metamodels.png') { $realIcon = $this->convertValueToPath($icon, $defaultIcon); $targetPath = $this->outputPath . '/' . basename($realIcon); if (\file_exists($targetPath)) { return $this->webPath . '/' . basename($realIcon); } $this->imageFactory->create($realIcon, [16, 16, 'center_center'], $targetPath); return $this->webPath . '/' . basename($realIcon); }
php
{ "resource": "" }
q245125
FilterSettingFactory.createSetting
validation
private function createSetting($dbResult, $filterSettings) { $factory = $this->getTypeFactory($dbResult['type']); if ($factory) { $setting = $factory->createInstance($dbResult, $filterSettings); if (!$setting) { return null; } // Collect next level. if ($factory->isNestedType()) { /** @var IWithChildren $setting */ $this->collectRulesFor($setting, $filterSettings); } return $setting; } return null; }
php
{ "resource": "" }
q245126
FilterSettingFactory.collectRulesFor
validation
private function collectRulesFor($parentSetting, $filterSettings) { $childInformation = $this->database ->createQueryBuilder() ->select('*') ->from('tl_metamodel_filtersetting') ->where('pid=:pid') ->andWhere('enabled=1') ->orderBy('sorting', 'ASC') ->setParameter('pid', $parentSetting->get('id')) ->execute(); foreach ($childInformation->fetchAll(\PDO::FETCH_ASSOC) as $item) { $childSetting = $this->createSetting($item, $filterSettings); if ($childSetting) { $parentSetting->addChild($childSetting); } } }
php
{ "resource": "" }
q245127
FilterSettingFactory.collectRules
validation
public function collectRules($filterSettings) { $information = $this->database ->createQueryBuilder() ->select('*') ->from('tl_metamodel_filtersetting') ->where('fid=:fid') ->andWhere('pid=0') ->andWhere('enabled=1') ->orderBy('sorting', 'ASC') ->setParameter('fid', $filterSettings->get('id')) ->execute(); foreach ($information->fetchAll(\PDO::FETCH_ASSOC) as $item) { $newSetting = $this->createSetting($item, $filterSettings); if ($newSetting) { $filterSettings->addSetting($newSetting); } } }
php
{ "resource": "" }
q245128
AbstractContentElementAndModuleCallback.editRenderSettingButton
validation
public function editRenderSettingButton(\DC_Table $dataContainer) { if ($dataContainer->value < 1) { return ''; } $url = $this->urlBuilderFactory->create('contao/main.php?do=metamodels&table=tl_metamodel_rendersetting') ->setQueryParameter( 'pid', ModelId::fromValues('tl_metamodel_rendersettings', $dataContainer->value)->getSerialized() ); return $this->renderEditButton( $GLOBALS['TL_LANG'][static::$tableName]['editrendersetting'][0], sprintf( StringUtil::specialchars($GLOBALS['TL_LANG'][static::$tableName]['editrendersetting'][1]), $dataContainer->value ), $url ); }
php
{ "resource": "" }
q245129
AbstractContentElementAndModuleCallback.getAttributeNames
validation
public function getAttributeNames(\DC_Table $objDc) { $attributeNames = [ 'sorting' => $GLOBALS['TL_LANG']['MSC']['metamodels_sorting'], 'random' => $GLOBALS['TL_LANG']['MSC']['random'], 'id' => $GLOBALS['TL_LANG']['MSC']['id'][0] ]; $metaModelName = $this->factory->translateIdToMetaModelName($objDc->activeRecord->metamodel); $metaModel = $this->factory->getMetaModel($metaModelName); if ($metaModel) { foreach ($metaModel->getAttributes() as $objAttribute) { $attributeNames[$objAttribute->getColName()] = $objAttribute->getName(); } } return $attributeNames; }
php
{ "resource": "" }
q245130
AbstractContentElementAndModuleCallback.getFilterSettings
validation
public function getFilterSettings(\DC_Table $objDC) { $filterSettings = $this->connection->createQueryBuilder() ->select('f.id', 'f.name') ->from('tl_metamodel_filter', 'f') ->where('f.pid=:id') ->setParameter('id', $objDC->activeRecord->metamodel) ->execute() ->fetchAll(\PDO::FETCH_ASSOC); $result = []; foreach ($filterSettings as $filterSetting) { $result[$filterSetting['id']] = $filterSetting['name']; } // Sort the filter settings. asort($result); return $result; }
php
{ "resource": "" }
q245131
AbstractContentElementAndModuleCallback.buildFilterParamsFor
validation
protected function buildFilterParamsFor(\DC_Table $dataContainer, $elementName) { if (!$this->requestStack->getCurrentRequest()->query->get('act')) { return; } $filterId = $this->connection->createQueryBuilder() ->select('c.metamodel_filtering') ->from(static::$tableName, 'c') ->join('c', 'tl_metamodel', 'mm', 'mm.id=c.metamodel') ->where('c.id=:id') ->setParameter('id', $dataContainer->id) ->andWhere('c.type=:type') ->setParameter('type', $elementName) ->setMaxResults(1) ->execute() ->fetch(\PDO::FETCH_COLUMN); if (!$filterId) { unset($GLOBALS['TL_DCA'][static::$tableName]['fields']['metamodel_filterparams']); return; } $collection = $this->filterFactory->createCollection($filterId); $dca = $collection->getParameterDCA(); foreach ($dca as $fieldName => $subField) { $options = []; foreach ($subField['options'] as $key => $value) { $options[$this->loadCallback($key)] = $value; } $dca[$fieldName]['options'] = $options; $dca[$fieldName]['save_callback'][] = [static::class, 'saveCallback']; $dca[$fieldName]['load_callback'][] = [static::class, 'loadCallback']; } $GLOBALS['TL_DCA'][static::$tableName]['fields']['metamodel_filterparams']['eval']['subfields'] = $dca; }
php
{ "resource": "" }
q245132
AbstractContentElementAndModuleCallback.loadCallback
validation
public function loadCallback(string $value = null) { return null === $value ? null : trim(\base64_encode($value), '='); }
php
{ "resource": "" }
q245133
AbstractContentElementAndModuleCallback.getFilterParameterNames
validation
public function getFilterParameterNames(\DC_Table $objDc) { $return = array(); $filter = $objDc->activeRecord->metamodel_filtering; if (!$filter) { return $return; } $collection = $this->filterFactory->createCollection($filter); return $collection->getParameterFilterNames(); }
php
{ "resource": "" }
q245134
AbstractContentElementAndModuleCallback.renderEditButton
validation
private function renderEditButton($caption, $title, UrlBuilder $url) { $icon = $this->iconBuilder->getBackendIconImageTag( 'system/themes/flexible/icons/alias.svg', $caption, 'style="vertical-align:top"' ); return sprintf( '<a href="%s" title="%s" style="padding-left:3px">%s</a>', $url->getUrl(), $title, $icon ); }
php
{ "resource": "" }
q245135
AbstractContentElementAndModuleCallback.getFilteredAttributeNames
validation
private function getFilteredAttributeNames($metaModelId, $allowedTypes = array()) { $attributeNames = array(); if ($metaModel = $this->factory->getMetaModel($this->factory->translateIdToMetaModelName($metaModelId))) { foreach ($metaModel->getAttributes() as $attribute) { if (empty($allowedTypes) || in_array($attribute->get('type'), $allowedTypes)) { $attributeNames[$attribute->getColName()] = sprintf( '%s [%s]', $attribute->getName(), $attribute->getColName() ); } } } return $attributeNames; }
php
{ "resource": "" }
q245136
GetMetaModelTrait.getMetaModel
validation
protected function getMetaModel($metaModelId) { if (null === $this->factory) { throw new \RuntimeException('No factory set.'); } $metaModelName = $this->factory->translateIdToMetaModelName($metaModelId); $metaModel = $this->factory->getMetaModel($metaModelName); return $metaModel; }
php
{ "resource": "" }
q245137
ModuleCallback.getTemplates
validation
public function getTemplates(\DC_Table $objDC) { /** @noinspection PhpUndefinedFieldInspection */ $type = $objDC->activeRecord->type; return $this->getTemplateList('mod_' . $type); }
php
{ "resource": "" }
q245138
LanguageCodeWizardListener.pagePicker
validation
public function pagePicker(ManipulateWidgetEvent $event) { if (!$this->scopeDeterminator->currentScopeIsBackend() || !('tl_metamodel_rendersettings' === $event->getEnvironment()->getDataDefinition()->getName()) || !((0 === strpos($event->getProperty()->getName(), 'jumpTo')) && ('[value]' === substr($event->getProperty()->getName(), -\strlen('[value]')))) ) { return; } $environment = $event->getEnvironment(); $pickerUrl = $this->pickerBuilder->getUrl('cca_link'); $urlEvent = new GenerateHtmlEvent( 'pickpage.svg', $environment->getTranslator()->translate('MSC.pagepicker'), 'style="vertical-middle:top;cursor:pointer"' ); $environment->getEventDispatcher()->dispatch(ContaoEvents::IMAGE_GET_HTML, $urlEvent); $template = new ContaoBackendViewTemplate('dc_general_wizard_link_url_picker'); $template ->set('name', $event->getWidget()->name) ->set('popupUrl', $pickerUrl) ->set('html', ' ' . $urlEvent->getHtml()) ->set('label', $event->getProperty()->getLabel()[1]) ->set('id', $event->getWidget()->id); $event->getWidget()->wizard = $template->parse(); }
php
{ "resource": "" }
q245139
BaseSimple.handleMetaChange
validation
public function handleMetaChange($strMetaName, $varNewValue) { // By default we accept any change of meta information. if ($strMetaName == 'colname') { if ($this->get($strMetaName) != $varNewValue) { $this->renameColumn($varNewValue); } return $this; } return parent::handleMetaChange($strMetaName, $varNewValue); }
php
{ "resource": "" }
q245140
BaseSimple.setDataFor
validation
public function setDataFor($arrValues) { $strTable = $this->getMetaModel()->getTableName(); $strColName = $this->getColName(); foreach ($arrValues as $intId => $varData) { if (is_array($varData)) { $varData = serialize($varData); } $this->connection->update($strTable, [$strColName => $varData], ['id' => $intId]); } }
php
{ "resource": "" }
q245141
BaseSimple.searchFor
validation
public function searchFor($strPattern) { // Base implementation, do a simple search on given column. $strPattern = str_replace(array('*', '?'), array('%', '_'), $strPattern); $arrIds = $this->connection->createQueryBuilder() ->select('id') ->from($this->getMetaModel()->getTableName()) ->where($this->getColName() . ' LIKE :pattern') ->setParameter('pattern', $strPattern) ->execute() ->fetchAll(\PDO::FETCH_COLUMN, 'id'); return $arrIds; }
php
{ "resource": "" }
q245142
BaseSimple.createColumn
validation
public function createColumn() { if ($this->getColName()) { $this->tableManipulator->createColumn( $this->getMetaModel()->getTableName(), $this->getColName(), $this->getSQLDataType() ); } }
php
{ "resource": "" }
q245143
BaseSimple.deleteColumn
validation
public function deleteColumn() { $schemaManager = $this->connection->getSchemaManager(); $columns = $schemaManager->listTableColumns($this->getMetaModel()->getTableName()); // Try to delete the column. If it does not exist as we can assume it has been deleted already then. if ($this->getColName() && isset($columns[$this->getColName()])) { $this->tableManipulator->dropColumn($this->getMetaModel()->getTableName(), $this->getColName()); } }
php
{ "resource": "" }
q245144
BaseSimple.renameColumn
validation
public function renameColumn($strNewColumnName) { $this->tableManipulator->checkColumnName($strNewColumnName); $schemaManager = $this->connection->getSchemaManager(); $columns = $schemaManager->listTableIndexes($this->getMetaModel()->getTableName()); if ($this->getColName() && isset($columns[$this->getColName()])) { $this->tableManipulator->renameColumn( $this->getMetaModel()->getTableName(), $this->getColName(), $strNewColumnName, $this->getSQLDataType() ); } else { $strBackupColName = $this->getColName(); $this->set('colname', $strNewColumnName); $this->createColumn(); $this->set('colname', $strBackupColName); } }
php
{ "resource": "" }
q245145
InputScreenOptionListener.handle
validation
public function handle(GetOptionsEvent $event) { if (('tl_metamodel_dca_combine' !== $event->getEnvironment()->getDataDefinition()->getName()) || ('rows' !== $event->getPropertyName()) || ('dca_id' !== $event->getSubPropertyName())) { return; } $screens = $this ->connection ->createQueryBuilder() ->select('id') ->addSelect('name') ->from('tl_metamodel_dca') ->where('pid=:pid') ->setParameter('pid', $event->getModel()->getProperty('id')) ->execute() ->fetchAll(\PDO::FETCH_ASSOC); $result = []; foreach ($screens as $screen) { $result[$screen['id']] = $screen['name']; } $event->setOptions($result); }
php
{ "resource": "" }
q245146
Model.getPropertyNames
validation
protected function getPropertyNames() { $propertyNames = array('id', 'pid', 'tstamp', 'sorting'); if ($this->getItem()->getMetaModel()->hasVariants()) { $propertyNames[] = 'varbase'; $propertyNames[] = 'vargroup'; } return array_merge($propertyNames, array_keys($this->getItem()->getMetaModel()->getAttributes())); }
php
{ "resource": "" }
q245147
GroupOptionListener.handle
validation
public function handle(GetOptionsEvent $event) { if (('tl_metamodel_dca_combine' !== $event->getEnvironment()->getDataDefinition()->getName()) || ('rows' !== $event->getPropertyName()) || !in_array($event->getSubPropertyName(), ['be_group', 'fe_group'])) { return; } $isBackend = 'be_group' === $event->getSubPropertyName(); $groups = $this ->connection ->createQueryBuilder() ->select('id') ->addSelect('name') ->from($isBackend ? 'tl_user_group' : 'tl_member_group') ->execute() ->fetchAll(\PDO::FETCH_ASSOC); $result = []; $result[-1] = $event->getEnvironment()->getTranslator()->translate( $isBackend ? 'sysadmin' : 'anonymous', 'tl_metamodel_dca_combine' ); foreach ($groups as $group) { $result[$group['id']] = $group['name']; } $event->setOptions($result); }
php
{ "resource": "" }
q245148
MetaModelDefinitionBuilderTrait.handle
validation
public function handle(BuildDataDefinitionEvent $event) { $container = $event->getContainer(); if ($container instanceof IMetaModelDataDefinition) { $this->build($container); } }
php
{ "resource": "" }
q245149
ToolboxFile.setAcceptedExtensions
validation
public function setAcceptedExtensions($acceptedExtensions) { // We must not allow file extensions that are globally disabled. $allowedDownload = StringUtil::trimsplit(',', $GLOBALS['TL_CONFIG']['allowedDownload']); if (!is_array($acceptedExtensions)) { $acceptedExtensions = StringUtil::trimsplit(',', $acceptedExtensions); } $this->acceptedExtensions = array_map('strtolower', array_intersect($allowedDownload, $acceptedExtensions)); }
php
{ "resource": "" }
q245150
ToolboxFile.addPathById
validation
public function addPathById($strId) { // Check if empty. if (empty($strId)) { return $this; } if (!Validator::isBinaryUuid($strId)) { $this->pendingIds[] = StringUtil::uuidToBin($strId); return $this; } $this->pendingIds[] = $strId; return $this; }
php
{ "resource": "" }
q245151
ToolboxFile.getDownloadLink
validation
protected function getDownloadLink($strFile) { if (!isset($_SESSION['metaModels_downloads'][$strFile])) { $_SESSION['metaModels_downloads'][$strFile] = md5(uniqid()); } return UrlBuilder::fromUrl(Environment::get('request')) ->setQueryParameter('file', urlencode($strFile)) ->setQueryParameter('fileKey', $_SESSION['metaModels_downloads'][$strFile]) ->getUrl(); }
php
{ "resource": "" }
q245152
ToolboxFile.fetchAdditionalData
validation
protected function fetchAdditionalData() { $this->modifiedTime = array(); $this->outputBuffer = array(); if (!$this->foundFiles) { return; } foreach ($this->foundFiles as $strFile) { $this->processFile($strFile); } }
php
{ "resource": "" }
q245153
ToolboxFile.remapSorting
validation
protected function remapSorting($arrFiles, $arrSource) { $files = array(); $source = array(); foreach (array_keys($arrFiles) as $k) { $files[] = $arrFiles[$k]; $source[] = $arrSource[$k]; } $this->addClasses($source); return array ( 'files' => $files, 'source' => $source ); }
php
{ "resource": "" }
q245154
ToolboxFile.sortFiles
validation
public function sortFiles($sortType, $sortIds = array()) { switch ($sortType) { case 'name_desc': return $this->sortByName(false); case 'date_asc': return $this->sortByDate(true); case 'date_desc': return $this->sortByDate(false); case 'manual': return $this->sortByIdList($sortIds); case 'random': return $this->sortByRandom(); default: case 'name_asc': } return $this->sortByName(true); }
php
{ "resource": "" }
q245155
ToolboxFile.sortByName
validation
protected function sortByName($blnAscending = true) { $arrFiles = $this->foundFiles; if (!$arrFiles) { return array('files' => array(), 'source' => array()); } \uasort($arrFiles, ($blnAscending) ? '\basename_natcasecmp' : '\basename_natcasercmp'); return $this->remapSorting($arrFiles, $this->outputBuffer); }
php
{ "resource": "" }
q245156
ToolboxFile.sortByDate
validation
protected function sortByDate($blnAscending = true) { $arrFiles = $this->foundFiles; $arrDates = $this->modifiedTime; if (!$arrFiles) { return array('files' => array(), 'source' => array()); } if ($blnAscending) { array_multisort($arrFiles, SORT_NUMERIC, $arrDates, SORT_ASC); } else { array_multisort($arrFiles, SORT_NUMERIC, $arrDates, SORT_DESC); } return $this->remapSorting($arrFiles, $this->outputBuffer); }
php
{ "resource": "" }
q245157
ToolboxFile.sortByIdList
validation
protected function sortByIdList($sortIds) { $fileMap = $this->foundFiles; if (!$fileMap) { return array('files' => array(), 'source' => array()); } $fileKeys = array_flip(array_keys($this->uuidMap)); $sorted = array(); foreach ($sortIds as $sortStringId) { $key = $fileKeys[$sortStringId]; $sorted[$key] = $fileMap[$key]; unset($fileMap[$key]); } // Add anything not sorted yet to the end. $sorted += $fileMap; return $this->remapSorting($sorted, $this->outputBuffer); }
php
{ "resource": "" }
q245158
ToolboxFile.sortByRandom
validation
protected function sortByRandom() { $arrFiles = $this->foundFiles; $arrSource = $this->outputBuffer; if (!$arrFiles) { return array('files' => array(), 'source' => array()); } $keys = array_keys($arrFiles); $files = array(); shuffle($keys); foreach ($keys as $key) { $files[$key] = $arrFiles[$key]; } return $this->remapSorting($files, $arrSource); }
php
{ "resource": "" }
q245159
ToolboxFile.checkDownloads
validation
private function checkDownloads() { // If images are to be shown, get out. if ($this->getShowImages()) { return; } if (($file = Input::get('file')) && ($key = Input::get('fileKey'))) { // Check key and return 403 if mismatch. if (!(array_key_exists($file, $_SESSION['metaModels_downloads']) && $_SESSION['metaModels_downloads'][$file] === $key)) { $objHandler = new $GLOBALS['TL_PTY']['error_403'](); /** @var PageError403 $objHandler */ $objHandler->generate($file); } // Send the file to the browser if check succeeded. Controller::sendFileToBrowser($file); } }
php
{ "resource": "" }
q245160
ToolboxFile.convertUuidsOrPathsToMetaModels
validation
public static function convertUuidsOrPathsToMetaModels($values) { $values = array_filter((array) $values); if (empty($values)) { return array( 'bin' => array(), 'value' => array(), 'path' => array(), 'meta' => array() ); } foreach ($values as $key => $value) { if (!(Validator::isUuid($value))) { $file = FilesModel::findByPath($value) ?: Dbafs::addResource($value); if (!$file) { throw new InvalidArgumentException('Invalid value.'); } $values[$key] = $file->uuid; } } return self::convertValuesToMetaModels($values); }
php
{ "resource": "" }
q245161
ToolboxFile.addFileModels
validation
private function addFileModels($files, $skipPaths = array()) { $baseLanguage = $this->getBaseLanguage(); $fallbackLanguage = $this->getFallbackLanguage(); foreach ($files as $file) { if ('folder' === $file->type && !in_array($file->path, $skipPaths)) { $this->pendingPaths[] = $file->path . '/'; continue; } if (is_file(TL_ROOT . DIRECTORY_SEPARATOR . $file->path) && in_array(strtolower(pathinfo($file->path, PATHINFO_EXTENSION)), $this->acceptedExtensions) ) { $path = $file->path; $this->foundFiles[] = $path; $this->uuidMap[$file->uuid] = $path; $meta = StringUtil::deserialize($file->meta, true); if (isset($meta[$baseLanguage])) { $this->metaInformation[dirname($path)][basename($path)] = $meta[$baseLanguage]; } elseif (isset($meta[$fallbackLanguage])) { $this->metaInformation[dirname($path)][basename($path)] = $meta[$fallbackLanguage]; } } } }
php
{ "resource": "" }
q245162
ToolboxFile.processFile
validation
private function processFile($fileName) { $file = new File($fileName); $meta = $this->metaInformation[dirname($fileName)][$file->basename]; $title = strlen($meta['title']) ? $meta['title'] : StringUtil::specialchars($file->basename); if (strlen($meta['caption'])) { $altText = $meta['caption']; } else { $altText = ucfirst(str_replace('_', ' ', preg_replace('/^[0-9]+_/', '', $file->filename))); } $information = [ 'file' => $fileName, 'mtime' => $file->mtime, 'alt' => $altText, 'caption' => (!empty($meta['caption']) ? $meta['caption'] : ''), 'title' => $title, 'metafile' => $meta, 'icon' => 'assets/contao/images/' . $file->icon, 'extension' => $file->extension, 'size' => $file->filesize, 'sizetext' => sprintf('(%s)', Controller::getReadableSize($file->filesize, 2)), 'url' => StringUtil::specialchars($this->getDownloadLink($fileName)) ]; // Prepare GD images. if ($information['isGdImage'] = $file->isGdImage) { $information['src'] = urldecode($this->resizeImage($fileName)); if (file_exists(TL_ROOT . '/' . $information['src'])) { $size = getimagesize(TL_ROOT . '/' . $information['src']); $information['lb'] = 'lb' . $this->getLightboxId(); $information['w'] = $size[0]; $information['h'] = $size[1]; $information['wh'] = $size[3]; } } // Prepare SVG images. if ($information['isSvgImage'] = $file->isSvgImage) { $information['src'] = $fileName; } // Prepare the picture for provide the image size. if ($information['isPicture'] = (int) $this->resizeImages[2]) { $picture = Picture::create($file, $this->getResizeImages())->getTemplateData(); $picture['alt'] = $altText; $picture['title'] = $title; $information['picture'] = $picture; } $this->modifiedTime[] = $file->mtime; $this->outputBuffer[] = $information; }
php
{ "resource": "" }
q245163
ToolboxFile.resizeImage
validation
private function resizeImage($fileName) { list($width, $height, $mode) = $this->getResizeImages(); if ($this->getShowImages() && ($width || $height || $mode)) { if ($this->imageFactory) { $image = $this->imageFactory->create( $this->rootDir . '/' . $fileName, [$width, $height, $mode] ); return $image->getUrl($this->rootDir); } $event = new ResizeImageEvent($fileName, $width, $height, $mode); $this->dispatcher->dispatch(ContaoEvents::IMAGE_RESIZE, $event); return $event->getResultImage(); } return $fileName; }
php
{ "resource": "" }
q245164
MetaModelHybrid.getConnection
validation
protected function getConnection() { if (null === $this->connection) { // @codingStandardsIgnoreStart @trigger_error( 'Connection is missing in class ' . static::class . '. The automatic fallback will be dropped in MetaModels 3.0. Please use dependency injection', E_USER_DEPRECATED ); // @codingStandardsIgnoreEnd return $this->connection = System::getContainer()->get('database_connection'); } return $this->connection; }
php
{ "resource": "" }
q245165
ValueListener.getValueOptions
validation
public function getValueOptions(GetPropertyOptionsEvent $event) { if (!$this->wantToHandle($event)) { return; } $model = $event->getModel(); $metaModel = $this->getMetaModel($event->getEnvironment()); $attribute = $metaModel->getAttributeById($model->getProperty('attr_id')); if ($attribute) { $options = $this->getOptionsViaDcGeneral($metaModel, $event->getEnvironment(), $attribute); $mangled = []; foreach ((array) $options as $key => $option) { $mangled['value_' . $key] = $option; } $event->setOptions($mangled); } }
php
{ "resource": "" }
q245166
ValueListener.decodeValue
validation
public function decodeValue(DecodePropertyValueForWidgetEvent $event) { if (!$this->wantToHandle($event)) { return; } if (is_array($event->getValue())) { $values = []; foreach ($event->getValue() as $value) { $values[] = 'value_' . $value; } // Cut off the 'value_' prefix. $event->setValue($values); } else { $event->setValue('value_' . $event->getValue()); } }
php
{ "resource": "" }
q245167
ValueListener.encodeValue
validation
public function encodeValue(EncodePropertyValueFromWidgetEvent $event) { if (!$this->wantToHandle($event)) { return; } if (is_array($event->getValue())) { $values = []; foreach ($event->getValue() as $value) { $values[] = substr($value, 6); } // Cut off the 'value_' prefix. $event->setValue($values); } else { // Cut off the 'value_' prefix. $event->setValue(substr($event->getValue(), 6)); } }
php
{ "resource": "" }
q245168
ValueListener.setValueOptionsMultiple
validation
public function setValueOptionsMultiple(ManipulateWidgetEvent $event) { if (!$this->wantToHandle($event)) { return; } if ($event->getModel()->getProperty('type') !== 'conditionpropertycontainanyof') { return; } $metaModel = $this->getMetaModel($event->getEnvironment()); $attribute = $metaModel->getAttributeById($event->getModel()->getProperty('attr_id')); if (!($attribute && ($attribute->get('type') == 'tags'))) { return; } $event->getWidget()->multiple = true; }
php
{ "resource": "" }
q245169
ValueListener.getOptionsViaDcGeneral
validation
private function getOptionsViaDcGeneral($metaModel, $environment, $attribute) { $factory = DcGeneralFactory::deriveEmptyFromEnvironment($environment) ->setContainerName($metaModel->getTableName()); $dcGeneral = $factory->createDcGeneral(); $subEnv = $dcGeneral->getEnvironment(); $optEv = new GetPropertyOptionsEvent($subEnv, $subEnv->getDataProvider()->getEmptyModel()); $optEv->setPropertyName($attribute->getColName()); $subEnv->getEventDispatcher()->dispatch(GetPropertyOptionsEvent::NAME, $optEv); $options = $optEv->getOptions(); return $options; }
php
{ "resource": "" }
q245170
PropertyDefinitionBuilder.build
validation
protected function build(IMetaModelDataDefinition $container) { $inputScreen = $this->viewCombination->getScreen($container->getName()); if (!$inputScreen) { return; } if ($container->hasPropertiesDefinition()) { $definition = $container->getPropertiesDefinition(); } else { $definition = new DefaultPropertiesDefinition(); $container->setPropertiesDefinition($definition); } $metaModel = $this->factory->getMetaModel($container->getName()); // If the current metamodel has variants add the varbase and vargroup to the definition. if ($metaModel->hasVariants()) { // These are not properties yet, therefore we have to work around. $this->getOrCreateProperty($definition, 'varbase'); $this->getOrCreateProperty($definition, 'vargroup'); } $properties = []; foreach ($inputScreen['properties'] as $property) { if ('attribute' !== $property['dcatype']) { continue; } $properties[$property['attr_id']] = $property; } foreach ($metaModel->getAttributes() as $attribute) { if (!isset($properties[$attribute->get('id')])) { continue; } $this->buildProperty( $definition, $attribute, $attribute->getFieldDefinition($properties[$attribute->get('id')]) ); $event = new BuildAttributeEvent($metaModel, $attribute, $container); $this->dispatcher->dispatch($event::NAME, $event); } }
php
{ "resource": "" }
q245171
PropertyDefinitionBuilder.buildProperty
validation
private function buildProperty(PropertiesDefinitionInterface $definition, IAttribute $attribute, array $propInfo) { if (!$attribute) { return; } $property = $this->getOrCreateProperty($definition, $attribute->getColName()); $this->setLabel($property, $propInfo, $attribute); $this->setDescription($property, $propInfo); $this->setDefaultValue($property, $propInfo); $this->setExcluded($property, $propInfo); $this->setSearchable($property, $propInfo); $this->setFilterable($property, $propInfo); $this->setWidgetType($property, $propInfo); $this->setOptions($property, $propInfo); $this->setExplanation($property, $propInfo); $this->setEval($property, $propInfo, ($attribute instanceof ITranslated)); $this->setEmptyValue($property, $propInfo); }
php
{ "resource": "" }
q245172
PropertyDefinitionBuilder.getOrCreateProperty
validation
private function getOrCreateProperty(PropertiesDefinitionInterface $definition, $propName) { if ($definition->hasProperty($propName)) { return $definition->getProperty($propName); } $property = new DefaultProperty($propName); $definition->addProperty($property); return $property; }
php
{ "resource": "" }
q245173
PropertyDefinitionBuilder.setLabel
validation
private function setLabel(PropertyInterface $property, $propInfo, IAttribute $attribute) { if ($property->getLabel()) { return; } if (!isset($propInfo['label'])) { $property->setLabel($attribute->getName()); return; } $lang = $propInfo['label']; if (is_array($lang)) { $property->setLabel(reset($lang)); $property->setDescription(next($lang)); return; } $property->setLabel($lang); }
php
{ "resource": "" }
q245174
PropertyDefinitionBuilder.setDescription
validation
private function setDescription(PropertyInterface $property, $propInfo) { if ($property->getDescription() || !isset($propInfo['description'])) { return; } $property->setDescription($propInfo['description']); }
php
{ "resource": "" }
q245175
PropertyDefinitionBuilder.setExcluded
validation
private function setExcluded(PropertyInterface $property, $propInfo) { if (!isset($propInfo['exclude'])) { return; } $property->setExcluded((bool) $propInfo['exclude']); }
php
{ "resource": "" }
q245176
PropertyDefinitionBuilder.setSearchable
validation
private function setSearchable(PropertyInterface $property, $propInfo) { if (!isset($propInfo['search'])) { return; } $property->setSearchable((bool) $propInfo['search']); }
php
{ "resource": "" }
q245177
PropertyDefinitionBuilder.setWidgetType
validation
private function setWidgetType(PropertyInterface $property, $propInfo) { if (null !== $property->getWidgetType() || !isset($propInfo['inputType'])) { return; } $property->setWidgetType($propInfo['inputType']); }
php
{ "resource": "" }
q245178
PropertyDefinitionBuilder.setOptions
validation
private function setOptions(PropertyInterface $property, $propInfo) { if (null !== $property->getOptions() || !isset($propInfo['options'])) { return; } $property->setOptions($propInfo['options']); }
php
{ "resource": "" }
q245179
PropertyDefinitionBuilder.setExplanation
validation
private function setExplanation(PropertyInterface $property, $propInfo) { if ($property->getExplanation() || !isset($propInfo['explanation'])) { return; } $property->setExplanation($propInfo['explanation']); }
php
{ "resource": "" }
q245180
PropertyDefinitionBuilder.setEval
validation
private function setEval($property, $propInfo, $isTranslated) { $extra = isset($propInfo['eval']) ? $propInfo['eval'] : []; if ($isTranslated) { $extra['tl_class'] = 'translat-attr' . (!empty($extra['tl_class']) ? ' ' . $extra['tl_class'] : ''); } $property->setExtra(array_merge((array) $property->getExtra(), $extra)); }
php
{ "resource": "" }
q245181
PropertyDefinitionBuilder.setEmptyValue
validation
private function setEmptyValue(PropertyInterface $property, array $propInfo) { if (!array_key_exists('empty_value', $propInfo) || !($property instanceof EmptyValueAwarePropertyInterface)) { return; } $property->setEmptyValue($propInfo['empty_value']); }
php
{ "resource": "" }
q245182
FallbackPropertyConditionFactory.maxChildren
validation
public function maxChildren($conditionType) { if (!isset($GLOBALS['METAMODELS']['inputscreen_conditions'][$conditionType]['maxChildren'])) { return null; } // @codingStandardsIgnoreStart Silencing errors is discouraged @trigger_error('Configuring input screen conditions via global array is deprecated. ' . 'Please implement/configure a valid condition factory.', E_USER_DEPRECATED); // @codingStandardsIgnoreEnd return $GLOBALS['METAMODELS']['inputscreen_conditions'][$conditionType]['maxChildren']; }
php
{ "resource": "" }
q245183
Helper.buildLanguageArray
validation
private static function buildLanguageArray(IMetaModel $metaModel, TranslatorInterface $translator) { $languages = array(); foreach ((array) $metaModel->getAvailableLanguages() as $langCode) { $languages[$langCode] = $translator->translate('LNG.' . $langCode, 'languages'); } asort($languages); return $languages; }
php
{ "resource": "" }
q245184
Helper.prepareLanguageAwareWidget
validation
public static function prepareLanguageAwareWidget( EnvironmentInterface $environment, PropertyInterface $property, IMetaModel $metaModel, $languageLabel, $valueLabel, $isTextArea, $arrValues ) { if (!$metaModel->isTranslated()) { $extra = $property->getExtra(); $extra['tl_class'] .= empty($extra['tl_class']) ? 'w50' : ' w50'; $property ->setWidgetType('text') ->setExtra($extra); return; } $fallback = $metaModel->getFallbackLanguage(); $languages = self::buildLanguageArray($metaModel, $environment->getTranslator()); $neededKeys = array_keys($languages); // Ensure we have values for all languages present. if (array_diff_key(array_keys($arrValues), $neededKeys)) { foreach ($neededKeys as $langCode) { $arrValues[$langCode] = ''; } } $rowClasses = array(); foreach (array_keys($arrValues) as $langCode) { $rowClasses[] = ($langCode == $fallback) ? 'fallback_language' : 'normal_language'; } $extra = $property->getExtra(); $extra['minCount'] = $extra['maxCount'] = count($languages); $extra['disableSorting'] = true; $extra['tl_class'] = 'clr'; $extra['columnFields'] = array ( 'langcode' => array ( 'label' => $languageLabel, 'exclude' => true, 'inputType' => 'justtextoption', 'options' => $languages, 'eval' => array ( 'rowClasses' => $rowClasses, 'valign' => 'center', 'style' => 'min-width:75px;display:block;' ) ), 'value' => array ( 'label' => $valueLabel, 'exclude' => true, 'inputType' => $isTextArea ? 'textarea' : 'text', 'eval' => array ( 'rowClasses' => $rowClasses, 'style' => 'width:400px;', 'rows' => 3 ) ), ); $property ->setWidgetType('multiColumnWizard') ->setExtra($extra); }
php
{ "resource": "" }
q245185
Helper.searchFiles
validation
public static function searchFiles($folder, $extension) { $scanResult = array(); $result = array(); // Check if we have a file or folder. if (is_dir(TL_ROOT . '/' . $folder)) { $scanResult = scan(TL_ROOT . '/' . $folder); } // Run each value. foreach ($scanResult as $value) { if (!is_file(TL_ROOT . '/' . $folder . '/' . $value)) { $result += self::searchFiles($folder . '/' . $value, $extension); } else { if (preg_match('/'.$extension.'$/i', $value)) { $result[$folder][$folder . '/' . $value] = $value; } } } return $result; }
php
{ "resource": "" }
q245186
LoadDataContainer.onLoadDataContainer
validation
public function onLoadDataContainer($tableName) { static $tableExists; // Test that the tables have been created. if (null === $tableExists) { $tableExists = \System::getContainer() ->get('database_connection') ->getSchemaManager() ->tablesExist(['tl_metamodel']); } if (false === $tableExists) { return; } $this->handleMetaModelTable($tableName); $this->handleNonMetaModelTable($tableName); }
php
{ "resource": "" }
q245187
LoadDataContainer.handleMetaModelTable
validation
private function handleMetaModelTable($tableName) { static $tableNames; if (!$tableNames) { $tableNames = $this->factory->collectNames(); } // Not a MetaModel, get out now. if (!in_array($tableName, $tableNames)) { return; } $this->controller->loadLanguageFile('tl_metamodel_item'); $this->controller->loadDataContainer('tl_metamodel_item'); if (!isset($GLOBALS['TL_DCA'][$tableName])) { $GLOBALS['TL_DCA'][$tableName] = []; } $GLOBALS['TL_DCA'][$tableName] = array_replace_recursive( (array) $GLOBALS['TL_DCA']['tl_metamodel_item'], (array) $GLOBALS['TL_DCA'][$tableName] ); }
php
{ "resource": "" }
q245188
LoadDataContainer.handleNonMetaModelTable
validation
private function handleNonMetaModelTable($tableName) { // Nothing to do for MetaModel tables. if (substr($tableName, 0, 3) === 'mm_') { return; } static $map; if (!isset($map)) { $map = $this->buildMap(); } // No children for this table. if (!isset($map[$tableName])) { return; } $parentDCA = &$GLOBALS['TL_DCA'][$tableName]; $this->controller->loadLanguageFile('default'); foreach ($map[$tableName] as $metaModelTable => $inputScreen) { $metaModel = $this->factory->getMetaModel($metaModelTable); $caption = $this->buildCaption($metaModel, $inputScreen); $operationName = 'edit_' . $metaModel->getTableName(); $parentDCA['list']['operations'][$operationName] = array ( 'label' => &$caption, 'href' => 'table=' . $metaModelTable, 'icon' => $this->iconBuilder->getBackendIcon($inputScreen['meta']['backendicon']), 'attributes' => 'onclick="Backend.getScrollOffset()"', ); // Is the destination table a metamodel with variants? if ($metaModel->hasVariants()) { $parentDCA['list']['operations'][$operationName]['idparam'] = 'id_' . $tableName; } else { $parentDCA['list']['operations'][$operationName]['idparam'] = 'pid'; } // Compatibility with DC_Table. if ($parentDCA['config']['dataContainer'] !== 'General') { $idParameter = $parentDCA['list']['operations'][$operationName]['idparam']; $parentDCA['list']['operations'][$operationName]['button_callback'] = function ($row, $href, $label, $name, $icon, $attributes, $table) use ($idParameter) { return $this->buildChildOperationButton( $idParameter, $row['id'], $href, $label, $name, $icon, $attributes, $table ); }; } } }
php
{ "resource": "" }
q245189
LoadDataContainer.buildMap
validation
private function buildMap() { $map = []; foreach ($this->combination->getParented() as $childName => $child) { $map[$child['meta']['ptable']][$childName] = $child; } return $map; }
php
{ "resource": "" }
q245190
LoadDataContainer.buildCaption
validation
private function buildCaption($metaModel, $inputScreen): array { $caption = [ sprintf($GLOBALS['TL_LANG']['MSC']['metamodel_edit_as_child']['label'], $metaModel->getName()), '' ]; foreach ($inputScreen['label'] as $langCode => $label) { if ($label !== '' && $langCode === $GLOBALS['TL_LANGUAGE']) { $caption = [ $label, $inputScreen['description'][$langCode] ]; } } return $caption; }
php
{ "resource": "" }
q245191
LoadDataContainer.buildChildOperationButton
validation
private function buildChildOperationButton($idParameter, $itemId, $href, $label, $name, $icon, $attributes, $table) { $modelId = ModelId::fromValues($table, $itemId); $url = $href . '&amp;' . $idParameter . '=' . $modelId->getSerialized(); // If id parameter different, we have to override it in the URL. if ('id' !== $idParameter) { $url .= '&amp;id='; } $url = $this->controller->addToUrl($url); // If id parameter different, we have to clean out the id in the URL now. if ('id' !== $idParameter) { $url = preg_replace('#(&amp;)id=(?:&amp;)?#', '$1', $url); } $title = sprintf($label ?: $name, $itemId); return sprintf( '<a href="%1$s" title="%2$s"%3$s>%4$s</a> ', $url, specialchars($title), $attributes, $this->iconBuilder->getBackendIconImageTag($icon, $label) ); }
php
{ "resource": "" }
q245192
Item.isEmptyValue
validation
protected function isEmptyValue($mixValue) { if (is_array($mixValue)) { return $this->isArrayEmpty($mixValue); } elseif ($mixValue === '') { return true; } elseif ($mixValue === null) { return true; } return false; }
php
{ "resource": "" }
q245193
Item.isArrayEmpty
validation
protected function isArrayEmpty($arrArray) { // First off check for simple types. if (empty($arrArray)) { return true; } // Next check for a value array. if (is_array($arrArray) && array_key_exists('value', $arrArray)) { return $this->isArrayEmpty($arrArray['value']); } // Now check sub arrays. if (is_array($arrArray)) { foreach ($arrArray as $value) { if (is_array($value)) { return $this->isArrayEmpty($value); } elseif (!empty($value)) { return false; } } } return false; }
php
{ "resource": "" }
q245194
Item.get
validation
public function get($strAttributeName) { return array_key_exists($strAttributeName, $this->arrData) ? $this->arrData[$strAttributeName] : null; }
php
{ "resource": "" }
q245195
Item.getVariants
validation
public function getVariants($objFilter) { if ($this->isVariantBase()) { return $this->getMetaModel()->findVariants(array($this->get('id')), $objFilter); } return null; }
php
{ "resource": "" }
q245196
Item.getVariantBase
validation
public function getVariantBase() { if ($this->getMetaModel()->hasVariants() && !$this->isVariantBase()) { return $this->getMetaModel()->findById($this->get('vargroup')); } return $this; }
php
{ "resource": "" }
q245197
Item.getSiblings
validation
public function getSiblings($objFilter) { if (!$this->getMetaModel()->hasVariants()) { return null; } return $this->getMetaModel()->findVariantsWithBase(array($this->get('id')), $objFilter); }
php
{ "resource": "" }
q245198
Item.save
validation
public function save($timestamp = null) { if (null === $timestamp) { // @codingStandardsIgnoreStart @\trigger_error( 'Not passing a timestamp has been deprecated and will cause an error in MetaModels 3', E_USER_DEPRECATED ); // @codingStandardsIgnoreEnd } $objMetaModel = $this->getMetaModel(); $objMetaModel->saveItem($this, $timestamp); }
php
{ "resource": "" }
q245199
Item.registerAssets
validation
protected function registerAssets($objSettings) { if (!$objSettings) { return; } // Include CSS. $arrCss = $objSettings->get('additionalCss'); foreach ((array) $arrCss as $arrFile) { if ($arrFile['published']) { $GLOBALS['TL_CSS'][md5($arrFile['file'])] = $arrFile['file']; } } // Include JS. $arrJs = $objSettings->get('additionalJs'); foreach ((array) $arrJs as $arrFile) { if ($arrFile['published']) { $GLOBALS['TL_JAVASCRIPT'][md5($arrFile['file'])] = $arrFile['file']; } } }
php
{ "resource": "" }