root/releases/0.1.1b/units/weblogs/archives_view_month.php

Revision 2, 1.2 kB (checked in by sven, 3 years ago)

importing elgg-0.1.1a

Line 
1 <?php
2
3     // Get the current profile ID
4     
5         global $profile_id;
6         
7     // Obtain the separate archive pages from the database
8     
9         $archives = db_query("SELECT distinct
10                                     EXTRACT(YEAR_MONTH FROM FROM_UNIXTIME(posted)) as archivestamp
11                                     FROM `weblog_posts`
12                                     WHERE owner = $profile_id")
13                             or die(db_error());
14
15     // If there are any archives ...
16     
17         if (sizeof($archives) > 0) {
18         
19     // Get the name of the weblog user
20             
21         $weblog_name = htmlentities(stripslashes($_REQUEST['weblog_name']));
22             
23     // Run through them
24     
25             $run_result .= "<ul>";
26     
27             foreach($archives as $archive) {
28                 
29     // Extract the year and the month
30     
31                 $year = substr($archive->archivestamp, 0, 4);
32                 $month = substr($archive->archivestamp, 4, 2);
33                 
34     // Print a link
35     
36                 $run_result .= "<li>";
37                 $run_result .= "<a href=\"/$weblog_name/weblog/archive/$year/$month/\">";
38                 $run_result .= date("F",gmmktime(0,0,0,$month,1,$year)) . " " . $year;
39                 $run_result .= "</a>";
40                 $run_result .= "</li>";
41                 
42             }
43             
44             $run_result .= "</ul>";
45             
46     // If there are no posts to archive, say so!
47             
48         } else {
49             
50             $run_result .= "<p>There are no weblog posts to archive as yet.</p>";
51             
52         }
53     
54 ?>
Note: See TracBrowser for help on using the browser.