phpgroupware-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpgroupware-cvs] CVS: etemplate/inc class.solangfile.inc.php,1.1,1.2


From: Ralf Becker <address@hidden>
Subject: [Phpgroupware-cvs] CVS: etemplate/inc class.solangfile.inc.php,1.1,1.2
Date: Sun, 27 Apr 2003 04:20:01 -0400

Update of /cvsroot/phpgroupware/etemplate/inc
In directory subversions:/tmp/cvs-serv17765

Modified Files:
        class.solangfile.inc.php 
Log Message:
new version of solangfile for the .16 developer_tools

Index: class.solangfile.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/etemplate/inc/class.solangfile.inc.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** class.solangfile.inc.php    28 Oct 2002 01:17:32 -0000      1.1
--- class.solangfile.inc.php    27 Apr 2003 08:19:59 -0000      1.2
***************
*** 23,26 ****
--- 23,35 ----
                var $tgt_file;
                var $loaded_apps = array(); // Loaded app langs
+               
+               var $functions = array(         // functions containing phrases 
to translate and param#
+                       'lang' => array(1),
+                       'create_input_box' => array(1,3),
+                       'create_check_box' => array(1,3),
+                       'create_select_box' => array(1,4),
+                       'create_text_area' => array(1,5),
+                       'create_password_box' => array(1,3)
+               );
  
                var $public_functions = array(
***************
*** 33,44 ****
                }
  
-               //Known Issue, if a phrase contains a ' or a " the parse will 
be thrown off. unless ' are nested inside " or vice versa
                function parse_php_app($fd,$plist)
                {
                        define('SEP',filesystem_separator());
                        $d=dir($fd);
                        while ($fn=$d->read())
                        {
!                               if (is_dir($fd.$fn.SEP))
                                {
                                        if 
(($fn!='.')&&($fn!='..')&&($fn!='CVS'))
--- 42,54 ----
                }
  
                function parse_php_app($fd,$plist)
                {
+                       $reg_expr = 
'('.implode('|',array_keys($this->functions)).")[ \t]*\([ \t]*(.*)$";
                        define('SEP',filesystem_separator());
+                       list($app) = explode(SEP,$fd);
                        $d=dir($fd);
                        while ($fn=$d->read())
                        {
!                               if (@is_dir($fd.$fn.SEP))
                                {
                                        if 
(($fn!='.')&&($fn!='..')&&($fn!='CVS'))
***************
*** 49,79 ****
                                elseif ((strpos($fn,'.php')>1) && 
(is_readable($fd.$fn)))
                                {
!                                       $fp=fopen($fd.SEP.$fn,'r');
!                                       $fds=substr($fd,strpos($fd,SEP));
!                                       while (!feof($fp))
                                        {
!                                               $str=fgets($fp,8192);
!                                               while 
(strlen($str=$this->strstr_multiple($str,'lang','(','')))
                                                {
!                                                       if ($str[0]=="\"" || 
$str[0]=="'")
                                                        {
!                                                               if ($str[0] == 
"'")
                                                                {
!                                                                       
$str=substr($str,1);
!                                                                       
$s2=substr($str,0,strpos($str,"'"));
                                                                }
!                                                               else
                                                                {
!                                                                       
$str=substr($str,1);
!                                                                       
$s2=substr($str,0,strpos($str,"\""));                                           
                      
                                                                }
!                                                               if ($s2!='')
                                                                {
!                                                                       
$plist[$s2]=$fds;
                                                                }
                                                        }
                                                }
                                        }
-                                       fclose($fp);
                                }
                        }
--- 59,114 ----
                                elseif ((strpos($fn,'.php')>1) && 
(is_readable($fd.$fn)))
                                {
!                                       $lines = file($fd.SEP.$fn);
! 
!                                       foreach($lines as $n => $line)
                                        {
!                                               //echo "line='$line', 
lines[1+$n]='".$lines[1+$n]."'<br>\n";
!                                               while 
(eregi($reg_expr,$line,$parts))
                                                {
!                                                       //echo 
"***func='$parts[1]', rest='$parts[2]'<br>\n";
!                                                       $args = 
$this->functions[$parts[1]];
!                                                       $rest = $parts[2];
!                                                       for($i = 1; $i <= 
$args[0]; ++$i)
                                                        {
!                                                               $next = 1;
!                                                               if (!$rest || 
strpos($rest,$del,1) === False)
                                                                {
!                                                                       $rest 
.= trim($lines[++$n]);
                                                                }
!                                                               $del = $rest[0];
!                                                               if ($del == '"' 
|| $del == "'")
                                                                {
!                                                                       //echo 
"rest='$rest'<br>\n";
!                                                                       while 
(($next = strpos($rest,$del,$next)) !== False && $rest[$next-1] == '\\')
!                                                                       {
!                                                                               
$rest = substr($rest,0,$next-1).substr($rest,$next);
!                                                                       }
!                                                                       if 
($next === False)
!                                                                       {
!                                                                               
break;
!                                                                       }
!                                                                       $phrase 
= str_replace('\\\\','\\',substr($rest,1,$next-1));
!                                                                       //echo 
"next2=$next, phrase='$phrase'<br>\n";
!                                                                       if 
($args[0] == $i)
!                                                                       {
!                                                                               
//if (!isset($plist[$phrase])) echo ">>>$phrase<<<<br>\n";
!                                                                               
$plist[$phrase] = $app;
!                                                                               
array_shift($args);
!                                                                               
if (!count($args))
!                                                                               
{
!                                                                               
        break;  // no more args needed
!                                                                               
}
!                                                                       }
!                                                                       $rest = 
substr($rest,$next+1);
                                                                }
!                                                               if(!ereg("[ 
\t\n]*,[ \t\n]*(.*)$",$rest,$parts)) 
                                                                {
!                                                                       break;  
// nothing found
                                                                }
+                                                               $rest = 
$parts[1];
                                                        }
+                                                       $line = $rest;
                                                }
                                        }
                                }
                        }
***************
*** 82,122 ****
                }
  
-               /*!
-                @function strstr_multiple
-                @abstract search for a substring consisted of parts separated 
by whitespaces
-                @param $str original string
-                @param $sub1 first part of substring
-                @param $sub2 second part of substring
-                @result returns portion of $str from the end of substring to 
the end of $str, or empty string if substring was not found
-               */
-               function strstr_multiple($str,$sub1,$sub2)
-               {
-                       if (isset($sub1))
-                       {
-                               if(is_integer($pos=strpos($str,$sub1)))
-                               {
-                                       $str=substr($str,$pos+strlen($sub1));
-                                       if (isset($sub2))
-                                       {
-                                               $str=ltrim($str);
-                                               if(substr($str,0,strlen($sub2)) 
== $sub2)
-                                               {
-                                                       
$str=substr($str,strlen($sub2));
-                                                       return $str;
-                                               }
-                                       }
-                                       else
-                                       {
-                                               return $str;
-                                       }
-                               }
-                       }
-                       else
-                       {
-                               return $str;
-                       }
-                       return "";
-               }
- 
                function missing_app($app,$userlang=en)
                {
--- 117,120 ----
***************
*** 141,153 ****
                        $fd = PHPGW_SERVER_ROOT . SEP . $app . SEP . 'setup';
                        $fn = $fd . SEP . 'phpgw_' . $userlang . '.lang';
!                       if (is_writeable($fn))
                        {
                                $wr = True;
                        }
!                       elseif(!file_exists($fn) && is_writeable($fd))
  
-                       {
-                               $wr = True;
-                       }
                        if (file_exists($fn))
                        {
--- 139,148 ----
                        $fd = PHPGW_SERVER_ROOT . SEP . $app . SEP . 'setup';
                        $fn = $fd . SEP . 'phpgw_' . $userlang . '.lang';
!                       if (@is_writeable($fn) || is_writeable($fd))
                        {
                                $wr = True;
                        }
!                       $this->src_apps = array($app => $app);
  
                        if (file_exists($fn))
                        {
***************
*** 163,169 ****
                                        //echo '<br>add_app(): adding phrase: 
$this->langarray["'.$message_id.'"]=' . trim($content);
                                        $_mess_id = 
strtolower(trim($message_id));
                                        
$this->langarray[$_mess_id]['message_id'] = $_mess_id;
!                                       $this->langarray[$_mess_id]['app_name'] 
  = trim($app_name);
                                        $this->langarray[$_mess_id]['content']  
  = trim($content);
                                }
                                fclose($fp);
--- 158,166 ----
                                        //echo '<br>add_app(): adding phrase: 
$this->langarray["'.$message_id.'"]=' . trim($content);
                                        $_mess_id = 
strtolower(trim($message_id));
+                                       $app_name = trim($app_name);
                                        
$this->langarray[$_mess_id]['message_id'] = $_mess_id;
!                                       $this->langarray[$_mess_id]['app_name'] 
  = $app_name;
                                        $this->langarray[$_mess_id]['content']  
  = trim($content);
+                                       $this->src_apps[$app_name] = $app_name;
                                }
                                fclose($fp);
***************
*** 193,201 ****
                        $fd = PHPGW_SERVER_ROOT . SEP . $app . SEP . 'setup';
                        $fn = $fd . SEP . 'phpgw_' . $userlang . '.lang';
!                       if (is_writeable($fn))
!                       {
!                               $wr = True;
!                       }
!                       elseif(!file_exists($fn) && is_writeable($fd))
                        {
                                $wr = True;
--- 190,194 ----
                        $fd = PHPGW_SERVER_ROOT . SEP . $app . SEP . 'setup';
                        $fn = $fd . SEP . 'phpgw_' . $userlang . '.lang';
!                       if (@is_writeable($fn) || is_writeable($fd))
                        {
                                $wr = True;
***************
*** 205,223 ****
                        {
                                $this->tgt_file = $fn;
!                               $fp = fopen($fn,'rb');
!                               while ($data = fgets($fp,8000))
                                {
!                                       
list($message_id,$app_name,$null,$content) = explode("\t",$data);
!                                       if(!$message_id)
!                                       {
!                                               continue;
!                                       }
!                                       //echo '<br>add_app(): adding phrase: 
$this->langarray["'.$message_id.'"]=' . trim($content);
!                                       $_mess_id = 
strtolower(trim($message_id));
!                                       $langarray[$_mess_id]['message_id'] = 
$_mess_id;
!                                       $langarray[$_mess_id]['app_name']   = 
trim($app_name);
!                                       $langarray[$_mess_id]['content']    = 
trim($content);
                                }
-                               fclose($fp);
                        }
                        else
--- 198,218 ----
                        {
                                $this->tgt_file = $fn;
!                               if ($fp = @fopen($fn,'rb'))
                                {
!                                  while ($data = fgets($fp,8000))
!                                  {
!                                          
list($message_id,$app_name,$null,$content) = explode("\t",$data);
!                                          if(!$message_id)
!                                          {
!                                                  continue;
!                                          }
!                                          //echo '<br>add_app(): adding 
phrase: $this->langarray["'.$message_id.'"]=' . trim($content);
!                                          $_mess_id = 
strtolower(trim($message_id));
!                                          $langarray[$_mess_id]['message_id'] 
= $_mess_id;
!                                          $langarray[$_mess_id]['app_name']   
= trim($app_name);
!                                          $langarray[$_mess_id]['content']    
= trim($content);
!                                  }
!                                  fclose($fp);
                                }
                        }
                        else
***************
*** 233,260 ****
                }
  
!               function list_apps()
                {
!                       $this->db->query("SELECT * FROM 
phpgw_applications",__LINE__,__FILE__);
!                       if($this->db->num_rows())
                        {
!                               while($this->db->next_record())
!                               {
!                                       $name   = $this->db->f('app_name');
!                                       $title  = $this->db->f('app_title');
!                                       $apps[$name] = array(
!                                               'title'  => $title,
!                                               'name'   => $name
!                                       );
!                               }
                        }
!                       @reset($apps);
!                       $this->total = count($apps);
!                       if ($this->debug) { _debug_array($apps); }
!                       return $apps;
!               }
! 
!               function list_langs()
!               {
!                       $this->db->query("SELECT lang_id,lang_name FROM 
phpgw_languages ORDER BY lang_name");
                        $i = 0;
                        while ($this->db->next_record())
--- 228,243 ----
                }
  
!               function list_langs()
                {
!                       $this->db->query("SELECT DISTINCT lang FROM 
phpgw_lang");
!                       while($this->db->next_record())
                        {
!                               $lang = $this->db->f('lang');
!                               $installed[] = $lang;
                        }
!                       $installed = "('".implode("','",$installed)."')"; 
!                       
!                       // this shows first the installed, then the available 
and then the rest
!                       $this->db->query("SELECT lang_id,lang_name,lang_id IN 
$installed as installed FROM phpgw_languages ORDER BY installed DESC,available 
DESC,lang_name");
                        $i = 0;
                        while ($this->db->next_record())
***************
*** 272,277 ****
                {
                        $fn = PHPGW_SERVER_ROOT . SEP . $app_name . SEP . 
'setup' . SEP . 'phpgw_' . $userlang . '.lang';
                        $fp = fopen($fn,'wb');
!                       while(list($mess_id,$data) = each($langarray))
                        {
                                fwrite($fp,$mess_id . "\t" . $data['app_name'] 
. "\t" . $userlang . "\t" . $data['content'] . "\n");
--- 255,266 ----
                {
                        $fn = PHPGW_SERVER_ROOT . SEP . $app_name . SEP . 
'setup' . SEP . 'phpgw_' . $userlang . '.lang';
+                       if (file_exists($fn))
+                       {
+                               $backup = $fn . '.old';
+                               @unlink($backup);
+                               @rename($fn,$backup);
+                       }
                        $fp = fopen($fn,'wb');
!                       while(list($mess_id,$data) = @each($langarray))
                        {
                                fwrite($fp,$mess_id . "\t" . $data['app_name'] 
. "\t" . $userlang . "\t" . $data['content'] . "\n");
***************
*** 290,298 ****
                        while (list($x,$data) = @each($langarray))
                        {
                                $addit = False;
                                /*echo '<br><br><pre> checking ' . 
$data['message_id'] . "\t" . $data['app_name'] . "\t" . $userlang . "\t" . 
$data['content'];*/
!                               $this->db->query('SELECT COUNT(*) FROM 
phpgw_lang'
!                                       ."  WHERE message_id='" . 
$this->db->db_addslashes($data['message_id'])
!                                       ."' AND lang='".$userlang."' AND 
app_name='".$app_name."'",__LINE__,__FILE__);
                                $this->db->next_record();
  
--- 279,293 ----
                        while (list($x,$data) = @each($langarray))
                        {
+                               if (strlen($data['message_id']) > 
MAX_MESSAGE_ID_LENGTH)
+                               {
+                                       $data['message_id'] = 
substr($data['message_id'],0,MAX_MESSAGE_ID_LENGTH);
+                               }
+                               
+                               $message_id = 
$this->db->db_addslashes(substr($data['message_id'],0,MAX_MESSAGE_ID_LENGTH));
+ 
                                $addit = False;
                                /*echo '<br><br><pre> checking ' . 
$data['message_id'] . "\t" . $data['app_name'] . "\t" . $userlang . "\t" . 
$data['content'];*/
!                               $this->db->query("SELECT COUNT(*) FROM 
phpgw_lang"
!                                       ."  WHERE message_id='$message_id' AND 
lang='$userlang' AND app_name='$app_name'",__LINE__,__FILE__);
                                $this->db->next_record();
  
***************
*** 311,318 ****
                                        if($data['message_id'] && 
$data['content'])
                                        {
!                                               /* echo "<br>adding - insert 
into phpgw_lang values ('" . $data['message_id'] . 
"','$app_name','$userlang','" . $data['content'] . "')"; */
!                                               $this->db->query("INSERT into 
phpgw_lang VALUES ('"
!                                                       . 
$this->db->db_addslashes($data['message_id'])
!                                                       . 
"','$app_name','$userlang','"
                                                        . 
$this->db->db_addslashes($data['content']) . "')",__LINE__,__FILE__);
                                        }
--- 306,311 ----
                                        if($data['message_id'] && 
$data['content'])
                                        {
!                                               /* echo "<br>adding - insert 
into lang values ('" . $data['message_id'] . "','$app_name','$userlang','" . 
$data['content'] . "')"; */
!                                               $this->db->query("INSERT into 
phpgw_lang VALUES ('$message_id','$app_name','$userlang','"
                                                        . 
$this->db->db_addslashes($data['content']) . "')",__LINE__,__FILE__);
                                        }
***************
*** 323,327 ****
                                        {
                                                $this->db->query("UPDATE 
phpgw_lang SET content='". $this->db->db_addslashes($data['content']) . "'"
!                                                       . " WHERE message_id='" 
. $this->db->db_addslashes($data['message_id']) . "'"
                                                        . " AND 
app_name='$app_name' AND lang='$userlang'",__LINE__,__FILE__);
                                                if ($this->db->affected_rows() 
> 0)
--- 316,320 ----
                                        {
                                                $this->db->query("UPDATE 
phpgw_lang SET content='". $this->db->db_addslashes($data['content']) . "'"
!                                                       . " WHERE 
message_id='message_id'"
                                                        . " AND 
app_name='$app_name' AND lang='$userlang'",__LINE__,__FILE__);
                                                if ($this->db->affected_rows() 
> 0)





reply via email to

[Prev in Thread] Current Thread [Next in Thread]