source: trunk/Modules/ClientVersion/ClientVersion.php

Last change on this file was 888, checked in by chronos, 17 months ago
  • Modified: Updated Common package to latest version.
  • Modified: Fixes related to PHP 8.x.
File size: 3.8 KB
Line 
1<?php
2
3class 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
29class 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()
42 {
43 if (array_key_exists('id', $_GET))
44 {
45 $YesNo = array('Ne', 'Ano');
46 $DbResult = $this->System->Database->query('SELECT * FROM `ClientVersion` WHERE `Id`='.($_GET['id']*1));
47 if ($DbResult->num_rows > 0)
48 {
49 $Version = $DbResult->fetch_assoc();
50
51 $Output = '<h3>'.T('Client version').'</h3>';
52 $Output .= '<table class="BaseTable">'.
53 '<tr><td>'.T('Version').'</td><td>'.$Version['Version'].'</td></tr>'.
54 '<tr><td>'.T('More information').'</td><td><a href="http://www.wowwiki.com/Patch_'.$Version['Version'].'">wowwiki.com'.
55 '</a></td></tr>'.
56 '<tr><td>'.T('Build number').'</td><td>'.$Version['BuildNumber'].'</td></tr>'.
57 '<tr><td>'.T('Release date').'</td><td>'.HumanDate($Version['ReleaseDate']).'</td></tr>'.
58 '<tr><td>'.T('Title').'</td><td>'.$Version['Title'].'</td></tr>'.
59 '<tr><td>'.T('Imported').'</td><td>'.$YesNo[$Version['Imported']].'</td></tr>'.
60 '</table>';
61 $Output .= '<div><a href="?">'.T('All versions list').'</a></div>';
62 if ($Version['Imported'])
63 $Output .= '<div><a href="'.$this->System->Link('/progress/?Version='.
64 $Version['Version']).'">'.T('Progress').'</a></div>';
65 } else $Output = ShowMessage(T('Item not found'), MESSAGE_CRITICAL);
66 } else $Output = ShowMessage(T('Item not found'), MESSAGE_CRITICAL);
67 return $Output;
68 }
69
70 function ShowList()
71 {
72 $this->Title = T('Game version');
73 $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM `ClientVersion`');
74 $DbRow = $DbResult->fetch_row();
75 $PageList = GetPageList($DbRow[0]);
76
77 $Output = '<h3>'.T('Game version').'</h3>'.
78 $PageList['Output'];
79
80 $TableColumns = array(
81 array('Name' => 'Version', 'Title' => T('Version')),
82 array('Name' => 'BuildNumber', 'Title' => T('Build')),
83 array('Name' => 'ReleaseDate', 'Title' => T('Release date')),
84 array('Name' => 'Title', 'Title' => T('Title')),
85 array('Name' => 'Imported', 'Title' => T('Imported')),
86 );
87 $Order = GetOrderTableHeader($TableColumns, 'BuildNumber', 1);
88 $Output .= '<table class="BaseTable">'.
89 $Order['Output'];
90
91 $YesNo = array('Ne', 'Ano');
92
93 $DbResult = $this->System->Database->query('SELECT * FROM ClientVersion '.$Order['SQL'].$PageList['SQLLimit']);
94 while ($Version = $DbResult->fetch_assoc())
95 {
96 $Output .= '<tr><td><a href="?action=item&amp;id='.$Version['Id'].'">'.
97 $Version['Version'].'</a></td><td>'.$Version['BuildNumber'].'</td><td>'.
98 HumanDate($Version['ReleaseDate']).'</td><td>'.$Version['Title'].'</td>'.
99 '<td>'.$YesNo[$Version['Imported']].'</td></tr>';
100 }
101 $Output .= '</table>'.
102 $PageList['Output'];
103 return $Output;
104 }
105}
106
Note: See TracBrowser for help on using the repository browser.