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

  1. <?php /* SYSTEM $Id: translate.php,v 1.27 2003/07/04 01:45:10 eddieajau Exp $ */
  2.  
  3. // only user_type of Administrator (1) can access this page
  4. if (!$canEdit || $AppUI->user_type != 1) {
  5.     $AppUI->redirect( "m=public&a=access_denied" );
  6. }
  7.  
  8. $module = isset( $_REQUEST['module'] ) ? $_REQUEST['module'] : 'admin';
  9. $lang = isset( $_REQUEST['lang'] ) ? $_REQUEST['lang'] : 'en';
  10.  
  11. $AppUI->savePlace( "m=system&a=translate&module=$module&lang=$lang" );
  12.  
  13. // read the installed modules
  14. $modules = arrayMerge( array( 'common', 'styles' ), $AppUI->readDirs( 'modules' ));
  15.  
  16. // read the installed languages
  17. $locales = $AppUI->readDirs( 'locales' );
  18.  
  19. ob_start();
  20.     @readfile( "{$AppUI->cfg['root_dir']}/locales/en/$modules[$module].inc" );
  21.     eval( "\$english=array(".ob_get_contents()."\n'0');" );
  22. ob_end_clean();
  23.  
  24. $trans = array();
  25. foreach( $english as $k => $v ) {
  26.     if ($v != "0") {
  27.         $trans[ (is_int($k) ? $v : $k) ] = array(
  28.             'english' => $v
  29.         );
  30.     }
  31. }
  32.  
  33. //echo "<pre>";print_r($trans);echo "</pre>";die;
  34.  
  35. if ($lang != 'en') {
  36.     ob_start();
  37.         @readfile( "{$AppUI->cfg['root_dir']}/locales/$lang/$modules[$module].inc" );
  38.         eval( "\$locale=array(".ob_get_contents()."\n'0');" );
  39.     ob_end_clean();
  40.  
  41.     foreach( $locale as $k => $v ) {
  42.         if ($v != "0") {
  43.             $trans[$k]['lang'] = $v;
  44.         }
  45.     }
  46. }
  47. ksort($trans);
  48.  
  49. $titleBlock = new CTitleBlock( 'Translation Management', 'rdf2.png', $m, "$m.$a" );
  50. $titleBlock->addCell(
  51.     $AppUI->_( 'Module' ), '',
  52.     '<form action="?m=system&a=translate" method="post" name="modlang">', ''
  53. );
  54. $titleBlock->addCell(
  55.     arraySelect( $modules, 'module', 'size="1" class="text" onchange="document.modlang.submit();"', $module )
  56. );
  57. $titleBlock->addCell(
  58.     $AppUI->_( 'Language' )
  59. );
  60. $temp = $AppUI->setWarning( false );
  61. $titleBlock->addCell(
  62.     arraySelect( $locales, 'lang', 'size="1" class="text" onchange="document.modlang.submit();"', $lang, true ), '',
  63.     '', '</form>'
  64. );
  65. $AppUI->setWarning( $temp );
  66.  
  67. $titleBlock->addCrumb( "?m=system", "system admin" );
  68. $titleBlock->show();
  69. ?>
  70.  
  71. <table width="100%" border="0" cellpadding="1" cellspacing="1" class="tbl">
  72. <tr>
  73.     <th width="15%" nowrap><?php echo $AppUI->_( 'Abbreviation' );?></th>
  74.     <th width="40%" nowrap>English <?php echo $AppUI->_( 'String' );?></th>
  75.     <th width="40%" nowrap><?php echo $AppUI->_( $locales[$lang] ).' '.$AppUI->_( 'String' );?></th>
  76.     <th width="5%" nowrap><?php echo $AppUI->_( 'delete' );?></th>
  77. </tr>
  78. <form action="?m=system&a=translate_save" method="post" name="editlang">
  79. <input type="hidden" name="module" value="<?php echo $modules[$module];?>" />
  80. <input type="hidden" name="lang" value="<?php echo $lang;?>" />
  81. <?php
  82. $index = 0;
  83. if ($lang == 'en') {
  84.     echo "<tr>\n";
  85.     echo "<td><input type=\"text\" name=\"trans[$index][abbrev]\" value=\"\" size=\"20\" class=\"text\" /></td>\n";
  86.     echo "<td><input type=\"text\" name=\"trans[$index][english]\" value=\"\" size=\"40\" class=\"text\" /></td>\n";
  87.     echo "<td colspan=\"2\">New Entry</td>\n";
  88.     echo "</tr>\n";
  89. }
  90.  
  91. $index++;
  92. foreach ($trans as $k => $langs){
  93. ?>
  94. <tr>
  95.     <td><?php
  96.         if ($k != @$langs['english']) {
  97.             $k = dPformSafe( $k, true );
  98.             if ($lang == 'en') {
  99.                 echo "<input type=\"text\" name=\"trans[$index][abbrev]\" value=\"$k\" size=\"20\" class=\"text\" />";
  100.             } else {
  101.                 echo $k;
  102.             }
  103.         } else {
  104.             echo ' ';
  105.         }
  106.     ?></td>
  107.     <td><?php
  108.         $langs['english'] = htmlspecialchars( @$langs['english'], ENT_QUOTES );
  109.         if ($lang == 'en') {
  110.             if (strlen($langs['english']) < 40) {
  111.                 echo "<input type=\"text\" name=\"trans[$index][english]\" value=\"{$langs['english']}\" size=\"40\" class=\"text\" />";
  112.             } else {
  113.               $rows = round(strlen($langs['english']/35)) +1 ;
  114.               echo "<textarea name=\"trans[$index][english]\"  cols=\"40\" class=\"small\" rows=\"$rows\">".$langs['english']."</textarea>";
  115.             }
  116.         } else {
  117.             echo $langs['english'];
  118.             echo "<input type=\"hidden\" name=\"trans[$index][english]\" value=\""
  119.                 .($k ? $k : $langs['english'])
  120.                 ."\" size=\"20\" class=\"text\" />";
  121.         }
  122.     ?></td>
  123.     <td><?php
  124.         if ($lang != 'en') {
  125.             $langs['lang'] = dPformSafe( @$langs['lang'], true );
  126.             if (strlen($langs['lang']) < 40) {
  127.                 echo "<input type=\"text\" name=\"trans[$index][lang]\" value=\"{$langs['lang']}\" size=\"40\" class=\"text\" />";
  128.             } else {
  129.               $rows = round(strlen($langs['lang']/35)) +1 ;
  130.               echo "<textarea name=\"trans[$index][lang]\"  cols=\"40\" class=\"small\" rows=\"$rows\">".$langs['lang']."</textarea>";
  131.             }
  132.         }
  133.     ?></td>
  134.     <td align="center"><?php echo "<input type=\"checkbox\" name=\"trans[$index][del]\" />";?></td>
  135. </tr>
  136. <?php
  137.     $index++;
  138. }
  139. ?>
  140. <tr>
  141.     <td colspan="4" align="right">
  142.         <input type="submit" value="<?php echo $AppUI->_( 'submit' );?>" class="button" />
  143.     </td>
  144. </tr>
  145. </form>
  146. </table>
  147.