Subversion-Projekte lars-tiefland.prado

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
/**
3
 * ArchivePortlet class file
4
 *
5
 * @author Qiang Xue <qiang.xue@gmail.com>
6
 * @link http://www.pradosoft.com/
7
 * @copyright Copyright &copy; 2006 PradoSoft
8
 * @license http://www.pradosoft.com/license/
9
 * @version $Id: ArchivePortlet.php 1398 2006-09-08 19:31:03Z xue $
10
 */
11
 
12
Prado::using('Application.Portlets.Portlet');
13
 
14
/**
15
 * ArchivePortlet class
16
 *
17
 * @author Qiang Xue <qiang.xue@gmail.com>
18
 * @link http://www.pradosoft.com/
19
 * @copyright Copyright &copy; 2006 PradoSoft
20
 * @license http://www.pradosoft.com/license/
21
 */
22
class ArchivePortlet extends Portlet
23
{
24
	private function makeMonthTime($timestamp)
25
	{
26
		$date=getdate($timestamp);
27
		return mktime(0,0,0,$date['mon'],1,$date['year']);
28
	}
29
 
30
	public function onLoad($param)
31
	{
32
		$currentTime=time();
33
		$startTime=$this->Application->getModule('data')->queryEarliestPostTime();
34
		if(empty($startTime))	// if no posts
35
			$startTime=$currentTime;
36
 
37
		// obtain the timestamp for the initial month
38
		$date=getdate($startTime);
39
		$startTime=mktime(0,0,0,$date['mon'],1,$date['year']);
40
 
41
		$date=getdate($currentTime);
42
		$month=$date['mon'];
43
		$year=$date['year'];
44
 
45
		$timestamps=array();
46
		while(true)
47
		{
48
			if(($timestamp=mktime(0,0,0,$month,1,$year))<$startTime)
49
				break;
50
			$timestamps[]=$timestamp;
51
			if(--$month===0)
52
			{
53
				$month=12;
54
				$year--;
55
			}
56
		}
57
		$this->MonthList->DataSource=$timestamps;
58
		$this->MonthList->dataBind();
59
	}
60
}
61
 
62
?>