本文整理汇总了PHP中EBR::getLanguageQuery方法的典型用法代码示例。如果您正苦于以下问题:PHP EBR::getLanguageQuery方法的具体用法?PHP EBR::getLanguageQuery怎么用?PHP EBR::getLanguageQuery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EBR
的用法示例。
在下文中一共展示了EBR::getLanguageQuery方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _buildQueryLanguage
public function _buildQueryLanguage()
{
$mainframe = JFactory::getApplication();
$my = JFactory::getUser();
$db = EB::db();
$languageQ = '';
// @rule: When language filter is enabled, we need to detect the appropriate contents
$filterLanguage = JFactory::getApplication()->getLanguageFilter();
if ($filterLanguage) {
$languageQ .= EBR::getLanguageQuery('AND', 'a.language');
}
return $languageQ;
}
示例2: getPostNavigation
/**
* Retrieves the next post in line
*
* @since 5.0
* @access public
* @param string
* @return
*/
public function getPostNavigation(EasyBlogPost $post, $navigationType)
{
$db = EB::db();
$my = JFactory::getUser();
$config = EB::config();
$keys = array('prev', 'next');
$nav = new stdClass();
// Get the active menu
$active = JFactory::getApplication()->getMenu()->getActive();
$catAccess = array();
$queryInclude = '';
$teamId = $post->getTeamAssociation();
$author = $post->getAuthor();
// // If there is an active menu for EasyBlog, check if there's any filtering by categories
// if ($active) {
// $cats = EB::getCategoryInclusion($active->params->get('inclusion'));
// if ($cats && !is_array($cats)) {
// $cats = array($cats);
// }
// $catAccess['include'] = $cats;
// }
// // sql for category access
// $catLib = EB::category();
// $catAccessSQL = $catLib->genAccessSQL( 'a.`id`', $catAccess);
foreach ($keys as $key) {
$query = array();
$query[] = 'SELECT a.`id`, a.`title`';
$query[] = ' FROM `#__easyblog_post` AS `a`';
$query[] = ' WHERE a.`published` = ' . $db->Quote(EASYBLOG_POST_PUBLISHED);
$query[] = ' AND a.`state` = ' . $db->Quote(EASYBLOG_POST_NORMAL);
// EasySocial integrations
$query[] = EB::easysocial()->buildPrivacyQuery('a');
// Jomsocial integrations
$query[] = EB::jomsocial()->buildPrivacyQuery();
// Blog privacy settings
if ($my->guest) {
$query[] = 'AND a.' . $db->qn('access') . '=' . $db->Quote(BLOG_PRIVACY_PUBLIC);
}
// Exclude private categories
// $query[] = 'AND (' . $catAccessSQL . ')';
// If the current menu is blogger mode, we need to respect this by only loading author related items
$isBloggerMode = EBR::isBloggerMode();
if ($isBloggerMode !== false) {
$query[] = 'AND a.' . $db->qn('created_by') . '=' . $db->Quote($isBloggerMode);
$query[] = 'AND a.' . $db->qn('source_type') . '=' . $db->Quote(EASYBLOG_POST_SOURCE_SITEWIDE);
}
// Filter the next / previous link by team
if ($navigationType == 'team' && $teamId) {
$query[] = 'AND (a.' . $db->qn('source_type') . '=' . $db->Quote(EASYBLOG_POST_SOURCE_TEAM) . ' AND a.' . $db->qn('source_id') . '=' . $db->Quote($teamId) . ')';
}
// Filter the next / previous by author
if ($navigationType == 'author') {
$query[] = 'AND a.' . $db->qn('created_by') . '=' . $db->Quote($author->id);
$query[] = 'AND a.' . $db->qn('source_type') . '=' . $db->Quote(EASYBLOG_POST_SOURCE_SITEWIDE);
}
// Filter the next / previous post items from site wide
if ($navigationType == 'site') {
$query[] = 'AND a.' . $db->qn('source_type') . '=' . $db->Quote(EASYBLOG_POST_SOURCE_SITEWIDE);
}
// When language filter is enabled, we need to detect the appropriate contents
$filterLanguage = JFactory::getApplication()->getLanguageFilter();
if ($filterLanguage) {
$query[] = EBR::getLanguageQuery('AND', 'a.language');
}
if ($key == 'prev') {
$query[] = ' AND a.`created` < ' . $db->Quote($post->created);
$query[] = ' ORDER BY a.`created` DESC';
}
if ($key == 'next') {
$query[] = ' AND a.`created` > ' . $db->Quote($post->created);
$query[] = ' ORDER BY a.`created` ASC';
}
$query[] = 'LIMIT 1';
$query = implode(' ', $query);
$db->setQuery($query);
$result = $db->loadObject();
$nav->{$key} = $result;
}
return $nav;
}
示例3: getArchivePostCounts
public function getArchivePostCounts($yearStart = '', $yearStop = '0', $excludeCats = '', $includeCats = '', $filter = '', $filterId = '')
{
$db = EB::db();
$user = JFactory::getUser();
$config = EB::config();
$catAccess = array();
if (empty($yearStart)) {
$year = $this->getArchiveMinMaxYear();
$yearStart = $year['maxyear'];
}
if (!empty($yearStop)) {
$fr = $yearStart - 1;
$to = $yearStop + 1;
} else {
$fr = $yearStart - 1;
$to = $yearStart + 1;
}
if (!is_array($excludeCats) && !empty($excludeCats)) {
$excludeCats = explode(',', $excludeCats);
} else {
if (!is_array($excludeCats) && empty($excludeCats)) {
$excludeCats = array();
}
}
if (!is_array($includeCats) && !empty($includeCats)) {
$includeCats = explode(',', $includeCats);
} else {
if (!is_array($includeCats) && empty($includeCats)) {
$includeCats = array();
}
}
$includeCats = array_diff($includeCats, $excludeCats);
if (!empty($excludeCats) && count($excludeCats) >= 1) {
$catAccess['exclude'] = $excludeCats;
}
if (!empty($includeCats) && count($includeCats) >= 1) {
$catAccess['include'] = $includeCats;
}
//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($user->id);
// Insert query here.
$privateBlog .= ' AND (';
$privateBlog .= ' (a.`access`= 0 ) OR';
$privateBlog .= ' ( (a.`access` = 20) AND (' . $db->Quote($user->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') . '=' . $user->id . ') )';
$privateBlog .= ' )';
} else {
if ($user->id == 0) {
$privateBlog .= ' AND a.`access` = ' . $db->Quote(0);
}
}
}
$joinTeam = '';
$FilterSQL = '';
if ($filter != '') {
$FilterSQL = '';
switch ($filter) {
case 'blogger':
$FilterSQL = 'AND a.' . $db->nameQuote('created_by') . ' = ' . $db->Quote($filterId);
break;
case 'team':
$FilterSQL = 'AND (a.' . $db->quoteName('source_type') . ' = ' . $db->Quote(EASYBLOG_POST_SOURCE_TEAM) . ' and a.' . $db->quoteName('source_id') . ' = ' . $db->Quote($filterId) . ')';
break;
default:
break;
}
}
$languageFilterSQL = '';
// @rule: When language filter is enabled, we need to detect the appropriate contents
$filterLanguage = JFactory::getApplication()->getLanguageFilter();
if ($filterLanguage) {
$languageFilterSQL .= EBR::getLanguageQuery('AND', 'a.language');
}
$catLib = EB::category();
$catAccessSQL = $catLib->genAccessSQL('a.`id`', $catAccess);
$query = 'SELECT COUNT(1) as count, MONTH( a.' . $db->nameQuote('created') . ' ) AS month, YEAR( a.' . $db->nameQuote('created') . ' ) AS year ' . 'FROM ' . $db->nameQuote('#__easyblog_post') . ' AS a ' . $joinTeam . ' ' . 'WHERE a.' . $db->nameQuote('published') . '=' . $db->Quote(EASYBLOG_POST_PUBLISHED) . ' ' . 'AND a.' . $db->nameQuote('state') . '=' . $db->Quote(EASYBLOG_POST_NORMAL) . ' ' . $privateBlog . ' ' . $languageFilterSQL . ' ' . $FilterSQL . ' ' . 'AND ( a.' . $db->nameQuote('created') . ' > ' . $db->Quote($fr . '-12-31 23:59:59') . ' AND a.' . $db->nameQuote('created') . ' < ' . $db->Quote($to . '-01-01 00:00:00') . ') ' . 'AND (' . $catAccessSQL . ') ' . 'GROUP BY year, month DESC ' . 'ORDER BY a.' . $db->nameQuote('created') . ' DESC ';
$db->setQuery($query);
$row = $db->loadAssocList();
if (empty($row)) {
return false;
}
$postCount = new stdClass();
foreach ($row as $data) {
if (!isset($postCount->{$data['year']})) {
//.........这里部分代码省略.........
示例4: 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];
}
示例5: getMenusByTeamId
/**
* Retrieve menu items associated with team blogs
*
* @since 5.0
* @access public
* @param string
* @return
*/
public function getMenusByTeamId($id)
{
$db = EB::db();
$query = array();
$query[] = 'SELECT ' . $db->qn('id') . ' FROM ' . $db->qn('#__menu');
$query[] = 'WHERE';
$query[] = '(';
$query[] = $db->qn('link') . '=' . $db->Quote('index.php?option=com_easyblog&view=teamblog&layout=listings&id=' . $id);
$query[] = 'OR';
$query[] = $db->qn('link') . ' LIKE ' . $db->Quote('index.php?option=com_easyblog&view=teamblog&layout=listings&id=' . $id . '&limit%');
$query[] = ')';
$query[] = 'AND ' . $db->qn('published') . '=' . $db->Quote(1);
$query[] = EBR::getLanguageQuery();
$query[] = 'LIMIT 1';
$query = implode(' ', $query);
$db->setQuery($query);
$result = $db->loadResult();
return $result;
}
示例6: getPosts
static function getPosts(&$params)
{
$db = EB::db();
$config = EB::config();
$type = $params->get('type');
$joinQuery = '';
$headQuery = 'SELECT a.* FROM ' . $db->qn('#__easyblog_post') . ' as a';
// select valid latitude/longitude or address
$query = ' WHERE ((TRIM(a.' . $db->qn('latitude') . ') != ' . $db->quote('') . ' AND TRIM(a.' . $db->qn('longitude') . ') != ' . $db->quote('') . ')';
$query .= ' OR TRIM(a.' . $db->qn('address') . ') != ' . $db->quote('') . ')';
$query .= ' AND a.' . $db->qn('published') . ' = ' . $db->quote(EASYBLOG_POST_PUBLISHED);
$query .= ' AND a.' . $db->qn('state') . ' = ' . $db->quote(EASYBLOG_POST_NORMAL);
// @rule: When language filter is enabled, we need to detect the appropriate contents
$filterLanguage = JFactory::getApplication()->getLanguageFilter();
if ($filterLanguage) {
$queryWhere .= EBR::getLanguageQuery('AND', 'a.language');
}
switch ($type) {
case '1':
// by blogger
$bloggers = self::join($params->get('bloggerid'));
if (!empty($bloggers)) {
$query .= ' AND a.' . $db->qn('created_by') . ' IN (' . $bloggers . ')';
}
break;
case '2':
// by category
$categories = self::join($params->get('categoryid'));
if (!empty($categories)) {
$joinQuery .= ' INNER JOIN ' . $db->qn('#__easyblog_post_category') . ' as pc';
$joinQuery .= ' ON pc.' . $db->qn('post_id') . ' = a.' . $db->qn('id');
$query .= ' AND pc.' . $db->qn('category_id') . ' IN (' . $categories . ')';
}
break;
case '3':
// by tag
$tags = self::join($params->get('tagid'));
if (!empty($post_ids)) {
$joinQuery .= ' INNER JOIN ' . $db->qn('#__easyblog_post_tag') . ' as pt';
$joinQuery .= ' ON pt.' . $db->qn('post_id') . ' = a.' . $db->qn('id');
$query .= ' AND pt' . $db->qn('tag_id') . ' IN (' . $tags . ')';
}
break;
case '4':
// by team
$teams = self::join($params->get('teamids'));
if (!empty($post_ids)) {
$query .= ' AND a.' . $db->qn('source_type') . ' = ' . $db->Quote(EASYBLOG_POST_SOURCE_TEAM);
$query .= ' AND a.' . $db->qn('source_id') . ' IN (' . $post_ids . ')';
}
break;
case '0':
default:
// by latest
$featured = $params->get('usefeatured');
if ($featured) {
$joinQuery .= ' INNER JOIN ' . $db->qn('#__easyblog_featured') . ' as f';
$joinQuery .= ' ON f.' . $db->qn('content_id') . ' = a.' . $db->qn('id');
$joinQuery .= ' AND f.' . $db->qn('type') . ' = ' . $db->Quote(EBLOG_FEATURED_BLOG);
}
break;
}
// always sort by latest
$query .= ' ORDER BY a.' . $db->qn('created') . ' DESC';
// set limit
$query .= ' LIMIT ' . (int) $params->get('count', 5);
// joins the strings.
$query = $headQuery . $joinQuery . $query;
$db->setQuery($query);
$posts = $db->loadObjectList();
$posts = self::processItems($posts, $params);
return $posts;
}