| 1 | <?php
|
|---|
| 2 |
|
|---|
| 3 | include_once('ExportOutput.php');
|
|---|
| 4 |
|
|---|
| 5 | define('TAB_GENERAL', 0);
|
|---|
| 6 | define('TAB_TRANSLATORS', 1);
|
|---|
| 7 | define('TAB_GROUPS', 2);
|
|---|
| 8 | define('TAB_LANGUAGES', 3);
|
|---|
| 9 | define('TAB_OUTPUT_FORMAT', 4);
|
|---|
| 10 | define('TAB_VERSION', 5);
|
|---|
| 11 | define('TAB_STAT', 6);
|
|---|
| 12 | define('TAB_OUTPUT', 7);
|
|---|
| 13 |
|
|---|
| 14 | class PageExport extends Page
|
|---|
| 15 | {
|
|---|
| 16 | function ExportList()
|
|---|
| 17 | {
|
|---|
| 18 | $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
|
|---|
| 19 | $Output = '<a href="?Action=ViewList">'.T('All').'</a>';
|
|---|
| 20 | if ($User->Licence(LICENCE_USER))
|
|---|
| 21 | {
|
|---|
| 22 | $Output .= ' <a href="?Action=ViewList&Filter=Others">'.T('Others').'</a>'.
|
|---|
| 23 | ' <a href="?Action=ViewList&Filter=My">'.T('Mine').'</a>';
|
|---|
| 24 | }
|
|---|
| 25 |
|
|---|
| 26 | if ($User->Licence(LICENCE_USER))
|
|---|
| 27 | $Output .= '<br/><div style="text-align: center;"><a href="?Action=Create">'.T('Create new export').'</a></div><br/>';
|
|---|
| 28 |
|
|---|
| 29 | $Filter = '';
|
|---|
| 30 | if (array_key_exists('Filter', $_GET))
|
|---|
| 31 | {
|
|---|
| 32 | if ($_GET['Filter'] == 'My') $Filter = ' WHERE `Export`.`User` = '.$User->Id;
|
|---|
| 33 | if ($_GET['Filter'] == 'Others') $Filter = ' WHERE `Export`.`User` != '.$User->Id;
|
|---|
| 34 | }
|
|---|
| 35 |
|
|---|
| 36 | $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM `Export` '.$Filter);
|
|---|
| 37 | $DbRow = $DbResult->fetch_row();
|
|---|
| 38 | $PageList = GetPageList($DbRow[0]);
|
|---|
| 39 |
|
|---|
| 40 | $Output .= '<h3>'.T('List of export').'</h3>'.
|
|---|
| 41 | $PageList['Output'];
|
|---|
| 42 |
|
|---|
| 43 | $TableColumns = array(
|
|---|
| 44 | array('Name' => 'TimeCreate', 'Title' => T('Time made')),
|
|---|
| 45 | array('Name' => 'UserName', 'Title' => T('Translator')),
|
|---|
| 46 | array('Name' => 'Title', 'Title' => T('Name od export')),
|
|---|
| 47 | // array('Name' => 'UserCount', 'Title' => 'Vybraných překladatelů'),
|
|---|
| 48 | // array('Name' => 'GroupCount', 'Title' => 'Překladových skupin'),
|
|---|
| 49 | array('Name' => 'OutputType', 'Title' => T('Type of output')),
|
|---|
| 50 | array('Name' => 'ClientVersion', 'Title' => T('Client version')),
|
|---|
| 51 | array('Name' => 'UsedCount', 'Title' => T('Viewed count')),
|
|---|
| 52 | array('Name' => '', 'Title' => T('Action')),
|
|---|
| 53 | );
|
|---|
| 54 | $Order = GetOrderTableHeader($TableColumns, 'TimeCreate', 1);
|
|---|
| 55 | $Output .= '<table class="BaseTable">'.
|
|---|
| 56 | $Order['Output'];
|
|---|
| 57 |
|
|---|
| 58 | $DbResult = $this->System->Database->query('SELECT `User`.`Name` AS `UserName`, `Export`.`Id`, `Export`.`TimeCreate`, `Export`.`Title`, `Export`.`User`, `Export`.`UsedCount`, '.
|
|---|
| 59 | '(SELECT Version FROM `ClientVersion` WHERE `ClientVersion`.`Id`=`Export`.`ClientVersion`) AS `ClientVersion`, '.
|
|---|
| 60 | '(SELECT Id FROM `ClientVersion` WHERE `ClientVersion`.`Id`=`Export`.`ClientVersion`) AS `ClientVersionId`, '.
|
|---|
| 61 | '(SELECT Name FROM `ExportOutputType` WHERE `ExportOutputType`.`Id`=`Export`.`OutputType`) AS `OutputType`, '.
|
|---|
| 62 | '(SELECT COUNT(*) FROM `ExportGroup` WHERE `ExportGroup`.`Export`=`Export`.`Id`) AS `GroupCount`, '.
|
|---|
| 63 | '(SELECT COUNT(*) FROM `ExportUser` WHERE `ExportUser`.`Export`=`Export`.`Id`) AS `UserCount` FROM `Export` '.
|
|---|
| 64 | 'LEFT JOIN `User` ON `User`.`ID`=`Export`.`User` '.$Filter.$Order['SQL'].$PageList['SQLLimit']);
|
|---|
| 65 | while ($Export = $DbResult->fetch_assoc())
|
|---|
| 66 | {
|
|---|
| 67 | $Action = '<a href="?Action=View&ExportId='.$Export['Id'].'&Tab=0">'.T('View').'</a> '.
|
|---|
| 68 | '<a href="?Action=View&ExportId='.$Export['Id'].'&Tab=7">'.T('Make export').'</a>';
|
|---|
| 69 | if ($Export['User'] == $User->Id) $Action .= ' <a href="?Action=Delete&ExportId='.$Export['Id'].'" onclick="return confirmAction(\''.T('Realy delete item?').'\');">'.T('Delete').'</a>';
|
|---|
| 70 | if ($User->Id != null) $Action .= ' <a href="?Action=Clone&ExportId='.$Export['Id'].'" onclick="return confirmAction(\''.T('Realy clone item?').'\');">'.T('Clone').'</a>';
|
|---|
| 71 | $Output .= '<tr><td>'.HumanDate($Export['TimeCreate']).'</td>'.
|
|---|
| 72 | '<td><a href="'.$this->System->Link('/user/?user='.$Export['User']).'">'.$Export['UserName'].'</a></td>'.
|
|---|
| 73 | '<td>'.htmlspecialchars($Export['Title']).'</td>'.
|
|---|
| 74 | '<td>'.$Export['OutputType'].'</td>'.
|
|---|
| 75 | '<td><a href="'.$this->System->Link('/client-version/?action=item&id='.$Export['ClientVersionId']).'">'.$Export['ClientVersion'].'</a></td>'.
|
|---|
| 76 | '<td>'.$Export['UsedCount'].'</td>'.
|
|---|
| 77 | '<td>'.$Action.'</td></tr>';
|
|---|
| 78 | }
|
|---|
| 79 | $Output .= '</table>'.
|
|---|
| 80 | $PageList['Output'];
|
|---|
| 81 |
|
|---|
| 82 | return $Output;
|
|---|
| 83 | }
|
|---|
| 84 |
|
|---|
| 85 | function ExportCreate()
|
|---|
| 86 | {
|
|---|
| 87 | $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
|
|---|
| 88 | if ($User->Licence(LICENCE_USER))
|
|---|
| 89 | {
|
|---|
| 90 | $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM `Export` WHERE `User`='.$User->Id);
|
|---|
| 91 | $DbRow = $DbResult->fetch_row();
|
|---|
| 92 | if ($DbRow[0] < Core::Cast($this->System)->Config['MaxExportPerUser'])
|
|---|
| 93 | {
|
|---|
| 94 | $Output = '<form action="?Action=CreateFinish" method="post">'.
|
|---|
| 95 | '<fieldset><legend>'.T('Creation of new export').'</legend>'.
|
|---|
| 96 | '<table><tr><td>'.T('Identification').':</td><td><input type="text" name="Title" /></td></tr>'.
|
|---|
| 97 | '<tr><td>'.T('Description').':</td><td><textarea name="Description" cols="54" rows="10"></textarea></td></tr>'.
|
|---|
| 98 | '<tr><td colspan="2"><input type="submit" value="'.T('Create').'" /></td></tr>'.
|
|---|
| 99 | '</table></fieldset></form>';
|
|---|
| 100 | } else $Output = ShowMessage(sprintf(T('You can\'t create another export. Max for one user is %d.'), Core::Cast($this->System)->Config['MaxExportPerUser']), MESSAGE_CRITICAL);
|
|---|
| 101 | } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL);
|
|---|
| 102 | return $Output;
|
|---|
| 103 | }
|
|---|
| 104 |
|
|---|
| 105 | function ExportCreateFinish()
|
|---|
| 106 | {
|
|---|
| 107 | $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
|
|---|
| 108 | if ($User->Licence(LICENCE_USER))
|
|---|
| 109 | {
|
|---|
| 110 | if (array_key_exists('Title', $_POST) and array_key_exists('Description', $_POST))
|
|---|
| 111 | {
|
|---|
| 112 | $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM `Export` WHERE `User`='.$User->Id);
|
|---|
| 113 | $DbRow = $DbResult->fetch_row();
|
|---|
| 114 | if ($DbRow[0] < Core::Cast($this->System)->Config['MaxExportPerUser'])
|
|---|
| 115 | {
|
|---|
| 116 | $this->System->Database->query('INSERT INTO `Export` (`Title`, `User`, `TimeCreate`, `WithDiacritic`, `Description`) VALUES ("'.$_POST['Title'].'", '.$User->Id.', NOW(), 1, "'.$_POST['Description'].'")');
|
|---|
| 117 | $ExportId = $this->System->Database->insert_id;
|
|---|
| 118 | $Output = ShowMessage(T('New export created.<br />Direct link to export').': <a href="?Action=View&ExportId='.$ExportId.'">'.T('here').'</a>');
|
|---|
| 119 | $this->System->ModuleManager->Modules['Log']->WriteLog(T('New export created').' <a href="'.$this->System->Link('/export/?Action=View&ExportId='.$ExportId).'">'.$ExportId.'</a>.', LOG_TYPE_EXPORT);
|
|---|
| 120 | $_GET['Filter'] = 'my';
|
|---|
| 121 | $this->ExportList();
|
|---|
| 122 | } else $Output = ShowMessage(sprintf(T('You can\'t create another export. Max for one user is %d.'), Core::Cast($this->System)->Config['MaxExportPerUser']), MESSAGE_CRITICAL);
|
|---|
| 123 | } else $Output = ShowMessage(T('Missing data in form.'), MESSAGE_CRITICAL);
|
|---|
| 124 | } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL);
|
|---|
| 125 | return $Output;
|
|---|
| 126 | }
|
|---|
| 127 |
|
|---|
| 128 | function ExportDelete()
|
|---|
| 129 | {
|
|---|
| 130 | $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
|
|---|
| 131 | if ($User->Licence(LICENCE_USER))
|
|---|
| 132 | {
|
|---|
| 133 | $DbResult = $this->System->Database->query('SELECT * FROM `Export` WHERE (`Id`='.($_GET['ExportId'] * 1).') AND (`User`='.$User->Id.')');
|
|---|
| 134 | if ($DbResult->num_rows > 0)
|
|---|
| 135 | {
|
|---|
| 136 | $this->System->Database->query('DELETE FROM `ExportGroup` WHERE `Export`='.$_GET['ExportId']);
|
|---|
| 137 | $this->System->Database->query('DELETE FROM `ExportGroupItem` WHERE `Export`='.$_GET['ExportId']);
|
|---|
| 138 | $this->System->Database->query('DELETE FROM `ExportLanguage` WHERE `Export`='.$_GET['ExportId']);
|
|---|
| 139 | $this->System->Database->query('DELETE FROM `ExportTask` WHERE `Export`='.$_GET['ExportId']);
|
|---|
| 140 | $this->System->Database->query('DELETE FROM `ExportUser` WHERE `Export`='.$_GET['ExportId']);
|
|---|
| 141 | $this->System->Database->query('DELETE FROM `Export` WHERE `Id`='.$_GET['ExportId']);
|
|---|
| 142 | DeleteDirectory('../tmp/Export/'.$_GET['ExportId'].'/');
|
|---|
| 143 | $Output = ShowMessage(T('Export deleted.'));
|
|---|
| 144 | $_GET['Filter'] = 'my';
|
|---|
| 145 | $this->System->ModuleManager->Modules['Log']->WriteLog('Smazán export '.$_GET['ExportId'], LOG_TYPE_EXPORT);
|
|---|
| 146 | $Output .= $this->ExportList();
|
|---|
| 147 | } else $Output = ShowMessage(T('Export not found.'), MESSAGE_CRITICAL);
|
|---|
| 148 | } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL);
|
|---|
| 149 | return $Output;
|
|---|
| 150 | }
|
|---|
| 151 |
|
|---|
| 152 | function SaveAllUsers()
|
|---|
| 153 | {
|
|---|
| 154 | $Export = new Export($this->System);
|
|---|
| 155 | $Export->Id = $_GET['ExportId'];
|
|---|
| 156 | $Export->SaveAllUsers();
|
|---|
| 157 | }
|
|---|
| 158 |
|
|---|
| 159 | function ExportViewTranslators()
|
|---|
| 160 | {
|
|---|
| 161 | $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
|
|---|
| 162 |
|
|---|
| 163 | $Output = '';
|
|---|
| 164 | $DisabledInput = array(false => ' disabled="disabled"', true => '');
|
|---|
| 165 | $DbResult = $this->System->Database->query('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']);
|
|---|
| 166 | $Export = $DbResult->fetch_assoc();
|
|---|
| 167 | if ($User->Licence(LICENCE_USER) and ($User->Id == $Export['User'])) $Editable = true;
|
|---|
| 168 | else $Editable = false;
|
|---|
| 169 |
|
|---|
| 170 | if (array_key_exists('Operation', $_POST))
|
|---|
| 171 | {
|
|---|
| 172 | if ($_POST['Operation'] == 'Save')
|
|---|
| 173 | {
|
|---|
| 174 | // Update user selection page
|
|---|
| 175 | foreach ($_POST as $Index => $Value)
|
|---|
| 176 | {
|
|---|
| 177 | if (substr($Index, 0, 3) == 'seq')
|
|---|
| 178 | {
|
|---|
| 179 | $UserId = substr($Index, 3) * 1;
|
|---|
| 180 | if (array_key_exists('sel'.$UserId, $_POST)) $Selected = true;
|
|---|
| 181 | else $Selected = false;
|
|---|
| 182 | $Condition = ' WHERE `Export`='.$_GET['ExportId'].' AND `User`='.$UserId;
|
|---|
| 183 | $DbResult = $this->System->Database->query('SELECT * FROM `ExportUser` '.$Condition);
|
|---|
| 184 | if ($DbResult->num_rows > 0)
|
|---|
| 185 | {
|
|---|
| 186 | if (!$Selected) $this->System->Database->query('DELETE FROM `ExportUser` '.$Condition);
|
|---|
| 187 | else $this->System->Database->query('UPDATE `ExportUser` SET `Sequence`='.$Value.$Condition);
|
|---|
| 188 | } else
|
|---|
| 189 | {
|
|---|
| 190 | if ($Selected) $this->System->Database->query('INSERT INTO `ExportUser` (`Export`, `User`, `Sequence`) VALUES ('.$_GET['ExportId'].', '.$UserId.', '.$Value.')');
|
|---|
| 191 | }
|
|---|
| 192 | }
|
|---|
| 193 | }
|
|---|
| 194 |
|
|---|
| 195 | if (array_key_exists('AllUsers', $_POST))
|
|---|
| 196 | {
|
|---|
| 197 | //add allusers to export
|
|---|
| 198 | $this->System->Database->query('UPDATE `Export` SET `AllUsers`=1 WHERE `Id`='.$_GET['ExportId']);
|
|---|
| 199 |
|
|---|
| 200 | //update export stat
|
|---|
| 201 | $Export['AllUsers'] = 1;
|
|---|
| 202 | $this->SaveAllUsers();
|
|---|
| 203 | } else
|
|---|
| 204 | {
|
|---|
| 205 | //update export stat
|
|---|
| 206 | $Export['AllUsers'] = 0;
|
|---|
| 207 | $this->System->Database->query('UPDATE `Export` SET `AllUsers`=0 WHERE `Id`='.$_GET['ExportId']);
|
|---|
| 208 | }
|
|---|
| 209 |
|
|---|
| 210 | // Recalculate sequence number
|
|---|
| 211 | $this->System->Database->query('SET @I = 0');
|
|---|
| 212 | $this->System->Database->query('UPDATE `ExportUser` SET `Sequence` = (@I := @I + 1) WHERE `Export`='.$_GET['ExportId'].' ORDER BY `Sequence`;');
|
|---|
| 213 | $Output .= ShowMessage(T('Select saved.'));
|
|---|
| 214 | }
|
|---|
| 215 | }
|
|---|
| 216 |
|
|---|
| 217 | $TableColumns = array(
|
|---|
| 218 | array('Name' => 'Name', 'Title' => T('Name')),
|
|---|
| 219 | array('Name' => 'TranslatedCount', 'Title' => T('Translated count')),
|
|---|
| 220 | array('Name' => 'XP', 'Title' => T('Level')),
|
|---|
| 221 | array('Name' => 'XP', 'Title' => T('Experience')),
|
|---|
| 222 | array('Name' => '', 'Title' => T('Select')),
|
|---|
| 223 | array('Name' => 'Sequence2', 'Title' => T('Order')),
|
|---|
| 224 | );
|
|---|
| 225 | $Order = GetOrderTableHeader($TableColumns, 'TranslatedCount', 1);
|
|---|
| 226 | if ($Order['Column'] != 'Sequence2') $InitialOrder = ', '.substr($Order['SQL'], 10);
|
|---|
| 227 | else $InitialOrder = '';
|
|---|
| 228 |
|
|---|
| 229 | $Query = 'SELECT (@I := @I + 1) AS `Sequence2`, `TT`.* FROM (SELECT `ExportUser`.`Sequence`, `T`.`ID`, `T`.`TranslatedCount`, `T`.`Name`, `T`.`XP` FROM (SELECT `User`.`ID`, `User`.`Name`, `User`.`XP`, `TranslatedCount` FROM `User`) AS T';
|
|---|
| 230 | $Query .=' LEFT JOIN `ExportUser` ON `ExportUser`.`Export` = '.$_GET['ExportId'].' AND `ExportUser`.`User`=`T`.`ID`';
|
|---|
| 231 | $Query .=' WHERE `T`.`TranslatedCount` > 0 ORDER BY COALESCE(`ExportUser`.`Sequence`, 100000000)'.$InitialOrder.') AS `TT`';
|
|---|
| 232 |
|
|---|
| 233 | $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM ('.$Query.') AS `X`');
|
|---|
| 234 | $DbRow = $DbResult->fetch_row();
|
|---|
| 235 | $PageList = GetPageList($DbRow[0]);
|
|---|
| 236 |
|
|---|
| 237 | $Output .= '<form name="Translators" action="?Action=View&ExportId='.$_GET['ExportId'].'" method="post">'.
|
|---|
| 238 | '<h3>'.T('Translators').'</h3>';
|
|---|
| 239 | if ($Editable)
|
|---|
| 240 | {
|
|---|
| 241 | $Output .= '<input type="submit" value="'.T('Save').'" '.$DisabledInput[$Editable].'/>'.
|
|---|
| 242 | '<input type="hidden" name="Operation" value="Save"/><br />'.
|
|---|
| 243 | ' <span onclick="CheckAllCheckbox();">'.CheckBox('CheckAll', False, 'CheckAll').' '.T('Select all on page').'</span> <br />'.
|
|---|
| 244 | ' <span>'.CheckBox('AllUsers', $Export['AllUsers']).' '.T('Export allways from all users').'</span> '.
|
|---|
| 245 | '<br />'.
|
|---|
| 246 | T('Select users from list which you want to export from. And edit their order.').'<br />'.
|
|---|
| 247 | T('Order is done by numeric value which is can be edit to desirable order. Lines with same number will be renumbered in ascending order.');
|
|---|
| 248 | }
|
|---|
| 249 |
|
|---|
| 250 | $Output .= $PageList['Output'].
|
|---|
| 251 | '<table class="BaseTable">'.
|
|---|
| 252 | $Order['Output'];
|
|---|
| 253 |
|
|---|
| 254 | $Query = 'SELECT * FROM ('.$Query.') AS `TX` '.$Order['SQL'].$PageList['SQLLimit'];
|
|---|
| 255 | $this->System->Database->query('SET @I = 0');
|
|---|
| 256 | $DbResult = $this->System->Database->query($Query);
|
|---|
| 257 | while ($UserLine = $DbResult->fetch_assoc())
|
|---|
| 258 | {
|
|---|
| 259 | $XP = GetLevelMinMax($UserLine['XP']);
|
|---|
| 260 | $Checked = $UserLine['Sequence'] != '';
|
|---|
| 261 | $Selection = CheckBox('sel'.$UserLine['ID'], $Checked, '', 'CheckBox', ((!$Editable) or ($Export['AllUsers'])));
|
|---|
| 262 | $Sequence = '<input type="text" name="seq'.$UserLine['ID'].'" style="text-align: center; width: 40px;" value="'.$UserLine['Sequence2'].'"'.$DisabledInput[$Editable].'/>';
|
|---|
| 263 | $Output .= '<tr>'.
|
|---|
| 264 | '<td><a href="'.$this->System->Link('/TranslationList.php?user='.$UserLine['ID'].'&state=2&group=0').'" title="Zobrazit všechny jeho přeložené texty">'.$UserLine['Name'].'</a></td>'.
|
|---|
| 265 | '<td>'.$UserLine['TranslatedCount'].'</td>'.
|
|---|
| 266 | '<td>'.$XP['Level'].'</td>'.
|
|---|
| 267 | '<td>'.ProgressBar(150, round($XP['XP'] / $XP['MaxXP'] * 100, 2), $XP['XP'].' / '.$XP['MaxXP']).'</td>'.
|
|---|
| 268 | '<td>'.$Selection.'</td><td>'.$Sequence.'</td></tr>';
|
|---|
| 269 | }
|
|---|
| 270 | $Output .= '</table>'.
|
|---|
| 271 | '</form>'.
|
|---|
| 272 | $PageList['Output'];
|
|---|
| 273 | return $Output;
|
|---|
| 274 | }
|
|---|
| 275 |
|
|---|
| 276 | function ExportViewGeneral()
|
|---|
| 277 | {
|
|---|
| 278 | $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
|
|---|
| 279 | $DisabledInput = array(false => ' disabled="disabled"', true => '');
|
|---|
| 280 | $DisabledTextArea = array(false => ' readonly="yes"', true => '');
|
|---|
| 281 | $Output = '<h3>Obecná nastavení</h3>';
|
|---|
| 282 | $DbRows = $this->System->Database->query('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']);
|
|---|
| 283 | $Export = $DbRows->fetch_assoc();
|
|---|
| 284 | if ($User->Licence(LICENCE_USER) and ($User->Id == $Export['User'])) $Editable = true;
|
|---|
| 285 | else $Editable = false;
|
|---|
| 286 |
|
|---|
| 287 | if (array_key_exists('Operation', $_POST))
|
|---|
| 288 | {
|
|---|
| 289 | if ($_POST['Operation'] == 'Save') if ($Editable and array_key_exists('Title', $_POST) and array_key_exists('Description', $_POST))
|
|---|
| 290 | {
|
|---|
| 291 | if (array_key_exists('WithDiacritic', $_POST)) $WithDiacritic = 1;
|
|---|
| 292 | else $WithDiacritic = 0;
|
|---|
| 293 | if (array_key_exists('Featured', $_POST)) $Export['Featured'] = 1;
|
|---|
| 294 | $this->System->Database->query('UPDATE `Export` SET `Title`="'.$_POST['Title'].
|
|---|
| 295 | '", `Featured`='.$Export['Featured'].', `Description`="'.$_POST['Description'].
|
|---|
| 296 | '", `WithDiacritic`='.$WithDiacritic.' WHERE `Id`='.$Export['Id']);
|
|---|
| 297 | $Export['Title'] = $_POST['Title'];
|
|---|
| 298 | $Export['Description'] = $_POST['Description'];
|
|---|
| 299 | $Export['WithDiacritic'] = $WithDiacritic;
|
|---|
| 300 | $Output .= ShowMessage('Nastavení uloženo.');
|
|---|
| 301 | }
|
|---|
| 302 | }
|
|---|
| 303 |
|
|---|
| 304 | if ($Export['WithDiacritic'] == 1) $WithDiacritic = ' checked="checked"';
|
|---|
| 305 | else $WithDiacritic = '';
|
|---|
| 306 | $Output .= '<form action="?Action=View&Tab=0&ExportId='.$Export['Id'].'" method="post">'.
|
|---|
| 307 | '<table>';
|
|---|
| 308 | if ($User->Id != null)
|
|---|
| 309 | {
|
|---|
| 310 | $Output .= '<input type="hidden" name="Operation" value="Save"/>'.
|
|---|
| 311 | '<tr><td colspan="2">';
|
|---|
| 312 | if ($Editable) $Output .= ' <input type="submit" value="'.T('Save').'" '.$DisabledInput[$Editable].'/>';
|
|---|
| 313 | $Output .= ' <a href="?Action=Clone&ExportId='.$Export['Id'].'" onclick="return confirmAction(\''.T('Realy clone item?').'\');">'.T('Clone').'</a> ';
|
|---|
| 314 | if ($User->Licence(LICENCE_ADMIN))
|
|---|
| 315 | $Output .= CheckBox('Featured', $Export['Featured'], '', 'CheckBox', !$Editable). ' '.T('Recommended').' ';
|
|---|
| 316 | $Output .= '</td></tr>';
|
|---|
| 317 | }
|
|---|
| 318 | $Output .= '<tr><td>'.T('Identification').':</td><td><input type="text" style="width: 400px" name="Title" value="'.htmlspecialchars($Export['Title']).'"'.$DisabledInput[$Editable].'/></td></tr>'.
|
|---|
| 319 | '<tr><td>'.T('Description').':</td><td><textarea name="Description" cols="54" rows="10"'.$DisabledTextArea[$Editable].'>'.htmlspecialchars($Export['Description']).'</textarea></td></tr>'.
|
|---|
| 320 | '<tr><td>'.T('With diacritics').'</td><td><input type="checkbox" name="WithDiacritic" '.$WithDiacritic.''.$DisabledInput[$Editable].'/></td></tr>'.
|
|---|
| 321 | '</table></form>';
|
|---|
| 322 | return $Output;
|
|---|
| 323 | }
|
|---|
| 324 |
|
|---|
| 325 | function ExportViewLanguages()
|
|---|
| 326 | {
|
|---|
| 327 | $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
|
|---|
| 328 |
|
|---|
| 329 | $Output = '';
|
|---|
| 330 | $DisabledInput = array(false => ' disabled="disabled"', true => '');
|
|---|
| 331 | $DbRows = $this->System->Database->query('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']);
|
|---|
| 332 | $Export = $DbRows->fetch_assoc();
|
|---|
| 333 | if ($User->Licence(LICENCE_USER) and ($User->Id == $Export['User'])) $Editable = true;
|
|---|
| 334 | else $Editable = false;
|
|---|
| 335 |
|
|---|
| 336 | if (array_key_exists('Operation', $_POST))
|
|---|
| 337 | {
|
|---|
| 338 | if ($_POST['Operation'] == 'Save')
|
|---|
| 339 | {
|
|---|
| 340 | // Update user selection page
|
|---|
| 341 | foreach ($_POST as $Index => $Value)
|
|---|
| 342 | {
|
|---|
| 343 | if (substr($Index, 0, 3) == 'seq')
|
|---|
| 344 | {
|
|---|
| 345 | $LanguageId = substr($Index, 3) * 1;
|
|---|
| 346 | if (array_key_exists('sel'.$LanguageId, $_POST)) $Selected = true;
|
|---|
| 347 | else $Selected = false;
|
|---|
| 348 | $Condition = ' WHERE Export='.$_GET['ExportId'].' AND `Language`='.$LanguageId;
|
|---|
| 349 | $DbResult = $this->System->Database->query('SELECT * FROM `ExportLanguage` '.$Condition);
|
|---|
| 350 | if ($DbResult->num_rows > 0)
|
|---|
| 351 | {
|
|---|
| 352 | if (!$Selected) $this->System->Database->query('DELETE FROM `ExportLanguage` '.$Condition);
|
|---|
| 353 | else $this->System->Database->query('UPDATE `ExportLanguage` SET `Sequence`='.$Value.$Condition);
|
|---|
| 354 | } else
|
|---|
| 355 | {
|
|---|
| 356 | if ($Selected) $this->System->Database->query('INSERT INTO `ExportLanguage` (`Export`, `Language`, `Sequence`) VALUES ('.$_GET['ExportId'].', '.$LanguageId.', '.$Value.')');
|
|---|
| 357 | }
|
|---|
| 358 | }
|
|---|
| 359 | }
|
|---|
| 360 |
|
|---|
| 361 | // Recalculate sequence number
|
|---|
| 362 | $this->System->Database->query('SET @I = 0');
|
|---|
| 363 | $this->System->Database->query('UPDATE `ExportLanguage` SET `Sequence` = (@I := @I + 1) WHERE `Export`='.$_GET['ExportId'].' ORDER BY `Sequence`;');
|
|---|
| 364 | $Output .= ShowMessage('Výběr uložen.');
|
|---|
| 365 | }
|
|---|
| 366 | }
|
|---|
| 367 |
|
|---|
| 368 | $Query = 'SELECT (@I := @I + 1) AS `Sequence2`, `Sequence`, `Language`.`Id`, `Name` FROM `Language`';
|
|---|
| 369 | $Query .=' LEFT JOIN `ExportLanguage` ON `ExportLanguage`.`Export` = '.$_GET['ExportId'].' AND `ExportLanguage`.`Language`=`Language`.`Id`';
|
|---|
| 370 | $Query .=' WHERE `Language`.`Enabled` = 1 ORDER BY COALESCE(`Sequence`, 100)';
|
|---|
| 371 |
|
|---|
| 372 | $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM ('.$Query.') AS X');
|
|---|
| 373 | $DbRow = $DbResult->fetch_row();
|
|---|
| 374 | $PageList = GetPageList($DbRow[0]);
|
|---|
| 375 |
|
|---|
| 376 | $TableColumns = array(
|
|---|
| 377 | array('Name' => 'Name', 'Title' => T('Name')),
|
|---|
| 378 | array('Name' => '', 'Title' => T('Select')),
|
|---|
| 379 | array('Name' => 'Sequence2', 'Title' => T('Order')),
|
|---|
| 380 | );
|
|---|
| 381 | $Order = GetOrderTableHeader($TableColumns, 'Sequence2');
|
|---|
| 382 | $Output .= '<form action="?Action=View&ExportId='.$_GET['ExportId'].'" method="post">'.
|
|---|
| 383 | '<h3>'.T('Languages').'</h3>';
|
|---|
| 384 | if ($Editable)
|
|---|
| 385 | {
|
|---|
| 386 | $Output .= '<input type="submit" value="'.T('Save').'" '.$DisabledInput[$Editable].'/>'.
|
|---|
| 387 | '<input type="hidden" name="Operation" value="Save"/>'.
|
|---|
| 388 | '<br />'.
|
|---|
| 389 | T('Select languades from list witch you want to export from. And edit theirs order.').'<br />'.
|
|---|
| 390 | T('Order is done by numeric value which is can be edit to desirable order. Lines with same number will be renumbered in ascending order.');
|
|---|
| 391 | }
|
|---|
| 392 |
|
|---|
| 393 | $Output .= $PageList['Output'].
|
|---|
| 394 | '<table class="BaseTable">'.
|
|---|
| 395 | $Order['Output'];
|
|---|
| 396 |
|
|---|
| 397 | $Query = 'SELECT * FROM ('.$Query.') AS TX '.$Order['SQL'].$PageList['SQLLimit'];
|
|---|
| 398 | $this->System->Database->query('SET @I = 0');
|
|---|
| 399 | $DbResult = $this->System->Database->query($Query);
|
|---|
| 400 | while ($Langugage = $DbResult->fetch_assoc())
|
|---|
| 401 | {
|
|---|
| 402 | $Checked = $Langugage['Sequence'] != '';
|
|---|
| 403 | $Selection = CheckBox('sel'.$Langugage['Id'], $Checked, '', 'CheckBox', !$Editable);
|
|---|
| 404 | $Sequence = '<input type="text" name="seq'.$Langugage['Id'].'" style="text-align: center; width: 40px;" value="'.$Langugage['Sequence2'].'"'.$DisabledInput[$Editable].'/>';
|
|---|
| 405 | $Output .= '<tr>
|
|---|
| 406 | <td>'.T($Langugage['Name']).'</td>
|
|---|
| 407 | <td>'.$Selection.'</td><td>'.$Sequence.'</td></tr>';
|
|---|
| 408 | }
|
|---|
| 409 | $Output .= '</table>'.
|
|---|
| 410 | '</form>'.
|
|---|
| 411 | $PageList['Output'];
|
|---|
| 412 | return $Output;
|
|---|
| 413 | }
|
|---|
| 414 |
|
|---|
| 415 | function ExportViewGroups()
|
|---|
| 416 | {
|
|---|
| 417 | $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
|
|---|
| 418 | $TranslationTree = $this->System->ModuleManager->Modules['Translation']->GetTranslationTree();
|
|---|
| 419 |
|
|---|
| 420 | $Output = '';
|
|---|
| 421 | $DisabledInput = array(false => ' disabled="disabled"', true => '');
|
|---|
| 422 | $DbRows = $this->System->Database->query('SELECT * FROM Export WHERE Id='.$_GET['ExportId']);
|
|---|
| 423 | $Export = $DbRows->fetch_assoc();
|
|---|
| 424 | if ($User->Licence(LICENCE_USER) and ($User->Id == $Export['User'])) $Editable = true;
|
|---|
| 425 | else $Editable = false;
|
|---|
| 426 |
|
|---|
| 427 | if (array_key_exists('Operation', $_POST))
|
|---|
| 428 | {
|
|---|
| 429 | if ($_POST['Operation'] == 'Save')
|
|---|
| 430 | {
|
|---|
| 431 | // Update user selection page
|
|---|
| 432 | foreach ($_POST as $Index => $Value)
|
|---|
| 433 | {
|
|---|
| 434 | if (substr($Index, 0, 3) == 'seq')
|
|---|
| 435 | {
|
|---|
| 436 | $GroupId = substr($Index, 3) * 1;
|
|---|
| 437 | if (array_key_exists('sel'.$GroupId, $_POST)) $Selected = true;
|
|---|
| 438 | else $Selected = false;
|
|---|
| 439 | $Condition = ' WHERE `Export`='.$_GET['ExportId'].' AND `Group`='.$GroupId;
|
|---|
| 440 | $DbResult = $this->System->Database->query('SELECT * FROM `ExportGroup` '.$Condition);
|
|---|
| 441 | if ($DbResult->num_rows > 0)
|
|---|
| 442 | {
|
|---|
| 443 | if (!$Selected) $this->System->Database->query('DELETE FROM `ExportGroup` '.$Condition);
|
|---|
| 444 | } else
|
|---|
| 445 | {
|
|---|
| 446 | if ($Selected) $this->System->Database->query('INSERT INTO `ExportGroup` (`Export`, `Group`) VALUES ('.$_GET['ExportId'].', '.$GroupId.')');
|
|---|
| 447 | }
|
|---|
| 448 | }
|
|---|
| 449 | }
|
|---|
| 450 | $Output .= ShowMessage(T('Select saved.'));
|
|---|
| 451 | }
|
|---|
| 452 | //items
|
|---|
| 453 | foreach ($TranslationTree as $Group)
|
|---|
| 454 | {
|
|---|
| 455 | foreach ($TranslationTree[$Group['Id']]['Items'] as $Column) {
|
|---|
| 456 | if (array_key_exists('item'.$Column['Id'], $_POST)) $Selected = true;
|
|---|
| 457 | else $Selected = false;
|
|---|
| 458 | // we will save only forbitten collums and need to be visible
|
|---|
| 459 | $Selected = !$Selected;
|
|---|
| 460 | if (!$Column['Visible']) $Selected = false;
|
|---|
| 461 |
|
|---|
| 462 | $Condition = ' WHERE `Export`='.$_GET['ExportId'].' AND `GroupItem`='.$Column['Id'];
|
|---|
| 463 | $DbResult = $this->System->Database->query('SELECT * FROM `ExportGroupItem` '.$Condition);
|
|---|
| 464 | if ($DbResult->num_rows > 0)
|
|---|
| 465 | {
|
|---|
| 466 | if (!$Selected) $this->System->Database->query('DELETE FROM `ExportGroupItem` '.$Condition);
|
|---|
| 467 | } else
|
|---|
| 468 | {
|
|---|
| 469 | if ($Selected) $this->System->Database->query('INSERT INTO `ExportGroupItem` (`Export`, `GroupItem`) VALUES ('.$_GET['ExportId'].', '.$Column['Id'].')');
|
|---|
| 470 | }
|
|---|
| 471 | }
|
|---|
| 472 | }
|
|---|
| 473 | }
|
|---|
| 474 |
|
|---|
| 475 | $Query = 'SELECT `Group`.*, `ExportGroup`.`Id` AS `ExportGroupId` FROM `Group` LEFT JOIN `ExportGroup` ON `ExportGroup`.`Export`='.$_GET['ExportId'].' AND `Group`=`Group`.`Id`';
|
|---|
| 476 |
|
|---|
| 477 | $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM ('.$Query.') AS X');
|
|---|
| 478 | $DbRow = $DbResult->fetch_row();
|
|---|
| 479 | $PageList = GetPageList($DbRow[0]);
|
|---|
| 480 |
|
|---|
| 481 | $TableColumns = array(
|
|---|
| 482 | array('Name' => '', 'Title' => T('Select')),
|
|---|
| 483 | array('Name' => 'Name', 'Title' => T('Name')),
|
|---|
| 484 | array('Name' => 'MangosTable', 'Title' => 'Mangos/DBC/Lua'),
|
|---|
| 485 | // array('Name' => 'DBCFileName', 'Title' => 'DBC soubor'),
|
|---|
| 486 | // array('Name' => 'LuaFileName', 'Title' => 'Lua soubor'),
|
|---|
| 487 | array('Name' => '', 'Title' => T('Items of translation')),
|
|---|
| 488 | );
|
|---|
| 489 | $Order = GetOrderTableHeader($TableColumns, 'Name');
|
|---|
| 490 | $Output .= '<form action="?Action=View&ExportId='.$_GET['ExportId'].'" method="post">'.
|
|---|
| 491 | '<h3>'.T('Translation groups').'</h3>';
|
|---|
| 492 | if ($Editable)
|
|---|
| 493 | {
|
|---|
| 494 | $Output .= '<input type="submit" value="'.T('Save').'" '.$DisabledInput[$Editable].'/>'.
|
|---|
| 495 | '<input type="hidden" name="Operation" value="Save"/>'.
|
|---|
| 496 | ' <span onclick="CheckAllCheckbox();">'.CheckBox('CheckAll', False, 'CheckAll').' '.T('Select all').'</span> '.
|
|---|
| 497 | '<br />'.
|
|---|
| 498 | T('Select translation groups witch you want to export.').'<br />';
|
|---|
| 499 | }
|
|---|
| 500 |
|
|---|
| 501 | $Output .= $PageList['Output'].
|
|---|
| 502 | '<table class="BaseTable">'.
|
|---|
| 503 | $Order['Output'];
|
|---|
| 504 |
|
|---|
| 505 | $DbResultItem = $this->System->Database->query('SELECT * FROM `ExportGroupItem` WHERE `Export`='.$_GET['ExportId']);
|
|---|
| 506 | while ($GroupItem = $DbResultItem->fetch_assoc())
|
|---|
| 507 | {
|
|---|
| 508 | $GroupItems[$GroupItem['GroupItem']] = 1;
|
|---|
| 509 | }
|
|---|
| 510 |
|
|---|
| 511 | $Query = 'SELECT * FROM ('.$Query.') AS TX '.$Order['SQL'].$PageList['SQLLimit'];
|
|---|
| 512 | $DbResult = $this->System->Database->query($Query);
|
|---|
| 513 | while ($Group = $DbResult->fetch_assoc())
|
|---|
| 514 | {
|
|---|
| 515 | $Columns = '';
|
|---|
| 516 | foreach ($TranslationTree[$Group['Id']]['Items'] as $Column)
|
|---|
| 517 | {
|
|---|
| 518 | if ($Column['Visible']) $Columns .= CheckBox('item'.$Column['Id'],
|
|---|
| 519 | !isset($GroupItems[$Column['Id']]), '', 'CheckBox', !$Editable).' '.T($Column['Name']).' <br/>';
|
|---|
| 520 | }
|
|---|
| 521 | $Checked = $Group['ExportGroupId'] != '';
|
|---|
| 522 | $Selection = CheckBox('sel'.$Group['Id'], $Checked, '', 'CheckBox', !$Editable);
|
|---|
| 523 | $Output .= '<tr>'.
|
|---|
| 524 | '<td>'.$Selection.'<input type="hidden" name="seq'.$Group['Id'].'"/></td>'.
|
|---|
| 525 | '<td>'.T($Group['Name']).'</td><td>';
|
|---|
| 526 | if ($Group['MangosTable'] <> '')
|
|---|
| 527 | $Output .= $Group['MangosTable'].'.sql ';
|
|---|
| 528 | if ($Group['LuaFileName'] <> '')
|
|---|
| 529 | $Output .= $Group['LuaFileName'].'.lua ';
|
|---|
| 530 | if ($Group['DBCFileName'] <> '')
|
|---|
| 531 | $Output .= $Group['DBCFileName'].'.dbc ';
|
|---|
| 532 |
|
|---|
| 533 | $Output .= '</td><td>';
|
|---|
| 534 | $Output .= $Columns. '</td>';
|
|---|
| 535 | $Output .= '</tr>';
|
|---|
| 536 | }
|
|---|
| 537 | $Output .= '</table>'.
|
|---|
| 538 | '</form>'.
|
|---|
| 539 | $PageList['Output'];
|
|---|
| 540 | return $Output;
|
|---|
| 541 | }
|
|---|
| 542 |
|
|---|
| 543 | function ExportViewOutputFormat()
|
|---|
| 544 | {
|
|---|
| 545 | $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
|
|---|
| 546 | $Output = '';
|
|---|
| 547 | $DisabledInput = array(false => ' disabled="disabled"', true => '');
|
|---|
| 548 | if (array_key_exists('ExportId', $_GET))
|
|---|
| 549 | {
|
|---|
| 550 | $DbRows = $this->System->Database->query('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']);
|
|---|
| 551 | if ($DbRows->num_rows > 0)
|
|---|
| 552 | {
|
|---|
| 553 | $Export = $DbRows->fetch_assoc();
|
|---|
| 554 | if ($User->Licence(LICENCE_USER) and ($User->Id == $Export['User'])) $Editable = true;
|
|---|
| 555 | else $Editable = false;
|
|---|
| 556 |
|
|---|
| 557 | if (array_key_exists('Operation', $_POST))
|
|---|
| 558 | {
|
|---|
| 559 | if ($_POST['Operation'] == 'Save')
|
|---|
| 560 | {
|
|---|
| 561 | if (array_key_exists('OutputType', $_POST) and ($_POST['OutputType'] * 1 > 0))
|
|---|
| 562 | {
|
|---|
| 563 | $this->System->Database->query('UPDATE Export SET OutputType='.$_POST['OutputType'].' WHERE Id='.$_GET['ExportId']);
|
|---|
| 564 | $Output .= ShowMessage(T('Select saved.'));
|
|---|
| 565 | } else $Output .= ShowMessage(T('Format wasn\'t selected'), MESSAGE_CRITICAL);
|
|---|
| 566 | }
|
|---|
| 567 | }
|
|---|
| 568 |
|
|---|
| 569 | $DbResult = $this->System->Database->query('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']);
|
|---|
| 570 | $Export = $DbResult->fetch_assoc();
|
|---|
| 571 |
|
|---|
| 572 | $Output .= '<h3>'.T('Format the generated output').'</h3>'.
|
|---|
| 573 | '<form action="?Action=View&ExportId='.$_GET['ExportId'].'" method="post">';
|
|---|
| 574 | if ($Editable)
|
|---|
| 575 | {
|
|---|
| 576 | $Output .= '<input type="submit" value="'.T('Save').'" '.$DisabledInput[$Editable].'/>'.
|
|---|
| 577 | '<input type="hidden" name="Operation" value="Save"/>'.
|
|---|
| 578 | '<br />';
|
|---|
| 579 | }
|
|---|
| 580 | $DbResult = $this->System->Database->query('SELECT * FROM `ExportOutputType` ORDER BY `Name`');
|
|---|
| 581 | while ($ExportFormat = $DbResult->fetch_assoc())
|
|---|
| 582 | {
|
|---|
| 583 | $Output .= RadioButton('OutputType', $ExportFormat['Id'], $Export['OutputType'] == $ExportFormat['Id'], '', !$Editable).' '.$ExportFormat['Name'].'<br/>';
|
|---|
| 584 | }
|
|---|
| 585 | $Output .= '</form>';
|
|---|
| 586 | } else $Output .= ShowMessage(T('Item not found'), MESSAGE_CRITICAL);
|
|---|
| 587 | } else $Output .= ShowMessage(T('Is isn\'t select'), MESSAGE_CRITICAL);
|
|---|
| 588 | return $Output;
|
|---|
| 589 | }
|
|---|
| 590 |
|
|---|
| 591 | function ExportViewVersion()
|
|---|
| 592 | {
|
|---|
| 593 | $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
|
|---|
| 594 | $Output = '';
|
|---|
| 595 | $DisabledInput = array(false => ' disabled="disabled"', true => '');
|
|---|
| 596 | $DbRows = $this->System->Database->query('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']);
|
|---|
| 597 | $Export = $DbRows->fetch_assoc();
|
|---|
| 598 | if ($User->Licence(LICENCE_USER) and ($User->Id == $Export['User'])) $Editable = true;
|
|---|
| 599 | else $Editable = false;
|
|---|
| 600 |
|
|---|
| 601 | if (array_key_exists('Operation', $_POST))
|
|---|
| 602 | {
|
|---|
| 603 | if (($_POST['Operation'] == 'Save') and (array_key_exists('ClientVersion', $_POST)))
|
|---|
| 604 | {
|
|---|
| 605 | $this->System->Database->query('UPDATE `Export` SET `ClientVersion`='.$_POST['ClientVersion'].' WHERE `Id`='.$_GET['ExportId']);
|
|---|
| 606 | $Output .= ShowMessage(T('Select saved.'));
|
|---|
| 607 | }
|
|---|
| 608 | }
|
|---|
| 609 |
|
|---|
| 610 | $DbResult = $this->System->Database->query('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']);
|
|---|
| 611 | $Export = $DbResult->fetch_assoc();
|
|---|
| 612 |
|
|---|
| 613 | if ($Export['OutputType'] == '')
|
|---|
| 614 | {
|
|---|
| 615 | $Output .= ShowMessage('Nevybrán typ exportu', MESSAGE_CRITICAL);
|
|---|
| 616 | } else
|
|---|
| 617 | {
|
|---|
| 618 | $Query = 'SELECT `ClientVersion`.* FROM `ExportVersion` '.
|
|---|
| 619 | 'LEFT JOIN `ClientVersion` ON `ClientVersion`.`Id`=`ExportVersion`.`ClientVersion` WHERE `ExportType`='.$Export['OutputType'];
|
|---|
| 620 |
|
|---|
| 621 | $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM ('.$Query.') AS `X`');
|
|---|
| 622 | $DbRow = $DbResult->fetch_row();
|
|---|
| 623 | $PageList = GetPageList($DbRow[0]);
|
|---|
| 624 |
|
|---|
| 625 | $TableColumns = array(
|
|---|
| 626 | array('Name' => 'Version', 'Title' => T('Version')),
|
|---|
| 627 | array('Name' => 'BuildNumber', 'Title' => T('Build')),
|
|---|
| 628 | array('Name' => 'ReleaseDate', 'Title' => T('Release date')),
|
|---|
| 629 | array('Name' => 'Title', 'Title' => T('Name2')),
|
|---|
| 630 | array('Name' => '', 'Title' => T('Select')),
|
|---|
| 631 | );
|
|---|
| 632 | $Order = GetOrderTableHeader($TableColumns, 'BuildNumber', 1);
|
|---|
| 633 | $Output .= '<form action="?Action=View&ExportId='.$_GET['ExportId'].'" method="post">'.
|
|---|
| 634 | '<h3>'.T('Client version').'</h3>';
|
|---|
| 635 |
|
|---|
| 636 | if ($Editable)
|
|---|
| 637 | {
|
|---|
| 638 | $Output .= '<input type="submit" value="'.T('Save').'" '.$DisabledInput[$Editable].'/>'.
|
|---|
| 639 | '<input type="hidden" name="Operation" value="Save"/>'.
|
|---|
| 640 | '<br />'.
|
|---|
| 641 | T('Select version of game client witch you want to export.').'<br />';
|
|---|
| 642 | }
|
|---|
| 643 | $Output .= $PageList['Output'].
|
|---|
| 644 | '<table class="BaseTable">'.
|
|---|
| 645 | $Order['Output'];
|
|---|
| 646 |
|
|---|
| 647 | $Query = 'SELECT * FROM ('.$Query.') AS `TX` '.$Order['SQL'].$PageList['SQLLimit'];
|
|---|
| 648 | $DbResult = $this->System->Database->query($Query);
|
|---|
| 649 | while ($Version = $DbResult->fetch_assoc())
|
|---|
| 650 | {
|
|---|
| 651 | $Output .= '<tr><td><a href="'.$this->System->Link('/client-version/?action=item&id='.$Version['Id']).'">'.
|
|---|
| 652 | $Version['Version'].'</a></td><td>'.$Version['BuildNumber'].'</td><td>'.
|
|---|
| 653 | HumanDate($Version['ReleaseDate']).'</td><td>'.$Version['Title'].'</td><td>'.
|
|---|
| 654 | RadioButton('ClientVersion', $Version['Id'], $Export['ClientVersion'] == $Version['Id'], '', !$Editable
|
|---|
| 655 | ).'</td></tr>';
|
|---|
| 656 | }
|
|---|
| 657 | $Output .= '</table>'.
|
|---|
| 658 | '</form>'.
|
|---|
| 659 | $PageList['Output'];
|
|---|
| 660 | }
|
|---|
| 661 | return $Output;
|
|---|
| 662 | }
|
|---|
| 663 |
|
|---|
| 664 | function ExportViewOutput()
|
|---|
| 665 | {
|
|---|
| 666 | $Output = '';
|
|---|
| 667 | $DbResult = $this->System->Database->query('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']);
|
|---|
| 668 | $Export = $DbResult->fetch_assoc();
|
|---|
| 669 | if ($Export['OutputType'] == '') $Output .= ShowMessage('Nevybrán typ exportu', MESSAGE_CRITICAL);
|
|---|
| 670 | else if ($Export['ClientVersion'] == '') $Output .= ShowMessage(T('Export don\'t have selected version of client'), MESSAGE_CRITICAL);
|
|---|
| 671 | else
|
|---|
| 672 | {
|
|---|
| 673 | $DbResult = $this->System->Database->query('SELECT * FROM `ExportOutputType` WHERE `Id`='.$Export['OutputType']);
|
|---|
| 674 | if ($DbResult->num_rows > 0)
|
|---|
| 675 | {
|
|---|
| 676 | $DbResult = $this->System->Database->query('SELECT * FROM `ExportVersion` WHERE (`ExportType`='.$Export['OutputType'].') AND (`ClientVersion`='.$Export['ClientVersion'].')');
|
|---|
| 677 | if ($DbResult->num_rows > 0)
|
|---|
| 678 | {
|
|---|
| 679 | if (array_key_exists('Auto', $_GET) == false)
|
|---|
| 680 | $this->System->Database->query('UPDATE `Export` SET `UsedCount` = `UsedCount` + 1 WHERE `Id`='.$Export['Id']);
|
|---|
| 681 | $Output = ExportOutput($Export['Id'], $Export['OutputType']);
|
|---|
| 682 | } else $Output = ShowMessage(T('Export don\'t have selected version of client'), MESSAGE_CRITICAL);
|
|---|
| 683 | } else $Output = ShowMessage(T('Format output isn\'t select').'.', MESSAGE_CRITICAL);
|
|---|
| 684 | }
|
|---|
| 685 | return $Output;
|
|---|
| 686 | }
|
|---|
| 687 |
|
|---|
| 688 | function ExportViewStat($Where = '')
|
|---|
| 689 | {
|
|---|
| 690 | $Export = new Export($this->System);
|
|---|
| 691 | $Export->Id = $_GET['ExportId'];
|
|---|
| 692 | $Export->Init();
|
|---|
| 693 | $Export->LoadFilters();
|
|---|
| 694 |
|
|---|
| 695 | if (($Export->Export['ClientVersion'] == '') or ($Export->ClientVersion['BuildNumber'] == ''))
|
|---|
| 696 | $Output = ShowMessage(T('Export don\'t have selected version of client'), MESSAGE_CRITICAL);
|
|---|
| 697 | else
|
|---|
| 698 | {
|
|---|
| 699 | $GroupListQuery = 'SELECT `Group`.* FROM `Group` '.
|
|---|
| 700 | ' JOIN `ExportGroup` ON (`ExportGroup`.`Export`='.$Export->Id.') AND (`ExportGroup`.`Group`=`Group`.`Id`)';
|
|---|
| 701 | $Query = '';
|
|---|
| 702 | $UnionItems = array();
|
|---|
| 703 | $DbResult = $this->System->Database->query($GroupListQuery.$Where);
|
|---|
| 704 | while ($DbRow = $DbResult->fetch_assoc())
|
|---|
| 705 | {
|
|---|
| 706 | $UnionItems[] = 'SELECT (SELECT COUNT(DISTINCT(`Entry`)) FROM ('.
|
|---|
| 707 | ' SELECT `T`.* FROM `'.$DbRow['TablePrefix'].'` AS `T`'.
|
|---|
| 708 | ' JOIN `ExportUser` ON (`ExportUser`.`User`=`T`.`User`) AND (`ExportUser`.`Export`='.$Export->Id.') '.
|
|---|
| 709 | ' JOIN `ExportLanguage` ON (`ExportLanguage`.`Export`='.$Export->Id.')'.
|
|---|
| 710 | ' WHERE (`Complete` = 1) AND (`VersionStart` <= '.$Export->ClientVersion['BuildNumber'].') AND (`VersionEnd` >= '.$Export->ClientVersion['BuildNumber'].')'.
|
|---|
| 711 | ') AS `C1`) AS `Translated`, '.
|
|---|
| 712 | '(SELECT COUNT(DISTINCT(`Entry`)) FROM ('.
|
|---|
| 713 | ' SELECT `T`.* FROM `'.$DbRow['TablePrefix'].'` AS `T`'.
|
|---|
| 714 | ' WHERE (`Language` = '.Core::Cast($this->System)->Config['OriginalLanguage'].') AND (`VersionStart` <= '.$Export->ClientVersion['BuildNumber'].') AND (`VersionEnd` >= '.$Export->ClientVersion['BuildNumber'].')'.
|
|---|
| 715 | ') AS `C2`) AS `Total`, "'.$DbRow['Name'].'" AS `Name`';
|
|---|
| 716 | }
|
|---|
| 717 | $Query = substr($Query, 0, - 6);
|
|---|
| 718 |
|
|---|
| 719 | $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM ('.$GroupListQuery.') AS `T`');
|
|---|
| 720 | $DbRow = $DbResult->fetch_row();
|
|---|
| 721 | $PageList = GetPageList($DbRow[0]);
|
|---|
| 722 | $Output = '<h3>'.T('Statistic of completion selected groups').'</h3>'.
|
|---|
| 723 | $PageList['Output'];
|
|---|
| 724 |
|
|---|
| 725 | $Output .= '<table class="BaseTable">';
|
|---|
| 726 | $TableColumns = array(
|
|---|
| 727 | array('Name' => 'Name', 'Title' => T('Name')),
|
|---|
| 728 | array('Name' => 'Translated', 'Title' => T('Translated count')),
|
|---|
| 729 | array('Name' => 'Total', 'Title' => T('English')),
|
|---|
| 730 | array('Name' => 'Percent', 'Title' => T('Percent')),
|
|---|
| 731 | );
|
|---|
| 732 |
|
|---|
| 733 | $Order = GetOrderTableHeader($TableColumns, 'Name', 0);
|
|---|
| 734 | $Output .= $Order['Output'];
|
|---|
| 735 |
|
|---|
| 736 | $Translated = 0;
|
|---|
| 737 | $Total = 0;
|
|---|
| 738 | if (count($UnionItems) > 0)
|
|---|
| 739 | {
|
|---|
| 740 | $ID = $this->System->Database->query('SELECT *, ROUND(`Translated` / `Total` * 100, 2) AS `Percent` FROM ('.implode(' UNION ALL ', $UnionItems).') AS `C3` '.$Order['SQL'].$PageList['SQLLimit']);
|
|---|
| 741 | while ($Group = $ID->fetch_assoc())
|
|---|
| 742 | {
|
|---|
| 743 | $Output .= '<tr><td>'.T($Group['Name']).'</td><td>'.$Group['Translated'].'</td><td>'.$Group['Total'].'</td><td>'.ProgressBar(150, $Group['Percent']).'</td></tr>';
|
|---|
| 744 | $Translated += $Group['Translated'];
|
|---|
| 745 | $Total += $Group['Total'];
|
|---|
| 746 | }
|
|---|
| 747 | }
|
|---|
| 748 | if ($Total > 0) $Percent = $Translated / $Total * 100;
|
|---|
| 749 | else $Percent = 100;
|
|---|
| 750 |
|
|---|
| 751 | $Output .= '<tr><td><strong>'.T('Altogether').'</strong></td><td><strong>'.$Translated.'</strong></td><td><strong>'.$Total.'</strong></td><td><strong>'.ProgressBar(150, round($Percent, 2)).'</strong></td></tr>';
|
|---|
| 752 | $Output .= '</table>';
|
|---|
| 753 | }
|
|---|
| 754 | return $Output;
|
|---|
| 755 | }
|
|---|
| 756 |
|
|---|
| 757 | function ExportView()
|
|---|
| 758 | {
|
|---|
| 759 | $Output = '';
|
|---|
| 760 | if (array_key_exists('ExportId', $_GET) and is_numeric($_GET['ExportId']))
|
|---|
| 761 | {
|
|---|
| 762 | $DbResult = $this->System->Database->query('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']);
|
|---|
| 763 | if ($DbResult->num_rows > 0)
|
|---|
| 764 | {
|
|---|
| 765 | $Export = $DbResult->fetch_assoc();
|
|---|
| 766 |
|
|---|
| 767 | $DbResult = $this->System->Database->query('SELECT * FROM `User` WHERE `ID`='.$Export['User']);
|
|---|
| 768 | $UserLine = $DbResult->fetch_assoc();
|
|---|
| 769 | $Output .= sprintf(T('Export %s of translator %s'),
|
|---|
| 770 | '<strong><a href="?Action=View&Tab=6&ExportId='.$Export['Id'].'">'.htmlspecialchars($Export['Title']).'</a></strong>',
|
|---|
| 771 | '<strong>'.$UserLine['Name'].'</strong>');
|
|---|
| 772 | $Output .= ShowTabs(array(T('General'), T('Translators'),
|
|---|
| 773 | T('Translations'), T('Languages'), T('Format'), T('Version'),
|
|---|
| 774 | T('Statistic'), T('Output')));
|
|---|
| 775 | $Output .= '<div id="content">';
|
|---|
| 776 | if ($_SESSION['Tab'] == TAB_GENERAL) $Output .= $this->ExportViewGeneral();
|
|---|
| 777 | else if ($_SESSION['Tab'] == TAB_TRANSLATORS) $Output .= $this->ExportViewTranslators();
|
|---|
| 778 | else if ($_SESSION['Tab'] == TAB_GROUPS) $Output .= $this->ExportViewGroups();
|
|---|
| 779 | else if ($_SESSION['Tab'] == TAB_LANGUAGES) $Output .= $this->ExportViewLanguages();
|
|---|
| 780 | else if ($_SESSION['Tab'] == TAB_OUTPUT_FORMAT) $Output .= $this->ExportViewOutputFormat();
|
|---|
| 781 | else if ($_SESSION['Tab'] == TAB_VERSION) $Output .= $this->ExportViewVersion();
|
|---|
| 782 | else if ($_SESSION['Tab'] == TAB_STAT) $Output .= $this->ExportViewStat();
|
|---|
| 783 | else if ($_SESSION['Tab'] == TAB_OUTPUT) $Output .= $this->ExportViewOutput();
|
|---|
| 784 | else $Output .= $this->ExportViewGeneral();
|
|---|
| 785 |
|
|---|
| 786 | $Output .= '</div>';
|
|---|
| 787 | } else $Output .= ShowMessage(T('Export not found.'), MESSAGE_CRITICAL);
|
|---|
| 788 | } else $Output .= ShowMessage(T('Is isn\'t select'), MESSAGE_CRITICAL);
|
|---|
| 789 | return $Output;
|
|---|
| 790 | }
|
|---|
| 791 |
|
|---|
| 792 | function ExportClone()
|
|---|
| 793 | {
|
|---|
| 794 | $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
|
|---|
| 795 | if ($User->Licence(LICENCE_USER))
|
|---|
| 796 | {
|
|---|
| 797 | if (array_key_exists('ExportId', $_GET) and is_numeric($_GET['ExportId']))
|
|---|
| 798 | {
|
|---|
| 799 | $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM `Export` WHERE `User`='.$User->Id);
|
|---|
| 800 | $DbRow = $DbResult->fetch_row();
|
|---|
| 801 | if ($DbRow[0] < Core::Cast($this->System)->Config['MaxExportPerUser'])
|
|---|
| 802 | {
|
|---|
| 803 | $DbResult = $this->System->Database->query('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']);
|
|---|
| 804 | if ($DbResult->num_rows > 0)
|
|---|
| 805 | {
|
|---|
| 806 | $DbRow = $DbResult->fetch_assoc();
|
|---|
| 807 | unset($DbRow['Id']);
|
|---|
| 808 | $DbRow['UsedCount'] = '0';
|
|---|
| 809 | $DbRow['User'] = $User->Id;
|
|---|
| 810 | $DbRow['TimeCreate'] = 'NOW()';
|
|---|
| 811 | $DbRow['Title'] .= ' - '.T('clone');
|
|---|
| 812 | $DbRow['Featured'] = 0;
|
|---|
| 813 | $this->System->Database->insert('Export', $DbRow);
|
|---|
| 814 | $ExportId = $this->System->Database->insert_id;
|
|---|
| 815 | $this->System->Database->query('INSERT INTO `ExportGroup` (SELECT NULL AS `Id`, '.$ExportId.' AS `Export`, `Group` FROM `ExportGroup` WHERE `Export`='.$_GET['ExportId'].')');
|
|---|
| 816 | $this->System->Database->query('INSERT INTO `ExportGroupItem` (SELECT NULL AS `Id`, '.$ExportId.' AS `Export`, `GroupItem` FROM `ExportGroupItem` WHERE `Export`='.$_GET['ExportId'].')');
|
|---|
| 817 | $this->System->Database->query('INSERT INTO `ExportLanguage` (SELECT NULL AS `Id`, '.$ExportId.' AS `Export`, `Language`, `Sequence` FROM `ExportLanguage` WHERE `Export`='.$_GET['ExportId'].')');
|
|---|
| 818 | $this->System->Database->query('INSERT INTO `ExportUser` (SELECT NULL AS `Id`, '.$ExportId.' AS `Export`, `User`, `Sequence` FROM `ExportUser` WHERE `Export`='.$_GET['ExportId'].')');
|
|---|
| 819 | $Output = ShowMessage(T('Clone export created.<br />Direct link to export').': <a href="?Action=View&ExportId='.$ExportId.'">zde</a>');
|
|---|
| 820 | $this->System->ModuleManager->Modules['Log']->WriteLog(T('Clone export created').' <a href="'.$this->System->Link('/export/?Action=View&ExportId='.$ExportId).'">'.$ExportId.'</a>.', LOG_TYPE_EXPORT);
|
|---|
| 821 | $_GET['Filter'] = 'my';
|
|---|
| 822 | $this->ExportList();
|
|---|
| 823 | } else $Output = ShowMessage('Zdrojový export nenalezen', MESSAGE_CRITICAL);
|
|---|
| 824 | } else $Output = ShowMessage(sprintf(T('You can\'t create another export. Max for one user is %d.'),
|
|---|
| 825 | Core::Cast($this->System)->Config['MaxExportPerUser']), MESSAGE_CRITICAL);
|
|---|
| 826 | } else $Output = ShowMessage(T('Export not found.'), MESSAGE_CRITICAL);
|
|---|
| 827 | } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL);
|
|---|
| 828 | return $Output;
|
|---|
| 829 | }
|
|---|
| 830 |
|
|---|
| 831 | function Show(): string
|
|---|
| 832 | {
|
|---|
| 833 | $this->Title = T('Export');
|
|---|
| 834 | if (array_key_exists('Action', $_GET))
|
|---|
| 835 | {
|
|---|
| 836 | if ($_GET['Action'] == 'Create') $Output = $this->ExportCreate();
|
|---|
| 837 | else if ($_GET['Action'] == 'CreateFinish') $Output = $this->ExportCreateFinish();
|
|---|
| 838 | else if ($_GET['Action'] == 'View') $Output = $this->ExportView();
|
|---|
| 839 | else if ($_GET['Action'] == 'Delete') $Output = $this->ExportDelete();
|
|---|
| 840 | else if ($_GET['Action'] == 'Clone') $Output = $this->ExportClone();
|
|---|
| 841 | else $Output = $this->ExportList();
|
|---|
| 842 | } else $Output = $this->ExportList();
|
|---|
| 843 | return $Output;
|
|---|
| 844 | }
|
|---|
| 845 | }
|
|---|
| 846 |
|
|---|
| 847 | class PageExportProgress extends Page
|
|---|
| 848 | {
|
|---|
| 849 | function __construct($System)
|
|---|
| 850 | {
|
|---|
| 851 | parent::__construct($System);
|
|---|
| 852 | $this->RawPage = true;
|
|---|
| 853 | }
|
|---|
| 854 |
|
|---|
| 855 | function Show(): string
|
|---|
| 856 | {
|
|---|
| 857 | if (array_key_exists('i', $_GET))
|
|---|
| 858 | $Output = $this->System->ModuleManager->Modules['Export']->GetTaskProgress($_GET['i'] * 1);
|
|---|
| 859 | else $Output = 'Missing task id';
|
|---|
| 860 | return $Output;
|
|---|
| 861 | }
|
|---|
| 862 | }
|
|---|