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


PHP EasyBlogHelper::getCategoryInclusion方法代码示例

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


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

示例1: getItemIdByEntry

 public static function getItemIdByEntry($blogId)
 {
     static $entriesItems = null;
     if (!isset($entriesItems[$blogId])) {
         $db = EasyBlogHelper::db();
         // We need to check against the correct latest entry to be used based on the category this article is in
         $query = 'SELECT ' . $db->nameQuote('id') . ',' . $db->nameQuote('params') . ' FROM ' . $db->nameQuote('#__menu') . 'WHERE ' . $db->nameQuote('link') . '=' . $db->Quote('index.php?option=com_easyblog&view=latest') . 'AND ' . $db->nameQuote('published') . '=' . $db->Quote('1') . EBR::getLanguageQuery();
         $db->setQuery($query);
         $menus = $db->loadObjectList();
         $blog = EB::table('Blog');
         $blog->load($blogId);
         if ($menus) {
             foreach ($menus as $menu) {
                 $params = EB::registry($menu->params);
                 $inclusion = EasyBlogHelper::getCategoryInclusion($params->get('inclusion'));
                 if (empty($inclusion)) {
                     continue;
                 }
                 if (!is_array($inclusion)) {
                     $inclusion = array($inclusion);
                 }
                 if (in_array($blog->category_id, $inclusion)) {
                     $entriesItems[$blogId] = $menu->id;
                 }
             }
         }
         // Test if there is any entry specific view as this will always override the latest above.
         $query = 'SELECT ' . $db->nameQuote('id') . ' FROM ' . $db->nameQuote('#__menu') . ' ' . 'WHERE ' . $db->nameQuote('link') . '=' . $db->Quote('index.php?option=com_easyblog&view=entry&id=' . $blogId) . ' ' . 'AND ' . $db->nameQuote('published') . '=' . $db->Quote('1') . EBR::getLanguageQuery() . ' LIMIT 1';
         $db->setQuery($query);
         $itemid = $db->loadResult();
         if ($itemid) {
             $entriesItems[$blogId] = $itemid;
         } else {
             // this is to check if we used category menu item from this post or not.
             // if yes, we do nothing. if not, we need to update the cache object so that the next checking will
             // not execute sql again.
             if (isset($entriesItems[$blogId])) {
                 return $entriesItems[$blogId];
             } else {
                 $entriesItems[$blogId] = '';
             }
         }
     }
     return $entriesItems[$blogId];
 }
开发者ID:BetterBetterBetter,项目名称:B3App,代码行数:45,代码来源:router.php

示例2: onAlbumPrepare

 /**
  * 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');
     $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';
     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';
     $model = EasyBlogHelper::getModel('Blog');
     $categories = EasyBlogHelper::getCategoryInclusion($params->get('plg_easyblog_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('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);
     $slides = array();
     foreach ($posts as $item) {
         $slide = (object) array();
         $row = EasyBlogHelper::getTable('Blog', 'Table');
         $row->bind($item);
         $image = $row->getImage();
         if (!empty($image)) {
             $slide->image = str_replace(JURI::base(), '', $image->getSource('original'));
         } else {
             $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();
//.........这里部分代码省略.........
开发者ID:chaudhary4k4,项目名称:modernstore,代码行数:101,代码来源:easyblog.php

示例3: getBlogNavigation

 public static function getBlogNavigation($blogId, $creationDate, $typeId = '0', $type = 'sitewide')
 {
     $db = EasyBlogHelper::db();
     $my = JFactory::getUser();
     $config = EasyBlogHelper::getConfig();
     $keys = array('prev', 'next');
     $nav = array();
     $nav['prev'] = null;
     $nav['next'] = null;
     $isBloggerMode = EasyBlogRouter::isBloggerMode();
     $menus = JFactory::getApplication()->getMenu();
     $menu = $menus->getActive();
     $queryInclude = '';
     if (is_object($menu)) {
         $params = EasyBlogHelper::getRegistry();
         $params->load($menu->params);
         $cats = EasyBlogHelper::getCategoryInclusion($params->get('inclusion'));
         if ($cats) {
             if (!is_array($cats)) {
                 $cats = array($cats);
             }
             $queryInclude = ' AND a.`category_id` IN (';
             foreach ($cats as $allowedCat) {
                 $queryInclude .= $db->Quote($allowedCat);
                 if (next($cats) !== false) {
                     $queryInclude .= ',';
                 }
             }
             $queryInclude .= ')';
         }
     }
     // get all private categories id
     $excludeCats = EasyBlogHelper::getPrivateCategories();
     $queryExclude = '';
     if (!empty($excludeCats)) {
         $queryExclude .= ' AND a.`category_id` NOT IN (';
         for ($i = 0; $i < count($excludeCats); $i++) {
             $queryExclude .= $db->Quote($excludeCats[$i]);
             if (next($excludeCats) !== false) {
                 $queryExclude .= ',';
             }
         }
         $queryExclude .= ')';
     }
     foreach ($keys as $key) {
         $query = 'SELECT a.`id`, a.`title`';
         $query .= ' FROM `#__easyblog_post` AS `a`';
         if ($type == 'team' && !empty($typeId)) {
             $query .= ' INNER JOIN `#__easyblog_team_post` AS `b`';
             $query .= ' 	ON a.`id` = b.`post_id`';
         }
         $query .= ' WHERE a.`published` = ' . $db->Quote('1');
         $query .= ' AND a.`ispending` = ' . $db->Quote('0');
         //blog privacy setting
         // @integrations: jomsocial privacy
         $file = JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_community' . DIRECTORY_SEPARATOR . 'libraries' . DIRECTORY_SEPARATOR . 'core.php';
         $easysocial = EasyBlogHelper::getHelper('EasySocial');
         if ($config->get('integrations_easysocial_privacy') && $easysocial->exists() && !EasyBlogHelper::isSiteAdmin()) {
             $esPrivacyQuery = $easysocial->buildPrivacyQuery('a');
             $query .= $esPrivacyQuery;
         } else {
             if ($config->get('main_jomsocial_privacy') && JFile::exists($file) && !EasyBlogHelper::isSiteAdmin()) {
                 require_once $file;
                 $my = JFactory::getUser();
                 $jsFriends = CFactory::getModel('Friends');
                 $friends = $jsFriends->getFriendIds($my->id);
                 // Insert query here.
                 $query .= ' AND (';
                 $query .= ' (a.`private`= 0 ) OR';
                 $query .= ' ( (a.`private` = 20) AND (' . $db->Quote($my->id) . ' > 0 ) ) OR';
                 if (empty($friends)) {
                     $query .= ' ( (a.`private` = 30) AND ( 1 = 2 ) ) OR';
                 } else {
                     $query .= ' ( (a.`private` = 30) AND ( a.' . $db->nameQuote('created_by') . ' IN (' . implode(',', $friends) . ') ) ) OR';
                 }
                 $query .= ' ( (a.`private` = 40) AND ( a.' . $db->nameQuote('created_by') . '=' . $my->id . ') )';
                 $query .= ' )';
             } else {
                 //blog privacy setting
                 if ($my->id == 0) {
                     $query .= ' AND a.`private` = ' . $db->Quote(BLOG_PRIVACY_PUBLIC);
                 }
             }
         }
         //include categories
         if (!empty($queryInclude)) {
             $query .= $queryInclude;
         }
         //exclude private categories
         $query .= $queryExclude;
         if ($isBloggerMode !== false) {
             $query .= ' AND a.`created_by` = ' . $db->Quote($isBloggerMode);
         }
         if ($type == 'team' && !empty($typeId)) {
             $query .= ' 	AND b.`team_id` = ' . $db->Quote($typeId);
         } else {
             $query .= ' 	AND a.`issitewide` = ' . $db->Quote('1');
         }
         //language filtering
         if (EasyBlogHelper::getJoomlaVersion() >= '1.6') {
//.........这里部分代码省略.........
开发者ID:Tommar,项目名称:vino2,代码行数:101,代码来源:helper.php

示例4: latest

 /**
  * Displays a single latest blog entry.
  *
  * @since	3.5
  * @author	Mark Lee <mark@stackideas.com>
  */
 public function latest()
 {
     // Fetch the latest blog entry
     $model = $this->getModel('Blog');
     // Get the current active menu's properties.
     $app = JFactory::getApplication();
     $menu = $app->getMenu()->getActive();
     $inclusion = '';
     if (is_object($menu)) {
         $params = EasyBlogHelper::getRegistry($menu->params);
         $inclusion = EasyBlogHelper::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');
 }
开发者ID:Tommar,项目名称:vino2,代码行数:25,代码来源:view.html.php

示例5: simple

 function simple($tmpl = null)
 {
     $app = JFactory::getApplication();
     $doc = JFactory::getDocument();
     $config = EasyBlogHelper::getConfig();
     // @task: Set meta tags for bloggers
     EasyBlogHelper::setMeta(META_ID_GATEGORIES, META_TYPE_VIEW);
     // @task: Set the pathway
     $pathway = $app->getPathway();
     if (!EasyBlogRouter::isCurrentActiveMenu('categories')) {
         $this->setPathway(JText::_('COM_EASYBLOG_CATEGORIES_BREADCRUMB'), '');
     }
     // @task: Get the sorting options.
     $sortConfig = $config->get('layout_sorting_category', 'latest');
     $sort = JRequest::getCmd('sort', $sortConfig);
     // @task: Retrieve models
     $categoriesModel = $this->getModel('Categories');
     $categoryModel = $this->getModel('Category');
     // @task: Test if there's any explicit inclusion of categories
     $menu = $app->getMenu()->getActive();
     $inclusion = '';
     if (is_object($menu) && stristr($menu->link, 'view=categories') !== false) {
         $params = EasyBlogHelper::getRegistry($menu->params);
         $inclusion = EasyBlogHelper::getCategoryInclusion($params->get('inclusion'));
     }
     $data = $categoriesModel->getCategoryTree($sort);
     if (!empty($data)) {
         for ($i = 0; $i < count($data); $i++) {
             $row =& $data[$i];
             // 				$row->childs = null;
             // 				EasyBlogHelper::buildNestedCategories($row->id, $row, false , true );
             $catIds = array();
             $catIds[] = $row->id;
             $row->cnt = $categoryModel->getTotalPostCount($catIds);
             $row->description = $row->get('description');
             // 				$row->rssLink   	= $row->getRSS();
             // 				$row->avatar    	= $row->getAvatar();
         }
     }
     // 		echo '<pre>';
     // 		print_r($data);
     // 		echo '</pre>';
     // 		exit;
     // @task: Set page title
     parent::setPageTitle(JText::_('COM_EASYBLOG_CATEGORIES_PAGE_TITLE'), '0', true);
     $theme = new CodeThemes();
     $theme->set('data', $data);
     $theme->set('sort', $sort);
     echo $theme->fetch('blog.categories.simple.php');
 }
开发者ID:Tommar,项目名称:vino2,代码行数:50,代码来源:view.html.php

示例6: display

 /**
  * Responsible to display the front page of the blog listings
  *
  * @access	public
  */
 function display($tmpl = null)
 {
     // @task: Set meta tags for latest post
     EasyBlogHelper::setMeta(META_ID_LATEST, META_TYPE_VIEW);
     // @task: Set rss links into headers.
     EasyBlogHelper::getHelper('Feeds')->addHeaders('index.php?option=com_easyblog&view=latest');
     $app = JFactory::getApplication();
     $doc = JFactory::getDocument();
     $config = EasyBlogHelper::getConfig();
     $my = JFactory::getUser();
     $acl = EasyBlogACLHelper::getRuleSet();
     // @task: Add a breadcrumb if the current menu that's being accessed is not from the latest view.
     if (!EasyBlogRouter::isCurrentActiveMenu('latest')) {
         $this->setPathway(JText::_('COM_EASYBLOG_LATEST_BREADCRUMB'), '');
     }
     // @task: Get the current active menu's properties.
     $menu = $app->getMenu()->getActive();
     $menu = JFactory::getApplication()->getMenu()->getActive();
     $inclusion = '';
     if (is_object($menu)) {
         $params = EasyBlogHelper::getRegistry();
         $params->load($menu->params);
         $inclusion = EasyBlogHelper::getCategoryInclusion($params->get('inclusion'));
         if ($params->get('includesubcategories', 0) && !empty($inclusion)) {
             $tmpInclusion = array();
             foreach ($inclusion as $includeCatId) {
                 //get the nested categories
                 $category = new stdClass();
                 $category->id = $includeCatId;
                 $category->childs = null;
                 EasyBlogHelper::buildNestedCategories($category->id, $category);
                 $linkage = '';
                 EasyBlogHelper::accessNestedCategories($category, $linkage, '0', '', 'link', ', ');
                 $catIds = array();
                 $catIds[] = $category->id;
                 EasyBlogHelper::accessNestedCategoriesId($category, $catIds);
                 $tmpInclusion = array_merge($tmpInclusion, $catIds);
             }
             $inclusion = $tmpInclusion;
         }
     }
     // @task: Necessary filters
     $sort = JRequest::getCmd('sort', $config->get('layout_postorder'));
     $model = $this->getModel('Blog');
     // @task: Retrieve the list of featured blog posts.
     $featured = $model->getFeaturedBlog($inclusion);
     $excludeIds = array();
     // @task: Add canonical URLs.
     if ($config->get('main_canonical_entry')) {
         $canonicalUrl = EasyBlogRouter::getRoutedURL('index.php?option=com_easyblog&view=latest', false, true, true);
         $doc->addCustomTag('<link rel="canonical" href="' . $canonicalUrl . '"/>');
     }
     // 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 (!$config->get('layout_featured_frontpage')) {
         foreach ($featured as $item) {
             $excludeIds[] = $item->id;
         }
     }
     // @task: Admin might want to display the featured blogs on all pages.
     if (!$config->get('layout_featured_allpages') && (JRequest::getInt('start', 0) != 0 || JRequest::getInt('limitstart', 0) != 0)) {
         $featured = array();
     } else {
         for ($i = 0; $i < count($featured); $i++) {
             $row = $featured[$i];
             $row->featuredImage = EasyBlogHelper::getFeaturedImage($row->intro . $row->content);
         }
         $featured = EasyBlogHelper::formatBlog($featured, true, false, false, false, false);
     }
     // @task: Try to retrieve any categories to be excluded.
     $excludedCategories = $config->get('layout_exclude_categories');
     $excludedCategories = empty($excludedCategories) ? '' : explode(',', $excludedCategories);
     // @task: Fetch the blog entries.
     $data = $model->getBlogsBy('', '', $sort, 0, EBLOG_FILTER_PUBLISHED, null, true, $excludeIds, false, false, true, $excludedCategories, $inclusion);
     $pagination = $model->getPagination();
     $params = $app->getParams('com_easyblog');
     // @task: Perform necessary formatting here.
     $data = EasyBlogHelper::formatBlog($data, true, true, true, true);
     // @task: Update the title of the page if navigating on different pages to avoid Google marking these title's as duplicates.
     $title = EasyBlogHelper::getPageTitle(JText::_('COM_EASYBLOG_LATEST_PAGE_TITLE'));
     // @task: Set the page title
     parent::setPageTitle($title, $pagination, $config->get('main_pagetitle_autoappend'));
     // @task: Get pagination output here.
     $paginationHTML = $pagination->getPagesLinks();
     $theme = new CodeThemes();
     $theme->set('data', $data);
     $theme->set('featured', $featured);
     $theme->set('currentURL', EasyBlogRouter::_('index.php?option=com_easyblog&view=latest', false));
     $theme->set('pagination', $paginationHTML);
     // @task: Send back response to the browser.
     echo $theme->fetch('blog.latest.php');
 }
开发者ID:Tommar,项目名称:vino2,代码行数:97,代码来源:view.html.php


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