summaryrefslogtreecommitdiff
path: root/modules/statistics/statistics.module
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2008-12-18 03:58:24 +0000
committerDries Buytaert <dries@buytaert.net>2008-12-18 03:58:24 +0000
commit22570fd6f583cde7393d20abfa0da53bd771a4bf (patch)
treedd5555513b544b7effb124302408e3bae5c2aec1 /modules/statistics/statistics.module
parent8d7eeb0df6c7e7870106f62f07c94a0d3aa95d9d (diff)
downloadbrdo-22570fd6f583cde7393d20abfa0da53bd771a4bf.tar.gz
brdo-22570fd6f583cde7393d20abfa0da53bd771a4bf.tar.bz2
- Patch #345866 by alexanderplas: remove from hook_block() -- addendum patch.
Diffstat (limited to 'modules/statistics/statistics.module')
-rw-r--r--modules/statistics/statistics.module95
1 files changed, 51 insertions, 44 deletions
diff --git a/modules/statistics/statistics.module b/modules/statistics/statistics.module
index 98dab7531..d90c257d2 100644
--- a/modules/statistics/statistics.module
+++ b/modules/statistics/statistics.module
@@ -252,58 +252,65 @@ function statistics_get($nid) {
}
/**
- * Implementation of hook_block().
+ * Implementation of hook_block_list().
*/
-function statistics_block($op = 'list', $delta = '', $edit = array()) {
- switch ($op) {
- case 'list':
- if (variable_get('statistics_count_content_views', 0)) {
- $blocks['popular']['info'] = t('Popular content');
- // Too dynamic to cache.
- $blocks['popular']['cache'] = BLOCK_NO_CACHE;
- return $blocks;
- }
- break;
+function statistics_block_list() {
+ if (variable_get('statistics_count_content_views', 0)) {
+ $blocks['popular']['info'] = t('Popular content');
+ // Too dynamic to cache.
+ $blocks['popular']['cache'] = BLOCK_NO_CACHE;
+ return $blocks;
+ }
+}
- case 'configure':
- // Popular content block settings
- $numbers = array('0' => t('Disabled')) + drupal_map_assoc(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30, 40));
- $form['statistics_block_top_day_num'] = array('#type' => 'select', '#title' => t("Number of day's top views to display"), '#default_value' => variable_get('statistics_block_top_day_num', 0), '#options' => $numbers, '#description' => t('How many content items to display in "day" list.'));
- $form['statistics_block_top_all_num'] = array('#type' => 'select', '#title' => t('Number of all time views to display'), '#default_value' => variable_get('statistics_block_top_all_num', 0), '#options' => $numbers, '#description' => t('How many content items to display in "all time" list.'));
- $form['statistics_block_top_last_num'] = array('#type' => 'select', '#title' => t('Number of most recent views to display'), '#default_value' => variable_get('statistics_block_top_last_num', 0), '#options' => $numbers, '#description' => t('How many content items to display in "recently viewed" list.'));
- return $form;
+/**
+ * Implementation of hook_block_configure().
+ */
+function statistics_block_configure($delta = '') {
+ // Popular content block settings
+ $numbers = array('0' => t('Disabled')) + drupal_map_assoc(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30, 40));
+ $form['statistics_block_top_day_num'] = array('#type' => 'select', '#title' => t("Number of day's top views to display"), '#default_value' => variable_get('statistics_block_top_day_num', 0), '#options' => $numbers, '#description' => t('How many content items to display in "day" list.'));
+ $form['statistics_block_top_all_num'] = array('#type' => 'select', '#title' => t('Number of all time views to display'), '#default_value' => variable_get('statistics_block_top_all_num', 0), '#options' => $numbers, '#description' => t('How many content items to display in "all time" list.'));
+ $form['statistics_block_top_last_num'] = array('#type' => 'select', '#title' => t('Number of most recent views to display'), '#default_value' => variable_get('statistics_block_top_last_num', 0), '#options' => $numbers, '#description' => t('How many content items to display in "recently viewed" list.'));
+ return $form;
+}
- case 'save':
- variable_set('statistics_block_top_day_num', $edit['statistics_block_top_day_num']);
- variable_set('statistics_block_top_all_num', $edit['statistics_block_top_all_num']);
- variable_set('statistics_block_top_last_num', $edit['statistics_block_top_last_num']);
- break;
+/**
+ * Implementation of hook_block_save().
+ */
+function statistics_block_save($delta = '', $edit = array()) {
+ variable_set('statistics_block_top_day_num', $edit['statistics_block_top_day_num']);
+ variable_set('statistics_block_top_all_num', $edit['statistics_block_top_all_num']);
+ variable_set('statistics_block_top_last_num', $edit['statistics_block_top_last_num']);
+}
- case 'view':
- if (user_access('access content')) {
- $content = array();
+/**
+ * Implementation of hook_block_view().
+ */
+function statistics_block_view($delta = '') {
+ if (user_access('access content')) {
+ $content = array();
- $daytop = variable_get('statistics_block_top_day_num', 0);
- if ($daytop && ($result = statistics_title_list('daycount', $daytop)) && ($node_title_list = node_title_list($result, t("Today's:")))) {
- $content[] = $node_title_list;
- }
+ $daytop = variable_get('statistics_block_top_day_num', 0);
+ if ($daytop && ($result = statistics_title_list('daycount', $daytop)) && ($node_title_list = node_title_list($result, t("Today's:")))) {
+ $content[] = $node_title_list;
+ }
- $alltimetop = variable_get('statistics_block_top_all_num', 0);
- if ($alltimetop && ($result = statistics_title_list('totalcount', $alltimetop)) && ($node_title_list = node_title_list($result, t('All time:')))) {
- $content[] = $node_title_list;
- }
+ $alltimetop = variable_get('statistics_block_top_all_num', 0);
+ if ($alltimetop && ($result = statistics_title_list('totalcount', $alltimetop)) && ($node_title_list = node_title_list($result, t('All time:')))) {
+ $content[] = $node_title_list;
+ }
- $lasttop = variable_get('statistics_block_top_last_num', 0);
- if ($lasttop && ($result = statistics_title_list('timestamp', $lasttop)) && ($node_title_list = node_title_list($result, t('Last viewed:')))) {
- $content[] = $node_title_list;
- }
+ $lasttop = variable_get('statistics_block_top_last_num', 0);
+ if ($lasttop && ($result = statistics_title_list('timestamp', $lasttop)) && ($node_title_list = node_title_list($result, t('Last viewed:')))) {
+ $content[] = $node_title_list;
+ }
- if (count($content)) {
- $block['content'] = implode('<br />', $content);
- $block['subject'] = t('Popular content');
- return $block;
- }
- }
+ if (count($content)) {
+ $block['content'] = implode('<br />', $content);
+ $block['subject'] = t('Popular content');
+ return $block;
+ }
}
}