Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decouple the calendar, FAQ and news bundles from the comments bundle #6650

Merged
merged 36 commits into from
Jan 4, 2024
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
f1b3913
Rework conditional comment / news bundle fields
zoglo Dec 20, 2023
62e3eab
Rework conditional comment / faq bundle fields
zoglo Dec 21, 2023
2166b73
Rework conditional comment / calendar bundle fields
zoglo Dec 21, 2023
60863be
CS
zoglo Dec 21, 2023
c898da0
CS #2
zoglo Dec 21, 2023
107e164
Revert comment / calendar translations
zoglo Dec 21, 2023
346149d
Revert comment / faq translations
zoglo Dec 21, 2023
0e3c064
Revert comment / news translations
zoglo Dec 21, 2023
85cdc03
Revert auto linting eol
zoglo Dec 21, 2023
ad7dff8
CS
zoglo Dec 21, 2023
974ab40
Revert editorconfig
zoglo Dec 21, 2023
bf4f0f3
Conditionally load fields via DataContainerListener
zoglo Dec 22, 2023
a95005a
CS
zoglo Dec 22, 2023
cdc29f2
CS
zoglo Dec 22, 2023
41a2d1e
CS
zoglo Dec 22, 2023
0b7a6c9
Merge branch '5.x' into feature/comments-conditional-fields
zoglo Dec 22, 2023
31e937a
Merge branch '5.x' into feature/comments-conditional-fields
zoglo Dec 24, 2023
6f0f557
Improve DataContainerListener and more
zoglo Dec 24, 2023
fe5d32b
CS
zoglo Dec 24, 2023
32a76aa
Updates to DataContainerListener
zoglo Dec 25, 2023
cf933bb
CS
zoglo Dec 27, 2023
1b05ec5
Merge branch '5.x' into feature/comments-conditional-fields
zoglo Dec 27, 2023
f4a08ff
Merge branch '5.x' into feature/comments-conditional-fields
zoglo Dec 27, 2023
f902eae
Add plugin test
zoglo Dec 27, 2023
e16cdec
Merge remote-tracking branch 'origin/feature/comments-conditional-fie…
zoglo Dec 27, 2023
a581fd6
Update test name
zoglo Dec 27, 2023
288da1d
Add CommentsConditionalFieldsListenerTest
zoglo Dec 28, 2023
0ab1d8c
Merge branch '5.x' into feature/comments-conditional-fields
zoglo Dec 28, 2023
f6f3aa7
Update tests
zoglo Dec 28, 2023
29b1420
Unset TL_LANG after test
zoglo Dec 28, 2023
e14b1a5
CS
zoglo Dec 28, 2023
512223d
Update tests (100% code cov)
zoglo Dec 28, 2023
dc8320d
Merge branch '5.x' into feature/comments-conditional-fields
leofeyer Jan 3, 2024
283bc2b
CS
leofeyer Jan 3, 2024
93b0127
Merge branch '5.x' into feature/comments-conditional-fields
zoglo Jan 3, 2024
f72fbad
Rename `CommentsConditionalFields` to `AddCommentFields`
zoglo Jan 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ root = true
# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[*.{php,twig,yaml,yml}]
Expand Down
70 changes: 4 additions & 66 deletions calendar-bundle/contao/dca/tl_calendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,14 @@
// Palettes
'palettes' => array
(
'__selector__' => array('protected', 'allowComments'),
'default' => '{title_legend},title,jumpTo;{protected_legend:hide},protected;{comments_legend:hide},allowComments'
'__selector__' => array('protected'),
'default' => '{title_legend},title,jumpTo;{protected_legend:hide},protected'
),

// Sub-palettes
'subpalettes' => array
(
'protected' => 'groups',
'allowComments' => 'notify,sortOrder,perPage,moderate,bbcode,requireLogin,disableCaptcha'
'protected' => 'groups'
),

// Fields
Expand Down Expand Up @@ -142,59 +141,6 @@
'eval' => array('mandatory'=>true, 'multiple'=>true),
'sql' => "blob NULL",
'relation' => array('type'=>'hasMany', 'load'=>'lazy')
),
'allowComments' => array
(
'filter' => true,
'inputType' => 'checkbox',
'eval' => array('submitOnChange'=>true),
'sql' => array('type' => 'boolean', 'default' => false)
),
'notify' => array
(
'inputType' => 'select',
'options' => array('notify_admin', 'notify_author', 'notify_both'),
'eval' => array('tl_class'=>'w50'),
'reference' => &$GLOBALS['TL_LANG']['tl_calendar'],
'sql' => "varchar(32) NOT NULL default 'notify_admin'"
),
'sortOrder' => array
(
'inputType' => 'select',
'options' => array('ascending', 'descending'),
'reference' => &$GLOBALS['TL_LANG']['MSC'],
'eval' => array('tl_class'=>'w50 clr'),
'sql' => "varchar(32) NOT NULL default 'ascending'"
),
'perPage' => array
(
'inputType' => 'text',
'eval' => array('rgxp'=>'natural', 'tl_class'=>'w50'),
'sql' => "smallint(5) unsigned NOT NULL default 0"
),
'moderate' => array
(
'inputType' => 'checkbox',
'eval' => array('tl_class'=>'w50'),
'sql' => array('type' => 'boolean', 'default' => false)
),
'bbcode' => array
(
'inputType' => 'checkbox',
'eval' => array('tl_class'=>'w50'),
'sql' => array('type' => 'boolean', 'default' => false)
),
'requireLogin' => array
(
'inputType' => 'checkbox',
'eval' => array('tl_class'=>'w50'),
'sql' => array('type' => 'boolean', 'default' => false)
),
'disableCaptcha' => array
(
'inputType' => 'checkbox',
'eval' => array('tl_class'=>'w50'),
'sql' => array('type' => 'boolean', 'default' => false)
)
)
);
Expand All @@ -209,18 +155,10 @@
class tl_calendar extends Backend
{
/**
* Set the root IDs and unset the "allowComments" field if the comments bundle is not available.
* Set the root IDs.
*/
public function adjustDca()
{
$bundles = System::getContainer()->getParameter('kernel.bundles');

// HOOK: comments extension required
if (!isset($bundles['ContaoCommentsBundle']))
{
unset($GLOBALS['TL_DCA']['tl_calendar']['fields']['allowComments']);
}

$user = BackendUser::getInstance();

if ($user->isAdmin)
Expand Down
32 changes: 5 additions & 27 deletions calendar-bundle/contao/dca/tl_calendar_events.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
'markAsCopy' => 'title',
'onload_callback' => array
(
array('tl_calendar_events', 'adjustDca'),
array('tl_calendar_events', 'generateFeed')
),
'oncut_callback' => array
Expand Down Expand Up @@ -79,7 +78,7 @@
(
'mode' => DataContainer::MODE_PARENT,
'fields' => array('startTime DESC'),
'headerFields' => array('title', 'jumpTo', 'tstamp', 'protected', 'allowComments'),
'headerFields' => array('title', 'jumpTo', 'tstamp', 'protected'),
'panelLayout' => 'filter;sort,search,limit',
'defaultSearchField' => 'title',
'child_record_callback' => array('tl_calendar_events', 'listEvents')
Expand Down Expand Up @@ -110,10 +109,10 @@
'palettes' => array
(
'__selector__' => array('source', 'addTime', 'addImage', 'recurring', 'addEnclosure', 'overwriteMeta'),
'default' => '{title_legend},title,featured,alias,author;{date_legend},addTime,startDate,endDate;{source_legend},source,linkText;{meta_legend},pageTitle,robots,description,serpPreview;{details_legend},location,address,teaser;{image_legend},addImage;{recurring_legend},recurring;{enclosure_legend:hide},addEnclosure;{expert_legend:hide},cssClass,noComments;{publish_legend},published,start,stop',
'internal' => '{title_legend},title,featured,alias,author;{date_legend},addTime,startDate,endDate;{source_legend},source,jumpTo,linkText;{details_legend},location,address,teaser;{image_legend},addImage;{recurring_legend},recurring;{enclosure_legend:hide},addEnclosure;{expert_legend:hide},cssClass,noComments;{publish_legend},published,start,stop',
'article' => '{title_legend},title,featured,alias,author;{date_legend},addTime,startDate,endDate;{source_legend},source,articleId,linkText;{details_legend},location,address,teaser;{image_legend},addImage;{recurring_legend},recurring;{enclosure_legend:hide},addEnclosure;{expert_legend:hide},cssClass,noComments;{publish_legend},published,start,stop',
'external' => '{title_legend},title,featured,alias,author;{date_legend},addTime,startDate,endDate;{source_legend},source,url,target,linkText;{details_legend},location,address,teaser;{image_legend},addImage;{recurring_legend},recurring;{enclosure_legend:hide},addEnclosure;{expert_legend:hide},cssClass,noComments;{publish_legend},published,start,stop'
'default' => '{title_legend},title,featured,alias,author;{date_legend},addTime,startDate,endDate;{source_legend},source,linkText;{meta_legend},pageTitle,robots,description,serpPreview;{details_legend},location,address,teaser;{image_legend},addImage;{recurring_legend},recurring;{enclosure_legend:hide},addEnclosure;{expert_legend:hide},cssClass;{publish_legend},published,start,stop',
'internal' => '{title_legend},title,featured,alias,author;{date_legend},addTime,startDate,endDate;{source_legend},source,jumpTo,linkText;{details_legend},location,address,teaser;{image_legend},addImage;{recurring_legend},recurring;{enclosure_legend:hide},addEnclosure;{expert_legend:hide},cssClass;{publish_legend},published,start,stop',
'article' => '{title_legend},title,featured,alias,author;{date_legend},addTime,startDate,endDate;{source_legend},source,articleId,linkText;{details_legend},location,address,teaser;{image_legend},addImage;{recurring_legend},recurring;{enclosure_legend:hide},addEnclosure;{expert_legend:hide},cssClass;{publish_legend},published,start,stop',
'external' => '{title_legend},title,featured,alias,author;{date_legend},addTime,startDate,endDate;{source_legend},source,url,target,linkText;{details_legend},location,address,teaser;{image_legend},addImage;{recurring_legend},recurring;{enclosure_legend:hide},addEnclosure;{expert_legend:hide},cssClass;{publish_legend},published,start,stop'
),

// Sub-palettes
Expand Down Expand Up @@ -448,12 +447,6 @@
'eval' => array('tl_class'=>'w50'),
'sql' => "varchar(255) NOT NULL default ''"
),
'noComments' => array
(
'inputType' => 'checkbox',
'eval' => array('tl_class'=>'w50 m12'),
'sql' => array('type' => 'boolean', 'default' => false)
),
'published' => array
(
'toggle' => true,
Expand Down Expand Up @@ -487,21 +480,6 @@
*/
class tl_calendar_events extends Backend
{
/**
* Unset the "allowComments" field if the comments bundle is not available.
*/
public function adjustDca()
{
$bundles = System::getContainer()->getParameter('kernel.bundles');

// HOOK: comments extension required
if (!isset($bundles['ContaoCommentsBundle']))
{
$key = array_search('allowComments', $GLOBALS['TL_DCA']['tl_calendar_events']['list']['sorting']['headerFields'] ?? array());
unset($GLOBALS['TL_DCA']['tl_calendar_events']['list']['sorting']['headerFields'][$key], $GLOBALS['TL_DCA']['tl_calendar_events']['fields']['noComments']);
}
}

/**
* Auto-generate the event alias if it has not been set yet
*
Expand Down
8 changes: 0 additions & 8 deletions calendar-bundle/contao/dca/tl_module.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,6 @@
'sql' => "varchar(16) COLLATE ascii_bin NOT NULL default 'all_items'"
);

$bundles = System::getContainer()->getParameter('kernel.bundles');

// Add the comments template drop-down menu
if (isset($bundles['ContaoCommentsBundle']))
{
$GLOBALS['TL_DCA']['tl_module']['palettes']['eventreader'] = str_replace('{protected_legend:hide}', '{comment_legend:hide},com_template;{protected_legend:hide}', $GLOBALS['TL_DCA']['tl_module']['palettes']['eventreader']);
}

/**
* Provide miscellaneous methods that are used by the data configuration array.
*
Expand Down
51 changes: 0 additions & 51 deletions calendar-bundle/contao/languages/en/tl_calendar.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -14,54 +14,6 @@
<trans-unit id="tl_calendar.jumpTo.1">
<source>Please choose the event reader page to which visitors will be redirected when clicking an event.</source>
</trans-unit>
<trans-unit id="tl_calendar.allowComments.0">
<source>Enable comments</source>
</trans-unit>
<trans-unit id="tl_calendar.allowComments.1">
<source>Allow visitors to comment events.</source>
</trans-unit>
<trans-unit id="tl_calendar.notify.0">
<source>Notify</source>
</trans-unit>
<trans-unit id="tl_calendar.notify.1">
<source>Please choose who to notify when comments are added.</source>
</trans-unit>
<trans-unit id="tl_calendar.sortOrder.0">
<source>Sort order</source>
</trans-unit>
<trans-unit id="tl_calendar.sortOrder.1">
<source>By default, comments are sorted ascending, starting with the oldest one.</source>
</trans-unit>
<trans-unit id="tl_calendar.perPage.0">
<source>Comments per page</source>
</trans-unit>
<trans-unit id="tl_calendar.perPage.1">
<source>Number of comments per page. Set to 0 to disable pagination.</source>
</trans-unit>
<trans-unit id="tl_calendar.moderate.0">
<source>Moderate comments</source>
</trans-unit>
<trans-unit id="tl_calendar.moderate.1">
<source>Approve comments before they are published on the website.</source>
</trans-unit>
<trans-unit id="tl_calendar.bbcode.0">
<source>Allow BBCode</source>
</trans-unit>
<trans-unit id="tl_calendar.bbcode.1">
<source>Allow visitors to format their comments with BBCode.</source>
</trans-unit>
<trans-unit id="tl_calendar.requireLogin.0">
<source>Require login to comment</source>
</trans-unit>
<trans-unit id="tl_calendar.requireLogin.1">
<source>Allow only authenticated members to create comments.</source>
</trans-unit>
<trans-unit id="tl_calendar.disableCaptcha.0">
<source>Disable spam protection</source>
</trans-unit>
<trans-unit id="tl_calendar.disableCaptcha.1">
<source>Use this option only if you have limited comments to authenticated users.</source>
</trans-unit>
<trans-unit id="tl_calendar.protected.0">
<source>Protect calendar</source>
</trans-unit>
Expand All @@ -83,9 +35,6 @@
<trans-unit id="tl_calendar.title_legend">
<source>Title and redirect page</source>
</trans-unit>
<trans-unit id="tl_calendar.comments_legend">
<source>Comments</source>
</trans-unit>
<trans-unit id="tl_calendar.protected_legend">
<source>Access protection</source>
</trans-unit>
Expand Down
6 changes: 0 additions & 6 deletions calendar-bundle/contao/languages/en/tl_calendar_events.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -185,12 +185,6 @@
<trans-unit id="tl_calendar_events.cssClass.1">
<source>Here you can enter one or more classes.</source>
</trans-unit>
<trans-unit id="tl_calendar_events.noComments.0">
<source>Disable comments</source>
</trans-unit>
<trans-unit id="tl_calendar_events.noComments.1">
<source>Do not allow comments for this particular event.</source>
</trans-unit>
<trans-unit id="tl_calendar_events.featured.0">
<source>Feature event</source>
</trans-unit>
Expand Down
81 changes: 81 additions & 0 deletions comments-bundle/contao/dca/tl_calendar.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?php

/*
* This file is part of Contao.
*
* (c) Leo Feyer
*
* @license LGPL-3.0-or-later
*/

use Contao\CoreBundle\DataContainer\PaletteManipulator;

$GLOBALS['TL_DCA']['tl_calendar']['palettes']['__selector__'][] = 'allowComments';
$GLOBALS['TL_DCA']['tl_calendar']['subpalettes']['allowComments'] = 'notify,sortOrder,perPage,moderate,bbcode,requireLogin,disableCaptcha';

$GLOBALS['TL_DCA']['tl_calendar']['fields']['allowComments'] = array(
'filter' => true,
'inputType' => 'checkbox',
'eval' => array('submitOnChange'=>true),
'sql' => array('type' => 'boolean', 'default' => false)
);

$GLOBALS['TL_DCA']['tl_calendar']['fields']['notify'] = array
(
'inputType' => 'select',
'options' => array('notify_admin', 'notify_author', 'notify_both'),
'eval' => array('tl_class'=>'w50'),
'reference' => &$GLOBALS['TL_LANG']['tl_calendar'],
'sql' => "varchar(32) NOT NULL default 'notify_admin'"
);

$GLOBALS['TL_DCA']['tl_calendar']['fields']['sortOrder'] = array
(
'inputType' => 'select',
'options' => array('ascending', 'descending'),
'reference' => &$GLOBALS['TL_LANG']['MSC'],
'eval' => array('tl_class'=>'w50 clr'),
'sql' => "varchar(32) NOT NULL default 'ascending'"
);

$GLOBALS['TL_DCA']['tl_calendar']['fields']['perPage'] = array
(
'inputType' => 'text',
'eval' => array('rgxp'=>'natural', 'tl_class'=>'w50'),
'sql' => "smallint(5) unsigned NOT NULL default 0"
);

$GLOBALS['TL_DCA']['tl_calendar']['fields']['moderate'] = array
(
'inputType' => 'checkbox',
'eval' => array('tl_class'=>'w50'),
'sql' => array('type' => 'boolean', 'default' => false)
);

$GLOBALS['TL_DCA']['tl_calendar']['fields']['bbcode'] = array
(
'inputType' => 'checkbox',
'eval' => array('tl_class'=>'w50'),
'sql' => array('type' => 'boolean', 'default' => false)
);

$GLOBALS['TL_DCA']['tl_calendar']['fields']['requireLogin'] = array
(
'inputType' => 'checkbox',
'eval' => array('tl_class'=>'w50'),
'sql' => array('type' => 'boolean', 'default' => false)
);

$GLOBALS['TL_DCA']['tl_calendar']['fields']['disableCaptcha'] = array
(
'inputType' => 'checkbox',
'eval' => array('tl_class'=>'w50'),
'sql' => array('type' => 'boolean', 'default' => false)
);

// Extend the default palettes
PaletteManipulator::create()
->addLegend('comments_legend', 'protected_legend', PaletteManipulator::POSITION_AFTER, true)
->addField(array('allowComments'), 'comments_legend', PaletteManipulator::POSITION_APPEND)
->applyToPalette('default', 'tl_calendar')
;
28 changes: 28 additions & 0 deletions comments-bundle/contao/dca/tl_calendar_events.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

/*
* This file is part of Contao.
*
* (c) Leo Feyer
*
* @license LGPL-3.0-or-later
*/

use Contao\CoreBundle\DataContainer\PaletteManipulator;

$GLOBALS['TL_DCA']['tl_calendar_events']['list']['sorting']['headerFields'][] = 'allowComments';

$GLOBALS['TL_DCA']['tl_calendar_events']['fields']['noComments'] = array
(
'inputType' => 'checkbox',
'eval' => array('tl_class'=>'w50 m12'),
'sql' => array('type' => 'boolean', 'default' => false)
);

PaletteManipulator::create()
->addField(array('noComments'), 'expert_legend', PaletteManipulator::POSITION_APPEND)
->applyToPalette('default', 'tl_calendar_events')
->applyToPalette('internal', 'tl_calendar_events')
->applyToPalette('article', 'tl_calendar_events')
->applyToPalette('external', 'tl_calendar_events')
;