forked from TheGamesDB/TheGamesDB
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tab_platforms.php
144 lines (124 loc) · 6.79 KB
/
tab_platforms.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<?php
include('simpleimage.php');
function imageResize($filename, $cleanFilename, $target)
{
if(!file_exists($cleanFilename))
{
$dims = getimagesize($filename);
$width = $dims[0];
$height = $dims[1];
//takes the larger size of the width and height and applies the formula accordingly...this is so this script will work dynamically with any size image
if ($width > $height)
{
$percentage = ($target / $width);
}
else
{
$percentage = ($target / $height);
}
//gets the new value and applies the percentage, then rounds the value
$width = round($width * $percentage);
$height = round($height * $percentage);
$image = new SimpleImage();
$image->load($filename);
$image->resize($width, $height);
$image->save($cleanFilename);
$image = null;
}
//returns the new sizes in html image tag format...this is so you can plug this function inside an image tag and just get the
return "src=\"$baseurl/$cleanFilename\"";
}
?>
<div id="gameHead">
<?php if($errormessage): ?>
<div class="error"><?= $errormessage ?></div>
<?php endif; ?>
<?php if($message): ?>
<div class="message"><?= $message ?></div>
<?php endif; ?>
<h1>All Platforms</h1>
<?php
$recentResult = mysql_query(" SELECT p.* FROM platforms AS p ORDER BY p. name ASC ");
$count = 1;
## Platform Items Display
while($recent = mysql_fetch_object($recentResult))
{
?>
<div style=" width: 90%; padding: 16px; margin: 10px auto 20px auto; border-radius: 4px; border: 1px solid #4f4f4f; background-color: #333;">
<?php
if($boxartResult = mysql_query(" SELECT b.filename FROM banners as b WHERE b.keyvalue = '$recent->id' AND b.keytype = 'platform-boxart' LIMIT 1 "))
{
$boxart = mysql_fetch_object($boxartResult);
}
?>
<div style="height: 200px; float: left; padding-right: 12px; width: 202px; text-align: center;">
<?php
if($boxart->filename != "")
{
?>
<img <?=imageResize("$baseurl/banners/$boxart->filename", "banners/_allplatformscache/$boxart->filename", 200)?> alt="<?=$game->GameTitle?> Boxart" style="border: 1px solid #666;"/>
<?php
}
else
{
?>
<img src="<?=$baseurl?>/images/common/placeholders/boxart_blank.png" alt="<?=$game->GameTitle?> Boxart" style="width:140px; height: 200px; border: 1px solid #666;"/>
<?php
}
?>
</div>
<span style="float: right; background-color: #333; padding: 6px; border-radius: 6px;">
<?php
$ratingquery = "SELECT AVG(rating) AS average, count(*) AS count FROM ratings WHERE itemtype='platform' AND itemid=$recent->id";
$ratingresult = mysql_query($ratingquery) or die('Query failed: ' . mysql_error());
$rating = mysql_fetch_object($ratingresult);
for ($i = 2; $i <= 10; $i = $i + 2) {
if ($i <= $rating->average) {
print "<img src=\"$baseurl/images/game/star_on.png\" width=15 height=15 border=0 />";
}
else if ($rating->average > $i - 2 && $rating->average < $i) {
print "<img src=\"$baseurl/images/game/star_half.png\" width=15 height=15 border=0 />";
}
else {
print "<img src=\"$baseurl/images/game/star_off.png\" width=15 height=15 border=0 />";
}
}
?>
</span>
<?php
$gameCountQuery = mysql_query(" SELECT count(*) AS gamecount FROM games WHERE games.platform = $recent->id ");
$gameCountResult = mysql_fetch_object($gameCountQuery);
?>
<h2><?= $count ?>: <img src="<?=$baseurl?>/images/common/consoles/png24/<?=$recent->icon?>" alt="<?=$recent->name?>" style="vertical-align: -6px;" /> <a style="color: orange; text-decoration: underline;" href="<?= $baseurl; ?>/platform/<?php if(!empty($recent->alias)) { echo $recent->alias; } else { echo $recent->id; } ?>/"><?=$recent->name?></a> (<?= $gameCountResult->gamecount ?> games)</h2>
<p style="text-align: justify;"><?php if ($recent->overview != "") { echo substr($recent->overview, 0, 410) . "..."; } else { echo "<br />No Overview Available...<br /><br />"; } ?></p>
<hr />
<div>
<p style="text-align: center;"><a href="<?= $baseurl; ?>/platform/<?php if(!empty($recent->alias)) { echo $recent->alias; } else { echo $recent->id; } ?>/" style="color: orange;">View platform page</a> | <a href="<?= $baseurl ?>/browse/<?= $recent->id ?>/" style="color: orange;">View all games for <?= $recent->name ?></a></p>
<hr />
<p style="text-align: center;">
<?php
$boxartQuery = mysql_query("SELECT keyvalue FROM banners WHERE banners.keyvalue = '$recent->id' AND banners.keytype = 'platform-boxart' LIMIT 1");
$boxartResult = mysql_num_rows($boxartQuery);
$fanartQuery = mysql_query("SELECT keyvalue FROM banners WHERE banners.keyvalue = '$recent->id' AND keytype = 'platform-fanart' LIMIT 1");
$fanartResult = mysql_num_rows($fanartQuery);
$bannerQuery = mysql_query("SELECT keyvalue FROM banners WHERE banners.keyvalue = '$recent->id' AND keytype = 'platform-banner' LIMIT 1");
$bannerResult = mysql_num_rows($bannerQuery);
?>
<?php
if($boxartResult != 0){ ?>Boxart: <img src="<?= $baseurl ?>/images/common/icons/tick_16.png" alt="Yes" style="vertical-align: -3px;" /> | <?php } else{ ?>Boxart: <img src="<?= $baseurl ?>/images/common/icons/cross_16.png" alt="No" style="vertical-align: -3px;" /> | <?php }
if($fanartResult != 0){ ?>Fanart: <img src="<?= $baseurl ?>/images/common/icons/tick_16.png" alt="Yes" style="vertical-align: -3px;" /> | <?php } else{ ?>Fanart: <img src="<?= $baseurl ?>/images/common/icons/cross_16.png" alt="No" style="vertical-align: -3px;" /> | <?php }
if($bannerResult != 0){ ?>Banner: <img src="<?= $baseurl ?>/images/common/icons/tick_16.png" alt="Yes" style="vertical-align: -3px;" /> | <?php } else{ ?>Banner: <img src="<?= $baseurl ?>/images/common/icons/cross_16.png" alt="No" style="vertical-align: -3px;" /> | <?php }
if($recent->console != ""){ ?>Console Art: <img src="<?= $baseurl ?>/images/common/icons/tick_16.png" alt="Yes" style="vertical-align: -3px;" /> | <?php } else{ ?>Console Art: <img src="<?= $baseurl ?>/images/common/icons/cross_16.png" alt="No" style="vertical-align: -3px;" /> | <?php }
if($recent->controller != ""){ ?>Controller Art: <img src="<?= $baseurl ?>/images/common/icons/tick_16.png" alt="Yes" style="vertical-align: -3px;" /> | <?php } else{ ?>Controller Art: <img src="<?= $baseurl ?>/images/common/icons/cross_16.png" alt="No" style="vertical-align: -3px;" /> | <?php }
if($recent->youtube != ""){ ?>Trailer: <img src="<?= $baseurl ?>/images/common/icons/tick_16.png" alt="Yes" style="vertical-align: -3px;" /><?php } else{ ?>Trailer: <img src="<?= $baseurl ?>/images/common/icons/cross_16.png" alt="No" style="vertical-align: -3px;" /><?php }
?>
</p>
</div>
<div style="clear: both;"></div>
</div>
<?php
$count++;
}
?>
<div style="clear: both;"></div>
</div>