1
0

Finished Highscore API

This commit is contained in:
2014-07-20 16:18:05 +02:00
parent 49b7368f44
commit e4a08ce32d
11 changed files with 661 additions and 1 deletions

View File

@@ -0,0 +1,8 @@
<?php
/* @var $this HighscoresController */
/* @var $game HighscoreGames */
for ($i = 0; $i < 50; $i++)
{
print($game->ENTRIES[$i]->POINTS . '||' . htmlentities($game->ENTRIES[$i]->PLAYER) . "\r\n");
}

View File

@@ -0,0 +1,102 @@
<?php
/* @var $this HighscoresController */
/* @var $game HighscoreGames */
/* @var $start int */
/* @var $highlight int */
/* @var $pagesize int */
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta charset="utf-8"/>
<title>highscores</title>
<style type="text/css">
<!--
body {
background-color: #DDF;
padding: 1em 1em 0em;
}
table {
margin: auto;
width: 80%;
text-align: center;
border-spacing: 0px;
}
table td {
padding: 2px 0px;
}
caption {
font-weight: bolder;
text-decoration: underline;
font-size: x-large;
}
a {
color: #008;
text-decoration: underline;
}
a:hover { text-decoration: none; }
#headline > td { text-decoration: underline; }
#highlight {
font-weight: bolder;
background-color: #CCF;
}
-->
</style>
</head>
<body>
<table>
<caption><?php echo $game->NAME; ?></caption>
<tr id="headline" >
<td>rank</td>
<td>points</td>
<td>name</td>
</tr>
<?php
$current = 0;
foreach ($game->ENTRIES as $entry)
{
$current++;
if ($current >= $start && $current - $start <= $pagesize)
{
if ($current == $highlight)
echo '<tr id="highlight">';
else
echo "<tr>";
echo "<td>$current</td>";
echo "<td>$entry->POINTS</td>";
echo "<td>$entry->PLAYER</td>";
echo "</tr>";
}
}
$more = max(0, $start - $pagesize);
$less = $start + $pagesize;
echo '<tr>';
if ($start > 0)
echo '<td><a href="' . "/Highscores/list?gameid=$game->ID&start=$more&highlight=$highlight" . '">[more points]</a></td>';
else
echo '<td></td>';
echo '<td></td>';
if ($start + $pagesize < count($game->ENTRIES))
echo '<td><a href="' . "/Highscores/list?gameid=$game->ID&start=$less&highlight=$highlight" . '">[less points]</a></td>';
else
echo '<td></td>';
echo '</tr>';
?>
</table>
</body>
</html>

View File

@@ -0,0 +1,36 @@
<?php
/* @var $this HighscoresController */
/* @var $games HighscoreGames[] */
?>
<html>
<head>
<meta charset="utf-8"/>
<title>highscores</title>
<style type="text/css">
<!--
body {
background-color: #DDF;
padding: 1em 1em 0em;
}
a {
color: #008;
text-decoration: underline;
}
a:hover { text-decoration: none; }
-->
</style>
</head>
<body>
<?php
foreach ($games as $game)
{
echo '<a href="' . $game->getListLink() . '">' . $game->NAME . '</a><br>' . "\r\n";
}
?>
</body>
</html>

View File

@@ -0,0 +1,7 @@
<?php
/* @var $this APIController */
/* @var $gm HighscoreGames */
$gm = HighscoreGames::model()->findByPk(1);
echo nl2br(print_r( $gm->ENTRIES, true));