<?php

	class ContenidoController extends ApplicationController {
				
		public $posts = array();
		
		function index(){
			
			$this->posts = $this->Posts->find('order: created_at');
			
			for($i=0;$i<=count($this->posts)-1;$i++){
				$this->posts[$i]->mes = strtoupper(strftime('%b', mktime(0, 0, 0, substr($this->posts[$i]->created_at, 5, 2), 1, date("Y"))));
				$this->posts[$i]->dia = substr($this->posts[$i]->created_at, 8, 2);
				
			}
			
			if(!count(Session::get_data('all_tags'))){
				$tags = array();								
				$all_tags = array();
				foreach($this->Posts->find() as $post){
					$tags = array_merge($tags, explode(" ", trim(ereg_replace("[ ]+", " ", $post->tags))));	
				}						
				
				$tags = array_count_values($tags);
								
				for($i=0;$i<=count($tags)-1;$i++){
					$key = key($tags);
					$tags[$key] = $tags[$key]*4 + 16; 
					next($tags);
				}
				Session::set_data('all_tags', $tags);
			}
						
									
		}
		
	}

?>