Ignore:
Timestamp:
Mar 6, 2023, 12:16:38 PM (22 months ago)
Author:
chronos
Message:
  • Fixed: Export error due to PHP 8.1 deprecated code.
  • Modified: Code cleanup.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Modules/Export/CreateAddon.php

    r893 r894  
    66{
    77  // Replace special codes by lua functions
    8   function ReplaceVarInText($string, $strlower = 'strlower')
     8  function ReplaceVarInText(string $string, string $strlower = 'strlower'): string
    99  {
    1010    $string = str_replace('$N', '"..'.$strlower.'(UnitName("player")).."', $string);
     
    4747  }
    4848
    49   function ReplaceEnText($string)
    50   {
    51     //  $string = mysql_escape_string($string);
     49  function ReplaceEnText(string $string): string
     50  {
    5251    $string = strtolower($string);
    53 
    5452    $string = str_replace('"', '\"', $string);
    5553    $string = str_replace('$b$b', ' ', $string);
     
    6260    $string = str_replace('\\n', ' ', $string);
    6361    $string = str_replace(' ', '', $string);
    64 //    while (strpos($string, '  '))
    65 //      $string = str_replace('  ', ' ', $string);
    6662    return $string;
    6763  }
    6864
    69   function ReplaceCzText($string)
     65  function ReplaceCzText(string $string): string
    7066  {
    7167    $string = $this->Database->real_escape_string($string);
     
    7672  }
    7773
    78   function NotCancel($string)
    79   {
    80     //echo (strpos($string,'<html>'));
     74  function NotCancel(string $string): bool
     75  {
    8176    if (strpos($string,'<html>') > -1) return false;
    8277      else return true;
    8378  }
    8479
    85   function my_trim($string)
     80  function my_trim(string $string): string
    8681  {
    8782    $string = addslashes($string);
     
    9994  }
    10095
    101   function MakeLanguageFiles()
    102   {
    103     global $CreatedFileList;
    104 
     96  function MakeLanguageFiles(): string
     97  {
    10598    $TranslationTree = $this->System->ModuleManager->Modules['Translation']->GetTranslationTree();
    10699
     
    116109    while ($Group = $DbResult->fetch_assoc())
    117110    {
    118     //získání čísla verze pro export
     111      // získání čísla verze pro export
    119112      $ID = $this->Database->query('SELECT LastVersion FROM `Group` WHERE Id = '.$Group['Id']);
    120113      $LastVersion = $ID->fetch_assoc();
     
    141134        $TableTexts = array();
    142135
    143         //old version
    144         //get version before
     136        // old version
     137        // get version before
    145138        $BuildNumber = $ExportVersion;
    146139        if ($ExportVersion == '') $BuildNumber = $this->ClientVersion['BuildNumber'];
     
    152145          $ExportVersionOld = $ExportVersionOld['BuildNumber'];
    153146
    154           $DbResult2 = $this->Database->query($this->BuildQuery($Group,$ExportVersionOld));
     147          $DbResult2 = $this->Database->query($this->BuildQuery($Group, $ExportVersionOld));
    155148          while ($Line = $DbResult2->fetch_assoc())
    156149          {
    157             $en = trim($this->ReplaceEnText($Line['En'.$Column['Column']]));
    158             $cz = $this->ReplaceCzText($Line[$Column['Column']]);
     150            $Text = $Line['En'.$Column['Column']];
     151            if ($Text == null) $Text = '';
     152            $en = trim($this->ReplaceEnText($Text));
     153            $Text = $Line[$Column['Column']];
     154            if ($Text == null) $Text = '';
     155            $cz = $this->ReplaceCzText($Text);
    159156            if (($en <> '') and ($cz <> '') and ($this->NotCancel($en)))
    160157            {
     
    165162        //last version
    166163
    167         $DbResult2 = $this->Database->query($this->BuildQuery($Group,$ExportVersion));
     164        $DbResult2 = $this->Database->query($this->BuildQuery($Group, $ExportVersion));
    168165        while ($Line = $DbResult2->fetch_assoc())
    169166        {
    170           $en = trim($this->ReplaceEnText($Line['En'.$Column['Column']]));
    171           $cz = $this->ReplaceCzText($Line[$Column['Column']]);
     167          $Text = $Line['En'.$Column['Column']];
     168          if ($Text == null) $Text = '';
     169          $en = trim($this->ReplaceEnText($Text));
     170          $Text = $Line[$Column['Column']];
     171          if ($Text == null) $Text = '';
     172          $cz = $this->ReplaceCzText($Text);
    172173          if (($en <> '') and ($cz <> '') and ($this->NotCancel($en)))
    173174          {
     
    221222  }
    222223
    223   function MakeClientStrings()
     224  function MakeClientStrings(): void
    224225  {
    225226    $TranslationTree = $this->System->ModuleManager->Modules['Translation']->GetTranslationTree();
     
    232233
    233234    $DbResult = $this->Database->query('SELECT `Group`.* FROM `ExportGroup` JOIN `Group` ON `Group`.`Id` = `ExportGroup`.`Group` WHERE `ExportGroup`.`Export`='.$this->Id.' AND `Group`.`TablePrefix` != "" AND `Group`.`Id` = 14');
    234     //$Group = $DbResult->fetch_assoc();
    235235    if ($DbResult->num_rows == 0)
    236236      $CanGenerated = '-1';
     
    255255  }
    256256
    257   function MakeAddon()
     257  function MakeAddon(): string
    258258  {
    259259    if (!file_exists($this->TempDir)) mkdir($this->TempDir, 0777, true);
     
    264264  }
    265265
    266   function MakeReadme()
     266  function MakeReadme(): void
    267267  {
    268268    $DbResult = $this->Database->query('SELECT * FROM `CzWoWPackageVersion` ORDER BY `Date` DESC');
Note: See TracChangeset for help on using the changeset viewer.