public function execute() { if ($this->cache) { // Cache data and preload posts EB::cache()->insert($this->items); } // For list items we wouldn't want to process comments $comment = true; // For list items we do not want to load videos $video = false; // For list items we do not want to process gallery $gallery = false; // Result $result = array(); // Load up the tags model $tagsModel = EB::model('PostTag'); foreach ($this->items as $item) { $post = EB::post($item->id); $blog = new stdClass(); // Post details $blog->id = $post->id; $blog->title = $post->title; $blog->intro = $post->getIntro(); $blog->content = $post->getContent(); $blog->content_plain = $this->sanitize($blog->content); $blog->image = $post->getImage('thumbnail'); $blog->created = $post->created; $blog->hits = $post->hits; $blog->permalink = $post->getPermalink(true, true, 'json'); // Get the author details $author = $post->getAuthor(); $blog->author = new stdClass(); $blog->author->name = $author->getName(); $blog->author->avatar = $author->getAvatar(); // Get the tags for this post $tags = $post->getTags(); $blog->tags = array(); if ($tags) { foreach ($tags as $tag) { $item = new stdClass(); $item->title = $tag->getTitle(); $item->permalink = $tag->getExternalPermalink('json'); $blog->tags[] = $item; } } // Get the category details $category = $post->getPrimaryCategory(); $blog->category = new stdClass(); $blog->category->id = $category->id; $blog->category->title = $category->getTitle(); $blog->category->avatar = $category->getAvatar(); $blog->category->permalink = $category->getExternalPermalink('json'); $result[] = $blog; } return $result; }
/** * Default method to format normal posts * * @since 5.0 * @access public * @param string * @return */ public function execute() { // Result $result = array(); // Cache data and preload posts if ($this->cache) { EB::cache()->insert($this->items); } // Preload all featured posts for posts $featuredItems = array(); // Do a simple test to see if preload featured items is require or not if (!isset($this->items[0]->featured)) { $featuredItems = $this->preloadFeaturedItems(); } $i = 0; foreach ($this->items as $item) { // Load up the post library $post = EB::post(); $post->load($item->id); // Get the list of categories for this particular blog post $post->category = $post->getPrimaryCategory(); $post->categories = $post->getCategories(); // @Assign dynamic properties that must exist everytime formatBlog is called // We can't rely on ->author because CB plugins would mess things up. $post->author = $post->getAuthor(); // Determines if the blog post is featured if (isset($item->featured)) { $post->isFeatured = $item->featured; } else { if (isset($featuredItems[$post->id])) { $post->isFeatured = $featuredItems[$post->id]; } else { $post->isFeatured = 0; } } // Password verifications $this->password($post); // Get custom fields $post->fields = $post->getCustomFields(); // Format microblog postings if ($post->posttype) { $this->formatMicroblog($post); } else { $post->posttype = 'standard'; } // Assign tags to the custom properties. $post->tags = $post->getTags(); // Prepare nice date for the list $post->date = EB::date($post->created)->format(JText::_('DATE_FORMAT_LC')); $result[] = $post; $i++; } return $result; }
public function execute() { if ($this->cache) { //preload posts information EB::cache()->insert($this->items); } // For featured items we wouldn't want to process comments $comment = true; // For featured items we want to remove featured image $removeFeaturedImage = true; // For featured items we do not want to load videos $video = false; // For featured items we do not want to process gallery $gallery = false; // Ensure that the content does not exceed the introtext limit for featured items $contentLimit = $this->config->get('layout_featured_intro_limit'); $result = array(); foreach ($this->items as &$item) { $blog = EB::post($item->id); // Load the author's profile $author = EB::user($blog->created_by); // @Assign dynamic properties that must exist everytime formatBlog is called // We can't rely on ->author because CB plugins would mess things up. $blog->author = $author; $blog->blogger = $author; // Password verifications $this->password($blog); // Format microblog postings if ($blog->posttype) { $this->formatMicroblog($blog); } // Detect if content requires read more link $blog->readmore = $this->hasReadmore($blog); // // Truncate content // $this->truncate($blog); // EB::truncateContent($blog, $loadVideo, $frontpage, $loadGallery); // Format the content for the featured items if (empty($blog->intro)) { $blog->intro = $blog->content; } // We wouldn't want to display html codes in the content $blog->intro = strip_tags($blog->intro); // Get the content length $length = JString::strlen($blog->intro); if ($length > $contentLimit) { $blog->intro = JString::substr($blog->intro, 0, $contentLimit); } // Prepare nice date for the featured area $blog->date = EB::date($blog->created)->format(JText::_('DATE_FORMAT_LC')); $result[] = $blog; } return $result; }
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; }
public function execute() { if ($this->cache) { //preload posts information EB::cache()->insert($this->items); } // For featured items we wouldn't want to process comments $comment = true; // For featured items we want to remove featured image $removeFeaturedImage = true; // For featured items we do not want to load videos $video = false; // For featured items we do not want to process gallery $gallery = false; // Ensure that the content does not exceed the introtext limit for featured items $contentLimit = $this->config->get('layout_featured_intro_limit'); $result = array(); foreach ($this->items as &$item) { $blog = EB::post($item->id); // Load the author's profile $author = EB::user($blog->created_by); // @Assign dynamic properties that must exist everytime formatBlog is called // We can't rely on ->author because CB plugins would mess things up. $blog->author = $author; $blog->blogger = $author; // Password verifications $this->password($blog); // Format microblog postings if ($blog->posttype) { $this->formatMicroblog($blog); } // Get featured image if ($blog->hasImage()) { $blog->image = $blog->getImage($this->config->get('cover_featured_size', 'large')); } else { $tmp = $blog->getContentImage(); if ($tmp) { $blog->image = $tmp; } else { $blog->image = ''; } } // Detect if content requires read more link $blog->readmore = $this->hasReadmore($blog); // Prepare nice date for the featured area $blog->date = EB::date($blog->created)->format(JText::_('DATE_FORMAT_LC')); $result[] = $blog; } return $result; }
public function getCategoryUsed($bloggerId) { $db = EB::db(); //lets check if this blogger data cached or not. if (EB::cache()->exists($bloggerId, 'bloggers')) { $data = EB::cache()->get($bloggerId, 'bloggers'); if (isset($data['category'])) { return $data['category']; } else { return array(); } } $query = 'select distinct a.*, count(b.`id`) as `post_count` from `#__easyblog_category` as a'; $query .= ' inner join `#__easyblog_post_category` as b ON a.`id` = b.`category_id`'; $query .= ' inner join `#__easyblog_post` as c ON b.`post_id` = c.`id`'; $query .= ' where c.`created_by` = ' . $db->Quote($bloggerId); $query .= ' and c.`published` = ' . $db->Quote(EASYBLOG_POST_PUBLISHED); $query .= ' and c.`state` = ' . $db->Quote(EASYBLOG_POST_NORMAL); $query .= ' group by a.id'; $query .= ' order by null'; $db->setQuery($query); $result = $db->loadObjectList(); return $result; }
function EasyBlogBuildRoute(&$query) { $segments = array(); $config = EB::config(); // index.php?option=com_easyblog&view=entry if (isset($query['view']) && $query['view'] == 'entry' && isset($query['id'])) { if ($config->get('main_sef') != 'simple') { $segments[] = EBR::translate($query['view']); } // Get the post from the cache $postId = (int) $query['id']; $post = EB::post(); $post->load($postId); // Since the cache library is already using the post library to re-render the post table data, just use the permalink. $segments[] = $post->getAlias(); unset($query['id']); unset($query['view']); } // Single category view // index.php?option=com_easyblog&view=categories&layout=listings&id=xxxx if (isset($query['view']) && $query['view'] == 'categories') { // Try to get rid of duplicated view vs menu alias $itemId = isset($query['Itemid']) ? $query['Itemid'] : ''; if ($itemId) { $menu = JFactory::getApplication()->getMenu()->getItem($itemId); // Translate the view first if ($menu->query['view'] != EBR::translate($query['view'])) { $segments[] = EBR::translate($query['view']); } } // Translate the category permalink now if (isset($query['id'])) { $category = EB::cache()->get((int) $query['id'], 'category'); if ($category) { $segments[] = $category->getAlias(); } } unset($query['id']); unset($query['view']); unset($query['layout']); } // Single tag view // index.php?option=com_easyblog&view=tags&layout=listings&id=xxxx if (isset($query['view']) && $query['view'] == 'tags') { $segments[] = EBR::translate($query['view']); if (isset($query['id']) && isset($query['layout'])) { $segments[] = $query['id']; } unset($query['id']); unset($query['view']); unset($query['layout']); } // index.php?option=com_easyblog&view=teamblog&layout=listings&id=xxx if (isset($query['view']) && $query['view'] == 'teamblog') { $segments[] = EBR::translate($query['view']); if (isset($query['layout'])) { $segments[] = EBR::translate($query['layout']); } if (isset($query['id'])) { $team = EB::cache()->get((int) $query['id'], 'team'); $segments[] = $team->getAlias(); } unset($query['id']); unset($query['stat']); unset($query['layout']); unset($query['view']); } // view=blogger&layout=listings&id=xxx if (isset($query['view']) && $query['view'] == 'blogger') { // Add view=blogger $segments[] = EBR::translate($query['view']); // Add bloggers permalink if (isset($query['id'])) { $author = EB::cache()->get((int) $query['id'], 'author'); $segments[] = $author->getAlias(); } if (isset($query['sort'])) { $segments[] = EBR::translate('sort'); $segments[] = EBR::translate($query['sort']); unset($query['sort']); } if (isset($query['search'])) { $segments[] = $query['search']; } unset($query['view']); unset($query['id']); unset($query['layout']); } // index.php?option=com_easyblog&view=dashboard&layout=xxx if (isset($query['view']) && $query['view'] == 'dashboard') { $segments[] = EBR::translate($query['view']); if (isset($query['layout'])) { $segments[] = EBR::translate($query['layout']); } if (isset($query['filter'])) { $segments[] = $query['filter']; unset($query['filter']); } if (isset($query['blogid'])) { $segments[] = $query['blogid']; unset($query['blogid']); } if (isset($query['postType'])) { $segments[] = $query['postType']; unset($query['postType']); } unset($query['view']); unset($query['layout']); } // index.php?option=com_easyblog&view=archive if (isset($query['view']) && $query['view'] == 'archive') { $segments[] = EBR::translate($query['view']); unset($query['view']); if (isset($query['layout'])) { $segments[] = $query['layout']; unset($query['layout']); } if (isset($query['archiveyear'])) { $segments[] = $query['archiveyear']; unset($query['archiveyear']); } if (isset($query['archivemonth'])) { $segments[] = $query['archivemonth']; unset($query['archivemonth']); } if (isset($query['archiveday'])) { $segments[] = $query['archiveday']; unset($query['archiveday']); } } // index.php?option=com_easyblog&view=calendar if (isset($query['view']) && $query['view'] == 'calendar') { $segments[] = EBR::translate($query['view']); unset($query['view']); if (isset($query['year'])) { $segments[] = $query['year']; unset($query['year']); } if (isset($query['month'])) { $segments[] = $query['month']; unset($query['month']); } if (isset($query['day'])) { $segments[] = $query['day']; unset($query['day']); } } // index.php?option=com_easyblog&view=search if (isset($query['view']) && $query['view'] == 'search') { $segments[] = EBR::translate($query['view']); unset($query['view']); if (isset($query['layout'])) { $segments[] = $query['layout']; unset($query['layout']); } if (isset($query['query'])) { $segments[] = $query['query']; unset($query['query']); } } // // index.php?option=com_easyblog&view=composer // if (isset($query['view']) && $query['view'] == 'composer') { // dump('here'); // } // index.php?option=com_easyblog&view=login if (isset($query['view']) && $query['view'] == 'login') { $segments[] = EBR::translate($query['view']); unset($query['view']); } if (isset($query['type'])) { if (!isset($query['format']) && !isset($query['controller'])) { $segments[] = $query['type']; unset($query['type']); } } if (!isset($query['Itemid'])) { $query['Itemid'] = EBR::getItemId(); } return $segments; }
/** * 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'); }
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; }
/** * Converts the non sef links to SEF links when necessary * * @since 5.0 * @access public * @param string * @return */ public static function _($url, $xhtml = true, $ssl = null, $search = false, $isCanonical = false) { static $cache = array(); static $itemIds = array(); // Cache index $key = $url . (int) $xhtml . (int) $isCanonical; // If the url has already loaded previously, do not need to load it again. if (isset($cache[$key])) { return $cache[$key]; } $config = EB::config(); $app = JFactory::getApplication(); $input = $app->input; // Parse the url parse_str($url, $query); // Get the view portion from the query string $view = isset($query['view']) ? $query['view'] : 'latest'; $layout = isset($query['layout']) ? $query['layout'] : null; $itemId = isset($query['Itemid']) ? $query['Itemid'] : ''; $task = isset($query['task']) ? $query['task'] : ''; $id = isset($query['id']) ? $query['id'] : null; // Get routing behavior $behavior = $config->get('main_routing', 'default'); $dropSegment = false; // Legacy settings for "use current active menu" if ($behavior == 'currentactive' && !$isCanonical) { // Get the current active menu $active = $app->getMenu()->getActive(); if ($active) { $itemId = $active->id; } } // Legacy settings for "use menu id" if ($behavior == 'menuitemid' && !$isCanonical) { // Get the menu id from the settings $itemId = $config->get('main_routing_itemid'); } // Default routing behavior if ($behavior == 'default') { // The default menu in the event we can't find anything for the url $defaultMenu = EBR::getMenus('latest'); // Entry view needs to be treated differently. if ($view == 'entry') { // Respect which settings the user configured $respectView = $config->get('main_routing_entry'); // Entry view has higher precedence over all $menu = EBR::getMenus('entry', 'entry', $id); if ($menu) { $dropSegment = true; } else { // Get the post data from the cache $postCache = EB::cache(); $post = $postCache->get($id, 'post'); // Get the category the post is created in if ($respectView == 'categories') { $menu = EBR::getMenus('categories', 'listings', $post->category_id); } if ($respectView == 'blogger') { $menu = EBR::getMenus('blogger', 'listings', $post->created_by); } if ($respectView == 'teamblog' && $post->source_type == EASYBLOG_POST_SOURCE_TEAM) { $menu = EBR::getMenus('teamblog', 'listings', $post->source_id); } } } // Get the default menu that the current view should use if ($view != 'entry') { $menu = EBR::getMenus($view); // If there's a layout an id accompanying the view, we should search for a menu to a single item layout. if ($layout && $id) { $itemMenu = EBR::getMenus($view, $layout, $id); // If there's a menu item created on the site associated with this item, we need to drop the segment // to avoid redundant duplicate urls. // E.g: // menu alias = test // post alias = test // result = /test/test if ($itemMenu) { $menu = $itemMenu; $dropSegment = true; } } else { if ($layout) { // this section here is to cater a view + layout page. // e.g dashboard/entries $itemMenu = EBR::getMenus($view, $layout); if ($itemMenu) { $menu = $itemMenu; $dropSegment = true; } } } // If there is a menu created for the view, we just drop the segment if (!$layout && !$id && $menu) { $dropSegment = true; } } // If we still cannot find any menu, use the default menu :( if (!isset($menu) || !$menu) { $menu = $defaultMenu; } // Only proceed when there is at least 1 menu created on the site for EasyBlog if (isset($menu) && $menu) { $itemId = $menu->id; } // If this is a task, we shouldn't drop any segments at all if ($task) { $dropSegment = false; } } // If there's an item id located for the url, we need to intelligently apply it into the url. if ($itemId) { // We need to respect dropSegment to avoid duplicated menu and view name. // For instance, if a menu is called "categories" which links to the categories page, it would be /categories/categories if ($dropSegment && EBR::isSefEnabled()) { $url = 'index.php?Itemid=' . $itemId; } else { $url = EBR::appendItemIdToQueryString($url, $itemId); } } $cache[$key] = JRoute::_($url, $xhtml, $ssl); return $cache[$key]; }
/** * Displays the all bloggers * * @since 4.0 * @access public * @param string * @return */ public function display($tmpl = null) { // Set meta tags for bloggers EB::setMeta(META_ID_BLOGGERS, META_TYPE_VIEW); // Set the breadcrumbs only when necessary if (!EBR::isCurrentActiveMenu('blogger')) { $this->setPathway(JText::_('COM_EASYBLOG_BLOGGERS_BREADCRUMB'), ''); } // Retrieve the current sorting options $sort = $this->input->get('sort', '', 'cmd'); $sortHTML = $this->getSorting($sort); // Retrieve the current filtering options. $filter = $this->input->get('filter', 'showallblogger', 'cmd'); if ($this->config->get('main_bloggerlistingoption')) { $filter = $this->input->get('filter', 'showbloggerwithpost', 'cmd'); } // Get the filter html codes $filterHTML = $this->getFilter($filter); // Retrieve search values $search = $this->input->get('search', '', 'string'); // Retrieve the models. $bloggerModel = EB::model('Blogger'); $blogModel = EB::model('Blog'); $postTagModel = EB::model('PostTag'); // Get limit $limit = $this->config->get('layout_pagination_bloggers_per_page'); if (!$sort) { // Retrieve default sort from setting $sort = $this->config->get('layout_bloggerorder', 'latest'); } // Retrieve the bloggers to show on the page. $results = $bloggerModel->getBloggers($sort, $limit, $filter, $search); $pagination = $bloggerModel->getPagination(); // Determine the current page if there's pagination $limitstart = $this->input->get('limitstart', 0, 'int'); // Set the title of the page $title = JText::_('COM_EASYBLOG_BLOGGERS_PAGE_TITLE'); $this->setPageTitle($title, $pagination, true); // Add canonical urls $this->canonical('index.php?option=com_easyblog&view=blogger'); // Determine the default ordering for the posts $postsOrdering = $this->config->get('layout_postorder'); $postsLimit = EB::call('Pagination', 'getLimit', array(EBLOG_PAGINATION_BLOGGERS)); // Format the blogger listing. $authors = array(); if (!empty($results)) { //preload users $ids = array(); foreach ($results as $row) { $ids[] = $row->id; } EB::user($ids); // lets cache the bloggers EB::cache()->insertBloggers($results); // lets group the posts for posts caching first $tobeCached = array(); $bloggerPosts = array(); foreach ($results as $row) { $bloggerId = $row->id; $items = $blogModel->getBlogsBy('blogger', $row->id, $postsOrdering, $postsLimit, EBLOG_FILTER_PUBLISHED); $bloggerPosts[$bloggerId] = $items; if ($items) { $tobeCached = array_merge($tobeCached, $items); } } // now we can cache the posts. if ($tobeCached) { EB::cache()->insert($tobeCached); } foreach ($results as $row) { // Load the author object $author = EB::user($row->id); // Retrieve blog posts from this user. $posts = $bloggerPosts[$row->id]; $author->blogs = EB::formatter('list', $posts, false); // Get tags that are used by this author $tmpTags = $bloggerModel->getTagUsed($row->id); $tags = array(); if ($tmpTags) { foreach ($tmpTags as $tagRow) { $tag = EB::table('Tag'); $tag->bind($tagRow); $tags[] = $tag; } } $author->tags = $tags; // Get categories that are used by this author $author->categories = $bloggerModel->getCategoryUsed($row->id); // Get the twitter link for this author. $author->twitter = EB::socialshare()->getLink('twitter', $row->id); // Get total posts created by the author. $author->blogCount = $row->totalPost; // Get total posts created by the author. $author->featured = $row->featured ? 1 : 0; $author->isBloggerSubscribed = $bloggerModel->isBloggerSubscribedEmail($author->id, $this->my->email); // Messaging integrations $author->messaging = EB::messaging()->html($author); $authors[] = $author; } } // Format the pagination $pagination = $pagination->getPagesLinks(); $this->set('authors', $authors); $this->set('search', $search); $this->set('sort', $sort); $this->set('pagination', $pagination); $this->set('sortHTML', $sortHTML); $this->set('filterHTML', $filterHTML); parent::display('authors/default'); }
public function getPosts($tmpl = null) { // Ensure that the user is logged in. EB::requireLogin(); $lang = $this->input->getVar('code', null); $langid = $this->input->getVar('codeid', null); $search = $this->input->getVar('query', ''); // Admin might want to display the featured blogs on all pages. $start = $this->input->get('start', 0, 'int'); $limitstart = $this->input->get('limitstart', 0, 'int'); // conditions $options = array(); $options['langcode'] = $lang; if ($search) { $options['search'] = $search; } if (!EB::isSiteAdmin()) { $options['userid'] = $this->my->id; } $model = EB::model('Blog'); // get results $data = $model->getAssociationPosts($options); // Get the pagination $pagination = $model->getPagination(); // $pagination = $pagination->getPagesLinks(); if ($data) { EB::cache()->insert($data); } $posts = EB::formatter('list', $data, false); $this->set('posts', $posts); $this->set('langcode', $lang); $this->set('langid', $langid); $this->set('search', $search); $this->set('pagination', $pagination); parent::display('composer/posts/listing'); }
/** * Determines if there are any values for fields within this group for a particular post. * * @since 5.0 * @access public * @param string * @return */ public function hasValues(EasyBlogPost $post) { static $result = array(); $idx = $this->id . $post->id; if (!isset($result[$idx])) { if (EB::cache()->exists($post->id, 'posts')) { $data = EB::cache()->get($post->id, 'posts'); if (isset($data['customfields'])) { $fCount = 0; foreach ($data['customfields'] as $fields) { foreach ($fields as $fieldvalue) { if ($fieldvalue->value) { $fCount++; } } } $result[$idx] = $fCount; return $result[$idx]; } } } // if still empty, let run the sql if (!isset($result[$idx])) { $model = EB::model('FieldGroups'); $result[$idx] = $model->hasValues($post->id, $this->id); } return $result[$idx]; }
/** * Displays the frontpage blog listings on the site. * * @since 5.0 * @access public */ public function display($tmpl = null) { // Add the RSS headers on the page EB::feeds()->addHeaders('index.php?option=com_easyblog'); // Add breadcrumbs on the site menu. $this->setPathway('COM_EASYBLOG_LATEST_BREADCRUMB'); // Get the current active menu's properties. $params = $this->theme->params; $inclusion = ''; if ($params) { // Get a list of category inclusions $inclusion = EB::getCategoryInclusion($params->get('inclusion')); if ($params->get('includesubcategories', 0) && !empty($inclusion)) { $tmpInclusion = array(); foreach ($inclusion as $includeCatId) { // Retrieve nested categories $category = new stdClass(); $category->id = $includeCatId; $category->childs = null; EB::buildNestedCategories($category->id, $category); $linkage = ''; EB::accessNestedCategories($category, $linkage, '0', '', 'link', ', '); $catIds = array(); $catIds[] = $category->id; EB::accessNestedCategoriesId($category, $catIds); $tmpInclusion = array_merge($tmpInclusion, $catIds); } $inclusion = $tmpInclusion; } } // Sorting for the posts $sort = $this->input->get('sort', $this->config->get('layout_postorder'), 'cmd'); $model = EB::model('Blog'); $tobeCached = array(); // Retrieve a list of featured blog posts on the site. $featured = $model->getFeaturedBlog($inclusion); $excludeIds = array(); // Test if user also wants the featured items to be appearing in the blog listings on the front page. // Otherwise, we'll need to exclude the featured id's from appearing on the front page. if (!$this->theme->params->get('post_include_featured', true)) { foreach ($featured as $item) { $excludeIds[] = $item->id; } } // Admin might want to display the featured blogs on all pages. $start = $this->input->get('start', 0, 'int'); $limitstart = $this->input->get('limitstart', 0, 'int'); if (!$this->theme->params->get('featured_slider_all_pages') && ($start != 0 || $limitstart != 0)) { $featured = array(); } if ($featured) { $tobeCached = array_merge($tobeCached, $featured); } // Try to retrieve any categories to be excluded. $excludedCategories = $this->config->get('layout_exclude_categories'); $excludedCategories = empty($excludedCategories) ? '' : explode(',', $excludedCategories); // Fetch the blog entries. $data = $model->getBlogsBy('', '', $sort, 0, EBLOG_FILTER_PUBLISHED, null, true, $excludeIds, false, false, true, $excludedCategories, $inclusion, null, 'listlength', $this->theme->params->get('post_pin_featured', false)); if ($data) { $tobeCached = array_merge($tobeCached, $data); } // we will cache it here. if ($tobeCached) { EB::cache()->insert($tobeCached); } // Get the pagination $pagination = $model->getPagination(); if ($featured) { // Format the featured items without caching $featured = EB::formatter('featured', $featured, false); } // Perform blog formatting without caching $posts = EB::formatter('list', $data, false); // 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_LATEST_PAGE_TITLE')); // Set the page title $this->setPageTitle($title, $pagination, $this->config->get('main_pagetitle_autoappend')); // Add canonical URLs. $this->canonical('index.php?option=com_easyblog'); // Retrieve the pagination for the latest view $pagination = $pagination->getPagesLinks(); // Meta should be set later because formatter would have cached the post already. EB::setMeta(META_ID_LATEST, META_TYPE_VIEW); // Get the current url $return = EBR::_('index.php?option=com_easyblog', false); $this->set('return', $return); $this->set('posts', $posts); $this->set('featured', $featured); $this->set('pagination', $pagination); parent::display('blogs/latest/default'); }
/** * Retrieves the total number of posts available in this team * * @since 5.0 * @access public * @param string * @return */ public function getPostCount() { static $counter = array(); if (!isset($counter[$this->id])) { if (EB::cache()->exists($this->id, 'teamblogs')) { $data = EB::cache()->get($this->id, 'teamblogs'); if (isset($data['postcount'])) { $counter[$this->id] = $data['postcount']; } else { $counter[$this->id] = '0'; } } else { $model = EB::model('TeamBlogs'); $counter[$this->id] = $model->getPostCount($this->id); } } return $counter[$this->id]; }
/** * Retrieves the custom field value * * @since 4.0 * @access public * @param string * @return */ public function getFieldValues($fieldId, $blogId) { $db = EB::db(); $values = array(); if (EB::cache()->exists($blogId, 'posts')) { $data = EB::cache()->get($blogId, 'posts'); if (isset($data['customfields']) && isset($data['customfields'][$fieldId])) { foreach ($data['customfields'][$fieldId] as $item) { $values[] = $item; } return $values; } // no customfield values for this post. return array(); } else { $query = 'SELECT * FROM ' . $db->quoteName('#__easyblog_fields_values'); $query .= ' WHERE ' . $db->quoteName('field_id') . '=' . $db->Quote($fieldId); $query .= ' AND ' . $db->quoteName('post_id') . '=' . $db->Quote($blogId); $db->setQuery($query); $result = $db->loadObjectList(); if (!$result) { return $result; } foreach ($result as $row) { $value = EB::table('FieldValue'); $value->bind($row); $values[] = $value; } } return $values; }
public function isCategorySubscribedEmail($categoryId, $email) { $db = EB::db(); // lets check if this item already cached or not if (EB::cache()->exists($categoryId, 'cats')) { $data = EB::cache()->get($categoryId, 'cats'); if (isset($data['subs'])) { return true; } else { return false; } } $query = 'SELECT `id` FROM `#__easyblog_subscriptions`'; $query .= ' WHERE `uid` = ' . $db->Quote($categoryId); $query .= ' AND `utype` = ' . $db->Quote(EBLOG_SUBSCRIPTION_CATEGORY); $query .= ' AND `email` = ' . $db->Quote($email); $db->setQuery($query); $result = $db->loadResult(); return $result; }
/** * Retrieves a list of categories associated with this blog post * * @since 4.0 * @access public * @param string * @return */ public function getCategories() { static $categories = array(); if (!isset($categories[$this->id])) { $results = array(); // lets load from cache if there is any if (EB::cache()->exists($this->id, 'posts')) { $data = EB::cache()->get($this->id, 'posts'); if ($data['category']) { $results = $data['category']; } } else { $model = EB::model('Categories'); $results = $model->getBlogCategories($this->id); } $categories[$this->id] = $results; } return $categories[$this->id]; }
public static function buildNestedCategories($parentId, &$parent, $ignorePrivate = false, $isPublishedOnly = false, $isWrite = false, $exclusion = array()) { $my = JFactory::getUser(); $childs = array(); //lets try to get from cache if there is any if (EB::cache()->exists($parentId, 'cats')) { $data = EB::cache()->get($parentId, 'cats'); if (isset($data['child'])) { $childs = $data['child']; } else { return false; } } else { $catModel = EB::model('Categories'); $childs = $catModel->getChildCategories($parentId, $isPublishedOnly, $isWrite, $exclusion); } if (!$childs) { return false; } $items = array(); foreach ($childs as $child) { $items[$child->id] = $child; } $parent->childs = array(); $catLib = EB::category(); $catLib::addChilds($parent, $items); return false; }
/** * Retrieves a list of posts from a specific team * * @since 5.0 * @access public * @param string * @return */ public function getPosts($id, $limit = null) { //lets check if posts already cached or not. if (EB::cache()->exists($id, 'teamblogs')) { $data = EB::cache()->get($id, 'teamblogs'); if (isset($data['post'])) { return $data['post']; } else { return array(); } } $db = EB::db(); $config = EB::config(); $query = array(); $options = array('teamId' => $id, 'concateOperator' => 'AND'); // contribution type sql $contributor = EB::contributor(); $contributeSQL = ''; $contributeSQL .= $contributor::genAccessSQL(EASYBLOG_POST_SOURCE_TEAM, 'a', $options); $query[] = 'SELECT a.* FROM ' . $db->quoteName('#__easyblog_post') . ' AS a'; $query[] = 'where a.' . $db->quoteName('published') . '=' . $db->Quote(EASYBLOG_POST_PUBLISHED); $query[] = 'and a.' . $db->quoteName('state') . '=' . $db->Quote(EASYBLOG_POST_NORMAL); $query[] = $contributeSQL; // category access here $catLib = EB::category(); $catAccessSQL = $catLib->genAccessSQL('a.`id`'); $query[] = 'AND (' . $catAccessSQL . ')'; // Ordering options $ordering = $config->get('layout_teamblogsort', 'DESC'); $query[] = ' ORDER BY a.' . $db->quoteName('created') . ' ' . $ordering; if (!is_null($limit) && $limit) { // Glue back the sql queries into a single string. $queryCount = implode(' ', $query); $queryCount = str_ireplace('SELECT a.*', 'SELECT COUNT(1)', $queryCount); $db->setQuery($queryCount); $count = $db->loadResult(); $limit = $limit == 0 ? $this->getState('limit') : $limit; $limitstart = $this->input->get('limitstart', $this->getState('limitstart'), 'int'); // Set the limit $query[] = 'LIMIT ' . $limitstart . ',' . $limit; $this->_pagination = EB::pagination($count, $limitstart, $limit); } else { // TODO: prepare the pagination object } $query = implode(' ', $query); // Debug // echo str_ireplace('#__', 'jos_', $query);exit; $db->setQuery($query); $result = $db->loadObjectList(); return $result; }
/** * Retrieves custom fields for this category * * @since 4.0 * @access public * @param string * @return */ public function getCustomFields() { static $loaded = array(); if (!isset($loaded[$this->id])) { $group = null; $fields = null; if (EB::cache()->exists($this->id, 'categories')) { $cachedCategory = EB::cache()->get($this->id, 'categories'); $group = $cachedCategory['group']; $fields = $cachedCategory['field']; } else { $model = EB::model('Categories'); $group = $model->getCustomFieldGroup($this->id); $fields = $model->getCustomFields($this->id); } if (!$group->id && !$fields) { $obj = false; } else { $obj = new stdClass(); $obj->group = $group; $obj->fields = $fields; } $loaded[$this->id] = $obj; } return $loaded[$this->id]; }
/** * Retrieves a list of posts from a specific team * * @since 5.0 * @access public * @param string * @return */ public function getPosts($id, $limit = null) { //lets check if posts already cached or not. if (EB::cache()->exists($id, 'teamblogs')) { $data = EB::cache()->get($id, 'teamblogs'); if (isset($data['post'])) { return $data['post']; } else { return array(); } } $db = EB::db(); $query = array(); $options = array('teamId' => $id, 'concateOperator' => 'AND'); // contribution type sql $contributor = EB::contributor(); $contributeSQL = ''; $contributeSQL .= $contributor::genAccessSQL(EASYBLOG_POST_SOURCE_TEAM, 'a', $options); $query[] = 'SELECT a.* FROM ' . $db->quoteName('#__easyblog_post') . ' AS a'; $query[] = 'where a.' . $db->quoteName('published') . '=' . $db->Quote(EASYBLOG_POST_PUBLISHED); $query[] = 'and a.' . $db->quoteName('state') . '=' . $db->Quote(EASYBLOG_POST_NORMAL); $query[] = $contributeSQL; // category access here $catLib = EB::category(); $catAccessSQL = $catLib->genAccessSQL('a.`id`'); $query[] = 'AND (' . $catAccessSQL . ')'; if (!is_null($limit) && $limit) { $query[] = 'LIMIT 0,' . $limit; } else { // TODO: prepare the pagination object } $query = implode(' ', $query); // echo $query; $db->setQuery($query); $result = $db->loadObjectList(); return $result; }