![]() |
|---|
| [ Index ] |
Source Code Reference for V1.00 |
[Summary view] [Print] [Text view]
1 <?php /* $Id: translate_save.php 153 2008-04-09 22:08:53Z pedroix $ $URL: https://web2project.svn.sourceforge.net/svnroot/web2project/trunk/modules/system/translate_save.php $ */ 2 /** 3 * Processes the entries in the translation form. 4 * @version $Revision: 153 $ 5 * @author Andrew Eddie <users.sourceforge.net> 6 */ 7 8 if (!defined('W2P_BASE_DIR')) { 9 die('You should not call this file directly.'); 10 } 11 12 // check permissions 13 $perms = &$AppUI->acl(); 14 if (!$perms->checkModule('system', 'edit')) { 15 $AppUI->redirect('m=public&a=access_denied'); 16 } 17 18 $module = w2PgetParam($_POST, 'module', 0); 19 $lang = w2PgetParam($_POST, 'lang', $AppUI->user_locale); 20 21 $trans = w2PgetParam($_POST, 'trans', 0); 22 //echo '<pre>';print_r( $trans );echo '</pre>';die; 23 24 // save to core locales if a translation exists there, otherwise save 25 // into the module's local locale area if it exists. If not then 26 // the core table is updated. 27 $core_filename = W2P_BASE_DIR . '/locales/' . $lang . '/' . $module . '.inc'; 28 if (file_exists($core_filename)) { 29 $filename = $core_filename; 30 } else { 31 $mod_locale = W2P_BASE_DIR . '/modules/' . $module . '/locales'; 32 if (is_dir($mod_locale)) 33 $filename = W2P_BASE_DIR . '/modules/' . $module . '/locales/' . $lang . '.inc'; 34 else 35 $filename = $core_filename; 36 } 37 38 $fp = fopen($filename, 'wt'); 39 40 if (!$fp) { 41 $AppUI->setMsg("Could not open locales file ($filename) to save.", UI_MSG_ERROR); 42 $AppUI->redirect('m=system'); 43 } 44 45 $txt = "##\n## DO NOT MODIFY THIS FILE BY HAND!\n##\n"; 46 47 if ($lang == 'en') { 48 // editing the english file 49 foreach ($trans as $langs) { 50 if (($langs['abbrev'] || $langs['english']) && empty($langs['del'])) { 51 $langs['abbrev'] = addslashes(stripslashes($langs['abbrev'])); 52 $langs['english'] = addslashes(stripslashes($langs['english'])); 53 if (!empty($langs['abbrev'])) { 54 $txt .= '\'' . $langs['abbrev'] . '\'=>'; 55 } 56 $txt .= '\'' . $langs['english'] . '\',' . "\n"; 57 } 58 } 59 } else { 60 // editing the translation 61 foreach ($trans as $langs) { 62 if (empty($langs['del'])) { 63 $langs['english'] = stripslashes($langs['english']); 64 $langs['lang'] = addslashes(stripslashes($langs['lang'])); 65 //fwrite( $fp, "\"{$langs['english']}\"=>\"{$langs['lang']}\",\n" ); 66 $txt .= '\'' . $langs['english'] . '\'=>\'' . $langs['lang'] . '\',' . "\n"; 67 } 68 } 69 } 70 //echo "<pre>$txt</pre>"; 71 fwrite($fp, $txt); 72 fclose($fp); 73 74 $AppUI->setMsg('Locales file saved', UI_MSG_OK); 75 $AppUI->redirect($AppUI->getPlace()); 76 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Thu Jan 8 03:00:03 2009 | Cross-referenced by PHPXref 0.7 |