From c9de8306a0d1131b23f38065a8b019105df52c90 Mon Sep 17 00:00:00 2001 From: Boris Komraz Date: Sun, 29 Oct 2023 01:07:05 +0300 Subject: [PATCH 1/2] Joomla4/5 --- helper.php | 19 +++++++++++-------- mod_dn.xml | 6 +++--- 2 files changed, 14 insertions(+), 11 deletions(-) mode change 100755 => 100644 helper.php diff --git a/helper.php b/helper.php old mode 100755 new mode 100644 index 60e9312..c3619ee --- a/helper.php +++ b/helper.php @@ -9,13 +9,16 @@ defined('_JEXEC') or die ('Restricted access'); -use Joomla\CMS\Helper\ModuleHelper; +use Joomla\CMS\Factory; -if (version_compare(JVERSION, '4.0.0', '>=')) { +if (version_compare(JVERSION, '5.0.0', '<')) { +if (version_compare(JVERSION, '4.0.0', '>=')) +{ require_once JPATH_LIBRARIES . '/classmap.php'; } else { require_once(JPATH_SITE . '/components/com_content/helpers/route.php'); } +} // loads module function file jimport('joomla.event.dispatcher'); @@ -34,9 +37,9 @@ class modDisplayNewsHelper var string $version = "DisplayNews by BK 3.0.3"; var string $target = ""; static array $shown_list = array(); - var JApplicationSite $app; + var Joomla\CMS\Application\SiteApplication $app; var string $currcontentid; - var JRegistry $params; + var Joomla\Registry\Registry $params; function readmore_out($row, $aroute, $aparams): string { @@ -1255,8 +1258,8 @@ function init_params($params, $module_id): bool $this->set_article_id = array_filter(array_merge((array)($this->params->get('set_article_id')), (array)($this->params->get('set_article_archived_id')), - explode(",", $this->params->get('set_article_id_extra')), - explode(",", $this->params->get('set_article_archived_id_extra')))); + explode(",", $this->params->get('set_article_id_extra') ?? ''), + explode(",", $this->params->get('set_article_archived_id_extra') ?? ''))); // $set_author_id = $this->params->get( 'set_author_id'); // $set_author_name = $this->params->get( 'set_author_name'); @@ -1542,7 +1545,7 @@ function init_params($params, $module_id): bool if ($this->view == "article") { $temp = $this->app->input->getString('id'); - $temp = explode(':', $temp); + $temp = explode(':', $temp ?? ''); $this->currcontentid = $temp[0]; } @@ -2178,7 +2181,7 @@ function mod_title_out($row): string function main(&$params, $module_id): string { - $this->app = JFactory::getApplication(); + $this->app = Factory::getApplication(); if ($this->init_params($params, $module_id) === false) { return ""; diff --git a/mod_dn.xml b/mod_dn.xml index 233c5ea..3fea8fe 100644 --- a/mod_dn.xml +++ b/mod_dn.xml @@ -2,12 +2,12 @@ DisplayNews BK - 2022-Nov-27 - (C) 2006 - 2022 BK. All rights reserved. + 2023-Oct-29 + (C) 2006 - 2023 BK. All rights reserved. http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL bkomraz1@gmail.com http://joomla.rjews.net - 3.0.3 + 4.0.0 DISPLAY_NEWS_BY_BK_MODULE Date: Sat, 4 Nov 2023 00:02:55 +0200 Subject: [PATCH 2/2] Joomla4/5 --- helper.php | 2 -- mod_dn.xml | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/helper.php b/helper.php index c3619ee..f8600ec 100644 --- a/helper.php +++ b/helper.php @@ -980,8 +980,6 @@ function dn_hovertext($text1, $text2): string function truncate($text, $length = 100, $ending = '...', $exact = true, $considerHtml = false): array { - require_once(JPATH_LIBRARIES . '/phputf8/utf8.php'); - if (utf8_strlen($ending) > $length) { $ending = utf8_substr($ending, 0, $length); } diff --git a/mod_dn.xml b/mod_dn.xml index 3fea8fe..d4e4f2f 100644 --- a/mod_dn.xml +++ b/mod_dn.xml @@ -2,7 +2,7 @@ DisplayNews BK - 2023-Oct-29 + 2023-Nov-03 (C) 2006 - 2023 BK. All rights reserved. http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL bkomraz1@gmail.com