/** * Build filter items * * @param ORM_Iterator $events * @return array */ public function _build_filters(ORM_Iterator $events) { $filters = array(); if ($events->count()) { $cities = array(); // Build filter list foreach ($events as $event) { // Build city $city = $event->city_id ? $event->city->city : $event->city_name; $filter = url::title($city); if (!isset($cities[$filter])) { $cities[$filter] = utf8::ucfirst(utf8::strtolower($city)); } } // Drop empty to last ksort($cities); if (isset($cities[''])) { $cities[url::title(__('Elsewhere'))] = utf8::ucfirst(utf8::strtolower(__('Elsewhere'))); unset($cities['']); } // Build city filter $filters['city'] = array('name' => __('City'), 'filters' => $cities); } return $filters; }