public function onItemRender(OW_Event $event) { $params = $event->getParams(); $data = $event->getData(); if ($params['action']['entityType'] != EQUESTIONS_BOL_Service::ENTITY_TYPE) { return; } $language = OW::getLanguage(); $configs = OW::getConfig()->getValues('equestions'); $questionId = $params['action']['entityId']; $userId = OW::getUser()->getId(); $question = $this->service->findQuestion($questionId); $optionTotal = $this->service->findOptionCount($questionId); $answerCount = $this->service->findTotalAnswersCount($questionId); $postCount = BOL_CommentService::getInstance()->findCommentCount(EQUESTIONS_BOL_Service::ENTITY_TYPE, $params['action']['entityId']); $userContext = array(); $count = EQUESTIONS_BOL_Service::DISPLAY_COUNT; if ($optionTotal - $count < 2) { $count = $optionTotal; } $cmp = new EQUESTIONS_CMP_Answers($question, $optionTotal, array(0, $count)); $cmp->setTotalAnswerCount($answerCount); if (in_array($params['feedType'], array('user', 'my'))) { foreach ($params['activity'] as $act) { if ($act['activityType'] == 'answer') { $userContext[] = $act['userId']; } } $cmp->setUsersContext($userContext); } $lastActivity = $this->getBubbleActivity($params); $data['assign']['answers'] = $cmp->render(); $questionUrl = OW::getRouter()->urlForRoute('equestions-question', array('qid' => $question->id)); $jsSelector = 'QUESTIONS_AnswerListCollection.' . $cmp->getUniqId(); $allowPopups = !isset($configs['allow_popups']) || $configs['allow_popups']; $data['assign']['string'] = $data['string'] = $this->getItemString($question, $lastActivity, $jsSelector, $questionUrl); $data['features'] = array(); $onClickStr = "window.location.href='{$questionUrl}'"; if ($configs['allow_comments']) { if ($allowPopups) { $onClickStr = "return {$jsSelector}.openQuestionDelegate(true);"; } $data['features'][] = array('class' => 'q-' . $cmp->getUniqId() . '-status-comments', 'iconClass' => 'ow_miniic_comment', 'label' => $postCount, 'onclick' => $onClickStr, 'string' => null); } if ($allowPopups) { $onClickStr = "return {$jsSelector}.openQuestionDelegate();"; } $data['features'][] = array('class' => 'q-' . $cmp->getUniqId() . '-status-votes', 'iconClass' => 'questions_miniicon_check', 'label' => $answerCount, 'onclick' => $onClickStr, 'string' => null); if ($configs['enable_follow']) { $onClickStr = "OW.error('" . $language->text('equestions', 'follow_not_allowed') . "')"; $isFollowing = false; if ($this->service->isCurrentUserCanInteract($question)) { $isFollowing = $this->service->isFollow($userId, $question->id); $onClickStr = $isFollowing ? $jsSelector . '.unfollowQuestion();' : $jsSelector . '.followQuestion();'; } else { if (OW::getUser()->isAuthenticated()) { $isFollowing = $this->service->isFollow($userId, $question->id); if ($isFollowing) { $onClickStr = $jsSelector . '.unfollowQuestion();'; } } } $data['features'][] = array('class' => 'q-' . $cmp->getUniqId() . '-status-follows', 'iconClass' => 'questions_miniic_follow', 'label' => $this->service->findFollowsCount($question->id), 'onclick' => $onClickStr, 'active' => $isFollowing); } $settings = $question->getSettings(); if (isset($settings['context']) && $settings['context']['type'] != $params['feedType']) { if (!empty($settings['context']['url']) && !empty($settings['context']['label'])) { $data['context'] = $settings['context']; } } $event->setData($data); }