Ver código fonte

/anime works

raylu 14 anos atrás
pai
commit
2e6016922c

+ 8 - 2
controllers/AnimeController.php

@@ -5,7 +5,13 @@ namespace app\controllers;
 use app\models\Anime;
 
 class AnimeController extends \lithium\action\Controller {
-	public $publicActions = array('view');
+	public $publicActions = array('index', 'view');
+
+	public function index()
+	{
+		$page = $this->request->query['page'];
+		return Anime::search(null, $page, null);
+	}
 
 	public function view($id = null)
 	{
@@ -17,4 +23,4 @@ class AnimeController extends \lithium\action\Controller {
 		}
 	
 	}
-}	
+}

+ 19 - 11
models/Anime.php

@@ -11,8 +11,7 @@ class Anime extends \lithium\data\Model {
 		$limit = 20;
 
 		switch($by) {
-			case 'special_id':
-			
+		case 'special_id':
 			$content = self::find('first',
 				array('conditions' => array(
 						$by => $query
@@ -22,20 +21,29 @@ class Anime extends \lithium\data\Model {
 				));
 
 
-		
 			$total = self::count(array($by => $query)); 
 			break;
 			
-			default:
-			$content = self::find('all',
-				array('conditions' => array(
-						$by => array('like' => $query)
-					),
+		default:
+			if ($query)
+			{
+				$conditions = null; // TODO
+				$content = self::find('all', array(
+					'conditions' => array($by => array('like' => $query)),
 					'limit' => $limit,
 					'page' => $page
 				));
 				$total = Anime::count(array($by => array('like' => $query)));
+			}
+			else
+			{
+				$content = self::find('all', array(
+					'limit' => $limit,
+					'page' => $page
+				));
+				$total = Anime::count();
+			}
+		}
+		return compact('content', 'by', 'limit', 'total', 'page');
 	}
-	return compact('content', 'by', 'limit', 'total', 'page');
-	}
-}
+}

+ 40 - 0
views/anime/index.html.php

@@ -0,0 +1,40 @@
+<?php
+$this->styles($this->html->style('anime'));
+?>
+
+<h2 class="ribbon full">Anime</h2>
+<div class="triangle-ribbon"></div>
+
+<?= $this->Paginator->paginate(array('separator' => '')) ?>
+
+<table>
+<th>Title</th>
+<th>Date</th>
+<th>Type</th>
+<?php foreach ($content as $anime): ?>
+	<tr>
+		<td>
+			<a href="/anime/view/<?= $anime->special_id ?>"><?= $anime->title ?></a>
+			<?php if ($anime->foreign_titles || $anime->alternative_titles): ?>
+				<span class="alt_titles">
+				<?php if ($anime->foreign_titles): ?>
+					<?= $anime->foreign_titles[0] ?>
+				<?php endif ?>
+				<?php if ($anime->alternative_titles): ?>
+					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+					<?= $anime->alternative_titles[0] ?>
+				<?php endif ?>
+				</span>
+			<?php endif ?>
+		</td>
+		<td>
+			<?= $anime->aired ?>
+		</td>
+		<td>
+			<?= $anime->view_type ?>
+		</td>
+	</tr>
+<?php endforeach ?>
+</table>
+
+<?= $this->Paginator->paginate(array('separator' => '')) ?>

+ 39 - 0
webroot/css/anime.css

@@ -0,0 +1,39 @@
+span.alt_titles {
+	font-size: 90%;
+	opacity: 0.7;
+}
+
+table {
+	border-collapse: collapse;
+	width: 898px;
+	max-width: 898px;
+	table-layout: fixed;
+}
+tr {
+	height: 45px;
+}
+tr:first-child { /* th row */
+	height: 25px;
+}
+th {
+	vertical-align: middle;
+}
+th:nth-child(2) {
+	width: 240px;
+}
+th:nth-child(3) {
+	width: 50px;
+}
+td {
+	border: 0px solid #bbb;
+	border-top-width: 1px;
+	vertical-align: middle;
+	white-space: nowrap;
+	overflow: hidden;
+}
+td:nth-child(2) {
+	padding-left: 25px;
+}
+td a {
+	display: block;
+}

+ 3 - 0
webroot/css/base.css

@@ -2,6 +2,9 @@ body {
 	font-family: Cantarell;
 	letter-spacing: -0.01em;
 }
+a:link, a:visited {
+	text-decoration: none;
+}
 h1 {
 	font-weight: bold;
 	font-size: 220%;

+ 8 - 0
webroot/css/themes/light.css

@@ -5,6 +5,14 @@ body {
 	background: -webkit-linear-gradient(top, #fff, #ddd 500px, #ddd);
 	filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff', endColorstr='#dddddd');
 }
+
+a, a:visited {
+	color: #33a;
+}
+a:hover {
+	color: #55f;
+}
+
 nav a, nav a:visited {
 	color: #222;	
 	text-shadow:0 1px 0 #fff;