Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
],
"type": "contao-module",
"homepage": "http://now.metamodel.me/",
"license": "LGPL-3.0+",
"license": "LGPL-3.0-or-later",
"authors": [
{
"name": "Christian Schiffler",
Expand Down
5 changes: 3 additions & 2 deletions contao/dca/tl_metamodel_attribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* This file is part of MetaModels/attribute_alias.
*
* (c) 2012-2017 The MetaModels team.
* (c) 2012-2018 The MetaModels team.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand All @@ -16,7 +16,7 @@
* @author Andreas Isaak <info@andreas-isaak.de>
* @author Stefan Heimes <stefan_heimes@hotmail.com>
* @author Ingolf Steinhardt <info@e-spin.de>
* @copyright 2012-2017 The MetaModels team.
* @copyright 2012-2018 The MetaModels team.
* @license https://github.com/MetaModels/attribute_alias/blob/master/LICENSE LGPL-3.0
* @filesource
*/
Expand Down Expand Up @@ -65,6 +65,7 @@
'label' => &$GLOBALS['TL_LANG']['tl_metamodel_attribute']['field_attribute'],
'exclude' => true,
'inputType' => 'select',
'reference' => &$GLOBALS['TL_LANG']['tl_metamodel_attribute']['select_values'],
'eval' => array
(
'style' => 'width:600px',
Expand Down
13 changes: 11 additions & 2 deletions contao/languages/en/tl_metamodel_attribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* This file is part of MetaModels/attribute_alias.
*
* (c) 2012-2017 The MetaModels team.
* (c) 2012-2018 The MetaModels team.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand All @@ -16,7 +16,7 @@
* @author Andreas Isaak <info@andreas-isaak.de>
* @author Stefan Heimes <stefan_heimes@hotmail.com>
* @author Ingolf Steinhardt <info@e-spin.de>
* @copyright 2012-2017 The MetaModels team.
* @copyright 2012-2018 The MetaModels team.
* @license https://github.com/MetaModels/attribute_alias/blob/master/LICENSE LGPL-3.0
* @filesource
*/
Expand All @@ -39,3 +39,12 @@
$GLOBALS['TL_LANG']['tl_metamodel_attribute']['force_alias'][1] =
'Check this, if you want the alias to be regenerated whenever any of the dependant fields is changed. Note that ' .
'this will invalidate old urls that are based upon the alias.';

$GLOBALS['TL_LANG']['tl_metamodel_attribute']['select_values']['id'] = 'ID';
$GLOBALS['TL_LANG']['tl_metamodel_attribute']['select_values']['pid'] = 'PID';
$GLOBALS['TL_LANG']['tl_metamodel_attribute']['select_values']['sorting'] = 'Sorting';
$GLOBALS['TL_LANG']['tl_metamodel_attribute']['select_values']['tstamp'] = 'Timestamp';
$GLOBALS['TL_LANG']['tl_metamodel_attribute']['select_values']['vargroup'] = 'Vargroup';
$GLOBALS['TL_LANG']['tl_metamodel_attribute']['select_values']['varbase'] = 'Varbase';
$GLOBALS['TL_LANG']['tl_metamodel_attribute']['select_values']['meta'] = 'Metafields';
$GLOBALS['TL_LANG']['tl_metamodel_attribute']['select_values']['attributes'] = 'Attributes';
44 changes: 40 additions & 4 deletions src/MetaModels/Attribute/Alias/Alias.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* This file is part of MetaModels/attribute_alias.
*
* (c) 2012-2017 The MetaModels team.
* (c) 2012-2018 The MetaModels team.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand All @@ -18,7 +18,7 @@
* @author Oliver Hoff <oliver@hofff.com>
* @author Ingolf Steinhardt <info@e-spin.de>
* @author Sven Baumann <baumann.sv@gmail.com>
* @copyright 2012-2017 The MetaModels team.
* @copyright 2012-2018 The MetaModels team.
* @license https://github.com/MetaModels/attribute_alias/blob/master/LICENSE LGPL-3.0
* @filesource
*/
Expand Down Expand Up @@ -142,8 +142,13 @@ private function generateAlias(IItem $objItem)
}

foreach (deserialize($this->get('alias_fields')) as $strAttribute) {
$arrValues = $objItem->parseAttribute($strAttribute['field_attribute'], 'text', null);
$arrAlias[] = $arrValues['text'];
if ($this->isMetaField($strAttribute['field_attribute'])) {
$strField = $strAttribute['field_attribute'];
$arrAlias[] = $objItem->get($strField);
} else {
$arrValues = $objItem->parseAttribute($strAttribute['field_attribute'], 'text', null);
$arrAlias[] = $arrValues['text'];
}
}

if ($this->get('alias_postfix')) {
Expand All @@ -152,4 +157,35 @@ private function generateAlias(IItem $objItem)

return implode('-', $arrAlias);
}

/**
* Check if we have a meta field from metamodels.
*
* @param string $strField The selected value.
*
* @return boolean True => Yes we have | False => nope.
*/
protected function isMetaField($strField)
{
$strField = trim($strField);

if (in_array($strField, $this->getMetaModelsSystemColumns())) {
return true;
}

return false;
}

/**
* Returns the global MetaModels System Columns (replacement for super global access).
*
* @return mixed Global MetaModels System Columns
*
* @SuppressWarnings(PHPMD.Superglobals)
* @SuppressWarnings(PHPMD.CamelCaseVariableName)
*/
protected function getMetaModelsSystemColumns()
{
return $GLOBALS['METAMODELS_SYSTEM_COLUMNS'];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* This file is part of MetaModels/attribute_alias.
*
* (c) 2012-2016 The MetaModels team.
* (c) 2012-2018 The MetaModels team.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand All @@ -13,7 +13,8 @@
* @package MetaModels
* @subpackage AttributeAlias
* @author Christian Schiffler <c.schiffler@cyberspectrum.de>
* @copyright 2012-2016 The MetaModels team.
* @author Ingolf Steinhardt <info@e-spin.de>
* @copyright 2012-2018 The MetaModels team.
* @license https://github.com/MetaModels/attribute_alias/blob/master/LICENSE LGPL-3.0
* @filesource
*/
Expand Down Expand Up @@ -101,13 +102,16 @@ public function getOptions(GetOptionsEvent $event)

$result = array();

// Add meta fields.
$result['meta'] = self::getMetaModelsSystemColumns();

// Fetch all attributes except for the current attribute.
foreach ($metaModel->getAttributes() as $attribute) {
if ($attribute->get('id') === $model->getId()) {
continue;
}

$result[$attribute->getColName()] = sprintf(
$result['attributes'][$attribute->getColName()] = sprintf(
'%s [%s]',
$attribute->getName(),
$attribute->get('type')
Expand All @@ -116,4 +120,17 @@ public function getOptions(GetOptionsEvent $event)

$event->setOptions($result);
}

/**
* Returns the global MetaModels System Columns (replacement for super global access).
*
* @return mixed Global MetaModels System Columns
*
* @SuppressWarnings(PHPMD.Superglobals)
* @SuppressWarnings(PHPMD.CamelCaseVariableName)
*/
protected static function getMetaModelsSystemColumns()
{
return $GLOBALS['METAMODELS_SYSTEM_COLUMNS'];
}
}