protected function xmlObjToLocations($obj) { $locations = array(); $locationsArr = $this->xmlObjToArr($obj); if ($locationsArr['location']) { foreach ($locationsArr['location'] as $key => $location) { if (!isset($location['id'])) { $location['id'] = 'id' . $key; } $location = new LocationDataObject($location); if ($location->hasAttribute('hours')) { $hours = new DailyHoursDataObject($location->getAttribute('hours')); $location->setAttribute('hours', $hours); } if ($location->hasAttribute('amenities')) { $amenities = $location->getAttribute('amenities'); $formattedAmenities = array(); foreach ($amenities['amenity'] as $amenityData) { $amenity = new AmenityDataObject(); $amenity->setTitle($amenityData['name']); if (isset($amenityData['image'])) { $amenity->setIcon($amenityData['image']); } $formattedAmenities[$amenityData['name']] = $amenity; } $location->setAttribute('amenities', $formattedAmenities); } if ($location->hasAttribute('events')) { $eventsConfig = $location->getAttribute('events'); $eventsConfig = array_change_key_case($eventsConfig, CASE_UPPER); // If it is a kurogo relative path you need to replace the path constants if (isset($eventsConfig['KUROGO_PATH']) && isset($eventsConfig['BASE_URL'])) { $explodedBaseURL = explode('"', $eventsConfig['BASE_URL']); $baseURL = ''; foreach ($explodedBaseURL as $part) { if (defined($part)) { $baseURL .= constant($part); } else { $baseURL .= $part; } } $eventsConfig['BASE_URL'] = $baseURL; } $eventModelClass = isset($eventsConfig['DATA_MODEL']) ? $eventsConfig['DATA_MODEL'] : $this->DEFAULT_EVENT_MODEL_CLASS; $eventModel = EventsDataModel::factory($eventModelClass, $eventsConfig); $location->setAttribute('events', $eventModel); } $locations[$location->getID()] = $location; } } return $locations; }
protected function initializeIndex() { $breadcrumbs = $this->page != 'pane'; // get location data models $locationDataModels = array(); $groupedLocations = array(); foreach ($this->feeds as $feedID => $feed) { $locationDataModels[$feedID] = $this->loadFeed($feedID); $groupedLocations[$feedID]['title'] = isset($feed['title']) ? $feed['title'] : null; } foreach ($locationDataModels as $feedID => $model) { if ($this->getOptionalModuleVar('SHOW_OPEN_AT_TOP', 0)) { $model->setSortByOpen(); } $locations = $model->getLocations(); $locationLinks = array(); foreach ($locations as $location) { if ($location->hasAttribute('events')) { $subtitle = ''; $currentEvents = $location->getCurrentEvents(time()); $nextEvent = $location->getNextEvent(true); if (count($currentEvents) > 0) { $events = array(); $lastTime = null; foreach ($currentEvents as $event) { if ($event->getEnd() > $lastTime) { $lastTime = $event->getEnd(); } $eventSummary = $event->getTitle(); if (strlen($eventSummary)) { $events[] = $eventSummary . ': ' . EventsDataModel::timeText($event, true); } else { $events[] = EventsDataModel::timeText($event, true); } } $subtitle .= implode("<br />", $events); } else { if ($nextEvent) { $eventSummary = $nextEvent->getTitle(); if (strlen($eventSummary)) { $subtitle .= $this->getLocalizedString('NEXT_EVENT') . $eventSummary . ': ' . EventsDataModel::timeText($nextEvent); } else { $subtitle .= $this->getLocalizedString('NEXT_EVENT') . EventsDataModel::timeText($nextEvent); } } } } else { // Dining module requires events attribute so skip this location // if it does not contain any events. Events don't necessarily need // to be currently occurring, but each location needs an events data model. continue; } $summary = $location->getAttribute('summary'); if (strlen($summary)) { $subtitle = $summary . '<br />' . $subtitle; } $locationLinks[] = array('title' => $location->getTitle(), 'subtitle' => $subtitle, 'url' => $this->buildBreadcrumbURL('detail', array('groupID' => $feedID, 'id' => $location->getID()), $breadcrumbs), 'listclass' => $this->SHOW_HOURS_STATUS ? $location->getListClass() : null); } $groupedLocations[$feedID]['items'] = $locationLinks; } $this->assign('groupedLocations', $groupedLocations); }