本文整理汇总了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);
}
示例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'];
}
示例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();
}
示例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();
}
示例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();
}
示例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'] = '';
}
示例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();
}
示例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'];
}
示例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;
}
示例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';
}
示例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'] = '';
}
示例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();
}
示例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);
}
示例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.');
}
示例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);
}