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.8


From: Mark A Peters <address@hidden>
Subject: [Phpgroupware-cvs] CVS: developer_tools/inc class.bolangfile.inc.php,1.8,1.8.2.1 class.solangfile.inc.php,1.9,1.9.2.1 class.uilangfile.inc.php,1.10,1.10.2.1
Date: Sat, 29 Jun 2002 20:11:27 -0400

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

Modified Files:
      Tag: Version-0_9_14-branch
        class.bolangfile.inc.php class.solangfile.inc.php 
        class.uilangfile.inc.php 
Log Message:
GNU Patch #356.

Index: class.bolangfile.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/developer_tools/inc/class.bolangfile.inc.php,v
retrieving revision 1.8
retrieving revision 1.8.2.1
diff -C2 -r1.8 -r1.8.2.1
*** class.bolangfile.inc.php    16 Dec 2001 12:36:50 -0000      1.8
--- class.bolangfile.inc.php    30 Jun 2002 00:11:25 -0000      1.8.2.1
***************
*** 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,89 ----
                        $this->src_file = $src_file;
                        $this->tgt_file = $tgt_file;
+                       $this->tgt_lang = $tgt_lang;
+                       $this->loaded_apps = $loaded_apps;
+ 
                }
  
***************
*** 86,89 ****
--- 94,99 ----
                        
$GLOBALS['phpgw']->session->appsession('developer_source_file','developer_tools','');
                        
$GLOBALS['phpgw']->session->appsession('developer_target_file','developer_tools','');
+                       
$GLOBALS['phpgw']->session->appsession('developer_t_lang','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'],
--- 113,119 ----
                {
                        /* _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'
                                );
--- 127,136 ----
                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=='')
                        //{
--- 149,152 ----
***************
*** 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->bo->source_langarray,$this->bo->target_langarray);
                        return $this->missing_langarray;
                }
--- 155,174 ----
                        while (list($p,$loc) = each($plist))
                        {
! //                            if 
((!$this->source_langarray[strtolower($p)])&&(!$this->source_langarray[$p]))
!                               $_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->messing_langarray))
!                       {
!                               reset ($this->missing_langarray);
!                               @ksort($this->missing_langarray);               
        
!                       }
! //                    
$this->save_sessiondata($this->bo->source_langarray,$this->bo->target_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;
--- 190,201 ----
                        if(gettype($this->target_langarray) == 'array')
                        {
!                               if ($this->target_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.9
retrieving revision 1.9.2.1
diff -C2 -r1.9 -r1.9.2.1
*** class.solangfile.inc.php    28 Dec 2001 15:20:24 -0000      1.9
--- class.solangfile.inc.php    30 Jun 2002 00:11:25 -0000      1.9.2.1
***************
*** 45,49 ****
                }
  
!               //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)
                {
--- 45,49 ----
                }
  
!               //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)
                {
***************
*** 66,86 ****
                                        {
                                                $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!='')
--- 66,82 ----
                                        {
                                                $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!='')
***************
*** 98,101 ****
--- 94,134 ----
                }
  
+               /*!
+               @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)
                {
***************
*** 141,147 ****
                                        }
                                        //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);
--- 174,181 ----
                                        }
                                        //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);
***************
*** 161,165 ****
  
                /*!
!               @function add_app
                @abstract loads all app phrases into langarray
                @param $lang user lang variable (defaults to en)
--- 195,199 ----
  
                /*!
!               @function load_app
                @abstract loads all app phrases into langarray
                @param $lang user lang variable (defaults to en)
***************
*** 192,198 ****
                                        }
                                        //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);
--- 226,233 ----
                                        }
                                        //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);
***************
*** 268,273 ****
                        {
                                $addit = False;
!                               /* echo '<pre> checking ' . $data['message_id'] 
. "\t" . $data['app_name'] . "\t" . $userlang . "\t" . $data['content']; */
!                               $this->db->query("SELECT COUNT(*) FROM lang 
WHERE message_id='" . $this->db->db_addslashes($data['message_id']) . "' and 
lang='$userlang'",__LINE__,__FILE__);
                                $this->db->next_record();
  
--- 303,310 ----
                        {
                                $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 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();
  
***************
*** 288,294 ****
                                                /* echo "<br>adding - insert 
into lang values ('" . $data['message_id'] . "','$app_name','$userlang','" . 
$data['content'] . "')"; */
                                                $this->db->query("INSERT into 
lang VALUES ('"
!                                                       . 
$this->db->db_addslashes($data['message_id']) . "','"
!                                                       . $data['app_name'] . 
"','$userlang','"
                                                        . 
$this->db->db_addslashes($data['content']) . "')",__LINE__,__FILE__);
                                        }
                                }
--- 325,348 ----
                                                /* echo "<br>adding - insert 
into lang values ('" . $data['message_id'] . "','$app_name','$userlang','" . 
$data['content'] . "')"; */
                                                $this->db->query("INSERT into 
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 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.10
retrieving revision 1.10.2.1
diff -C2 -r1.10 -r1.10.2.1
*** class.uilangfile.inc.php    16 Dec 2001 12:36:50 -0000      1.10
--- class.uilangfile.inc.php    30 Jun 2002 00:11:25 -0000      1.10.2.1
***************
*** 144,150 ****
                                        if($_checked == 'on')
                                        {
                                                $this->bo->movephrase($_mess);
                                                /* 
_debug_array($missingarray[$_mess]); */
!                                               
unset($missingarray[strtolower($_mess)]);
                                                /* 
_debug_array($missingarray[$_mess]); */
                                        }
--- 144,151 ----
                                        if($_checked == 'on')
                                        {
+                                               $_mess = 
$this->reverse_htmlspecialchars($_mess);
                                                $this->bo->movephrase($_mess);
                                                /* 
_debug_array($missingarray[$_mess]); */
!                                               unset($missingarray[$_mess]);
                                                /* 
_debug_array($missingarray[$_mess]); */
                                        }
***************
*** 225,238 ****
                                );
                                $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));
--- 226,240 ----
                                );
                                $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));
***************
*** 417,420 ****
--- 419,423 ----
                                        if($_mess)
                                        {
+                                               $_mess = 
$this->reverse_htmlspecialchars($_mess);
                                                
$this->bo->source_langarray[$_mess]['app_name'] = $_app;
                                                
$this->bo->target_langarray[$_mess]['app_name'] = $_app;
***************
*** 425,433 ****
                                        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;
                                                }
                                        }
--- 428,440 ----
                                        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);
                                                }
                                        }
***************
*** 437,440 ****
--- 444,448 ----
                                        if($_checked == 'on')
                                        {
+                                               $_mess = 
$this->reverse_htmlspecialchars($_mess);
                                                
unset($this->bo->source_langarray[$_mess]);
                                                
unset($this->bo->target_langarray[$_mess]);
***************
*** 478,486 ****
                                        $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');
--- 486,494 ----
                                        $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 ----
                        
$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);
+               }
  
                function save($which,$userlang)




reply via email to

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