From 4a37be34ca61a2920afbcbbe4c3eaaa29d90e1c1 Mon Sep 17 00:00:00 2001 From: McKillo Date: Sun, 14 Jan 2024 19:10:20 +0100 Subject: [PATCH 01/11] Update attachments.php --- attachments_plugin/attachments.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/attachments_plugin/attachments.php b/attachments_plugin/attachments.php index 19f84582..6d5e2cfb 100644 --- a/attachments_plugin/attachments.php +++ b/attachments_plugin/attachments.php @@ -100,8 +100,13 @@ public static function getSubscribedEvents(): array // public function onContentPrepare($context, &$row, &$params, $page = 0) public function onContentPrepare(Event $event) { - [$context, $row, $params, $page] = $event->getArguments(); - // Enable the following four diagnostic lines to see if a component uses onContentPrepare + $arguments = $event->getArguments(); + $context = $arguments['context']; + $row = $arguments['subject']; + $params = $arguments['params']; + $page = $arguments['page']; + + // Enable the following four diagnostic lines to see if a component uses onContentPrepare // $msg = "
onContentPrepare: CONTEXT: $context, OBJ: " . get_class($row) . ", VIEW: " . JRequest::getCmd('view'); // if (isset($row->text)) $row->text .= $msg; // if (isset($row->introtext)) $row->introtext .= $msg; @@ -253,7 +258,12 @@ public function onContentPrepare(Event $event) */ public function onContentBeforeDisplay(Event $event) { - [$context, $row, $params, $page] = $event->getArguments(); + $arguments = $event->getArguments(); + $context = $arguments['context']; + $row = $arguments['subject']; + $params = $arguments['params']; + $page = $arguments['page']; + $input = $this->app->getInput(); $view = $input->getCmd('view'); $layout = $input->getCmd('layout'); From 4853c7ba67887611a61fe5405c9035e26f16a6ed Mon Sep 17 00:00:00 2001 From: McKillo Date: Sun, 14 Jan 2024 20:33:59 +0100 Subject: [PATCH 02/11] Update attachments_for_content.php --- attachments_for_content/attachments_for_content.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/attachments_for_content/attachments_for_content.php b/attachments_for_content/attachments_for_content.php index f7c40c74..1e510c62 100644 --- a/attachments_for_content/attachments_for_content.php +++ b/attachments_for_content/attachments_for_content.php @@ -494,12 +494,12 @@ public function isParentPublished($parent_id, $parent_entity = 'default') } $now = Factory::getDate()->toUnix(); - $nullDate = Factory::getDate($db->getNullDate())->toUnix(); + $nullDate = null; if ($article) { $publish_up = Factory::getDate($article->publish_up)->toUnix(); - $publish_down = Factory::getDate($article->publish_down)->toUnix(); + $publish_down = $article->publish_down? Factory::getDate($article->publish_down)->toUnix():null; $published = (($article->state == 1) && ($now >= $publish_up) && (($publish_down == $nullDate) || ($now <= $publish_down))); } From 5ed42de3c635416e50b5b3ac975158173d2181f8 Mon Sep 17 00:00:00 2001 From: McKillo Date: Sun, 14 Jan 2024 20:56:05 +0100 Subject: [PATCH 03/11] Update attachments_for_content.php --- attachments_for_content/attachments_for_content.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/attachments_for_content/attachments_for_content.php b/attachments_for_content/attachments_for_content.php index 1e510c62..b59eb7b7 100644 --- a/attachments_for_content/attachments_for_content.php +++ b/attachments_for_content/attachments_for_content.php @@ -837,12 +837,18 @@ public function attachmentsHiddenForParent(&$parent, $parent_id, $parent_entity) } // See if the options apply to this article - $created_by = (int) $attachments[0]->created_by; - $catid = (int) $attachments[0]->catid; + if(count($attachments)) + { + $created_by = (int)$attachments[0]->created_by; + $catid = (int)$attachments[0]->catid; + }else{ + $created_by = 0; + $catid = 0; + } // First, check to see whether the attachments should be hidden for this parent $hide_attachments_for_categories = $aparams->get('hide_attachments_for_categories', Array()); - if (in_array($catid, $hide_attachments_for_categories)) + if (in_array($catid, $hide_attachments_for_categories) && $catid) { return true; } From 4ff42db1aa896db3ba417a20b728d08dc95935ff Mon Sep 17 00:00:00 2001 From: McKillo Date: Mon, 15 Jan 2024 23:55:57 +0100 Subject: [PATCH 04/11] Update AttachmentsController.php --- .../admin/src/Controller/AttachmentsController.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/attachments_component/admin/src/Controller/AttachmentsController.php b/attachments_component/admin/src/Controller/AttachmentsController.php index 10ade93c..9ed281d0 100644 --- a/attachments_component/admin/src/Controller/AttachmentsController.php +++ b/attachments_component/admin/src/Controller/AttachmentsController.php @@ -156,13 +156,12 @@ public function delete() $cid = $input->get('cid', array(), 'array'); $deleted_ids = Array(); + /** @var \JMCameron\Component\Attachments\Administrator\Model\AttachmentModel $model */ + $model = $this->getModel('Attachment'); + $attachment = $model->getTable(); + if (count($cid)) { - /** @var \JMCameron\Component\Attachments\Administrator\Model\AttachmentModel $model */ - $model = $this->getModel('Attachment'); - $attachment = $model->getTable(); - - // Loop through the attachments and delete them one-by-one foreach ($cid as $attachment_id) { From 95859acae25437dbfe9b8eb29abadbe271abf47a Mon Sep 17 00:00:00 2001 From: McKillo Date: Tue, 16 Jan 2024 00:02:31 +0100 Subject: [PATCH 05/11] Update default.php --- attachments_component/admin/tmpl/help/default.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/attachments_component/admin/tmpl/help/default.php b/attachments_component/admin/tmpl/help/default.php index 54f597d1..785021f0 100644 --- a/attachments_component/admin/tmpl/help/default.php +++ b/attachments_component/admin/tmpl/help/default.php @@ -91,7 +91,7 @@ ?>
- +

>logo_img ?>


From 02e04c681c8a30d01abecc2352e182f48aaf3351 Mon Sep 17 00:00:00 2001 From: McKillo Date: Tue, 16 Jan 2024 00:04:46 +0100 Subject: [PATCH 06/11] Update default.php --- attachments_component/site/tmpl/update/default.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/attachments_component/site/tmpl/update/default.php b/attachments_component/site/tmpl/update/default.php index 9f426aa8..c7f72055 100644 --- a/attachments_component/site/tmpl/update/default.php +++ b/attachments_component/site/tmpl/update/default.php @@ -204,7 +204,7 @@ get('allow_frontend_access_editing', false) ): ?>      -
access_level; ?>
+
access_level; ?>
get('user_field_1_name') ): ?>

From 45347b8de440bf8732216df30391eeaef30808d4 Mon Sep 17 00:00:00 2001 From: McKillo Date: Tue, 16 Jan 2024 00:04:50 +0100 Subject: [PATCH 07/11] Update default.php --- attachments_component/site/tmpl/upload/default.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/attachments_component/site/tmpl/upload/default.php b/attachments_component/site/tmpl/upload/default.php index b5ed07c6..7c86ed99 100644 --- a/attachments_component/site/tmpl/upload/default.php +++ b/attachments_component/site/tmpl/upload/default.php @@ -147,7 +147,7 @@ get('allow_frontend_access_editing', false) ): ?>      -

access_level; ?>
+
access_level; ?>
get('user_field_1_name', false) ): ?>

From d293223188cfa082b223c1087e95b589f669b4e2 Mon Sep 17 00:00:00 2001 From: McKillo Date: Tue, 16 Jan 2024 00:05:01 +0100 Subject: [PATCH 08/11] Update default.php --- attachments_component/site/tmpl/attachments/default.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/attachments_component/site/tmpl/attachments/default.php b/attachments_component/site/tmpl/attachments/default.php index a46cb437..d7096fea 100644 --- a/attachments_component/site/tmpl/attachments/default.php +++ b/attachments_component/site/tmpl/attachments/default.php @@ -174,7 +174,8 @@ else { $url = $base_url . $attachment->url; if (strtoupper(substr(PHP_OS,0,3) == 'WIN')) { - $url = utf8_encode($url); + // $url = utf8_encode($url); Deprecated from php 8.2 + $url = iconv('ISO-8859-1', 'UTF-8', $url); } } $tooltip = Text::sprintf('ATTACH_DOWNLOAD_THIS_FILE_S', $actual_filename); From 0d923929386bed76ae8531596bc4681c40f7eeb2 Mon Sep 17 00:00:00 2001 From: McKillo Date: Fri, 16 Aug 2024 07:42:49 +0200 Subject: [PATCH 09/11] First install the component Declare the component as the first element of the file list, so that this zip is the first to be installed. The component is the base of the installation, then modules and components. For this reason, the order has been changed and the component line has been placed first. --- pkg_attachments/pkg_attachments.xml | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/pkg_attachments/pkg_attachments.xml b/pkg_attachments/pkg_attachments.xml index 8b74098d..b0ffd25a 100644 --- a/pkg_attachments/pkg_attachments.xml +++ b/pkg_attachments/pkg_attachments.xml @@ -14,16 +14,15 @@ ATTACH_PACKAGE_ATTACHMENTS_FOR_JOOMLA_16PLUS - attachments_plugin.zip - attachments_search.zip - attachments_plugin_framework.zip - attachments_for_content.zip - show_attachments_in_editor_plugin.zip - add_attachment_btn_plugin.zip - insert_attachments_token_btn_plugin.zip - attachments_quickicon_plugin.zip - - attachments_component.zip + attachments_component.zip + attachments_plugin.zip + attachments_search.zip + attachments_plugin_framework.zip + attachments_for_content.zip + show_attachments_in_editor_plugin.zip + add_attachment_btn_plugin.zip + insert_attachments_token_btn_plugin.zip + attachments_quickicon_plugin.zip From 4002184caf910aa45b81eaa84482dcb00b09ee8c Mon Sep 17 00:00:00 2001 From: McKillo Date: Fri, 16 Aug 2024 08:16:07 +0200 Subject: [PATCH 10/11] Update en-GB.pkg_attachments.sys.ini Fix error ATTACH_PACKAGE_ATTACHMENTS_FOR_JOOMLA_40PLUS doesn't exist. The version in the string is updated for Joomla 4.0+. Now, the package name is right. --- pkg_attachments/language/en-GB/en-GB.pkg_attachments.sys.ini | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg_attachments/language/en-GB/en-GB.pkg_attachments.sys.ini b/pkg_attachments/language/en-GB/en-GB.pkg_attachments.sys.ini index 1a24ad6f..baa10aed 100644 --- a/pkg_attachments/language/en-GB/en-GB.pkg_attachments.sys.ini +++ b/pkg_attachments/language/en-GB/en-GB.pkg_attachments.sys.ini @@ -6,6 +6,6 @@ ; English translation -ATTACH_PACKAGE_ATTACHMENTS_FOR_JOOMLA_16PLUS="Attachments for Joomla 2.5+ or 3.x" +ATTACH_PACKAGE_ATTACHMENTS_FOR_JOOMLA_40PLUS="Attachments for Joomla 4.0+" ATTACH_PACKAGE_NOTICE_UNINSTALL_PACKAGE_S="To uninstall the Attachments extension, uninstall the Package '%s'!" -PKG_ATTACHMENTS="Package: Attachments for Joomla 2.5+ or 3.x" +PKG_ATTACHMENTS="Package: Attachments for Joomla 4.0+" From 7d1d18791beccc41fdc6b395ea480126e77680c8 Mon Sep 17 00:00:00 2001 From: McKillo Date: Fri, 16 Aug 2024 10:30:59 +0200 Subject: [PATCH 11/11] Fix deprecated datetime format with null value [edit attach from BE] Update code with datetime when the article could have a null in publish_up and publish_down value. --- attachments_for_content/attachments_for_content.php | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/attachments_for_content/attachments_for_content.php b/attachments_for_content/attachments_for_content.php index f18ed7c3..c6ba99dc 100644 --- a/attachments_for_content/attachments_for_content.php +++ b/attachments_for_content/attachments_for_content.php @@ -496,14 +496,13 @@ public function isParentPublished($parent_id, $parent_entity = 'default') } $now = Factory::getDate()->toUnix(); - $nullDate = Factory::getDate($db->getNullDate())->toUnix(); if ($article) { - $publish_up = Factory::getDate($article->publish_up)->toUnix(); - $publish_down = Factory::getDate($article->publish_down)->toUnix(); + $publish_up = $article->publish_up? Factory::getDate($article->publish_up)->toUnix() : null; + $publish_down = $article->publish_down? Factory::getDate($article->publish_down)->toUnix() : null; - $published = (($article->state == 1) && ($now >= $publish_up) && (($publish_down == $nullDate) || ($now <= $publish_down))); + $published = (($article->state == 1) && ($now >= $publish_up) && (($publish_down === null) || ($now <= $publish_down))); } else { @@ -593,11 +592,10 @@ public function getParentPublishedFilter($parent_state, $filter_entity) if (($filter_entity == 'ALL') || ($filter_entity == 'ARTICLE')) { $now = Factory::getDate()->toSql(); - $nullDate = $db->getNullDate(); $where[] = "EXISTS (SELECT * FROM #__content AS c1 " . "WHERE (a.parent_entity = 'article' AND c1.id = a.parent_id AND c1.state=1 AND " . - '(c1.publish_up = ' . $db->quote($nullDate) . ' OR c1.publish_up <= ' . $db->quote($now) . ') AND ' . - '(c1.publish_down = ' . $db->quote($nullDate) . ' OR c1.publish_down >= ' . $db->quote($now) . ')))'; + '(c1.publish_up IS null OR c1.publish_up <= ' . $db->quote($now) . ') AND ' . + '(c1.publish_down IS null OR c1.publish_down >= ' . $db->quote($now) . ')))'; } if (($filter_entity == 'ALL') || ($filter_entity == 'CATEGORY'))