Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

show 5 most recent battles no individual avatar page. slight layout c…

…hange
  • Loading branch information...
commit ea56c9a03a87290b401b83b2f232a783d14206d2 1 parent a1e4f31
@iamcal iamcal authored
Showing with 73 additions and 14 deletions.
  1. +38 −0 avatar.php
  2. +35 −14 templates/page_avatar.txt
View
38 avatar.php
@@ -50,6 +50,44 @@
#
+ # fetch the most recent 5 battles
+ #
+
+ $recent_count = 5;
+
+ $ret1 = db_fetch("SELECT * FROM glitchmash_votes WHERE win_id=$id_enc ORDER BY date_updated DESC LIMIT $recent_count");
+ $ret2 = db_fetch("SELECT * FROM glitchmash_votes WHERE lose_id=$id_enc ORDER BY date_updated DESC LIMIT $recent_count");
+
+ $votes = array();
+ $smarty->assign_by_ref('votes', $votes);
+
+ foreach (array_merge($ret1['rows'], $ret2['rows']) as $row){
+
+ $opp_id = $row['win_id'] == $avatar['id'] ? $row['lose_id'] : $row['win_id'];
+ $opp = db_single(db_fetch("SELECT * FROM glitchmash_avatars WHERE id='$opp_id'"));
+ $opp_tsid_enc = AddSlashes($opp['player_tsid']);
+ $opp['player'] = db_single(db_fetch("SELECT * FROM glitchmash_players WHERE tsid='$opp_tsid_enc'"));
+
+ $opp['url_50'] = str_replace('_172.png', '_50.png', $opp['url']);
+
+ $votes[] = array(
+ 'did_win' => !!($row['win_id'] == $avatar['id']),
+ 'avatar' => $opp,
+ 'date_updated' => $row['date_updated'],
+ );
+ }
+
+ usort($votes, 'local_vote_sort');
+
+ function local_vote_sort($a, $b){
+ return $b['date_updated'] - $a['date_updated'];
+ }
+
+ $votes = array_slice($votes, 0, $recent_count);
+
+
+
+ #
# output
#
View
49 templates/page_avatar.txt
@@ -6,20 +6,12 @@
<p><a href="/">&laquo; Back to the voting</a></p>
{/if}
-{if $avatar.is_active}
- <p><b>This outfit is still being voted for.</b></p>
-{else}
- <p><b>This outfit is no longer being voted for.</b></p>
-{/if}
- <p>Added {'Y-m-d H:i:s'|date:$avatar.date_added}</p>
-
- <p>This outfit has won {$avatar.wins} votes out of {$avatar.votes}.</p>
-
<div style="border-top: 1px solid #eee; padding: 1em 0;">
<img src="{$avatar.url}" width="172" height="248" style="margin: 0 1em 1em 0; float: left" />
+ <div style="margin: 0 3em 1em 0; float: left">
<table border="0">
{foreach from=$avatar.details item='row2'}
<tr>
@@ -27,20 +19,49 @@
<td>
<a href="{$row2.url}">{$row2.name|escape}</a><br />
{if $row2.sub_only && $row2.credits}
- {$row2.credits} credits, subscribers only<br />
+ <span class="cost">{$row2.credits} credits, subscribers only</span><br />
{elseif $row2.sub_only}
- Free for subscribers<br />
+ <span class="cost">Free for subscribers</span><br />
{elseif $row2.credits}
- {$row2.credits} credits<br />
+ <span class="cost">{$row2.credits} credits</span><br />
{else}
- Free<br />
+ <span class="cost">Free</span><br />
{/if}
</td>
</tr>
{/foreach}
</table>
+ </div>
+
+{if $avatar.is_active}
+ <p><b>This outfit is still being voted for.</b></p>
+{else}
+ <p><b>This outfit is no longer being voted for.</b></p>
+{/if}
+ <p>Added {'Y-m-d H:i:s'|date:$avatar.date_added}</p>
+
+ <p>This outfit has won {$avatar.wins} votes out of {$avatar.votes}.</p>
- <br clear="both" />
+ <p>Check out <a href="http://beta.glitch.com/profiles/{$avatar.player.tsid|escape}/">their profile</a> on Glitch.</p>
+
+ <br clear="all" />
+ </div>
+
+ <div style="border-top: 1px solid #eee; padding: 1em 0;">
+
+ <h2>Recent Battles</h2>
+
+{foreach from=$votes item='row'}
+ <div style="float: left; padding: 1em; width: 120px; text-align: center;">
+{if $row.did_win}
+ Won against<br />
+{else}
+ Lost to<br />
+{/if}
+ <a href="/a-{$row.avatar.id}/"><img src="{$row.avatar.url_50}" width="50" height="72" /></a><br />
+ </div>
+{/foreach}
+ <br clear="all" />
</div>
{include file='inc_foot.txt'}
Please sign in to comment.
Something went wrong with that request. Please try again.