Initial standalone bundle extraction
This commit is contained in:
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
|
||||
namespace Mummert\KsNossenerlandBundle\DataContainer;
|
||||
|
||||
use Contao\Database;
|
||||
use Contao\Date;
|
||||
use Contao\StringUtil;
|
||||
use Contao\System;
|
||||
use Contao\Calendar;
|
||||
use Contao\Config;
|
||||
|
||||
class CalendarEvents
|
||||
{
|
||||
public function listEvents($arrRow)
|
||||
{
|
||||
$database = Database::getInstance();
|
||||
|
||||
// Ortstitel aus `ctlg_orte`-Tabelle holen
|
||||
$ort = $database->prepare("SELECT ortTitle FROM ctlg_orte WHERE id=?")
|
||||
->execute($arrRow['catalog_ort'])
|
||||
->fetchAssoc();
|
||||
|
||||
$ortTitle = $ort ? $ort['ortTitle'] : '-';
|
||||
|
||||
// Event-Datum formatieren
|
||||
$span = Calendar::calculateSpan($arrRow['startTime'], $arrRow['endTime']);
|
||||
|
||||
if ($span > 0) {
|
||||
$date = Date::parse(Config::get(($arrRow['addTime'] ? 'datimFormat' : 'dateFormat')), $arrRow['startTime']) .
|
||||
$GLOBALS['TL_LANG']['MSC']['cal_timeSeparator'] .
|
||||
Date::parse(Config::get(($arrRow['addTime'] ? 'datimFormat' : 'dateFormat')), $arrRow['endTime']);
|
||||
} elseif ($arrRow['startTime'] == $arrRow['endTime']) {
|
||||
$date = Date::parse(Config::get('dateFormat'), $arrRow['startTime']) .
|
||||
($arrRow['addTime'] ? ' ' . Date::parse(Config::get('timeFormat'), $arrRow['startTime']) : '');
|
||||
} else {
|
||||
$date = Date::parse(Config::get('dateFormat'), $arrRow['startTime']) .
|
||||
($arrRow['addTime'] ? ' ' . Date::parse(Config::get('timeFormat'), $arrRow['startTime']) .
|
||||
$GLOBALS['TL_LANG']['MSC']['cal_timeSeparator'] .
|
||||
Date::parse(Config::get('timeFormat'), $arrRow['endTime']) : '');
|
||||
}
|
||||
|
||||
// Rückgabe ohne <strong>-Tag
|
||||
return '<div class="tl_content_left">' .
|
||||
$arrRow['title'] .
|
||||
' <span style="color:#999;padding-left:3px">[' . $ortTitle . ' ' . $date . ']</span>' .
|
||||
'</div>';
|
||||
}
|
||||
|
||||
public function getCtlgOrteOptions(): array
|
||||
{
|
||||
$options = [];
|
||||
$result = Database::getInstance()->prepare("SELECT id, ortTitle FROM ctlg_orte ORDER BY ortTitle")->execute();
|
||||
|
||||
while ($result->next()) {
|
||||
$options[$result->id] = $result->ortTitle;
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
public function getCtlgPfarrbereicheOptions(): array
|
||||
{
|
||||
$options = [];
|
||||
|
||||
// Daten aus ctlg_districts sortiert nach districtsTitle laden
|
||||
$result = Database::getInstance()->prepare("
|
||||
SELECT id, districtsTitle
|
||||
FROM ctlg_districts
|
||||
ORDER BY districtsTitle
|
||||
")->execute();
|
||||
|
||||
while ($result->next()) {
|
||||
$options[$result->id] = $result->districtsTitle;
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
|
||||
public function getCtlgKontaktOptions(): array
|
||||
{
|
||||
$options = [];
|
||||
|
||||
// Sortierung nach lastname, contactsTerm, firstname
|
||||
$result = Database::getInstance()->prepare("
|
||||
SELECT id, contactsTerm, contactsFirstname, contactsLastname, contactsFunction
|
||||
FROM ctlg_contacts
|
||||
ORDER BY contactsLastname, contactsTerm, contactsFirstname
|
||||
")->execute();
|
||||
|
||||
while ($result->next()) {
|
||||
// Aufbau des Labels
|
||||
if (empty($result->contactsLastname) && empty($result->contactsFirstname)) {
|
||||
// Wenn lastname und firstname fehlen
|
||||
$label = $result->contactsTerm;
|
||||
} else {
|
||||
// Wenn lastname oder firstname vorhanden
|
||||
$label = $result->contactsLastname;
|
||||
|
||||
if (!empty($result->contactsFirstname)) {
|
||||
$label .= ', ' . $result->contactsFirstname;
|
||||
}
|
||||
|
||||
if (!empty($result->contactsFunction)) {
|
||||
$label .= ' (' . $result->contactsFunction . ')';
|
||||
}
|
||||
}
|
||||
|
||||
// Nur Labels hinzufügen, die tatsächlich Werte haben
|
||||
if (!empty($label)) {
|
||||
$options[$result->id] = $label;
|
||||
}
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user