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