Пример #1
0
 public static function InitializeLanguage()
 {
     global $argv;
     if (strstr($_SERVER['REQUEST_URI'], '_devtools')) {
         return false;
     }
     if (strstr($_SERVER['REQUEST_URI'], 'image.php')) {
         return false;
     }
     if (strstr($_SERVER['REQUEST_URI'], 'profile.php')) {
         return false;
     }
     QApplication::$SourceLanguage = NarroLanguage::LoadByLanguageCode(__SOURCE_LANGUAGE_CODE__);
     // language passed through the l parameter
     if (@$_REQUEST['l']) {
         QApplication::$TargetLanguage = NarroLanguage::LoadByLanguageCode(@$_REQUEST['l']);
     } elseif (isset($argv) && ($strLanguage = $argv[array_search('--translation-lang', $argv) + 1])) {
         QApplication::$TargetLanguage = NarroLanguage::LoadByLanguageCode($strLanguage);
     } else {
         if (QApplication::$User->UserId != NarroUser::ANONYMOUS_USER_ID) {
             $objGuessedLanguage = NarroLanguage::LoadByLanguageCode(QApplication::$User->GetPreferenceValueByName('Language'));
             if (!$objGuessedLanguage instanceof NarroLanguage || !$objGuessedLanguage->Active) {
                 $objGuessedLanguage = null;
             }
         }
         if (!$objGuessedLanguage) {
             $objGuessedLanguage = QApplication::GetBrowserLanguage();
             if (!$objGuessedLanguage instanceof NarroLanguage || !$objGuessedLanguage->Active) {
                 $objGuessedLanguage = null;
             }
         }
         if (!$objGuessedLanguage) {
             $objGuessedLanguage = NarroLanguage::QuerySingle(QQ::Equal(QQN::NarroLanguage()->Active, true));
         }
         if (!$objGuessedLanguage) {
             die('There are no active languages in the database.');
         } else {
             if (!isset($_REQUEST['openid_mode']) && !isset($argv)) {
                 QApplication::Redirect(sprintf('projects.php?l=%s', $objGuessedLanguage->LanguageCode));
                 exit;
             } else {
                 QApplication::$TargetLanguage = $objGuessedLanguage;
             }
         }
     }
     if (QApplication::$TargetLanguage->Active == false && !isset($argv)) {
         die(sprintf('The language %s is not active. Please ask the administrator to activate or check your URL if this is not the language you wanted.', QApplication::$TargetLanguage->LanguageName));
     }
 }
Пример #2
0
 /**
  * Load a single NarroLanguage object,
  * by LanguageCode Index(es)
  * @param string $strLanguageCode
  * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
  * @return NarroLanguage
  */
 public static function LoadByLanguageCode($strLanguageCode, $objOptionalClauses = null)
 {
     return NarroLanguage::QuerySingle(QQ::AndCondition(QQ::Equal(QQN::NarroLanguage()->LanguageCode, $strLanguageCode)), $objOptionalClauses);
 }