fix: add labels, init variables, replace deprecated joomla 3 classes, add return types, removed commented code, removed unused parameters

This commit is contained in:
Marvin Flock
2025-03-28 14:31:33 +01:00
parent 1af673df17
commit 0f4a3242b1
10 changed files with 41115 additions and 42314 deletions
File diff suppressed because it is too large Load Diff
@@ -2,15 +2,25 @@
/* /*
* Sports Manager API Extension * Sports Manager API Extension
*/ */
use JetBrains\PhpStorm\NoReturn;
use Joomla\CMS\Application\SiteApplication;
use Joomla\CMS\Factory;
use Joomla\CMS\User\UserFactory;
use Joomla\Input\Input;
use Joomla\Registry\Registry;
defined("_JEXEC") or die(); defined("_JEXEC") or die();
//$secret = JFactory::$config['secret']; require_once JPATH_SITE . '/components/com_sportsmanager/database/init.php';
$secret = \Joomla\CMS\Factory::getConfig(); Factory::getContainer()->set(Registry::class, function () {
return new Registry();
});
$secret = $secret->get("secret"); $secret = Factory::getContainer()->get(Registry::class)->get("secret");
function abortWithError($error) #[NoReturn] function abortWithError($error): void
{ {
if (isJson()) { if (isJson()) {
header("content-type: application/json"); header("content-type: application/json");
@@ -20,22 +30,23 @@ function abortWithError($error)
} }
} }
function isJson() { function isJson(): bool
$jinput = JFactory::getApplication()->input; {
$jInput = Factory::getContainer()->get(SiteApplication::class)->getInput();
return $jinput->get('format') === 'json'; return $jInput->get('format') === 'json';
} }
function notifyChange($data) { function notifyChange($data): void
{
try { try {
$db = &getDatabase(); $db = getDatabase();
$query = "SELECT wert from #__sportsmanager_einstellungen WHERE name='api_push_key'"; $query = "SELECT wert from #__sportsmanager_einstellungen WHERE name='api_push_key'";
$db->setQuery($query); $db->setQuery($query);
$push_key = $db->loadResult(); $push_key = $db->loadResult();
$push_server = !empty($push_key) && isset(_payload($push_key)->aud) ? _payload($push_key)->aud : ''; $push_server = !empty($push_key) && isset(_payload($push_key)->aud) ? _payload($push_key)->aud : '';
if ($push_server != '' && $push_key != '') { if ($push_server != '' && $push_key != '') {
$url = $push_server . (substr($push_server, -1) == '/' ? '' : '/') . 'v1/notifications/send'; $url = $push_server . (str_ends_with($push_server, '/') ? '' : '/') . 'v1/notifications/send';
$key = 'key=' . $push_key; $key = 'key=' . $push_key;
$ch = curl_init($url); $ch = curl_init($url);
@@ -51,7 +62,7 @@ function notifyChange($data) {
CURLOPT_POSTFIELDS => json_encode($data), CURLOPT_POSTFIELDS => json_encode($data),
)); ));
$resp = curl_exec($ch); $resp = curl_exec($ch);
if ($resp == FALSE) { if (!$resp) {
error_log("failed to send notification"); error_log("failed to send notification");
} }
} }
@@ -60,7 +71,8 @@ function notifyChange($data) {
} }
} }
function begegnungChanged($begegnung, $begegnung_vorher, $modus, $heim_team, $gast_team, $spiele) { function begegnungChanged($begegnung, $begegnung_vorher, $modus, $heim_team, $gast_team, $spiele): void
{
notifyChange(['payload' => [ notifyChange(['payload' => [
'begegnung' => $begegnung, 'begegnung' => $begegnung,
'begegnung_vorher' => $begegnung_vorher, 'begegnung_vorher' => $begegnung_vorher,
@@ -71,7 +83,8 @@ function begegnungChanged($begegnung, $begegnung_vorher, $modus, $heim_team, $ga
], 'type' => 'FIXTURE_RESULT_CHANGED']); ], 'type' => 'FIXTURE_RESULT_CHANGED']);
} }
function begegnungTischChanged($begegnung, $heim_team, $gast_team) { function begegnungTischChanged($begegnung, $heim_team, $gast_team): void
{
notifyChange(['payload' => [ notifyChange(['payload' => [
'begegnung' => $begegnung, 'begegnung' => $begegnung,
'heim_team' => $heim_team, 'heim_team' => $heim_team,
@@ -79,7 +92,8 @@ function begegnungTischChanged($begegnung, $heim_team, $gast_team) {
], 'type' => 'TABLE_CHANGED']); ], 'type' => 'TABLE_CHANGED']);
} }
function begegnungVerlegenNotify($begegnung, $users, $vorschlagendes_team_id, $heim_team, $gast_team) { function begegnungVerlegenNotify($begegnung, $users, $vorschlagendes_team_id, $heim_team, $gast_team): void
{
notifyChange([ notifyChange([
'payload' => [ 'payload' => [
'begegnung' => $begegnung, 'begegnung' => $begegnung,
@@ -97,7 +111,8 @@ function begegnungVerlegenNotify($begegnung, $users, $vorschlagendes_team_id, $h
* @reponse body * @reponse body
* { data: { token: "reqest_token", access_for_team: ["team_id_1", "team_id_2"]}, expires: 1520013747000} * { data: { token: "reqest_token", access_for_team: ["team_id_1", "team_id_2"]}, expires: 1520013747000}
*/ */
function userToken() { #[NoReturn] function userToken(): void
{
global $secret; global $secret;
if (!isJson()) { if (!isJson()) {
abortWithError("JSON Request only"); abortWithError("JSON Request only");
@@ -105,19 +120,21 @@ function userToken() {
if (isExternalDatabase()) { if (isExternalDatabase()) {
abortWithError("Local Database only"); abortWithError("Local Database only");
} }
$jinput = JFactory::getApplication()->input->json; $container = Factory::getContainer();
$access_key = $jinput->getString('access_key'); $jInput = $container->get(SiteApplication::class)->getInput()->json;
$access_key = $jInput->getString('access_key');
$user_id = _payload($access_key)->sub; $user_id = _payload($access_key)->sub;
$user = JFactory::getUser($user_id); $user = $container->get(UserFactory::class)->loadUserById($user_id);
if (!jwt_validate($access_key, $secret . $user->password)) { if (!jwt_validate($access_key, $secret . $user->password)) {
abortWithError('Access Key is invalid'); abortWithError('Access Key is invalid');
} }
try {
$expires = new DateTime(); $expires = new DateTime();
$expires->modify('+16 hours'); $expires->modify('+16 hours');
$db = &getDatabase(); $db = getDatabase();
$query = "SELECT berechtigt_team_id from #__sportsmanager_berechtigt_fuer_team where berechtigt_user_id = $user_id"; $query = "SELECT berechtigt_team_id from #__sportsmanager_berechtigt_fuer_team where berechtigt_user_id = $user_id";
$db->setQuery($query); $db->setQuery($query);
if (!$db->execute()) { if (!$db->execute()) {
@@ -129,9 +146,15 @@ function userToken() {
'sub' => $user_id, 'sub' => $user_id,
'exp' => $expires->getTimestamp(), 'exp' => $expires->getTimestamp(),
], $secret), ], $secret),
'access_for_teams' => array_map(function($item) { return $item->berechtigt_team_id; }, $team_id), 'access_for_teams' => array_map(function ($item) {
return $item->berechtigt_team_id;
}, $team_id),
'expires' => $expires->getTimestamp() * 1000, // 'expires' => $expires->getTimestamp() * 1000, //
]); ]);
} catch (Exception $ex) {
error_log($ex);
}
} }
/* /*
@@ -139,7 +162,8 @@ function userToken() {
* @response body * @response body
* { data: { token: "api_acccess_token" }} * { data: { token: "api_acccess_token" }}
*/ */
function userAuth() { #[NoReturn] function userAuth(): void
{
global $secret; global $secret;
if (!isJson()) { if (!isJson()) {
die(); die();
@@ -147,18 +171,20 @@ function userAuth() {
if (isExternalDatabase()) { if (isExternalDatabase()) {
abortWithError("Local Database only"); abortWithError("Local Database only");
} }
$jinput = JFactory::getApplication()->input->json; $container = Factory::getContainer();
$username = $jinput->getString('username'); $jInput = $container->get(SiteApplication::class)->getInput()->json;
$password = $jinput->getString('password'); $username = $jInput->getString('username');
$password = $jInput->getString('password');
$db = &getDatabase(); $db = getDatabase();
$query = $db->getQuery(true); $query = $db->getQuery(true);
$query->select('id')->from('#__users')->where('username = "' . $username . '"')->limit(1); $query->select('id')->from('#__users')->where('username = "' . $username . '"')->limit(1);
$db->setQuery($query); $db->setQuery($query);
$user_id = $db->loadResult(); $user_id = $db->loadResult();
$user = JFactory::getUser($user_id); $user = $container->get(UserFactory::class)->loadUserById($user_id);
if (JUserHelper::verifyPassword($password, $user->password, $user->id)) { //TODO: pw verification modernising: use php native methods, however this also needs new pw hashing. maybe force a pw reset on all accounts
if (password_verify($password, $user->password)) {
JSON_sportsmanager::JSON([ JSON_sportsmanager::JSON([
'token' => jwt_token([ 'token' => jwt_token([
@@ -166,24 +192,27 @@ function userAuth() {
'iat' => (new DateTime())->getTimestamp(), 'iat' => (new DateTime())->getTimestamp(),
], $secret . $user->password) ], $secret . $user->password)
]); ]);
return;
} }
abortWithError('Wrong credentials'); abortWithError('Wrong credentials');
} }
function getUserID() { function getUserID(): int
{
global $secret; global $secret;
$token = JFactory::getApplication()->input->server->getString('HTTP_SECRET', NULL); $container = Factory::getContainer();
$input = $container->get(Input::class);
$token = $input->server->getString('HTTP_SECRET', NULL);
return $token != NULL && jwt_validate($token, $secret) && isset(_payload($token)->sub) return $token != NULL && jwt_validate($token, $secret) && isset(_payload($token)->sub)
? (int)_payload($token)->sub ? (int)_payload($token)->sub
: 0; : 0;
} }
function getColorOfImage($image) { function getColorOfImage($image)
{
if ($image != NULL) { if ($image != NULL) {
if (strpos($image, '.png') !== false) { if (str_contains($image, '.png')) {
$img = imagecreatefrompng($image); $img = imagecreatefrompng($image);
} else { } else {
$img = imagecreatefromjpeg($image); $img = imagecreatefromjpeg($image);
@@ -215,7 +244,8 @@ function getColorOfImage($image) {
return NULL; return NULL;
} }
function colorKey($rgb) { function colorKey($rgb): string
{
$r = (int)($rgb['red'] / 100); $r = (int)($rgb['red'] / 100);
$g = (int)($rgb['green'] / 100); $g = (int)($rgb['green'] / 100);
@@ -224,7 +254,8 @@ function colorKey($rgb) {
return $r . '-' . $g . '-' . $b; return $r . '-' . $g . '-' . $b;
} }
function hex($rgb) { function hex($rgb): ?string
{
$r = $rgb['red']; $r = $rgb['red'];
$g = $rgb['green']; $g = $rgb['green'];
$b = $rgb['blue']; $b = $rgb['blue'];
@@ -249,14 +280,16 @@ function hex($rgb) {
/* /*
* sign string with secret * sign string with secret
*/ */
function _sign($data, $secret, $algo = 'sha256') { function _sign($data, $secret): string
{
return base64_encode(hash_hmac('sha256', $data, $secret)); return base64_encode(hash_hmac('sha256', $data, $secret));
} }
/* /*
* get payload from jwt token * get payload from jwt token
*/ */
function _payload($token) { function _payload($token)
{
$jwt = explode('.', $token); $jwt = explode('.', $token);
return json_decode(base64_decode($jwt[0])); return json_decode(base64_decode($jwt[0]));
} }
@@ -264,7 +297,8 @@ function _payload($token) {
/* /*
* headless signed jwt token * headless signed jwt token
*/ */
function jwt_token($payload, $secret) { function jwt_token($payload, $secret): string
{
$data = base64_encode(json_encode($payload)); $data = base64_encode(json_encode($payload));
return $data . '.' . _sign($data, $secret); return $data . '.' . _sign($data, $secret);
@@ -273,7 +307,8 @@ function jwt_token($payload, $secret) {
/* /*
* validate token * validate token
*/ */
function jwt_validate($token, $secret) { function jwt_validate($token, $secret): bool
{
$jwt = explode('.', $token); $jwt = explode('.', $token);
if (sizeof($jwt) == 2 && $jwt[1] == _sign($jwt[0], $secret)) { if (sizeof($jwt) == 2 && $jwt[1] == _sign($jwt[0], $secret)) {
if (isset(_payload($token)->exp)) { if (isset(_payload($token)->exp)) {
File diff suppressed because it is too large Load Diff
@@ -4,50 +4,60 @@
*/ */
// kein direkter Zugriff // kein direkter Zugriff
use JetBrains\PhpStorm\NoReturn;
use Joomla\CMS\Application\SiteApplication;
use Joomla\CMS\Factory;
use Joomla\CMS\Log\Log;
use Joomla\CMS\Router\Route;
use Joomla\CMS\Uri\Uri;
use Joomla\CMS\User\User;
use Joomla\CMS\Version;
defined('_JEXEC') or die('Restricted access'); defined('_JEXEC') or die('Restricted access');
require_once (JPATH_COMPONENT.DIRECTORY_SEPARATOR.'mathparser.php'); require_once JPATH_SITE . '/components/com_sportsmanager/mathparser.php';
require_once JPATH_SITE . '/components/com_sportsmanager/database/init.php';
function mathParserVerteilung($rohpunkte, $platz, $teilnehmer, $multiplikator) { class MathParserSM extends MathParser
return max(round($multiplikator * round(((($rohpunkte - 1) * (-log($platz / $teilnehmer) * (1 - ($platz / $teilnehmer)))) / (-log(1 / $teilnehmer) * (1 - (1 / $teilnehmer)))) + 1)), 1); {
}
function mathParserVerteilungR($rohpunkte, $platz, $teilnehmer, $multiplikator) {
return max(round(((($multiplikator * $rohpunkte - 1) * (-log($platz / $teilnehmer) * (1 - ($platz / $teilnehmer)))) / (-log(1 / $teilnehmer) * (1 - (1 / $teilnehmer)))) + 1), 1);
}
class MathParserSM extends MathParser {
// Verteilung nach Klostermann/Wahle // Verteilung nach Klostermann/Wahle
public function __construct() { public function __construct()
MathParser::__construct(); {
parent::__construct();
try {
$this->createFunc("ROUND", 'round', 1); $this->createFunc("ROUND", 'round', 1);
$this->createFunc("VERTEILUNG", 'mathParserVerteilung', 4); $this->createFunc("VERTEILUNG", 'mathParserVerteilung', 4);
$this->createFunc("VERTEILUNGR", 'mathParserVerteilungR', 4); $this->createFunc("VERTEILUNGR", 'mathParserVerteilungR', 4);
} catch (Exception $e) {
Log::add('an error occurred: ' . $e->getMessage(), Log::ERROR, 'com_sportsmanager');
throw new RuntimeException('An error occurred.', 500);
}
} }
} }
function keinZugriff($login = FALSE) { #[NoReturn] function keinZugriff($login = FALSE): void
{
if (isJson()) { if (isJson()) {
abortWithError(401 . ' Unauthorized'); abortWithError(401 . ' Unauthorized');
} }
if (!$login || JFactory::getUser()->id) { if (!$login || Factory::getContainer()->get(SiteApplication::class)->getIdentity()->id) {
JError::raiseError(500, JText::_('JERROR_ALERTNOAUTHOR')); Log::add('an error occurred', Log::ERROR, 'com_sportsmanager');
jexit(); throw new RuntimeException('An error occurred.', 500);
} }
$version = new JVersion; $version = new Version();
$joomla = $version->getShortVersion(); $joomla = $version->getShortVersion();
//$u =& JFactory::getURI(); $u = Uri::getInstance();
$u = JURI::getInstance();
$redirectUrl = urlencode(base64_encode($u->toString())); $redirectUrl = urlencode(base64_encode($u->toString()));
$redirectUrl = '&return=' . $redirectUrl; $redirectUrl = '&return=' . $redirectUrl;
$joomlaLoginUrl = 'index.php?option=' . (substr($joomla, 0, 3) != '1.5' ? 'com_users' : 'com_user') . '&view=login'; $joomlaLoginUrl = 'index.php?option=' . (!str_starts_with($joomla, '1.5') ? 'com_users' : 'com_user') . '&view=login';
$finalUrl = $joomlaLoginUrl . $redirectUrl; $finalUrl = $joomlaLoginUrl . $redirectUrl;
$app = JFactory::getApplication(); $app = Factory::getContainer()->get(SiteApplication::class);
$app->redirect(JRoute::_($finalUrl)); $app->redirect(Route::_($finalUrl));
jexit(); jexit();
} }
function bereinigterDateiname($dateiname) { function bereinigterDateiname($dateiname): array|string
{
$_convertTable = array( $_convertTable = array(
'&' => 'and', '@' => 'at', '©' => 'c', '®' => 'r', 'À' => 'a', '&' => 'and', '@' => 'at', '©' => 'c', '®' => 'r', 'À' => 'a',
'Á' => 'a', 'Â' => 'a', 'Ä' => 'a', 'Å' => 'a', 'Æ' => 'ae', 'Ç' => 'c', 'Á' => 'a', 'Â' => 'a', 'Ä' => 'a', 'Å' => 'a', 'Æ' => 'ae', 'Ç' => 'c',
@@ -110,28 +120,30 @@ function bereinigterDateiname($dateiname) {
return str_replace($bad, "", strtr($dateiname, $_convertTable)); return str_replace($bad, "", strtr($dateiname, $_convertTable));
} }
function setMinMemoryLimit($memDestSize) { function setMinMemoryLimit($memDestSize): void
{
if (getBytes(ini_get('memory_limit')) < getBytes($memDestSize)) if (getBytes(ini_get('memory_limit')) < getBytes($memDestSize))
ini_set('memory_limit', $memDestSize); ini_set('memory_limit', $memDestSize);
} }
function getBytes($val) { function getBytes($val): int|string
{
$val = trim($val); $val = trim($val);
$numeric = substr($val, 0, strlen($val) - 1); $numeric = substr($val, 0, strlen($val) - 1);
$last = strtolower($val[strlen($val) - 1]); $last = strtolower($val[strlen($val) - 1]);
switch ($last) { switch ($last) {
// The 'G' modifier is available since PHP 5.1.0 // The 'G' modifier is available since PHP 5.1.0
case 'g':
$numeric *= 1024;
case 'm': case 'm':
$numeric *= 1024; case 'g':
case 'k': case 'k':
$numeric *= 1024; $numeric *= 1024;
break;
} }
return $numeric; return $numeric;
} }
function encrypt($str, $key){ function encrypt($str, $key): string
{
$result = ""; $result = "";
for ($i = 0; $i < strlen($str); $i++) { for ($i = 0; $i < strlen($str); $i++) {
$char = substr($str, $i, 1); $char = substr($str, $i, 1);
@@ -142,7 +154,8 @@ function encrypt($str, $key){
return base64_encode($result); return base64_encode($result);
} }
function decrypt($str, $key){ function decrypt($str, $key): string
{
$str = base64_decode($str); $str = base64_decode($str);
$result = ""; $result = "";
for ($i = 0; $i < strlen($str); $i++) { for ($i = 0; $i < strlen($str); $i++) {
@@ -154,13 +167,14 @@ function decrypt($str, $key){
return $result; return $result;
} }
function individualwettbewerbFilter($prefix) { function individualwettbewerbFilter($prefix): string
$db =& getDatabase(); {
$user_id = isExternalDatabase() ? 0 : JFactory::getUser()->id; $user_id = isExternalDatabase() ? 0 : Factory::getContainer()->get(SiteApplication::class)->getIdentity()->id;
return " " . $prefix . " (SELECT berechtigt_individualwettbewerb_id FROM #__sportsmanager_berechtigt_fuer_individualwettbewerb INNER JOIN #__sportsmanager_individualwettbewerb ON individualwettbewerb_id = berechtigt_individualwettbewerb_id WHERE berechtigt_user_id = $user_id) "; return " " . $prefix . " (SELECT berechtigt_individualwettbewerb_id FROM #__sportsmanager_berechtigt_fuer_individualwettbewerb INNER JOIN #__sportsmanager_individualwettbewerb ON individualwettbewerb_id = berechtigt_individualwettbewerb_id WHERE berechtigt_user_id = $user_id) ";
} }
function kategorieFilter($prefix, $suffix = "") { function kategorieFilter($prefix, $suffix = ""): string
{
global $params; global $params;
$kategorien = explode(",", $params->get('kategorien')); $kategorien = explode(",", $params->get('kategorien'));
$filter = ""; $filter = "";
@@ -175,32 +189,33 @@ function kategorieFilter($prefix, $suffix = "") {
return empty($filter) ? "" : (" " . $prefix . " (" . $filter . ") " . $suffix); return empty($filter) ? "" : (" " . $prefix . " (" . $filter . ") " . $suffix);
} }
function turnierFilter($prefix) { function turnierFilter($prefix): string
$db =& getDatabase(); {
$user_id = isExternalDatabase() ? 0 : JFactory::getUser()->id; $user_id = isExternalDatabase() ? 0 : Factory::getContainer()->get(SiteApplication::class)->getIdentity()->id;
return " " . $prefix . " (SELECT berechtigt_turnier_id FROM #__sportsmanager_berechtigt_fuer_turnier WHERE berechtigt_user_id = $user_id AND DATEDIFF(letzter_tag, NOW()) >= -14) "; return " " . $prefix . " (SELECT berechtigt_turnier_id FROM #__sportsmanager_berechtigt_fuer_turnier WHERE berechtigt_user_id = $user_id AND DATEDIFF(letzter_tag, NOW()) >= -14) ";
} }
function vereinFilter($prefix) { function vereinFilter($prefix): string
$db =& getDatabase(); {
$user_id = isExternalDatabase() ? 0 : JFactory::getUser()->id; $user_id = isExternalDatabase() ? 0 : Factory::getContainer()->get(SiteApplication::class)->getIdentity()->id;
return " " . $prefix . " (SELECT berechtigt_verein_id FROM #__sportsmanager_berechtigt_fuer_verein INNER JOIN #__sportsmanager_verein ON berechtigt_verein_id = verein_id WHERE berechtigt_user_id = $user_id AND NOT ausgetreten) "; return " " . $prefix . " (SELECT berechtigt_verein_id FROM #__sportsmanager_berechtigt_fuer_verein INNER JOIN #__sportsmanager_verein ON berechtigt_verein_id = verein_id WHERE berechtigt_user_id = $user_id AND NOT ausgetreten) ";
} }
function veranstalterFilter($prefix) { function veranstalterFilter($prefix): string
$db =& getDatabase(); {
$user_id = isExternalDatabase() ? 0 : JFactory::getUser()->id; $user_id = isExternalDatabase() ? 0 : Factory::getContainer()->get(SiteApplication::class)->getIdentity()->id;
return " " . $prefix . " (SELECT berechtigt_veranstalter_id FROM #__sportsmanager_berechtigt_fuer_veranstalter WHERE berechtigt_user_id = $user_id) "; return " " . $prefix . " (SELECT berechtigt_veranstalter_id FROM #__sportsmanager_berechtigt_fuer_veranstalter WHERE berechtigt_user_id = $user_id) ";
} }
function veranstaltungFilter($prefix) { function veranstaltungFilter($prefix): string
$db =& getDatabase(); {
$user_id = isExternalDatabase() ? 0 : JFactory::getUser()->id; $user_id = isExternalDatabase() ? 0 : Factory::getContainer()->get(SiteApplication::class)->getIdentity()->id;
return " " . $prefix . " (SELECT berechtigt_veranstaltung_id FROM #__sportsmanager_berechtigt_fuer_veranstaltung INNER JOIN #__sportsmanager_veranstaltung ON veranstaltung_id = berechtigt_veranstaltung_id WHERE berechtigt_user_id = $user_id AND DATEDIFF(letzter_tag, NOW()) >= -14) "; return " " . $prefix . " (SELECT berechtigt_veranstaltung_id FROM #__sportsmanager_berechtigt_fuer_veranstaltung INNER JOIN #__sportsmanager_veranstaltung ON veranstaltung_id = berechtigt_veranstaltung_id WHERE berechtigt_user_id = $user_id AND DATEDIFF(letzter_tag, NOW()) >= -14) ";
} }
// Berechnet Datum zum Montag der ersten Kalenderwoche eines Jahres // Berechnet Datum zum Montag der ersten Kalenderwoche eines Jahres
function firstkw($jahr) { function firstkw($jahr): bool|int
{
$erster = mktime(0, 0, 0, 1, 1, $jahr); $erster = mktime(0, 0, 0, 1, 1, $jahr);
$wtag = date('w', $erster); $wtag = date('w', $erster);
if ($wtag <= 4) { if ($wtag <= 4) {
@@ -208,8 +223,7 @@ function firstkw($jahr) {
* Donnerstag oder kleiner: auf den Montag zurückrechnen. * Donnerstag oder kleiner: auf den Montag zurückrechnen.
*/ */
$montag = mktime(0, 0, 0, 1, 1 - ($wtag - 1), $jahr); $montag = mktime(0, 0, 0, 1, 1 - ($wtag - 1), $jahr);
} } else {
else {
/** /**
* auf den Montag nach vorne rechnen. * auf den Montag nach vorne rechnen.
*/ */
@@ -219,32 +233,34 @@ function firstkw($jahr) {
} }
// Berechnet Wochentag über Kalenderwoche, Jahr und Wochentag (0 = Montag, ..., 6 = Sonntag) // Berechnet Wochentag über Kalenderwoche, Jahr und Wochentag (0 = Montag, ..., 6 = Sonntag)
function mondaykw($kw, $jahr, $weekday) { function mondaykw($kw, $jahr, $weekday): bool|int
{
$firstmonday = firstkw($jahr); $firstmonday = firstkw($jahr);
$mon_monat = date('m', $firstmonday); $mon_monat = date('m', $firstmonday);
$mon_jahr = date('Y', $firstmonday); $mon_jahr = date('Y', $firstmonday);
$mon_tage = date('d',$firstmonday); $mon_tage = (int)date('d', $firstmonday);
$tage = ($kw - 1) * 7; $tage = ($kw - 1) * 7;
$daykw = mktime(0,0,0,$mon_monat,$mon_tage+$tage+$weekday,$mon_jahr); return mktime(0, 0, 0, $mon_monat, $mon_tage + $tage + $weekday, $mon_jahr);
return $daykw;
} }
// Berechnet Termin am Wochentag (0 = Montag, ..., 6 = Sonntag) in Kalenderwoche zum Datum // Berechnet Termin am Wochentag (0 = Montag, ..., 6 = Sonntag) in Kalenderwoche zum Datum
function geaenderterWochentag($datum, $wochentag) { function geaenderterWochentag($datum, $wochentag): bool|int
{
$wtag = date('w', $datum); $wtag = date('w', $datum);
if ($wtag == 0) // Sonntag if ($wtag == 0) // Sonntag
$wtag = 7; $wtag = 7;
$mon_monat = date('m', $datum); $mon_monat = date('m', $datum);
$mon_jahr = date('Y', $datum); $mon_jahr = date('Y', $datum);
$mon_tage = date('d', $datum); $mon_tage = (int)date('d', $datum);
return mktime(0, 0, 0, $mon_monat, $mon_tage + 1 - $wtag + $wochentag, $mon_jahr); return mktime(0, 0, 0, $mon_monat, $mon_tage + 1 - $wtag + $wochentag, $mon_jahr);
} }
function normalisiertesDatum($datum) { function normalisiertesDatum($datum): ?string
{
if ($datum == NULL) if ($datum == NULL)
return NULL; return NULL;
if (strpos($datum, "-") !== false) if (str_contains($datum, "-"))
$trennzeichen = "-"; $trennzeichen = "-";
else else
$trennzeichen = "."; $trennzeichen = ".";
@@ -258,37 +274,35 @@ function normalisiertesDatum($datum) {
$jahr = intval(substr($s, 0, 4)); $jahr = intval(substr($s, 0, 4));
$monat = intval(substr($s, 4, 2)); $monat = intval(substr($s, 4, 2));
$tag = intval(substr($s, 6, 2)); $tag = intval(substr($s, 6, 2));
} } else if ($n == 3) {
else if ($n == 3) {
if ($trennzeichen != ".") { if ($trennzeichen != ".") {
$jahr = intval($t[0]); $jahr = intval($t[0]);
if (strlen($t[0]) <= 2) if (strlen($t[0]) <= 2)
$jahr += 1900; $jahr += 1900;
$monat = intval($t[1]); $monat = intval($t[1]);
$tag = intval($t[2]); $tag = intval($t[2]);
} } else {
else {
$tag = intval($t[0]); $tag = intval($t[0]);
$monat = intval($t[1]); $monat = intval($t[1]);
$jahr = intval($t[2]); $jahr = intval($t[2]);
if (strlen($t[2]) <= 2) if (strlen($t[2]) <= 2)
$jahr += 1900; $jahr += 1900;
} }
} } else
else
return NULL; return NULL;
if (!checkdate($monat, $tag, $jahr)) if (!checkdate($monat, $tag, $jahr))
return NULL; return NULL;
return sprintf("%04d-%02d-%02d", $jahr, $monat, $tag);; return sprintf("%04d-%02d-%02d", $jahr, $monat, $tag);
} }
function normalisierteUhrzeit($uhrzeit) { function normalisierteUhrzeit($uhrzeit): ?string
{
if ($uhrzeit == NULL) if ($uhrzeit == NULL)
return NULL; return NULL;
if (strpos($uhrzeit, "-") !== FALSE) if (str_contains($uhrzeit, "-"))
$trennzeichen = "-"; $trennzeichen = "-";
else else
$trennzeichen = ":"; $trennzeichen = ":";
@@ -303,22 +317,21 @@ function normalisierteUhrzeit($uhrzeit) {
$stunden = intval(substr($s, 0, 2)); $stunden = intval(substr($s, 0, 2));
$minuten = intval(substr($s, 2, 2)); $minuten = intval(substr($s, 2, 2));
$sekunden = $len != 6 ? 0 : intval(substr($s, 4, 2)); $sekunden = $len != 6 ? 0 : intval(substr($s, 4, 2));
} } else if ($n == 2 || $n == 3) {
else if ($n == 2 || $n == 3) {
$stunden = intval($t[0]); $stunden = intval($t[0]);
$minuten = intval($t[1]); $minuten = intval($t[1]);
$sekunden = $n != 3 ? 0 : intval($t[2]); $sekunden = $n != 3 ? 0 : intval($t[2]);
} } else
else
return NULL; return NULL;
if ($stunden < 0 || $stunden > 23 || $minuten < 0 || $minuten > 59 || $sekunden < 0 || $sekunden > 59) if ($stunden < 0 || $stunden > 23 || $minuten < 0 || $minuten > 59 || $sekunden < 0 || $sekunden > 59)
return NULL; return NULL;
return sprintf("%02d:%02d:%02d", $stunden, $minuten, $sekunden);; return sprintf("%02d:%02d:%02d", $stunden, $minuten, $sekunden);
} }
function runden_detailliert_invers($runden) { function runden_detailliert_invers($runden): ?string
{
if ($runden == null) if ($runden == null)
return null; return null;
$runden_invers = ""; $runden_invers = "";
@@ -332,7 +345,8 @@ function runden_detailliert_invers($runden) {
return $runden_invers; return $runden_invers;
} }
function runden_detailliert_auswertung($runden) { function runden_detailliert_auswertung($runden): array
{
$ergebnis = 0; $ergebnis = 0;
$heim_saetze = 0; $heim_saetze = 0;
$unentschieden_saetze = 0; $unentschieden_saetze = 0;
@@ -362,7 +376,8 @@ function runden_detailliert_auswertung($runden) {
// pass two file names // pass two file names
// returns TRUE if files are the same, FALSE otherwise // returns TRUE if files are the same, FALSE otherwise
function files_identical($fn1, $fn2) { function files_identical($fn1, $fn2): bool
{
if (!is_file($fn1) || !is_file($fn2)) if (!is_file($fn1) || !is_file($fn2))
return FALSE; return FALSE;
@@ -392,4 +407,4 @@ function files_identical($fn1, $fn2) {
return $same; return $same;
} }
?>
File diff suppressed because it is too large Load Diff
@@ -1,12 +1,18 @@
<?php <?php
use JetBrains\PhpStorm\NoReturn;
defined('_JEXEC') or die('Restricted access'); defined('_JEXEC') or die('Restricted access');
require_once(JPATH_COMPONENT . DIRECTORY_SEPARATOR . 'views/sportsmanager/view_tools.php'); require_once JPATH_SITE . '/components/com_sportsmanager/views/sportsmanager/view_tools.php';
require_once JPATH_SITE . '/components/com_sportsmanager/util/image.php';
class JSON_sportsmanager { class JSON_sportsmanager
{
static function mannschaften($veranstaltung, $rows) { static function mannschaften($veranstaltung, $rows): array
{
$teams = []; $teams = [];
foreach ($rows as $team) { foreach ($rows as $team) {
$team->teambild = teamImage($team->team_id, $team->verein_id); $team->teambild = teamImage($team->team_id, $team->verein_id);
@@ -22,7 +28,8 @@ class JSON_sportsmanager {
]; ];
} }
static function tabelleAnzeigen($veranstaltung, $modus, $teams, $spieltag, $spieltage, $alleine_angezeigt, $praesentation) { static function tabelleAnzeigen($modus, $teams): array
{
foreach ($teams as $team) { foreach ($teams as $team) {
$team->teambild = teamImage($team->team_id, $team->verein_id); $team->teambild = teamImage($team->team_id, $team->verein_id);
} }
@@ -33,7 +40,8 @@ class JSON_sportsmanager {
]; ];
} }
static function tabelleEigeneAnzeigen($veranstaltung, $modus, $teams, $alleine_angezeigt, $praesentation) { static function tabelleEigeneAnzeigen($modus, $teams): array
{
foreach ($teams as $team) { foreach ($teams as $team) {
$team->teambild = teamImage($team->team_id, $team->verein_id); $team->teambild = teamImage($team->team_id, $team->verein_id);
} }
@@ -43,7 +51,8 @@ class JSON_sportsmanager {
]; ];
} }
static function _getPlayerDetails($game, $home_player_map, $away_player_map) { static function _getPlayerDetails($game, $home_player_map, $away_player_map): void
{
// TODO dynamisch machen // TODO dynamisch machen
$game->heim_spieler_1_vorname = isset($home_player_map[$game->heim_spieler_1_id]) $game->heim_spieler_1_vorname = isset($home_player_map[$game->heim_spieler_1_id])
? $home_player_map[$game->heim_spieler_1_id]->vorname ? $home_player_map[$game->heim_spieler_1_id]->vorname
@@ -87,7 +96,8 @@ class JSON_sportsmanager {
} }
static function adminEditBegegnungSpielplan($bestaetigen, $veranstaltung, $begegnung, $heim_team, $gast_team, $spiele, $heim_spieler, $gast_spieler, $teamspiel_modus, $encrypted_pin, $count_verlegen_aktionen, $erneut_oeffnen, $aus_uebersicht) { static function adminEditBegegnungSpielplan($bestaetigen, $veranstaltung, $begegnung, $heim_team, $gast_team, $spiele, $heim_spieler, $gast_spieler, $teamspiel_modus): array
{
$heim_team->teambild = teamImage($heim_team->team_id, $heim_team->verein_id); $heim_team->teambild = teamImage($heim_team->team_id, $heim_team->verein_id);
$gast_team->teambild = teamImage($gast_team->team_id, $gast_team->verein_id); $gast_team->teambild = teamImage($gast_team->team_id, $gast_team->verein_id);
$heim_spieler_map = []; $heim_spieler_map = [];
@@ -119,7 +129,8 @@ class JSON_sportsmanager {
]; ];
} }
static function mannschaftDetails($veranstaltung, $team, $mitglieder, $mailverteiler, $mitglieder_statistiken, $teamansprechpartner, $begegnungen, $vorheriges_team_id, $naechstes_team_id, $team_moderator, $details_anzeigen, $ansprechpartner_anzeigen, $weitere_veranstaltungen, $veranstaltungsbezeichnungen, $spielberechtigungen, $ansicht_vereinigt, $ist_vergangen) { static function mannschaftDetails($veranstaltung, $team, $mitglieder, $teamansprechpartner, $begegnungen, $ansprechpartner_anzeigen, $veranstaltungsbezeichnungen): array
{
global $sportsmanager_joomla_path; global $sportsmanager_joomla_path;
global $sportsmanager_joomla_url; global $sportsmanager_joomla_url;
@@ -156,25 +167,27 @@ class JSON_sportsmanager {
]; ];
} }
static function JSON($data, $meta = NULL) { #[NoReturn] static function JSON($data, $meta = NULL): void
{
$response = [ $response = [
'data' => $data 'data' => $data
]; ];
if ($meta != NULL) { if ($meta != NULL) {
$response['meta'] = $meta; $response['meta'] = $meta;
} }
header('Content-Type: application/json; charset=utf-8', true); header('Content-Type: application/json; charset=utf-8');
echo json_encode($response); echo json_encode($response);
jexit(); jexit();
} }
static function spielerstatistik($spielerstatistik, $spielerstatistik_punkte, $allein_angezeigt, $filter_saison_id, $vorherige_spielerstatistik_id, $naechste_spielerstatistik_id, $details_anzeigen) { #[NoReturn] static function spielerstatistik($spielerstatistik_punkte): void
{
$rank = 1; $rank = 1;
foreach ($spielerstatistik_punkte as $s) { foreach ($spielerstatistik_punkte as $s) {
$s->spieler_bild = playerImage($s->spieler_id, $s->geschlecht); $s->spieler_bild = playerImage($s->spieler_id, $s->geschlecht);
$s->spieler_2_bild = playerImage($s->spieler_2_id, $s->geschlecht_2); $s->spieler_2_bild = playerImage($s->spieler_2_id, $s->geschlecht_2);
$s->quote = ($s->spielpunkte_gewonnen > 0 || $s->spielpunkte_verloren > 0) $s->quote = ($s->spielpunkte_gewonnen > 0 || $s->spielpunkte_verloren > 0)
? round($s->spielpunkte_gewonnen * 100 / ($s->spielpunkte_gewonnen + $s->spielpunkte_verloren), 0) . '%' ? round($s->spielpunkte_gewonnen * 100 / ($s->spielpunkte_gewonnen + $s->spielpunkte_verloren)) . '%'
: '-'; : '-';
$s->rank = '' . $rank; $s->rank = '' . $rank;
$rank++; $rank++;
@@ -182,7 +195,8 @@ class JSON_sportsmanager {
self::JSON($spielerstatistik_punkte); self::JSON($spielerstatistik_punkte);
} }
static function spielerDetails($spieler, $vereine, $veranstalter, $spieler_elo_verlauf_einzel, $spieler_elo_verlauf_doppel, $spielerNamen, $teamNamen, $veranstaltungBezeichnungen, $turnierdisziplinBezeichnungen, $individualwettbewerbBezeichnungen, $ranglistenplatzierungen, $turnierplatzierungen, $teams, $sortierung, $vorheriger_spieler_id, $naechster_spieler_id, $elo_detailliert, $statistik, $beginn, $kategorie, $einstufungen, $filter, $veranstaltungid, $veranstalterid, $einstufungid, $unabhaengige_ansicht, $details_anzeigen) { #[NoReturn] static function spielerDetails($spieler, $vereine, $veranstalter, $spieler_elo_verlauf_einzel, $spieler_elo_verlauf_doppel, $spielerNamen, $teamNamen, $veranstaltungBezeichnungen, $turnierdisziplinBezeichnungen, $individualwettbewerbBezeichnungen, $ranglistenplatzierungen, $turnierplatzierungen, $teams, $elo_detailliert, $statistik, $einstufungen): void
{
$letzte_einzel = []; $letzte_einzel = [];
$spieler->bild = playerImage($spieler->spieler_id, $spieler->geschlecht); $spieler->bild = playerImage($spieler->spieler_id, $spieler->geschlecht);
for ($i = sizeof($spieler_elo_verlauf_einzel) - 1; $i >= max(sizeof($spieler_elo_verlauf_einzel) - 10, 0); $i--) { for ($i = sizeof($spieler_elo_verlauf_einzel) - 1; $i >= max(sizeof($spieler_elo_verlauf_einzel) - 10, 0); $i--) {
@@ -285,13 +299,14 @@ class JSON_sportsmanager {
]); ]);
} }
static function begegnungVerlegen($veranstaltung, $begegnung, $heim_team, $gast_team, $verlegen_aktionen, $berechtigt_fuer_akzeptieren, $aus_uebersicht, $vorschlagendes_team_id) { #[NoReturn] static function begegnungVerlegen($veranstaltung, $verlegen_aktionen, $berechtigt_fuer_akzeptieren, $vorschlagendes_team_id): void
{
$letzte_aktionen = array(); $letzte_aktionen = array();
foreach ($verlegen_aktionen as $aktion) { foreach ($verlegen_aktionen as $aktion) {
if ($aktion->aktion == 1 || $aktion->aktion == 5 || $aktion == 10) { if ($aktion->aktion == 1 || $aktion->aktion == 5 || $aktion == 10) {
break; break;
} }
array_push($letzte_aktionen, $aktion); $letzte_aktionen[] = $aktion;
} }
$termine = array(); $termine = array();
if (count($letzte_aktionen) > 0) { if (count($letzte_aktionen) > 0) {
@@ -300,7 +315,7 @@ class JSON_sportsmanager {
if ($aktion->eingetragen != $eingetragen || $aktion->aktion != 0 || $aktion->zeitpunkt == NULL) { if ($aktion->eingetragen != $eingetragen || $aktion->aktion != 0 || $aktion->zeitpunkt == NULL) {
break; break;
} }
array_push($termine, $aktion); $termine[] = $aktion;
} }
} }
@@ -328,7 +343,7 @@ class JSON_sportsmanager {
'termine' => $response, 'termine' => $response,
'berechtigt_anfordern' => $berechtigt_anfordern, 'berechtigt_anfordern' => $berechtigt_anfordern,
'berechtigt_ablehnen' => $berechtigt_ablehnen, 'berechtigt_ablehnen' => $berechtigt_ablehnen,
'berechtigt_akzeptieren' => $berechtigt_fuer_akzeptieren ? TRUE : FALSE, 'berechtigt_akzeptieren' => (bool)$berechtigt_fuer_akzeptieren,
'termine_minimal' => $veranstaltung->termine_minimal, 'termine_minimal' => $veranstaltung->termine_minimal,
'termine_maximal' => $veranstaltung->termine_maximal, 'termine_maximal' => $veranstaltung->termine_maximal,
]); ]);
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -3,29 +3,32 @@
* Sports Manager (C) 2006-2020, Sven Nickel * Sports Manager (C) 2006-2020, Sven Nickel
*/ */
use Joomla\Filesystem\Folder;
use Joomla\CMS\Router\Route;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Uri\Uri;
// kein direkter Zugriff // kein direkter Zugriff
defined("_JEXEC") or die("Restricted access"); defined("_JEXEC") or die("Restricted access");
function htmlentities_utf8($s) { function htmlentities_utf8($s): string
{
return htmlentities($s, ENT_QUOTES, "UTF-8"); return htmlentities($s, ENT_QUOTES, "UTF-8");
} }
function htmlentities_noquotes_utf8($s) { function addOnLoad($function): void
return htmlentities($s, ENT_NOQUOTES, "UTF-8"); {
}
function addOnLoad($function) {
?> ?>
<script language="JavaScript"> <script language="JavaScript">
function addLoadEvent(func) { function addLoadEvent(func) {
var oldonload = window.onload; const oldOnload = window.onload;
if (typeof window.onload != 'function') { if (typeof window.onload != 'function') {
window.onload = func; window.onload = func;
} }
else { else {
window.onload = function () { window.onload = function () {
if (oldonload) { if (oldOnload) {
oldonload(); oldOnload();
} }
func(); func();
} }
@@ -37,17 +40,17 @@ function addOnLoad($function) {
<?php <?php
} }
function SportsManagerURL($weitereParameter = null, $ssl = 0) function SportsManagerURL($weitereParameter = null, $ssl = 0): ?string
{ {
$urlPath = handleFilter($weitereParameter); $urlPath = handleFilter($weitereParameter);
$joomlaBaseUrl = JUri::getInstance()->toString([ $joomlaBaseUrl = Uri::getInstance()->toString([
"scheme", "scheme",
"host", "host",
"port", "port",
"path", "path",
]); ]);
if (strpos($joomlaBaseUrl, "?") !== false) { if (str_contains($joomlaBaseUrl, "?")) {
// Base URL already contains a query string, append with '&' // Base URL already contains a query string, append with '&'
$finalUrl = $joomlaBaseUrl . "&" . ltrim($urlPath, "&"); $finalUrl = $joomlaBaseUrl . "&" . ltrim($urlPath, "&");
} else { } else {
@@ -55,15 +58,15 @@ function SportsManagerURL($weitereParameter = null, $ssl = 0)
$finalUrl = $joomlaBaseUrl . "?" . ltrim($urlPath, "&"); $finalUrl = $joomlaBaseUrl . "?" . ltrim($urlPath, "&");
} }
return \Joomla\CMS\Router\Route::_($finalUrl, false, $ssl); return Route::_($finalUrl, false, $ssl);
} }
function handleFilter($urlPart) function handleFilter($urlPart)
{ {
// Check if both '&filter=' and '#' are present in the URL part // Check if both '&filter=' and '#' are present in the URL part
if ( if (
strpos($urlPart, "&filter=") !== false && str_contains($urlPart, "&filter=") &&
strpos($urlPart, "#") !== false str_contains($urlPart, "#")
) { ) {
// Split the string by '#' to remove the hash part // Split the string by '#' to remove the hash part
$parts = explode("#", $urlPart, 2); $parts = explode("#", $urlPart, 2);
@@ -76,9 +79,7 @@ function handleFilter($urlPart)
unset($queryParams["filter"]); unset($queryParams["filter"]);
// Rebuild the query string without the 'filter' parameter // Rebuild the query string without the 'filter' parameter
$newQuery = http_build_query($queryParams); return http_build_query($queryParams);
return $newQuery;
} else { } else {
// Return the original URL part if either '&filter=' or '#' is not present // Return the original URL part if either '&filter=' or '#' is not present
return $urlPart; return $urlPart;
@@ -98,42 +99,27 @@ function hervorheben($titel) {
return $titel . " *"; return $titel . " *";
} }
function Laenderkennungen() { function Laenderkennungen(): array
$kennungen = array("AUT", "BEL", "BUL", "CZE", "DEN", "FRA", "GBR", "GER", "LUX", "NED", "SUI", "USA"); {
return array("AUT", "BEL", "BUL", "CZE", "DEN", "FRA", "GBR", "GER", "LUX", "NED", "SUI", "USA");
return $kennungen;
} }
function rundenstufe($stufe) { function rundenstufe($stufe): string
switch ($stufe) { {
case 0: return match ($stufe) {
$bezeichnung = JText::_("COM_SPORTSMANAGER_FINAL_RANKS"); 0 => Text::_("COM_SPORTSMANAGER_FINAL_RANKS"),
break; 1 => Text::_("COM_SPORTSMANAGER_MAIN_ROUND"),
case 1: 2 => Text::_("COM_SPORTSMANAGER_ADDITIONAL_ROUND"),
$bezeichnung = JText::_("COM_SPORTSMANAGER_MAIN_ROUND"); 3 => Text::_("COM_SPORTSMANAGER_2ND_ADDITIONAL_ROUND"),
break; 10 => Text::_("COM_SPORTSMANAGER_PRELIMINARY_ROUND"),
case 2: 20 => Text::_("COM_SPORTSMANAGER_REGISTRATIONS"),
$bezeichnung = JText::_("COM_SPORTSMANAGER_ADDITIONAL_ROUND"); default => "",
break; };
case 3:
$bezeichnung = JText::_("COM_SPORTSMANAGER_2ND_ADDITIONAL_ROUND");
break;
case 10:
$bezeichnung = JText::_("COM_SPORTSMANAGER_PRELIMINARY_ROUND");
break;
case 20:
$bezeichnung = JText::_("COM_SPORTSMANAGER_REGISTRATIONS");
break;
default:
$bezeichnung = "";
} // switch
return $bezeichnung;
} }
function StringsZusammenfassen($titel1, $titel2, $ersatz = null, $separator = " / ") { function StringsZusammenfassen($titel1, $titel2, $ersatz = null, $separator = " / ") {
if ($ersatz == null) { if ($ersatz == null) {
$ersatz = JText::_("COM_SPORTSMANAGER_NONE"); $ersatz = Text::_("COM_SPORTSMANAGER_NONE");
} }
$t1 = NichtLeererString($titel1, $ersatz); $t1 = NichtLeererString($titel1, $ersatz);
$t2 = NichtLeererString($titel2, $ersatz); $t2 = NichtLeererString($titel2, $ersatz);
@@ -144,76 +130,59 @@ function StringsZusammenfassen($titel1, $titel2, $ersatz = null, $separator = "
function Rundenbezeichnung($runde, $spieltag = false, $bezeichnung_verstecken = false, $kurzform = false) { function Rundenbezeichnung($runde, $spieltag = false, $bezeichnung_verstecken = false, $kurzform = false) {
if ($kurzform) { if ($kurzform) {
if ($runde >= 20000) if ($runde >= 20000)
return JText::sprintf("COM_SPORTSMANAGER_PLACE_FROM_TO_SHORTCUT", 99 - $runde % 100, 99 - floor(($runde - 20000) / 100) + 99 - ($runde % 100)); return Text::sprintf("COM_SPORTSMANAGER_PLACE_FROM_TO_SHORTCUT", 99 - $runde % 100, 99 - floor(($runde - 20000) / 100) + 99 - ($runde % 100));
switch ($runde) { return match ($runde) {
case 0: 0 => $spieltag
return $spieltag ? Text::_("COM_SPORTSMANAGER_MATCH_DAY_NONE")
? JText::_("COM_SPORTSMANAGER_MATCH_DAY_NONE") : Text::_("COM_SPORTSMANAGER_ROUND_NONE"),
: JText::_("COM_SPORTSMANAGER_ROUND_NONE"); 19999 => Text::_("COM_SPORTSMANAGER_FINAL_SHORTCUT"),
case 19999: 19998 => Text::_("COM_SPORTSMANAGER_3RD_PLACE_SHORTCUT"),
return JText::_("COM_SPORTSMANAGER_FINAL_SHORTCUT"); 19997 => Text::_("COM_SPORTSMANAGER_HALF_FINAL_SHORTCUT"),
case 19998: 19996 => Text::_("COM_SPORTSMANAGER_QUARTER_FINAL_SHORTCUT"),
return JText::_("COM_SPORTSMANAGER_3RD_PLACE_SHORTCUT"); 19995 => Text::_("COM_SPORTSMANAGER_ROUND_OF_16_SHORTCUT"),
case 19997: 19994 => Text::_("COM_SPORTSMANAGER_ROUND_OF_32_SHORTCUT"),
return JText::_("COM_SPORTSMANAGER_HALF_FINAL_SHORTCUT"); 19993 => Text::_("COM_SPORTSMANAGER_ROUND_OF_64_SHORTCUT"),
case 19996: 19992 => Text::_("COM_SPORTSMANAGER_ROUND_OF_128_SHORTCUT"),
return JText::_("COM_SPORTSMANAGER_QUARTER_FINAL_SHORTCUT"); default => $bezeichnung_verstecken ? $runde : Text::sprintf($spieltag ? "COM_SPORTSMANAGER_MATCH_DAY_NR_SHORTCUT" : "COM_SPORTSMANAGER_ROUND_NR_SHORTCUT", $runde),
case 19995: };
return JText::_("COM_SPORTSMANAGER_ROUND_OF_16_SHORTCUT");
case 19994:
return JText::_("COM_SPORTSMANAGER_ROUND_OF_32_SHORTCUT");
case 19993:
return JText::_("COM_SPORTSMANAGER_ROUND_OF_64_SHORTCUT");
case 19992:
return JText::_("COM_SPORTSMANAGER_ROUND_OF_128_SHORTCUT");
}
return $bezeichnung_verstecken ? $runde : JText::sprintf($spieltag ? "COM_SPORTSMANAGER_MATCH_DAY_NR_SHORTCUT" : "COM_SPORTSMANAGER_ROUND_NR_SHORTCUT", $runde);
} }
else { else {
if ($runde >= 20000) if ($runde >= 20000)
return JText::sprintf("COM_SPORTSMANAGER_PLACE_FROM_TO", 99 - $runde % 100, 99 - floor(($runde - 20000) / 100) + 99 - ($runde % 100)); return Text::sprintf("COM_SPORTSMANAGER_PLACE_FROM_TO", 99 - $runde % 100, 99 - floor(($runde - 20000) / 100) + 99 - ($runde % 100));
switch ($runde) { return match ($runde) {
case 0: 0 => $spieltag
return $spieltag ? Text::_("COM_SPORTSMANAGER_MATCH_DAY_NONE")
? JText::_("COM_SPORTSMANAGER_MATCH_DAY_NONE") : Text::_("COM_SPORTSMANAGER_ROUND_NONE"),
: JText::_("COM_SPORTSMANAGER_ROUND_NONE"); 19999 => Text::_("COM_SPORTSMANAGER_FINAL"),
case 19999: 19998 => Text::_("COM_SPORTSMANAGER_3RD_PLACE"),
return JText::_("COM_SPORTSMANAGER_FINAL"); 19997 => Text::_("COM_SPORTSMANAGER_HALF_FINAL"),
case 19998: 19996 => Text::_("COM_SPORTSMANAGER_QUARTER_FINAL"),
return JText::_("COM_SPORTSMANAGER_3RD_PLACE"); 19995 => Text::_("COM_SPORTSMANAGER_ROUND_OF_16"),
case 19997: 19994 => Text::_("COM_SPORTSMANAGER_ROUND_OF_32"),
return JText::_("COM_SPORTSMANAGER_HALF_FINAL"); 19993 => Text::_("COM_SPORTSMANAGER_ROUND_OF_64"),
case 19996: 19992 => Text::_("COM_SPORTSMANAGER_ROUND_OF_128"),
return JText::_("COM_SPORTSMANAGER_QUARTER_FINAL"); default => $bezeichnung_verstecken
case 19995:
return JText::_("COM_SPORTSMANAGER_ROUND_OF_16");
case 19994:
return JText::_("COM_SPORTSMANAGER_ROUND_OF_32");
case 19993:
return JText::_("COM_SPORTSMANAGER_ROUND_OF_64");
case 19992:
return JText::_("COM_SPORTSMANAGER_ROUND_OF_128");
}
return $bezeichnung_verstecken
? $runde ? $runde
: JText::sprintf( : Text::sprintf(
$spieltag $spieltag
? "COM_SPORTSMANAGER_MATCH_DAY_NR" ? "COM_SPORTSMANAGER_MATCH_DAY_NR"
: "COM_SPORTSMANAGER_ROUND_NR", : "COM_SPORTSMANAGER_ROUND_NR",
$runde $runde
); ),
};
} }
} }
function FormatiertesDatum($s, $zeit_anzeigen = true, $wochentag_anzeigen = true) { function FormatiertesDatum($s, $zeit_anzeigen = true, $wochentag_anzeigen = true): string
{
if ($s != null && strlen($s) > 0) { if ($s != null && strlen($s) > 0) {
$ts = getdate(strtotime($s)); $ts = getdate(strtotime($s));
if ($wochentag_anzeigen) { if ($wochentag_anzeigen) {
$wochentage = array(JText::_("COM_SPORTSMANAGER_DAY_0_SHORTCUT"), JText::_("COM_SPORTSMANAGER_DAY_1_SHORTCUT"), JText::_("COM_SPORTSMANAGER_DAY_2_SHORTCUT"), JText::_("COM_SPORTSMANAGER_DAY_3_SHORTCUT"), JText::_("COM_SPORTSMANAGER_DAY_4_SHORTCUT"), JText::_("COM_SPORTSMANAGER_DAY_5_SHORTCUT"), JText::_("COM_SPORTSMANAGER_DAY_6_SHORTCUT")); $wochentage = array(Text::_("COM_SPORTSMANAGER_DAY_0_SHORTCUT"), Text::_("COM_SPORTSMANAGER_DAY_1_SHORTCUT"), Text::_("COM_SPORTSMANAGER_DAY_2_SHORTCUT"), Text::_("COM_SPORTSMANAGER_DAY_3_SHORTCUT"), Text::_("COM_SPORTSMANAGER_DAY_4_SHORTCUT"), Text::_("COM_SPORTSMANAGER_DAY_5_SHORTCUT"), Text::_("COM_SPORTSMANAGER_DAY_6_SHORTCUT"));
if ($zeit_anzeigen) if ($zeit_anzeigen)
return sprintf("%s, %02d.%02d.%04d %02d:%02d", $wochentage[$ts["wday"]], $ts["mday"], $ts["mon"], $ts["year"], $ts["hours"], $ts["minutes"]); return sprintf("%s, %02d.%02d.%04d %02d:%02d", $wochentage[$ts["wday"]], $ts["mday"], $ts["mon"], $ts["year"], $ts["hours"], $ts["minutes"]);
@@ -225,10 +194,11 @@ function FormatiertesDatum($s, $zeit_anzeigen = true, $wochentag_anzeigen = true
return sprintf("%02d.%02d.%04d", $ts["mday"], $ts["mon"], $ts["year"]); return sprintf("%02d.%02d.%04d", $ts["mday"], $ts["mon"], $ts["year"]);
} }
return JText::_("COM_SPORTSMANAGER_DATE_NONE"); return Text::_("COM_SPORTSMANAGER_DATE_NONE");
} }
function FormatierterTermin($erster_tag, $letzter_tag, $jahr_anzeigen = false, $filter_jahr = null) { function FormatierterTermin($erster_tag, $letzter_tag, $jahr_anzeigen = false, $filter_jahr = null): string
{
$erster_ts = getdate(strtotime($erster_tag)); $erster_ts = getdate(strtotime($erster_tag));
$letzter_ts = getdate(strtotime($letzter_tag)); $letzter_ts = getdate(strtotime($letzter_tag));
if (!empty($filter_jahr)) if (!empty($filter_jahr))
@@ -246,401 +216,12 @@ function FormatierterTermin($erster_tag, $letzter_tag, $jahr_anzeigen = false, $
return $erster_termin . "-" . $letzter_termin; return $erster_termin . "-" . $letzter_termin;
} }
function bildLoeschen($typ, $id) { function terminDokumentname($id): bool|string
global $sportsmanager_joomla_path;
$typ_exploded = explode("/", $typ);
$typ = $typ_exploded[0];
$typ_prefix = count($typ_exploded) > 1 ? $typ_exploded[1] : "";
$bilder_pfad = $sportsmanager_joomla_path . DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR . 'sportsmanager' . DIRECTORY_SEPARATOR . $typ;
$pfad = $bilder_pfad . '/' . $typ_prefix . $id . ".";
if (!is_file($pfad . 'png') && !is_file($pfad . 'jpg'))
return;
$alte_bilder = JFolder::files($bilder_pfad, '^' . $typ_prefix . $id . '\.|^' . $typ_prefix . 'I' . $id . 'T');
foreach ($alte_bilder as $fn)
JFile::delete($bilder_pfad . DIRECTORY_SEPARATOR . $fn);
}
function bildIdentisch($typ1, $id1, $typ2, $id2) {
global $sportsmanager_joomla_path;
$typ1_exploded = explode("/", $typ1);
$typ1 = $typ1_exploded[0];
$typ1_prefix = count($typ1_exploded) > 1 ? $typ1_exploded[1] : "";
$bilder_pfad1 = $sportsmanager_joomla_path . DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR . 'sportsmanager' . DIRECTORY_SEPARATOR . $typ1;
$pfad1 = $bilder_pfad1 . '/' . $typ1_prefix . $id1 . ".";
if (is_file($pfad1 . "png"))
$ext = "png";
else if (is_file($pfad1 . "jpg"))
$ext = "jpg";
else
$ext = "";
$pfad1 .= $ext;
$typ2_exploded = explode("/", $typ2);
$typ2 = $typ2_exploded[0];
$typ2_prefix = count($typ2_exploded) > 1 ? $typ2_exploded[1] : "";
$bilder_pfad2 = $sportsmanager_joomla_path . DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR . 'sportsmanager' . DIRECTORY_SEPARATOR . $typ2;
$pfad2 = $bilder_pfad2 . '/' . $typ2_prefix . $id2 . "." . $ext;
return files_identical($pfad1, $pfad2);
}
function teamImage($teamId, $vereinId, $width = 240, $height = 240) {
$url = bildURL("mannschaften", $teamId, 0, 0, $width, $height);
if ($url == null) {
$url = bildURL("vereine", $vereinId, 0, 0, $width, $height);
}
return $url;
}
function playerImage($playerId, $gender, $width = 180, $height = 240) {
$url = bildURL("spieler", $playerId, $width, $height, 0,0,'', $gender == 'M' ? 'm' : 'w');
if ($url == null) {
$url = bildURL("mannschaftsmitglieder", $playerId, $width, $height, 0,0,'');
}
return $url;
}
function bildURL($typ, $id, $fixed_width = 0, $fixed_height = 0, $max_width = 0, $max_height = 0, $zusatz = "", $alternativ = "") {
global $sportsmanager_joomla_path;
global $sportsmanager_joomla_url;
$typ_exploded = explode("/", $typ);
$typ = $typ_exploded[0];
$typ_prefix = count($typ_exploded) > 1 ? $typ_exploded[1] : "";
$pfad = $sportsmanager_joomla_path . "/images/sportsmanager/" . $typ . "/" . $typ_prefix . $id . ".";
if (is_file($pfad . "png"))
$ext = "png";
else if (is_file($pfad . "jpg"))
$ext = "jpg";
else if (!empty($alternativ)) {
$id = $alternativ;
$pfad = $sportsmanager_joomla_path . "/images/sportsmanager/" . $typ . "/" . $typ_prefix . $id . ".";
if (is_file($pfad . "png"))
$ext = "png";
else if (is_file($pfad . "jpg"))
$ext = "jpg";
else
return null;
}
else
return null;
$time = filemtime($pfad . $ext);
if ($fixed_width > 0 && $fixed_height > 0) {
$pfad_angepasst = $sportsmanager_joomla_path . "/images/sportsmanager/" . $typ . "/" . $typ_prefix . "I" . $id . "T" . $time . "W" . $fixed_width . "H" . $fixed_height . "." . $ext;
if (is_file($pfad_angepasst)) {
return $sportsmanager_joomla_url . 'images/sportsmanager/' . $typ . '/' . basename($pfad_angepasst);
}
}
$size = getimagesize($pfad . $ext);
$width = $size[0];
$height = $size[1];
$max_width = $fixed_width > 0 ? $fixed_width : $max_width;
$max_height = $fixed_height > 0 ? $fixed_height : $max_height;
if (($fixed_width == 0 || $width == $fixed_width) && ($fixed_height == 0 || $height == $fixed_height) && ($fixed_width != 0 || $max_width == 0 || $width <= $max_width) && ($fixed_height != 0 || $max_height == 0 || $height <= $max_height)) {
$pfad_angepasst = $sportsmanager_joomla_path . "/images/sportsmanager/" . $typ . "/" . $typ_prefix . "I" . $id . "T" . $time . "W" . $width . "H" . $height . "." . $ext;
if (!is_file($pfad_angepasst)) {
if (!copy($pfad . $ext, $pfad_angepasst))
return null;
}
return $sportsmanager_joomla_url . 'images/sportsmanager/' . $typ . '/' . basename($pfad_angepasst);
}
$new_width = $width;
$new_height = $height;
if ($max_height > 0 && $new_height > $max_height) {
$new_width = max(round($new_width * $max_height / $new_height), 1);
$new_height = $max_height;
}
if ($max_width > 0 && $new_width > $max_width) {
$new_height = max(round($new_height * $max_width / $new_width), 1);
$new_width = $max_width;
}
if ($max_width > 0 && (($max_width - $new_width) % 2) == 1) // Toleranz bei nur 1 Pixel Unterschied
$new_width += 1;
if ($max_height > 0 && (($max_height - $new_height) % 2) == 1) // Toleranz bei nur 1 Pixel Unterschied
$new_height += 1;
$pfad_angepasst = $sportsmanager_joomla_path . "/images/sportsmanager/" . $typ . "/" . $typ_prefix . "I" . $id . "T" . $time . "W" . max($fixed_width, $new_width) . "H" . max($fixed_height, $new_height) . "." . $ext;
if (!is_file($pfad_angepasst)) {
$image = $ext == "png" ? imagecreatefrompng($pfad . $ext) : imagecreatefromjpeg($pfad . $ext);
if ($image === false)
return null;
$image_resized = imagecreatetruecolor(max($fixed_width, $new_width), max($fixed_height, $new_height));
$color = $ext == "png" ? imagecolorallocatealpha($image_resized, 0, 0, 0, 127) : imagecolorallocate($image_resized, 64, 64, 64);
imagefill($image_resized, 0, 0, $color);
imagecopyresampled($image_resized, $image, round((imagesx($image_resized) - $new_width) / 2), round((imagesy($image_resized) - $new_height) / 2), 0, 0, $new_width, $new_height, $width, $height);
if ($ext == "png") {
imagesavealpha($image_resized, true);
imagepng($image_resized, $pfad_angepasst);
}
else
imagejpeg($image_resized, $pfad_angepasst);
}
return $sportsmanager_joomla_url . 'images/sportsmanager/' . $typ . '/' . basename($pfad_angepasst);
}
/*
* #resize=250
#resize=250,250,blue
#resize=250,250,blue
#resize=250,250&sizes=60%,80%,200%
#resize=250,250,cover&sizes=60%,80%,200%
#resize=250,250,fill&sizes=60%,80%,200%
#crop=250,250,center,top
#crop=250,250
#crop=250,250,center,bottom
#crop=250,250,left
#crop=250,250,right
*/
function yoothemeBild($typ, $id, $resize = '', $zusatz = "", $alternativ)
{ {
global $sportsmanager_joomla_path; global $sportsmanager_joomla_path;
global $sportsmanager_joomla_url;
$typ_exploded = explode("/", $typ);
$typ = $typ_exploded[0];
$typ_prefix = count($typ_exploded) > 1 ? $typ_exploded[1] : "";
$pfad = $sportsmanager_joomla_path . "/images/sportsmanager/" . $typ . "/" . $typ_prefix . $id . ".";
if (is_file($pfad . "png"))
$ext = "png";
else if (is_file($pfad . "jpg"))
$ext = "jpg";
else if (!empty($alternativ)) {
$id = $alternativ;
$pfad = $sportsmanager_joomla_path . "/images/sportsmanager/" . $typ . "/" . $typ_prefix . $id . ".";
if (is_file($pfad . "png"))
$ext = "png";
else if (is_file($pfad . "jpg"))
$ext = "jpg";
else
return null;
}
else
return null;
$time = filemtime($pfad . $ext);
$bildpfad = "images/sportsmanager/" . $typ . "/" . $typ_prefix . $id . "." . $ext;
return '<img class="el-image" data-src="' . $bildpfad . $resize . '" ' . $zusatz . ' uk-img />';
}
/*
Quick and dirty DTFL Logo Bilder
*/
function logoBilder($typ, $id, $resize = '', $zusatz = "", $alternativ)
{
global $sportsmanager_joomla_path;
global $sportsmanager_joomla_url;
$typ_exploded = explode("/", $typ);
$typ = $typ_exploded[0];
$typ_prefix = count($typ_exploded) > 1 ? $typ_exploded[1] : "";
$pfad = $sportsmanager_joomla_path . "/images/sportsmanager/" . $typ . "/" . $typ_prefix . $id . ".";
if (is_file($pfad . "png"))
$ext = "png";
else if (is_file($pfad . "jpg"))
$ext = "jpg";
else if (!empty($alternativ)) {
$id = $alternativ;
$pfad = $sportsmanager_joomla_path . "/images/sportsmanager/" . $typ . "/" . $typ_prefix . $id . ".";
if (is_file($pfad . "png"))
$ext = "png";
else if (is_file($pfad . "jpg"))
$ext = "jpg";
else
return null;
}
else
return null;
$time = filemtime($pfad . $ext);
$bildpfad = "images/sportsmanager/" . $typ . "/" . $typ_prefix . $id . "." . $ext;
return '<img class="el-image" data-src="' . $bildpfad . $resize . '" ' . $zusatz . ' uk-img />';
}
function bildHTML($typ, $id, $fixed_width = 0, $fixed_height = 0, $max_width = 0, $max_height = 0, $zusatz = "", $alternativ = "") {
global $sportsmanager_joomla_path;
global $sportsmanager_joomla_url;
$typ_exploded = explode("/", $typ);
$typ = $typ_exploded[0];
$typ_prefix = count($typ_exploded) > 1 ? $typ_exploded[1] : "";
$pfad = $sportsmanager_joomla_path . "/images/sportsmanager/" . $typ . "/" . $typ_prefix . $id . ".";
if (is_file($pfad . "png"))
$ext = "png";
else if (is_file($pfad . "jpg"))
$ext = "jpg";
else if (!empty($alternativ)) {
$id = $alternativ;
$pfad = $sportsmanager_joomla_path . "/images/sportsmanager/" . $typ . "/" . $typ_prefix . $id . ".";
if (is_file($pfad . "png"))
$ext = "png";
else if (is_file($pfad . "jpg"))
$ext = "jpg";
else
return null;
}
else
return null;
$time = filemtime($pfad . $ext);
if ($fixed_width > 0 && $fixed_height > 0) {
$pfad_angepasst = $sportsmanager_joomla_path . "/images/sportsmanager/" . $typ . "/" . $typ_prefix . "I" . $id . "T" . $time . "W" . $fixed_width . "H" . $fixed_height . "." . $ext;
if (is_file($pfad_angepasst)) {
return '<img src="' . $sportsmanager_joomla_url . 'images/sportsmanager/' . $typ . '/' . basename($pfad_angepasst) . '" width="' . $fixed_width . '" height="' . $fixed_height . '" ' . $zusatz . ' />';
}
}
$size = getimagesize($pfad . $ext);
$width = $size[0];
$height = $size[1];
$max_width = $fixed_width > 0 ? $fixed_width : $max_width;
$max_height = $fixed_height > 0 ? $fixed_height : $max_height;
if (($fixed_width == 0 || $width == $fixed_width) && ($fixed_height == 0 || $height == $fixed_height) && ($fixed_width != 0 || $max_width == 0 || $width <= $max_width) && ($fixed_height != 0 || $max_height == 0 || $height <= $max_height)) {
$pfad_angepasst = $sportsmanager_joomla_path . "/images/sportsmanager/" . $typ . "/" . $typ_prefix . "I" . $id . "T" . $time . "W" . $width . "H" . $height . "." . $ext;
if (!is_file($pfad_angepasst)) {
if (!copy($pfad . $ext, $pfad_angepasst))
return null;
}
return '<img src="' . $sportsmanager_joomla_url . 'images/sportsmanager/' . $typ . '/' . basename($pfad_angepasst) . '" width="' . $width . '" height="' . $height . '" ' . $zusatz . ' />';
}
$new_width = $width;
$new_height = $height;
if ($max_height > 0 && $new_height > $max_height) {
$new_width = max(round($new_width * $max_height / $new_height), 1);
$new_height = $max_height;
}
if ($max_width > 0 && $new_width > $max_width) {
$new_height = max(round($new_height * $max_width / $new_width), 1);
$new_width = $max_width;
}
if ($max_width > 0 && (($max_width - $new_width) % 2) == 1) // Toleranz bei nur 1 Pixel Unterschied
$new_width += 1;
if ($max_height > 0 && (($max_height - $new_height) % 2) == 1) // Toleranz bei nur 1 Pixel Unterschied
$new_height += 1;
$pfad_angepasst = $sportsmanager_joomla_path . "/images/sportsmanager/" . $typ . "/" . $typ_prefix . "I" . $id . "T" . $time . "W" . max($fixed_width, $new_width) . "H" . max($fixed_height, $new_height) . "." . $ext;
if (!is_file($pfad_angepasst)) {
$image = $ext == "png" ? imagecreatefrompng($pfad . $ext) : imagecreatefromjpeg($pfad . $ext);
if ($image === false)
return null;
$image_resized = imagecreatetruecolor(max($fixed_width, $new_width), max($fixed_height, $new_height));
$color = $ext == "png" ? imagecolorallocatealpha($image_resized, 0, 0, 0, 127) : imagecolorallocate($image_resized, 64, 64, 64);
imagefill($image_resized, 0, 0, $color);
imagecopyresampled($image_resized, $image, round((imagesx($image_resized) - $new_width) / 2), round((imagesy($image_resized) - $new_height) / 2), 0, 0, $new_width, $new_height, $width, $height);
if ($ext == "png") {
imagesavealpha($image_resized, true);
imagepng($image_resized, $pfad_angepasst);
}
else
imagejpeg($image_resized, $pfad_angepasst);
}
return '<img src="' . $sportsmanager_joomla_url . 'images/sportsmanager/' . $typ . '/' . basename($pfad_angepasst) . '" width="' . max($fixed_width, $new_width) . '" height="' . max($fixed_height, $new_height) . '" ' . $zusatz . ' />';
}
function terminDokumentname($id) {
global $sportsmanager_joomla_path;
$pfad = $sportsmanager_joomla_path . "/images/sportsmanager/termine"; $pfad = $sportsmanager_joomla_path . "/images/sportsmanager/termine";
$dokumente = JFolder::files($pfad, '^' . $id . ' '); $dokumente = Folder::files($pfad, '^' . $id . ' ');
return !empty($dokumente) ? substr($dokumente[0], strlen((string) $id) + 1) : false; return !empty($dokumente) ? substr($dokumente[0], strlen((string) $id) + 1) : false;
} }
function lightBoxJSShow($lightbox_class = "lightbox") {
return "show" . $lightbox_class . "();";
}
function lightBoxJSHide($lightbox_class = "lightbox") {
return "hide" . $lightbox_class . "();";
}
function lightBoxClassHide($lightbox_class = "lightbox") {
return $lightbox_class . "_close";
}
function lightBoxHeader($lightbox_class = "lightbox") {
?>
<style type="text/css">
div<?php echo "#" . $lightbox_class; ?> {
position: fixed;
left: 50px;
right: 50px;
top: 50px;
bottom: 50px;
border: 1px solid #999999;
overflow: scroll;
background-color: #e4e4e4;
padding: 20px;
display: none;
visibility: hidden;
}
div<?php echo "#" . $lightbox_class . "_close"; ?> {
position: fixed;
right: 0px;
top: 0px;
bottom: 0px;
left: 0px;
overflow: hidden;
display: none;
visibility: hidden;
background-color: rgba(0, 0, 0, 0.8);
}
</style>
<script type="text/javascript">
//<!--
function show<?php echo $lightbox_class; ?>() {
document.getElementById("<?php echo $lightbox_class; ?>").style.display = "inline";
document.getElementById("<?php echo $lightbox_class; ?>").style.visibility = "visible";
document.getElementById("<?php echo $lightbox_class . "_close"; ?>").style.display = "inline";
document.getElementById("<?php echo $lightbox_class . "_close"; ?>").style.visibility = "visible";
}
function hide<?php echo $lightbox_class; ?>() {
document.getElementById("<?php echo $lightbox_class; ?>").style.display = "none";
document.getElementById("<?php echo $lightbox_class; ?>").style.visibility = "hidden";
document.getElementById("<?php echo $lightbox_class . "_close"; ?>").style.display = "none";
document.getElementById("<?php echo $lightbox_class . "_close"; ?>").style.visibility = "hidden";
}
//-->
</script>
<?php
}
+240 -218
View File
File diff suppressed because it is too large Load Diff