| 1 |
<?php |
<?php |
| 2 |
// $Id: archive.module,v 1.13 2007/08/24 16:03:17 susurrus Exp $ |
// $Id$ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* Implementation of hook_help(). |
* Implementation of hook_help(). |
| 25 |
function archive_menu() { |
function archive_menu() { |
| 26 |
$items = array(); |
$items = array(); |
| 27 |
$items['archive'] = array( |
$items['archive'] = array( |
| 28 |
'title' => t('Archives'), |
'title' => 'Archives', |
| 29 |
'access' => user_access('access content'), |
'access callback' => 'user_is_logged_in', |
| 30 |
'callback' => 'archive_page', |
'page callback' => '_archive_page', |
| 31 |
'file' => 'archive.pages.inc', |
'file' => 'archive.pages.inc', |
| 32 |
'type' => MENU_SUGGESTED_ITEM); |
'type' => MENU_SUGGESTED_ITEM); |
| 33 |
$items['admin/settings/archive'] = array( |
$items['admin/settings/archive'] = array( |
| 34 |
'title' => t('Archives'), |
'title' => 'Archive settings', |
| 35 |
'callback' => 'drupal_get_form', |
'page callback' => 'drupal_get_form', |
| 36 |
'callback arguments' => array('archive_admin_settings'), |
'page arguments' => array('archive_admin_settings'), |
| 37 |
'file' => 'archive.admin.inc', |
'file' => 'archive.admin.inc', |
| 38 |
'type' => MENU_NORMAL_ITEM); |
'type' => MENU_NORMAL_ITEM); |
| 39 |
|
|
| 40 |
return $items; |
return $items; |
| 41 |
} |
} |
| 42 |
|
|
| 43 |
/** |
/** |
| 44 |
|
* Implementation of hook_theme(). |
| 45 |
|
*/ |
| 46 |
|
function archive_theme() { |
| 47 |
|
return array( |
| 48 |
|
'archive_block_calendar' => array( |
| 49 |
|
'arguments' => array('timestamp' => 0) |
| 50 |
|
), |
| 51 |
|
'archive_navigation' => array( |
| 52 |
|
'arguments' => array('type' => '', 'date' => NULL) |
| 53 |
|
), |
| 54 |
|
'archive_navigation_days' => array( |
| 55 |
|
'arguments' => array('type' => '', 'date' => NULL) |
| 56 |
|
), |
| 57 |
|
'archive_navigation_months' => array( |
| 58 |
|
'arguments' => array('type' => '', 'date' => NULL) |
| 59 |
|
), |
| 60 |
|
'archive_navigation_node_types' => array( |
| 61 |
|
'arguments' => array('type' => '', 'date' => NULL) |
| 62 |
|
), |
| 63 |
|
'archive_navigation_years' => array( |
| 64 |
|
'arguments' => array('type' => '', 'date' => NULL) |
| 65 |
|
), |
| 66 |
|
); |
| 67 |
|
} |
| 68 |
|
|
| 69 |
|
/** |
| 70 |
* Returns a single month as a calendar grid |
* Returns a single month as a calendar grid |
| 71 |
* TODO: take the archive logic out to allow better theme-overloading of this function |
* TODO: take the archive logic out to allow better theme-overloading of this function |
| 72 |
* TODO: make sure that no wheels are reinvented that could be reused from the rest of the archive module |
* TODO: make sure that no wheels are reinvented that could be reused from the rest of the archive module |
| 73 |
*/ |
*/ |
| 74 |
|
|
| 75 |
function theme_archive_month($timestamp) { |
function theme_archive_block_calendar($timestamp) { |
| 76 |
$title = format_date($timestamp,'custom',"F Y"); |
$title = format_date($timestamp, 'custom', "F Y"); |
| 77 |
$year = date('Y',$timestamp); |
$year = date('Y',$timestamp); |
| 78 |
$month = date('m',$timestamp); |
$month = date('m',$timestamp); |
| 79 |
$date = _archive_date($year,$month,1); |
$date = _archive_date($year,$month,1); |
| 132 |
if (!$archive_block_time) $archive_block_time = time(); |
if (!$archive_block_time) $archive_block_time = time(); |
| 133 |
$block = array( |
$block = array( |
| 134 |
'subject' => t("Archives"), |
'subject' => t("Archives"), |
| 135 |
'content' => theme('archive_month', $archive_block_time), |
'content' => theme('archive_block_calendar', $archive_block_time), |
| 136 |
); |
); |
| 137 |
return $block; |
return $block; |
| 138 |
} |
} |