diff options
author | Michael Francis <edude03@gmail.com> | 2011-05-28 13:28:16 -0400 |
---|---|---|
committer | Michael Francis <edude03@gmail.com> | 2011-05-28 13:28:16 -0400 |
commit | 2389d66da849798f8d4ec5f10e3b07c11da49185 (patch) | |
tree | e22556d12982395b469a23420c662662e3e064cc /controllers/SearchController.php | |
download | otakuhub-2389d66da849798f8d4ec5f10e3b07c11da49185.tar.xz |
Initial Commit
Diffstat (limited to 'controllers/SearchController.php')
-rw-r--r-- | controllers/SearchController.php | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/controllers/SearchController.php b/controllers/SearchController.php new file mode 100644 index 0000000..fea8e41 --- /dev/null +++ b/controllers/SearchController.php @@ -0,0 +1,37 @@ +<?php + +namespace app\controllers; + +use app\models\Anime; +use \MongoRegex; + +class SearchController extends \lithium\action\Controller { + public function index($type, $by = "series_title") + { + + if (empty($this->request->query['search'])) { + //Redirect them or something + } + + + $searchParam = '/' . $this->request->query['search'] . '/i'; + + $content; + $limit = 20; + $page = $this->request->page ?: 1; + $total; //<-- number of search results + + + switch($type) + { + case "anime": $content = Anime::find('all', array('conditions' => array('title' => array('like' => $searchParam)), $limit, $page)); + $total = Anime::count(array('title' => array('like' => $searchParam))); + break; + case "kdrama": break; + case "manga": break; + } + return compact('content', 'type', 'by', 'limit', 'total', 'page'); + } + + +}
\ No newline at end of file |