public function display($tmpl = null) { // Checks if rss is enabled if (!$this->config->get('main_rss')) { return; } // Get the archives model $model = EB::model('Archive'); // Get a list of posts $posts = $model->getPosts(); // Format the posts $posts = EB::formatter('list', $posts); // Set the link for this feed $this->doc->link = EBR::_('index.php?option=com_easyblog&view=archive'); $this->doc->setTitle(JText::_('COM_EASYBLOG_ARCHIVED_POSTS')); $this->doc->setDescription(JText::_('COM_EASYBLOG_ARCHIVED_POSTS_DESC')); if (!$posts) { return; } foreach ($posts as $post) { $image = ''; if ($post->getImage('medium', true, true)) { $image = '<img src=' . $post->getImage('medium', true, true) . '" alt="' . $post->title . '" />'; } $item = new JFeedItem(); $item->title = $post->title; $item->link = $post->getPermalink(); $item->description = $image . $post->getIntro(); $item->date = $post->getCreationDate()->format(); $item->category = $post->getPrimaryCategory()->getTitle(); $item->author = $post->author->getName(); $item->authorEmail = $this->getRssEmail($post->author); $this->doc->addItem($item); } }
/** * Default display method for featured listings * * @since 4.0 * @access public * @param string * @return */ public function display($tmpl = null) { // Set the meta tags for this page EB::setMeta(META_ID_FEATURED, META_TYPE_VIEW); // Add the RSS headers on the page EB::feeds()->addHeaders('index.php?option=com_easyblog&view=featured'); // Add breadcrumbs on the site menu. $this->setPathway('COM_EASYBLOG_FEATURED_BREADCRUMB'); // Get the model $model = EB::model('Featured'); // Get a list of featured posts $posts = $model->getPosts(); // Get the pagination $pagination = $model->getPagination(); // Format the posts $posts = EB::formatter('list', $posts); // Set the page title $title = EB::getPageTitle(JText::_('COM_EASYBLOG_FEATURED_PAGE_TITLE')); $this->setPageTitle($title, $pagination, $this->config->get('main_pagetitle_autoappend')); // Get the current url $return = EBR::_('index.php?option=com_easyblog', false); $this->set('return', $return); $this->set('posts', $posts); $this->set('pagination', $pagination); parent::display('blogs/featured/default'); }
/** * @since 3.0 * Unsubscribe a user with email to a blog post * * @param int Subscription ID * @param int Blog post ID * * @return bool True on success */ public function unsubscribe() { $subscriptionId = JRequest::getInt('subscription_id'); $blogId = JRequest::getInt('blog_id'); $my = JFactory::getUser(); $mainframe = JFactory::getApplication(); $redirect = EBR::_('index.php?option=com_easyblog&view=entry&id=' . $blogId, false); // Check variables if ($my->id == 0 || !$subscriptionId || !$blogId) { EB::info()->set(JText::_('COM_EASYBLOG_NOT_ALLOWED'), 'error'); $mainframe->redirect($redirect); } // Need to ensure that whatever id passed in is owned by the current browser $blogModel = EB::model('Blog'); $sid = $blogModel->isBlogSubscribedUser($blogId, $my->id, $my->email); if ($subscriptionId != $sid) { EB::info()->set(JText::_('COM_EASYBLOG_NOT_ALLOWED'), 'error'); $mainframe->redirect($redirect); } // Proceed to unsubscribe $table = EB::table('Subscriptions'); $table->load($subscriptionId); if (!$table->delete()) { EB::info()->set(JText::_('COM_EASYBLOG_UNSUBSCRIBE_BLOG_FAILED'), 'error'); $mainframe->redirect($redirect); } EB::info()->set(JText::_('COM_EASYBLOG_UNSUBSCRIBE_BLOG_SUCCESS'), 'success'); $mainframe->redirect($redirect); }
public function load($cid) { static $instances = array(); if (!isset($instances[$cid])) { $this->_item = EB::post($cid); if (!$this->_item) { return $this->onLoadArticleError($cid); } $blogger = EB::user($this->_item->created_by); $this->_item->blogger = $blogger; $link = 'index.php?option=com_easyblog&view=entry&id=' . $this->getContentId(); // forcefully get item id if request is ajax $format = JRequest::getString('format', 'html'); if ($format === 'ajax') { $itemid = JRequest::getInt('pageItemId'); if (!empty($itemid)) { $link .= '&Itemid=' . $itemid; } } $link = EBR::_($link); $this->_item->permalink = $this->prepareLink($link); $instances[$cid] = $this->_item; } $this->_item = $instances[$cid]; return $this; }
/** * Outputs the html code for Twitter button * * @since 4.0 * @access public * @param string * @return */ public function html() { if (!$this->isEnabled()) { return; } $this->addScript(); // Get the pinterest button style from the configuration $size = $this->getButtonSize(); $url = EBR::getRoutedURL('index.php?option=com_easyblog&view=entry&id=' . $this->post->id, false, true); // Combine the introtext and the content $content = $this->post->intro . $this->post->content; // Get the media $media = $this->getMedia(); $contentLength = 350; $text = $this->post->intro . $this->post->content; $text = nl2br($text); $text = strip_tags($text); $text = trim(preg_replace('/\\s+/', ' ', $text)); $text = JString::strlen($text) > $contentLength ? JString::substr($text, 0, $contentLength) . '...' : $text; $title = $this->post->title; // Urlencode all the necessary properties. $url = urlencode($url); $text = urlencode($text); $media = urlencode($media); $placeholder = $this->getPlaceholderId(); $theme = EB::template(); $theme->set('size', $size); $theme->set('placeholder', $placeholder); $theme->set('url', $url); $theme->set('title', $title); $theme->set('media', $media); $theme->set('text', $text); $output = $theme->output('site/socialbuttons/pinterest'); return $output; }
/** * Displays the pagination links at the bottom of the page. * * @since 5.0 * @access public * @param string * @return */ public function toHTML($view = 'index', $replace = false) { // Retrieve the pagination data. $data = $this->getData(); // If there's no pagination at all, skip this if (count($data->pages) == $this->get('pages.total') && $this->get('pages.total') == 1 || $this->get('pages.total') == 0) { return false; } $queries = ''; if (!empty($data) && $replace) { $currentPageLink = 'index.php?option=com_easyblog&view=' . $view . $queries; foreach ($data->pages as $page) { if (!empty($page->link)) { $limitstart = !empty($page->base) ? '&limitstart=' . $page->base : ''; $page->link = EBR::_($currentPageLink . $limitstart); } } if (!empty($data->next->link)) { $limitstart = !empty($data->next->base) ? '&limitstart=' . $data->next->base : ''; $data->next->link = EBR::_($currentPageLink . $limitstart); } if (!empyt($data->previous->link)) { $limitstart = !empty($data->previous->base) ? '&limitstart=' . $data->previous->base : ''; $data->previous->link = EBR::_($currentPageLink . $limitstart); } } $template = EB::template(); $template->set('data', $data); return $template->output('site/blogs/pagination/default'); }
/** 1.5 **/ public function onSearch($text, $phrase = '', $ordering = '', $areas = null) { $plugin = JPluginHelper::getPlugin('search', 'easyblog'); $params = EB::registry($plugin->params); if (!plgSearchEasyblog::exists()) { return array(); } if (is_array($areas)) { if (!array_intersect($areas, array_keys(plgSearchEasyblog::onContentSearchAreas()))) { return array(); } } $text = trim($text); if ($text == '') { return array(); } $result = plgSearchEasyblog::getResult($text, $phrase, $ordering); if (!$result) { return array(); } // require_once( EBLOG_HELPERS . DIRECTORY_SEPARATOR . 'router.php' ); foreach ($result as $row) { $row->section = plgSearchEasyblog::getCategory($row->category_id); $row->section = JText::sprintf('PLG_EASYBLOG_SEARCH_BLOGS_SECTION', $row->section); $row->href = EBR::_('index.php?option=com_easyblog&view=entry&id=' . $row->id); $blog = EB::table('Blog'); $blog->bind($row); if ($blog->getImage()) { $row->image = $blog->getImage('frontpage'); } } return $result; }
/** * Generates the unsubscribe link for the email * * @since 5.0 * @access public * @param string * @return */ public function getUnsubscribeLink($data, $external = false) { $itemId = EBR::getItemId('latest'); // Generate the unsubscribe hash $hash = base64_encode(json_encode($data->export())); $link = EBR::getRoutedURL('index.php?option=com_easyblog&task=subscription.unsubscribe&data=' . $hash . '&Itemid=' . $itemId, false, $external); return $link; }
/** * Default feed display method * * @since 5.0 * @access public * @param string * @return */ public function display($tmpl = null) { // Ensure that rss is enabled if (!$this->config->get('main_rss')) { return JError::raiseError(404, JText::_('COM_EASYBLOG_FEEDS_DISABLED')); } $id = $this->input->get('id', '', 'cmd'); $category = EB::table('Category'); $category->load($id); // Private category shouldn't allow to access. $privacy = $category->checkPrivacy(); if (!$privacy->allowed) { return JError::raiseError(500, JText::_('COM_EASYBLOG_NOT_ALLOWED_HERE')); } // Get the nested categories $category->childs = null; EB::buildNestedCategories($category->id, $category); $linkage = ''; EB::accessNestedCategories($category, $linkage, '0', '', 'link', ', '); $catIds = array(); $catIds[] = $category->id; EB::accessNestedCategoriesId($category, $catIds); $category->nestedLink = $linkage; $model = EB::model('Blog'); $sort = $this->input->get('sort', $this->config->get('layout_postorder'), 'cmd'); $posts = $model->getBlogsBy('category', $catIds, $sort); $posts = EB::formatter('list', $posts); $this->doc->link = EBR::_('index.php?option=com_easyblog&view=categories&id=' . $id . '&layout=listings'); $this->doc->setTitle($this->escape($category->getTitle())); $this->doc->setDescription(JText::sprintf('COM_EASYBLOG_FEEDS_CATEGORY_DESC', $this->escape($category->getTitle()))); if (!$posts) { return; } $uri = JURI::getInstance(); $scheme = $uri->toString(array('scheme')); $scheme = str_replace('://', ':', $scheme); foreach ($posts as $post) { $image = ''; if ($post->hasImage()) { $image = '<img src="' . $post->getImage('medium', true, true) . '" width="250" align="left" />'; } $item = new JFeedItem(); $item->title = $this->escape($post->title); $item->link = $post->getPermalink(); $item->description = $image . $post->getIntro(); // replace the image source to proper format so that feed reader can view the image correctly. $item->description = str_replace('src="//', 'src="' . $scheme . '//', $item->description); $item->description = str_replace('href="//', 'href="' . $scheme . '//', $item->description); $item->date = $post->getCreationDate()->toSql(); $item->category = $post->getPrimaryCategory()->getTitle(); $item->author = $post->author->getName(); $item->authorEmail = $this->getRssEmail($post->author); $this->doc->addItem($item); } // exit; }
function display($tmpl = null) { if (!$this->config->get('main_rss')) { return; } $model = EB::model('Blog'); $data = $model->getFeaturedBlog(); $document = JFactory::getDocument(); $document->link = EBR::_('index.php?option=com_easyblog&view=featured'); $document->setTitle(JText::_('COM_EASYBLOG_FEEDS_FEATURED_TITLE')); $document->setDescription(JText::sprintf('COM_EASYBLOG_FEEDS_FEATURED_DESC', JURI::root())); if (empty($data)) { return; } $uri = JURI::getInstance(); $scheme = $uri->toString(array('scheme')); $scheme = str_replace('://', ':', $scheme); foreach ($data as $row) { $blog = EB::table('Blog'); $blog->load($row->id); $profile = EB::user($row->created_by); $created = EB::date($row->created); $row->created = $created->toSql(); if ($this->config->get('main_rss_content') == 'introtext') { $row->text = !empty($row->intro) ? $row->intro : $row->content; //read more for feed $row->text .= '<br /><a href=' . EBR::_('index.php?option=com_easyblog&view=entry&id=' . $row->id) . '>Read more</a>'; } else { $row->text = $row->intro . $row->content; } $row->text = EB::videos()->strip($row->text); $row->text = EB::adsense()->stripAdsenseCode($row->text); $category = EB::table('Category'); // Get primary category $primaryCategory = $blog->getPrimaryCategory(); $category->load($primaryCategory->id); // Assign to feed item $title = $this->escape($row->title); $title = html_entity_decode($title); // load individual item creator class $item = new JFeedItem(); $item->title = $title; $item->link = EBR::_('index.php?option=com_easyblog&view=entry&id=' . $row->id); $item->description = $row->text; // replace the image source to proper format so that feed reader can view the image correctly. $item->description = str_replace('src="//', 'src="' . $scheme . '//', $item->description); $item->description = str_replace('href="//', 'href="' . $scheme . '//', $item->description); $item->date = $row->created; $item->category = $category->getTitle(); $item->author = $profile->getName(); $item->authorEmail = $this->getRssEmail($profile); $document->addItem($item); } }
/** * Appends the necessary rss fragments on existing url * * @since 4.0 * @access public * @param string * @return */ public function getFeedURL($url, $atom = false, $type = 'site') { if ($this->config->get('main_feedburner') && $type == 'site' && $this->config->get('main_feedburner_url') != '') { return $this->config->get('main_feedburner_url'); } $join = EasyBlogRouter::isSefEnabled() ? '?' : '&'; // Append the necessary queries $url = EBR::_($url) . $join . 'format=feed'; $url .= $atom ? '&type=atom' : '&type=rss'; return $url; }
/** * Retrieves the profile link * * @since 5.0 * @access public * @param string * @return */ public function getLink() { // If profile user is not an author for whatever reason it is, we shouldn't display it as a link if (!$this->config->get('main_nonblogger_profile')) { $isAuthor = EB::isBlogger($this->profile->id); if (!$isAuthor) { return 'javascript:void(0);'; } } $default = EBR::_('index.php?option=com_easyblog&view=blogger&layout=listings&id=' . $this->profile->id); return $default; }
/** * Allows caller to unsubscribe a person given the id of the subscription * * @since 5.0 * @access public */ public function unsubscribe() { // Default redirection url $redirect = EBR::_('index.php?option=com_easyblog&view=subscription', false); // Default redirection link should link to the front page if the user isn't logged in if ($this->my->guest) { $redirect = EBR::_('index.php?option=com_easyblog', false); } $return = $this->getReturnURL(); if ($return) { $redirect = $return; } // Get the subscription id $id = $this->input->get('id', 0, 'int'); $subscription = EB::table('Subscriptions'); // Load up the subscription if id is provided if ($id) { $subscription->load($id); // Verify if the user really has access to unsubscribe for guests if (!$subscription->id) { return JError::raiseError(500, JText::_('COM_EASYBLOG_NOT_ALLOWED_TO_PERFORM_ACTION')); } // Ensure that the registered user is allowed to unsubscribe. if ($subscription->user_id && $this->my->id != $subscription->user_id && !EB::isSiteAdmin()) { return JError::raiseError(500, JText::_('COM_EASYBLOG_NOT_ALLOWED_TO_PERFORM_ACTION')); } } else { // Try to get the email and what not from the query $data = $this->input->get('data', '', 'raw'); $data = base64_decode($data); $registry = new JRegistry($data); $id = $registry->get('sid', ''); $subscription->load($id); // Verify if the user really has access to unsubscribe for guests if (!$subscription->id) { return JError::raiseError(500, JText::_('COM_EASYBLOG_NOT_ALLOWED_TO_PERFORM_ACTION')); } // Get the token from the url and ensure that the token matches $token = $registry->get('token', ''); if ($token != md5($subscription->id . $subscription->created)) { JError::raiseError(500, JText::_('COM_EASYBLOG_NOT_ALLOWED_TO_PERFORM_ACTION')); } } // Try to delete the subscription $state = $subscription->delete(); // Ensure that the user really owns this item if (!$state) { $this->info->set($subscription->getError()); return $this->app->redirect($redirect); } $this->info->set('COM_EASYBLOG_UNSUBSCRIBED_SUCCESS', 'success'); return $this->app->redirect($redirect); }
public function _buildQueryLanguage() { $mainframe = JFactory::getApplication(); $my = JFactory::getUser(); $db = EB::db(); $languageQ = ''; // @rule: When language filter is enabled, we need to detect the appropriate contents $filterLanguage = JFactory::getApplication()->getLanguageFilter(); if ($filterLanguage) { $languageQ .= EBR::getLanguageQuery('AND', 'a.language'); } return $languageQ; }
/** * Allows visitor to approve a comment * * @since 5.0 * @access public */ public function moderate() { // Get the hash key $key = $this->input->get('key', '', 'default'); // Default redirection url $redirect = EBR::_('index.php?option=com_easyblog', false); if (!$key) { $this->info->set('COM_EASYBLOG_NOT_ALLOWED', 'error'); return $this->app->redirect($redirect); } // Get the hashkey from the site $hashkey = EB::table('Hashkeys'); $state = $hashkey->loadByKey($key); // If the key doesn't exist, it may no longer be a valid request if (!$state || !$hashkey->id) { $this->info->set('COM_EASYBLOG_NOT_ALLOWED', 'error'); return $this->app->redirect($redirect); } // Load the comment now $comment = EB::table('Comment'); $comment->load($hashkey->uid); // Get the task to perform $task = $this->getTask(); // Load up the post library $post = EB::post($comment->post_id); if ($task == 'approve') { $comment->published = EBLOG_COMMENT_PUBLISHED; // Save the comment now $comment->store(true); // Process the mails for comments now $comment->processEmails(false, $post); // Update the sent flag for the comment $comment->updateSent(); } if ($task == 'reject') { $comment->published = EBLOG_COMMENT_UNPUBLISHED; $comment->store(true); } // Delete the unused hashkey now. $hashkey->delete(); $message = 'COM_EASYBLOG_MODERATE_COMMENT_PUBLISHED_SUCCESS'; if ($task == 'reject') { $message = 'COM_EASYBLOG_MODERATE_COMMENT_UNPUBLISHED_SUCCESS'; } $this->info->set($message, 'success'); // Get the permalink to the post $permalink = $post->getPermalink(false); return $this->app->redirect($permalink); }
public function display($tmpl = null) { // If user is already logged in, just redirect them if (!$this->my->guest) { $this->info->set(JText::_('COM_EASYBLOG_YOU_ARE_ALREADY_LOGIN'), 'error'); return $this->app->redirect(EBR::_('index.php?option=com_easyblog')); } // Determines if there's any return url $return = $this->input->get('return', ''); if (empty($return)) { $return = base64_encode(EBR::_('index.php?option=com_easyblog', false)); } $this->set('return', $return); parent::display('login/default'); }
function display($tmpl = null) { if (!$this->config->get('main_rss')) { return; } $id = $this->input->get('id', '', 'cmd'); $team = EB::table('TeamBlog'); $team->load($id); // if ($team->access != EBLOG_TEAMBLOG_ACCESS_EVERYONE ) { // return; // } $sort = JRequest::getCmd('sort', $this->config->get('layout_postorder')); $model = EB::model('Blog'); $data = $model->getBlogsBy('teamblog', $id, $sort); // $model = EB::model('TeamBlogs'); // $posts = $model->getPosts($team->id); // $posts = EB::formatter('list', $posts); $document = JFactory::getDocument(); $document->link = EBR::_('index.php?option=com_easyblog&view=latest'); $document->setTitle(JText::sprintf('COM_EASYBLOG_FEEDS_TEAMBLOGS_TITLE', $team->title)); $document->setDescription(JText::sprintf('COM_EASYBLOG_FEEDS_TEAMBLOGS_DESC', $team->title)); if (empty($data)) { return; } $uri = JURI::getInstance(); $scheme = $uri->toString(array('scheme')); $scheme = str_replace('://', ':', $scheme); $data = EB::formatter('list', $data); foreach ($data as $post) { $image = ''; if ($post->hasImage()) { $image = '<img src="' . $post->getImage('medium', true, true) . '" width="250" align="left" />'; } $item = new JFeedItem(); $item->title = $this->escape($post->title); $item->link = $post->getPermalink(); $item->description = $image . $post->getIntro(); // replace the image source to proper format so that feed reader can view the image correctly. $item->description = str_replace('src="//', 'src="' . $scheme . '//', $item->description); $item->description = str_replace('href="//', 'href="' . $scheme . '//', $item->description); $item->date = $post->getCreationDate()->toSql(); $item->category = $post->getPrimaryCategory()->getTitle(); $item->author = $post->author->getName(); $item->authorEmail = $this->getRssEmail($profile); $this->doc->addItem($item); } }
function request() { $mainframe = JFactory::getApplication(); if (!EasyBlogHelper::isLoggedIn()) { $mainframe->enqueueMessage(JText::_('COM_EASYBLOG_YOU_MUST_LOGIN_FIRST'), 'error'); $this->setRedirect(EBR::_('index.php?option=com_easyblog', false)); return; } $redirect = JRequest::getVar('redirect', ''); $type = JRequest::getCmd('type'); if (!empty($redirect)) { $redirect = '&redirect=' . $redirect; } $userId = JRequest::getVar('id'); // Flickr integration does not require user id. if (empty($userId)) { $mainframe->enqueueMessage(JText::_('Error, User not found.'), 'error'); $redirect = JRoute::_('index.php?option=com_easyblog&view=users', false); $this->setRedirect($redirect); return; } $call = JRequest::getWord('call'); $callUri = !empty($call) ? '&call=' . $call . '&id=' . $userId : '&id=' . $userId; $config = EasyBlogHelper::getConfig(); $key = $config->get('integrations_' . $type . '_api_key'); $secret = $config->get('integrations_' . $type . '_secret_key'); $callback = rtrim(JURI::root(), '/') . '/administrator/index.php?option=com_easyblog&c=oauth&task=grant&type=' . $type . $redirect . $callUri; $consumer = EasyBlogOauthHelper::getConsumer($type, $key, $secret, $callback); $request = $consumer->getRequestToken(); if (empty($request->token) || empty($request->secret)) { $mainframe->enqueueMessage(JText::_('COM_EASYBLOG_OAUTH_KEY_INVALID'), 'error'); $redirect = JRoute::_('index.php?option=com_easyblog&view=users', false); $this->setRedirect($redirect); return; } $oauth = EB::table('Oauth'); $oauth->user_id = $userId; $oauth->type = $type; $oauth->created = EB::date()->toMySQL(); // Bind the request tokens $param = EB::registry(); $param->set('token', $request->token); $param->set('secret', $request->secret); $oauth->request_token = $param->toString(); $oauth->store(); $this->setRedirect($consumer->getAuthorizationURL($request->token, false, 'popup')); }
/** * Default display method for my blog listings * * @since 4.0 * @access public * @param string * @return */ public function display($tmpl = null) { // Require user to be logged in to access this page EB::requireLogin(); // Get the default sorting behavior $sort = $this->input->get('sort', $this->config->get('layout_postorder'), 'cmd'); // Load up the author profile $author = EB::user($this->my->id); // Set meta tags for blogger EB::setMeta($this->my->id, META_ID_BLOGGERS); // Set the breadcrumbs $this->setPathway(JText::_('COM_EASYBLOG_BLOGGERS_BREADCRUMB'), EB::_('index.php?option=com_easyblog&view=blogger')); $this->setPathway($author->getName()); $menu = JFactory::getApplication()->getMenu(); $categoryInclusion = array(); if ($menu) { $active = $menu->getActive(); $categoryInclusion = $active->params->get('inclusion'); } $model = EB::model('Blog'); $posts = $model->getBlogsBy('blogger', $author->id, $sort, 0, EBLOG_FILTER_PUBLISHED, false, false, array(), false, false, true, array(), $categoryInclusion); // Get the pagination $pagination = $model->getPagination(); // Set the page title $title = $author->getName() . ' - ' . EB::getPageTitle(JText::_('COM_EASYBLOG_MY_BLOG_PAGE_TITLE')); $this->setPageTitle($title, $pagination, $this->config->get('main_pagetitle_autoappend')); // Format the posts $posts = EB::formatter('list', $posts); // Add the RSS headers on the page EB::feeds()->addHeaders('index.php?option=com_easyblog&view=myblog'); // Determines if the viewer already subscribed to the author $subscribed = false; $bloggerModel = EB::model('Blogger'); if ($bloggerModel->isBloggerSubscribedUser($author->id, $this->my->id, $this->my->email)) { $subscribed = true; } // Get the current url $return = EBR::_('index.php?option=com_easyblog', false); $this->set('return', $return); $this->set('subscribed', $subscribed); $this->set('author', $author); $this->set('posts', $posts); $this->set('sort', $sort); $this->set('pagination', $pagination); parent::display('blogs/myblog/default'); }
public function display($tmpl = null) { // Checks if rss is enabled if (!$this->config->get('main_rss')) { return; } // Get the archives model $model = EB::model('Archive'); // Get a list of posts $posts = $model->getPosts(); // Format the posts $posts = EB::formatter('list', $posts); // Set the link for this feed $this->doc->link = EBR::_('index.php?option=com_easyblog&view=archive'); $this->doc->setTitle(JText::_('COM_EASYBLOG_ARCHIVED_POSTS')); $this->doc->setDescription(JText::_('COM_EASYBLOG_ARCHIVED_POSTS_DESC')); if (!$posts) { return; } $uri = JURI::getInstance(); $scheme = $uri->toString(array('scheme')); $scheme = str_replace('://', ':', $scheme); foreach ($posts as $post) { $image = ''; if ($post->hasImage()) { $image = '<img src=' . $post->getImage('medium', true, true) . '" alt="' . $post->title . '" />'; } $item = new JFeedItem(); $item->title = $post->title; $item->link = $post->getPermalink(); $item->description = $image . $post->getIntro(); // replace the image source to proper format so that feed reader can view the image correctly. $item->description = str_replace('src="//', 'src="' . $scheme . '//', $item->description); $item->description = str_replace('href="//', 'href="' . $scheme . '//', $item->description); $item->date = $post->getCreationDate()->format(); $item->category = $post->getPrimaryCategory()->getTitle(); $item->author = $post->author->getName(); $item->authorEmail = $this->getRssEmail($post->author); $this->doc->addItem($item); } }
/** * Displays a list of subscriptions the user belongs to. * * @since 5.0 * @access public * @param string * @return */ public function display($tpl = null) { // Check for acl $this->checkAcl('allow_subscription'); // Do not allow guests to access this page if ($this->my->guest) { return EB::requireLogin(); } // Set the title of the page $this->doc->setTitle(JText::_('COM_EASYBLOG_SUBSCRIPTIONS_PAGE_TITLE')); // Add pathway if (!EBR::isCurrentActiveMenu('subscription')) { $this->setPathway(JText::_('COM_EASYBLOG_SUBSCRIPTIONS_BREADCRUMB')); } // Ensure that the user has access to manage subscriptions if (!$this->acl->get('allow_subscription')) { return JError::raiseError(500, JText::_('COM_EASYBLOG_YOU_DO_NOT_HAVE_PERMISSION_TO_VIEW')); } // Get a list of subscriptions the user has $model = EB::model('Subscriptions'); $result = $model->getSubscriptionsByUser($this->my->id); $subscriptions = array(); $groups = array(); if ($result) { foreach ($result as $row) { $type = $row->utype; $groups[] = $type; if (!isset($subscriptions[$type])) { $subscriptions[$row->utype] = array(); } // Get the formatted type title $row->object = $row->getObject(); $subscriptions[$row->utype][] = $row; } } // Ensure that the groups are unique $groups = array_unique($groups); $this->set('groups', $groups); $this->set('subscriptions', $subscriptions); parent::display('subscription/default'); }
/** * Notifies the site owners when a new report is made on the site * * @since 5.0 * @access public * @param string * @return */ public function notify(EasyBlogPost &$post) { $config = EB::config(); // Send notification to site admins when a new blog post is reported $data = array(); $data['blogTitle'] = $post->title; $data['blogLink'] = $post->getExternalPermalink(); // Get the author of this reporter $author = $this->getAuthor(); $data['reporterAvatar'] = $author->getAvatar(); $data['reporterName'] = $author->getName(); $data['reporterLink'] = $author->getProfileLink(); $data['reason'] = $this->reason; $data['reportDate'] = EB::date()->format(JText::_('DATE_FORMAT_LC2')); // If blog post is being posted from the back end and SH404 is installed, we should just use the raw urls. $app = JFactory::getApplication(); if ($app->isAdmin() && EBR::isSh404Enabled()) { $data['blogLink'] = JURI::root() . 'index.php?option=com_easyblog&view=entry&id=' . $post->id; } // Set the title of the email $subject = JString::substr($post->title, 0, $config->get('main_mailtitle_length')); $subject = JText::sprintf('COM_EASYBLOG_EMAIL_TITLE_NEW_REPORT', $subject) . ' ...'; // Get the notification library $notification = EB::notification(); $recipients = array(); // Fetch custom emails defined at the back end. if ($config->get('notification_blogadmin')) { if ($config->get('custom_email_as_admin')) { $notification->getCustomEmails($recipients); } else { $notification->getAdminEmails($recipients); } } if (!empty($recipients)) { $notification->send($recipients, $subject, 'post.reported', $data); } }
function display($tmpl = null) { if (!$this->config->get('main_rss')) { return; } $id = $this->input->get('id', '', 'cmd'); JTable::addIncludePath(EBLOG_TABLES); $tag = EB::table('Tag'); $tag->load($id); $sort = 'latest'; $model = EB::model('Blog'); $data = $model->getTaggedBlogs($id); $document = JFactory::getDocument(); $document->link = EBR::_('index.php?option=com_easyblog&view=latest'); $document->setTitle(JText::sprintf('COM_EASYBLOG_FEEDS_TAGS_TITLE', htmlentities($tag->title))); $document->setDescription(JText::sprintf('COM_EASYBLOG_FEEDS_TAGS_DESC', htmlentities($tag->title))); if (empty($data)) { return; } $data = EB::formatter('list', $data); foreach ($data as $post) { $image = ''; if ($post->getImage('medium', true, true)) { $image = '<img src="' . $post->getImage('medium', true, true) . '" width="250" align="left" />'; } $item = new JFeedItem(); $item->title = $this->escape($post->title); $item->link = $post->getPermalink(); $item->description = $image . $post->getIntro(); $item->date = $post->getCreationDate()->toSql(); $item->category = $post->getPrimaryCategory()->getTitle(); $item->author = $post->author->getName(); $item->authorEmail = $this->getRssEmail($profile); $this->doc->addItem($item); } }
?> "> <?php $i = 1; ?> <div class="ezb-grids"> <?php foreach ($posts as $post) { ?> <div class="ezb-grid" style="width: <?php echo 100 / $params->get('columns'); ?> %"> <a class="ezb-card" href="<?php echo EBR::_('index.php?option=com_easyblog&view=entry&id=' . $post->id); ?> " title="<?php echo $post->title; ?> " style="background-image: url('<?php echo $post->media; ?> ');"> <span><?php echo $post->title; ?> </span> </a> </div>
/** * Retrieves alias for the category * * @since 5.0 * @access public * @param string * @return */ public function getAlias() { $config = EB::config(); $alias = $this->alias; if ($config->get('main_sef_unicode') || !EBR::isSefEnabled()) { $alias = $this->id . ':' . $this->alias; } return $alias; }
/** * Retrieves the next post in line * * @since 5.0 * @access public * @param string * @return */ public function getPostNavigation(EasyBlogPost $post, $navigationType) { $db = EB::db(); $my = JFactory::getUser(); $config = EB::config(); $keys = array('prev', 'next'); $nav = new stdClass(); // Get the active menu $active = JFactory::getApplication()->getMenu()->getActive(); $catAccess = array(); $queryInclude = ''; $teamId = $post->getTeamAssociation(); $author = $post->getAuthor(); // // If there is an active menu for EasyBlog, check if there's any filtering by categories // if ($active) { // $cats = EB::getCategoryInclusion($active->params->get('inclusion')); // if ($cats && !is_array($cats)) { // $cats = array($cats); // } // $catAccess['include'] = $cats; // } // // sql for category access // $catLib = EB::category(); // $catAccessSQL = $catLib->genAccessSQL( 'a.`id`', $catAccess); foreach ($keys as $key) { $query = array(); $query[] = 'SELECT a.`id`, a.`title`'; $query[] = ' FROM `#__easyblog_post` AS `a`'; $query[] = ' WHERE a.`published` = ' . $db->Quote(EASYBLOG_POST_PUBLISHED); $query[] = ' AND a.`state` = ' . $db->Quote(EASYBLOG_POST_NORMAL); // EasySocial integrations $query[] = EB::easysocial()->buildPrivacyQuery('a'); // Jomsocial integrations $query[] = EB::jomsocial()->buildPrivacyQuery(); // Blog privacy settings if ($my->guest) { $query[] = 'AND a.' . $db->qn('access') . '=' . $db->Quote(BLOG_PRIVACY_PUBLIC); } // Exclude private categories // $query[] = 'AND (' . $catAccessSQL . ')'; // If the current menu is blogger mode, we need to respect this by only loading author related items $isBloggerMode = EBR::isBloggerMode(); if ($isBloggerMode !== false) { $query[] = 'AND a.' . $db->qn('created_by') . '=' . $db->Quote($isBloggerMode); $query[] = 'AND a.' . $db->qn('source_type') . '=' . $db->Quote(EASYBLOG_POST_SOURCE_SITEWIDE); } // Filter the next / previous link by team if ($navigationType == 'team' && $teamId) { $query[] = 'AND (a.' . $db->qn('source_type') . '=' . $db->Quote(EASYBLOG_POST_SOURCE_TEAM) . ' AND a.' . $db->qn('source_id') . '=' . $db->Quote($teamId) . ')'; } // Filter the next / previous by author if ($navigationType == 'author') { $query[] = 'AND a.' . $db->qn('created_by') . '=' . $db->Quote($author->id); $query[] = 'AND a.' . $db->qn('source_type') . '=' . $db->Quote(EASYBLOG_POST_SOURCE_SITEWIDE); } // Filter the next / previous post items from site wide if ($navigationType == 'site') { $query[] = 'AND a.' . $db->qn('source_type') . '=' . $db->Quote(EASYBLOG_POST_SOURCE_SITEWIDE); } // When language filter is enabled, we need to detect the appropriate contents $filterLanguage = JFactory::getApplication()->getLanguageFilter(); if ($filterLanguage) { $query[] = EBR::getLanguageQuery('AND', 'a.language'); } if ($key == 'prev') { $query[] = ' AND a.`created` < ' . $db->Quote($post->created); $query[] = ' ORDER BY a.`created` DESC'; } if ($key == 'next') { $query[] = ' AND a.`created` > ' . $db->Quote($post->created); $query[] = ' ORDER BY a.`created` ASC'; } $query[] = 'LIMIT 1'; $query = implode(' ', $query); $db->setQuery($query); $result = $db->loadObject(); $nav->{$key} = $result; } return $nav; }
</title> <content> <form data-form-delete-post method="post" action="<?php echo JRoute::_('index.php'); ?> "> <p><?php echo JText::_('COM_EASYBLOG_DIALOG_COMPOSER_DELETE_POST_CONFIRMATION'); ?> </p> <input type="hidden" name="ids" value="<?php echo $uid; ?> " /> <?php echo $this->html('form.hidden', 'return', base64_encode(EBR::_('index.php?option=com_easyblog&view=composer&tmpl=component', false))); ?> <?php echo $this->html('form.action', 'posts.delete'); ?> </form> </content> <buttons> <button data-close-button type="button" class="btn btn-default btn-sm"><?php echo JText::_('COM_EASYBLOG_CANCEL_BUTTON'); ?> </button> <button data-delete-button type="button" class="btn btn-danger btn-sm"><?php echo JText::_('COM_EASYBLOG_DELETE_BUTTON'); ?> </button>
/** * Formats the message to be published on Twitter * * @since 4.0 * @access public * @param string * @return */ public function formatMessage(EasyBlogPost &$post, EasyBlogTableOAuth &$oauth) { // Get the message template to use to push to Twitter $content = !empty($oauth->message) ? $oauth->message : $this->config->get('main_twitter_message'); // Default vars to search / replace $search = array(); $replace = array(); // Replace the {title} tag if (JString::stristr($content, '{title}') !== false) { $search[] = '{title}'; $replace[] = $post->title; } // Replace the {introtext} tag if (JString::stristr($content, '{introtext}') !== false) { $search[] = '{introtext}'; $replace[] = $post->getIntro(EASYBLOG_STRIP_TAGS); } // Replace the {category} tag if (JString::stristr($content, '{category}') !== false) { // Get the primary category of the blog post $category = $post->getPrimaryCategory(); $search[] = '{category}'; $replace[] = $category->title; } // Get the final content $content = JString::str_ireplace($search, $replace, $content); // Replace the {link} tag if (JString::stristr($content, '{link}') !== false) { // Twitter will automatically shorten urls and a link will have a maximum of 22 chars // which leaves us with an offset of 118 characters $length = 22; $link = EBR::getRoutedURL('index.php?option=com_easyblog&view=entry&id=' . $post->id, false, true); // If blog post is being posted from the back end and SH404 is installed, we should just use the raw urls. $sh404exists = EBR::isSh404Enabled(); if ($this->app->isAdmin() && $sh404exists) { $link = rtrim(JURI::root(), '/') . '/index.php?option=com_easyblog&view=entry&id=' . $post->id; } // Get the remaining length that we can use. $remaining = 140 - $length; // Split the message $parts = explode('{link}', $content); for ($i = 0; $i < count($parts); $i++) { $tmp =& $parts[$i]; $tmpLength = JString::strlen($tmp); if ($tmpLength > $remaining) { if ($remaining <= 0) { $tmp = JString::substr($tmp, 0, 0); } else { if ($remaining < 6) { $tmp = JString::substr($tmp, 0, $remaining); } else { $tmp = JString::substr($tmp, 0, $remaining - 3) . JText::_('COM_EASYBLOG_ELLIPSES'); } $remaining = 0; } } else { $remaining -= $tmpLength; } } $content = implode($link, $parts); } else { $content = JString::substr($content, 0, 136) . JText::_('COM_EASYBLOG_ELLIPSES'); } return $content; }
/** * Generate a canonical tag on the header of the page * * @since 4.0 * @access public * @param string * @return */ public function canonical($url) { $url = EBR::_($url, false, null, true); $this->doc->addHeadLink($this->escape($url), 'canonical'); }
/** * Given a revision id, update the post to use the revision * * @since 5.0 * @access public * @param string * @return */ public function useRevision() { try { $this->verifyAccess(); } catch (EasyBlogException $exception) { dump($exception->getMessage()); } $return = $this->input->get('return', '', 'default'); $uid = $this->input->get('uid', '', 'default'); if (!$return) { $return = EBR::_('index.php?option=com_easyblog&view=composer&tmpl=component&uid=' . $uid, false); } else { $return = base64_decode($return); } // Load up the post $uid = $this->input->get('uid'); $post = EB::post($uid); $post->published = EASYBLOG_POST_PUBLISHED; $post->useRevision(); return $this->app->redirect($return); }