_id
stringlengths 2
7
| title
stringlengths 3
151
| partition
stringclasses 3
values | text
stringlengths 83
13k
| language
stringclasses 1
value | meta_information
dict |
---|---|---|---|---|---|
q245000 | NameAndDescriptionListener.buildWidget | validation | public function buildWidget(BuildWidgetEvent $event)
{
if (!($this->wantToHandle($event) && \in_array($event->getProperty()->getName(), ['name', 'description']))) {
return;
}
$metaModel = $this->getMetaModelByModelPid($event->getModel());
Helper::prepareLanguageAwareWidget(
$event->getEnvironment(),
$event->getProperty(),
$metaModel,
$this->translator->trans('tl_metamodel_attribute.name_langcode', [], 'contao_tl_metamodel_attribute'),
$this->translator->trans('tl_metamodel_attribute.name_value', [], 'contao_tl_metamodel_attribute'),
false,
StringUtil::deserialize($event->getModel()->getProperty($event->getProperty()->getName()), true)
);
} | php | {
"resource": ""
} |
q245001 | SubPaletteSubscriber.createConditionsForPalette | validation | private function createConditionsForPalette(PaletteInterface $palette, array $typeLegends)
{
$conditions = [];
foreach ($typeLegends as $value => $legends) {
// We use an immutable implementation. Using the same condition is save here.
$valueCondition = new FilterSettingTypeSubPaletteCondition($this->filterFactory, $value);
foreach ($legends as $legendName => $legendProperties) {
$legend = $this->getLegend($palette, $legendName);
foreach ($legendProperties as $propertyName) {
$this
->getConditionChain($legend, $propertyName, $conditions)
->addCondition($valueCondition);
}
}
}
} | php | {
"resource": ""
} |
q245002 | SubPaletteSubscriber.getLegend | validation | private function getLegend(PaletteInterface $palette, $legendName)
{
if ($palette->hasLegend($legendName)) {
return $palette->getLegend($legendName);
}
$legend = new Legend($legendName);
$palette->addLegend($legend);
return $legend;
} | php | {
"resource": ""
} |
q245003 | SubPaletteSubscriber.getConditionChain | validation | private function getConditionChain(LegendInterface $legend, $propertyName, array &$conditions)
{
// Cache condition chain for each legend property.
if (isset($conditions[$legend->getName()][$propertyName])) {
return $conditions[$legend->getName()][$propertyName];
}
$property = $this->getLegendProperty($legend, $propertyName);
// There is no condition assigned to the property. Create an condition chain with an and conjunction
// and add the condition condition chain for the sub palette with an or condition to it.
$condition = $this->getVisibleCondition($property);
$orCondition = new PropertyConditionChain();
$orCondition->setConjunction(PropertyConditionChain::OR_CONJUNCTION);
$conditions[$legend->getName()][$propertyName] = $orCondition;
$condition->addCondition($orCondition);
return $orCondition;
} | php | {
"resource": ""
} |
q245004 | SubPaletteSubscriber.getLegendProperty | validation | private function getLegendProperty(LegendInterface $legend, $propertyName)
{
if ($legend->hasProperty($propertyName)) {
$property = $legend->getProperty($propertyName);
} else {
$property = new Property($propertyName);
$legend->addProperty($property);
}
return $property;
} | php | {
"resource": ""
} |
q245005 | SubPaletteSubscriber.getVisibleCondition | validation | private function getVisibleCondition($property)
{
$condition = $property->getVisibleCondition();
if ($condition instanceof PropertyConditionChain) {
return $condition;
}
$conditionChain = new PropertyConditionChain();
$property->setVisibleCondition($conditionChain);
if ($condition) {
$conditionChain->addCondition($condition);
}
return $conditionChain;
} | php | {
"resource": ""
} |
q245006 | TranslatorPopulator.mapTranslations | validation | private function mapTranslations($array, $domain, StaticTranslator $translator, $baseKey = '')
{
foreach ($array as $key => $value) {
$newKey = ($baseKey ? $baseKey . '.' : '') . $key;
if (is_array($value)) {
$this->mapTranslations($value, $domain, $translator, $newKey);
} else {
$translator->setValue($newKey, $value, $domain);
}
}
} | php | {
"resource": ""
} |
q245007 | TranslatorPopulator.addInputScreenTranslations | validation | private function addInputScreenTranslations(StaticTranslator $translator, $inputScreen, $containerName)
{
$currentLocale = $GLOBALS['TL_LANGUAGE'];
foreach ($inputScreen['legends'] as $legendName => $legendInfo) {
foreach ($legendInfo['label'] as $langCode => $label) {
$translator->setValue(
$legendName . '_legend',
$label,
$containerName,
$langCode
);
if ($currentLocale === $langCode) {
$translator->setValue(
$legendName . '_legend',
$label,
$containerName
);
}
}
}
} | php | {
"resource": ""
} |
q245008 | DefaultOptionListener.getOptions | validation | private function getOptions($attribute, $onlyUsed)
{
// Remove empty values.
$options = [];
foreach ($attribute->getFilterOptions(null, $onlyUsed) as $key => $value) {
// Remove html/php tags.
$value = trim(strip_tags($value));
if (!empty($value)) {
$options[$key] = $value;
}
}
return $options;
} | php | {
"resource": ""
} |
q245009 | Configuration.resolvePath | validation | private function resolvePath($value)
{
$path = Path::canonicalize($value);
if ('\\' === DIRECTORY_SEPARATOR) {
$path = str_replace('/', '\\', $path);
}
return $path;
} | php | {
"resource": ""
} |
q245010 | RenderSettingFactory.collectAttributeSettings | validation | public function collectAttributeSettings(IMetaModel $metaModel, $renderSetting)
{
$attributeRows = $this
->database
->createQueryBuilder()
->select('*')
->from('tl_metamodel_rendersetting')
->where('pid=:pid')
->andWhere('enabled=1')
->orderBy('sorting')
->setParameter('pid', $renderSetting->get('id'))
->execute();
foreach ($attributeRows->fetchAll(\PDO::FETCH_ASSOC) as $attributeRow) {
$attribute = $metaModel->getAttributeById($attributeRow['attr_id']);
if (!$attribute) {
continue;
}
$attributeSetting = $renderSetting->getSetting($attribute->getColName());
if (!$attributeSetting) {
$attributeSetting = $attribute->getDefaultRenderSettings();
}
foreach ($attributeRow as $strKey => $varValue) {
if ($varValue) {
$attributeSetting->set($strKey, StringUtil::deserialize($varValue));
}
}
$renderSetting->setSetting($attribute->getColName(), $attributeSetting);
}
} | php | {
"resource": ""
} |
q245011 | RenderSettingFactory.internalCreateRenderSetting | validation | protected function internalCreateRenderSetting(IMetaModel $metaModel, $settingId)
{
$row = $this
->database
->createQueryBuilder()
->select('*')
->from('tl_metamodel_rendersettings')
->where('pid=:pid')
->andWhere('id=:id')
->setParameter('pid', $metaModel->get('id'))
->setParameter('id', $settingId ?: 0)
->setMaxResults(1)
->execute()
->fetch(\PDO::FETCH_ASSOC);
if (!$row) {
$row = [];
}
$renderSetting = new Collection(
$metaModel,
$row,
$this->eventDispatcher,
$this->filterFactory,
$this->filterUrlBuilder
);
if ($renderSetting->get('id')) {
$this->collectAttributeSettings($metaModel, $renderSetting);
}
return $renderSetting;
} | php | {
"resource": ""
} |
q245012 | FixupUserGroupModules.fixupModules | validation | public function fixupModules(DataContainer $dataContainer)
{
if (!class_exists('tl_user_group', false)) {
throw new \RuntimeException('data container is not loaded!');
}
$original = new \tl_user_group();
$modules = $original->getModules();
// 1. remove all MetaModels
foreach (array_keys($modules) as $group) {
foreach ($modules[$group] as $key => $module) {
if (strpos($module, 'metamodel_') === 0) {
unset($modules[$group][$key]);
}
}
// Otherwise we end up with an associative array.
$modules[$group] = array_values($modules[$group]);
}
// 2. Add our "custom" modules and remove the main module.
$modules['metamodels'][] = 'support_metamodels';
if (false !== $index = array_search('metamodels', $modules['metamodels'], true)) {
unset($modules['metamodels'][$index]);
$modules['metamodels'] = array_values($modules['metamodels']);
}
// 3. Add back all MetaModels for the current group.
$combinations = $this->combinationBuilder->getCombinationsForUser([$dataContainer->activeRecord->id], 'be');
$screenIds = array_map(function ($combination) {
return $combination['dca_id'];
}, $combinations['byName']);
$screens = $this->inputScreens->fetchInputScreens($screenIds);
$locale = $this->requestStack->getCurrentRequest()->getLocale();
foreach ($screens as $metaModel => $screen) {
if ('standalone' === $screen['meta']['rendertype']) {
$modules[$screen['meta']['backendsection']][] = 'metamodel_' . $metaModel;
$this->buildLanguageString('metamodel_' . $metaModel, $screen, $locale);
}
}
return $modules;
} | php | {
"resource": ""
} |
q245013 | FixupUserGroupModules.buildLanguageString | validation | private function buildLanguageString($name, $screen, $locale)
{
if (isset($screen['label'][$locale])) {
$GLOBALS['TL_LANG']['MOD'][$name] = $screen['label'][$locale];
return;
}
$GLOBALS['TL_LANG']['MOD'][$name] = $screen['label'][''];
} | php | {
"resource": ""
} |
q245014 | PaletteRestrictionListener.buildMetaPaletteConditions | validation | private function buildMetaPaletteConditions($palette, $metaPalettes)
{
foreach ($metaPalettes as $typeName => $paletteInfo) {
if ('default' === $typeName) {
continue;
}
if (preg_match('#^(\w+) extends (\w+)$#', $typeName, $matches)) {
$typeName = $matches[1];
}
foreach ($paletteInfo as $legendName => $properties) {
foreach ($properties as $propertyName) {
$condition = new AttributeByIdIsOfType($typeName, $this->connection, 'attr_id');
$legend = $this->getLegend($legendName, $palette);
$property = $this->getProperty($propertyName, $legend);
$this->addCondition($property, $condition);
}
}
}
} | php | {
"resource": ""
} |
q245015 | PropertyConditionFactory.getTypeNames | validation | public function getTypeNames()
{
$names = $this->factories->ids();
if ([] !== $fallback = $this->fallbackFactory->getIds()) {
$names = array_unique(array_merge($fallback, $names));
}
return $names;
} | php | {
"resource": ""
} |
q245016 | PropertyConditionFactory.maxChildren | validation | public function maxChildren($conditionType)
{
$factory = $this->factories->has($conditionType) ? $this->getFactory($conditionType) : null;
if (!$factory instanceof NestablePropertyConditionFactoryInterface) {
if (null !== $value = $this->fallbackFactory->maxChildren($conditionType)) {
return $value;
}
return 0;
}
return $factory->maxChildren();
} | php | {
"resource": ""
} |
q245017 | PickerWidget.run | validation | public function run()
{
$template = new BackendTemplate('be_dcastylepicker');
$template->main = '';
$template->headline = $GLOBALS['TL_LANG']['MSC']['metamodelspicker'];
$inputName = Input::get('inputName');
if (!preg_match('~^[a-z\-_0-9]+$~i', $inputName)) {
throw new RuntimeException('Field-Parameter ERROR!');
}
$template->field = $inputName;
$template->items = $GLOBALS[Input::get('item')];
if (!strlen($template->headline)) {
$template->headline = $GLOBALS['TL_CONFIG']['websiteTitle'];
}
$template->theme = Backend::getTheme();
$template->base = Environment::get('base');
$template->language = $GLOBALS['TL_LANGUAGE'];
$template->title = $GLOBALS['TL_CONFIG']['websiteTitle'];
$template->charset = $GLOBALS['TL_CONFIG']['characterSet'];
$template->pageOffset = Input::cookie('BE_PAGE_OFFSET');
$template->error = (Input::get('act') == 'error') ? $GLOBALS['TL_LANG']['ERR']['general'] : '';
$template->skipNavigation = $GLOBALS['TL_LANG']['MSC']['skipNavigation'];
$template->request = ampersand(Environment::get('request'));
$template->top = $GLOBALS['TL_LANG']['MSC']['backToTop'];
$template->be27 = !$GLOBALS['TL_CONFIG']['oldBeTheme'];
$template->expandNode = $GLOBALS['TL_LANG']['MSC']['expandNode'];
$template->collapseNode = $GLOBALS['TL_LANG']['MSC']['collapseNode'];
$template->strField = Input::get('fld');
$template->output();
} | php | {
"resource": ""
} |
q245018 | SimpleLookup.getParamName | validation | protected function getParamName()
{
if ($this->get('urlparam')) {
return $this->get('urlparam');
}
$objAttribute = $this->getFilteredAttribute();
if ($objAttribute) {
return $objAttribute->getColName();
}
return null;
} | php | {
"resource": ""
} |
q245019 | SimpleLookup.getLabel | validation | protected function getLabel()
{
if (null === ($attribute = $this->getFilteredAttribute())) {
return null;
}
if ($label = $this->get('label')) {
return $label;
}
return $attribute->getName();
} | php | {
"resource": ""
} |
q245020 | SimpleLookup.getParameterFilterOptions | validation | protected function getParameterFilterOptions($objAttribute, $arrIds, &$arrCount = null)
{
$arrOptions = $objAttribute->getFilterOptions(
$this->get('onlypossible') ? $arrIds : null,
(bool) $this->get('onlyused'),
$arrCount
);
// Remove empty values.
foreach ($arrOptions as $mixOptionKey => $mixOptions) {
// Remove html/php tags.
$mixOptions = strip_tags($mixOptions);
$mixOptions = trim($mixOptions);
if ($mixOptions === '' || $mixOptions === null) {
unset($arrOptions[$mixOptionKey]);
}
}
return $arrOptions;
} | php | {
"resource": ""
} |
q245021 | SimpleLookup.getFilteredAttribute | validation | protected function getFilteredAttribute()
{
if (!($attributeId = $this->get('attr_id'))) {
return null;
}
if ($attribute = $this->getMetaModel()->getAttributeById($attributeId)) {
return $attribute;
}
return null;
} | php | {
"resource": ""
} |
q245022 | SimpleLookup.determineFilterValue | validation | private function determineFilterValue($filterValues, $valueName)
{
if (!isset($filterValues[$valueName]) && $this->get('defaultid')) {
return $this->get('defaultid');
}
return $filterValues[$valueName];
} | php | {
"resource": ""
} |
q245023 | AttributeRendererListener.modelToLabel | validation | public function modelToLabel(ModelToLabelEvent $event)
{
if (!$this->wantToHandle($event)) {
return;
}
$model = $event->getModel();
$type = $model->getProperty('type');
$image = '<img src="' . $this->attributeFactory->getIconForType($type) . '" />';
$metaModel = $this->getMetaModelByModelPid($model);
$attribute = $this->attributeFactory->createAttribute($model->getPropertiesAsArray(), $metaModel);
if (!$attribute) {
$translator = $event
->getEnvironment()
->getTranslator();
$event
->setLabel(
'<div class="field_heading cte_type"><strong>%s</strong> <em>[%s]</em></div>
<div class="field_type block">
<strong>%s</strong><br />
</div>'
)
->setArgs(
array
(
$translator->translate('error_unknown_attribute.0', 'tl_metamodel_attribute'),
$type,
$translator->translate('error_unknown_attribute.1', 'tl_metamodel_attribute', array($type)),
)
);
return;
}
$colName = $attribute->getColName();
$name = $attribute->getName();
$arrDescription = StringUtil::deserialize($attribute->get('description'));
if (is_array($arrDescription)) {
$description = $arrDescription[$attribute->getMetaModel()->getActiveLanguage()];
if (!$description) {
$description = $arrDescription[$attribute->getMetaModel()->getFallbackLanguage()];
}
} else {
$description = $arrDescription ?: $attribute->getName();
}
$event
->setLabel(
'<div class="field_heading cte_type"><strong>%s</strong> <em>[%s]</em></div>
<div class="field_type block">
%s<strong>%s</strong> - %s
</div>'
)
->setArgs(array(
$colName,
$type,
$image,
$name,
$description
));
} | php | {
"resource": ""
} |
q245024 | BreadcrumbDcaSettingConditionListener.getConditionAttribute | validation | private function getConditionAttribute($settingId)
{
$setting = $this->getRow($settingId, 'tl_metamodel_dcasetting');
if ($setting->dcatype == 'attribute') {
$attribute = (object) $this->getRow($setting->attr_id, 'tl_metamodel_attribute');
$metaModelName = $this->factory->translateIdToMetaModelName($attribute->pid);
$attribute = $this->factory->getMetaModel($metaModelName)->getAttributeById($attribute->id);
if ($attribute) {
return $attribute->getName();
}
} else {
$title = StringUtil::deserialize($setting->legendtitle, true);
return isset($title[$GLOBALS['TL_LANGUAGE']]) ? $title[$GLOBALS['TL_LANGUAGE']] : current($title);
}
return 'unknown ' . $setting->dcatype;
} | php | {
"resource": ""
} |
q245025 | FixTypeSafetyListener.handle | validation | public function handle(EncodePropertyValueFromWidgetEvent $event)
{
if (('tl_metamodel_dca_combine' !== $event->getEnvironment()->getDataDefinition()->getName())
|| ('rows' !== $event->getProperty())) {
return;
}
$environment = $event->getEnvironment();
$dataProvider = $environment->getDataProvider();
$properties = $environment->getDataDefinition()->getPropertiesDefinition();
$values = (array) $event->getValue();
foreach ($values as $row => $current) {
$values[$row] = $this->updateValues($current, $properties, $dataProvider);
}
$event->setValue($values);
} | php | {
"resource": ""
} |
q245026 | FixTypeSafetyListener.updateValues | validation | private function updateValues(
array &$values,
PropertiesDefinitionInterface $properties,
DataProviderInterface $dataProvider
) {
foreach ($values as $propertyName => $propertyValue) {
if (($dataProvider->getIdProperty() === $propertyName)
|| ($dataProvider->getGroupColumnProperty() === $propertyName)
|| ($dataProvider->getSortingColumnProperty() === $propertyName)
|| ($dataProvider->getTimeStampProperty() === $propertyName)
|| !$properties->hasProperty($propertyName)
) {
continue;
}
$values[$propertyName] =
ModelManipulator::sanitizeValue($properties->getProperty($propertyName), $propertyValue);
}
return $values;
} | php | {
"resource": ""
} |
q245027 | BaseSubscriber.addListener | validation | public function addListener($eventName, $listener, $priority = 200)
{
$dispatcher = $this->getServiceContainer()->getEventDispatcher();
$dispatcher->addListener($eventName, $listener, $priority);
return $this;
} | php | {
"resource": ""
} |
q245028 | BaseSubscriber.getMetaModelById | validation | protected function getMetaModelById($modelId)
{
$services = $this->getServiceContainer();
$modelFactory = $services->getFactory();
$name = $modelFactory->translateIdToMetaModelName($modelId);
return $modelFactory->getMetaModel($name);
} | php | {
"resource": ""
} |
q245029 | AbstractConditionBuilder.calculateConditions | validation | public static function calculateConditions(IMetaModelDataDefinition $container, array $inputScreen)
{
if ($container->hasDefinition(ModelRelationshipDefinitionInterface::NAME)) {
$definition = $container->getDefinition(ModelRelationshipDefinitionInterface::NAME);
} else {
$definition = new DefaultModelRelationshipDefinition();
$container->setDefinition(ModelRelationshipDefinitionInterface::NAME, $definition);
}
if (!$definition instanceof ModelRelationshipDefinitionInterface) {
throw new \InvalidArgumentException('Search element does not implement the correct interface.');
}
$instance = new static();
$instance->container = $container;
$instance->inputScreen = $inputScreen;
$instance->definition = $definition;
$instance->calculate();
} | php | {
"resource": ""
} |
q245030 | TranslatedReference.getSetValues | validation | protected function getSetValues($arrValue, $intId, $strLangCode)
{
if (($arrValue !== null) && !is_array($arrValue)) {
throw new \InvalidArgumentException(sprintf('Invalid value provided: %s', var_export($arrValue, true)));
}
return array
(
'tstamp' => time(),
'value' => (string) $arrValue['value'],
'att_id' => $this->get('id'),
'langcode' => $strLangCode,
'item_id' => $intId,
);
} | php | {
"resource": ""
} |
q245031 | TranslatedReference.determineLanguages | validation | private function determineLanguages()
{
$languages = $this->getMetaModel()->getAvailableLanguages();
if ($languages === null) {
throw new \RuntimeException(
'MetaModel ' . $this->getMetaModel()->getName() . ' does not seem to be translated.'
);
}
return $languages;
} | php | {
"resource": ""
} |
q245032 | TranslatedReference.fetchExistingIdsFor | validation | protected function fetchExistingIdsFor($idList, $langCode)
{
$queryBuilder = $this
->connection
->createQueryBuilder()
->select('item_id')
->from($this->getValueTable());
$this->buildWhere($queryBuilder, $idList, $langCode);
$statement = $queryBuilder->execute();
return $statement->fetchAll(\PDO::FETCH_COLUMN);
} | php | {
"resource": ""
} |
q245033 | PasteButtonListener.getModelById | validation | private function getModelById($modelId)
{
if ($modelId === null) {
return null;
}
$provider = $this->environment->getDataProvider();
$config = $provider
->getEmptyConfig()
->setId($modelId);
return $provider->fetch($config);
} | php | {
"resource": ""
} |
q245034 | PasteButtonListener.hasVariants | validation | private function hasVariants()
{
$metaModel = $this->factory->getMetaModel($this->providerName);
if ($metaModel === null) {
throw new \RuntimeException(sprintf('Could not find a MetaModels with the name %s', $this->providerName));
}
return $metaModel->hasVariants();
} | php | {
"resource": ""
} |
q245035 | PasteButtonListener.checkForAction | validation | private function checkForAction($clipboard, $action)
{
// Make a filter for the given action.
$filter = new Filter();
$filter->andActionIs($action);
$items = $clipboard->fetch($filter);
// Check if there are items.
if ($items === null) {
return;
}
/** @var ItemInterface[] $items */
foreach ($items as $item) {
// Check the context.
$itemProviderName = $item->getDataProviderName();
$modelId = $item->getModelId();
if ($this->providerName !== $itemProviderName) {
continue;
}
if (!$modelId) {
$this->checkEmpty($action);
continue;
}
$containedModel = $this->getModelById($modelId->getId());
if ($this->currentModel == null) {
$this->checkForRoot($containedModel, $action);
} elseif ($containedModel) {
$this->checkForModel($containedModel, $action);
} else {
$this->checkEmpty($action);
}
}
} | php | {
"resource": ""
} |
q245036 | PasteButtonListener.checkEmpty | validation | private function checkEmpty($action)
{
if ($this->hasVariants() && $this->currentModel !== null) {
$this->disablePA = false;
} elseif ($action == 'create') {
$this->disablePA = false;
$this->disablePI = false;
}
} | php | {
"resource": ""
} |
q245037 | PasteButtonListener.checkForRoot | validation | private function checkForRoot($containedModel, $action)
{
if ($this->hasVariants() && $action == 'cut' && $containedModel->getProperty('varbase') == 0) {
$this->disablePI = true;
}
} | php | {
"resource": ""
} |
q245038 | PasteButtonListener.checkForModel | validation | private function checkForModel($containedModel, $action)
{
if (!$this->circularReference) {
if ($this->hasVariants()) {
$this->checkModelWithVariants($containedModel);
}
$this->checkModelWithoutVariants($containedModel);
} elseif ($this->currentModel == null && $containedModel->getProperty('varbase') == 0) {
$this->disablePA = true;
} else {
$this->disablePA = false;
// The following rules apply:
// 1. Variant bases must not get pasted into anything.
// 2. If we are not in create mode, disable the paste into for the item itself.
$this->disablePI =
($this->hasVariants() && $containedModel->getProperty('varbase') == 1)
|| ($action != 'create' && $containedModel->getId() == $this->currentModel->getId());
}
} | php | {
"resource": ""
} |
q245039 | PasteButtonListener.checkModelWithVariants | validation | private function checkModelWithVariants($containedModel)
{
// Item and variant support.
$isVarbase = (bool) $containedModel->getProperty('varbase');
$vargroup = $containedModel->getProperty('vargroup');
$isCurrentVarbase = (bool) $this->currentModel->getProperty('varbase');
$currentVargroup = $this->currentModel->getProperty('vargroup');
if ($isVarbase && !$this->circularReference && $isCurrentVarbase) {
// Insert new items only after bases.
// Insert a varbase after any other varbase, for sorting.
$this->disablePA = false;
} elseif (!$isVarbase && !$isCurrentVarbase && $vargroup == $currentVargroup) {
// Move items in their vargroup and only there.
$this->disablePA = false;
}
$this->disablePI = !$isCurrentVarbase || $isVarbase;
} | php | {
"resource": ""
} |
q245040 | PasteButtonListener.checkModelWithoutVariants | validation | private function checkModelWithoutVariants($containedModel)
{
$parentDefinition = $this->environment->getDataDefinition()->getBasicDefinition()->getParentDataProvider();
$this->disablePA = ($this->currentModel->getId() == $containedModel->getId())
|| ($parentDefinition && $this->currentModel->getProperty('pid') == $containedModel->getProperty('pid'));
$this->disablePI = ($this->circularReference)
|| ($this->currentModel->getId() == $containedModel->getId())
|| ($parentDefinition && $this->currentModel->getProperty('pid') == $containedModel->getId());
} | php | {
"resource": ""
} |
q245041 | AbstractListener.getMetaModel | validation | public function getMetaModel(EnvironmentInterface $interface)
{
$metaModelId = $this->connection->createQueryBuilder()
->select('d.pid')
->from('tl_metamodel_dca', 'd')
->leftJoin('d', 'tl_metamodel_dcasetting', 's', '(d.id=s.pid)')
->where('(s.id=:id)')
->setParameter('id', ModelId::fromSerialized($interface->getInputProvider()->getParameter('pid'))->getId())
->execute();
if ($tableName = $this->factory->translateIdToMetaModelName($metaModelId = $metaModelId->fetchColumn())) {
return $this->factory->getMetaModel($tableName);
}
throw new \RuntimeException('Could not retrieve MetaModel ' . $metaModelId);
} | php | {
"resource": ""
} |
q245042 | MetaModelsServiceContainer.getCache | validation | public function getCache()
{
// @codingStandardsIgnoreStart
@trigger_error(
'"' .__METHOD__ . '" is deprecated as the service container will get removed.',
E_USER_DEPRECATED
);
// @codingStandardsIgnoreEnd
if (\is_callable($this->cache)) {
$this->cache = \call_user_func($this->cache);
}
return $this->cache;
} | php | {
"resource": ""
} |
q245043 | PaletteBuilder.getOrCreatePaletteDefinition | validation | private function getOrCreatePaletteDefinition(IMetaModelDataDefinition $container)
{
if ($container->hasDefinition(PalettesDefinitionInterface::NAME)) {
return $container->getDefinition(PalettesDefinitionInterface::NAME);
}
$container->setDefinition(
PalettesDefinitionInterface::NAME,
$palettesDefinition = new DefaultPalettesDefinition()
);
return $palettesDefinition;
} | php | {
"resource": ""
} |
q245044 | PaletteBuilder.createProperty | validation | private function createProperty(
PropertyInterface $property,
$propertyName,
$variantHandling,
ConditionInterface $condition = null,
ConditionInterface $legendCondition = null
) {
$paletteProperty = new Property($propertyName);
$extra = $property->getExtra();
$chain = new PropertyConditionChain();
$paletteProperty->setEditableCondition($chain);
if (isset($extra['readonly'])) {
$chain->addCondition(new BooleanCondition($extra['readonly']));
}
$chain = new PropertyConditionChain();
$paletteProperty->setVisibleCondition($chain);
// If variants, do show only if allowed.
if ($variantHandling) {
$chain->addCondition(new IsVariantAttribute());
}
$chain->addCondition(
new BooleanCondition(
!((isset($extra['doNotShow']) && $extra['doNotShow'])
|| (isset($extra['hideInput']) && $extra['hideInput']))
)
);
if (null !== $condition) {
$chain->addCondition($condition);
}
if (null !== $legendCondition) {
$chain->addCondition($legendCondition);
}
return $paletteProperty;
} | php | {
"resource": ""
} |
q245045 | PaletteBuilder.buildCondition | validation | private function buildCondition($condition, $metaModel)
{
if (null === $condition) {
return null;
}
return $this->conditionFactory->createCondition($condition, $metaModel);
} | php | {
"resource": ""
} |
q245046 | Module.generate | validation | public function generate()
{
$GLOBALS['TL_CSS'][] = 'bundles/metamodelscore/css/style.css';
$arrModule = $GLOBALS['BE_MOD']['metamodels']['metamodels'];
// Custom action (if key is not defined in config.php the default action will be called).
if (\Input::get('key') && isset($arrModule[\Input::get('key')])) {
Callbacks::call($arrModule[\Input::get('key')], $this, $arrModule);
}
$act = \Input::get('act');
if (!strlen($act)) {
$act = 'showAll';
}
return $this->dataContainer->getEnvironment()->getController()->handle(new Action($act));
} | php | {
"resource": ""
} |
q245047 | AttributeSavedListener.isAttributeNameOrTypeChanged | validation | private function isAttributeNameOrTypeChanged(ModelInterface $new, ModelInterface $old)
{
return ($old->getProperty('type') !== $new->getProperty('type'))
|| ($old->getProperty('colname') !== $new->getProperty('colname'));
} | php | {
"resource": ""
} |
q245048 | InputScreen.translateLegend | validation | protected function translateLegend($legend, $metaModel)
{
$arrLegend = StringUtil::deserialize($legend['legendtitle']);
if (is_array($arrLegend)) {
// Try to use the language string from the array.
$strLegend = $arrLegend[$GLOBALS['TL_LANGUAGE']];
if (!$strLegend) {
// Use the fallback.
$strLegend = $arrLegend[$metaModel->getFallbackLanguage()];
if (!$strLegend) {
// Last resort, simply "legend". See issue #926.
$strLegend = 'legend' . (count($this->legends) + 1);
}
}
} else {
$strLegend = $legend['legendtitle'] ? $legend['legendtitle'] : 'legend';
}
$legendName = StringUtil::standardize($strLegend);
$this->legends[$legendName] = array
(
'name' => $strLegend,
'visible' => !(isset($legend['legendhide']) && (bool) $legend['legendhide']),
'properties' => array()
);
return $legendName;
} | php | {
"resource": ""
} |
q245049 | InputScreen.translateProperty | validation | protected function translateProperty($property, $metaModel, $legend)
{
$attribute = $metaModel->getAttributeById($property['attr_id']);
// Dead meat.
if (!$attribute) {
return false;
}
$propName = $attribute->getColName();
$this->legends[$legend]['properties'][] = $propName;
$this->properties[$propName] = array
(
'info' => $attribute->getFieldDefinition($property),
);
return true;
} | php | {
"resource": ""
} |
q245050 | InputScreen.applyLegendConditions | validation | protected function applyLegendConditions($attributeId, $activeLegendId)
{
// No conditions for legend defined.
if (!isset($this->conditions[$activeLegendId])) {
return;
}
if (!isset($this->conditions[$attributeId])) {
$this->conditions[$attributeId] = new PropertyConditionChain();
}
$this->conditions[$attributeId]->addCondition($this->conditions[$activeLegendId]);
} | php | {
"resource": ""
} |
q245051 | InputScreen.translateRows | validation | protected function translateRows($rows)
{
$metaModel = $this->getMetaModel();
$activeLegend = $this->translateLegend(
array('legendtitle' => $metaModel->getName(), 'legendhide' => false),
$metaModel
);
$activeLegendId = null;
// First pass, fetch all attribute names.
$columnNames = array();
foreach ($rows as $row) {
if ($row['dcatype'] != 'attribute') {
continue;
}
$attribute = $metaModel->getAttributeById($row['attr_id']);
if ($attribute) {
$columnNames[$row['id']] = $attribute->getColName();
}
}
$this->propertyMap = $columnNames;
$this->propertyMap2 = array_flip($columnNames);
// Second pass, translate all information into local properties.
foreach ($rows as $row) {
switch ($row['dcatype']) {
case 'legend':
$activeLegend = $this->translateLegend($row, $metaModel);
$activeLegendId = $row['id'];
break;
case 'attribute':
$exists = $this->translateProperty($row, $metaModel, $activeLegend);
if ($exists && $activeLegendId) {
$this->applyLegendConditions($row['id'], $activeLegendId);
}
break;
default:
throw new \RuntimeException('Unknown palette rendering mode ' . $row['dcatype']);
}
}
} | php | {
"resource": ""
} |
q245052 | InputScreen.transformCondition | validation | protected function transformCondition($condition)
{
$dispatcher = $GLOBALS['container']['event-dispatcher'];
$event = new CreatePropertyConditionEvent($condition, $this->getMetaModel());
/** @var \Symfony\Component\EventDispatcher\EventDispatcherInterface $dispatcher */
$dispatcher->dispatch(CreatePropertyConditionEvent::NAME, $event);
if ($event->getInstance() === null) {
throw new \RuntimeException(sprintf(
'Condition of type %s could not be transformed to an instance.',
$condition['type']
));
}
return $event->getInstance();
} | php | {
"resource": ""
} |
q245053 | InputScreen.transformConditions | validation | protected function transformConditions($conditions)
{
// First pass, sort them into pid.
$sorted = array();
$byPid = array();
foreach ($conditions as $i => $condition) {
$sorted[$condition['id']] = $conditions[$i];
$byPid[$condition['pid']][] = $condition['id'];
}
$instances = array();
// Second pass, handle them.
foreach ($sorted as $id => $condition) {
$instances[$id] = $this->transformCondition($condition);
}
// Sort all conditions into their parents.
foreach ($byPid as $pid => $ids) {
foreach ($ids as $id) {
$settingId = $sorted[$id]['settingId'];
if (!isset($this->conditions[$settingId])) {
$this->conditions[$settingId] = new PropertyConditionChain();
}
$result = $this->conditions[$settingId];
$condition = $instances[$id];
$parent = ($pid == 0) ? $result : $instances[$pid];
// have other classes in the future.
if ($parent instanceof ConditionChainInterface) {
$parent->addCondition($condition);
} elseif ($parent instanceof NotCondition) {
$parent->setCondition($condition);
}
}
}
} | php | {
"resource": ""
} |
q245054 | InputScreen.transformGroupSort | validation | protected function transformGroupSort($rows)
{
foreach ($rows as $row) {
$this->groupSort[] = new InputScreenGroupingAndSorting($row, $this);
}
} | php | {
"resource": ""
} |
q245055 | DataProviderPopulator.injectServiceContainerIntoDataDrivers | validation | private function injectServiceContainerIntoDataDrivers($providerDefinitions, $environment)
{
foreach ($providerDefinitions as $provider) {
$providerInstance = $environment->getDataProvider($provider->getName());
if ($providerInstance instanceof Driver) {
$initialization = $provider->getInitializationData();
$metaModel = $this->factory->getMetaModel($initialization['source']);
$providerInstance->setBaseConfig(
array_merge($initialization, ['metaModel' => $metaModel])
);
$providerInstance->setDispatcher($this->dispatcher);
$providerInstance->setConnection($this->connection);
}
}
} | php | {
"resource": ""
} |
q245056 | AbstractAddAllController.process | validation | protected function process($table, $metaModelName, $parentId, Request $request)
{
$this->knownAttributes = $this->fetchExisting($table, $parentId);
$metaModel = $this->factory->getMetaModel($metaModelName);
if (!$metaModel) {
throw new \RuntimeException('Could not retrieve MetaModel ' . $metaModelName);
}
if ($request->request->has('add') || $request->request->has('saveNclose')) {
$this->perform($table, $request, $metaModel, $parentId);
// If we want to close, go back to referer.
if ($request->request->has('saveNclose')) {
return new RedirectResponse($this->getReferer($request, $table, false));
}
}
return new Response($this->templating->render(
'MetaModelsCoreBundle::Backend/add-all.html.twig',
$this->render($table, $metaModel, $request)
));
} | php | {
"resource": ""
} |
q245057 | AbstractAddAllController.render | validation | protected function render($table, $metaModel, Request $request)
{
$fields = $this->generateForm($table, $metaModel, $request);
return [
'action' => '',
'requestToken' => REQUEST_TOKEN,
'href' => $this->getReferer($request, $table, true),
'backBt' => $this->translator->trans('MSC.backBT', [], 'contao_default'),
'add' => $this->translator->trans('MSC.continue', [], 'contao_default'),
'saveNclose' => $this->translator->trans('MSC.saveNclose', [], 'contao_default'),
'activate' => $this->translator->trans($table . '.addAll_activate', [], 'contao_' . $table),
'headline' => $this->translator->trans($table . '.addall.1', [], 'contao_' . $table),
'selectAll' => $this->translator->trans('MSC.selectAll', [], 'contao_default'),
'cacheMessage' => '',
'updateMessage' => '',
'hasCheckbox' => count($fields) > 0,
'fields' => $fields,
];
} | php | {
"resource": ""
} |
q245058 | AbstractAddAllController.fetchExisting | validation | private function fetchExisting($table, $parentId)
{
// Keep the sorting value.
$this->startSort = 0;
$this->knownAttributes = [];
$alreadyExisting = $this
->connection
->createQueryBuilder()
->select('*')
->from($table)
->where('pid=:pid')
->setParameter('pid', $parentId)
->orderBy('sorting')
->execute();
foreach ($alreadyExisting->fetchAll(\PDO::FETCH_ASSOC) as $item) {
$this->knownAttributes[$item['attr_id']] = $item;
$this->startSort = $item['sorting'];
}
return $this->knownAttributes;
} | php | {
"resource": ""
} |
q245059 | AbstractAddAllController.generateForm | validation | private function generateForm($table, $metaModel, Request $request)
{
$fields = [];
// Loop over all attributes now.
foreach ($metaModel->getAttributes() as $attribute) {
$attrId = $attribute->get('id');
if (!$this->accepts($attribute)) {
continue;
}
if ($this->knowsAttribute($attribute)) {
$fields[] = [
'checkbox' => false,
'text' => $this->checkboxCaption('addAll_alreadycontained', $table, $attribute),
'class' => 'tl_info',
'attr_id' => $attrId,
'name' => 'attribute_' . $attrId
];
continue;
} elseif ($this->isAttributeSubmitted($attrId, $request)) {
$fields[] = array(
'checkbox' => false,
'text' => $this->checkboxCaption('addAll_addsuccess', $table, $attribute),
'class' => 'tl_confirm',
'attr_id' => $attrId,
'name' => 'attribute_' . $attrId
);
continue;
}
$fields[] = [
'checkbox' => true,
'text' => $this->checkboxCaption('addAll_willadd', $table, $attribute),
'class' => 'tl_new',
'attr_id' => $attrId,
'name' => 'attribute_' . $attrId
];
}
return $fields;
} | php | {
"resource": ""
} |
q245060 | AbstractAddAllController.checkboxCaption | validation | private function checkboxCaption($key, $table, IAttribute $attribute)
{
return $this->translator->trans($table . '.' . $key, [$attribute->getName()], 'contao_' . $table);
} | php | {
"resource": ""
} |
q245061 | AbstractAddAllController.perform | validation | private function perform($table, Request $request, $metaModel, $parentId)
{
$activate = (bool) $request->request->get('activate');
$query = $this
->connection
->createQueryBuilder()
->insert($table);
foreach ($metaModel->getAttributes() as $attribute) {
if ($this->knowsAttribute($attribute)
|| !($this->accepts($attribute) && $this->isAttributeSubmitted($attribute->get('id'), $request))
) {
continue;
}
$data = [];
foreach ($this->createEmptyDataFor($attribute, $parentId, $activate, $this->startSort) as $key => $value) {
$data[$key] = ':' . $key;
$query->setParameter($key, $value);
}
$query->values($data)->execute();
$this->startSort += 128;
}
$this->purger->purge();
} | php | {
"resource": ""
} |
q245062 | AbstractAddAllController.getReferer | validation | private function getReferer(Request $request, $table, $encodeAmp = false)
{
$uri = $this->systemAdapter->getReferer($encodeAmp, $table);
// Make the location an absolute URL
if (!preg_match('@^https?://@i', $uri)) {
$uri = $request->getBasePath() . '/' . ltrim($uri, '/');
}
return $uri;
} | php | {
"resource": ""
} |
q245063 | PurgeCache.purge | validation | public function purge()
{
$fileSystem = new Filesystem();
$fileSystem->remove($this->cacheDir);
$this->logger->log(
LogLevel::INFO,
'Purged the MetaModels cache',
['contao' => new ContaoContext(__METHOD__, TL_CRON)]
);
} | php | {
"resource": ""
} |
q245064 | FilterUrl.setPageValue | validation | public function setPageValue(string $name, $value): self
{
if (empty($value)) {
unset($this->page[$name]);
return $this;
}
$this->page[$name] = $value;
return $this;
} | php | {
"resource": ""
} |
q245065 | HybridList.getFilterParameters | validation | protected function getFilterParameters($objItemRenderer)
{
$filterUrlBuilder = System::getContainer()->get('metamodels.filter_url');
$filterUrl = $filterUrlBuilder->getCurrentFilterUrl();
$result = [];
foreach ($objItemRenderer->getFilterSettings()->getParameters() as $name) {
if ($filterUrl->hasSlug($name)) {
$result[$name] = $filterUrl->getSlug($name);
}
// DAMN Contao - we have to "mark" the keys in the Input class as used as we get an 404 otherwise.
Input::get($name);
}
return $filterUrl->getSlugParameters();
} | php | {
"resource": ""
} |
q245066 | HybridList.compile | validation | protected function compile()
{
$objItemRenderer = new ItemList();
$this->Template->searchable = !$this->metamodel_donotindex;
$sorting = $this->metamodel_sortby;
$direction = $this->metamodel_sortby_direction;
if ($this->metamodel_sort_override) {
if (\Input::get('orderBy')) {
$sorting = \Input::get('orderBy');
}
if (\Input::get('orderDir')) {
$direction = \Input::get('orderDir');
}
}
$objItemRenderer
->setServiceContainerFallback(
function () {
return $this->getServiceContainer();
}
)
->setFactory(System::getContainer()->get('metamodels.factory'))
->setFilterFactory(System::getContainer()->get('metamodels.filter_setting_factory'))
->setRenderSettingFactory(System::getContainer()->get('metamodels.render_setting_factory'))
->setEventDispatcher(System::getContainer()->get('event_dispatcher'))
->setMetaModel($this->metamodel, $this->metamodel_rendersettings)
->setLimit($this->metamodel_use_limit, $this->metamodel_offset, $this->metamodel_limit)
->setPageBreak($this->perPage)
->setSorting($sorting, $direction)
->setFilterSettings($this->metamodel_filtering)
->setFilterParameters(
StringUtil::deserialize($this->metamodel_filterparams, true),
$this->getFilterParameters($objItemRenderer)
)
->setMetaTags($this->metamodel_meta_title, $this->metamodel_meta_description);
// Render items with encoded email strings as contao standard.
$this->Template->items =
\StringUtil::encodeEmail($objItemRenderer->render($this->metamodel_noparsing, $this));
$this->Template->numberOfItems = $objItemRenderer->getItems()->getCount();
$this->Template->pagination = $objItemRenderer->getPagination();
} | php | {
"resource": ""
} |
q245067 | Simple.isActiveFrontendFilterValue | validation | protected function isActiveFrontendFilterValue($arrWidget, $arrFilterUrl, $strKeyOption)
{
// Special case, the "empty" value first.
if (empty($strKeyOption) && !isset($arrFilterUrl[$arrWidget['eval']['urlparam']])) {
return true;
}
$blnIsActive = isset($arrFilterUrl[$arrWidget['eval']['urlparam']])
&& ($arrFilterUrl[$arrWidget['eval']['urlparam']] == $strKeyOption);
if (!$blnIsActive && $this->get('defaultid')) {
$blnIsActive = ($arrFilterUrl[$arrWidget['eval']['urlparam']] == $this->get('defaultid'));
}
return $blnIsActive;
} | php | {
"resource": ""
} |
q245068 | Simple.getFrontendFilterValue | validation | protected function getFrontendFilterValue($arrWidget, $arrFilterUrl, $strKeyOption)
{
// Toggle if active.
if ($this->isActiveFrontendFilterValue($arrWidget, $arrFilterUrl, $strKeyOption)) {
return '';
}
return $strKeyOption;
} | php | {
"resource": ""
} |
q245069 | Simple.addUrlParameter | validation | protected function addUrlParameter($url, $name, $value)
{
// @codingStandardsIgnoreStart
@trigger_error(
sprintf('"%1$s" has been deprecated in favor of the "FilterUrlBuilder"', __METHOD__),
E_USER_DEPRECATED
);
// @codingStandardsIgnoreEnd
if (is_array($value)) {
$value = implode(',', array_filter($value));
}
$value = str_replace('%', '%%', urlencode($value));
if (empty($value)) {
return $url;
}
if ($name !== 'auto_item') {
$url .= '/' . $name . '/' . $value;
} else {
$url = '/' . $value . $url;
}
return $url;
} | php | {
"resource": ""
} |
q245070 | Simple.buildFilterUrl | validation | protected function buildFilterUrl($fragments, $searchKey)
{
// @codingStandardsIgnoreStart
@trigger_error(
sprintf('"%1$s" has been deprecated in favor of the "FilterUrlBuilder"', __METHOD__),
E_USER_DEPRECATED
);
// @codingStandardsIgnoreEnd
$url = '';
$found = false;
// Create base url containing for preserving the current filter on unrelated widgets and modules.
// The URL parameter concerning us will be masked via %s to be used later on in a sprintf().
foreach ($fragments as $key => $value) {
// Skip the magic "language" parameter.
if (($key == 'language') && $GLOBALS['TL_CONFIG']['addLanguageToUrl']) {
continue;
}
if ($key == $searchKey) {
if ($key !== 'auto_item') {
$url .= '%s';
} else {
$url = '%s' . $url;
}
$found = true;
} else {
$url = $this->addUrlParameter($url, $key, $value);
}
}
// If we have not found our parameter in the URL, we add it as %s now to be able to populate it via sprintf()
// below.
if (!$found) {
if ($searchKey !== 'auto_item') {
$url .= '%s';
} else {
$url = '%s' . $url;
}
}
return $url;
} | php | {
"resource": ""
} |
q245071 | Simple.prepareFrontendFilterOptions | validation | protected function prepareFrontendFilterOptions($arrWidget, $arrFilterUrl, $arrJumpTo, $blnAutoSubmit)
{
$arrOptions = array();
if (!isset($arrWidget['options'])) {
return $arrOptions;
}
$filterUrl = new FilterUrl($arrJumpTo);
foreach ($arrFilterUrl as $name => $value) {
if (is_array($value)) {
$value = implode(',', array_filter($value));
}
$filterUrl->setSlug($name, (string) $value);
}
$parameterName = $arrWidget['eval']['urlparam'];
if ($arrWidget['eval']['includeBlankOption']) {
$blnActive = $this->isActiveFrontendFilterValue($arrWidget, $arrFilterUrl, '');
$arrOptions[] = array
(
'key' => '',
'value' => (
$arrWidget['eval']['blankOptionLabel']
? $arrWidget['eval']['blankOptionLabel']
: $GLOBALS['TL_LANG']['metamodels_frontendfilter']['do_not_filter']
),
'href' => $this->filterUrlBuilder->generate($filterUrl->clone()->setSlug($parameterName, '')),
'active' => $blnActive,
'class' => 'doNotFilter'.($blnActive ? ' active' : ''),
);
}
foreach ($arrWidget['options'] as $strKeyOption => $strOption) {
$strValue = $this->getFrontendFilterValue($arrWidget, $arrFilterUrl, $strKeyOption);
$blnActive = $this->isActiveFrontendFilterValue($arrWidget, $arrFilterUrl, $strKeyOption);
$arrOptions[] = array
(
'key' => $strKeyOption,
'value' => $strOption,
'href' => $this->filterUrlBuilder->generate($filterUrl->clone()->setSlug($parameterName, $strValue)),
'active' => $blnActive,
'class' => StringUtil::standardize($strKeyOption) . ($blnActive ? ' active' : '')
);
}
return $arrOptions;
} | php | {
"resource": ""
} |
q245072 | Simple.prepareFrontendFilterWidget | validation | protected function prepareFrontendFilterWidget(
$arrWidget,
$arrFilterUrl,
$arrJumpTo,
FrontendFilterOptions $objFrontendFilterOptions
) {
$strClass = $GLOBALS['TL_FFL'][$arrWidget['inputType']];
// No widget? no output! that's it.
if (!$strClass) {
return array();
}
// Determine current value.
$arrWidget['value'] = isset($arrFilterUrl[$arrWidget['eval']['urlparam']])
? $arrFilterUrl[$arrWidget['eval']['urlparam']]
: null;
$event = new GetAttributesFromDcaEvent(
$arrWidget,
$arrWidget['eval']['urlparam']
);
$this->eventDispatcher->dispatch(
ContaoEvents::WIDGET_GET_ATTRIBUTES_FROM_DCA,
$event
);
if ($objFrontendFilterOptions->isAutoSubmit() && TL_MODE == 'FE') {
$GLOBALS['TL_JAVASCRIPT']['metamodels'] = 'bundles/metamodelscore/js/metamodels.js';
}
/** @var \Widget $objWidget */
$objWidget = new $strClass($event->getResult());
$this->validateWidget($objWidget, $arrWidget['value']);
$strField = $objWidget->generateWithError();
return array
(
'class' => sprintf(
'mm_%s %s%s%s',
$arrWidget['inputType'],
$arrWidget['eval']['urlparam'],
(($arrWidget['value'] !== null) ? ' used' : ' unused'),
($objFrontendFilterOptions->isAutoSubmit() ? ' submitonchange' : '')
),
'label' => $objWidget->generateLabel(),
'formfield' => $strField,
'raw' => $arrWidget,
'urlparam' => $arrWidget['eval']['urlparam'],
'options' => $this->prepareFrontendFilterOptions(
$arrWidget,
$arrFilterUrl,
$arrJumpTo,
$objFrontendFilterOptions->isAutoSubmit()
),
'count' => isset($arrWidget['count']) ? $arrWidget['count'] : null,
'showCount' => $objFrontendFilterOptions->isShowCountValues(),
'autosubmit' => $objFrontendFilterOptions->isAutoSubmit(),
'urlvalue' => array_key_exists('urlvalue', $arrWidget) ? $arrWidget['urlvalue'] : $arrWidget['value'],
'errors' => $objWidget->hasErrors() ? $objWidget->getErrors() : array()
);
} | php | {
"resource": ""
} |
q245073 | Simple.validateWidget | validation | protected function validateWidget($widget, $value)
{
if (null === $value) {
return;
}
$widget->setInputCallback(function () use ($value) {
return $value;
});
$widget->validate();
} | php | {
"resource": ""
} |
q245074 | Base.getLangValue | validation | protected function getLangValue($arrValues, $strLangCode = null)
{
if (!($this->getMetaModel()->isTranslated() && is_array($arrValues))) {
return $arrValues;
}
if ($strLangCode === null) {
return $this->getLangValue($arrValues, $this->getMetaModel()->getActiveLanguage());
}
if (array_key_exists($strLangCode, $arrValues)) {
return $arrValues[$strLangCode];
}
// Language code not set, use fallback.
return $arrValues[$this->getMetaModel()->getFallbackLanguage()];
} | php | {
"resource": ""
} |
q245075 | Base.hookAdditionalFormatters | validation | public function hookAdditionalFormatters($arrBaseFormatted, $arrRowData, $strOutputFormat, $objSettings)
{
$arrResult = $arrBaseFormatted;
if (isset($GLOBALS['METAMODEL_HOOKS']['parseValue']) && is_array($GLOBALS['METAMODEL_HOOKS']['parseValue'])) {
foreach ($GLOBALS['METAMODEL_HOOKS']['parseValue'] as $callback) {
list($strClass, $strMethod) = $callback;
$objCallback = (in_array('getInstance', get_class_methods($strClass)))
? call_user_func(array($strClass, 'getInstance'))
: new $strClass();
$arrResult = $objCallback->$strMethod(
$this,
$arrResult,
$arrRowData,
$strOutputFormat,
$objSettings
);
}
}
return $arrResult;
} | php | {
"resource": ""
} |
q245076 | Base.prepareTemplate | validation | protected function prepareTemplate(Template $objTemplate, $arrRowData, $objSettings)
{
$objTemplate->setData(array(
'attribute' => $this,
'settings' => $objSettings,
'row' => $arrRowData,
'raw' => $arrRowData[$this->getColName()],
'additional_class' => $objSettings->get('additional_class')
? ' ' . $objSettings->get('additional_class')
: ''
));
} | php | {
"resource": ""
} |
q245077 | Base.setLanguageStrings | validation | private function setLanguageStrings()
{
// Only overwrite the language if not already set.
if (empty($GLOBALS['TL_LANG'][$this->getMetaModel()->getTableName()][$this->getColName()])) {
$GLOBALS['TL_LANG'][$this->getMetaModel()->getTableName()][$this->getColName()] = array
(
$this->getLangValue($this->get('name')),
$this->getLangValue($this->get('description')),
);
}
} | php | {
"resource": ""
} |
q245078 | Base.getBaseDefinition | validation | private function getBaseDefinition()
{
$this->setLanguageStrings();
$tableName = $this->getMetaModel()->getTableName();
$definition = array();
if (isset($GLOBALS['TL_DCA'][$tableName]['fields'][$this->getColName()])) {
$definition = $GLOBALS['TL_DCA'][$tableName]['fields'][$this->getColName()];
}
return array_replace_recursive(
array
(
'label' => &$GLOBALS['TL_LANG'][$tableName][$this->getColName()],
'eval' => array()
),
$definition
);
} | php | {
"resource": ""
} |
q245079 | PanelBuilder.build | validation | protected function build(IMetaModelDataDefinition $container)
{
$this->inputScreen = $this->viewCombination->getScreen($container->getName());
// Check if we have a BackendViewDef.
if ($container->hasDefinition(Contao2BackendViewDefinitionInterface::NAME)) {
/** @var Contao2BackendViewDefinitionInterface $view */
$view = $container->getDefinition(Contao2BackendViewDefinitionInterface::NAME);
} else {
return;
}
// Get the panel layout.
$panelLayout = $this->inputScreen['meta']['panelLayout'];
// Check if we have a layout.
if (empty($panelLayout)) {
return;
}
// Get the layout from the dca.
$arrRows = StringUtil::trimsplit(';', $panelLayout);
// Create a new panel container.
$panel = $view->getPanelLayout();
$panelRows = $panel->getRows();
foreach ($arrRows as $rowNo => $rowElements) {
// Get the row, if we have one or create a new one.
if ($panelRows->getRowCount() < ($rowNo + 1)) {
$panelRow = $panelRows->addRow();
} else {
$panelRow = $panelRows->getRow($rowNo);
}
// Get the fields.
$fields = StringUtil::trimsplit(',', $rowElements);
$fields = array_reverse($fields);
$this->parsePanelRow($fields, $panelRow);
// If we have no entries for this row, remove it.
if ($panelRow->getCount() == 0) {
$panelRows->deleteRow($rowNo);
}
}
$this->ensureSubmitElement($panelRows);
$this->inputScreen = null;
} | php | {
"resource": ""
} |
q245080 | PanelBuilder.ensureSubmitElement | validation | private function ensureSubmitElement($panelRows)
{
// Check if we have a submit button.
$hasSubmit = false;
foreach ($panelRows as $panelRow) {
foreach ($panelRow as $element) {
if ($element instanceof SubmitElementInformationInterface) {
$hasSubmit = true;
break;
}
if ($hasSubmit) {
break;
}
}
}
// If not add a submit.
if (!$hasSubmit && $panelRows->getRowCount()) {
$row = $panelRows->getRow($panelRows->getRowCount() - 1);
$row->addElement(new DefaultSubmitElementInformation(), 0);
}
} | php | {
"resource": ""
} |
q245081 | PanelBuilder.parsePanelRow | validation | private function parsePanelRow($fields, PanelRowInterface $panelRow)
{
// Parse each type.
foreach ($fields as $field) {
switch ($field) {
case 'sort':
$this->parsePanelSort($panelRow);
break;
case 'limit':
$this->parsePanelLimit($panelRow);
break;
case 'filter':
$this->parsePanelFilter($panelRow);
break;
case 'search':
$this->parsePanelSearch($panelRow);
break;
case 'submit':
$this->parsePanelSubmit($panelRow);
break;
default:
break;
}
}
} | php | {
"resource": ""
} |
q245082 | PanelBuilder.parsePanelFilter | validation | private function parsePanelFilter(PanelRowInterface $row)
{
foreach ($this->inputScreen['properties'] as $value) {
if (!empty($value['filter'])) {
$element = new DefaultFilterElementInformation();
$element->setPropertyName($value['col_name']);
if (!$row->hasElement($element->getName())) {
$row->addElement($element);
}
}
}
} | php | {
"resource": ""
} |
q245083 | PanelBuilder.parsePanelSort | validation | private function parsePanelSort(PanelRowInterface $row)
{
if (!$row->hasElement('sort')) {
$element = new DefaultSortElementInformation();
$row->addElement($element);
}
} | php | {
"resource": ""
} |
q245084 | PanelBuilder.parsePanelSearch | validation | private function parsePanelSearch(PanelRowInterface $row)
{
if ($row->hasElement('search')) {
$element = $row->getElement('search');
} else {
$element = new DefaultSearchElementInformation();
}
if (!$element instanceof SearchElementInformationInterface) {
throw new \InvalidArgumentException('Search element does not implement the correct interface.');
}
foreach ($this->inputScreen['properties'] as $value) {
if (!empty($value['search'])) {
$element->addProperty($value['col_name']);
}
}
if ($element->getPropertyNames() && !$row->hasElement('search')) {
$row->addElement($element);
}
} | php | {
"resource": ""
} |
q245085 | UpgradeHandler.upgradeJumpTo | validation | protected static function upgradeJumpTo()
{
$objDB = self::DB();
if ($objDB->tableExists('tl_content', null, true)
&& !$objDB->fieldExists('metamodel_jumpTo', 'tl_content', true)
) {
// Create the column in the database and copy the data over.
TableManipulation::createColumn(
'tl_content',
'metamodel_jumpTo',
'int(10) unsigned NOT NULL default \'0\''
);
if ($objDB->fieldExists('jumpTo', 'tl_content', true)) {
$objDB->execute('UPDATE tl_content SET metamodel_jumpTo=jumpTo;');
}
}
if ($objDB->tableExists('tl_module', null, true)
&& !$objDB->fieldExists('metamodel_jumpTo', 'tl_module', true)
) {
// Create the column in the database and copy the data over.
TableManipulation::createColumn(
'tl_module',
'metamodel_jumpTo',
'int(10) unsigned NOT NULL default \'0\''
);
if ($objDB->fieldExists('jumpTo', 'tl_module', true)) {
$objDB->execute('UPDATE tl_module SET metamodel_jumpTo=jumpTo;');
}
}
} | php | {
"resource": ""
} |
q245086 | UpgradeHandler.upgradeDcaSettingsPublished | validation | protected static function upgradeDcaSettingsPublished()
{
$objDB = self::DB();
if ($objDB->tableExists('tl_metamodel_dcasetting', null, true)
&& !$objDB->fieldExists('published', 'tl_metamodel_dcasetting', true)
) {
// Create the column in the database and copy the data over.
TableManipulation::createColumn(
'tl_metamodel_dcasetting',
'published',
'char(1) NOT NULL default \'\''
);
// Publish everything we had so far.
$objDB->execute('UPDATE tl_metamodel_dcasetting SET published=1;');
}
} | php | {
"resource": ""
} |
q245087 | UpgradeHandler.changeSubPalettesToConditions | validation | protected static function changeSubPalettesToConditions()
{
$objDB = self::DB();
// Create the table.
if (!$objDB->tableExists('tl_metamodel_dcasetting_condition')) {
$objDB->execute(
'CREATE TABLE `tl_metamodel_dcasetting_condition` (
`id` int(10) unsigned NOT NULL auto_increment,
`pid` int(10) unsigned NOT NULL default \'0\',
`settingId` int(10) unsigned NOT NULL default \'0\',
`sorting` int(10) unsigned NOT NULL default \'0\',
`tstamp` int(10) unsigned NOT NULL default \'0\',
`enabled` char(1) NOT NULL default \'\',
`type` varchar(255) NOT NULL default \'\',
`attr_id` int(10) unsigned NOT NULL default \'0\',
`comment` varchar(255) NOT NULL default \'\',
`value` blob NULL,
PRIMARY KEY (`id`)
)ENGINE=MyISAM DEFAULT CHARSET=utf8;'
);
}
if ($objDB->tableExists('tl_metamodel_dcasetting', null, true)
&& $objDB->fieldExists('subpalette', 'tl_metamodel_dcasetting', true)
) {
$subpalettes = $objDB->execute('SELECT * FROM tl_metamodel_dcasetting WHERE subpalette!=0');
if ($subpalettes->numRows) {
// Get all attribute names and setting ids.
$attributes = $objDB
->execute('
SELECT attr_id, colName
FROM tl_metamodel_dcasetting AS setting
LEFT JOIN tl_metamodel_attribute AS attribute
ON (setting.attr_id=attribute.id)
WHERE dcatype=\'attribute\'
');
$attr = array();
while ($attributes->next()) {
$attr[$attributes->attr_id] = $attributes->colName;
}
$checkboxes = $objDB->execute('
SELECT *
FROM tl_metamodel_dcasetting
WHERE
subpalette=0
AND dcatype=\'attribute\'
');
$check = array();
while ($checkboxes->next()) {
$check[$checkboxes->id] = $checkboxes->attr_id;
}
while ($subpalettes->next()) {
// Add property value condition for parent property dependency.
$data = array(
'pid' => 0,
'settingId' => $subpalettes->id,
'sorting' => '128',
'tstamp' => time(),
'enabled' => '1',
'type' => 'conditionpropertyvalueis',
'attr_id' => $check[$subpalettes->subpalette],
'comment' => sprintf(
'Only show when checkbox "%s" is checked',
$attr[$check[$subpalettes->subpalette]]
),
'value' => '1',
);
$objDB
->prepare('INSERT INTO tl_metamodel_dcasetting_condition %s')
->set($data)
->execute();
$objDB
->prepare('UPDATE tl_metamodel_dcasetting SET subpalette=0 WHERE id=?')
->execute($subpalettes->id);
$objDB
->prepare('UPDATE tl_metamodel_dcasetting SET submitOnChange=1 WHERE id=?')
->execute($subpalettes->subpalette);
}
}
TableManipulation::dropColumn('tl_metamodel_dcasetting', 'subpalette', true);
}
} | php | {
"resource": ""
} |
q245088 | UpgradeHandler.upgradeClosed | validation | protected static function upgradeClosed()
{
$objDB = self::DB();
// Change isclosed to iseditable, iscreatable and isdeleteable.
if ($objDB->tableExists('tl_metamodel_dca', null, true)
&& !$objDB->fieldExists('iseditable', 'tl_metamodel_dca')) {
// Create the column in the database and copy the data over.
TableManipulation::createColumn(
'tl_metamodel_dca',
'iseditable',
'char(1) NOT NULL default \'\''
);
TableManipulation::createColumn(
'tl_metamodel_dca',
'iscreatable',
'char(1) NOT NULL default \'\''
);
TableManipulation::createColumn(
'tl_metamodel_dca',
'isdeleteable',
'char(1) NOT NULL default \'\''
);
$objDB->execute('
UPDATE tl_metamodel_dca
SET
iseditable=isclosed^1,
iscreatable=isclosed^1,
isdeleteable=isclosed^1
');
TableManipulation::dropColumn('tl_metamodel_dca', 'isclosed', true);
}
} | php | {
"resource": ""
} |
q245089 | UpgradeHandler.perform | validation | public static function perform()
{
self::upgradeJumpTo();
self::upgradeDcaSettingsPublished();
self::changeSubPalettesToConditions();
self::upgradeClosed();
self::upgradeInputScreenMode();
self::upgradeInputScreenFlag();
} | php | {
"resource": ""
} |
q245090 | TableNamePrefixingListener.handle | validation | public function handle(EncodePropertyValueFromWidgetEvent $event)
{
if (!$this->wantToHandle($event) || ($event->getProperty() !== 'tableName')) {
return;
}
// See #49.
$tableName = strtolower($event->getValue());
if (!strlen($tableName)) {
throw new \RuntimeException('Table name not given');
}
// Force mm_ prefix.
if (substr($tableName, 0, 3) !== 'mm_') {
$tableName = 'mm_' . $tableName;
}
$dataProvider = $event->getEnvironment()->getDataProvider('tl_metamodel');
try {
// New model, ensure the table does not exist.
if (!$event->getModel()->getId()) {
$this->tableManipulator->checkTableDoesNotExist($tableName);
} else {
// Edited model, ensure the value is unique and then that the table does not exist.
$oldVersion = $dataProvider->fetch($dataProvider->getEmptyConfig()->setId($event->getModel()->getId()));
if ($oldVersion->getProperty('tableName') !== $event->getModel()->getProperty('tableName')) {
$this->tableManipulator->checkTableDoesNotExist($tableName);
}
}
} catch (\Exception $exception) {
throw new \RuntimeException($exception->getMessage(), $exception->getCode(), $exception);
}
$event->setValue($tableName);
} | php | {
"resource": ""
} |
q245091 | ItemList.getServiceContainer | validation | public function getServiceContainer()
{
if (!$this->serviceContainer) {
$this->useDefaultServiceContainer();
}
if (is_callable($this->serviceContainer)) {
return $this->serviceContainer = $this->serviceContainer->__invoke();
}
return $this->serviceContainer;
} | php | {
"resource": ""
} |
q245092 | ItemList.setLimit | validation | public function setLimit($blnUse, $intOffset, $intLimit)
{
$this
->paginationLimitCalculator
->setApplyLimitAndOffset($blnUse)
->setOffset($intOffset)
->setLimit($intLimit);
return $this;
} | php | {
"resource": ""
} |
q245093 | ItemList.setSorting | validation | public function setSorting($strSortBy, $strDirection = 'ASC')
{
$this->strSortBy = $strSortBy;
$this->strSortDirection = ($strDirection == 'DESC') ? 'DESC' : 'ASC';
return $this;
} | php | {
"resource": ""
} |
q245094 | ItemList.overrideOutputFormat | validation | public function overrideOutputFormat($strOutputFormat = null)
{
$strOutputFormat = strval($strOutputFormat);
if (strlen($strOutputFormat)) {
$this->strOutputFormat = $strOutputFormat;
} else {
unset($this->strOutputFormat);
}
return $this;
} | php | {
"resource": ""
} |
q245095 | ItemList.setMetaModel | validation | public function setMetaModel($intMetaModel, $intView)
{
$this->intMetaModel = $intMetaModel;
$this->intView = $intView;
$this->prepareMetaModel();
$this->prepareView();
return $this;
} | php | {
"resource": ""
} |
q245096 | ItemList.setMetaTags | validation | public function setMetaTags($strTitleAttribute, $strDescriptionAttribute)
{
$this->strDescriptionAttribute = $strDescriptionAttribute;
$this->strTitleAttribute = $strTitleAttribute;
return $this;
} | php | {
"resource": ""
} |
q245097 | ItemList.prepareMetaModel | validation | protected function prepareMetaModel()
{
$factory = $this->getFactory();
$this->objMetaModel = $factory->getMetaModel($factory->translateIdToMetaModelName($this->intMetaModel));
if (!$this->objMetaModel) {
throw new \RuntimeException('Could get metamodel id: ' . $this->intMetaModel);
}
} | php | {
"resource": ""
} |
q245098 | ItemList.prepareView | validation | protected function prepareView()
{
if ($this->renderSettingFactory) {
$this->objView = $this->renderSettingFactory->createCollection($this->objMetaModel, $this->intView);
} else {
$this->objView = $this->objMetaModel->getView($this->intView);
}
if ($this->objView) {
$this->objTemplate = new Template($this->objView->get('template'));
$this->objTemplate->view = $this->objView;
} else {
// Fallback to default.
$this->objTemplate = new Template('metamodel_full');
}
} | php | {
"resource": ""
} |
q245099 | ItemList.setFilterSettings | validation | public function setFilterSettings($intFilter)
{
$this->intFilter = $intFilter;
$this->objFilterSettings = $this->getFilterFactory()->createCollection($this->intFilter);
if (!$this->objFilterSettings) {
throw new \RuntimeException('Error: no filter object defined.');
}
return $this;
} | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.