phpgroupware-cvs
[Top][All Lists]
Advanced

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

[Phpgroupware-cvs] CVS: developer_tools/inc class.bolangfile.inc.php,1.9


From: Mark A Peters <address@hidden>
Subject: [Phpgroupware-cvs] CVS: developer_tools/inc class.bolangfile.inc.php,1.9,1.10 class.solangfile.inc.php,1.11,1.12 class.uilangfile.inc.php,1.11,1.12
Date: Tue, 02 Jul 2002 19:59:18 -0400

Update of /cvsroot/phpgroupware/developer_tools/inc
In directory subversions:/tmp/cvs-serv24188/developer_tools/inc

Modified Files:
        class.bolangfile.inc.php class.solangfile.inc.php 
        class.uilangfile.inc.php 
Log Message:
GNU Bug #384.

Index: class.bolangfile.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/developer_tools/inc/class.bolangfile.inc.php,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -r1.9 -r1.10
*** class.bolangfile.inc.php    17 Feb 2002 18:02:40 -0000      1.9
--- class.bolangfile.inc.php    2 Jul 2002 23:59:14 -0000       1.10
***************
*** 26,29 ****
--- 26,30 ----
                var $src_file;
                var $tgt_file;
+               var $tgt_lang;
  
                function bolangfile()
***************
*** 55,58 ****
--- 56,61 ----
                        
$GLOBALS['phpgw']->session->appsession('developer_source_file','developer_tools',$this->src_file);
                        
$GLOBALS['phpgw']->session->appsession('developer_target_file','developer_tools',$this->tgt_file);
+                       
$GLOBALS['phpgw']->session->appsession('developer_t_lang','developer_tools',$this->tgt_lang);
+                       
$GLOBALS['phpgw']->session->appsession('developer_loaded_apps','developer_tools',$this->loaded_apps);
                }
  
***************
*** 67,76 ****
                        $src_file = 
$GLOBALS['phpgw']->session->appsession('developer_source_file','developer_tools');
                        $tgt_file = 
$GLOBALS['phpgw']->session->appsession('developer_target_file','developer_tools');
  
!                       
$this->set_sessiondata($source,$target,$src_file,$tgt_file);
                        return;
                }
  
!               function set_sessiondata($source,$target,$src_file,$tgt_file)
                {
                        $this->source_langarray = $source;
--- 70,81 ----
                        $src_file = 
$GLOBALS['phpgw']->session->appsession('developer_source_file','developer_tools');
                        $tgt_file = 
$GLOBALS['phpgw']->session->appsession('developer_target_file','developer_tools');
+                       $tgt_lang = 
$GLOBALS['phpgw']->session->appsession('developer_t_lang','developer_tools');
+                       $loaded_apps = 
$GLOBALS['phpgw']->session->appsession('developer_loaded_apps','developer_tools');
  
!                       
$this->set_sessiondata($source,$target,$src_file,$tgt_file,$tgt_lang,$loaded_apps);
                        return;
                }
  
!               function 
set_sessiondata($source,$target,$src_file,$tgt_file,$tgt_lang,$loaded_apps)
                {
                        $this->source_langarray = $source;
***************
*** 78,81 ****
--- 83,88 ----
                        $this->src_file = $src_file;
                        $this->tgt_file = $tgt_file;
+                       $this->tgt_lang = $tgt_lang;
+                       $this->loaded_apps = $loaded_apps;
                }
  
***************
*** 86,89 ****
--- 93,97 ----
                        
$GLOBALS['phpgw']->session->appsession('developer_source_file','developer_tools','');
                        
$GLOBALS['phpgw']->session->appsession('developer_target_file','developer_tools','');
+                       
$GLOBALS['phpgw']->session->appsession('developer_loaded_apps','developer_tools','');
                }
  
***************
*** 103,109 ****
                {
                        /* _debug_array($this->source_langarray);exit; */
!                       $mess_id = $entry['message_id'];
                        $this->source_langarray[$mess_id] = array(
!                               'message_id' => $entry['message_id'],
                                'content'    => $entry['content'],
                                'app_name'   => $entry['app_name'],
--- 111,117 ----
                {
                        /* _debug_array($this->source_langarray);exit; */
!                       $mess_id = strtolower(trim($entry['message_id']));
                        $this->source_langarray[$mess_id] = array(
!                               'message_id' => $mess_id,
                                'content'    => $entry['content'],
                                'app_name'   => $entry['app_name'],
***************
*** 117,127 ****
                function movephrase($mess='')
                {
!                       if ($mess !='' && 
($this->missing_langarray[strtolower($mess)]['message_id']))
                        {
-                               $_mess = strtolower($mess);
                                $this->source_langarray[$mess] = array(
!                                       'message_id' => 
$this->missing_langarray[$_mess]['message_id'],
!                                       'content'    => 
$this->missing_langarray[$_mess]['content'],
!                                       'app_name'   => 
$this->missing_langarray[$_mess]['app_name'],
                                        'lang'       => 'en'
                                );
--- 125,134 ----
                function movephrase($mess='')
                {
!                       if ($mess !='' && 
($this->missing_langarray[$mess]['message_id']))
                        {
                                $this->source_langarray[$mess] = array(
!                                       'message_id' => 
$this->missing_langarray[$mess]['message_id'],
!                                       'content'    => 
$this->missing_langarray[$mess]['content'],
!                                       'app_name'   => 
$this->missing_langarray[$mess]['app_name'],
                                        'lang'       => 'en'
                                );
***************
*** 140,144 ****
                {
                        //$this->src_file = $this->so->src_file;
-                       $this->loaded_apps = $this->so->loaded_apps;
                        //if ($this->missing_langarray=='')
                        //{
--- 147,150 ----
***************
*** 147,161 ****
                        while (list($p,$loc) = each($plist))
                        {
!                               if 
((!$this->source_langarray[strtolower($p)])&&(!$this->source_langarray[$p]))
                                {
!                                       
$this->missing_langarray[strtolower(trim($p))]['message_id'] = 
strtolower(trim($p));
!                                       
$this->missing_langarray[strtolower(trim($p))]['app_name']   = trim($app);
!                                       
$this->missing_langarray[strtolower(trim($p))]['content']    = $p;
                                }
                        }
!                       //}        
!                       reset ($this->missing_langarray);
!                       @ksort($this->missing_langarray);
!                       
$this->save_sessiondata($this->source_langarray,$this->target_langarray);
                        return $this->missing_langarray;
                }
--- 153,169 ----
                        while (list($p,$loc) = each($plist))
                        {
!                               $_mess_id = strtolower(trim($p));
!                               if (!$this->source_langarray[$_mess_id])
                                {
!                                       
$this->missing_langarray[$_mess_id]['message_id'] = $_mess_id;
!                                       
$this->missing_langarray[$_mess_id]['app_name']   = trim($app);
!                                       
$this->missing_langarray[$_mess_id]['content']    = $p;
                                }
                        }
!                       if (is_array($this->missing_langarray))
!                       {
!                               reset ($this->missing_langarray);
!                               @ksort($this->missing_langarray);
!                       }
                        return $this->missing_langarray;
                }
***************
*** 177,184 ****
                        if(gettype($this->target_langarray) == 'array')
                        {
!                               /* return $this->target_langarray; */
                        }
                        $this->target_langarray = 
$this->so->load_app($app,$userlang);
                        $this->tgt_file = $this->so->tgt_file;
                        $this->loaded_apps = $this->so->loaded_apps;
                        return $this->target_langarray;
--- 185,196 ----
                        if(gettype($this->target_langarray) == 'array')
                        {
!                               if ($this->tgt_lang == $userlang)
!                               {
!                                       return $this->target_langarray;
!                               }
                        }
                        $this->target_langarray = 
$this->so->load_app($app,$userlang);
                        $this->tgt_file = $this->so->tgt_file;
+                       $this->tgt_lang = $userlang;
                        $this->loaded_apps = $this->so->loaded_apps;
                        return $this->target_langarray;

Index: class.solangfile.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/developer_tools/inc/class.solangfile.inc.php,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -r1.11 -r1.12
*** class.solangfile.inc.php    8 Mar 2002 04:14:21 -0000       1.11
--- class.solangfile.inc.php    2 Jul 2002 23:59:14 -0000       1.12
***************
*** 33,37 ****
                }
  
!               //Known Issue, if a phrase contains a ' or a " the parse will 
be thrown off. unless ' are nesed inside "
                function parse_php_app($fd,$plist)
                {
--- 33,37 ----
                }
  
!               //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)
                {
***************
*** 54,74 ****
                                        {
                                                $str=fgets($fp,8192);
!                                               while 
($pos=strpos($str,'lang('))
                                                {
!                                                       $str=substr($str,$pos);
!                                                       if (strpos($str,'$')==5)
                                                        {
!                                                               
$str=substr($str,6);
!                                                       }
!                                                       else
!                                                       {
!                                                               
$str=substr($str,6);
!                                                               if 
(!strpos($str,'\")'))
                                                                {
!                                                                       
$s2=substr($str,0,strpos($str,'\')'));
                                                                }
                                                                else
                                                                {
!                                                                       
$s2=substr($str,0,strpos($str,'\")'));
                                                                }
                                                                if ($s2!='')
--- 54,70 ----
                                        {
                                                $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!='')
***************
*** 86,89 ****
--- 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)
                {
***************
*** 129,135 ****
                                        }
                                        //echo '<br>add_app(): adding phrase: 
$this->langarray["'.$message_id.'"]=' . trim($content);
!                                       
$this->langarray[$message_id]['message_id'] = trim($message_id);
!                                       
$this->langarray[$message_id]['app_name']   = trim($app_name);
!                                       
$this->langarray[$message_id]['content']    = trim($content);
                                }
                                fclose($fp);
--- 162,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);
***************
*** 149,153 ****
  
                /*!
!               @function add_app
                @abstract loads all app phrases into langarray
                @param $lang user lang variable (defaults to en)
--- 183,187 ----
  
                /*!
!               @function load_app
                @abstract loads all app phrases into langarray
                @param $lang user lang variable (defaults to en)
***************
*** 180,186 ****
                                        }
                                        //echo '<br>add_app(): adding phrase: 
$this->langarray["'.$message_id.'"]=' . trim($content);
!                                       $langarray[$message_id]['message_id'] = 
trim($message_id);
!                                       $langarray[$message_id]['app_name']   = 
trim($app_name);
!                                       $langarray[$message_id]['content']    = 
trim($content);
                                }
                                fclose($fp);
--- 214,221 ----
                                        }
                                        //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);
***************
*** 256,261 ****
                        {
                                $addit = False;
!                               /* echo '<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'",__LINE__,__FILE__);
                                $this->db->next_record();
  
--- 291,298 ----
                        {
                                $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();
                                $this->db->next_record();
  
***************
*** 276,282 ****
                                                /* 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']) . "','"
!                                                       . $data['app_name'] . 
"','$userlang','"
                                                        . 
$this->db->db_addslashes($data['content']) . "')",__LINE__,__FILE__);
                                        }
                                }
--- 313,336 ----
                                                /* 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__);
+                                       }
+                               }
+                               else
+                               {
+                                       if($data['message_id'] && 
$data['content'])
+                                       {
+                                               $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)
+                                               {
+ /*
+                                                       echo "<br>changing - 
update lang set content='". $data['content'] . "'"
+                                                               . " where 
message_id='" . $data['message_id'] ."'"
+                                                               . " and 
app_name='$app_name' and lang='$userlang'";
+ */
+                                               }
                                        }
                                }

Index: class.uilangfile.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/developer_tools/inc/class.uilangfile.inc.php,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -r1.11 -r1.12
*** class.uilangfile.inc.php    30 Apr 2002 18:39:53 -0000      1.11
--- class.uilangfile.inc.php    2 Jul 2002 23:59:14 -0000       1.12
***************
*** 145,151 ****
                                        if($_checked == 'on')
                                        {
                                                $this->bo->movephrase($_mess);
                                                /* 
_debug_array($missingarray[$_mess]); */
!                                               
unset($missingarray[strtolower($_mess)]);
                                                /* 
_debug_array($missingarray[$_mess]); */
                                        }
--- 145,152 ----
                                        if($_checked == 'on')
                                        {
+                                               $_mess = 
$this->reverse_htmlspecialchars($_mess);
                                                $this->bo->movephrase($_mess);
                                                /* 
_debug_array($missingarray[$_mess]); */
!                                               unset($missingarray[$_mess]);
                                                /* 
_debug_array($missingarray[$_mess]); */
                                        }
***************
*** 226,239 ****
                                );
                                $this->template->pfp('out','postheader');
                                $translation = 
$this->bo->load_app($app_name,$targetlang);
                                // 
$this->template->set_var('src_file',$this->bo->src_file);
                                while(list($key,$data) = @each($missingarray))
                                {
!                                       $mess_id  = $data['message_id'];
                                        $content  = $data['content'];
                                        $transapp = $data['app_name'];
                                        // $transy   = $content;
!                                       
$this->template->set_var('mess_id',$GLOBALS['phpgw']->strip_html($mess_id));
!                                       
$this->template->set_var('source_content',$GLOBALS['phpgw']->strip_html($content));
                                        // 
$this->template->set_var('content',$GLOBALS['phpgw']->strip_html($transy));
                                        
$this->template->set_var('transapp',$this->lang_option($app_name,$transapp,$mess_id));
--- 227,241 ----
                                );
                                $this->template->pfp('out','postheader');
+                               //Is this needed? $translation is never used 
and bo->load_app() does nothing here.
                                $translation = 
$this->bo->load_app($app_name,$targetlang);
                                // 
$this->template->set_var('src_file',$this->bo->src_file);
                                while(list($key,$data) = @each($missingarray))
                                {
!                                       $mess_id  = $key;
                                        $content  = $data['content'];
                                        $transapp = $data['app_name'];
                                        // $transy   = $content;
!                                       
$this->template->set_var('mess_id',htmlspecialchars($mess_id));
!                                       
$this->template->set_var('source_content',htmlspecialchars($content));
                                        // 
$this->template->set_var('content',$GLOBALS['phpgw']->strip_html($transy));
                                        
$this->template->set_var('transapp',$this->lang_option($app_name,$transapp,$mess_id));
***************
*** 418,421 ****
--- 420,424 ----
                                        if($_mess)
                                        {
+                                               $_mess = 
$this->reverse_htmlspecialchars($_mess);
                                                
$this->bo->source_langarray[$_mess]['app_name'] = $_app;
                                                
$this->bo->target_langarray[$_mess]['app_name'] = $_app;
***************
*** 426,434 ****
                                        if($_mess && $_cont)
                                        {
                                                
$this->bo->target_langarray[$_mess]['message_id'] = $_mess;
!                                               
$this->bo->target_langarray[$_mess]['content'] = $_cont;
                                                if($sourcelang == $targetlang)
                                                {
!                                                       
$this->bo->source_langarray[$_mess]['content'] = $_cont;
                                                }
                                        }
--- 429,441 ----
                                        if($_mess && $_cont)
                                        {
+                                               $_mess = 
$this->reverse_htmlspecialchars(strtolower(trim($_mess)));
+                                               //Known issue: if a message 
containing a ] is used as index of array, when the array is posted the index 
gets truncated;
                                                
$this->bo->target_langarray[$_mess]['message_id'] = $_mess;
!                                               //POST method adds slashes
!                                               
$this->bo->target_langarray[$_mess]['content'] = stripslashes($_cont);
                                                if($sourcelang == $targetlang)
                                                {
!                                                       //POST method adds 
slashes
!                                                       
$this->bo->source_langarray[$_mess]['content'] = stripslashes($_cont);
                                                }
                                        }
***************
*** 438,441 ****
--- 445,449 ----
                                        if($_checked == 'on')
                                        {
+                                               $_mess = 
$this->reverse_htmlspecialchars($_mess);
                                                
unset($this->bo->source_langarray[$_mess]);
                                                
unset($this->bo->target_langarray[$_mess]);
***************
*** 479,487 ****
                                        $content  = $data['content'];
                                        $transapp = $data['app_name'];
!                                       $transy   = 
$translation[$mess_id]['content'];
!                                       
$this->template->set_var('mess_id',$GLOBALS['phpgw']->strip_html($mess_id));
!                                       
$this->template->set_var('source_content',$GLOBALS['phpgw']->strip_html($content));
!                                       
$this->template->set_var('content',$GLOBALS['phpgw']->strip_html($transy));
!                                       
$this->template->set_var('transapp',$this->lang_option($app_name,$transapp,$mess_id));
                                        
$this->template->set_var('tr_color',$this->nextmatchs->alternate_row_color());
                                        $this->template->pfp('out','detail');
--- 487,495 ----
                                        $content  = $data['content'];
                                        $transapp = $data['app_name'];
!                                       $transy   = 
$translation[$key]['content'];
!                                       
$this->template->set_var('mess_id',htmlspecialchars($key));
!                                       
$this->template->set_var('source_content',htmlspecialchars($content));
!                                       
$this->template->set_var('content',htmlspecialchars($transy));
!                                       
$this->template->set_var('transapp',$this->lang_option($app_name,$transapp,htmlspecialchars($key)));
                                        
$this->template->set_var('tr_color',$this->nextmatchs->alternate_row_color());
                                        $this->template->pfp('out','detail');
***************
*** 513,516 ****
--- 521,537 ----
                        /* _debug_array($this->bo->loaded_apps); */
                        
$this->bo->save_sessiondata($this->bo->source_langarray,$this->bo->target_langarray);
+               }
+ 
+               /*!
+               @function reverse_htmlspecialchars
+               @abstract reverts a string converted by htmlspecialchars() to 
its original form
+               @param $text
+               */
+               function reverse_htmlspecialchars($text)
+               {
+                       $text=ereg_replace('&gt;', '>', $text);
+                       $text=ereg_replace('&lt;', '<', $text);
+                       $text=ereg_replace('&quot;', "\"", $text);
+                       return ereg_replace('&amp;', '&', $text);
                }
  




reply via email to

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