示例#1
0
 protected function getFeatures($data)
 {
     $configs = $this->sharedData['configs'];
     $feturesData = $this->getFeaturesData($data);
     $featureDefaults = array("uniqId" => uniqid("nf-feature-"), "class" => "", "active" => false, "count" => null, "error" => null, "url" => "javascript://", "hideButton" => false, "innerHtml" => null, "html" => null);
     $features = array();
     $js = UTIL_JsGenerator::newInstance();
     // Likes
     if (!empty($feturesData["system"]["likes"])) {
         $feature = $feturesData["system"]["likes"];
         $features["likes"] = array_merge($featureDefaults, array("uniqId" => uniqid("nf-feature-"), "class" => "owm_newsfeed_control_like", "active" => $feature["liked"], "count" => $feature["count"], "error" => $feature["error"], "url" => "javascript://"));
         $js->newObject("likeFeature", "NEWSFEED_MobileFeatureLikes", array($feature["entityType"], $feature["entityId"], $features["likes"]));
     }
     // Comments
     if (!empty($feturesData["system"]["comments"])) {
         $feature = $feturesData["system"]["comments"];
         $comments = array_merge($featureDefaults, array("uniqId" => uniqid("nf-feature-"), "class" => "owm_newsfeed_control_comment", "active" => false, "count" => $feature["count"], "url" => OW::getRequest()->buildUrlQueryString($this->itemPermalink, array(), "comments")));
         if ($this->displayType == NEWSFEED_MCMP_Feed::DISPLAY_TYPE_PAGE) {
             $comments["hideButton"] = true;
             $commentsParams = new BASE_CommentsParams($feature["authGroup"], $feature["entityType"]);
             $commentsParams->setEntityId($feature["entityId"]);
             $commentsParams->setCommentCountOnPage($configs['comments_count']);
             $commentsParams->setBatchData($feature["comments"]);
             //$commentsParams->setDisplayType(BASE_CommentsParams::DISPLAY_TYPE_BOTTOM_FORM_WITH_PARTIAL_LIST_AND_MINI_IPC);
             $commentsParams->setOwnerId($data['action']['userId']);
             $commentsParams->setWrapInBox(false);
             if (!empty($feature['error'])) {
                 $commentsParams->setErrorMessage($feature['error']);
             }
             if (isset($feature['allow'])) {
                 $commentsParams->setAddComment($feature['allow']);
             }
             $commentCmp = new BASE_MCMP_Comments($commentsParams);
             $comments['html'] = $commentCmp->render();
         }
         $features[] = $comments;
     }
     $jsString = $js->generateJs();
     if (trim($jsString)) {
         OW::getDocument()->addOnloadScript($js);
     }
     foreach ($feturesData["custom"] as $customFeature) {
         $features[] = array_merge($featureDefaults, $customFeature);
     }
     $visibleCount = 0;
     foreach ($features as $f) {
         if (empty($f["hideButton"])) {
             $visibleCount++;
         }
     }
     return array("items" => $features, "buttonsCount" => $visibleCount);
 }
示例#2
0
 /**
  * @return Constructor.
  */
 public function __construct(BASE_CLASS_WidgetParameter $paramObj)
 {
     parent::__construct();
     $params = $paramObj->customParamList;
     $commentParams = new BASE_CommentsParams('groups', GROUPS_BOL_Service::ENTITY_TYPE_WAL);
     $groupId = (int) $paramObj->additionalParamList['entityId'];
     $commentParams->setEntityId($groupId);
     if (isset($params['comments_count'])) {
         $commentParams->setCommentCountOnPage($params['comments_count']);
     }
     if (isset($params['display_mode'])) {
         $commentParams->setDisplayType($params['display_mode']);
     }
     $isMember = GROUPS_BOL_Service::getInstance()->findUser($groupId, OW::getUser()->getId()) !== null;
     $commentParams->setAddComment($isMember);
     $this->addComponent('comments', new BASE_CMP_Comments($commentParams));
 }
示例#3
0
 /**
  * Constructor.
  */
 public function __construct(BASE_CLASS_WidgetParameter $paramObj)
 {
     parent::__construct();
     $userId = (int) $paramObj->additionalParamList['entityId'];
     $params = $paramObj->customParamList;
     $commentParams = new BASE_CommentsParams('base', 'base_profile_wall');
     $commentParams->setEntityId($userId);
     if (isset($params['comments_count'])) {
         $commentParams->setCommentCountOnPage($params['comments_count']);
     }
     if (isset($params['display_mode'])) {
         $commentParams->setDisplayType($params['display_mode']);
     }
     $commentParams->setOwnerId($userId);
     $commentParams->setWrapInBox(false);
     $this->addComponent('comments', new BASE_CMP_Comments($commentParams));
 }
示例#4
0
 /**
  * @return Constructor.
  */
 public function __construct($paramObj)
 {
     parent::__construct();
     // check if comments are empty and user can't add comments
     if ((int) BOL_CommentService::getInstance()->findCommentCount('base_index_wall', 1) === 0) {
         if (!OW::getUser()->isAuthenticated()) {
             $this->setVisible(false);
         }
     }
     $params = $paramObj->customParamList;
     $commentParams = new BASE_CommentsParams('base', 'base_index_wall');
     if (isset($params['comments_count'])) {
         $commentParams->setCommentCountOnPage($params['comments_count']);
     }
     $commentParams->setDisplayType(BASE_CommentsParams::DISPLAY_TYPE_TOP_FORM_WITH_PAGING);
     $commentParams->setWrapInBox(false);
     $this->addComponent('comments', new BASE_CMP_Comments($commentParams));
 }
示例#5
0
 private function getParamsObject()
 {
     $errorMessage = false;
     $entityType = !isset($_POST['entityType']) ? null : trim($_POST['entityType']);
     $entityId = !isset($_POST['entityId']) ? null : (int) $_POST['entityId'];
     $pluginKey = !isset($_POST['pluginKey']) ? null : trim($_POST['pluginKey']);
     if (!$entityType || !$entityId || !$pluginKey) {
         $errorMessage = OW::getLanguage()->text('base', 'comment_ajax_error');
     }
     $params = new BASE_CommentsParams($pluginKey, $entityType);
     $params->setEntityId($entityId);
     if (isset($_POST['ownerId'])) {
         $params->setOwnerId((int) $_POST['ownerId']);
     }
     if (isset($_POST['commentCountOnPage'])) {
         $params->setCommentCountOnPage((int) $_POST['commentCountOnPage']);
     }
     if (isset($_POST['displayType'])) {
         $params->setDisplayType($_POST['displayType']);
     }
     if (isset($_POST['initialCount'])) {
         $params->setInitialCommentsCount((int) $_POST['initialCount']);
     }
     if (isset($_POST['loadMoreCount'])) {
         $params->setLoadMoreCount((int) $_POST['loadMoreCount']);
     }
     if ($errorMessage) {
         echo json_encode(array('error' => $errorMessage));
         exit;
     }
     return $params;
 }
示例#6
0
 public function __construct($questionId, $userContext = null, $count = null, $options = null)
 {
     parent::__construct();
     $language = OW::getLanguage();
     $configs = OW::getConfig()->getValues('questions');
     $count = empty($count) ? QUESTIONS_BOL_Service::MORE_DISPLAY_COUNT : $count;
     $uniqId = uniqid('question_');
     $this->assign('uniqId', $uniqId);
     $service = QUESTIONS_BOL_Service::getInstance();
     $userId = OW::getUser()->getId();
     $question = $service->findQuestion($questionId);
     if (empty($question)) {
         $this->assign('noQuestion', true);
         return;
     }
     $settings = $question->getSettings();
     $isPoll = !$settings['allowAddOprions'];
     $optionTotal = $service->findOptionCount($questionId);
     $answerCount = $service->findTotalAnswersCount($questionId);
     $postCount = BOL_CommentService::getInstance()->findCommentCount('question', $questionId);
     $isAutor = $question->userId == $userId;
     if ($optionTotal - $count < 10) {
         $count = $optionTotal;
     }
     $limit = $count ? array(0, $count) : null;
     $answers = new QUESTIONS_CMP_Answers($question, $optionTotal, $limit);
     $answers->setExpandedView();
     $answers->setSettings($options);
     if (isset($options['inPopup']) && $options['inPopup'] === true) {
         $answers->setInPopupMode();
     }
     if (isset($options['loadStatic']) && $options['loadStatic'] === false) {
         $answers->setDoNotLoadStatic();
     }
     $editable = $service->isCurrentUserCanInteract($question);
     $answers->setEditable($editable && $service->isCurrentUserCanAnswer($question));
     if ($userContext !== null) {
         $answers->setUsersContext($userContext);
     }
     $answers->showAddNew();
     $this->addComponent('answers', $answers);
     $followsCount = $service->findFollowsCount($question->id, $userContext, array($question->userId));
     $statusCmp = new QUESTIONS_CMP_QuestionStatus($answers->getUniqId(), $postCount, $answerCount, $followsCount);
     $plugin = OW::getPluginManager()->getPlugin('questions');
     $statusCmp->setTemplate($plugin->getCmpViewDir() . 'question_static_status.html');
     $this->addComponent('questionStatus', $statusCmp);
     $tplQuestion = array('text' => nl2br($question->text));
     $event = new OW_Event(QUESTIONS_BOL_Service::EVENT_ON_QUESTION_RENDER, array("questionId" => $question->id, "questionDto" => $question, "text" => $question->text, "settings" => $settings, "uniqId" => $uniqId), $tplQuestion);
     OW::getEventManager()->trigger($event);
     $this->assign('question', $event->getData());
     $js = UTIL_JsGenerator::newInstance()->newObject('question', 'QUESTIONS_Question', array($uniqId, $question->id));
     if ($configs['allow_comments']) {
         $commentsParams = new BASE_CommentsParams('questions', QUESTIONS_BOL_Service::ENTITY_TYPE);
         $commentsParams->setEntityId($question->id);
         $commentsParams->setDisplayType(BASE_CommentsParams::DISPLAY_TYPE_TOP_FORM_WITH_PAGING);
         $commentsParams->setCommentCountOnPage(5);
         $commentsParams->setOwnerId($question->userId);
         $commentsParams->setAddComment($editable);
         $commentCmp = new BASE_CMP_Comments($commentsParams);
         //$commentTemplate = OW::getPluginManager()->getPlugin('questions')->getCmpViewDir() . 'comments.html';
         //$commentCmp->setTemplate($commentTemplate);
         $this->addComponent('comments', $commentCmp);
         if (!empty($options['focusToPost'])) {
             $js->addScript('question.focusOnPostInput()');
         }
     }
     $jsSelector = 'QUESTIONS_AnswerListCollection.' . $answers->getUniqId();
     $js->addScript('question.setAnswerList(' . $jsSelector . ');');
     if (!empty($options['relation'])) {
         $js->addScript($jsSelector . '.setRelation("' . $options['relation'] . '");');
     }
     $js->equateVarables(array('QUESTIONS_QuestionColletction', $uniqId), 'question');
     OW::getDocument()->addOnloadScript($js);
     $toolbar = array();
     if ($service->isCurrentUserCanInteract($question)) {
         if ($configs['enable_follow']) {
             $this->assign('follow', array('isFollow' => $service->isFollow($userId, $question->id), 'followId' => $answers->getUniqId() . '-follow', 'unfollowId' => $answers->getUniqId() . '-unfollow', 'followClick' => $jsSelector . '.followQuestion()', 'unfollowClick' => $jsSelector . '.unfollowQuestion()'));
             /*$followLabel = $language->text('questions', 'toolbar_follow_btn');
                             $unfollowLabel = $language->text('questions', 'toolbar_unfollow_btn');
             
                             if ( $service->isFollow($userId, $question->id) )
                             {
                                 $toolbar[] = array(
                                     'label' => '<a id="' . $answers->getUniqId() . '-unfollow" href="javascript://" onclick="' .$jsSelector . '.unfollowQuestion()">' . $unfollowLabel . '</a>
                                                 <a id="' . $answers->getUniqId() . '-follow" href="javascript://" style="display: none;" onclick="' .$jsSelector . '.followQuestion()">' . $followLabel . '</a>'
                                 );
                             }
                             else
                             {
                                 $toolbar[] = array(
                                     'label' => '<a id="' . $answers->getUniqId() . '-unfollow" href="javascript://" style="display: none;" onclick="' .$jsSelector . '.unfollowQuestion()">' . $unfollowLabel . '</a>
                                                 <a id="' . $answers->getUniqId() . '-follow" href="javascript://" onclick="' .$jsSelector . '.followQuestion()">' . $followLabel . '</a>'
                                 );
                             }*/
         }
     }
     if ($isPoll) {
         $list = $service->findUserAnswerListByQuestionId($userId, $question->id);
         if (count($list)) {
             $toolbar[] = array('label' => '<a id="' . $answers->getUniqId() . '-unvote" href="javascript://" onclick="' . $jsSelector . '.unvote()">' . $language->text('questions', 'toolbar_unvote_btn') . '</a>');
         }
     }
     if ($service->isCurrentUserCanEdit($question)) {
         $condEmbed = "confirm('" . $language->text('questions', 'delete_question_confirm') . "')";
         $toolbar[] = array('label' => '<a href="javascript://" onclick="if(' . $condEmbed . ') ' . $jsSelector . '.deleteQuestion();">' . $language->text('questions', 'toolbar_delete_btn') . '</a>');
     }
     $userData = BOL_AvatarService::getInstance()->getDataForUserAvatars(array($question->userId));
     $questionInfo = array('avatar' => $userData[$question->userId], 'profileUrl' => $userData[$question->userId]['url'], 'displayName' => $userData[$question->userId]['title'], 'content' => '', 'toolbar' => $toolbar, 'date' => UTIL_DateTime::formatDate($question->timeStamp));
     $this->assign('questionInfo', $questionInfo);
 }
示例#7
0
 protected function getFeatures($data)
 {
     $configs = $this->sharedData['configs'];
     $featuresData = $this->getFeaturesData($data);
     $out = array('system' => array('comments' => false, 'likes' => false), 'custom' => array());
     $out['custom'] = $featuresData["custom"];
     $systemFeatures = $featuresData["system"];
     if (!empty($systemFeatures["comments"])) {
         $feature = $systemFeatures["comments"];
         $commentsParams = new BASE_CommentsParams($feature["authGroup"], $feature["entityType"]);
         $commentsParams->setEntityId($feature["entityId"]);
         $commentsParams->setCommentCountOnPage($configs['comments_count']);
         $commentsParams->setBatchData($feature["comments"]);
         $commentsParams->setOwnerId($this->action->getUserId());
         $commentsParams->setDisplayType(BASE_CommentsParams::DISPLAY_TYPE_BOTTOM_FORM_WITH_PARTIAL_LIST_AND_MINI_IPC);
         $commentsParams->setWrapInBox(false);
         if (!empty($feature['error'])) {
             $commentsParams->setErrorMessage($feature['error']);
         }
         if (isset($feature['allow'])) {
             $commentsParams->setAddComment($feature['allow']);
         }
         $commentCmp = new BASE_CMP_Comments($commentsParams);
         $out['system']['comments']['cmp'] = $commentCmp->render();
         $out['system']['comments']['count'] = $feature["count"];
         $out['system']['comments']['allow'] = $feature["allow"];
         $out['system']['comments']['expanded'] = $feature["expanded"];
     }
     if (!empty($systemFeatures["likes"])) {
         $feature = $systemFeatures['likes'];
         $out['system']['likes']['count'] = $feature["count"];
         $out['system']['likes']['liked'] = $feature["liked"];
         $out['system']['likes']['allow'] = $feature["allow"];
         $out['system']['likes']['error'] = $feature["error"];
         $likeCmp = new NEWSFEED_CMP_Likes($feature["entityType"], $feature["entityId"], $feature["likes"]);
         $out['system']['likes']['cmp'] = $likeCmp->render();
     }
     return $out;
 }