Example #1
0
 /**
  * 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]);
 }
Example #2
0
 /**
  * Tagged vwls list view action
  *
  * @param array $params
  */
 public function viewTaggedList(array $params = null)
 {
     // is moderator
     $modPermissions = OW::getUser()->isAuthorized('vwls');
     if (!OW::getUser()->isAuthorized('vwls', 'view') && !$modPermissions) {
         $this->setTemplate(OW::getPluginManager()->getPlugin('base')->getCtrlViewDir() . 'authorization_failed.html');
         return;
     }
     $tag = !empty($params['tag']) ? trim(htmlspecialchars(urldecode($params['tag']))) : '';
     $this->addComponent('vwlsMenu', $this->menu);
     $this->menu->getElement('tagged')->setActive(true);
     $this->setTemplate(OW::getPluginManager()->getPlugin('vwls')->getCtrlViewDir() . 'vwls_view_list-tagged.html');
     $listUrl = OW::getRouter()->urlForRoute('vwview_taggedlist_st_ls');
     OW::getDocument()->addScript($this->pluginJsUrl . 'vwls_tag_search.js');
     $objParams = array('listUrl' => $listUrl);
     $script = "\$(document).ready(function(){\n                var vwlsSearch = new vwlsTagSearch(" . json_encode($objParams) . ");\n            }); ";
     OW::getDocument()->addOnloadScript($script);
     if (strlen($tag)) {
         $this->assign('tag', $tag);
         OW::getDocument()->setTitle(OW::getLanguage()->text('vwls', 'meta_title_vwls_tagged_as', array('tag' => $tag)));
         OW::getDocument()->setDescription(OW::getLanguage()->text('vwls', 'meta_description_vwls_tagged_as', array('tag' => $tag)));
     } else {
         $tags = new BASE_CMP_EntityTagCloud('vwls');
         $tags->setRouteName('vwview_tagged_list_ls');
         $this->addComponent('tags', $tags);
         OW::getDocument()->setTitle(OW::getLanguage()->text('vwls', 'meta_title_vwls_tagged'));
         $tagsArr = BOL_TagService::getInstance()->findMostPopularTags('vwls', 20);
         foreach ($tagsArr as $t) {
             $labels[] = $t['label'];
         }
         $tagStr = $tagsArr ? implode(', ', $labels) : '';
         OW::getDocument()->setDescription(OW::getLanguage()->text('vwls', 'meta_description_vwls_tagged', array('topTags' => $tagStr)));
     }
     $this->assign('listType', 'tagged');
     OW::getDocument()->setHeading(OW::getLanguage()->text('vwls', 'page_title_browse_vwls'));
     OW::getDocument()->setHeadingIconClass('ow_ic_vwls');
     $js = UTIL_JsGenerator::newInstance()->newVariable('addNewUrl', OW::getRouter()->urlFor('VWLS_CTRL_Add', 'index'))->jQueryEvent('#btn-add-new-vwls', 'click', 'document.location.href = addNewUrl');
     OW::getDocument()->addOnloadScript($js);
 }
Example #3
0
 public function index()
 {
     if (!OW::getUser()->isAuthorized('links', 'view')) {
         $this->setTemplate(OW::getPluginManager()->getPlugin('base')->getCtrlViewDir() . 'authorization_failed.html');
         return;
     }
     $this->assign('addNew_isAuthorized', OW::getUser()->isAuthenticated() && OW::getUser()->isAuthorized('links', 'add'));
     switch (OW::getConfig()->getValue('links', 'result_mode')) {
         case LinkService::RESULT_MODE_SUM:
             $this->assign('mode', 'sum');
             break;
         case LinkService::RESULT_MODE_DETAILED:
             $this->assign('mode', 'detailed');
             break;
     }
     $this->setPageHeading(OW::getLanguage()->text('links', 'list_page_heading'));
     $this->setPageHeadingIconClass('ow_ic_link');
     $plugin = OW::getPluginManager()->getPlugin('links');
     OW::getNavigation()->activateMenuItem(OW_Navigation::MAIN, $plugin->getKey(), 'main_menu_item');
     if (false === strstr($_SERVER['REQUEST_URI'], 'browse-by-tag')) {
         $isBrowseByTagCase = false;
     } else {
         $this->assign('tag', empty($_GET['tag']) ? '' : strip_tags($_GET['tag']));
         $isBrowseByTagCase = true;
     }
     $this->assign('isBrowseByTagCase', $isBrowseByTagCase);
     $tagCloud = new BASE_CMP_EntityTagCloud('link', OW::getRouter()->urlForRoute('links-by-tag'));
     if ($isBrowseByTagCase) {
         $tagCloud->setTemplate(OW::getPluginManager()->getPlugin('base')->getCmpViewDir() . 'big_tag_cloud.html');
     }
     $this->addComponent('tagCloud', $tagCloud);
     $tagSearch = new BASE_CMP_TagSearch(OW::getRouter()->urlForRoute('links-by-tag'));
     $this->addComponent('tagSearch', $tagSearch);
     //~~
     $menu = new BASE_CMP_ContentMenu($this->getMenuItems());
     $this->assign('menu', $menu->render());
     $service = LinkService::getInstance();
     $rpp = (int) OW::getConfig()->getValue('links', 'results_per_page');
     $page = !empty($_GET['page']) && (int) $_GET['page'] ? (int) $_GET['page'] : 1;
     $first = ($page - 1) * $rpp;
     $count = $rpp;
     $list = array();
     $itemsCount = 0;
     list($list, $itemsCount) = $this->getData($first, $count);
     $descLength = 120;
     //$this->assign('descLength', $descLength);
     $titleLength = 50;
     $this->assign('titleLength', $titleLength);
     $voteService = BOL_VoteService::getInstance();
     $idList = array();
     $links = array();
     $voteTotall = array();
     $authorIdList = array();
     $commentTotall = array();
     foreach ($list as $item) {
         $link = $item['dto'];
         $link->setUrl(strip_tags($link->getUrl()));
         $link->setTitle(strip_tags($link->getTitle()));
         $description = BASE_CMP_TextFormatter::fromBBtoHtml($link->getDescription());
         $description = strip_tags($description);
         if (strlen($description) > $descLength) {
             $description = UTIL_String::truncate($description, $descLength, '...');
             $description .= ' <a href="' . OW::getRouter()->urlForRoute('link', array('id' => $link->getId())) . '" class="ow_lbutton">' . OW::getLanguage()->text('base', 'more') . '</a>';
         }
         $link->setDescription($description);
         $links[$link->getId()] = array('dto' => $link);
         $idList[] = $link->getId();
         $authorIdList[] = $link->getUserId();
     }
     $ulist = BOL_UserService::getInstance()->getUserNamesForList($authorIdList);
     $nlist = BOL_UserService::getInstance()->getDisplayNamesForList($authorIdList);
     $this->assign('usernameList', $ulist);
     $this->assign('nameList', $nlist);
     if (!empty($idList)) {
         $commentTotall = BOL_CommentService::getInstance()->findCommentCountForEntityList('link', $idList);
         $voteTotall = $voteService->findTotalVotesResultForList($idList, 'link');
         $tagsInfo = BOL_TagService::getInstance()->findTagListByEntityIdList('link', $idList);
         $this->assign('tagsInfo', $tagsInfo);
         $toolbars = array();
         foreach ($list as $item) {
             $dto = $item['dto'];
             $toolbars[$dto->id] = array();
             $userId = $dto->userId;
             $toolbars[$dto->id][] = array('class' => ' ow_icon_control ow_ic_user', 'label' => !empty($nlist[$userId]) ? $nlist[$userId] : OW::getLanguage()->text('base', 'deleted_user'), 'href' => !empty($ulist[$userId]) ? BOL_UserService::getInstance()->getUserUrlForUsername($ulist[$userId]) : '#');
             $toolbars[$dto->id][] = array('href' => OW::getRouter()->urlForRoute('link', array('id' => $dto->id)), 'label' => UTIL_DateTime::formatDate($dto->timestamp));
             if ($commentTotall[$dto->id]) {
                 $toolbars[$dto->id][] = array('href' => OW::getRouter()->urlForRoute('link', array('id' => $dto->id)) . "#comments", 'label' => '<span class="ow_txt_value">' . $commentTotall[$dto->id] . '</span> ' . OW::getLanguage()->text('links', 'toolbar_comments'));
             }
             if (empty($tagsInfo[$dto->id])) {
                 continue;
             }
             $value = OW::getLanguage()->text('links', 'tags') . ' ';
             $c = 0;
             foreach ($tagsInfo[$dto->id] as $tag) {
                 if ($c == 3) {
                     break;
                 }
                 $value .= '<a href="' . OW::getRouter()->urlForRoute('links-by-tag') . "?tag={$tag}" . "\">{$tag}</a>, ";
                 $c++;
             }
             $value = mb_substr($value, 0, mb_strlen($value) - 2);
             $toolbars[$dto->id][] = array('label' => $value);
         }
         if (OW::getUser()->isAuthenticated()) {
             $userVotes = $voteService->findUserVoteForList($idList, 'link', OW::getUser()->getId());
             $this->assign('userVotes', $userVotes);
         }
         $this->assign('tb', $toolbars);
     }
     foreach ($voteTotall as $val) {
         $links[$val['id']]['isVoted'] = true;
         $links[$val['id']]['voteTotal'] = $val['sum'];
         $links[$val['id']]['up'] = $val['up'];
         $links[$val['id']]['down'] = $val['down'];
     }
     $this->assign('commentTotall', $commentTotall);
     $this->assign('list', $links);
     $this->assign('url_new_link', OW::getRouter()->urlForRoute('link-save-new'));
     $paging = new BASE_CMP_Paging($page, ceil($itemsCount / $rpp), 5);
     $this->assign('paging', $paging->render());
     $this->assign('isAuthenticated', OW::getUser()->isAuthenticated());
 }
Example #4
0
 public function index($params)
 {
     $username = !empty($params['user']) ? $params['user'] : '';
     $id = $params['id'];
     $plugin = OW::getPluginManager()->getPlugin('blogs');
     OW::getNavigation()->activateMenuItem(OW_Navigation::MAIN, 'blogs', 'main_menu_item');
     $service = PostService::getInstance();
     $userService = BOL_UserService::getInstance();
     $this->assign('user', OW::getUser()->getId() !== null ? $userService->findUserById(OW::getUser()->getId()) : null);
     $post = $service->findById($id);
     if ($post === null) {
         throw new Redirect404Exception();
     }
     if ($post->isDraft() && $post->authorId != OW::getUser()->getId()) {
         throw new Redirect404Exception();
     }
     $post->post = BASE_CMP_TextFormatter::fromBBtoHtml($post->post);
     $post->setTitle(strip_tags($post->getTitle()));
     if (!OW::getUser()->isAuthorized('blogs', 'view')) {
         $this->setTemplate(OW::getPluginManager()->getPlugin('base')->getCtrlViewDir() . 'authorization_failed.html');
         return;
     }
     if (OW::getUser()->isAuthenticated() && OW::getUser()->getId() != $post->getAuthorId() && !OW::getUser()->isAuthorized('blogs', 'view')) {
         $this->setTemplate(OW::getPluginManager()->getPlugin('base')->getCtrlViewDir() . 'authorization_failed.html');
         return;
     }
     /* Check privacy permissions */
     if ($post->authorId != OW::getUser()->getId() && !OW::getUser()->isAuthorized('blogs')) {
         $eventParams = array('action' => 'blogs_view_blog_posts', 'ownerId' => $post->authorId, 'viewerId' => OW::getUser()->getId());
         OW::getEventManager()->getInstance()->call('privacy_check_permission', $eventParams);
     }
     /* */
     $parts = explode('<!--page-->', $post->getPost());
     $page = !empty($_GET['page']) ? $_GET['page'] : 1;
     $count = count($parts);
     if (strlen($username) > 0) {
         $author = $userService->findByUsername($username);
     } else {
         $author = $userService->findUserById($post->getAuthorId());
         $isAuthorExists = !empty($author);
         if ($isAuthorExists) {
             $username = $author->getUsername();
         }
     }
     $this->assign('isAuthorExists', $isAuthorExists);
     if ($isAuthorExists) {
         $displayName = $userService->getDisplayName($author->getId());
         $this->assign('username', $userService->getUserName($author->getId()));
         $this->assign('displayname', $displayName);
         $url = OW::getRouter()->urlForRoute('user-blog', array('user' => $username));
         $this->setPageHeading(OW::getLanguage()->text('blogs', 'view_page_heading', array('url' => $url, 'name' => $displayName, 'postTitle' => htmlspecialchars($post->getTitle()))));
         $this->setPageHeadingIconClass('ow_ic_write');
         OW::getDocument()->setTitle(OW::getLanguage()->text('blogs', 'blog_post_title', array('post_title' => htmlspecialchars($post->getTitle()), 'display_name' => $displayName)));
         $post_body = UTIL_String::truncate($post->getPost(), 200, '...');
         $postTagsArray = BOL_TagService::getInstance()->findEntityTags($post->getId(), 'blog-post');
         $postTags = "";
         foreach ($postTagsArray as $tag) {
             $postTags .= $tag->label . ", ";
         }
         $postTags = substr($postTags, 0, -2);
         OW::getDocument()->setDescription(OW::getLanguage()->text('blogs', 'blog_post_description', array('post_body' => htmlspecialchars(strip_tags($post_body)), 'tags' => htmlspecialchars($postTags))));
         //OW::getDocument()->setKeywords(OW::getLanguage()->text('nav', 'page_default_keywords').", ".$postTags);
     }
     $info = array('dto' => $post, 'text' => $parts[$page - 1]);
     $this->assign('info', $info);
     if ($isAuthorExists) {
         //blog navigation
         $prev = $service->findAdjacentUserPost($author->getId(), $post->getId(), 'prev');
         $next = $service->findAdjacentUserPost($author->getId(), $post->getId(), 'next');
         if (!empty($prev)) {
             $prevUser = $userService->findUserById($prev->getAuthorId());
         }
         if (!empty($next)) {
             $nextUser = $userService->findUserById($next->getAuthorId());
         }
         $this->assign('adjasentUrl', array('next' => !empty($nextUser) ? OW::getRouter()->urlForRoute('user-post', array('id' => $next->getId(), 'user' => $nextUser->getUsername())) : '', 'prev' => !empty($prevUser) ? OW::getRouter()->urlForRoute('user-post', array('id' => $prev->getId(), 'user' => $prevUser->getUsername())) : '', 'index' => OW::getRouter()->urlForRoute('user-blog', array('user' => $author->getUsername()))));
     } else {
         $this->assign('adjasentUrl', null);
     }
     //~blog navigation
     //toolbar
     $tb = array();
     $toolbarEvent = new BASE_CLASS_EventCollector('blogs.collect_post_toolbar_items', array('postId' => $post->id, 'postDto' => $post));
     OW::getEventManager()->trigger($toolbarEvent);
     foreach ($toolbarEvent->getData() as $toolbarItem) {
         array_push($tb, $toolbarItem);
     }
     if (OW::getUser()->isAuthenticated() && $post->getAuthorId() != OW::getUser()->getId()) {
         $js = UTIL_JsGenerator::newInstance()->jQueryEvent('#blog_post_toolbar_flag', 'click', UTIL_JsGenerator::composeJsString('OW.flagContent({$entity}, {$id}, {$title}, {$href}, "blogs+flags");', array('entity' => 'blog_post', 'id' => $post->getId(), 'title' => htmlspecialchars(json_encode($post->getTitle())), 'href' => OW::getRouter()->urlForRoute('user-post', array('id' => $post->getId())))));
         OW::getDocument()->addOnloadScript($js, 1001);
         $tb[] = array('label' => OW::getLanguage()->text('base', 'flag'), 'href' => 'javascript://', 'id' => 'blog_post_toolbar_flag');
     }
     if (OW::getUser()->isAuthenticated() && (OW::getUser()->getId() == $post->getAuthorId() || BOL_AuthorizationService::getInstance()->isModerator(OW::getUser()->getId()))) {
         $tb[] = array('href' => OW::getRouter()->urlForRoute('post-save-edit', array('id' => $post->getId())), 'label' => OW::getLanguage()->text('blogs', 'toolbar_edit'));
         $tb[] = array('href' => OW::getRouter()->urlFor('BLOGS_CTRL_Save', 'delete', array('id' => $post->getId())), 'click' => "return confirm('" . OW::getLanguage()->text('base', 'are_you_sure') . "');", 'label' => OW::getLanguage()->text('blogs', 'toolbar_delete'));
     }
     $this->assign('tb', $tb);
     //~toolbar
     $paging = new BASE_CMP_Paging($page, $count, $count);
     //<ARCHIVE-NAVIGATOR>
     $this->assign('paging', $paging->render());
     if ($isAuthorExists) {
         $rows = $service->findUserArchiveData($author->getId());
         $archive = array();
         foreach ($rows as $row) {
             if (!array_key_exists($row['y'], $archive)) {
                 $archive[$row['y']] = array();
             }
             $archive[$row['y']][] = $row['m'];
         }
         $this->assign('archive', $archive);
     }
     //</ARCHIVE-NAVIGATOR>
     if ($isAuthorExists) {
         $this->assign('author', $author);
     }
     $this->assign('isModerator', OW::getUser()->isAuthorized('blogs'));
     if ($isAuthorExists) {
         $this->assign('userBlogUrl', OW::getRouter()->urlForRoute('user-blog', array('user' => $author->getUsername())));
     }
     /* Check comments privacy permissions */
     $allow_comments = true;
     if ($post->authorId != OW::getUser()->getId() && !OW::getUser()->isAuthorized('blogs')) {
         $eventParams = array('action' => 'blogs_comment_blog_posts', 'ownerId' => $post->authorId, 'viewerId' => OW::getUser()->getId());
         try {
             OW::getEventManager()->getInstance()->call('privacy_check_permission', $eventParams);
         } catch (RedirectException $ex) {
             $allow_comments = false;
         }
     }
     /* */
     // additional components
     $cmpParams = new BASE_CommentsParams('blogs', 'blog-post');
     $cmpParams->setEntityId($post->getId())->setOwnerId($post->getAuthorId())->setDisplayType(BASE_CommentsParams::DISPLAY_TYPE_BOTTOM_FORM_WITH_FULL_LIST)->setAddComment($allow_comments);
     $this->addComponent('comments', new BASE_CMP_Comments($cmpParams));
     $this->assign('avatarUrl', '');
     $tagCloud = new BASE_CMP_EntityTagCloud('blog-post', OW::getRouter()->urlForRoute('blogs.list', array('list' => 'browse-by-tag')));
     $tagCloud->setEntityId($post->getId());
     $rateInfo = new BASE_CMP_Rate('blogs', 'blog-post', $post->getId(), $post->getAuthorId());
     $this->addComponent('rate', $rateInfo);
     $this->addComponent('tagCloud', $tagCloud);
     //~ additional components
 }
Example #5
0
 public function viewvideo($params)
 {
     if (!isset($params['id']) || !($id = (int) $params['id'])) {
         throw new Redirect404Exception();
         return;
     }
     $id = empty($params['id']) ? 0 : (int) $params['id'];
     $modPermissions = OW::getUser()->isAuthorized('ivideo');
     $contentOwner = (int) IVIDEO_BOL_Service::getInstance()->findVideoOwner($id);
     $userId = OW::getUser()->getId();
     $ownerMode = $contentOwner == $userId;
     if (!$ownerMode && !OW::getUser()->isAuthorized('ivideo', 'view') && !$modPermissions) {
         $this->setTemplate(OW::getPluginManager()->getPlugin('base')->getCtrlViewDir() . 'authorization_failed.html');
         return;
     }
     $item = IVIDEO_BOL_VideoDao::getInstance()->findById((int) $id);
     if (!$ownerMode && !$modPermissions) {
         $privacyParams = array('action' => 'ivideo_view_video', 'ownerId' => $contentOwner, 'viewerId' => $userId);
         $event = new OW_Event('privacy_check_permission', $privacyParams);
         OW::getEventManager()->trigger($event);
     }
     $eventParams = array('pluginKey' => 'ivideo', 'action' => 'view_video');
     $credits = OW::getEventManager()->call('usercredits.check_balance', $eventParams);
     if ($credits === false) {
         $this->assign('authMsg', OW::getEventManager()->call('usercredits.error_message', $eventParams));
         return;
     } else {
         $this->assign('authMsg', null);
     }
     $language = OW::getLanguage();
     if (is_null($item)) {
         OW::getFeedback()->error($language->text('ivideo', 'view_invalid_video_error'));
         $this->redirect(OW::getRouter()->urlForRoute('ivideo_view_list', array('type' => 'latest')));
     }
     $this->setPageTitle($item->name);
     $this->setPageHeading($item->name);
     $this->assign('isAdmin', OW::getUser()->isAdmin());
     $this->assign('item', $item);
     $allow_comments = true;
     if ($item->owner != OW::getUser()->getId() && !OW::getUser()->isAuthorized('ivideo')) {
         $eventParams = array('action' => 'add_comment', 'ownerId' => $item->id, 'viewerId' => OW::getUser()->getId());
         try {
             OW::getEventManager()->getInstance()->call('privacy_check_permission', $eventParams);
         } catch (RedirectException $ex) {
             $allow_comments = false;
         }
     }
     OW::getDocument()->addScript(OW::getPluginManager()->getPlugin('ivideo')->getStaticJsUrl() . 'ivideo.js');
     $objParams = array('ajaxResponder' => $this->ajaxResponder, 'id' => $item->id, 'txtDelConfirm' => OW::getLanguage()->text('ivideo', 'confirm_delete'), 'txtMarkFeatured' => OW::getLanguage()->text('ivideo', 'mark_featured'), 'txtRemoveFromFeatured' => OW::getLanguage()->text('ivideo', 'remove_from_featured'), 'txtApprove' => OW::getLanguage()->text('base', 'approve'), 'txtDisapprove' => OW::getLanguage()->text('base', 'disapprove'));
     $script = "\$(document).ready(function(){\n                var clip = new ivideoClip( " . json_encode($objParams) . ");\n            }); ";
     OW::getDocument()->addOnloadScript($script);
     $cmpParams = new BASE_CommentsParams('ivideo', 'ivideo-comments');
     $cmpParams->setEntityId($item->id)->setOwnerId($item->owner)->setDisplayType(BASE_CommentsParams::DISPLAY_TYPE_BOTTOM_FORM_WITH_FULL_LIST)->setAddComment($allow_comments);
     $this->addComponent('comments', new BASE_CMP_Comments($cmpParams));
     $rateInfo = new BASE_CMP_Rate('ivideo', 'ivideo-rates', $item->id, $item->owner);
     $this->addComponent('rate', $rateInfo);
     $postTagsArray = BOL_TagService::getInstance()->findEntityTags($item->getId(), 'ivideo-video');
     $postTags = "";
     foreach ($postTagsArray as $tag) {
         $postTags .= $tag->label . ", ";
     }
     $postTags = substr($postTags, 0, -2);
     $tagCloud = new BASE_CMP_EntityTagCloud('ivideo-video');
     $tagCloud->setEntityId($item->id);
     $tagCloud->setRouteName('ivideo_view_tagged_list');
     $this->addComponent('tagCloud', $tagCloud);
     $username = BOL_UserService::getInstance()->getUserName($item->owner);
     $this->assign('username', $username);
     $displayName = BOL_UserService::getInstance()->getDisplayName($item->owner);
     $this->assign('displayName', $displayName);
     $ownerMode = $item->owner == OW::getUser()->getId();
     $modPermissions = OW::getUser()->isAuthorized('ivideo');
     $is_featured = IVIDEO_BOL_VideoFeaturedService::getInstance()->isFeatured($item->id);
     $this->assign('featured', $is_featured);
     $categoryList = IVIDEO_BOL_VideoCategoryService::getInstance()->getVideoCategories($item->id);
     $this->assign('categoryList', $categoryList);
     $toolbar = array();
     if (OW::getUser()->isAuthenticated()) {
         array_push($toolbar, array('href' => 'javascript://', 'id' => 'btn-ivideo-flag', 'label' => $language->text('base', 'flag')));
     }
     if ($ownerMode || $modPermissions) {
         array_push($toolbar, array('href' => OW::getRouter()->urlForRoute('ivideo_edit_video', array('id' => $item->getId())), '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('ivideo', 'remove_from_featured')));
         } else {
             array_push($toolbar, array('href' => 'javascript://', 'id' => 'clip-mark-featured', 'rel' => 'mark_featured', 'label' => $language->text('ivideo', 'mark_featured')));
         }
         if ($item->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-ivideo-flag', 'click', 'OW.flagContent(e.data.entity, e.data.id, e.data.title, e.data.href, "ivideo+flags");', array('e'), array('entity' => 'ivideo_video', 'id' => $item->getId(), 'title' => $item->name, 'href' => OW::getRouter()->urlForRoute('ivideo_view_video', array('id' => $item->getId()))));
     OW::getDocument()->addOnloadScript($js, 1001);
     $this->assign('getUserFilesUrl', OW::getPluginManager()->getPlugin('ivideo')->getUserFilesUrl());
     $this->assign('videoWidth', OW::getConfig()->getValue('ivideo', 'videoWidth'));
     $this->assign('videoHeight', OW::getConfig()->getValue('ivideo', 'videoHeight'));
     $this->assign('videoType', UTIL_File::getExtension($item->filename));
     $jsURL = OW::getPluginManager()->getPlugin('ivideo')->getStaticJsUrl();
     $this->assign('jsURL', $jsURL);
     OW::getDocument()->addScript($jsURL . 'jquery.media.js');
     OW::getDocument()->addStyleSheet(OW::getPluginManager()->getPlugin('ivideo')->getStaticCssUrl() . 'video-js.css');
     OW::getDocument()->addCustomHeadInfo('<script src="' . $jsURL . 'video.js" type="text/javascript"></script>');
     OW::getDocument()->addCustomHeadInfo('<script type="text/javascript"> _V_.options.flash.swf ="' . $jsURL . 'video-js.swf"</script>');
     OW::getDocument()->addCustomHeadInfo('<script type="text/javascript"> _V_.options.techOrder = ["flash", "html5"]</script>');
 }
Example #6
0
 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]);
     */
 }
Example #7
0
 public function getTagCloudHtml($photoId)
 {
     $photoTags = new BASE_CMP_EntityTagCloud(UTAGS_CLASS_TagsBridge::ENTITY_PHOTO);
     $photoTags->setEntityId($photoId);
     $photoTags->setRouteName('view_tagged_photo_list');
     return trim($photoTags->render());
 }
Example #8
0
    /**
     * Tagged photo list action
     *
     * @param array $params
     */
    public function viewTaggedList(array $params = null)
    {
        if (isset($params['tag'])) {
            $tag = htmlspecialchars(urldecode($params['tag']));
        }
        // is moderator
        $modPermissions = OW::getUser()->isAuthorized('photo');
        if (!$modPermissions && !OW::getUser()->isAuthorized('photo', 'view')) {
            $this->setTemplate(OW::getPluginManager()->getPlugin('base')->getCtrlViewDir() . 'authorization_failed.html');
            return;
        }
        $this->addComponent('photoMenu', $this->menu);
        $this->menu->getElement('tagged')->setActive(true);
        $this->setTemplate(OW::getPluginManager()->getPlugin('advancedphoto')->getCtrlViewDir() . 'photo_view_list-tagged.html');
        $listUrl = OW::getRouter()->urlForRoute('view_tagged_photo_list_st');
        OW::getDocument()->addScript($this->photoPluginJsUrl . 'photo_tag_search.js');
        $objParams = array('listUrl' => $listUrl);
        $script = "\$(document).ready(function(){\n                var photoSearch = new photoTagSearch(" . json_encode($objParams) . ");\n            }); ";
        OW::getDocument()->addOnloadScript($script);
        if (isset($tag)) {
            $this->assign('tag', $tag);
            OW::getDocument()->setTitle(OW::getLanguage()->text('photo', 'meta_title_photo_tagged_as', array('tag' => $tag)));
            OW::getDocument()->setDescription(OW::getLanguage()->text('photo', 'meta_description_photo_tagged_as', array('tag' => $tag)));
            OW::getDocument()->addScript(OW::getPluginManager()->getPlugin('advancedphoto')->getStaticJsUrl() . 'hap.min.js');
            $script = '
				hap.initialize({request_url: "' . OW::getRouter()->urlForRoute('photo_list_index') . '", max_width: 220, listType: "tagged", tag: "' . $tag . '"});			  
			';
            OW::getDocument()->addOnloadScript($script);
            OW::getDocument()->addScript(OW::getPluginManager()->getPlugin('base')->getStaticJsUrl() . 'jquery.bbq.min.js');
            OW::getDocument()->addScript(OW::getPluginManager()->getPlugin('photo')->getStaticJsUrl() . 'photo.js');
            OW::getLanguage()->addKeyForJs('photo', 'tb_edit_photo');
            OW::getLanguage()->addKeyForJs('photo', 'confirm_delete');
            OW::getLanguage()->addKeyForJs('photo', 'mark_featured');
            OW::getLanguage()->addKeyForJs('photo', 'remove_from_featured');
            $objParams = array('ajaxResponder' => OW::getRouter()->urlFor('PHOTO_CTRL_Photo', 'ajaxResponder'), 'fbResponder' => OW::getRouter()->urlForRoute('photo.floatbox'));
            $script = '$("div.photo a").on("click", function(e){
				e.preventDefault();
				var photo_id = $(this).attr("rel");

				if ( !window.photoViewObj ) {
					window.photoViewObj = new photoView(' . json_encode($objParams) . ');
				}
				
				window.photoViewObj.setId(photo_id);
			}); 
			
			$(window).bind( "hashchange", function(e) {
				var photo_id = $.bbq.getState("view-photo");
				if ( photo_id != undefined )
				{
					if ( window.photoFBLoading ) { return; }
					window.photoViewObj.showPhotoCmp(photo_id);
				}
			});';
            OW::getDocument()->addOnloadScript($script);
        } else {
            $tags = new BASE_CMP_EntityTagCloud('photo');
            $tags->setRouteName('view_tagged_photo_list');
            $this->addComponent('tags', $tags);
            OW::getDocument()->setTitle(OW::getLanguage()->text('photo', 'meta_title_photo_tagged'));
            $tagsArr = BOL_TagService::getInstance()->findMostPopularTags('photo', 20);
            foreach ($tagsArr as $t) {
                $labels[] = $t['label'];
            }
            $tagStr = $tagsArr ? implode(', ', $labels) : '';
            OW::getDocument()->setDescription(OW::getLanguage()->text('photo', 'meta_description_photo_tagged', array('topTags' => $tagStr)));
        }
        $this->assign('listType', 'tagged');
        //OW::getDocument()->setHeading(OW::getLanguage()->text('photo', 'page_title_browse_photos'));
        //OW::getDocument()->setHeadingIconClass('ow_ic_picture');
        $js = UTIL_JsGenerator::newInstance()->newVariable('addNewUrl', OW::getRouter()->urlFor('PHOTO_CTRL_Upload', 'index'))->jQueryEvent('#btn-add-new-photo', 'click', 'document.location.href = addNewUrl');
        OW::getDocument()->addOnloadScript($js);
    }
Example #9
0
 public function view($params)
 {
     $event = $this->getEventForParams($params);
     $cmpId = UTIL_HtmlTag::generateAutoId('cmp');
     $this->assign('contId', $cmpId);
     $language = OW::getLanguage();
     if (!OW::getUser()->isAuthorized('eventx', 'view_event') && $event->getUserId() != OW::getUser()->getId()) {
         $this->assign('authErrorText', OW::getLanguage()->text('eventx', 'event_view_permission_error_message'));
         return;
     }
     // guest gan't view private events
     if ((int) $event->getWhoCanView() === EVENTX_BOL_EventService::CAN_VIEW_INVITATION_ONLY && !OW::getUser()->isAuthenticated()) {
         $this->redirect(OW::getRouter()->urlForRoute('eventx.private_event', array('eventId' => $event->getId())));
     }
     $eventInvite = $this->eventService->findEventInvite($event->getId(), OW::getUser()->getId());
     $eventUser = $this->eventService->findEventUser($event->getId(), OW::getUser()->getId());
     // check if user can view event
     if ((int) $event->getWhoCanView() === EVENTX_BOL_EventService::CAN_VIEW_INVITATION_ONLY && $eventUser === null && $eventInvite === null && !OW::getUser()->isAuthorized('eventx')) {
         $this->redirect(OW::getRouter()->urlForRoute('eventx.private_event', array('eventId' => $event->getId())));
     }
     $modPermissions = OW::getUser()->isAuthorized('eventx');
     $ownerMode = $event->getUserId() == OW::getUser()->getId();
     $whoCanDeleteEvent = explode(",", OW::getConfig()->getValue('eventx', 'eventDelete'));
     $toolbar = array();
     if (OW::getUser()->isAuthenticated()) {
         array_push($toolbar, array('href' => 'javascript://', 'id' => 'btn-eventx-flag', 'label' => OW::getLanguage()->text('base', 'flag')));
     }
     if ($ownerMode || $modPermissions) {
         array_push($toolbar, array('href' => OW::getRouter()->urlForRoute('eventx.edit', array('eventId' => $event->getId())), 'label' => OW::getLanguage()->text('eventx', 'edit_button_label')));
     }
     if ($modPermissions) {
         if ($event->status == 'approved') {
             array_push($toolbar, array('href' => 'javascript://', 'id' => 'eventx-set-approval-staus', 'rel' => 'disapprove', 'label' => $language->text('base', 'disapprove')));
         } else {
             array_push($toolbar, array('href' => 'javascript://', 'id' => 'eventx-set-approval-staus', 'rel' => 'approve', 'label' => $language->text('base', 'approve')));
         }
     }
     $canDelete = FALSE;
     if ($ownerMode && in_array(3, $whoCanDeleteEvent)) {
         $canDelete = TRUE;
     }
     if (OW::getUser()->isAuthorized('eventx') && in_array(2, $whoCanDeleteEvent)) {
         $canDelete = TRUE;
     }
     if (OW::getUser()->isAdmin() && in_array(1, $whoCanDeleteEvent)) {
         $canDelete = TRUE;
     }
     if ($canDelete) {
         array_push($toolbar, array('href' => 'javascript://', 'id' => 'eventx-delete', 'label' => OW::getLanguage()->text('eventx', 'delete_button_label')));
     }
     $this->assign('toolbar', $toolbar);
     OW::getNavigation()->activateMenuItem(OW_Navigation::MAIN, 'eventx', 'main_menu_item');
     $this->setPageHeading($event->getTitle());
     $this->setPageTitle(OW::getLanguage()->text('eventx', 'event_view_page_heading', array('event_title' => $event->getTitle())));
     $this->setPageHeadingIconClass('ow_ic_calendar');
     OW::getDocument()->setDescription(UTIL_String::truncate(strip_tags($event->getDescription()), 200, '...'));
     $maxInvites = $event->getMaxInvites();
     $currentInvites = $this->eventService->findEventUsersCount($event->getId(), EVENTX_BOL_EventService::USER_STATUS_YES);
     $isFullyBooked = $currentInvites >= $maxInvites && $maxInvites > 0;
     $infoArray = array('id' => $event->getId(), 'image' => $event->getImage() ? $this->eventService->generateImageUrl($event->getImage(), false) : null, 'date' => $this->eventService->formatSimpleDate($event->getStartTimeStamp(), $event->getStartTimeDisable()), 'endDate' => $event->getEndTimeStamp() === null || !$event->getEndDateFlag() ? null : $this->eventService->formatSimpleDate($event->getEndTimeDisable() ? strtotime("-1 day", $event->getEndTimeStamp()) : $event->getEndTimeStamp(), $event->getEndTimeDisable()), 'location' => $event->getLocation(), 'desc' => UTIL_HtmlTag::autoLink($event->getDescription()), 'title' => $event->getTitle(), 'maxInvites' => $maxInvites, 'currentInvites' => $currentInvites, 'availableInvites' => $maxInvites - $currentInvites, 'creatorName' => BOL_UserService::getInstance()->getDisplayName($event->getUserId()), 'creatorLink' => BOL_UserService::getInstance()->getUserUrl($event->getUserId()));
     $this->assign('info', $infoArray);
     // event attend form
     if (OW::getUser()->isAuthenticated() && $event->getEndTimeStamp() > time()) {
         if ($eventUser !== null) {
             $this->assign('currentStatus', OW::getLanguage()->text('eventx', 'user_status_label_' . $eventUser->getStatus()));
         }
         $this->addForm(new AttendForm($event->getId(), $cmpId));
         $onloadJs = "\n                var \$context = \$('#" . $cmpId . "');";
         $onloadJs .= " \$('#event_attend_yes_btn').click(\n                    function(){\n                        \$('input[name=attend_status]', \$context).val(" . EVENTX_BOL_EventService::USER_STATUS_YES . ");\n                    }\n                );\n                \n                \$('#event_attend_maybe_btn').click(\n                    function(){\n                        \$('input[name=attend_status]', \$context).val(" . EVENTX_BOL_EventService::USER_STATUS_MAYBE . ");\n                    }\n                );\n                \$('#event_attend_no_btn').click(\n                    function(){\n                        \$('input[name=attend_status]', \$context).val(" . EVENTX_BOL_EventService::USER_STATUS_NO . ");\n                    }\n                );\n\n                \$('.current_status a', \$context).click(\n                    function(){\n                        \$('.attend_buttons .buttons', \$context).fadeIn(500);\n                    }\n                );\n            ";
         OW::getDocument()->addOnloadScript($onloadJs);
     } else {
         $this->assign('no_attend_form', true);
     }
     if ($event->getEndTimeStamp() > time() && ((int) $event->getUserId() === OW::getUser()->getId() || (int) $event->getWhoCanInvite() === EVENTX_BOL_EventService::CAN_INVITE_PARTICIPANT && $eventUser !== null)) {
         $params = array($event->id);
         $this->assign('inviteLink', true);
         OW::getDocument()->addOnloadScript("\n                var eventFloatBox;\n                \$('#inviteLink', \$('#" . $cmpId . "')).click(\n                    function(){\n                        eventFloatBox = OW.ajaxFloatBox('EVENTX_CMP_InviteUserListSelect', " . json_encode($params) . ", {width:600, height:400, iconClass: 'ow_ic_user', title: '" . OW::getLanguage()->text('eventx', 'friends_invite_button_label') . "'});\n                    }\n                );\n                OW.bind('base.avatar_user_list_select',\n                    function(list){\n                        eventFloatBox.close();\n                        \$.ajax({\n                            type: 'POST',\n                            url: " . json_encode(OW::getRouter()->urlFor('EVENTX_CTRL_Base', 'inviteResponder')) . ",\n                            data: 'eventId=" . json_encode($event->getId()) . "&userIdList='+JSON.stringify(list),\n                            dataType: 'json',\n                            success : function(data){\n                                if( data.messageType == 'error' ){\n                                    OW.error(data.message);\n                                }\n                                else{\n                                    OW.info(data.message);\n                                }\n                            },\n                            error : function( XMLHttpRequest, textStatus, errorThrown ){\n                                OW.error(textStatus);\n                            }\n                        });\n                    }\n                );\n            ");
     }
     $cmntParams = new BASE_CommentsParams('eventx', 'eventx');
     $cmntParams->setEntityId($event->getId());
     $cmntParams->setOwnerId($event->getUserId());
     $this->addComponent('comments', new BASE_CMP_Comments($cmntParams));
     $this->addComponent('userListCmp', new EVENTX_CMP_EventUsers($event->getId()));
     $tagCloud = new BASE_CMP_EntityTagCloud('eventx');
     $tagCloud->setEntityId($event->id);
     $tagCloud->setRouteName('eventx_view_tagged_list');
     $this->addComponent('tagCloud', $tagCloud);
     OW::getDocument()->addScript(OW::getPluginManager()->getPlugin("eventx")->getStaticJsUrl() . 'eventx.js');
     OW::getDocument()->addScript("http://maps.google.com/maps/api/js?sensor=false");
     OW::getDocument()->addScript(OW::getPluginManager()->getPlugin("eventx")->getStaticJsUrl() . 'jquery.gmap.min.js');
     $objParams = array('ajaxResponder' => $this->ajaxResponder, 'id' => $event->getId(), 'txtDelConfirm' => $language->text('eventx', 'confirm_delete'), 'txtApprove' => $language->text('base', 'approve'), 'txtDisapprove' => $language->text('base', 'disapprove'));
     $script = "\$(document).ready(function(){\n                   var item = new eventxItem( " . json_encode($objParams) . ");\n                 });";
     OW::getDocument()->addOnloadScript($script);
     $js = UTIL_JsGenerator::newInstance()->jQueryEvent('#btn-eventx-flag', 'click', 'OW.flagContent(e.data.entity, e.data.id, e.data.title, e.data.href, "eventx+flags");', array('e'), array('entity' => 'eventx_event', 'id' => $event->getId(), 'title' => $event->getTitle(), 'href' => OW::getRouter()->urlForRoute('eventx.view', array('eventId' => $event->getId()))));
     OW::getDocument()->addOnloadScript($js, 1001);
     $categoryList = $this->eventService->getItemCategories($event->id);
     $i = 0;
     $categoryUrlList = array();
     foreach ($categoryList as $category) {
         $catName = $this->eventService->getCategoryName($category->categoryId);
         $categoryUrlList[$i]['id'] = $category->categoryId;
         $categoryUrlList[$i]['name'] = $catName;
         $categoryUrlList[$i]['url'] = OW::getRouter()->urlForRoute('eventx_category_items', array('category' => $catName));
         $i += 1;
     }
     $this->assign('categoryUrl', $categoryUrlList);
     $this->assign('mapWidth', OW::getConfig()->getValue('eventx', 'mapWidth'));
     $this->assign('mapHeight', OW::getConfig()->getValue('eventx', 'mapHeight'));
 }
Example #10
0
 /**
  * Tagged video list view action
  *
  * @param array $params
  * @throws AuthorizationException
  */
 public function viewTaggedList(array $params = null)
 {
     // is moderator
     $modPermissions = OW::getUser()->isAuthorized('video');
     if (!OW::getUser()->isAuthorized('video', 'view') && !$modPermissions) {
         $error = BOL_AuthorizationService::getInstance()->getActionStatus('video', 'view');
         throw new AuthorizationException($error['msg']);
     }
     $tag = !empty($params['tag']) ? trim(htmlspecialchars(urldecode($params['tag']))) : '';
     $this->addComponent('videoMenu', $this->menu);
     $this->menu->getElement('tagged')->setActive(true);
     $this->setTemplate(OW::getPluginManager()->getPlugin('video')->getCtrlViewDir() . 'video_view_list-tagged.html');
     $listUrl = OW::getRouter()->urlForRoute('view_tagged_list_st');
     OW::getDocument()->addScript($this->pluginJsUrl . 'video_tag_search.js');
     $objParams = array('listUrl' => $listUrl);
     $script = "\$(document).ready(function(){\n                var videoSearch = new videoTagSearch(" . json_encode($objParams) . ");\n            }); ";
     OW::getDocument()->addOnloadScript($script);
     if (strlen($tag)) {
         $this->assign('tag', $tag);
         OW::getDocument()->setTitle(OW::getLanguage()->text('video', 'meta_title_video_tagged_as', array('tag' => $tag)));
         OW::getDocument()->setDescription(OW::getLanguage()->text('video', 'meta_description_video_tagged_as', array('tag' => $tag)));
     } else {
         $tags = new BASE_CMP_EntityTagCloud('video');
         $tags->setRouteName('view_tagged_list');
         $this->addComponent('tags', $tags);
         OW::getDocument()->setTitle(OW::getLanguage()->text('video', 'meta_title_video_tagged'));
         $tagsArr = BOL_TagService::getInstance()->findMostPopularTags('video', 20);
         $labels = array();
         foreach ($tagsArr as $t) {
             $labels[] = $t['label'];
         }
         $tagStr = $tagsArr ? implode(', ', $labels) : '';
         OW::getDocument()->setDescription(OW::getLanguage()->text('video', 'meta_description_video_tagged', array('topTags' => $tagStr)));
     }
     $this->assign('listType', 'tagged');
     // check auth
     $showAddButton = true;
     $status = BOL_AuthorizationService::getInstance()->getActionStatus('video', 'add');
     if ($status['status'] == BOL_AuthorizationService::STATUS_AVAILABLE) {
         $script = '$("#btn-add-new-video").click(function(){
             document.location.href = ' . json_encode(OW::getRouter()->urlFor('VIDEO_CTRL_Add', 'index')) . ';
         });';
         OW::getDocument()->addOnloadScript($script);
     } else {
         if ($status['status'] == BOL_AuthorizationService::STATUS_PROMOTED) {
             $script = '$("#btn-add-new-video").click(function(){
             OW.authorizationLimitedFloatbox(' . json_encode($status['msg']) . ');
         });';
             OW::getDocument()->addOnloadScript($script);
         } else {
             $showAddButton = false;
         }
     }
     $this->assign('showAddButton', $showAddButton);
     OW::getDocument()->setHeading(OW::getLanguage()->text('video', 'page_title_browse_video'));
     OW::getDocument()->setHeadingIconClass('ow_ic_video');
 }
Example #11
0
 public function index($params)
 {
     if (empty($params['list'])) {
         $params['list'] = 'latest';
     }
     $plugin = OW::getPluginManager()->getPlugin('blogs');
     OW::getNavigation()->activateMenuItem(OW_Navigation::MAIN, 'blogs', 'main_menu_item');
     $this->setPageHeading(OW::getLanguage()->text('blogs', 'list_page_heading'));
     $this->setPageHeadingIconClass('ow_ic_write');
     if (!OW::getUser()->isAdmin() && !OW::getUser()->isAuthorized('blogs', 'view')) {
         $this->setTemplate(OW::getPluginManager()->getPlugin('base')->getCtrlViewDir() . 'authorization_failed.html');
         return;
     }
     /*
      @var $service PostService
     */
     $service = PostService::getInstance();
     $page = !empty($_GET['page']) && intval($_GET['page']) > 0 ? $_GET['page'] : 1;
     $this->assign('addNew_isAuthorized', OW::getUser()->isAuthenticated() && OW::getUser()->isAuthorized('blogs', 'add'));
     $rpp = (int) OW::getConfig()->getValue('blogs', 'results_per_page');
     $first = ($page - 1) * $rpp;
     $count = $rpp;
     $case = $params['list'];
     if (!in_array($case, array('latest', 'browse-by-tag', 'most-discussed', 'top-rated'))) {
         throw new Redirect404Exception();
     }
     $showList = true;
     $isBrowseByTagCase = $case == 'browse-by-tag';
     $contentMenu = $this->getContentMenu();
     $contentMenu->getElement($case)->setActive(true);
     $this->addComponent('menu', $contentMenu);
     $this->assign('isBrowseByTagCase', $isBrowseByTagCase);
     $tagSearch = new BASE_CMP_TagSearch(OW::getRouter()->urlForRoute('blogs.list', array('list' => 'browse-by-tag')));
     $this->addComponent('tagSearch', $tagSearch);
     $tagCloud = new BASE_CMP_EntityTagCloud('blog-post', OW::getRouter()->urlForRoute('blogs.list', array('list' => 'browse-by-tag')));
     if ($isBrowseByTagCase) {
         $tagCloud->setTemplate(OW::getPluginManager()->getPlugin('base')->getCmpViewDir() . 'big_tag_cloud.html');
         $tag = !empty($_GET['tag']) ? UTIL_HtmlTag::stripTags($_GET['tag']) : '';
         $this->assign('tag', $tag);
         if (empty($tag)) {
             $showList = false;
         }
     }
     $this->addComponent('tagCloud', $tagCloud);
     $this->assign('showList', $showList);
     $list = array();
     $itemsCount = 0;
     list($list, $itemsCount) = $this->getData($case, $first, $count);
     $posts = array();
     $toolbars = array();
     $userService = BOL_UserService::getInstance();
     $authorIdList = array();
     $previewLength = 50;
     foreach ($list as $item) {
         $dto = $item['dto'];
         $dto->setPost($dto->getPost());
         $dto->setTitle(UTIL_String::truncate(strip_tags($dto->getTitle()), 65, '...'));
         $text = explode("<!--more-->", $dto->getPost());
         $isPreview = count($text) > 1;
         if (!$isPreview) {
             $text = explode('<!--page-->', $text[0]);
             $showMore = count($text) > 1;
         } else {
             $showMore = true;
         }
         $text = $text[0];
         $posts[] = array('dto' => $dto, 'text' => $text, 'showMore' => $showMore, 'url' => OW::getRouter()->urlForRoute('user-post', array('id' => $dto->getId())));
         $authorIdList[] = $dto->authorId;
         $idList[] = $dto->getId();
     }
     if (!empty($idList)) {
         $avatars = BOL_AvatarService::getInstance()->getDataForUserAvatars($authorIdList, true, false);
         $this->assign('avatars', $avatars);
         $nlist = array();
         foreach ($avatars as $userId => $avatar) {
             $nlist[$userId] = $avatar['title'];
         }
         $urls = BOL_UserService::getInstance()->getUserUrlsForList($authorIdList);
         $this->assign('toolbars', $this->getToolbar($idList, $list, $urls, $nlist));
     }
     $this->assign('list', $posts);
     $this->assign('url_new_post', OW::getRouter()->urlForRoute('post-save-new'));
     $paging = new BASE_CMP_Paging($page, ceil($itemsCount / $rpp), 5);
     $this->addComponent('paging', $paging);
 }