本文整理汇总了PHP中EB::call方法的典型用法代码示例。如果您正苦于以下问题:PHP EB::call方法的具体用法?PHP EB::call怎么用?PHP EB::call使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EB
的用法示例。
在下文中一共展示了EB::call方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct()
{
parent::__construct();
$limit = EB::call('Pagination', 'getLimit');
$limitstart = $this->input->get('limitstart', 0, 'int');
$limitstart = $limit != 0 ? floor($limitstart / $limit) * $limit : 0;
$this->setState('limit', $limit);
$this->setState('limitstart', $limitstart);
}
示例2: __construct
public function __construct()
{
parent::__construct();
$mainframe = JFactory::getApplication();
$limit = EB::call('Pagination', 'getLimit');
$limitstart = $this->input->get('limitstart', '0', 'int');
// In case limit has been changed, adjust it
$limitstart = (int) ($limit != 0 ? floor($limitstart / $limit) * $limit : 0);
$this->setState('limit', $limit);
$this->setState('limitstart', $limitstart);
}
示例3: listings
/**
* 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());
$limit = EB::call('Pagination', 'getLimit', array(EBLOG_PAGINATION_TEAMBLOGS));
// Retrieve the model
$model = EB::model('TeamBlogs');
$posts = $model->getPosts($team->id, $limit);
$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');
}
示例4: getAssociationPosts
public function getAssociationPosts($options = array())
{
$db = EB::db();
$query = "select a.* from `#__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);
if (isset($options['langcode']) && $options['langcode']) {
$query .= " AND a." . $db->quoteName('language') . " = " . $db->Quote($options['langcode']);
}
if (isset($options['userid']) && $options['userid']) {
$query .= " AND a." . $db->quoteName('created_by') . " = " . $db->Quote($options['userid']);
}
if (isset($options['search']) && $options['search']) {
$query .= " AND a." . $db->quoteName('title') . " LIKE " . $db->Quote('%' . $options['search'] . '%');
}
// limits
$limit = EB::call('Pagination', 'getLimit', array('listlength'));
$limitstart = JRequest::getInt('limitstart', 0, 'REQUEST');
// In case limit has been changed, adjust it
$limitstart = (int) ($limit != 0 ? floor($limitstart / $limit) * $limit : 0);
if ($limitstart < 0) {
$limitstart = 0;
}
$queryLimit = " LIMIT " . $limitstart . "," . $limit;
// total count
$queryCnt = "SELECT COUNT(1) from (";
$queryCnt .= $query;
$queryCnt .= ") as x";
$db->setQuery($queryCnt);
$this->_total = $db->loadResult();
$this->_pagination = EB::pagination($this->_total, $limitstart, $limit);
$query = $query . $queryLimit;
$db->setQuery($query);
$results = $db->loadObjectList();
return $results;
}
示例5: execute
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;
}
示例6: listings
/**
* 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);
//.........这里部分代码省略.........
示例7: preloadPosts
public function preloadPosts($catIds)
{
$db = EB::db();
$config = EB::config();
$limit = EB::call('Pagination', 'getLimit', array(EBLOG_PAGINATION_CATEGORIES));
// Determines if this is currently on blogger mode
$isBloggerMode = EasyBlogRouter::isBloggerMode();
$query = array();
$i = 1;
foreach ($catIds as $cid => $cIds) {
$p = 'p' . $i;
$a = 'a' . $i;
$f = 'f' . $i;
$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 ( ({$p}.`source_type` = " . $db->Quote(EASYBLOG_POST_SOURCE_SITEWIDE) . ") ";
if ($config->get('main_includeteamblogpost')) {
$contributeSQL .= $contributor::genAccessSQL(EASYBLOG_POST_SOURCE_TEAM, $p);
}
if ($includeJSEvent) {
$contributeSQL .= $contributor::genAccessSQL(EASYBLOG_POST_SOURCE_JOMSOCIAL_EVENT, $p);
}
if ($includeJSGrp) {
$contributeSQL .= $contributor::genAccessSQL(EASYBLOG_POST_SOURCE_JOMSOCIAL_GROUP, $p);
}
// Test if easysocial exists on the site
if (EB::easysocial()->exists()) {
$contributeSQL .= $contributor::genAccessSQL(EASYBLOG_POST_SOURCE_EASYSOCIAL_GROUP, $p);
$contributeSQL .= $contributor::genAccessSQL(EASYBLOG_POST_SOURCE_EASYSOCIAL_EVENT, $p);
}
$contributeSQL .= ")";
$tmp = "(select {$p}.*, " . $db->Quote($cid) . " as `category_id`, {$f}.`id` as `featured`";
$tmp .= "\tfrom `#__easyblog_post` as {$p}";
$tmp .= "\t\tinner join `#__easyblog_post_category` as {$a} on {$p}.`id` = {$a}.`post_id`";
$tmp .= " LEFT JOIN `#__easyblog_featured` AS {$f}";
$tmp .= " \tON {$p}.`id` = {$f}.`content_id` AND {$f}.`type` = " . $db->Quote('post');
if (count($cIds) == 1) {
$tmp .= " where {$a}.`category_id` = " . $db->Quote($cIds[0]);
} else {
$tmp .= " where {$a}.`category_id` IN (" . implode(',', $cIds) . ")";
}
$tmp .= " and {$p}.`published` = " . $db->Quote(EASYBLOG_POST_PUBLISHED);
$tmp .= " and {$p}.`state` = " . $db->Quote(EASYBLOG_POST_NORMAL);
if ($isBloggerMode !== false) {
$tmp .= " AND {$p}." . $db->qn('created_by') . " = " . $db->Quote($isBloggerMode);
} else {
// Get the author id based on the category menu
$authorId = EB::getCategoryMenuBloggerId();
if ($authorId) {
$tmp .= " AND {$p}." . $db->qn('created_by') . " = " . $db->Quote($authorId);
}
}
// If user is a guest, ensure that they can really view the blog post
if ($this->my->guest) {
$tmp .= " AND {$p}." . $db->qn('access') . " = " . $db->Quote(BLOG_PRIVACY_PUBLIC);
}
// Ensure that the blog posts is available site wide
$tmp .= $contributeSQL;
// $tmp .= " AND $p." . $db->qn('source_id') . " = " . $db->Quote("0");
// Filter by language
$language = EB::getCurrentLanguage();
if ($language) {
$tmp .= " AND ({$p}." . $db->qn('language') . "=" . $db->Quote($language) . " OR {$p}." . $db->qn('language') . "=" . $db->Quote('*') . " OR {$p}." . $db->qn('language') . "=" . $db->Quote('') . ")";
}
$tmp .= " order by {$p}.`created` desc";
$tmp .= " limit " . $limit . ")";
$query[] = $tmp;
$i++;
}
$query = implode(' UNION ALL ', $query);
// echo $query;exit;
$db->setQuery($query);
$results = $db->loadObjectList();
$posts = array();
if ($results) {
foreach ($results as $row) {
$posts[$row->category_id][] = $row;
}
}
return $posts;
}
示例8: getBlogsBy
//.........这里部分代码省略.........
$queryWhere .= ' AND a.`blogpassword` = ""';
}
// category access here
$catLib = EB::category();
$catAccessSQL = $catLib->genAccessSQL('a.`id`', $catAccess);
$queryWhere .= ' AND (' . $catAccessSQL . ')';
// get the default sorting.
$defaultSorting = $customOrdering ? $customOrdering : $config->get('layout_postsort', 'desc');
$queryOrder = ' ORDER BY ';
$sortableItems = array('latest', 'published', 'popular', 'active', 'alphabet', 'modified', 'random');
if ($frontpage && $pinFeatured) {
$queryOrder .= ' f.`created` DESC ,';
}
switch ($sort) {
case 'latest':
$queryOrder .= ' a.`created` ' . $defaultSorting;
break;
case 'published':
$queryOrder .= ' a.`publish_up` ' . $defaultSorting;
break;
case 'popular':
$queryOrder .= ' a.`hits` ' . $defaultSorting;
break;
case 'active':
$queryOrder .= ' a.`publish_down` ' . $defaultSorting;
break;
case 'alphabet':
$queryOrder .= ' a.`title` ' . $defaultSorting;
break;
case 'modified':
$queryOrder .= ' a.`modified` ' . $defaultSorting;
break;
case 'random':
$queryOrder .= ' `random_id` ';
break;
default:
break;
}
if ($max > 0) {
$queryLimit = ' LIMIT ' . $max;
} else {
//set frontpage list length if it is detected to be the frontpage
$view = JRequest::getCmd('view', '');
$limit = EB::call('Pagination', 'getLimit', array($limitType));
$limitstart = JRequest::getInt('limitstart', 0, 'REQUEST');
// In case limit has been changed, adjust it
$limitstart = (int) ($limit != 0 ? floor($limitstart / $limit) * $limit : 0);
if ($limitstart < 0) {
$limitstart = 0;
}
$queryLimit = ' LIMIT ' . $limitstart . ',' . $limit;
$queryPagination = true;
}
if ($queryPagination) {
$query = 'SELECT COUNT(1) FROM `#__easyblog_post` AS a';
if (($type == 'blogger' || $type == 'teamblog') && $statType == 'tag') {
$query .= ' LEFT JOIN `#__easyblog_post_tag` AS t ON a.id = t.post_id';
}
$query .= $queryWhere;
$query .= $contributeSQL;
$query .= $queryExclude;
$query .= $queryInclude;
// echo $query;exit;
$db->setQuery($query);
$this->_total = $db->loadResult();
$this->_pagination = EB::pagination($this->_total, $limitstart, $limit);
}
$query = 'SELECT a.`id` AS key1, a.*';
$query .= ', ifnull(f.`id`, 0) as `featured`';
if ($sort == 'random') {
$query .= ', floor( 1 + rand() * rd.`rid` ) as `random_id`';
}
$query .= ' FROM `#__easyblog_post` AS a';
// if ($frontpage && $pinFeatured) {
$query .= ' LEFT JOIN `#__easyblog_featured` AS f';
$query .= ' ON a.`id` = f.`content_id` AND f.`type` = ' . $db->Quote('post');
// }
if (($type == 'blogger' || $type == 'teamblog') && $statType == 'tag') {
$query .= ' LEFT JOIN `#__easyblog_post_tag` AS t ON a.`id` = t.`post_id`';
$query .= ' AND t.`tag_id` = ' . $db->Quote($statId);
}
if ($sort == 'random') {
$query .= ', (select max(tmp.`id`) - 1 as `rid` from `#__easyblog_post` as tmp ) as rd';
}
$query .= $queryWhere;
$query .= $contributeSQL;
$query .= $queryExclude;
$query .= $queryInclude;
$query .= $queryOrder;
$query .= $queryLimit;
// // Debugging
// echo str_ireplace( '#__' , 'jos_' , $query );
// exit;
$db->setQuery($query);
if ($db->getErrorNum() > 0) {
JError::raiseError($db->getErrorNum(), $db->getErrorMsg() . $db->stderr());
}
$result = $db->loadObjectList();
return $result;
}
示例9: formatDate
/**
* Formats a date.
*
* @since 1.3
* @access public
* @param string
* @return
*/
public function formatDate($format, $dateString)
{
$date = EB::call('Date', 'dateWithOffSet', array($dateString));
return $date->format($format);
}
示例10: get
public function get()
{
$input = JFactory::getApplication()->input;
$model = EasyBlogHelper::getModel('Blog');
$category = EasyBlogHelper::table('Category', 'Table');
$id = $input->get('id', null, 'INT');
$search = $input->get('search', null, 'STRING');
$posts = array();
if (!isset($id)) {
$categoriesmodel = EasyBlogHelper::getModel('Categories');
$categories = $categoriesmodel->getCategoryTree('ordering');
$this->plugin->setResponse($categories);
return;
}
$category->load($id);
// private category shouldn't allow to access.
$privacy = $category->checkPrivacy();
if (!$category->id || !$privacy->allowed) {
$this->plugin->setResponse($this->getErrorResponse(404, 'Category not found'));
return;
}
//new code
$category = EB::table('Category');
$category->load($id);
//get the nested categories
$category->childs = null;
// Build nested childsets
EB::buildNestedCategories($category->id, $category, false, true);
$catIds = array();
$catIds[] = $category->id;
EB::accessNestedCategoriesId($category, $catIds);
// 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);
$rows = EB::formatter('list', $data);
//end
foreach ($rows as $k => $v) {
//$item = EasyBlogHelper::getHelper( 'SimpleSchema' )->mapPost($v, '', 100, array('text'));
$scm_obj = new EasyBlogSimpleSchema_plg();
$item = $scm_obj->mapPost($v, '', 100, array('text'));
$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);
}
示例11: display
/**
* 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;
//.........这里部分代码省略.........