Просмотр исходного кода

Posts: menu based category list, as in Market and Forum (#5902)

Posts get a categories menu object (bx_posts_categories, BxPostsMenuCategories
on BxBaseModTextMenuCategories) and the posts home shows it as a menu block in
place of the categories_list service block, which stays inactive. Config gets
PARAM_VISIBLE_CATEGORIES (option bx_posts_visible_categories, 10) and the
"All Categories" string, as Market got in #5578.

For NEO (enable-app.sql) the block is active in the app and flagged
use_as_menu, like the forum's: the categories show in the left sidebar under
the posts tabs, and as a dropdown next to the tabs on narrow screens.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Andrey Yasko 5 дней назад
Родитель
Сommit
8e462e877b

+ 2 - 0
modules/boonex/posts/classes/BxPostsConfig.php

@@ -90,6 +90,7 @@ class BxPostsConfig extends BxBaseModTextConfig
             'PARAM_SEARCHABLE_FIELDS' => 'bx_posts_searchable_fields',
             'PARAM_PER_PAGE_BROWSE_SHOWCASE' => 'bx_posts_per_page_browse_showcase',
             'PARAM_PER_PAGE_FOR_FAVORITES_LISTS' => 'bx_posts_per_page_for_favorites_lists',
+            'PARAM_VISIBLE_CATEGORIES' => 'bx_posts_visible_categories',
 
             'PARAM_MULTICAT_ENABLED' => true,
             'PARAM_LINKS_ENABLED' => true,
@@ -214,6 +215,7 @@ class BxPostsConfig extends BxBaseModTextConfig
                 'txt_all_entries_in' => '_bx_posts_txt_all_entries_in',
                 'txt_all_entries_by_author' => '_bx_posts_page_title_browse_by_author',
                 'txt_all_entries_by_context' => '_bx_posts_page_title_browse_by_context',
+                'txt_all_categories' => '_bx_posts_txt_all_categories',
                 'txt_err_cannot_perform_action' => '_bx_posts_txt_err_cannot_perform_action',
                 'txt_poll_form_answers_add' => '_bx_posts_form_poll_input_answers_add',
                 'txt_poll_menu_view_answers' => '_bx_posts_txt_poll_view_answers',

+ 31 - 0
modules/boonex/posts/classes/BxPostsMenuCategories.php

@@ -0,0 +1,31 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    Posts Posts
+ * @ingroup     UnaModules
+ *
+ * @{
+ */
+
+/**
+ * Menu based category list.
+ * @see BxDolMenu
+ */
+class BxPostsMenuCategories extends BxBaseModTextMenuCategories
+{
+    public function __construct ($aObject, $oTemplate)
+    {
+        $this->_sModule = 'bx_posts';
+
+        parent::__construct ($aObject, $oTemplate);
+    }
+
+    protected function _getExtendedInfo($iId)
+    {
+        return [];
+    }
+}
+
+/** @} */

+ 3 - 0
modules/boonex/posts/install/langs/en.xml

@@ -14,6 +14,7 @@
     <string name="_bx_posts_option_searchable_fields"><![CDATA[Searchable fields for keyword search]]></string>
     <string name="_bx_posts_option_auto_activation_for_categories"><![CDATA[Auto-Activation For Categories]]></string>
     <string name="_bx_posts_option_per_page_for_favorites_lists"><![CDATA[Number of favorite lists per page]]></string>
+    <string name="_bx_posts_option_visible_categories"><![CDATA[Number of visible categories]]></string>
 
     <string name="_bx_posts_form_entry"><![CDATA[Posts]]></string>
     <string name="_bx_posts_form_entry_display_add"><![CDATA[Add Post]]></string>
@@ -240,6 +241,7 @@
     <string name="_bx_posts_menu_set_title_view_entry"><![CDATA[Post Actions]]></string>
     <string name="_bx_posts_menu_title_view_entry"><![CDATA[Post Actions]]></string>
     <string name="_bx_posts_menu_title_submenu"><![CDATA[Posts Submenu]]></string>
+    <string name="_bx_posts_menu_title_categories"><![CDATA[Categories]]></string>
     <string name="_bx_posts_menu_title_public_submenu"><![CDATA[Posts]]></string>
     <string name="_bx_posts_menu_set_title_submenu"><![CDATA[Posts Submenu]]></string>
     <string name="_bx_posts_menu_item_title_system_create_entry"><![CDATA[Post]]></string>
@@ -343,6 +345,7 @@
     <string name="_bx_posts_cat_Womens_Fashion"><![CDATA[Women's Fashion]]></string>
 
     <string name="_bx_posts_txt_all_entries_in"><![CDATA[<a href="{0}">All Posts in {1} ({2})</a>]]></string>
+    <string name="_bx_posts_txt_all_categories"><![CDATA[All Categories]]></string>
     <string name="_bx_posts_txt_all_entries_by"><![CDATA[{0} posts]]></string>
     <string name="_bx_posts_txt_sample_single"><![CDATA[post]]></string>
     <string name="_bx_posts_txt_sample_single_with_article"><![CDATA[a post]]></string>

+ 1 - 1
modules/boonex/posts/install/sql/disable.sql

@@ -13,7 +13,7 @@ DELETE FROM `sys_pages_blocks` WHERE `module` = 'bx_posts' OR `object` IN('bx_po
 -- MENU
 DELETE FROM `sys_objects_menu` WHERE `module` = 'bx_posts';
 DELETE FROM `sys_menu_sets` WHERE `module` = 'bx_posts';
-DELETE FROM `sys_menu_items` WHERE `module` = 'bx_posts' OR `set_name` IN('bx_posts_entry_attachments', 'bx_posts_view', 'bx_posts_view_actions', 'bx_posts_submenu', 'bx_posts_view_submenu', 'bx_posts_snippet_meta', 'bx_posts_my', 'bx_posts_menu_manage_tools');
+DELETE FROM `sys_menu_items` WHERE `module` = 'bx_posts' OR `set_name` IN('bx_posts_entry_attachments', 'bx_posts_view', 'bx_posts_view_actions', 'bx_posts_submenu', 'bx_posts_view_submenu', 'bx_posts_snippet_meta', 'bx_posts_my', 'bx_posts_menu_manage_tools', 'bx_posts_categories');
 
 -- PRIVACY 
 DELETE FROM `sys_objects_privacy` WHERE `object` IN ('bx_posts_allow_view_to', 'bx_posts_allow_view_favorite_list');

+ 5 - 0
modules/boonex/posts/install/sql/enable-app.sql

@@ -3,7 +3,12 @@ UPDATE `sys_objects_page` SET `config_api`='{\r\n    layout: \'post\',\r\n}' WHE
 
 UPDATE `sys_pages_blocks` SET `config_api`='{\r\n\"content_type\":\"browse_simple\",\r\n\"header_more_url\":\"/posts-home\",\r\n\"view\":\"row\"\r\n}' WHERE `object`='sys_explore' AND `module`='bx_posts' AND `title_system`='_bx_posts_page_block_title_sys_featured_entries_view_showcase';
 
+-- PAGES: blocks config_api
+-- Categories on the posts home: a dropdown next to the tabs while NEO's left panel is off screen.
+UPDATE `sys_pages_blocks` SET `config_api`='{"use_as_menu": true}' WHERE `object`='bx_posts_home' AND `module`='bx_posts' AND `type`='menu' AND `content`='bx_posts_categories';
+
 -- PAGES: active_api
+UPDATE `sys_pages_blocks` SET `active_api`=1 WHERE `object`='bx_posts_home' AND `module`='bx_posts' AND `type`='menu' AND `content`='bx_posts_categories';
 UPDATE `sys_pages_blocks` SET `active_api`=1 WHERE `object`='bx_posts_create_entry' AND `module`='bx_posts' AND `title_system`='' AND `title`='_bx_posts_page_block_title_create_entry';
 UPDATE `sys_pages_blocks` SET `active_api`=1 WHERE `object`='bx_posts_edit_entry' AND `module`='bx_posts' AND `title_system`='' AND `title`='_bx_posts_page_block_title_edit_entry';
 UPDATE `sys_pages_blocks` SET `active_api`=1 WHERE `object`='bx_posts_delete_entry' AND `module`='bx_posts' AND `title_system`='' AND `title`='_bx_posts_page_block_title_delete_entry';

+ 8 - 2
modules/boonex/posts/install/sql/enable.sql

@@ -20,7 +20,8 @@ INSERT INTO `sys_options` (`name`, `value`, `category_id`, `caption`, `type`, `c
 ('bx_posts_per_page_for_favorites_lists', '5', @iCategId, '_bx_posts_option_per_page_for_favorites_lists', 'digit', '', '', '', 17),
 ('bx_posts_rss_num', '10', @iCategId, '_bx_posts_option_rss_num', 'digit', '', '', '', 20),
 ('bx_posts_searchable_fields', 'title,text', @iCategId, '_bx_posts_option_searchable_fields', 'list', '', '', 'a:2:{s:6:"module";s:8:"bx_posts";s:6:"method";s:21:"get_searchable_fields";}', 30),
-('bx_posts_auto_activation_for_categories', 'on', @iCategId, '_bx_posts_option_auto_activation_for_categories', 'checkbox', '', '', '', 35);
+('bx_posts_auto_activation_for_categories', 'on', @iCategId, '_bx_posts_option_auto_activation_for_categories', 'checkbox', '', '', '', 35),
+('bx_posts_visible_categories', '10', @iCategId, '_bx_posts_option_visible_categories', 'digit', '', '', '', 40);
 
 -- PAGE: create entry
 
@@ -146,7 +147,8 @@ INSERT INTO `sys_pages_blocks`(`object`, `cell_id`, `module`, `title_system`, `t
 ('bx_posts_home', 1, 'bx_posts', '', '_bx_posts_page_block_title_featured_entries_view_extended', 11, 2147483647, 'service', 'a:3:{s:6:"module";s:8:"bx_posts";s:6:"method";s:15:"browse_featured";s:6:"params";a:1:{i:0;s:8:"extended";}}', 0, 1, 1, 0),
 ('bx_posts_home', 1, 'bx_posts', '', '_bx_posts_page_block_title_recent_entries_view_extended', 11, 2147483647, 'service', 'a:3:{s:6:"module";s:8:"bx_posts";s:6:"method";s:13:"browse_public";s:6:"params";a:1:{i:0;s:8:"extended";}}', 0, 1, 1, 1),
 ('bx_posts_home', 2, 'bx_posts', '', '_bx_posts_page_block_title_popular_keywords', 11, 2147483647, 'service', 'a:4:{s:6:\"module\";s:6:\"system\";s:6:\"method\";s:14:\"keywords_cloud\";s:6:\"params\";a:2:{i:0;s:8:\"bx_posts\";i:1;s:8:\"bx_posts\";}s:5:\"class\";s:20:\"TemplServiceMetatags\";}', 0, 1, 1, 0),
-('bx_posts_home', 2, 'bx_posts', '', '_bx_posts_page_block_title_cats', 11, 2147483647, 'service', 'a:4:{s:6:\"module\";s:6:\"system\";s:6:\"method\";s:15:\"categories_list\";s:6:\"params\";a:2:{i:0;s:13:\"bx_posts_cats\";i:1;a:1:{s:10:\"show_empty\";b:1;}}s:5:\"class\";s:20:\"TemplServiceCategory\";}', 0, 1, 1, 1),
+('bx_posts_home', 2, 'bx_posts', '', '_bx_posts_page_block_title_cats', 11, 2147483647, 'menu', 'bx_posts_categories', 0, 1, 1, 1),
+('bx_posts_home', 2, 'bx_posts', '', '_bx_posts_page_block_title_cats', 11, 2147483647, 'service', 'a:4:{s:6:\"module\";s:6:\"system\";s:6:\"method\";s:15:\"categories_list\";s:6:\"params\";a:2:{i:0;s:13:\"bx_posts_cats\";i:1;a:1:{s:10:\"show_empty\";b:1;}}s:5:\"class\";s:20:\"TemplServiceCategory\";}', 0, 1, 0, 3),
 ('bx_posts_home', 2, 'bx_posts', '_bx_posts_page_block_title_sys_multicats', '_bx_posts_page_block_title_multicats', 11, 2147483647, 'service', 'a:2:{s:6:"module";s:8:"bx_posts";s:6:"method";s:21:"categories_multi_list";}', 0, 1, 0, 2);
 
 -- PAGE: search for entries
@@ -315,6 +317,10 @@ INSERT INTO `sys_menu_items`(`set_name`, `module`, `name`, `title_system`, `titl
 ('bx_posts_submenu', 'bx_posts', 'posts-search', '_bx_posts_menu_item_title_system_entries_search', '_bx_posts_menu_item_title_entries_search', 'page.php?i=posts-search', '', '', '', '', 2147483647, 1, 1, 4),
 ('bx_posts_submenu', 'bx_posts', 'posts-manage', '_bx_posts_menu_item_title_system_entries_manage', '_bx_posts_menu_item_title_entries_manage', 'page.php?i=posts-manage', '', '', '', '', 2147483646, 1, 1, 5);
 
+-- MENU: categories
+INSERT INTO `sys_objects_menu`(`object`, `title`, `set_name`, `module`, `template_id`, `deletable`, `active`, `override_class_name`, `override_class_file`) VALUES 
+('bx_posts_categories', '_bx_posts_menu_title_categories', '', 'bx_posts', 21, 0, 1, 'BxPostsMenuCategories', 'modules/boonex/posts/classes/BxPostsMenuCategories.php');
+
 -- MENU: sub-menu for view entry
 INSERT INTO `sys_objects_menu`(`object`, `title`, `set_name`, `module`, `template_id`, `deletable`, `active`, `override_class_name`, `override_class_file`) VALUES 
 ('bx_posts_view_submenu', '_bx_posts_menu_title_view_entry_submenu', 'bx_posts_view_submenu', 'bx_posts', 8, 0, 1, 'BxPostsMenuView', 'modules/boonex/posts/classes/BxPostsMenuView.php');

+ 3 - 0
modules/boonex/russian/data/langs/bx_posts/ru.xml

@@ -14,6 +14,7 @@
     <string name="_bx_posts_option_searchable_fields"><![CDATA[Поля для поиска по ключевому слову]]></string>
     <string name="_bx_posts_option_auto_activation_for_categories"><![CDATA[Автоактивация для категорий]]></string>
     <string name="_bx_posts_option_per_page_for_favorites_lists"><![CDATA[Количество списков избранного на странице]]></string>
+    <string name="_bx_posts_option_visible_categories"><![CDATA[Количество отображаемых категорий]]></string>
 
     <string name="_bx_posts_form_entry"><![CDATA[Публикации]]></string>
     <string name="_bx_posts_form_entry_display_add"><![CDATA[Добавить публикацию]]></string>
@@ -228,6 +229,7 @@
     <string name="_bx_posts_menu_set_title_view_entry"><![CDATA[Публикация - Действия]]></string>
     <string name="_bx_posts_menu_title_view_entry"><![CDATA[Публикация - Действия]]></string>
     <string name="_bx_posts_menu_title_submenu"><![CDATA[Публикации - Подменю]]></string>
+    <string name="_bx_posts_menu_title_categories"><![CDATA[Категории]]></string>
     <string name="_bx_posts_menu_title_public_submenu"><![CDATA[Публикации]]></string>
     <string name="_bx_posts_menu_set_title_submenu"><![CDATA[Публикации - Подменю]]></string>
     <string name="_bx_posts_menu_item_title_system_create_entry"><![CDATA[Публикация]]></string>
@@ -333,6 +335,7 @@
 
     <string name="_bx_posts_txt_all_entries_by"><![CDATA[{0} публикаций]]></string>
     <string name="_bx_posts_txt_all_entries_in"><![CDATA[<a href="{0}">Все публикации в {1} ({2})</a>]]></string>
+    <string name="_bx_posts_txt_all_categories"><![CDATA[Все категории]]></string>
     <string name="_bx_posts_txt_sample_single"><![CDATA[публикация]]></string>
     <string name="_bx_posts_txt_sample_single_with_article"><![CDATA[публикация]]></string>
     <string name="_bx_posts_txt_sample_comment_single"><![CDATA[комментарий к публикации]]></string>