107 $this->_blIsTranslated = $blIsTranslated;
127 $this->_iBaseLanguageId = null;
137 if ($this->_iBaseLanguageId === null) {
143 if ($blAdmin && (($iSeLang =
oxRegistry::getConfig()->getRequestParameter(
'changelang')) !== null)) {
144 $this->_iBaseLanguageId = $iSeLang;
147 if (is_null($this->_iBaseLanguageId)) {
152 $aLanguageUrls =
$myConfig->getConfigParam(
'aLanguageURLs');
154 if (!$blAdmin && is_array($aLanguageUrls)) {
155 foreach ($aLanguageUrls as $iId => $sUrl) {
156 if ($sUrl &&
$myConfig->isCurrentUrl($sUrl)) {
157 $this->_iBaseLanguageId = $iId;
163 if (is_null($this->_iBaseLanguageId)) {
165 if (!isset($this->_iBaseLanguageId)) {
172 if (is_null($this->_iBaseLanguageId) && !$blAdmin && !
oxRegistry::getUtils()->isSearchEngine()) {
175 $this->_iBaseLanguageId =
oxRegistry::get(
"oxUtilsServer")->getOxCookie(
'language');
178 if (is_null($this->_iBaseLanguageId)) {
183 if (is_null($this->_iBaseLanguageId)) {
184 $this->_iBaseLanguageId =
$myConfig->getConfigParam(
'sDefaultLang');
187 $this->_iBaseLanguageId = (int) $this->_iBaseLanguageId;
192 oxRegistry::get(
"oxUtilsServer")->setOxCookie(
'language', $this->_iBaseLanguageId);
205 if ($this->_iObjectTplLanguageId === null) {
208 if (!isset(
$aLanguages[$this->_iObjectTplLanguageId]) ||
209 $aLanguages[$this->_iObjectTplLanguageId]->active == 0
227 if ($this->_iTplLanguageId === null) {
242 if ($this->_iEditLanguageId === null) {
251 if (
"saveinnlang" == $this->
getConfig()->getActiveView()->getFncName()) {
278 public function getLanguageArray($iLanguage = null, $blOnlyActive =
false, $blSort =
false)
282 if (is_null($iLanguage)) {
287 $aConfLanguages =
$myConfig->getConfigParam(
'aLanguages');
288 $aLangParams =
$myConfig->getConfigParam(
'aLanguageParams');
290 if (is_array($aConfLanguages)) {
292 reset($aConfLanguages);
293 while (list($key, $val) = each($aConfLanguages)) {
295 if ($blOnlyActive && is_array($aLangParams)) {
297 if (!$aLangParams[$key][
'active']) {
304 $oLang =
new stdClass();
305 $oLang->id = isset($aLangParams[$key][
'baseId']) ? $aLangParams[$key][
'baseId'] : $i;
310 if (is_array($aLangParams)) {
311 $oLang->active = $aLangParams[$key][
'active'];
312 $oLang->sort = $aLangParams[$key][
'sort'];
315 $oLang->selected = (isset($iLanguage) && $oLang->id == $iLanguage) ? 1 : 0;
322 if ($blSort && is_array($aLangParams)) {
323 uasort(
$aLanguages, array($this,
'_sortLanguagesCallback'));
336 if ($this->_aAdminTplLanguageArray === null) {
340 $this->_aAdminTplLanguageArray = array();
342 $sSourceDir =
$myConfig->getAppDir() .
'views/admin/';
343 foreach ($aLangArray as $iLangKey => $oLang) {
344 $sFilePath =
"{$sSourceDir}{$oLang->abbr}/lang.php";
345 if (file_exists($sFilePath) && is_readable($sFilePath)) {
346 $this->_aAdminTplLanguageArray[$iLangKey] = $oLang;
352 reset($this->_aAdminTplLanguageArray);
366 if ($this->_aLangAbbr === null) {
370 $iLanguage = isset($iLanguage) ? (int) $iLanguage : $this->
getBaseLanguage();
371 if (isset($this->_aLangAbbr[$iLanguage])) {
372 $iLanguage = $this->_aLangAbbr[$iLanguage];
386 $aConfLanguages = $this->
getConfig()->getConfigParam(
'aLanguages');
389 foreach ($aLangIds as $iId => $sValue) {
408 public function translateString($sStringToTranslate, $iLang = null, $blAdminMode = null)
413 if (isset(
$aLang[$sStringToTranslate])) {
414 return $aLang[$sStringToTranslate];
419 if (isset(
$aLang[$aMap[$sStringToTranslate]])) {
420 return $aLang[$aMap[$sStringToTranslate]];
424 if (count($this->_aAdditionalLangFiles)) {
426 if (isset(
$aLang[$sStringToTranslate])) {
427 return $aLang[$sStringToTranslate];
433 return $sStringToTranslate;
448 foreach ($aData as $sValKey => $sValue) {
449 if (strpos($sValKey, $sKey) === 0) {
450 $aCollection[$sValKey] = $sValue;
469 startProfile(
"getSimilarByKey");
472 $blAdmin = isset($blAdmin) ? $blAdmin : $this->
isAdmin();
483 if (count($this->_aAdditionalLangFiles)) {
488 stopProfile(
"getSimilarByKey");
490 return $aSimilarConst;
504 $oActCur = $this->
getConfig()->getActShopCurrencyObject();
508 return number_format((
double) $sValue, $oActCur->decimal, $oActCur->dec, $oActCur->thousand);
522 $sValue = ( string ) $dValue;
525 if (($iDotPos = $oStr->strpos($sValue,
'.')) !==
false) {
526 $iDecPos = $oStr->strlen($oStr->substr($sValue, $iDotPos + 1));
529 $oActCur = $oActCur ? $oActCur : $this->
getConfig()->getActShopCurrencyObject();
530 $iDecPos = ($iDecPos < $oActCur->decimal) ? $iDecPos : $oActCur->decimal;
532 return number_format((
double) $dValue, $iDecPos, $oActCur->dec, $oActCur->thousand);
544 if (!isset($iLanguage)) {
548 $iLanguage = (int) $iLanguage;
550 return (($iLanguage) ?
"_$iLanguage" :
"");
562 $iLang = (int) $iLang;
568 if (isset($oLang->id)) {
583 if (is_null($iLang)) {
586 $this->_iBaseLanguageId = (int) $iLang;
589 if (defined(
'OXID_PHP_UNIT')) {
590 modSession::getInstance();
605 $this->_iTplLanguageId = isset($iLang) ? (int) $iLang : $this->
getBaseLanguage();
613 if (defined(
'OXID_PHP_UNIT')) {
614 modSession::getInstance();
634 foreach ($aLangArray as $sKey => $sValue) {
636 if ($blRecodeKeys ===
true) {
637 $sItemKey = iconv($sCharset,
'UTF-8', $sItemKey);
640 $aLangs[$sItemKey] = iconv($sCharset,
'UTF-8', $sValue);
641 unset($aLangArray[$sKey]);
657 $aLangFiles = array();
659 $sAppDir = $oConfig->getAppDir();
661 $sTheme = $oConfig->getConfigParam(
"sTheme");
662 $sCustomTheme = $oConfig->getConfigParam(
"sCustomTheme");
663 $sShopId = $oConfig->getShopId();
667 $sGenericPath = $sAppDir .
'translations/' . $sLang;
669 $aLangFiles[] = $sGenericPath .
"/lang.php";
675 $sThemePath = $sAppDir .
'views/' . $sTheme .
'/' . $sLang;
676 $aLangFiles[] = $sThemePath .
"/lang.php";
682 $sCustPath = $sAppDir .
'views/' . $sCustomTheme .
'/' . $sLang;
683 $aLangFiles[] = $sCustPath .
"/lang.php";
696 return count($aLangFiles) ? $aLangFiles :
false;
709 $aLangFiles = array();
711 $sAppDir = $oConfig->getAppDir();
714 $aModulePaths = array();
719 $sAdminPath = $sAppDir .
'views/admin/' . $sLang;
720 $aLangFiles[] = $sAdminPath .
"/lang.php";
721 $aLangFiles[] = $sAppDir .
'translations/' . $sLang .
'/translit_lang.php';
725 $sThemePath = $sAppDir .
'views/*/' . $sLang;
726 $aLangFiles = $this->
_appendLangFile($aLangFiles, $sThemePath,
"options");
734 return count($aLangFiles) ? $aLangFiles :
false;
748 $aFiles = glob($sFullPath .
"/*_{$sFilePattern}.php");
749 if (is_array($aFiles) && count($aFiles)) {
750 foreach ($aFiles as $sFile) {
751 if (!strpos($sFile,
'cust_lang.php')) {
752 $aLangFiles[] = $sFile;
772 $sAppDir = $oConfig->getAppDir();
773 $sTheme = $oConfig->getConfigParam(
"sTheme");
774 $sCustomTheme = $oConfig->getConfigParam(
"sCustomTheme");
777 $aLangFiles[] = $sAppDir .
'views/admin/' . $sLang .
'/cust_lang.php';
780 $aLangFiles[] = $sAppDir .
'views/' . $sTheme .
'/' . $sLang .
'/cust_lang.php';
783 $aLangFiles[] = $sAppDir .
'views/' . $sCustomTheme .
'/' . $sLang .
'/cust_lang.php';
802 if (is_array($aModulePaths)) {
804 foreach ($aModulePaths as $sPath) {
805 $sFullPath = $oConfig->getModulesDir() . $sPath;
806 if (file_exists($sFullPath .
'/application/')) {
807 $sFullPath .=
'/application';
809 $sFullPath .= ($blForAdmin) ?
'/views/admin/' :
'/translations/';
810 $sFullPath .= $sLang;
814 $aLangFiles[] = $sFullPath .
'/module_options.php';
834 $sLangFilesIdent =
'_default';
835 if (is_array($aLangFiles) && $aLangFiles) {
836 $sLangFilesIdent =
'_' . md5(implode(
'+', $aLangFiles));
839 return "langcache_" . ((int) $blAdmin) .
"_{$iLang}_" .
$myConfig->getShopId() .
"_" .
$myConfig->getConfigParam(
'sTheme') . $sLangFilesIdent;
857 $aLangCache = $myUtils->getLangCache($sCacheName);
858 if (!$aLangCache && $aLangFiles === null) {
865 if (!$aLangCache && $aLangFiles) {
866 $aLangCache = array();
867 $sBaseCharset =
false;
869 $aLangSeoReplaceChars = array();
870 foreach ($aLangFiles as $sLangFile) {
872 if (file_exists($sLangFile) && is_readable($sLangFile)) {
877 if (isset(
$aLang[
'charset'])) {
888 $aLang[
'charset'] =
'UTF-8';
895 if (!$sBaseCharset) {
896 $sBaseCharset =
$aLang[
'charset'];
899 $aLangCache = array_merge($aLangCache,
$aLang);
906 $aLangCache[
'charset'] = $sBaseCharset;
910 $aLangCache[
'_aSeoReplaceChars'] = $aLangSeoReplaceChars;
913 $myUtils->setLangCache($sCacheName, $aLangCache);
929 $blAdmin = isset($blAdmin) ? $blAdmin : $this->
isAdmin();
930 $sKey = $iLang . ((int) $blAdmin);
931 if (!isset($this->_aLangMap[$sKey])) {
932 $this->_aLangMap[$sKey] = array();
936 $sParentMapFile =
$myConfig->getAppDir() .
'/views/' . ($blAdmin ?
'admin' :
$myConfig->getConfigParam(
"sTheme")) .
'/' .
oxRegistry::getLang()->getLanguageAbbr($iLang) .
'/map.php';
937 $sCustomThemeMapFile =
$myConfig->getAppDir() .
'/views/' . ($blAdmin ?
'admin' :
$myConfig->getConfigParam(
"sCustomTheme")) .
'/' .
oxRegistry::getLang()->getLanguageAbbr($iLang) .
'/map.php';
939 if (file_exists($sCustomThemeMapFile) && is_readable($sCustomThemeMapFile)) {
940 $sMapFile = $sCustomThemeMapFile;
941 } elseif (file_exists($sParentMapFile) && is_readable($sParentMapFile)) {
942 $sMapFile = $sParentMapFile;
947 $this->_aLangMap[$sKey] = $aMap;
952 return $this->_aLangMap[$sKey];
965 $iLang = ($iLang === null && $blAdmin) ? $this->
getTplLanguage() : $iLang;
966 if (!isset($iLang)) {
968 if (!isset($iLang)) {
987 startProfile(
"_getLangTranslationArray");
989 $blAdmin = isset($blAdmin) ? $blAdmin : $this->
isAdmin();
993 if (!isset($this->_aLangCache[$sCacheName])) {
994 $this->_aLangCache[$sCacheName] = array();
996 if (!isset($this->_aLangCache[$sCacheName][$iLang])) {
998 $this->_aLangCache[$sCacheName][$iLang] = $this->
_getLanguageFileData($blAdmin, $iLang, $aLangFiles);
1001 stopProfile(
"_getLangTranslationArray");
1004 return (isset($this->_aLangCache[$sCacheName][$iLang]) ? $this->_aLangCache[$sCacheName][$iLang] : array());
1017 return ($a1->sort > $a2->sort);
1039 $sLang =
"<input type=\"hidden\" name=\"" . $this->
getName() .
"\" value=\"" . $this->
getBaseLanguage() .
"\" />";
1057 $sLang = $this->
getName() .
"=" . $iLang;
1085 if (!$oStr->preg_match(
'/(\?|&(amp;)?)lang=[0-9]+/', $sUrl) &&
1086 ($iLang != $iDefaultLang || $iDefaultLang != $iBrowserLanguage)
1089 if ($oStr->strpos($sUrl,
'?') ===
false) {
1091 } elseif (!$oStr->preg_match(
'/(\?|&(amp;)?)$/', $sUrl)) {
1095 $sUrl .= $sParam .
"&";
1097 $sUrl = $oStr->preg_replace(
'/(\?|&(amp;)?)lang=[0-9]+/',
'\1' . $sParam, $sUrl);
1114 if (!is_null($sBrowserLanguage)) {
1118 if ($oLang->abbr == $sBrowserLanguage) {
1132 $aTables = array(
"oxarticles",
"oxartextends",
"oxattribute",
1133 "oxcategories",
"oxcontents",
"oxcountry",
1134 "oxdelivery",
"oxdiscount",
"oxgroups",
1135 "oxlinks",
"oxnews",
"oxobject2attribute",
1136 "oxpayments",
"oxselectlist",
"oxshops",
1137 "oxactions",
"oxwrapping",
"oxdeliveryset",
1138 "oxvendor",
"oxmanufacturers",
"oxmediaurls",
1142 $aMultiLangTables = $this->
getConfig()->getConfigParam(
'aMultiLangTables');
1144 if (is_array($aMultiLangTables)) {
1145 $aTables = array_merge($aTables, $aMultiLangTables);
1176 if ($this->_aActiveModuleInfo === null) {
1177 $oModuleList =
oxNew(
'oxModuleList');
1178 $this->_aActiveModuleInfo = $oModuleList->getActiveModuleInfo();
1191 if ($this->_aDisabledModuleInfo === null) {
1192 $oModuleList =
oxNew(
'oxModuleList');
1193 $this->_aDisabledModuleInfo = $oModuleList->getDisabledModuleInfo();
1206 $sBrowserLang = null;
1207 if (isset($_SERVER[
'HTTP_ACCEPT_LANGUAGE']) && $_SERVER[
'HTTP_ACCEPT_LANGUAGE']) {
1208 $sBrowserLang = strtolower(substr($_SERVER[
'HTTP_ACCEPT_LANGUAGE'], 0, 2));
1211 return $sBrowserLang;
1235 if (empty($iShopId) || $iShopId == $this->
getConfig()->getShopId()) {
1254 $aLangParams = $oConfig->getConfigParam(
'aLanguageParams');
1255 if (is_array($aLangParams)) {
1289 $aConfigDecodedValues = array();
1292 foreach ($aConfigValues as $sConfigValue) {
1293 $aConfigLanguages = unserialize($sConfigValue[
'oxvarvalue']);
1296 if ($sLanguageParameterName ==
'aLanguageParams') {
1298 } elseif ($sLanguageParameterName ==
'aLanguages') {
1302 $aConfigDecodedValues = array_unique(array_merge($aConfigDecodedValues,
$aLanguages));
1305 return $aConfigDecodedValues;
1322 select " . $oConfig->getDecodeValueQuery() .
" as oxvarvalue
1324 where oxvarname = '{$sParamName}' ";
1326 if (!empty($sShopId)) {
1327 $sQuery .=
" and oxshopid = '{$sShopId}' limit 1";
1330 return $oDb->getArray($sQuery);
1344 foreach ($aLanguageParams as $sAbbr => $aValue) {
1345 $iBaseId = (int) $aValue[
'baseId'];