From 2485e682599fcbd2cbe48dc47c705a027609ee25 Mon Sep 17 00:00:00 2001
From: Thorsten <88725484+IMC-GER@users.noreply.github.com>
Date: Fri, 15 Dec 2023 19:37:35 +0100
Subject: [PATCH] v1.1.0
---
README.md | 27 ++--
..._version.json => activetopics_version.json | 4 +-
.../README.md | 28 ++--
.../style/event/acp_overall_footer_after.html | 36 +++++
.../composer.json | 14 +-
imcger/activetopics/config/services.yml | 19 +++
imcger/activetopics/event/acp_listener.php | 103 +++++++++++++++
imcger/activetopics/event/main_listener.php | 123 ++++++++++++++++++
imcger/activetopics/ext.php | 22 ++++
imcger/activetopics/language/de/common.php | 40 ++++++
.../activetopics/language/de_x_sie/common.php | 40 ++++++
imcger/activetopics/language/en/common.php | 40 ++++++
.../license.txt | 0
.../migrations/activetopics_01.php | 59 +++++++++
.../styles/prosilver/template/activetopics.js | 18 +++
.../topiclist_row_topic_by_author_after.html | 1 +
.../event/viewforum_forum_title_before.html | 3 +
.../event/acp_forums_custom_settings.html | 28 ----
18 files changed, 544 insertions(+), 61 deletions(-)
rename numberactivetopics_version.json => activetopics_version.json (61%)
rename imcger/{numberactivetopics => activetopics}/README.md (50%)
create mode 100644 imcger/activetopics/adm/style/event/acp_overall_footer_after.html
rename imcger/{numberactivetopics => activetopics}/composer.json (57%)
create mode 100644 imcger/activetopics/config/services.yml
create mode 100644 imcger/activetopics/event/acp_listener.php
create mode 100644 imcger/activetopics/event/main_listener.php
create mode 100644 imcger/activetopics/ext.php
create mode 100644 imcger/activetopics/language/de/common.php
create mode 100644 imcger/activetopics/language/de_x_sie/common.php
create mode 100644 imcger/activetopics/language/en/common.php
rename imcger/{numberactivetopics => activetopics}/license.txt (100%)
create mode 100644 imcger/activetopics/migrations/activetopics_01.php
create mode 100644 imcger/activetopics/styles/prosilver/template/activetopics.js
create mode 100644 imcger/activetopics/styles/prosilver/template/event/topiclist_row_topic_by_author_after.html
create mode 100644 imcger/activetopics/styles/prosilver/template/event/viewforum_forum_title_before.html
delete mode 100644 imcger/numberactivetopics/adm/style/event/acp_forums_custom_settings.html
diff --git a/README.md b/README.md
index 65f5858..cd39b9b 100644
--- a/README.md
+++ b/README.md
@@ -1,37 +1,40 @@
-# phpBB Number of Active Topics
+# phpBB Active Topics
## Description
-If you configure a forum as a category, the active topics of the sub-forums can be displayed there. This extension allows you to set the number of topics.
+If you configure a forum as a category, the active topics of the sub-forums can be displayed there. This extension allows you to define the position of the active topics and the number of topics displayed.
+
#### Settings in Administration Control Panel
In "Manage Forums" -> "Edit Forum"
+- Display active topics above the forums
- Topics per page
## Screenshots
-- [ACP](https://raw.githubusercontent.com/IMC-GER/images/main/screenshots/numberactivetopics/en/acp-edit-forum.png)
+- [ACP](https://raw.githubusercontent.com/IMC-GER/images/main/screenshots/activetopics/acp_en.png)
+- [Forum](https://raw.githubusercontent.com/IMC-GER/images/main/screenshots/activetopics/forum.png)
## Requirements
- phpBB 3.3.0 or higher
## Installation
-Copy the extension to `phpBB3/ext/imcger/numberactivetopics`.
-Go to "ACP" > "Customise" > "Manage extensions" and enable the "Number of Active Topics" extension.
+Copy the extension to `phpBB3/ext/imcger/activetopics`.
+Go to "ACP" > "Customise" > "Manage extensions" and enable the "Active Topics" extension.
## Update
- Navigate in the ACP to `Customise -> Manage extensions`.
-- Click the `Disable` link for "Number of Active Topics".
-- Delete the `numberactivetopics` folder from `phpBB3/ext/imcger/`.
-- Copy the extension to `phpBB3/ext/imcger/numberactivetopics`.
-- Go to "ACP" > "Customise" > "Manage extensions" and enable the "Number of Active Topics" extension.
+- Click the `Disable` link for "Active Topics".
+- Delete the `activetopics` folder from `phpBB3/ext/imcger/`.
+- Copy the extension to `phpBB3/ext/imcger/activetopics`.
+- Go to "ACP" > "Customise" > "Manage extensions" and enable the "Active Topics" extension.
## Changelog
-### v1.0.0 (29-07-2023)
+### v1.1.0 (15-12-2023)
- Published
## Uninstallation
- Navigate in the ACP to `Customise -> Manage extensions`.
-- Click the `Disable` link for "Number of Active Topics".
-- To permanently uninstall, click `Delete Data`, then delete the `numberactivetopics` folder from `phpBB3/ext/imcger/`.
+- Click the `Disable` link for "Active Topics".
+- To permanently uninstall, click `Delete Data`, then delete the `activetopics` folder from `phpBB3/ext/imcger/`.
## License
[GPLv2](https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html)
diff --git a/numberactivetopics_version.json b/activetopics_version.json
similarity index 61%
rename from numberactivetopics_version.json
rename to activetopics_version.json
index 2c2091c..9095ff6 100644
--- a/numberactivetopics_version.json
+++ b/activetopics_version.json
@@ -1,9 +1,9 @@
{
"stable": {
"1.0": {
- "current": "1.0.0",
+ "current": "1.1.0",
"announcement": "https://www.phpbb.de/community/viewtopic.php?t=246827",
- "download": "https://github.com/IMC-GER/phpBB-Number-of-Active-Topics/tags",
+ "download": "https://github.com/IMC-GER/phpBB-Active-Topics/tags",
"eol": null,
"security": false
}
diff --git a/imcger/numberactivetopics/README.md b/imcger/activetopics/README.md
similarity index 50%
rename from imcger/numberactivetopics/README.md
rename to imcger/activetopics/README.md
index 65f5858..eccf08a 100644
--- a/imcger/numberactivetopics/README.md
+++ b/imcger/activetopics/README.md
@@ -1,37 +1,41 @@
-# phpBB Number of Active Topics
+# phpBB Active Topics
## Description
-If you configure a forum as a category, the active topics of the sub-forums can be displayed there. This extension allows you to set the number of topics.
+If you configure a forum as a category, the active topics of the sub-forums can be displayed there.
+This extension allows you to define the position of the active topics and the number of topics displayed.
+
#### Settings in Administration Control Panel
In "Manage Forums" -> "Edit Forum"
+- Display active topics above the forums
- Topics per page
## Screenshots
-- [ACP](https://raw.githubusercontent.com/IMC-GER/images/main/screenshots/numberactivetopics/en/acp-edit-forum.png)
+- [ACP](https://raw.githubusercontent.com/IMC-GER/images/main/screenshots/activetopics/acp_en.png)
+- [Forum](https://raw.githubusercontent.com/IMC-GER/images/main/screenshots/activetopics/forum.png)
## Requirements
- phpBB 3.3.0 or higher
## Installation
-Copy the extension to `phpBB3/ext/imcger/numberactivetopics`.
-Go to "ACP" > "Customise" > "Manage extensions" and enable the "Number of Active Topics" extension.
+Copy the extension to `phpBB3/ext/imcger/activetopics`.
+Go to "ACP" > "Customise" > "Manage extensions" and enable the "Active Topics" extension.
## Update
- Navigate in the ACP to `Customise -> Manage extensions`.
-- Click the `Disable` link for "Number of Active Topics".
-- Delete the `numberactivetopics` folder from `phpBB3/ext/imcger/`.
-- Copy the extension to `phpBB3/ext/imcger/numberactivetopics`.
-- Go to "ACP" > "Customise" > "Manage extensions" and enable the "Number of Active Topics" extension.
+- Click the `Disable` link for "Active Topics".
+- Delete the `activetopics` folder from `phpBB3/ext/imcger/`.
+- Copy the extension to `phpBB3/ext/imcger/activetopics`.
+- Go to "ACP" > "Customise" > "Manage extensions" and enable the "Active Topics" extension.
## Changelog
-### v1.0.0 (29-07-2023)
+### v1.1.0 (15-12-2023)
- Published
## Uninstallation
- Navigate in the ACP to `Customise -> Manage extensions`.
-- Click the `Disable` link for "Number of Active Topics".
-- To permanently uninstall, click `Delete Data`, then delete the `numberactivetopics` folder from `phpBB3/ext/imcger/`.
+- Click the `Disable` link for "Active Topics".
+- To permanently uninstall, click `Delete Data`, then delete the `activetopics` folder from `phpBB3/ext/imcger/`.
## License
[GPLv2](https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html)
diff --git a/imcger/activetopics/adm/style/event/acp_overall_footer_after.html b/imcger/activetopics/adm/style/event/acp_overall_footer_after.html
new file mode 100644
index 0000000..1377bf4
--- /dev/null
+++ b/imcger/activetopics/adm/style/event/acp_overall_footer_after.html
@@ -0,0 +1,36 @@
+{#
+ Active Topics
+ An extension for the phpBB Forum Software package.
+
+ @copyright (c) 2023, Thorsten Ahlers
+ @license GNU General Public License, version 2 (GPL-2.0)
+#}
+{% if FORUM_POST || FORUM_LINK || FORUM_CAT %}
+
+{% endif %}
diff --git a/imcger/numberactivetopics/composer.json b/imcger/activetopics/composer.json
similarity index 57%
rename from imcger/numberactivetopics/composer.json
rename to imcger/activetopics/composer.json
index 7f8d438..c3be245 100644
--- a/imcger/numberactivetopics/composer.json
+++ b/imcger/activetopics/composer.json
@@ -1,10 +1,10 @@
{
- "name": "imcger/numberactivetopics",
+ "name": "imcger/activetopics",
"type": "phpbb-extension",
- "description": "This extension enables the setting, topics per page for active topics.",
+ "description": "This extension enables settings for active topics.",
"homepage": "",
- "version": "1.0.0",
- "time": "2023-07-29",
+ "version": "1.1.0",
+ "time": "2023-12-15",
"license": "GPL-2.0-only",
"authors": [{
"name": "Thorsten Ahlers",
@@ -16,14 +16,14 @@
"php": ">=7.1.3"
},
"extra": {
- "display-name": "Number of Active Topics",
+ "display-name": "Active Topics",
"soft-require": {
"phpbb/phpbb": ">=3.3.0"
},
"version-check": {
"host": "raw.githubusercontent.com",
- "directory": "/IMC-GER/phpBB-Number-of-Active-Topics/master",
- "filename": "numberactivetopics_version.json",
+ "directory": "/IMC-GER/phpBB-Active-Topics/master",
+ "filename": "activetopics_version.json",
"ssl": true
}
}
diff --git a/imcger/activetopics/config/services.yml b/imcger/activetopics/config/services.yml
new file mode 100644
index 0000000..3e6366a
--- /dev/null
+++ b/imcger/activetopics/config/services.yml
@@ -0,0 +1,19 @@
+services:
+ imcger.activetopics.acp_listener:
+ class: imcger\activetopics\event\acp_listener
+ arguments:
+ - '@request'
+ - '@language'
+ tags:
+ - { name: event.listener }
+
+ imcger.activetopics.main_listener:
+ class: imcger\activetopics\event\main_listener
+ arguments:
+ - '@template'
+ - '@dbal.conn'
+ - '%core.root_path%'
+ - '%core.php_ext%'
+ tags:
+ - { name: event.listener }
+
diff --git a/imcger/activetopics/event/acp_listener.php b/imcger/activetopics/event/acp_listener.php
new file mode 100644
index 0000000..6fcaa93
--- /dev/null
+++ b/imcger/activetopics/event/acp_listener.php
@@ -0,0 +1,103 @@
+request = $request;
+ $this->language = $language;
+ }
+
+ /**
+ * Get subscribed events
+ *
+ * @return array
+ * @static
+ */
+ public static function getSubscribedEvents()
+ {
+ return [
+ 'core.acp_manage_forums_request_data' => 'acp_manage_forums_request_data',
+ 'core.acp_manage_forums_initialise_data' => 'acp_manage_forums_initialise_data',
+ 'core.acp_manage_forums_display_form' => 'acp_manage_forums_display_form',
+ ];
+ }
+
+ /**
+ * Submit form (add/update)
+ *
+ * @param \phpbb\event\data $event The event object
+ * @return null
+ * @access public
+ */
+ public function acp_manage_forums_request_data($event)
+ {
+ $array = $event['forum_data'];
+ $array['imcger_display_active_position'] = $this->request->variable('imcger_display_active_position', 0);
+ $event['forum_data'] = $array;
+ }
+
+ /**
+ * Default settings for new forums
+ *
+ * @param \phpbb\event\data $event The event object
+ * @return null
+ * @access public
+ */
+ public function acp_manage_forums_initialise_data($event)
+ {
+ if ($event['action'] == 'add')
+ {
+ $array = $event['forum_data'];
+ $array['imcger_display_active_position'] = '0';
+ $event['forum_data'] = $array;
+ }
+ }
+
+ /**
+ * ACP forums template output
+ *
+ * @param \phpbb\event\data $event The event object
+ * @return null
+ * @access public
+ */
+ public function acp_manage_forums_display_form($event)
+ {
+ $this->language->add_lang('common', 'imcger/activetopics');
+
+ $array = $event['template_data'];
+ $array['IMCGER_DISPLAY_ACTIVE_POSITION'] = $event['forum_data']['imcger_display_active_position'];
+ $event['template_data'] = $array;
+ }
+}
diff --git a/imcger/activetopics/event/main_listener.php b/imcger/activetopics/event/main_listener.php
new file mode 100644
index 0000000..8108a6b
--- /dev/null
+++ b/imcger/activetopics/event/main_listener.php
@@ -0,0 +1,123 @@
+template = $template;
+ $this->db = $db;
+ $this->phpbb_root_path = $root_path;
+ $this->php_ext = $php_ext;
+ }
+
+ /**
+ * Get subscribed events
+ *
+ * @return array
+ * @static
+ */
+ public static function getSubscribedEvents()
+ {
+ return [
+ 'core.viewforum_modify_page_title' => 'set_template_vars',
+ 'core.viewforum_modify_topicrow' => 'set_template_vars_forum_name',
+ ];
+ }
+
+ /**
+ * Set template vars
+ *
+ * @return null
+ * @access public
+ */
+ public function set_template_vars($event)
+ {
+ $this->forum_id = $event['forum_id'];
+
+ $sql = 'SELECT imcger_display_active_position FROM ' . FORUMS_TABLE . '
+ WHERE forum_id = ' . $this->forum_id;
+
+ $result = $this->db->sql_query($sql);
+ $row = $this->db->sql_fetchrow($result);
+ $this->db->sql_freeresult($result);
+
+ $this->template->assign_vars([
+ 'IMCGER_DISPLAY_ACTIVE_POSITION' => (int) $row['imcger_display_active_position'],
+ ]);
+ }
+
+ /**
+ * Set template vars
+ *
+ * @return null
+ * @access public
+ */
+ public function set_template_vars_forum_name($event)
+ {
+ $topic_row = $event['topic_row'];
+ $links_forum = '';
+ $topic_forum_id = $topic_row['FORUM_ID'];
+
+ do {
+ $sql = 'SELECT forum_name, parent_id FROM ' . FORUMS_TABLE . '
+ WHERE forum_id = ' . (int) $topic_forum_id;
+
+ $result = $this->db->sql_query($sql);
+ $row = $this->db->sql_fetchrow($result);
+ $this->db->sql_freeresult($result);
+
+ $u_view_forum = append_sid("{$this->phpbb_root_path}viewforum.$this->php_ext", 'f=' . $topic_forum_id);
+ $link_forum = '' . $row['forum_name'] . '';
+
+ $links_forum = strlen($links_forum) == 0 ? $link_forum : $link_forum . ' » ' . $links_forum;
+ $topic_forum_id = $row['parent_id'];
+
+ } while ($row['parent_id'] != 0 && $row['parent_id'] != $this->forum_id);
+
+ $topic_row['IMCGER_LINKS_FORUM'] = $links_forum;
+ $event['topic_row'] = $topic_row;
+ }
+}
diff --git a/imcger/activetopics/ext.php b/imcger/activetopics/ext.php
new file mode 100644
index 0000000..feed4f9
--- /dev/null
+++ b/imcger/activetopics/ext.php
@@ -0,0 +1,22 @@
+=') && phpbb_version_compare(PHPBB_VERSION, '4.0.0-dev', '<');
+ $valid_php = phpbb_version_compare(PHP_VERSION, '7.1.3', '>=');
+
+ return ($valid_phpbb && $valid_php);
+ }
+}
diff --git a/imcger/activetopics/language/de/common.php b/imcger/activetopics/language/de/common.php
new file mode 100644
index 0000000..b331753
--- /dev/null
+++ b/imcger/activetopics/language/de/common.php
@@ -0,0 +1,40 @@
+ 'Aktive Themen oberhalb anzeigen',
+ 'IMCGER_DISPLAY_ACTIVE_POSITION_DESC' => 'Wenn diese Einstellung auf „Ja“ gesetzt wird, werden aktive Themen der gewählten Unterforen auf der Seite oberhalb dieser Kategorie angezeigt.',
+]);
diff --git a/imcger/activetopics/language/de_x_sie/common.php b/imcger/activetopics/language/de_x_sie/common.php
new file mode 100644
index 0000000..b331753
--- /dev/null
+++ b/imcger/activetopics/language/de_x_sie/common.php
@@ -0,0 +1,40 @@
+ 'Aktive Themen oberhalb anzeigen',
+ 'IMCGER_DISPLAY_ACTIVE_POSITION_DESC' => 'Wenn diese Einstellung auf „Ja“ gesetzt wird, werden aktive Themen der gewählten Unterforen auf der Seite oberhalb dieser Kategorie angezeigt.',
+]);
diff --git a/imcger/activetopics/language/en/common.php b/imcger/activetopics/language/en/common.php
new file mode 100644
index 0000000..0104243
--- /dev/null
+++ b/imcger/activetopics/language/en/common.php
@@ -0,0 +1,40 @@
+ 'Display active topics above',
+ 'IMCGER_DISPLAY_ACTIVE_POSITION_DESC' => 'If this setting is set to "Yes", active topics of the selected sub-forums are displayed on the page above this category.',
+]);
diff --git a/imcger/numberactivetopics/license.txt b/imcger/activetopics/license.txt
similarity index 100%
rename from imcger/numberactivetopics/license.txt
rename to imcger/activetopics/license.txt
diff --git a/imcger/activetopics/migrations/activetopics_01.php b/imcger/activetopics/migrations/activetopics_01.php
new file mode 100644
index 0000000..34941fe
--- /dev/null
+++ b/imcger/activetopics/migrations/activetopics_01.php
@@ -0,0 +1,59 @@
+db_tools->sql_column_exists(FORUMS_TABLE, 'imcger_display_active_position');
+ }
+
+ public function update_schema()
+ {
+ return [
+ 'add_columns' => [
+ FORUMS_TABLE => [
+ 'imcger_display_active_position' => ['UINT:2', 0],
+ ],
+ ],
+ ];
+ }
+
+ public function revert_schema()
+ {
+ return [
+ 'drop_columns' => [
+ FORUMS_TABLE => [
+ 'imcger_display_active_position',
+ ],
+ ],
+ ];
+ }
+
+ public function revert_data()
+ {
+ return [
+ ['custom', [[$this, 'reset_topics_per_page']]],
+ ];
+ }
+
+ public function reset_topics_per_page()
+ {
+ $sql = 'UPDATE ' . FORUMS_TABLE . ' SET forum_topics_per_page = 0 WHERE forum_type = ' . FORUM_CAT;
+ $this->db->sql_query($sql);
+ }
+}
diff --git a/imcger/activetopics/styles/prosilver/template/activetopics.js b/imcger/activetopics/styles/prosilver/template/activetopics.js
new file mode 100644
index 0000000..19a64f8
--- /dev/null
+++ b/imcger/activetopics/styles/prosilver/template/activetopics.js
@@ -0,0 +1,18 @@
+/*
+ * Active Topics
+ * An extension for the phpBB Forum Software package.
+ *
+ * @copyright (c) 2023, Thorsten Ahlers
+ * @license GNU General Public License, version 2 (GPL-2.0)
+ *
+ */
+
+(function($) { // Avoid conflicts with other libraries
+
+ 'use strict';
+
+ // Move active topics to the top of forumlist
+ if ($('.forumbg dt#active_topics').length) {
+ $('.forabg').first().before($('.forumbg'));
+ }
+})(jQuery); // Avoid conflicts with other libraries
diff --git a/imcger/activetopics/styles/prosilver/template/event/topiclist_row_topic_by_author_after.html b/imcger/activetopics/styles/prosilver/template/event/topiclist_row_topic_by_author_after.html
new file mode 100644
index 0000000..7153f99
--- /dev/null
+++ b/imcger/activetopics/styles/prosilver/template/event/topiclist_row_topic_by_author_after.html
@@ -0,0 +1 @@
+{% if S_DISPLAY_ACTIVE %} » {{ lang('IN') }} {{ topicrow.IMCGER_LINKS_FORUM }}{% endif %}
diff --git a/imcger/activetopics/styles/prosilver/template/event/viewforum_forum_title_before.html b/imcger/activetopics/styles/prosilver/template/event/viewforum_forum_title_before.html
new file mode 100644
index 0000000..46cb5b8
--- /dev/null
+++ b/imcger/activetopics/styles/prosilver/template/event/viewforum_forum_title_before.html
@@ -0,0 +1,3 @@
+{% if IMCGER_DISPLAY_ACTIVE_POSITION %}
+ {% INCLUDEJS '@imcger_activetopics/activetopics.js' %}
+{% endif %}
diff --git a/imcger/numberactivetopics/adm/style/event/acp_forums_custom_settings.html b/imcger/numberactivetopics/adm/style/event/acp_forums_custom_settings.html
deleted file mode 100644
index f11a6fd..0000000
--- a/imcger/numberactivetopics/adm/style/event/acp_forums_custom_settings.html
+++ /dev/null
@@ -1,28 +0,0 @@
-{#
- Number of Active Topics
- An extension for the phpBB Forum Software package.
-
- @copyright (c) 2023, Thorsten Ahlers
- @license GNU General Public License, version 2 (GPL-2.0)
-#}
-