protected function init() { if ($this->commentCount === 0 && $this->params->getDisplayType() !== BASE_CommentsParams::DISPLAY_TYPE_BOTTOM_FORM_WITH_PARTIAL_LIST_AND_MINI_IPC) { $this->assign('noComments', true); } if ($this->commentCount === 0) { $commentList = array(); } else { if ($this->params->getDisplayType() === BASE_CommentsParams::DISPLAY_TYPE_BOTTOM_FORM_WITH_FULL_LIST) { $commentList = $this->commentService->findFullCommentList($this->params->getEntityType(), $this->params->getEntityId()); } else { if (in_array($this->params->getDisplayType(), array(BASE_CommentsParams::DISPLAY_TYPE_BOTTOM_FORM_WITH_PARTIAL_LIST, BASE_CommentsParams::DISPLAY_TYPE_BOTTOM_FORM_WITH_PARTIAL_LIST_AND_MINI_IPC))) { $commentList = empty($this->batchData['commentsList']) ? $this->commentService->findCommentList($this->params->getEntityType(), $this->params->getEntityId(), 1, $this->params->getCommentCountOnPage()) : $this->batchData['commentsList']; $commentList = array_reverse($commentList); if ($this->commentCount > $this->params->getCommentCountOnPage()) { $this->assign('viewAllLink', OW::getLanguage()->text('base', 'comment_view_all', array('count' => $this->commentCount))); } } 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))); 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_TOP_FORM_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; } 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, 'commentIds' => $this->commentIdList, 'pages' => $pages, 'pluginKey' => $this->params->getPluginKey(), 'ownerId' => $this->params->getOwnerId(), 'commentCountOnPage' => $this->params->getCommentCountOnPage(), 'cid' => $this->id, 'actionArray' => $this->actionArr)); OW::getDocument()->addOnloadScript("window.owCommentListCmps.items['{$this->id}'] = new OwCommentsList({$jsParams});\n window.owCommentListCmps.items['{$this->id}'].init();"); }