/** * Method to get the field options. * * @return array The field option objects. * @since 1.6 */ protected function getOptions() { // Initialise variables. $app = JFactory::getApplication(); // Detect the native language. $native = JLanguageHelper::detectLanguage(); if (empty($native)) { $native = 'en-GB'; } // Get a forced language if it exists. $forced = $app->getLocalise(); if (!empty($forced['language'])) { $native = $forced['language']; } // If a language is already set in the session, use this instead $session = JFactory::getSession()->get('setup.options', array()); if (!empty($session['language'])) { $native = $session['language']; } // Get the list of available languages. $options = JLanguageHelper::createLanguageList($native); if (!$options || JError::isError($options)) { $options = array(); } // Set the default value from the native language. $this->value = $native; // Merge any additional options in the XML definition. $options = array_merge(parent::getOptions(), $options); return $options; }
/** * Method to get the field options. * * @return array The field option objects. * * @since 1.6 */ protected function getOptions() { $app = JFactory::getApplication(); // Detect the native language. $native = JLanguageHelper::detectLanguage(); if (empty($native)) { $native = 'en-GB'; } // Get a forced language if it exists. $forced = $app->getLocalise(); if (!empty($forced['language'])) { $native = $forced['language']; } // If a language is already set in the session, use this instead $model = new InstallationModelSetup(); $options = $model->getOptions(); if (isset($options['language'])) { $native = $options['language']; } // Get the list of available languages. $options = JLanguageHelper::createLanguageList($native); if (!$options || $options instanceof Exception) { $options = array(); } else { usort($options, array($this, '_sortLanguages')); } // Set the default value from the native language. $this->value = $native; // Merge any additional options in the XML definition. $options = array_merge(parent::getOptions(), $options); return $options; }
/** * Initialise the application. * * @param array */ public function initialise($options = array()) { $config = JFactory::getConfig(); // if a language was specified it has priority // otherwise use user or default language settings JPluginHelper::importPlugin('system', 'languagefilter'); if (empty($options['language'])) { $lang = JRequest::getString('language', null); if ($lang && JLanguage::exists($lang)) { $options['language'] = $lang; } } if ($this->_language_filter && empty($options['language'])) { // Detect cookie language jimport('joomla.utilities.utility'); $lang = JRequest::getString(self::getHash('language'), null, 'cookie'); // Make sure that the user's language exists if ($lang && JLanguage::exists($lang)) { $options['language'] = $lang; } } if (empty($options['language'])) { // Detect user language $lang = JFactory::getUser()->getParam('language'); // Make sure that the user's language exists if ($lang && JLanguage::exists($lang)) { $options['language'] = $lang; } } if ($this->_detect_browser && empty($options['language'])) { // Detect browser language $lang = JLanguageHelper::detectLanguage(); // Make sure that the user's language exists if ($lang && JLanguage::exists($lang)) { $options['language'] = $lang; } } if (empty($options['language'])) { // Detect default language $params = JComponentHelper::getParams('com_languages'); $client = JApplicationHelper::getClientInfo($this->getClientId()); $options['language'] = $params->get($client->name, $config->get('language', 'en-GB')); } // One last check to make sure we have something if (!JLanguage::exists($options['language'])) { $lang = $config->get('language', 'en-GB'); if (JLanguage::exists($lang)) { $options['language'] = $lang; } else { $options['language'] = 'en-GB'; // as a last ditch fail to english } } // Execute the parent initialise method. parent::initialise($options); // Load Library language $lang = JFactory::getLanguage(); // Try the lib_joomla file in the current language (without allowing the loading of the file in the default language) $lang->load('lib_joomla', JPATH_SITE, null, false, false) || $lang->load('lib_joomla', JPATH_ADMINISTRATOR, null, false, false) || $lang->load('lib_joomla', JPATH_SITE, null, true) || $lang->load('lib_joomla', JPATH_ADMINISTRATOR, null, true); }
/** * Get Uri * * @param string $url URL * * @return JUri */ public function getUri($url = 'SERVER') { static $uriArray = array(); if (!array_key_exists($url, $uriArray)) { // This will enable both SEF and non-SEF URI to be parsed properly $router = clone JRouter::getInstance('site'); $uri = clone JUri::getInstance($url); $langCode = JLanguageHelper::detectLanguage(); $lang = $uri->getVar('lang', $langCode); $uri->setVar('lang', $lang); $sefs = JLanguageHelper::getLanguages('lang_code'); if (isset($sefs[$lang])) { $lang = $sefs[$lang]->sef; $uri->setVar('lang', $lang); } $router->setVars(array(), false); $query = $router->parse($uri); $query = array_merge($query, $uri->getQuery(true)); $uri->setQuery($query); // We are removing format because of default value is csv if present and if not set // and we are never going to remember csv page in a browser history anyway $uri->delVar('format'); $uriArray[$url] = $uri; } return $uriArray[$url]; }
/** * Test... * * @covers JLanguageHelper::detectLanguage * @todo Implement testDetectLanguage(). * * @return void */ public function testDetectLanguage() { $lang = JLanguageHelper::detectLanguage(); // Since we're running in a CLI context we can only check the defualt value $this->assertNull( $lang ); }
/** * Gets the current language * * @param boolean $detectBrowser Flag indicating whether to use the browser language as a fallback. * * @return string The language string * * @since 3.2 */ public function getCurrentLanguage($detectBrowser = true) { $app = JFactory::getApplication(); $langCode = $app->input->cookie->getString(JApplicationHelper::getHash('language')); // No cookie - let's try to detect browser language or use site default if (!$langCode) { if ($detectBrowser) { $langCode = JLanguageHelper::detectLanguage(); } else { $langCode = JComponentHelper::getParams('com_languages')->get('site', 'en-GB'); } } return $langCode; }
public function getList($refresh = false) { jimport('joomla.language.helper'); $list = JLanguageHelper::createLanguageList(JLanguageHelper::detectLanguage()); foreach ($list as $l) { $l['link'] = "index.php?option=com_citruscart&view=emails&task=edit&id=" . $l['value']; $item = new JObject(); foreach ($l as $k => $v) { $item->{$k} = $v; } $result[] = $item; } return $result; }
/** * Generate a panel of language choices for the user to select their language * * @return boolean True if successful * @access public * @since 1.5 */ function chooseLanguage() { global $mainframe; $vars =& $this->getVars(); jimport('joomla.language.helper'); $native = JLanguageHelper::detectLanguage(); $forced = $mainframe->getLocalise(); if (!empty($forced['lang'])) { $native = $forced['lang']; } $lists = array(); $lists['langs'] = JLanguageHelper::createLanguageList($native); $this->setData('lists', $lists); return true; }
/** * Return any options this element may have * * @param string $name Name of the field * @param string $value Value to check against * @param object $element Data Source Object. * @param string $control_name Control name (eg, control[fieldname]) * @return string HTML */ public function fetchElement($name, $value, &$element, $control_name) { if (!$value) { jimport('joomla.language.helper'); $language = \JLanguageHelper::detectLanguage(); $language = explode('-', $language); $value = $language[0]; } $languages = array(); foreach ($this->_codes as $code => $lang) { $languages[] = \Html::select('option', $code, $lang); } array_unshift($languages, \Html::select('option', '', '- ' . Lang::txt('Select Language') . ' -')); return '<span class="field-wrap">' . \Html::select('genericlist', $languages, $control_name . '[' . $name . ']', 'class="inputbox"', 'value', 'text', $value, $control_name . '-' . $name) . '</span>'; }
/** * @todo Implement testDetectLanguage().. */ public function testDetectLanguage() { // This method returns the language that is active or which is by default $langCompareEqual = 'en-GB'; $langCompareNotEqual = 'es-ES'; $help = new JLanguageHelper(); $lang = $help->detectLanguage(); // in this case, returns default language // Todo impossible to verify this test in console test because joomla cannot detect browser language /* $this->assertEquals( $langCompareEqual, $lang );*/ $this->assertNotEquals($langCompareNotEqual, $lang); }
/** * Method to get a list of options for a list input. * * @return array An array of JHtml options. */ protected function _getOptions() { // Initialise variables. $app =& JFactory::getApplication(); // Detect the native language. jimport('joomla.language.helper'); $native = JLanguageHelper::detectLanguage(); // Get a forced language if it exists. $forced = $app->getLocalise(); if (!empty($forced['lang'])) { $native = $forced['lang']; } // Get the list of available languages. $options = JLanguageHelper::createLanguageList($native); if (!$options || JError::isError($options)) { $options = array(); } // Set the default value from the native language. $this->value = $native; // Merge in any explicitly listed options from the XML definition. $options = array_merge(parent::_getOptions(), $options); return $options; }
function ReadCountries($countries = true, $active_currencies = true, $language = '', $where = '', $resultType = 'Assoc', $firstOnly = false, $orderf = '', $orderdir = 'ASC') { if ($resultType == '') { $resultType = "Assoc"; } $db =& JFactory::getDBO(); if ($countries) { if ($orderf == '') { $orderf = "hits DESC, id"; } if ($language == '') { jimport('joomla.language.helper'); $lg = JLanguageHelper::detectLanguage(); $language = substr($lg, 0, 2); } $req = "select * from #__jaderp_countries"; $db->setQuery($req); $row = $db->loadAssoc(); if (!array_key_exists($language, $row)) { $language = "en"; } $req = "SELECT id, hits, " . $language . " as country FROM " . $db->nameQuote("#__jaderp_countries") . " " . $where . " ORDER BY " . $orderf . " " . $orderdir; } else { if ($orderf == '') { $orderf = "id"; } if ($active_currencies) { if ($where == '') { $where = ' WHERE active_currency = ' . $db->quote('1'); } else { $where = ' AND active_currency = ' . $db->quote('1'); } } $req = "SELECT id, currency, iso4217, currency_symbol, currency_format, hits FROM " . $db->nameQuote("#__jaderp_countries") . " " . $where . " ORDER BY " . $orderf . " " . $orderdir; } $db->setQuery($req); //echo $req; switch ($resultType) { case 'Object': if ($firstOnly) { $result = $db->loadObject(); } else { $result = $db->loadObjectList(); } break; case 'Array': if ($firstOnly) { $result = $db->loadRow(); } else { $result = $db->loadRowList(); } break; case 'Assoc': default: if ($firstOnly) { $result = $db->loadAssoc(); } else { $result = $db->loadAssocList(); } break; } if (!$result) { return false; } else { return $result; } }
# Technical Support: Forum - http://www.ijoomla.com.com/forum/index/ -------------------------------------------------------------------------*/ 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
/** * Initialise the application. * * @param array $options An optional associative array of configuration settings. * * @return void * * @since 3.2 */ protected function initialiseApp($options = array()) { $user = JFactory::getUser(); // If the user is a guest we populate it with the guest user group. if ($user->guest) { $guestUsergroup = JComponentHelper::getParams('com_users')->get('guest_usergroup', 1); $user->groups = array($guestUsergroup); } // If a language was specified it has priority, otherwise use user or default language settings JPluginHelper::importPlugin('system', 'languagefilter'); if (empty($options['language'])) { // Detect the specified language $lang = $this->input->getString('language', null); // Make sure that the user's language exists if ($lang && JLanguage::exists($lang)) { $options['language'] = $lang; } } if ($this->_language_filter && empty($options['language'])) { // Detect cookie language $lang = $this->input->cookie->get(md5($this->get('secret') . 'language'), null, 'string'); // Make sure that the user's language exists if ($lang && JLanguage::exists($lang)) { $options['language'] = $lang; } } if (empty($options['language'])) { // Detect user language $lang = $user->getParam('language'); // Make sure that the user's language exists if ($lang && JLanguage::exists($lang)) { $options['language'] = $lang; } } if ($this->_detect_browser && empty($options['language'])) { // Detect browser language $lang = JLanguageHelper::detectLanguage(); // Make sure that the user's language exists if ($lang && JLanguage::exists($lang)) { $options['language'] = $lang; } } if (empty($options['language'])) { // Detect default language $params = JComponentHelper::getParams('com_languages'); $options['language'] = $params->get('site', $this->get('language', 'en-GB')); } // One last check to make sure we have something if (!JLanguage::exists($options['language'])) { $lang = $this->config->get('language', 'en-GB'); if (JLanguage::exists($lang)) { $options['language'] = $lang; } else { // As a last ditch fail to english $options['language'] = 'en-GB'; } } // Finish initialisation parent::initialiseApp($options); /* * Try the lib_joomla file in the current language (without allowing the loading of the file in the default language) * Fallback to the default language if necessary */ $this->getLanguage()->load('lib_joomla', JPATH_SITE, null, false, true) || $this->getLanguage()->load('lib_joomla', JPATH_ADMINISTRATOR, null, false, true); }
/** * Generate a panel of language choices for the user to select their language. * * @return boolean True if successful. * * @since 3.1 */ public function getLanguages() { /* @var InstallationApplicationWeb $app */ $app = JFactory::getApplication(); // Detect the native language. $native = JLanguageHelper::detectLanguage(); if (empty($native)) { $native = 'en-GB'; } // Get a forced language if it exists. $forced = $app->getLocalise(); if (!empty($forced['language'])) { $native = $forced['language']; } // Get the list of available languages. $list = JLanguageHelper::createLanguageList($native); if (!$list || $list instanceof Exception) { $list = array(); } return $list; }
public function parseRule(&$router, &$uri) { $array = array(); $lang_code = JRequest::getString(JUtility::getHash('language'), null, 'cookie'); if (!$lang_code) { $lang_code = JLanguageHelper::detectLanguage(); } if (self::$mode_sef) { $path = $uri->getPath(); $parts = explode('/', $path); $sef = $parts[0]; if (!isset(self::$sefs[$sef])) { $sef = isset(self::$lang_codes[$lang_code]) ? self::$lang_codes[$lang_code]->sef : self::$default_sef; $uri->setPath($sef . '/' . $path); $post = JRequest::get('POST'); if (JRequest::getMethod() != "POST" || count($post) == 0) { $app = JFactory::getApplication(); if ($app->getCfg('sef_rewrite')) { $app->redirect($uri->base() . $uri->toString(array('path', 'query', 'fragment'))); } else { $app->redirect($uri->base() . 'index.php/' . $uri->toString(array('path', 'query', 'fragment'))); } } } $lang_code = self::$sefs[$sef]->lang_code; if ($lang_code && JLanguage::exists($lang_code)) { array_shift($parts); $uri->setPath(implode('/', $parts)); } } else { $sef = $uri->getVar('lang'); if (!isset(self::$sefs[$sef])) { $sef = isset(self::$lang_codes[$lang_code]) ? self::$lang_codes[$lang_code]->sef : self::$default_sef; $uri->setVar('lang', $sef); $post = JRequest::get('POST'); if (JRequest::getMethod() != "POST" || count($post) == 0) { $app = JFactory::getApplication(); $app->redirect(JURI::base(true) . '/index.php?' . $uri->getQuery()); } } } $array = array('lang' => $sef); return $array; }
/** * Initialise the application. * * @param array $options * * @return void */ public function initialise($options = array()) { //Get the localisation information provided in the localise.xml file. $forced = $this->getLocalise(); // Check the request data for the language. if (empty($options['language'])) { $requestLang = JRequest::getCmd('lang', null); if (!is_null($requestLang)) { $options['language'] = $requestLang; } } // Check the session for the language. if (empty($options['language'])) { $sessionLang = JFactory::getSession()->get('setup.language'); if (!is_null($sessionLang)) { $options['language'] = $sessionLang; } } // This could be a first-time visit - try to determine what the client accepts. if (empty($options['language'])) { if (!empty($forced['language'])) { $options['language'] = $forced['language']; } else { $options['language'] = JLanguageHelper::detectLanguage(); if (empty($options['language'])) { $options['language'] = 'en-GB'; } } } // Give the user English if (empty($options['language'])) { $options['language'] = 'en-GB'; } // Set the language in the class $conf = JFactory::getConfig(); $conf->set('language', $options['language']); $conf->set('debug_lang', $forced['debug']); $conf->set('sampledata', $forced['sampledata']); }
/** * Method to add alternative meta tags for associated menu items. * * @return void * * @since 1.7 */ public function onAfterDispatch() { $doc = JFactory::getDocument(); $menu = $this->app->getMenu(); $server = JUri::getInstance()->toString(array('scheme', 'host', 'port')); $option = $this->app->input->get('option'); $eName = JString::ucfirst(JString::str_ireplace('com_', '', $option)); if ($this->app->isSite() && $this->params->get('alternate_meta') && $doc->getType() == 'html') { // Get active menu item. $active = $menu->getActive(); $assocs = array(); $home = false; // Load menu associations. if ($active) { $active_link = JRoute::_($active->link . '&Itemid=' . $active->id, false); // Get current link. $current_link = JUri::getInstance()->toString(array('path', 'query')); // Check the exact menu item's URL. if ($active_link == $current_link) { $associations = MenusHelper::getAssociations($active->id); unset($associations[$active->language]); $assocs = array_keys($associations); // If the menu item is a home menu item and the URLs are identical, we are on the homepage $home = true; } } // Load component associations. $cName = JString::ucfirst($eName . 'HelperAssociation'); JLoader::register($cName, JPath::clean(JPATH_COMPONENT_SITE . '/helpers/association.php')); if (class_exists($cName) && is_callable(array($cName, 'getAssociations'))) { $cassociations = call_user_func(array($cName, 'getAssociations')); $lang_code = $this->app->input->cookie->getString(JApplicationHelper::getHash('language')); // No cookie - let's try to detect browser language or use site default. if (!$lang_code) { if ($this->params->get('detect_browser', 1)) { $lang_code = JLanguageHelper::detectLanguage(); } else { $lang_code = $this->default_lang; } } unset($cassociations[$lang_code]); $assocs = array_merge(array_keys($cassociations), $assocs); } // Handle the default associations. if ($this->params->get('item_associations') || $active && $active->home && $home) { $languages = JLanguageHelper::getLanguages('lang_code'); foreach ($assocs as $language) { if (!JLanguage::exists($language)) { continue; } $lang = $languages[$language]; if (isset($cassociations[$language])) { $link = JRoute::_($cassociations[$language] . '&lang=' . $lang->sef); // Check if language is the default site language and remove url language code is on if ($lang->sef == $this->lang_codes[$this->default_lang]->sef && $this->params->get('remove_default_prefix') == '1') { $link = preg_replace('|/' . $lang->sef . '/|', '/', $link, 1); } $doc->addHeadLink($server . $link, 'alternate', 'rel', array('hreflang' => $language)); } elseif (isset($associations[$language])) { $item = $menu->getItem($associations[$language]); if ($item) { $link = JRoute::_($item->link . '&Itemid=' . $item->id . '&lang=' . $lang->sef); $doc->addHeadLink($server . $link, 'alternate', 'rel', array('hreflang' => $language)); } } } } } }
/** * Tries to detect the language. * * @return string locale or null if not found * * @since 2.1.5 */ public static function detectLanguageFromBrowser() { return \JLanguageHelper::detectLanguage(); }
/** * Initialise the application. * * @param array $options An optional associative array of configuration settings. * * @return void * * @since 3.1 */ protected function initialiseApp($options = array()) { // Get the localisation information provided in the localise.xml file. $forced = $this->getLocalise(); // Check the request data for the language. if (empty($options['language'])) { $requestLang = $this->input->getCmd('lang', null); if (!is_null($requestLang)) { $options['language'] = $requestLang; } } // Check the session for the language. if (empty($options['language'])) { $sessionOptions = $this->getSession()->get('setup.options'); if (isset($sessionOptions['language'])) { $options['language'] = $sessionOptions['language']; } } // This could be a first-time visit - try to determine what the client accepts. if (empty($options['language'])) { if (!empty($forced['language'])) { $options['language'] = $forced['language']; } else { $options['language'] = JLanguageHelper::detectLanguage(); if (empty($options['language'])) { $options['language'] = 'en-GB'; } } } // Give the user English. if (empty($options['language'])) { $options['language'] = 'en-GB'; } // Check for custom helpurl. if (empty($forced['helpurl'])) { $options['helpurl'] = 'https://help.joomla.org/proxy/index.php?keyref=Help{major}{minor}:{keyref}'; } else { $options['helpurl'] = $forced['helpurl']; } // Store helpurl in the session. $this->getSession()->set('setup.helpurl', $options['helpurl']); // Set the language in the class. $this->config->set('language', $options['language']); $this->config->set('debug_lang', $forced['debug']); $this->config->set('sampledata', $forced['sampledata']); $this->config->set('helpurl', $options['helpurl']); }
/** * Method to add alternative meta tags for associated menu items. * * @return void * * @since 1.7 */ public function onAfterDispatch() { $app = JFactory::getApplication(); $doc = JFactory::getDocument(); $menu = $app->getMenu(); $server = JUri::getInstance()->toString(array('scheme', 'host', 'port')); $option = $app->input->get('option'); $eName = JString::ucfirst(JString::str_ireplace('com_', '', $option)); if ($app->isSite() && $this->params->get('alternate_meta') && $doc->getType() == 'html') { // Get active menu item. $active = $menu->getActive(); // Load menu associations. if ($active) { // Get menu item link. if ($app->get('sef')) { $active_link = JRoute::_('index.php?Itemid=' . $active->id, false); } else { $active_link = JRoute::_($active->link . '&Itemid=' . $active->id, false); } if ($active_link == JUri::base(true) . '/') { $active_link .= 'index.php'; } // Get current link. $current_link = JUri::getInstance()->toString(array('path', 'query')); if ($current_link == JUri::base(true) . '/') { $current_link .= 'index.php'; } // Check the exact menu item's URL. if ($active_link == $current_link) { $associations = MenusHelper::getAssociations($active->id); unset($associations[$active->language]); } } // Load component associations. $cName = JString::ucfirst($eName . 'HelperAssociation'); JLoader::register($cName, JPath::clean(JPATH_COMPONENT_SITE . '/helpers/association.php')); if (class_exists($cName) && is_callable(array($cName, 'getAssociations'))) { $cassociations = call_user_func(array($cName, 'getAssociations')); $lang_code = $app->input->cookie->getString(JApplication::getHash('language')); // No cookie - let's try to detect browser language or use site default. if (!$lang_code) { if ($this->params->get('detect_browser', 1)) { $lang_code = JLanguageHelper::detectLanguage(); } else { $lang_code = self::$default_lang; } } unset($cassociations[$lang_code]); } // Handle the default associations. if ((!empty($associations) || !empty($cassociations)) && $this->params->get('item_associations')) { foreach (JLanguageHelper::getLanguages() as $language) { if (!JLanguage::exists($language->lang_code)) { continue; } if (isset($cassociations[$language->lang_code])) { $link = JRoute::_($cassociations[$language->lang_code] . '&lang=' . $language->sef); $doc->addHeadLink($server . $link, 'alternate', 'rel', array('hreflang' => $language->lang_code)); } elseif (isset($associations[$language->lang_code])) { $item = $menu->getItem($associations[$language->lang_code]); if ($item) { if ($app->get('sef')) { $link = JRoute::_('index.php?Itemid=' . $item->id . '&lang=' . $language->sef); } else { $link = JRoute::_($item->link . '&Itemid=' . $item->id . '&lang=' . $language->sef); } $doc->addHeadLink($server . $link, 'alternate', 'rel', array('hreflang' => $language->lang_code)); } } } } elseif ($active && $active->home) { foreach (JLanguageHelper::getLanguages() as $language) { if (!JLanguage::exists($language->lang_code)) { continue; } $item = $menu->getDefault($language->lang_code); if ($item && $item->language != $active->language && $item->language != '*') { if ($app->get('sef')) { $link = JRoute::_('index.php?Itemid=' . $item->id . '&lang=' . $language->sef); } else { $link = JRoute::_($item->link . '&Itemid=' . $item->id . '&lang=' . $language->sef); } $doc->addHeadLink($server . $link, 'alternate', 'rel', array('hreflang' => $language->lang_code)); } } } } }
/** * Get the API url needed for the given operation * @param enum(insert, update, delete) $type * @param TiendaTableProduct $product */ protected function getAPIUrl($type, $product = null) { // automatic language from joomla jimport('joomla.language.helper'); $lang = JLanguageHelper::detectLanguage(); // We need this for insert and update $lang = explode("-", $lang); switch ($type) { case 'delete': return 'https://content.googleapis.com/content/v1/' . $this->account_id . '/items/products/generic/online:' . $lang[0] . ':' . $lang[1] . ':' . $product->product_id; break; case 'update': return 'https://content.googleapis.com/content/v1/' . $this->account_id . '/items/products/generic/online::' . $lang[0] . ':' . $lang[1] . ':' . $product->product_id; break; default: case 'insert': return 'https://content.googleapis.com/content/v1/' . $this->account_id . '/items/products/generic'; break; } }
/** * Add parse rule to router. * * @param JRouter &$router JRouter object. * @param JUri &$uri JUri object. * * @return void * * @since 1.6 */ public function parseRule(&$router, &$uri) { // Did we find the current and existing language yet? $found = false; $lang_code = false; // Are we in SEF mode or not? if ($this->mode_sef) { $path = $uri->getPath(); $parts = explode('/', $path); $sef = $parts[0]; // Do we have a URL Language Code ? if (!isset($this->sefs[$sef])) { // Check if remove default url language code is set if ($this->params->get('remove_default_prefix', 0)) { if ($parts[0]) { // We load a default site language page $lang_code = $this->default_lang; } else { // We check for an existing language cookie $lang_code = $this->getLanguageCookie(); } } else { $lang_code = $this->getLanguageCookie(); } // No language code. Try using browser settings or default site language if (!$lang_code && $this->params->get('detect_browser', 0) == 1) { $lang_code = JLanguageHelper::detectLanguage(); } if (!$lang_code) { $lang_code = $this->default_lang; } if ($this->params->get('remove_default_prefix', 0) && $lang_code == $this->default_lang) { $found = true; } } else { // We found our language $found = true; $lang_code = $this->sefs[$sef]->lang_code; // If we found our language, but its the default language and we don't want a prefix for that, we are on a wrong URL. // Or we try to change the language back to the default language. We need a redirect to the proper URL for the default language. if ($this->params->get('remove_default_prefix', 0) && $lang_code == $this->default_lang) { // Create a cookie. $this->setLanguageCookie($lang_code); $found = false; array_shift($parts); $path = implode('/', $parts); } // We have found our language and the first part of our URL is the language prefix if ($found) { array_shift($parts); $uri->setPath(implode('/', $parts)); } } } else { $lang_code = $this->getLanguageCookie(); if ($this->params->get('detect_browser', 1) && !$lang_code) { $lang_code = JLanguageHelper::detectLanguage(); } if (!isset($this->lang_codes[$lang_code])) { $lang_code = $this->default_lang; } } $lang = $uri->getVar('lang', $lang_code); if (isset($this->sefs[$lang])) { // We found our language $found = true; $lang_code = $this->sefs[$lang]->lang_code; } // We are called via POST. We don't care about the language // and simply set the default language as our current language. if ($this->app->input->getMethod() == "POST" || count($this->app->input->post) > 0 || count($this->app->input->files) > 0) { $found = true; if (!isset($lang_code)) { $lang_code = $this->getLanguageCookie(); } if ($this->params->get('detect_browser', 1) && !$lang_code) { $lang_code = JLanguageHelper::detectLanguage(); } if (!isset($this->lang_codes[$lang_code])) { $lang_code = $this->default_lang; } } // We have not found the language and thus need to redirect if (!$found) { // Lets find the default language for this user if (!isset($lang_code) || !isset($this->lang_codes[$lang_code])) { $lang_code = false; if ($this->params->get('detect_browser', 1)) { $lang_code = JLanguageHelper::detectLanguage(); if (!isset($this->lang_codes[$lang_code])) { $lang_code = false; } } if (!$lang_code) { $lang_code = $this->default_lang; } } if ($this->mode_sef) { // Use the current language sef or the default one. if (!$this->params->get('remove_default_prefix', 0) || $lang_code != $this->default_lang) { $path = $this->lang_codes[$lang_code]->sef . '/' . $path; } $uri->setPath($path); if (!$this->app->get('sef_rewrite')) { $uri->setPath('index.php/' . $uri->getPath()); } $redirectUri = $uri->base() . $uri->toString(array('path', 'query', 'fragment')); } else { $uri->setVar('lang', $this->lang_codes[$lang_code]->sef); $redirectUri = $uri->base() . 'index.php?' . $uri->getQuery(); } // Set redirect HTTP code to "302 Found". $redirectHttpCode = 302; // If selected language is the default language redirect code is "301 Moved Permanently". if ($lang_code === $this->default_lang) { $redirectHttpCode = 301; // We cannot cache this redirect in browser. 301 is cachable by default so we need to force to not cache it in browsers. $this->app->setHeader('Expires', 'Wed, 17 Aug 2005 00:00:00 GMT', true); $this->app->setHeader('Last-Modified', gmdate('D, d M Y H:i:s') . ' GMT', true); $this->app->setHeader('Cache-Control', 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0', false); $this->app->setHeader('Pragma', 'no-cache'); $this->app->sendHeaders(); } // Redirect to language. $this->app->redirect($redirectUri, $redirectHttpCode); } // We have found our language and now need to set the cookie and the language value in our system $array = array('lang' => $lang_code); $this->current_lang = $lang_code; // Set the request var. $this->app->input->set('language', $lang_code); $this->app->set('language', $lang_code); $language = JFactory::getLanguage(); if ($language->getTag() != $lang_code) { $newLang = JLanguage::getInstance($lang_code); foreach ($language->getPaths() as $extension => $files) { $newLang->load($extension); } JFactory::$language = $newLang; $this->app->loadLanguage($newLang); } // Create a cookie. if ($this->getLanguageCookie() != $lang_code) { $this->setLanguageCookie($lang_code); } return $array; }
protected function _tryToHandleJoomlaBloodyMultilingualFeat(&$uri, $vars) { if (self::$requestParsed || !Sh404sefFactory::getConfig()->enableMultiLingualSupport) { return; } $currentLanguageTag = JFactory::getLanguage()->getTag(); $cookieTag = JRequest::getString(JUtility::getHash('language'), null, 'cookie'); // what's language extracted from URL? $langCode = empty($vars['lang']) ? $currentLanguageTag : shGetNameFromIsoCode($vars['lang']); // Create a cookie, if target different from current language if ($langCode != $cookieTag) { $conf = JFactory::getConfig(); $cookie_domain = $conf->get('config.cookie_domain', ''); $cookie_path = $conf->get('config.cookie_path', '/'); setcookie(JUtility::getHash('language'), $langCode, time() + 365 * 86400, $cookie_path, $cookie_domain); // set the request var JRequest::setVar('language', $langCode); } // no cookie - try autoredirect to user language if (empty($cookieTag)) { // get language filter plugin params try { $rawParams = Sh404sefHelperDb::selectObject('#__extensions', 'params', array('type' => 'system', 'name' => 'languagefilter')); } catch (Sh404sefExceptionDefault $e) { return; } $langFilterParams = new JRegistry(); $langFilterParams->loadString($rawParams); if ($langFilterParams->get('detect_browser', 1)) { $userLanguage = JLanguageHelper::detectLanguage(); if (!empty($userLanguage) && $userLanguage != $langCode) { _log(__METHOD__ . '/' . __LINE__ . ': user lang: ' . $userLanguage . ' langcode: ' . $langCode); // user has a specific language, let's redirect to that $vars['lang'] = shGetIsoCodeFromName($userLanguage); $uri->setQuery($vars); $this->_redirectNonSef($uri); } } } // set current language, if different from current if ($langCode != $currentLanguageTag) { jimport('joomla.language.language'); $conf = JFactory::getConfig(); $debug = $conf->get('debug_lang'); $lang = JLanguage::getInstance($langCode, $debug); JFactory::$language = $lang; $pageInfo =& Sh404sefFactory::getPageInfo(); $pageInfo->shMosConfig_locale = $langCode; $pageInfo->shMosConfig_shortcode = $vars['lang']; } }
/** * Add parse rule to router. * * @param JRouter &$router JRouter object. * @param JUri &$uri JUri object. * * @return void * * @since 1.6 */ public function parseRule(&$router, &$uri) { // Did we find the current and existing language yet? $found = false; $lang_code = false; // Are we in SEF mode or not? if ($this->mode_sef) { $path = $uri->getPath(); $parts = explode('/', $path); $sef = $parts[0]; // Do we have a URL Language Code ? if (!isset($this->sefs[$sef])) { // Check if remove default url language code is set if ($this->params->get('remove_default_prefix', 0)) { if ($parts[0]) { // We load a default site language page $lang_code = $this->default_lang; } else { // We check for an existing language cookie $lang_code = $this->getLanguageCookie(); } } else { $lang_code = $this->getLanguageCookie(); } // No language code. Try using browser settings or default site language if (!$lang_code && $this->params->get('detect_browser', 0) == 1) { $lang_code = JLanguageHelper::detectLanguage(); } if (!$lang_code) { $lang_code = $this->default_lang; } if ($this->params->get('remove_default_prefix', 0) && $lang_code == $this->default_lang) { $found = true; } } else { // We found our language $found = true; $lang_code = $this->sefs[$sef]->lang_code; // If we found our language, but its the default language and we don't want a prefix for that, we are on a wrong URL. // Or we try to change the language back to the default language. We need a redirect to the proper URL for the default language. if ($this->params->get('remove_default_prefix', 0) && $lang_code == $this->default_lang) { // Create a cookie. $this->setLanguageCookie($lang_code); $found = false; array_shift($parts); $path = implode('/', $parts); } // We have found our language and the first part of our URL is the language prefix if ($found) { array_shift($parts); $uri->setPath(implode('/', $parts)); } } } else { $lang_code = $this->getLanguageCookie(); if ($this->params->get('detect_browser', 1) && !$lang_code) { $lang_code = JLanguageHelper::detectLanguage(); } if (!isset($this->lang_codes[$lang_code])) { $lang_code = $this->default_lang; } } $lang = $uri->getVar('lang', $lang_code); if (isset($this->sefs[$lang])) { // We found our language $found = true; $lang_code = $this->sefs[$lang]->lang_code; } // We are called via POST. We don't care about the language // and simply set the default language as our current language. if ($this->app->input->getMethod() == "POST" || count($this->app->input->post) > 0 || count($this->app->input->files) > 0) { $found = true; if (!isset($lang_code)) { $lang_code = $this->getLanguageCookie(); } if ($this->params->get('detect_browser', 1) && !$lang_code) { $lang_code = JLanguageHelper::detectLanguage(); } if (!isset($this->lang_codes[$lang_code])) { $lang_code = $this->default_lang; } } // We have not found the language and thus need to redirect if (!$found) { // Lets find the default language for this user if (!isset($lang_code) || !isset($this->lang_codes[$lang_code])) { $lang_code = false; if ($this->params->get('detect_browser', 1)) { $lang_code = JLanguageHelper::detectLanguage(); if (!isset($this->lang_codes[$lang_code])) { $lang_code = false; } } if (!$lang_code) { $lang_code = $this->default_lang; } } if ($this->mode_sef) { // Use the current language sef or the default one. if (!$this->params->get('remove_default_prefix', 0) || $lang_code != $this->default_lang) { $path = $this->lang_codes[$lang_code]->sef . '/' . $path; } $uri->setPath($path); if (!$this->app->get('sef_rewrite')) { $uri->setPath('index.php/' . $uri->getPath()); } $this->app->redirect($uri->base() . $uri->toString(array('path', 'query', 'fragment')), 301); } else { $uri->setVar('lang', $this->lang_codes[$lang_code]->sef); $this->app->redirect($uri->base() . 'index.php?' . $uri->getQuery(), 301); } } // We have found our language and now need to set the cookie and the language value in our system $array = array('lang' => $lang_code); $this->current_lang = $lang_code; // Set the request var. $this->app->input->set('language', $lang_code); $this->app->set('language', $lang_code); $language = JFactory::getLanguage(); if ($language->getTag() != $lang_code) { $newLang = JLanguage::getInstance($lang_code); foreach ($language->getPaths() as $extension => $files) { $newLang->load($extension); } JFactory::$language = $newLang; $this->app->loadLanguage($newLang); } // Create a cookie. if ($this->getLanguageCookie() != $lang_code) { $this->setLanguageCookie($lang_code); } return $array; }
/** * Initialise the application. * * @param array */ public function initialise($options = array()) { $config = JFactory::getConfig(); jimport('joomla.language.helper'); if (empty($options['language'])) { $lang = JRequest::getString('language', null); if ($lang && JLanguage::exists($lang)) { $options['language'] = $lang; } } if ($this->_language_filter && empty($options['language'])) { // Detect cookie language jimport('joomla.utilities.utility'); $lang = JRequest::getString(JUtility::getHash('language'), null ,'cookie'); // Make sure that the user's language exists if ($lang && JLanguage::exists($lang)) { $options['language'] = $lang; } } if (empty($options['language'])) { // Detect user language $lang = JFactory::getUser()->getParam('language'); // Make sure that the user's language exists if ($lang && JLanguage::exists($lang)) { $options['language'] = $lang; } } if ($this->_detect_browser && empty($options['language'])) { // Detect browser language $lang = JLanguageHelper::detectLanguage(); // Make sure that the user's language exists if ($lang && JLanguage::exists($lang)) { $options['language'] = $lang; } } if (empty($options['language'])) { // Detect default language $params = JComponentHelper::getParams('com_languages'); $client = JApplicationHelper::getClientInfo($this->getClientId()); $options['language'] = $params->get($client->name, $config->get('language', 'en-GB')); } // One last check to make sure we have something if (!JLanguage::exists($options['language'])) { $lang = $config->get('language','en-GB'); if (JLanguage::exists($lang)) { $options['language'] = $lang; } else { $options['language'] = 'en-GB'; // 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_SITE) || $lang->load('lib_joomla', JPATH_ADMINISTRATOR); }
public function parseRule(&$router, &$uri) { $array = array(); $lang_code = JRequest::getString(JApplication::getHash('language'), null, 'cookie'); // No cookie - let's try to detect browser language or use site default if (!$lang_code) { if ($this->params->get('detect_browser', 1)) { $lang_code = JLanguageHelper::detectLanguage(); } else { $lang_code = self::$default_lang; } } if (self::$mode_sef) { $path = $uri->getPath(); $parts = explode('/', $path); $sef = $parts[0]; $app = JFactory::getApplication(); // Redirect only if not in post $post = JRequest::get('POST'); if (JRequest::getMethod() != "POST" || count($post) == 0) { if ($this->params->get('remove_default_prefix', 0) == 0) { // redirect if sef does not exists if (!isset(self::$sefs[$sef])) { // Use the current language sef or the default one $sef = isset(self::$lang_codes[$lang_code]) ? self::$lang_codes[$lang_code]->sef : self::$default_sef; $uri->setPath($sef . '/' . $path); if ($app->getCfg('sef_rewrite')) { $app->redirect($uri->base() . $uri->toString(array('path', 'query', 'fragment'))); } else { $path = $uri->toString(array('path', 'query', 'fragment')); $app->redirect($uri->base() . 'index.php' . ($path ? '/' . $path : '')); } } } else { // redirect if sef does not exists and language is not the default one if (!isset(self::$sefs[$sef]) && $lang_code != self::$default_lang) { $sef = self::$default_sef; $uri->setPath($sef . '/' . $path); if ($app->getCfg('sef_rewrite')) { $app->redirect($uri->base() . $uri->toString(array('path', 'query', 'fragment'))); } else { $path = $uri->toString(array('path', 'query', 'fragment')); $app->redirect($uri->base() . 'index.php' . ($path ? '/' . $path : '')); } } elseif (isset(self::$sefs[$sef]) && self::$default_lang == self::$sefs[$sef]->lang_code && (!$this->params->get('detect_browser', 1) || JLanguageHelper::detectLanguage() == self::$tag || self::$cookie)) { array_shift($parts); $uri->setPath(implode('/', $parts)); if ($app->getCfg('sef_rewrite')) { $app->redirect($uri->base() . $uri->toString(array('path', 'query', 'fragment'))); } else { $path = $uri->toString(array('path', 'query', 'fragment')); $app->redirect($uri->base() . 'index.php' . ($path ? '/' . $path : '')); } } } } $lang_code = isset(self::$sefs[$sef]) ? self::$sefs[$sef]->lang_code : ''; if ($lang_code && JLanguage::exists($lang_code)) { array_shift($parts); $uri->setPath(implode('/', $parts)); } } else { $sef = $uri->getVar('lang'); if (!isset(self::$sefs[$sef])) { $sef = isset(self::$lang_codes[$lang_code]) ? self::$lang_codes[$lang_code]->sef : self::$default_sef; $uri->setVar('lang', $sef); $post = JRequest::get('POST'); if (JRequest::getMethod() != "POST" || count($post) == 0) { $app = JFactory::getApplication(); $app->redirect(JURI::base(true) . '/index.php?' . $uri->getQuery()); } } } $array = array('lang' => $sef); return $array; }
public function fetchElement($name, $value, &$node, $control_name) { $params['selector'] = 'div.dashboard'; ComNinjaHtmlPane::getInstance('tabs', $params); jimport('joomla.filesystem.file'); $doc =& JFactory::getDocument(); $uri = JFactory::getURI(); //Get path to manifestfile, and get required data $xml =& JFactory::getXMLParser('Simple'); if ($node['path']) { $explode = explode('::', $node['path']); $path = JApplicationHelper::getPath(current($explode), next($explode)); } else { if ($this->_parent->_path) { $path = $this->_parent->_path; } } $xml->loadFile($path); $xml = $xml->document; if (!defined('NAPI_DASHBOARD')) { //return '<pre>'.print_r($xml,true).'</pre>'; define('NAPI_DASHBOARD', 1); } jimport('joomla.language.helper'); $locale = JLanguageHelper::detectLanguage(); $instructions = JText::_('NINSTRUCTIONS'); //$instructions = JFile::read(JURI::root().'modules/'.$modname.'/dashboard/'.$locale.'/instructions.html'); if (!$instructions) { //$instructions = JFile::read(JURI::root().'modules/'.$modname.'/dashboard/en-GB/instructions.html'); } $changelog = JText::_($node['changelog']); if (!$changelog) { $changelog = 'No changelog here yet.'; } $imgpath = $node['imgpath'] ? $node['imgpath'] : 'media/napi/img/dashboard/'; $support = '<a href="http://ninjaforge.com/index.php?option=com_fireboard&Itemid=111"> NinjaForge forums</a>'; $rate = '<a href="http://extensions.joomla.org/extensions/style-&-design/tabs-&-tabss/5726/details"> Joomla.org</a>'; $return = ''; $script = "\n\t\tfunction runonce()\n\t\t{\n\t\t\t\$('tablink1').getParent().addClass('tabactive');\n\t\t\t\$('tabcontent1').addClass('runonce');\n\t\t\t\$\$('ul.menu-nav a').each(function(e){\n\t\t\t\te.addEvent('click', function(){ \n\t\t\t\t\tif(!\$" . "defined(runonce))\n\t\t\t\t\t{\n\t\t\t\t\t\t\$('tabcontent1').removeClass('runonce');\n\t\t\t\t\t\tvar runonce = true;\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t});\n\t\t}\n\t\twindow.addEvent('domready', function(){\n\t\t\twindow.location.hash ? \$('tablink'+window.location.hash.substring(window.location.hash.length - 1, window.location.hash.length)).getParent().addClass('tabactive') : runonce();\n\t\t\tvar dashboard = \$\$('ul.menu-nav a');\n\t\t\tdashboard.each(function(e){\n\t\t\t\te.addEvent('click', (function(event){ \n\t\t\t\t\tthis.addClass('tabactive');\n\t\t\t\t\tindex = dashboard.indexOf(this);\n\t\t\t\t\tdashboard.each(function(e, i){ \n\t\t\t\t\t\tif(i!=index) e.removeClass('tabactive'); \n\t\t\t\t\t}); \n\t\t\t\t}).bindWithEvent(e));\n\t\t\t});\n\t\t});"; // $filter = ' {prefix: \'tab-\', invert: \'ui-filter-select\', parent: \'.ui-corner-all.ui-filter\', items: \'.nftab\', onfilter: function(){ '.$control_name.$name.'(this)} }'; $filter = ''; //$return .= $panel->endPanel(); if (!$this->_parent->get('dashboardStyle')) { $return .= '<style type="text/css"> #' . $control_name . $name . '{ border:1px solid #dddddd; } .nftab .inner{} .nftab{} </style>'; } else { $return .= '<div id="' . $control_name . $name . '" class="ui-corner-all ui-filter">'; } $doc->addStyleDeclaration(' #paramsdashboard-lbl { display: none; } body{font-family:Helvetica,Arial,sans-serif; } #' . $control_name . $name . '{background: #ffffff 0 0; background-repeat: repeat-x; background-position: center -63px; border:0px solid #dddddd; position:relative; margin:0;overflow:hidden; } #' . $control_name . $name . '.content .ui-corner-top { -webkit-border-top-left-radius: 0px; -webkit-border-top-right-radius: 0px; -moz-border-radius-topLeft: 0px; -moz-border-radius-topRight: 0px; } .nftab { display:none; } .nftab:target { display:block; } .menu{ display:block; background-position: 50% 100%; position:relative; } .menu img.dashbg{ width:100%; max-width:692px; display:block;margin: 0px auto 0px 0px auto; background-color: #6A84AB; } .menu ul{display: block; margin-left:auto; margin-right:auto; padding:0px; list-style:none; text-align:center; position: absolute; top:0px; width:100%;} .menu li{background:none; float:left; margin:0px 0px 0px 0px; padding:0px; display:inline-block; overflow:hidden;} .menu li img { float:left; cursor:pointer;visibility:hidden; position: relative; width: 100%; } .menu li#tablink0{max-width: 135px; width:19.5086705202312%;cursor:default; } .menu li#tablink1{max-width: 183px; width:26.4450867052023%} .menu li#tablink2{max-width:191px; width:27.6011560693642%;} .menu li#tablink3{max-width:183px; width:26.4450867052023%; } .menu li#tablink3 img{ cursor:default; } .menu a.tabactive li#tablink1,{backgroud:url(\'' . JURI::root() . $imgpath . 'bg.png\') no-repeat 0 0; } .menu a.tabactive li#tablink2,{backgrond:url(\'' . JURI::root() . $imgpath . 'bg.png\') no-repeat -139px 0; } .menu a.tabactive li#tablink3,.menu li#tablink3:hover{backgroud:url(\'' . JURI::root() . $imgpath . 'bg.png\') no-repeat -277px 0; } .menu a.tabactive li img, .menu li:hover img { /*display:inline;*/ visibility: visible; } .menu .menu-nav li:hover { opacity:0.1; } .menu .menu-nav a.tabactive li, .menu .menu-nav a.tabactive:active li { opacity:1; } .tabtxt{padding:0 0 0 0px; float:none; display:none; } .nftab{ width:auto; text-align:left; padding:0px 10px 6px 10px; font-size:12px; margin-bottom:5px; background-position: 50% -67px; background-repeat: repeat-x; background-color: transparent; background-image: url(' . JURI::root() . $imgpath . 'dashbg.png); } .nftab .inner{ overflow-y:auto; overflow-x:hidden; width:100%; } .nftab h2,.nftab h1{font-weight:bold; text-align:center; padding: 10px 0px; } .nftab h1{color:#fff; margin:0px 0px 15px; padding: 1px 0px 0px 0px; } .nftab strong{font-weight:normal; } .nftab dt strong,.nftab h3 strong{font-weight:bold !important; } .nftab dt{font-weight:bold !important; padding:5px 0pt 2px; } .buttons{border:none; padding:3px; } .nftab .boxshot { text-align:center; margin:0px auto; } .nftab .boxshot img { max-width: ' . ($node['boxshotwidth'] ? $node['boxshotwidth'] : '233px') . '; width: 100%; } .runonce { display:block!important; } .nftab .nftab-content { display: inline-block; width: 50%; float:left; } .nftab .nftab-content p { margin-left: 10px; } .nftab ol { counter-reset: steps; } .nftab ol li { counter-increment: steps; } .nftab ol li:before { content: counter(steps)". "; } .nftab.tab-changelog .inner div { float:left; width:100%; display:block; clear:both; margin-bottom: 40px; } .dashboard-footer { text-align:center; display:inline-block; }'); //die('<pre>'.JURI::base(true).print_r(parse_url(JRequest::getURI(), PHP_URL_QUERY), true).'</pre>'); $return .= ' <!--[if lte IE 6]> <style> .nftab h1 {margin:0px 0px 15px 0px !important;} .nftab {padding:0px 0px 6px !important;} </style> <![endif]--> <div class="menu ui-corner-top"> <img src="' . JURI::root() . $imgpath . 'bg.png" class="dashbg ui-corner-top" /> <ul class="menu-nav ui-corner-top"> <li title="" id="tablink0" class="ui-corner-tl"><img src="' . JURI::root() . $imgpath . 'dashtabbg_0.png" class="ui-corner-tl" /></li> <a href="#tabcontent1"><li title="" id="tablink1" class="tab ui-filter-trigger' . $filter . '"><img src="' . JURI::root() . $imgpath . 'dashtabbg_1.png" /><span id="info" class="tabtxt">General Info</span></li></a> <a href="#tabcontent2"><li title="" id="tablink2" class="tab ui-filter-trigger' . $filter . '"><img src="' . JURI::root() . $imgpath . 'dashtabbg_2.png" /><span id="inst" class="tabtxt">Instructions</span></li></a> <a href="#tabcontent3"><li title="" id="tablink3" class="tab ui-filter-trigger' . $filter . '"><img src="' . JURI::root() . $imgpath . 'dashtabbg_3.png" /><span id="change" class="tabtxt">Changelog</span></li></a> </ul> </div> <div id="tabcontent1" class="nftab tab-general-info filter-general-info ui-filter-item ui-filter-select "> <h1>' . JText::_(current($xml->name)->data()) . '</h1> <div class="inner"> <h2>' . JText::_(current($xml->slogan)->data()) . '</h2> <div class="boxshot nftab-content"><img class="ui-widget-content" src="' . JURI::root() . 'media/' . basename($path, '.xml') . '/img/box.png" alt="' . JText::_(current($xml->name)->data()) . '" title="' . JText::_(current($xml->name)->data()) . '"></div> <div class="description nftab-content"> <p><b>' . JText::_('EXTCREATEDBY') . '</b> '; $i = 0; $count = count($xml->author); $separator = ' '; foreach ($xml->author as $author) { $separator = ' '; $i++; if ($count != 1 && $i != $count) { $separator = $i + 1 == $count ? ' &' : ($i != 0 ? ',' : ''); } //$separator = $i.$count; $email = $author['email'] ? $author['email'] : $xml['authorEmail']; $return .= ' <a href="mailto:' . $email . '">' . $author->data() . '</a>' . $separator; } $creditsxml = current($xml->credits); $credits = array(); $i = 0; foreach ($creditsxml->children() as $credit) { $credits[$i] = '<p>'; $credits[$i] .= '<b>' . JText::_($credit['what']) . '</b> '; $credits[$i] .= '<a href="' . JText::_($credit['where']) . '">' . JText::_($credit['who']) . '</a>'; $credits[$i] .= '</p>'; $i++; } $credits = implode("\n", $credits); $return .= '</p> ' . $credits . ' <p><b>' . JText::_('EXTPHPLIC') . '</b> <a href="http://creativecommons.org/licenses/LGPL/2.1/"> CC-GNU LGPL</a></p> <p><b>' . JText::_('EXTJSLIC') . '</b> <a rel="license" href="http://www.opensource.org/licenses/mit-license.php"> MIT </a></p> <p><b>' . JText::_('EXTCSSIMGCOP') . '</b> ' . JText::sprintf('EXTCSSIMGCOPTXT', '2008', date('Y')) . ' <a target="_blank" href="http://' . current($xml->authorUrl)->data() . '" class="hasTip" title="Click me!::Get more extensions at ' . JText::_(current($xml->copyright)->data()) . '">' . JText::_(current($xml->copyright)->data()) . '</a></p> <p><b>' . JText::_('EXTSUP') . '</b> ' . JText::sprintf('EXTSUPTXT', $support) . '</p> <p><b>' . JText::_('EXTRATE') . '</b> ' . JText::sprintf('EXTRATETXT', $rate) . '</p> </div> </div> </div> <div id="tabcontent2" class="nftab tab-instructions filter-instructions ui-helper-hidden ui-filter-select ui-filter-item"> <h1>' . JText::_('INSTRUCTIONS') . '</h1> <div class="inner"> ' . $instructions . ' </div> </div> <div id="tabcontent3" class="nftab tab-changelog ui-helper-hidden ui-filter-select"> <h1>' . JText::_('CHANGELOG') . '</h1> <div class="inner"> '; $i = 0; $changelog = current($xml->changelog); $count = count($changelog->children()); $count = 2; foreach ($changelog->children() as $log) { $i++; //$separator = $i.$count; //$children = $log[$i]; //die(print_r($log, true)); //$children = $children->children(); //$test = print_r($children->children(), true); $version = $log['version'] ? '<p><b>' . JText::_('Version:') . '</b> ' . $log['version'] . '</p>' : '<p><b>' . JText::_('Version:') . '</b> ' . $xml['version'] . '</p>'; $date = $log['date'] ? '<p><b>' . JText::_('Date:') . '</b> ' . $log['date'] . '</p>' : ''; $state = $log['state'] ? '<p><b>' . JText::_('State:') . '</b> ' . $log['state'] . '</p>' : ''; $changes = '<ul>'; foreach ($log->children() as $child) { $changes .= '<li>' . $child->data() . '</li>'; } $changes .= '</ul>'; $return .= '<div>' . $version . $date . $state . $changes . '</div>'; unset($email); } unset($i); unset($separator); $return .= ' </div> </div> <span class="dashboard-footer"> <a href="http://www.ninjaforge.com" target="_self"><img class="buttons" src="' . JURI::root() . $imgpath . 'ninjaforge.png" alt="Visit NinjaForge" title="Visit Ninjaforge"/></a> <a href="http://jcd-a.org" target="_self"><img class="buttons" src="' . JURI::root() . $imgpath . 'jcda.png" alt="NinjaForge is a JCDA Member" title="NinjaForge is a JCDA Member"/></a> <a href="http://www.mozilla-europe.org/en/firefox/" target="_self"><img class="buttons" src="' . JURI::root() . $imgpath . 'firefox3.png" alt="Get Firefox for a better internet experience" title="Get Firefox for a better internet experience"/></a> <a href="http://getfirebug.com/" target="_self"><img class="buttons" src="' . JURI::root() . $imgpath . 'firebug.png" alt="Ninjas use and recommend Firebug" title="Ninjas use and recommend Firebug"/></a> <a href="http://validator.w3.org/check?uri=referer" target="_self"><img class="buttons" src="' . JURI::root() . $imgpath . 'validation_xhtml.png" alt="Valid XHTML Transitional" title="Valid XHTML Transitional"/></a> <a href="http://jigsaw.w3.org/css-validator/check/referer" target="_self"><img class="buttons" src="' . JURI::root() . $imgpath . 'validation_css.png" alt="Valid CSS" title="Valid CSS"/></a> <a href="http://creativecommons.org/licenses/by-nc-sa/3.0/us/"><img class="buttons" alt="Creative Commons License" src="' . JURI::root() . $imgpath . 'byncsa.png" /></a> <a href="http://creativecommons.org/licenses/LGPL/2.1/"><img class="buttons" alt="CC-GNU GPL" src="' . JURI::root() . $imgpath . 'gnugpl.png" /></a> </span>'; if ($this->_parent->get('dashboardStyle')) { $return .= '</div>'; } JRequest::getCmd('format', 'html') == 'script' ? $doc->addScriptDeclaration($script, '', true) : $uri->setVar('format', 'script'); $uri->setVar('strict', 'true'); $doc->addScript($uri->toString()); $uri->delVar('format'); $uri->delVar('strict'); //filter shortcut return $this->filter($return); }
function getLanguage($uri) { $sefConfig =& SEFConfig::getConfig(); if (!$sefConfig->langEnable) { // Use default language from Joomla or whichever plugin return; } $suffix = $sefConfig->suffix; $lang = ''; $langs = JLanguageHelper::getLanguages('sef'); JFactory::getApplication()->setLanguageFilter(true); switch ($sefConfig->langPlacementJoomla) { case _COM_SEF_LANG_PATH: $lang = $uri->getVar('lang'); if (strlen($lang) == 0) { // Get language from path $path = $uri->getPath(); $suffixLen = strlen($suffix); if ($suffixLen > 0) { if (substr($path, -$suffixLen) == $suffix) { $path = substr($path, 0, -$suffixLen); } } $path = str_replace($uri->base(true), '', $path); $path = ltrim($path, '/'); $path = explode('/', $path); if (array_key_exists($path[0], $langs)) { $lang = $path[0]; } } break; case _COM_SEF_LANG_DOMAIN: // 22.2.2012, dajo: simplified and fixed the function $host = trim($uri->toString(array('host')), '/'); foreach ($sefConfig->subDomainsJoomla as $lng => $domain) { if ($host == $domain) { $lang = $lng; // Save the language code obtained from domain for later use self::set('domain_lang', $lang); break; } } break; } if (strlen($lang) == 0) { $pth = rtrim($uri->getPath(), '/'); if (substr($pth, -9) == 'index.php') { $pth = substr($pth, 0, -9); $pth = rtrim($pth, '/'); } if ($pth == rtrim(JURI::base(true), '/')) { // This is homepage if ($sefConfig->alwaysUseLangHomeJoomla || count($uri->getQuery(true)) > 0 || count($_POST) > 0) { // 17.4.2013 dajo: we should also use cookie if there are some variables set, // eg. for VirtueMart's AJAX cart to display correct language // Language code must always be present, so we can use // cookie and browser setting if it's not there if ($sefConfig->langCookieJoomla) { $lang = JRequest::getString('joomsef_lang', '', 'cookie'); } if (strlen($lang) == 0 || !isset($langs[$lang])) { if ($sefConfig->browserLangJoomla) { $lang = JLanguageHelper::detectLanguage(); $langsCode = JLanguageHelper::getLanguages('lang_code'); if (isset($langsCode[$lang])) { $lang = $langsCode[$lang]->sef; } } } } // If no other language set, use the default one if (strlen($lang) == 0 || !isset($langs[$lang])) { $lang = $sefConfig->mainLanguageJoomla; } } else { // This is not homepage, so if language is not present in URL, use the default one $lang = $sefConfig->mainLanguageJoomla; } } if (strlen($lang)) { if (!isset($langs[$lang])) { $lang = reset(array_keys($langs)); } $lang_code = $langs[$lang]->lang_code; $cfg = JFactory::getConfig(); $cfg->set('language', $lang_code); JRequest::setVar('lang', $lang); JRequest::setVar('language', $lang_code); JFactory::getLanguage()->setLanguage($lang_code); if ($sefConfig->langCookieJoomla && !headers_sent()) { setcookie('joomsef_lang', $lang, time() + 24 * 60 * 60 * 1000, "/"); } JFactory::getLanguage()->getMetadata($lang_code); // Set correct sitename if (!empty($langs[$lang]->sitename)) { $cfg->set('sitename', $langs[$lang]->sitename); } // Set VM currency if enabled if ($sefConfig->vmCurrencyEnable) { if (isset($sefConfig->vmCurrency[$lang]) && !is_null($sefConfig->vmCurrency[$lang])) { $app = JFactory::getApplication(); $app->setUserState('virtuemart_currency_id', $sefConfig->vmCurrency[$lang]); } } } }
/** * Generate a panel of language choices for the user to select their language * * @return boolean True if successful * @since 1.6 */ public function getLanguages() { // Initialise variables. $app = JFactory::getApplication(); // Detect the native language. jimport('joomla.language.helper'); $native = JLanguageHelper::detectLanguage(); if (empty($native)) { $native = 'en-GB'; } // Get a forced language if it exists. $forced = $app->getLocalise(); if (!empty($forced['language'])) { $native = $forced['language']; } // Get the list of available languages. $list = JLanguageHelper::createLanguageList($native); if (!$list || JError::isError($list)) { $list = array(); } return $list; }