Esempio n. 1
0
 public function __construct(BASE_CommentsParams $params, $id, $formName)
 {
     parent::__construct();
     $language = OW::getLanguage();
     $form = new Form($formName);
     $textArea = new Textarea('commentText');
     $textArea->setHasInvitation(true);
     $textArea->setInvitation($language->text('base', 'comment_form_element_invitation_text'));
     $form->addElement($textArea);
     $hiddenEls = array('entityType' => $params->getEntityType(), 'entityId' => $params->getEntityId(), 'displayType' => $params->getDisplayType(), 'pluginKey' => $params->getPluginKey(), 'ownerId' => $params->getOwnerId(), 'cid' => $id, 'commentCountOnPage' => $params->getCommentCountOnPage(), 'isMobile' => 1);
     foreach ($hiddenEls as $name => $value) {
         $el = new HiddenField($name);
         $el->setValue($value);
         $form->addElement($el);
     }
     $submit = new Submit('comment-submit');
     $submit->setValue($language->text('base', 'comment_add_submit_label'));
     $form->addElement($submit);
     $form->setAjax(true);
     $form->setAction(OW::getRouter()->urlFor('BASE_CTRL_Comments', 'addComment'));
     //        $form->bindJsFunction(Form::BIND_SUBMIT, "function(){ $('#comments-" . $id . " .comments-preloader').show();}");
     //        $form->bindJsFunction(Form::BIND_SUCCESS, "function(){ $('#comments-" . $id . " .comments-preloader').hide();}");
     $this->addForm($form);
     OW::getDocument()->addOnloadScript("window.owCommentCmps['{$id}'].initForm('" . $textArea->getId() . "', '" . $submit->getId() . "');");
     $this->assign('form', true);
     $this->assign('id', $id);
 }
Esempio n. 2
0
 public function initForm()
 {
     if ($this->isAuthorized) {
         $countOnPage = isset($this->batchData['countOnPage']) ? $this->batchData['countOnPage'] : $this->params->getCommentCountOnPage();
         $formCmpParams = array($this->params->getEntityType(), $this->params->getEntityId(), $this->params->getDisplayType(), $this->params->getPluginKey(), $this->params->getOwnerId(), 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)) ? $countOnPage + 1 : $countOnPage, $this->id, $this->cmpContextId, $this->formName);
         OW::getDocument()->addOnloadScript("window.owCommentCmps['{$this->id}'] = new OwComments('{$this->cmpContextId}', '{$this->formName}', '{$this->id}', " . json_encode($formCmpParams) . ");\n                    \$('.comments_fake_autoclick', \$('#{$this->cmpContextId}')).one('focus', function(){window.owCommentCmps['{$this->id}'].loadForm();});");
         $this->assign('formCmp', true);
         if (!empty($this->staticData['currentUserInfo'])) {
             $userInfoToAssign = $this->staticData['currentUserInfo'];
         } else {
             $currentUserInfo = BOL_AvatarService::getInstance()->getDataForUserAvatars(array(OW::getUser()->getId()));
             $userInfoToAssign = $currentUserInfo[OW::getUser()->getId()];
         }
         $this->assign('currentUserInfo', $userInfoToAssign);
     }
     $this->assign('displayType', $this->params->getDisplayType());
     // add comment list cmp
     $this->addComponent('commentList', new BASE_CMP_CommentsList($this->params, $this->id));
 }
Esempio n. 3
0
 public function initForm()
 {
     $jsParams = array('entityType' => $this->params->getEntityType(), 'entityId' => $this->params->getEntityId(), 'pluginKey' => $this->params->getPluginKey(), 'contextId' => $this->cmpContextId, 'userAuthorized' => $this->isAuthorized, 'customId' => $this->params->getCustomId());
     if ($this->isAuthorized) {
         OW::getDocument()->addScript(OW::getPluginManager()->getPlugin('base')->getStaticJsUrl() . 'jquery.autosize.js');
         $taId = 'cta' . $this->id;
         $attchId = 'attch' . $this->id;
         $attchUid = BOL_CommentService::getInstance()->generateAttachmentUid($this->params->getEntityType(), $this->params->getEntityId());
         $jsParams['ownerId'] = $this->params->getOwnerId();
         $jsParams['cCount'] = isset($this->batchData['countOnPage']) ? $this->batchData['countOnPage'] : $this->params->getCommentCountOnPage();
         $jsParams['initialCount'] = $this->params->getInitialCommentsCount();
         $jsParams['loadMoreCount'] = $this->params->getLoadMoreCount();
         $jsParams['countOnPage'] = $this->params->getCommentCountOnPage();
         $jsParams['uid'] = $this->id;
         $jsParams['addUrl'] = OW::getRouter()->urlFor('BASE_CTRL_Comments', 'addComment');
         $jsParams['displayType'] = $this->params->getDisplayType();
         $jsParams['textAreaId'] = $taId;
         $jsParams['attchId'] = $attchId;
         $jsParams['attchUid'] = $attchUid;
         $jsParams['enableSubmit'] = true;
         $jsParams['mediaAllowed'] = BOL_TextFormatService::getInstance()->isCommentsRichMediaAllowed();
         $jsParams['labels'] = array('emptyCommentMsg' => OW::getLanguage()->text('base', 'empty_comment_error_msg'), 'disabledSubmit' => OW::getLanguage()->text('base', 'submit_disabled_error_msg'), 'attachmentLoading' => OW::getLanguage()->text('base', 'submit_attachment_not_loaded'));
         if (!empty($this->staticData['currentUserInfo'])) {
             $userInfoToAssign = $this->staticData['currentUserInfo'];
         } else {
             $currentUserInfo = BOL_AvatarService::getInstance()->getDataForUserAvatars(array(OW::getUser()->getId()));
             $userInfoToAssign = $currentUserInfo[OW::getUser()->getId()];
         }
         $buttonContId = 'bCcont' . $this->id;
         if (BOL_TextFormatService::getInstance()->isCommentsRichMediaAllowed()) {
             $this->addComponent('attch', new BASE_CLASS_Attachment($this->params->getPluginKey(), $attchUid, $buttonContId));
         }
         $this->assign('buttonContId', $buttonContId);
         $this->assign('currentUserInfo', $userInfoToAssign);
         $this->assign('formCmp', true);
         $this->assign('taId', $taId);
         $this->assign('attchId', $attchId);
     }
     OW::getDocument()->addOnloadScript("new OwComments(" . json_encode($jsParams) . ");");
     $this->assign('displayType', $this->params->getDisplayType());
     // add comment list cmp
     $this->addComponent('commentList', new BASE_CMP_CommentsList($this->params, $this->id));
 }
Esempio n. 4
0
 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();");
 }