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


PHP JFactory::_createLanguage方法代码示例

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


在下文中一共展示了JFactory::_createLanguage方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1:

 /**
  * Get a language object
  *
  * Returns a reference to the global {@link JLanguage} object, only creating it
  * if it doesn't already exist.
  *
  * @access public
  * @return object JLanguage
  */
 function &getLanguage()
 {
     static $instance;
     if (!is_object($instance)) {
         //get the debug configuration setting
         $conf =& JFactory::getConfig();
         $debug = $conf->getValue('config.debug_lang');
         $instance = JFactory::_createLanguage();
         $instance->setDebug($debug);
     }
     return $instance;
 }
开发者ID:janssit,项目名称:www.technovit.be,代码行数:21,代码来源:factory.php

示例2: onAfterRoute

 /**
  * Grabs the params from the db if we are getting an article,
  * then gets the language tag from it. If there's a valid language
  * tag then we set it into the JDocument. That's all.
  * @access	public
  */
 function onAfterRoute()
 {
     $option = JRequest::getVar("option", '');
     if ($option == "com_content") {
         if (JRequest::getVar("view", null) == 'article') {
             $id = (int) JRequest::getVar('id');
             $db =& JFactory::getDBO();
             $query = 'SELECT attribs ' . ' FROM #__content' . ' WHERE id = ' . $id;
             $db->setQuery($query);
             $attribs = $db->loadResult();
             $aparams = explode("\n", $attribs);
             $html_lang_tag = $this->params->get('html_lang_tag', 1);
             foreach ($aparams as $param) {
                 $vart = strpos($param, "language");
                 if ($vart !== false) {
                     $langnow = $param;
                     $user = JFactory::getUser();
                     $langnow = explode("=", $langnow);
                     foreach ($langnow as $langnow) {
                         if ($langnow !== "language" && $langnow != '') {
                             if (!$html_lang_tag) {
                                 $doc =& JFactory::getDocument();
                                 $doc->setLanguage($langnow);
                             }
                             if ($html_lang_tag) {
                                 // do the whole page (also does the <html> tag stuff)
                                 $config =& JFactory::getConfig();
                                 $oldlang =& JFactory::getLanguage();
                                 if ($oldlang->getTag() != $langnow) {
                                     // this is slightly dodgy, in that the original language object was created
                                     // BEFORE all the routing was done.
                                     // $mainframe->route()   and  $mainframe->authorize()  are done with the
                                     // old language, before we get this chance to set the new one.
                                     // But neither of those seem to need anything to do with the old language
                                     // so we are almost certainly fine :-)
                                     $config->setValue('config.language', $langnow);
                                     $oldlang = JFactory::_createLanguage();
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
开发者ID:raulrotundo,项目名称:jpmoser_guide,代码行数:52,代码来源:enablecontentlanguages.php

示例3: shSetJfLanguage

function shSetJfLanguage($requestlang)
{
    if (empty($requestlang)) {
        return;
    }
    // get instance of JoomFishManager to obtain active language list and config values
    $jfm =& JoomFishManager::getInstance();
    $activeLanguages = $jfm->getActiveLanguages();
    // get the name of the language file for joomla
    $jfLang = TableJFLanguage::createByShortcode($requestlang, true);
    // set Joomfish stuff
    // Get the global configuration object
    global $mainframe;
    $registry =& JFactory::getConfig();
    $params = $registry->getValue("jfrouter.params");
    $enableCookie = empty($params) ? 1 : $params->get('enableCookie', 1);
    if ($enableCookie) {
        setcookie("lang", "", time() - 1800, "/");
        setcookie("jfcookie", "", time() - 1800, "/");
        setcookie("jfcookie[lang]", $jfLang->shortcode, time() + 24 * 3600, '/');
    }
    $GLOBALS['iso_client_lang'] = $jfLang->shortcode;
    $GLOBALS['mosConfig_lang'] = $jfLang->code;
    $mainframe->setUserState('application.lang', $jfLang->code);
    $registry->setValue("config.jflang", $jfLang->code);
    $registry->setValue("config.lang_site", $jfLang->code);
    $registry->setValue("config.language", $jfLang->code);
    $registry->setValue("joomfish.language", $jfLang);
    // Force factory static instance to be updated if necessary
    $lang =& JFactory::getLanguage();
    if ($jfLang->code != $lang->getTag()) {
        $lang = JFactory::_createLanguage();
    }
    $lang16 =& shjlang16Helper::getLanguage();
    if ($jfLang->code != $lang16->getTag()) {
        $lang16 = Jlanguage16::createLanguage();
    }
    // overwrite with the valued from $jfLang
    $params = new JParameter($jfLang->params);
    $paramarray = $params->toArray();
    foreach ($paramarray as $key => $val) {
        $registry->setValue("config." . $key, $val);
        if (defined("_JLEGACY")) {
            $name = 'mosConfig_' . $key;
            $GLOBALS[$name] = $val;
        }
    }
    // set our own data
    $GLOBALS['shMosConfig_lang'] = $lang->get('backwardlang', 'english');
    $GLOBALS['shMosConfig_locale'] = $jfLang->code;
    $GLOBALS['shMosConfig_shortcode'] = $jfLang->shortcode;
}
开发者ID:sangkasi,项目名称:joomla,代码行数:52,代码来源:sh404sef.class.php

示例4: _discoverJFLanguage


//.........这里部分代码省略.........
                        }
                    }
                }
            }
            // Add the existing variables
            if ($hrefVars != "") {
                $href .= '?' . $hrefVars;
            }
            if ($jfLang->getLanguageCode() != null) {
                $ulang = 'lang=' . $jfLang->getLanguageCode();
            } else {
                // it's important that we add at least the basic parameter - as of the sef is adding the actual otherwise!
                $ulang = 'lang=';
            }
            // if there are other vars we need to add a & otherwiese ?
            if ($hrefVars == '') {
                $href .= '?' . $ulang;
            } else {
                $href .= '&amp;' . $ulang;
            }
            $registry->setValue("config.multilingual_support", true);
            global $mainframe;
            $mainframe->setUserState('application.lang', $jfLang->code);
            $registry->setValue("config.jflang", $jfLang->code);
            $registry->setValue("config.lang_site", $jfLang->code);
            $registry->setValue("config.language", $jfLang->code);
            $registry->setValue("joomfish.language", $jfLang);
            $href = JRoute::_($href, false);
            header('HTTP/1.1 303 See Other');
            header("Location: " . $href);
            exit;
        }
        if (isset($jfLang) && $jfLang->code != "" && ($jfLang->active || $jfm->getCfg("frontEndPreview"))) {
            $locale = $jfLang->code;
        } else {
            $jfLang = TableJFLanguage::createByJoomla($locale);
            if (!$jfLang->active) {
                ?>
			<div style="background-color: #c00; color: #fff">
				<p style="font-size: 1.5em; font-weight: bold; padding: 10px 0px 10px 0px; text-align: center; font-family: Arial, Helvetica, sans-serif;">
				Joom!Fish config error: Default language is inactive!<br />&nbsp;<br />
				Please check configuration, try to use first active language</p>
			</div>
			<?php 
                $activeLanguages = $jfm->getActiveLanguages();
                if (count($activeLanguages) > 0) {
                    $jfLang = $activeLanguages[0];
                    $locale = $jfLang->code;
                } else {
                    // No active language defined - using system default is only alternative!
                }
            }
            $client_lang = $jfLang->shortcode != '' ? $jfLang->shortcode : $jfLang->iso;
        }
        // TODO set the cookie domain so that it works for all subdomains
        if ($enableCookie) {
            setcookie("lang", "", time() - 1800, "/");
            setcookie("jfcookie", "", time() - 1800, "/");
            setcookie("jfcookie[lang]", $client_lang, time() + 24 * 3600, '/');
        }
        if (defined("_JLEGACY")) {
            $GLOBALS['iso_client_lang'] = $client_lang;
            $GLOBALS['mosConfig_lang'] = $jfLang->code;
        }
        $registry->setValue("config.multilingual_support", true);
        global $mainframe;
        $mainframe->setUserState('application.lang', $jfLang->code);
        $registry->setValue("config.jflang", $jfLang->code);
        $registry->setValue("config.lang_site", $jfLang->code);
        $registry->setValue("config.language", $jfLang->code);
        $registry->setValue("joomfish.language", $jfLang);
        // Force factory static instance to be updated if necessary
        $lang =& JFactory::getLanguage();
        if ($jfLang->code != $lang->getTag()) {
            // Must not assign by reference in order to overwrite the existing reference to the static instance of the language
            $lang = JFactory::_createLanguage();
            $lang->setDefault($jfLang->code);
            $lang->_metadata = array();
            $lang->_metadata['tag'] = $jfLang->code;
            $lang->_metadata['rtl'] = false;
        }
        // no need to set locale for this ISO code its done by JLanguage
        // overwrite with the valued from $jfLang
        $jfparams = JComponentHelper::getParams("com_joomfish");
        $overwriteGlobalConfig = $jfparams->get('overwriteGlobalConfig', 0);
        if ($overwriteGlobalConfig) {
            // We should overwrite additional global variables based on the language parameter configuration
            $params = new JParameter($jfLang->params);
            $paramarray = $params->toArray();
            foreach ($paramarray as $key => $val) {
                if (trim($val) !== '') {
                    $registry->setValue("config." . $key, $val);
                }
                if (defined("_JLEGACY")) {
                    $name = 'mosConfig_' . $key;
                    $GLOBALS[$name] = $val;
                }
            }
        }
    }
开发者ID:JoomFish,项目名称:joomfish-2.2,代码行数:101,代码来源:jfrouter.php

示例5: getLanguage

 /**
  * Get a language object
  *
  * Returns the global {@link JLanguage} object, only creating it
  * if it doesn't already exist.
  *
  * @return object JLanguage
  */
 public static function getLanguage()
 {
     if (!is_object(JFactory::$language)) {
         //get the debug configuration setting
         $conf =& JFactory::getConfig();
         $debug = $conf->getValue('config.debug_lang');
         JFactory::$language = JFactory::_createLanguage();
         JFactory::$language->setDebug($debug);
     }
     return JFactory::$language;
 }
开发者ID:joebushi,项目名称:joomla,代码行数:19,代码来源:factory.php


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