protected function init() { if ($this->commentCount === 0 && $this->params->getShowEmptyList()) { $this->assign('noComments', true); } $countToLoad = 0; if ($this->commentCount === 0) { $commentList = array(); } else { if (in_array($this->params->getDisplayType(), array(BASE_CommentsParams::DISPLAY_TYPE_WITH_LOAD_LIST, BASE_CommentsParams::DISPLAY_TYPE_WITH_LOAD_LIST_MINI))) { $commentList = empty($this->batchData['commentsList']) ? $this->commentService->findCommentList($this->params->getEntityType(), $this->params->getEntityId(), 1, $this->params->getInitialCommentsCount()) : $this->batchData['commentsList']; $commentList = array_reverse($commentList); $countToLoad = $this->commentCount - $this->params->getInitialCommentsCount(); $this->assign('countToLoad', $countToLoad); } else { $commentList = $this->commentService->findCommentList($this->params->getEntityType(), $this->params->getEntityId(), $this->page, $this->params->getCommentCountOnPage()); } } OW::getEventManager()->trigger(new OW_Event('base.comment_list_prepare_data', array('list' => $commentList, 'entityType' => $this->params->getEntityType(), 'entityId' => $this->params->getEntityId()))); OW::getEventManager()->bind('base.comment_item_process', array($this, 'itemHandler')); $this->assign('comments', $this->processList($commentList)); $pages = false; if ($this->params->getDisplayType() === BASE_CommentsParams::DISPLAY_TYPE_WITH_PAGING) { $pagesCount = $this->commentService->findCommentPageCount($this->params->getEntityType(), $this->params->getEntityId(), $this->params->getCommentCountOnPage()); if ($pagesCount > 1) { $pages = $this->getPages($this->page, $pagesCount, 8); $this->assign('pages', $pages); } } else { $pagesCount = 0; } $this->assign('loadMoreLabel', OW::getLanguage()->text('base', 'comment_load_more_label')); static $dataInit = false; if (!$dataInit) { $staticDataArray = array('respondUrl' => OW::getRouter()->urlFor('BASE_CTRL_Comments', 'getCommentList'), 'delUrl' => OW::getRouter()->urlFor('BASE_CTRL_Comments', 'deleteComment'), 'delAtchUrl' => OW::getRouter()->urlFor('BASE_CTRL_Comments', 'deleteCommentAtatchment'), 'delConfirmMsg' => OW::getLanguage()->text('base', 'comment_delete_confirm_message'), 'preloaderImgUrl' => OW::getThemeManager()->getCurrentTheme()->getStaticImagesUrl() . 'ajax_preloader_button.gif'); OW::getDocument()->addOnloadScript("window.owCommentListCmps.staticData=" . json_encode($staticDataArray) . ";"); $dataInit = true; } $jsParams = json_encode(array('totalCount' => $this->commentCount, 'contextId' => $this->cmpContextId, 'displayType' => $this->params->getDisplayType(), 'entityType' => $this->params->getEntityType(), 'entityId' => $this->params->getEntityId(), 'pagesCount' => $pagesCount, 'initialCount' => $this->params->getInitialCommentsCount(), 'loadMoreCount' => $this->params->getLoadMoreCount(), 'commentIds' => $this->commentIdList, 'pages' => $pages, 'pluginKey' => $this->params->getPluginKey(), 'ownerId' => $this->params->getOwnerId(), 'commentCountOnPage' => $this->params->getCommentCountOnPage(), 'cid' => $this->id, 'actionArray' => $this->actionArr, 'countToLoad' => $countToLoad)); OW::getDocument()->addOnloadScript("window.owCommentListCmps.items['{$this->id}'] = new OwCommentsList({$jsParams});\n window.owCommentListCmps.items['{$this->id}'].init();"); }