Пример #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
 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->setInitialCommentsCount($configs['comments_count']);
         $commentsParams->setLoadMoreCount(6);
         $commentsParams->setBatchData($feature["comments"]);
         $commentsParams->setOwnerId($this->action->getUserId());
         $commentsParams->setDisplayType(BASE_CommentsParams::DISPLAY_TYPE_WITH_LOAD_LIST_MINI);
         $commentsParams->setWrapInBox(false);
         $commentsParams->setShowEmptyList(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;
 }