Ignore:
Timestamp:
Feb 22, 2015, 11:20:50 PM (9 years ago)
Author:
chronos
Message:
  • Modified: Tabs converted to spaces.
  • Modified: Remove spaces from end of lines.
  • Added: Code format script.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Modules/Dictionary/Dictionary.php

    r809 r816  
    1313    $this->Dependencies = array();
    1414  }
    15  
     15
    1616  function Start()
    1717  {
    18         $this->System->RegisterPage('dictionary', 'PageDictionary');
    19         $this->System->RegisterMenuItem(array(
    20                 'Name' => 'Dictionary',
    21         'Title' => T('Dictionary'),
    22         'Hint' => T('Dictionary words from WoW'),
    23         'Link' => $this->System->Link('/dictionary/'),
    24         'Permission' => LICENCE_ANONYMOUS,
    25         'Icon' => '',
     18    $this->System->RegisterPage('dictionary', 'PageDictionary');
     19    $this->System->RegisterMenuItem(array(
     20      'Name' => 'Dictionary',
     21      'Title' => T('Dictionary'),
     22      'Hint' => T('Dictionary words from WoW'),
     23      'Link' => $this->System->Link('/dictionary/'),
     24      'Permission' => LICENCE_ANONYMOUS,
     25      'Icon' => '',
    2626    ), 1);
    2727    if(array_key_exists('Search', $this->System->ModuleManager->Modules))
    2828      $this->System->ModuleManager->Modules['Search']->RegisterSearch('dictionary',
    29       T('Dictionary'), array('Text', 'Description'), 
     29      T('Dictionary'), array('Text', 'Description'),
    3030     '(SELECT * FROM `Dictionary` WHERE `Language` = '.$this->System->Config['OriginalLanguage'].') AS `T`', $this->System->Link('/dictionary/?search='));
    3131  }
     
    3535{
    3636
    37 function WriteTranslatNames($Text, $mode) 
     37function WriteTranslatNames($Text, $mode)
    3838{
    3939  $Output = '';
     
    6262
    6363  $buff = GetTranslatNames($Text,$mode,GetTranslatNamesArray());
    64  
     64
    6565   // $buff[] = array($Line['ID'],GetIDbyName($Table),$Line[$Column],$Line['Tran']);
    6666  foreach($buff as $Line) {
    67       if ($mode == 0) 
    68       {
    69         if (strpos(strtolower($Text), strtolower($Line[2])) > 0) 
     67      if ($mode == 0)
     68      {
     69        if (strpos(strtolower($Text), strtolower($Line[2])) > 0)
    7070        {
    7171          $Output .= '<tr><td>'.$Line[2].'</td>';
     
    7373          else $Output .= '<td><a target="_NEW2" href="'.$this->System->Link('/form.php?group='.$Line[1].'&amp;ID='.$Line[0]).'">Překládat</a></td></tr>';
    7474        }
    75       } else 
     75      } else
    7676      {
    7777        $Output .= '<tr><td>'.$Line[2].'</td>';
     
    101101        '</form>';
    102102  } else $Output .= ShowMessage(T('Access denied'), MESSAGE_CRITICAL);
    103   return($Output); 
     103  return($Output);
    104104}
    105105
     
    125125          '`User`, `Language` ) VALUES ("'.$_POST['Original'].'", "'.$Entry.'", "", NULL, '.$this->System->Config['OriginalLanguage'].');');
    126126      }
    127  
     127
    128128      $DbResult = $this->Database->query('SELECT `Id` FROM `Dictionary` WHERE '.
    129129        '`Entry` = '.$Entry.' AND `Language`='.$_POST['Language'].' AND `User`='.$this->System->User->Id);
     
    136136        $this->Database->query('INSERT INTO `Dictionary` ( `Text` , `Entry` , `Description` , '.
    137137          '`User`, `Language` ) VALUES ("'.$_POST['Translated'].'", "'.$Entry.'", "'.
    138                 $_POST['Description'].'", '.$this->System->User->Id.', '.$_POST['Language'].')');
     138          $_POST['Description'].'", '.$this->System->User->Id.', '.$_POST['Language'].')');
    139139      $Output = ShowMessage('Záznam byl uložen!');
    140140    } else $Output = ShowMessage(T('You have to fill all column of form.'), MESSAGE_CRITICAL);
    141141  } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL);
    142   return($Output); 
     142  return($Output);
    143143}
    144144
     
    176176        '</fieldset>'.
    177177        '</form>';
    178     } else $Output = ShowMessage(T('Item not found'), MESSAGE_CRITICAL); 
     178    } else $Output = ShowMessage(T('Item not found'), MESSAGE_CRITICAL);
    179179  } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL);
    180180  return($Output);
     
    184184{
    185185  global $TranslationTree;
    186  
     186
    187187  $Output = '';
    188188  $GroupId = LoadGroupIdParameter();
     
    190190  else $mode = 0; //0 = exact names, 1=all names, 2=nontranslated
    191191  $Table = $TranslationTree[$GroupId]['TablePrefix'];
    192  
     192
    193193  if(array_key_exists('ID', $_GET))
    194194  {
     
    208208      $Output .= $this->WriteTranslatNames($Text, $mode);
    209209    }
    210   } 
     210  }
    211211  return($Output);
    212212}
     
    215215{
    216216  global $LanguageList;
    217  
     217
    218218  $Output = '<form action="?" method="get" style="margin: 0px; padding: 0px;">'.
    219219  '<table style="width: 100%; height: 100%;">';
     
    221221  if(array_key_exists('search', $_GET)) $Search = $_GET['search'];
    222222    else $Search = '';
    223        
     223
    224224  $Output .= '<tr><td>
    225225    <input type="text" value="'.$Search.'" name="search" size="30" />
    226226    <input type="submit" value="'.T('Search').'" />';
    227   if($this->System->User->Licence(LICENCE_USER)) 
    228         $Output .= ' <a href="?action=insert">'.T('Add word').'</a>';
    229            
    230   $Output .= '</td></tr>'. 
     227  if($this->System->User->Licence(LICENCE_USER))
     228    $Output .= ' <a href="?action=insert">'.T('Add word').'</a>';
     229
     230  $Output .= '</td></tr>'.
    231231    '<tr><td>'.T('Language').': ';
    232232  $Lang = '<a href="?language=">'.T('All').'</a>';
     
    236236    if($Language['Enabled'] == 1)
    237237    {
    238         $Lang = ' <a href="?language='.$Language['Id'].'">'.$Language['Name'].'</a>';
     238      $Lang = ' <a href="?language='.$Language['Id'].'">'.$Language['Name'].'</a>';
    239239      if($Language['Id'] == $_SESSION['language']) $Output .= '<strong>'.$Lang.'</strong> ';
    240240        else $Output .= $Lang;
     
    247247    else $LanguageFilter = ' AND (`T1`.`Language` = '.$_SESSION['language'].')';
    248248
    249   if($Search <> '') 
     249  if($Search <> '')
    250250  {
    251251    $Condition = ' AND (LOWER(`T1`.`Text`) LIKE LOWER("%'.$Search.'%")) OR '.
    252252      ' (LOWER(`T2`.`Text`) LIKE LOWER("%'.$Search.'%")) OR '.
    253253      '(LOWER(`T1`.`Description`) LIKE LOWER("%'.$Search.'%"))';
    254   } else $Condition = ''; 
     254  } else $Condition = '';
    255255  $sql = 'SELECT `User`.`Name` AS `UserName`, `User`.`Id` AS `UserId`, '.
    256256      '`Language`.`Name` AS `LangName`, `T1`.`Id` AS `Id`, '.
    257       '`T1`.`Entry`, `T2`.`Text` AS `Original`, `T1`.`Text` AS `Translated`, `T1`.`Description` '.   
     257      '`T1`.`Entry`, `T2`.`Text` AS `Original`, `T1`.`Text` AS `Translated`, `T1`.`Description` '.
    258258      'FROM `Dictionary` AS `T1` JOIN `Dictionary` AS `T2` '.
    259259      'ON (`T2`.`Entry` = `T1`.`Entry`) AND (`T2`.`Language` = '.$this->System->Config['OriginalLanguage'].') '.
     
    262262      'WHERE 1'.
    263263      $LanguageFilter.$Condition;
    264  
     264
    265265  $DbResult = $this->Database->query('SELECT COUNT(*) FROM ('.$sql.') AS `T1`');
    266266  $DbRow = $DbResult->fetch_row();
    267   $PageList = GetPageList($DbRow[0]); 
     267  $PageList = GetPageList($DbRow[0]);
    268268
    269269  $Output .= $PageList['Output'];
    270  
     270
    271271  if(is_numeric($_SESSION['language'])) $LanguageName = $LanguageList[$_SESSION['language']]['Name'];
    272272    else $LanguageName = 'Překlad';
    273   $TableColumns = array(     
    274     array('Name' => 'Original', 'Title' => T('English')), 
     273  $TableColumns = array(
     274    array('Name' => 'Original', 'Title' => T('English')),
    275275    array('Name' => 'Translated', 'Title' => $LanguageName),
    276   ); 
     276  );
    277277  if(!is_numeric($_SESSION['language'])) $TableColumns[] = array('Name' => 'LangName', 'Title' => T('Language'));
    278278  $TableColumns[] = array('Name' => 'Description', 'Title' => T('Description'));
    279   $TableColumns[] = array('Name' => 'UserName', 'Title' => T('Translator'));   
     279  $TableColumns[] = array('Name' => 'UserName', 'Title' => T('Translator'));
    280280  if($this->System->User->Licence(LICENCE_USER)) $TableColumns[] = array('Name' => '', 'Title' => T('Action'));
    281281  $Order = GetOrderTableHeader($TableColumns, 'Original');
     
    284284  $sql_page = $sql.$Order['SQL'].$PageList['SQLLimit'];
    285285  $DbResult = $this->Database->query($sql_page);
    286   while($Line = $DbResult->fetch_assoc()) 
     286  while($Line = $DbResult->fetch_assoc())
    287287  {
    288288    $Output .= '<tr>'.
     
    294294    if($this->System->User->Licence(LICENCE_USER))
    295295    {
    296       if($Line['UserId'] == $this->System->User->Id) 
     296      if($Line['UserId'] == $this->System->User->Id)
    297297        $Output .= '<td><a href="?action=remove&amp;id='.$Line['Id'].'" onclick="return confirmAction(\''.T('Do you really want to delete item?').'\');">'.T('Delete').'</a>'.
    298298        ' <a href="?action=modify&amp;id='.$Line['Id'].'">'.T('Modify').'</a></td>';
     
    301301    $Output .= '</tr>';
    302302  }
    303   $Output .= '</table>'. 
     303  $Output .= '</table>'.
    304304    $PageList['Output'].
    305     '</td></tr>'. 
     305    '</td></tr>'.
    306306    '</table></form>';
    307307  return($Output);
     
    310310function Show()
    311311{
    312         global $LanguageList;
    313        
    314         $this->Title = T('Dictionary');
    315        
     312  global $LanguageList;
     313
     314  $this->Title = T('Dictionary');
     315
    316316$LanguageList = GetLanguageList();
    317317
    318318if(!isset($_SESSION['language']))
    319319{
    320         if($this->System->User->Licence(LICENCE_USER))
    321         {
    322                 $_SESSION['language'] = $this->System->User->Language;
     320  if($this->System->User->Licence(LICENCE_USER))
     321  {
     322    $_SESSION['language'] = $this->System->User->Language;
    323323  } else $_SESSION['language'] = '';
    324324}
    325325if(array_key_exists('language', $_GET)) {
    326326  if($_GET['language'] == '') $_SESSION['language'] = '';
    327           else $_SESSION['language'] = $_GET['language'] * 1;
     327    else $_SESSION['language'] = $_GET['language'] * 1;
    328328}
    329329
     
    331331
    332332$ShowList = true;
    333 if(array_key_exists('action', $_GET)) 
     333if(array_key_exists('action', $_GET))
    334334{
    335335  if($_GET['action'] == 'group') {
     
    337337    $ShowList = false;
    338338  }
    339   else if($_GET['action'] == 'insert') $Output .= $this->DictionaryInsert(); 
    340   else if($_GET['action'] == 'save') $Output .= $this->DictionarySave(); 
     339  else if($_GET['action'] == 'insert') $Output .= $this->DictionaryInsert();
     340  else if($_GET['action'] == 'save') $Output .= $this->DictionarySave();
    341341  else if($_GET['action'] == 'remove') $Output .= $this->DictionaryRemove();
    342342  else if($_GET['action'] == 'modify') $Output .= $this->DictionaryModify();
    343   else $Output .= ShowMessage(T('Unknown action'), MESSAGE_CRITICAL); 
    344 } 
     343  else $Output .= ShowMessage(T('Unknown action'), MESSAGE_CRITICAL);
     344}
    345345if($ShowList == true) $Output .= $this->DictionaryShow();
    346346    return($Output);
Note: See TracChangeset for help on using the changeset viewer.