瀏覽代碼

#3515 - popups + custom icons

RomanL 5 年之前
父節點
當前提交
07bb0102f1

+ 9 - 5
inc/classes/BxDolConnection.php

@@ -142,20 +142,20 @@ class BxDolConnection extends BxDolFactory implements iBxDolFactoryObject
         if (!$sObject)
             return false;
 
-        if (isset($GLOBALS['bxDolClasses']['BxDolConnection!'.$sObject]))
-            return $GLOBALS['bxDolClasses']['BxDolConnection!'.$sObject];
+        if (isset($GLOBALS['bxDolClasses']['BxTemplConnection!'.$sObject]))
+            return $GLOBALS['bxDolClasses']['BxTemplConnection!'.$sObject];
 
         $aObject = BxDolConnectionQuery::getConnectionObject($sObject);
         if (!$aObject || !is_array($aObject))
             return false;
 
-        $sClass = empty($aObject['override_class_name']) ? 'BxDolConnection' : $aObject['override_class_name'];
+        $sClass = empty($aObject['override_class_name']) ? 'BxTemplConnection' : $aObject['override_class_name'];
         if (!empty($aObject['override_class_file']))
             require_once(BX_DIRECTORY_PATH_ROOT . $aObject['override_class_file']);
 
         $o = new $sClass($aObject);
 
-        return ($GLOBALS['bxDolClasses']['BxDolConnection!'.$sObject] = $o);
+        return ($GLOBALS['bxDolClasses']['BxTemplConnection!'.$sObject] = $o);
     }
 
     /**
@@ -261,10 +261,14 @@ class BxDolConnection extends BxDolFactory implements iBxDolFactoryObject
     public function outputActionResult ($mixed, $sFormat = 'json')
     {
         switch ($sFormat) {
+            case 'html':
+                echo $mixed;
+                break;
+                
             case 'json':
             default:
                 header('Content-Type: application/json; charset=utf-8');
-                echo json_encode($mixed);
+                echo json_encode($mixed);     
         }
         exit;
     }

+ 83 - 0
inc/js/classes/BxDolConnection.js

@@ -0,0 +1,83 @@
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    UnaCore UNA Core
+ * @{
+ */
+
+function BxDolConnection(options)
+{
+    this._sObjName = undefined == options.sObjName ? 'oView' : options.sObjName; // javascript object name, to run current object instance from onTimer
+    this._sSystem = options.sSystem; // current comment system
+    this._iObjId = options.iObjId; // this object id comments
+    this._sContentType = options.sContentType; 
+    this._bIsMutual = options.bIsMutual; 
+    
+    this._sActionsUri = 'conn.php';
+    this._sActionsUrl = options.sRootUrl + this._sActionsUri; // actions url address
+
+    this._sAnimationEffect = 'fade';
+    this._iAnimationSpeed = 'slow';
+    this._sSP = undefined == options.sStylePrefix ? 'bx-view' : options.sStylePrefix;
+    this._aHtmlIds = options.aHtmlIds;
+}
+
+BxDolConnection.prototype.toggleByPopup = function(oLink) {
+    var $this = this;
+    var oData = this._getDefaultParams();
+    oData['act'] = 'GetConnected';
+
+    $(oLink).dolPopupAjax({
+        id: this._aHtmlIds['by_popup'], 
+        url: bx_append_url_params(this._sActionsUri, oData)
+    });
+};
+
+BxDolView.prototype.getUsers = function(oLink, iStart, iPerPage) {
+    var $this = this;
+    var oData = this._getDefaultParams();
+    oData['action'] = 'GetUsers';
+    oData['start'] = iStart;
+    oData['per_page'] = iPerPage;
+
+    this._loadingInPopup(oLink, true);
+
+    $.get(
+        this._sActionsUri,
+        oData,
+        function(oData) {
+            $this._loadingInPopup(oLink, false);
+
+            oData.source = oLink;
+            processJsonData(oData);
+        },
+        'json'
+    );
+};
+
+BxDolConnection.prototype._loadingInButton = function(e, bShow) {
+    if($(e).length)
+        bx_loading_btn($(e), bShow);
+    else
+        bx_loading($('body'), bShow);
+};
+
+BxDolConnection.prototype._loadingInPopup = function(e, bShow) {
+    var oParent = $(e).length ? $(e).parents('.bx-popup-content:first') : $('body'); 
+    bx_loading(oParent, bShow);
+};
+
+BxDolConnection.prototype._getDefaultParams = function() {
+    var oDate = new Date();
+    return {
+        obj: this._sSystem,
+        id: this._iObjId,
+        mutual: this._bIsMutual,
+        content_type: this._sContentType,
+        _t: oDate.getTime(),
+        fmt: 'html'
+    };
+};
+
+/** @} */

+ 1 - 0
install/sql/system.sql

@@ -5525,6 +5525,7 @@ INSERT INTO `sys_preloader`(`module`, `type`, `content`, `active`, `order`) VALU
 ('system', 'js_system', 'BxDolMenuMoreAuto.js', 1, 41),
 ('system', 'js_system', 'BxDolForm.js', 1, 42),
 ('system', 'js_system', 'BxDolNestedForm.js', 1, 43),
+('system', 'js_system', 'BxDolConnection.js', 1, 44),
 
 ('system', 'js_translation', '_Are_you_sure', 1, 1),
 ('system', 'js_translation', '_error occured', 1, 2),

+ 21 - 0
template/connected_by_list.html

@@ -0,0 +1,21 @@
+<div class="__style_prefix__-by-list">
+    <div class="__style_prefix__-by-list-cnt">
+        <div class="__style_prefix__-by-items">
+            <bx_repeat:list>
+                <div class="__style_prefix__-by-item bx-def-padding-sec">
+                    <div class="__style_prefix__-user bx-clearfix">
+                        <div class="__style_prefix__-user-avatar bx-def-thumb-size">
+                            __user_unit__
+                        </div>
+                        <div class="__style_prefix__-user-info bx-def-thumb-size-min-height bx-def-thumb-size-left-indent">
+                            <div class="__style_prefix__-user-name bx-def-font-middle bx-def-font-light bx-def-font-grayed">
+                                <a href="__user_url__" class="__style_prefix__-user-name" title="__user_title__">__user_name__</a>
+                            </div>
+                        </div>
+                    </div>
+                </div>
+            </bx_repeat:list>
+        </div>
+        <div class="__style_prefix__-by-paginate">__paginate__</div>
+    </div>
+</div>

+ 7 - 0
template/connection_counter.html

@@ -0,0 +1,7 @@
+<bx_if:show_text>
+    <span class="__class__" <bx_repeat:attrs>__key__="__value__"</bx_repeat:attrs>>__content__</span>
+</bx_if:show_text>
+<bx_if:show_link>
+    <a class="__class__" <bx_repeat:attrs>__key__="__value__"</bx_repeat:attrs>>__content__</a>
+</bx_if:show_link>
+__script__

+ 10 - 0
template/connection_counter_label.html

@@ -0,0 +1,10 @@
+<span class="__style_prefix__-counter-label bx-def-valign-center">
+    <bx_if:show_icon>
+        <span class="sys-action-counter-icon __style_prefix__-counter-icon bx-def-align-center">
+            __name__
+        </span>
+    </bx_if:show_icon>
+    <bx_if:show_text>
+        <span class="sys-action-counter-text __style_prefix__-counter-text bx-def-margin-sec-left-auto">__text__</span>
+    </bx_if:show_text>
+</span>

+ 4 - 4
template/scripts/BxBaseCmts.php

@@ -747,12 +747,12 @@ class BxBaseCmts extends BxDolCmts
                     'onclick' => $sOnclick
                 )
             ),
-            'content' => $this->_getCounterLabel($iCount),
+            'content' => $this->_getCounterLabel($iCount, $aParams),
             'bx_repeat:profiles' => $aTmplVarsProfiles,
             'bx_if:show_icon' => array(
                 'condition' => $bShowEmpty || !empty($aTmplVarsProfiles),
                 'content' => array(
-                    'sp' => $this->_sStylePrefix
+                    'icon' => isset($aParams['custom_icon']) && $aParams['custom_icon'] != '' ? $aParams['custom_icon'] : BxTemplFunctions::getInstanceWithTemplate($this->_oTemplate)->getFontIconAsHtml('comment', $this->_sStylePrefix . '-counter-icon sys-icon')
                 )
             )
         ));
@@ -786,9 +786,9 @@ class BxBaseCmts extends BxDolCmts
         ));
     }
 
-    protected function _getCounterLabel($iCount)
+    protected function _getCounterLabel($iCount, $aParams = array())
     {
-        return (int)$iCount != 0 ? _t('_cmt_txt_counter', $iCount) : _t('_cmt_txt_counter_empty');
+        return (int)$iCount != 0 ? _t(isset($aParams['caption']) ? $aParams['caption'] : '_cmt_txt_counter', $iCount) : _t('_cmt_txt_counter_empty');
     }
 
     protected function _getTmplElementBlock()

+ 12 - 1
template/scripts/BxBaseFunctions.php

@@ -211,7 +211,7 @@ class BxBaseFunctions extends BxDolFactory implements iBxDolSingleton
                             }
 							else{
 								$sIconFont = $sCode; // font icons
-                                $sIconFontWithHtml = '<i class="sys-icon ' . $sIconFont .' ' . $sClass . '"' . $sAttrs . '></i>';
+                                $sIconFontWithHtml = $this->getFontIconAsHtml($sIconFont, $sClass, $sAttrs);
                             }
 						} else {
 							$sIconUrl = $this->_oTemplate->getIconUrl($sCode);
@@ -222,6 +222,17 @@ class BxBaseFunctions extends BxDolFactory implements iBxDolSingleton
         }
         return array ($sIconFont, $sIconUrl, $sIconA, $sIconHtml, $sIconFontWithHtml);
     }
+    
+    function getFontIconAsHtml($sIconFont, $sClass = '', $sAttrs = '')
+    {
+        return  '<i class="sys-icon ' . $sIconFont .' ' . $sClass . '"' . $sAttrs . '></i>';
+    }
+    
+    function getIconAsHtml($sCode, $aAttrs = array())
+    {
+        $aIcons = $this->getIcon($sCode, $aAttrs);
+        return $aIcons[3] . $aIcons[4]; 
+    }
 
     function getTemplateIcon($sName)
     {

+ 2 - 2
template/scripts/BxBaseView.php

@@ -236,14 +236,14 @@ class BxBaseView extends BxDolView
                 'condition' => !isset($aParams['show_counter_label_icon']) || $aParams['show_counter_label_icon'] === true,
                 'content' => array(
                     'style_prefix' => $this->_sStylePrefix,
-                    'name' => $this->_getIconDo()
+                    'name' => isset($aParams['custom_icon']) && $aParams['custom_icon'] != '' ? $aParams['custom_icon'] : BxTemplFunctions::getInstanceWithTemplate($this->_oTemplate)->getFontIconAsHtml($this->_getIconDo())
                 )
             ),
             'bx_if:show_text' => array(
                 'condition' => !isset($aParams['show_counter_label_text']) || $aParams['show_counter_label_text'] === true,
                 'content' => array(
                     'style_prefix' => $this->_sStylePrefix,
-                    'text' => _t('_view_counter', $iCount)
+                    'text' => _t(isset($aParams['caption']) ? $aParams['caption'] : '_view_counter', $iCount)
                 )
             )
         ));

+ 1 - 1
template/scripts/BxBaseVote.php

@@ -264,7 +264,7 @@ class BxBaseVote extends BxDolVote
 
     protected function _getCounterLabel($iCount, $aParams = array())
     {
-        return _t('_vote_counter', $iCount);
+        return _t(isset($aParams['caption']) ? $aParams['caption'] : '_vote_counter', $iCount);
     }
 
     protected function _getVotedBy($aParams = array())

+ 1 - 1
template/scripts/BxBaseVoteLikes.php

@@ -133,7 +133,7 @@ class BxBaseVoteLikes extends BxDolVoteLikes
                 'condition' => !isset($aParams['show_counter_label_icon']) || (bool)$aParams['show_counter_label_icon'] === true,
                 'content' => array(
                     'style_prefix' => $this->_sStylePrefix,
-                    'name' => $this->_getIconDo($bVoted)
+                    'name' => isset($aParams['custom_icon']) && $aParams['custom_icon'] != '' ? $aParams['custom_icon'] : BxTemplFunctions::getInstanceWithTemplate($this->_oTemplate)->getFontIconAsHtml($this->_getIconDo($bVoted))
                 )
             ),
             'bx_if:show_text' => array(

+ 10 - 1
template/view_counter_label.html

@@ -1 +1,10 @@
-<span class="__style_prefix__-counter-label bx-def-valign-center"><bx_if:show_icon><span class="sys-action-counter-icon __style_prefix__-counter-icon bx-def-align-center"><i class="sys-icon __name__"></i></span></bx_if:show_icon><bx_if:show_text><span class="sys-action-counter-text __style_prefix__-counter-text bx-def-margin-sec-left-auto">__text__</span></bx_if:show_text></span>
+<span class="__style_prefix__-counter-label bx-def-valign-center">
+    <bx_if:show_icon>
+        <span class="sys-action-counter-icon __style_prefix__-counter-icon bx-def-align-center">
+            __name__
+        </span>
+    </bx_if:show_icon>
+    <bx_if:show_text>
+        <span class="sys-action-counter-text __style_prefix__-counter-text bx-def-margin-sec-left-auto">__text__</span>
+    </bx_if:show_text>
+</span>

+ 10 - 1
template/vote_counter_label_likes.html

@@ -1 +1,10 @@
-<span class="sys-action-counter-label __style_prefix__-counter-label bx-def-valign-center"><bx_if:show_icon><span class="sys-action-counter-icon __style_prefix__-counter-icon bx-def-align-center"><i class="sys-icon __name__"></i></span></bx_if:show_icon><bx_if:show_text><span class="sys-action-counter-text __style_prefix__-counter-text bx-def-margin-sec-left-auto">__text__</span></bx_if:show_text></span>
+<span class="sys-action-counter-label __style_prefix__-counter-label bx-def-valign-center">
+    <bx_if:show_icon>
+        <span class="sys-action-counter-icon __style_prefix__-counter-icon bx-def-align-center">
+            __name__
+        </span>
+    </bx_if:show_icon>
+    <bx_if:show_text>
+        <span class="sys-action-counter-text __style_prefix__-counter-text bx-def-margin-sec-left-auto">__text__</span>
+    </bx_if:show_text>
+</span>