Update of /cvsroot/php-blog/jBlog
In directory sc8-pr-cvs1:/tmp/cvs-serv29917
Modified Files:
jBlog_functions.inc.php jBlog_layout.php
jBlog_layout_table.php
Log Message:
A quick and dirty so user's can view the archives.
Index: jBlog_functions.inc.php
===================================================================
RCS file: /cvsroot/php-blog/jBlog/jBlog_functions.inc.php,v
retrieving revision 1.75
retrieving revision 1.76
diff -u -d -r1.75 -r1.76
--- jBlog_functions.inc.php 27 Mar 2003 21:29:49 -0000 1.75
+++ jBlog_functions.inc.php 28 Mar 2003 11:44:04 -0000 1.76
@@ -1525,6 +1525,48 @@
fclose($fp);
}
+/*
+* Amount of posts for given year & month
+*/
+function jBlog_postAmount($year, $month) {
+ global $jBlog;
+ $s = mktime(0,0,0, $month, 1, $year);
+ $e = mktime(23,59,59, $month, date("t",$s) , $year);
+ $querystring = "SELECT count(id) FROM {$jBlog['dbPrefix']}entries WHERE timestamp>$s AND timestamp<$e";
+ $query = jBlog_db_query($querystring);
+ return $query[0][0];
+}
+
+/*
+* Print the archive
+*/
+function jBlog_printArchives() {
+ global $jBlog;
+
+ echo "<div class='jBlog_title'>The Archive:</div>";
+ $f = jBlog_db_query("SELECT timestamp FROM {$jBlog['dbPrefix']}entries ORDER BY timestamp ASC LIMIT 1");
+ $lastYear = date("Y", $f[0][0]);
+ $lastMonth= date("m", $f[0]);
+ $currYear = date("Y");
+ while($currYear>=$lastYear) {
+ echo "<h2>$currYear</h2><div class='jBlog_entry'>";
+ for($x=1; $x<13; $x++) {
+ $entries = jBlog_postAmount($currYear, $x);
+ if ($entries>0) {
+ $a = "<a href='{$jBlog['jBlogHTTPPath']}archives/d_$currYear".sprintf("%02s",$x).".html'>";
+ $b = "($entries entries)</a>";
+ }
+ else {
+ $a = "<font color='#cdcdcd'>";
+ $b = "</font>";
+ }
+ if ($x<=date("m") || $currYear < date("Y"))
+ echo str_repeat(" ", 8)."$a{$jBlog['months'][$x]} $b<br>";
+ }
+ echo "</div>";
+ $currYear--;
+ }
+}
define("JBLOG_FUNCTIONS_LOADED", true);
?>
Index: jBlog_layout.php
===================================================================
RCS file: /cvsroot/php-blog/jBlog/jBlog_layout.php,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- jBlog_layout.php 11 Mar 2003 18:49:06 -0000 1.15
+++ jBlog_layout.php 28 Mar 2003 11:44:05 -0000 1.16
@@ -64,6 +64,11 @@
jBlog_printEntries($r);
break;
+ // Show the archives
+ case "archives":
+ jBlog_printArchives();
+ break;
+
// Welcome screen or whatever
default:
jBlog_printEntries(jBlog_fetchEntries(null, true, 15));
Index: jBlog_layout_table.php
===================================================================
RCS file: /cvsroot/php-blog/jBlog/jBlog_layout_table.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- jBlog_layout_table.php 11 Mar 2003 01:41:07 -0000 1.1
+++ jBlog_layout_table.php 28 Mar 2003 11:44:05 -0000 1.2
@@ -54,6 +54,11 @@
jBlog_printEntries($r);
break;
+ // Show the archive
+ case "archives":
+ jBlog_printArchives();
+ break;
+
// Welcome screen or whatever
default:
jBlog_printEntries(jBlog_fetchEntries(null, true, 15));
|