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

Ticket #3946 - Timeline: Comments: wrong per_page value

AntonLV 4 лет назад
Родитель
Сommit
0fc5a6fe24

+ 6 - 2
inc/classes/BxDolCmts.php

@@ -1928,6 +1928,7 @@ class BxDolCmts extends BxDolFactory implements iBxDolReplaceable, iBxDolContent
         $aBp['filter'] = !empty($aBp['filter']) ? $aBp['filter'] : $this->_sBrowseFilter;
         $aBp['parent_id'] = isset($aBp['parent_id']) ? $aBp['parent_id'] : 0;
         $aBp['start'] = isset($aBp['start']) ? $aBp['start'] : -1;
+        $aBp['init_view'] = isset($aBp['init_view']) ? $aBp['init_view'] : -1;
         $aBp['per_view'] = isset($aBp['per_view']) ? $aBp['per_view'] : -1;
         $aBp['order']['by'] = isset($aBp['order_by']) ? $aBp['order_by'] : $this->_aOrder['by'];
         $aBp['order']['way'] = isset($aBp['order_way']) ? $aBp['order_way'] : $this->_aOrder['way'];
@@ -1950,6 +1951,7 @@ class BxDolCmts extends BxDolFactory implements iBxDolReplaceable, iBxDolContent
         $aBp['filter'] = !empty($aBp['filter']) ? $aBp['filter'] : $this->_sBrowseFilter;
         $aBp['parent_id'] = isset($aBp['parent_id']) ? $aBp['parent_id'] : 0;
         $aBp['start'] = isset($aBp['start']) ? $aBp['start'] : -1;
+        $aBp['init_view'] = isset($aBp['init_view']) ? $aBp['init_view'] : -1;
         $aBp['per_view'] = isset($aBp['per_view']) ? $aBp['per_view'] : -1;
         $aBp['pinned'] = isset($aBp['pinned']) ? (int)$aBp['pinned'] : 0;
         $aBp['order']['by'] = isset($aBp['order_by']) ? $aBp['order_by'] : $this->_aOrder['by'];
@@ -1997,9 +1999,11 @@ class BxDolCmts extends BxDolFactory implements iBxDolReplaceable, iBxDolContent
 
         $aBp['start'] = 0;
         if($aBp['type'] == BX_CMT_BROWSE_TAIL) {
-            $aBp['start'] = $aBp['count'] - $aBp['per_view'];
+            $sPerView = ($aBp['init_view'] != -1 ? 'init' : 'per') . '_view';
+
+            $aBp['start'] = $aBp['count'] - $aBp[$sPerView];
             if($aBp['start'] < 0) {
-                $aBp['per_view'] += $aBp['start'];
+                $aBp[$sPerView] += $aBp['start'];
                 $aBp['start'] = 0;
             }
         }

+ 1 - 1
modules/boonex/timeline/classes/BxTimelineTemplate.php

@@ -978,7 +978,7 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
 
         $aCmtsBp = array();
         if(!empty($aBrowseParams['cmts_preload_number']))
-            $aCmtsBp['per_view'] = $aBrowseParams['cmts_preload_number'];
+            $aCmtsBp['init_view'] = $aBrowseParams['cmts_preload_number'];
 
         $aCmtsDp = array(
             'in_designbox' => false, 

+ 2 - 2
template/scripts/BxBaseCmts.php

@@ -216,7 +216,7 @@ class BxBaseCmts extends BxDolCmts
     {
         $this->_prepareParams($aBp, $aDp);
 
-        $aCmts = $this->getCommentsArray($aBp['vparent_id'], $aBp['filter'], $aBp['order'], $aBp['start'], $aBp['per_view']);
+        $aCmts = $this->getCommentsArray($aBp['vparent_id'], $aBp['filter'], $aBp['order'], $aBp['start'], $aBp[($aBp['init_view'] != -1 ? 'init' : 'per') . '_view']);
         if(empty($aCmts) || !is_array($aCmts)) {
             if((int)$aBp['parent_id'] == 0 && !isLogged()) {
                 $oPermalink = BxDolPermalinks::getInstance();
@@ -256,7 +256,7 @@ class BxBaseCmts extends BxDolCmts
 
         $aBp['count'] = count($aDp['structure']);
         $this->_prepareParams($aBp, $aDp);
-        $aDp['structure'] = array_slice($aDp['structure'], $aBp['start'], $aBp['per_view'], true);
+        $aDp['structure'] = array_slice($aDp['structure'], $aBp['start'], $aBp[($aBp['init_view'] != -1 ? 'init' : 'per') . '_view'], true);
 
         $sCmts = '';
         foreach($aDp['structure'] as $iCmtId => $aCmt)