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

Revision 2, 1.5 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                                     order by posted desc");
14
15     // If there are any archives ...
16     
17         if (sizeof($archives) > 0) {
18         
19             $run_result .= "<h1 class=\"weblogdateheader\">Weblog Archive</h1>";
20             
21     // Get the name of the weblog user
22             
23         $weblog_name = htmlentities(stripslashes($_REQUEST['weblog_name']));
24             
25     // Run through them
26     
27             $lastyear = 0;
28     
29             foreach($archives as $archive) {
30                 
31     // Extract the year and the month
32     
33                 $year = substr($archive->archivestamp, 0, 4);
34                 $month = substr($archive->archivestamp, 4, 2);
35                 
36                 if ($year != $lastyear) {
37                     if ($lastyear .= 0) {
38                         $run_result .= "</ul>";
39                     }
40                     $lastyear = $year;
41                     $run_result .= "<h2 class=\"weblogdateheader\">$year</h2>";
42                     $run_result .= "<ul>";
43                 }
44                 
45     // Print a link
46     
47                 $run_result .= "<li>";
48                 $run_result .= "<a href=\"/$weblog_name/weblog/archive/$year/$month/\">";
49                 $run_result .= date("F",gmmktime(0,0,0,$month,1,$year)) . " " . $year;
50                 $run_result .= "</a>";
51                 $run_result .= "</li>";
52                 
53             }
54             
55             $run_result .= "</ul>";
56             
57     // If there are no posts to archive, say so!
58             
59         } else {
60             
61             $run_result .= "<p>There are no weblog posts to archive as yet.</p>";
62             
63         }
64     
65 ?>
Note: See TracBrowser for help on using the browser.