Location: PHPKode > projects > ProNuke. Postnuke To Oracle > postnuke/html/modules/NS-Languages/admin.php
<?php
// $Id: admin.php,v 1.29 2001/12/08 15:54:59 phiber_xat Exp $
// ----------------------------------------------------------------------
// POST-NUKE Content Management System
// Copyright (C) 2001 by the Post-Nuke Development Team.
// http://www.postnuke.com/
// ----------------------------------------------------------------------
// Based on:
// PHP-NUKE Web Portal System - http://phpnuke.org/
// Thatware - http://thatware.org/
// ----------------------------------------------------------------------
// LICENSE
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License (GPL)
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// To read the license please visit http://www.gnu.org/copyleft/gpl.html
// ----------------------------------------------------------------------
// Original Author of file: PN boys and girls band
// Purpose of file: language file management
// ----------------------------------------------------------------------
// FTO - 02/03/20 : make all SQL request ADODB compatible

   function languages_option($module,$op,$language,$text,$img)
   {
      menu_add_option('admin.php?module='.$module.'&op='.$op.'&language='.$language,$text,$img);
   }

   function languages_menu($module,$language)
   {
      menu_title('admin.php?module='.$module.'&op=main&language='.$language,_LANG_CURENT.' : '.language_name($language));
      menu_graphic(false);
      menu_help('manual/languages.html',_ONLINEMANUAL);
      languages_option($module,'select',$language,_LANG_SELECT,'');
      languages_option($module,'constant',$language,_LANG_LOAD_CONSTANT,'');
      languages_option($module,'translation',$language,_LANG_LOAD_TRANSLATION,'');
      languages_option($module,'missing',$language,_LANG_ADD_MISSING,'');
      languages_option($module,'generate',$language,_LANG_GENERATE,'');
//    languages_option($module,'hardcode',$language,_LANG_HARDCODE,'');
   }

   function languages_file($file)
   {

      $part = explode('/',substr($file,2));
      if ($part[0]=='modules')
      {
         if (($part[2]=='data.php') or ($part[2].'/'.$part[3]=='admin/links') or $part[1].'/'.$part[2]=='NS-Admin/tools.php')
            return 'ADMIN';
         if ($part[1].'/'.$part[2]=='NS-User/tools.php')
            return 'USER';
         if (substr($part[1],0,3)=='NS-')
            $part[1] = substr($part[1],3);
         if (($part[2]=='admin') or ($part[2]=='admin.php'))
//          return 'MODULE-ADMIN-'.$part[1];
            return 'MODULE-'.$part[1];
         else
            return 'MODULE-'.$part[1];
      }
      elseif (($part[0]=='includes') and ($part[1]=='blocks'))
         return 'BLOCK-'.ereg_replace('\.php$','',$part[2]);
      elseif ($part[0]=='admin.php')
      {
         return 'ADMIN';
      }
      elseif ($part[0]=='user.php')
      {
         return 'USER';
      }
      elseif ($part[0]=='error.php')
      {
         return 'ERROR';
      }
      else
      {
         return 'GLOBAL';
      }
   }

   function languages_choice_file($file1,$file2)
   {
      if ($file1=='GLOBAL' or $file2=='GLOBAL')
         return 'GLOBAL';
      elseif ($file1==$file2)
         return $file1;
      elseif (ereg_replace('ADMIN-','',$file1) == $file2)
         return $file2;
      elseif (ereg_replace('ADMIN-','',$file2) == $file1)
         return $file1;
      elseif (ereg('ADMIN',$file1) and ereg('ADMIN',$file2))
         return 'ADMIN';
      else
         return 'GLOBAL';
   }

   function languages_extract_constant($file,$line)
   {



// FTO USE AdoDB
//      global $pntable ;
      global $pntable, $dbconn, $pnconfig, $oracledb;

      //FTO use column name from PNTABLES
      $colCo = $pntable['languages_constant_column'];
      $colTl = $pntable['languages_translation_column'];
      $colFi = $pntable['languages_file_column'];

      static $file_list = array();
      $count = preg_match_all('/\b(_[0-9A-Z]+)+\b/',$line,$matches);
      $file = languages_file($file);
//      echo "$file<br>";
      for ($i=0;$i<$count;$i++)
      {
         $constant = FixQuotes($matches[0][$i]);

         // This is not really portable !!
         // Use AdoDB instead
         //         mysql_query("insert into ".$pntable['languages_constant']." (constant,file) values('$constant','$file')");

         $PkError = false;
         $result = $dbconn->Execute("insert into ".$pntable['languages_constant']." ($colCo[constant],$colCo[file]) values('$constant','$file')");
    


         //FTO 0001 error  means primary constraint violated for Oracle (doublon) as 1062 for MySQL
         if ( $oracledb && $dbconn->ErrorNo()== 1 )
             $PkError=true;
         // Assume MySQL
         elseif ($dbconn->ErrorNo()== 1062)
             $PkError=true;

         if($PkError)
//        if (mysql_errno()==1062)
         {
//FTO            list($old_file) = db_select_one_row("select file from ".$pntable['languages_constant']." where constant='$constant'");

           $result = $dbconn->Execute("select $colCo[file] from ".$pntable['languages_constant']." where $colCo[constant]='$constant'");

           if (!$result) {
               PN_DBMsgError($dbconn, __FILE__, __LINE__, "An error ocurred");
               die();
            }
           list($old_file) = $result->fields;
           $result->MoveNext();
            
           $file2 = languages_choice_file($file,$old_file);
//            echo "$file , $old_file => $file2<br>";
           if ($file2!=$old_file)
              {
//               mysql_query("update ".$pntable['languages_constant']." set file='$file2' where constant='$constant'");
              $result = $dbconn->Execute("update ".$pntable['languages_constant']." set $colCo[file]='$file2' where $colCo[constant]='$constant'");
              if (!$result) {
                 PN_DBMsgError($dbconn, __FILE__, __LINE__, "An error ocurred");
                 die();
                }
              }

         }
//FTO         elseif (mysql_errno()!=0)
         elseif($dbconn->ErrorNo()!= 0)
//FTO           echo '('.mysql_errno().') '.mysql_error().'<br>';
               PN_DBMsgError($dbconn, __FILE__, __LINE__, "An error ocurred");
         else
            $file2 = $file;
         if (!isset($file_list[$file2]))
         {
            $file_list[$file2] = '';
            $part = explode('-',$file2);
            if ($part[0]=='GLOBAL')
               $target = 'language/$language/global.php';
            elseif (($part[0]=='MODULE') and ($part[1]=='ADMIN'))
               $target = 'modules/NS-'.$part[2].'/lang/$language/admin.php';
            elseif (($part[0]=='MODULE'))
               $target = 'modules/NS-'.$part[1].'/lang/$language/global.php';
            elseif (($part[0]=='BLOCK'))
               $target = 'includes/language/blocks/$language/'.$part[1].'.php';
            elseif (($part[0]=='ADMIN'))
               $target = 'language/$language/admin.php';
            elseif (($part[0]=='USER'))
               $target = 'language/$language/user.php';
            elseif (($part[0]=='ERROR'))
               $target = 'language/$language/error.php';
            else
               die('target unknown : '.$file2.'/'.$file);

         $result = $dbconn->Execute("insert into ".$pntable['languages_file']." ($colFi[target],$colFi[source]) values('$target','$file2')");
//FTO            mysql_query("insert into ".$pntable['languages_file']." (target,source) values('$target','$file2')");
//FTO            if ((mysql_errno()!=0) and (mysql_errno()!=1062))

         //FTO 0001 error  means primary constraint violated for Oracle (doublon) as 1062 for MySQL
         if ( $oracledb,$pnconfig['dbtype']) && $dbconn->ErrorNo()== 1 )
             $PkError=true;
         // Assume MySQL
         elseif ($dbconn->ErrorNo()== 1062)
             $PkError=true;

         if (!$result and !$PkError) PN_DBMsgError($dbconn, __FILE__, __LINE__, "An error ocurred");
               
               
         }
      }

//FTO      mysql_query("delete from ".$pntable['languages_constant']." where constant like '_ADODB%' or constant = '_TW' or constant ='_TB' or constant='_TP' or constant ='_FP' or constant = '_FB' or constant = '_FW' or constant = '_PEAR' or constant = '_SYLLABELS' or constant = '_MAKEPASS_BOX' or constant = '_MAKEPASS_LEN'");
//FTO Changed cascaded OR by IN clause

        $result = $dbconn->Execute("delete from ".$pntable['languages_constant']." where $colCo[constant] like '_ADODB%' or $colCo[constant] IN ('_TW','_TB','_TP','_FP','_FB','_FW','_PEAR','_SYLLABELS','_MAKEPASS_BOX','_MAKEPASS_LEN')");
        if (!$result) PN_DBMsgError($dbconn, __FILE__, __LINE__, "An error ocurred");
   }

   function languages_dir_walk($dir)
   {
      if (!$handle=@opendir($dir)) return;
      while ($file=readdir($handle))
      {
         if ($file=='.');
         elseif ($file=='..');
         elseif (ereg('\.php$',$file))
            languages_extract_constant($dir.'/'.$file,implode('',file($dir.'/'.$file)));
         elseif ($file=='lang');
         elseif ($file=='language');
         elseif (!ereg('\.',$file))
            languages_dir_walk($dir.'/'.$file);
      }
      closedir($handle);
   }

   function languages_admin_main($var)
   {
      global $dbconn,$pntable,$pnconfig,$oracledb;
      if (!isset($var['language'])) $var['language'] = 'eng';
      languages_menu($var['module'],$var['language']);
      $language = $var['language'];
      include 'header.php';
      menu_draw();

      $result = $dbconn->Execute("select count(*) from ".$pntable['languages_constant']);
      //FTO Check DB Errors
      if (!$result) PN_DBMsgError($dbconn, __FILE__, __LINE__, "An error ocurred");

      list($num) = $result->fields;
      opentable();
      echo _LANG_NUM_CONSTANT.' : '.$num."\n";
      echo '<br>'."\n";
      closetable();
      echo '<br>'."\n";
      opentable();

      //FTO left join syntax is not consistent.  We check for oracle and assume
      //FTO MySQL if not.  Other databases added here.
      //FTO Test for every ORACLE compatible drivers
      //FTO use column name from PNTABLES
      $colCo = $pntable['languages_constant_column'];
      $colTl = $pntable['languages_translation_column'];
      $colFi = $pntable['languages_file_column'];
      
      if ( $oracledb )
        {
          $query= "select  $colTl[language],count($colTl[translation]),sum($colTl[level])"
                  ." from  $pntable[languages_constant] , $pntable[languages_translation]"
                  ." where $colCo[constant] = $colTl[constant] (+) AND $colTl[language] is NOT NULL group by $colTl[language]";
        }
      else
        {
           $query= "select $colTl[language],count($colTl[translation]),sum($colTl[level])"
              ." from ".$pntable['languages_constant']." left join ".$pntable['languages_translation']
              ." on $colCo[constant] = $colTl[constant] where $colTl[language] is NOT NULL group by $colTl[language]";
        }

      $result = $dbconn->Execute($query);
      if (!$result)
         {
              PN_DBMsgError($dbconn, __FILE__, __LINE__, "An error ocurred");
              die();
         }

      if ($num==0)
         $link = '[ <a href="admin.php?module='.$var['module'].'&op=constant&language='.$language.'">'._LANG_LOAD_CONSTANT.'</a> ]';
      else
         $link = '[ <a href="admin.php?module='.$var['module'].'&op=constant&language='.$language.'">'._LANG_RELOAD_CONSTANT.'</a> ]';
      echo  _LANG_NUM_TRANSLATION."\n"
           .'<br><br>'."\n"
           .'<table>'."\n"
           .'<tr><td>'._LANGUAGE.'</td><td>'._LANG_LANGUAGES_NUMBER.'</td><td>'._LANG_MISSING_NUMBER.'</td><td>'._LANG_DEFAULT_TRANSLATION.'</td><td>'._NEXT_OP_TODO.'</td></tr>'."\n"
           .'<tr><td>'._LANG_OBJECTIVE.'</td><td>'.$num.'</td><td>0</td><td>0</td><td>'.$link.'</td></tr>'."\n";

      while (!$result->EOF)
      {
         list($language,$total,$total3) = $result->fields;
         $total2 = $num - $total;
         $total3 = $total - $total3;
         if ($num==0)
            $link = '';
         elseif ($total2==0)
            $link = '[ <a href="admin.php?module='.$var['module'].'&op=generate&language='.$language.'">'._LANG_GENERATE.'</a> ]';
         else
            $link = '[ <a href="admin.php?module='.$var['module'].'&op=missing&language='.$language.'">'._LANGUAGES_MISSING.'</a> ]';
         echo '<tr><td>'.language_name($language).'</td><td>'.$total.'</td><td>'.$total2.'</td><td>'.$total3.'</td><td>'.$link.'</td</tr>'."\n";
         $result->MoveNext();
      }
      echo '</table>'."\n";
      closetable();
      echo '<br>'."\n";
      opentable();

      //FTO left join syntax is not consistent.  We check for oracle and assume
      //FTO MySQL if not.  Other databases added here.
      //FTO Test for every ORACLE compatible drivers
      //FTO use column name from PNTABLES

/*
("select A.source,A.target,count(B.constant),count(C.translation),sum(level)
from ".$pntable['languages_file']." A, ".$pntable['languages_constant']." B
 left join ".$pntable['languages_translation']." C
on B.constant=C.constant and language='".$var['language']."' where A.source=B.file group by B.file");
*/

      if ( $oracledb )
        {
          $query= "select $colFi[source], $colFi[target], count($colCo[constant]), count($colTl[translation]),sum($colTl[level])"
                  ." from $pntable[languages_file], $pntable[languages_constant] , $pntable[languages_translation] "
                  ." where $colCo[constant] = $colTl[constant]  (+) AND ($colTl[language] = '$var[language]' OR $colTl[language] IS NULL) "
                  ." AND $colFi[source] = $colCo[file] group by $colFi[source],$colFi[target]";
        }
      else
        {
          $query= "select $colFi[source], $colFi[target], count($colCo[constant]), count($colTl[translation]),sum($colTl[level])"
                  ." from $pntable[languages_file], $pntable[languages_constant] LEFT JOIN $pntable[languages_translation] "
                  ." on $colCo[constant] = $colTl[constant] AND $colTl[language] = '$var[language]'"
                  ." WHERE $colFi[source] = $colCo[file] group by $colCo[file]";

        }


      $result = $dbconn->Execute($query);
      if (!$result)
         {
              PN_DBMsgError($dbconn, __FILE__, __LINE__, "An error ocurred");
              die();
         }



      echo '<table>'."\n";
      echo  _LANG_FILE_TARGET."\n"
           .'<br><br>'."\n"
           .'<table>'."\n"
           .'<tr><td>'._TARGET.'</td><td>'._LANG_FILE.'</td><td>'._LANG_LANGUAGES_NUMBER.'</td><td>'._LANG_MISSING_NUMBER.'</td><td>'._LANG_DEFAULT_TRANSLATION.'</td></tr>'."\n";
      while (!$result->EOF)
      {
         list($file,$target,$total,$total2,$total3) = $result->fields;
         $total2 = $total - $total2;
         $total3 = $total - $total3;
         echo '<tr><td>'.$file.'</td><td>'.$target.'</td><td>'.$total.'</td><td>'.$total2.'</td><td>'.$total3.'</td></tr>'."\n";
         $result->MoveNext();
      }
      echo '</table>'."\n";
      closetable();
      echo '<br>'."\n";
      include 'footer.php';
   }

   function languages_admin_select($var)
   {
      if (!isset($var['language'])) $var['language'] = 'eng';
      languages_menu($var['module'],$var['language']);
      include 'header.php';
      menu_draw();
      opentable();
      echo  '<form action="admin.php" methode="get">'."\n"
           ._LANGUAGE.' : <select name="language">'."\n";
      $handle = opendir('language');
      while ($file=readdir($handle))
      {
         if (!ereg('\.|html',$file))
         {
            $lang = substr($file,0,strlen($file));
            echo '<option value="'.$lang.'"';
            if ($lang==$var['language']) echo ' selected';
            echo '>'.language_name($lang).'</option>'."\n";
         }
      }
      closedir($handle);
      echo '</select>'."\n"
            .'<input type="hidden" name="module" value="'.$var['module'].'">'."\n"
            .'<input type="hidden" name="op" value="main">'."\n"
            .'<input type="submit" value="'._LANG_SELECT.'">'."\n"
            .'</form>'."\n";
      closetable();
      include 'footer.php';
   }

   function languages_admin_constant($var)
   {
      global $pntable;

      csrfcheck();

      db_delete("delete from ".$pntable['languages_constant']);
      db_delete("delete from ".$pntable['languages_file']);
      languages_dir_walk('.');
      if (!isset($var['language'])) $var['language'] = 'eng';
      languages_menu($var['module'],$var['language']);
      include 'header.php';
      menu_draw();
      opentable();
      echo  'All constants loaded'."\n";
      closetable();
      include 'footer.php';
   }
   function languages_extract_translation($file,$language,$line)
   {
      global $dbconn,$pntable,$pnconfig,$oracledb;

      csrfcheck();

      //FTO use column name from PNTABLES
      $colTl = $pntable['languages_translation_column'];

      $i = strpos($line,'define(');
      if ($i===false) return;
      $line = substr($line,$i+7);
      $i = strrpos($line,')');
      $line = substr($line,0,$i);
      $i = strpos($line,',');
      $constant = trim(substr($line,0,$i));
      $text = trim(substr($line,$i+1));
      $constant = substr($constant,1,strlen($constant)-2);
      $text = substr($text,1,strlen($text)-2);
//      echo "/$constant/$text/<br>";
      $text = fixquotes($text);
      if (($constant==$text) or (substr($text,0,2)=='&&'))
       {
          $text = $constant;



          $sql = "insert into
                 ".$pntable['languages_translation']."
                  ($colTl[language],$colTl[constant],$colTl[translation],$colTl[level])
                   values('$language','$constant','$text',0)";
       }
       else
       {
          $sql = "insert into
                 ".$pntable['languages_translation']."
                  ($colTl[language],$colTl[constant],$colTl[translation],$colTl[level])
                  values('$language','$constant','$text',1)";
          $result = $dbconn->Execute($sql);

         //FTO 0001 error  means primary constraint violated for Oracle (doublon) as 1062 for MySQL
         $PkError = false;
         if ( $oracledb  && $dbconn->ErrorNo()== 1 )
             $PkError=true;
         // Assume MySQL
         elseif ($dbconn->ErrorNo()== 1062)
             $PkError=true;

         if (!$result and !$PkError) PN_DBMsgError($dbconn, __FILE__, __LINE__, "An error ocurred");

//          if (mysql_errno()!=0 and mysql_errno()!=1062)
//            {
//              echo '('.mysql_errno().')'.mysql_error().'<br>'.$sql.'<br>///'.$text."///<br>\n";
//            }
       }
   }

   function languages_get_file($file,$language)
   {
      echo $file.'<br>'."\n";
      $content = file($file);
      foreach ($content as $num=>$line)
         languages_extract_translation($file,$language,$line);
   }

   function languages_get_dir($dir,$language)
   {
      if (!$handle=@opendir($dir)) return;
      while ($file=readdir($handle))
      {
         if ($file=='.');
         elseif ($file=='..');
         elseif (ereg('\.php$',$file))
            languages_get_file($dir.'/'.$file,$language);
      }
      closedir($handle);
   }

   function languages_languages_walk($dir,$language)
   {
      if (!$handle=@opendir($dir)) return;
      while ($file=readdir($handle))
      {
         if ($file=='.');
         elseif ($file=='..');
         elseif ($file==$language.'.php')
            languages_get_file($dir.'/'.$file,$language);
         elseif ($file==$language)
            languages_get_dir($dir.'/'.$file,$language);
         elseif (!ereg('\.',$file))
            languages_languages_walk($dir.'/'.$file,$language);
      }
      closedir($handle);
   }

   function languages_admin_translation($var)
   {
      global $dbconn,$pntable;

      csrfcheck();

      //FTO use column name from PNTABLES
      $colTl = $pntable['languages_translation_column'];

      if (!isset($var['language'])) $var['language'] = 'eng';
      $sql ="delete from ".$pntable['languages_translation']." where $colTl[language]='".$var['language']."'";
      $result=$dbconn->Execute($sql);
//      if ($result===false) die(mysql_error().'<br>'.$sql);

      if ($result===false) PN_DBMsgError($dbconn, __FILE__, __LINE__, "An error ocurred");
      
      
      
      if (file_exists($file='language/'.$var['language'].'/personnal.php'))
         languages_get_file($file,$var['language']);
      languages_menu($var['module'],$var['language']);
      include 'header.php';
      menu_draw();
      opentable();
      echo  '<b>Files list</b><br>'."\n";
      if (file_exists($file='language/'.$var['language'].'/personnal.php'))
         languages_get_file($file,$var['language']);
      if (file_exists($file='language/'.$var['language'].'/missing.php'))
         languages_get_file($file,$var['language']);
      languages_languages_walk('includes/language',$var['language']);
      languages_languages_walk('modules',$var['language']);
      if (file_exists($file='language/'.$var['language'].'/global.php'))
         languages_get_file($file,$var['language']);
      if (file_exists($file='language/'.$var['language'].'/admin.php'))
         languages_get_file($file,$var['language']);
      if (file_exists($file='language/'.$var['language'].'/user.php'))
         languages_get_file($file,$var['language']);
      if (file_exists($file='language/'.$var['language'].'/error.php'))
         languages_get_file($file,$var['language']);
      if (file_exists($file='language/'.$var['language'].'/total.php'))
         languages_get_file($file,$var['language']);
      if (file_exists($file='language/'.$var['language'].'/default.php'))
         languages_get_file($file,$var['language']);
      echo  '<br><br><b>All translations loaded for '.$var['language'].'</b>'."\n";
      closetable();
      include 'footer.php';
   }

   function languages_admin_missing($var)
   {
      global $dbconn,$pntable,$pnconfig,$oracledb;

      csrfcheck();

      if (!isset($var['language'])) $var['language'] = 'eng';
      
      //FTO left join syntax is not consistent.  We check for oracle and assume
      //FTO MySQL if not.  Other databases added here.
      //FTO Test for every ORACLE compatible drivers
      //FTO use column name from PNTABLES
      $colCo = $pntable['languages_constant_column'];
      $colTl = $pntable['languages_translation_column'];
      $colFi = $pntable['languages_file_column'];

      //$sql = "select A.constant from ".$pntable['languages_constant']." A left join ".$pntable['languages_translation']." B
      //on A.constant=B.constant and B.language='".$var['language']."' where B.constant IS NULL";

      if ( $oracledb )
        {
          $query= "select  $colCo[constant]"
                  ." from  $pntable[languages_constant] , $pntable[languages_translation]"
                  ." where $colCo[constant] = $colTl[constant] (+) AND ($colTl[language] = '$var[language]' OR $colTl[language] IS NULL) "
                  ." AND $colTl[constant] IS NULL";

        }
      else
        {

         $query = "select $colCo[constant] from $pntable[languages_constant] left join $pntable[languages_translation]"
                  ." on $colCo[constant]= $colTl[constant] and $colTl[language]='".$var['language']."' where $colTl[constant] IS NULL";

        }

      $result = $dbconn->Execute($query);

//      if (mysql_errno()!=0)
//         die(mysql_error().'<br>'.$sql);

      if (!$result)
         {
              PN_DBMsgError($dbconn, __FILE__, __LINE__, "An error ocurred");
              die();
         }



      languages_menu($var['module'],$var['language']);
      include 'header.php';
      menu_draw();
      opentable();
      while (!$result->EOF)
      {
         list($constant) = $result->fields;
         $translation = '';
         if ($var['language']!='eng')
            {
//             list($translation) = mysql_fetch_row(mysql_query("select translation from ".$pntable['languages_translation']." where constant = '$constant'"));
             $result2=$dbconn->Execute("select transalation from $pntable[languages_translation] where $colTl[constant] = '$constant'");
             if (!$result2)
                {
                PN_DBMsgError($dbconn, __FILE__, __LINE__, "An error ocurred");
                die();
                }
             list($translation) = $result2->fields;
            }

         if ($translation=='') $translation = $constant;
         $dbconn->Execute("insert into ".$pntable['languages_translation']." ($colTl[language],$colTl[constant],$colTl[translation],$colTl[level]) values('".$var['language']."','$constant','".fixquotes($translation)."',0)");
         echo $var['language'].' : '.$constant.' => '.fixquotes($translation)."<br>\n";
         $result->MoveNext();
      }
      closetable();
      include 'footer.php';
   }
//==================================================================================================================================
// Language hardcode traitment
//==================================================================================================================================
   function languages_extract_constant_to_hardcode($file,$line)
   {
      global $dbconn,$pntable,$pnconfig,$language;
//FTO      global $pntable,$language;

      $count = preg_match_all('/\b(_[0-9A-Z]+)+\b/',$line,$matches);

      //FTO use column name from PNTABLES

      $colTl = $pntable['languages_translation_column'];

      for ($i=0;$i<$count;$i++)
      {
         $result = $dbconn->Execute('select $colTl[translation] from '.$pntable['languages_translation']." where $colTl[constant]='".$matches[0][$i]."'");
//         if (mysql_errno()!=0)
//           echo '('.mysql_errno().') '.mysql_error().'<br>';
         if (!$result)
            {
              PN_DBMsgError($dbconn, __FILE__, __LINE__, "An error ocurred");
              die();
            }
         if ( !list($translation)= $result->fields ) $translation = $matches[0][$i];
//         if(!list($translation)=mysql_fetch_row($result)) $translation = $matches[0][$i];
         $translation = ereg_replace('"','\"',$translation);
         $line = preg_replace('/\b'.$matches[0][$i].'\b/','"'.$translation.'"',$line);
         echo "\$line = ereg_replace('/\b'".$matches[0][$i]."'\b/','\"'".$translation."'\"',\$line);<br>";
      }
      $handle = fopen($file,'w');
      if (!$handle) die('Unable  to open '.$file.'<br>'.ereg_replace('<','&lt;',$line));
      fwrite($handle,$line);
   }

   function languages_dir_walk_to_hardcode($dir)
   {
      if (!$handle=@opendir($dir)) return;
      while ($file=readdir($handle))
      {
         if ($file=='.');
         elseif ($file=='..');
         elseif (ereg('\.php$',$file))
            languages_extract_constant_to_hardcode($dir.'/'.$file,implode('',file($dir.'/'.$file)));
         elseif ($file=='lang');
         elseif ($file=='language');
         elseif (!ereg('\.',$file))
            languages_dir_walk_to_hardcode($dir.'/'.$file);
      }
      closedir($handle);
   }

   function languages_admin_hardcode($var)
   {
      global $dbconn,$pntable;
      if (!isset($var['language'])) $var['language'] = 'eng';
      $language = $var['language'];
      languages_menu($var['module'],$var['language']);
      include 'header.php';
      menu_draw();
      opentable();
      languages_dir_walk_to_hardcode('.');
      echo  _LANGUAGE_ALL_CONSTANT_HARDCODE.'<br>'."\n";
      closetable();
      include 'footer.php';
   }

   function languages_admin_generate($var)
   {
      global $dbconn,$pntable,$pnconfig;

      if (!isset($var['language'])) $var['language'] = 'eng';
      $language = $var['language'];
      languages_menu($var['module'],$var['language']);
      include 'header.php';
      menu_draw();
      opentable();
      $content = "<?php\n"
                ."// Generated: \$d\$ by \$id\$\n"
                ."// ----------------------------------------------------------------------\n"
                ."// POST-NUKE Content Management System\n"
                ."// Copyright (C) 2001 by the Post-Nuke Development Team.\n"
                ."// http://www.postnuke.com/\n"
                ."// ----------------------------------------------------------------------\n"
                ."// Based on:\n"
                ."// PHP-NUKE Web Portal System - http://phpnuke.org/\n"
                ."// Thatware - http://thatware.org/\n"
                ."// ----------------------------------------------------------------------\n"
                ."// LICENSE\n"
                ."//\n"
                ."// This program is free software; you can redistribute it and/or\n"
                ."// modify it under the terms of the GNU General Public License (GPL)\n"
                ."// as published by the Free Software Foundation; either version 2\n"
                ."// of the License, or (at your option) any later version.\n"
                ."//\n"
                ."// This program is distributed in the hope that it will be useful,\n"
                ."// but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
                ."// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n"
                ."// GNU General Public License for more details.\n"
                ."//\n"
                ."// To read the license please visit http://www.gnu.org/copyleft/gpl.html\n"
                ."// ----------------------------------------------------------------------\n"
                ."// Original Author of file: Everyone\n"
                ."// Purpose of file: Translation files\n"
                ."// Translation team: Read credits in /docs/CREDITS.txt\n"
                ."// ----------------------------------------------------------------------\n";

      //FTO use column name from PNTABLES
      $colCo = $pntable['languages_constant_column'];
      $colTl = $pntable['languages_translation_column'];
      $colFi = $pntable['languages_file_column'];

      $current_file = '';
      $result = $dbconn->Execute("select $colFi[target],$colCo[constant],$colTl[translation],$colTl[level] from $pntable[languages_file] , $pntable[languages_constant]  , $pntable[languages_translation] where $colFi[source] = $colCo[file] and $colCo[constant] = $colTl[constant] and $colTl[language]='".$language."' order by $colFi[target],$colTl[level],$colCo[constant]");
      if (!$result)
            {
              PN_DBMsgError($dbconn, __FILE__, __LINE__, "An error ocurred");
              die();
            }
//      if (mysql_errno()!=0)
//         die(mysql_error());

      $handle_total = fopen('language/'.$language.'/total.php','w');
      fwrite($handle_total,$content);
      $handle_missing = fopen('language/'.$language.'/missing.php','w');
      fwrite($handle_missing,$content);
      while (!$result->EOF)
      {
         list($file,$constant,$translation,$level) = $result->fields;
         if ($current_file!=$file)
         {
//          echo("$current_file!=$file<br>");
            if ($current_file!='')
            {
               fwrite($handle,">"."?");
               fclose($handle);                  ;
            }
            eval("\$filename = \"temp_lang/$file\";");
            $part = explode('/',$filename);
            if ($part[1]=='modules')
               if (!file_exists('modules/'.$part[2]))
                  $part[2] = substr($part[2],3);
            $filename = '';
            for ($i=0;$i<count($part)-1;$i++)
            {
               if(!file_exists($filename.=$part[$i].'/'))
               {
                  mkdir($filename,0777);
                  echo 'create : '.$filename.'<br>';
               }
            }
            $filename .= $part[count($part)-1];
            echo 'create file : '.$filename.'<br>';
            $handle = fopen($filename,'w');
            if (!$handle) die('Unable to open '.$filename.'<br>');
            $current_file = $file;
            fwrite($handle,$content);
         }
         $translation = ereg_replace('"','\\"',$translation);
         if ($language=='fra')
            $html = array('é'=>'&eacute;','è'=>'&eagrave;','à'=>'&agrave;','ê'=>'&ecirc;','û'=>'&circ;','ô'=>'$ocirc;');
         else
            $html = array();
         foreach($html as $k=>$v) $translation = ereg_replace($k,$v,$translation);
         if ($level==0)
         {
            fwrite($handle,"define('$constant',\"&&$constant (from $filename)\");\n");
            fwrite($handle_missing,"define('$constant',\"$constant\"); //$translation\n");
         }
         else
         {
            fwrite($handle,"define('$constant',\"$translation\");\n");
            fwrite($handle_total,"define('$constant',\"$translation\");\n");
         }
//         fwrite($handle,"define('$constant','$translation');\n");
         $result->MoveNext();
      }
      fwrite($handle,"?>");
      fclose($handle);
      fwrite($handle_total,"?>");
      fclose($handle_total);
      fwrite($handle_missing,"?>");
      fclose($handle_missing);
      closetable();
      include 'footer.php';
   }
?>
Return current item: ProNuke. Postnuke To Oracle