本文整理汇总了PHP中JHelperContent::getCurrentLanguage方法的典型用法代码示例。如果您正苦于以下问题:PHP JHelperContent::getCurrentLanguage方法的具体用法?PHP JHelperContent::getCurrentLanguage怎么用?PHP JHelperContent::getCurrentLanguage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JHelperContent
的用法示例。
在下文中一共展示了JHelperContent::getCurrentLanguage方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getList
public static function getList(&$params)
{
$db = JFactory::getDbo();
$user = JFactory::getUser();
$groups = implode(',', $user->getAuthorisedViewLevels());
$timeframe = $params->get('timeframe', 'alltime');
$maximum = $params->get('maximum', 5);
$order_value = $params->get('order_value', 'count');
if ($order_value == 'rand()') {
$order_direction = '';
} else {
$order_value = $db->quoteName($order_value);
$order_direction = $params->get('order_direction', 1) ? 'DESC' : 'ASC';
}
$query = $db->getQuery(true)->select(array('MAX(' . $db->quoteName('tag_id') . ') AS tag_id', ' COUNT(*) AS count', 'MAX(t.title) AS title', 'MAX(' . $db->quoteName('t.access') . ') AS access', 'MAX(' . $db->quoteName('t.alias') . ') AS alias'))->group($db->quoteName(array('tag_id', 'title', 'access', 'alias')))->from($db->quoteName('#__contentitem_tag_map'))->where($db->quoteName('t.access') . ' IN (' . $groups . ')');
// Only return published tags
$query->where($db->quoteName('t.published') . ' = 1 ');
// Optionally filter on language
$language = JComponentHelper::getParams('com_tags')->get('tag_list_language_filter', 'all');
if ($language != 'all') {
if ($language == 'current_language') {
$language = JHelperContent::getCurrentLanguage();
}
$query->where($db->quoteName('t.language') . ' IN (' . $db->quote($language) . ', ' . $db->quote('*') . ')');
}
if ($timeframe != 'alltime') {
$now = new JDate();
$query->where($db->quoteName('tag_date') . ' > ' . $query->dateAdd($now->toSql('date'), '-1', strtoupper($timeframe)));
}
$query->join('INNER', $db->quoteName('#__tags', 't') . ' ON ' . $db->quoteName('tag_id') . ' = t.id')->order($order_value . ' ' . $order_direction);
$db->setQuery($query, 0, $maximum);
$results = $db->loadObjectList();
return $results;
}
示例2: getList
/**
* Get a list of tags
*
* @param JRegistry &$params Module parameters
*
* @return mixed Results array / null
*/
public static function getList(&$params)
{
$app = JFactory::getApplication();
$option = $app->input->get('option');
$view = $app->input->get('view');
// For now assume com_tags and com_users do not have tags.
// This module does not apply to list views in general at this point.
if ($option == 'com_tags' || $view == 'category' || $option == 'com_users') {
return;
}
$db = JFactory::getDbo();
$user = JFactory::getUser();
$groups = implode(',', $user->getAuthorisedViewLevels());
$matchtype = $params->get('matchtype', 'all');
$maximum = $params->get('maximum', 5);
$tagsHelper = new JHelperTags();
$prefix = $option . '.' . $view;
$id = $app->input->getInt('id');
$tagsToMatch = $tagsHelper->getTagIds($id, $prefix);
if (!$tagsToMatch || is_null($tagsToMatch)) {
return;
}
$tagCount = substr_count($tagsToMatch, ',') + 1;
$query = $db->getQuery(true)->select(array($db->quoteName('m.tag_id'), $db->quoteName('m.core_content_id'), $db->quoteName('m.content_item_id'), $db->quoteName('m.type_alias'), 'COUNT( ' . $db->quoteName('tag_id') . ') AS ' . $db->quoteName('count'), $db->quoteName('t.access'), $db->quoteName('t.id'), $db->quoteName('ct.router'), $db->quoteName('cc.core_title'), $db->quoteName('cc.core_alias'), $db->quoteName('cc.core_catid'), $db->quoteName('cc.core_language')));
$query->from($db->quoteName('#__contentitem_tag_map', 'm'));
$query->join('INNER', $db->quoteName('#__tags', 't') . ' ON m.tag_id = t.id')->join('INNER', $db->quoteName('#__ucm_content', 'cc') . ' ON m.core_content_id = cc.core_content_id')->join('INNER', $db->quoteName('#__content_types', 'ct') . ' ON m.type_alias = ct.type_alias');
$query->where($db->quoteName('m.tag_id') . ' IN (' . $tagsToMatch . ')');
$query->where('t.access IN (' . $groups . ')');
$query->where('(cc.core_access IN (' . $groups . ') OR cc.core_access = 0)');
// Don't show current item
$query->where('(' . $db->quoteName('m.content_item_id') . ' <> ' . $id . ' OR ' . $db->quoteName('m.type_alias') . ' <> ' . $db->quote($prefix) . ')');
// Only return published tags
$query->where($db->quoteName('cc.core_state') . ' = 1 ');
// Optionally filter on language
$language = JComponentHelper::getParams('com_tags')->get('tag_list_language_filter', 'all');
if ($language != 'all') {
if ($language == 'current_language') {
$language = JHelperContent::getCurrentLanguage();
}
$query->where($db->quoteName('cc.core_language') . ' IN (' . $db->quote($language) . ', ' . $db->quote('*') . ')');
}
$query->group($db->quoteName(array('m.core_content_id')));
if ($matchtype == 'all' && $tagCount > 0) {
$query->having('COUNT( ' . $db->quoteName('tag_id') . ') = ' . $tagCount);
} elseif ($matchtype == 'half' && $tagCount > 0) {
$tagCountHalf = ceil($tagCount / 2);
$query->having('COUNT( ' . $db->quoteName('tag_id') . ') >= ' . $tagCountHalf);
}
$query->order($db->quoteName('count') . ' DESC');
$db->setQuery($query, 0, $maximum);
$results = $db->loadObjectList();
foreach ($results as $result) {
$explodedAlias = explode('.', $result->type_alias);
$result->link = 'index.php?option=' . $explodedAlias[0] . '&view=' . $explodedAlias[1] . '&id=' . $result->content_item_id . '-' . $result->core_alias;
}
return $results;
}
示例3: getList
/**
* Get list of popular tags
*
* @param \Joomla\Registry\Registry &$params module parameters
*
* @return mixed
*
* @since 3.1
*/
public static function getList(&$params)
{
$db = JFactory::getDbo();
$user = JFactory::getUser();
$groups = implode(',', $user->getAuthorisedViewLevels());
$timeframe = $params->get('timeframe', 'alltime');
$maximum = $params->get('maximum', 5);
$order_value = $params->get('order_value', 'title');
$nowDate = JFactory::getDate()->toSql();
$nullDate = $db->quote($db->getNullDate());
$query = $db->getQuery(true)->select(array('MAX(' . $db->quoteName('tag_id') . ') AS tag_id', ' COUNT(*) AS count', 'MAX(t.title) AS title', 'MAX(' . $db->quoteName('t.access') . ') AS access', 'MAX(' . $db->quoteName('t.alias') . ') AS alias', 'MAX(' . $db->quoteName('t.params') . ') AS params'))->group($db->quoteName(array('tag_id', 'title', 'access', 'alias')))->from($db->quoteName('#__contentitem_tag_map', 'm'))->where($db->quoteName('t.access') . ' IN (' . $groups . ')');
// Only return published tags
$query->where($db->quoteName('t.published') . ' = 1 ');
// Optionally filter on language
$language = JComponentHelper::getParams('com_tags')->get('tag_list_language_filter', 'all');
if ($language != 'all') {
if ($language == 'current_language') {
$language = JHelperContent::getCurrentLanguage();
}
$query->where($db->quoteName('t.language') . ' IN (' . $db->quote($language) . ', ' . $db->quote('*') . ')');
}
if ($timeframe != 'alltime') {
$query->where($db->quoteName('tag_date') . ' > ' . $query->dateAdd($nowDate, '-1', strtoupper($timeframe)));
}
$query->join('INNER', $db->quoteName('#__tags', 't') . ' ON ' . $db->quoteName('tag_id') . ' = t.id')->join('INNER', $db->qn('#__ucm_content', 'c') . ' ON ' . $db->qn('m.core_content_id') . ' = ' . $db->qn('c.core_content_id'));
$query->where($db->quoteName('m.type_alias') . ' = ' . $db->quoteName('c.core_type_alias'));
// Only return tags connected to published articles
$query->where($db->quoteName('c.core_state') . ' = 1')->where('(' . $db->quoteName('c.core_publish_up') . ' = ' . $nullDate . ' OR ' . $db->quoteName('c.core_publish_up') . ' <= ' . $db->quote($nowDate) . ')')->where('(' . $db->quoteName('c.core_publish_down') . ' = ' . $nullDate . ' OR ' . $db->quoteName('c.core_publish_down') . ' >= ' . $db->quote($nowDate) . ')');
// Set query depending on order_value param
if ($order_value == 'rand()') {
$query->order($query->Rand());
} else {
$order_value = $db->quoteName($order_value);
$order_direction = $params->get('order_direction', 1) ? 'DESC' : 'ASC';
if ($params->get('order_value', 'title') == 'title') {
$query->setLimit($maximum);
$query->order('count DESC');
$equery = $db->getQuery(true)->select(array('a.tag_id', 'a.count', 'a.title', 'a.access', 'a.alias'))->from('(' . (string) $query . ') AS a')->order('a.title' . ' ' . $order_direction);
$query = $equery;
} else {
$query->order($order_value . ' ' . $order_direction);
}
}
$db->setQuery($query, 0, $maximum);
try {
$results = $db->loadObjectList();
} catch (RuntimeException $e) {
$results = array();
JFactory::getApplication()->enqueueMessage($e->getMessage(), 'error');
}
return $results;
}
示例4: getTags
static function getTags($content_type = '', $whole = false, $tag_ids = array())
{
$tags = array();
$db = JFactory::getDBO();
$query = $db->getQuery(true);
if ($whole) {
// get the whole object
$query->select('a.*');
} else {
$query->select('a.id, a.path, a.title, a.level');
}
$query->from('#__tags AS a');
$query->join('LEFT', $db->quoteName('#__tags') . ' AS b ON a.lft > b.lft AND a.rgt < b.rgt');
// get tags for a specific content type
if (!empty($content_type)) {
// get only tags associated with the content type
$query->join('INNER', $db->quoteName('#__contentitem_tag_map') . ' AS m ON m.tag_id = a.id AND m.type_alias =' . $db->quote($content_type));
}
$query->where('a.published = 1');
$query->where($db->quoteName('a.alias') . ' <> ' . $db->quote('root'));
// get tags with specific ids
if (is_array($tag_ids) && count($tag_ids) > 0) {
JArrayHelper::toInteger($tag_ids);
$tag_ids = implode(',', $tag_ids);
$query->where($db->quoteName('a.id') . ' IN (' . $tag_ids . ')');
}
// access groups
$user = JFactory::getUser();
$groups = implode(',', $user->getAuthorisedViewLevels());
$query->where('a.access IN (' . $groups . ')');
// language
$language = JComponentHelper::getParams('com_tags')->get('tag_list_language_filter', 'all');
if ($language != 'all') {
if ($language == 'current_language') {
$language = JHelperContent::getCurrentLanguage();
}
$query->where($db->quoteName('language') . ' IN (' . $db->quote($language) . ', ' . $db->quote('*') . ')');
}
$query->group('a.id, a.title, a.level, a.lft, a.rgt, a.parent_id, a.path');
$query->order('a.lft ASC');
$db->setQuery($query);
try {
$tags = $db->loadObjectList();
} catch (RuntimeException $e) {
return false;
}
return $tags;
}
示例5: getTagItemsQuery
/**
* Method to get a query to retrieve a detailed list of items for a tag.
*
* @param mixed $tagId Tag or array of tags to be matched
* @param mixed $typesr Null, type or array of type aliases for content types to be included in the results
* @param boolean $includeChildren True to include the results from child tags
* @param string $orderByOption Column to order the results by
* @param string $orderDir Direction to sort the results in
* @param boolean $anyOrAll True to include items matching at least one tag, false to include
* items all tags in the array.
* @param string $languageFilter Optional filter on language. Options are 'all', 'current' or any string.
* @param string $stateFilter Optional filtering on publication state, defaults to published or unpublished.
*
* @return JDatabaseQuery Query to retrieve a list of tags
*
* @since 3.1
*/
public function getTagItemsQuery($tagId, $typesr = null, $includeChildren = false, $orderByOption = 'c.core_title', $orderDir = 'ASC', $anyOrAll = true, $languageFilter = 'all', $stateFilter = '0,1')
{
// Create a new query object.
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$user = JFactory::getUser();
$nullDate = $db->quote($db->getNullDate());
$ntagsr = substr_count($tagId, ',') + 1;
// If we want to include children we have to adjust the list of tags.
// We do not search child tags when the match all option is selected.
if ($includeChildren) {
if (!is_array($tagId)) {
$tagIdArray = explode(',', $tagId);
} else {
$tagIdArray = $tagId;
}
$tagTreeList = '';
foreach ($tagIdArray as $tag) {
if ($this->getTagTreeArray($tag, $tagTreeArray)) {
$tagTreeList .= implode(',', $this->getTagTreeArray($tag, $tagTreeArray)) . ',';
}
}
if ($tagTreeList) {
$tagId = trim($tagTreeList, ',');
}
}
if (is_array($tagId)) {
$tagId = implode(',', $tagId);
}
// M is the mapping table. C is the core_content table. Ct is the content_types table.
$query->select('m.type_alias, m.content_item_id, m.core_content_id, count(m.tag_id) AS match_count, MAX(m.tag_date) as tag_date, MAX(c.core_title) AS core_title')->select('MAX(c.core_alias) AS core_alias, MAX(c.core_body) AS core_body, MAX(c.core_state) AS core_state, MAX(c.core_access) AS core_access')->select('MAX(c.core_metadata) AS core_metadata, MAX(c.core_created_user_id) AS core_created_user_id, MAX(c.core_created_by_alias) AS core_created_by_alias')->select('MAX(c.core_created_time) as core_created_time, MAX(c.core_images) as core_images')->select('CASE WHEN c.core_modified_time = ' . $nullDate . ' THEN c.core_created_time ELSE c.core_modified_time END as core_modified_time')->select('MAX(c.core_language) AS core_language, MAX(c.core_catid) AS core_catid')->select('MAX(c.core_publish_up) AS core_publish_up, MAX(c.core_publish_down) as core_publish_down')->select('MAX(ct.type_title) AS content_type_title, MAX(ct.router) AS router')->from('#__contentitem_tag_map AS m')->join('INNER', '#__ucm_content AS c ON m.type_alias = c.core_type_alias AND m.core_content_id = c.core_content_id')->join('INNER', '#__content_types AS ct ON ct.type_alias = m.type_alias')->select("CASE WHEN c.core_created_by_alias > ' ' THEN c.core_created_by_alias ELSE ua.name END AS author")->select("ua.email AS author_email")->join('LEFT', '#__users AS ua ON ua.id = c.core_created_user_id')->where('m.tag_id IN (' . $tagId . ')')->where('c.core_state IN (' . $stateFilter . ')');
// Optionally filter on language
if (empty($language)) {
$language = $languageFilter;
}
if ($language != 'all') {
if ($language == 'current_language') {
$language = JHelperContent::getCurrentLanguage();
}
$query->where($db->quoteName('c.core_language') . ' IN (' . $db->quote($language) . ', ' . $db->quote('*') . ')');
}
// Get the type data, limited to types in the request if there are any specified.
$typesarray = self::getTypes('assocList', $typesr, false);
$typeAliases = '';
foreach ($typesarray as $type) {
$typeAliases .= "'" . $type['type_alias'] . "'" . ',';
}
$typeAliases = rtrim($typeAliases, ',');
$query->where('m.type_alias IN (' . $typeAliases . ')');
$groups = '0,' . implode(',', array_unique($user->getAuthorisedViewLevels()));
$query->where('c.core_access IN (' . $groups . ')')->group('m.type_alias, m.content_item_id, m.core_content_id');
// Use HAVING if matching all tags and we are matching more than one tag.
if ($ntagsr > 1 && $anyOrAll != 1 && $includeChildren != 1) {
// The number of results should equal the number of tags requested.
$query->having("COUNT('m.tag_id') = " . $ntagsr);
}
// Set up the order by using the option chosen
if ($orderByOption == 'match_count') {
$orderBy = 'COUNT(m.tag_id)';
} else {
$orderBy = 'MAX(' . $orderByOption . ')';
}
$query->order($orderBy . ' ' . $orderDir);
return $query;
}
示例6: getListQuery
/**
* Method to build an SQL query to load the list data.
*
* @return string An SQL query
*
* @since 1.6
*/
protected function getListQuery()
{
$app = JFactory::getApplication('site');
$user = JFactory::getUser();
$groups = implode(',', $user->getAuthorisedViewLevels());
$pid = $this->getState('tag.parent_id');
$orderby = $this->state->params->get('all_tags_orderby', 'title');
$published = $this->state->params->get('published', 1);
$orderDirection = $this->state->params->get('all_tags_orderby_direction', 'ASC');
$language = $this->getState('tag.language');
// Create a new query object.
$db = $this->getDbo();
$query = $db->getQuery(true);
// Select required fields from the tags.
$query->select('a.*')->from($db->quoteName('#__tags') . ' AS a')->where($db->quoteName('a.access') . ' IN (' . $groups . ')');
if (!empty($pid)) {
$query->where($db->quoteName('a.parent_id') . ' = ' . $pid);
}
// Exclude the root.
$query->where($db->quoteName('a.parent_id') . ' <> 0');
// Optionally filter on language
if (empty($language)) {
$language = JComponentHelper::getParams('com_tags')->get('tag_list_language_filter', 'all');
}
if ($language != 'all') {
if ($language == 'current_language') {
$language = JHelperContent::getCurrentLanguage();
}
$query->where($db->quoteName('language') . ' IN (' . $db->quote($language) . ', ' . $db->quote('*') . ')');
}
// List state information
$format = $app->input->getWord('format');
if ($format == 'feed') {
$limit = $app->get('feed_limit');
} else {
if ($this->state->params->get('show_pagination_limit')) {
$limit = $app->getUserStateFromRequest('global.list.limit', 'limit', $app->get('list_limit'), 'uint');
} else {
$limit = $this->state->params->get('maximum', 20);
}
}
$this->setState('list.limit', $limit);
$offset = $app->input->get('limitstart', 0, 'uint');
$this->setState('list.start', $offset);
// Optionally filter on entered value
if ($this->state->get('list.filter')) {
$query->where($db->quoteName('a.title') . ' LIKE ' . $db->quote('%' . $this->state->get('list.filter') . '%'));
}
$query->where($db->quoteName('a.published') . ' = ' . $published);
$query->order($db->quoteName($orderby) . ' ' . $orderDirection . ', a.title ASC');
return $query;
}
示例7: getList
/**
* Get a list of tags
*
* @param Registry &$params Module parameters
*
* @return mixed Results array / null
*/
public static function getList(&$params)
{
$app = JFactory::getApplication();
$option = $app->input->get('option');
$view = $app->input->get('view');
// For now assume com_tags and com_users do not have tags.
// This module does not apply to list views in general at this point.
if ($option == 'com_tags' || $view == 'category' || $option == 'com_users') {
return;
}
$db = JFactory::getDbo();
$user = JFactory::getUser();
$groups = implode(',', $user->getAuthorisedViewLevels());
$matchtype = $params->get('matchtype', 'all');
$maximum = $params->get('maximum', 5);
$ordering = $params->get('ordering', 'count');
$tagsHelper = new JHelperTags();
$prefix = $option . '.' . $view;
$id = $app->input->getInt('id');
$now = JFactory::getDate()->toSql();
$nullDate = $db->getNullDate();
$tagsToMatch = $tagsHelper->getTagIds($id, $prefix);
if (!$tagsToMatch || is_null($tagsToMatch)) {
return;
}
$tagCount = substr_count($tagsToMatch, ',') + 1;
$query = $db->getQuery(true)->select(array($db->quoteName('m.core_content_id'), $db->quoteName('m.content_item_id'), $db->quoteName('m.type_alias'), 'COUNT( ' . $db->quoteName('tag_id') . ') AS ' . $db->quoteName('count'), $db->quoteName('ct.router'), $db->quoteName('cc.core_title'), $db->quoteName('cc.core_alias'), $db->quoteName('cc.core_catid'), $db->quoteName('cc.core_language'), $db->quoteName('cc.core_params'), $db->quoteName('cc.core_created_user_id'), $db->quoteName('cc.core_publish_up'), $db->quoteName('cc.core_images'), $db->quoteName('cc.core_created_time')));
$query->from($db->quoteName('#__contentitem_tag_map', 'm'));
$query->join('INNER', $db->quoteName('#__tags', 't') . ' ON m.tag_id = t.id')->join('INNER', $db->quoteName('#__ucm_content', 'cc') . ' ON m.core_content_id = cc.core_content_id')->join('INNER', $db->quoteName('#__content_types', 'ct') . ' ON m.type_alias = ct.type_alias');
// Join over the created by field 'created_by'
$query->select('`created_by`.name AS `author`, `created_by`.email as `author_email`');
$query->join('LEFT', '#__users AS created_by ON created_by.id = cc.core_created_user_id');
$query->where($db->quoteName('m.tag_id') . ' IN (' . $tagsToMatch . ')');
$query->where('t.access IN (' . $groups . ')');
$query->where('(cc.core_access IN (' . $groups . ') OR cc.core_access = 0)');
// Don't show current item
$query->where('(' . $db->quoteName('m.content_item_id') . ' <> ' . $id . ' OR ' . $db->quoteName('m.type_alias') . ' <> ' . $db->quote($prefix) . ')');
// Only return published tags
$query->where($db->quoteName('cc.core_state') . ' = 1 ')->where('(' . $db->quoteName('cc.core_publish_up') . '=' . $db->quote($nullDate) . ' OR ' . $db->quoteName('cc.core_publish_up') . '<=' . $db->quote($now) . ')')->where('(' . $db->quoteName('cc.core_publish_down') . '=' . $db->quote($nullDate) . ' OR ' . $db->quoteName('cc.core_publish_down') . '>=' . $db->quote($now) . ')');
// Optionally filter on language
$language = JComponentHelper::getParams('com_tags')->get('tag_list_language_filter', 'all');
if ($language != 'all') {
if ($language == 'current_language') {
$language = JHelperContent::getCurrentLanguage();
}
$query->where($db->quoteName('cc.core_language') . ' IN (' . $db->quote($language) . ', ' . $db->quote('*') . ')');
}
$query->group($db->quoteName(array('m.core_content_id', 'm.content_item_id', 'm.type_alias', 'ct.router', 'cc.core_title', 'cc.core_alias', 'cc.core_catid', 'cc.core_language', 'cc.core_params')));
if ($matchtype == 'all' && $tagCount > 0) {
$query->having('COUNT( ' . $db->quoteName('tag_id') . ') = ' . $tagCount);
} elseif ($matchtype == 'half' && $tagCount > 0) {
$tagCountHalf = ceil($tagCount / 2);
$query->having('COUNT( ' . $db->quoteName('tag_id') . ') >= ' . $tagCountHalf);
}
if ($ordering == 'count' || $ordering == 'countrandom') {
$query->order($db->quoteName('count') . ' DESC');
}
if ($ordering == 'random' || $ordering == 'countrandom') {
$query->order('RAND()');
}
$db->setQuery($query, 0, $maximum);
try {
$results = $db->loadObjectList();
} catch (RuntimeException $e) {
$results = array();
JFactory::getApplication()->enqueueMessage(JText::_('JERROR_AN_ERROR_HAS_OCCURRED'), 'error');
}
foreach ($results as $result) {
$explodedAlias = explode('.', $result->type_alias);
$result->link = 'index.php?option=' . $explodedAlias[0] . '&view=' . $explodedAlias[1] . '&id=' . $result->content_item_id . '-' . $result->core_alias;
$result->core_params = new Registry($result->core_params);
}
return $results;
}