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

Ticket #5653 - Notifications: Make notifications more accurate. Core changes.

AntonLV 1 месяц назад
Родитель
Сommit
5bca94d914

+ 20 - 0
modules/base/general/classes/BxBaseModGeneralModule.php

@@ -766,6 +766,26 @@ class BxBaseModGeneralModule extends BxDolModule
         return isset($this->_oConfig->CNF['ICON']) ? $this->_oConfig->CNF['ICON'] : '';
     }
 
+    /**
+     * @page service Service Calls
+     * @section bx_base_general Base General
+     * @subsection bx_base_general-other Other
+     * @subsubsection bx_base_general-module_sample module_sample
+     * 
+     * @code bx_srv('bx_posts', 'module_sample', [...]); @endcode
+     * 
+     * Get module sample
+     * 
+     * @see BxBaseModGeneralModule::serviceModuleSample
+     */
+    /** 
+     * @ref bx_base_general-module_sample "module_sample"
+     */
+    public function serviceModuleSample ()
+    {
+        return $this->_oConfig->CNF['T']['txt_sample_single'] ?? '';
+    }
+
     public function serviceGetModerators($iContentId)
     {
         return $this->getModerators($iContentId);

+ 5 - 0
modules/base/groups/classes/BxBaseModGroupsModule.php

@@ -261,6 +261,11 @@ class BxBaseModGroupsModule extends BxBaseModProfileModule
         return array_merge(parent::serviceGetSafeServices(), $a);
     }
 
+    public function serviceModuleSample ()
+    {
+        return parent::serviceModuleSample() ?: '_sys_sample_context';
+    }
+
     /**
      * Check if this module entry can be used as profile
      */

+ 5 - 0
modules/base/profile/classes/BxBaseModProfileModule.php

@@ -114,6 +114,11 @@ class BxBaseModProfileModule extends BxBaseModGeneralModule implements iBxDolCon
         ));
     }
 
+    public function serviceModuleSample ()
+    {
+        return parent::serviceModuleSample() ?: '_sys_sample_profile';
+    }
+
     public function serviceGetOptionsRedirectAfterAdd()
     {
         $CNF = &$this->_oConfig->CNF;

+ 5 - 0
modules/base/text/classes/BxBaseModTextModule.php

@@ -59,6 +59,11 @@ class BxBaseModTextModule extends BxBaseModGeneralModule implements iBxDolConten
         ));
     }
 
+    public function serviceModuleSample ()
+    {
+        return parent::serviceModuleSample() ?: '_sys_sample_content';
+    }
+
     public function serviceManageTools($sType = 'common')
     {
         $this->_oTemplate->addJs(['modules/base/text/js/|manage_tools.js']);

+ 4 - 1
modules/boonex/english/data/langs/system/en.xml

@@ -3811,7 +3811,7 @@ If it is not enabled then please consider implementing this optimization, since
     <string name="_sys_menu_set_title_ntfs_submenu"><![CDATA[Notifications]]></string>
     <string name="_sys_menu_item_title_system_ntfs_context_invitations"><![CDATA[Notifications: Context Invitations]]></string>
     <string name="_sys_menu_item_title_ntfs_context_invitations"><![CDATA[Invitations]]></string>
-    <string name="_sys_metatags_mention_added"><![CDATA[<b class="bx-ntfs-content-profile">{owner_name}</b> mentioned <b class="bx-ntfs-content-entry">{entry_caption}</b>]]></string>
+    <string name="_sys_metatags_mention_added"><![CDATA[{author_name_wrapped} mentioned <b class="bx-ntfs-content-entry">{entry_caption}</b> in a {subentry_sample} <b class="bx-ntfs-content-entry">{subentry_caption}</b>]]></string>
     <string name="_sys_mobile_friends"><![CDATA[Friends]]></string>
     <string name="_sys_mobile_info"><![CDATA[Info]]></string>
     <string name="_sys_mobile_mail"><![CDATA[Messages]]></string>
@@ -4162,6 +4162,9 @@ If it is not enabled then please consider implementing this optimization, since
     <string name="_sys_request_page_not_found_cnt"><![CDATA[Page({0}) was not found in module({1})]]></string>
     <string name="_sys_request_method_not_found_cpt"><![CDATA[Method was not found]]></string>
     <string name="_sys_request_method_not_found_cnt"><![CDATA[Method({0}) was not found in module({1})]]></string>
+    <string name="_sys_sample_content"><![CDATA[content]]></string>
+    <string name="_sys_sample_context"><![CDATA[context]]></string>
+    <string name="_sys_sample_profile"><![CDATA[profile]]></string>
     <string name="_sys_score_counter"><![CDATA[{0}]]></string>
     <string name="_sys_score_counter_empty"><![CDATA[Vote]]></string>
     <string name="_sys_score_n_score"><![CDATA[{0} score]]></string>

+ 4 - 1
modules/boonex/russian/data/langs/system/ru.xml

@@ -3770,7 +3770,7 @@
     <string name="_sys_menu_set_title_ntfs_submenu"><![CDATA[Уведомления]]></string>
     <string name="_sys_menu_item_title_system_ntfs_context_invitations"><![CDATA[Уведомления: Контекстные приглашения]]></string>
     <string name="_sys_menu_item_title_ntfs_context_invitations"><![CDATA[Приглашения]]></string>
-    <string name="_sys_metatags_mention_added"><![CDATA[<b class="bx-ntfs-content-profile">{owner_name}</b> упомянул <b class="bx-ntfs-content-entry">{entry_caption}</b>]]></string>
+    <string name="_sys_metatags_mention_added"><![CDATA[{author_name_wrapped} - упоминание о <b class="bx-ntfs-content-entry">{entry_caption}</b> в {subentry_sample} <b class="bx-ntfs-content-entry">{subentry_caption}</b>]]></string>
     <string name="_sys_mobile_friends"><![CDATA[Друзья]]></string>
     <string name="_sys_mobile_info"><![CDATA[Инфо]]></string>
     <string name="_sys_mobile_mail"><![CDATA[Сообщения]]></string>
@@ -4094,6 +4094,9 @@
     <string name="_sys_request_page_not_found_cnt"><![CDATA[Страница({0}) не найдена в модуле ({1})]]></string>
     <string name="_sys_request_method_not_found_cpt"><![CDATA[Метод не найден]]></string>
     <string name="_sys_request_method_not_found_cnt"><![CDATA[Метод ({0}) не найден в модуле ({1})]]></string>
+    <string name="_sys_sample_content"><![CDATA[контент]]></string>
+    <string name="_sys_sample_context"><![CDATA[контекст]]></string>
+    <string name="_sys_sample_profile"><![CDATA[профиль]]></string>
     <string name="_sys_score_counter"><![CDATA[{0}]]></string>
     <string name="_sys_score_counter_empty"><![CDATA[Проголосовать]]></string>
     <string name="_sys_score_n_score"><![CDATA[{0} очков]]></string>

+ 20 - 6
template/scripts/BxBaseServiceMetatags.php

@@ -113,18 +113,30 @@ class BxBaseServiceMetatags extends BxDol
         if(!$oProfile)
             return [];
 
+        $sEntrySample = $sEntryCaption = '';
         $sEntryUrl = $sEntryUrlApi = '';
-        if (isset($aEvent['content']['module']) && isset($aEvent['content']['content_id'])) {
-            if ('sys_cmts' == $aEvent['content']['module']) {
-                $oCmts = BxDolCmts::getObjectInstanceByUniqId($aEvent['content']['content_id']);
-                $aCmt = BxDolCmtsQuery::getCommentExtendedByUniqId($aEvent['content']['content_id']);
+        if (($sModule = $aEvent['content']['module'] ?? false) && ($iContentId = $aEvent['content']['content_id'] ?? false)) {
+            if ($sModule == 'sys_cmts') {
+                $oCmts = BxDolCmts::getObjectInstanceByUniqId($iContentId);
+                $aCmt = BxDolCmtsQuery::getCommentExtendedByUniqId($iContentId);
                 if ($oCmts && $aCmt) {
+                    $sEntrySample = '_cmt_txt_sample_comment_single';
+                    $sEntryCaption = $oCmts->getViewSnippet($aCmt);
+
                     $sEntryUrl = $oCmts->getItemUrl($aCmt['cmt_id'], '{bx_url_root}');
                     $sEntryUrlApi = $oCmts->getItemUrlApi($aCmt['cmt_id'], '{bx_url_root}');
                 }
             }
-            elseif (BxDolRequest::serviceExists($aEvent['content']['module'], 'get_link'))
-                $sEntryUrl = str_replace(BX_DOL_URL_ROOT, '{bx_url_root}', bx_srv($aEvent['content']['module'], 'get_link', [$aEvent['content']['content_id']]));
+            else {
+                if (bx_is_srv($sModule, 'module_sample'))
+                    $sEntrySample = bx_srv($sModule, 'module_sample', []);
+
+                if (bx_is_srv($sModule, 'get_title'))
+                    $sEntryCaption = bx_srv($sModule, 'get_title', [$iContentId]);
+
+                if (bx_is_srv($sModule, 'get_link') && ($sLink = bx_srv($sModule, 'get_link', [$iContentId])))
+                    $sEntryUrl = str_replace(BX_DOL_URL_ROOT, '{bx_url_root}', $sLink);
+            }
         }
 
         if(!$sEntryUrl)
@@ -135,6 +147,8 @@ class BxBaseServiceMetatags extends BxDol
             'entry_url' => $sEntryUrl,
             'entry_url_api' => $sEntryUrlApi,
             'entry_caption' => $oProfile->getDisplayName(),
+            'subentry_sample' => $sEntrySample,
+            'subentry_caption' => $sEntryCaption,
             'entry_author' => $iProfile,
             'lang_key' => '_sys_metatags_mention_added',
         ];