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

Ticket #4561 - Ads: Enhancements. Ppoint 3.

AntonLV 2 лет назад
Родитель
Сommit
a9dba8671c

+ 10 - 0
modules/boonex/russian/data/langs/bx_timeline/ru.xml

@@ -64,6 +64,16 @@
     <string name="_bx_timeline_option_editor_auto_attach_insertion"><![CDATA[Обрабатывать изображения, вставленные в редактор, как вложения]]></string>
     <string name="_bx_timeline_option_enable_media_priority"><![CDATA[Включить приоритет медиаконтента над ссылками во вложениях]]></string>
     <string name="_bx_timeline_option_limit_attach_links"><![CDATA[Ограничить число присоединенных линок (0 - без ограничений)]]></string>
+    <string name="_bx_timeline_option_extenals_every_public"><![CDATA[Показывать внешнее событие как каждое N-е в публичной ленте.]]></string>
+    <string name="_bx_timeline_option_extenals_every_owner"><![CDATA[Показывать внешнее событие как каждое N-е в ленте контекста (профиля)]]></string>
+    <string name="_bx_timeline_option_extenals_every_feed"><![CDATA[Показывать внешнее событие как каждое N-е в ленте контекст (профиль) + подписки]]></string>
+    <string name="_bx_timeline_option_extenals_every_hot"><![CDATA[Показывать внешнее событие как каждое N-е в 'горячей' ленте]]></string>
+    <string name="_bx_timeline_option_extenals_every_feed_and_hot"><![CDATA[Показывать внешнее событие как каждое N-е в ленте 'Для тебя']]></string>
+    <string name="_bx_timeline_option_extenals_every_public_preload"><![CDATA[Показывать внешнее событие как каждое N-е в публичной ленте при включенной 'Бесконечной прокрутке']]></string>
+    <string name="_bx_timeline_option_extenals_every_owner_preload"><![CDATA[Показывать внешнее событие как каждое N-е в ленте контекста (профиля) при включенной 'Бесконечной прокрутке']]></string>
+    <string name="_bx_timeline_option_extenals_every_feed_preload"><![CDATA[Показывать внешнее событие как каждое N-е в ленте контекст (профиль) + подписки при включенной 'Бесконечной прокрутке']]></string>
+    <string name="_bx_timeline_option_extenals_every_hot_preload"><![CDATA[Показывать внешнее событие как каждое N-е в hot timeline при включенной 'Бесконечной прокрутке']]></string>
+    <string name="_bx_timeline_option_extenals_every_feed_and_hot_preload"><![CDATA[CDATA[Показывать внешнее событие как каждое N-е в ленте 'Для тебя' при включенной 'Бесконечной прокрутке']]></string>
 
     <string name="_bx_timeline_form_post"><![CDATA[Сообщение]]></string>
     <string name="_bx_timeline_form_post_display_add"><![CDATA[Написать сообщение]]></string>

+ 19 - 4
modules/boonex/timeline/classes/BxTimelineModule.php

@@ -2236,7 +2236,7 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
         return $oGrid->getCode();
     }
 
-    public function serviceGetPost($mixedEvent, $aParams = array())
+    public function serviceGetPost($mixedEvent, $aParams = [])
     {
         if(!empty($mixedEvent) && !is_array($mixedEvent))
             $mixedEvent = $this->_oDb->getContentInfoById((int)$mixedEvent);
@@ -2244,12 +2244,12 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
         if(empty($mixedEvent) || !is_array($mixedEvent))
             return '';
 
-        $aParams = $this->_prepareParams(array_merge(array(
+        $sPost = $this->_oTemplate->getPost($mixedEvent, $this->_prepareParams(array_merge([
             'view' => BX_TIMELINE_VIEW_ITEM, 
             'type' => BX_TIMELINE_TYPE_ITEM
-        ), $aParams));
+        ], $aParams)));
 
-        return $this->_oTemplate->getPost($mixedEvent, $aParams);
+        return isset($aParams['return_data_type']) && $aParams['return_data_type'] == 'array' ? $mixedEvent : $sPost;
     }
 
     public function serviceGetTimelineRepostAllowedView($aEvent)
@@ -3474,6 +3474,21 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
         return '';
     }
 
+    public function serviceGetEvents($aParams = [])
+    {
+        return $this->_oDb->getEvents($aParams);
+    }
+
+    public function serviceGetEventsByDescriptor($sType, $sAction, $iObjectId)
+    {
+        return $this->_oDb->getEvents([
+            'browse' => 'descriptor', 
+            'type' => $sType, 
+            'action' => $sAction, 
+            'object_id' => $iObjectId
+        ]);
+    }
+
     /*
      * COMMON METHODS
      */

+ 23 - 14
modules/boonex/timeline/classes/BxTimelineTemplate.php

@@ -844,23 +844,25 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
             if(empty($sEvent))
                 continue;
 
-            if($bReturnArray) {
+            if($bReturnArray)
                 $mixedEvents[] = $aEvent;
-                continue;
-            }
-
-            $mixedEvents .= $sEvent;
+            else
+                $mixedEvents .= $sEvent;
 
             $iEventIndex++;
             if($iExtenalsEvery > 0 && $iEventIndex % $iExtenalsEvery == 0) {
-                $sExternalPost = false;
-                bx_alert($this->_oConfig->getName(), 'get_external_post', 0, 0, array(
+                $mixedExternalPost = false;
+                bx_alert($this->_oConfig->getName(), 'get_external_post', 0, 0, [
                     'params' => $aParams,
-                    'override_result' => &$sExternalPost,
-                ));
+                    'override_result' => &$mixedExternalPost,
+                ]);
 
-                if($sExternalPost !== false)
-                    $mixedEvents .= $sExternalPost;
+                if($mixedExternalPost !== false) {
+                    if($bReturnArray)
+                        $mixedEvents[] = $mixedExternalPost;
+                    else
+                        $mixedEvents .= $mixedExternalPost;
+                }
             }
         }
 
@@ -2301,15 +2303,22 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
 
         //--- Process Text ---//
         $sUrl = isset($aContent['url']) ? bx_html_attribute($aContent['url']) : '';
+        $OnClick = isset($aContent['onclick']) ? bx_html_attribute($aContent['onclick']) : '';
+
         $sTitle = '';
         if(isset($aContent['title']))
             $sTitle = bx_process_output($aContent['title']);
 
-        if(!empty($sUrl) && !empty($sTitle))
-            $sTitle = $this->parseLink($sUrl, $sTitle, array(
+        if(!empty($sUrl) && !empty($sTitle)) {
+            $aTitleParams = [
             	'class' => $sStylePrefix . '-title bx-lnk-src',
                 'title' => $sTitle
-            ));
+            ];
+            if(!empty($OnClick))
+                $aTitleParams['onclick'] = $OnClick;
+
+            $sTitle = $this->parseLink($sUrl, $sTitle, $aTitleParams);
+        }
 
         $sMethodPrepare = '_prepareTextForOutput';
         if($this->_oConfig->isBriefCards() && !$bViewItem)

+ 10 - 0
modules/boonex/timeline/install/langs/en.xml

@@ -64,6 +64,16 @@
     <string name="_bx_timeline_option_editor_auto_attach_insertion"><![CDATA[Treat images inserted in the editor as attachments]]></string>
     <string name="_bx_timeline_option_enable_media_priority"><![CDATA[Enable priority of media content over links in attachments]]></string>
     <string name="_bx_timeline_option_limit_attach_links"><![CDATA[Limit number of attached links (0 - no limit)]]></string>
+    <string name="_bx_timeline_option_extenals_every_public"><![CDATA[Show external event as every N-th in public timeline]]></string>
+    <string name="_bx_timeline_option_extenals_every_owner"><![CDATA[Show external event as every N-th in context (profile) timeline]]></string>
+    <string name="_bx_timeline_option_extenals_every_feed"><![CDATA[Show external event as every N-th in context (profile) + subscriptions timeline]]></string>
+    <string name="_bx_timeline_option_extenals_every_hot"><![CDATA[Show external event as every N-th in hot timeline]]></string>
+    <string name="_bx_timeline_option_extenals_every_feed_and_hot"><![CDATA[Show external event as every N-th in 'For You' timeline]]></string>
+    <string name="_bx_timeline_option_extenals_every_public_preload"><![CDATA[Show external event as every N-th in public timeline with Infinite Scroll enabled]]></string>
+    <string name="_bx_timeline_option_extenals_every_owner_preload"><![CDATA[Show external event as every N-th in context (profile) timeline with Infinite Scroll enabled]]></string>
+    <string name="_bx_timeline_option_extenals_every_feed_preload"><![CDATA[Show external event as every N-th in context (profile) + subscriptions timeline with Infinite Scroll enabled]]></string>
+    <string name="_bx_timeline_option_extenals_every_hot_preload"><![CDATA[Show external event as every N-th in hot timeline with Infinite Scroll enabled]]></string>
+    <string name="_bx_timeline_option_extenals_every_feed_and_hot_preload"><![CDATA[CDATA[Show external event as every N-th in 'For You' timeline with Infinite Scroll enabled]]></string>
 
     <string name="_bx_timeline_form_post"><![CDATA[Post]]></string>
     <string name="_bx_timeline_form_post_display_add"><![CDATA[Write Post]]></string>

+ 13 - 1
modules/boonex/timeline/install/sql/enable.sql

@@ -334,7 +334,19 @@ INSERT INTO `sys_options` (`name`, `value`, `category_id`, `caption`, `type`, `c
 ('bx_timeline_hot_threshold_age', '0', @iCategId, '_bx_timeline_option_hot_threshold_age', 'digit', '', '', '', '', 32),
 ('bx_timeline_hot_threshold_comment', '1', @iCategId, '_bx_timeline_option_hot_threshold_comment', 'digit', '', '', '', '', 33),
 ('bx_timeline_hot_threshold_vote', '2', @iCategId, '_bx_timeline_option_hot_threshold_vote', 'digit', '', '', '', '', 34),
-('bx_timeline_hot_interval', '48', @iCategId, '_bx_timeline_option_hot_interval', 'digit', '', '', '', '', 35);
+('bx_timeline_hot_interval', '48', @iCategId, '_bx_timeline_option_hot_interval', 'digit', '', '', '', '', 35), 
+
+('bx_timeline_extenals_every_public', '0', @iCategId, '_bx_timeline_option_extenals_every_public', 'digit', '', '', '', '', 40),
+('bx_timeline_extenals_every_owner', '0', @iCategId, '_bx_timeline_option_extenals_every_owner', 'digit', '', '', '', '', 41),
+('bx_timeline_extenals_every_feed', '0', @iCategId, '_bx_timeline_option_extenals_every_feed', 'digit', '', '', '', '', 42),
+('bx_timeline_extenals_every_hot', '0', @iCategId, '_bx_timeline_option_extenals_every_hot', 'digit', '', '', '', '', 43),
+('bx_timeline_extenals_every_feed_and_hot', '0', @iCategId, '_bx_timeline_option_extenals_every_feed_and_hot', 'digit', '', '', '', '', 44),
+('bx_timeline_extenals_every_public_preload', '0', @iCategId, '_bx_timeline_option_extenals_every_public_preload', 'digit', '', '', '', '', 45),
+('bx_timeline_extenals_every_owner_preload', '0', @iCategId, '_bx_timeline_option_extenals_every_owner_preload', 'digit', '', '', '', '', 46),
+('bx_timeline_extenals_every_feed_preload', '0', @iCategId, '_bx_timeline_option_extenals_every_feed_preload', 'digit', '', '', '', '', 47),
+('bx_timeline_extenals_every_hot_preload', '0', @iCategId, '_bx_timeline_option_extenals_every_hot_preload', 'digit', '', '', '', '', 48),
+('bx_timeline_extenals_every_feed_and_hot_preload', '0', @iCategId, '_bx_timeline_option_extenals_every_feed_and_hot_preload', 'digit', '', '', '', '', 49);
+
 
 -- Category: Card
 INSERT INTO `sys_options_categories` (`type_id`, `name`, `caption`, `order`)