Преглед изворни кода

#2380 Events: calendar block in group based modules

RomanL пре 6 година
родитељ
комит
49831b27f8

+ 6 - 0
modules/base/general/classes/BxBaseModGeneralDb.php

@@ -82,6 +82,12 @@ class BxBaseModGeneralDb extends BxDolModuleDb
         $aMethod['params'][0] = "SELECT " . $sSelectClause . " FROM `" . $CNF['TABLE_ENTRIES'] . "` " . $sJoinClause . " WHERE 1 " . $sWhereClause . " " . $sOrderClause . " " . $sLimitClause;
 		return call_user_func_array(array($this, $aMethod['name']), $aMethod['params']);
     }
+    
+    public function getEntriesNumByContext ($iProfileId)
+    {
+        $sQuery = $this->prepare ("SELECT COUNT(*) FROM `" . $this->_oConfig->CNF['TABLE_ENTRIES'] . "` WHERE `" . $this->_oConfig->CNF['FIELD_ALLOW_VIEW_TO'] . "` = ?", - $iProfileId);
+        return $this->getOne($sQuery);
+    }
 
     public function getEntriesByAuthor ($iProfileId)
     {

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

@@ -1158,6 +1158,14 @@ class BxBaseModGeneralModule extends BxDolModule
             'menu' => $sMenu
         ));
     }
+    
+    /**
+     * Entry context block
+     */
+    public function serviceEntityContext ($iContentId = 0)
+    {
+        return $this->_serviceTemplateFunc ('entryContext', $iContentId);
+    }
 
     /**
      * Blocks for lables tree browsing

+ 50 - 0
modules/base/general/classes/BxBaseModGeneralTemplate.php

@@ -119,6 +119,19 @@ class BxBaseModGeneralTemplate extends BxDolModuleTemplate
             'content' => $aParams['content']
         ));
     }
+    
+    function getContextAddon ($aData, $oProfile)
+    {
+        $CNF = &$this->getModule()->_oConfig->CNF;
+        $sUrl = 'page.php?i=' . $CNF['URI_ENTRIES_BY_CONTEXT'] . '&profile_id=' . $oProfile->id();
+        $sUrl = BxDolPermalinks::getInstance()->permalink($sUrl);
+        return _t($CNF['T']['txt_all_entries_in'], $sUrl, $oProfile->getDisplayName(), $this->getModule()->_oDb->getEntriesNumByContext($oProfile->id()));
+    }
+    
+    function getContextDesc ($aData)
+    {
+        return '';
+    }
 
     public function getTmplVarsText($aData)
     {
@@ -256,6 +269,43 @@ class BxBaseModGeneralTemplate extends BxDolModuleTemplate
             'bx_repeat:attachments' => $aResult,
         ));
     }
+    
+    function entryContext ($aData, $iProfileId = false, $sFuncContextDesc = 'getContextDesc', $sTemplateName = 'context.html', $sFuncContextAddon = 'getContextAddon')
+    {
+        $CNF = &$this->getModule()->_oConfig->CNF;
+
+        $iContextId = $aData[$CNF['FIELD_ALLOW_VIEW_TO']];
+        if ($iContextId >= 0)
+            return '';
+        
+        $iProfileId = - $iContextId;
+
+        $oProfile = BxDolProfile::getInstance($iProfileId);
+        if (!$oProfile) 
+            $oProfile = BxDolProfileUndefined::getInstance();
+
+        if (!$oProfile)
+            return '';
+
+        $sName = $oProfile->getDisplayName();
+        $sAddon = $sFuncContextAddon ? $this->$sFuncContextAddon($aData, $oProfile) : '';
+        
+        $aVars = array (
+            'author_url' => $oProfile->getUrl(),
+            'author_thumb_url' => $oProfile->getThumb(),
+            'author_unit' => $oProfile->getUnit(0, array('template' => 'unit_wo_info')),
+            'author_title' => $sName,
+            'author_title_attr' => bx_html_attribute($sName),
+            'author_desc' => $sFuncContextDesc ? $this->$sFuncContextDesc($aData) : '',
+            'bx_if:addon' => array (
+                'condition' => (bool)$sAddon,
+                'content' => array (
+                    'content' => $sAddon,
+                ),
+            ),
+        );
+        return $this->parseHtmlByName($sTemplateName, $aVars);
+    }
 
     protected function getAttachmentsImagesTranscoders ($sStorage = '')
     {

+ 14 - 0
modules/base/general/template/context.html

@@ -0,0 +1,14 @@
+<div class="sys-author bx-def-unit absolute">
+    <div class="bx-def-unit-img">__author_unit__</div>
+    <div class="bx-def-unit-info bx-def-thumb-size-min-height bx-def-thumb-size-max-height bx-def-thumb-size-left-indent">
+        <div class="bx-def-unit-info-cnt bx-def-box-sizing">
+            <div class="bx-def-unit-line"><a class="bx-def-unit-info-title" href="__author_url__" title="__author_title_attr__">__author_title__</a></div>
+            <div class="bx-def-unit-line bx-def-font-grayed bx-def-font-small">__author_desc__</div> 
+        </div>
+    </div>
+</div>
+<bx_if:addon>
+    <div class="bx-def-margin-sec-top">
+        __content__ 
+    </div>
+</bx_if:addon>

+ 0 - 7
modules/base/text/classes/BxBaseModTextDb.php

@@ -43,13 +43,6 @@ class BxBaseModTextDb extends BxBaseModGeneralDb
         return $this->getAll($sQuery, $aBindings);
     }
     
-    public function getEntriesNumByContext ($iProfileId)
-    {
-        $sQuery = $this->prepare ("SELECT COUNT(*) FROM `" . $this->_oConfig->CNF['TABLE_ENTRIES'] . "` WHERE `" . $this->_oConfig->CNF['FIELD_ALLOW_VIEW_TO'] . "` = ?", - $iProfileId);
-        return $this->getOne($sQuery);
-    }
-
-
     /**
      * 
      * Internal Polls related methods. 

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

@@ -213,14 +213,6 @@ class BxBaseModTextModule extends BxBaseModGeneralModule implements iBxDolConten
         return $this->_serviceTemplateFunc ('entryAuthor', $iContentId);
     }
     
-    /**
-     * Entry context block
-     */
-    public function serviceEntityContext ($iContentId = 0)
-    {
-        return $this->_serviceTemplateFunc ('entryContext', $iContentId);
-    }
-    
     /**
      * Entry polls block
      */

+ 0 - 50
modules/base/text/classes/BxBaseModTextTemplate.php

@@ -115,43 +115,6 @@ class BxBaseModTextTemplate extends BxBaseModGeneralTemplate
     	return parent::entryBreadcrumb($aContentInfo, $aTmplVarsItems);
     }
 
-    function entryContext ($aData, $iProfileId = false, $sFuncContextDesc = 'getContextDesc', $sTemplateName = 'context.html', $sFuncContextAddon = 'getContextAddon')
-    {
-        $CNF = &$this->getModule()->_oConfig->CNF;
-
-        $iContextId = $aData[$CNF['FIELD_ALLOW_VIEW_TO']];
-        if ($iContextId >= 0)
-            return '';
-        
-        $iProfileId = - $iContextId;
-
-        $oProfile = BxDolProfile::getInstance($iProfileId);
-        if (!$oProfile) 
-            $oProfile = BxDolProfileUndefined::getInstance();
-
-        if (!$oProfile)
-            return '';
-
-        $sName = $oProfile->getDisplayName();
-        $sAddon = $sFuncContextAddon ? $this->$sFuncContextAddon($aData, $oProfile) : '';
-
-        $aVars = array (
-            'author_url' => $oProfile->getUrl(),
-            'author_thumb_url' => $oProfile->getThumb(),
-            'author_unit' => $oProfile->getUnit(0, array('template' => 'unit_wo_info')),
-            'author_title' => $sName,
-            'author_title_attr' => bx_html_attribute($sName),
-            'author_desc' => $sFuncContextDesc ? $this->$sFuncContextDesc($aData) : '',
-            'bx_if:addon' => array (
-                'condition' => (bool)$sAddon,
-                'content' => array (
-                    'content' => $sAddon,
-                ),
-            ),
-        );
-        return $this->parseHtmlByName($sTemplateName, $aVars);
-    }
-
     public function entryPolls($aData)
     {
         $CNF = &$this->getModule()->_oConfig->CNF;
@@ -583,11 +546,6 @@ class BxBaseModTextTemplate extends BxBaseModGeneralTemplate
         return $aSnippetMeta['meta'];
     }
 
-    function getContextDesc ($aData)
-    {
-        return '';
-    }
-
     function getProfileSnippetMenu ($aData)
     {
         $CNF = &$this->getModule()->_oConfig->CNF;
@@ -602,14 +560,6 @@ class BxBaseModTextTemplate extends BxBaseModGeneralTemplate
         return '';
     }
 
-    function getContextAddon ($aData, $oProfile)
-    {
-        $CNF = &$this->getModule()->_oConfig->CNF;
-        $sUrl = 'page.php?i=' . $CNF['URI_ENTRIES_BY_CONTEXT'] . '&profile_id=' . $oProfile->id();
-        $sUrl = BxDolPermalinks::getInstance()->permalink($sUrl);
-        return _t($CNF['T']['txt_all_entries_in'], $sUrl, $oProfile->getDisplayName(), $this->getModule()->_oDb->getEntriesNumByContext($oProfile->id()));
-    }
-
     protected function checkPrivacy ($aData, $isCheckPrivateContent, $oModule, $sTemplateName = '')
     {
         if ($isCheckPrivateContent && CHECK_ACTION_RESULT_ALLOWED !== ($sMsg = $oModule->checkAllowedView($aData))) {

+ 1 - 14
modules/base/text/template/context.html

@@ -1,14 +1 @@
-<div class="sys-author bx-def-unit absolute">
-    <div class="bx-def-unit-img">__author_unit__</div>
-    <div class="bx-def-unit-info bx-def-thumb-size-min-height bx-def-thumb-size-max-height bx-def-thumb-size-left-indent">
-        <div class="bx-def-unit-info-cnt bx-def-box-sizing">
-            <div class="bx-def-unit-line"><a class="bx-def-unit-info-title" href="__author_url__" title="__author_title_attr__">__author_title__</a></div>
-            <div class="bx-def-unit-line bx-def-font-grayed bx-def-font-small">__author_desc__</div> 
-        </div>
-    </div>
-</div>
-<bx_if:addon>
-    <div class="bx-def-margin-sec-top">
-        __content__ 
-    </div>
-</bx_if:addon>
+<bx_include_base:.. />modules/base/general/template/context.html />

+ 1 - 0
modules/boonex/events/classes/BxEventsConfig.php

@@ -178,6 +178,7 @@ class BxEventsConfig extends BxBaseModProfileConfig
                 'txt_ntfs_join_request' => '_bx_events_txt_ntfs_join_request',
                 'txt_ntfs_fan_added' => '_bx_events_txt_ntfs_fan_added',
             	'txt_ntfs_timeline_post_common' => '_bx_events_txt_ntfs_timeline_post_common',
+                'txt_all_entries_in' => '_bx_events_txt_all_entries_in',
             	'form_field_author' => '_bx_events_form_profile_input_author',
                 'menu_item_title_befriend_sent' => '_bx_events_menu_item_title_befriend_sent',
                 'menu_item_title_unfriend_cancel_request' => '_bx_events_menu_item_title_unfriend_cancel_request',

+ 5 - 1
modules/boonex/events/install/langs/en.xml

@@ -129,7 +129,8 @@
     <string name="_bx_events_page_block_title_sys_entries_in_context"><![CDATA[Events in context]]></string>
     <string name="_bx_events_page_block_title_calendar_in_context"><![CDATA[Calendar events in <a href="{profile_link}">{display_name}</a>]]></string>
     <string name="_bx_events_page_block_title_sys_calendar_in_context"><![CDATA[Calendar events in context]]></string>
-    <string name="_bx_events_page_block_title_calendar_for_context"><![CDATA[Events calendar]]></string>
+    <string name="_bx_events_page_block_title_calendar_for_context"><![CDATA[Calendar events in context]]></string>
+    <string name="_bx_events_page_block_title_browse_for_context"><![CDATA[Events in context]]></string>
     <string name="_bx_events_page_block_title_sys_entries_of_author"><![CDATA[Events of author]]></string>
     <string name="_bx_events_page_block_title_entries_of_author"><![CDATA[Events by {display_name}]]></string>
     <string name="_bx_events_page_block_title_favorites_of_author"><![CDATA[Favorite Events]]></string>
@@ -169,6 +170,8 @@
     <string name="_bx_events_page_block_title_categories"><![CDATA[Event categories]]></string>
     <string name="_bx_events_page_block_title_calendar"><![CDATA[Events calendar]]></string>
     <string name="_bx_events_page_block_title_profile_calendar"><![CDATA[Calendar]]></string>
+    <string name="_bx_events_page_block_title_sys_entry_context"><![CDATA[Posted in]]></string>
+    <string name="_bx_events_page_block_title_entry_context"><![CDATA[Posted in]]></string>
     <string name="_bx_events_page_block_title_entry_location"><![CDATA[Location]]></string>
     <string name="_bx_events_page_block_title_invite_to_group"><![CDATA[Invite Members to the Event]]></string>
     <string name="_bx_events_page_block_title_search_form"><![CDATA[Search Form]]></string>
@@ -297,6 +300,7 @@
     <string name="_bx_events_search_extended"><![CDATA[Events Search]]></string>
     <string name="_bx_events_search_extended_cmts"><![CDATA[Events Comments Search]]></string>
 
+    <string name="_bx_events_txt_all_entries_in"><![CDATA[<a href="{0}">All Events in {1} ({2})</a>]]></string>
     <string name="_bx_events_txt_account_pending"><![CDATA[This event is pending approval, please wait until it is activated.]]></string>
     <string name="_bx_events_txt_account_suspended"><![CDATA[This event is suspended.]]></string>
     <string name="_bx_events_txt_N_fans"><![CDATA[{0} members]]></string>

+ 3 - 2
modules/boonex/events/install/sql/enable.sql

@@ -43,10 +43,10 @@ INSERT INTO `sys_pages_blocks`(`object`, `cell_id`, `module`, `title_system`, `t
 ('bx_events_view_profile', 1, 'bx_events', '', '_bx_events_page_block_title_entry_social_sharing', 13, '', 2147483647, 'service', 'a:2:{s:6:\"module\";s:9:\"bx_events\";s:6:\"method\";s:21:\"entity_social_sharing\";}', 0, 0, 0, 0),
 ('bx_events_view_profile', 1, 'bx_events', '', '_bx_events_page_block_title_entry_all_actions', 13, '', 2147483647, 'service', 'a:2:{s:6:"module";s:9:"bx_events";s:6:"method";s:18:"entity_all_actions";}', 0, 0, 0, 0),
 ('bx_events_view_profile', 3, 'bx_events', '', '_bx_events_page_block_title_profile_calendar', 11, '', 2147483647, 'service', 'a:3:{s:6:\"module\";s:9:\"bx_events\";s:6:\"method\";s:8:\"calendar\";s:6:\"params\";a:2:{i:0;a:1:{s:5:\"event\";s:12:\"{content_id}\";}i:1;s:21:\"calendar_compact.html\";}}', 0, 0, 1, 0),
+('bx_events_view_profile', 3, 'bx_events', '_bx_events_page_block_title_sys_entry_context', '_bx_events_page_block_title_entry_context', 13, '', 2147483647, 'service', 'a:2:{s:6:\"module\";s:9:\"bx_events\";s:6:\"method\";s:14:\"entity_context\";}', 0, 0, 1, 1),
 ('bx_events_view_profile', 4, 'bx_events', '', '_bx_events_page_block_title_fans', 11, '', 2147483647, 'service', 'a:2:{s:6:\"module\";s:9:\"bx_events\";s:6:\"method\";s:4:\"fans\";}', 0, 0, 1, 1),
 ('bx_events_view_profile', 4, 'bx_events', '', '_bx_events_page_block_title_admins', 11, '', 2147483647, 'service', 'a:2:{s:6:\"module\";s:9:\"bx_events\";s:6:\"method\";s:6:\"admins\";}', 0, 0, 1, 2),
 ('bx_events_view_profile', 2, 'bx_events', '', '_bx_events_page_block_title_entry_location', 11, '', 2147483647, 'service', 'a:4:{s:6:\"module\";s:6:\"system\";s:6:\"method\";s:13:\"locations_map\";s:6:\"params\";a:2:{i:0;s:9:\"bx_events\";i:1;s:12:\"{content_id}\";}s:5:\"class\";s:20:\"TemplServiceMetatags\";}', 0, 0, 1, 1);
-
 -- PAGE: view closed profile 
 
 INSERT INTO `sys_objects_page`(`object`, `uri`, `title_system`, `title`, `module`, `layout_id`, `visible_for_levels`, `visible_for_levels_editable`, `url`, `meta_description`, `meta_keywords`, `meta_robots`, `cache_lifetime`, `cache_editable`, `deletable`, `override_class_name`, `override_class_file`) VALUES 
@@ -208,7 +208,8 @@ INSERT INTO `sys_pages_blocks` (`object`, `cell_id`, `module`, `title_system`, `
  
  -- PAGES: add page block to profiles modules (trigger* page objects are processed separately upon modules enable/disable)
 INSERT INTO `sys_pages_blocks` (`object`, `cell_id`, `module`, `title`, `designbox_id`, `visible_for_levels`, `type`, `content`, `deletable`, `copyable`, `order`, `active`) VALUES
-('trigger_page_group_view_entry', 2, 'bx_events', '_bx_events_page_block_title_calendar_for_context', 11, 2147483647, 'service', 'a:4:{s:6:"module";s:9:"bx_events";s:6:"method";s:8:"calendar";s:12:"ignore_cache";b:1;s:6:"params";a:1:{i:0;a:1:{s:10:"context_id";s:12:"{profile_id}";}}}', 0, 0, 0, 0);
+('trigger_page_group_view_entry', 2, 'bx_events', '_bx_events_page_block_title_calendar_for_context', 11, 2147483647, 'service', 'a:4:{s:6:"module";s:9:"bx_events";s:6:"method";s:8:"calendar";s:12:"ignore_cache";b:1;s:6:"params";a:1:{i:0;a:1:{s:10:"context_id";s:12:"{profile_id}";}}}', 0, 0, 0, 0),
+('trigger_page_group_view_entry', 4, 'bx_events', '_bx_events_page_block_title_browse_for_context', 11, 2147483647, 'service', 'a:3:{s:6:"module";s:9:"bx_events";s:6:"method";s:14:"browse_context";s:6:"params";a:1:{s:10:"context_id";s:12:"{profile_id}";}}', 0, 0, 1, 0);
 
 
 -- MENU

+ 1 - 0
modules/boonex/events/template/context.html

@@ -0,0 +1 @@
+<bx_include_base:../modules/base/general/template/context.html />

+ 13 - 0
modules/boonex/russian/data/langs/bx_events/ru.xml

@@ -78,6 +78,8 @@
 
 	<string name="_bx_events_page_title_sys_joined_entries"><![CDATA[События профиля]]></string>
 	<string name="_bx_events_page_title_joined_entries"><![CDATA[События профиля]]></string>
+  <string name="_bx_events_page_title_sys_entries_in_context"><![CDATA[События в контексте]]></string>
+  <string name="_bx_events_page_title_entries_in_context"><![CDATA[События в {display_name}]]></string>
 	<string name="_bx_events_page_title_sys_create_profile"><![CDATA[Создать событие]]></string>
 	<string name="_bx_events_page_title_create_profile"><![CDATA[Создать событие]]></string>
 	<string name="_bx_events_page_title_sys_edit_profile"><![CDATA[Редактировать событие]]></string>
@@ -123,6 +125,12 @@
 
     <string name="_bx_events_page_block_title_sys_entries_actions"><![CDATA[События - Действия]]></string>
     <string name="_bx_events_page_block_title_entries_actions"><![CDATA[События - Действия]]></string>
+    <string name="_bx_events_page_block_title_entries_in_context"><![CDATA[События в <a href="{profile_link}">{display_name}</a>]]></string>
+    <string name="_bx_events_page_block_title_sys_entries_in_context"><![CDATA[События в контексте]]></string>
+    <string name="_bx_events_page_block_title_calendar_in_context"><![CDATA[Календарь событий в <a href="{profile_link}">{display_name}</a>]]></string>
+    <string name="_bx_events_page_block_title_sys_calendar_in_context"><![CDATA[Календарь событий в контексте]]></string>
+    <string name="_bx_events_page_block_title_calendar_for_context"><![CDATA[Календарь событий в контексте]]></string>
+    <string name="_bx_events_page_block_title_browse_for_context"><![CDATA[События в контексте]]></string>
     <string name="_bx_events_page_block_title_sys_entries_of_author"><![CDATA[События автора]]></string>
     <string name="_bx_events_page_block_title_entries_of_author"><![CDATA[{display_name} - События]]></string>
     <string name="_bx_events_page_block_title_favorites_of_author"><![CDATA[Избранные события]]></string>   
@@ -162,6 +170,8 @@
     <string name="_bx_events_page_block_title_categories"><![CDATA[Категории событий]]></string>
     <string name="_bx_events_page_block_title_calendar"><![CDATA[Календарь событий]]></string>
     <string name="_bx_events_page_block_title_profile_calendar"><![CDATA[Календарь событий]]></string>
+    <string name="_bx_events_page_block_title_sys_entry_context"><![CDATA[Опубликовано в]]></string>
+    <string name="_bx_events_page_block_title_entry_context"><![CDATA[Опубликовано в]]></string>
     <string name="_bx_events_page_block_title_entry_location"><![CDATA[Местоположение]]></string>
     <string name="_bx_events_page_block_title_categories"><![CDATA[Категории событий]]></string>
     <string name="_bx_events_page_block_title_invite_to_group"><![CDATA[Приглашение на событие]]></string>
@@ -240,6 +250,8 @@
 
     <string name="_bx_events_menu_item_title_system_subscribe"><![CDATA[Получать уведомления]]></string>
     <string name="_bx_events_menu_item_title_subscribe"><![CDATA[Заинтересован]]></string>
+    <string name="_bx_events_menu_item_title_system_view_entries_in_context"><![CDATA[События]]></string>
+    <string name="_bx_events_menu_item_title_view_entries_in_context"><![CDATA[События]]></string>
     <string name="_bx_events_menu_item_title_system_unsubscribe"><![CDATA[Отключить уведомления]]></string>
     <string name="_bx_events_menu_item_title_unsubscribe"><![CDATA[Не заинтересован]]></string>
     <string name="_bx_events_menu_item_title_system_more_actions"><![CDATA[Дополнительные действия]]></string>
@@ -290,6 +302,7 @@
     <string name="_bx_events_search_extended_cmts"><![CDATA[Поиск комментариев к событиям]]></string>
 
     <string name="_bx_events_txt_account_pending"><![CDATA[Это событие ожидает одобрения. Пожалуйста, дождитесь ее активации.]]></string>
+    <string name="_bx_events_txt_all_entries_in"><![CDATA[<a href="{0}">Все события в {1} ({2})</a>]]></string>
     <string name="_bx_events_txt_account_suspended"><![CDATA[Это событие заблокировано.]]></string>
     <string name="_bx_events_txt_N_fans"><![CDATA[{0} участников]]></string>
     <string name="_bx_events_txt_sample_single"><![CDATA[событие]]></string>