本文整理汇总了PHP中JLanguage::load方法的典型用法代码示例。如果您正苦于以下问题:PHP JLanguage::load方法的具体用法?PHP JLanguage::load怎么用?PHP JLanguage::load使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JLanguage
的用法示例。
在下文中一共展示了JLanguage::load方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Constructor method for widget base object
*/
public function __construct()
{
$this->app = JFactory::getApplication();
$this->session = JFactory::getSession();
$this->request = $this->app->input;
$this->dbo = JFactory::getDBO();
$this->queryMethod = version_compare(JSNTplHelper::getJoomlaVersion(), '3.0', '>=') ? 'execute' : 'query';
$this->language = JFactory::getLanguage();
$this->language->load('tpl_' . $this->request->getCmd('template'), JPATH_ROOT);
$this->language->load('lib_joomla');
$this->_parseTemplateInfo($this->request->getCmd('template'));
}
示例2: getItemModel
/**
* Return an instance of a model that loaded base on configuration
* @param mixed $config
* @param object $state
* @param string $coverage
* @return JModelList
*/
private function getItemModel($config, $state, $coverage)
{
$path = '';
// Load model file
if (!$config['path']) {
$path = JPATH_ADMINISTRATOR . '/';
} else {
$path = $config['path'] . '/';
}
require_once $path . $config['modelfile'];
// Load component language
$this->language->load($config['language'], JPATH_ADMINISTRATOR);
// Create model instance
$model = new $config['modelname'](array('state' => $state));
$model->getState('filter.search');
$currentCoverage = $this->app->getUserStateFromRequest('components.selected', 'tab');
if ($currentCoverage == $coverage) {
$order = $this->app->getUserStateFromRequest("{$currentCoverage}.{$config['modelname']}.order", 'filter_order', $config['order']);
$orderDir = $this->app->getUserStateFromRequest("{$currentCoverage}.{$config['modelname']}.orderDir", 'filter_order_Dir', 'asc');
$state->set('list.ordering', $order);
$state->set('list.direction', $orderDir);
}
$state->set('filter.search', $this->keyword);
$state->set('filter.published', 'all');
$state->set('filter.state', 'all');
if (isset($config['filters']) && is_array($config['filters'])) {
foreach ($config['filters'] as $key => $value) {
$state->set($key, $value);
}
}
return $model;
}
示例3: testLoad
/**
* @todo Implement testLoad().
*/
public function testLoad()
{
// This method loads an extension language
$extension1 = 'com_admin';
$extension2 = 'com_sobi2';
$basePath = '../../administrator/';
$l1 = 'en-GB';
$l2 = 'es-ES';
$reloaded1 = false;
$reloaded2 = true;
$lang = new JLanguage('');
// com_admin (exist), OK
$this->assertTrue($lang->load($extension1, $basePath, $l1, $reloaded1));
$this->assertTrue($lang->load($extension1, $basePath, $l2, $reloaded1));
// com_sobi2 (not exist), KO
$this->assertFalse($lang->load($extension2, $basePath, $l1, $reloaded1));
$this->assertFalse($lang->load($extension2, $basePath, $l2, $reloaded1));
// com_admin (exist), OK
$this->assertTrue($lang->load($extension1, $basePath, $l1, $reloaded2));
$this->assertTrue($lang->load($extension1, $basePath, $l2, $reloaded2));
// com_sobi2 (not exist), KO
$this->assertFalse($lang->load($extension2, $basePath, $l1, $reloaded2));
$this->assertFalse($lang->load($extension2, $basePath, $l2, $reloaded2));
}
示例4: com_install
function com_install()
{
$result = true;
$app = JFactory::getApplication();
if (version_compare(JVERSION, "1.6", "lt")) {
$lang = new JLanguage();
$lang->load("com_sro", JPATH_ROOT . "/administrator/components/com_sro");
}
$required_php = "5.3.0";
if (version_compare(PHP_VERSION, $required_php, "lt")) {
$app->enqueueMessage(JText::sprintf("COM_SRO_INSTALL_INCOMPATIBLE_PHP_VERSION", PHP_VERSION, $required_php), "error");
return false;
}
$adminpath = JPATH_ROOT . "/administrator/components/com_sro/";
$adminlangpath = JPATH_ROOT . "/administrator/language/ru-RU/";
$config = "config.xml";
$config15 = "cnf15.xml";
transfer();
JFile::move($adminpath . "javascriptdisabled.html", JPATH_ROOT);
if (version_compare(JVERSION, "1.6", "lt")) {
$result = JFile::move($config15, $config, $adminpath);
$result = $result && JFile::move($adminpath . "language/ru-RU/ru-RU.com_sro.sys.ini", $adminlangpath . "ru-RU.com_sro.menu.ini");
$result = $result && JFile::move($adminpath . "language/ru-RU/ru-RU.com_sro.ini", $adminlangpath . "ru-RU.com_sro.ini");
alterdb();
} else {
JFile::delete($adminpath . $config15);
$oldlangfile = JPATH_ROOT . "/language/ru-RU/ru-RU.com_sro.ini";
if (JFile::exists($oldlangfile)) {
JFile::delete($oldlangfile);
}
$oldlangfile = JPATH_ROOT . "/administrator/language/ru-RU/ru-RU.com_sro.ini";
if (JFile::exists($oldlangfile)) {
JFile::delete($oldlangfile);
}
}
return $result;
}
示例5: addArticle
/**
* Create an article in a specific language
*
* @param stdClass $itemLanguage Language Object
* @param int $categoryId The id of the category where we want to add the article
*
* @return JTable Category Object
*
* @since 3.2
*/
public function addArticle($itemLanguage, $categoryId)
{
$db = JFactory::getDbo();
$newlanguage = new JLanguage($itemLanguage->language, false);
$newlanguage->load('plg_editors-xtd_article', JPATH_ADMINISTRATOR, $itemLanguage->language, true);
$title = $newlanguage->_('PLG_ARTICLE_BUTTON_ARTICLE');
$article = JTable::getInstance('Content');
$article->title = $title . ' (' . strtolower($itemLanguage->language) . ')';
$article->introtext = '<p>Lorem ipsum ad his scripta blandit partiendo, eum fastidii accumsan euripidis' . ' in, eum liber hendrerit an. Qui ut wisi vocibus suscipiantur, quo dicit' . ' ridens inciderint id. Quo mundi lobortis reformidans eu, legimus senserit' . 'definiebas an eos. Eu sit tincidunt incorrupte definitionem, vis mutat' . ' affert percipit cu, eirmod consectetuer signiferumque eu per. In usu latine' . 'equidem dolores. Quo no falli viris intellegam, ut fugit veritus placerat' . 'per. Ius id vidit volumus mandamus, vide veritus democritum te nec, ei eos' . 'debet libris consulatu.</p>';
$article->state = 1;
$article->created = JFactory::getDate()->toSql();
$article->created_by = $this->getAdminId();
$article->created_by_alias = 'Joomla';
$article->publish_up = JFactory::getDate()->toSql();
$article->publish_down = $db->getNullDate();
$article->version = 1;
$article->catid = $categoryId;
$article->metadata = '{"robots":"","author":"","rights":"","xreference":"","tags":null}';
$article->language = $itemLanguage->language;
$article->featured = 1;
// Check to make sure our data is valid
if (!$article->check()) {
return false;
}
// Now store the category
if (!$article->store(true)) {
return false;
}
// Get the new item ID
$newId = $article->get('id');
$query = $db->getQuery(true)->insert($db->quoteName('#__content_frontpage'))->values($newId . ', 0');
$db->setQuery($query);
if (!$db->execute()) {
return false;
}
return true;
}
示例6: die
defined('_JEXEC') or die('Restricted access');
$plans = $this->plans;
$guruModelguruEditplans = new guruModelguruEditplans();
$config = $guruModelguruEditplans->getConfigs();
$currency = $config["0"]["currency"];
$character = JTExt::_("GURU_CURRENCY_" . $currency);
$course_id = intval(JRequest::getVar("course_id", "0"));
$action = JRequest::getVar("action", "");
$my = JFactory::getUser();
$user_id = $my->id;
$db = JFactory::getDBO();
$document = JFactory::getDocument();
jimport('joomla.language.helper');
$lang_value = JLanguageHelper::detectLanguage();
$lang = new JLanguage();
$lang->load('com_guru', JPATH_BASE, $lang_value);
$Itemid = JRequest::getVar("Itemid", "0");
?>
<link rel="stylesheet" href="<?php
echo JURI::root() . 'components/com_guru/css/uikit.almost-flat.min.css';
?>
"/>
<div id="g_content" class="gru-content">
<?php
if ($action == "") {
?>
<form action="<?php
echo JRoute::_('index.php?option=com_guru&view=guruEditplans&task=buy&Itemid=' . intval($Itemid));
?>
示例7: addArticle
/**
* Create an article in a specific language.
*
* @param stdClass $itemLanguage Language Object.
* @param int $categoryId The id of the category where we want to add the article.
*
* @return JTable Category Object
*
* @since 3.2
*/
public function addArticle($itemLanguage, $categoryId)
{
$db = JFactory::getDbo();
$newlanguage = new JLanguage($itemLanguage->language, false);
$newlanguage->load('com_content.sys', JPATH_ADMINISTRATOR, $itemLanguage->language, true);
$title = $newlanguage->_('COM_CONTENT_CONTENT_TYPE_ARTICLE');
$article = JTable::getInstance('Content');
$data = array('title' => $title . ' (' . strtolower($itemLanguage->language) . ')', 'introtext' => '<p>Lorem ipsum ad his scripta blandit partiendo, eum fastidii accumsan euripidis' . ' in, eum liber hendrerit an. Qui ut wisi vocibus suscipiantur, quo dicit' . ' ridens inciderint id. Quo mundi lobortis reformidans eu, legimus senserit' . 'definiebas an eos. Eu sit tincidunt incorrupte definitionem, vis mutat' . ' affert percipit cu, eirmod consectetuer signiferumque eu per. In usu latine' . 'equidem dolores. Quo no falli viris intellegam, ut fugit veritus placerat' . 'per. Ius id vidit volumus mandamus, vide veritus democritum te nec, ei eos' . 'debet libris consulatu.</p>', 'images' => json_encode(array()), 'urls' => json_encode(array()), 'state' => 1, 'created' => JFactory::getDate()->toSql(), 'created_by' => $this->getAdminId(), 'created_by_alias' => 'Joomla', 'publish_up' => JFactory::getDate()->toSql(), 'publish_down' => $db->getNullDate(), 'version' => 1, 'catid' => $categoryId, 'metadata' => '{"robots":"","author":"","rights":"","xreference":"","tags":null}', 'metakey' => '', 'metadesc' => '', 'language' => $itemLanguage->language, 'featured' => 1, 'attribs' => array(), 'rules' => array());
// Bind the data to the table
if (!$article->bind($data)) {
return false;
}
// Check to make sure our data is valid.
if (!$article->check()) {
return false;
}
// Now store the category.
if (!$article->store(true)) {
return false;
}
// Get the new item ID.
$newId = $article->get('id');
$query = $db->getQuery(true)->insert($db->qn('#__content_frontpage'))->values($newId . ', 0');
$db->setQuery($query);
if (!$db->execute()) {
return false;
}
return true;
}
示例8: strpos
static function send_confirmation_email($username, $email, $course_id, $state)
{
$app = JFactory::getApplication();
$comp_params = JComponentHelper::getParams('com_joomdle');
$linkstarget = $comp_params->get('linkstarget');
$moodle_url = $comp_params->get('MOODLE_URL');
$user_id = JUserHelper::getUserId($username);
$user = JFactory::getUser($user_id);
if ($linkstarget == 'wrapper') {
/* XXX After and hour tryng and searching I could not find the GOOD way
to do this, so I do this kludge and it seems to work ;)
*/
$url = JURI::base();
$pos = strpos($url, '/administrator/');
if ($pos) {
$url = substr($url, 0, $pos);
}
$url = $url . '/index.php?option=com_joomdle&view=wrapper&moodle_page_type=course&id=' . $course_id;
} else {
$url = $moodle_url . '/course/view.php?id=' . $course_id;
}
$course_info = JoomdleHelperContent::getCourseInfo((int) $course_id);
$name = $course_info['fullname'];
/* Set language for email to the one chosen by user */
$user_lang = $user->getParam('language', '');
$default_language = JComponentHelper::getParams('com_languages')->get('administrator');
if ($user_lang) {
$lang = new JLanguage($user_lang);
$lang->load('com_joomdle', JPATH_ADMINISTRATOR, $user_lang, true);
} else {
$lang = JLanguage::getInstance($default_language);
}
// Set the e-mail parameters
$from = $app->getCfg('mailfrom');
$fromname = $app->getCfg('fromname');
switch ($state) {
case JOOMDLE_APPLICATION_STATE_APPROVED:
$subject = JText::sprintf('COM_JOOMDLE_APPLICATION_ACCEPTED_MESSAGE_SUBJECT', $name);
$body = JText::sprintf($lang->_('COM_JOOMDLE_APPLICATION_ACCEPTED_MESSAGE_BODY'), $user->name, $name);
break;
case JOOMDLE_APPLICATION_STATE_REJECTED:
$subject = JText::sprintf('COM_JOOMDLE_APPLICATION_REJECTED_MESSAGE_SUBJECT', $name);
$body = JText::sprintf($lang->_('COM_JOOMDLE_APPLICATION_REJECTED_MESSAGE_BODY'), $user->name, $name);
break;
}
// Send the e-mail
if (!JFactory::getMailer()->sendMail($from, $fromname, $email, $subject, $body)) {
$this->setError('ERROR_SENDING_CONFIRMATION_EMAIL');
return false;
}
return true;
}
示例9: _install
//.........这里部分代码省略.........
// If the admin exists say so.
JLog::add(JText::sprintf('JLIB_INSTALLER_ABORT', JText::sprintf('JLIB_INSTALLER_ERROR_FOLDER_IN_USE', $this->parent->getPath('extension_administrator'))), JLog::WARNING, 'jerror');
}
return false;
}
}
/*
* If we created the language directory we will want to remove it if we
* have to roll back the installation, so let's add it to the installation
* step stack
*/
if ($created) {
$this->parent->pushStep(array('type' => 'folder', 'path' => $this->parent->getPath('extension_site')));
}
// Copy all the necessary files
if ($this->parent->parseFiles($element) === false) {
// Install failed, rollback changes
$this->parent->abort();
return false;
}
// Parse optional tags
$this->parent->parseMedia($this->getManifest()->media);
// Copy all the necessary font files to the common pdf_fonts directory
$this->parent->setPath('extension_site', $basePath . '/language/pdf_fonts');
$overwrite = $this->parent->setOverwrite(true);
if ($this->parent->parseFiles($this->getManifest()->fonts) === false) {
// Install failed, rollback changes
$this->parent->abort();
return false;
}
$this->parent->setOverwrite($overwrite);
// Get the language description
$description = (string) $this->getManifest()->description;
if ($description) {
$this->parent->set('message', JText::_($description));
} else {
$this->parent->set('message', '');
}
// Add an entry to the extension table with a whole heap of defaults
$row = JTable::getInstance('extension');
$row->set('name', $this->get('name'));
$row->set('type', 'language');
$row->set('element', $this->get('tag'));
// There is no folder for languages
$row->set('folder', '');
$row->set('enabled', 1);
$row->set('protected', 0);
$row->set('access', 0);
$row->set('client_id', $clientId);
$row->set('params', $this->parent->getParams());
$row->set('manifest_cache', $this->parent->generateManifestCache());
if (!$row->store()) {
// Install failed, roll back changes
$this->parent->abort(JText::sprintf('JLIB_INSTALLER_ABORT', $row->getError()));
return false;
}
// Create an unpublished content language.
if ((int) $clientId === 0) {
// Load the site language manifest.
$siteLanguageManifest = JLanguage::parseXMLLanguageFile(JPATH_SITE . '/language/' . $this->tag . '/' . $this->tag . '.xml');
// Set the content language title as the language metadata name.
$contentLanguageTitle = $siteLanguageManifest['name'];
// Set, as fallback, the content language native title to the language metadata name.
$contentLanguageNativeTitle = $contentLanguageTitle;
// If exist, load the native title from the language xml metadata.
if (isset($siteLanguageMetadata['nativeName']) && $siteLanguageMetadata['nativeName']) {
$contentLanguageNativeTitle = $siteLanguageMetadata['nativeName'];
}
// Try to load a language string from the installation language var. Will be removed in 4.0.
if ($contentLanguageNativeTitle === $contentLanguageTitle) {
if (file_exists(JPATH_INSTALLATION . '/language/' . $this->tag . '/' . $this->tag . '.xml')) {
$installationLanguage = new JLanguage($this->tag);
$installationLanguage->load('', JPATH_INSTALLATION);
if ($installationLanguage->hasKey('INSTL_DEFAULTLANGUAGE_NATIVE_LANGUAGE_NAME')) {
// Make sure it will not use the en-GB fallback.
$defaultLanguage = new JLanguage('en-GB');
$defaultLanguage->load('', JPATH_INSTALLATION);
$defaultLanguageNativeTitle = $defaultLanguage->_('INSTL_DEFAULTLANGUAGE_NATIVE_LANGUAGE_NAME');
$installationLanguageNativeTitle = $installationLanguage->_('INSTL_DEFAULTLANGUAGE_NATIVE_LANGUAGE_NAME');
if ($defaultLanguageNativeTitle != $installationLanguageNativeTitle) {
$contentLanguageNativeTitle = $installationLanguage->_('INSTL_DEFAULTLANGUAGE_NATIVE_LANGUAGE_NAME');
}
}
}
}
// Prepare language data for store.
$languageData = array('lang_id' => 0, 'lang_code' => $this->tag, 'title' => $contentLanguageTitle, 'title_native' => $contentLanguageNativeTitle, 'sef' => $this->getSefString($this->tag), 'image' => strtolower(str_replace('-', '_', $this->tag)), 'published' => 0, 'ordering' => 0, 'access' => (int) JFactory::getConfig()->get('access', 1), 'description' => '', 'metakey' => '', 'metadesc' => '', 'sitename' => '');
$tableLanguage = JTable::getInstance('language');
if (!$tableLanguage->bind($languageData) || !$tableLanguage->check() || !$tableLanguage->store() || !$tableLanguage->reorder()) {
JLog::add(JText::sprintf('JLIB_INSTALLER_WARNING_UNABLE_TO_INSTALL_CONTENT_LANGUAGE', $siteLanguageManifest['name'], $tableLanguage->getError()), JLog::WARNING, 'jerror');
}
}
// Clobber any possible pending updates
$update = JTable::getInstance('update');
$uid = $update->find(array('element' => $this->get('tag'), 'type' => 'language', 'folder' => ''));
if ($uid) {
$update->delete($uid);
}
return $row->get('extension_id');
}