diff options
author | Michael Francis <edude03@gmail.com> | 2011-07-01 01:05:00 -0400 |
---|---|---|
committer | Michael Francis <edude03@gmail.com> | 2011-07-01 01:05:00 -0400 |
commit | 940f12c660c415c831c19012230c409968d71a03 (patch) | |
tree | 6102908614c52bba0bb44ba65e1c20ef7332ca90 /controllers/SearchController.php | |
parent | ecf24b77b0caafdedb1d985e695a169b5adddb19 (diff) | |
download | otakuhub-940f12c660c415c831c19012230c409968d71a03.tar.xz |
Did something here, I think the backend part of the new headers system
Diffstat (limited to 'controllers/SearchController.php')
-rw-r--r-- | controllers/SearchController.php | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/controllers/SearchController.php b/controllers/SearchController.php index d8c8298..f09f446 100644 --- a/controllers/SearchController.php +++ b/controllers/SearchController.php @@ -18,19 +18,40 @@ class SearchController extends \lithium\action\Controller { 'manga' => 'app\models\Manga', 'kdrama' => 'app\models\Kdrama'); + public function index($type, $by = 'title') { + //Regex-ize the search param + $searchParam = (isset($this->request->query['search'])) ? + '/' . $this->request->query['search'] . '/i' : ""; + + - $searchParam = '/' . $this->request->query['search'] . '/i'; + //Get the page number $page = isset($this->request->query['page']) ? $this->request->query['page'] : 1; + $headers = array(); + switch ($type) + { + case 'Anime': + case 'anime': $headers = array('title' => 'Title', + 'episode_count' => 'Episodes', + 'view_type' => 'Type', 'mal_score' => 'MAL Score'); + + case 'kdrama': + case 'Kdrama': $headers = array('title' => 'Title', + 'episode_count' => 'Episodes'); + + } + //If the type part of the URL is a valid type (as defined above), if (isset($this->_types[$type])) { $model = $this->_types[$type]; //Forcing search to title for now, until the search frontend is done - return $model::search($searchParam, $page, 'title'); + $search = $model::search($searchParam, $page, 'title'); + return array('content' => $search['content'], 'page' => $search['page'], 'headers' => $headers, 'total' => $search['total'], 'limit' => $search['limit']); } } }
\ No newline at end of file |