diff options
Diffstat (limited to 'controllers')
-rw-r--r-- | controllers/AnimeController.php | 29 | ||||
-rw-r--r-- | controllers/SearchController.php | 18 |
2 files changed, 40 insertions, 7 deletions
diff --git a/controllers/AnimeController.php b/controllers/AnimeController.php index bd29116..3a40cee 100644 --- a/controllers/AnimeController.php +++ b/controllers/AnimeController.php @@ -5,7 +5,7 @@ namespace app\controllers; use app\models\Anime; class AnimeController extends \lithium\action\Controller { - public $publicActions = array('index', 'view'); + public $publicActions = array('index', 'view', 'cast'); public function index() { @@ -16,12 +16,31 @@ class AnimeController extends \lithium\action\Controller { public function view($id = null) { - if (is_numeric($id)) { - return Anime::search($id, null, 'special_id'); + if (is_numeric($id)) + { + $data = Anime::search($id, null, 'special_id'); + $related = $data['anime']->related; + $str = ''; + for ($i = 0; $i < count($related); $i++) + { + if ($i > 0) $str .= ', '; + $ra = Anime::search($related[$i], null, 'special_id'); + $str .= '<a href="' . $related[$i] . '">' . $ra['anime']->title . '</a>'; + } + $data['related'] = $str; + return $data; } - else { + else + { return $this->redirect(array('controller' => 'search','q' => array('search' => $id))); } - + } + + public function cast($id = null) + { + if (is_numeric($id)) + { + return Anime::search($id, null, 'special_id'); + } } } diff --git a/controllers/SearchController.php b/controllers/SearchController.php index abcaabd..efd25f3 100644 --- a/controllers/SearchController.php +++ b/controllers/SearchController.php @@ -25,8 +25,22 @@ class SearchController extends \lithium\action\Controller { public function anime($by = 'title') { - $q = isset($this->request->query['q']) ? '/' . $this->request->query['q'] . '/i' : ''; + $q = isset($this->request->query['q']) ? $this->request->query['q'] : ''; $page = isset($this->request->query['page']) ? $this->request->query['page'] : 1; - return Anime::search($q, $page, 'title'); + return Anime::search("/$q/i", $page, 'title'); + } + + public function manga($by = 'title') + { + $q = isset($this->request->query['q']) ? $this->request->query['q'] : ''; + $page = isset($this->request->query['page']) ? $this->request->query['page'] : 1; + return Manga::search("/$q/i", $page, 'title'); + } + + public function kdrama($by = 'title') + { + $q = isset($this->request->query['q']) ? $this->request->query['q'] : ''; + $page = isset($this->request->query['page']) ? $this->request->query['page'] : 1; + return Kdrama::search("/$q/i", $page, 'title'); } } |