<?php
/*
 *
 * sflog!
 * Copyright (C) 2005 Alberto Sfolcini <a.sfolcini@gmail.com>
 *
 * This file is a part of sflog!.
 *
 * sflog! is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * sflog! is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 *
 */


/**
 * @title			: Archive
 * @description		: Manages Archive   
 * @date			: 20-Nov-2006   
 * @author			: Alberto Sfolcini  <a.sfolcini@gmail.com>
 */
class Archive {
	
	var $blogID;
	var $sectionID;	
	var $year;
	var $month;
	
	/**
	 * Constructor
	 */
	function Archive($blogID,$sectionID,$year,$month){
		$this->blogID = $blogID;
		$this->sectionID = $sectionID;
		$this->year = $year;
		$this->month = $month;
	}

	/**
	 *   monthsArchive
	 *   @param $url
	 */
	function monthsArchive($url){				
		print('<div align=center><a href="'.$url.'&year='.($this->year-1).'&month='.$this->month.'"><<</a>&nbsp;&nbsp;&nbsp;&nbsp;<b>'.$this->year.'</b>&nbsp;&nbsp;&nbsp;&nbsp;<a href="'.$url.'&year='.($this->year+1).'&month='.$this->month.'">>></a></div>');		
		print('<a href="'.$url.'">All</a> '.'<br>');
		$url = $url.'&year='.$this->year.'&month=';				
		$months = array(JANUARY,FEBRUARY,MARCH,APRIL,MAY,JUNE,JULY,AUGUST,SEPTEMBER,OCTOBER,NOVEMBER,DECEMBER);		
		// set up blog entry class
		$blogEntry = new BlogEntry($this->blogID,$this->sectionID);		
		for($i=0;$i<12;$i++){			
			$mnum = '';
			if ($i<9)
				$mnum = '0'.($i+1);
			else
				$mnum = $i+1;				
			print('<a href="'.$url.$mnum.'">'.$months[$i].'</a> '.'('.$blogEntry->countEntries($mnum,$this->year).')'.'<br>');			
		}
				
	}
	

}