1
0
AntonLV 5 жил өмнө
parent
commit
9f9076756c

+ 15 - 0
inc/classes/BxDolView.php

@@ -56,6 +56,8 @@ class BxDolView extends BxDolObject
         if(empty($this->_sSystem))
             return;
 
+        $this->_aSystem['per_page_default'] = 20;
+
         $this->_oQuery = new BxDolViewQuery($this);
     }
 
@@ -127,6 +129,19 @@ class BxDolView extends BxDolObject
 
         return $this->_getViewedBy();
     }
+    
+    public function actionGetUsers()
+    {
+        if (!$this->isEnabled())
+           return echoJson(array());
+
+        $iStart = (int)bx_get('start');
+        $iPerPage = (int)bx_get('per_page');
+        return echoJson(array(
+            'content' => $this->_getViewedBy($iStart, $iPerPage),
+            'eval' => $this->getJsObjectName() . '.onGetUsers(oData)'
+        ));
+    }
 
     public function doView()
     {

+ 1 - 2
inc/classes/BxDolViewQuery.php

@@ -23,8 +23,7 @@ class BxDolViewQuery extends BxDolObjectQuery
 
         $aSystem = $this->_oModule->getSystemInfo();
         $this->_iPeriod = (int)$aSystem['period'];
-
-        $this->_iPerPageDefault = 30;
+        $this->_iPerPageDefault = $aSystem['per_page_default'];
     }
 
     public function isPerformed($iObjectId, $iAuthorId)

+ 34 - 0
inc/js/classes/BxDolView.js

@@ -33,6 +33,35 @@ BxDolView.prototype.toggleByPopup = function(oLink) {
     });
 };
 
+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'
+    );
+};
+
+BxDolView.prototype.onGetUsers = function(oData) {
+    if(!oData.content)
+        return;
+
+    $(oData.source).parents('.bx-popup-content-wrapped:first').html(oData.content);
+};
+
 BxDolView.prototype._loadingInButton = function(e, bShow) {
     if($(e).length)
         bx_loading_btn($(e), bShow);
@@ -40,6 +69,11 @@ BxDolView.prototype._loadingInButton = function(e, bShow) {
         bx_loading($('body'), bShow);
 };
 
+BxDolView.prototype._loadingInPopup = function(e, bShow) {
+    var oParent = $(e).length ? $(e).parents('.bx-popup-content:first') : $('body'); 
+    bx_loading(oParent, bShow);
+};
+
 BxDolView.prototype._getDefaultParams = function() {
     var oDate = new Date();
     return {

+ 14 - 6
template/css/view.css

@@ -1,11 +1,12 @@
 /*--- Comment Viewed By ---*/
 div.bx-view-by-list {}
-div.bx-view-by-list-cnt {
-	max-height: 200px;
-	max-height: 12.5rem;
-	min-width: 220px;
-	min-width: 13.75rem;
-	overflow: auto;
+div.bx-view-by-list-cnt {}
+div.bx-view-by-items {
+    max-height: 200px;
+    max-height: 12.5rem;
+    min-width: 220px;
+    min-width: 13.75rem;
+    overflow: auto;
 }
 div.bx-view-user {
     position: relative;
@@ -31,6 +32,13 @@ div.bx-view-user-name a.bx-view-user-name {
 div.bx-view-user-name span.bx-view-user-info {
     white-space: nowrap;
 }
+div.bx-view-by-paginate {
+    text-align: right;
+}
+div.bx-view-by-paginate div.bx-paginate {
+    display: inline-block;
+    margin-top: 0.5rem;
+}
 
 /*--- View Element Styles ---*/
 div.bx-view-element-holder,

+ 16 - 5
template/scripts/BxBaseView.php

@@ -270,11 +270,21 @@ class BxBaseView extends BxDolView
         ));
     }
 
-    protected function _getViewedBy()
+    protected function _getViewedBy($iStart = 0, $iPerPage = 0)
     {
-        $aTmplUsers = array();
+        if(empty($iPerPage))
+            $iPerPage = $this->_aSystem['per_page_default'];
+
+        $aUsers = $this->_oQuery->getPerformedBy($this->getId(), $iStart, $iPerPage + 1);
 
-        $aUsers = $this->_oQuery->getPerformedBy($this->getId());
+        $oPaginate = new BxTemplPaginate(array(
+            'on_change_page' => $this->getJsObjectName() . '.getUsers(this, {start}, {per_page})',
+            'start' => $iStart,
+            'per_page' => $iPerPage,
+        ));
+        $oPaginate->setNumFromDataArray($aUsers);
+
+        $aTmplUsers = array();
         foreach($aUsers as $aUser) {
             list($sUserName, $sUserUrl, $sUserIcon, $sUserUnit, $sUserUnitWoInfo) = $this->_getAuthorInfo($aUser['id']);
 
@@ -287,7 +297,7 @@ class BxBaseView extends BxDolView
                 'bx_if:show_user_info' => array(
                     'condition' => (int)$aUser['id'] == 0 && (int)$aUser['count'] > 0,
                     'content' => array(
-                		'style_prefix' => $this->_sStylePrefix,
+                        'style_prefix' => $this->_sStylePrefix,
                         'user_info' => _t('_view_do_view_by_counter', $aUser['count'])
                     )
                 )
@@ -299,7 +309,8 @@ class BxBaseView extends BxDolView
 
         return $this->_oTemplate->parseHtmlByName($this->_sTmplNameByList, array(
             'style_prefix' => $this->_sStylePrefix,
-            'bx_repeat:list' => $aTmplUsers
+            'bx_repeat:list' => $aTmplUsers,
+            'paginate' => $oPaginate->getSimplePaginate()
         ));
     }
 }

+ 1 - 0
template/view_by_list.html

@@ -17,5 +17,6 @@
                 </div>
             </bx_repeat:list>
         </div>
+        <div class="__style_prefix__-by-paginate">__paginate__</div>
     </div>
 </div>