BxBaseCmtsView.php 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537
  1. <?php
  2. /**
  3. * @package Dolphin Core
  4. * @copyright Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
  5. * @license CC-BY - http://creativecommons.org/licenses/by/3.0/
  6. */
  7. defined('BX_DOL') or die('hack attempt');
  8. bx_import('BxDolCmts');
  9. bx_import('BxDolProfile');
  10. bx_import('BxTemplPaginate');
  11. /**
  12. * @see BxDolCmts
  13. */
  14. class BxBaseCmtsView extends BxDolCmts {
  15. var $_sJsObjName;
  16. var $_sStylePrefix;
  17. function BxBaseCmtsView( $sSystem, $iId, $iInit = 1 ) {
  18. BxDolCmts::BxDolCmts( $sSystem, $iId, $iInit );
  19. if(empty($sSystem))
  20. return;
  21. $this->_sJsObjName = 'oCmts' . ucfirst($sSystem) . $iId;
  22. $this->_sStylePrefix = isset($this->_aSystem['root_style_prefix']) ? $this->_aSystem['root_style_prefix'] : 'cmt';
  23. BxDolTemplate::getInstance()->addJsTranslation('_sys_txt_cmt_loading');
  24. }
  25. /**
  26. * get full comments block with initializations
  27. */
  28. function getCommentsBlock($iParentId = 0) {
  29. $aBp = array('parent_id' => $iParentId);
  30. $sCmts = $this->getComments($aBp);
  31. return BxDolTemplate::getInstance()->parseHtmlByName('comments_block.html', array(
  32. 'system' => $this->_sSystem,
  33. 'id' => $this->getId(),
  34. 'bx_if:show_empty' => array(
  35. 'condition' => $sCmts == '',
  36. 'content' => array(
  37. 'style_prefix' => $this->_sStylePrefix
  38. )
  39. ),
  40. 'controls' => $this->_getControlsBox(),
  41. 'comments' => $sCmts,
  42. 'post_form_top' => $this->_getPostReplyBox($aBp, array('type' => $this->_sDisplayType, 'position' => BX_CMT_PFP_TOP)),
  43. 'post_form_bottom' => $this->_getPostReplyBox($aBp, array('type' => $this->_sDisplayType, 'position' => BX_CMT_PFP_BOTTOM)),
  44. 'script' => $this->getCmtsInit()
  45. ));
  46. }
  47. /**
  48. * get comments list for specified parent comment
  49. *
  50. * @param array $aBp - browse params array
  51. * @param array $aDp - display params array
  52. *
  53. */
  54. function getComments($aBp = array(), $aDp = array())
  55. {
  56. $this->_prepareParams($aBp, $aDp);
  57. $aCmts = $this->getCommentsArray($aBp['parent_id'], $aBp['order'], $aBp['start'], $aBp['per_view']);
  58. if(empty($aCmts) || !is_array($aCmts))
  59. return '';
  60. $sCmts = '';
  61. foreach($aCmts as $k => $r)
  62. $sCmts .= $this->getComment($r, $aDp);
  63. $sCmts = $this->_getMoreLink($sCmts, $aBp, $aDp);
  64. return $sCmts;
  65. }
  66. /**
  67. * get comment view block with initializations
  68. */
  69. function getCommentBlock($iCmtId = 0)
  70. {
  71. return BxDolTemplate::getInstance()->parseHtmlByName('comment_block.html', array(
  72. 'system' => $this->_sSystem,
  73. 'id' => $this->getId(),
  74. 'comment' => $this->getComment($iCmtId, array('type' => BX_CMT_DISPLAY_THREADED, 'opened' => true)),
  75. 'script' => $this->getCmtsInit()
  76. ));
  77. }
  78. /**
  79. * get one just posted comment
  80. *
  81. * @param int $iCmtId - comment id
  82. * @return string
  83. */
  84. function getComment($mixedCmt, $aDp = array())
  85. {
  86. $oTemplate = BxDolTemplate::getInstance();
  87. $iUserId = $this->_getAuthorId();
  88. $r = !is_array($mixedCmt) ? $this->getCommentRow((int)$mixedCmt) : $mixedCmt;
  89. list($sAuthorName, $sAuthorLink, $sAuthorIcon) = $this->_getAuthorInfo($r);
  90. $sClass = $sRet = '';
  91. if($r['cmt_rated'] == -1 || $r['cmt_rate'] < $this->_aSystem['viewing_threshold']) {
  92. $oTemplate->pareseHtmlByName('comment_hidden.html', array(
  93. 'js_object' => $this->_sJsObjName,
  94. 'id' => $r['cmt_id'],
  95. 'title' => bx_process_output(_t('_hidden_comment', $sAuthorName)),
  96. 'bx_if:show_replies' => array(
  97. 'condition' => $r['cmt_replies'] > 0,
  98. 'content' => array(
  99. 'replies' => _t('_Show N replies', $r['cmt_replies'])
  100. )
  101. )
  102. ));
  103. $sClass = ' cmt-hidden';
  104. }
  105. if($r['cmt_author_id'] == $iUserId)
  106. $sClass .= ' cmt-mine';
  107. $sActions = $this->_getActionsBox($r, $aDp);
  108. $sText = bx_process_output($r['cmt_text'], BX_DATA_TEXT_MULTILINE);
  109. $sTextMore = '';
  110. $iMaxLength = (int)$this->_aSystem['chars_display_max'];
  111. if(strlen($sText) > $iMaxLength) {
  112. $iLength = strpos($sText, ' ', $iMaxLength);
  113. $sTextMore = substr($sText, $iLength);
  114. $sText = substr($sText, 0, $iLength);
  115. }
  116. $aTmplReplyTo = array();
  117. if((int)$r['cmt_parent_id'] != 0) {
  118. $aParent = $this->getCommentRow($r['cmt_parent_id']);
  119. list($sParAuthorName, $sParAuthorLink, $sParAuthorIcon) = $this->_getAuthorInfo($aParent);
  120. $aTmplReplyTo = array(
  121. 'style_prefix' => $this->_sStylePrefix,
  122. 'par_cmt_link' => $this->_sHomeUrl. '#' . $this->_sSystem . $r['cmt_parent_id'],
  123. 'par_cmt_author' => $sParAuthorName
  124. );
  125. }
  126. $sReplies = '';
  127. if((int)$r['cmt_replies'] > 0 && !empty($aDp) && $aDp['type'] == BX_CMT_DISPLAY_THREADED && $aDp['opened'])
  128. $sReplies = $this->getComments(array('parent_id' => $r['cmt_id']));
  129. return $oTemplate->parseHtmlByName('comment.html', array(
  130. 'system' => $this->_sSystem,
  131. 'style_prefix' => $this->_sStylePrefix,
  132. 'id' => $r['cmt_id'],
  133. 'class' => $sClass,
  134. 'margin' => $this->_getLevelGap($r, $aDp),
  135. 'author_icon' => $sAuthorIcon,
  136. 'bx_if:show_author_link' => array(
  137. 'condition' => !empty($sAuthorLink),
  138. 'content' => array(
  139. 'author_link' => $sAuthorLink,
  140. 'author_name' => $sAuthorName
  141. )
  142. ),
  143. 'bx_if:show_author_text' => array(
  144. 'condition' => empty($sAuthorLink),
  145. 'content' => array(
  146. 'author_name' => $sAuthorName
  147. )
  148. ),
  149. 'bx_if:show_reply_to' => array(
  150. 'condition' => !empty($aTmplReplyTo),
  151. 'content' => $aTmplReplyTo
  152. ),
  153. 'text' => $sText,
  154. 'bx_if:show_more' => array(
  155. 'condition' => !empty($sTextMore),
  156. 'content' => array(
  157. 'js_object' => $this->_sJsObjName,
  158. 'text_more' => $sTextMore
  159. )
  160. ),
  161. 'actions' => $sActions,
  162. 'replies' => $sReplies
  163. ));
  164. }
  165. function getFormBox($aBp = array(), $aDp = array())
  166. {
  167. return $this->_getPostReplyBox($aBp, $aDp);
  168. }
  169. function getForm($iCmtParentId, $sText, $sFunction)
  170. {
  171. return $this->_getPostReplyForm($iCmtParentId, $sText, $sFunction);
  172. }
  173. /**
  174. * Get comments css file string
  175. *
  176. * @return string
  177. */
  178. function getExtraCss ()
  179. {
  180. BxDolTemplate::getInstance()->addCss('cmts.css');
  181. }
  182. /**
  183. * Get comments js file string
  184. *
  185. * @return string
  186. */
  187. function getExtraJs ()
  188. {
  189. BxDolTemplate::getInstance()->addJs(array('common_anim.js', 'BxDolCmts.js'));
  190. }
  191. /**
  192. * Get initialization section of comments box
  193. *
  194. * @return string
  195. */
  196. function getCmtsInit()
  197. {
  198. $sToggleAdd = '';
  199. $ret = '';
  200. $ret .= $sToggleAdd . "
  201. <script type=\"text/javascript\">
  202. var " . $this->_sJsObjName . " = new BxDolCmts({
  203. sObjName: '" . $this->_sJsObjName . "',
  204. sBaseUrl: '" . BX_DOL_URL_ROOT . "',
  205. sSystem: '" . $this->getSystemName() . "',
  206. sSystemTable: '" . $this->_aSystem['table_cmts'] . "',
  207. iAuthorId: '" . $this->_getAuthorId() . "',
  208. iObjId: '" . $this->getId () . "',
  209. sOrder: '" . $this->getOrder() . "',
  210. sPostFormPosition: '" . $this->_aSystem['post_form_position'] . "',
  211. sBrowseType: '" . $this->_sBrowseType . "',
  212. sDisplayType: '" . $this->_sDisplayType . "'});
  213. " . $this->_sJsObjName . ".oCmtElements = {";
  214. for (reset($this->_aCmtElements); list($k,$r) = each ($this->_aCmtElements); ) {
  215. $ret .= "\n'$k' : { 'reg' : '{$r['reg']}', 'msg' : \"". bx_js_string(trim($r['msg'])) . "\" },";
  216. }
  217. $ret = substr($ret, 0, -1);
  218. $ret .= "\n};\n";
  219. $ret .= "</script>";
  220. $this->getExtraJs();
  221. $this->getExtraCss();
  222. BxDolTemplate::getInstance()->addJsTranslation(array(
  223. '_Error occured',
  224. '_Are you sure?'
  225. ));
  226. return $ret;
  227. }
  228. /**
  229. * private functions
  230. */
  231. function _getControlsBox()
  232. {
  233. $oTemplate = BxDolTemplate::getInstance();
  234. $sDisplay = '';
  235. $bDisplay = (int)$this->_aSystem['is_display_switch'] == 1;
  236. if($bDisplay) {
  237. $aDisplayLinks = array(
  238. array('id' => $this->_sSystem . '-flat', 'name' => $this->_sSystem . '-flat', 'class' => '', 'title' => '_cmt_display_flat', 'target' => '_self', 'onclick' => 'javascript:' . $this->_sJsObjName . '.cmtChangeDisplay(this, \'flat\');'),
  239. array('id' => $this->_sSystem . '-threaded', 'name' => $this->_sSystem . '-threaded', 'class' => '', 'title' => '_cmt_display_threaded', 'target' => '_self', 'onclick' => 'javascript:' . $this->_sJsObjName . '.cmtChangeDisplay(this, \'threaded\');')
  240. );
  241. bx_import('BxTemplMenuInteractive');
  242. $oMenu = new BxTemplMenuInteractive(array('template' => 'menu_interactive.html', 'menu_id'=> $this->_sSystem . '-display', 'menu_items' => $aDisplayLinks));
  243. $oMenu->setSelected('', $this->_sSystem . '-' . $this->_sDisplayType);
  244. $sDisplay = $oMenu->getCode();
  245. }
  246. $sBrowse = '';
  247. $bBrowse = (int)$this->_aSystem['is_browse_switch'] == 1;
  248. if($bBrowse) {
  249. $aBrowseLinks = array(
  250. array('id' => $this->_sSystem . '-tail', 'name' => $this->_sSystem . '-tail', 'class' => '', 'title' => '_cmt_browse_tail', 'target' => '_self', 'onclick' => 'javascript:' . $this->_sJsObjName . '.cmtChangeBrowse(this, \'tail\');'),
  251. array('id' => $this->_sSystem . '-head', 'name' => $this->_sSystem . '-head', 'class' => '', 'title' => '_cmt_browse_head', 'target' => '_self', 'onclick' => 'javascript:' . $this->_sJsObjName . '.cmtChangeBrowse(this, \'head\');'),
  252. array('id' => $this->_sSystem . '-popular', 'name' => $this->_sSystem . '-popular', 'class' => '', 'title' => '_cmt_browse_popular', 'target' => '_self', 'onclick' => 'javascript:' . $this->_sJsObjName . '.cmtChangeBrowse(this, \'popular\');'),
  253. array('id' => $this->_sSystem . '-connection', 'name' => $this->_sSystem . '-connection', 'class' => '', 'title' => '_cmt_browse_connection', 'target' => '_self', 'onclick' => 'javascript:' . $this->_sJsObjName . '.cmtChangeBrowse(this, \'connection\');')
  254. );
  255. bx_import('BxTemplMenuInteractive');
  256. $oMenu = new BxTemplMenuInteractive(array('template' => 'menu_interactive.html', 'menu_id'=> $this->_sSystem . '-browse', 'menu_items' => $aBrowseLinks));
  257. $oMenu->setSelected('', $this->_sSystem . '-' . $this->_sBrowseType);
  258. $sBrowse = $oMenu->getCode();
  259. }
  260. return $oTemplate->parseHtmlByName('comments_controls.html', array(
  261. 'js_object' => $this->_sJsObjName,
  262. 'style_prefix' => $this->_sStylePrefix,
  263. 'comments_count' => _t('_N_comments', $this->_oQuery->getCommentsCount($this->_iId)),
  264. 'display_switcher' => $bDisplay ? $sDisplay : '',
  265. 'bx_if:is_divider' => array(
  266. 'condition' => $bDisplay && $bBrowse,
  267. 'content' => array(
  268. 'style_prefix' => $this->_sStylePrefix,
  269. )
  270. ),
  271. 'browse_switcher' => $bBrowse ? $sBrowse : '',
  272. ));
  273. }
  274. function _getActionsBox(&$a, $aDp = array())
  275. {
  276. $iUserId = $this->_getAuthorId();
  277. $isEditAllowedPermanently = ($a['cmt_author_id'] == $iUserId && $this->isEditAllowed()) || $this->isEditAllowedAll();
  278. $isRemoveAllowedPermanently = ($a['cmt_author_id'] == $iUserId && $this->isRemoveAllowed()) || $this->isRemoveAllowedAll();
  279. return BxDolTemplate::getInstance()->parseHtmlByName('comment_actions.html', array(
  280. 'id' => $a['cmt_id'],
  281. 'style_prefix' => $this->_sStylePrefix,
  282. 'view_link' => bx_append_url_params($this->_sViewUrl, array(
  283. 'sys' => $this->_sSystem,
  284. 'id' => $this->_iId,
  285. 'cmt_id' => $a['cmt_id']
  286. )),
  287. 'ago' => $a['cmt_ago'],
  288. 'points' => _t($a['cmt_rate'] == 1 || $a['cmt_rate'] == -1 ? '_N_point' : '_N_points', $a['cmt_rate']),
  289. 'bx_if:show_reply' => array(
  290. 'condition' => $this->isPostReplyAllowed(),
  291. 'content' => array(
  292. 'js_object' => $this->_sJsObjName,
  293. 'style_prefix' => $this->_sStylePrefix,
  294. 'id' => $a['cmt_id'],
  295. 'text' => _t(isset($a['cmt_type']) && $a['cmt_type'] == 'comment' ? '_Comment_to_this_comment' : '_Reply_to_this_comment')
  296. )
  297. ),
  298. 'bx_if:show_rate' => array(
  299. 'condition' => $this->isRatable(),
  300. 'content' => array(
  301. 'js_object' => $this->_sJsObjName,
  302. 'style_prefix' => $this->_sStylePrefix,
  303. 'id' => $a['cmt_id']
  304. )
  305. ),
  306. 'bx_if:show_replies' => array(
  307. 'condition' => (int)$a['cmt_replies'] > 0 && !empty($aDp) && $aDp['type'] == BX_CMT_DISPLAY_THREADED && !$aDp['opened'],
  308. 'content' => array(
  309. 'js_object' => $this->_sJsObjName,
  310. 'style_prefix' => $this->_sStylePrefix,
  311. 'id' => $a['cmt_id'],
  312. 'text' => _t((isset($a['cmt_type']) && $a['cmt_type'] == 'comment' ? '_N_comments' : '_N_replies'), $a['cmt_replies'])
  313. )
  314. ),
  315. 'bx_if:show_edit' => array(
  316. 'condition' => $isEditAllowedPermanently,
  317. 'content' => array(
  318. 'js_object' => $this->_sJsObjName,
  319. 'style_prefix' => $this->_sStylePrefix,
  320. 'id' => $a['cmt_id']
  321. )
  322. ),
  323. 'bx_if:show_delete' => array(
  324. 'condition' => $isRemoveAllowedPermanently,
  325. 'content' => array(
  326. 'js_object' => $this->_sJsObjName,
  327. 'style_prefix' => $this->_sStylePrefix,
  328. 'id' => $a['cmt_id']
  329. )
  330. ),
  331. ));
  332. }
  333. function _getPostReplyBox($aBp, $aDp)
  334. {
  335. $iCmtParentId = isset($aBp['parent_id']) ? (int)$aBp['parent_id'] : 0;
  336. $sPosition = isset($aDp['position']) ? $aDp['position'] : '';
  337. if(!$this->isPostReplyAllowed())
  338. return '';
  339. bx_import('BxDolProfile');
  340. $oProfile = BxDolProfile::getInstanceAccountProfile($this->_getAuthorId());
  341. $sPositionSystem = $this->_aSystem['post_form_position'];
  342. if(!empty($sPosition) && $sPositionSystem != BX_CMT_PFP_BOTH && $sPositionSystem != $sPosition)
  343. return '';
  344. return BxDolTemplate::getInstance()->parseHtmlByName('comment_reply_box.html', array(
  345. 'style_prefix' => $this->_sStylePrefix,
  346. 'margin' => $this->_getLevelGapByParent($iCmtParentId, $aDp),
  347. 'bx_if:show_class' => array(
  348. 'condition' => !empty($sPosition),
  349. 'content' => array(
  350. 'class' => $this->_sStylePrefix . '-reply-' . $sPosition
  351. )
  352. ),
  353. 'author_icon' => $oProfile->getThumb(),
  354. 'form' => $this->_getPostReplyForm($iCmtParentId)
  355. ));
  356. }
  357. function _getPostReplyForm($iCmtParentId = 0, $sText = "", $sFunction = "cmtSubmit(this)")
  358. {
  359. return BxDolTemplate::getInstance()->parseHtmlByName('comment_reply_form.html', array(
  360. 'js_object' => $this->_sJsObjName,
  361. 'js_function' => $sFunction,
  362. 'parent_id' => $iCmtParentId,
  363. 'text' => bx_process_output($sText)
  364. ));
  365. }
  366. function _getMoreLink($sCmts, $aBp = array(), $aDp = array())
  367. {
  368. $iStart = $iPerView = 0;
  369. switch($aBp['type']) {
  370. case BX_CMT_BROWSE_HEAD:
  371. $iPerView = $aBp['per_view'];
  372. $iStart = $aBp['start'] + $iPerView;
  373. if($iStart >= $aBp['count'])
  374. return $sCmts;
  375. break;
  376. case BX_CMT_BROWSE_TAIL:
  377. $iPerView = $aBp['per_view'];
  378. $iStart = $aBp['start'] - $iPerView;
  379. if($iStart < 0) {
  380. $iPerView += $iStart;
  381. $iStart = 0;
  382. }
  383. if($iStart == 0 && $iPerView == 0)
  384. return $sCmts;
  385. break;
  386. }
  387. $sMore = BxDolTemplate::getInstance()->parseHtmlByName('comment_more.html', array(
  388. 'js_object' => $this->_sJsObjName,
  389. 'style_prefix' => $this->_sStylePrefix,
  390. 'margin' => $this->_getLevelGapByParent($aBp['parent_id'], $aDp),
  391. 'parent_id' => $aBp['parent_id'],
  392. 'start' => $iStart,
  393. 'per_view' => $iPerView
  394. ));
  395. switch($aBp['type']) {
  396. case BX_CMT_BROWSE_HEAD:
  397. $sCmts .= $sMore;
  398. break;
  399. case BX_CMT_BROWSE_TAIL:
  400. $sCmts = $sMore . $sCmts;
  401. break;
  402. }
  403. return $sCmts;
  404. }
  405. function _getLevelGap($a, $aDp = array())
  406. {
  407. if($aDp['type'] != BX_CMT_DISPLAY_THREADED || !is_array($a) || !isset($a['cmt_level']))
  408. return 0;
  409. return 84 * ((int)$a['cmt_level'] <= $this->_iDpMaxLevel ? (int)$a['cmt_level'] : $this->_iDpMaxLevel);
  410. }
  411. function _getLevelGapByParent($iParentId, $aDp = array()) {
  412. if($aDp['type'] != BX_CMT_DISPLAY_THREADED || (int)$iParentId == 0)
  413. return 0;
  414. $a = $this->getCommentRow($iParentId);
  415. if(isset($a['cmt_level']))
  416. $a['cmt_level'] += 1;
  417. return $this->_getLevelGap($a, $aDp);
  418. }
  419. function _getAuthorInfo($r)
  420. {
  421. $sAuthorName = _t('_Anonymous');
  422. $sAuthorLink = '';
  423. $sAuthorIcon = '';
  424. if((int)$r['cmt_author_id'] != 0) {
  425. $oProfile = BxDolProfile::getInstanceAccountProfile($r['cmt_author_id']);
  426. $sAuthorName = $oProfile->getDisplayName();
  427. $sAuthorLink = $oProfile->getUrl();
  428. $sAuthorIcon = $oProfile->getThumb();
  429. }
  430. return array($sAuthorName, $sAuthorLink, $sAuthorIcon);
  431. }
  432. function _prepareParams(&$aBp, &$aDp)
  433. {
  434. $aBp['type'] = isset($aBp['type']) && !empty($aBp['type']) ? $aBp['type'] : $this->_sBrowseType;
  435. $aBp['parent_id'] = isset($aBp['parent_id']) ? $aBp['parent_id'] : 0;
  436. $aBp['start'] = isset($aBp['start']) ? $aBp['start'] : -1;
  437. $aBp['per_view'] = isset($aBp['per_view']) ? $aBp['per_view'] : -1;
  438. $aBp['order'] = isset($aBp['order']) ? $aBp['order'] : $this->_sOrder;
  439. $aDp['type'] = isset($aDp['type']) && !empty($aDp['type']) ? $aDp['type'] : $this->_sDisplayType;
  440. $aDp['opened'] = isset($aDp['opened']) ? $aDp['opened'] : $this->_bDpOpened;
  441. switch($aDp['type']) {
  442. case BX_CMT_DISPLAY_FLAT:
  443. $aBp['parent_id'] = -1;
  444. $aBp['per_view'] = $aBp['per_view'] != -1 ? $aBp['per_view'] : $this->getPerView(0);
  445. break;
  446. case BX_CMT_DISPLAY_THREADED:
  447. $aBp['per_view'] = $aBp['per_view'] != -1 ? $aBp['per_view'] : $this->getPerView($aBp['parent_id']);
  448. break;
  449. }
  450. $aBp['count'] = $this->_oQuery->getCommentsCount($this->_iId, $aBp['parent_id']);
  451. if($aBp['start'] != -1)
  452. return;
  453. $aBp['start'] = 0;
  454. if($aBp['type'] == BX_CMT_BROWSE_TAIL) {
  455. $aBp['start'] = $aBp['count'] - $aBp['per_view'];
  456. if($aBp['start'] < 0) {
  457. $aBp['per_view'] += $aBp['start'];
  458. $aBp['start'] = 0;
  459. }
  460. }
  461. }
  462. }