function _archive_query in Archive 5
Same name and namespace in other branches
- 6 archive.pages.inc \_archive_query()
- 7.2 archive.pages.inc \_archive_query()
- 7 archive.pages.inc \_archive_query()
Builds an SQL query array (query and parameters) to use to display an archive page for the specified date.
Parameters
$type: A string representing the node-type currently being displayed
$date: A date object obtained from _archive_date()
Return value
An array of (query, param_start, param_end)
1 call to _archive_query()
- _archive_page in ./
archive.inc - Fetch nodes for the selected date, or current date if none selected.
File
- ./
archive.inc, line 69
Code
function _archive_query($type, $date) {
// Confine the display interval to only one day
if ($date->day) {
$start = gmmktime(0, 0, 0, $date->month, $date->day, $date->year);
$end = gmmktime(0, 0, 0, $date->month, $date->day + 1, $date->year);
}
else {
if ($date->month) {
$start = gmmktime(0, 0, 0, $date->month, 1, $date->year);
$end = gmmktime(0, 0, 0, $date->month + 1, 1, $date->year);
}
else {
if ($date->year) {
$start = gmmktime(0, 0, 0, 1, 1, $date->year);
$end = gmmktime(0, 0, 0, 1, 1, $date->year + 1);
}
else {
$start = 0;
$end = 0;
}
}
}
// Grab limits on node types if exist
$final_types = _archive_types_sql_string($type);
// Allow viewing all nodes, not just nodes by year
if ($start && $end) {
return array(
'SELECT n.nid, n.type FROM {node} n WHERE n.status = 1 ' . $final_types . 'AND n.created >= %d AND n.created < %d ORDER BY n.created DESC',
$start - $date->tz,
$end - $date->tz,
);
}
else {
return array(
'SELECT n.nid, n.type FROM {node} n WHERE n.status = 1 ' . $final_types . 'ORDER BY n.created DESC',
);
}
}