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

#24 - Search in Notifications based modules.

AntonLV 12 лет назад
Родитель
Сommit
cb1af112ba

+ 5 - 0
modules/base/notifications/classes/BxBaseModNotificationsModule.php

@@ -75,6 +75,11 @@ class BxBaseModNotificationsModule extends BxDolModule
         return $aResults;
     }
 
+    public function isAllowedView($bPerform = false)
+    {
+		return true;
+    }
+
 	public function getUserId()
     {
         return isLogged() ? bx_get_logged_profile_id() : 0;

+ 22 - 0
modules/base/notifications/classes/BxBaseModNotificationsSearchResult.php

@@ -0,0 +1,22 @@
+<?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    BaseNotifications Base classes for Notifications like modules
+ * @ingroup     DolphinModules
+ *
+ * @{
+ */
+
+bx_import('BxBaseModGeneralSearchResult');
+
+class BxBaseModNotificationsSearchResult extends BxBaseModGeneralSearchResult
+{
+    function __construct($sMode = '', $aParams = array())
+    {
+        parent::__construct($sMode, $aParams);
+    }
+}
+
+/** @} */

+ 50 - 0
modules/base/notifications/classes/BxBaseModNotificationsTemplate.php

@@ -56,6 +56,56 @@ class BxBaseModNotificationsTemplate extends BxBaseModGeneralTemplate
         $sName = $this->_oConfig->getName();
         return BxDolModule::getInstance($sName);
     }
+    
+    public function getPost(&$aEvent, $aBrowseParams = array())
+    {
+    	return '';
+    }
+
+	function unit($aData, $isCheckPrivateContent = true, $sTemplateName = 'unit.html')
+    {
+    	$this->getCssJs();
+
+    	if($sTemplateName == 'unit.html')
+    		return $this->getPost($aData);
+
+        $oModule = $this->getModule();
+        $CNF = &$this->_oConfig->CNF;
+
+        if ($isCheckPrivateContent && CHECK_ACTION_RESULT_ALLOWED !== ($sMsg = $oModule->isAllowedView($aData))) {
+            $aVars = array (
+                'summary' => $sMsg,
+            );
+            return $this->parseHtmlByName('unit_private.html', $aVars);
+        }
+
+        list($sAuthorName, $sAuthorUrl, $sAuthorIcon) = $oModule->getUserInfo($aData['object_id']);
+        $bAuthorIcon = !empty($sAuthorIcon);
+
+        // generate html
+        $aVars = array (
+            'id' => $aData['id'],
+            'author' => $sAuthorName,
+            'author_url' => $sAuthorUrl,
+            'title' => bx_process_output($aData['title']),
+        	'item_url' => $this->_oConfig->getItemViewUrl($aData),
+            'item_date' => bx_time_js($aData['date'], BX_FORMAT_DATE),
+            'module_name' => _t($CNF['T']['txt_sample_single_ext']),
+            'ts' => $aData['date'],
+            'bx_if:show_icon' => array(
+                'condition' => $bAuthorIcon,
+                'content' => array(
+                    'author_icon' => $sAuthorIcon
+                )
+            ),
+            'bx_if:show_icon_empty' => array(
+                'condition' => !$bAuthorIcon,
+                'content' => array()
+            ),
+        );
+
+        return $this->parseHtmlByName($sTemplateName, $aVars);
+    }
 
 }
 

+ 0 - 0
modules/base/notifications/template/unit.html


+ 5 - 0
modules/base/notifications/template/unit_live_search.html

@@ -0,0 +1,5 @@
+<div class="bx-base-notifications-unit bx-def-unit bx-def-unit-live-search bx-def-margin-sec-bottom" data-ts="__ts__">
+	<bx_if:show_icon><img class="bx-def-thumb bx-def-thumb-size" src="__author_icon__" /></bx_if:show_icon>
+	<bx_if:show_icon_empty><i class="sys-icon user"></i></bx_if:show_icon_empty>
+    <div class="bx-def-unit-info bx-def-thumb-size-max-height bx-def-padding-sec-left"><a href="__item_url__">__title__</a><br /><span class="bx-def-fonr-grayed bx-def-font-small">__module_name__</span></div>
+</div>

+ 6 - 0
modules/base/notifications/template/unit_private.html

@@ -0,0 +1,6 @@
+<div class="bx-base-text-unit bx-def-margin-bottom">
+    <h2><bx_text:_sys_private /></h2>
+    <div class="bx-base-text-unit-summary">
+        __summary__
+    </div>
+</div>

+ 2 - 2
template/scripts/BxBaseSearch.php

@@ -96,13 +96,13 @@ class BxBaseSearch extends BxDolSearch
             $o->addCssJs();
         }
 
-        return DesignBoxContent($sTitle, $sForm, $iDesignBoxTemplate);
+        return '<div class="bx-page-block-container bx-def-padding-topbottom bx-clearfix">' . DesignBoxContent($sTitle, $sForm, $iDesignBoxTemplate) . '</div>';
     }
 
     public function getResultsContainer($sCode = '')
     {
         $sIdResults = $this->_sIdResults . ($this->_bLiveSearch ? $this->_sSuffixLiveSearch : '');
-        return '<div id="' . $sIdResults . '" class="bx-def-margin-top">' . $sCode . '</div>';
+        return '<div id="' . $sIdResults . '">' . $sCode . '</div>';
     }
 }
 

+ 1 - 1
template/scripts/BxBaseSearchResult.php

@@ -77,7 +77,7 @@ class BxBaseSearchResult extends BxDolSearchResult
 
         if ($this->id) {
         	$sCode = $this->oFunctions->designBoxContent($sTitle, $sContent, $this->iDesignBoxTemplate, $sMenu);
-            return '<div class="bx-page-block-container bx-clearfix" id="bx-page-block-' . $this->id . '">' . $sCode . '</div>';
+            return '<div class="bx-page-block-container bx-def-padding-topbottom bx-clearfix" id="bx-page-block-' . $this->id . '">' . $sCode . '</div>';
         }
 
         return array(