Skip to content

Commit 4730ee9

Browse files
committed
Merge tag '2.1.3'
Hotfix release Final version.
2 parents 27cfbe7 + a5f9f8f commit 4730ee9

10 files changed

Lines changed: 161 additions & 140 deletions

File tree

.github/workflows/diagnostics.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: MetaModels attribute_contentarticle
2+
3+
on:
4+
push:
5+
branches-ignore:
6+
- '**-translation'
7+
pull_request:
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
php: [7.3, 7.4]
15+
contao: [~4.4.0, ~4.9.0]
16+
17+
steps:
18+
- name: PHP ${{ matrix.php }} ${{ matrix.contao }} Pull source
19+
uses: actions/checkout@v2
20+
with:
21+
fetch-depth: 0
22+
23+
# see https://github.com/shivammathur/setup-php
24+
- name: PHP ${{ matrix.php }} ${{ matrix.contao }} Setup PHP.
25+
uses: shivammathur/setup-php@v2
26+
with:
27+
php-version: ${{ matrix.php }}
28+
coverage: none
29+
30+
- name: PHP ${{ matrix.php }} ${{ matrix.contao }} Cache composer cache directory
31+
uses: actions/cache@v1
32+
env:
33+
cache-name: composer-cache-dir
34+
with:
35+
path: ~/.cache/composer
36+
key: ${{ runner.os }}-build-${{ env.cache-name }}
37+
38+
- name: PHP ${{ matrix.php }} ${{ matrix.contao }} Cache vendor directory
39+
uses: actions/cache@v1
40+
env:
41+
cache-name: composer-vendor
42+
with:
43+
path: vendor
44+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/composer.lock') }}
45+
restore-keys: |
46+
${{ runner.os }}-build-${{ env.cache-name }}-
47+
48+
- name: PHP ${{ matrix.php }} ${{ matrix.contao }} Install composer dependencies
49+
run: composer update --prefer-dist --no-interaction --no-suggest
50+
51+
- name: PHP ${{ matrix.php }} ${{ matrix.contao }} Run tests
52+
run: ant -keep-going

.travis.yml

Lines changed: 0 additions & 62 deletions
This file was deleted.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[![Build Status](https://travis-ci.org/MetaModels/attribute_contentarticle.svg)](https://travis-ci.org/MetaModels/attribute_contentarticle)
1+
[![Build Status](https://github.com/MetaModels/attribute_contentarticle/actions/workflows/diagnostics.yml/badge.svg)](https://github.com/MetaModels/attribute_contentarticle/actions)
22
[![Latest Version tagged](http://img.shields.io/github/tag/MetaModels/attribute_contentarticle.svg)](https://github.com/MetaModels/attribute_contentarticle/tags)
33
[![Latest Version on Packagist](http://img.shields.io/packagist/v/MetaModels/attribute_contentarticle.svg)](https://packagist.org/packages/MetaModels/attribute_contentarticle)
44
[![Installations via composer per month](http://img.shields.io/packagist/dm/MetaModels/attribute_contentarticle.svg)](https://packagist.org/packages/MetaModels/attribute_contentarticle)

build.default.properties

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ phpcs.standard=${basedir}/vendor/phpcq/coding-standard/phpcs/PhpCodeQuality/rule
99
phpmd.ruleset=${basedir}/vendor/phpcq/coding-standard/phpmd/ruleset.xml
1010

1111
phpcs.excluded=src/Resources/contao/languages
12-
phpcs.src=driver src
13-
phpmd.src=driver src
14-
phpcpd.src=driver src
15-
phploc.src=driver src
16-
pdepend.src=driver src
12+
phpcs.src=src
13+
phpmd.src=src
14+
phpcpd.src=src
15+
phploc.src=src
16+
pdepend.src=src

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"contao",
66
"metamodels",
77
"attribute",
8-
"article"
8+
"article",
9+
"content element"
910
],
1011
"type": "contao-bundle",
1112
"homepage": "http://now.metamodel.me/",
@@ -30,7 +31,7 @@
3031
"contao-community-alliance/dc-general": "^2.1.3",
3132
"contao/core-bundle": "^4.4.8",
3233
"metamodels/core": "^2.1.1",
33-
"symfony/dependency-injection": "^3.3 || ^4.0",
34+
"symfony/dependency-injection": "^3.3 || ^4.1.12",
3435
"symfony/http-kernel": "^3.3 || ^4.0",
3536
"ext-pdo": "*"
3637
},
@@ -41,8 +42,7 @@
4142
},
4243
"autoload": {
4344
"psr-4": {
44-
"MetaModels\\AttributeContentArticleBundle\\": "src/",
45-
"Contao\\": "driver/"
45+
"MetaModels\\AttributeContentArticleBundle\\": "src/"
4646
}
4747
},
4848
"extra": {

driver/DC_TableMetaModelsContentArticle.php

Lines changed: 0 additions & 56 deletions
This file was deleted.

src/EventListener/InitializeListener.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,11 @@ class InitializeListener
3939
* Constructor.
4040
*
4141
* @param TokenStorageInterface $tokenStorage The token storage.
42+
*
4243
* @param AuthenticationTrustResolverInterface $authenticationTrustResolver The authentication resolver.
44+
*
4345
* @param ScopeMatcher $scopeMatcher The scope matche.
46+
*
4447
* @param ViewCombination $viewCombination The view combination.
4548
*/
4649
public function __construct(
@@ -95,11 +98,7 @@ public function addBackendModules(&$localMenu)
9598
$strTable = Input::get('table');
9699
$blnLangSupport = Input::get('langSupport');
97100

98-
if (
99-
substr($strModule, 0, 10) == 'metamodel_'
100-
&& $strTable == 'tl_content'
101-
&& $blnLangSupport === null
102-
) {
101+
if (substr($strModule, 0, 10) == 'metamodel_' && $strTable == 'tl_content' && $blnLangSupport === null) {
103102
$needsToBeAdded = true;
104103
foreach ($GLOBALS['BE_MOD'] as $key => $mod) {
105104
if (isset($mod[$strModule])) {

src/Resources/contao/dca/tl_content.php

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,7 @@
3131
$strLangSupport = Input::get('langSupport');
3232

3333
// Change TL_Content for the article popup
34-
if (
35-
\substr($strModule, 0, 10) == 'metamodel_'
36-
&& $strTable == 'tl_content'
37-
&& $strLangSupport === null
38-
) {
39-
$GLOBALS['TL_DCA']['tl_content']['config']['dataContainer'] =
40-
'TableMetaModelsContentArticle';
34+
if (\substr($strModule, 0, 10) == 'metamodel_' && $strTable == 'tl_content' && $strLangSupport === null) {
4135
$GLOBALS['TL_DCA']['tl_content']['config']['ptable'] =
4236
Input::get('ptable');
4337
$GLOBALS['TL_DCA']['tl_content']['config']['onsubmit_callback'][] =
@@ -50,6 +44,16 @@
5044
ArticleContent::class,
5145
'checkPermission'
5246
];
47+
$GLOBALS['TL_DCA']['tl_content']['config']['oncopy_callback'][] =
48+
[
49+
ArticleContent::class,
50+
'updateCopyData'
51+
];
52+
$GLOBALS['TL_DCA']['tl_content']['config']['oncut_callback'][] =
53+
[
54+
ArticleContent::class,
55+
'updateCutData'
56+
];
5357
$GLOBALS['TL_DCA']['tl_content']['list']['operations']['toggle']['button_callback'] =
5458
[
5559
ArticleContent::class,

src/Table/ArticleContent.php

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,89 @@ public function save(DataContainer $dataContainer)
6464
->execute(Input::get('slot'), $dataContainer->id);
6565
}
6666

67+
/**
68+
* Update the data from copies and set the context like pid, parent table, slot.
69+
*
70+
* @param string $insertId The id of the new entry.
71+
*
72+
* @param DataContainer $dataContainer The DC Driver.
73+
*
74+
* @return void
75+
*
76+
* @throws \RuntimeException If the id is missing for the entry.
77+
*
78+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
79+
*/
80+
public function updateCopyData(string $insertId, DataContainer $dataContainer)
81+
{
82+
$pid = Input::get('mid');
83+
$ptable = Input::get('ptable');
84+
$slot = Input::get('slot');
85+
86+
if (empty($pid) || empty($ptable) || empty($slot)) {
87+
$errorCode = 'Could not update row because one of the data are missing. ';
88+
$errorCode .= 'Insert ID: %s, Pid: %s, Parent table: %s, Slot: %s';
89+
throw new \RuntimeException(
90+
\sprintf(
91+
$errorCode,
92+
$insertId,
93+
$pid,
94+
$ptable,
95+
$slot
96+
)
97+
);
98+
}
99+
100+
Database::getInstance()
101+
->prepare('UPDATE tl_content SET pid=?, ptable=?, mm_slot=? WHERE id=?')
102+
->execute(
103+
$pid,
104+
$ptable,
105+
$slot,
106+
$insertId
107+
);
108+
}
109+
110+
/**
111+
* Update the data from copies and set the context like pid, parent table, slot.
112+
*
113+
* @param DataContainer $dataContainer The DC Driver.
114+
*
115+
* @return void
116+
*
117+
* @throws \RuntimeException If the id is missing for the entry.
118+
*/
119+
public function updateCutData(DataContainer $dataContainer)
120+
{
121+
$pid = Input::get('mid');
122+
$ptable = Input::get('ptable');
123+
$slot = Input::get('slot');
124+
$insertId = $dataContainer->id;
125+
126+
if (empty($pid) || empty($ptable) || empty($slot)) {
127+
$errorCode = 'Could not update row because one of the data are missing. ';
128+
$errorCode .= 'Insert ID: %s, Pid: %s, Parent table: %s, Slot: %s';
129+
throw new \RuntimeException(
130+
\sprintf(
131+
$errorCode,
132+
$insertId,
133+
$pid,
134+
$ptable,
135+
$slot
136+
)
137+
);
138+
}
139+
140+
Database::getInstance()
141+
->prepare('UPDATE tl_content SET pid=?, ptable=?, mm_slot=? WHERE id=?')
142+
->execute(
143+
$pid,
144+
$ptable,
145+
$slot,
146+
$insertId
147+
);
148+
}
149+
67150
/**
68151
* Check permissions to edit table tl_content.
69152
*

src/Widgets/ContentArticleWidget.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ public function generate()
134134
'table' => 'tl_content',
135135
'ptable' => $this->strTable,
136136
'id' => $this->currentRecord,
137+
'mid' => $this->currentRecord,
137138
'slot' => $this->strName,
138139
'popup' => 1,
139140
'nb' => 1,

0 commit comments

Comments
 (0)