Преглед изворни кода

make search index work

clean up a lot of code
renamed anime.css to table.css
raylu пре 14 година
родитељ
комит
30bd3dc2c8

+ 0 - 1
controllers/SearchController.php

@@ -21,7 +21,6 @@ class SearchController extends \lithium\action\Controller {
 			$kdrama = Kdrama::find('all', compact('conditions', 'limit'));
 			
 			return compact('anime', 'manga', 'kdrama');	
-
 		}
 	}
 

+ 4 - 4
models/Anime.php

@@ -12,7 +12,7 @@ class Anime extends \lithium\data\Model {
 
 		switch($by) {
 		case 'special_id':
-			$content = self::find('first',
+			$anime = self::find('first',
 				array('conditions' => array(
 						$by => $query
 					),
@@ -28,7 +28,7 @@ class Anime extends \lithium\data\Model {
 			if ($query)
 			{
 				$conditions = null; // TODO
-				$content = self::find('all', array(
+				$anime = self::find('all', array(
 					'conditions' => array($by => array('like' => $query)),
 					'limit' => $limit,
 					'page' => $page
@@ -37,13 +37,13 @@ class Anime extends \lithium\data\Model {
 			}
 			else
 			{
-				$content = self::find('all', array(
+				$anime = self::find('all', array(
 					'limit' => $limit,
 					'page' => $page
 				));
 				$total = Anime::count();
 			}
 		}
-		return compact('content', 'by', 'limit', 'total', 'page');
+		return compact('anime', 'by', 'limit', 'total', 'page');
 	}
 }

+ 9 - 9
views/elements/animetable.html.php

@@ -2,27 +2,27 @@
 <th>Title</th>
 <th>Date</th>
 <th>Type</th>
-<?php foreach ($content as $anime): ?>
+<?php foreach ($anime as $a): ?>
 	<tr>
 		<td>
-			<a href="/anime/view/<?= $anime->special_id ?>"><?= $anime->title ?></a>
-			<?php if ($anime->foreign_titles || $anime->alternative_titles): ?>
+			<a href="/anime/view/<?= $a->special_id ?>"><?= $a->title ?></a>
+			<?php if ($a->foreign_titles || $a->alternative_titles): ?>
 				<span class="alt_titles">
-				<?php if ($anime->foreign_titles): ?>
-					<?= $anime->foreign_titles[0] ?>
+				<?php if ($a->foreign_titles): ?>
+					<?= $a->foreign_titles[0] ?>
 				<?php endif ?>
-				<?php if ($anime->alternative_titles): ?>
+				<?php if ($a->alternative_titles): ?>
 					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
-					<?= $anime->alternative_titles[0] ?>
+					<?= $a->alternative_titles[0] ?>
 				<?php endif ?>
 				</span>
 			<?php endif ?>
 		</td>
 		<td>
-			<?= $anime->aired ?>
+			<?= $a->aired ?>
 		</td>
 		<td>
-			<?= $anime->view_type ?>
+			<?= $a->view_type ?>
 		</td>
 	</tr>
 <?php endforeach ?>

+ 2 - 2
views/search/anime.html.php

@@ -1,6 +1,6 @@
 <?php
-$this->styles($this->html->style('anime'));
 $this->styles($this->html->style('pagination'));
+$this->styles($this->html->style('table'));
 ?>
 
 <?= $this->_render('element', 'search') ?>
@@ -10,6 +10,6 @@ $this->styles($this->html->style('pagination'));
 
 <?= $this->Paginator->paginate(array('separator' => '')) ?>
 
-<?= $this->_render('element', 'animetable', compact('anime')) ?>
+<?= $this->_render('element', 'animetable') ?>
 
 <?= $this->Paginator->paginate(array('separator' => '')) ?>

+ 7 - 57
views/search/index.html.php

@@ -1,65 +1,15 @@
 <?php
-$this->styles($this->html->style('pagination'));
+$this->styles($this->html->style('table'));
 ?>
 
 <h3>Anime</h3>
 <?= $this->_render('element', 'animetable', compact('anime')) ?>
 <?= $this->html->link("More", array('controller' => 'search',
-										'action' => 'anime')); ?>
+									'action' => 'anime')); ?>
 <h3>Manga</h3>
-<hr>
-<table>
-<th>Title</th>
-<th>Date</th>
-<th>Type</th>
-<?php if(count($manga) > 0): ?>
-<?php foreach ($manga as $item): ?>
-	<tr>
-		<td>
-			<a href="/anime/view/<?= $item->special_id ?>"><?= $item->title ?></a>
-		</td>
-		<td>
-			<?= $item->aired ?>
-		</td>
-		<td>
-			<?= $item->view_type ?>
-		</td>
-	</tr>
-<?php endforeach ?>
-</table>
-<div style = "float:right">
-	<?= $this->html->link("More", array('controller' => 'search',
-										'action' => 'anime')); ?>
-</div>
-<?php else: ?>
-<p> No entries found </p>
-<?php endif; ?>
+<?= $this->html->link("More", array('controller' => 'search',
+									'action' => 'anime')); ?>
 
-<h3> K Drama </h3>
-<hr>
-<table>
-<th>Title</th>
-<th>Date</th>
-<th>Type</th>
-<?php if(count($kdrama) > 0): ?>
-<?php foreach ($kdrama as $item): ?>
-	<tr>
-		<td>
-			<a href="/anime/view/<?= $item->special_id ?>"><?= $item->title ?></a>
-		</td>
-		<td>
-			<?= $item->aired ?>
-		</td>
-		<td>
-			<?= $item->view_type ?>
-		</td>
-	</tr>
-<?php endforeach ?>
-</table>
-<div style = "float:right">
-	<?= $this->html->link("More", array('controller' => 'search',
-										'action' => 'anime')); ?>
-</div>
-<?php else: ?>
-<p>No Entries found</p>
-<?php endif; ?>
+<h3>K Drama</h3>
+<?= $this->html->link("More", array('controller' => 'search',
+									'action' => 'anime')); ?>

+ 2 - 0
webroot/css/anime.css → webroot/css/table.css

@@ -1,3 +1,5 @@
+/* for search results and anime/manga/kdrama lists */
+
 span.alt_titles {
 	font-size: 90%;
 	opacity: 0.7;