当前位置: 首页>>代码示例>>PHP>>正文


PHP EB::accessNestedCategories方法代码示例

本文整理汇总了PHP中EB::accessNestedCategories方法的典型用法代码示例。如果您正苦于以下问题:PHP EB::accessNestedCategories方法的具体用法?PHP EB::accessNestedCategories怎么用?PHP EB::accessNestedCategories使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EB的用法示例。


在下文中一共展示了EB::accessNestedCategories方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: display

 /**
  * Default feed display method
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return
  */
 public function display($tmpl = null)
 {
     // Ensure that rss is enabled
     if (!$this->config->get('main_rss')) {
         return JError::raiseError(404, JText::_('COM_EASYBLOG_FEEDS_DISABLED'));
     }
     $id = $this->input->get('id', '', 'cmd');
     $category = EB::table('Category');
     $category->load($id);
     // Private category shouldn't allow to access.
     $privacy = $category->checkPrivacy();
     if (!$privacy->allowed) {
         return JError::raiseError(500, JText::_('COM_EASYBLOG_NOT_ALLOWED_HERE'));
     }
     // Get the nested categories
     $category->childs = null;
     EB::buildNestedCategories($category->id, $category);
     $linkage = '';
     EB::accessNestedCategories($category, $linkage, '0', '', 'link', ', ');
     $catIds = array();
     $catIds[] = $category->id;
     EB::accessNestedCategoriesId($category, $catIds);
     $category->nestedLink = $linkage;
     $model = EB::model('Blog');
     $sort = $this->input->get('sort', $this->config->get('layout_postorder'), 'cmd');
     $posts = $model->getBlogsBy('category', $catIds, $sort);
     $posts = EB::formatter('list', $posts);
     $this->doc->link = EBR::_('index.php?option=com_easyblog&view=categories&id=' . $id . '&layout=listings');
     $this->doc->setTitle($this->escape($category->getTitle()));
     $this->doc->setDescription(JText::sprintf('COM_EASYBLOG_FEEDS_CATEGORY_DESC', $this->escape($category->getTitle())));
     if (!$posts) {
         return;
     }
     $uri = JURI::getInstance();
     $scheme = $uri->toString(array('scheme'));
     $scheme = str_replace('://', ':', $scheme);
     foreach ($posts as $post) {
         $image = '';
         if ($post->hasImage()) {
             $image = '<img src="' . $post->getImage('medium', true, true) . '" width="250" align="left" />';
         }
         $item = new JFeedItem();
         $item->title = $this->escape($post->title);
         $item->link = $post->getPermalink();
         $item->description = $image . $post->getIntro();
         // replace the image source to proper format so that feed reader can view the image correctly.
         $item->description = str_replace('src="//', 'src="' . $scheme . '//', $item->description);
         $item->description = str_replace('href="//', 'href="' . $scheme . '//', $item->description);
         $item->date = $post->getCreationDate()->toSql();
         $item->category = $post->getPrimaryCategory()->getTitle();
         $item->author = $post->author->getName();
         $item->authorEmail = $this->getRssEmail($post->author);
         $this->doc->addItem($item);
     }
     // exit;
 }
开发者ID:knigherrant,项目名称:decopatio,代码行数:64,代码来源:view.feed.php

示例2: 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;
 }
开发者ID:knigherrant,项目名称:decopatio,代码行数:73,代码来源:categories.php

示例3: accessNestedCategories

 public static function accessNestedCategories($arr, &$html, $deep = '0', $default = '0', $type = 'select', $linkDelimiter = '')
 {
     if (isset($arr->childs) && is_array($arr->childs)) {
         $sup = '<sup>|_</sup>';
         $space = '';
         $ld = empty($linkDelimiter) ? '>' : $linkDelimiter;
         if ($type == 'select' || $type == 'popup') {
             $deep++;
             for ($d = 0; $d < $deep; $d++) {
                 $space .= '&nbsp;&nbsp;&nbsp;';
             }
         }
         for ($j = 0; $j < count($arr->childs); $j++) {
             $child = $arr->childs[$j];
             $cat = EB::table('Category');
             $cat->bind($child);
             if ($type == 'select') {
                 $selected = $child->id == $default ? ' selected="selected"' : '';
                 $html .= '<option value="' . $child->id . '" ' . $selected . '>' . $space . $sup . JText::_($child->title) . '</option>';
             } else {
                 if ($type == 'popup') {
                     $html .= '<div class="category-list-item" id="' . $child->id . '">' . $space . $sup . '<a href="javascript:void(0);" onclick="eblog.dashboard.selectCategory(\'' . $child->id . '\')">' . JText::_($child->title) . '</a>';
                     $html .= '<input type="hidden" id="category-list-item-' . $child->id . '" value="' . JText::_($child->title) . '" />';
                     $html .= '</div>';
                 } else {
                     $str = '<a href="' . $cat->getPermalink() . '">' . $cat->getTitle() . '</a>';
                     $html .= empty($html) ? $str : $ld . $str;
                 }
             }
             EB::accessNestedCategories($child, $html, $deep, $default, $type, $linkDelimiter);
         }
     }
     return false;
 }
开发者ID:knigherrant,项目名称:decopatio,代码行数:34,代码来源:easyblog.php

示例4: 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);
//.........这里部分代码省略.........
开发者ID:BetterBetterBetter,项目名称:B3App,代码行数:101,代码来源:view.html.php

示例5: display

 /**
  * 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');
 }
开发者ID:knigherrant,项目名称:decopatio,代码行数:97,代码来源:view.html.php


注:本文中的EB::accessNestedCategories方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。