<?php
  /*

      i18n_remarks.inc

      Tranlation of remarks stored as strings in database.

      ----
    Modified by:
      Copyright (C) 2005  1stBnA GmbH 
      Copyright (C) 2005  Stephan Kaufhold (s.kauhold@1stbna.com)

      This program is free software; you can redistribute it and/or
      modify it under the terms of the GNU General Public License
      as published by the Free Software Foundation version 2.

      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.

      You should have received a copy of the GNU General Public License
      along with this program; if not, write to the Free Software
      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

  */

function loc_remarks($arr, $str)
{
  $lines = split("\n", $str);

  foreach ($lines as $help)
  {
      // $aa = substr($help, 0, 1);
    if (substr($help, 0, 5) == "Issue" )
    {
//       $aa .= substr($help, 6, 1);
//       $aa .= substr($help, 15, 1);
//       $aa .= substr($help, 23, 1);
//       print "$aa<br />\n";

      if (substr($help, 5, 23) == " priority changed from ")
      {
        $aa = array('/Ungraded/','/["|\'](.*)["|\']\s+to\s+["|\'](.*)["|\'].*/');
        $bb = array($arr[15],$arr[0].' "\1" '.$arr[3].' "\2".<br />'."\n");
        print preg_replace($aa, $bb, substr($help,27));
      }
      elseif (substr($help, 5, 21) == " status changed from ")
      {
//         $aa = split("\" to \"", substr($help,25));
//         print $arr[2]." ".$aa[0]."\" ".$arr[3]." \"".$aa[1]."<br />\n";
        print preg_replace('/["|\'](.*)["|\']\s+to\s+["|\'](.*)["|\'].*/',
            $arr[2].' "\1" '.$arr[3].' "\2".<br />'."\n", substr($help,25));
      }
      elseif (substr($help, 5, 20) == " level changed from ")
      {
//         $aa = split("\" to \"", substr($help,25));
//         print $arr[1]." ".$aa[0]."\" ".$arr[3]." \"".$aa[1]."<br />\n";
        print preg_replace('/["|\'](.*)["|\']\s+to\s+["|\'](.*)["|\'].*/',
            $arr[1].' "\1" '.$arr[3].' "\2".<br />'."\n", substr($help,24));
      }
      elseif (substr($help, 5, 19) == " site changed from ")
      {
//         $aa = split("\" to \"", substr($help,24));
//         print $arr[11]." ".$aa[0]."\" ".$arr[3]." \"".$aa[1]."<br />\n";
        print preg_replace('/["|\'](.*)["|\']\s+to\s+["|\'](.*)["|\'].*/',
            $arr[11].' "\1" '.$arr[3].' "\2".<br />'."\n", substr($help,23));
      }
      elseif (substr($help, 5, 17) == " reassigned from ")
      {
        $aa = array('/\* unassigned \*/','/["|\'](.*)["|\']\s+to\s+["|\'](.*)["|\'].*/');
        $bb = array($arr[13], 
          $arr[12].' "\1" '.$arr[3].' "\2".<br />'."\n"
          );
        print preg_replace($aa,$bb,substr($help, 21));
//         if ($aa[0] == "\"* unassigned *") 
//         {
//           print $arr[12]." \"".$arr[13]."\" ".$arr[3]." \"".$aa[1]."<br />\n";
//         }
//         elseif ($aa[1] == "* unassigned *\".")
//         {
//           print $arr[12]." ".$aa[0]."\" ".$arr[3]." \"".$arr[13]."\".<br />\n";
//         }
//         else
//         {
//           //print "#$aa[1]#<br />\n";
//           print $arr[12]." ".$aa[0]."\" ".$arr[3]." \"".$aa[1]."<br />\n";
//         }
      }
      elseif (substr($help, 5, 23) == " recalled by the client")
      {
        print $arr[14]."<br />\n";
      }
      else
      { 
        print "$help<br />\n";
      }
    }
    elseif (substr($help, 0, 5) == "Spent")
    {
      //print "Spent<br />\n";
      $aa = strrev($help);
      if (substr($aa, 0, 15) == ".melborp eht no")
      {
        $aa = substr($aa, 16);
        //print "$aa<br />\n";
        $aa = strrev($aa);
        //print "$aa<br />\n";
        $aa = substr($aa, 6);
        if (substr($aa, 0, 13) == "an additional")
        {
          $aa = substr($aa, 14);
          $aa = str_replace("hours", $arr[7], $aa);
          $aa = str_replace("hour", $arr[6], $aa);
          $aa = str_replace("minutes", $arr[9], $aa);
          $aa = str_replace("minute", $arr[8], $aa);
          print "$arr[5] $aa $arr[10].<br />\n";
        }
        else
        {
          $aa = str_replace("hours", $arr[7], $aa);
          $aa = str_replace("hour", $arr[6], $aa);
          $aa = str_replace("minutes", $arr[9], $aa);
          $aa = str_replace("minute", $arr[8], $aa);
          print "$arr[4] $aa $arr[10].<br />\n";
        }
      }
      else
      {
        print "$help<br />\n";
      }
    }
    else
    {
      print nl2br($help);
    }
  }
}

?>
