home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 April / CMCD0404.ISO / Software / Freeware / Programare / dotproject / modules / system / translate_save.php < prev    next >
Encoding:
PHP Script  |  2003-07-04  |  1.7 KB  |  50 lines

  1. <?php /* SYSTEM $Id: translate_save.php,v 1.5 2003/07/04 01:45:10 eddieajau Exp $ */
  2. /**
  3. * Processes the entries in the translation form.
  4. * @version $Revision: 1.5 $
  5. * @author Andrew Eddie <users.sourceforge.net>
  6. */
  7.  
  8. $module = isset( $HTTP_POST_VARS['module'] ) ? $HTTP_POST_VARS['module'] : 0;
  9. $lang = isset( $HTTP_POST_VARS['lang'] ) ? $HTTP_POST_VARS['lang'] : 'es';
  10.  
  11. $trans = isset( $HTTP_POST_VARS['trans'] ) ? $HTTP_POST_VARS['trans'] : 0;
  12. //echo '<pre>';print_r( $trans );echo '</pre>';die;
  13.  
  14. if (!($fp = fopen ("{$AppUI->cfg['root_dir']}/locales/$lang/$module.inc", "wt"))) {
  15.     $AppUI->setMsg( "Could not open locales file to save.", UI_MSG_ERROR );
  16.     $AppUI->redirect( "m=system" );
  17. }
  18.  
  19. $txt = "##\n## DO NOT MODIFY THIS FILE BY HAND!\n##\n";
  20.  
  21. if ($lang == 'en') {
  22. // editing the english file
  23.     foreach ($trans as $langs) {
  24.         if ( (@$langs['abbrev'] || $langs['english']) && empty($langs['del']) ) {
  25.             $langs['abbrev'] = addslashes( stripslashes( @$langs['abbrev'] ) );
  26.             $langs['english'] = addslashes( stripslashes( $langs['english'] ) );
  27.             if (!empty($langs['abbrev'])) {
  28.                 $txt .= "\"{$langs['abbrev']}\"=>";
  29.             }
  30.             $txt .= "\"{$langs['english']}\",\n";
  31.         }
  32.     }
  33. } else {
  34. // editing the translation
  35.     foreach ($trans as $langs) {
  36.         if ( empty($langs['del']) ) {
  37.             $langs['english'] = addslashes( stripslashes( $langs['english'] ) );
  38.             $langs['lang'] = addslashes( stripslashes( $langs['lang'] ) );
  39.             //fwrite( $fp, "\"{$langs['english']}\"=>\"{$langs['lang']}\",\n" );
  40.             $txt .= "\"{$langs['english']}\"=>\"{$langs['lang']}\",\n";
  41.         }
  42.     }
  43. }
  44. //echo "<pre>$txt</pre>";
  45. fwrite( $fp, $txt );
  46. fclose( $fp );
  47.  
  48. $AppUI->setMsg( "Locales file saved", UI_MSG_OK );
  49. $AppUI->redirect();
  50. ?>