/** * 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; }
/** * 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); }
/** * 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); }
/** * @todo Implement testGetPaths(). */ public function testGetPaths() { $extension1 = ''; $extension2 = 'com_sobi2'; $extension3 = 'joomla'; $lang = new JLanguage(''); // extension = joomla, returns array with language path $this->assertNotNull($lang->getPaths($extension3)); // No call parameter, returns array with language path $this->assertNotNull($lang->getPaths()); }
/** * 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')); }
/** * Method to get the field input. * * @return string The field input. */ protected function getInput() { $attributes = ''; if ($v = (string) $this->element['onchange']) { $attributes .= ' onchange="' . $v . '"'; } $params = JComponentHelper::getParams('com_localise'); $reference = $params->get('reference', 'en-GB'); $admin = JLanguage::getKnownLanguages(LOCALISEPATH_ADMINISTRATOR); $site = JLanguage::getKnownLanguages(LOCALISEPATH_SITE); if (JFolder::exists(LOCALISEPATH_INSTALLATION)) { $install = JLanguage::getKnownLanguages(LOCALISEPATH_INSTALLATION); } else { $install = array(); } $languages = array_merge($admin, $site, $install); $attributes .= ' class="' . (string) $this->element['class'] . ($this->value == $reference ? ' iconlist-16-reference"' : '"'); foreach ($languages as $i => $language) { $languages[$i] = JArrayHelper::toObject($language); } JArrayHelper::sortObjects($languages, 'name'); $options = array(); foreach ($this->element->children() as $option) { $options[] = JHtml::_('select.option', $option->attributes('value'), JText::_(trim($option)), array('option.attr' => 'attributes', 'attr' => '')); } foreach ($languages as $language) { $options[] = JHtml::_('select.option', $language->tag, $language->name, array('option.attr' => 'attributes', 'attr' => 'class="' . ($language->tag == $reference ? 'iconlist-16-reference" title="' . JText::_('COM_LOCALISE_TOOLTIP_FIELD_LANGUAGE_REFERENCE') . '"' : '"'))); } $return = JHtml::_('select.genericlist', $options, $this->name, array('id' => $this->id, 'list.select' => $this->value, 'option.attr' => 'attributes', 'list.attr' => $attributes)); return $return; }
/** * Gets menu items by attribute * * @param string $attributes The field name * @param string $values The value of the field * @param boolean $firstonly If true, only returns the first item found * * @return array * * @since 1.6 */ public function getItems($attributes, $values, $firstonly = false) { $attributes = (array) $attributes; $values = (array) $values; if ($this->app->isSite()) { // Filter by language if not set if (($key = array_search('language', $attributes)) === false) { if (JLanguageMultilang::isEnabled()) { $attributes[] = 'language'; $values[] = array($this->language->getTag(), '*'); } } elseif ($values[$key] === null) { unset($attributes[$key]); unset($values[$key]); } // Filter by access level if not set if (($key = array_search('access', $attributes)) === false) { $attributes[] = 'access'; $values[] = $this->user->getAuthorisedViewLevels(); } elseif ($values[$key] === null) { unset($attributes[$key]); unset($values[$key]); } } // Reset arrays or we get a notice if some values were unset $attributes = array_values($attributes); $values = array_values($values); return parent::getItems($attributes, $values, $firstonly); }
/** * Initialise the application. * * @access public */ function initialise( $options = array()) { // if a language was specified it has priority // otherwise use user or default language settings if (empty($options['language'])) { $user = & JFactory::getUser(); $lang = $user->getParam( 'language' ); // Make sure that the user's language exists if ( $lang && JLanguage::exists($lang) ) { $options['language'] = $lang; } else { $params = JComponentHelper::getParams('com_extensions'); $client =& JApplicationHelper::getClientInfo($this->getClientId()); $options['language'] = $params->get('language_'.$client->name, 'en-GB'); } } // One last check to make sure we have something if ( ! JLanguage::exists($options['language']) ) { $options['language'] = 'en-GB'; } parent::initialise($options); }
function listslanguagesType() { jimport('joomla.filesystem.folder'); $path = JLanguage::getLanguagePath(JPATH_ROOT); $dirs = JFolder::folders($path); $this->languages = array(); foreach ($dirs as $dir) { if (strlen($dir) != 5 || $dir == "xx-XX") { continue; } $xmlFiles = JFolder::files($path . DS . $dir, '^([-_A-Za-z]*)\\.xml$'); $xmlFile = reset($xmlFiles); if (empty($xmlFile)) { continue; } $data = JApplicationHelper::parseXMLLangMetaFile($path . DS . $dir . DS . $xmlFile); $oneLanguage = new stdClass(); $oneLanguage->language = strtolower($dir); $oneLanguage->name = empty($data['name']) ? $dir : $data['name']; $this->languages[] = $oneLanguage; } if (count($this->languages) < 2) { return; } $this->multipleLang = true; $this->choice = array(); $this->choice[] = JHTML::_('select.option', 'all', JText::_('ACY_ALL')); $this->choice[] = JHTML::_('select.option', 'special', JText::_('ACY_CUSTOM')); $js = "function updateLanguages(){\n\t\t\tchoice = eval('document.adminForm.choice_languages');\n\t\t\tchoiceValue = 'special';\n\t\t\tfor (var i=0; i < choice.length; i++){\n\t\t\t\t if (choice[i].checked){\n\t\t\t\t\t choiceValue = choice[i].value;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\thiddenVar = document.getElementById('hidden_languages');\n\t\t\tif(choiceValue != 'special'){\n\t\t\t\thiddenVar.value = choiceValue;\n\t\t\t\tdocument.getElementById('div_languages').style.display = 'none';\n\t\t\t}else{\n\t\t\t\tdocument.getElementById('div_languages').style.display = 'block';\n\t\t\t\tspecialVar = eval('document.adminForm.special_languages');\n\t\t\t\tfinalValue = '';\n\t\t\t\tfor (var i=0; i < specialVar.length; i++){\n\t\t\t\t\tif (specialVar[i].checked){\n\t\t\t\t\t\t\t finalValue += specialVar[i].value+',';\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\thiddenVar.value = finalValue;\n\t\t\t}\n\n\t\t}"; $doc = JFactory::getDocument(); $doc->addScriptDeclaration($js); }
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; }
function convertLng($data) { session_cache_expire(1800000); $path = JLanguage::getLanguagePath(JPATH_COMPONENT_ADMINISTRATOR) . DS . $data['lng'] . DS . '*.ini'; $dirs = glob($path); foreach ($dirs as $file) { header("Content-type: application/csv"); header("Content-Disposition: attachment; filename=" . basename($file)); header("Pragma: no-cache"); header("Expires: 0"); $arr = file($file); foreach ($arr as $line) { $line = str_replace('"', "'", $line); // dmp($line); $ex = explode("=", $line); // dmp($ex); if (count($ex) > 1) { echo $ex[0] . "="; if (count($ex) > 2) { unset($ex[0]); $str = '"' . implode("=", $ex); $str = str_replace("\r\n", "\"\r\n", $str); echo $str; } else { $str = '"' . $ex[1]; $str = str_replace("\r\n", "\"\r\n", $str); echo $str; } } } } }
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; }
/** * Initialise the application. * * @param array An optional associative array of configuration settings. */ function initialise($options = array()) { $config =& JFactory::getConfig(); // if a language was specified it has priority // otherwise use user or default language settings if (empty($options['language'])) { $user =& JFactory::getUser(); $lang = $user->getParam('admin_language'); // Make sure that the user's language exists if ($lang && JLanguage::exists($lang)) { $options['language'] = $lang; } else { $params = JComponentHelper::getParams('com_languages'); $client =& JApplicationHelper::getClientInfo($this->getClientId()); $options['language'] = $params->get($client->name, $config->getValue('config.language', 'en-GB')); } } // One last check to make sure we have something if (!JLanguage::exists($options['language'])) { $lang = $config->getValue('config.language', 'en-GB'); if (JLanguage::exists($lang)) { $options['language'] = $lang; } else { $options['language'] = 'en-GB'; // as a last ditch fail to english } } parent::initialise($options); }
/** * * * */ 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; }
function language() { $this->setLayout('default'); $code = JRequest::getString('code'); if (empty($code)) { acymailing::display('Code not specified', 'error'); return; } $file = null; $file->name = $code; $path = JLanguage::getLanguagePath(JPATH_ROOT) . DS . $code . DS . $code . '.com_acymailing.ini'; $file->path = $path; jimport('joomla.filesystem.file'); $showLatest = true; $loadLatest = false; if (JFile::exists($path)) { $file->content = JFile::read($path); if (empty($file->content)) { acymailing::display('File not found : ' . $path, 'error'); } } else { $loadLatest = true; acymailing::display(JText::_('LOAD_ENGLISH_1') . '<br/>' . JText::_('LOAD_ENGLISH_2') . '<br/>' . JText::_('LOAD_ENGLISH_3'), 'info'); $file->content = JFile::read(JLanguage::getLanguagePath(JPATH_ROOT) . DS . 'en-GB' . DS . 'en-GB.com_acymailing.ini'); } if ($loadLatest or JRequest::getString('task') == 'latest') { $doc =& JFactory::getDocument(); $doc->addScript(ACYMAILING_UPDATEURL . 'languageload&code=' . JRequest::getString('code')); $showLatest = false; } elseif (JRequest::getString('task') == 'save') { $showLatest = false; } $this->assignRef('showLatest', $showLatest); $this->assignRef('file', $file); }
/** * Tries to detect the language. * * @return string locale * @since 1.5 */ public static function detectLanguage() { if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { $systemLangs = JLanguage::getKnownLanguages(); $browserLangs = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']); foreach ($browserLangs as $browserLang) { // slice out the part before ; on first step, the part before - on second, place into array $browserLang = substr($browserLang, 0, strcspn($browserLang, ';')); $primary_browserLang = substr($browserLang, 0, 2); foreach ($systemLangs as $systemLang => $metadata) { // take off 3 letters iso code languages as they can't match browsers' languages and default them to en $Jinstall_lang = $metadata['tag']; if (strlen($Jinstall_lang) < 6) { if (strtolower($browserLang) == strtolower(substr($metadata['tag'], 0, strlen($browserLang)))) { return $systemLang; } else { if ($primary_browserLang == substr($metadata['tag'], 0, 2)) { $primaryDetectedLang = $systemLang; } } } } if (isset($primaryDetectedLang)) { return $primaryDetectedLang; } } } return 'en-GB'; }
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']; }
/** * Initialise the application. * * @param array $options An optional associative array of configuration settings. * * @return void * @since 1.5 */ public function initialise($options = array()) { $config = JFactory::getConfig(); // if a language was specified it has priority // otherwise use user or default language settings if (empty($options['language'])) { $user = JFactory::getUser(); $lang = $user->getParam('admin_language'); // Make sure that the user's language exists if ($lang && JLanguage::exists($lang)) { $options['language'] = $lang; } else { $params = JComponentHelper::getParams('com_languages'); $client = JApplicationHelper::getClientInfo($this->getClientId()); $options['language'] = $params->get($client->name, $config->get('language', 'es-LA')); } } // One last check to make sure we have something if (!JLanguage::exists($options['language'])) { $lang = $config->get('language', 'es-LA'); if (JLanguage::exists($lang)) { $options['language'] = $lang; } else { $options['language'] = 'es-LA'; // as a last ditch fail to english } } // Execute the parent initialise method. parent::initialise($options); // Load Library language $lang = JFactory::getLanguage(); $lang->load('lib_joomla', JPATH_ADMINISTRATOR, null, false, true); }
/** * 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(); }
function __construct(& $subject, $config) { // Check if Kunena API exists $api = JPATH_ADMINISTRATOR . '/components/com_kunena/api.php'; if (! is_file ( $api )) return false; jimport ( 'joomla.application.component.helper' ); // Check if Kunena component is installed/enabled if (! JComponentHelper::isEnabled ( 'com_kunena', true )) { return false; } // Load Kunena API require_once $api; // Fix Joomla 1.5 bugs and bad performance $version = new JVersion(); if ($version->RELEASE == '1.5') { $lang = JFactory::getLanguage(); if (JFactory::getApplication()->isAdmin()) { $lang->load('com_kunena.menu', JPATH_ADMINISTRATOR); } else { $filename = JLanguage::getLanguagePath( JPATH_BASE, $lang->_lang)."/{$lang->_lang}.com_kunena.ini"; $lang->_paths['com_kunena'][$filename] = 1; } } parent::__construct ( $subject, $config ); }
function installMessage() { $db = JFactory::getDBO(); $lang = JFactory::getLanguage(); $currentlang = $lang->getTag(); $objectReadxmlDetail = new JSNISReadXmlDetails(); $infoXmlDetail = $objectReadxmlDetail->parserXMLDetails(); $langSupport = $infoXmlDetail['langs']; $registry = new JRegistry(); $newStrings = array(); $path = null; $realLang = null; $queries = array(); if (array_key_exists($currentlang, $langSupport)) { $path = JLanguage::getLanguagePath(JPATH_BASE, $currentlang); $realLang = $currentlang; } else { $filepath = JPATH_ROOT . DS . 'administrator' . DS . 'language'; $foldersLang = $this->getFolder($filepath); foreach ($foldersLang as $value) { if (in_array($value, $langSupport) == true) { $path = JLanguage::getLanguagePath(JPATH_BASE, $value); $realLang = $value; break; } } } $filename = $path . DS . $realLang . '.com_imageshow.ini'; $objJNSUtils = JSNISFactory::getObj('classes.jsn_is_utils'); $content = $objJNSUtils->readFileToString($filename); if ($content) { $registry->loadString($content); $newStrings = $registry->toArray(); if (count($newStrings)) { if (count($infoXmlDetail['menu'])) { $queries[] = 'TRUNCATE TABLE #__jsn_imageshow_messages'; foreach ($infoXmlDetail['menu'] as $value) { $index = 1; while (isset($newStrings['MESSAGE_' . $value . '_' . $index . '_PRIMARY'])) { $queries[] = 'INSERT INTO #__jsn_imageshow_messages (msg_screen, published, ordering) VALUES (\'' . $value . '\', 1, ' . $index . ')'; $index++; } } } } if (count($queries)) { foreach ($queries as $query) { $query = trim($query); if ($query != '') { $db->setQuery($query); $db->query(); } } } } return true; }
function getOptions() { $languages = JLanguage::getKnownLanguages(); $fields = array(); foreach ($languages as $language) { $options[] = JHtml::_('select.option', strtolower($language['tag']), $language['name'] . ' (' . strtolower($language['tag'] . ')')); } return $options; }
public static function getList(&$params) { $user = JFactory::getUser(); $lang = JFactory::getLanguage(); $app = JFactory::getApplication(); $menu = $app->getMenu(); // Get menu home items $homes = array(); foreach ($menu->getMenu() as $item) { if ($item->home) { $homes[$item->language] = $item; } } // Load associations $assoc = isset($app->menu_associations) ? $app->menu_associations : 0; if ($assoc) { $active = $menu->getActive(); if ($active) { $associations = MenusHelper::getAssociations($active->id); } } $levels = $user->getAuthorisedViewLevels(); $languages = JLanguageHelper::getLanguages(); // Filter allowed languages 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]); } elseif (isset($language->access) && $language->access && !in_array($language->access, $levels)) { unset($languages[$i]); } else { $language->active = $language->lang_code == $lang->getTag(); if ($app->getLanguageFilter()) { if (isset($associations[$language->lang_code]) && $menu->getItem($associations[$language->lang_code])) { $itemid = $associations[$language->lang_code]; if ($app->getCfg('sef') == '1') { $language->link = JRoute::_('index.php?lang=' . $language->sef . '&Itemid=' . $itemid); } else { $language->link = 'index.php?lang=' . $language->sef . '&Itemid=' . $itemid; } } else { 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 = JRoute::_('&Itemid=' . $homes['*']->id); } } } return $languages; }
function installMessage() { $db =& JFactory::getDBO(); $lang =& JFactory::getLanguage(); $currentlang = $lang->getTag(); $objectReadxmlDetail = new JSNISReadXmlDetails(); $infoXmlDetail = $objectReadxmlDetail->parserXMLDetails(); $langSupport = $infoXmlDetail['langs']; $registry = new JRegistry(); $newStrings = array(); $path = null; $realLang = null; $queries = array(); if (array_key_exists($currentlang, $langSupport)) { $path = JLanguage::getLanguagePath(JPATH_BASE, $currentlang); $realLang = $currentlang; } else { $filepath = JPATH_ROOT . DS . 'administrator' . DS . 'language'; $foldersLang = $this->getFolder($filepath); foreach ($foldersLang as $value) { if (in_array($value, $langSupport) == true) { $path = JLanguage::getLanguagePath(JPATH_BASE, $value); $realLang = $value; break; } } } $filename = $path . DS . $realLang . '.com_imageshow.ini'; $content = @file_get_contents($filename); if ($content) { $registry->loadINI($content); $newStrings = $registry->toArray(); if (count($newStrings)) { if (count($infoXmlDetail['menu'])) { $queries[] = 'TRUNCATE TABLE `#__imageshow_messages`'; foreach ($infoXmlDetail['menu'] as $value) { $index = 1; while (isset($newStrings['MESSAGE ' . $value . ' ' . $index . ' PRIMARY'])) { $queries[] = 'INSERT INTO `#__imageshow_messages` (`msg_id`,`msg_screen`,`published`,`ordering`) VALUES (NULL, "' . $value . '", 1, ' . $index . ')'; $index++; } } } } if (count($queries)) { foreach ($queries as $query) { $query = trim($query); if ($query != '') { $db->setQuery($query); $db->query(); } } } } return true; }
public function zipLiveTemplate(&$model) { jimport('joomla.filesystem.archive'); jimport('joomla.filesystem.file'); jimport('joomla.filesystem.folder'); $item =& $model->getItem(); $item->name = strtolower($item->name); //Create TempFolders if (JFolder::exists($model->getTempPath(true))) { JFolder::delete($model->getTempPath(true)); } JFolder::create($model->getTempPath()); //Copy the template if (JFolder::exists(JPATH_SITE . DS . 'templates' . DS . $item->name)) { JFolder::copy(JPATH_SITE . DS . 'templates' . DS . $item->name, $model->getTempPath(), '', true); } elseif (JFolder::exists(JPATH_ADMINISTRATOR . DS . 'templates' . DS . $item->name)) { JFolder::copy(JPATH_ADMINISTRATOR . DS . 'templates' . DS . $item->name, $model->getTempPath(), '', true); } else { JFolder::delete($model->getTempPath()); return -2; } //Create Language Folders if (!JFolder::exists($model->getTempPath() . DS . 'language')) { JFolder::create($model->getTempPath() . DS . 'language'); } //Find Language Files $langs_site = JLanguage::getKnownLanguages(JPATH_SITE); $langs_admin = JLanguage::getKnownLanguages(JPATH_ADMINISTRATOR); $langfiles_site = array(); $langfiles_admin = array(); foreach ($langs_site as $lang) { $langfiles_site = array_merge(JFolder::files(JPATH_SITE . DS . 'language' . DS . $lang['tag'], $item->name, true, true), $langfiles_site); } foreach ($langs_admin as $lang) { $langfiles_admin = array_merge(JFolder::files(JPATH_ADMINISTRATOR . DS . 'language' . DS . $lang['tag'], $item->name, true, true), $langfiles_admin); } //Copy Language Files if (count($langfiles_site)) { foreach ($langfiles_site as $file) { JFile::copy($file, $model->getTempPath() . DS . 'language' . DS . JFile::getName($file)); } } if (count($langfiles_admin)) { foreach ($langfiles_admin as $file) { JFile::copy($file, $model->getTempPath() . DS . 'language' . DS . JFile::getName($file)); } } $model->readinFiles(); $model->buildArchiveContent(); //create archive $model->createArchive(); //delete tmp folder if (JFolder::exists(JPATH_SITE . DS . 'tmp' . DS . 'jctmp')) { JFolder::delete(JPATH_SITE . DS . 'tmp' . DS . 'jctmp'); } }
/** * 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'] = ''; }
public function buildComponent($component) { $sides = ['admin', 'site']; $languages = array_keys(\JLanguage::getKnownLanguages()); foreach ($sides as $side) { $strings = $this->getStrings($side, $component); foreach ($languages as $lang) { $this->saveStrings($strings, $component, $lang, $side); } } }
function isFrontpage() { // get all known languages $languages = JLanguage::getKnownLanguages(); $menu = JSite::getMenu(); foreach ($languages as $lang) { if ($menu->getActive() == $menu->getDefault($lang['tag'])) { return true; } } return false; }
public function getOptions() { jimport('joomla.utilities.arrayhelper'); $languages = JLanguage::getKnownLanguages(JPATH_ROOT); foreach ($languages as $index => $language) { $language['value'] = $language['tag']; $language['title'] = $language['name']; $languages[$index] = JArrayHelper::toObject($language); } $this->options = $languages; return $this->options; }
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; }