1 | <?php
|
---|
2 |
|
---|
3 | class ModuleExport extends Module
|
---|
4 | {
|
---|
5 | function __construct(System $System)
|
---|
6 | {
|
---|
7 | parent::__construct($System);
|
---|
8 | $this->Name = 'Export';
|
---|
9 | $this->Version = '1.0';
|
---|
10 | $this->Creator = 'Chronos';
|
---|
11 | $this->License = 'GNU/GPL';
|
---|
12 | $this->Description = 'Allow parametric export of translated texts to various supported output formats';
|
---|
13 | $this->Dependencies = array('Translation');
|
---|
14 | }
|
---|
15 |
|
---|
16 | function DoStart(): void
|
---|
17 | {
|
---|
18 | $this->System->RegisterPage(['export'], 'PageExport');
|
---|
19 | $this->System->RegisterPage(['export', 'progress'], 'PageExportProgress');
|
---|
20 | Core::Cast($this->System)->RegisterMenuItem(array(
|
---|
21 | 'Title' => 'Exporty',
|
---|
22 | 'Hint' => 'Zde si můžete stáhnout přeložené texty',
|
---|
23 | 'Link' => $this->System->Link('/export/'),
|
---|
24 | 'Permission' => LICENCE_ANONYMOUS,
|
---|
25 | 'Icon' => '',
|
---|
26 | ), 2);
|
---|
27 | }
|
---|
28 |
|
---|
29 | function GetTaskProgress($TaskId)
|
---|
30 | {
|
---|
31 | $Output = '';
|
---|
32 | $DbResult = $this->Database->query('SELECT * FROM `ExportTask` '.
|
---|
33 | 'LEFT JOIN `Export` ON `Export`.`Id` = `ExportTask`.`Export` WHERE '.
|
---|
34 | '((`Export`.`OutputType` = 9) OR (`Export`.`OutputType` = 10)) AND '.
|
---|
35 | '(`TimeFinish` IS NULL) OR (`Export` ='.$TaskId.') ORDER BY `TimeQueued`'); // `Export`='.$Export->Id
|
---|
36 | while ($Task = $DbResult->fetch_assoc())
|
---|
37 | {
|
---|
38 | $Export = '<a href="'.$this->System->Link('/export/?Action=View&ExportId='.$Task['Export']).'">'.$Task['Export'].'</a>';
|
---|
39 | if ($TaskId == $Task['Export'])
|
---|
40 | $Export = ''.$Export.' (tento)';
|
---|
41 |
|
---|
42 | // Show progress bar
|
---|
43 | $Output .= ' <strong>Export '.$Export.':</strong> <div id="progress'.$Task['Export'].'">'.
|
---|
44 | '<strong>'.ProgressBar(300, $Task['Progress']).'</strong> ';
|
---|
45 |
|
---|
46 | // Show estimated time to complete
|
---|
47 | $PrefixMultiplier = new PrefixMultiplier();
|
---|
48 | if ($Task['Progress'] > 0)
|
---|
49 | {
|
---|
50 | $ElapsedTime = time() - MysqlDateTimeToTime($Task['TimeStart']);
|
---|
51 | $Output .= T('Elapsed time').': <strong>'.$PrefixMultiplier->Add($ElapsedTime, '', 4, 'Time').'</strong> / ';
|
---|
52 | $EstimatedTime = (time() - MysqlDateTimeToTime($Task['TimeStart'])) / $Task['Progress'] * (100 - $Task['Progress']);
|
---|
53 | $Output .= T('Estimated remaining time').': <strong>'.$PrefixMultiplier->Add($EstimatedTime, '', 4, 'Time').'</strong><br/>';
|
---|
54 | }
|
---|
55 | $Output .= '</div>';
|
---|
56 |
|
---|
57 | if ($Task['Progress'] > 99)
|
---|
58 | $Output .= '<script type="text/javascript" language="JavaScript" charset="utf-8">'.
|
---|
59 | 'setTimeout("parent.location.href=\''.$this->System->Link('/export/?Action=View&Tab=7&ExportId='.$TaskId).'\'", 500)'.
|
---|
60 | '</script>';
|
---|
61 | }
|
---|
62 | return $Output;
|
---|
63 | }
|
---|
64 | }
|
---|