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

#42 - page builder for conversations homepage

Alex Trofimov 12 лет назад
Родитель
Сommit
3e12f61631

+ 5 - 0
modules/base/text/template/css/main.css

@@ -54,6 +54,11 @@
     margin-top:0;
 }
 
+.bx-base-text-entity-content p:last-child,
+.bx-base-text-entity-content h1:last-child {
+    margin-bottom:0;
+}
+
 .bx-base-text-entity-share .bx-vote,
 .bx-base-text-entity-share .bx-tl-share,
 .bx-base-text-entity-share .bx-social-sharing {

+ 35 - 19
modules/boonex/convos/classes/BxCnvModule.php

@@ -143,35 +143,29 @@ class BxCnvModule extends BxBaseModTextModule
      */
     public function actionFolder ($iFolderId)
     {
-        // TODO: add to page builder
-        bx_import('BxDolGrid');
-        $oGrid = BxDolGrid::getObjectInstance($this->_oConfig->CNF['OBJECT_GRID']);
-        if (!$oGrid){
-            $this->_oTemplate->displayErrorOccured();
-            exit;
-        }
+        $oTemplate = BxDolTemplate::getInstance();
 
+        bx_import('BxDolPage');
         $aFolder = $this->_oDb->getFolder((int)$iFolderId);
-        if (!$aFolder) {
+        $oPage = BxDolPage::getObjectInstance('bx_convos_home');
+
+        if (!$aFolder || !$oPage) {
             $this->_oTemplate->displayPageNotFound();
             exit;
         }
 
-        $this->setModuleSubmenu ((int)$iFolderId);
-
-        // TODO: incorporate markers into custom class, so replace will work in search and so on
-        $oGrid->addMarkers(array(
+        // add replaceable markers
+        $oPage->addMarkers(array(
             'folder_id' => (int)$iFolderId,
-            'profile_id' => bx_get_logged_profile_id(),
+            'folder' => _t($aFolder['name']),
         ));
 
-        // TODO: refactor below
-        $oTemplate = BxDolTemplate::getInstance();
-        $oTemplate->setPageNameIndex (BX_PAGE_DEFAULT);
-        $oTemplate->setPageHeader (str_replace('{folder}', _t($aFolder['name']), _t('_bx_cnv_page_title_folder')));
-        $oTemplate->setPageContent ('page_main_code', $oGrid->getCode());
-        $oTemplate->getPageCode();
+        $s = $oPage->getCode();
 
+        $this->_oTemplate = BxDolTemplate::getInstance();
+        $this->_oTemplate->setPageNameIndex (BX_PAGE_DEFAULT);
+        $this->_oTemplate->setPageContent ('page_main_code', $s);
+        $this->_oTemplate->getPageCode();
     }
 
     /**
@@ -187,6 +181,28 @@ class BxCnvModule extends BxBaseModTextModule
         echo(json_encode($a));
     }
 
+    public function serviceConversationsInFolder ($iFolderId = BX_CNV_FOLDER_INBOX)
+    {
+        bx_import('BxDolGrid');
+        $oGrid = BxDolGrid::getObjectInstance($this->_oConfig->CNF['OBJECT_GRID']);
+        if (!$oGrid)
+            return false;
+
+        $aFolder = $this->_oDb->getFolder((int)$iFolderId);
+        if (!$aFolder)
+            return false;
+
+        $this->setModuleSubmenu ((int)$iFolderId);
+
+        // TODO: incorporate markers into custom class, so replace will work in search and so on
+        $oGrid->addMarkers(array(
+            'folder_id' => (int)$iFolderId,
+            'profile_id' => bx_get_logged_profile_id(),
+        ));
+
+        return $oGrid->getCode();
+    }
+
     public function serviceMessagesPreviews ($iProfileId = 0)
     {
         if (!$iProfileId)

+ 26 - 0
modules/boonex/convos/classes/BxCnvPageFolder.php

@@ -0,0 +1,26 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
+ * CC-BY License - http://creativecommons.org/licenses/by/3.0/
+ *
+ * @defgroup    Convos Convos
+ * @ingroup     DolphinModules
+ *
+ * @{
+ */
+
+bx_import('BxTemplPage');
+
+/**
+ * Display conversations in the folder
+ */
+class BxCnvPageFolder extends BxTemplPage
+{
+    public function __construct($aObject, $oTemplate = false)
+    {
+        parent::__construct($aObject, $oTemplate);
+    }
+
+}
+
+/** @} */

+ 1 - 1
modules/boonex/convos/install/sql/enable.sql

@@ -48,7 +48,7 @@ INSERT INTO `sys_objects_page`(`object`, `title_system`, `title`, `module`, `lay
 ('bx_convos_home', '_bx_cnv_page_title_sys_folder', '_bx_cnv_page_title_folder', 'bx_convos', 5, 2147483647, 1, 'convos-folder', 'modules/?r=convos/folder/1', '', '', '', 0, 1, 0, 'BxCnvPageBrowse', 'modules/boonex/convos/classes/BxCnvPageBrowse.php');
 
 INSERT INTO `sys_pages_blocks`(`object`, `cell_id`, `module`, `title`, `designbox_id`, `visible_for_levels`, `type`, `content`, `deletable`, `copyable`, `order`) VALUES 
-('bx_convos_home', 1, 'bx_convos', '_bx_cnv_page_block_title_folder', 0, 2147483647, 'service', 'a:2:{s:6:\"module\";s:9:\"bx_convos\";s:6:\"method\";s:4:\"home\";}', 0, 1, 0);
+('bx_convos_home', 1, 'bx_convos', '_bx_cnv_page_block_title_folder', 11, 2147483647, 'service', 'a:3:{s:6:"module";s:9:"bx_convos";s:6:"method";s:23:"conversations_in_folder";s:6:"params";a:1:{i:0;s:11:"{folder_id}";}}', 0, 1, 0);
 
 
 -- MENU: actions menu for view entry