Changeset 639 for trunk/Modules/Server


Ignore:
Timestamp:
Dec 11, 2013, 10:21:12 PM (11 years ago)
Author:
chronos
Message:
  • Added: Make server list more general to cover also non-translated servers.
  • Added: Partialy implemented generic view named PageEdit which serve as template to present item lists, add, delete and modify items.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Modules/Server/Server.php

    r637 r639  
    2727}
    2828
    29 
    30 class PageServerList extends Page
     29class PageServerList extends PageEdit
    3130{
    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()
    3349        {
    3450                $this->Title = T('Servers');
     
    3753    'Term "Czech server" doesn\'t mean that server is operated by Czech people but that it is possible to play in Czech.').'.</p>';
    3854    $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();
    6456                return($Output);
    6557        }
Note: See TracChangeset for help on using the changeset viewer.