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


PHP EB::category方法代码示例

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


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

示例1: getResult

 public function getResult($text, $phrase, $ordering)
 {
     $config = EasyBlogHelper::getConfig();
     $my = JFactory::getUser();
     $db = EasyBlogHelper::db();
     $where = array();
     $where2 = array();
     // used for privacy
     $queryWhere = '';
     $queryExclude = '';
     $queryExcludePending = '';
     $excludeCats = array();
     switch ($phrase) {
         case 'exact':
             $where[] = 'a.`title` LIKE ' . $db->Quote('%' . $db->escape($text, true) . '%', false);
             $where[] = 'a.`content` LIKE ' . $db->Quote('%' . $db->escape($text, true) . '%', false);
             $where[] = 'a.`intro` LIKE ' . $db->Quote('%' . $db->escape($text, true) . '%', false);
             $where2 = '( t.title LIKE ' . $db->Quote('%' . $db->escape($text, true) . '%', false) . ')';
             $where = '(' . implode(') OR (', $where) . ')';
             break;
         case 'all':
         case 'any':
         default:
             $words = explode(' ', $text);
             $wheres = array();
             $where2 = array();
             $wheres2 = array();
             foreach ($words as $word) {
                 $word = $db->Quote('%' . $db->escape($word, true) . '%', false);
                 $where[] = 'a.`title` LIKE ' . $word;
                 $where[] = 'a.`content` LIKE ' . $word;
                 $where[] = 'a.`intro` LIKE ' . $word;
                 $where2[] = 't.title LIKE ' . $word;
                 $wheres[] = implode(' OR ', $where);
                 $wheres2[] = implode(' OR ', $where2);
             }
             $where = '(' . implode($phrase == 'all' ? ') AND (' : ') OR (', $wheres) . ')';
             $where2 = '(' . implode($phrase == 'all' ? ') AND (' : ') OR (', $wheres2) . ')';
             break;
     }
     $isJSGrpPluginInstalled = false;
     $isJSGrpPluginInstalled = JPluginHelper::isEnabled('system', 'groupeasyblog');
     $isEventPluginInstalled = JPluginHelper::isEnabled('system', 'eventeasyblog');
     $isJSInstalled = false;
     // need to check if the site installed jomsocial.
     if (JFile::exists(JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_community' . DIRECTORY_SEPARATOR . 'libraries' . DIRECTORY_SEPARATOR . 'core.php')) {
         $isJSInstalled = true;
     }
     $includeJSGrp = $isJSGrpPluginInstalled && $isJSInstalled ? true : false;
     $includeJSEvent = $isEventPluginInstalled && $isJSInstalled ? true : false;
     //get teamblogs id.
     $query = '';
     // contribution type sql
     $contributor = EB::contributor();
     $contributeSQL = ' AND ( (a.`source_type` = ' . $db->Quote(EASYBLOG_POST_SOURCE_SITEWIDE) . ') ';
     if ($config->get('main_includeteamblogpost')) {
         $contributeSQL .= $contributor::genAccessSQL(EASYBLOG_POST_SOURCE_TEAM, 'a');
     }
     if ($includeJSEvent) {
         $contributeSQL .= $contributor::genAccessSQL(EASYBLOG_POST_SOURCE_JOMSOCIAL_EVENT, 'a');
     }
     if ($includeJSGrp) {
         $contributeSQL .= $contributor::genAccessSQL(EASYBLOG_POST_SOURCE_JOMSOCIAL_GROUP, 'a');
     }
     if (EB::easysocial()->exists()) {
         $contributeSQL .= $contributor::genAccessSQL(EASYBLOG_POST_SOURCE_EASYSOCIAL_GROUP, 'a');
         $contributeSQL .= $contributor::genAccessSQL(EASYBLOG_POST_SOURCE_EASYSOCIAL_EVENT, 'a');
     }
     $contributeSQL .= ')';
     $queryWhere .= $contributeSQL;
     // category access here
     $catLib = EB::category();
     $catAccessSQL = $catLib->genAccessSQL('a.`id`');
     $queryWhere .= ' AND (' . $catAccessSQL . ')';
     $query = 'SELECT a.*, CONCAT(a.`content` , a.`intro`) AS text , "2" as browsernav';
     $query .= ' FROM `#__easyblog_post` as a USE INDEX (`easyblog_post_searchnew`) ';
     $query .= ' WHERE (' . $where;
     $query .= ' OR a.`id` IN( ';
     $query .= '		SELECT tp.`post_id` FROM `#__easyblog_tag` AS t ';
     $query .= '		INNER JOIN `#__easyblog_post_tag` AS tp ON tp.`tag_id` = t.`id` ';
     $query .= '		WHERE ' . $where2;
     $query .= '))';
     $my = JFactory::getUser();
     if ($my->id == 0) {
         //guest should only see public post.
         $query .= ' AND a.`access` = ' . $db->Quote('0');
     }
     //do not show unpublished post
     $query .= ' AND a.`published` = ' . $db->Quote(EASYBLOG_POST_PUBLISHED);
     $query .= ' AND a.`state` = ' . $db->Quote(EASYBLOG_POST_NORMAL);
     $query .= $queryWhere;
     switch ($ordering) {
         case 'oldest':
             $query .= ' ORDER BY a.`created` ASC';
             break;
         case 'newest':
             $query .= ' ORDER BY a.`created` DESC';
             break;
     }
     $db->setQuery($query);
//.........这里部分代码省略.........
开发者ID:knigherrant,项目名称:decopatio,代码行数:101,代码来源:easyblog.php

示例2: buildNestedCategories

 public static function buildNestedCategories($parentId, &$parent, $ignorePrivate = false, $isPublishedOnly = false, $isWrite = false, $exclusion = array())
 {
     $my = JFactory::getUser();
     $childs = array();
     //lets try to get from cache if there is any
     if (EB::cache()->exists($parentId, 'cats')) {
         $data = EB::cache()->get($parentId, 'cats');
         if (isset($data['child'])) {
             $childs = $data['child'];
         } else {
             return false;
         }
     } else {
         $catModel = EB::model('Categories');
         $childs = $catModel->getChildCategories($parentId, $isPublishedOnly, $isWrite, $exclusion);
     }
     if (!$childs) {
         return false;
     }
     $items = array();
     foreach ($childs as $child) {
         $items[$child->id] = $child;
     }
     $parent->childs = array();
     $catLib = EB::category();
     $catLib::addChilds($parent, $items);
     return false;
 }
开发者ID:knigherrant,项目名称:decopatio,代码行数:28,代码来源:easyblog.php

示例3: getTaggedBlogs


//.........这里部分代码省略.........
         $contributeSQL .= $contributor::genAccessSQL(EASYBLOG_POST_SOURCE_EASYSOCIAL_EVENT, 'b');
     }
     $contributeSQL .= ')';
     //get teamblogs id.
     $query = 'SELECT b.*';
     $query .= ' FROM ' . $db->nameQuote('#__easyblog_post_tag') . ' AS a ';
     $query .= ' INNER JOIN ' . $db->nameQuote('#__easyblog_post') . ' AS b ';
     $query .= ' ON a.post_id=b.id ';
     $query .= ' WHERE a.' . $db->quoteName('tag_id') . ' = ' . $db->Quote($tagId);
     $query .= ' AND b.' . $db->quoteName('published') . ' = ' . $db->Quote(EASYBLOG_POST_PUBLISHED);
     $query .= ' AND b.' . $db->quoteName('state') . '=' . $db->Quote(EASYBLOG_POST_NORMAL);
     $query .= $contributeSQL;
     // @rule: When language filter is enabled, we need to detect the appropriate contents
     $filterLanguage = JFactory::getApplication()->getLanguageFilter();
     if ($filterLanguage) {
         $query .= EBR::getLanguageQuery('AND', 'b.language');
     }
     $file = JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_community' . DIRECTORY_SEPARATOR . 'libraries' . DIRECTORY_SEPARATOR . 'core.php';
     //blog privacy setting
     if ($config->get('main_jomsocial_privacy') && JFile::exists($file) && !EasyBlogHelper::isSiteAdmin()) {
         require_once $file;
         $jsFriends = CFactory::getModel('Friends');
         $friends = $jsFriends->getFriendIds($my->id);
         array_push($friends, $my->id);
         // Insert query here.
         $query .= ' AND (';
         $query .= ' (b.`access`= 0 ) OR';
         $query .= ' ( (b.`access` = 20) AND (' . $db->Quote($my->id) . ' > 0 ) ) OR';
         if (empty($friends)) {
             $query .= ' ( (b.`access` = 30) AND ( 1 = 2 ) ) OR';
         } else {
             $query .= ' ( (b.`access` = 30) AND ( b.' . $db->nameQuote('created_by') . ' IN (' . implode(',', $friends) . ') ) ) OR';
         }
         $query .= ' ( (b.`access` = 40) AND ( b.' . $db->nameQuote('created_by') . '=' . $my->id . ') )';
         $query .= ' )';
     } else {
         if ($my->id == 0) {
             $query .= ' AND b.`access` = ' . $db->Quote(BLOG_PRIVACY_PUBLIC);
         }
     }
     if ($isBloggerMode !== false) {
         $query .= ' AND b.`created_by` = ' . $db->Quote($isBloggerMode);
     }
     $includeCats = array();
     $includeCatIds = trim($includeCatIds);
     if (!empty($includeCatIds)) {
         $includeCats = explode(',', $includeCatIds);
         if (!empty($includeCats)) {
             $catAccess['include'] = $includeCats;
         }
     }
     // category access
     $catLib = EB::category();
     $catAccessSQL = $catLib->genAccessSQL('b.`id`', $catAccess);
     $query .= ' AND (' . $catAccessSQL . ')';
     $sort = $config->get('layout_postorder', 'latest');
     $defaultSorting = $config->get('layout_postsort', 'desc');
     if ($sorting) {
         $defaultSorting = $sorting;
     }
     switch ($sort) {
         case 'latest':
             $queryOrder = ' ORDER BY b.`created` ' . $defaultSorting;
             break;
         case 'published':
             $queryOrder = ' ORDER BY b.`publish_up` ' . $defaultSorting;
             break;
         case 'popular':
             $queryOrder = ' ORDER BY b.`hits` ' . $defaultSorting;
             break;
         case 'active':
             $queryOrder = ' ORDER BY b.`publish_down` ' . $defaultSorting;
             break;
         case 'alphabet':
             $queryOrder = ' ORDER BY b.`title` ' . $defaultSorting;
             break;
         case 'modified':
             $queryOrder = ' ORDER BY b.`modified` ' . $defaultSorting;
             break;
         case 'random':
             $queryOrder = ' ORDER BY RAND() ';
             break;
         default:
             break;
     }
     $query .= $queryOrder;
     //total tag's post sql
     $totalQuery = 'SELECT COUNT(1) FROM (';
     $totalQuery .= $query;
     $totalQuery .= ') as x';
     $query .= ' LIMIT ' . $limitstart . ',' . $limit;
     $db->setQuery($query);
     $rows = $db->loadObjectList();
     $db->setQuery($totalQuery);
     $db->loadResult();
     $this->_total = $db->loadResult();
     jimport('joomla.html.pagination');
     $this->_pagination = EB::pagination($this->_total, $limitstart, $limit);
     return $rows;
 }
开发者ID:knigherrant,项目名称:decopatio,代码行数:101,代码来源:blog.php

示例4: getPosts

 /**
  * Retrieve a list of blog posts from a specific list of categories
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return
  */
 public function getPosts($categories, $limit = null)
 {
     $db = EB::db();
     $my = JFactory::getUser();
     $config = EB::config();
     // Determines if this is currently on blogger mode
     $isBloggerMode = EasyBlogRouter::isBloggerMode();
     // use in generating category access sql
     $catAccess = array();
     $catAccess['include'] = $categories;
     $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 ( (a.`source_type` = ' . $db->Quote(EASYBLOG_POST_SOURCE_SITEWIDE) . ') ';
     if ($config->get('main_includeteamblogpost')) {
         $contributeSQL .= $contributor::genAccessSQL(EASYBLOG_POST_SOURCE_TEAM, 'a');
     }
     if ($includeJSEvent) {
         $contributeSQL .= $contributor::genAccessSQL(EASYBLOG_POST_SOURCE_JOMSOCIAL_EVENT, 'a');
     }
     if ($includeJSGrp) {
         $contributeSQL .= $contributor::genAccessSQL(EASYBLOG_POST_SOURCE_JOMSOCIAL_GROUP, 'a');
     }
     // Test if easysocial exists on the site
     if (EB::easysocial()->exists()) {
         $contributeSQL .= $contributor::genAccessSQL(EASYBLOG_POST_SOURCE_EASYSOCIAL_GROUP, 'a');
         $contributeSQL .= $contributor::genAccessSQL(EASYBLOG_POST_SOURCE_EASYSOCIAL_EVENT, 'a');
     }
     $contributeSQL .= ')';
     $query = array();
     $query[] = 'SELECT a.* FROM ' . $db->quoteName('#__easyblog_post') . ' AS a';
     // Build the WHERE clauses
     $query[] = 'WHERE a.' . $db->quoteName('published') . '=' . $db->Quote(EASYBLOG_POST_PUBLISHED);
     $query[] = 'AND a.' . $db->quoteName('state') . '=' . $db->Quote(EASYBLOG_POST_NORMAL);
     // If this is on blogger mode, fetch items created by the current author only
     if ($isBloggerMode !== false) {
         $query[] = ' AND a.' . $db->quoteName('created_by') . '=' . $db->Quote($isBloggerMode);
     } else {
         // Get the author id based on the category menu
         $authorId = EB::getCategoryMenuBloggerId();
         if ($authorId) {
             $query[] = ' AND a.' . $db->quoteName('created_by') . '=' . $db->Quote($authorId);
         }
     }
     //sql for blog contribution
     $query[] = $contributeSQL;
     // sql for category access
     $catLib = EB::category();
     $catAccessSQL = $catLib->genAccessSQL('a.`id`', $catAccess);
     $query[] = 'AND (' . $catAccessSQL . ')';
     // If user is a guest, ensure that they can really view the blog post
     if ($this->my->guest) {
         $query[] = 'AND a.' . $db->quoteName('access') . '=' . $db->Quote(BLOG_PRIVACY_PUBLIC);
     }
     // Ensure that the blog posts is available site wide
     // $query[] = 'AND a.' . $db->quoteName('source_id') . '=' . $db->Quote('0');
     // Filter by language
     $language = EB::getCurrentLanguage();
     if ($language) {
         $query[] = 'AND (a.' . $db->quoteName('language') . '=' . $db->Quote($language) . ' OR a.' . $db->quoteName('language') . '=' . $db->Quote('*') . ' OR a.' . $db->quoteName('language') . '=' . $db->Quote('') . ')';
     }
     // Ordering options
     $ordering = $config->get('layout_postsort', 'DESC');
     // Order the posts
     $query[] = 'ORDER BY a.' . $db->quoteName('created') . ' ' . $ordering;
     // Set the pagination
     if (!is_null($limit)) {
         // Glue back the sql queries into a single string.
         $queryCount = implode(' ', $query);
         $queryCount = str_ireplace('SELECT a.*', 'SELECT COUNT(1)', $queryCount);
         $db->setQuery($queryCount);
         $count = $db->loadResult();
         $limit = $limit == 0 ? $this->getState('limit') : $limit;
         $limitstart = $this->input->get('limitstart', $this->getState('limitstart'), 'int');
         // Set the limit
         $query[] = 'LIMIT ' . $limitstart . ',' . $limit;
         $this->_pagination = EB::pagination($count, $limitstart, $limit);
     }
     // Glue back the sql queries into a single string.
     $query = implode(' ', $query);
     // Debug
     // echo str_ireplace('#__', 'jos_', $query);exit;
     $db->setQuery($query);
//.........这里部分代码省略.........
开发者ID:knigherrant,项目名称:decopatio,代码行数:101,代码来源:category.php

示例5: getArchivePostByMonth

 /**
  * Retrieves a list of blog posts by specific month
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return
  */
 public function getArchivePostByMonth($month = '', $year = '', $showPrivate = false)
 {
     $db = EB::db();
     $user = JFactory::getUser();
     $config = EB::config();
     // used for privacy
     $queryWhere = '';
     $queryExclude = '';
     $queryExcludePending = '';
     $excludeCats = array();
     if ($user->id == 0) {
         $showPrivate = false;
     }
     // Blog privacy setting
     // @integrations: jomsocial privacy
     $privateBlog = '';
     if (EB::easysocial()->exists() && $config->get('integrations_easysocial_privacy') && !EB::isSiteAdmin()) {
         $esPrivacyQuery = EB::easysocial()->buildPrivacyQuery('a');
         $privateBlog .= $esPrivacyQuery;
     } else {
         if ($config->get('main_jomsocial_privacy') && EB::jomsocial()->exists() && !EB::isSiteAdmin()) {
             $friendsModel = CFactory::getModel('Friends');
             $friends = $friendsModel->getFriendIds($user->id);
             // Insert query here.
             $privateBlog .= ' AND (';
             $privateBlog .= ' (a.`access`= 0 ) OR';
             $privateBlog .= ' ( (a.`access` = 20) AND (' . $db->Quote($user->id) . ' > 0 ) ) OR';
             if (!$friends) {
                 $privateBlog .= ' ( (a.`access` = 30) AND ( 1 = 2 ) ) OR';
             } else {
                 $privateBlog .= ' ( (a.`access` = 30) AND ( a.' . $db->nameQuote('created_by') . ' IN (' . implode(',', $friends) . ') ) ) OR';
             }
             $privateBlog .= ' ( (a.`access` = 40) AND ( a.' . $db->nameQuote('created_by') . '=' . $user->id . ') )';
             $privateBlog .= ' )';
         } else {
             if ($user->id == 0) {
                 $privateBlog .= ' AND a.`access` = ' . $db->Quote(0);
             }
         }
     }
     // Join the query ?
     $privateBlog = $showPrivate ? '' : $privateBlog;
     $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 ( (a.`source_type` = ' . $db->Quote(EASYBLOG_POST_SOURCE_SITEWIDE) . ') ';
     if ($config->get('main_includeteamblogpost')) {
         $contributeSQL .= $contributor::genAccessSQL(EASYBLOG_POST_SOURCE_TEAM, 'a');
     }
     if ($includeJSEvent) {
         $contributeSQL .= $contributor::genAccessSQL(EASYBLOG_POST_SOURCE_JOMSOCIAL_EVENT, 'a');
     }
     if ($includeJSGrp) {
         $contributeSQL .= $contributor::genAccessSQL(EASYBLOG_POST_SOURCE_JOMSOCIAL_GROUP, 'a');
     }
     if (EB::easysocial()->exists()) {
         $contributeSQL .= $contributor::genAccessSQL(EASYBLOG_POST_SOURCE_EASYSOCIAL_GROUP, 'a');
         $contributeSQL .= $contributor::genAccessSQL(EASYBLOG_POST_SOURCE_EASYSOCIAL_EVENT, 'a');
     }
     $contributeSQL .= ')';
     $queryWhere .= $contributeSQL;
     //get teamblogs id.
     $query = '';
     $extraSQL = '';
     // If this is on blogger mode, we need to only pick items from the blogger.
     $blogger = EBR::isBloggerMode();
     if ($blogger !== false) {
         $extraSQL = ' AND a.`created_by` = ' . $db->Quote($blogger);
     }
     $tzoffset = EB::date()->getOffSet(true);
     $query = 'SELECT a.*, DAY( DATE_ADD(a.`created`, INTERVAL ' . $tzoffset . ' HOUR) ) AS day,';
     $query .= ' MONTH( DATE_ADD(a.`created`, INTERVAL ' . $tzoffset . ' HOUR) ) AS month,';
     $query .= ' YEAR( DATE_ADD(a.`created`, INTERVAL ' . $tzoffset . ' HOUR) ) AS year ';
     $query .= ' FROM ' . $db->nameQuote('#__easyblog_post') . ' as a';
     $query .= ' WHERE a.`published` = ' . $db->Quote(EASYBLOG_POST_PUBLISHED) . ' ';
     $query .= ' AND a.' . $db->quoteName('state') . ' = ' . $db->Quote(EASYBLOG_POST_NORMAL) . ' ';
     $query .= $privateBlog . ' ';
     $query .= ' AND (a.`created` > ' . $db->Quote($year . '-' . $month . '-01 00:00:00') . ' AND a.`created` < ' . $db->Quote($year . '-' . $month . '-31 23:59:59') . ') ';
     // If do not display private posts, we need to append additional queries here.
     if (!$showPrivate) {
         // sql for category access
         $catLib = EB::category();
         $catAccessSQL = $catLib->genAccessSQL('a.`id`');
//.........这里部分代码省略.........
开发者ID:knigherrant,项目名称:decopatio,代码行数:101,代码来源:archive.php

示例6: getMostCommentedPost

 public static function getMostCommentedPost(&$params)
 {
     $mainframe = JFactory::getApplication();
     $db = EB::db();
     $my = JFactory::getUser();
     $config = EB::config();
     $count = (int) trim($params->get('count', 0));
     $categories = $params->get('catid');
     $catAccess = array();
     // Get the category ID if any from the module setting
     if (!empty($categories)) {
         $categories = explode(',', $categories);
     }
     // Respect inclusion categories
     if (!empty($categories)) {
         if (!is_array($categories)) {
             $categories = array($categories);
         }
         $catAccess['include'] = $categories;
     }
     $showprivate = $params->get('showprivate', true);
     $showcomment = $params->get('showlatestcomment', true);
     $query = 'SELECT a.*, count(b.' . $db->quoteName('id') . ') as ' . $db->quoteName('comment_count');
     if ($showcomment) {
         $query .= ', c.' . $db->quoteName('id') . ' as ' . $db->quoteName('comment_id') . ', c.' . $db->quoteName('comment') . ', c.' . $db->quoteName('created_by') . ' as ' . $db->quoteName('commentor') . ', c.' . $db->quoteName('title') . ' as ' . $db->quoteName('comment_title') . ', c.' . $db->quoteName('name') . ' as ' . $db->quoteName('commentor_name');
     }
     $query .= ' FROM ' . $db->quoteName('#__easyblog_post') . ' AS a';
     $query .= '  LEFT JOIN ' . $db->quoteName('#__easyblog_comment') . ' AS b ON a.' . $db->quoteName('id') . ' = b.' . $db->quoteName('post_id');
     if ($showcomment) {
         $query .= '  LEFT JOIN ' . $db->quoteName('#__easyblog_comment') . ' AS c ON a.' . $db->quoteName('id') . ' = c.' . $db->quoteName('post_id');
         $query .= '    AND c.' . $db->quoteName('id') . ' = (SELECT MAX(d.' . $db->quoteName('id') . ') FROM ' . $db->quoteName('#__easyblog_comment') . ' AS d WHERE c.' . $db->quoteName('post_id') . ' = d.' . $db->quoteName('post_id') . ')';
     }
     $query .= ' WHERE a.' . $db->quoteName('published') . ' = ' . $db->Quote(EASYBLOG_POST_PUBLISHED);
     $query .= ' AND a.' . $db->quoteName('state') . ' = ' . $db->Quote(EASYBLOG_POST_NORMAL);
     if (!$showprivate) {
         $query .= ' AND a.' . $db->quoteName('access') . ' = ' . $db->Quote('0');
     }
     // get teamblogs id.
     // contribution type sql
     $contributor = EB::contributor();
     $contributeSQL = ' AND ( (a.`source_type` = ' . $db->Quote(EASYBLOG_POST_SOURCE_SITEWIDE) . ') ';
     if ($config->get('main_includeteamblogpost')) {
         $contributeSQL .= $contributor::genAccessSQL(EASYBLOG_POST_SOURCE_TEAM, 'a');
     }
     $contributeSQL .= ')';
     $query .= $contributeSQL;
     // category access here
     $catLib = EB::category();
     $catAccessSQL = $catLib->genAccessSQL('a.`id`', $catAccess);
     $query .= ' AND (' . $catAccessSQL . ')';
     $query .= ' GROUP BY a.' . $db->quoteName('id');
     $query .= ' HAVING (' . $db->quoteName('comment_count') . ' > 0)';
     $query .= ' ORDER BY ' . $db->quoteName('comment_count') . ' DESC';
     if ($count > 0) {
         $query .= ' LIMIT ' . $count;
     }
     $db->setQuery($query);
     $posts = $db->loadObjectList();
     // process item
     $posts = EB::modules()->processItems($posts, $params);
     return $posts;
 }
开发者ID:knigherrant,项目名称:decopatio,代码行数:62,代码来源:helper.php

示例7: getCategoryTree

 public function getCategoryTree($sort = 'latest')
 {
     $db = EB::db();
     $my = JFactory::getUser();
     $config = EasyBlogHelper::getConfig();
     $queryExclude = '';
     $excludeCats = array();
     $query = 'SELECT a.*, ';
     $query .= ' ( SELECT COUNT(id) FROM ' . $db->nameQuote('#__easyblog_category');
     $query .= ' WHERE lft < a.lft AND rgt > a.rgt AND a.lft != ' . $db->Quote(0) . ' ) AS depth ';
     $query .= ' FROM ' . $db->nameQuote('#__easyblog_category') . ' AS a ';
     $query .= ' WHERE a.`published`=' . $db->Quote('1');
     // category access here
     $catLib = EB::category();
     $catAccess = $catLib::genCatAccessSQL('a.`private`', 'a.`id`');
     $query .= ' AND (' . $catAccess . ')';
     switch ($sort) {
         case 'ordering':
             $query .= ' ORDER BY `lft`, `ordering`';
             break;
         case 'alphabet':
             $query .= ' ORDER BY `title`, `lft`';
             break;
         case 'latest':
         default:
             $query .= ' ORDER BY `rgt` DESC';
             break;
     }
     // echo $query;
     $db->setQuery($query);
     $rows = $db->loadObjectList();
     $total = count($rows);
     $categories = array();
     for ($i = 0; $i < $total; $i++) {
         $category = EB::table('Category');
         $category->bind($rows[$i]);
         $category->depth = $rows[$i]->depth;
         $categories[] = $category;
     }
     return $categories;
 }
开发者ID:BetterBetterBetter,项目名称:B3App,代码行数:41,代码来源:categories.php

示例8: preloadPostCount

 public function preloadPostCount($teamIds)
 {
     $db = EB::db();
     $query = 'SELECT a.`source_id`, COUNT(a.`source_id`) as `cnt` FROM ' . $db->qn('#__easyblog_post') . ' AS a';
     $query .= ' where a.' . $db->qn('published') . '=' . $db->Quote(EASYBLOG_POST_PUBLISHED);
     $query .= ' and a.' . $db->qn('state') . '=' . $db->Quote(EASYBLOG_POST_NORMAL);
     $query .= ' and a.' . $db->qn('source_type') . ' = ' . $db->Quote(EASYBLOG_POST_SOURCE_TEAM);
     $query .= ' and a.' . $db->qn('source_id') . ' IN (' . implode(',', $teamIds) . ')';
     // category access here
     $catLib = EB::category();
     $catAccessSQL = $catLib->genAccessSQL('a.`id`');
     $query .= ' AND (' . $catAccessSQL . ')';
     $query .= ' group by a.`source_id`';
     $query .= ' order by null';
     $db->setQuery($query);
     $results = $db->loadObjectList();
     $counts = array();
     if ($results) {
         foreach ($results as $item) {
             $counts[$item->source_id] = $item->cnt;
         }
     }
     return $counts;
 }
开发者ID:knigherrant,项目名称:decopatio,代码行数:24,代码来源:teamblogs.php

示例9: _buildQuery

 public function _buildQuery()
 {
     $db = EB::db();
     $my = JFactory::getUser();
     $config = EasyBlogHelper::getConfig();
     // used for privacy
     $queryWhere = '';
     $queryExclude = '';
     $queryExcludePending = '';
     $excludeCats = array();
     $isBloggerMode = EasyBlogRouter::isBloggerMode();
     $where = array();
     $where2 = array();
     $text = JRequest::getVar('query');
     $words = explode(' ', $text);
     $wheres = array();
     foreach ($words as $word) {
         $word = $db->Quote('%' . $db->getEscaped($word, true) . '%', false);
         $where[] = 'a.`title` LIKE ' . $word;
         $where[] = 'a.`content` LIKE ' . $word;
         $where[] = 'a.`intro` LIKE ' . $word;
         $where2[] = 't.title LIKE ' . $word;
         $wheres2[] = implode(' OR ', $where2);
         $wheres[] = implode(' OR ', $where);
     }
     $where = '(' . implode(') OR (', $wheres) . ')';
     $where2 = '(' . implode(') OR (', $wheres2) . ')';
     $isJSGrpPluginInstalled = false;
     $isJSGrpPluginInstalled = JPluginHelper::isEnabled('system', 'groupeasyblog');
     $isEventPluginInstalled = JPluginHelper::isEnabled('system', 'eventeasyblog');
     $isJSInstalled = false;
     // need to check if the site installed jomsocial.
     if (JFile::exists(JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_community' . DIRECTORY_SEPARATOR . 'libraries' . DIRECTORY_SEPARATOR . 'core.php')) {
         $isJSInstalled = true;
     }
     $includeJSGrp = $isJSGrpPluginInstalled && $isJSInstalled ? true : false;
     $includeJSEvent = $isEventPluginInstalled && $isJSInstalled ? true : false;
     $query = '';
     // contribution type sql
     $contributor = EB::contributor();
     $contributeSQL = ' AND ( (a.`source_type` = ' . $db->Quote(EASYBLOG_POST_SOURCE_SITEWIDE) . ') ';
     if ($config->get('main_includeteamblogpost')) {
         $contributeSQL .= $contributor::genAccessSQL(EASYBLOG_POST_SOURCE_TEAM, 'a');
     }
     if ($includeJSEvent) {
         $contributeSQL .= $contributor::genAccessSQL(EASYBLOG_POST_SOURCE_JOMSOCIAL_EVENT, 'a');
     }
     if ($includeJSGrp) {
         $contributeSQL .= $contributor::genAccessSQL(EASYBLOG_POST_SOURCE_JOMSOCIAL_GROUP, 'a');
     }
     if (EB::easysocial()->exists()) {
         $contributeSQL .= $contributor::genAccessSQL(EASYBLOG_POST_SOURCE_EASYSOCIAL_GROUP, 'a');
         $contributeSQL .= $contributor::genAccessSQL(EASYBLOG_POST_SOURCE_EASYSOCIAL_EVENT, 'a');
     }
     $contributeSQL .= ')';
     $queryWhere .= $contributeSQL;
     // category access here
     $catLib = EB::category();
     $catAccessSQL = $catLib->genAccessSQL('a.`id`');
     $queryWhere .= ' AND (' . $catAccessSQL . ')';
     if ($isBloggerMode) {
         $queryWhere .= ' AND a.`created_by`=' . $db->Quote($isBloggerMode);
     }
     $query = 'SELECT a.*, CONCAT(a.`content` , a.`intro`) AS text';
     $query .= ' FROM `#__easyblog_post` as a USE INDEX (`easyblog_post_searchnew`)';
     // Always inner join with jos_users and a.created_by so that only valid blogs are loaded
     $query .= ' INNER JOIN ' . $db->nameQuote('#__users') . ' AS c ON a.`created_by`=c.`id`';
     $query .= ' WHERE (' . $where;
     $query .= ' OR a.`id` IN( ';
     $query .= '		SELECT tp.`post_id` FROM `#__easyblog_tag` AS t ';
     $query .= '		INNER JOIN `#__easyblog_post_tag` AS tp ON tp.`tag_id` = t.`id` ';
     $query .= '		WHERE ' . $where2;
     $query .= ') )';
     //blog privacy setting
     // @integrations: jomsocial privacy
     $privateBlog = '';
     $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');
         $privateBlog .= $esPrivacyQuery;
     } else {
         if ($config->get('main_jomsocial_privacy') && JFile::exists($file) && !EasyBlogHelper::isSiteAdmin()) {
             require_once $file;
             $jsFriends = CFactory::getModel('Friends');
             $friends = $jsFriends->getFriendIds($my->id);
             // Insert query here.
             $privateBlog .= ' AND (';
             $privateBlog .= ' (a.`access`= 0 ) OR';
             $privateBlog .= ' ( (a.`access` = 20) AND (' . $db->Quote($my->id) . ' > 0 ) ) OR';
             if (empty($friends)) {
                 $privateBlog .= ' ( (a.`access` = 30) AND ( 1 = 2 ) ) OR';
             } else {
                 $privateBlog .= ' ( (a.`access` = 30) AND ( a.' . $db->nameQuote('created_by') . ' IN (' . implode(',', $friends) . ') ) ) OR';
             }
             $privateBlog .= ' ( (a.`access` = 40) AND ( a.' . $db->nameQuote('created_by') . '=' . $my->id . ') )';
             $privateBlog .= ' )';
         } else {
             if ($my->id == 0) {
                 $privateBlog .= ' AND a.`access` = ' . $db->Quote(0);
//.........这里部分代码省略.........
开发者ID:knigherrant,项目名称:decopatio,代码行数:101,代码来源:search.php

示例10: getTagPrivateBlogCount

 /**
  * *********************************************************************
  * These part of codes will used in tag clod tags.
  * *********************************************************************
  */
 public function getTagPrivateBlogCount($tagId)
 {
     $db = EB::db();
     $isBloggerMode = EasyBlogRouter::isBloggerMode();
     $query = 'select count(1) from `#__easyblog_post` as a';
     $query .= '  inner join `#__easyblog_post_tag` as b';
     $query .= '    on a.`id` = b.`post_id`';
     $query .= '    and b.`tag_id` = ' . $db->Quote($tagId);
     $query .= '  where a.`access` = ' . $db->Quote(BLOG_PRIVACY_PRIVATE);
     if ($isBloggerMode !== false) {
         $query .= '  and a.`created_by` = ' . $db->Quote($isBloggerMode);
     }
     // category access here
     $catLib = EB::category();
     $catAccessSQL = $catLib->genAccessSQL('a.`id`');
     $query .= ' AND (' . $catAccessSQL . ')';
     $db->setQuery($query);
     $result = $db->loadResult();
     return empty($result) ? '0' : $result;
 }
开发者ID:knigherrant,项目名称:decopatio,代码行数:25,代码来源:tags.php


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