protected function getAboutMeContent() { $settings = BOL_ComponentEntityService::getInstance()->findSettingList('profile-BASE_CMP_AboutMeWidget', $this->user->id, array('content')); if (empty($settings['content'])) { return null; } return $this->length === null ? $settings['content'] : UTIL_String::truncate($settings['content'], $this->length, "..."); }
public function __construct(BASE_CLASS_WidgetParameter $params) { parent::__construct(); $service = LinkService::getInstance(); $userId = $params->additionalParamList['entityId']; if ($userId != OW::getUser()->getId() && !OW::getUser()->isAuthorized('links', 'view')) { $this->setVisible(false); return; } /* Check privacy permissions */ $eventParams = array('action' => LinkService::PRIVACY_ACTION_VIEW_LINKS, 'ownerId' => $userId, 'viewerId' => OW::getUser()->getId()); try { OW::getEventManager()->getInstance()->call('privacy_check_permission', $eventParams); } catch (RedirectException $ex) { $this->setVisible(false); return; } /* */ if ($service->countUserLinks($userId) == 0 && !$params->customizeMode) { $this->setVisible(false); return; } $this->assign('displayname', BOL_UserService::getInstance()->getDisplayName($userId)); $this->assign('username', BOL_UserService::getInstance()->getUsername($userId)); $list = array(); $count = $params->customParamList['count']; $userLinkList = $service->findUserLinkList($userId, 0, $count); $idList = array(); foreach ($userLinkList as $item) { /* Check privacy permissions */ if ($item->userId != OW::getUser()->getId() && !OW::getUser()->isAuthorized('links')) { $eventParams = array('action' => LinkService::PRIVACY_ACTION_VIEW_LINKS, 'ownerId' => $item->userId, 'viewerId' => OW::getUser()->getId()); try { OW::getEventManager()->getInstance()->call('privacy_check_permission', $eventParams); } catch (RedirectException $ex) { continue; } } /* */ $list[] = $item; $idList[] = $item->id; } $commentInfo = array(); if (!empty($idList)) { $commentInfo = BOL_CommentService::getInstance()->findCommentCountForEntityList('link', $idList); $tb = array(); foreach ($list as $key => $item) { if (mb_strlen($item->getDescription()) > 100) { $item->setDescription(UTIL_String::truncate($item->getDescription(), 100, '...')); } $list[$key]->setDescription(strip_tags($item->getDescription())); $tb[$item->getId()] = array(array('label' => '<span class="ow_txt_value">' . $commentInfo[$item->getId()] . '</span> ' . OW::getLanguage()->text('links', 'comments'), 'href' => OW::getRouter()->urlForRoute('link', array('id' => $item->getId()))), array('label' => UTIL_DateTime::formatDate($item->getTimestamp()), 'class' => 'ow_ic_date')); } $this->assign('tb', $tb); } $this->assign('list', $list); $this->setSettingValue(self::SETTING_TOOLBAR, array(array('label' => OW::getLanguage()->text('base', 'view_all'), 'href' => OW::getRouter()->urlForRoute('links-user', array('user' => BOL_UserService::getInstance()->getUserName($userId)))))); }
/** * Smarty truncate modifier. * * @author Sergey Kambalin <*****@*****.**> * @package ow.ow_smarty.plugin * @since 1.0 */ function smarty_modifier_more($string, $length) { $truncated = UTIL_String::truncate($string, $length); if (strlen($string) - strlen($truncated) < 50) { return $string; } $uniqId = uniqid("more-"); $seeMoreEmbed = '<a href="javascript://" class="ow_small" onclick="$(\'#' . $uniqId . '\').attr(\'data-collapsed\', 0);" style="padding-left:4px;">' . OW::getLanguage()->text("base", "comments_see_more_label") . '</a>'; return '<span class="ow_more_text" data-collapsed="1" id="' . $uniqId . '">' . '<span data-text="full">' . $string . '</span>' . '<span data-text="truncated">' . $truncated . '...' . $seeMoreEmbed . '</span>' . '</span>'; }
public function onBeforeRender() { parent::onBeforeRender(); if (!empty($this->oembed['title'])) { $this->oembed['title'] = UTIL_String::truncate($this->oembed['title'], 23, '...'); } if (!empty($this->oembed['description'])) { $this->oembed['description'] = UTIL_String::truncate($this->oembed['description'], 40, '...'); } $this->assign('message', $this->message); $this->assign('data', $this->oembed); }
public function __construct(BASE_CLASS_WidgetParameter $params) { parent::__construct(); $service = PostService::getInstance(); $count = $params->customParamList['count']; $previewLength = $params->customParamList['previewLength']; $list = $service->findList(0, $count); if ((empty($list) || false && !OW::getUser()->isAuthorized('blogs', 'add') && !OW::getUser()->isAuthorized('blogs', 'view')) && !$params->customizeMode) { $this->setVisible(false); return; } $posts = array(); $userService = BOL_UserService::getInstance(); $postIdList = array(); foreach ($list as $dto) { /* @var $dto Post */ if (mb_strlen($dto->getTitle()) > 50) { $dto->setTitle(UTIL_String::splitWord(UTIL_String::truncate($dto->getTitle(), 50, '...'))); } $text = $service->processPostText($dto->getPost()); $posts[] = array('dto' => $dto, 'text' => UTIL_String::splitWord(UTIL_String::truncate($text, $previewLength)), 'truncated' => mb_strlen($text) > $previewLength, 'url' => OW::getRouter()->urlForRoute('user-post', array('id' => $dto->getId()))); $idList[] = $dto->getAuthorId(); $postIdList[] = $dto->id; } $commentInfo = array(); if (!empty($idList)) { $avatars = BOL_AvatarService::getInstance()->getDataForUserAvatars($idList, true, false); $this->assign('avatars', $avatars); $urls = BOL_UserService::getInstance()->getUserUrlsForList($idList); $commentInfo = BOL_CommentService::getInstance()->findCommentCountForEntityList('blog-post', $postIdList); $toolbars = array(); foreach ($list as $dto) { $toolbars[$dto->getId()] = array(array('class' => 'ow_icon_control ow_ic_user', 'href' => isset($urls[$dto->getAuthorId()]) ? $urls[$dto->getAuthorId()] : '#', 'label' => isset($avatars[$dto->getAuthorId()]['title']) ? $avatars[$dto->getAuthorId()]['title'] : ''), array('class' => 'ow_remark ow_ipc_date', 'label' => UTIL_DateTime::formatDate($dto->getTimestamp()))); } $this->assign('tbars', $toolbars); } $this->assign('commentInfo', $commentInfo); $this->assign('list', $posts); if ($service->countPosts() > 0) { $toolbar = array(); if (OW::getUser()->isAuthorized('blogs', 'add')) { $toolbar[] = array('label' => OW::getLanguage()->text('blogs', 'add_new'), 'href' => OW::getRouter()->urlForRoute('post-save-new')); } if (OW::getUser()->isAuthorized('blogs', 'view')) { $toolbar[] = array('label' => OW::getLanguage()->text('blogs', 'go_to_blog'), 'href' => Ow::getRouter()->urlForRoute('blogs')); } if (!empty($toolbar)) { $this->setSettingValue(self::SETTING_TOOLBAR, $toolbar); } } }
public function question($params) { $questionId = (int) $params['qid']; $question = $this->service->findQuestion($questionId); if (empty($question)) { throw new Redirect404Exception(); } $language = OW::getLanguage(); OW::getDocument()->setTitle($language->text('equestions', 'question_page_title')); OW::getDocument()->setDescription($language->text('equestions', 'question_page_description', array('question' => UTIL_String::truncate(strip_tags($question->text), 200)))); OW::getNavigation()->activateMenuItem(OW_Navigation::MAIN, 'equestions', 'main_menu_list'); $cmp = new EQUESTIONS_CMP_Question($questionId, null, null, array('focusToPost' => isset($_GET['f']))); $this->addComponent('question', $cmp); }
public function feedOnProjectAdd(OW_Event $e) { $params = $e->getParams(); if ($params['entityType'] != 'ocsfundraising_project') { return; } $service = OCSFUNDRAISING_BOL_Service::getInstance(); $project = $service->getGoalById($params['entityId']); if (!$project) { return; } $content = array("format" => "image_content", "vars" => array("image" => $project['dto']->image ? $service->generateImageUrl($project['dto']->image, false) : null, "thumbnail" => $project['dto']->image ? $service->generateImageUrl($project['dto']->image) : null, "title" => UTIL_String::truncate(strip_tags($project['dto']->name), 100, '...'), "description" => UTIL_String::truncate(strip_tags($project['dto']->description), 150, '...'), "url" => array("routeName" => "ocsfundraising.project", "vars" => array('id' => $project['dto']->id)), "iconClass" => "ow_ic_folder")); $data = array('time' => (int) $project['dto']->startStamp, 'ownerId' => $project['dto']->ownerId, 'string' => array('key' => 'ocsfundraising+feed_add_project_label'), 'content' => $content, 'view' => array('iconClass' => 'ow_ic_folder')); $e->setData($data); }
public function onBeforeRender() { parent::onBeforeRender(); $tplList = array(); foreach ($this->response['feed']['entry'] as $item) { $vid = $item['media$group']['yt$videoid']['$t']; $uploaded = strtotime($item['media$group']['yt$uploaded']['$t']); $duration = $item['media$group']['yt$duration']['seconds']; $description = UTIL_String::truncate(strip_tags($item['media$group']['media$description']['$t']), 130, ' ...'); $title = UTIL_String::truncate(strip_tags($item['media$group']['media$title']['$t']), 65, ' ...'); $thumb = $item['media$group']['media$thumbnail'][0]['url']; $image = $item['media$group']['media$thumbnail'][1]['url']; $oembed = array('thumbnail_url' => $image, 'type' => 'video', 'title' => $title, 'description' => $description, 'html' => '<iframe class="attp-yt-iframe" width="300" height="230" src="http://www.youtube.com/embed/' . $vid . '?autoplay=1" frameborder="0" allowfullscreen></iframe>'); $tplList[] = array('title' => $title, 'description' => $description, 'thumb' => $thumb, 'video' => $vid, 'duration' => round($duration / 60), 'uploaded' => $uploaded, 'date' => UTIL_DateTime::formatDate($uploaded), 'oembed' => json_encode($oembed)); } $this->assign('list', $tplList); }
public function findUserVideos($userId, $start, $offset) { $clipDao = VIDEO_BOL_ClipDao::getInstance(); $example = new OW_Example(); $example->andFieldEqual('status', 'approved'); $example->andFieldEqual('userId', $userId); $example->setOrder('`addDatetime` DESC'); $example->setLimitClause($start, $offset); $list = $clipDao->findListByExample($example); $out = array(); foreach ($list as $video) { $id = $video->id; $videoThumb = VIDEO_BOL_ClipService::getInstance()->getClipThumbUrl($id); $out[$id] = array('id' => $id, 'embed' => $video->code, 'title' => UTIL_String::truncate($video->title, 65, ' ...'), 'description' => UTIL_String::truncate($video->description, 130, ' ...'), 'thumb' => $videoThumb == 'undefined' ? null : $videoThumb, 'date' => UTIL_DateTime::formatDate($video->addDatetime), 'permalink' => OW::getRouter()->urlForRoute('view_clip', array('id' => $id))); $out[$id]['oembed'] = json_encode(array('type' => 'video', 'thumbnail_url' => $out[$id]['thumb'], 'html' => $out[$id]['embed'], 'title' => $out[$id]['title'], 'description' => $out[$id]['description'])); } return $out; }
public function onInvite(OW_Event $event) { $params = $event->getParams(); $eventId = $params['eventId']; $eventDto = EVENT_BOL_EventService::getInstance()->findEvent($params['eventId']); $eventUrl = OW::getRouter()->urlForRoute('event.view', array('eventId' => $eventDto->id)); $eventTitle = UTIL_String::truncate($eventDto->title, 100, '...'); $userId = OW::getUser()->getId(); $userDto = OW::getUser()->getUserObject(); $userUrl = BOL_UserService::getInstance()->getUserUrlForUsername($userDto->username); $userDisplayName = BOL_UserService::getInstance()->getDisplayName($userId); $avatars = BOL_AvatarService::getInstance()->getDataForUserAvatars(array($userId)); $avatar = $avatars[$userId]; $users = array($userId); $stringAssigns = array('event' => '<a href="' . $eventUrl . '">' . $eventTitle . '</a>'); $stringAssigns['user1'] = '<a href="' . $userUrl . '">' . $userDisplayName . '</a>'; $contentImage = null; if (!empty($eventDto->image)) { $eventSrc = EVENT_BOL_EventService::getInstance()->generateImageUrl($eventDto->image, true); $contentImage = array('src' => $eventSrc, 'url' => $eventUrl, 'title' => $eventTitle); } //$userCount = count($data['users']); // $userIds = array(); // for ( $i = 0; $i < $userCount; $i++ ) // { // $user = $data['users'][$i]; // $stringAssigns['user' . ($i+1)] = '<a href="' . $user['url'] . '">' . $user['name'] . '</a>'; // // if ( $i >= 2 ) // { // $userIds[] = $user['userId']; // } // } //$stringAssigns['otherUsers'] = '<a href="javascript://" onclick="OW.showUsers(' . json_encode($users) . ');">' . //OW::getLanguage()->text('event', 'invitation_join_string_other_users', array( 'count' => count($users) )) . '</a>'; // $languageKey = $userCount > 2 ? 'invitation_join_string_many' : 'invitation_join_string_' . $userCount; $languageKey = 'invitation_join_string_' . 1; $invitationEvent = new OW_Event('invitations.add', array('pluginKey' => 'event', 'entityType' => self::INVITATION_JOIN, 'entityId' => $eventDto->id, 'userId' => $params['userId'], 'time' => time(), 'action' => 'event-invitation'), array('string' => array('key' => 'event+' . $languageKey, 'vars' => $stringAssigns), 'users' => $users, 'avatar' => $avatar, 'contentImage' => $contentImage)); OW::getEventManager()->trigger($invitationEvent); }
public function onBeforeQuestionAdd(OW_Event $event) { $params = $event->getParams(); $data = $event->getData(); if (empty($params['settings']['context']['type']) || $params['settings']['context']['type'] != 'groups') { return; } if (!$this->isActive()) { return; } $context = $params['settings']['context']; $service = GROUPS_BOL_Service::getInstance(); $groupId = (int) $context['id']; $group = $service->findGroupById($groupId); $url = $service->getGroupUrl($group); $title = UTIL_String::truncate(strip_tags($group->title), 100, '...'); $context['label'] = $title; $context['url'] = $url; $data['settings']['context'] = $context; $data['privacy'] = 'groups'; $event->setData($data); }
private function processDataInterface($item) { $data = $item['data']; foreach (array('string', 'conten') as $langProperty) { if (!empty($data[$langProperty]) && is_array($data[$langProperty])) { $key = explode('+', $data[$langProperty]['key']); $vars = empty($data[$langProperty]['vars']) ? array() : $data[$langProperty]['vars']; $data[$langProperty] = OW::getLanguage()->text($key[0], $key[1], $vars); } } if (!empty($data['contentImage'])) { $data['contentImage'] = is_string($data['contentImage']) ? array('src' => $data['contentImage']) : $data['contentImage']; } else { $data['contentImage'] = null; } $data['content'] = empty($data['content']) ? '' : UTIL_String::truncate($data['content'], 140, '...'); $data['string'] = empty($data['string']) ? '' : $data['string']; $data['avatar'] = empty($data['avatar']) ? null : $data['avatar']; $data['contentImage'] = empty($data['contentImage']) ? array() : $data['contentImage']; $data['toolbar'] = empty($data['toolbar']) ? array() : $data['toolbar']; $data['url'] = empty($data['url']) ? null : $data['url']; $data['time'] = $item['time']; return $data; }
public function onInvite(OW_Event $event) { $params = $event->getParams(); $eventDto = EVENTX_BOL_EventService::getInstance()->findEvent($params['eventId']); $eventUrl = OW::getRouter()->urlForRoute('eventx.view', array('eventId' => $eventDto->id)); $eventTitle = UTIL_String::truncate($eventDto->title, 100, '...'); $userId = OW::getUser()->getId(); $userDto = OW::getUser()->getUserObject(); $userUrl = BOL_UserService::getInstance()->getUserUrlForUsername($userDto->username); $userDisplayName = BOL_UserService::getInstance()->getDisplayName($userId); $avatars = BOL_AvatarService::getInstance()->getDataForUserAvatars(array($userId)); $avatar = $avatars[$userId]; $users = array($userId); $stringAssigns = array('event' => '<a href="' . $eventUrl . '">' . $eventTitle . '</a>'); $stringAssigns['user1'] = '<a href="' . $userUrl . '">' . $userDisplayName . '</a>'; $contentImage = null; if (!empty($eventDto->image)) { $eventSrc = EVENTX_BOL_EventService::getInstance()->generateImageUrl($eventDto->image, true); $contentImage = array('src' => $eventSrc, 'url' => $eventUrl, 'title' => $eventTitle); } $languageKey = 'invitation_join_string_' . 1; $invitationEvent = new OW_Event('invitations.add', array('pluginKey' => 'eventx', 'entityType' => self::INVITATION_JOIN, 'entityId' => $eventDto->id, 'userId' => $params['userId'], 'time' => time(), 'action' => 'event-invitation'), array('string' => array('key' => 'eventx+' . $languageKey, 'vars' => $stringAssigns), 'users' => $users, 'avatar' => $avatar, 'contentImage' => $contentImage)); OW::getEventManager()->trigger($invitationEvent); }
public function onUpdateBlogPost(OW_Event $e) { $params = $e->getParams(); $data = $e->getData(); if ($params['entityType'] != 'blog-post') { return; } $post = $this->service->findById($params['entityId']); $content = nl2br(UTIL_String::truncate(strip_tags($post->post), 150, '...')); $title = UTIL_String::truncate(strip_tags($post->title), 100, '...'); $data = array('time' => (int) $post->timestamp, 'ownerId' => $post->authorId, 'content' => array('format' => 'content', 'vars' => array('title' => $title, 'description' => $content, 'url' => array("routeName" => 'post', "vars" => array('id' => $post->id)), 'iconClass' => 'ow_ic_blog')), 'view' => array('iconClass' => 'ow_ic_write'), 'actionDto' => $data['actionDto']); $e->setData($data); }
public function onFeedItemRenderContext(OW_Event $event) { $params = $event->getParams(); $data = $event->getData(); $groupActions = array('groups-status'); if (in_array($params['action']['entityType'], $groupActions) && $params['feedType'] == 'groups') { $data['context'] = null; } if ($params['action']['entityType'] == 'forum-topic' && isset($data['contextFeedType']) && $data['contextFeedType'] == 'groups' && $data['contextFeedType'] != $params['feedType']) { $service = GROUPS_BOL_Service::getInstance(); $group = $service->findGroupById($data['contextFeedId']); $url = $service->getGroupUrl($group); $title = UTIL_String::truncate(strip_tags($group->title), 100, '...'); $data['context'] = array('label' => $title, 'url' => $url); } $event->setData($data); }
public function follow() { if (!OW::getUser()->isAuthenticated()) { throw new AuthenticateException(); } $groupId = (int) $_GET['groupId']; $groupDto = GROUPS_BOL_Service::getInstance()->findGroupById($groupId); if ($groupDto === null) { throw new Redirect404Exception(); } $eventParams = array('userId' => OW::getUser()->getId(), 'feedType' => GROUPS_BOL_Service::ENTITY_TYPE_GROUP, 'feedId' => $groupId); $title = UTIL_String::truncate(strip_tags($groupDto->title), 100, '...'); switch ($_GET['command']) { case 'follow': OW::getEventManager()->call('feed.add_follow', $eventParams); OW::getFeedback()->info(OW::getLanguage()->text('groups', 'feed_follow_complete_msg', array('groupTitle' => $title))); break; case 'unfollow': OW::getEventManager()->call('feed.remove_follow', $eventParams); OW::getFeedback()->info(OW::getLanguage()->text('groups', 'feed_unfollow_complete_msg', array('groupTitle' => $title))); break; } $this->redirect(OW_URL_HOME . $_GET['backUri']); }
function vwvc_feed_entity_add(OW_Event $e) { $params = $e->getParams(); $data = $e->getData(); if ($params['entityType'] != 'vwvc_comments') { return; } $vwvcService = VWVC_BOL_ClipService::getInstance(); $clip = $vwvcService->findClipById($params['entityId']); $thumb = $vwvcService->getClipThumbUrl($clip->id); $url = OW::getRouter()->urlForRoute('vwview_clip', array('id' => $clip->id)); $content = UTIL_String::truncate(strip_tags($clip->description), 150, '...'); $title = UTIL_String::truncate(strip_tags($clip->title), 100, '...'); if ($thumb == "undefined") { $thumb = $vwvcService->getClipDefaultThumbUrl(); $markup = '<div class="clearfix"><div class="ow_newsfeed_item_picture">'; $markup .= '<a style="display: block;" href="' . $url . '"><div style="width: 75px; height: 60px; background: url(' . $thumb . ') no-repeat center center;"></div></a>'; $markup .= '</div><div class="ow_newsfeed_item_content"><a href="' . $url . '">' . $title . '</a><div class="ow_remark">'; $markup .= $content . '</div></div></div>'; } else { $markup = '<div class="clearfix ow_newsfeed_large_image"><div class="ow_newsfeed_item_picture">'; $markup .= '<a href="' . $url . '"><img src="' . $thumb . '" /></a>'; $markup .= '</div><div class="ow_newsfeed_item_content"><a href="' . $url . '">' . $title . '</a><div class="ow_remark">'; $markup .= $content . '</div></div></div>'; } $data = array('time' => (int) $clip->addDatetime, 'ownerId' => $clip->userId, 'content' => '<div class="clearfix">' . $markup . '</div>', 'view' => array('iconClass' => 'ow_ic_vwvc')); $e->setData($data); }
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 }
public function onInfoRender(OW_Event $event) { $params = $event->getParams(); $entityType = $params["entityType"]; $entityId = $params["entityId"]; switch ($params["key"]) { case "base-gender-age": $questionData = BOL_QuestionService::getInstance()->getQuestionData(array($entityId), array("birthdate")); $ageStr = ""; if (!empty($questionData[$entityId]['birthdate'])) { $date = UTIL_DateTime::parseDate($questionData[$entityId]['birthdate'], UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT); $age = UTIL_DateTime::getAge($date['year'], $date['month'], $date['day']); $ageStr = $age . " " . OW::getLanguage()->text('base', 'questions_age_year_old'); } $sex = $this->renderQuestion($entityId, "sex"); $event->setData($sex . " " . $ageStr); break; case "base-about": $settings = BOL_ComponentEntityService::getInstance()->findSettingList("profile-BASE_CMP_AboutMeWidget", $entityId, array('content')); $content = empty($settings['content']) ? null : UTIL_String::truncate($settings['content'], 100, '...'); $event->setData('<span class="ow_remark ow_small">' . $content . '</span>'); break; case "base-activity": // Check privacy permissions $eventParams = array('action' => 'base_view_my_presence_on_site', 'ownerId' => $entityId, 'viewerId' => OW::getUser()->getId()); try { OW::getEventManager()->getInstance()->call('privacy_check_permission', $eventParams); } catch (RedirectException $e) { break; } $isOnline = BOL_UserService::getInstance()->findOnlineUserById($entityId); if ($isOnline) { $event->setData(OW::getLanguage()->text("base", "activity_online")); } else { $user = BOL_UserService::getInstance()->findUserById($entityId); $activity = UTIL_DateTime::formatDate($user->activityStamp); $event->setData(OW::getLanguage()->text("hint", "info-activity", array("activity" => $activity))); } break; case "base-question": if (!empty($params["question"])) { $renderedQuestion = $this->renderQuestion($entityId, $params["question"]); if ($params["line"] == HINT_BOL_Service::INFO_LINE2) { $renderedQuestion = '<span class="ow_remark">' . $renderedQuestion . '</span>'; } $event->setData($renderedQuestion); } break; } }
function eventx_after_event_edit(OW_Event $event) { $params = $event->getParams(); $evemtId = (int) $params['eventId']; $eventService = EVENTX_BOL_EventService::getInstance(); $event = $eventService->findEvent($evemtId); $url = OW::getRouter()->urlForRoute('eventx.view', array('eventId' => $event->getId())); $thumb = $eventService->generateImageUrl($event->image, true); $data = array('time' => $event->getCreateTimeStamp(), 'ownerId' => $event->getUserId(), 'string' => OW::getLanguage()->text('eventx', 'feed_add_item_label'), 'content' => '<div class="clearfix"><div class="ow_newsfeed_item_picture"> <a href="' . $url . '"><img src="' . $thumb . '" /></a> </div><div class="ow_newsfeed_item_content"> <a class="ow_newsfeed_item_title" href="' . $url . '">' . $event->getTitle() . '</a><div class="ow_remark ow_smallmargin">' . UTIL_String::truncate(strip_tags($event->getDescription()), 200, '...') . '</div><div class="ow_newsfeed_action_activity event_newsfeed_activity">[ph:activity]</div></div></div>', 'view' => array('iconClass' => 'ow_ic_calendar')); if ($event->getWhoCanView() == EVENTX_BOL_EventService::CAN_VIEW_INVITATION_ONLY) { $data['params']['visibility'] = 4; } $event = new OW_Event('feed.action', array('entityType' => 'eventx', 'entityId' => $evemtId, 'pluginKey' => 'eventx'), $data); OW::getEventManager()->trigger($event); }
/** * Prepares data for ipc listing. * * @param array<EVENT_BOL_Event> $events * @return array */ public function getListingData(array $events) { $resultArray = array(); /* @var $eventItem EVENT_BOL_Event */ foreach ($events as $eventItem) { $title = UTIL_String::truncate(strip_tags($eventItem->getTitle()), 80, "..."); $content = UTIL_String::truncate(strip_tags($eventItem->getDescription()), 100, "..."); $resultArray[$eventItem->getId()] = array('content' => $content, 'title' => $title, 'eventUrl' => OW::getRouter()->urlForRoute('event.view', array('eventId' => $eventItem->getId())), 'imageSrc' => $eventItem->getImage() ? $this->generateImageUrl($eventItem->getImage(), true) : $this->generateDefaultImageUrl(), 'imageTitle' => $title); } return $resultArray; }
public function userFeedStatusUpdate(OW_Event $event) { $params = $event->getParams(); $data = $event->getData(); if ($params['feedType'] != 'user') { return; } $recipientId = (int) $params['feedId']; $userId = (int) $params['userId']; if ($recipientId == $userId) { return; } $action = NEWSFEED_BOL_Service::getInstance()->findAction('user-status', $data['statusId']); if (empty($action)) { return; } $url = OW::getRouter()->urlForRoute('newsfeed_view_item', array('actionId' => $action->id)); $actionData = json_decode($action->data, true); $contentImage = empty($actionData['contentImage']) ? null : $actionData['contentImage']; $avatarData = BOL_AvatarService::getInstance()->getDataForUserAvatars(array($userId), true, true, true, false); $avatar = $avatarData[$userId]; $stringKey = 'newsfeed+notifications_user_status'; $event = new OW_Event('notifications.add', array('pluginKey' => 'newsfeed', 'action' => 'newsfeed-user_status', 'entityType' => 'user_status', 'entityId' => $data['statusId'], 'userId' => $recipientId), array('format' => "text", 'avatar' => $avatar, 'string' => array('key' => $stringKey, 'vars' => array('userName' => $avatar['title'], 'userUrl' => $avatar['url'])), 'content' => UTIL_String::truncate($data['status'], 100, '...'), 'url' => $url, "contentImage" => $contentImage)); OW::getEventManager()->trigger($event); }
public function feedOnItemRender(OW_Event $event) { $params = $event->getParams(); $data = $event->getData(); $language = OW::getLanguage(); if ($params['action']['entityType'] != 'forum-topic') { return; } $service = FORUM_BOL_ForumService::getInstance(); $postCount = $service->findTopicPostCount($params['action']['entityId']) - 1; if (!$postCount) { return; } if (is_array($data['toolbar'])) { $data['toolbar'][] = array('label' => $language->text('forum', 'feed_toolbar_replies', array('postCount' => $postCount))); } $event->setData($data); $postIds = array(); foreach ($params['activity'] as $activity) { if ($activity['activityType'] == 'forum-post') { $postIds[] = $activity['data']['postId']; } } if (empty($postIds)) { return; } $postDto = null; foreach ($postIds as $pid) { $postDto = $service->findPostById($pid); if ($postDto !== null) { break; } } if ($postDto === null) { return; } $postUrlEmbed = '...'; $content = UTIL_String::truncate(strip_tags(str_replace(" ", "", $postDto->text)), 100, $postUrlEmbed); $usersData = BOL_AvatarService::getInstance()->getDataForUserAvatars(array($postDto->userId), true, true, true, false); $avatarData = $usersData[$postDto->userId]; $postUrl = $service->getPostUrl($postDto->topicId, $postDto->id); /*$ipcContent = OW::getThemeManager()->processDecorator('mini_ipc', array( 'avatar' => $avatarData, 'profileUrl' => $avatarData['url'], 'displayName' => $avatarData['title'], 'content' => $content)); $data['assign']['activity'] = array('template' => 'activity', 'vars' => array( 'title' => $language->text('forum', 'feed_activity_last_reply', array('postUrl' => $postUrl)), 'content' => $ipcContent ));*/ if (is_array($data['content']) && !empty($data['content']['vars'])) { $data['content']['vars']['activity'] = array('url' => $postUrl, 'title' => $language->text('forum', 'last_reply'), 'avatarData' => $avatarData, 'description' => $content); } $event->setData($data); }
public function feedOnEntityAction(OW_Event $e) { $params = $e->getParams(); $data = $e->getData(); if (!in_array($params['entityType'], array('photo_comments', 'multiple_photo_upload'))) { return; } $photoService = PHOTO_BOL_PhotoService::getInstance(); $albumService = PHOTO_BOL_PhotoAlbumService::getInstance(); $photoId = !empty($data['photoIdList']) ? $data['photoIdList'][0] : $params['entityId']; $photo = $photoService->findPhotoById($photoId); if (!$photo) { return; } $album = $albumService->findAlbumById($photo->albumId); if (!$album) { return; } $info = array('route' => array('textKey' => 'photo+album', 'label' => UTIL_String::truncate(strip_tags($album->name), 100, '...'), 'routeName' => 'photo_user_album', 'vars' => array('user' => BOL_UserService::getInstance()->getUserName($params['userId']), 'album' => $album->id))); $entityType = $params['entityType']; if ($params['entityType'] == 'multiple_photo_upload' && count($data['photoIdList']) == 1) { $data['params'] = array('entityType' => 'photo_comments', 'entityId' => $data['photoIdList'][0], 'merge' => array('entityType' => 'multiple_photo_upload', 'entityId' => $params['entityId'])); $entityType = 'photo_comments'; } $vars = array(); if (!empty($data['status'])) { $vars['status'] = $data['status']; } $actionFormat = null; if (isset($data["content"]) && is_array($data["content"])) { $vars = empty($data["content"]["vars"]) ? array() : $data["content"]["vars"]; $actionFormat = empty($data["content"]["format"]) ? null : $data["content"]["format"]; } switch ($entityType) { case 'multiple_photo_upload': $format = 'image_list'; $photoIdList = array_slice($data['photoIdList'], 0, PHOTO_BOL_PhotoService::FORMAT_LIST_LIMIT); $list = array(); foreach ($photoIdList as $id) { $list[] = array("image" => $photoService->getPhotoUrlByType($id, PHOTO_BOL_PhotoService::TYPE_PREVIEW), "url" => array("routeName" => "view_photo", "vars" => array('id' => $id))); } $vars["list"] = $list; $data['features'] = array('likes'); break; case 'photo_comments': $format = 'image'; if (!empty($photo->dimension)) { $type = PHOTO_BOL_PhotoService::TYPE_PREVIEW; } else { $type = PHOTO_BOL_PhotoService::TYPE_MAIN; } $vars["image"] = $photoService->getPhotoUrlByType($photo->id, $type, $photo->hash, !empty($photo->dimension) ? $photo->dimension : FALSE); $vars["url"] = array("routeName" => "view_photo", "vars" => array('id' => $photoId)); break; default: return; } $vars['info'] = $info; if (!empty($actionFormat)) { $format = $actionFormat; } $data['content'] = array('format' => $format, 'vars' => $vars); $data['view'] = array('iconClass' => 'ow_ic_picture'); $e->setData($data); }
public function onLike(OW_Event $event) { $params = $event->getParams(); if ($params['entityType'] != GHEADER_CLASS_CommentsBridge::ENTITY_TYPE) { return; } $userId = $params['userId']; $coverId = $params['entityId']; $cover = GHEADER_BOL_Service::getInstance()->findCoverById($coverId); if ($cover === null) { return; } $group = GROUPS_BOL_Service::getInstance()->findGroupById($cover->groupId); $string = null; $url = GROUPS_BOL_Service::getInstance()->getGroupUrl($group); $title = UTIL_String::truncate(strip_tags($group->title), 100, '...'); $groupEmbed = '<a href="' . $url . '">' . $title . '</a>'; if ($group->userId == $userId) { $string = OW::getLanguage()->text('gheader', 'activity_string_cover_like_self', array('group' => $groupEmbed)); } else { $string = OW::getLanguage()->text('gheader', 'activity_string_cover_like', array('group' => $groupEmbed)); } OW::getEventManager()->trigger(new OW_Event('feed.activity', array('activityType' => 'like', 'activityId' => $userId, 'entityId' => $params['entityId'], 'entityType' => $params['entityType'], 'userId' => $userId, 'pluginKey' => $this->plugin->getKey(), 'feedType' => 'groups', 'feedId' => $group->id, 'visibility' => $this->getVisibility($group), 'postOnUserFeed' => $this->getPostOnUserFeed($group)), array('string' => $string))); }
function ivideo_feed_entity_add(OW_Event $e) { $params = $e->getParams(); $data = $e->getData(); if ($params['entityType'] != 'ivideo-comments') { return; } $videoService = IVIDEO_BOL_Service::getInstance(); $video = $videoService->findVideoById($params['entityId']); $url = OW::getRouter()->urlForRoute('ivideo_view_video', array('id' => $video->id)); $content = UTIL_String::truncate(strip_tags($video->description), 150, '...'); $title = UTIL_String::truncate(strip_tags($video->name), 100, '...'); $thumbImgUrl = OW::getPluginManager()->getPlugin('ivideo')->getUserFilesDir() . $video->filename . ".png"; if (file_exists($thumbImgUrl)) { $thumb = $thumbImgUrl; } else { $thumb = OW::getPluginManager()->getPlugin('ivideo')->getStaticUrl() . 'video.png'; } $string = OW::getLanguage()->text('ivideo', 'feed_entity_entry_string', array('title' => $title)); $markup = '<div class="clearfix"><div class="ow_newsfeed_item_picture">'; $markup .= '<a style="display: block;" href="' . $url . '"><div style="width: 75px; height: 60px; background: url(' . $thumb . ') center center;"></div></a>'; $markup .= '</div><div class="ow_newsfeed_item_content"><a href="' . $url . '">' . $string . '</a><div class="ow_remark">'; $markup .= $content . '</div></div></div>'; $data = array('time' => (int) $video->timestamp, 'ownerId' => $video->owner, 'content' => '<div class="clearfix">' . $markup . '</div>', 'view' => array('iconClass' => 'ow_ic_video')); $e->setData($data); }
public function onGetInfo(OW_Event $event) { $params = $event->getParams(); if ($params["entityType"] != self::ENTITY_TYPE && $params["entityType"] != self::POST_ENTITY_TYPE) { return; } if ($params["entityType"] == self::ENTITY_TYPE) { $topics = $this->service->findTopicListByIds($params["entityIds"]); $out = array(); /** * @var FORUM_BOL_Post $post */ foreach ($topics as $topic) { $info = array(); $topicPost = $this->service->findTopicFirstPost($topic->id); $info["id"] = $topic->id; $info["userId"] = $topic->userId; $info["url"] = OW::getRouter()->urlForRoute('topic-default', array('topicId' => $topic->id)); $info["label"] = OW::getLanguage()->text('forum', 'content_forum_topic', array('topicUrl' => $info["url"], 'title' => $topic->title)); $info["title"] = $topic->title; $info["description"] = $topicPost->text; $info["timeStamp"] = $topicPost->createStamp; $out[$topic->id] = $info; } } elseif ($params["entityType"] == self::POST_ENTITY_TYPE) { $posts = $this->service->findPostListByIds($params["entityIds"]); $out = array(); /** * @var FORUM_BOL_Post $post */ foreach ($posts as $post) { $info = array(); $topicInfo = $this->service->getTopicInfo($post->topicId); $info["id"] = $post->id; $info["userId"] = $post->userId; $info["url"] = $this->service->getPostUrl($post->topicId, $post->id); $info["label"] = OW::getLanguage()->text('forum', 'content_forum_post_in_topic', array('topicUrl' => $info["url"], 'title' => UTIL_String::truncate($topicInfo['title'], 20))); $info["text"] = $post->text; $info["timeStamp"] = $post->createStamp; $out[$post->id] = $info; } } $event->setData($out); return $out; }
/** * Smarty truncate modifier. * * @author Zarif Safiullin <*****@*****.**> * @package ow.ow_smarty.plugin * @since 1.0 */ function smarty_modifier_truncate($string, $length, $ending = null) { return UTIL_String::truncate($string, $length, $ending); }
public function index($params) { $plugin = OW::getPluginManager()->getPlugin('blogs'); OW::getNavigation()->activateMenuItem(OW_Navigation::MAIN, 'blogs', 'main_menu_item'); if (!OW::getUser()->isAdmin() && !OW::getUser()->isAuthorized('blogs', 'view')) { $status = BOL_AuthorizationService::getInstance()->getActionStatus('blogs', 'view'); throw new AuthorizationException($status['msg']); return; } /* @var $service PostService */ $service = PostService::getInstance(); /* @var $userService BOL_UserService */ $userService = BOL_UserService::getInstance(); /* @var $author BOL_User */ if (!empty($params['user'])) { $author = $userService->findByUsername($params['user']); } else { $author = $userService->findUserById(OW::getUser()->getId()); } if (empty($author)) { throw new Redirect404Exception(); return; } /* Check privacy permissions */ $eventParams = array('action' => 'blogs_view_blog_posts', 'ownerId' => $author->getId(), 'viewerId' => OW::getUser()->getId()); OW::getEventManager()->getInstance()->call('privacy_check_permission', $eventParams); /* */ $displaySocialSharing = true; try { $eventParams = array('action' => 'blogs_view_blog_posts', 'ownerId' => $author->getId(), 'viewerId' => 0); OW::getEventManager()->getInstance()->call('privacy_check_permission', $eventParams); } catch (RedirectException $ex) { $displaySocialSharing = false; } if ($displaySocialSharing && !BOL_AuthorizationService::getInstance()->isActionAuthorizedForUser(0, 'blogs', 'view')) { $displaySocialSharing = false; } $this->assign('display_social_sharing', $displaySocialSharing); $displayName = $userService->getDisplayName($author->getId()); $this->assign('author', $author); $this->assign('username', $author->getUsername()); $this->assign('displayname', $displayName); $this->setPageHeading(OW::getLanguage()->text('blogs', 'user_blog_page_heading', array('name' => $author->getUsername()))); $this->setPageHeadingIconClass('ow_ic_write'); $page = !empty($_GET['page']) && intval($_GET['page']) > 0 ? intval($_GET['page']) : 1; $rpp = (int) OW::getConfig()->getValue('blogs', 'results_per_page'); $first = ($page - 1) * $rpp; $count = $rpp; if (!empty($_GET['month'])) { $archive_params = htmlspecialchars($_GET['month']); $arr = explode('-', $archive_params); $month = $arr[0]; $year = $arr[1]; $lb = mktime(null, null, null, $month, 1, $year); $ub = mktime(null, null, null, $month + 1, null, $year); $list = $service->findUserPostListByPeriod($author->getId(), $lb, $ub, $first, $count); $itemsCount = $service->countUserPostByPeriod($author->getId(), $lb, $ub); $l = OW::getLanguage(); $arciveHeaderPart = ', ' . $l->text('base', "month_{$month}") . " {$year} " . $l->text('base', 'archive'); OW::getDocument()->setTitle(OW::getLanguage()->text('blogs', 'user_blog_archive_title', array('month_name' => $l->text('base', "month_{$month}"), 'display_name' => $displayName))); OW::getDocument()->setDescription(OW::getLanguage()->text('blogs', 'user_blog_archive_description', array('year' => $year, 'month_name' => $l->text('base', "month_{$month}"), 'display_name' => $displayName))); } else { $list = $service->findUserPostList($author->getId(), $first, $count); $itemsCount = $service->countUserPost($author->getId()); OW::getDocument()->setTitle(OW::getLanguage()->text('blogs', 'user_blog_title', array('display_name' => $displayName))); OW::getDocument()->setDescription(OW::getLanguage()->text('blogs', 'user_blog_description', array('display_name' => $displayName))); } $this->assign('archiveHeaderPart', !empty($arciveHeaderPart) ? $arciveHeaderPart : ''); $posts = array(); $commentInfo = array(); $idList = array(); foreach ($list as $dto) { $idList[] = $dto->getId(); $dto_post = BASE_CMP_TextFormatter::fromBBtoHtml($dto->getPost()); $dto->setPost($dto_post); $parts = explode('<!--more-->', $dto->getPost()); if (!empty($parts)) { $text = $parts[0]; //$text = UTIL_HtmlTag::sanitize($text); } else { $text = $dto->getPost(); } $posts[] = array('id' => $dto->getId(), 'href' => OW::getRouter()->urlForRoute('user-post', array('id' => $dto->getId())), 'title' => UTIL_String::truncate($dto->getTitle(), 65, '...'), 'text' => $text, 'truncated' => count($parts) > 1 ? true : false); } if (!empty($idList)) { $commentInfo = BOL_CommentService::getInstance()->findCommentCountForEntityList('blog-post', $idList); $this->assign('commentInfo', $commentInfo); $tagsInfo = BOL_TagService::getInstance()->findTagListByEntityIdList('blog-post', $idList); $this->assign('tagsInfo', $tagsInfo); $tb = array(); foreach ($list as $dto) { $tb[$dto->getId()] = array(array('label' => UTIL_DateTime::formatDate($dto->timestamp))); //if ( $commentInfo[$dto->getId()] ) //{ $tb[$dto->getId()][] = array('href' => OW::getRouter()->urlForRoute('post', array('id' => $dto->getId())), 'label' => '<span class="ow_outline">' . $commentInfo[$dto->getId()] . '</span> ' . OW::getLanguage()->text('blogs', 'toolbar_comments')); //} if ($tagsInfo[$dto->getId()]) { $tags =& $tagsInfo[$dto->getId()]; $t = OW::getLanguage()->text('blogs', 'tags'); for ($i = 0; $i < (count($tags) > 3 ? 3 : count($tags)); $i++) { $t .= " <a href=\"" . OW::getRouter()->urlForRoute('blogs.list', array('list' => 'browse-by-tag')) . "?tag={$tags[$i]}\">{$tags[$i]}</a>" . ($i != 2 ? ',' : ''); } $tb[$dto->getId()][] = array('label' => mb_substr($t, 0, mb_strlen($t) - 1)); } } $this->assign('tb', $tb); } $this->assign('list', $posts); $info = array('lastPost' => $service->findUserLastPost($author->getId()), 'author' => $author); $this->assign('info', $info); $paging = new BASE_CMP_Paging($page, ceil($itemsCount / $rpp), 5); $this->assign('paging', $paging->render()); $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); $this->assign('my_drafts_url', OW::getRouter()->urlForRoute('blog-manage-drafts')); if (OW::getUser()->isAuthenticated()) { $isOwner = $params['user'] == OW::getUser()->getUserObject()->getUsername() ? true : false; } else { $isOwner = false; } $this->assign('isOwner', $isOwner); }
private function getItemString($question, $bubbleActivity, $jsSelector, $questionUrl) { $activityType = $bubbleActivity['activityType']; $configs = OW::getConfig()->getValues('questions'); $allowPopups = !isset($configs['allow_popups']) || $configs['allow_popups']; $onClickStr = $allowPopups ? 'onclick="return ' . $jsSelector . '.openQuestionDelegate();"' : ''; $questionEmbed = '<a href="' . $questionUrl . '" ' . $onClickStr . '>' . $question->text . '</a>'; if (in_array($activityType, array(QUESTIONS_BOL_FeedService::ACTIVITY_CREATE, QUESTIONS_BOL_FeedService::ACTIVITY_FOLLOW))) { return OW::getLanguage()->text('questions', 'item_text_' . $activityType, array('question' => $questionEmbed)); } $buubleData = $bubbleActivity['data']; $with = ''; if (!empty($buubleData['text'])) { $text = UTIL_String::truncate($buubleData['text'], 50, '...'); $with = '<a href="' . $questionUrl . '" ' . $onClickStr . '>' . $text . '</a>'; } return OW::getLanguage()->text('questions', 'item_text_' . $activityType, array('question' => $questionEmbed, 'with' => $with)); }