/** * Displays the default categories layout * * @since 4.0 * @access public * @param string * @return */ public function display($tmpl = null) { // Set meta tags for bloggers EB::setMeta(META_ID_GATEGORIES, META_TYPE_VIEW); // If the active menu is this view, we should not make the breadcrumb linkable. if (EasyBlogRouter::isCurrentActiveMenu('categories')) { $this->setPathway(JText::_('COM_EASYBLOG_CATEGORIES_BREADCRUMB'), ''); } // Sorting options $defaultSorting = $this->config->get('layout_sorting_category', 'latest'); $sort = $this->input->get('sort', $defaultSorting, 'cmd'); // Load up our own models $model = EB::model('Category'); // Test if there's any explicit inclusion of categories $menu = $this->app->getMenu()->getActive(); $inclusion = ''; if (is_object($menu) && stristr($menu->link, 'view=categories') !== false) { $inclusion = EB::getCategoryInclusion($menu->params->get('inclusion')); } // Get the number of categories to show per page $limit = $this->config->get('layout_pagination_categories_per_page'); // Get the categories $categories = $model->getCategories($sort, $this->config->get('main_categories_hideempty'), $limit, $inclusion); // Get the pagination $pagination = $model->getPagination(); $pagination = $pagination->getPagesLinks(); // Format the categories $categories = EB::formatter('categories', $categories); // 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_CATEGORIES_PAGE_TITLE')); $this->setPageTitle($title, $pagination, $this->config->get('main_pagetitle_autoappend')); // Add canonical URLs. $this->canonical('index.php?option=com_easyblog&view=categories'); // Get the default pagination limit for authors $limit = $this->app->getCfg('list_limit'); $limit = $limit == 0 ? 5 : $limit; $this->set('limit', $limit); $this->set('categories', $categories); $this->set('sort', $sort); $this->set('pagination', $pagination); $namespace = 'blogs/categories/default'; if ($this->getLayout() == 'simple') { $namespace = 'blogs/categories/default.simple'; } parent::display($namespace); }
if ($year['maxyear'] - $year['minyear'] > $count) { $year['minyear'] = $year['maxyear'] - $count; } } //set default year $defaultYear = JRequest::getVar('archiveyear', $year['maxyear'], 'REQUEST'); //set default month $defaultMonth = JRequest::getVar('archivemonth', 0, 'REQUEST'); $menuitemid = $params->get('menuitemid', ''); $menuitemid = !empty($menuitemid) ? '&Itemid=' . $menuitemid : ''; //@task: Get the parameter $showEmptyMonth = $params->get('showempty', 1); $showEmptyYear = $params->get('showemptyyear', false); // @task: Get excluded categories $excludeCats = $params->get('excatid', array()); $includeCats = EB::getCategoryInclusion($params->get('catid', array())); if (is_array($includeCats)) { foreach ($includeCats as $includeCat) { $catid .= 'modCid[]=' . $includeCat . '&'; } } $filter = $params->get('filter', ''); $filterId = ''; // Get filter if any if ($filter == 'blogger') { $filterId = $params->get('bloggerId', ''); } else { $filterId = $params->get('teamId', ''); } $postCounts = $model->getArchivePostCounts($year['minyear'], $year['maxyear'], $excludeCats, $includeCats, $filter, $filterId); require JModuleHelper::getLayoutPath('mod_easyblogarchive');
/** * Displays the latest entry on the site using the entry view * * @since 5.0 * @access public * @param string * @return */ public function latest() { // Fetch the latest blog entry $model = EB::model('Blog'); // Get the current active menu's properties. $app = JFactory::getApplication(); $menu = $app->getMenu()->getActive(); $inclusion = ''; if (is_object($menu)) { $params = EB::registry($menu->params); $inclusion = EB::getCategoryInclusion($params->get('inclusion')); } $items = $model->getBlogsBy('latest', 0, '', 1, EBLOG_FILTER_PUBLISHED, null, true, array(), false, false, true, array(), $inclusion); if (is_array($items) && !empty($items)) { JRequest::setVar('id', $items[0]->id); return $this->display(); } echo JText::_('COM_EASYBLOG_NO_BLOG_ENTRY'); }
static function getLatestPost(&$params, $id = null, $type = 'latest') { $db = EB::db(); $config = EB::config(); $count = (int) $params->get('count', 0); $model = EB::model('Blog'); $posts = ''; $sort = $params->get('sortby', 'latest') == 'latest' ? 'latest' : 'modified'; switch ($type) { case 'blogger': $posts = $model->getBlogsBy('blogger', $id, $sort, $count, EBLOG_FILTER_PUBLISHED, null, false); break; case 'category': $posts = $model->getBlogsBy('category', $id, $sort, $count, EBLOG_FILTER_PUBLISHED, null, false); break; case 'tag': $posts = $model->getTaggedBlogs($id, $count); break; case 'team': $posts = $model->getBlogsBy('teamblog', $id, $sort, $count, EBLOG_FILTER_PUBLISHED, null, false); break; case 'latest': default: if ($params->get('usefeatured')) { $posts = $model->getFeaturedBlog(array(), $count); } else { $categories = EB::getCategoryInclusion($params->get('catid')); $catIds = array(); if (!empty($categories)) { if (!is_array($categories)) { $categories = array($categories); } foreach ($categories as $item) { $category = new stdClass(); $category->id = trim($item); $catIds[] = $category->id; if ($params->get('includesubcategory', 0)) { $category->childs = null; EB::buildNestedCategories($category->id, $category, false, true); EB::accessNestedCategoriesId($category, $catIds); } } $catIds = array_unique($catIds); } $cid = $catIds; if (!empty($cid)) { $type = 'category'; } $postType = null; if ($params->get('postType') != 'all') { $postType = $params->get('postType'); } $posts = $model->getBlogsBy($type, $cid, 'latest', $count, EBLOG_FILTER_PUBLISHED, null, false, array(), false, false, true, array(), $cid, $postType); } break; } if (count($posts) > 0) { $posts = EB::modules()->processItems($posts, $params); } return $posts; }
/** * 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'); }
/** * Plugin that returns the object list for DJ-Mediatools album * * Each object must contain following properties (mandatory): title, description, image * Optional properties: link, target (_blank or _self), alt (alt attribute for image) * * @param object The album params */ public function onAlbumPrepare(&$source, &$params) { // Lets check the requirements $check = $this->onCheckRequirements($source); if (is_null($check) || is_string($check)) { return null; } $app = JFactory::getApplication(); $default_image = $params->get('plg_easyblog_image'); $eb5 = true; $engine = JPATH_ADMINISTRATOR . '/components/com_easyblog/includes/easyblog.php'; if (!JFile::exists($engine)) { // Easyblog < 5 $path = JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_easyblog' . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'helper.php'; if (!JFile::exists($path)) { return null; } require_once $path; require_once EBLOG_HELPERS . DIRECTORY_SEPARATOR . 'router.php'; $model = EasyBlogHelper::getModel('Blog'); $categories = EasyBlogHelper::getCategoryInclusion($params->get('plg_easyblog_catid')); $eb5 = false; } else { // Easyblog 5+ require_once $engine; require_once JPATH_ADMINISTRATOR . '/components/com_easyblog/includes/modules/modules.php'; $model = EB::model('Blog'); $categories = EB::getCategoryInclusion($params->get('plg_easyblog_catid')); } JFactory::getLanguage()->load('com_easyblog', JPATH_ROOT); $mparams = new JRegistry(); $count = $params->get('max_images'); $sort = array(); $sort[0] = $params->get('plg_easyblog_order'); $sort[1] = $params->get('plg_easyblog_order_dir'); $featured = $params->get('plg_easyblog_usefeatured'); $type = 'latest'; $catIds = array(); if (!empty($categories)) { if (!is_array($categories)) { $categories = array($categories); } foreach ($categories as $item) { $category = new stdClass(); $category->id = trim($item); $catIds[] = $category->id; if ($params->get('plg_easyblog_includesubcategory', 0)) { $category->childs = null; EasyBlogHelper::buildNestedCategories($category->id, $category, false, true); EasyBlogHelper::accessNestedCategoriesId($category, $catIds); } } $catIds = array_unique($catIds); } $cid = $catIds; if (!empty($cid)) { $type = 'category'; } $posts = $model->getBlogsBy($type, $cid, $sort, $count, EBLOG_FILTER_PUBLISHED, null, $featured, array(), false, false, true, array(), $cid); if (count($posts) > 0) { $posts = EasyBlogHelper::modules()->processItems($posts, $params); } $slides = array(); $base = preg_replace('/^https?:/', '', JURI::base()); foreach ($posts as $item) { $slide = (object) array(); if ($eb5) { $post = EB::post($item->id); if ($post->hasImage()) { $slide->image = str_replace($base, '', $post->getImage('original')); } } else { $row = EasyBlogHelper::getTable('Blog', 'Table'); $row->bind($item); $image = $row->getImage(); if (!empty($image)) { $image = str_replace(JURI::base(), '', is_object($image) ? $image->getSource('original') : $image); } if (strstr($image, 'components/com_easyblog/themes/wireframe/images/placeholder-image.png') !== FALSE) { $image = null; } if (!empty($image)) { $slide->image = $image; } } // if no image found in images then try introtext if (empty($slide->image)) { $slide->image = DJMediatoolsLayoutHelper::getImageFromText($item->intro); } // if no image found in images and introtext then try fulltext if (empty($slide->image)) { $slide->image = DJMediatoolsLayoutHelper::getImageFromText($item->content); } // if no image found in fulltext then take default image if (empty($slide->image)) { $slide->image = $default_image; } // if no default image set then don't display this article if (empty($slide->image)) { continue; } $slide->title = $item->title; $slide->description = $item->intro; if (empty($slide->description)) { $slide->description = $item->content; } $slide->canonical = $slide->link = EasyBlogRouter::_('index.php?option=com_easyblog&view=entry&id=' . $item->id); //.'&Itemid='. EasyBlogRouter::getItemIdByCategories( $item->category_id ) ); $slide->id = $item->id . ':' . $item->permalink; //$this->dd($item); if ($comments = $params->get('commnets', 0)) { $host = str_replace(JURI::root(true), '', JURI::root()); $host = preg_replace('/\\/$/', '', $host); switch ($comments) { case 1: // jcomments $slide->comments = array('id' => $item->id, 'group' => 'com_easyblog'); break; case 2: // disqus $disqus_shortname = $params->get('disqus_shortname', ''); if (!empty($disqus_shortname)) { $slide->comments = array(); $slide->comments['url'] = $host . $slide->link; $slide->comments['identifier'] = $disqus_shortname . '-easyblog-' . $item->id; // ?? } break; case 3: // facebook $slide->comments = $host . $slide->link; break; case 4: //komento // not implemented break; } } $slides[] = $slide; } return $slides; }