Ignore:
Timestamp:
Aug 26, 2013, 9:49:06 PM (11 years ago)
Author:
chronos
Message:
  • Fixed: Configurable relative path to data source directory.
  • Added: Link to show directly user export from profile page.
File:
1 edited

Legend:

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

    r564 r571  
    1111  var $ClientVersion;
    1212  var $OrderByUserList;
     13  var $TempDir;
     14  var $SourceDir;
    1315 
    1416  function Init()
    1517  {
    1618    $this->TempDir = dirname(__FILE__).'/../../'.$this->Config['Web']['TempFolder'].'Export/'.$this->Id.'/';
     19    if(!file_exists($this->TempDir)) mkdir($this->TempDir, 0777, true);
    1720    $this->TempDirRelative = $this->Config['Web']['TempFolder'].'Export/'.$this->Id.'/';
    18     if(!file_exists($this->TempDir)) mkdir($this->TempDir, 0777, true);
     21    $this->SourceDir = dirname(__FILE__).'/../../'.$this->Config['Web']['SourceFolder'];
     22    $this->SourceDirRelative = $this->Config['Web']['SourceFolder'];
     23    if(!file_exists($this->SourceDir)) mkdir($this->SourceDir, 0777, true);
    1924  }
    2025 
     
    2732    // Filter selected users
    2833    $this->UserNames = '';
    29     $DbResult = $this->Database->query('SELECT `ExportUser`.*, `User`.`Name`, `User`.`ID` FROM `ExportUser` LEFT JOIN `User` ON `User`.`ID`=`ExportUser`.`User` WHERE `ExportUser`.`Export`='.$this->Id.' ORDER BY `ExportUser`.`Sequence`');
     34    $DbResult = $this->Database->query('SELECT `ExportUser`.*, `User`.`Name`, `User`.`ID` FROM `ExportUser` '.
     35        'LEFT JOIN `User` ON `User`.`ID`=`ExportUser`.`User` '.
     36        'WHERE `ExportUser`.`Export`='.$this->Id.' ORDER BY `ExportUser`.`Sequence`');
    3037    while($UserLine = $DbResult->fetch_assoc())
    3138    {
     
    9097      "-- Generované tabulky: ";
    9198   
    92     $DbResult = $this->Database->query('SELECT `Group`.* FROM `ExportGroup` JOIN `Group` ON `Group`.`Id` = `ExportGroup`.`Group` WHERE `ExportGroup`.`Export`='.$this->Id);
     99    $DbResult = $this->Database->query('SELECT `Group`.* FROM `ExportGroup` '.
     100        'JOIN `Group` ON `Group`.`Id` = `ExportGroup`.`Group` WHERE `ExportGroup`.`Export`='.$this->Id);
    93101    while($Group = $DbResult->fetch_assoc())
    94102    {
     
    97105    $Buffer .= "\n\n"; 
    98106
    99     $DbResult = $this->Database->query('SELECT `Group`.* FROM `ExportGroup` JOIN `Group` ON `Group`.`Id` = `ExportGroup`.`Group` WHERE `ExportGroup`.`Export`='.$this->Id);
     107    $DbResult = $this->Database->query('SELECT `Group`.* FROM `ExportGroup` '.
     108        'JOIN `Group` ON `Group`.`Id` = `ExportGroup`.`Group` WHERE `ExportGroup`.`Export`='.$this->Id);
    100109    while($Group = $DbResult->fetch_assoc())
    101110    {
     
    215224    "  <translation>\n";
    216225
    217     $DbResult = $this->Database->query('SELECT `Group`.* FROM `ExportGroup` JOIN `Group` ON `Group`.`Id` = `ExportGroup`.`Group` WHERE `ExportGroup`.`Export`='.$this->Id);
     226    $DbResult = $this->Database->query('SELECT `Group`.* FROM `ExportGroup` '.
     227        'JOIN `Group` ON `Group`.`Id` = `ExportGroup`.`Group` WHERE `ExportGroup`.`Export`='.$this->Id);
    218228    while($Group = $DbResult->fetch_assoc())
    219229    {
     
    233243          if($GroupItem['MangosColumn'] == '') $GroupItem['MangosColumn'] = $GroupItem['Column'];
    234244          if($Line[$GroupItem['Column']] != '')
    235           $Buffer .= '        <text index="'.$GroupItem['Id'].'" name="'.$GroupItem['Column'].'">'.addslashes($Line[$GroupItem['Column']]).'</text>'."\n";
     245          $Buffer .= '        <text index="'.$GroupItem['Id'].'" name="'.
     246            $GroupItem['Column'].'">'.addslashes($Line[$GroupItem['Column']]).'</text>'."\n";
    236247        }
    237248        $Buffer .= "      </item>\n";
     
    251262    $this->LoadFilters();
    252263       
    253     $DbResult = $this->Database->query('SELECT `Group`.* FROM `ExportGroup` JOIN `Group` ON `Group`.`Id` = `ExportGroup`.`Group` WHERE `ExportGroup`.`Export`='.$this->Id.' AND `Group`.`DBCFileName` != ""');
     264    $DbResult = $this->Database->query('SELECT `Group`.* FROM `ExportGroup` '.
     265        'JOIN `Group` ON `Group`.`Id` = `ExportGroup`.`Group` '.
     266        'WHERE `ExportGroup`.`Export`='.$this->Id.' AND `Group`.`DBCFileName` != ""');
    254267    $Output = 'Počet generovaných skupin: '.$DbResult->num_rows."\n";
    255268    while($Group = $DbResult->fetch_assoc())
    256269    {
    257270      $Output .= $Group['Name'].', ';
    258       if(file_exists('../source/'.$this->ClientVersion['Version'].'/dbc/'.$Group['DBCFileName'].'.dbc'))
     271      if(file_exists($this->SourceDir.$this->ClientVersion['Version'].'/dbc/'.$Group['DBCFileName'].'.dbc'))
    259272      {
    260273        // Load string column index list
    261         $DbResult2 = $this->Database->query('SELECT * FROM `GroupItem` JOIN `GroupItemDBC` ON `GroupItem`.`Id` = `GroupItemDBC`.`GroupItem` AND `GroupItemDBC`.`ClientVersion` = '.$this->ClientVersion['Id'].'  WHERE `GroupItem`.`Group` = '.$Group['Id']);     
     274        $DbResult2 = $this->Database->query('SELECT * FROM `GroupItem` '.
     275                'JOIN `GroupItemDBC` ON `GroupItem`.`Id` = `GroupItemDBC`.`GroupItem` AND `GroupItemDBC`.`ClientVersion` = '.$this->ClientVersion['Id'].'  WHERE `GroupItem`.`Group` = '.$Group['Id']);     
    262276        $ColumnIndexes = array();
    263277        $ColumnFormat = array();
     
    276290        // Open original DBC file
    277291        $SourceDBCFile = new DBCFile();
    278         $SourceDBCFile->OpenFile('../source/'.$this->ClientVersion['Version'].'/dbc/'.$Group['DBCFileName'].'.dbc', $ColumnFormat);
     292        $SourceDBCFile->OpenFile($this->SourceDir.$this->ClientVersion['Version'].'/dbc/'.$Group['DBCFileName'].'.dbc', $ColumnFormat);
    279293       
    280294        // Create new DBC file
     
    322336          {
    323337            $Output .= $Progress."%\r";
    324 echo($Output);
    325 $Output = '';
     338            echo($Output);
     339            $Output = '';
    326340            $OldProgress = $Progress;
    327341          }
    328342        }   
    329343        $NewDBCFile->Commit();             
    330       } else $Output .= ShowMessage('Zdrojový soubor '.'../source/'.$this->ClientVersion['Version'].'/dbc/'.$Group['DBCFileName'].'.dbc'.' nenalezen.'."\n", MESSAGE_CRITICAL);
     344      } else $Output .= ShowMessage('Zdrojový soubor '.$this->SourceDirRelative.$this->ClientVersion['Version'].'/dbc/'.$Group['DBCFileName'].'.dbc'.' nenalezen.'."\n", MESSAGE_CRITICAL);
    331345    }
    332346    $Output .= 'Hotovo <br />';
     
    347361      $Output .= $Group['Name'].'... ';
    348362      $File = new FileStream();
    349       $File->OpenFile('../source/'.$this->ClientVersion['Version'].'/lua/'.$Group['LuaFileName'].'.lua');
     363      $File->OpenFile($this->SourceDir.$this->ClientVersion['Version'].'/lua/'.$Group['LuaFileName'].'.lua');
    350364      $File2 = new FileStream();
    351365      $File2->CreateFile($this->TempDir.'lua/'.$Group['LuaFileName'].'.lua');
     
    355369      while($DbRow = $DbResult2->fetch_assoc())
    356370        $LookupTable[$DbRow['ShortCut']] = $DbRow;
    357       //print_r($LookupTable);
    358371       
    359372      while(!$File->EOF())
     
    419432    $this->Creator = 'Chronos';
    420433    $this->License = 'GNU/GPL';
    421     $this->Description = 'Allow parametric export translated texts to various supported output formats';
     434    $this->Description = 'Allow parametric export of translated texts to various supported output formats';
    422435    $this->Dependencies = array();
    423436  }
Note: See TracChangeset for help on using the changeset viewer.