Skip to content

Commit

Permalink
Merge branch 'release/0.5.5'
Browse files Browse the repository at this point in the history
  • Loading branch information
ta2edchimp committed Oct 8, 2015
2 parents eb3d257 + f628954 commit 9c8ed52
Show file tree
Hide file tree
Showing 10 changed files with 102 additions and 20 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# Release 0.5.5

- a72e7e2 Versionbump.
- 00f0a5e Change imageserver links. Closes #93
- 3bde826 Implemented pagination of BattleReports Overview. Closes #86
- 6a2fd18 Merge branch 'release/0.5.4' into develop

# Release 0.5.4

- 66726cb Versionbump
Expand Down
30 changes: 30 additions & 0 deletions classes/Battle.php
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,13 @@ public static function getList(array $options = array()) {
$limit = " limit :limit";
$params["limit"] = intval($options["count"]);
}
if (isset($options["page"]) && is_int($options["page"])) {
if (!isset($options["count"]) || empty($options["count"])) {
$params["limit"] = 10;
}
$limit = " limit :offset, :limit";
$params["offset"] = (intval($options["page"]) - 1) * $params["limit"];
}
}

$db = Db::getInstance();
Expand Down Expand Up @@ -772,6 +779,29 @@ public static function getList(array $options = array()) {

}

public static function getBattlesCount(array $options = array()) {

$battlesCount = 0;

$onlyPublished = isset($options["onlyPublished"]) && is_bool($options["onlyPublished"]) ? $options["onlyPublished"] : true;

$db = \Db::getInstance();

$result = $db->single(
"select count(battleReportID) as battlesCount " .
"from brBattles " .
"where brDeleteTime is NULL " .
($onlyPublished ? "and brPublished = 1 " : "")
);

if ($result !== NULL && $result !== FALSE) {
$battlesCount = $result;
}

return $battlesCount;

}

public static function updateStats($battleReportID = 0) {
if ($battleReportID <= 0) {
return false;
Expand Down
2 changes: 1 addition & 1 deletion index.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

define('BR_VERSION', '0.5.4');
define('BR_VERSION', '0.5.5');

require_once('vendor/autoload.php');

Expand Down
2 changes: 1 addition & 1 deletion public/themes/default/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
{% if BR_USER_CHARACTERID is defined %}
<img id="character-portrait" src="//image.eveonline.com/Character/{{ BR_USER_CHARACTERID }}_64.jpg">
<img id="character-portrait" src="//imageserver.eveonline.com/Character/{{ BR_USER_CHARACTERID }}_64.jpg">
{% endif %}
{{ BR_USER_NAME }}
<span class="caret"></span>
Expand Down
2 changes: 1 addition & 1 deletion public/themes/default/components/brCombatant.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<tr class="combatant{% if combatant.died %} danger{% endif %}{% if combatant.brHidden %} hidden-on-br{% endif %}" data-combatant-id="{{ combatant.brCombatantID }}" data-kill-id="{{ combatant.killID }}" data-character-id="{{ combatant.characterID }}">
<td>
<div class="ship-icon-container">
<img src="//image.eveonline.com/InventoryType/{{ combatant.shipTypeID }}_64.png">
<img src="//imageserver.eveonline.com/InventoryType/{{ combatant.shipTypeID }}_64.png">
{% if (combatant.shipGroup is defined and combatant.shipGroup != 'DPS') or combatant.brCyno == true %}
<div class="ship-type-icon">
{% if combatant.brCyno == true %}
Expand Down
2 changes: 1 addition & 1 deletion public/themes/default/components/brFootage.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ <h3 class="panel-title">Battle Footage</h3>
<table id="battlereport-{{ currentTeamID }}" class="table table-striped table-hover battlereport-combatants">
<tbody>
<tr class="combatant">
<td><img src="//image.eveonline.com/InventoryType/{{ combatant.shipTypeID }}_64.png"></td>
<td><img src="//imageserver.eveonline.com/InventoryType/{{ combatant.shipTypeID }}_64.png"></td>
<td style="width:100%">
<div class="combatant-details">
{% if combatant.characterName != '' %}<strong>{{ combatant.characterName }}</strong><br>{% endif %}
Expand Down
23 changes: 23 additions & 0 deletions public/themes/default/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ <h1>{{ BR_OWNER }}'s BattleReports</h1>
{% if battleList|length == 0 %}
<div class="panel">
<div class="panel-body">
{% if currentPage <= 1 %}
<strong>No Battles</strong> stored in {{ BR_OWNER }}'s BattleReporter yet.
{% else %}
There are <strong>no Battles</strong> stored from this far ago ...
{% endif %}
</div>
</div>
{% else %}
Expand Down Expand Up @@ -62,6 +66,25 @@ <h1>{{ BR_OWNER }}'s BattleReports</h1>
</tbody>
</table>
{% endif %}
{% if totalPages > 1 %}
<div style="text-align:center">
<ul class="pagination">
{% if currentPage > 4 %}
<li><a href="/page/1">&laquo; First</a></li>
{% endif %}
{% for i in range(currentPage - 3, currentPage - 1) if (i > 0) %}
<li><a href="/page/{{ i }}">{{ i }}</a></li>
{% endfor %}
<li class="active"><a href="/page/{{ currentPage }}">{{ currentPage }}</a></li>
{% for i in range(currentPage + 1, currentPage + 3) if (i <= totalPages) %}
<li><a href="/page/{{ i }}">{{ i }}</a></li>
{% endfor %}
{% if currentPage < (totalPages - 4) %}
<li><a href="/page/{{ totalPages }}">Last &raquo;</a></li>
{% endif %}
</ul>
</div>
{% endif %}
{% endblock %}

{% block scripts %}
Expand Down
10 changes: 5 additions & 5 deletions public/themes/default/show.html
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ <h4 class="list-group-item-heading text-center">Team C</h4>
<tr>
{% if event.occurredToTeamA %}
{% set combatant = event.combatantEventOccuredTo %}
<td class="danger combatant" data-kill-id="{{ event.killID }}"><img src="//image.eveonline.com/InventoryType/{{ combatant.shipTypeID }}_64.png"></td>
<td class="danger combatant" data-kill-id="{{ event.killID }}"><img src="//imageserver.eveonline.com/InventoryType/{{ combatant.shipTypeID }}_64.png"></td>
<td class="danger combatant" data-kill-id="{{ event.killID }}" style="width:{{ pilotColWidth }}">
<div class="combatant-details">
{% if combatant.characterName != '' %}<strong>{{ combatant.characterName }}</strong><br>{% endif %}
Expand All @@ -175,7 +175,7 @@ <h4 class="list-group-item-heading text-center">Team C</h4>
<td class="text-center">{{ event.timeStampString }}</td>
{% if event.occurredToTeamB %}
{% set combatant = event.combatantEventOccuredTo %}
<td class="danger combatant" data-kill-id="{{ event.killID }}"><img src="//image.eveonline.com/InventoryType/{{ combatant.shipTypeID }}_64.png"></td>
<td class="danger combatant" data-kill-id="{{ event.killID }}"><img src="//imageserver.eveonline.com/InventoryType/{{ combatant.shipTypeID }}_64.png"></td>
<td class="danger combatant" data-kill-id="{{ event.killID }}" style="width:{{ pilotColWidth }}">
<div class="combatant-details">
{% if combatant.characterName != '' %}<strong>{{ combatant.characterName }}</strong><br>{% endif %}
Expand All @@ -192,7 +192,7 @@ <h4 class="list-group-item-heading text-center">Team C</h4>
<td class="text-center">{{ event.timeStampString }}</td>
{% if event.occurredToTeamC %}
{% set combatant = event.combatantEventOccuredTo %}
<td class="danger combatant" data-kill-id="{{ event.killID }}"><img src="//image.eveonline.com/InventoryType/{{ combatant.shipTypeID }}_64.png"></td>
<td class="danger combatant" data-kill-id="{{ event.killID }}"><img src="//imageserver.eveonline.com/InventoryType/{{ combatant.shipTypeID }}_64.png"></td>
<td class="danger combatant" data-kill-id="{{ event.killID }}" style="width:{{ pilotColWidth }}">
<div class="combatant-details">
{% if combatant.characterName != '' %}<strong>{{ combatant.characterName }}</strong><br>{% endif %}
Expand Down Expand Up @@ -220,7 +220,7 @@ <h4 class="list-group-item-heading text-center">Team C</h4>
{% set separator = '' %}
{% for comment in comments %}
{{ separator|raw }}
<div id="comment-{{ comment.commentID }}" class="comment"{% if comment.characterID is defined and comment.characterID != '' %} style="background-image:url(//image.eveonline.com/Character/{{ comment.characterID }}_64.jpg)"{% endif %}>
<div id="comment-{{ comment.commentID }}" class="comment"{% if comment.characterID is defined and comment.characterID != '' %} style="background-image:url(//imageserver.eveonline.com/Character/{{ comment.characterID }}_64.jpg)"{% endif %}>
<p><strong>{{ comment.userName }}</strong><br>
<small>{{ comment.commentTime|time_ago }}</small></p>
<p>{{ comment.commentMessage|enable_urls }}</p>
Expand Down Expand Up @@ -248,7 +248,7 @@ <h4 class="list-group-item-heading text-center">Team C</h4>
{% else %}
{% if BR_USER_LOGGEDIN %}
<form action="/comment/{{ battleReport.battleReportID }}" method="post">
<div class="form-group"{% if BR_USER_CHARACTERID is defined %} style="background-image:url(//image.eveonline.com/Character/{{ BR_USER_CHARACTERID }}_128.jpg);background-position:100% 0;background-size:contain;background-repeat:no-repeat"{% endif %}>
<div class="form-group"{% if BR_USER_CHARACTERID is defined %} style="background-image:url(//imageserver.eveonline.com/Character/{{ BR_USER_CHARACTERID }}_128.jpg);background-position:100% 0;background-size:contain;background-repeat:no-repeat"{% endif %}>
<label class="control-label">Comment as:</label>
<div>
{{ BR_USER_NAME }}
Expand Down
8 changes: 7 additions & 1 deletion routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,14 @@
* Default routings
*/
// Homepage
$app->get('/', function () use ($app, $db) {
$app->get('/(page/:currentPage)', function ($currentPage = 0) use ($app, $db) {

if (empty($currentPage) || !is_numeric($currentPage)) {
$currentPage = 1;
} else {
$currentPage = intval($currentPage);
}

include("views/index.php");

});
Expand Down
36 changes: 26 additions & 10 deletions views/index.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,26 @@
<?php

/**
* Comes from routes:
* ==================
*
* int $currentPage currently requested page (default: 1)
*/

$output = array();

$battlesCountTotal = Battle::getBattlesCount(array(
"onlyPublished" => !(User::isLoggedIn() && User::can("edit"))
));

$output["currentPage"] = $currentPage;
$output["totalPages"] = intval(floor($battlesCountTotal / 20) + 1);

$params = array();

$battleList = Battle::getList(array(
"page" => $currentPage,
"count" => 20,
"onlyPublished" => !(User::isLoggedIn() && User::can("edit"))
));

Expand Down Expand Up @@ -34,17 +50,17 @@

$output["battleList"] = $battleList;

$previewEfficiencyAvg = ($previewEfficiencyAvg * 100) / $previewBattlesTotal;
// $previewEfficiencyAvg = ($previewEfficiencyAvg * 100) / $previewBattlesTotal;

if ($previewISKdestroyed < 1000000000000) {
if ($previewISKdestroyed < 1000000000) {
$previewISKdestroyed = number_format($previewISKdestroyed / 1000000, 2, '.', ',') . " million";
} else {
$previewISKdestroyed = number_format($previewISKdestroyed / 1000000000, 2, '.', ',') . " billion";
}
} else {
$previewISKdestroyed = number_format($previewISKdestroyed / 1000000000000, 2, '.', ',') . " trillion";
}
// if ($previewISKdestroyed < 1000000000000) {
// if ($previewISKdestroyed < 1000000000) {
// $previewISKdestroyed = number_format($previewISKdestroyed / 1000000, 2, '.', ',') . " million";
// } else {
// $previewISKdestroyed = number_format($previewISKdestroyed / 1000000000, 2, '.', ',') . " billion";
// }
// } else {
// $previewISKdestroyed = number_format($previewISKdestroyed / 1000000000000, 2, '.', ',') . " trillion";
// }

}

Expand Down

0 comments on commit 9c8ed52

Please sign in to comment.