Changeset 614


Ignore:
Timestamp:
Nov 28, 2013, 6:24:17 PM (11 years ago)
Author:
maron
Message:
  • Fixed: Double colorization
  • Optimalization: Faster SQL query for search translated names
Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Modules/Translation/Form.php

    r613 r614  
    33class PageTranslationForm extends Page
    44{
     5  function ReplaceTranslated($orig,$tran,$Text,$ID,$Group) {
     6         $tran_replace = str_replace(' ',' ',$tran);
     7         $orig_replace = str_replace(' ',' ',$orig);
     8                                  $Text = str_replace(' '.$orig,' <span Title="Přelož jako: '.$tran_replace.'" class="edit"><a class="edit" target="_NEW2" href="'.$this->System->Link('/form.php?group='.$Group.'&amp;ID='.$ID).'">'.$orig_replace.'</a></span>',$Text);
     9                                 return ($Text);
     10  }
     11  function ReplaceNotTranslated($orig,$tran,$Text,$ID,$Group) {
     12         $orig_replace = str_replace(' ','&nbsp;',$orig);
     13                                 $Text = str_replace($orig,' <span title="Kliknutím přeložíš" class="needtran"><a class="needtran" target="_NEW2" href="'.$this->System->Link('/form.php?group='.$Group.'&amp;ID='.$ID).'">'.$orig_replace.'</a></span>',$Text);
     14                                 return ($Text);
     15  }
     16 
    517        function ColorNames($Text, $names)
    618        {
    7                 // $buff[] = array($Line['ID'],GetIDbyName($Table),$Line[$Column],$Line['Tran']);
     19    $Text = ' '.$Text;
    820                foreach($names as $Line) {
    921                        if ($Line[3] <> '') {
    10                           if (strpos($Text, '>'.$Line[2]) == 0)
    11                                   $Text = str_replace($Line[2],'<span Title="Přelož jako: '.$Line[3].'" class="edit"><a class="edit" target="_NEW2" href="'.$this->System->Link('/form.php?group='.$Line[1].'&amp;ID='.$Line[0]).'">'.$Line[2].'</a></span>',$Text);
    12                                 if (strpos($Text, '>'.$Line[2]) == 0)
    13           $Text = str_replace(strtolower($Line[2]),'<span Title="Překládej jako: '.$Line[3].'" class="edit"><a class="edit" target="_NEW2" href="'.$this->System->Link('/form.php?group='.$Line[1].'&amp;ID='.$Line[0]).'">'.$Line[2].'</a></span>',$Text);
     22        $Text = $this->ReplaceTranslated($Line[2],$Line[3],$Text,$Line[0],$Line[1]);
     23       
    1424                        } else {
    15                           if (strpos($Text, '>'.$Line[2]) == 0)
    16                                 $Text = str_replace($Line[2],'<span title="Kliknutím přeložíš" class="needtran"><a class="needtran" target="_NEW2" href="'.$this->System->Link('/form.php?group='.$Line[1].'&amp;ID='.$Line[0]).'">'.$Line[2].'</a></span>',$Text);
    17                                 if (strpos($Text, '>'.$Line[2]) == 0)
    18           $Text = str_replace(strtolower($Line[2]),'<span title="Kliknutím přeložíš" class="needtran"><a class="needtran" target="_NEW2" href="'.$this->System->Link('/form.php?group='.$Line[1].'&amp;ID='.$Line[0]).'">'.$Line[2].'</a></span>',$Text);
     25        $Text = $this->ReplaceNotTranslated($Line[2],$Line[3],$Text,$Line[0],$Line[1]);
    1926                        }
    2027                }
  • trunk/includes/Version.php

    r613 r614  
    66// and system will need database update.
    77
    8 $Revision = 613; // Subversion revision
     8$Revision = 614; // Subversion revision
    99$DatabaseRevision = 610; // Database structure revision
    1010$ReleaseTime = '2013-11-27';
  • trunk/includes/global.php

    r603 r614  
    550550    if ($mode == 2) $where .= ' AND NOT EXISTS(SELECT 1 FROM `'.$Table.'` AS `Sub` WHERE (`Sub`.`Language` <> '.$Config['OriginalLanguage'].') AND (`Sub`.`Entry` = `O`.`Entry`))';
    551551    $where .= ' AND (';
     552    if (array_search('the' , $ArrStr)) $where .= '(`O`.`'.$Column.'` LIKE "The %") OR ';
    552553   
    553554    $SqlOK = false;
     
    555556      for($i = 0; $i < count($ArrStr); $i++)
    556557      {
    557        // if (strpos($ArrStr[$i],"'s") > 0)     $ArrStr[$i] = substr($ArrStr[$i],0,strlen($ArrStr[$i])-2);
    558       //  if (strpos($ArrStr[$i],',') > 0) $ArrStr[$i] = substr($ArrStr[$i],0,strlen($ArrStr[$i])-1);
    559        // if (strpos($ArrStr[$i],'.') > 0) $ArrStr[$i] = substr($ArrStr[$i],0,strlen($ArrStr[$i])-1);
    560        // if (strpos($ArrStr[$i],'!') > 0) $ArrStr[$i] = substr($ArrStr[$i],0,strlen($ArrStr[$i])-1);
    561        // if (strpos($ArrStr[$i],'?') > 0) $ArrStr[$i] = substr($ArrStr[$i],0,strlen($ArrStr[$i])-1);
    562 
    563         if (strlen($ArrStr[$i]) > 4) {
    564           $where .= '(`O`.`'.$Column.'` LIKE "%'.addslashes($ArrStr[$i]).'%") OR ';
     558
     559        //find word only if is 3 characters and more, and if starts by upper char, and search only once
     560        if ((strlen($ArrStr[$i]) > 3) and (ctype_upper(substr($ArrStr[$i],0,1))) and (array_search($ArrStr[$i], $ArrStr) == $i)) {
     561          $where .= '(`O`.`'.$Column.'` LIKE "'.addslashes($ArrStr[$i]).'%") OR ';
    565562          $SqlOK = true;
    566563        }
Note: See TracChangeset for help on using the changeset viewer.