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


PHP JFactory::language方法代码示例

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


在下文中一共展示了JFactory::language方法的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: 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

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

示例4: setUp

 /**
  * Setup for testing.
  *
  * @return  void
  *
  * @since   11.3
  */
 public function setUp()
 {
     parent::setUp();
     // We are only coupled to Document and Language in JFactory.
     $this->saveFactoryState();
     JFactory::$language = $this->getMockLanguage();
 }
开发者ID:rvsjoen,项目名称:joomla-platform,代码行数:14,代码来源:JHtmlDateTest.php

示例5: setUp

 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  *
  * @return  void
  *
  * @since   3.2
  */
 public function setUp()
 {
     parent::setUp();
     // Add JApplication and JLanguage dependencies
     $this->saveFactoryState();
     JFactory::$language = $this->getMockLanguage();
     JFactory::$application = $this->getMockCmsApp();
 }
开发者ID:joomla-projects,项目名称:media-manager-improvement,代码行数:16,代码来源:JCategoriesTest.php

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

示例7: setUp

 /**
  * Setup for testing.
  *
  * @return  void
  *
  * @since   11.3
  */
 public function setUp()
 {
     parent::setUp();
     $_SERVER['HTTP_HOST'] = self::TEST_HTTP_HOST;
     $_SERVER['HTTP_USER_AGENT'] = self::TEST_USER_AGENT;
     // Get a new JApplicationWebInspector instance.
     $this->inspector = new JApplicationWebInspector();
     // We are only coupled to Document and Language in JFactory.
     $this->saveFactoryState();
     JFactory::$document = $this->getMockDocument();
     JFactory::$language = $this->getMockLanguage();
 }
开发者ID:raquelsa,项目名称:Joomla,代码行数:19,代码来源:JApplicationWebTest.php

示例8: restoreFactoryState

 /**
  * Sets the Factory pointers
  *
  * @return  void
  */
 protected function restoreFactoryState()
 {
     \JFactory::$application = $this->savedFactoryState['application'];
     \JFactory::$config = $this->savedFactoryState['config'];
     \JFactory::$dates = $this->savedFactoryState['dates'];
     \JFactory::$session = $this->savedFactoryState['session'];
     \JFactory::$language = $this->savedFactoryState['language'];
     \JFactory::$document = $this->savedFactoryState['document'];
     \JFactory::$acl = $this->savedFactoryState['acl'];
     \JFactory::$database = $this->savedFactoryState['database'];
     \JFactory::$mailer = $this->savedFactoryState['mailer'];
 }
开发者ID:Joal01,项目名称:fof,代码行数:17,代码来源:FOFTestCase.php

示例9: setUp

 /**
  * Setup for testing.
  *
  * @return  void
  *
  * @since   3.1
  */
 public function setUp()
 {
     parent::setUp();
     // Get mock CMS application
     $app = $this->getMockCmsApp();
     $app->expects($this->any())->method('getTemplate')->willReturn('foobar');
     // Whilst we inject the application into this class we still need the language
     // property to be set for JText and the application for inclusion of scripts (such as bootstrap for the tooltips)
     $this->saveFactoryState();
     JFactory::$language = $this->getMockLanguage();
     JFactory::$application = $app;
     $this->app = $app;
 }
开发者ID:klas,项目名称:joomla-cms,代码行数:20,代码来源:JPaginationTest.php

示例10: setUp

 /**
  * Setup for testing.
  *
  * @return  void
  *
  * @since   3.6
  */
 public function setUp()
 {
     parent::setUp();
     $this->saveFactoryState();
     JFactory::$document = $this->getMockDocument();
     JFactory::$language = $this->getMockLanguage();
     JFactory::$session = $this->getMockSession();
     $this->backupServer = $_SERVER;
     $_SERVER['HTTP_HOST'] = self::TEST_HTTP_HOST;
     $_SERVER['HTTP_USER_AGENT'] = self::TEST_USER_AGENT;
     $_SERVER['REQUEST_URI'] = self::TEST_REQUEST_URI;
     $_SERVER['SCRIPT_NAME'] = '/index.php';
 }
开发者ID:joomla-projects,项目名称:media-manager-improvement,代码行数:20,代码来源:JLanguageMultilangTest.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.1
  */
 protected function setUp()
 {
     parent::setUp();
     $this->saveFactoryState();
     JFactory::$application = $this->getMockCmsApp();
     JFactory::$config = $this->getMockConfig();
     JFactory::$document = $this->getMockDocument();
     JFactory::$language = $this->getMockLanguage();
     JFactory::$session = $this->getMockSession();
     $this->backupServer = $_SERVER;
     $_SERVER['HTTP_HOST'] = 'example.com';
     $_SERVER['SCRIPT_NAME'] = '';
 }
开发者ID:sural98,项目名称:joomla-cms,代码行数:21,代码来源:JFormFieldCalendarTest.php

示例12: setUp

 /**
  * Prepares the environment before running a test.
  *
  * @return  void
  *
  * @since   1.0
  */
 protected function setUp()
 {
     parent::setUp();
     $_SERVER['HTTP_HOST'] = self::TEST_HTTP_HOST;
     $_SERVER['HTTP_USER_AGENT'] = self::TEST_USER_AGENT;
     $_SERVER['REQUEST_URI'] = self::TEST_REQUEST_URI;
     $_SERVER['SCRIPT_NAME'] = '/index.php';
     // Get a new JApplicationWebInspector instance.
     $this->_instance = new WebServiceApplicationWebInspector();
     // We are only coupled to Document and Language in JFactory.
     $this->saveFactoryState();
     JFactory::$document = $this->getMockDocument();
     JFactory::$language = $this->getMockLanguage();
 }
开发者ID:prox91,项目名称:joomla-dev,代码行数:21,代码来源:webTest.php

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

示例14: testGetDate

 /**
  * Tests the JFactory::getDate method.
  *
  * @return  void
  *
  * @since   11.3
  */
 public function testGetDate()
 {
     JFactory::$language = $this->getMockLanguage();
     $date = JFactory::getDate('2001-01-01 01:01:01');
     $this->assertThat((string) $date, $this->equalTo('2001-01-01 01:01:01'), 'Tests that a date passed in comes back unchanged.');
     $date = JFactory::getDate('now');
     sleep(2);
     $date2 = JFactory::getDate('now');
     $this->assertThat($date2, $this->equalTo($date), 'Tests that the cache for the same time is working.');
     $tz = 'Etc/GMT+0';
     $date = JFactory::getDate('2001-01-01 01:01:01', $tz);
     $this->assertThat((string) $date, $this->equalTo('2001-01-01 01:01:01'), 'Tests that a date passed in with UTC timezone string comes back unchanged.');
     $tz = new DateTimeZone('Etc/GMT+0');
     $date = JFactory::getDate('2001-01-01 01:01:01', $tz);
     $this->assertThat((string) $date, $this->equalTo('2001-01-01 01:01:01'), 'Tests that a date passed in with UTC timezone comes back unchanged.');
 }
开发者ID:raquelsa,项目名称:Joomla,代码行数:23,代码来源:JFactoryTest.php

示例15: display

 function display($tpl = null)
 {
     $this->canDo = JCKHelper::getActions();
     $this->app = JFactory::getApplication();
     $this->user = JFactory::getUser();
     $this->state = $this->get('State');
     $this->item = $this->get('Item');
     $this->form = $this->get('Form');
     $this->params = $this->prepareForm($this->item);
     if (!$this->canDo->get('core.edit')) {
         $this->app->redirect(JRoute::_('index.php?option=com_jckman&view=list', false), JText::_('COM_JCKMAN_PLUGIN_PERM_NO_EDIT'), 'error');
         return false;
     }
     //end if
     //language
     $lang = JCKHelper::getLanguage();
     $tag = $lang->getTag();
     JFactory::$language = $lang;
     //override Joomla default language class
     $name = $this->item->name;
     $plugin = 'plg_jck' . $name;
     $pluginOverideFile = JPATH_COMPONENT . '/language/overrides/' . $tag . '.' . $plugin . '.ini';
     $pluginLangFile = JPATH_COMPONENT . '/language/' . $tag . '/' . $tag . '.' . $plugin . '.ini';
     if (JFile::exists($pluginOverideFile)) {
         //check in language overrides to see if user has installed an override language file
         $lang->loadFile($pluginOverideFile, $plugin);
     } else {
         if (JFile::exists($pluginLangFile)) {
             //load core language file if it exists
             $lang->load($plugin, JPATH_COMPONENT);
         } else {
             //load english default languge
             if (JFile::exists(JPATH_COMPONENT . '/language/en-GB/en-GB.plg_jck' . $name . '.ini')) {
                 $lang->load($plugin, JPATH_COMPONENT, 'en-GB');
             }
         }
     }
     $this->item->description = JText::_($this->item->description);
     $this->form->bind($this->item);
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JCKHelper::error(implode("\n", $errors));
         return false;
     }
     $this->addToolbar();
     parent::display($tpl);
 }
开发者ID:enjoy2000,项目名称:714water,代码行数:47,代码来源:view.html.php


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