public function __construct($groupId) { parent::__construct(); $cover = GHEADER_BOL_Service::getInstance()->findCoverByGroupId($groupId); if (empty($cover)) { $this->assign('error', OW::getLanguage()->text('gheader', 'cover_not_found')); return; } $group = GROUPS_BOL_Service::getInstance()->findGroupById($cover->groupId); $src = GHEADER_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; } $this->assign('src', $src); $this->assign('top', $top); $this->assign('dimensions', $settings['dimensions']); $userId = OW::getUser()->getId(); $cmtParams = new BASE_CommentsParams('gheader', GHEADER_CLASS_CommentsBridge::ENTITY_TYPE); $cmtParams->setEntityId($cover->id); $cmtParams->setAddComment(GHEADER_BOL_Service::getInstance()->isUserCanInteract($userId, $group->id)); $cmtParams->setOwnerId($group->userId); $cmtParams->setDisplayType(BASE_CommentsParams::DISPLAY_TYPE_TOP_FORM_WITH_PAGING); $photoCmts = new BASE_CMP_Comments($cmtParams); $this->addComponent('comments', $photoCmts); }
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); }
/** * @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)); }
/** * 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)); }
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; }
/** * Vwls view_video action * * @param array $params */ public function viewVideo(array $params) { if (!isset($params['id']) || !($id = (int) $params['id'])) { throw new Redirect404Exception(); return; } $clip = $this->clipService->findClipById($id); if (!$clip) { throw new Redirect404Exception(); } $contentOwner = (int) $this->clipService->findClipOwner($id); $language = OW_Language::getInstance(); $description = $clip->description; $clip->description = UTIL_HtmlTag::autoLink($clip->description); $this->assign('clip', $clip); // $is_featured = VWLS_BOL_ClipFeaturedService::getInstance()->isFeatured($clip->id); // $this->assign('featured', $is_featured); // is moderator $modPermissions = OW::getUser()->isAuthorized('vwls'); $this->assign('moderatorMode', $modPermissions); $userId = OW::getUser()->getId(); $ownerMode = $contentOwner == $userId; $this->assign('ownerMode', $ownerMode); if (!$ownerMode && !OW::getUser()->isAuthorized('vwls', 'view') && !$modPermissions) { $this->setTemplate(OW::getPluginManager()->getPlugin('base')->getCtrlViewDir() . 'authorization_failed.html'); return; } // $this->assign('auth_msg', null); // permissions check if (!$ownerMode && !$modPermissions) { $privacyParams = array('action' => 'vwls_view_vwls', 'ownerId' => $contentOwner, 'viewerId' => $userId); $event = new OW_Event('privacy_check_permission', $privacyParams); OW::getEventManager()->trigger($event); } $cmtParams = new BASE_CommentsParams('vwls', 'vwls_comments'); $cmtParams->setEntityId($id); $cmtParams->setOwnerId($contentOwner); $cmtParams->setDisplayType(BASE_CommentsParams::DISPLAY_TYPE_BOTTOM_FORM_WITH_FULL_LIST); $vwlsCmts = new BASE_CMP_Comments($cmtParams); $this->addComponent('comments', $vwlsCmts); $vwlsRates = new BASE_CMP_Rate('vwls', 'vwls_rates', $id, $contentOwner); $this->addComponent('rate', $vwlsRates); $vwlsTags = new BASE_CMP_EntityTagCloud('vwls'); $vwlsTags->setEntityId($id); $vwlsTags->setRouteName('vwview_tagged_list_ls'); $this->addComponent('tags', $vwlsTags); $username = BOL_UserService::getInstance()->getUserName($clip->userId); $this->assign('username', $username); $displayName = BOL_UserService::getInstance()->getDisplayName($clip->userId); $this->assign('displayName', $displayName); OW::getDocument()->addScript($this->pluginJsUrl . 'vwls.js'); $objParams = array('ajaxResponder' => $this->ajaxResponder, 'clipId' => $id, 'txtDelConfirm' => OW::getLanguage()->text('vwls', 'confirm_delete'), 'txtMarkFeatured' => OW::getLanguage()->text('vwls', 'mark_featured'), 'txtRemoveFromFeatured' => OW::getLanguage()->text('vwls', 'remove_from_featured'), 'txtApprove' => OW::getLanguage()->text('base', 'approve'), 'txtDisapprove' => OW::getLanguage()->text('base', 'disapprove')); $script = "\$(document).ready(function(){\n var clip = new vwlsClip( " . json_encode($objParams) . ");\n }); "; OW::getDocument()->addOnloadScript($script); OW::getDocument()->setHeading($clip->title); OW::getDocument()->setHeadingIconClass('ow_ic_vwls'); $toolbar = array(); array_push($toolbar, array('href' => 'javascript://', 'id' => 'btn-vwls-flag', 'label' => $language->text('base', 'flag'))); if ($ownerMode || $modPermissions) { array_push($toolbar, array('href' => OW::getRouter()->urlForRoute('vwedit_clip_ls', array('id' => $clip->id)), 'label' => $language->text('base', 'edit'))); array_push($toolbar, array('href' => 'javascript://', 'id' => 'clip-delete', 'label' => $language->text('base', 'delete'))); } /** if ( $modPermissions ) { if ( $is_featured ) { array_push($toolbar, array( 'href' => 'javascript://', 'id' => 'clip-mark-featured', 'rel' => 'remove_from_featured', 'label' => $language->text('vwls', 'remove_from_featured') )); } else { array_push($toolbar, array( 'href' => 'javascript://', 'id' => 'clip-mark-featured', 'rel' => 'mark_featured', 'label' => $language->text('vwls', 'mark_featured') )); } if ( $clip->status == 'approved' ) { array_push($toolbar, array( 'href' => 'javascript://', 'id' => 'clip-set-approval-staus', 'rel' => 'disapprove', 'label' => $language->text('base', 'disapprove') )); } else { array_push($toolbar, array( 'href' => 'javascript://', 'id' => 'clip-set-approval-staus', 'rel' => 'approve', 'label' => $language->text('base', 'approve') )); } } */ $this->assign('toolbar', $toolbar); $js = UTIL_JsGenerator::newInstance()->jQueryEvent('#btn-vwls-flag', 'click', 'document.flag(e.data.entity, e.data.id, e.data.title, e.data.href, "vwls+flags");', array('e'), array('entity' => 'vwls_clip', 'id' => $clip->id, 'title' => $clip->title, 'href' => OW::getRouter()->urlForRoute('vwview_clip_ls', array('id' => $clip->id)))); OW::getDocument()->addOnloadScript($js, 1001); OW::getDocument()->setTitle($language->text('vwls', 'meta_title_vwls_view', array('title' => $clip->title))); $tagsArr = BOL_TagService::getInstance()->findEntityTags($clip->id, 'vwls'); foreach ($tagsArr as $t) { $labels[] = $t->label; } $tagStr = $tagsArr ? implode(', ', $labels) : ''; OW::getDocument()->setDescription($language->text('vwls', 'meta_description_vwls_view', array('title' => $clip->title, 'tags' => $tagStr))); }
/** * Class constructor * * @param string $listType * @param int $count * @param string $tag */ public function __construct(array $params) { parent::__construct(); $photoId = $params['photoId']; $config = OW::getConfig(); $lang = OW::getLanguage(); $this->photoService = PHOTO_BOL_PhotoService::getInstance(); $this->photoAlbumService = PHOTO_BOL_PhotoAlbumService::getInstance(); $photo = $this->photoService->findPhotoById($photoId); $album = $this->photoAlbumService->findAlbumById($photo->albumId); $this->assign('album', $album); // is owner $contentOwner = $this->photoService->findPhotoOwner($photo->id); $userId = OW::getUser()->getId(); $ownerMode = $contentOwner == $userId; $this->assign('ownerMode', $ownerMode); // is moderator $modPermissions = OW::getUser()->isAuthorized('photo'); $this->assign('moderatorMode', $modPermissions); $canView = true; if (!$ownerMode && !$modPermissions && !OW::getUser()->isAuthorized('photo', 'view')) { $canView = false; } $this->assign('canView', $canView); $cmtParams = new BASE_CommentsParams('photo', 'photo_comments'); $cmtParams->setEntityId($photo->id); $cmtParams->setOwnerId($contentOwner); $cmtParams->setDisplayType(BASE_CommentsParams::DISPLAY_TYPE_BOTTOM_FORM_WITH_FULL_LIST); $photoCmts = new BASE_CMP_Comments($cmtParams); $this->addComponent('comments', $photoCmts); $photoRates = new BASE_CMP_Rate('photo', 'photo_rates', $photo->id, $contentOwner); $this->addComponent('rate', $photoRates); $photoTags = new BASE_CMP_EntityTagCloud('photo'); $photoTags->setEntityId($photo->id); $photoTags->setRouteName('view_tagged_photo_list'); $this->addComponent('tags', $photoTags); $description = $photo->description; $photo->description = UTIL_HtmlTag::autoLink($photo->description); $this->assign('photo', $photo); $this->assign('url', $this->photoService->getPhotoUrl($photo->id, false, $photo->hash)); $this->assign('ownerName', BOL_UserService::getInstance()->getUserName($album->userId)); $is_featured = PHOTO_BOL_PhotoFeaturedService::getInstance()->isFeatured($photo->id); if ((int) $config->getValue('photo', 'store_fullsize') && $photo->hasFullsize) { $this->assign('fullsizeUrl', $this->photoService->getPhotoFullsizeUrl($photo->id, $photo->hash)); } else { $this->assign('fullsizeUrl', null); } $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' => $photoId, '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); } if ($userId && !$ownerMode) { $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 ($is_featured) { $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); } else { $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); } } $this->addComponent('contextAction', $context); $nextPhoto = $this->photoService->getNextPhoto($photo->albumId, $photo->id); $this->assign('nextPhoto', $nextPhoto); $previousPhoto = $this->photoService->getPreviousPhoto($photo->albumId, $photo->id); $this->assign('previousPhoto', $previousPhoto); $photoCount = $this->photoAlbumService->countAlbumPhotos($photo->albumId); $this->assign('photoCount', $photoCount); $photoIndex = $this->photoService->getPhotoIndex($photo->albumId, $photo->id); $this->assign('photoIndex', $photoIndex); $avatar = BOL_AvatarService::getInstance()->getDataForUserAvatars(array($contentOwner), true, true, true, false); $this->assign('avatar', $avatar[$contentOwner]); }
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); }
public function view(array $params) { if (!isset($params['id']) || !($photoId = (int) $params['id'])) { throw new Redirect404Exception(); } $lang = OW::getLanguage(); $photo = $this->photoService->findPhotoById($photoId); if (!$photo) { throw new Redirect404Exception(); } $album = $this->photoAlbumService->findAlbumById($photo->albumId); $this->assign('album', $album); $ownerName = BOL_UserService::getInstance()->getUserName($album->userId); $albumUrl = OW::getRouter()->urlForRoute('photo_user_album', array('album' => $album->id, 'user' => $ownerName)); $this->assign('albumUrl', $albumUrl); // is owner $contentOwner = $this->photoService->findPhotoOwner($photo->id); $userId = OW::getUser()->getId(); $ownerMode = $contentOwner == $userId; $this->assign('ownerMode', $ownerMode); // is moderator $modPermissions = OW::getUser()->isAuthorized('photo'); $this->assign('moderatorMode', $modPermissions); $this->assign('url', $this->photoService->getPhotoUrl($photo->id, false, $photo->hash)); if (!$ownerMode && !$modPermissions && !OW::getUser()->isAuthorized('photo', 'view')) { $status = BOL_AuthorizationService::getInstance()->getActionStatus('photo', 'view'); $this->assign('authError', $status['msg']); return; } // permissions check if (!$ownerMode && !$modPermissions) { $privacyParams = array('action' => 'photo_view_album', 'ownerId' => $contentOwner, 'viewerId' => $userId); $event = new OW_Event('privacy_check_permission', $privacyParams); OW::getEventManager()->trigger($event); } $photo->description = UTIL_HtmlTag::autoLink($photo->description); $this->assign('photo', $photo); $fullsizeUrl = (int) OW::getConfig()->getValue('photo', 'store_fullsize') && $photo->hasFullsize ? $this->photoService->getPhotoFullsizeUrl($photo->id, $photo->hash) : null; $this->assign('fullsizeUrl', $fullsizeUrl); $this->assign('nextPhoto', $this->photoService->getNextPhotoId($photo->albumId, $photo->id)); $this->assign('previousPhoto', $this->photoService->getPreviousPhotoId($photo->albumId, $photo->id)); $photoCount = $this->photoAlbumService->countAlbumPhotos($photo->albumId); $this->assign('photoCount', $photoCount); $photoIndex = $this->photoService->getPhotoIndex($photo->albumId, $photo->id); $this->assign('photoIndex', $photoIndex); $avatar = BOL_AvatarService::getInstance()->getDataForUserAvatars(array($contentOwner), true, true, true, false); $this->assign('avatar', $avatar[$contentOwner]); $cmtParams = new BASE_CommentsParams('photo', 'photo_comments'); $cmtParams->setEntityId($photo->id); $cmtParams->setOwnerId($contentOwner); $cmtParams->setDisplayType(BASE_CommentsParams::DISPLAY_TYPE_BOTTOM_FORM_WITH_FULL_LIST); $photoCmts = new BASE_MCMP_Comments($cmtParams); $this->addComponent('comments', $photoCmts); OW::getDocument()->setHeading($album->name); $description = strip_tags($photo->description); $description = mb_strlen($description) ? $description : $photo->id; OW::getDocument()->setTitle($lang->text('photo', 'meta_title_photo_view', array('title' => $description))); }
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; }
public function __construct(array $params) { parent::__construct(); $id = $params['videoId']; $this->clipService = VIDEO_BOL_ClipService::getInstance(); $clip = $this->clipService->findClipById($id); if (!$clip) { throw new Redirect404Exception(); } $contentOwner = (int) $this->clipService->findClipOwner($id); $language = OW_Language::getInstance(); $description = $clip->description; $clip->description = UTIL_HtmlTag::autoLink($clip->description); $this->assign('clip', $clip); $is_featured = VIDEO_BOL_ClipFeaturedService::getInstance()->isFeatured($clip->id); $this->assign('featured', $is_featured); // is moderator $modPermissions = OW::getUser()->isAuthorized('video'); $this->assign('moderatorMode', $modPermissions); $userId = OW::getUser()->getId(); $ownerMode = $contentOwner == $userId; $this->assign('ownerMode', $ownerMode); if (!$ownerMode && !OW::getUser()->isAuthorized('video', 'view') && !$modPermissions) { $this->setTemplate(OW::getPluginManager()->getPlugin('base')->getCtrlViewDir() . 'authorization_failed.html'); return; } $this->assign('auth_msg', null); // permissions check if (!$ownerMode && !$modPermissions) { $privacyParams = array('action' => 'video_view_video', 'ownerId' => $contentOwner, 'viewerId' => $userId); $event = new OW_Event('privacy_check_permission', $privacyParams); OW::getEventManager()->trigger($event); } $cmtParams = new BASE_CommentsParams('video', 'video_comments'); $cmtParams->setEntityId($id); $cmtParams->setOwnerId($contentOwner); $cmtParams->setDisplayType(BASE_CommentsParams::DISPLAY_TYPE_BOTTOM_FORM_WITH_FULL_LIST); $videoCmts = new BASE_CMP_Comments($cmtParams); $this->addComponent('comments', $videoCmts); $videoRates = new BASE_CMP_Rate('video', 'video_rates', $id, $contentOwner); $this->addComponent('rate', $videoRates); $videoTags = new BASE_CMP_EntityTagCloud('video'); $videoTags->setEntityId($id); $videoTags->setRouteName('view_tagged_list'); $this->addComponent('tags', $videoTags); $this->assign('canEdit', false); $this->assign('canReport', false); $this->assign('canMakeFeature', false); OW::getLanguage()->addKeyForJs('video', 'tb_edit_clip'); OW::getLanguage()->addKeyForJs('video', 'confirm_delete'); OW::getLanguage()->addKeyForJs('video', 'mark_featured'); OW::getLanguage()->addKeyForJs('video', 'remove_from_featured'); OW::getLanguage()->addKeyForJs('base', 'approve'); OW::getLanguage()->addKeyForJs('base', 'disapprove'); $toolbar = array(); $toolbarEvent = new BASE_CLASS_EventCollector('video.collect_video_toolbar_items', array('clipId' => $clip->id, 'clipDto' => $clip)); OW::getEventManager()->trigger($toolbarEvent); foreach ($toolbarEvent->getData() as $toolbarItem) { array_push($toolbar, $toolbarItem); } if (OW::getUser()->isAuthenticated() && !$ownerMode) { array_push($toolbar, array('href' => 'javascript://', 'id' => 'btn-video-flag', 'label' => $language->text('base', 'flag'))); $this->assign('canReport', true); } if ($ownerMode || $modPermissions) { array_push($toolbar, array('href' => OW::getRouter()->urlForRoute('edit_clip', array('id' => $clip->id)), 'label' => $language->text('base', 'edit'))); array_push($toolbar, array('href' => 'javascript://', 'id' => 'clip-delete', 'label' => $language->text('base', 'delete'))); $this->assign('canEdit', true); } if ($modPermissions) { if ($is_featured) { array_push($toolbar, array('href' => 'javascript://', 'id' => 'clip-mark-featured', 'rel' => 'remove_from_featured', 'label' => $language->text('video', 'remove_from_featured'))); $this->assign('isFeature', true); } else { array_push($toolbar, array('href' => 'javascript://', 'id' => 'clip-mark-featured', 'rel' => 'mark_featured', 'label' => $language->text('video', 'mark_featured'))); $this->assign('isFeature', false); } $this->assign('canMakeFeature', true); /* if ( $clip->status == 'approved' ) { array_push($toolbar, array( 'href' => 'javascript://', 'id' => 'clip-set-approval-staus', 'rel' => 'disapprove', 'label' => $language->text('base', 'disapprove') )); } else { array_push($toolbar, array( 'href' => 'javascript://', 'id' => 'clip-set-approval-staus', 'rel' => 'approve', 'label' => $language->text('base', 'approve') )); } */ } $this->assign('toolbar', $toolbar); /* $js = UTIL_JsGenerator::newInstance() ->jQueryEvent('#btn-video-flag', 'click', 'OW.flagContent(e.data.entity, e.data.id, e.data.title, e.data.href, "video+flags");', array('e'), array('entity' => 'video_clip', 'id' => $clip->id, 'title' => $clip->title, 'href' => OW::getRouter()->urlForRoute('view_clip', array('id' => $clip->id)) )); OW::getDocument()->addOnloadScript($js, 1001); */ //avatar $avatar = BOL_AvatarService::getInstance()->getDataForUserAvatars(array($contentOwner), true, true, true, false); $this->assign('avatar', $avatar[$contentOwner]); /* $config = OW::getConfig(); $lang = OW::getLanguage(); $this->videoService = VIDEO_BOL_VideoService::getInstance(); $this->videoAlbumService = VIDEO_BOL_VideoAlbumService::getInstance(); $video = $this->videoService->findVideoById($videoId); $album = $this->videoAlbumService->findAlbumById($video->albumId); $this->assign('album', $album); $this->assign('video', $video); // is owner $contentOwner = $this->videoService->findVideoOwner($video->id); $userId = OW::getUser()->getId(); $ownerMode = $contentOwner == $userId; $this->assign('ownerMode', $ownerMode); // is moderator $modPermissions = OW::getUser()->isAuthorized('video'); $this->assign('moderatorMode', $modPermissions); $canView = true; if ( !$ownerMode && !$modPermissions && !OW::getUser()->isAuthorized('video', 'view') ) { $canView = false; } $this->assign('canView', $canView); $this->assign('canDownload', $config->getValue('gvideoviewer', 'can_users_to_download_videos')); $cmtParams = new BASE_CommentsParams('video', 'video_comments'); $cmtParams->setEntityId($video->id); $cmtParams->setOwnerId($contentOwner); $cmtParams->setDisplayType(BASE_CommentsParams::DISPLAY_TYPE_BOTTOM_FORM_WITH_FULL_LIST); $videoCmts = new BASE_CMP_Comments($cmtParams); $this->addComponent('comments', $videoCmts); $videoRates = new BASE_CMP_Rate('video', 'video_rates', $video->id, $contentOwner); $this->addComponent('rate', $videoRates); $videoTags = new BASE_CMP_EntityTagCloud('video'); $videoTags->setEntityId($video->id); $videoTags->setRouteName('view_tagged_video_list'); $this->addComponent('tags', $videoTags); $description = $video->description; $video->description = UTIL_HtmlTag::autoLink($video->description); $this->assign('video', $video); $this->assign('url', $this->videoService->getVideoUrl($video->id)); $this->assign('ownerName', BOL_UserService::getInstance()->getUserName($album->userId)); $is_featured = VIDEO_BOL_VideoFeaturedService::getInstance()->isFeatured($video->id); if ( (int) $config->getValue('video', 'store_fullsize') && $video->hasFullsize ) { $this->assign('fullsizeUrl', $this->videoService->getVideoFullsizeUrl($video->id)); } else { $this->assign('fullsizeUrl', null); } $action = new BASE_ContextAction(); $action->setKey('video-moderate'); $context = new BASE_CMP_ContextAction(); $context->addAction($action); $contextEvent = new BASE_CLASS_EventCollector('video.collect_video_context_actions', array( 'videoId' => $videoId, 'videoDto' => $video )); OW::getEventManager()->trigger($contextEvent); $this->assign('canEdit', false); $this->assign('canReport', false); $this->assign('canMakeFeature', false); foreach ( $contextEvent->getData() as $contextAction ) { $action = new BASE_ContextAction(); $action->setKey(empty($contextAction['key']) ? uniqid() : $contextAction['key']); $action->setParentKey('video-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); } if ( $userId && !$ownerMode ) { $action = new BASE_ContextAction(); $action->setKey('flag'); $action->setParentKey('video-moderate'); $action->setLabel($lang->text('base', 'flag')); $action->setId('btn-video-flag'); $action->addAttribute('rel', $videoId); $action->addAttribute('url', OW::getRouter()->urlForRoute('view_video', array('id' => $video->id))); $context->addAction($action); $this->assign('canReport', true); } if ( $ownerMode || $modPermissions ) { $action = new BASE_ContextAction(); $action->setKey('edit'); $action->setParentKey('video-moderate'); $action->setLabel($lang->text('base', 'edit')); $action->setId('btn-video-edit'); $action->addAttribute('rel', $videoId); $context->addAction($action); $action = new BASE_ContextAction(); $action->setKey('delete'); $action->setParentKey('video-moderate'); $action->setLabel($lang->text('base', 'delete')); $action->setId('video-delete'); $action->addAttribute('rel', $videoId); $context->addAction($action); $this->assign('canEdit', true); } if ( $modPermissions ) { if ( $is_featured ) { $action = new BASE_ContextAction(); $action->setKey('unmark-featured'); $action->setParentKey('video-moderate'); $action->setLabel($lang->text('video', 'remove_from_featured')); $action->setId('video-mark-featured'); $action->addAttribute('rel', 'remove_from_featured'); $action->addAttribute('video-id', $videoId); $context->addAction($action); $this->assign('isFeature', true); } else { $action = new BASE_ContextAction(); $action->setKey('mark-featured'); $action->setParentKey('video-moderate'); $action->setLabel($lang->text('video', 'mark_featured')); $action->setId('video-mark-featured'); $action->addAttribute('rel', 'mark_featured'); $action->addAttribute('video-id', $videoId); $context->addAction($action); $this->assign('isFeature', false); } $this->assign('canMakeFeature', true); } $this->addComponent('contextAction', $context); $avatar = BOL_AvatarService::getInstance()->getDataForUserAvatars(array($contentOwner), true, true, true, false); $this->assign('avatar', $avatar[$contentOwner]); */ }
/** * Video view action * * @param array $params * @throws Redirect404Exception */ public function view(array $params) { if (!isset($params['id']) || !($id = (int) $params['id'])) { throw new Redirect404Exception(); } $clip = $this->clipService->findClipById($id); if (!$clip) { throw new Redirect404Exception(); } $userId = OW::getUser()->getId(); $contentOwner = (int) $this->clipService->findClipOwner($id); $ownerMode = $contentOwner == $userId; // is moderator $modPermissions = OW::getUser()->isAuthorized('video'); if ($clip->status != "approved" && !($modPermissions || $ownerMode)) { throw new Redirect403Exception(); } $language = OW_Language::getInstance(); $description = $clip->description; $clip->description = UTIL_HtmlTag::autoLink($clip->description); $this->assign('clip', $clip); $is_featured = VIDEO_BOL_ClipFeaturedService::getInstance()->isFeatured($clip->id); $this->assign('featured', $is_featured); $this->assign('moderatorMode', $modPermissions); $this->assign('ownerMode', $ownerMode); if (!$ownerMode && !OW::getUser()->isAuthorized('video', 'view') && !$modPermissions) { $error = BOL_AuthorizationService::getInstance()->getActionStatus('video', 'view'); throw new AuthorizationException($error['msg']); } // permissions check if (!$ownerMode && !$modPermissions) { $privacyParams = array('action' => 'video_view_video', 'ownerId' => $contentOwner, 'viewerId' => $userId); $event = new OW_Event('privacy_check_permission', $privacyParams); OW::getEventManager()->trigger($event); } $cmtParams = new BASE_CommentsParams('video', 'video_comments'); $cmtParams->setEntityId($id); $cmtParams->setOwnerId($contentOwner); $cmtParams->setDisplayType(BASE_CommentsParams::DISPLAY_TYPE_BOTTOM_FORM_WITH_FULL_LIST); $cmtParams->setAddComment($clip->status == "approved"); $videoCmts = new BASE_CMP_Comments($cmtParams); $this->addComponent('comments', $videoCmts); if ($clip->status == "approved") { $videoRates = new BASE_CMP_Rate('video', 'video_rates', $id, $contentOwner); $this->addComponent('rate', $videoRates); } $videoTags = new BASE_CMP_EntityTagCloud('video'); $videoTags->setEntityId($id); $videoTags->setRouteName('view_tagged_list'); $this->addComponent('tags', $videoTags); $username = BOL_UserService::getInstance()->getUserName($clip->userId); $this->assign('username', $username); $displayName = BOL_UserService::getInstance()->getDisplayName($clip->userId); $this->assign('displayName', $displayName); OW::getDocument()->addScript($this->pluginJsUrl . 'video.js'); $objParams = array('ajaxResponder' => $this->ajaxResponder, 'clipId' => $id, 'txtDelConfirm' => OW::getLanguage()->text('video', 'confirm_delete'), 'txtMarkFeatured' => OW::getLanguage()->text('video', 'mark_featured'), 'txtRemoveFromFeatured' => OW::getLanguage()->text('video', 'remove_from_featured'), 'txtApprove' => OW::getLanguage()->text('base', 'approve'), 'txtDisapprove' => OW::getLanguage()->text('base', 'disapprove')); $script = "\$(document).ready(function(){\n var clip = new videoClip( " . json_encode($objParams) . ");\n }); "; OW::getDocument()->addOnloadScript($script); $pendingApprovalString = ""; if ($clip->status != "approved") { $pendingApprovalString = '<span class="ow_remark ow_small">(' . OW::getLanguage()->text("base", "pending_approval") . ')</span>'; } OW::getDocument()->setHeading($clip->title . " " . $pendingApprovalString); OW::getDocument()->setHeadingIconClass('ow_ic_video'); $toolbar = array(); $toolbarEvent = new BASE_CLASS_EventCollector('video.collect_video_toolbar_items', array('clipId' => $clip->id, 'clipDto' => $clip)); OW::getEventManager()->trigger($toolbarEvent); foreach ($toolbarEvent->getData() as $toolbarItem) { array_push($toolbar, $toolbarItem); } if ($clip->status == "approved" && OW::getUser()->isAuthenticated() && !$ownerMode) { array_push($toolbar, array('href' => 'javascript://', 'id' => 'btn-video-flag', 'label' => $language->text('base', 'flag'))); } if ($ownerMode || $modPermissions) { array_push($toolbar, array('href' => OW::getRouter()->urlForRoute('edit_clip', array('id' => $clip->id)), 'label' => $language->text('base', 'edit'))); array_push($toolbar, array('href' => 'javascript://', 'id' => 'clip-delete', 'label' => $language->text('base', 'delete'))); } if ($modPermissions) { if ($is_featured) { array_push($toolbar, array('href' => 'javascript://', 'id' => 'clip-mark-featured', 'rel' => 'remove_from_featured', 'label' => $language->text('video', 'remove_from_featured'))); } else { array_push($toolbar, array('href' => 'javascript://', 'id' => 'clip-mark-featured', 'rel' => 'mark_featured', 'label' => $language->text('video', 'mark_featured'))); } if ($clip->status != 'approved') { array_push($toolbar, array('href' => OW::getRouter()->urlFor(__CLASS__, "approve", array("clipId" => $clip->id)), 'label' => $language->text('base', 'approve'), "class" => "ow_green")); } } $this->assign('toolbar', $toolbar); $js = UTIL_JsGenerator::newInstance()->jQueryEvent('#btn-video-flag', 'click', 'OW.flagContent(e.data.entity, e.data.id);', array('e'), array('entity' => VIDEO_BOL_ClipService::ENTITY_TYPE, 'id' => $clip->id)); OW::getDocument()->addOnloadScript($js, 1001); OW::getDocument()->setTitle($language->text('video', 'meta_title_video_view', array('title' => $clip->title))); $tagsArr = BOL_TagService::getInstance()->findEntityTags($clip->id, 'video'); $labels = array(); foreach ($tagsArr as $t) { $labels[] = $t->label; } $tagStr = $tagsArr ? implode(', ', $labels) : ''; OW::getDocument()->setDescription($language->text('video', 'meta_description_video_view', array('title' => $clip->title, 'tags' => $tagStr))); $clipThumbUrl = $this->clipService->getClipThumbUrl($id); $this->assign('clipThumbUrl', $clipThumbUrl); }
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; }