summaryrefslogtreecommitdiffstats
path: root/controllers/SearchController.php
blob: 421efb6e8c8699e38221966ff8280adf99b6fef0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<?php
namespace app\controllers;

use app\models\Anime;
use app\models\Manga;
use app\models\Kdrama;

class SearchController extends \lithium\action\Controller {
	public $publicActions = array('index', 'anime');

	public function index() {
		if (isset($this->request->query['q']))
		{
			$q = '/' . $this->request->query['q'] . '/i';
			return Anime::search($q, $page, 'title');
		}
		return $this->render(array('template' => 'index'));
	}

	public function anime($by = 'title')
	{
		$q = isset($this->request->query['q']) ?  '/' . $this->request->query['q'] . '/i' : '';
		$page = isset($this->request->query['page']) ? $this->request->query['page'] : 1;
		return Anime::search($q, $page, 'title');
	}
}