ContentController.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. namespace app\controllers;
  3. use app\models\Anime;
  4. class ContentController extends \lithium\action\Controller {
  5. public $publicActions = array('anime');
  6. public function index($type) //type has to equal something
  7. {
  8. switch($type) {
  9. case "anime": $content = Anime::all(compact('limit','page','order'));
  10. $total = Anime::count();
  11. break;
  12. case "manga":
  13. case "kdrama": $content = Kdrama::all(compact('limit', 'page', 'order'));
  14. $total = Kdrama::count();
  15. break;
  16. }
  17. return compact('content', 'total', 'page', 'limit');
  18. }
  19. public function manga($id = null)
  20. {
  21. if ($id != null)
  22. {
  23. }
  24. else
  25. {
  26. $content = Manga::all(compact('limit', 'page', 'order'));
  27. $total = Manga::count();
  28. }
  29. }
  30. public function anime($id = null)
  31. {
  32. $limit = 20;
  33. $page = $this->request->page ?: 1;
  34. $order = array('title' => 'ASC');
  35. $content;
  36. $total;
  37. if ($id != null)
  38. {
  39. $content = Anime::find('first', array('conditions' => array('special_id' => $id), 'order' => array('title' => 'ASC')));
  40. return compact('content');
  41. }
  42. else
  43. {
  44. $content = Anime::all(compact('limit','page','order'));
  45. $total = Anime::count();
  46. $this->render(array('template' => 'index', 'data' => compact('limit', 'page', 'content', 'total')));
  47. }
  48. }
  49. }