8 Commits

Author SHA1 Message Date
Wruczek 9257912eb7 Version bump 2019-01-15 13:39:44 +01:00
Wruczek 355df433c1 Added a ban list loader, hiding the table until it fully initializes 2019-01-15 13:29:39 +01:00
Wruczek d36099a8e3 Fixed priority speaker icon in viewer 2019-01-13 21:26:34 +01:00
Wruczek b8e3cd2466 Forgotten space 2019-01-12 10:53:53 +01:00
Wruczek f45e0a03d8 Configurable language cache interval, sort languages by their native name 2019-01-10 13:16:25 +01:00
Wruczek 84453234b4 Updated languages 2019-01-10 13:07:07 +01:00
Wruczek be2a2dc473 Make use of DateUtils class, update composer error message 2019-01-10 12:50:12 +01:00
Wruczek cf990c8544 Bugfix: use single quotes in config
So that the passwords with a dollar ($) wont be parsed into a variable by PHP
2019-01-09 13:48:46 +01:00
11 changed files with 1470 additions and 1459 deletions
+1
View File
@@ -19,6 +19,7 @@ INSERT INTO `DBPREFIXconfig` (`identifier`, `type`, `value`, `user_editable`) VA
('loginpokeclient', 'BOOL', 'true', 1),
('cache_logincode', 'INT', '120', 1),
('cache_adminstatus', 'INT', '60', 1),
('cache_languages', 'INT', '300', 1),
('adminstatus_groups', 'JSON', '[]', 1),
('adminstatus_mode', 'INT', '2', 1),
('adminstatus_enabled', 'BOOL', 'true', 1),
File diff suppressed because it is too large Load Diff
+2 -2
View File
@@ -9,8 +9,8 @@ if (!file_exists(__PRIVATE_DIR . "/vendor/autoload.php")) {
die(
'<h2>Oops! We cannot find Composer\'s autoload file.</h2>' .
'<h3>In 2.0, the installation procedure is a little different. Go to the ' .
'<a href="https://github.com/Wruczek/ts-website/releases" target="_blank">releases</a> on GitHub, ' .
'download the latest version and upload in on your server.</h3>' .
'<a href="https://github.com/Wruczek/ts-website/wiki/%5BEN%5D-Website-Installation" target="_blank">wiki</a> ' .
'and follow the installation tutorial.</h3>' .
'Or, if you know what you are doing, run <code>composer update</code> in the ' .
'<code>' . realpath(__BASE_DIR) . '</code> directory'
);
+1 -1
View File
@@ -88,7 +88,7 @@ EOT;
// Add all variables to the config
foreach ($dbconfig as $key => $value) {
$confarray .= sprintf(' "%s" => "%s",' . PHP_EOL, addcslashes($key, '"'), addcslashes($value, '"'));
$confarray .= sprintf(" '%s' => '%s'," . PHP_EOL, addcslashes($key, '"'), addcslashes($value, '"'));
}
// Remove semicolon and new line from the end
+5
View File
@@ -12,6 +12,11 @@ $(document).ready(function() {
language: {
url: "https://cdn.datatables.net/plug-ins/1.10.19/i18n/" + DATATABLES_LANGUAGE_NAME + ".json"
},
initComplete: function(settings, json) {
console.log("DataTables Loaded")
$("#banlist-loader").hide()
$("#banlist").show()
}
/*
TODO:
It looks better with the "search" text as an placeholder instead of the label
+9 -63
View File
@@ -5,12 +5,13 @@ namespace Wruczek\TSWebsite\Utils;
use Wruczek\TSWebsite\Utils\Language\LanguageUtils;
class DateUtils {
/**
* Returns current date format based on current user language. If it cannot
* be retrieved, default value is returned
* @return string date format
*/
public function getDateFormat() {
public static function getDateFormat() {
try {
return LanguageUtils::i()->translate("DATE_FORMAT");
} catch (\Exception $e) {
@@ -23,7 +24,7 @@ class DateUtils {
* be retrieved, default value is returned
* @return string time format
*/
public function getTimeFormat() {
public static function getTimeFormat() {
try {
return LanguageUtils::i()->translate("TIME_FORMAT");
} catch (\Exception $e) {
@@ -36,8 +37,8 @@ class DateUtils {
* @param $timestamp
* @return false|string
*/
public function formatToDate($timestamp) {
return date($this->getDateFormat(), $timestamp);
public static function formatDate($timestamp) {
return date(self::getDateFormat(), $timestamp);
}
/**
@@ -45,8 +46,8 @@ class DateUtils {
* @param $timestamp
* @return false|string
*/
public function formatToTime($timestamp) {
return date($this->getTimeFormat(), $timestamp);
public static function foramtTime($timestamp) {
return date(self::getTimeFormat(), $timestamp);
}
/**
@@ -55,63 +56,8 @@ class DateUtils {
* @param string $additional additional date format
* @return false|string
*/
public function formatToDateTime($timestamp, $additional = "") {
return date("{$this->getDateFormat()} {$this->getTimeFormat()} $additional", $timestamp);
public static function formatDatetime($timestamp, $additional = "") {
return date(trim(self::getDateFormat() . ", " . self::getTimeFormat() . " " . $additional), $timestamp);
}
/**
* Formats timestamp into "time ago" string
* For example, timestamp set to 60 seconds ago will return "1 minute ago"
*
* Taken from StackOverflow: https://stackoverflow.com/a/18602474
* @param $timestamp int timestamp with past date
* @param bool $full if true, full date will be returned. For example "5 hours, 2 minutes, 8 seconds"
* @return string timestamp formatted to fuzzy date. Marf.
*/
public function fuzzyDate($timestamp, $full = false) {
$now = new \DateTime;
$ago = (new \DateTime)->setTimestamp($timestamp);
$diff = $now->diff($ago);
$diff->w = floor($diff->d / 7);
$diff->d -= $diff->w * 7;
$string = [
'y' => 'year',
'm' => 'month',
'w' => 'week',
'd' => 'day',
'h' => 'hour',
'i' => 'minute',
's' => 'second'
];
foreach ($string as $k => &$v) {
if ($diff->$k) {
$v = $diff->$k . ' ' . $v . ($diff->$k > 1 ? 's' : '');
} else {
unset($string[$k]);
}
}
if (!$full) $string = array_slice($string, 0, 1);
return $string ? implode(', ', $string) . ' ago' : 'just now';
}
/**
* Returns fuzzy date with abbreviation showing precise date
* @see fuzzyDate
* @param $timestamp
* @param bool $full
* @return string
*/
public function fuzzyDateHTML($timestamp, $full = false) {
$fuzzyDate = $this->fuzzyDate($timestamp, $full);
$fullDate = $this->formatToDateTime($timestamp, "T");
return '<abbr data-fuzzydate="' . $timestamp . '"></abbr>';
// return '<abbr data-toggle="tooltip" title="' . htmlentities($fullDate) . '">' . htmlentities($fuzzyDate) . '</abbr>';
}
}
@@ -3,6 +3,7 @@
namespace Wruczek\TSWebsite\Utils\Language;
use Wruczek\PhpFileCache\PhpFileCache;
use Wruczek\TSWebsite\Config;
use Wruczek\TSWebsite\Utils\DatabaseUtils;
use Wruczek\TSWebsite\Utils\SingletonTait;
@@ -147,10 +148,18 @@ class LanguageUtils {
$langs[] = new Language($langid, $englishname, $nativename, $langcode, $isdefault, $languageItems);
}
uasort($langs, function ($a, $b) {
if ($a->getLanguageId() === $b->getLanguageId()) {
return 0;
}
return strnatcmp($a->getLanguageNameNative(), $b->getLanguageNameNative());
});
$this->languages = $langs;
if($updateCache)
$this->cache->store("languages", $langs, 300);
$this->cache->store("languages", $langs, Config::get("cache_languages", 300));
return $langs;
}
+4 -2
View File
@@ -27,11 +27,13 @@ class TemplateUtils {
// Add custom filters...
$this->getLatte()->addFilter("fuzzyDateAbbr", function ($s) {
return new Html('<span data-relativetime="fuzzydate" data-timestamp="' . $s . '">{cannot convert ' . $s . '}</span>');
$default = DateUtils::formatDatetime($s);
return new Html('<span data-relativetime="fuzzydate" data-timestamp="' . $s . '">' . $default . '</span>');
});
$this->getLatte()->addFilter("fullDate", function ($s) {
return new Html('<span data-relativetime="fulldate" data-timestamp="' . $s . '">{cannot convert ' . $s . '}</span>');
$default = DateUtils::formatDatetime($s);
return new Html('<span data-relativetime="fulldate" data-timestamp="' . $s . '">' . $default . '</span>');
});
$this->getLatte()->addFilter("translate", function ($s, ...$args) {
+1 -1
View File
@@ -317,7 +317,7 @@ EOD;
$html = "";
if($client["client_is_priority_speaker"]) {
$html .= $this->getIcon("microphone.svg", __get("VIEWER_CLIENT_PRIORITY_SPEAKER"));
$html .= $this->getIcon("capture.svg", __get("VIEWER_CLIENT_PRIORITY_SPEAKER"));
}
if($client["client_is_channel_commander"]) {
+1 -1
View File
@@ -1,5 +1,5 @@
<?php
define("__TSWEBSITE_VERSION", "dev-2.0.1");
define("__TSWEBSITE_VERSION", "dev-2.0.2");
define("__TSWEBSITE_COMMIT", "no-commit");
define("__BASE_DIR", __DIR__ . "/../..");
define("__PRIVATE_DIR", __BASE_DIR . "/private");
+8 -1
View File
@@ -16,6 +16,7 @@
<i class="fas fa-info-circle"></i>{_"BANS_EMPTY"}
</div>
{else}
<!-- Tip shown when the table shrinks, telling you that you can tap a row to view more -->
<div id="responsive-table-details-tip" class="alert alert-info alert-dismissible fade show" style="display: none" role="alert">
<i class="fas fa-info-circle"></i>{_"BANS_VIEW_MORE_TIP"}
<button type="button" class="close" data-dismiss="alert" aria-label="{_"ARIA_CLOSE"}">
@@ -24,6 +25,7 @@
</div>
{if $ipbanned !== false}
<!-- IP ban alert -->
<div class="alert alert-danger ban-alert banned" role="alert">
<i class="fas fa-exclamation-circle fa-2x"></i>
<div>
@@ -35,7 +37,12 @@
</div>
{/if}
<table id="banlist" class="table display dt-responsive no-wrap" width="100%">
<!-- Loader shown when DataTables is initialising the table -->
<div id="banlist-loader" class="position-relative p-3">
<div class="loader"></div>
</div>
<table id="banlist" class="table display dt-responsive no-wrap" width="100%" style="display: none">
<thead>
<tr>
<th data-priority="1">{_"BANS_HEADER_TARGET"}</th>