removed auth usage, php-cs-fixer
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
|
||||
class shiai{
|
||||
class shiai
|
||||
{
|
||||
private $id = null; //< unique id
|
||||
private $date = null; //< date of the shiai
|
||||
private $name = null; //< name of the shiai as string
|
||||
@@ -12,10 +12,11 @@ class shiai{
|
||||
private $galleryUrl = null; //< url of the gallery to a gallery of the shiai
|
||||
private $promoImgUrl = null; //< promotional image for the shiai (as url)
|
||||
|
||||
function __construct($id, $date, $name, $ageclasses, $place, $announcementUrl, $routeUrl, $galleryUrl, $promoImgUrl){
|
||||
public function __construct($id, $date, $name, $ageclasses, $place, $announcementUrl, $routeUrl, $galleryUrl, $promoImgUrl)
|
||||
{
|
||||
//! @todo input validation and sanitation
|
||||
$this->id = (int) $id;
|
||||
$this->date = DateTime::createFromFormat("Y-m-d", $date);
|
||||
$this->date = DateTime::createFromFormat('Y-m-d', $date);
|
||||
$this->name = $name;
|
||||
$this->ageclasses = $ageclasses;
|
||||
$this->place = $place;
|
||||
@@ -25,23 +26,29 @@ class shiai{
|
||||
$this->promoImgUrl = $promoImgUrl;
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
public function getAgeClasses(){
|
||||
return $this->ageclasses ? $this->ageclasses : "-";
|
||||
|
||||
public function getAgeClasses()
|
||||
{
|
||||
return $this->ageclasses ? $this->ageclasses : '-';
|
||||
}
|
||||
public function getId(){
|
||||
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
static public function fromArray($member){
|
||||
public static function fromArray($member)
|
||||
{
|
||||
return new shiai(
|
||||
$member['lfdeNr'] ?? null,
|
||||
$member['Datum'] ?? null,
|
||||
$member['Veranstaltung'] ?? "<fehlender Name>",
|
||||
$member['Veranstaltung'] ?? '<fehlender Name>',
|
||||
$member['Altersklassen'] ?? null,
|
||||
$member['Ort'] ?? "<fehlender Ort>",
|
||||
$member['Ort'] ?? '<fehlender Ort>',
|
||||
$member['Ausschreibung'] ?? null,
|
||||
$member['Routenplaner'] ?? null,
|
||||
$member['galleryLink'] ?? null,
|
||||
@@ -50,7 +57,8 @@ class shiai{
|
||||
}
|
||||
} // end class shiai
|
||||
|
||||
class event{
|
||||
class event
|
||||
{
|
||||
private $id = null; //< unique id of the event in the db
|
||||
private $date = null; //< date for the event (@todo ranges?)
|
||||
private $shiaiId = null; //< unique id of the shiai in the db (if appropriate)
|
||||
@@ -59,54 +67,61 @@ class event{
|
||||
|
||||
private $shiai = null;
|
||||
|
||||
function __construct($id, $date, $shiaiId, $deadline, $remarks, $shiai){
|
||||
public function __construct($id, $date, $shiaiId, $deadline, $remarks, $shiai)
|
||||
{
|
||||
//! @todo InputValidation
|
||||
$this->id = (int) $id;
|
||||
$this->date = DateTime::createFromFormat("Y-m-d", $date);
|
||||
$this->shiaiId = (($shiaiId!=null)?((int)$shiaiId):(null));
|
||||
$this->deadline = DateTime::createFromFormat("Y-m-d", $deadline);
|
||||
$this->date = DateTime::createFromFormat('Y-m-d', $date);
|
||||
$this->shiaiId = (($shiaiId != null) ? ((int)$shiaiId) : (null));
|
||||
$this->deadline = DateTime::createFromFormat('Y-m-d', $deadline);
|
||||
$this->remarks = $remarks;
|
||||
|
||||
$this->shiai = $shiai;
|
||||
}
|
||||
|
||||
function asHtmlCard(){
|
||||
return
|
||||
"<div class=\"card blue-grey darken-1\">".
|
||||
"<div class=\"card-content white-text\">".
|
||||
"<span class=\"card-title\">".$this->shiai->getName()."</span>".
|
||||
"<dl>".
|
||||
"<dt>Datum</dt>".
|
||||
"<dd>".$this->date->format("Y-m-d")."</dd>".
|
||||
"<dt>Meldefrist</dt>".
|
||||
"<dd>".$this->deadline->format("Y-m-d")."</dd>".
|
||||
"<dt>Altersklassen</dt>".
|
||||
"<dd>".$this->shiai->getAgeClasses()."</dd>".
|
||||
"</div>".
|
||||
"</div>";
|
||||
}
|
||||
public function htmlTableRow(){
|
||||
return
|
||||
"<tr>".
|
||||
"<td>Datum ".$this->date->format("Y-m-d")."</td>".
|
||||
"<td><a href=\"/pages/desktop/wkParticipo/showWkEvent.php?eventId=".$this->id."\" >".$this->shiai->getName()."</a></td>".
|
||||
"<td><a class=\"waves-effect waves-light btn-floating modal-trigger\" href=\"#event-modal-".$this->id."\"><i class=\"material-icons\">add</i></a></td>".
|
||||
"</tr>";
|
||||
}
|
||||
public function htmlModal(){
|
||||
return
|
||||
"<div id=\"event-modal-".$this->id."\" class=\"modal\">".
|
||||
"<div class=\"modal-content\">".
|
||||
"<h4>".$this->shiai->getName()."</h4>".
|
||||
"<p>A bunch of text</p>".
|
||||
"</div>". // end modal-content
|
||||
"<div class=\"modal-footer\">".
|
||||
"<a href=\"#!\" class=\"modal-close waves-effect waves-green btn-flat\">Agree</a>".
|
||||
"</div>".
|
||||
"</div>";
|
||||
public function asHtmlCard()
|
||||
{
|
||||
return
|
||||
'<div class="card blue-grey darken-1">' .
|
||||
'<div class="card-content white-text">' .
|
||||
'<span class="card-title">' . $this->shiai->getName() . '</span>' .
|
||||
'<dl>' .
|
||||
'<dt>Datum</dt>' .
|
||||
'<dd>' . $this->date->format('Y-m-d') . '</dd>' .
|
||||
'<dt>Meldefrist</dt>' .
|
||||
'<dd>' . $this->deadline->format('Y-m-d') . '</dd>' .
|
||||
'<dt>Altersklassen</dt>' .
|
||||
'<dd>' . $this->shiai->getAgeClasses() . '</dd>' .
|
||||
'</div>' .
|
||||
'</div>';
|
||||
}
|
||||
|
||||
static public function fromArray($member){
|
||||
public function htmlTableRow()
|
||||
{
|
||||
return
|
||||
'<tr>' .
|
||||
'<td>' . $this->date->format('Y-m-d') . '</td>' .
|
||||
'<td><a href="/pages/desktop/wkParticipo/showWkEvent.php?eventId=' . $this->id . '" >' . $this->shiai->getName() . '</a></td>' .
|
||||
'<td><a class="waves-effect waves-light btn-floating modal-trigger" href="#event-modal-' . $this->id . '"><i class="material-icons">add</i></a></td>' .
|
||||
'</tr>';
|
||||
}
|
||||
|
||||
public function htmlModal()
|
||||
{
|
||||
return
|
||||
'<div id="event-modal-' . $this->id . '" class="modal">' .
|
||||
'<div class="modal-content">' .
|
||||
'<h4>' . $this->shiai->getName() . '</h4>' .
|
||||
'<p>A bunch of text</p>' .
|
||||
'</div>' . // end modal-content
|
||||
'<div class="modal-footer">' .
|
||||
'<a href="#!" class="modal-close waves-effect waves-green btn-flat">Agree</a>' .
|
||||
'</div>' .
|
||||
'</div>';
|
||||
}
|
||||
|
||||
public static function fromArray($member)
|
||||
{
|
||||
$shiai = json_decode($member['bemerkungen'], true);
|
||||
|
||||
return new event(
|
||||
@@ -115,72 +130,75 @@ class event{
|
||||
$member['wkId'] ?? null,
|
||||
$member['meldefrist'] ?? null,
|
||||
$member['bemerkungen'] ?? null,
|
||||
shiai::fromArray( ($shiai != null) ? $shiai : $member )
|
||||
shiai::fromArray(($shiai != null) ? $shiai : $member)
|
||||
);
|
||||
}
|
||||
} // end class event
|
||||
|
||||
class eventPlaner{
|
||||
static private $db = null;
|
||||
class eventPlaner
|
||||
{
|
||||
private static $db = null;
|
||||
|
||||
// set the dbConnection (just setting, no establishing)
|
||||
public static function setDbConnection($dbConnection){
|
||||
if($dbConnection instanceof PDO)
|
||||
public static function setDbConnection($dbConnection)
|
||||
{
|
||||
if ($dbConnection instanceof PDO) {
|
||||
self::$db = $dbConnection;
|
||||
else
|
||||
} else {
|
||||
self::$db = null;
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
static public function getCommingWkEvents($someOptions=array() ){
|
||||
public static function getCommingWkEvents($someOptions = [])
|
||||
{
|
||||
// wir befinden uns in der Übergangsphase:
|
||||
// - als Standard wird das derzeitige Verhalten definiert (ISO-8859-1
|
||||
// - als Standard wird das derzeitige Verhalten definiert (ISO-8859-1
|
||||
// und die Konvertierung erfolgt ausserhalb)
|
||||
// - wenn einmal alle mbConvertEncoding weg sind, kann der Standard auf
|
||||
// - wenn einmal alle mbConvertEncoding weg sind, kann der Standard auf
|
||||
// das gewünschte Verhalten umgestellt werden
|
||||
$dbCharset = $someOptions['dbCharset'] ?? "ISO-8859-1";
|
||||
$dbCharset = $someOptions['dbCharset'] ?? 'ISO-8859-1';
|
||||
// dbCharset = $someOptions['outCharset'] ?? "UTF-8";// das spätere, gewünschte Verhalten
|
||||
$outCharset = $someOptions['outCharset'] ?? "ISO-8859-1";
|
||||
|
||||
$query =
|
||||
"SELECT ".
|
||||
"wkParticipo_Events.id, ".
|
||||
"wkParticipo_Events.date, ".
|
||||
"wkParticipo_Events.wkId, ".
|
||||
"wkParticipo_Events.meldefrist, ".
|
||||
"wkParticipo_Events.bemerkungen, ".
|
||||
"wkParticipo_Events.kvOptions, ".
|
||||
"wettkampfkalender.Datum, ".
|
||||
"wettkampfkalender.Veranstaltung, ".
|
||||
"wettkampfkalender.Altersklassen, ".
|
||||
"wettkampfkalender.Ort, ".
|
||||
"wettkampfkalender.Ausschreibung, ".
|
||||
"wettkampfkalender.Routenplaner ".
|
||||
"FROM wkParticipo_Events ".
|
||||
"LEFT JOIN wettkampfkalender ".
|
||||
"ON wettkampfkalender.lfdeNr = wkParticipo_Events.wkId ".
|
||||
"WHERE wkParticipo_Events.date >= CURDATE() ".
|
||||
"ORDER BY wkParticipo_Events.date;";
|
||||
$outCharset = $someOptions['outCharset'] ?? 'ISO-8859-1';
|
||||
|
||||
$query =
|
||||
'SELECT ' .
|
||||
'wkParticipo_Events.id, ' .
|
||||
'wkParticipo_Events.date, ' .
|
||||
'wkParticipo_Events.wkId, ' .
|
||||
'wkParticipo_Events.meldefrist, ' .
|
||||
'wkParticipo_Events.bemerkungen, ' .
|
||||
'wkParticipo_Events.kvOptions, ' .
|
||||
'wettkampfkalender.Datum, ' .
|
||||
'wettkampfkalender.Veranstaltung, ' .
|
||||
'wettkampfkalender.Altersklassen, ' .
|
||||
'wettkampfkalender.Ort, ' .
|
||||
'wettkampfkalender.Ausschreibung, ' .
|
||||
'wettkampfkalender.Routenplaner ' .
|
||||
'FROM wkParticipo_Events ' .
|
||||
'LEFT JOIN wettkampfkalender ' .
|
||||
'ON wettkampfkalender.lfdeNr = wkParticipo_Events.wkId ' .
|
||||
'WHERE wkParticipo_Events.date >= CURDATE() ' .
|
||||
'ORDER BY wkParticipo_Events.date;';
|
||||
$ret = dbQuery(self::$db, $query);
|
||||
$events = array();
|
||||
foreach($ret as $event){
|
||||
array_push( $events, event::fromArray( $event ) );
|
||||
$events = [];
|
||||
foreach ($ret as $event) {
|
||||
array_push($events, event::fromArray($event));
|
||||
}
|
||||
return $events;
|
||||
}
|
||||
|
||||
static public function getHtmlEventTable($eventList){
|
||||
$ret = "<table>";
|
||||
$ret .= "<!-- And now the table -->";
|
||||
foreach($eventList as $event){
|
||||
|
||||
public static function getHtmlEventTable($eventList)
|
||||
{
|
||||
$ret = '<table>';
|
||||
$ret .= '<!-- And now the table -->';
|
||||
foreach ($eventList as $event) {
|
||||
$ret .= $event->htmlTableRow();
|
||||
}
|
||||
$ret .= "</table>";
|
||||
foreach($eventList as $event){
|
||||
$ret .= '</table>';
|
||||
foreach ($eventList as $event) {
|
||||
$ret .= $event->htmlModal();
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user