diff --git a/CHANGELOG.md b/CHANGELOG.md index 953d5d6..454942c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/classes/Battle.php b/classes/Battle.php index 4959238..8e1e81c 100644 --- a/classes/Battle.php +++ b/classes/Battle.php @@ -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(); @@ -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; diff --git a/index.php b/index.php index e4ca62b..33c48c1 100644 --- a/index.php +++ b/index.php @@ -1,6 +1,6 @@
+
+ {% endif %} {% endblock %} {% block scripts %} diff --git a/public/themes/default/show.html b/public/themes/default/show.html index 7f090f4..9ec558c 100644 --- a/public/themes/default/show.html +++ b/public/themes/default/show.html @@ -159,7 +159,7 @@

Team C

{% if event.occurredToTeamA %} {% set combatant = event.combatantEventOccuredTo %} - +
{% if combatant.characterName != '' %}{{ combatant.characterName }}
{% endif %} @@ -175,7 +175,7 @@

Team C

{{ event.timeStampString }} {% if event.occurredToTeamB %} {% set combatant = event.combatantEventOccuredTo %} - +
{% if combatant.characterName != '' %}{{ combatant.characterName }}
{% endif %} @@ -192,7 +192,7 @@

Team C

{{ event.timeStampString }} {% if event.occurredToTeamC %} {% set combatant = event.combatantEventOccuredTo %} - +
{% if combatant.characterName != '' %}{{ combatant.characterName }}
{% endif %} @@ -220,7 +220,7 @@

Team C

{% set separator = '' %} {% for comment in comments %} {{ separator|raw }} -
+

{{ comment.userName }}
{{ comment.commentTime|time_ago }}

{{ comment.commentMessage|enable_urls }}

@@ -248,7 +248,7 @@

Team C

{% else %} {% if BR_USER_LOGGEDIN %}
-
+
{{ BR_USER_NAME }} diff --git a/routes.php b/routes.php index 0d97235..ca55839 100644 --- a/routes.php +++ b/routes.php @@ -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"); }); diff --git a/views/index.php b/views/index.php index 3185282..ef26a4c 100644 --- a/views/index.php +++ b/views/index.php @@ -1,10 +1,26 @@ !(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")) )); @@ -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"; + // } }