本文整理汇总了PHP中EB::cache方法的典型用法代码示例。如果您正苦于以下问题:PHP EB::cache方法的具体用法?PHP EB::cache怎么用?PHP EB::cache使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EB
的用法示例。
在下文中一共展示了EB::cache方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
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;
}
示例2: execute
/**
* 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;
}
示例3: execute
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;
}
示例4: execute
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;
}
示例5: execute
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;
}
示例6: getCategoryUsed
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;
}
示例7: EasyBlogBuildRoute
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'];
//.........这里部分代码省略.........
示例8: preview
/**
* 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');
}
示例9: 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;
}
示例10: _
/**
* 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;
}
}
}
//.........这里部分代码省略.........
示例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;
//.........这里部分代码省略.........
示例12: getPosts
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');
}
示例13: hasValues
/**
* 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];
}
示例14: getPostCount
/**
* 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];
}
示例15: getFieldValues
/**
* 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;
}