Sfoglia il codice sorgente

Did something here, I think the backend part of the new headers system

Michael Francis 14 anni fa
parent
commit
940f12c660
1 ha cambiato i file con 23 aggiunte e 2 eliminazioni
  1. 23 2
      controllers/SearchController.php

+ 23 - 2
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']);
 		}
 	}
 }