From 05869f23f798c9393e2bc6d310d56a97a11d1acd Mon Sep 17 00:00:00 2001 From: xue <> Date: Mon, 29 May 2006 02:05:19 +0000 Subject: Added blog demo (not done yet) --- demos/blog/protected/Portlets/ArchivePortlet.php | 45 ++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 demos/blog/protected/Portlets/ArchivePortlet.php (limited to 'demos/blog/protected/Portlets/ArchivePortlet.php') diff --git a/demos/blog/protected/Portlets/ArchivePortlet.php b/demos/blog/protected/Portlets/ArchivePortlet.php new file mode 100644 index 00000000..a004c7a9 --- /dev/null +++ b/demos/blog/protected/Portlets/ArchivePortlet.php @@ -0,0 +1,45 @@ +Application->getModule('data')->queryEarliestPostTime(); + if(empty($startTime)) // if no posts + $startTime=$currentTime; + + // obtain the timestamp for the initial month + $date=getdate($startTime); + $startTime=mktime(0,0,0,$date['mon'],1,$date['year']); + + $date=getdate($currentTime); + $month=$date['mon']; + $year=$date['year']; + + $timestamps=array(); + while(true) + { + if(($timestamp=mktime(0,0,0,$month,1,$year))<$startTime) + break; + $timestamps[]=$timestamp; + if(--$month===0) + { + $month=12; + $year--; + } + } + $this->MonthList->DataSource=$timestamps; + $this->MonthList->dataBind(); + } +} + +?> \ No newline at end of file -- cgit v1.2.3