Skip to content

Commit

Permalink
Fixed list and removed old index.php from examples. Need something be…
Browse files Browse the repository at this point in the history
…tter. Fixes #294.
  • Loading branch information
Austinb committed Mar 6, 2016
1 parent 1321d27 commit c170691
Show file tree
Hide file tree
Showing 2 changed files with 107 additions and 254 deletions.
140 changes: 0 additions & 140 deletions examples/index.php

This file was deleted.

221 changes: 107 additions & 114 deletions examples/list.php
Original file line number Diff line number Diff line change
@@ -1,47 +1,41 @@
<?php
// Include the main class file
require '../GameQ.php';
ini_set('display_errors', 1);
// Load auto loader
require_once(__DIR__ . '/../src/GameQ/Autoloader.php');

// Define the protocols path
$protocols_path = GAMEQ_BASE."gameq/protocols/";
$protocols_path = __DIR__ . "/../src/GameQ/Protocols/";

// Grab the dir with all the classes available
$dir = dir($protocols_path);

$protocols = array();
$protocols = [];

// Now lets loop the directories
while (false !== ($entry = $dir->read()))
{
if(!is_file($protocols_path.$entry))
{
continue;
}

// Figure out the class name
$class_name = 'GameQ_Protocols_'.ucfirst(pathinfo($entry, PATHINFO_FILENAME));

// Lets get some info on the class
$reflection = new ReflectionClass($class_name);

// Check to make sure we can actually load the class
if(!$reflection->IsInstantiable())
{
continue;
}

// Load up the class so we can get info
$class = new $class_name;

// Add it to the list
$protocols[$class->name()] = array(
'name' => $class->name_long(),
'port' => $class->port(),
'state' => $class->state(),
);

// Unset the class
unset($class);
while (false !== ($entry = $dir->read())) {
if (!is_file($protocols_path . $entry)) {
continue;
}

// Lets get some info on the class
$reflection = new ReflectionClass('\\GameQ\\Protocols\\' . pathinfo($entry, PATHINFO_FILENAME));

// Check to make sure we can actually load the class
if (!$reflection->IsInstantiable()) {
continue;
}

// Load up the class so we can get info
$class = $reflection->newInstance();

// Add it to the list
$protocols[ $class->name() ] = [
'name' => $class->nameLong(),
'state' => $class->state(),
];

// Unset the class
unset($class);
}

// Close the directory
Expand All @@ -52,87 +46,86 @@
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>GameQ - Supported Games</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<style type="text/css">
* {
font-size: 9pt;
font-family: Verdana, sans-serif;
}
h1 {
font-size: 12pt;
}
table {
border: 1px solid #000;
background-color: #DDD;
border-spacing:1px 1px;
}
table thead {
font-weight: bold;
background-color: #CCC;
}
table tr.uneven td {
background-color:#FFF;
}
table td {
padding: 5px 8px;
}
table tbody {
background-color: #F9F9F9;
}
green {
font-color: #000000;
}
</style>
</head>
<body>
<h1>GameQ - Supported Games (<?php echo count($protocols); ?>)</h1>
<table>
<head>
<title>GameQ v3 - Supported Games</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
<style type="text/css">
* {
font-size: 9pt;
font-family: Verdana, sans-serif;
}

h1 {
font-size: 12pt;
}

table {
border: 1px solid #000;
background-color: #DDD;
border-spacing: 1px 1px;
}

table thead {
font-weight: bold;
background-color: #CCC;
}

table tr.uneven td {
background-color: #FFF;
}

table td {
padding: 5px 8px;
}

table tbody {
background-color: #F9F9F9;
}
</style>
</head>
<body>
<h1>GameQ v3 - Supported Games (<?php echo count($protocols); ?>)</h1>
<table>
<thead>
<tr>
<td>Game Name</td>
<td>GameQ Identifier</td>
<td>Default port</td>
<td>State</td>
</tr>
<tr>
<td>Game Name</td>
<td>GameQ Identifier</td>
<td>State</td>
</tr>
</thead>
<tbody>
<?php

foreach ($protocols AS $gameq => $info)
{


switch($info['state'])
{
case 1:
$state = 'Testing';
break;

case 2:
$state = 'Beta';
break;

case 3:
$state = 'Stable';
break;

case 4:
$state = 'Deprecated';
break;
}

$cls = empty($cls) ? ' class="uneven"' : '';
printf("<tr%s><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>\n", $cls,
htmlentities($info['name']),
$gameq,
$info['port'],
$state
);
}
?>
<tbody>
<?php

foreach ($protocols AS $gameq => $info) {


switch ($info['state']) {
case 1:
$state = 'Testing';
break;

case 2:
$state = 'Beta';
break;

case 3:
$state = 'Stable';
break;

case 4:
$state = 'Deprecated';
break;
}

$cls = empty($cls) ? ' class="uneven"' : '';
printf("<tr%s><td>%s</td><td>%s</td><td>%s</td></tr>\n", $cls,
htmlentities($info['name']),
$gameq,
$state
);
}
?>
</tbody>
</table>
</table>
</body>
</html>

0 comments on commit c170691

Please sign in to comment.