added requisite-events .. mostly for future use

do not display empty dates in listview
This commit is contained in:
Sarjuuk
2013-03-13 23:04:52 +01:00
parent 5e8d1a2a39
commit e14c3b61d5
2 changed files with 31 additions and 3 deletions

View File

@@ -57,6 +57,10 @@ class WorldEventList extends BaseType
else if ($sT == -1) else if ($sT == -1)
$this->curTpl['category'] = 1; $this->curTpl['category'] = 1;
// preparse requisites
if ($this->curTpl['requires'])
$this->curTpl['requires'] = explode(' ', $this->curTpl['requires']);
// change Ids if holiday is set // change Ids if holiday is set
if ($this->curTpl['holidayId'] > 0) if ($this->curTpl['holidayId'] > 0)
{ {
@@ -101,6 +105,16 @@ class WorldEventList extends BaseType
public static function updateDates($start, $end, $occurence, $final = 5000000000) // in the far far FAR future.. public static function updateDates($start, $end, $occurence, $final = 5000000000) // in the far far FAR future..
{ {
if (!$start)
{
return array(
'start' => 0,
'end' => 0,
'nextStart' => 0,
'nextEnd' => 0
);
}
// Convert everything to seconds // Convert everything to seconds
$start = intVal($start); $start = intVal($start);
$end = intVal($end); $end = intVal($end);

View File

@@ -42,14 +42,21 @@ if (!$smarty->loadCache($cacheKey, $pageData))
$events = new WorldEventList($condition); $events = new WorldEventList($condition);
$events->addGlobalsToJScript($pageData);
$deps = [];
while ($events->iterate())
if ($d = $events->getField('requires'))
$deps[$events->id] = $d;
$pageData = array( $pageData = array(
'page' => $events->getListviewData(), 'page' => $events->getListviewData(),
'deps' => $deps,
'params' => array( 'params' => array(
'tabs' => '$myTabs' 'tabs' => '$myTabs'
) )
); );
$events->addGlobalsToJScript($pageData);
$smarty->saveCache($cacheKey, $pageData); $smarty->saveCache($cacheKey, $pageData);
} }
@@ -57,9 +64,16 @@ if (!$smarty->loadCache($cacheKey, $pageData))
// recalculate dates with now(); can't be cached, obviously // recalculate dates with now(); can't be cached, obviously
foreach ($pageData['page'] as &$data) foreach ($pageData['page'] as &$data)
{ {
// is a followUp-event
if (!empty($pageData['deps'][$data['id']]))
{
$data['startDate'] = $data['endDate'] = false;
continue;
}
$updated = WorldEventList::updateDates($data['startDate'], $data['endDate'], $data['rec']); $updated = WorldEventList::updateDates($data['startDate'], $data['endDate'], $data['rec']);
$data['startDate'] = date(Util::$dateFormatLong, $updated['start']); $data['startDate'] = $updated['start'] ? date(Util::$dateFormatLong, $updated['start']) : false;
$data['endDate'] = date(Util::$dateFormatLong, $updated['end']); $data['endDate'] = $updated['end' ] ? date(Util::$dateFormatLong, $updated['end']) : false;
} }