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


PHP JLanguage::getInstance方法代码示例

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


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

示例1: switchAdminLanguage

 /**
  * Task to switch the administrator language.
  *
  * @return  void
  */
 public function switchAdminLanguage()
 {
     // Check for request forgeries.
     JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
     $cid = $this->input->get('cid', '');
     $model = $this->getModel('installed');
     // Fetching the language name from the xx-XX.xml
     $file = JPATH_ADMINISTRATOR . '/language/' . $cid . '/' . $cid . '.xml';
     $info = JInstaller::parseXMLInstallFile($file);
     $languageName = $info['name'];
     if ($model->switchAdminLanguage($cid)) {
         // Switching to the new language for the message
         $language = JFactory::getLanguage();
         $newLang = JLanguage::getInstance($cid);
         JFactory::$language = $newLang;
         JFactory::getApplication()->loadLanguage($language = $newLang);
         $newLang->load('com_languages', JPATH_ADMINISTRATOR);
         $msg = JText::sprintf('COM_LANGUAGES_MSG_SWITCH_ADMIN_LANGUAGE_SUCCESS', $languageName);
         $type = 'message';
     } else {
         $msg = $model->getError();
         $type = 'error';
     }
     $this->setRedirect('index.php?option=com_languages&view=installed', $msg, $type);
 }
开发者ID:Rai-Ka,项目名称:joomla-cms,代码行数:30,代码来源:installed.php

示例2: setUp

 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  */
 protected function setUp()
 {
     parent::setUp();
     $this->saveFactoryState();
     JFactory::$language = JLanguage::getInstance('en-GB');
     $this->object = new JDocumentHTML();
 }
开发者ID:SysBind,项目名称:joomla-cms,代码行数:11,代码来源:JDocumentHTMLTest.php

示例3: setFile

 /**
  * 
  *
  * 
  */
 protected function setFile()
 {
     $params = JComponentHelper::getParams('com_languages');
     $frontend_lang = $params->get('site', 'en-GB');
     $language = JLanguage::getInstance($frontend_lang);
     // get language file for edit
     $language = JFactory::getLanguage();
     $language->load('com_jdownloads');
     $lang_file = JLanguage::getLanguagePath(JPATH_SITE);
     $lang_file .= DS . $frontend_lang . DS . $frontend_lang . '.com_jdownloads.ini';
     @chmod($lang_file, 0755);
     clearstatcache();
     if (is_writable($lang_file) == false) {
         $language_writable = false;
     } else {
         $language_writable = true;
     }
     if ($language_writable) {
         $f = fopen($lang_file, "r");
         $language_text = fread($f, filesize($lang_file));
         $this->languagetext = htmlspecialchars($language_text);
     } else {
         $this->languagetext = '';
     }
     $this->languagefile = $lang_file;
     $this->languagefile_writable = $language_writable;
 }
开发者ID:ashanrupasinghe,项目名称:dnp,代码行数:32,代码来源:view.html.php

示例4: getItem

 public function getItem($id = 'en-GB', $refresh = false, $emptyState = true)
 {
     if (empty($this->_item)) {
         $lang = JLanguage::getInstance($id);
         // Load only site language (Email language costants should be only there)
         $lang->load('com_citruscart', JPATH_ADMINISTRATOR, $id, true);
         $temp_paths = $lang->getPaths('com_citruscart');
         foreach ($temp_paths as $p => $k) {
             $path = $p;
         }
         $result = new JObject();
         $result->name = $lang->getName();
         $result->code = $lang->getTag();
         $result->path = $path;
         $result->strings = array();
         // Load File and Take only the constants that contains "EMAIL_"
         $file = new DSCParameter();
         $file->loadFile($path);
         $strings = $file->toArray();
         $result_strings = array();
         foreach ($strings as $k => $v) {
             // Only if it is a prefix!
             if (stripos($k, $this->email_prefix) === 0) {
                 $result_strings[$k] = $v;
             }
         }
         $result->strings = array('file' => $path, 'strings' => $result_strings);
         JFactory::getApplication()->triggerEvent('onPrepare' . $this->getTable()->get('_suffix'), array(&$result));
         $this->_item = $result;
     }
     return $this->_item;
 }
开发者ID:joomlacorner,项目名称:citruscart,代码行数:32,代码来源:emails.php

示例5: 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

示例6: testGetInstance

 /**
  * @todo Implement testGetInstance().
  */
 public function testGetInstance()
 {
     // This method returns the language in use
     // English is the default language
     $langEqual = 'en-GB';
     $langNotEqual = 'es-ES';
     $lang = new JLanguage('');
     $listEqual = $lang->getInstance($langEqual);
     $this->assertObjectHasAttribute('metadata', $listEqual);
     $this->assertObjectNotHasAttribute('name', $listEqual);
     $this->assertTrue($listEqual->exists($langEqual));
     $this->assertFalse($listEqual->exists($langNotEqual));
     $listNotEqual = $lang->getInstance($langNotEqual);
     $this->assertObjectHasAttribute('metadata', $listNotEqual);
     $this->assertObjectNotHasAttribute('name', $listNotEqual);
     $this->assertTrue($listNotEqual->exists($langEqual));
 }
开发者ID:nguyen1986vn,项目名称:atj25,代码行数:20,代码来源:JLanguageTest.php

示例7: testGetInstance

 /**
  * @covers JLanguage::getInstance
  */
 public function testGetInstance()
 {
     $instance = JLanguage::getInstance(null);
     $this->assertInstanceOf('JLanguage', $instance);
     $instance = JLanguage::getInstance(null, true);
     $this->assertInstanceOf('JLanguage', $instance);
     $this->assertTrue($instance->getDebug());
 }
开发者ID:rvsjoen,项目名称:joomla-platform,代码行数:11,代码来源:JLanguageTest.php

示例8: setUp

 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  *
  * @return  void
  *
  * @since   3.1
  */
 protected function setUp()
 {
     parent::setUp();
     $this->saveFactoryState();
     JFactory::$application = $this->getMockCmsApp();
     JFactory::$language = JLanguage::getInstance('en-GB', false);
     $this->backupServer = $_SERVER;
     $_SERVER['HTTP_HOST'] = 'example.com';
     $_SERVER['SCRIPT_NAME'] = '';
 }
开发者ID:eshiol,项目名称:joomla-cms,代码行数:18,代码来源:JHtmlBatchTest.php

示例9: transliterate

 public static function transliterate($string, $languageId)
 {
     if ($languageId == '*') {
         $params = JComponentHelper::getParams('com_languages');
         $tag = $params->get('site');
     } else {
         $tag = $languageId;
     }
     $language = JLanguage::getInstance($tag);
     $string = $language->transliterate($string);
     $string = JFilterOutput::stringURLSafe($string);
     return $string;
 }
开发者ID:Naldo100,项目名称:k2-v3-dev-build,代码行数:13,代码来源:language.php

示例10: stringURLSafe

 /**
  * This method processes a string and replaces all accented UTF-8 characters by unaccented
  * ASCII-7 "equivalents", whitespaces are replaced by hyphens and the string is lowercase.
  *
  * @param   string  $string    String to process
  * @param   string  $language  Language to transilterate to
  *
  * @return  string  Processed string
  *
  * @since   11.1
  */
 public static function stringURLSafe($string, $language = '')
 {
     // Remove any '-' from the string since they will be used as concatenaters
     $str = str_replace('-', ' ', $string);
     // Transliterate on the language requested (fallback to current language if not specified)
     $lang = $language == '' || $language == '*' ? JFactory::getLanguage() : JLanguage::getInstance($language);
     $str = $lang->transliterate($str);
     // Trim white spaces at beginning and end of alias and make lowercase
     $str = trim(StringHelper::strtolower($str));
     // Remove any duplicate whitespace, and ensure all characters are alphanumeric
     $str = preg_replace('/(\\s|[^A-Za-z0-9\\-])+/', '-', $str);
     // Trim dashes at beginning and end of alias
     $str = trim($str, '-');
     return $str;
 }
开发者ID:eshiol,项目名称:joomla-cms,代码行数:26,代码来源:output.php

示例11: setUp

 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  *
  * @return  void
  *
  * @since   3.0
  */
 protected function setUp()
 {
     parent::setUp();
     // Store the factory state so we can mock the necessary objects
     $this->saveFactoryState();
     JFactory::$application = $this->getMockCmsApp();
     JFactory::$config = $this->getMockConfig();
     JFactory::$session = $this->getMockSession();
     JFactory::$language = JLanguage::getInstance('en-GB');
     // Set up our mock config
     $this->config = JFactory::getConfig();
     $this->config->set('helpurl', 'https://help.joomla.org/proxy/index.php?option=com_help&keyref=Help{major}{minor}:{keyref}');
     // Load the admin en-GB.ini language file
     JFactory::getLanguage()->load('', JPATH_ADMINISTRATOR);
 }
开发者ID:nirpan,项目名称:joomla-cms,代码行数:23,代码来源:JHelpTest.php

示例12: getForm

 /**
  * Method to get the record form.
  *
  * @param   array    $data      Data for the form.
  * @param   boolean  $loadData  True if the form is to load its own data (default case), false if not.
  *
  * @return  mixed A JForm object on success, false on failure.
  *
  * @since   2.5
  */
 public function getForm($data = array(), $loadData = true)
 {
     // Get the form.
     $form = $this->loadForm('com_languages.override', 'override', array('control' => 'jform', 'load_data' => $loadData));
     if (empty($form)) {
         return false;
     }
     $client = $this->getState('filter.client', 'site');
     $language = $this->getState('filter.language', 'en-GB');
     $langName = JLanguage::getInstance($language)->getName();
     if (!$langName) {
         // If a language only exists in frontend, it's meta data cannot be
         // loaded in backend at the moment, so fall back to the language tag.
         $langName = $language;
     }
     $form->setValue('client', null, JText::_('COM_LANGUAGES_VIEW_OVERRIDE_CLIENT_' . strtoupper($client)));
     $form->setValue('language', null, JText::sprintf('COM_LANGUAGES_VIEW_OVERRIDE_LANGUAGE', $langName, $language));
     $form->setValue('file', null, JPath::clean(constant('JPATH_' . strtoupper($client)) . '/language/overrides/' . $language . '.override.ini'));
     return $form;
 }
开发者ID:eshiol,项目名称:joomla-cms,代码行数:30,代码来源:override.php

示例13: onContentAfterSave

 /**
  * Example after save content method
  * Article is passed by reference, but after the save, so no changes will be saved.
  * Method is called right after the content is saved
  *
  * @param   string   $context  The context of the content passed to the plugin (added in 1.6)
  * @param   object   $article  A JTableContent object
  * @param   boolean  $isNew    If the content is just about to be created
  *
  * @return  boolean   true if function not enabled, is in frontend or is new. Else true or
  *                    false depending on success of save function.
  *
  * @since   1.6
  */
 public function onContentAfterSave($context, $article, $isNew)
 {
     // Check we are handling the frontend edit form.
     if ($context != 'com_content.form') {
         return true;
     }
     // Check if this function is enabled.
     if (!$this->params->def('email_new_fe', 1)) {
         return true;
     }
     // Check this is a new article.
     if (!$isNew) {
         return true;
     }
     $db = JFactory::getDbo();
     $query = $db->getQuery(true)->select($db->quoteName('id'))->from($db->quoteName('#__users'))->where($db->quoteName('sendEmail') . ' = 1')->where($db->quoteName('block') . ' = 0');
     $db->setQuery($query);
     $users = (array) $db->loadColumn();
     if (empty($users)) {
         return true;
     }
     $user = JFactory::getUser();
     // Messaging for new items
     JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_messages/models', 'MessagesModel');
     JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_messages/tables');
     $default_language = JComponentHelper::getParams('com_languages')->get('administrator');
     $debug = JFactory::getConfig()->get('debug_lang');
     $result = true;
     foreach ($users as $user_id) {
         if ($user_id != $user->id) {
             // Load language for messaging
             $receiver = JUser::getInstance($user_id);
             $lang = JLanguage::getInstance($receiver->getParam('admin_language', $default_language), $debug);
             $lang->load('com_content');
             $message = array('user_id_to' => $user_id, 'subject' => $lang->_('COM_CONTENT_NEW_ARTICLE'), 'message' => sprintf($lang->_('COM_CONTENT_ON_NEW_CONTENT'), $user->get('name'), $article->title));
             $model_message = JModelLegacy::getInstance('Message', 'MessagesModel');
             $result = $model_message->save($message);
         }
     }
     return $result;
 }
开发者ID:joomla-projects,项目名称:media-manager-improvement,代码行数:55,代码来源:joomla.php

示例14: onContentAfterSave

 /**
  * Example after save content method
  * Article is passed by reference, but after the save, so no changes will be saved.
  * Method is called right after the content is saved
  *
  * @param	string		The context of the content passed to the plugin (added in 1.6)
  * @param	object		A JTableContent object
  * @param	bool		If the content is just about to be created
  * @since	1.6
  */
 public function onContentAfterSave($context, &$article, $isNew)
 {
     // Check we are handling the frontend edit form.
     if ($context != 'com_content.form') {
         return true;
     }
     // Check if this function is enabled.
     if (!$this->params->def('email_new_fe', 1)) {
         return true;
     }
     // Check this is a new article.
     if (!$isNew) {
         return true;
     }
     $user = User::getRoot();
     // Messaging for new items
     JModelLegacy::addIncludePath(PATH_CORE . '/components/com_messages/admin/models', 'MessagesModel');
     JTable::addIncludePath(PATH_CORE . '/components/com_messages/admin/tables');
     $db = App::get('db');
     $db->setQuery('SELECT id FROM #__users WHERE sendEmail = 1');
     $users = (array) $db->loadColumn();
     $default_language = Component::params('com_languages')->get('administrator');
     $debug = Config::get('debug_lang');
     foreach ($users as $user_id) {
         if ($user_id != $user->id) {
             // Load language for messaging
             $receiver = User::getInstance($user_id);
             $lang = JLanguage::getInstance($receiver->getParam('admin_language', $default_language), $debug);
             $lang->load('com_content');
             $message = array('user_id_to' => $user_id, 'subject' => $lang->_('COM_CONTENT_NEW_ARTICLE'), 'message' => sprintf($lang->_('COM_CONTENT_ON_NEW_CONTENT'), $user->get('name'), $article->title));
             $model_message = JModelLegacy::getInstance('Message', 'MessagesModel');
             $model_message->save($message);
         }
     }
     return true;
 }
开发者ID:mined-gatech,项目名称:hubzero-cms,代码行数:46,代码来源:joomla.php

示例15: jimport

 /**
  * Create a language object
  *
  * @access private
  * @return object JLanguage
  * @since 1.5
  */
 private static function &_createLanguage()
 {
     jimport('joomla.language.language');
     $conf =& JFactory::getConfig();
     $locale = $conf->getValue('config.language');
     $lang =& JLanguage::getInstance($locale);
     $lang->setDebug($conf->getValue('config.debug_lang'));
     return $lang;
 }
开发者ID:stonyyi,项目名称:anahita,代码行数:16,代码来源:factory.php


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