protected static function sortByDateAndLocation($query) { $dates = array(); $locations = array(); $result = Database::query($query); $rows = Database::convertResult($result); foreach ($rows as $row) { $oGame = new Game(); $oGame->setData($row); if (!$locations[$oGame->location_nefub_id]) { $locations[$oGame->location_nefub_id] = Location::getByNefubId($oGame->location_nefub_id); } $oLocation = $locations[$oGame->location_nefub_id]; // create array for locations per date if (!is_array($dates[$oGame->date])) { $dates[$oGame->date] = array(); } // create array for times per location if (!is_array($dates[$oGame->date][$oGame->location_nefub_id])) { $dates[$oGame->date][$oGame->location_nefub_id] = array('location' => $oLocation, 'gameTimes' => array()); } // create array for times per location if (!is_array($dates[$oGame->date][$oGame->location_nefub_id]['gameTimes'][$oGame->time])) { $dates[$oGame->date][$oGame->location_nefub_id]['gameTimes'][$oGame->time] = array(); } $dates[$oGame->date][$oGame->location_nefub_id]['gameTimes'][$oGame->time][] = $oGame; } return $dates; }
/** * Enter description here ... * @return Location */ public function getLocation() { if (!$this->location) { $this->location = Location::getByNefubId($this->location_nefub_id); } return $this->location; }
protected function runLocationSchedule($nefubId, $date) { if (is_numeric($nefubId) && $date) { if ($oLocation = Location::getByNefubId($nefubId)) { $formattedDate = strftime("%A %e %B %Y", strtotime($date)); $filename = 'agenda ' . $date . ' ' . $oLocation->name; $oSeason = Season::getInstance(); $aGames = Game::getAll(array('date' => $date, 'location_nefub_id' => $oLocation->nefub_id), 'time` ASC, `field', 'asc'); if (count($aGames)) { $title = 'Programma ' . $formattedDate; $includeField = false; $footer = $title . ' in ' . $oLocation->name . ', ' . $oLocation->city . '. Gedownload van http://' . $_SERVER['HTTP_HOST'] . '/locatie/' . $nefubId; $this->renderGames($filename, $title, $aGames, $footer); } } } $this->redirect(); }
/** * * @param int $nefubId */ public function showLocation($nefubId) { $this->subdirectory = '/locatie'; $this->path = '/' . $nefubId; $this->template = '/locatie/locatie.tpl'; if ($this->getClearRender()) { $oLocation = Location::getByNefubId($nefubId); if ($oLocation && $oLocation->name != 'TBA') { $this->assign('oLocation', $oLocation); } else { $this->redirect(); } } $this->showOutput(); }
/** * * @param ing $locationNefubId * return Location */ protected function retrieveLocation($locationNefubId) { $oLocation = Location::getByNefubId($locationNefubId); if (!$oLocation) { $url = NEFUB_API . '/location.php?id=' . $locationNefubId; $locationData = $this->getNefubContentsParsed($url, MAX_AGE_LOCATION_DETAILS); $oLocation = new Location(); $oLocation->nefub_id = $locationNefubId; $oLocation->name = $locationData->Name; $oLocation->street = $locationData->Address; $oLocation->postalcode = $locationData->PostalCode; $oLocation->city = $locationData->Place; $oLocation->telephone = $locationData->Phone; $oLocation->website = $locationData->Url; $oLocation->email = $locationData->{'E-mail'}; $oLocation->route = $locationData->Route; $oLocation->save(); $this->addedNefubObject($oLocation); self::put('Locatie ' . $locationNefubId . ' toegevoegd: ' . $oLocation->name . ' in ' . $oLocation->city); } return $oLocation; }
protected function showLocations() { switch ($this->mode) { case 'bewerken': $oLocation = Location::getByNefubId($this->editId); $this->editObject($oLocation, '/bewerken.tpl'); break; default: $query = 'SELECT DISTINCT(`city`) FROM `Location` ORDER BY `city` ASC'; $cityRows = Database::select_rows_by_query($query); $cities = array(); foreach ($cityRows as $cityRow) { $name = $cityRow['city']; if (!is_array($cities[$name])) { $cities[$name] = array(); } $cities[$name] = Location::getAll(array('city' => $name), 'name'); } $this->assign('cities', $cities); $this->template = '/locaties.tpl'; $this->showOutput(); } }