Funktionen zum Konvertieren der unterschiedlichen Altereklassenformate
in Jahrgangsintervalle - Spielwiese new file: admin/ak2jg.php - Zwei Funktionen hinzugefügt (ak2..) modified: phpLib/cwsvJudo/wkKalender.php - Bonus: die Jahrgangsintervalle als Tooltip im Kalender modified: src/css/cwsvJudo-2018-wkKalender.css
This commit is contained in:
58
homepage/redesign2018/markdownExperiment/admin/ak2jg.php
Normal file
58
homepage/redesign2018/markdownExperiment/admin/ak2jg.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
include_once("config.inc.php");
|
||||
|
||||
$basePath = "/users/cwsvjudo/www";
|
||||
|
||||
require_once($basePath."/config/cwsvJudo.config.php");
|
||||
|
||||
require_once($basePath."/config/phpcount.config.php");
|
||||
require_once($basePath."/ressourcen/phpLib/phpcount/phpcount.php");
|
||||
|
||||
require_once($basePath."/ressourcen/phpLib/cwsvJudo/miscAssis.php");
|
||||
|
||||
$cwsvJudoDbConnection = getCwsvJudoDbConn();
|
||||
$cwsvJudoDbConnection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
|
||||
$akQuery =
|
||||
$cwsvJudoDbConnection->prepare(
|
||||
"SELECT lfdeNr, Datum, Veranstaltung, Altersklassen FROM cwsvjudo.`wettkampfkalender` WHERE DATUM > CURRENT_DATE() ORDER BY Datum ASC, lfdeNr ASC LIMIT 24;"
|
||||
);
|
||||
|
||||
$akQuery->execute();
|
||||
$wkList = $akQuery->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
// Zeichensatzkonvertierung
|
||||
$someOptions = array();
|
||||
if( empty($someOptions['dbCharset']) )
|
||||
$someOptions['dbCharset'] = "ISO-8859-1";
|
||||
if( empty($someOptions['outCharset']) )
|
||||
$someOptions['outCharset'] = "UTF-8";
|
||||
|
||||
foreach($wkList as &$entry){
|
||||
array_walk(
|
||||
$entry,
|
||||
function (&$value, $key, $someOptions) {
|
||||
$value = iconv($someOptions['dbCharset'], $someOptions['outCharset'], $value);
|
||||
},
|
||||
$someOptions
|
||||
);
|
||||
}
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
</head>
|
||||
<body>
|
||||
<table>
|
||||
<?php
|
||||
foreach($wkList as $wk){
|
||||
$jg=array();
|
||||
$jg=akListString2jgArray($wk['Altersklassen'], date('Y', strtotime($wk['Datum'])) );
|
||||
echo("<tr><td>".$wk['lfdeNr']."</td><td>".$wk['Datum']."</td><td>".$wk['Veranstaltung']."</td><td>".$wk['Altersklassen']."</td><td>".json_encode($jg)."</td></tr>");
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
@@ -10,6 +10,7 @@ function echoWkTitle(){
|
||||
);
|
||||
}
|
||||
/// Einen Wettkampfnamen per ID abfragen
|
||||
|
||||
function getWkName( $wkId, $alternative="Judo-Wettkampf" ){
|
||||
|
||||
if( !is_positive_integer($wkId) ) return $alternative;
|
||||
@@ -215,8 +216,8 @@ $htmlWkTableString = "";
|
||||
"<td data-title=\"Wegbeschreibung\">".
|
||||
"<a title=\"Wegbeschreibung ".$wk['Veranstaltung']."\" href=\"".$wk['Routenplaner']."\"><span>".$wk['Ort']."</span></a>".
|
||||
"</td>".
|
||||
"<td data-title=\"Altersklassen\">".
|
||||
$wk['Altersklassen'].
|
||||
"<td data-title=\"Altersklassen\" class=\"tooltip\">".
|
||||
$wk['Altersklassen']."<span class=\"tooltiptext\">".json_encode(akListString2jgArray($wk['Altersklassen']))."</span>".
|
||||
"</td>".
|
||||
"<td data-title=\"iCal\">".
|
||||
"<a title=\"Termin für ".$wk['Veranstaltung']." in Kalender übernehmen\" href=\"/ressourcen/phpLib/calendar.php?wkID=".$wk['lfdeNr']."\">iCal</a>".
|
||||
@@ -251,6 +252,83 @@ function nicerAkList($akArray){
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/// Als String gegebene Altersklassen als Jahrgangsintervalle
|
||||
/// ausdrücken
|
||||
function akListString2jgArray($akListString, $year = NULL ){
|
||||
$ret = array();
|
||||
|
||||
if($year==NULL)
|
||||
$year=date("Y");
|
||||
else{
|
||||
if( !((int)$year == $year && (int)$year >= 0) )
|
||||
$year=date("Y");
|
||||
}
|
||||
|
||||
$year = (int)$year;
|
||||
|
||||
foreach(explode(" ", $akListString) as $ak)
|
||||
array_push(
|
||||
$ret,
|
||||
akString2jgIntervall($ak, $year)
|
||||
);
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
/// Aus einer als String gegebenen Altersklasse ein Jahrgangsintervall
|
||||
/// machen
|
||||
function akString2jgIntervall($akString, $year){
|
||||
$ret= array(NULL, NULL);
|
||||
|
||||
// Speziell für die Ux-Altersklassen
|
||||
// Es fehlt noch das <=U
|
||||
$akUmatchString = "/(.*)U(.*)/";
|
||||
|
||||
$matches = array();
|
||||
|
||||
preg_match($akUmatchString, $akString, $matches);
|
||||
// Wenn wir nicht den gesamten akString Matchen ist etwas schief
|
||||
// gelaufen
|
||||
if($matches[0]==$akString){
|
||||
// Das ausgelesene Alter der Ux sollte eine positive Integer sein,
|
||||
// sonst ist was schiefgelaufen
|
||||
$ageLimit = (int)$matches[2];
|
||||
if( ($ageLimit == $matches[2] && $ageLimit > 0) ){
|
||||
$ret[0] = $year-$ageLimit+1;
|
||||
|
||||
if($matches[1] == "")
|
||||
$ret[1] = $year-$ageLimit+2;
|
||||
else{
|
||||
if($matches[1] == "-")
|
||||
$ret[1] = $year-$ageLimit+3;
|
||||
else{
|
||||
if($matches[1] == "--")
|
||||
$ret[1] = $year-$ageLimit+4;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
// Speziell Altersklassen der Form Jg.x-y
|
||||
$akUmatchString = "/Jg\.(.*)\-(.*)/";
|
||||
|
||||
$matches = array();
|
||||
|
||||
preg_match($akUmatchString, $akString, $matches);
|
||||
// Wenn wir nicht den gesamten akString Matchen ist etwas schief
|
||||
// gelaufen
|
||||
if($matches[0]==$akString){
|
||||
$ret[0]=(int)$matches[1];
|
||||
$ret[1]=(int)$matches[2];
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
/// Wettkampfdaten als json-formatierte strukturierte Event-Daten
|
||||
function wkArray2jsonSdEvent($wk){
|
||||
|
||||
@@ -835,3 +835,39 @@
|
||||
.wkBoxMediaGallery > *{
|
||||
flex-basis:50%;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Tooltipps
|
||||
*/
|
||||
|
||||
/* Tooltip container */
|
||||
.tooltip {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
border-bottom: 1px dotted black; /* If you want dots under the hoverable text */
|
||||
}
|
||||
|
||||
/* Tooltip text */
|
||||
.tooltip .tooltiptext {
|
||||
visibility: hidden;
|
||||
width: 120px;
|
||||
background-color: black;
|
||||
color: #fff;
|
||||
text-align: center;
|
||||
padding: 5px 0;
|
||||
border-radius: 6px;
|
||||
|
||||
/* Position the tooltip text - see examples below! */
|
||||
position: absolute;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/* Show the tooltip text when you mouse over the tooltip container */
|
||||
.tooltip:hover .tooltiptext {
|
||||
visibility: visible;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user