本文整理匯總了PHP中FinderHelperLanguage::branchLanguageTitle方法的典型用法代碼示例。如果您正苦於以下問題:PHP FinderHelperLanguage::branchLanguageTitle方法的具體用法?PHP FinderHelperLanguage::branchLanguageTitle怎麽用?PHP FinderHelperLanguage::branchLanguageTitle使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類FinderHelperLanguage
的用法示例。
在下文中一共展示了FinderHelperLanguage::branchLanguageTitle方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getGroups
/**
* Method to get the list of content map options grouped by first level.
*
* @return array The field option objects as a nested array in groups.
*
* @since 3.6.0
*/
protected function getGroups()
{
$groups = array();
// Get the database object and a new query object.
$db = JFactory::getDbo();
// Levels subquery.
$levelQuery = $db->getQuery(true);
$levelQuery->select('title AS branch_title, 1 as level')->select($db->quoteName('id'))->from($db->quoteName('#__finder_taxonomy'))->where($db->quoteName('parent_id') . ' = 1');
$levelQuery2 = $db->getQuery(true);
$levelQuery2->select('b.title AS branch_title, 2 as level')->select($db->quoteName('a.id'))->from($db->quoteName('#__finder_taxonomy', 'a'))->join('LEFT', $db->quoteName('#__finder_taxonomy', 'b') . ' ON ' . $db->qn('a.parent_id') . ' = ' . $db->qn('b.id'))->where($db->quoteName('a.parent_id') . ' NOT IN (0, 1)');
$levelQuery->union($levelQuery2);
// Main query.
$query = $db->getQuery(true)->select($db->quoteName('a.title', 'text'))->select($db->quoteName('a.id', 'value'))->select($db->quoteName('d.level'))->from($db->quoteName('#__finder_taxonomy', 'a'))->join('LEFT', '(' . $levelQuery . ') AS d ON ' . $db->qn('d.id') . ' = ' . $db->qn('a.id'))->where($db->quoteName('a.parent_id') . ' <> 0')->order('d.branch_title ASC, d.level ASC, a.title ASC');
$db->setQuery($query);
try {
$contentMap = $db->loadObjectList();
} catch (RuntimeException $e) {
return;
}
// Build the grouped list array.
if ($contentMap) {
$lang = JFactory::getLanguage();
foreach ($contentMap as $branch) {
if ((int) $branch->level === 1) {
$name = $branch->text;
} else {
$levelPrefix = str_repeat('- ', max(0, $branch->level - 1));
if (trim($name, '**') == 'Language') {
$text = FinderHelperLanguage::branchLanguageTitle($branch->text);
} else {
$key = FinderHelperLanguage::branchSingular($branch->text);
$text = $lang->hasKey($key) ? JText::_($key) : $branch->text;
}
// Initialize the group if necessary.
if (!isset($groups[$name])) {
$groups[$name] = array();
}
$groups[$name][] = JHtml::_('select.option', $branch->value, $levelPrefix . $text);
}
}
}
// Merge any additional groups in the XML definition.
$groups = array_merge(parent::getGroups(), $groups);
return $groups;
}
示例2: select
/**
* Method to generate filters using select box dropdown controls.
*
* @param FinderIndexerQuery $idxQuery A FinderIndexerQuery object.
* @param array $options An array of options.
*
* @return mixed A rendered HTML widget on success, null otherwise.
*
* @since 2.5
*/
public static function select($idxQuery, $options)
{
$user = JFactory::getUser();
$groups = implode(',', $user->getAuthorisedViewLevels());
$filter = null;
// Get the configuration options.
$classSuffix = $options->get('class_suffix', null);
$showDates = $options->get('show_date_filters', false);
// Try to load the results from cache.
$cache = JFactory::getCache('com_finder', '');
$cacheId = 'filter_select_' . serialize(array($idxQuery->filter, $options, $groups, JFactory::getLanguage()->getTag()));
// Check the cached results.
if (!($branches = $cache->get($cacheId))) {
$db = JFactory::getDbo();
$query = $db->getQuery(true);
// Load the predefined filter if specified.
if (!empty($idxQuery->filter)) {
$query->select('f.data, ' . $db->quoteName('f.params'))->from($db->quoteName('#__finder_filters') . ' AS f')->where('f.filter_id = ' . (int) $idxQuery->filter);
// Load the filter data.
$db->setQuery($query);
try {
$filter = $db->loadObject();
} catch (RuntimeException $e) {
return null;
}
// Initialize the filter parameters.
if ($filter) {
$registry = new Registry();
$registry->loadString($filter->params);
$filter->params = $registry;
}
}
// Build the query to get the branch data and the number of child nodes.
$query->clear()->select('t.*, count(c.id) AS children')->from($db->quoteName('#__finder_taxonomy') . ' AS t')->join('INNER', $db->quoteName('#__finder_taxonomy') . ' AS c ON c.parent_id = t.id')->where('t.parent_id = 1')->where('t.state = 1')->where('t.access IN (' . $groups . ')')->where('c.state = 1')->where('c.access IN (' . $groups . ')')->group($db->quoteName('t.id'))->order('t.ordering, t.title');
// Limit the branch children to a predefined filter.
if (!empty($filter->data)) {
$query->where('c.id IN(' . $filter->data . ')');
}
// Load the branches.
$db->setQuery($query);
try {
$branches = $db->loadObjectList('id');
} catch (RuntimeException $e) {
return null;
}
// Check that we have at least one branch.
if (count($branches) === 0) {
return null;
}
// Iterate through the branches and build the branch groups.
foreach ($branches as $bk => $bv) {
// If the multi-lang plugin is enabled then drop the language branch.
if ($bv->title == 'Language' && JLanguageMultilang::isEnabled()) {
continue;
}
// Build the query to get the child nodes for this branch.
$query->clear()->select('t.*')->from($db->quoteName('#__finder_taxonomy') . ' AS t')->where('t.parent_id = ' . (int) $bk)->where('t.state = 1')->where('t.access IN (' . $groups . ')')->order('t.ordering, t.title');
// Self-join to get the parent title.
$query->select('e.title AS parent_title')->join('LEFT', $db->quoteName('#__finder_taxonomy', 'e') . ' ON ' . $db->quoteName('e.id') . ' = ' . $db->quoteName('t.parent_id'));
// Limit the nodes to a predefined filter.
if (!empty($filter->data)) {
$query->where('t.id IN(' . $filter->data . ')');
}
// Load the branches.
$db->setQuery($query);
try {
$branches[$bk]->nodes = $db->loadObjectList('id');
} catch (RuntimeException $e) {
return null;
}
// Translate branch nodes if possible.
$language = JFactory::getLanguage();
foreach ($branches[$bk]->nodes as $node_id => $node) {
if (trim($node->parent_title, '**') == 'Language') {
$title = FinderHelperLanguage::branchLanguageTitle($node->title);
} else {
$key = FinderHelperLanguage::branchPlural($node->title);
$title = $language->hasKey($key) ? JText::_($key) : $node->title;
}
$branches[$bk]->nodes[$node_id]->title = $title;
}
// Add the Search All option to the branch.
array_unshift($branches[$bk]->nodes, array('id' => null, 'title' => JText::_('COM_FINDER_FILTER_SELECT_ALL_LABEL')));
}
// Store the data in cache.
$cache->store($branches, $cacheId);
}
$html = '';
// Add the dates if enabled.
if ($showDates) {
//.........這裏部分代碼省略.........
示例3:
?>
">
<td class="center">
<?php
echo JHtml::_('grid.id', $i, $item->id);
?>
</td>
<td class="center nowrap">
<?php
echo JHtml::_('jgrid.published', $item->state, $i, 'maps.', $canChange, 'cb');
?>
</td>
<td>
<?php
if (trim($item->parent_title, '**') == 'Language') {
$title = FinderHelperLanguage::branchLanguageTitle($item->title);
} else {
$key = FinderHelperLanguage::branchSingular($item->title);
$title = $lang->hasKey($key) ? JText::_($key) : $item->title;
}
?>
<?php
if ((int) $item->num_children === 0) {
?>
<span class="gi">—</span>
<?php
}
?>
<label for="cb<?php
echo $i;
?>