Skip to content

Commit

Permalink
unlock Contao 5
Browse files Browse the repository at this point in the history
  • Loading branch information
fritzmg committed Jul 31, 2022
1 parent 6095f70 commit b66d7fd
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
],
"require":{
"php": ">=7.1",
"contao/core-bundle": "^4.9"
"contao/core-bundle": "^4.9 || ^5.0"
},
"require-dev": {
"contao/manager-plugin": "^2.0"
Expand Down
21 changes: 14 additions & 7 deletions src/Models/NewsRelatedModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@

namespace ContaoNewsRelatedBundle\Models;

use Contao\Config;
use Contao\Date;
use Contao\Input;
use Contao\NewsModel;
use Contao\StringUtil;
use Contao\System;

/*
* Dynamic parent class
*/
Expand Down Expand Up @@ -55,29 +62,29 @@ public function newsListFetchItems($newsArchives, $blnFeatured, $limit, $offset,
$retNoItem = $objModule->disableEmpty ? false : null;

// get the table and prepare columns, values and options
$t = \NewsModel::getTable();
$t = self::getTable();
$arrColumns = ["$t.pid IN(".implode(',', array_map('intval', $newsArchives)).')'];
$arrValues = [];
$arrOptions = [];

// get the active item
$item = \Config::get('useAutoItem') ? \Input::get('auto_item') : !\Input::get('items');
$item = Config::get('useAutoItem') ? Input::get('auto_item') : !Input::get('items');

// check if there is an active tem
if (!$item) {
return $retNoItem;
}

// get the news
$objNews = \NewsModel::findByAlias($item);
$objNews = self::findByAlias($item);

// check if news was found
if (!$objNews) {
return $retNoItem;
}

// Get the related news
$arrRelated = deserialize($objNews->relatedNews);
$arrRelated = StringUtil::deserialize($objNews->relatedNews);

// Check if any related news are defined
if (!$arrRelated) {
Expand All @@ -99,8 +106,8 @@ public function newsListFetchItems($newsArchives, $blnFeatured, $limit, $offset,
$arrColumns[] = "$t.featured=''";
}

if (!BE_USER_LOGGED_IN || TL_MODE === 'BE') {
$time = \Date::floorToMinute();
if (!System::getContainer()->get('contao.security.token_checker')->isPreviewMode()) {
$time = Date::floorToMinute();
$arrColumns[] = "($t.start='' OR $t.start<='$time') AND ($t.stop='' OR $t.stop>'".($time + 60)."') AND $t.published='1'";
}

Expand Down Expand Up @@ -147,7 +154,7 @@ public function newsListFetchItems($newsArchives, $blnFeatured, $limit, $offset,
// support for news_categories
if (class_exists('\NewsCategories\NewsModel')) {
$GLOBALS['NEWS_FILTER_CATEGORIES'] = $objModule->news_filterCategories ? true : false;
$GLOBALS['NEWS_FILTER_DEFAULT'] = deserialize($objModule->news_filterDefault, true);
$GLOBALS['NEWS_FILTER_DEFAULT'] = StringUtil::deserialize($objModule->news_filterDefault, true);
$GLOBALS['NEWS_FILTER_PRESERVE'] = $objModule->news_filterPreserve;

$arrColumns = self::filterByCategories($arrColumns);
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/contao/dca/tl_news.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
];

$pm = PaletteManipulator::create()
->addLegend('related_news_legend', null, PaletteManipulator::POSITION_AFTER, true)
->addLegend('related_news_legend', 'foobar', PaletteManipulator::POSITION_AFTER, true)
->addField('relatedNews', 'related_news_legend', PaletteManipulator::POSITION_APPEND)
;

Expand Down

0 comments on commit b66d7fd

Please sign in to comment.