Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Added action cloud and cleaned out output of pagination links.
Signed-off-by: Joachim Nyqvist <Joachim@JNyqvist.se>
  • Loading branch information
CalvinMcGee committed Nov 22, 2010
1 parent ec47455 commit 36af782
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 8 deletions.
27 changes: 27 additions & 0 deletions app/controllers/items_controller.php
Expand Up @@ -25,6 +25,13 @@ function index($category = null, $name = null) {
'Item.actors LIKE' => '%'.$name.'%'
));
break;

case 'country':
$title = $name;
$data = $this->paginate('Item', array(
'Item.country LIKE' => '%'.$name.'%'
));
break;

case 'director':
$title = $name;
Expand All @@ -39,6 +46,13 @@ function index($category = null, $name = null) {
'Item.genre LIKE' => '%'.$name.'%'
));
break;

case 'date':
$title = $name;
$data = $this->paginate('Item', array(
'Item.date LIKE' => '%'.$name.'%'
));
break;

default:
$title = __('Index', true);
Expand All @@ -53,5 +67,18 @@ function index($category = null, $name = null) {
'title' => $title
));
}

function cloud($category = null, $name = null) {
$title = 'Cloud';
$this->set(array(
'title_for_layout' => $title . ' : ' . Configure::read('Visual.title'),
'actors' => $this->Item->find('all', array('fields' => 'Item.actors')),
'countries' => $this->Item->find('all', array('fields' => 'Item.country')),
'directors' => $this->Item->find('all', array('fields' => 'Item.director')),
'genres' => $this->Item->find('all', array('fields' => 'Item.genre')),
'title' => $title,
'years' => $this->Item->find('all', array('fields' => 'Item.date'))
));
}
}
?>
7 changes: 4 additions & 3 deletions app/views/elements/tagcloud.ctp
@@ -1,8 +1,9 @@
<?php
$_key = '';
$_tags = array();
foreach ($data as $post) {
foreach ($post as $model) {
foreach ($model as $key => $value){
foreach ($model as $_key => $value){
/**
* Tags are comma separated.
*/
Expand Down Expand Up @@ -46,8 +47,8 @@ foreach ($_tags as $tag => $t_i) {
}

foreach ($tagcloud as $_tag => $s_i) {
echo $this->Html->link($_tag,
array('controller' => 'items', 'action' => 'index', 'genre', $_tag),
echo $this->Html->link(trim($_tag),
array('controller' => 'items', 'action' => 'index', $_key, trim($_tag)),
array(
'style' => 'font-size: '.$s_i.'%;')
)."\n";
Expand Down
22 changes: 22 additions & 0 deletions app/views/themed/default/items/cloud.ctp
@@ -0,0 +1,22 @@
<?php
echo $this->Html->div('tagcloud',
$this->Html->tag('h2', __('Genres', true), array('escape' => true)).
$this->element('tagcloud', array('data' => $genres, 'escape' => true))
)."\n";
echo $this->Html->div('tagcloud',
$this->Html->tag('h2', __('Directors', true), array('escape' => true)).
$this->element('tagcloud', array('data' => $directors, 'escape' => true))
)."\n";
echo $this->Html->div('tagcloud',
$this->Html->tag('h2', __('Actors', true), array('escape' => true)).
$this->element('tagcloud', array('data' => $actors, 'escape' => true))
)."\n";
echo $this->Html->div('tagcloud',
$this->Html->tag('h2', __('Countries', true), array('escape' => true)).
$this->element('tagcloud', array('data' => $countries, 'escape' => true))
)."\n";
echo $this->Html->div('tagcloud',
$this->Html->tag('h2', __('Years of publication', true), array('escape' => true)).
$this->element('tagcloud', array('data' => $years, 'escape' => true))
)."\n";
?>
18 changes: 13 additions & 5 deletions app/views/themed/default/items/index.ctp
@@ -1,5 +1,12 @@
<?php
echo $this->element('tagcloud', array('data' => $tags));
echo $this->Html->div('tagcloud', $this->element('tagcloud', array('data' => $tags, 'escape' => true)))."\n";

echo $this->Html->div('paginationlinks', $paginator->numbers()."<br />\n".
$paginator->prev('<< '.__('Previous', true).' ')."\n".
$paginator->next(' '.__('Next', true).' >>')."<br />\n".
$paginator->counter(array('format' => '<span>'.__('Page %page% of %pages%', true).'</span>'))."\n"
)."\n";

foreach ($data as $post) {
echo "<div class=\"item clearfix\">\n";

Expand Down Expand Up @@ -61,8 +68,9 @@ foreach ($data as $post) {
echo "</div>\n";
}

echo $paginator->numbers()."<br />\n";
echo $paginator->prev('<< '.__('Previous', true).' ');
echo $paginator->next(' '.__('Next', true).' >>')."<br />";
echo $paginator->counter(array('format' => __('Page %page% of %pages%', true)));
echo $this->Html->div('paginationlinks', $paginator->numbers()."<br />\n".
$paginator->prev('<< '.__('Previous', true).' ')."\n".
$paginator->next(' '.__('Next', true).' >>')."<br />\n".
$paginator->counter(array('format' => '<span>'.__('Page %page% of %pages%', true).'</span>'))."\n"
)."\n";
?>

0 comments on commit 36af782

Please sign in to comment.