Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Added action cloud and cleaned out output of pagination links.

Signed-off-by: Joachim Nyqvist <Joachim@JNyqvist.se>
  • Loading branch information...
commit 36af782d7a9867c2bef00730c73a147ce400dfcf 1 parent ec47455
Joachim Wallsin authored
27 app/controllers/items_controller.php
@@ -25,6 +25,13 @@ function index($category = null, $name = null) {
25 25 'Item.actors LIKE' => '%'.$name.'%'
26 26 ));
27 27 break;
  28 +
  29 + case 'country':
  30 + $title = $name;
  31 + $data = $this->paginate('Item', array(
  32 + 'Item.country LIKE' => '%'.$name.'%'
  33 + ));
  34 + break;
28 35
29 36 case 'director':
30 37 $title = $name;
@@ -39,6 +46,13 @@ function index($category = null, $name = null) {
39 46 'Item.genre LIKE' => '%'.$name.'%'
40 47 ));
41 48 break;
  49 +
  50 + case 'date':
  51 + $title = $name;
  52 + $data = $this->paginate('Item', array(
  53 + 'Item.date LIKE' => '%'.$name.'%'
  54 + ));
  55 + break;
42 56
43 57 default:
44 58 $title = __('Index', true);
@@ -53,5 +67,18 @@ function index($category = null, $name = null) {
53 67 'title' => $title
54 68 ));
55 69 }
  70 +
  71 + function cloud($category = null, $name = null) {
  72 + $title = 'Cloud';
  73 + $this->set(array(
  74 + 'title_for_layout' => $title . ' : ' . Configure::read('Visual.title'),
  75 + 'actors' => $this->Item->find('all', array('fields' => 'Item.actors')),
  76 + 'countries' => $this->Item->find('all', array('fields' => 'Item.country')),
  77 + 'directors' => $this->Item->find('all', array('fields' => 'Item.director')),
  78 + 'genres' => $this->Item->find('all', array('fields' => 'Item.genre')),
  79 + 'title' => $title,
  80 + 'years' => $this->Item->find('all', array('fields' => 'Item.date'))
  81 + ));
  82 + }
56 83 }
57 84 ?>
7 app/views/elements/tagcloud.ctp
... ... @@ -1,8 +1,9 @@
1 1 <?php
  2 +$_key = '';
2 3 $_tags = array();
3 4 foreach ($data as $post) {
4 5 foreach ($post as $model) {
5   - foreach ($model as $key => $value){
  6 + foreach ($model as $_key => $value){
6 7 /**
7 8 * Tags are comma separated.
8 9 */
@@ -46,8 +47,8 @@ foreach ($_tags as $tag => $t_i) {
46 47 }
47 48
48 49 foreach ($tagcloud as $_tag => $s_i) {
49   - echo $this->Html->link($_tag,
50   - array('controller' => 'items', 'action' => 'index', 'genre', $_tag),
  50 + echo $this->Html->link(trim($_tag),
  51 + array('controller' => 'items', 'action' => 'index', $_key, trim($_tag)),
51 52 array(
52 53 'style' => 'font-size: '.$s_i.'%;')
53 54 )."\n";
22 app/views/themed/default/items/cloud.ctp
... ... @@ -0,0 +1,22 @@
  1 +<?php
  2 +echo $this->Html->div('tagcloud',
  3 + $this->Html->tag('h2', __('Genres', true), array('escape' => true)).
  4 + $this->element('tagcloud', array('data' => $genres, 'escape' => true))
  5 + )."\n";
  6 +echo $this->Html->div('tagcloud',
  7 + $this->Html->tag('h2', __('Directors', true), array('escape' => true)).
  8 + $this->element('tagcloud', array('data' => $directors, 'escape' => true))
  9 + )."\n";
  10 +echo $this->Html->div('tagcloud',
  11 + $this->Html->tag('h2', __('Actors', true), array('escape' => true)).
  12 + $this->element('tagcloud', array('data' => $actors, 'escape' => true))
  13 + )."\n";
  14 +echo $this->Html->div('tagcloud',
  15 + $this->Html->tag('h2', __('Countries', true), array('escape' => true)).
  16 + $this->element('tagcloud', array('data' => $countries, 'escape' => true))
  17 + )."\n";
  18 +echo $this->Html->div('tagcloud',
  19 + $this->Html->tag('h2', __('Years of publication', true), array('escape' => true)).
  20 + $this->element('tagcloud', array('data' => $years, 'escape' => true))
  21 + )."\n";
  22 +?>
18 app/views/themed/default/items/index.ctp
... ... @@ -1,5 +1,12 @@
1 1 <?php
2   -echo $this->element('tagcloud', array('data' => $tags));
  2 +echo $this->Html->div('tagcloud', $this->element('tagcloud', array('data' => $tags, 'escape' => true)))."\n";
  3 +
  4 +echo $this->Html->div('paginationlinks', $paginator->numbers()."<br />\n".
  5 + $paginator->prev('<< '.__('Previous', true).' ')."\n".
  6 + $paginator->next(' '.__('Next', true).' >>')."<br />\n".
  7 + $paginator->counter(array('format' => '<span>'.__('Page %page% of %pages%', true).'</span>'))."\n"
  8 + )."\n";
  9 +
3 10 foreach ($data as $post) {
4 11 echo "<div class=\"item clearfix\">\n";
5 12
@@ -61,8 +68,9 @@ foreach ($data as $post) {
61 68 echo "</div>\n";
62 69 }
63 70
64   -echo $paginator->numbers()."<br />\n";
65   -echo $paginator->prev('<< '.__('Previous', true).' ');
66   -echo $paginator->next(' '.__('Next', true).' >>')."<br />";
67   -echo $paginator->counter(array('format' => __('Page %page% of %pages%', true)));
  71 +echo $this->Html->div('paginationlinks', $paginator->numbers()."<br />\n".
  72 + $paginator->prev('<< '.__('Previous', true).' ')."\n".
  73 + $paginator->next(' '.__('Next', true).' >>')."<br />\n".
  74 + $paginator->counter(array('format' => '<span>'.__('Page %page% of %pages%', true).'</span>'))."\n"
  75 + )."\n";
68 76 ?>

0 comments on commit 36af782

Please sign in to comment.
Something went wrong with that request. Please try again.