本文整理汇总了PHP中JLanguageHelper类的典型用法代码示例。如果您正苦于以下问题:PHP JLanguageHelper类的具体用法?PHP JLanguageHelper怎么用?PHP JLanguageHelper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了JLanguageHelper类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: getList
/**
* Function for getting the list of languages
*
* @return array Language list
*/
public static function getList()
{
$app = JFactory::getApplication();
$languages = JLanguageHelper::getLanguages();
$db = JFactory::getDbo();
$Itemid = $app->input->getInt('Itemid', 0);
$uri = new JURI(Juri::current());
$uri->delVar('lang');
$uri->delVar('Itemid');
$location = htmlspecialchars($uri->getQuery());
if (!empty($location)) {
$location .= '&';
}
if (!$Itemid) {
$active = $app->getMenu()->getActive();
if ($active) {
$Itemid = $active->id;
}
}
// For every language we load menu items language specific alias and params
foreach ($languages as $i => $language) {
$db->forceLanguageTranslation = $language->lang_code;
RMenu::resetJoomlaMenuItems();
$db->forceLanguageTranslation = false;
$languages[$i]->active = $language->lang_code == JFactory::getLanguage()->getTag();
$languages[$i]->link = RRoute::_('index.php?' . $location . 'lang=' . $language->sef . ($Itemid > 0 ? '&Itemid=' . $Itemid : ''));
}
// After we are done we reset it the way it was
RMenu::resetJoomlaMenuItems();
return $languages;
}
开发者ID:thangredweb,项目名称:redCORE,代码行数:36,代码来源:helper.php
示例2: getLanguageList
/**
* Get an HTML select list of the available languages.
*
* @return string
*/
public static function getLanguageList()
{
$languages = array();
$languages = JLanguageHelper::createLanguageList(null, JPATH_ADMINISTRATOR, false, true);
array_unshift($languages, JHtml::_('select.option', '', JText::_('JDEFAULT')));
return JHtml::_('select.genericlist', $languages, 'lang', ' class="inputbox"', 'value', 'text', null);
}
开发者ID:NavaINT1876,项目名称:ccustoms,代码行数:12,代码来源:helper.php
示例3: loadHomepages
public function loadHomepages()
{
$app = JFactory::getApplication();
if ($app->isAdmin()) {
return;
}
// store default links in each language
$defaultLanguage = shGetDefaultLang();
jimport('joomla.language.helper');
$languages = JLanguageHelper::getLanguages();
$menu = JFactory::getApplication()->getMenu();
foreach ($languages as $language) {
$menuItem = $menu->getDefault($language->lang_code);
if (!empty($menuItem)) {
$this->homeLinks[$language->lang_code] = $this->_prepareLink($menuItem, $languages);
}
}
// save default link
$this->homeLink = $this->homeLinks[$defaultLanguage];
// find about the "All" languages home link
$menuItem = $menu->getDefault('*');
if (!empty($menuItem)) {
$this->allLangHomeLink = $this->_prepareLink($menuItem, $languages);
}
}
开发者ID:srbsnkr,项目名称:sellingonlinemadesimple,代码行数:25,代码来源:pageinfo.php
示例4: getInput
protected function getInput()
{
$this->params = $this->element->attributes();
$size = (int) $this->get('size');
$multiple = $this->get('multiple');
$client = $this->get('client', 'SITE');
jimport('joomla.language.helper');
$langs = JLanguageHelper::createLanguageList($this->value, constant('JPATH_' . strtoupper($client)), true);
$options = array();
foreach ($langs as $lang)
{
if ($lang['value'])
{
$option = new stdClass;
$option->value = $lang['value'];
$option->text = $lang['text'] . ' [' . $lang['value'] . ']';
$options[] = $option;
}
}
require_once JPATH_PLUGINS . '/system/nnframework/helpers/html.php';
return nnHtml::selectlist($options, $this->name, $this->value, $this->id, $size, $multiple);
}
开发者ID:networksoft,项目名称:seekerplus2.com,代码行数:26,代码来源:languages.php
示例5: getList
public static function getList(&$params)
{
$lang = JFactory::getLanguage();
$languages = JLanguageHelper::getLanguages();
$db = JFactory::getDBO();
$app = JFactory::getApplication();
$query = $db->getQuery(true);
$query->select('id');
$query->select('language');
$query->from($db->nameQuote('#__menu'));
$query->where('home=1');
$db->setQuery($query);
$homes = $db->loadObjectList('language');
foreach ($languages as $i => &$language) {
// Do not display language without frontend UI
if (!JLanguage::exists($language->lang_code)) {
unset($languages[$i]);
} elseif (!isset($homes[$language->lang_code])) {
unset($languages[$i]);
} else {
if ($app->getLanguageFilter()) {
$language->active = $language->lang_code == $lang->getTag();
if ($app->getCfg('sef') == '1') {
$itemid = isset($homes[$language->lang_code]) ? $homes[$language->lang_code]->id : $homes['*']->id;
$language->link = JRoute::_('index.php?lang=' . $language->sef . '&Itemid=' . $itemid);
} else {
$language->link = 'index.php?lang=' . $language->sef;
}
} else {
$language->link = 'index.php';
}
}
}
return $languages;
}
开发者ID:akksi,项目名称:jcg,代码行数:35,代码来源:helper.php
示例6: getInput
function getInput($name, $id, $value, $params, $children, $j15 = 0)
{
$this->params = $params;
$size = $this->def('size');
$multiple = $this->def('multiple');
$client = $this->def('client', 'SITE');
$control = $name . '';
$attribs = 'class="inputbox"';
if ($multiple) {
if (!is_array($value)) {
$value = explode(',', $value);
}
$attribs .= ' multiple="multiple"';
$control .= '[]';
}
jimport('joomla.language.helper');
$options = JLanguageHelper::createLanguageList($value, constant('JPATH_' . strtoupper($client)), true);
foreach ($options as $i => $option) {
if ($option['value']) {
$options[$i]['text'] = $option['text'] . ' [' . $option['value'] . ']';
}
}
if ($size) {
$attribs .= ' size="' . $size . '"';
} else {
$attribs .= ' size="' . (count($options) > 10 ? 10 : count($options)) . '"';
}
$list = JHTML::_('select.genericlist', $options, $control, $attribs, 'value', 'text', $value, $id);
return $list;
}
开发者ID:jtresca,项目名称:nysurveyor,代码行数:30,代码来源:languages.php
示例7: parseLang
public function parseLang($vars)
{
if (Mijosef::getConfig()->multilang == 0) {
return;
}
if (empty($vars['lang'])) {
$lang = JRequest::getWord('lang', '');
if (empty($lang)) {
return;
}
$vars['lang'] = $lang;
}
$languages = JLanguageHelper::getLanguages('sef');
$lang_code = $languages[$vars['lang']]->lang_code;
// if current language, don't bother
if ($lang_code == JFactory::getLanguage()->getTag()) {
//self::checkHomepage($vars['lang']);
return;
}
// Create a cookie
$conf = JFactory::getConfig();
$cookie_domain = $conf->get('config.cookie_domain', '');
$cookie_path = $conf->get('config.cookie_path', '/');
setcookie(JUtility::getHash('language'), $lang_code, time() + 365 * 86400, $cookie_path, $cookie_domain);
// set the request var
JRequest::setVar('language', $lang_code);
// set current language
jimport('joomla.language.language');
$conf = JFactory::getConfig();
$debug = $conf->get('debug_lang');
$lang = JLanguage::getInstance($lang_code, $debug);
JFactory::$language = $lang;
self::$_lang = $vars['lang'];
}
开发者ID:affiliatelk,项目名称:ecc,代码行数:34,代码来源:language.php
示例8: getUri
/**
* Get Uri
*
* @param string $url URL
*
* @return JUri
*/
public function getUri($url = 'SERVER')
{
static $uriArray = array();
if (!array_key_exists($url, $uriArray)) {
// This will enable both SEF and non-SEF URI to be parsed properly
$router = clone JRouter::getInstance('site');
$uri = clone JUri::getInstance($url);
$langCode = JLanguageHelper::detectLanguage();
$lang = $uri->getVar('lang', $langCode);
$uri->setVar('lang', $lang);
$sefs = JLanguageHelper::getLanguages('lang_code');
if (isset($sefs[$lang])) {
$lang = $sefs[$lang]->sef;
$uri->setVar('lang', $lang);
}
$router->setVars(array(), false);
$query = $router->parse($uri);
$query = array_merge($query, $uri->getQuery(true));
$uri->setQuery($query);
// We are removing format because of default value is csv if present and if not set
// and we are never going to remember csv page in a browser history anyway
$uri->delVar('format');
$uriArray[$url] = $uri;
}
return $uriArray[$url];
}
开发者ID:thangredweb,项目名称:redCORE,代码行数:33,代码来源:browser.php
示例9: _actionCopy
/**
* @param KCommandContext $context
*/
public function _actionCopy(KCommandContext $context)
{
foreach (KRequest::get('get.id', 'raw') as $item_id) {
$this->count = 1;
$items = array();
$languages = JLanguageHelper::getLanguages();
$model_identifier = clone $context->caller->getIdentifier();
$model_identifier->path = array('model');
$model_identifier->name = KInflector::pluralize($model_identifier->name);
$isTranslatable = KService::get($model_identifier)->getTable()->hasBehavior('translatable');
if ($isTranslatable) {
foreach ($languages as $language) {
JFactory::getLanguage()->setLanguage($language->lang_code);
$item = $this->getService($model_identifier)->id($item_id)->getItem();
if ($item->original) {
$this->original_language = $language->lang_code;
$original = $item;
} else {
$items[$language->lang_code] = $item;
}
}
}
JFactory::getLanguage()->setLanguage($this->original_language);
$id = $this->_copyOriginal($original);
if ($isTranslatable) {
$this->_updateLanguages($id, $items);
}
}
}
开发者ID:kedweber,项目名称:com_moyo,代码行数:32,代码来源:copyable.php
示例10: getOptions
/**
* Method to get the field options.
*
* @return array The field option objects.
* @since 1.6
*/
protected function getOptions()
{
// Initialise variables.
$app = JFactory::getApplication();
// Detect the native language.
$native = JLanguageHelper::detectLanguage();
if (empty($native)) {
$native = 'en-GB';
}
// Get a forced language if it exists.
$forced = $app->getLocalise();
if (!empty($forced['language'])) {
$native = $forced['language'];
}
// If a language is already set in the session, use this instead
$session = JFactory::getSession()->get('setup.options', array());
if (!empty($session['language'])) {
$native = $session['language'];
}
// Get the list of available languages.
$options = JLanguageHelper::createLanguageList($native);
if (!$options || JError::isError($options)) {
$options = array();
}
// Set the default value from the native language.
$this->value = $native;
// Merge any additional options in the XML definition.
$options = array_merge(parent::getOptions(), $options);
return $options;
}
开发者ID:akksi,项目名称:jcg,代码行数:36,代码来源:language.php
示例11: display
function display($tpl = null)
{
JHTML::_('behavior.keepalive');
require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_k2' . DS . 'models' . DS . 'categories.php';
$model = new K2ModelCategories();
$categories = $model->categoriesTree(NULL, false, false);
$options = array();
$options[] = JHTML::_('select.optgroup', JText::_('K2MART_CREATE_NEW_K2_CATEGORY'));
$options[] = JHTML::_('select.option', 0, JText::_('K2MART_TYPE_CATEGORY_NAME'));
$options[] = JHTML::_('select.optgroup', JText::_('K2MART_USE_EXISTING_K2_CATEGORY'));
foreach ($categories as $category) {
$options[] = JHTML::_('select.option', $category->value, $category->text);
}
$lists['category'] = JHTML::_('select.genericlist', $options, 'catid', 'class="inputbox"', 'value', 'text', 0);
$vmLanguages = vmConfig::get('active_languages', array());
if (count($vmLanguages) > 1) {
jimport('joomla.language.helper');
$languages = JLanguageHelper::createLanguageList(NULL, constant('JPATH_SITE'), true);
foreach ($languages as $key => &$language) {
if (!in_array($language['value'], $vmLanguages)) {
unset($languages[$key]);
}
}
$lists['language'] = JHTML::_('select.genericlist', $languages, 'vmlang', '', 'value', 'text', NULL, 'vmlang');
}
$this->assignRef('lists', $lists);
$this->loadHelper('html');
K2martHTMLHelper::title('K2MART_VIRTUEMART_MIGRATOR');
K2martHTMLHelper::toolbar();
K2martHTMLHelper::subMenu();
parent::display($tpl);
}
开发者ID:Gskflute,项目名称:joomla25,代码行数:32,代码来源:view.html.php
示例12: isHome
/**
* Detect is this page are frontpage?
*
* @return boolean Is frontpage?
*/
public static function isHome()
{
$langPath = null;
$tag = null;
$lang = \JFactory::getLanguage();
// For multi language
if (\JPluginHelper::isEnabled('system', 'languagefilter')) {
$tag = $lang->getTag();
$langCodes = \JLanguageHelper::getLanguages('lang_code');
$langPath = $langCodes[$tag]->sef;
}
$uri = \JUri::getInstance();
$root = $uri::root(true);
// Get site route
$route = StringHelper::substr($uri->getPath(), StringHelper::strlen($root));
// Remove index.php
$route = str_replace('index.php', '', $route);
// If Multiple language enabled, we check first part of URI is language code or not.
if ($langPath) {
$params = ExtensionHelper::getParams('plg_system_languagefilter');
if ($tag == $lang->getDefault() && $params->get('remove_default_prefix', 0)) {
$langPath = '';
}
// If route equals lang path, means it is home route.
if (trim($route, '/') == $langPath && !$uri->getVar('option')) {
return true;
}
} else {
if (!trim($route, '/') && !$uri->getVar('option')) {
return true;
}
}
return false;
}
开发者ID:lyrasoft,项目名称:lyrasoft.github.io,代码行数:39,代码来源:Ezset.php
示例13: _getOptions
/**
* Method to get a list of options for a list input.
*
* @return array An array of JHtml options.
*/
protected function _getOptions()
{
jimport('joomla.language.helper');
$client = (string) $this->_element->attributes()->client;
$options = array_merge(parent::_getOptions(), JLanguageHelper::createLanguageList($this->value, constant('JPATH_' . strtoupper($client)), true));
return $options;
}
开发者ID:joebushi,项目名称:joomla,代码行数:12,代码来源:language.php
示例14: displayAssociations
/**
* Method to display in frontend the associations for a given article
*
* @param integer $id Id of the article
*
* @return array An array containing the association URL and the related language object
*
* @since __DEPLOY_VERSION__
*/
public static function displayAssociations($id)
{
$return = array();
if ($associations = self::getAssociations($id)) {
$levels = JFactory::getUser()->getAuthorisedViewLevels();
$languages = JLanguageHelper::getLanguages();
foreach ($languages as $language) {
// Do not display language when no association
if (empty($associations[$language->lang_code])) {
continue;
}
// Do not display language without frontend UI
if (!array_key_exists($language->lang_code, JLanguageMultilang::getSiteLangs())) {
continue;
}
// Do not display language without specific home menu
if (!array_key_exists($language->lang_code, JLanguageMultilang::getSiteHomePages())) {
continue;
}
// Do not display language without authorized access level
if (isset($language->access) && $language->access && !in_array($language->access, $levels)) {
continue;
}
$return[$language->lang_code] = array('item' => $associations[$language->lang_code], 'language' => $language);
}
}
return $return;
}
开发者ID:eshiol,项目名称:joomla-cms,代码行数:37,代码来源:association.php
示例15: getInput
/**
* Method to get the field input markup.
*
* @return string The field input markup.
*
* @since 11.1
*/
protected function getInput()
{
$html = array();
$thisid = $this->id;
$values = $this->value;
$class = $this->class;
$languages = JLanguageHelper::getLanguages();
foreach ($languages as $lang) {
$language = new JLanguage($lang->lang_code);
$this->class = $class . ($language->isRTL() ? ' rtl' : ' ltr');
$this->element['label'] = $lang->title;
$this->name = 'jform[' . $this->fieldname . '][' . $lang->lang_code . ']';
$this->id = $thisid . '_' . $lang->lang_code;
$this->value = array_key_exists($lang->lang_code, $values) ? $values[$lang->lang_code] : '';
$html[] = '<div class="control-group">';
$html[] = '<div class="control-label">';
$html[] = parent::getLabel();
$html[] = '</div>';
$html[] = '<div class="controls">';
$html[] = parent::getInput();
$html[] = '</div>';
$html[] = '</div>';
}
return implode($html);
}
开发者ID:smhnaji,项目名称:sdnet,代码行数:32,代码来源:multilang.php
示例16: preprocessForm
/**
* Auto-populate the model state.
*
* Note. Calling getState in this method will result in recursion.
*
* @return void
* @since 3.0
*/
protected function preprocessForm(JForm $form, $data, $group = 'jevents')
{
// Association content items
$app = JFactory::getApplication();
$assoc = false && JLanguageAssociations::isEnabled() && JFactory::getApplication()->isAdmin();
if ($assoc) {
$languages = JLanguageHelper::getLanguages('lang_code');
$addform = new SimpleXMLElement('<form />');
$fields = $addform->addChild('fields');
$fields->addAttribute('name', 'associations');
$fieldset = $fields->addChild('fieldset');
$fieldset->addAttribute('name', 'item_associations');
$fieldset->addAttribute('description', 'COM_JEVENTS_ITEM_ASSOCIATIONS_FIELDSET_DESC');
$add = false;
foreach ($languages as $tag => $language) {
if (empty($data->language) || $tag != $data->language) {
$add = true;
$field = $fieldset->addChild('field');
$field->addAttribute('name', $tag);
$field->addAttribute('type', 'modal_article');
$field->addAttribute('language', $tag);
$field->addAttribute('label', $language->title);
$field->addAttribute('translate_label', 'false');
$field->addAttribute('edit', 'true');
$field->addAttribute('clear', 'true');
}
}
if ($add) {
$form->load($addform, false);
}
}
parent::preprocessForm($form, $data, $group);
}
开发者ID:site4com,项目名称:prometheus,代码行数:41,代码来源:icalevent.php
示例17: getOptions
/**
* Method to get the field options.
*
* @return array The field option objects.
*
* @since 11.1
*/
protected function getOptions()
{
// Initialize some field attributes.
$client = (string) $this->element['client'];
if ($client != 'site' && $client != 'administrator') {
$client = 'site';
}
// Merge any additional options in the XML definition.
$options = array_merge(parent::getOptions(), JLanguageHelper::createLanguageList($this->value, constant('JPATH_' . strtoupper($client)), true, true));
// Set the default value active language
if ($langParams = JComponentHelper::getParams('com_languages')) {
switch ((string) $this->value) {
case 'site':
case 'frontend':
case '0':
$this->value = $langParams->get('site', 'en-GB');
break;
case 'admin':
case 'administrator':
case 'backend':
case '1':
$this->value = $langParams->get('administrator', 'en-GB');
break;
case 'active':
case 'auto':
$lang = JFactory::getLanguage();
$this->value = $lang->getTag();
break;
default:
break;
}
}
return $options;
}
开发者ID:kosir,项目名称:wp-pipes,代码行数:41,代码来源:language.php
示例18: getOptions
/**
* Method to get the field options.
*
* @return array The field option objects.
*
* @since 1.6
*/
protected function getOptions()
{
$app = JFactory::getApplication();
// Detect the native language.
$native = JLanguageHelper::detectLanguage();
if (empty($native)) {
$native = 'en-GB';
}
// Get a forced language if it exists.
$forced = $app->getLocalise();
if (!empty($forced['language'])) {
$native = $forced['language'];
}
// If a language is already set in the session, use this instead
$model = new InstallationModelSetup();
$options = $model->getOptions();
if (isset($options['language'])) {
$native = $options['language'];
}
// Get the list of available languages.
$options = JLanguageHelper::createLanguageList($native);
if (!$options || $options instanceof Exception) {
$options = array();
} else {
usort($options, array($this, '_sortLanguages'));
}
// Set the default value from the native language.
$this->value = $native;
// Merge any additional options in the XML definition.
$options = array_merge(parent::getOptions(), $options);
return $options;
}
开发者ID:Tommar,项目名称:remate,代码行数:39,代码来源:language.php
示例19: loadMultilangData
function loadMultilangData($prepareElementCallback)
{
$languages = JLanguageHelper::getLanguages();
$app = JApplication::getInstance('site');
$menu = $app->getMenu();
$config = JFactory::getConfig();
$sef = $config->get('sef', 0);
$sefRewrite = $config->get('sef_rewrite', 0);
$defaultLangCode = JFactory::getLanguage()->getDefault();
$websites = array();
//$websites['*'] = $menu->getDefault('*'); // TODO add?
$languageFilterEnabled = JPluginHelper::isEnabled('system', 'languagefilter');
if (!$languageFilterEnabled || $sef != '1') {
// TODO check also if sef is enabled
return $websites;
}
$oldLanguageFilterValue = $app->setLanguageFilter(true);
// necessary that $menu->getDefault() works
foreach ($languages as $language) {
$langCode = $language->lang_code;
$default = $menu->getDefault($langCode);
if ($default && $default->language == $langCode) {
$websites[$langCode] = $prepareElementCallback($language, $langCode, $defaultLangCode, $sefRewrite);
}
}
$app->setLanguageFilter($oldLanguageFilterValue);
return $websites;
}
开发者ID:webguerilla,项目名称:joomla-linkchecker,代码行数:28,代码来源:shared_functions.php
示例20: getContacts
public static function getContacts()
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)->select('u.name, count(cd.language) as counted, MAX(cd.language=' . $db->quote('*') . ') as all_languages')->from('#__users AS u')->join('LEFT', '#__contact_details AS cd ON cd.user_id=u.id')->join('LEFT', '#__languages as l on cd.language=l.lang_code')->where('EXISTS (SELECT * from #__content as c where c.created_by=u.id)')->where('(l.published=1 or cd.language=' . $db->quote('*') . ')')->where('cd.published=1')->group('u.id')->having('(counted !=' . count(JLanguageHelper::getLanguages()) . ' OR all_languages=1)')->having('(counted !=1 OR all_languages=0)');
$db->setQuery($query);
return $db->loadObjectList();
}
开发者ID:01J,项目名称:skazkipronebo,代码行数:7,代码来源:multilangstatus.php
注:本文中的JLanguageHelper类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论