diff options
Diffstat (limited to 'modules/statistics')
-rw-r--r-- | modules/statistics/statistics.module | 48 |
1 files changed, 27 insertions, 21 deletions
diff --git a/modules/statistics/statistics.module b/modules/statistics/statistics.module index 1189610d9..895f0083b 100644 --- a/modules/statistics/statistics.module +++ b/modules/statistics/statistics.module @@ -456,13 +456,6 @@ function statistics_settings() { $group .= form_radios(t('Display counter values'), 'statistics_display_counter', variable_get('statistics_display_counter', 0), array('1' => t('Enabled'), '0' => t('Disabled')), t('Display how many times given content has been viewed. User must have the "access statistics" permissions to be able to view these counts.')); $output .= form_group(t('Content viewing counter settings'), $group); - // 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)); - $group = form_select(t("Number of day's top views to display"), 'statistics_block_top_day_num', variable_get('statistics_block_top_day_num', 0), $numbers, t('How many content items to display in "day" list. Requires enabled content viewing counters.')); - $group .= form_select(t('Number of all time views to display'), 'statistics_block_top_all_num', variable_get('statistics_block_top_all_num', 0), $numbers, t('How many content items to display in "all time" list. Requires enabled content viewing counters.')); - $group .= form_select(t('Number of most recent views to display'), 'statistics_block_top_last_num', variable_get('statistics_block_top_last_num', 0), $numbers, t('How many content items to display in "recently viewed" list. Requires enabled content viewing counters.')); - $output .= form_group(t('"Popular content" block settings'), $group); - // Popular content page settings $numbers = array('0' => t('Disabled')) + drupal_map_assoc(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25)); $group = form_textfield(t('Name for link to user page'), 'statistics_userpage_link', variable_get('statistics_userpage_link', ''), 20, 40, t("This node generates a user page listing your site's most popular content. If you specify a name here, a link to the \"Popular content\" page will be added automatically.")); @@ -543,16 +536,30 @@ function statistics_get($nid) { /** * Implementation of hook_block(). */ -function statistics_block($op = 'list', $delta = 0) { - if ($op == 'list') { - if (variable_get('statistics_count_content_views', 0)) { - $blocks[0]['info'] = t('Popular content'); - } - return $blocks; - } - else if (user_access('access content')) { - switch ($delta) { - case 0: +function statistics_block($op = 'list', $delta = 0, $edit = array()) { + switch ($op) { + case 'list': + if (variable_get('statistics_count_content_views', 0)) { + $blocks[0]['info'] = t('Popular content'); + } + 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)); + $output = form_select(t("Number of day's top views to display"), 'statistics_block_top_day_num', variable_get('statistics_block_top_day_num', 0), $numbers, t('How many content items to display in "day" list.')); + $output .= form_select(t('Number of all time views to display'), 'statistics_block_top_all_num', variable_get('statistics_block_top_all_num', 0), $numbers, t('How many content items to display in "all time" list.')); + $output .= form_select(t('Number of most recent views to display'), 'statistics_block_top_last_num', variable_get('statistics_block_top_last_num', 0), $numbers, t('How many content items to display in "recently viewed" list.')); + return $output; + + 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; + + case 'view': + if (user_access('access content')) { $content = array(); $daytop = variable_get('statistics_block_top_day_num', 0); @@ -571,12 +578,11 @@ function statistics_block($op = 'list', $delta = 0) { } $output = implode($content, '<br />'); - $block['subject'] = variable_get('statistics_block_top_title', t('Popular content')); + $block['subject'] = t('Popular content'); $block['content'] = $output; - break; - } - return $block; + return $block; + } } } |