| 1 | <?php
|
|---|
| 2 |
|
|---|
| 3 | class ModuleClientVersion extends Module
|
|---|
| 4 | {
|
|---|
| 5 | function __construct(System $System)
|
|---|
| 6 | {
|
|---|
| 7 | parent::__construct($System);
|
|---|
| 8 | $this->Name = 'ClientVersion';
|
|---|
| 9 | $this->Version = '1.0';
|
|---|
| 10 | $this->Creator = 'Chronos';
|
|---|
| 11 | $this->License = 'GNU/GPL';
|
|---|
| 12 | $this->Description = 'Manage and show list of known versions of WoW client.';
|
|---|
| 13 | $this->Dependencies = array();
|
|---|
| 14 | }
|
|---|
| 15 |
|
|---|
| 16 | function DoStart(): void
|
|---|
| 17 | {
|
|---|
| 18 | $this->System->RegisterPage(['client-version'], 'PageClientVersion');
|
|---|
| 19 | Core::Cast($this->System)->RegisterMenuItem(array(
|
|---|
| 20 | 'Title' => T('Game version'),
|
|---|
| 21 | 'Hint' => T('List of the game client versions'),
|
|---|
| 22 | 'Link' => $this->System->Link('/client-version/'),
|
|---|
| 23 | 'Permission' => LICENCE_ANONYMOUS,
|
|---|
| 24 | 'Icon' => '',
|
|---|
| 25 | ), 10);
|
|---|
| 26 | }
|
|---|
| 27 | }
|
|---|
| 28 |
|
|---|
| 29 | class PageClientVersion extends Page
|
|---|
| 30 | {
|
|---|
| 31 | function Show(): string
|
|---|
| 32 | {
|
|---|
| 33 | if (array_key_exists('action', $_GET))
|
|---|
| 34 | {
|
|---|
| 35 | if ($_GET['action'] == 'item') $Output = $this->ShowItem();
|
|---|
| 36 | else $Output = $this->ShowList();
|
|---|
| 37 | } else $Output = $this->ShowList();
|
|---|
| 38 | return $Output;
|
|---|
| 39 | }
|
|---|
| 40 |
|
|---|
| 41 | function ShowItem(): string
|
|---|
| 42 | {
|
|---|
| 43 | $Id = 0;
|
|---|
| 44 | if (TryGetUrlParameterInt('id', $Id))
|
|---|
| 45 | {
|
|---|
| 46 | $YesNo = array('Ne', 'Ano');
|
|---|
| 47 | $DbResult = $this->System->Database->query('SELECT * FROM `ClientVersion` WHERE `Id`='.$Id);
|
|---|
| 48 | if ($DbResult->num_rows > 0)
|
|---|
| 49 | {
|
|---|
| 50 | $Version = $DbResult->fetch_assoc();
|
|---|
| 51 |
|
|---|
| 52 | $Output = '<h3>'.T('Client version').'</h3>';
|
|---|
| 53 | $Output .= '<table class="BaseTable">'.
|
|---|
| 54 | '<tr><td>'.T('Version').'</td><td>'.$Version['Version'].'</td></tr>'.
|
|---|
| 55 | '<tr><td>'.T('More information').'</td><td><a href="http://www.wowwiki.com/Patch_'.$Version['Version'].'">wowwiki.com'.
|
|---|
| 56 | '</a></td></tr>'.
|
|---|
| 57 | '<tr><td>'.T('Build number').'</td><td>'.$Version['BuildNumber'].'</td></tr>'.
|
|---|
| 58 | '<tr><td>'.T('Release date').'</td><td>'.HumanDate($Version['ReleaseDate']).'</td></tr>'.
|
|---|
| 59 | '<tr><td>'.T('Title').'</td><td>'.$Version['Title'].'</td></tr>'.
|
|---|
| 60 | '<tr><td>'.T('Imported').'</td><td>'.$YesNo[$Version['Imported']].'</td></tr>'.
|
|---|
| 61 | '</table>';
|
|---|
| 62 | $Output .= '<div><a href="?">'.T('All versions list').'</a></div>';
|
|---|
| 63 | if ($Version['Imported'])
|
|---|
| 64 | {
|
|---|
| 65 | $Output .= '<div><a href="'.$this->System->Link('/progress/?Version='.
|
|---|
| 66 | $Version['Version']).'">'.T('Progress').'</a></div>';
|
|---|
| 67 | }
|
|---|
| 68 | } else $Output = ShowMessage(T('Item not found'), MESSAGE_CRITICAL);
|
|---|
| 69 | } else $Output = ShowMessage(T('Id not valid'), MESSAGE_CRITICAL);
|
|---|
| 70 | return $Output;
|
|---|
| 71 | }
|
|---|
| 72 |
|
|---|
| 73 | function ShowList(): string
|
|---|
| 74 | {
|
|---|
| 75 | $this->Title = T('Game version');
|
|---|
| 76 | $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM `ClientVersion`');
|
|---|
| 77 | $DbRow = $DbResult->fetch_row();
|
|---|
| 78 | $PageList = GetPageList($DbRow[0]);
|
|---|
| 79 |
|
|---|
| 80 | $Output = '<h3>'.T('Game version').'</h3>'.
|
|---|
| 81 | $PageList['Output'];
|
|---|
| 82 |
|
|---|
| 83 | $TableColumns = array(
|
|---|
| 84 | array('Name' => 'Version', 'Title' => T('Version')),
|
|---|
| 85 | array('Name' => 'BuildNumber', 'Title' => T('Build')),
|
|---|
| 86 | array('Name' => 'ReleaseDate', 'Title' => T('Release date')),
|
|---|
| 87 | array('Name' => 'Title', 'Title' => T('Title')),
|
|---|
| 88 | array('Name' => 'Imported', 'Title' => T('Imported')),
|
|---|
| 89 | );
|
|---|
| 90 | $Order = GetOrderTableHeader($TableColumns, 'BuildNumber', 1);
|
|---|
| 91 | $Output .= '<table class="BaseTable">'.
|
|---|
| 92 | $Order['Output'];
|
|---|
| 93 |
|
|---|
| 94 | $YesNo = array('Ne', 'Ano');
|
|---|
| 95 |
|
|---|
| 96 | $DbResult = $this->System->Database->query('SELECT * FROM ClientVersion '.$Order['SQL'].$PageList['SQLLimit']);
|
|---|
| 97 | while ($Version = $DbResult->fetch_assoc())
|
|---|
| 98 | {
|
|---|
| 99 | $Output .= '<tr><td><a href="?action=item&id='.$Version['Id'].'">'.
|
|---|
| 100 | $Version['Version'].'</a></td><td>'.$Version['BuildNumber'].'</td><td>'.
|
|---|
| 101 | HumanDate($Version['ReleaseDate']).'</td><td>'.$Version['Title'].'</td>'.
|
|---|
| 102 | '<td>'.$YesNo[$Version['Imported']].'</td></tr>';
|
|---|
| 103 | }
|
|---|
| 104 | $Output .= '</table>'.
|
|---|
| 105 | $PageList['Output'];
|
|---|
| 106 | return $Output;
|
|---|
| 107 | }
|
|---|
| 108 | }
|
|---|
| 109 |
|
|---|