Skip to content

Commit ec333e6

Browse files
committed
Rework
- rename files - rework functions
1 parent ef60a83 commit ec333e6

11 files changed

Lines changed: 62 additions & 500 deletions

File tree

contao/config/autoload.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@
2020
* Register the templates
2121
*/
2222
TemplateLoader::addFiles(array(
23-
'mm_attr_translatedtabletext' => 'system/modules/metamodelsattribute_translatedtabletext/templates',
23+
'mm_attr_translatedmulti' => 'system/modules/metamodelsattribute_translatedmulti/templates',
2424
));

contao/config/database.sql

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,20 @@
77
-- * *
88
-- **********************************************************
99

10-
--
10+
--
1111
-- Table `tl_metamodel_tabletext`
12-
--
12+
--
1313

14-
CREATE TABLE `tl_metamodel_translatedtabletext` (
14+
CREATE TABLE `tl_metamodel_translatedmulti` (
1515
`id` int(10) unsigned NOT NULL auto_increment,
1616
`tstamp` int(10) unsigned NOT NULL default '0',
1717
`att_id` int(10) unsigned NOT NULL default '0',
1818
`item_id` int(10) unsigned NOT NULL default '0',
1919
`langcode` varchar(5) NOT NULL default '',
2020
`row` int(5) unsigned NOT NULL default '0',
21-
`col` int(5) unsigned NOT NULL default '0',
22-
`value` varchar(255) NOT NULL default '',
21+
`col` varchar(255) NOT NULL default '',
22+
`value` text NOT NULL default '',
2323
PRIMARY KEY (`id`),
2424
KEY `attitem` (`att_id`, `item_id`),
2525
UNIQUE KEY `attitemrowcol` (`att_id`, `item_id`, `row`, `col`, `langcode`)
2626
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
27-
28-
--
29-
-- Table `tl_metamodel_attribute`
30-
--
31-
32-
CREATE TABLE `tl_metamodel_attribute` (
33-
`translatedtabletext_cols` blob NULL,
34-
`tabletext_quantity_cols` varchar(2) NOT NULL default ''
35-
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

contao/config/event_listeners.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,14 @@
1414
* @filesource
1515
*/
1616

17-
use MetaModels\Attribute\TranslatedTableText\AttributeTypeFactory;
1817
use MetaModels\Attribute\Events\CreateAttributeFactoryEvent;
19-
use MetaModels\DcGeneral\Events\Table\Attribute\TranslatedTableText\Subscriber;
18+
use MetaModels\Attribute\TranslatedMulti\AttributeTypeFactory;
19+
use MetaModels\DcGeneral\Events\Table\Attribute\TranslatedMulti\Subscriber;
2020
use MetaModels\Events\MetaModelsBootEvent;
2121
use MetaModels\MetaModelsEvents;
2222

2323
return array
2424
(
25-
MetaModelsEvents::SUBSYSTEM_BOOT_BACKEND => array(
26-
function (MetaModelsBootEvent $event) {
27-
new Subscriber($event->getServiceContainer());
28-
}
29-
),
3025
MetaModelsEvents::ATTRIBUTE_FACTORY_CREATE => array(
3126
function (CreateAttributeFactoryEvent $event) {
3227
$factory = $event->getFactory();

contao/dca/tl_metamodel_attribute.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@
2020
/**
2121
* Table tl_metamodel_attribute
2222
*/
23+
$GLOBALS['TL_DCA']['tl_metamodel_attribute']['metapalettes']['translatedmulti extends _complexattribute_'] = array();

contao/languages/de/tl_metamodel_attribute.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@
33
* Translations are managed using Transifex. To create a new translation
44
* or to help to maintain an existing one, please register at transifex.com.
55
*
6-
* @link http://help.transifex.com/intro/translating.html
7-
* @link https://www.transifex.com/projects/p/metamodels/language/de/
6+
* @link http://help.transifex.com/intro/translating.html
7+
* @link https://www.transifex.com/projects/p/metamodels/language/de/
88
*
99
* @license http://www.gnu.org/licenses/lgpl-3.0.html LGPL
1010
*
1111
* last-updated: 2013-09-25T20:17:05+02:00
1212
*/
1313

14-
$GLOBALS['TL_LANG']['tl_metamodel_attribute']['tabletext_cols']['0'] = 'Spalteneinstellung';
15-
$GLOBALS['TL_LANG']['tl_metamodel_attribute']['tabletext_cols']['1'] = 'Bitte ein Label und die Breite für jede Spalte angeben.';
16-
$GLOBALS['TL_LANG']['tl_metamodel_attribute']['tabletext_quantity_cols']['0'] = 'Anzahl der Spalten';
17-
$GLOBALS['TL_LANG']['tl_metamodel_attribute']['tabletext_quantity_cols']['1'] = 'Bitte die Anzahl der Spalten auswählen.';
18-
$GLOBALS['TL_LANG']['tl_metamodel_attribute']['tabletext_rowLabel']['0'] = 'Label';
19-
$GLOBALS['TL_LANG']['tl_metamodel_attribute']['tabletext_rowLabel']['1'] = 'Bitte das Label für die Spalten angeben.';
20-
$GLOBALS['TL_LANG']['tl_metamodel_attribute']['tabletext_rowStyle']['0'] = 'Breite';
21-
$GLOBALS['TL_LANG']['tl_metamodel_attribute']['tabletext_rowStyle']['1'] = 'Bitte geben Sie die Spaltenbreite ein (beispielsweise 200px).';
22-
$GLOBALS['TL_LANG']['tl_metamodel_attribute']['typeOptions']['translatedtabletext'] = 'Übersetzter Tabellen-Text';
14+
$GLOBALS['TL_LANG']['tl_metamodel_attribute']['tabletext_cols']['0'] = 'Spalteneinstellung';
15+
$GLOBALS['TL_LANG']['tl_metamodel_attribute']['tabletext_cols']['1'] = 'Bitte ein Label und die Breite für jede Spalte angeben.';
16+
$GLOBALS['TL_LANG']['tl_metamodel_attribute']['tabletext_quantity_cols']['0'] = 'Anzahl der Spalten';
17+
$GLOBALS['TL_LANG']['tl_metamodel_attribute']['tabletext_quantity_cols']['1'] = 'Bitte die Anzahl der Spalten auswählen.';
18+
$GLOBALS['TL_LANG']['tl_metamodel_attribute']['tabletext_rowLabel']['0'] = 'Label';
19+
$GLOBALS['TL_LANG']['tl_metamodel_attribute']['tabletext_rowLabel']['1'] = 'Bitte das Label für die Spalten angeben.';
20+
$GLOBALS['TL_LANG']['tl_metamodel_attribute']['tabletext_rowStyle']['0'] = 'Breite';
21+
$GLOBALS['TL_LANG']['tl_metamodel_attribute']['tabletext_rowStyle']['1'] = 'Bitte geben Sie die Spaltenbreite ein (beispielsweise 200px).';
22+
$GLOBALS['TL_LANG']['tl_metamodel_attribute']['typeOptions']['translatedmulti'] = 'Übersetzter Multi-Tabelle';

contao/languages/en/tl_metamodel_attribute.php

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,21 @@
1717
/**
1818
* Fields
1919
*/
20-
$GLOBALS['TL_LANG']['tl_metamodel_attribute']['typeOptions']['translatedtabletext'] = 'Translated table text';
21-
$GLOBALS['TL_LANG']['tl_metamodel_attribute']['tabletext_cols'] = array('Column config', 'Please enter a label and width for each column.');
22-
$GLOBALS['TL_LANG']['tl_metamodel_attribute']['tabletext_rowLabels'] = array('');
23-
$GLOBALS['TL_LANG']['tl_metamodel_attribute']['tabletext_rowLabel'] = array('Label', 'Please enter the labels for the columns');
24-
$GLOBALS['TL_LANG']['tl_metamodel_attribute']['tabletext_rowStyle'] = array('Width', 'Please enter the width of the columns (e.g. 200px)');
25-
$GLOBALS['TL_LANG']['tl_metamodel_attribute']['tabletext_quantity_cols'] = array('Number of columns','Please select the number of columns.');
20+
$GLOBALS['TL_LANG']['tl_metamodel_attribute']['typeOptions']['translatedmulti'] = 'Translated multi table';
21+
$GLOBALS['TL_LANG']['tl_metamodel_attribute']['tabletext_cols'] = array(
22+
'Column config',
23+
'Please enter a label and width for each column.'
24+
);
25+
$GLOBALS['TL_LANG']['tl_metamodel_attribute']['tabletext_rowLabels'] = array('');
26+
$GLOBALS['TL_LANG']['tl_metamodel_attribute']['tabletext_rowLabel'] = array(
27+
'Label',
28+
'Please enter the labels for the columns'
29+
);
30+
$GLOBALS['TL_LANG']['tl_metamodel_attribute']['tabletext_rowStyle'] = array(
31+
'Width',
32+
'Please enter the width of the columns (e.g. 200px)'
33+
);
34+
$GLOBALS['TL_LANG']['tl_metamodel_attribute']['tabletext_quantity_cols'] = array(
35+
'Number of columns',
36+
'Please select the number of columns.'
37+
);

src/MetaModels/Attribute/TranslatedMulti/AttributeTypeFactory.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
* @package MetaModels
99
* @subpackage AttributeTranslatedTableText
1010
* @author Christian Schiffler <c.schiffler@cyberspectrum.de>
11+
* @author Stefan Heimes <stefan_heimes@hotmail.com>
1112
* @copyright 2012-2016 The MetaModels team.
1213
* @license https://github.com/MetaModels/attribute_translatedtabletext/blob/master/LICENSE LGPL-3.0
1314
* @filesource
@@ -29,7 +30,7 @@ public function __construct()
2930
{
3031
parent::__construct();
3132
$this->typeName = 'translatedmulti';
32-
$this->typeIcon = 'system/modules/metamodelsattribute_translatedmulti/html/translatedtabletext.png';
33+
$this->typeIcon = 'system/modules/metamodelsattribute_translatedmulti/html/translatedmulti.png';
3334
$this->typeClass = 'MetaModels\Attribute\TranslatedMulti\TranslatedMulti';
3435
}
3536
}

src/MetaModels/Attribute/TranslatedMulti/TranslatedMulti.php

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,7 @@ class TranslatedMulti extends Base implements ITranslated, IComplex
3939
*/
4040
public function getAttributeSettingNames()
4141
{
42-
return array_merge(parent::getAttributeSettingNames(), array(
43-
// ...
44-
));
42+
return array_merge(parent::getAttributeSettingNames(), array());
4543
}
4644

4745
/**
@@ -51,7 +49,7 @@ public function getAttributeSettingNames()
5149
*/
5250
protected function getValueTable()
5351
{
54-
return 'tl_metamodel_translatedtabletext';
52+
return 'tl_metamodel_translatedmulti';
5553
}
5654

5755
/**
@@ -66,6 +64,14 @@ public function getFieldDefinition($arrOverrides = array())
6664

6765
// Check for override in local config
6866
if (isset($GLOBALS['TL_CONFIG']['metamodelsattribute_multi'][$strTable][$strField])) {
67+
// Cleanup the config.
68+
$config = $GLOBALS['TL_CONFIG']['metamodelsattribute_multi'][$strTable][$strField];
69+
foreach ($config['columnFields'] as $col => $data) {
70+
$config['columnFields']['col_' . $col] = $data;
71+
unset($config['columnFields'][$col]);
72+
}
73+
74+
// Build the array();
6975
$arrFieldDef['inputType'] = 'multiColumnWizard';
7076
$arrFieldDef['eval'] = $GLOBALS['TL_CONFIG']['metamodelsattribute_multi'][$strTable][$strField];
7177
} else {
@@ -93,28 +99,28 @@ protected function getWhere($mixIds, $strLangCode = null, $intRow = null, $intCo
9399
{
94100
$arrReturn = array(
95101
'procedure' => 'att_id=?',
96-
'params' => array(intval($this->get('id'))),
102+
'params' => array(intval($this->get('id'))),
97103
);
98104

99105
if ($mixIds) {
100106
if (is_array($mixIds)) {
101107
$arrReturn['procedure'] .= ' AND item_id IN (' . $this->parameterMask($mixIds) . ')';
102-
$arrReturn['params'] = array_merge($arrReturn['params'], $mixIds);
108+
$arrReturn['params'] = array_merge($arrReturn['params'], $mixIds);
103109
} else {
104110
$arrReturn['procedure'] .= ' AND item_id=?';
105-
$arrReturn['params'][] = $mixIds;
111+
$arrReturn['params'][] = $mixIds;
106112
}
107113
}
108114

109115
if (is_int($intRow) && is_int($intCol)) {
110116
$arrReturn['procedure'] .= ' AND row = ? AND col = ?';
111-
$arrReturn['params'][] = $intRow;
112-
$arrReturn['params'][] = $intCol;
117+
$arrReturn['params'][] = $intRow;
118+
$arrReturn['params'][] = $intCol;
113119
}
114120

115121
if ($strLangCode) {
116122
$arrReturn['procedure'] .= ' AND langcode=?';
117-
$arrReturn['params'][] = $strLangCode;
123+
$arrReturn['params'][] = $strLangCode;
118124
}
119125

120126
return $arrReturn;
@@ -132,7 +138,7 @@ public function valueToWidget($varValue)
132138
$widgetValue = array();
133139
foreach ($varValue as $row) {
134140
foreach ($row as $key => $col) {
135-
$widgetValue[$col['row']]['col_' . $key] = $col['value'];
141+
$widgetValue[$col['row']]['col_' . $col['col']] = $col['value'];
136142
}
137143
}
138144

@@ -177,10 +183,10 @@ protected function getSetValues($arrCell, $intId, $strLangCode)
177183
{
178184
return array(
179185
'tstamp' => time(),
180-
'value' => (string) $arrCell['value'],
186+
'value' => (string)$arrCell['value'],
181187
'att_id' => $this->get('id'),
182-
'row' => (int) $arrCell['row'],
183-
'col' => (int) $arrCell['col'],
188+
'row' => (int)$arrCell['row'],
189+
'col' => $arrCell['col'],
184190
'item_id' => $intId,
185191
'langcode' => $strLangCode,
186192
);
@@ -341,6 +347,7 @@ public function getDataFor($arrIds)
341347
}
342348
}
343349
}
350+
344351
return $arrReturn;
345352
}
346353

@@ -355,7 +362,7 @@ public function unsetDataFor($arrIds)
355362
{
356363
if (!is_array($arrIds)) {
357364
throw new \RuntimeException(
358-
'TranslatedTableText::unsetDataFor() invalid parameter given! Array of ids is needed.',
365+
'TranslatedMulti::unsetDataFor() invalid parameter given! Array of ids is needed.',
359366
1
360367
);
361368
}

0 commit comments

Comments
 (0)