Permalink
Browse files

added basic arena-team index- and show-feature

  • Loading branch information...
1 parent fbe9433 commit ff45d6ad2cb86ca1fd6073ff3b260dff7fcb2ab6 @reddragon010 reddragon010 committed Jan 20, 2012
@@ -0,0 +1,64 @@
+<?php
+/*
+ * Copyright (C) 2011 Michael Riedmann <michael.riedmann@gmx.net>
+ *
+ * his file is part of RG-ServerPanel.
+ *
+ * RG-ServerPanel is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * RG-ServerPanel is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with RG-ServerPanel. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+class ArenaTeamsController extends BaseController {
+ var $before = array(
+ 'check_login'
+ );
+
+ function index($params=array()) {
+ $realms = Realm::find()->all();
+ $realmnames = array('all' => 'All');
+ foreach($realms as $r){
+ $realmnames[$r->id] = $r->name;
+ }
+
+ $find = ArenaTeam::find()->where(array_filter($params))->page($params['page']);
+
+ $teams = array();
+ $teams_count = 0;
+ if(isset($params['realm']) && is_numeric($params['realm'])){
+ $find = $find->realm($params['realm']);
+ $teams += $find->all();
+ $teams_count += $find->count();
+ } else {
+ $teams_count = 0;
+ foreach ($realms as $realm) {
+ $find = $find->realm($realm->id);
+ $teams += $find->all();
+ $teams_count += $find->count();
+ }
+ }
+
+ $this->render(array(
+ 'teams' => $teams,
+ 'teams_count' => $teams_count,
+ 'realmnames' => $realmnames
+ ));
+ }
+
+ function show($params){
+ $team = ArenaTeam::find()->where(array('arenateamid'=> $params['id']))->realm($params['rid'])->first();
+ $data = array(
+ 'team' => $team
+ );
+ $this->render($data);
+ }
+}
@@ -0,0 +1,53 @@
+<?php
+/*
+ * Copyright (C) 2011 Michael Riedmann <michael.riedmann@gmx.net>
+ *
+ * his file is part of RG-ServerPanel.
+ *
+ * RG-ServerPanel is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * RG-ServerPanel is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with RG-ServerPanel. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+class ArenaTeam extends BaseModel {
+ static $dbname = 'realm';
+ static $dbid = null;
+ static $table = 'arena_team';
+ static $primary_key = 'arenateamid';
+ static $name_field = 'name';
+ static $plural = 'arenateams';
+ static $fields = array(
+ 'arenateamid',
+ 'name',
+ 'type',
+ 'rating',
+ 'seasongames',
+ 'seasonwins',
+ 'weekgames',
+ 'weekwins',
+ );
+
+ public function scope_realm($find, $realm_id){
+ $find->dbid = $realm_id;
+ $find->additions(array('realm' => Realm::find($realm_id)));
+ return $find;
+ }
+
+ public function get_members(){
+ $find = Character::find()
+ ->realm($this->realm->id)
+ ->join("INNER", 'arena_team_member' ,array('weekgames','weekwins','seasongames','seasonwins','personalrating','arenateamid'),'guid')
+ ->where(array('arena_team_member.arenateamid' => $this->arenateamid));
+ $members = $find->all();
+ return $members;
+ }
+}
@@ -0,0 +1,16 @@
+<form method="get" id="form" name="form" action="{{link_to('arena_teams','index')}}">
+ <fieldset>
+ <label for="name">Name</label>
+ <input type="text" name="name" value="{{ params.name }}" />
+
+ <label for="teamid">ID</label>
+ <input type="text" name="arenateamid" value="{{ params.arenateamid }}" />
+
+ <label for="realm">Realm</label>
+ {{ selectArray('realm',realmnames,params.realm) }}
+
+ <input type="submit" name="submit" value="Filter" />
+ </fieldset>
+</form>
+
+
@@ -0,0 +1,30 @@
+{% extends "base.tpl.html" %}
+
+{% block content %}
+{% include "filter.tpl.html" %}
+{{ pagination_bar('ArenaTeam', teams_count) }}
+<table class="hovering" style="text-align: center">
+ <thead>
+ <tr>
+ <th>{{ t('name') }}</th>
+ <th>Type</th>
+ <th>Rating</th>
+ <th>SeasonWins</th>
+ <th>WeekWins</th>
+ <th>Realm</th>
+ </tr>
+ </thead>
+ <tbody>
+ {% for team in teams %}
+ <tr>
+ <td style="text-align: left">#{{ team.arenateamid }} <a href="{{link_to('arena_teams', 'show', {'id': team.arenateamid, 'rid': team.realm.id})}}">{{ team.name }}</a></td>
+ <td>{{team.type}}vs{{team.type}}</td>
+ <td>{{ team.rating }}</td>
+ <td>{{team.seasonwins}} of {{team.seasongames}}</td>
+ <td>{{team.weekwins}} of {{team.weekgames}}</td>
+ <td>{{team.realm.name}}</td>
+ </tr>
+ {% endfor %}
+ </tbody>
+</table>
+{% endblock content %}
@@ -0,0 +1,58 @@
+{% extends "base.tpl.html" %}
+{% block headline %}
+<h2>#{{team.arenateamid}} {{team.name}}</h2>
+{% endblock %}
+
+{% block content %}
+
+<div style="float:left; width: 24%">
+ <table style="text-align: left" class="hovering">
+ <tr>
+ <th>Type:</th>
+ <td>{{team.type}}vs{{team.type}}</td>
+ </tr>
+ <tr>
+ <th>Rating:</th>
+ <td>{{team.rating}}</td>
+ </tr>
+ <tr>
+ <th>SeasonStats:</th>
+ <td>{{team.seasonwins}} Wins - {{team.seasongames}} Games</td>
+ </tr>
+ <tr>
+ <th>WeekStats:</th>
+ <td>{{team.weekwins}} Wins - {{team.weekgames}} Games</td>
+ </tr>
+ </table>
+</div>
+<div style="float:right; width: 74%">
+ <table style="text-align: left" class="hovering">
+ <thead>
+ <tr style="text-align: left">
+ <th></th>
+ <th>{{ t('name') }} (GUID)</th>
+ <th>{{ t('account','name') }}</th>
+ <th>{{ t('level') }}</th>
+ <th>Rating</th>
+ <th>SeasonStats</th>
+ <th>WeekStats</th>
+ <th style="width: 50px">{{ t('status') }}</th>
+ </tr>
+ </thead>
+ <tbody>
+ {% for char in team.members %}
+ <tr>
+ <td>{{ char|factionicon }} {{char|raceicon}} {{char|classicon}}</td>
+ <td>#{{ char.guid }} {{link_to_character(char)}}</td>
+ <td>{{ link_to_character_account(char) }}</td>
+ <td>{{ char.level }}</td>
+ <td>{{ char.personalrating }}</td>
+ <td>{{ char.seasonwins }} Wins - {{ char.seasongames }} Games</td>
+ <td>{{ char.weekwins }} Wins - {{ char.weekgames }} Games</td>
+ <td>{{ char|character_status }}</td>
+ </tr>
+ {% endfor %}
+ </tbody>
+ </table>
+</div>
+{% endblock content %}
@@ -11,6 +11,9 @@
{% if permitted_to('index','guilds') %}
<li><a href="{{link_to('guilds', 'index')}}">Guilds</a></li>
{% endif %}
+ {% if permitted_to('index','arenateams') %}
+ <li><a href="{{link_to('arena_teams', 'index')}}">ArenaTeams</a></li>
+ {% endif %}
{% if permitted_to('index','premiumcodes') %}
<li><a href="{{link_to('premium_codes', 'index')}}">Premium-Codes</a></li>
{% endif %}

0 comments on commit ff45d6a

Please sign in to comment.