Changeset 639
- Timestamp:
- Dec 11, 2013, 10:21:12 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/Server/Server.php
r637 r639 27 27 } 28 28 29 30 class PageServerList extends Page 29 class PageServerList extends PageEdit 31 30 { 32 function Show() 31 function __construct($System) 32 { 33 parent::__construct($System); 34 $this->Table = 'Server'; 35 $this->TableSQL = 'SELECT `Name`, `URL`, `Parts`, `XPRate`, `GameplayStyle`, '. 36 '`ClientVersion`.`Version` AS `Version` FROM `Server` '. 37 'LEFT JOIN `ClientVersion` ON `ClientVersion`.`Id` = `Server`.`ClientVersion`'; 38 $this->Definition = array( 39 'Name' => array('Type' => 'String', 'Title' => T('Name')), 40 'URL' => array('Type' => 'URL', 'Title' => T('URL')), 41 'Parts' => array('Type' => 'String', 'Title' => T('Translated')), 42 'XPRate' => array('Type' => 'String', 'Title' => T('XP rate')), 43 'GameplayStyle' => array('Type' => 'String', 'Title' => T('Style')), 44 'ClientVersion' => array('Type' => 'String', 'Title' => T('Client version')), 45 ); 46 } 47 48 function ViewList() 33 49 { 34 50 $this->Title = T('Servers'); … … 37 53 'Term "Czech server" doesn\'t mean that server is operated by Czech people but that it is possible to play in Czech.').'.</p>'; 38 54 $Output .= '<h3>'.T('Translated server list').'</h3>'; 39 40 $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM `ServerList`'); 41 $DbRow = $DbResult->fetch_row(); 42 $PageList = GetPageList($DbRow[0]); 43 44 $Output .= $PageList['Output']; 45 $Output .= '<table class="BaseTable">'; 46 47 $TableColumns = array( 48 array('Name' => 'Name', 'Title' => T('Name')), 49 array('Name' => 'Parts', 'Title' => T('Translated')), 50 ); 51 $Order = GetOrderTableHeader($TableColumns, 'Name', 1); 52 $Output .= $Order['Output']; 53 54 $Query = 'SELECT `URL`, `Name` FROM `ServerList` '.$Order['SQL'].$PageList['SQLLimit']; 55 56 $DbResult = $this->System->Database->query($Query); 57 while($Line = $DbResult->fetch_assoc()) 58 { 59 $Output .= '<tr><td><a href="'.$Line['URL'].'">'.$Line['Name'].'</a></td>'. 60 '<td>'.$Line['Parts'].'</td></tr>'; 61 } 62 $Output .= '</table>'. 63 $PageList['Output']; 55 $Output .= parent::ViewList(); 64 56 return($Output); 65 57 } -
trunk/admin/UpdateTrace.php
r610 r639 2649 2649 } 2650 2650 2651 function UpdateTo639($Manager) 2652 { 2653 $Manager->Execute('ALTER TABLE `ServerList` ADD `ClientVersion` INT NOT NULL , 2654 ADD INDEX ( `ClientVersion` ) ;'); 2655 $Manager->Execute('ALTER TABLE `ServerList` ADD FOREIGN KEY ( `ClientVersion` ) REFERENCES `ClientVersion` ( 2656 `Id`) ON DELETE RESTRICT ON UPDATE RESTRICT ;'); 2657 $Manager->Execute('RENAME TABLE `ServerList` TO `Server` ;'); 2658 $Manager->Execute('ALTER TABLE `Server` ADD `Description` TEXT NOT NULL ;'); 2659 $Manager->Execute('ALTER TABLE `Server` CHANGE `OnlineState` `LastOnlineTime` DATETIME NOT NULL ;'); 2660 $Manager->Execute('ALTER TABLE `Server` ADD INDEX (`UserCreate`)'); 2661 $Manager->Execute('ALTER TABLE `Server` ADD FOREIGN KEY ( `UserCreate` ) REFERENCES `User` ( 2662 `ID`) ON DELETE RESTRICT ON UPDATE RESTRICT ;'); 2663 $Manager->Execute('ALTER TABLE `Server` ADD `CheckIP` VARCHAR( 16 ) NOT NULL , 2664 ADD `CheckPort` INT NOT NULL ;'); 2665 } 2651 2666 2652 2667 $Updates = array( … … 2664 2679 604 => array('Revision' => 609, 'Function' => 'UpdateTo609'), 2665 2680 609 => array('Revision' => 610, 'Function' => 'UpdateTo610'), 2681 610 => array('Revision' => 639, 'Function' => 'UpdateTo639'), 2666 2682 ); -
trunk/includes/Page.php
r636 r639 26 26 } 27 27 } 28 29 class PageEdit extends Page 30 { 31 var $Table; 32 var $Definition; 33 34 function __construct($System) 35 { 36 parent::__construct($System); 37 $this->Table = ''; 38 $this->Definition = array(); 39 } 40 41 function Show() 42 { 43 $Output = ''; 44 if(array_key_exists('action', $_GET)) 45 { 46 if($_GET['action'] == 'add') $Output .= $this->AddItem(); 47 else if($_GET['action'] == 'view') $Output .= $this->ViewItem(); 48 else if($_GET['action'] == 'remove') $Output .= $this->RemoveItem(); 49 else if($_GET['action'] == 'delete') $Output .= $this->DeleteItem(); 50 else $Output .= ShowMessage(T('Unknown action'), MESSAGE_CRITICAL); 51 } else $Output .= $this->ViewList(); 52 return($Output); 53 } 54 55 function ViewItem() 56 { 57 $Output = ''; 58 return($Output); 59 } 60 61 function ViewList() 62 { 63 $DbResult = $this->Database->query('SELECT COUNT(*) FROM ('.$this->TableSQL.') AS `T`'); 64 $DbRow = $DbResult->fetch_row(); 65 $PageList = GetPageList($DbRow[0]); 66 $Output = $PageList['Output']; 67 68 $Output .= '<table class="BaseTable">'; 69 $TableColumns = array(); 70 foreach($this->Definition as $Index => $Def) 71 $TableColumns[] = array('Name' => $Index, 'Title' => $Def['Title']); 72 73 $Order = GetOrderTableHeader($TableColumns, 'Name', 0); 74 $Output .= $Order['Output']; 75 76 $DbResult = $this->Database->query('SELECT * FROM ('.$this->Table.') '.$Order['SQL'].$PageList['SQLLimit']); 77 while($Item = $DbResult->fetch_assoc()) 78 { 79 $Output .= '<tr>'; 80 foreach($this->Definition as $Index => $Def) 81 { 82 if($Def['Type'] == 'URL') $Output .= '<td><a href="'.$Item[$Index].'">'.$Item[$Index].'</a></td>'; 83 else $Output .= '<td>'.$Item[$Index].'</td>'; 84 } 85 $Output .= '</tr>'; 86 } 87 $Output .= '</table>'; 88 return($Output); 89 } 90 91 function AddItem() 92 { 93 $Output = ''; 94 if($this->System->User->Licence(LICENCE_USER)) 95 { 96 if(array_key_exists('finish', $_GET)) 97 { 98 $Items = array(); 99 foreach($this->Definition as $Index => $Def) 100 { 101 $Items[$Index] = $_POST[$Index]; 102 } 103 $this->Database->insert($this->Table, $Items); 104 $Output = ShowMessage(T('Item added'), MESSAGE_INFORMATION); 105 } else 106 { 107 $Output .= '<form action="?action=add&finish=1" method="post">'. 108 '<fieldset><legend>'.T('New item').'</legend>'. 109 '<table>'; 110 foreach($this->Definition as $DefIndex => $Def) 111 { 112 $Output .= '<tr><td>'.$Def['Title'].'</td><td>'.$this->GetControl($Def['Type'], $DefIndex).'</tr>'; 113 } 114 $Output .= '<tr><td colspan="2"><input type="submit" value="'.T('Add').'" /></td></tr>'. 115 '</table>'. 116 '</fieldset>'. 117 '</form>'; 118 } 119 } else $Output .= ShowMessage(T('Access denied'), MESSAGE_CRITICAL); 120 return($Output); 121 } 122 123 124 function DeleteItem() 125 { 126 if($this->System->User->Licence(LICENCE_USER)) 127 { 128 $this->Database->query('DELETE FROM `'.$this->Table.'` WHERE (`User`='.$this->System->User->Id.') AND (`Id`='.($_GET['id'] * 1).')'); 129 $Output = ShowMessage(T('Record removed')); 130 } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL); 131 return($Output); 132 } 133 134 function GetControl($Type, $Name) 135 { 136 if($Type == 'Text') $Output = '<input type="text" name="'.$Name.'"/>'; 137 else if($Type == 'Boolean') $Output = '<input type="checkbox" name="'.$Name.'"/>'; 138 else $Output = '<input type="text" name="'.$Name.'"/>'; 139 } 140 } -
trunk/includes/Version.php
r637 r639 6 6 // and system will need database update. 7 7 8 $Revision = 63 7; // Subversion revision8 $Revision = 639; // Subversion revision 9 9 $DatabaseRevision = 610; // Database structure revision 10 10 $ReleaseTime = '2013-12-11';
Note:
See TracChangeset
for help on using the changeset viewer.