From 657d270864c6f8f77d083fe4aa6ba636ecbbd372 Mon Sep 17 00:00:00 2001 From: raylu Date: Tue, 12 Jul 2011 00:50:00 -0700 Subject: rework a lot of search /search will eventually search all /search/anime searches only anime --- config/bootstrap/connections.php | 4 +-- controllers/SearchController.php | 59 +++++++++-------------------------- views/anime/index.html.php | 34 +------------------- views/search/anime.html.php | 32 ++++--------------- views/search/index.html.php | 67 +++++++++++++--------------------------- 5 files changed, 45 insertions(+), 151 deletions(-) diff --git a/config/bootstrap/connections.php b/config/bootstrap/connections.php index 645e587..48eb1e8 100644 --- a/config/bootstrap/connections.php +++ b/config/bootstrap/connections.php @@ -43,7 +43,7 @@ use lithium\data\Connections; Connections::add('default', array( 'type' => 'database', 'adapter' => 'MySql', - 'host' => '127.0.0.1', + 'host' => 'otaku.raylu.net', 'login' => 'otakuhub', 'password' => 'otakuhub', 'database' => 'otakuhub' @@ -71,4 +71,4 @@ Connections::add('default', array( -?> \ No newline at end of file +?> diff --git a/controllers/SearchController.php b/controllers/SearchController.php index 8deaf07..421efb6 100644 --- a/controllers/SearchController.php +++ b/controllers/SearchController.php @@ -1,57 +1,26 @@ - 'app\models\Anime', - 'Manga' => 'app\models\Manga', - 'Kdrama' => 'app\models\Kdrama', - - 'anime' => 'app\models\Anime', - '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' : ""; - - - - //Get the page number - $page = isset($this->request->query['page']) ? $this->request->query['page'] : 1; + public $publicActions = array('index', 'anime'); - $headers = array(); - switch ($type) + public function index() { + if (isset($this->request->query['q'])) { - 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'); - + $q = '/' . $this->request->query['q'] . '/i'; + return Anime::search($q, $page, 'title'); } + return $this->render(array('template' => 'index')); + } - //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 - $search = $model::search($searchParam, $page, 'title'); - return array('content' => $search['content'], 'page' => $search['page'], 'headers' => $headers, 'total' => $search['total'], 'limit' => $search['limit']); - } + 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'); } } diff --git a/views/anime/index.html.php b/views/anime/index.html.php index 2b95fcf..270ed76 100644 --- a/views/anime/index.html.php +++ b/views/anime/index.html.php @@ -6,36 +6,4 @@ $this->styles($this->html->style('pagination'));

Anime

-Paginator->paginate(array('separator' => '')) ?> - - - - - - - - - - - - -
TitleDateType
- title ?> - foreign_titles || $anime->alternative_titles): ?> - - foreign_titles): ?> - foreign_titles[0] ?> - - alternative_titles): ?> -       - alternative_titles[0] ?> - - - - - aired ?> - - view_type ?> -
- -Paginator->paginate(array('separator' => '')) ?> +_render('element', 'animetable', compact('anime')) ?> diff --git a/views/search/anime.html.php b/views/search/anime.html.php index 485e389..4d0332f 100644 --- a/views/search/anime.html.php +++ b/views/search/anime.html.php @@ -1,30 +1,10 @@ styles($this->html->style('anime')); $this->styles($this->html->style('pagination')); ?> -
-
-

Search options

-
-form->create(null, array('method' => 'get')); ?> - form->field('search', array('type' => 'textbox', 'class' => 'sidebar-search', 'style' => 'width:200px')); ?> - form->label('type', 'For:'); ?> - form->select('type', array('Anime' => 'Anime', - 'Manga' => 'Manga', - 'Kdrama' => 'Kdrama')); ?> - form->submit('Search', array('style' => 'width: 100px')); ?> -form->end(); ?> -
-
-

Search Results

-
- - - - - -
imgNameEpisodesTypeScore
"image"title ?> episode_count ?>view_type ?>mal_score ?>
-Paginator->paginate(array('separator' => '', 'action' => 'index/anime')); ?> -
-
-
+_render('element', 'search') ?> + +

Anime Search Results

+(search instead for ...) +_render('element', 'animetable', compact('anime')) ?> diff --git a/views/search/index.html.php b/views/search/index.html.php index ffdd82c..2afb320 100644 --- a/views/search/index.html.php +++ b/views/search/index.html.php @@ -1,51 +1,28 @@ styles($this->html->style('pagination')); +?> -//table helper -function table($data, array $headers = array(), array $options = array()) { - //Create the table - echo ''; - foreach ($headers as $k => $v) - { - echo "$v"; - } - echo "\n"; +_render('element', 'search', compact('anime')) ?> +Paginator->paginate(array('separator' => '')) ?> - foreach ($data as $item) - { - echo ''; - foreach($headers as $key => $value) - { - echo ''; - echo $item->$key; - echo ''; - } - echo "\n"; - } -} -?> + + + + + + + + + + + +
TitleDateType
+ title ?> + + aired ?> + + view_type ?> +
-
-
-

Search options

-
-form->create(null, array('method' => 'get')); ?> - form->field('search', array('type' => 'textbox', 'class' => 'sidebar-search', 'style' => 'width:200px')); ?> - form->label('type', 'For:'); ?> - form->select('type', array('Anime' => 'Anime', - 'Manga' => 'Manga', - 'Kdrama' => 'Kdrama')); ?> - form->submit('Search', array('style' => 'width: 100px')); ?> -form->end(); ?> -
-
-

Search Results

-
- - -
-Paginator->paginate(array('separator' => '', 'action' => 'index/anime')); ?> -
-
-
+Paginator->paginate(array('separator' => '')) ?> -- cgit v1.2.3