/** * 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'); }
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); } }
public function get() { $input = JFactory::getApplication()->input; $model = EasyBlogHelper::getModel('Blog'); //$id = $input->get('id', null, 'INT'); $id = 0; $search = $input->get('search', '', 'STRING'); $featured = $input->get('featured', 0, 'INT'); $tags = $input->get('tags', 0, 'INT'); $user_id = $input->get('user_id', 0, 'INT'); $posts = array(); // If we have an id try to fetch the user $blog = EasyBlogHelper::table('Blog'); $blog->load($id); $modelPT = EasyBlogHelper::getModel('PostTag'); if ($tags) { $rows = $model->getTaggedBlogs($tags); } else { if ($featured) { $rows = $this->getfeature_Blog(); $sorting = $this->plugin->params->get('sorting', 'featured'); } else { if ($user_id) { $blogs = EasyBlogHelper::getModel('Blog'); $rows = $blogs->getBlogsBy('blogger', $user_id, 'latest'); } else { //to get latest blog //$sorting = $this->plugin->params->get( 'sorting' , 'latest' ); //$rows = $model->getBlogsBy( $sorting , '' , $sorting , 0, EBLOG_FILTER_PUBLISHED, $search ); $rows = $model->getBlogsBy('', '', 'latest', 0, EBLOG_FILTER_PUBLISHED, null, true, array(), false, false, true, '', '', null, 'listlength', false); //$rows = EB::formatter('list', $rows, false); } } } $rows = EB::formatter('list', $rows, false); //data mapping foreach ($rows as $k => $v) { //$item = EB::helper( 'simpleschema' )->mapPost($v,'', 100, array('text')); $scm_obj = new EasyBlogSimpleSchema_plg(); $item = $scm_obj->mapPost($v, '', 100, array('text')); $item->tags = $modelPT->getBlogTags($item->postid); $item->isowner = $v->created_by == $this->plugin->get('user')->id ? true : false; if ($v->blogpassword != '') { $item->ispassword = true; } else { $item->ispassword = false; } $item->blogpassword = $v->blogpassword; $model = EasyBlogHelper::getModel('Ratings'); $ratingValue = $model->getRatingValues($item->postid, 'entry'); $item->rate = $ratingValue; $item->isVoted = $model->hasVoted($item->postid, 'entry', $this->plugin->get('user')->id); if ($item->rate->ratings == 0) { $item->rate->ratings = -2; } $posts[] = $item; } $this->plugin->setResponse($posts); }
public function display($tmpl = null) { JPluginHelper::importPlugin('easyblog'); $dispatcher = JDispatcher::getInstance(); $mainframe = JFactory::getApplication(); $document = JFactory::getDocument(); $config = EasyBlogHelper::getConfig(); //for trigger $params = $mainframe->getParams('com_easyblog'); $joomlaVersion = EasyBlogHelper::getJoomlaVersion(); $blogId = $this->input->get('id', 0, 'int'); if (empty($blogId)) { return JError::raiseError(404, JText::_('COM_EASYBLOG_BLOG_NOT_FOUND')); } $my = JFactory::getUser(); $blog = EB::table('Blog'); $blog->load($blogId); $post = EB::post($blogId); // Check if blog is password protected. $protected = $this->isProtected($post); if ($protected !== false) { return; } // If the blog post is already deleted, we shouldn't let it to be accessible at all. if ($post->isTrashed()) { return JError::raiseError(404, JText::_('COM_EASYBLOG_ENTRY_BLOG_NOT_FOUND')); } // Check if the blog post is trashed if (!$post->isPublished() && $this->my->id != $post->created_by && !EB::isSiteAdmin()) { return JError::raiseError(404, JText::_('COM_EASYBLOG_ENTRY_BLOG_NOT_FOUND')); } // Check for team's privacy $allowed = $this->checkTeamPrivacy($post); if ($allowed === false) { return JError::raiseError(404, JText::_('COM_EASYBLOG_TEAMBLOG_MEMBERS_ONLY')); } // Check if the blog post is accessible. $accessible = $post->isAccessible(); if (!$accessible->allowed) { echo $accessible->error; return; } // Format the post $post = EB::formatter('entry', $post); $tags = $post->getTags(); $theme = EB::template(); $theme->set('post', $post); $theme->set('tags', $tags); $blogHtml = $theme->output('site/blogs/entry/pdf'); $pageTitle = EasyBlogHelper::getPageTitle($config->get('main_title')); $document->setTitle($post->title . $pageTitle); $document->setName($post->getPermalink()); // Fix phoca pdf plugin. if (method_exists($document, 'setArticleText')) { $document->setArticleText($blogHtml); } echo $blogHtml; return; }
public function display($tmpl = null) { // Get the model $model = EB::model('Search'); $posts = $model->getData(); $posts = EB::formatter('list', $posts); $this->set('posts', $posts); return parent::display(); }
/** * 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; }
/** * Default method to render listings in json format. * * @since 5.0 * @access public * @param string * @return */ public function display($tmpl = null) { // Get the sorting options $sort = $this->input->get('sort', $this->config->get('layout_postorder')); $model = EB::model('Blog'); $posts = $model->getBlogsBy('', '', $sort, 0, EBLOG_FILTER_PUBLISHED, null, true); // Format the posts $posts = EB::formatter('list', $posts); $this->set('posts', $posts); return parent::display(); }
public function execute() { if (!$this->items) { return $this->items; } // cache teamblogs EB::cache()->insertTeams($this->items); $teams = array(); // Load up the blogs model $model = EB::model('TeamBlogs'); // Get the current user's group id's $gid = EB::getUserGids(); foreach ($this->items as $item) { $team = EB::table('TeamBlog'); $team->load($item->id); // Check if the logged in user is a member of the group $team->isMember = $team->isMember($this->my->id, $gid); $team->isActualMember = $team->isMember($this->my->id, $gid, false); $team->members = $model->getAllMembers($team->id, 5); // total member count ( including actual members and users from asociated joomla group.) $team->memberCount = $team->getAllMembersCount(); // post count associated with this teamblog. $team->postCount = $team->getPostCount(); // Get the list of blog posts form this team $blogs = array(); if ($team->access != EBLOG_TEAMBLOG_ACCESS_MEMBER || $team->isMember || EB::isSiteAdmin()) { $blogs = $model->getPosts($team->id, EASYBLOG_TEAMBLOG_LISTING_NO_POST); $blogs = EB::formatter('list', $blogs); } $team->blogs = $blogs; // Get the list of tags // $team->tags = $team->getTags(); // Get categories used in this team // $team->categories = $team->getCategories(); // Determines if the team is featured if (isset($item->isfeatured)) { $team->isFeatured = $item->isfeatured; } else { $team->isFeatured = EB::isFeatured('teamblog', $team->id); } // check if team description is emtpy or not. if yes, show default message. if (empty($team->description)) { $team->description = JText::_('COM_EASYBLOG_TEAMBLOG_NO_DESCRIPTION'); } // Determines if the viewer is subscribed to this team $team->isTeamSubscribed = $model->isTeamSubscribedEmail($team->id, $this->my->email); // If the user is subscribed, we need to get his subscription id $team->subscription_id = $team->isTeamSubscribed; $teams[] = $team; } return $teams; }
/** * Displays a list of blog posts from a specific team * * @since 4.0 * @access public * @param string * @return */ public function listings() { // Get the team id that is being accessed now $id = $this->input->get('id', 0, 'int'); $team = EB::table('TeamBlog'); $team->load($id); if (!$id || !$team->id) { return JError::raiseError(404, JText::_('COM_EASYBLOG_TEAMBLOG_INVALID_ID')); } // set meta tags for teamblog view EB::setMeta($id, META_TYPE_TEAM); $gid = EB::getUserGids(); $isMember = $team->isMember($this->my->id, $gid); $team->isMember = $isMember; $team->isActualMember = $team->isMember($this->my->id, $gid, false); // Add rss feed link if ($team->access == EBLOG_TEAMBLOG_ACCESS_EVERYONE || $team->isMember) { $this->doc->addHeadLink($team->getRSS(), 'alternate', 'rel', array('type' => 'application/rss+xml', 'title' => 'RSS 2.0')); $this->doc->addHeadLink($team->getAtom(), 'alternate', 'rel', array('type' => 'application/atom+xml', 'title' => 'Atom 1.0')); } // check if team description is emtpy or not. if yes, show default message. if (empty($team->description)) { $team->description = JText::_('COM_EASYBLOG_TEAMBLOG_NO_DESCRIPTION'); } // Set the breadcrumbs for this view $this->setViewBreadcrumb('teamblog'); $this->setPathway($team->getTitle()); // Retrieve the model $model = EB::model('TeamBlogs'); $posts = $model->getPosts($team->id); $posts = EB::formatter('list', $posts); // Get the pagination $pagination = $model->getPagination(); // Retrieve team's information $members = $model->getTeamMembers($team->id); // Determines if the team blog is featured $team->isFeatured = EB::isFeatured('teamblog', $team->id); // Set the page title $title = EB::getPageTitle($team->title); $this->setPageTitle($title, $pagination, $this->config->get('main_pagetitle_autoappend')); // Check if subscribed $isTeamSubscribed = $model->isTeamSubscribedEmail($team->id, $this->my->email); // Get the current url $return = $team->getPermalink(); $this->set('return', $return); $this->set('team', $team); $this->set('members', $members); $this->set('pagination', $pagination->getPagesLinks()); $this->set('posts', $posts); $this->set('isTeamSubscribed', $isTeamSubscribed); parent::display('teamblogs/item'); }
public static function getItems($params) { $model = EB::model('Blog'); // Determines if we should display featured or latest entries $type = $params->get('showposttype', 'featured'); // Determines if we should filter by category $categoryId = $params->get('catid'); $result = array(); if ($categoryId) { $categoryId = (int) $categoryId; } if ($type == 'latest' && !$categoryId) { $result = $model->getBlogsBy('', '', 'latest', $params->get('count'), EBLOG_FILTER_PUBLISHED, null, true, array(), false, false, false); } if ($type == 'latest' && $categoryId) { $result = $model->getBlogsBy('category', $categoryId, 'latest', $params->get('count'), EBLOG_FILTER_PUBLISHED, null, true, array(), false, false, false); } // If not latest posttype, show featured post. if ($type == 'featured') { if ($categoryId == 0) { $categoryId = ''; } $result = $model->getFeaturedBlog($categoryId); } // If there's nothing to show at all, don't display anything if (!$result) { return $result; } $results = EB::formatter('list', $result); // Randomize items if ($params->get('autoshuffle')) { shuffle($results); } $contentKey = $params->get('contentfrom', 'content'); $textcount = $params->get('textlimit', '200'); $posts = array(); foreach ($results as $result) { $content = $result->getContent(); // Get the content from the selected source if ($contentKey == 'intro') { $content = $result->getIntro(true); } // Truncate the content if (JString::strlen(strip_tags($content)) > $textcount) { $content = JString::substr(strip_tags($content), 0, $textcount) . '...'; } $result->content = $content; $posts[] = $result; } return $posts; }
/** * Displays the default archives view * * @since 4.0 * @access public * @param string * @return */ public function display($tpl = null) { // Get the archives model $model = EB::model('Archive'); // Get a list of posts $posts = $model->getPosts(); // Format the posts $posts = EB::formatter('list', $posts); // Get the pagination $pagination = $model->getPagination(); $this->set('posts', $posts); $this->set('pagination', $pagination); parent::display('blogs/archives/list'); }
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); } }
/** * Main display for the blog entry view * * @since 4.0 * @access public * @param string * @return */ public function display($tpl = null) { // Get the blog post id from the request $id = $this->input->get('id', 0, 'int'); // Load the blog post now $post = EB::post($id); // If blog id is not provided correctly, throw a 404 error page if (!$id || !$post->id) { return JError::raiseError(404, JText::_('COM_EASYBLOG_ENTRY_BLOG_NOT_FOUND')); } // If the settings requires the user to be logged in, do not allow guests here. if ($this->my->guest && $this->config->get('main_login_read')) { return EB::requireLogin(); } // Check if blog is password protected. $protected = $this->isProtected($post); if ($protected !== false) { return; } // If the blog post is already deleted, we shouldn't let it to be accessible at all. if ($post->isTrashed()) { return JError::raiseError(404, JText::_('COM_EASYBLOG_ENTRY_BLOG_NOT_FOUND')); } // Check if the blog post is trashed if (!$post->isPublished() && $this->my->id != $post->created_by && !EB::isSiteAdmin()) { return JError::raiseError(404, JText::_('COM_EASYBLOG_ENTRY_BLOG_NOT_FOUND')); } // Check for team's privacy $allowed = $this->checkTeamPrivacy($post); if ($allowed === false) { return JError::raiseError(404, JText::_('COM_EASYBLOG_TEAMBLOG_MEMBERS_ONLY')); } // Check if the blog post is accessible. $accessible = $post->isAccessible(); if (!$accessible->allowed) { echo $accessible->error; return; } // Increment the hit counter for the blog post. $post->hit(); // Format the post $post = EB::formatter('entry', $post); $theme = EB::template(); $theme->set('post', $post); $output = $theme->output('site/blogs/entry/default.print'); echo $output; }
/** * 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($tpl = null) { // Ensure that rss is enabled if (!$this->config->get('main_rss')) { return; } // 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); // Get the blogs model $model = EB::model('Blog'); $posts = $model->getBlogsBy('blogger', $author->id, $sort); $this->doc->link = EB::_('index.php?option=com_easyblog&view=myblog'); $this->doc->setTitle(JText::_('COM_EASYBLOG_FEEDS_MYBLOG_TITLE')); $this->doc->setDescription(JText::sprintf('COM_EASYBLOG_FEEDS_MYBLOG_DESC', $author->user->name)); // If there's no data, skip this altogether if (!$posts) { return; } $uri = JURI::getInstance(); $scheme = $uri->toString(array('scheme')); $scheme = str_replace('://', ':', $scheme); $posts = EB::formatter('list', $posts); 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); } return; }
public function display($tmpl = null) { // Check if rss is enabled if (!$this->config->get('main_rss')) { return JError::raiseError(404, JText::_('COM_EASYBLOG_FEEDS_DISABLED')); } // Check if the author's id is provided $id = $this->input->get('id', '', 'cmd'); if (!$id) { return JError::raiseError(404, JText::_('COM_EASYBLOG_FEEDS_INVALID_AUTHOR_ID')); } $author = EB::user($id); $model = EB::model('Blog'); $posts = $model->getBlogsBy('blogger', $author->id); $posts = EB::formatter('list', $posts); $this->doc->link = $author->getPermalink(); $this->doc->setTitle(JText::sprintf('COM_EASYBLOG_FEEDS_BLOGGER_TITLE', $author->getName())); $this->doc->setDescription(strip_tags($author->description)); 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($profile); $this->doc->addItem($item); } }
/** * Displays the default archives view * * @since 4.0 * @access public * @param string * @return */ public function display($tpl = null) { // Get the archives model $model = EB::model('Archive'); // Get a list of posts $posts = $model->getPosts(); // Format the posts $posts = EB::formatter('list', $posts); // Get the pagination $pagination = $model->getPagination(); // meta EB::setMeta(META_ID_ARCHIVE, META_TYPE_VIEW); // Update the title of the page if navigating on different pages to avoid Google marking these title's as duplicates. $title = EB::getPageTitle(JText::_('COM_EASYBLOG_ARCHIVE_PAGE_TITLE')); parent::setPageTitle($title, $pagination, $this->config->get('main_pagetitle_autoappend')); $this->set('posts', $posts); $this->set('pagination', $pagination); parent::display('blogs/archives/list'); }
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 blog posts from a specific category * * @since 4.0 * @access public * @param string * @return */ public function listings() { // Get the main category $id = $this->input->get('id', 0, 'int'); $category = EB::table('Category'); $category->load($id); // Check for the category privacy if (!$category->checkPrivacy()) { // @TODO: Display proper error message return; } $catIds = array(); $catIds[] = $category->id; EB::accessNestedCategoriesId($category, $catIds); $model = EB::model('Category'); $posts = $model->getPosts($catIds); $posts = EB::formatter('list', $posts); $this->set('category', $category); $this->set('posts', $posts); return parent::display(); }
public function display($tmpl = null) { // Get the blog post $id = $this->input->get('id', 0, 'int'); // Load the blog post now $blog = EB::table('Blog'); $blog->load($id); // If blog id is not provided correctly, throw a 404 error page if (!$id || !$blog->id) { return JError::raiseError(404, JText::_('COM_EASYBLOG_ENTRY_BLOG_NOT_FOUND')); } // If the settings requires the user to be logged in, do not allow guests here. if ($this->my->id <= 0 && $this->config->get('main_login_read')) { $url = EB::_('index.php?option=com_easyblog&view=entry&id=' . $id . '&layout=login', false); return $this->app->redirect($url); } // Check if blog is password protected. if ($this->config->get('main_password_protect') && !empty($blog->blogpassword) && !$blog->verifyPassword()) { return JError::raiseError(404, JText::_('COM_EASYBLOG_ENTRY_BLOG_NOT_FOUND')); } // If the blog post is already deleted, we shouldn't let it to be accessible at all. if ($blog->isTrashed()) { return JError::raiseError(404, JText::_('COM_EASYBLOG_ENTRY_BLOG_NOT_FOUND')); } // Check if the blog post is trashed if (!$blog->isPublished() && $my->id != $blog->created_by && !EB::isSiteAdmin()) { return JError::raiseError(404, JText::_('COM_EASYBLOG_ENTRY_BLOG_NOT_FOUND')); } // If the viewer is the owner of the blog post, display a proper message if ($this->my->id == $blog->created_by && !$blog->isPublished()) { $notice = JText::_('COM_EASYBLOG_ENTRY_BLOG_UNPUBLISHED_VISIBLE_TO_OWNER'); } if (EB::isSiteAdmin() && !$blog->isPublished()) { $notice = JText::_('COM_EASYBLOG_ENTRY_BLOG_UNPUBLISHED_VISIBLE_TO_ADMIN'); } $blog = EB::formatter('post', $blog); $this->set('post', $blog); return parent::display(); }
public static function getPosts($params) { // Get the default sorting and ordering $sort = $params->get('sorting', 'latest'); $order = $params->get('ordering', 'desc'); // Get the total number of posts to display $limit = (int) trim($params->get('count', 0)); // Determines if the user wants to filter items by specific ategories $catId = $params->get('catid'); $categories = array(); if ($catId) { $categories = explode(',', $catId); } $model = EB::model('Category'); $result = $model->getPosts($categories, $limit); $posts = array(); if (!$result) { return $posts; } $posts = EB::formatter('list', $result); return $posts; }
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); } }
public function display($tpl = null) { // Ensure that rss is enabled if (!$this->config->get('main_rss')) { return; } // Get sorting options $sort = $this->input->get('sort', $this->config->get('layout_postorder'), 'cmd'); // Get the blogs model $model = EB::model('Blog'); $posts = $model->getBlogsBy('', '', $sort, 0, EBLOG_FILTER_PUBLISHED, null, true); $this->doc->link = EB::_('index.php?option=com_easyblog&view=latest'); $this->doc->setTitle(JText::_('COM_EASYBLOG_FEEDS_LATEST_TITLE')); $this->doc->setDescription(JText::sprintf('COM_EASYBLOG_FEEDS_LATEST_DESC', JURI::root())); // If there's no data, skip this altogether if (!$posts) { return; } $posts = EB::formatter('list', $posts); foreach ($posts 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($post->author); $this->doc->addItem($item); } return; }
public function execute() { if (!$this->items) { return $this->items; } $limit = EB::call('Pagination', 'getLimit', array(EBLOG_PAGINATION_CATEGORIES)); // lets cache these categories EB::cache()->insertCategories($this->items); $categories = array(); // Get the category model $model = EB::model('Category'); foreach ($this->items as $row) { // We want to load the table objects $category = EB::table('Category'); $category->bind($row); // binding the extra info if (isset($row->cnt)) { $category->cnt = $row->cnt; } // Format the childs $category->childs = array(); // Build childs list EB::buildNestedCategories($category->id, $category, false, true); // Parameterize initial subcategories to display. Ability to configure from backend. $nestedLinks = ''; $subcategoryLimit = $this->app->getCfg('list_limit') == 0 ? 5 : $this->app->getCfg('list_limit'); if (count($category->childs) > $subcategoryLimit) { $initialNestedLinks = ''; $initialRow = new stdClass(); $initialRow->childs = array_slice($category->childs, 0, $subcategoryLimit); EB::accessNestedCategories($initialRow, $initialNestedLinks, '0', '', 'link', ', '); $moreNestedLinks = ''; $moreRow = new stdClass(); $moreRow->childs = array_slice($category->childs, $initialLimit); EB::accessNestedCategories($moreRow, $moreNestedLinks, '0', '', 'link', ', '); // Hide more nested links until triggered $nestedLinks .= $initialNestedLinks; $nestedLinks .= '<span class="more-subcategories-toggle"> ' . JText::_('COM_EASYBLOG_AND') . ' <a href="javascript:void(0);" onclick="eblog.categories.loadMore( this );">' . JText::sprintf('COM_EASYBLOG_OTHER_SUBCATEGORIES', count($row->childs) - $initialLimit) . '</a></span>'; $nestedLinks .= '<span class="more-subcategories" style="display: none;">, ' . $moreNestedLinks . '</span>'; } else { EB::accessNestedCategories($category, $nestedLinks, '0', '', 'link', ', '); } // Set the nested links $category->nestedLink = $nestedLinks; // Get a list of nested categories and itself. $filterCategories = array($category->id); EB::accessNestedCategoriesId($category, $filterCategories); // Get a list of blog posts from this category $blogs = array(); if (EB::cache()->exists($category->id, 'cats')) { $data = EB::cache()->get($category->id, 'cats'); if (isset($data['post'])) { $blogs = $data['post']; } } else { $blogs = $model->getPosts($filterCategories, $limit); } // Format the blog posts $blogs = EB::formatter('list', $blogs); // Assign other attributes to the category object $category->blogs = $blogs; // Get the total number of posts in the category if (!isset($category->cnt)) { $category->cnt = $model->getTotalPostCount($filterCategories); } // Get a list of active authors within this category. $category->authors = $category->getActiveBloggers(); // Check isCategorySubscribed $category->isCategorySubscribed = $model->isCategorySubscribedEmail($category->id, $this->my->email); $categories[] = $category; } return $categories; }
/** * Displays a list of blog posts on the site filtered by a category. * * @since 4.0 * @access public * @param string * @return */ public function listings() { // Retrieve sorting options $sort = $this->input->get('sort', $this->config->get('layout_postorder'), 'cmd'); $id = $this->input->get('id', 0, 'int'); // Try to load the category $category = EB::table('Category'); $category->load($id); // If the category isn't found on the site throw an error. if (!$id || !$category->id) { return JError::raiseError(404, JText::_('COM_EASYBLOG_CATEGORY_NOT_FOUND')); } // Set the meta description for the category EB::setMeta($category->id, META_TYPE_CATEGORY); // Set a canonical link for the category page. $this->canonical($category->getExternalPermalink()); // Get the privacy $privacy = $category->checkPrivacy(); if ($privacy->allowed || EB::isSiteAdmin() || !$this->my->guest && $this->config->get('main_allowguestsubscribe')) { $this->doc->addHeadLink($category->getRSS(), 'alternate', 'rel', array('type' => 'application/rss+xml', 'title' => 'RSS 2.0')); $this->doc->addHeadLink($category->getAtom(), 'alternate', 'rel', array('type' => 'application/atom+xml', 'title' => 'Atom 1.0')); } // Set views breadcrumbs $this->setViewBreadcrumb($this->getName()); // Set the breadcrumb for this category if (!EBR::isCurrentActiveMenu('categories', $category->id)) { // Always add the final pathway to the category title. $this->setPathway($category->title, ''); } //get the nested categories $category->childs = null; // Build nested childsets EB::buildNestedCategories($category->id, $category, false, true); // Parameterize initial subcategories to display. Ability to configure from backend. $nestedLinks = ''; $initialLimit = $this->app->getCfg('list_limit') == 0 ? 5 : $this->app->getCfg('list_limit'); if (count($category->childs) > $initialLimit) { $initialNestedLinks = ''; $initialRow = new stdClass(); $initialRow->childs = array_slice($category->childs, 0, $initialLimit); EB::accessNestedCategories($initialRow, $initialNestedLinks, '0', '', 'link', ', '); $moreNestedLinks = ''; $moreRow = new stdClass(); $moreRow->childs = array_slice($category->childs, $initialLimit); EB::accessNestedCategories($moreRow, $moreNestedLinks, '0', '', 'link', ', '); // Hide more nested links until triggered $nestedLinks .= $initialNestedLinks; $nestedLinks .= '<span class="more-subcategories-toggle" data-more-categories-link> ' . JText::_('COM_EASYBLOG_AND') . ' <a href="javascript:void(0);">' . JText::sprintf('COM_EASYBLOG_OTHER_SUBCATEGORIES', count($category->childs) - $initialLimit) . '</a></span>'; $nestedLinks .= '<span class="more-subcategories" style="display: none;" data-more-categories>, ' . $moreNestedLinks . '</span>'; } else { EB::accessNestedCategories($category, $nestedLinks, '0', '', 'link', ', '); } $catIds = array(); $catIds[] = $category->id; EB::accessNestedCategoriesId($category, $catIds); $category->nestedLink = $nestedLinks; // Get the category model $model = EB::model('Category'); // Get total posts in this category $category->cnt = $model->getTotalPostCount($category->id); // Get teamblog posts count // $teamBlogCount = $model->getTeamBlogCount($category->id); $limit = EB::call('Pagination', 'getLimit', array(EBLOG_PAGINATION_CATEGORIES)); // Get the posts in the category $data = $model->getPosts($catIds, $limit); // Get the pagination $pagination = $model->getPagination(); // Get allowed categories $allowCat = $model->allowAclCategory($category->id); // Format the data that we need $posts = array(); // Ensure that the user is really allowed to view the blogs if (!empty($data)) { $posts = EB::formatter('list', $data); } // Check isCategorySubscribed $isCategorySubscribed = $model->isCategorySubscribedEmail($category->id, $this->my->email); // If this category has a different theme, we need to output it differently if (!empty($category->theme)) { $this->setTheme($category->theme); } // Set the page title $title = EB::getPageTitle(JText::_($category->title)); $this->setPageTitle($title, $pagination, $this->config->get('main_pagetitle_autoappend')); // Set the return url $return = base64_encode($category->getExternalPermalink()); // Get the pagination $pagination = $pagination->getPagesLinks(); $this->set('allowCat', $allowCat); $this->set('category', $category); $this->set('sort', $sort); $this->set('posts', $posts); $this->set('return', $return); $this->set('pagination', $pagination); // $this->set('teamBlogCount', $teamBlogCount); $this->set('privacy', $privacy); $this->set('isCategorySubscribed', $isCategorySubscribed); parent::display('blogs/categories/item'); }
/** * Retrieves a list of blog posts by specific month * * @since 5.0 * @access public * @param string * @return */ public function getArchivePostByMonth($month = '', $year = '', $showPrivate = false) { $db = EB::db(); $user = JFactory::getUser(); $config = EB::config(); // used for privacy $queryWhere = ''; $queryExclude = ''; $queryExcludePending = ''; $excludeCats = array(); if ($user->id == 0) { $showPrivate = false; } // Blog privacy setting // @integrations: jomsocial privacy $privateBlog = ''; if (EB::easysocial()->exists() && $config->get('integrations_easysocial_privacy') && !EB::isSiteAdmin()) { $esPrivacyQuery = EB::easysocial()->buildPrivacyQuery('a'); $privateBlog .= $esPrivacyQuery; } else { if ($config->get('main_jomsocial_privacy') && EB::jomsocial()->exists() && !EB::isSiteAdmin()) { $friendsModel = CFactory::getModel('Friends'); $friends = $friendsModel->getFriendIds($user->id); // Insert query here. $privateBlog .= ' AND ('; $privateBlog .= ' (a.`access`= 0 ) OR'; $privateBlog .= ' ( (a.`access` = 20) AND (' . $db->Quote($user->id) . ' > 0 ) ) OR'; if (!$friends) { $privateBlog .= ' ( (a.`access` = 30) AND ( 1 = 2 ) ) OR'; } else { $privateBlog .= ' ( (a.`access` = 30) AND ( a.' . $db->nameQuote('created_by') . ' IN (' . implode(',', $friends) . ') ) ) OR'; } $privateBlog .= ' ( (a.`access` = 40) AND ( a.' . $db->nameQuote('created_by') . '=' . $user->id . ') )'; $privateBlog .= ' )'; } else { if ($user->id == 0) { $privateBlog .= ' AND a.`access` = ' . $db->Quote(0); } } } // Join the query ? $privateBlog = $showPrivate ? '' : $privateBlog; $isJSGrpPluginInstalled = false; $isJSGrpPluginInstalled = JPluginHelper::isEnabled('system', 'groupeasyblog'); $isEventPluginInstalled = JPluginHelper::isEnabled('system', 'eventeasyblog'); $isJSInstalled = false; // need to check if the site installed jomsocial. if (EB::jomsocial()->exists()) { $isJSInstalled = true; } $includeJSGrp = $isJSGrpPluginInstalled && $isJSInstalled ? true : false; $includeJSEvent = $isEventPluginInstalled && $isJSInstalled ? true : false; // contribution type sql $contributor = EB::contributor(); $contributeSQL = ' AND ( (a.`source_type` = ' . $db->Quote(EASYBLOG_POST_SOURCE_SITEWIDE) . ') '; if ($config->get('main_includeteamblogpost')) { $contributeSQL .= $contributor::genAccessSQL(EASYBLOG_POST_SOURCE_TEAM, 'a'); } if ($includeJSEvent) { $contributeSQL .= $contributor::genAccessSQL(EASYBLOG_POST_SOURCE_JOMSOCIAL_EVENT, 'a'); } if ($includeJSGrp) { $contributeSQL .= $contributor::genAccessSQL(EASYBLOG_POST_SOURCE_JOMSOCIAL_GROUP, 'a'); } if (EB::easysocial()->exists()) { $contributeSQL .= $contributor::genAccessSQL(EASYBLOG_POST_SOURCE_EASYSOCIAL_GROUP, 'a'); $contributeSQL .= $contributor::genAccessSQL(EASYBLOG_POST_SOURCE_EASYSOCIAL_EVENT, 'a'); } $contributeSQL .= ')'; $queryWhere .= $contributeSQL; //get teamblogs id. $query = ''; $extraSQL = ''; // If this is on blogger mode, we need to only pick items from the blogger. $blogger = EBR::isBloggerMode(); if ($blogger !== false) { $extraSQL = ' AND a.`created_by` = ' . $db->Quote($blogger); } $tzoffset = EB::date()->getOffSet(true); $query = 'SELECT a.*, DAY( DATE_ADD(a.`created`, INTERVAL ' . $tzoffset . ' HOUR) ) AS day,'; $query .= ' MONTH( DATE_ADD(a.`created`, INTERVAL ' . $tzoffset . ' HOUR) ) AS month,'; $query .= ' YEAR( DATE_ADD(a.`created`, INTERVAL ' . $tzoffset . ' HOUR) ) AS year '; $query .= ' FROM ' . $db->nameQuote('#__easyblog_post') . ' as a'; $query .= ' WHERE a.`published` = ' . $db->Quote(EASYBLOG_POST_PUBLISHED) . ' '; $query .= ' AND a.' . $db->quoteName('state') . ' = ' . $db->Quote(EASYBLOG_POST_NORMAL) . ' '; $query .= $privateBlog . ' '; $query .= ' AND (a.`created` > ' . $db->Quote($year . '-' . $month . '-01 00:00:00') . ' AND a.`created` < ' . $db->Quote($year . '-' . $month . '-31 23:59:59') . ') '; // If do not display private posts, we need to append additional queries here. if (!$showPrivate) { // sql for category access $catLib = EB::category(); $catAccessSQL = $catLib->genAccessSQL('a.`id`'); $query .= ' AND (' . $catAccessSQL . ')'; } $query .= $extraSQL . ' '; $query .= $queryWhere; $query .= ' ORDER BY a.`created` ASC '; // echo $query;exit; $db->setQuery($query); $result = $db->loadObjectList(); $postCount = new EasyblogCalendarObject($month, $year); if (!empty($result)) { foreach ($result as $row) { $post = EB::post($row->id); // $post->bind($row); $post = EB::formatter('entry', $post); // var_dump($row);exit; if ($postCount->{$year}->{$month}->{$row->day} == 0) { $postCount->{$year}->{$month}->{$row->day} = array($post); } else { array_push($postCount->{$year}->{$month}->{$row->day}, $post); } } } return $postCount; }
/** * Formats the result of the module * * @since 5.0 */ public static function processItems($data, &$params) { $config = EB::config(); $app = JFactory::getApplication(); $appParams = $app->getParams('com_easyblog'); $limitstart = $app->input->get('limitstart', 0, 'int'); $result = array(); $posts = EB::formatter('list', $data, false); foreach ($posts as $post) { // Default media items $post->media = ''; // If the post doesn't have a blog image try to locate for an image if ($post->posttype == 'standard' && !$post->hasImage()) { $photoWSize = $params->get('photo_width', 250); $photoHSize = $params->get('photo_height', 250); $size = array('width' => $photoWSize, 'height' => $photoHSize); $post->media = EB::modules()->getMedia($post, $params, $size); } // Get the comment count $post->commentCount = $post->getTotalComments(); // Determines if this post is password protected or not. $requireVerification = false; if ($config->get('main_password_protect', true) && !empty($r->blogpassword)) { $row->title = JText::sprintf('COM_EASYBLOG_PASSWORD_PROTECTED_BLOG_TITLE', $row->title); $requireVerification = true; } $post->showRating = true; $post->protect = false; $post->summary = ''; // Only if verification is necessary, we do not want to show the content if ($requireVerification && !EB::verifyBlogPassword($post->blogpassword, $post->id)) { $return = base64_encode($post->getPermalink()); $theme = EB::template(); $theme->set('post', $post); $theme->set('id', $post->id); $theme->set('return', $return); $post->summary = $theme->output('site/blogs/latest/default.protected'); $post->showRating = false; $post->protect = true; } // Determines the content source $contentSource = $params->get('showintro', -1); // Display only the intro if ($contentSource == self::SOURCE_INTRO) { $post->summary = $post->getIntro(self::POST_STRIP_TAGS, self::POST_TRUNCATE, self::POST_SOURCE_INTRO_COLUMN); } // Display the main content without intro if ($contentSource == self::SOURCE_CONTENT) { $post->summary = $post->getContentWithoutIntro('entry', self::POST_TRIGGER_PLUGIN); } // Remove any html codes from the content $post->summary = strip_tags($post->summary); // Truncation settings $maxLength = $params->get('textcount', 0); $length = JString::strlen($post->summary); if ($maxLength && $length > $maxLength && !$post->protect) { $post->summary = JString::substr($post->summary, 0, $maxLength) . JText::_('COM_EASYBLOG_ELLIPSES'); } $result[] = $post; } return $result; }
/** * Main display for the blog entry view * * @since 4.0 * @access public * @param string * @return */ public function preview($tpl = null) { // Get the blog post id from the request $id = $this->input->get('uid', '', 'default'); // Load the blog post now $post = EB::post($id); // After the post is loaded, set it into the cache EB::cache()->insert(array($post)); // If blog id is not provided correctly, throw a 404 error page if (!$id || !$post->id) { return JError::raiseError(404, JText::_('COM_EASYBLOG_ENTRY_BLOG_NOT_FOUND')); } // If the settings requires the user to be logged in, do not allow guests here. $post->requiresLoginToRead(); // Render necessary data on the headers $post->renderHeaders(); // Check if blog is password protected. $protected = $this->isProtected($post); if ($protected !== false) { return; } // Perform validation checks to see if post is valid $exception = $post->checkView(); if ($exception instanceof EasyBlogException) { return JError::raiseError(400, $exception->getMessage()); } // If the viewer is the owner of the blog post, display a proper message if ($this->my->id == $post->created_by && !$post->isPublished()) { $notice = JText::_('COM_EASYBLOG_ENTRY_BLOG_UNPUBLISHED_VISIBLE_TO_OWNER'); } if (EB::isSiteAdmin() && !$post->isPublished()) { $notice = JText::_('COM_EASYBLOG_ENTRY_BLOG_UNPUBLISHED_VISIBLE_TO_ADMIN'); } // Format the post $post = EB::formatter('entry', $post); // Add bloggers breadcrumbs if (!EBR::isCurrentActiveMenu('blogger', $post->author->id) && $this->config->get('layout_blogger_breadcrumb')) { $this->setPathway($post->author->getName(), $post->author->getPermalink()); } // Add entry breadcrumb if (!EBR::isCurrentActiveMenu('entry', $post->id)) { $this->setPathway($post->title, ''); } // Load up the blog model $model = EB::model('Blog'); // Get author's recent posts. $recent = $this->getRecentPosts($post); // Add canonical URLs for the blog post if ($this->config->get('main_canonical_entry')) { $this->canonical('index.php?option=com_easyblog&view=entry&id=' . $post->id); } // Prepare navigation object $navigation = $this->prepareNavigation($post); // Retrieve Google Adsense codes $adsense = EB::adsense()->html($post); // If a custom theme is setup for entries in the category, set a different theme if (!empty($post->category->theme)) { $this->setTheme($post->category->theme); } // Check if the user subscribed to this post. $isBlogSubscribed = $model->isBlogSubscribedEmail($post->id, $this->my->email); $theme = EB::template(); // Prepare related post $relatedPosts = array(); // @TODO: Related posts seems to be missing from the theme file. if ($theme->params->get('post_related', true)) { $relatedPosts = $model->getRelatedPosts($post->id, $theme->params->get('post_related_limit', 5)); } if (!$post->posttype) { $post->posttype = 'standard'; } $this->set('post', $post); $this->set('navigation', $navigation); $this->set('relatedPosts', $relatedPosts); $this->set('recent', $recent); $this->set('preview', true); $this->set('adsense', $adsense); $this->set('isBlogSubscribed', $isBlogSubscribed); // Get the menu params associated with this post $params = $post->getMenuParams(); $this->theme->entryParams = $params; parent::display('blogs/entry/default'); }
// Include the engine file. require_once $file; // Check if Foundry exists if (!FD::exists()) { FD::language()->loadSite(); echo JText::_('COM_EASYSOCIAL_FOUNDRY_DEPENDENCY_MISSING'); return; } // Include EasyBlog's library require_once JPATH_ROOT . '/administrator/components/com_easyblog/includes/easyblog.php'; $my = ES::user(); // Load up the module engine $modules = ES::modules('mod_easysocial_easyblog_posts'); $model = EB::model('Blog'); // Get the module options $total = (int) $params->get('total', 5); $sorting = $params->get('sorting', 'latest'); // Let's load the list of posts now $posts = $model->getBlogsBy('latest', '', $sorting, $total); // We need to format the blog post accordingly. $posts = EB::formatter('list', $posts, false); // Get the author of the blog posts foreach ($posts as $post) { $post->user = ES::user($post->created_by); } // We need these packages $modules->addDependency('css', 'javascript'); // Get the layout to use. $layout = $params->get('layout', 'default'); $suffix = $params->get('suffix', ''); require JModuleHelper::getLayoutPath('mod_easysocial_easyblog_posts', $layout);
/** * Default search view for EasyBlog * * @since 4.0 * @access public * @param string * @return */ public function display($tmpl = null) { // Set the meta tags for search EB::setMeta(META_ID_SEARCH, META_TYPE_SEARCH); // Set the page title $title = EasyBlogHelper::getPageTitle(JText::_('COM_EASYBLOG_SEARCH_PAGE_TITLE')); $this->setPageTitle($title); // Set the view's breadcrumbs $this->setViewBreadcrumb('search'); // Get any existing query $query = $this->input->get('query', '', 'default'); $Itemid = $this->input->get('Itemid', '', 'int'); $posts = array(); $pagination = ''; if (!empty($query)) { // Get the model $model = EB::model('Search'); $result = $model->getData(); $total = count($result); if ($total > 0) { $searchworda = preg_replace('#\\xE3\\x80\\x80#s', ' ', $query); $searchwords = preg_split("/\\s+/u", $searchworda); $needle = $searchwords[0]; $searchwords = array_unique($searchwords); // var_dump($result[0]); // Format the post $posts = EB::formatter('list', $result); // var_dump($posts[0]); // exit; // Remove all unecessary codes from the output foreach ($posts as &$row) { // var_dump($row->content); // Strip videos $row->intro = EB::videos()->strip($row->intro); $row->content = EB::videos()->strip($row->content); // strip gallery $row->intro = EB::gallery()->strip($row->intro); $row->content = EB::gallery()->strip($row->content); // strip jomsocial album $row->intro = EB::album()->strip($row->intro); $row->content = EB::album()->strip($row->content); // strip audio $row->intro = EB::audio()->strip($row->intro); $row->content = EB::audio()->strip($row->content); // Format the content so that we can apply our search highlighting $content = preg_replace('/\\s+/', ' ', strip_tags($row->content)); if (empty($content)) { $content = preg_replace('/\\s+/', ' ', strip_tags($row->intro)); } // We only want a snippet of the content $content = JString::substr(strip_tags($content), 0, 350); $pattern = '#('; $x = 0; foreach ($searchwords as $key => $value) { $pattern .= $x == 0 ? '' : '|'; $pattern .= preg_quote($value, '#'); $x++; } $pattern .= ')#iu'; $row->title = preg_replace($pattern, '<span class="search-highlight">\\0</span>', $row->title); $row->content = preg_replace($pattern, '<span class="search-highlight">\\0</span>', $content); } } $pagination = $model->getPagination(); } $this->set('query', $query); $this->set('posts', $posts); $this->set('pagination', $pagination); $this->set('Itemid', $Itemid); parent::display('search/default'); }