Things to Note:
<?
1 /*
2
3 the archive page - Saturday, April 24, 2004, 7:57:29 PM
4
5 by owen
6
7 from www.owensoft.net/v4/archive/
8
9 */
10
11
12 //--------------------------------------------------------------------------------------------
13 #print source if requested
14
15 if($option=='source' | $record=='source' ) {
16 highlight_file ( __FILE__ );
17 return false;
18 }
19
20 //--------------------------------------------------------------------------------------------
21
22 $pagetitle = "Archive";
23
24 //--------------------------------------------------------------------------------------------
25
26 #initialise a few variables
27 $year=$record;
28 $month=$option;
29
30 //--------------------------------------------------------------------------------------------
31 # generate both a year and month are specified generate a page of posts grouped by category
32
33 if ( vint($year) & vint($month) ) {
34
35 $pagetitle = 'Archive, ' . date('F', mktime(0,0,0,$month,1,date("Y") ) ) . ' of the year ' . $year;
36
37 //$menu='archive';
38 require_once("head.php");
39
40 $query = " SELECT p.*, c.name as 'category_name', c.tooltip, p.photo from post p, category c where 0=0 ";
41 $query .= " and c.id = p.category ";
42 $query .= " and DATE_FORMAT(p.thedate,'%m') = $month and DATE_FORMAT(p.thedate,'%Y') = $year ";
43 $query .= " order by category_name, p.thedate ";
44 $os->execsql2($query, 'CACHE');
45
46 $count=0;
47 $last_cat='';
48
49 while( $row = $os->fetch_array() ) {
50 $count++;
51
52 if ($count==1) {
53 include(template('archive', 'month_heading'));
54 }
55
56 if ($last_cat!=$row['category_name']) {
57 $last_cat=$row['category_name'];
58 if ($count != 1) include(template('archive', 'month_item_group_end'));
59 include(template('archive', 'month_item_group_begin'));
60 }
61
62 include(template('archive', 'month_item'));
63 }
64
65 if ($count > 0) include(template('archive', 'month_item_group_end'));
66 if ($count == 0) include(template('archive', 'month_none_found'));
67
68
69 }
70
71 //--------------------------------------------------------------------------------------------
72 # generate month achive page of a year is specified
73
74 if ( vint($year) & !vint($month) ) {
75
76 $pagetitle = 'Archives of the year ' . $year;
77 require_once("head.php");
78
79 $query = " SELECT DATE_FORMAT(p.thedate,'%Y%b') as 'ord', DATE_FORMAT(p.thedate,'%m') as 'month', DATE_FORMAT(p.thedate,'%M') as 'month_name', DATE_FORMAT(p.thedate,'%Y') as 'year', count(*) as 'posts' , SUM( photo > 0 ) AS 'photos', SUM(thecount) as 'comments' from post p where YEAR(p.thedate)=$year group by ord order by p.thedate ";
80 $os->execsql2($query, 'CACHE');
81
82 $count=0;
83 $c_year=0;
84
85
86 include(template('archive', 'heading'));
87
88 while( $row = $os->fetch_array() ) {
89 $count++;
90 if($count==1) include(template('archive', 'month_list_begin'));
91 include(template('archive', 'year_record'));
92 }
93
94 if ( $count>0 ) {
95 include(template('archive', 'month_list_end'));
96 } else include(template('archive', 'year_nothing'));
97 #----------------------------------------------
98 /*
99 $query = " SELECT p.*, c.name as 'category_name', c.tooltip, p.photo, AVG(thecount) as mh, AVG(thecount) from post p, category c where 0=0 ";
100 $query .= " and c.id = p.category and p.id !=61 and YEAR(p.thedate)=$year ";
101 $query .= " group by p.id ";
102 $query .= " order by mh desc LIMIT 5 ";
103 $os->execsql2($query, 'CACHE');
104
105 $count=0;
106 $last_cat='';
107
108 while( $row = $os->fetch_array() ) {
109 $count++;
110
111 if ($count==1) {
112 //include(template('archive', 'month_heading'));
113 }
114
115 if ($last_cat!=$row['category_name']) {
116 $last_cat=$row['category_name'];
117 if ($count != 1) include(template('archive', 'month_item_group_end'));
118 include(template('archive', 'month_item_group_begin'));
119 }
120
121 include(template('archive', 'month_item'));
122 }
123
124 if ($count > 0) include(template('archive', 'month_item_group_end'));
125 // if ($count == 0) include(template('archive', 'month_none_found'));
126 */
127 #------------------------------------------
128
129 $query = " select photo as 'photo_id', photo, p.name, p.category, p.id as 'post_id' from post p, category c where p.category = c.id and photo > 0 and YEAR(p.thedate)=$year order by thedate desc ";
130 $os->execsql2( $query, 'CACHE' );
131
132 $count=0;
133
134 while( $row = $os->fetch_array() ) {
135 $count++;
136 if($count==1) include(template('archive', 'photo_list_begin'));
137 if ($row['photo']>0) include(template('archive', 'photo_icon1'));
138 }
139
140 if ( $count>0 ) {
141 include(template('archive', 'photo_list_end'));
142 }
143
144 }
145 //--------------------------------------------------------------------------------------------
146 # generate year achive page/list/thing if month, year and photo is not specified
147
148 if ( !vint($year) & !vint($month) & $record!='photo' ) {
149
150 require_once("head.php");
151
152 $query = "SELECT DATE_FORMAT( p.thedate, '%Y' ) AS 'ord', DATE_FORMAT( p.thedate, '%Y' ) AS 'year', count( * ) AS 'posts', SUM( photo > 0 ) AS 'photos' FROM post p WHERE 0 = 0 GROUP BY ord ORDER BY p.thedate desc ";
153 $os->execsql2($query, 'CACHE');
154
155 $count=0;
156 $c_year=0;
157
158 include(template('archive', 'heading'));
159
160 while( $row = $os->fetch_array() ) {
161 $count++;
162
163 include(template('archive', 'year'));
164
165 }
166
167
168
169 //include(template('archive', 'photo_link'));
170
171 }
172
173 //--------------------------------------------------------------------------------------------
174 # generate photo achive page
175 if ( !vint($year) & !vint($month) & $record=='photo' ) {
176
177 $pagetitle = 'Archive Photo';
178
179 require_once("head.php");
180
181 $query = " select photo as 'photo_id', photo, p.name, p.category, p.id as 'post_id' from post p, category c where p.category = c.id and photo > 0 order by thedate desc ";
182 $os->execsql2( $query, 'CACHE' );
183
184 $count=0;
185
186 include(template('archive', 'photo_page_heading'));
187
188 while( $row = $os->fetch_array() ) {
189 $count++;
190
191 if ($row['photo']>0) include(template('archive', 'photo_icon1'));
192 }
193
194 }
195
196 //--------------------------------------------------------------------------------------------
197 #the footer is always shown unless
198 require_once("foot.php");
199
200
201 ?>