Exemple #1
0
 public function __construct($userId)
 {
     parent::__construct();
     $cover = UHEADER_BOL_Service::getInstance()->findCoverByUserId($userId);
     if (empty($cover)) {
         $this->assign('error', OW::getLanguage()->text('uheader', 'cover_not_found'));
         return;
     }
     $src = UHEADER_BOL_Service::getInstance()->getCoverUrl($cover);
     $settings = $cover->getSettings();
     $height = $settings['dimensions']['height'];
     $width = $settings['dimensions']['width'];
     $top = 0;
     if ($height < self::MIN_HEIGHT) {
         $top = (self::MIN_HEIGHT - $height) / 2;
     }
     $avatarsData = BOL_AvatarService::getInstance()->getDataForUserAvatars(array($userId));
     $this->assign('user', $avatarsData[$userId]);
     $this->assign('src', $src);
     $this->assign('top', $top);
     $this->assign('dimensions', $settings['dimensions']);
     $cmtParams = new BASE_CommentsParams('uheader', UHEADER_CLASS_CommentsBridge::ENTITY_TYPE);
     $cmtParams->setWrapInBox(false);
     $cmtParams->setEntityId($cover->id);
     $cmtParams->setOwnerId($userId);
     $cmtParams->setDisplayType(BASE_CommentsParams::DISPLAY_TYPE_TOP_FORM_WITH_PAGING);
     $photoCmts = new BASE_CMP_Comments($cmtParams);
     $this->addComponent('comments', $photoCmts);
 }
 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);
 }
 /**
  * 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));
 }
 /**
  * @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));
 }
Exemple #5
0
 private function prepareMarkup($photoId, $layout = NULL)
 {
     $markup = array();
     $photo = $this->photoService->findPhotoById($photoId);
     $album = $this->photoAlbumService->findAlbumById($photo->albumId);
     $layoutList = array('page' => BASE_CommentsParams::DISPLAY_TYPE_WITH_LOAD_LIST, 'floatbox' => BASE_CommentsParams::DISPLAY_TYPE_WITH_LOAD_LIST_MINI);
     $userId = OW::getUser()->getId();
     $ownerMode = $album->userId == $userId;
     $modPermissions = OW::getUser()->isAuthorized('photo');
     $photo->addDatetime = UTIL_DateTime::formatDate($photo->addDatetime);
     $photo->description = UTIL_HtmlTag::autoLink($photo->description);
     $dim = !empty($photo->dimension) ? $photo->dimension : FALSE;
     $photo->url = $this->photoService->getPhotoUrlByType($photo->id, PHOTO_BOL_PhotoService::TYPE_MAIN, $photo->hash, $dim);
     if ($photo->hasFullsize) {
         $photo->urlFullscreen = $this->photoService->getPhotoUrlByType($photo->id, PHOTO_BOL_PhotoService::TYPE_FULLSCREEN, $photo->hash, $dim);
     }
     if (!empty($photo->description)) {
         $photo->description = $this->photoService->hashtagToDesc($photo->description);
     }
     $markup['photo'] = $photo;
     $markup['album'] = $album;
     $markup['albumUrl'] = OW::getRouter()->urlForRoute('photo_user_album', array('user' => BOL_UserService::getInstance()->getUserName($album->userId), 'album' => $album->id));
     $markup['photoCount'] = $this->photoAlbumService->countAlbumPhotos($photo->albumId);
     $markup['photoIndex'] = $this->photoService->getPhotoIndex($photo->albumId, $photo->id);
     $avatar = BOL_AvatarService::getInstance()->getDataForUserAvatars(array($album->userId), TRUE, TRUE, TRUE, FALSE);
     $markup['avatar'] = $avatar[$album->userId];
     $cmtParams = new BASE_CommentsParams('photo', 'photo_comments');
     $cmtParams->setEntityId($photo->id);
     $cmtParams->setOwnerId($album->userId);
     $cmtParams->setWrapInBox(FALSE);
     $cmtParams->setDisplayType(array_key_exists($layout, $layoutList) ? $layoutList[$layout] : BASE_CommentsParams::DISPLAY_TYPE_WITH_LOAD_LIST_MINI);
     $cmtParams->setInitialCommentsCount(6);
     $cmtParams->setAddComment($photo->status == PHOTO_BOL_PhotoDao::STATUS_APPROVED);
     $customId = uniqid('photoComment');
     $cmtParams->setCustomId($customId);
     $markup['customId'] = $customId;
     $comment = new BASE_CMP_Comments($cmtParams);
     $markup['comment'] = $comment->render();
     $action = new BASE_ContextAction();
     $action->setKey('photo-moderate');
     $context = new BASE_CMP_ContextAction();
     $context->addAction($action);
     $contextEvent = new BASE_CLASS_EventCollector('photo.collect_photo_context_actions', array('photoId' => $photo->id, 'photoDto' => $photo));
     OW::getEventManager()->trigger($contextEvent);
     foreach ($contextEvent->getData() as $contextAction) {
         $action = new BASE_ContextAction();
         $action->setKey(empty($contextAction['key']) ? uniqid() : $contextAction['key']);
         $action->setParentKey('photo-moderate');
         $action->setLabel($contextAction['label']);
         if (!empty($contextAction['id'])) {
             $action->setId($contextAction['id']);
         }
         if (!empty($contextAction['order'])) {
             $action->setOrder($contextAction['order']);
         }
         if (!empty($contextAction['class'])) {
             $action->setClass($contextAction['class']);
         }
         if (!empty($contextAction['url'])) {
             $action->setUrl($contextAction['url']);
         }
         $attributes = empty($contextAction['attributes']) ? array() : $contextAction['attributes'];
         foreach ($attributes as $key => $value) {
             $action->addAttribute($key, $value);
         }
         $context->addAction($action);
     }
     $lang = OW::getLanguage();
     if ($userId && !$ownerMode && $photo->status == PHOTO_BOL_PhotoDao::STATUS_APPROVED) {
         $action = new BASE_ContextAction();
         $action->setKey('flag');
         $action->setParentKey('photo-moderate');
         $action->setLabel($lang->text('base', 'flag'));
         $action->setId('btn-photo-flag');
         $action->addAttribute('rel', $photoId);
         $action->addAttribute('url', OW::getRouter()->urlForRoute('view_photo', array('id' => $photo->id)));
         $context->addAction($action);
     }
     if ($ownerMode || $modPermissions) {
         $action = new BASE_ContextAction();
         $action->setKey('edit');
         $action->setParentKey('photo-moderate');
         $action->setLabel($lang->text('base', 'edit'));
         $action->setId('btn-photo-edit');
         $action->addAttribute('rel', $photoId);
         $context->addAction($action);
         $action = new BASE_ContextAction();
         $action->setKey('delete');
         $action->setParentKey('photo-moderate');
         $action->setLabel($lang->text('base', 'delete'));
         $action->setId('photo-delete');
         $action->addAttribute('rel', $photoId);
         $context->addAction($action);
     }
     if ($modPermissions) {
         if (PHOTO_BOL_PhotoFeaturedService::getInstance()->isFeatured($photo->id)) {
             $action = new BASE_ContextAction();
             $action->setKey('unmark-featured');
             $action->setParentKey('photo-moderate');
             $action->setLabel($lang->text('photo', 'remove_from_featured'));
             $action->setId('photo-mark-featured');
             $action->addAttribute('rel', 'remove_from_featured');
             $action->addAttribute('photo-id', $photoId);
             $context->addAction($action);
         } elseif ($photo->status == PHOTO_BOL_PhotoDao::STATUS_APPROVED) {
             $action = new BASE_ContextAction();
             $action->setKey('mark-featured');
             $action->setParentKey('photo-moderate');
             $action->setLabel($lang->text('photo', 'mark_featured'));
             $action->setId('photo-mark-featured');
             $action->addAttribute('rel', 'mark_featured');
             $action->addAttribute('photo-id', $photoId);
             $context->addAction($action);
         }
         if ($photo->status != PHOTO_BOL_PhotoDao::STATUS_APPROVED) {
             $action = new BASE_ContextAction();
             $action->setKey('mark-approved');
             $action->setParentKey('photo-moderate');
             $action->setLabel($lang->text('photo', 'approve_photo'));
             $action->setUrl(OW::getRouter()->urlForRoute('photo.approve', array('id' => $photoId)));
             //                $action->setId('photo-approve');
             //                $action->addAttribute('url', OW::getRouter()->urlForRoute('photo.approve', array('id' => $photoId)));
             $context->addAction($action);
         }
     }
     $markup['contextAction'] = $context->render();
     $eventParams = array('url' => OW::getRouter()->urlForRoute('view_photo', array('id' => $photo->id)), 'image' => $photo->url, 'title' => $photo->description, 'entityType' => 'photo', 'entityId' => $photo->id);
     $event = new BASE_CLASS_EventCollector('socialsharing.get_sharing_buttons', $eventParams);
     OW::getEventManager()->trigger($event);
     $markup['share'] = @implode("\n", $event->getData());
     $document = OW::getDocument();
     $onloadScript = $document->getOnloadScript();
     if (!empty($onloadScript)) {
         $markup['onloadScript'] = $onloadScript;
     }
     $scriptFiles = $document->getScripts();
     if (!empty($scriptFiles)) {
         $markup['scriptFiles'] = $scriptFiles;
     }
     $css = $document->getStyleDeclarations();
     if (!empty($css)) {
         $markup['css'] = $css;
     }
     $cssFiles = $document->getStyleSheets();
     if (!empty($cssFiles)) {
         $markup['cssFiles'] = $cssFiles;
     }
     $meta = $document->getMeta();
     if (!empty($meta)) {
         $markup['meta'] = $meta;
     }
     return $markup;
 }
 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;
 }