Ignore:
Timestamp:
Apr 7, 2020, 10:15:48 PM (5 years ago)
Author:
chronos
Message:
  • Modified: Improved code formatting.
File:
1 edited

Legend:

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

    r861 r880  
    2525      'Icon' => '',
    2626    ), 1);
    27     if(array_key_exists('Search', $this->System->ModuleManager->Modules))
     27    if (array_key_exists('Search', $this->System->ModuleManager->Modules))
    2828      $this->System->ModuleManager->Modules['Search']->RegisterSearch('dictionary',
    2929      T('Dictionary'), array('Text', 'Description'),
     
    6565
    6666    // $buff[] = array($Line['ID'],GetIDbyName($Table),$Line[$Column],$Line['Tran']);
    67     foreach($buff as $Line)
     67    foreach ($buff as $Line)
    6868    {
    6969      if ($mode == 0)
     
    8383    }
    8484    $Output .= '</table>';
    85     return($Output);
     85    return $Output;
    8686  }
    8787
     
    8989  {
    9090    $Output = '';
    91     if($this->System->User->Licence(LICENCE_USER))
     91    if ($this->System->User->Licence(LICENCE_USER))
    9292    {
    9393      $Output .= '<form action="?action=save" method="post">'.
     
    103103        '</form>';
    104104    } else $Output .= ShowMessage(T('Access denied'), MESSAGE_CRITICAL);
    105     return($Output);
     105    return $Output;
    106106  }
    107107
    108108  function DictionarySave()
    109109  {
    110     if($this->System->User->Licence(LICENCE_USER))
    111     {
    112       if(array_key_exists('Original', $_POST) and array_key_exists('Translated', $_POST) and array_key_exists('Description', $_POST))
     110    if ($this->System->User->Licence(LICENCE_USER))
     111    {
     112      if (array_key_exists('Original', $_POST) and array_key_exists('Translated', $_POST) and array_key_exists('Description', $_POST))
    113113      {
    114114        // Check if original text exists and determine entry id
    115115        $DbResult = $this->Database->query('SELECT * FROM `Dictionary` WHERE '.
    116116          '`Text` = "'.$_POST['Original'].'" AND `Language`= '.$this->System->Config['OriginalLanguage']);
    117         if($DbResult->num_rows > 0)
     117        if ($DbResult->num_rows > 0)
    118118        {
    119119          $DbRow = $DbResult->fetch_assoc();
     
    130130        $DbResult = $this->Database->query('SELECT `Id` FROM `Dictionary` WHERE '.
    131131          '`Entry` = '.$Entry.' AND `Language`='.$_POST['Language'].' AND `User`='.$this->System->User->Id);
    132         if($DbResult->num_rows > 0)
     132        if ($DbResult->num_rows > 0)
    133133        {
    134134          $DbRow = $DbResult->fetch_assoc();
     
    142142      } else $Output = ShowMessage(T('You have to fill all column of form.'), MESSAGE_CRITICAL);
    143143    } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL);
    144     return($Output);
     144    return $Output;
    145145  }
    146146
    147147  function DictionaryRemove()
    148148  {
    149     if($this->System->User->Licence(LICENCE_USER))
     149    if ($this->System->User->Licence(LICENCE_USER))
    150150    {
    151151      $this->Database->query('DELETE FROM `Dictionary` WHERE (`User`='.$this->System->User->Id.') AND (`Id`='.($_GET['id'] * 1).')');
    152152      $Output = ShowMessage(T('Record removed'));
    153153    } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL);
    154     return($Output);
     154    return $Output;
    155155  }
    156156
    157157  function DictionaryModify()
    158158  {
    159     if($this->System->User->Licence(LICENCE_USER))
     159    if ($this->System->User->Licence(LICENCE_USER))
    160160    {
    161161      $DbResult = $this->Database->query('SELECT * FROM `Dictionary` WHERE `Id`='.($_GET['id'] * 1));
    162       if($DbResult->num_rows > 0)
     162      if ($DbResult->num_rows > 0)
    163163      {
    164164        $DbRow = $DbResult->fetch_assoc();
     
    180180      } else $Output = ShowMessage(T('Item not found'), MESSAGE_CRITICAL);
    181181    } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL);
    182     return($Output);
     182    return $Output;
    183183  }
    184184
     
    189189    $Output = '';
    190190    $GroupId = LoadGroupIdParameter();
    191     if(array_key_exists('mode', $_GET)) $mode = $_GET['mode'];
     191    if (array_key_exists('mode', $_GET)) $mode = $_GET['mode'];
    192192    else $mode = 0; //0 = exact names, 1=all names, 2=nontranslated
    193193    $Table = $TranslationTree[$GroupId]['TablePrefix'];
    194194
    195     if(array_key_exists('ID', $_GET))
     195    if (array_key_exists('ID', $_GET))
    196196    {
    197197      $TextID = $_GET['ID'];
     
    202202      $DbResult = $this->Database->query('SELECT * FROM '.$Table.' WHERE ID = '.$TextID);
    203203      $Line = $DbResult->fetch_assoc();
    204       if(!$Line) $Output .= ShowMessage(T('Translation not found'), MESSAGE_CRITICAL);
     204      if (!$Line) $Output .= ShowMessage(T('Translation not found'), MESSAGE_CRITICAL);
    205205      else
    206206      {
    207207        $Text = '';
    208         foreach($TranslationTree[$GroupId]['Items'] as $Index => $TextItem)
     208        foreach ($TranslationTree[$GroupId]['Items'] as $Index => $TextItem)
    209209          $Text .= ' '.$Line[$TextItem['Column']];
    210210        $Output .= $this->WriteTranslatNames($Text, $mode);
    211211      }
    212212    }
    213     return($Output);
     213    return $Output;
    214214  }
    215215
     
    221221      '<table style="width: 100%; height: 100%;">';
    222222
    223     if(array_key_exists('search', $_GET)) $Search = $_GET['search'];
     223    if (array_key_exists('search', $_GET)) $Search = $_GET['search'];
    224224      else $Search = '';
    225225
     
    227227      <input type="text" value="'.$Search.'" name="search" size="30" />
    228228      <input type="submit" value="'.T('Search').'" />';
    229     if($this->System->User->Licence(LICENCE_USER))
     229    if ($this->System->User->Licence(LICENCE_USER))
    230230      $Output .= ' <a href="?action=insert">'.T('Add word').'</a>';
    231231
     
    233233      '<tr><td>'.T('Language').': ';
    234234    $Lang = '<a href="?language=">'.T('All').'</a>';
    235     if($_SESSION['language'] == '') $Output .= '<strong>'.$Lang.'</strong> ';
     235    if ($_SESSION['language'] == '') $Output .= '<strong>'.$Lang.'</strong> ';
    236236      else $Output .= $Lang;
    237     foreach($LanguageList as $Language)
    238       if($Language['Enabled'] == 1)
     237    foreach ($LanguageList as $Language)
     238      if ($Language['Enabled'] == 1)
    239239      {
    240240        $Lang = ' <a href="?language='.$Language['Id'].'">'.T($Language['Name']).'</a>';
    241         if($Language['Id'] == $_SESSION['language']) $Output .= '<strong>'.$Lang.'</strong> ';
     241        if ($Language['Id'] == $_SESSION['language']) $Output .= '<strong>'.$Lang.'</strong> ';
    242242          else $Output .= $Lang;
    243243      }
     
    245245      '<tr><td>';
    246246
    247     if(!is_numeric($_SESSION['language'])) $LanguageFilter = '';
     247    if (!is_numeric($_SESSION['language'])) $LanguageFilter = '';
    248248      else $LanguageFilter = ' AND (`T1`.`Language` = '.$_SESSION['language'].')';
    249249
    250     if($Search <> '')
     250    if ($Search <> '')
    251251    {
    252252      $Condition = ' AND (LOWER(`T1`.`Text`) LIKE LOWER("%'.$Search.'%")) OR '.
     
    270270    $Output .= $PageList['Output'];
    271271
    272     if(is_numeric($_SESSION['language'])) $LanguageName = $LanguageList[$_SESSION['language']]['Name'];
     272    if (is_numeric($_SESSION['language'])) $LanguageName = $LanguageList[$_SESSION['language']]['Name'];
    273273      else $LanguageName = T('Translation');
    274274    $TableColumns = array(
     
    276276      array('Name' => 'Translated', 'Title' => T($LanguageName)),
    277277    );
    278     if(!is_numeric($_SESSION['language'])) $TableColumns[] = array('Name' => 'LangName', 'Title' => T('Language'));
     278    if (!is_numeric($_SESSION['language'])) $TableColumns[] = array('Name' => 'LangName', 'Title' => T('Language'));
    279279    $TableColumns[] = array('Name' => 'Description', 'Title' => T('Description'));
    280280    $TableColumns[] = array('Name' => 'UserName', 'Title' => T('Translator'));
    281     if($this->System->User->Licence(LICENCE_USER)) $TableColumns[] = array('Name' => '', 'Title' => T('Action'));
     281    if ($this->System->User->Licence(LICENCE_USER)) $TableColumns[] = array('Name' => '', 'Title' => T('Action'));
    282282    $Order = GetOrderTableHeader($TableColumns, 'Original');
    283283    $Output .= '<table class="BaseTable">'.$Order['Output'];
     
    285285    $sql_page = $sql.$Order['SQL'].$PageList['SQLLimit'];
    286286    $DbResult = $this->Database->query($sql_page);
    287     while($Line = $DbResult->fetch_assoc())
     287    while ($Line = $DbResult->fetch_assoc())
    288288    {
    289289      $Output .= '<tr>'.
    290290        '<td>'.htmlspecialchars($Line['Original']).'</td>'.
    291291        '<td><strong>'.htmlspecialchars($Line['Translated']).'</strong></td>';
    292       if(!is_numeric($_SESSION['language'])) $Output .= '<td>'.T($Line['LangName']).'</td>';
     292      if (!is_numeric($_SESSION['language'])) $Output .= '<td>'.T($Line['LangName']).'</td>';
    293293      $Output .= '<td>'.htmlspecialchars($Line['Description']).'</td>'.
    294294        '<td><a href="'.$this->System->Link('/user/?user='.$Line['UserId']).'">'.
    295295        $Line['UserName'].'</a></td>';
    296       if($this->System->User->Licence(LICENCE_USER))
    297       {
    298         if($Line['UserId'] == $this->System->User->Id)
     296      if ($this->System->User->Licence(LICENCE_USER))
     297      {
     298        if ($Line['UserId'] == $this->System->User->Id)
    299299          $Output .= '<td><a href="?action=remove&amp;id='.$Line['Id'].
    300300            '" onclick="return confirmAction(\''.T('Do you really want to delete item?').'\');">'.T('Delete').'</a>'.
     
    308308      '</td></tr>'.
    309309      '</table></form>';
    310     return($Output);
     310    return $Output;
    311311  }
    312312
     
    319319    $LanguageList = GetLanguageList();
    320320
    321     if(!isset($_SESSION['language']))
    322     {
    323       if($this->System->User->Licence(LICENCE_USER))
     321    if (!isset($_SESSION['language']))
     322    {
     323      if ($this->System->User->Licence(LICENCE_USER))
    324324      {
    325325        $_SESSION['language'] = $this->System->User->Language;
    326326      } else $_SESSION['language'] = '';
    327327    }
    328     if(array_key_exists('language', $_GET))
    329     {
    330       if($_GET['language'] == '') $_SESSION['language'] = '';
     328    if (array_key_exists('language', $_GET))
     329    {
     330      if ($_GET['language'] == '') $_SESSION['language'] = '';
    331331        else $_SESSION['language'] = $_GET['language'] * 1;
    332332    }
     
    335335
    336336    $ShowList = true;
    337     if(array_key_exists('action', $_GET))
    338     {
    339       if($_GET['action'] == 'group')
     337    if (array_key_exists('action', $_GET))
     338    {
     339      if ($_GET['action'] == 'group')
    340340      {
    341341        $Output .= $this->DictionaryGroup();
    342342        $ShowList = false;
    343343      }
    344       else if($_GET['action'] == 'insert') $Output .= $this->DictionaryInsert();
    345       else if($_GET['action'] == 'save') $Output .= $this->DictionarySave();
    346       else if($_GET['action'] == 'remove') $Output .= $this->DictionaryRemove();
    347       else if($_GET['action'] == 'modify') $Output .= $this->DictionaryModify();
     344      else if ($_GET['action'] == 'insert') $Output .= $this->DictionaryInsert();
     345      else if ($_GET['action'] == 'save') $Output .= $this->DictionarySave();
     346      else if ($_GET['action'] == 'remove') $Output .= $this->DictionaryRemove();
     347      else if ($_GET['action'] == 'modify') $Output .= $this->DictionaryModify();
    348348      else $Output .= ShowMessage(T('Unknown action'), MESSAGE_CRITICAL);
    349349    }
    350     if($ShowList == true) $Output .= $this->DictionaryShow();
    351     return($Output);
     350    if ($ShowList == true) $Output .= $this->DictionaryShow();
     351    return $Output;
    352352  }
    353353}
Note: See TracChangeset for help on using the changeset viewer.