languages
[ class tree: languages ] [ index: languages ] [ all elements ]

Source for file import.php

Documentation is available at import.php

  1. <?php
  2. /**
  3.  * @package languages
  4.  * @subpackage functions
  5.  * @version $Header$
  6.  */
  7.  
  8. // Copyright (c) 2002-2003, Luis Argerich, Garland Foster, Eduardo Polidor, et. al.
  9. // All Rights Reserved. See below for details and a complete list of authors.
  10. // Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See http://www.gnu.org/copyleft/lesser.html for details.
  11.  
  12. /**
  13.  * Initialization
  14.  */
  15. require_once'../kernel/setup_inc.php' );
  16.  
  17. $gBitSystem->verifyPermission'p_languages_import' );
  18.  
  19. $impMsg array();
  20.  
  21. $mid 'bitpackage:languages/import_languages.tpl';
  22.  
  23. // Lookup translated names for the languages
  24. $impLanguages $gBitLanguage->listLanguagesTRUETRUE );
  25. foreacharray_keys($impLanguagesas $langCode {
  26.     if!$gBitLanguage->isImportFileAvailable$langCode ) ) {
  27.         unset$impLanguages[$langCode);
  28.     }
  29. }
  30. $gBitSmarty->assign_by_ref('impLanguages'$impLanguages );
  31.  
  32. if (isset($_REQUEST["exp_language"])) {
  33.     $exp_language $_REQUEST["exp_language"];
  34.     $gBitSmarty->assign('exp_language'$exp_language);
  35. }
  36.  
  37. // Import
  38. if (isset($_REQUEST["import"])) {
  39.     if!empty$_REQUEST['imp_languages') ) {
  40.         foreach$_REQUEST['imp_languages'as $impLang {
  41.             if$gBitLanguage->importTranslationStrings$impLang$_REQUEST['overwrite'== 'y' )) {
  42.                 $impMsg['success']["Imported lang/" $impLang "/language.php";
  43.             else {
  44.                 $impMsg['error']["Language could not be imported";
  45.             }
  46.         }
  47.     }
  48.  
  49.     if!empty$_REQUEST["import_master"&& $gBitUser->isAdmin() ) {
  50.         $gBitLanguage->importMasterStrings$_REQUEST['overwrite');
  51.         $impMsg['success'"Imported lang/masters.php";
  52.     }
  53.  
  54.     if!empty$_FILES['upload_file']['tmp_name') ) {
  55.         $gBitLanguage->importTranslationStrings$_REQUEST['upload_lang_code']$_REQUEST['overwrite'== 'y' )'i18n_strings`'$_FILES['upload_file']['tmp_name');
  56.     }
  57.  
  58.     if( ($_REQUEST['overwrite'== 'r'&& !empty$gBitLanguage->mImportConflicts ) ) {
  59.         unset$impMsg['error');
  60.         $impMsg['warning'][tra"Conflicts occured during language import" );
  61.         $gBitSmarty->assign_by_ref'impConflicts'$gBitLanguage->mImportConflicts );
  62.         $mid 'bitpackage:languages/import_resolve.tpl';
  63.     }
  64.  
  65. elseif (isset($_REQUEST["resolve"])) {
  66.     if!empty$_REQUEST['conflict') ) {
  67.         foreacharray_keys$_REQUEST['conflict'as $langCode {
  68.             foreacharray_keys$_REQUEST['conflict'][$langCodeas $sourceHash {
  69.                 if!empty$_REQUEST['conflict'][$langCode][$sourceHash) ) {
  70.                     $gBitLanguage->storeTranslationString$langCode$_REQUEST['conflict'][$langCode][$sourceHash]$sourceHash );
  71.                 }
  72.             }
  73.         }
  74.         $impMsg['success']["Language conflicts have been resolved.";
  75.     }
  76. elseif (isset($_REQUEST["export"])) {
  77.     $langCode $_REQUEST['export_lang_code'];
  78.     $gBitLanguage->loadLanguage$langCode );
  79.     $data  "<?php\n";
  80.     $data .= "// Save this to languages/lang/(lang_code)/language.php where lang_code is the language your are downloading.\n\n";
  81.     $data .= "\$lang=Array(\n";
  82.  
  83.     //vd($gBitLanguage->mStrings);
  84.     foreach$gBitLanguage->mStrings[$_REQUEST['export_lang_code']] as $tran {
  85.         if!empty$_REQUEST['all_trans'||  $tran['version'== BIT_MAJOR_VERSION && !empty$tran['trans'))) {
  86.             if!empty$_REQUEST['include_empty'|| !empty$tran['trans')) {
  87.                 $data .= "'" str_replace"'""\\'"stripslashes$tran["source")) "' => '" str_replace"'""\\'",stripslashes$tran["trans")) "',\n";
  88.             }
  89.         }
  90.     }
  91.  
  92.     $data $data ");\n?>";
  93.     if$_REQUEST['target'== 'download' {
  94.         header ("Content-type: application/unknown");
  95.         header ("Content-Disposition: attachment; filename=language-".$langCode.".php");
  96.         echo $data;
  97.         exit (0);
  98.     else {
  99.         // This file MUST be name "...txt" for security reasons.
  100.         // if the file ended with .php - an evil editor could enter evil shit into a translation, and export it to your temp dir, and then execute it.
  101.         // XOXO spiderr
  102.         $fileName 'lang/'.$langCode.'-language.php.txt';
  103.         $file fopenTEMP_PKG_PATH.$fileName"w" );
  104.         fwrite$file$data );
  105.         fclose$file );
  106.         $impMsg['success'"Language file has been exported to <a href=\"".TEMP_PKG_URL.$fileName."\">$fileName</a>";
  107.     }
  108.  
  109.     // unset this massive array to free up memory
  110.     unset$gBitLanguage->mStrings[$_REQUEST['export_lang_code']] );
  111. }
  112.  
  113. // Get languages that can be exported
  114. $expLanguages $gBitLanguage->getImportedLanguages();
  115. $gBitSmarty->assign_by_ref('expLanguages'$expLanguages );
  116.  
  117. $gBitSmarty->assign'impmsg'$impMsg );
  118.  
  119. $gBitSystem->display$mid'Languages Im/Export' array'display_mode' => 'display' ));
  120.  
  121. ?>

Documentation generated on Wed, 29 Jul 2015 13:56:42 +0000 by phpDocumentor 1.5.0-lsces