/** * @param $type * @param $id * * @throws Exception */ public function handle($type, $id) { if (!empty($type)) { $this->browse_type = $type; switch ($type) { case 'recent': $this->is_result = true; $repo = new PublicationRepository($this->db); $this->result = $repo->where('foreign', '=', 0)->order('date_added', 'DESC')->limit(20)->find(); break; case 'author': $repo = new AuthorRepository($this->db); $this->browse_list = $repo->order('family', 'ASC')->find(); break; case 'keyword': $repo = new KeywordRepository($this->db); $this->browse_list = $repo->order('name', 'ASC')->find(); break; case 'study_field': $repo = new StudyFieldRepository($this->db); $this->browse_list = $repo->order('name', 'ASC')->find(); break; case 'type': $repo = new TypeRepository($this->db); $this->browse_list = $repo->order('name', 'ASC')->find(); break; case 'year': if ($id > 0) { $this->is_result = true; $repo = new PublicationRepository($this->db); $this->result = $repo->where('date_published', '=', $id, 'YEAR')->order('date_published', 'DESC')->find(); } else { $this->browse_list = $this->fetchYears(); } break; default: throw new Exception('unknown browse type "' . $type . '"'); break; } } }
/** * @param int $offset * * @return array */ private function fetchSets($offset = 0) { $repo = new KeywordRepository($this->db); $keywords = $repo->order('name', 'ASC')->limit($this->sets_per_request, $offset)->find(); $sets = array(); foreach ($keywords as $keyword) { $setSpec = str_replace(' ', '_', $keyword->getName()); $setSpec = strtolower($setSpec); $sets[] = array('setSpec' => $setSpec, 'setName' => $keyword->getName()); } return $sets; }