diff options
author | Dries Buytaert <dries@buytaert.net> | 2003-11-25 21:12:26 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2003-11-25 21:12:26 +0000 |
commit | 6135c14c44fc1004ae7d4118fe4149e88419f186 (patch) | |
tree | 4b058cc6a886cde0b112b80bdd6a77dbd8f05dac | |
parent | 18d81e5ed372daee22416107cc29cc2fd30b00bf (diff) | |
download | brdo-6135c14c44fc1004ae7d4118fe4149e88419f186.tar.gz brdo-6135c14c44fc1004ae7d4118fe4149e88419f186.tar.bz2 |
Statistics module improvements by Jeremy:
- Remove custom configuration of "admin/system/block/top nodes block".
- Three remaining configuration options moved to "admin/system/modules/statistics".
- Move simple logic to display block within statistics_block().
-rw-r--r-- | modules/statistics.module | 111 | ||||
-rw-r--r-- | modules/statistics/statistics.module | 111 |
2 files changed, 46 insertions, 176 deletions
diff --git a/modules/statistics.module b/modules/statistics.module index 43792014a..2753b0a54 100644 --- a/modules/statistics.module +++ b/modules/statistics.module @@ -115,9 +115,6 @@ function statistics_link($type, $node = 0, $main = 0) { menu("admin/statistics/log/host", t("track host"), "statistics_admin", 0, 1); //hidden menu("admin/statistics/top nodes page", t("configure 'top nodes' page"), "statistics_admin", 5); menu("admin/statistics/help", t("help"), "statistics_help_page", 9); - - // block configuration: - menu("admin/system/block/top nodes block", t("configure 'top nodes' block"), "statistics_admin", 5); } if (user_access("access content")) { @@ -229,9 +226,6 @@ function statistics_help($section = "admin/help#statistics") { case 'admin/statistics/top nodes page': $output = t("The statistics module creates a user page that can display summaries of the day's top viewed nodes, the all time top nodes and the last nodes viewed. Each of these summaries can be enabled or disabled individually, and the number of nodes displayed for each can be configured with a drop down menu."); break; - case 'admin/system/block/top nodes block': - $output = t("The statistics module exports a block that can display the top viewed nodes of the day, the all time top viewed nodes and the last nodes viewed. Each of these links can be enabled or disabled individually, and the number of nodes displayed for each can be configured with a drop down menu. If you disable all sections of this block, it will not appear."); - break; } return $output; } @@ -266,10 +260,6 @@ function statistics_admin() { /* configuration admin pages */ if (user_access("administer statistics module")) { switch (stripslashes($op)) { - case t("Submit \"top nodes\" block changes"): - statistics_save_topnodes_block($edit); - $output .= status(t("saved 'top nodes' block changes.")); - break; case t("Submit \"top nodes\" page changes"): statistics_save_userconfig($edit); $output .= status(t("saved 'top nodes' page changes.")); @@ -285,19 +275,6 @@ function statistics_admin() { "statistics_userpage_last_cnt" => variable_get("statistics_userpage_last_cnt", 0) )); break; - case "block": - if (arg(3) == "top nodes block") { - $output .= statistics_config_topnodes_block(array( - "statistics_block_top_title" => variable_get("statistics_block_top_title", "Top nodes"), - "statistics_block_top_day_head" => variable_get("statistics_block_top_day_head", "<b>Todays top:</b>"), - "statistics_block_top_day_num" => variable_get("statistics_block_top_day_num", 0), - "statistics_block_top_all_head" => variable_get("statistics_block_top_all_head", "<b>All time top:</b>"), - "statistics_block_top_all_num" => variable_get("statistics_block_top_all_num", 0), - "statistics_block_top_last_head" => variable_get("statistics_block_top_last_head" ,"<b>Last:</b>"), - "statistics_block_top_last_num" => variable_get("statistics_block_top_last_num", 0) - )); - } - break; default: $output .= statistics_admin_topnodes(); } @@ -475,34 +452,6 @@ function statistics_admin_displaylog() { } -/* Displays the block configuration administration form */ -function statistics_config_topnodes_block($edit) { - - $form = form_textfield(t("Block name"), "statistics_block_top_title", $edit["statistics_block_top_title"], 20, 40, t("This module generates a block with top nodes. You may assign a name for this block.")); - - $form .= "<hr />"; - - $form .= form_textfield(t("Today's top nodes title"), "statistics_block_top_day_head", $edit["statistics_block_top_day_head"], 20, 40, t("Specify a name for the \"day's top\" section of the block generated by this module. HTML tags permitted.")); - $form .= form_select(t("Number of day's top views to display"), "statistics_block_top_day_num", $edit["statistics_block_top_day_num"], array("0" => t("Disabled"), "1" => "1", "2" => "2", "3" => "3", "4" => "4", "5" => "5", "6" => "6", "7" => "7", "8" => "8", "9" => "9", "10" => "10", "15" => "15", "20" => "20", "25" => "25", "30" => "30", "40" => "40"), t("Set how many \"today's top\" nodes to display on the block generated by this module.")); - - $form .= "<hr />"; - - $form .= form_textfield(t("All time top nodes title"), "statistics_block_top_all_head", $edit["statistics_block_top_all_head"], 20, 40, t("Specify a name for the \"all time top\" section of the block generated by this module. HTML tags permitted.")); - $form .= form_select(t("Number of all time views to display"), "statistics_block_top_all_num", $edit["statistics_block_top_all_num"], array("0" => t("Disabled"), "1" => "1", "2" => "2", "3" => "3", "4" => "4", "5" => "5", "6" => "6", "7" => "7", "8" => "8", "9" => "9", "10" => "10", "15" => "15", "20" => "20", "25" => "25", "30" => "30", "40" => "40"), t("Set how many \"all time top\" nodes to display on the block generated by this module.")); - - $form .= "<hr />"; - - $form .= form_textfield(t("Most recent views heading"), "statistics_block_top_last_head", $edit["statistics_block_top_last_head"], 20, 40, t("Specify a name for the \"last views\" section of the block generated by this module. HTML tags permitted.")); - $form .= form_select(t("Number of most recent views to display"), "statistics_block_top_last_num", $edit["statistics_block_top_last_num"], array("0" => t("Disabled"), "1" => "1", "2" => "2", "3" => "3", "4" => "4", "5" => "5", "6" => "6", "7" => "7", "8" => "8", "9" => "9", "10" => "10", "15" => "15", "20" => "20", "25" => "25", "30" => "30", "40" => "40"), t("Set how many \"last viewed\" nodes to display on the block generated by this module.")); - - $form .= "<hr />"; - - $form .= form_submit(t("Submit \"top nodes\" block changes")); - - return form($form); -} - - /* Displays the user page configuration administration form */ function statistics_admin_userpage_config($edit) { @@ -537,19 +486,11 @@ function statistics_settings() { $output .= form_radios(t("Enable node view counters"), "statistics_enable_node_counter", variable_get("statistics_enable_node_counter", 0), array("1" => t("Enabled"), "0" => t("Disabled")), t("Increment node view counter each time a node is viewed.")); $output .= form_radios(t("Display node view counters"), "statistics_display_counter", variable_get("statistics_display_counter", ""), array("1" => t("Enabled"), "0" => t("Disabled")), t("Display how many times each node has been viewed. User must have the 'access statistics' permissions.")); - return $output; -} + $output .= form_select(t("Number of day's top views to display"), "statistics_block_top_day_num", $edit["statistics_block_top_day_num"], array("0" => t("Disabled"), "1" => "1", "2" => "2", "3" => "3", "4" => "4", "5" => "5", "6" => "6", "7" => "7", "8" => "8", "9" => "9", "10" => "10", "15" => "15", "20" => "20", "25" => "25", "30" => "30", "40" => "40"), t("Affects \"Top nodes\" block. How many nodes to display in \"day's\" list.")); + $output .= form_select(t("Number of all time views to display"), "statistics_block_top_all_num", $edit["statistics_block_top_all_num"], array("0" => t("Disabled"), "1" => "1", "2" => "2", "3" => "3", "4" => "4", "5" => "5", "6" => "6", "7" => "7", "8" => "8", "9" => "9", "10" => "10", "15" => "15", "20" => "20", "25" => "25", "30" => "30", "40" => "40"), t("Affects \"Top nodes\" block. How many nodes to display in \"all time\" list.")); + $output .= form_select(t("Number of most recent views to display"), "statistics_block_top_last_num", $edit["statistics_block_top_last_num"], array("0" => t("Disabled"), "1" => "1", "2" => "2", "3" => "3", "4" => "4", "5" => "5", "6" => "6", "7" => "7", "8" => "8", "9" => "9", "10" => "10", "15" => "15", "20" => "20", "25" => "25", "30" => "30", "40" => "40"), t("Affects \"Top nodes\" block. How many nodes to display in \"recently viewed\" list.")); - -/* Saves the values entered in the "blockconfig" administration form */ -function statistics_save_topnodes_block($edit) { - variable_set("statistics_block_top_title", $edit["statistics_block_top_title"]); - variable_set("statistics_block_top_day_head", $edit["statistics_block_top_day_head"]); - variable_set("statistics_block_top_day_num", $edit["statistics_block_top_day_num"]); - variable_set("statistics_block_top_all_head", $edit["statistics_block_top_all_head"]); - variable_set("statistics_block_top_all_num", $edit["statistics_block_top_all_num"]); - variable_set("statistics_block_top_last_head", $edit["statistics_block_top_last_head"]); - variable_set("statistics_block_top_last_num", $edit["statistics_block_top_last_num"]); + return $output; } @@ -595,30 +536,6 @@ function statistics_cron() { } -/* Displays the "Top nodes" block */ -function statistics_display_topnodes_block() { - - $content = array(); - - $daytop = variable_get("statistics_block_top_day_num", ""); - if ($daytop) { - $content[] = node_title_list(statistics_title_list("daycount", $daytop), variable_get("statistics_block_top_day_head", "")); - } - - $alltimetop = variable_get("statistics_block_top_all_num", ""); - if ($alltimetop) { - $content[] = node_title_list(statistics_title_list("totalcount", $alltimetop), variable_get("statistics_block_top_all_head", "")); - } - - $lasttop = variable_get("statistics_block_top_last_num", ""); - if ($lasttop) { - $content[] = node_title_list(statistics_title_list("timestamp", $lasttop), variable_get("statistics_block_top_last_head", "")); - } - - $output = implode($content, "<br />"); - - return $output; -} /* Display linked title based on field name */ @@ -652,8 +569,26 @@ function statistics_block($op = "list", $delta = 0) { else if (user_access("access content")) { switch ($delta) { case 0: + $content = array(); + + $daytop = variable_get("statistics_block_top_day_num", ""); + if ($daytop) { + $content[] = node_title_list(statistics_title_list("daycount", $daytop), variable_get("statistics_block_top_day_head", "")); + } + + $alltimetop = variable_get("statistics_block_top_all_num", ""); + if ($alltimetop) { + $content[] = node_title_list(statistics_title_list("totalcount", $alltimetop), variable_get("statistics_block_top_all_head", "")); + } + + $lasttop = variable_get("statistics_block_top_last_num", ""); + if ($lasttop) { + $content[] = node_title_list(statistics_title_list("timestamp", $lasttop), variable_get("statistics_block_top_last_head", "")); + } + $output = implode($content, "<br />"); + $block["subject"] = variable_get("statistics_block_top_title", t("Popular content")); - $block["content"] = statistics_display_topnodes_block(); + $block["content"] = $output; break; } diff --git a/modules/statistics/statistics.module b/modules/statistics/statistics.module index 43792014a..2753b0a54 100644 --- a/modules/statistics/statistics.module +++ b/modules/statistics/statistics.module @@ -115,9 +115,6 @@ function statistics_link($type, $node = 0, $main = 0) { menu("admin/statistics/log/host", t("track host"), "statistics_admin", 0, 1); //hidden menu("admin/statistics/top nodes page", t("configure 'top nodes' page"), "statistics_admin", 5); menu("admin/statistics/help", t("help"), "statistics_help_page", 9); - - // block configuration: - menu("admin/system/block/top nodes block", t("configure 'top nodes' block"), "statistics_admin", 5); } if (user_access("access content")) { @@ -229,9 +226,6 @@ function statistics_help($section = "admin/help#statistics") { case 'admin/statistics/top nodes page': $output = t("The statistics module creates a user page that can display summaries of the day's top viewed nodes, the all time top nodes and the last nodes viewed. Each of these summaries can be enabled or disabled individually, and the number of nodes displayed for each can be configured with a drop down menu."); break; - case 'admin/system/block/top nodes block': - $output = t("The statistics module exports a block that can display the top viewed nodes of the day, the all time top viewed nodes and the last nodes viewed. Each of these links can be enabled or disabled individually, and the number of nodes displayed for each can be configured with a drop down menu. If you disable all sections of this block, it will not appear."); - break; } return $output; } @@ -266,10 +260,6 @@ function statistics_admin() { /* configuration admin pages */ if (user_access("administer statistics module")) { switch (stripslashes($op)) { - case t("Submit \"top nodes\" block changes"): - statistics_save_topnodes_block($edit); - $output .= status(t("saved 'top nodes' block changes.")); - break; case t("Submit \"top nodes\" page changes"): statistics_save_userconfig($edit); $output .= status(t("saved 'top nodes' page changes.")); @@ -285,19 +275,6 @@ function statistics_admin() { "statistics_userpage_last_cnt" => variable_get("statistics_userpage_last_cnt", 0) )); break; - case "block": - if (arg(3) == "top nodes block") { - $output .= statistics_config_topnodes_block(array( - "statistics_block_top_title" => variable_get("statistics_block_top_title", "Top nodes"), - "statistics_block_top_day_head" => variable_get("statistics_block_top_day_head", "<b>Todays top:</b>"), - "statistics_block_top_day_num" => variable_get("statistics_block_top_day_num", 0), - "statistics_block_top_all_head" => variable_get("statistics_block_top_all_head", "<b>All time top:</b>"), - "statistics_block_top_all_num" => variable_get("statistics_block_top_all_num", 0), - "statistics_block_top_last_head" => variable_get("statistics_block_top_last_head" ,"<b>Last:</b>"), - "statistics_block_top_last_num" => variable_get("statistics_block_top_last_num", 0) - )); - } - break; default: $output .= statistics_admin_topnodes(); } @@ -475,34 +452,6 @@ function statistics_admin_displaylog() { } -/* Displays the block configuration administration form */ -function statistics_config_topnodes_block($edit) { - - $form = form_textfield(t("Block name"), "statistics_block_top_title", $edit["statistics_block_top_title"], 20, 40, t("This module generates a block with top nodes. You may assign a name for this block.")); - - $form .= "<hr />"; - - $form .= form_textfield(t("Today's top nodes title"), "statistics_block_top_day_head", $edit["statistics_block_top_day_head"], 20, 40, t("Specify a name for the \"day's top\" section of the block generated by this module. HTML tags permitted.")); - $form .= form_select(t("Number of day's top views to display"), "statistics_block_top_day_num", $edit["statistics_block_top_day_num"], array("0" => t("Disabled"), "1" => "1", "2" => "2", "3" => "3", "4" => "4", "5" => "5", "6" => "6", "7" => "7", "8" => "8", "9" => "9", "10" => "10", "15" => "15", "20" => "20", "25" => "25", "30" => "30", "40" => "40"), t("Set how many \"today's top\" nodes to display on the block generated by this module.")); - - $form .= "<hr />"; - - $form .= form_textfield(t("All time top nodes title"), "statistics_block_top_all_head", $edit["statistics_block_top_all_head"], 20, 40, t("Specify a name for the \"all time top\" section of the block generated by this module. HTML tags permitted.")); - $form .= form_select(t("Number of all time views to display"), "statistics_block_top_all_num", $edit["statistics_block_top_all_num"], array("0" => t("Disabled"), "1" => "1", "2" => "2", "3" => "3", "4" => "4", "5" => "5", "6" => "6", "7" => "7", "8" => "8", "9" => "9", "10" => "10", "15" => "15", "20" => "20", "25" => "25", "30" => "30", "40" => "40"), t("Set how many \"all time top\" nodes to display on the block generated by this module.")); - - $form .= "<hr />"; - - $form .= form_textfield(t("Most recent views heading"), "statistics_block_top_last_head", $edit["statistics_block_top_last_head"], 20, 40, t("Specify a name for the \"last views\" section of the block generated by this module. HTML tags permitted.")); - $form .= form_select(t("Number of most recent views to display"), "statistics_block_top_last_num", $edit["statistics_block_top_last_num"], array("0" => t("Disabled"), "1" => "1", "2" => "2", "3" => "3", "4" => "4", "5" => "5", "6" => "6", "7" => "7", "8" => "8", "9" => "9", "10" => "10", "15" => "15", "20" => "20", "25" => "25", "30" => "30", "40" => "40"), t("Set how many \"last viewed\" nodes to display on the block generated by this module.")); - - $form .= "<hr />"; - - $form .= form_submit(t("Submit \"top nodes\" block changes")); - - return form($form); -} - - /* Displays the user page configuration administration form */ function statistics_admin_userpage_config($edit) { @@ -537,19 +486,11 @@ function statistics_settings() { $output .= form_radios(t("Enable node view counters"), "statistics_enable_node_counter", variable_get("statistics_enable_node_counter", 0), array("1" => t("Enabled"), "0" => t("Disabled")), t("Increment node view counter each time a node is viewed.")); $output .= form_radios(t("Display node view counters"), "statistics_display_counter", variable_get("statistics_display_counter", ""), array("1" => t("Enabled"), "0" => t("Disabled")), t("Display how many times each node has been viewed. User must have the 'access statistics' permissions.")); - return $output; -} + $output .= form_select(t("Number of day's top views to display"), "statistics_block_top_day_num", $edit["statistics_block_top_day_num"], array("0" => t("Disabled"), "1" => "1", "2" => "2", "3" => "3", "4" => "4", "5" => "5", "6" => "6", "7" => "7", "8" => "8", "9" => "9", "10" => "10", "15" => "15", "20" => "20", "25" => "25", "30" => "30", "40" => "40"), t("Affects \"Top nodes\" block. How many nodes to display in \"day's\" list.")); + $output .= form_select(t("Number of all time views to display"), "statistics_block_top_all_num", $edit["statistics_block_top_all_num"], array("0" => t("Disabled"), "1" => "1", "2" => "2", "3" => "3", "4" => "4", "5" => "5", "6" => "6", "7" => "7", "8" => "8", "9" => "9", "10" => "10", "15" => "15", "20" => "20", "25" => "25", "30" => "30", "40" => "40"), t("Affects \"Top nodes\" block. How many nodes to display in \"all time\" list.")); + $output .= form_select(t("Number of most recent views to display"), "statistics_block_top_last_num", $edit["statistics_block_top_last_num"], array("0" => t("Disabled"), "1" => "1", "2" => "2", "3" => "3", "4" => "4", "5" => "5", "6" => "6", "7" => "7", "8" => "8", "9" => "9", "10" => "10", "15" => "15", "20" => "20", "25" => "25", "30" => "30", "40" => "40"), t("Affects \"Top nodes\" block. How many nodes to display in \"recently viewed\" list.")); - -/* Saves the values entered in the "blockconfig" administration form */ -function statistics_save_topnodes_block($edit) { - variable_set("statistics_block_top_title", $edit["statistics_block_top_title"]); - variable_set("statistics_block_top_day_head", $edit["statistics_block_top_day_head"]); - variable_set("statistics_block_top_day_num", $edit["statistics_block_top_day_num"]); - variable_set("statistics_block_top_all_head", $edit["statistics_block_top_all_head"]); - variable_set("statistics_block_top_all_num", $edit["statistics_block_top_all_num"]); - variable_set("statistics_block_top_last_head", $edit["statistics_block_top_last_head"]); - variable_set("statistics_block_top_last_num", $edit["statistics_block_top_last_num"]); + return $output; } @@ -595,30 +536,6 @@ function statistics_cron() { } -/* Displays the "Top nodes" block */ -function statistics_display_topnodes_block() { - - $content = array(); - - $daytop = variable_get("statistics_block_top_day_num", ""); - if ($daytop) { - $content[] = node_title_list(statistics_title_list("daycount", $daytop), variable_get("statistics_block_top_day_head", "")); - } - - $alltimetop = variable_get("statistics_block_top_all_num", ""); - if ($alltimetop) { - $content[] = node_title_list(statistics_title_list("totalcount", $alltimetop), variable_get("statistics_block_top_all_head", "")); - } - - $lasttop = variable_get("statistics_block_top_last_num", ""); - if ($lasttop) { - $content[] = node_title_list(statistics_title_list("timestamp", $lasttop), variable_get("statistics_block_top_last_head", "")); - } - - $output = implode($content, "<br />"); - - return $output; -} /* Display linked title based on field name */ @@ -652,8 +569,26 @@ function statistics_block($op = "list", $delta = 0) { else if (user_access("access content")) { switch ($delta) { case 0: + $content = array(); + + $daytop = variable_get("statistics_block_top_day_num", ""); + if ($daytop) { + $content[] = node_title_list(statistics_title_list("daycount", $daytop), variable_get("statistics_block_top_day_head", "")); + } + + $alltimetop = variable_get("statistics_block_top_all_num", ""); + if ($alltimetop) { + $content[] = node_title_list(statistics_title_list("totalcount", $alltimetop), variable_get("statistics_block_top_all_head", "")); + } + + $lasttop = variable_get("statistics_block_top_last_num", ""); + if ($lasttop) { + $content[] = node_title_list(statistics_title_list("timestamp", $lasttop), variable_get("statistics_block_top_last_head", "")); + } + $output = implode($content, "<br />"); + $block["subject"] = variable_get("statistics_block_top_title", t("Popular content")); - $block["content"] = statistics_display_topnodes_block(); + $block["content"] = $output; break; } |