analytics_dashboard.module

  1. cis7 sites/all/modules/local_contrib/google_chart_tools/analytics_dashboard/analytics_dashboard.module
  2. icor7 sites/all/modules/local_contrib/google_chart_tools/analytics_dashboard/analytics_dashboard.module

Functions

Namesort descending Description
analytics_dashboard_analytics_dashboard Implements hook_analytics_dashboard().
analytics_dashboard_get_charts Fetch all available analytics_dashboard charts
analytics_dashboard_menu Implements hook_menu().
analytics_dashboard_page Page callback for report page.
analytics_dashboard_permission Implements hook_permission().
analytics_dashboard_theme Implements hook_theme().
theme_analytics_dashboard_form Theme wrapper for analytics_dashboard_form()
_charts_sort Utility function for usort in analytics_dashboard_get_charts();
_get_time_from_url Retrieve the time period or interval from the URL

File

sites/all/modules/local_contrib/google_chart_tools/analytics_dashboard/analytics_dashboard.module
View source
  1. <?php
  2. /**
  3. * Implements hook_menu().
  4. */
  5. function analytics_dashboard_menu() {
  6. $items = array();
  7. $items['admin/reports/analytics-dashboard'] = array(
  8. 'title' => 'Analytics',
  9. 'access arguments' => array('view analytics dashboard'),
  10. 'page callback' => 'analytics_dashboard_page',
  11. );
  12. // Settings page
  13. $items['admin/config/analytics-dashboard'] = array(
  14. 'title' => 'Analytics dashboard configuration',
  15. 'description' => 'Configure the Analytics dashboard page',
  16. 'page callback' => 'drupal_get_form',
  17. 'page arguments' => array('analytics_dashboard_admin_settings'),
  18. 'access arguments' => array('administer analytics dashboard'),
  19. 'type' => MENU_NORMAL_ITEM,
  20. 'file' => 'analytics_dashboard.admin.inc',
  21. );
  22. return $items;
  23. }
  24. /**
  25. * Implements hook_permission().
  26. */
  27. function analytics_dashboard_permission() {
  28. return array(
  29. 'administer analytics dashboard' => array(
  30. 'title' => t('Administer Analytics dashboard'),
  31. 'description' => t('Perform administration tasks for Analytics dashboard.'),
  32. ),
  33. 'view analytics dashboard' => array(
  34. 'title' => t('View Analytics Dashboard'),
  35. 'description' => t('View analytics dashboard.'),
  36. ),
  37. );
  38. }
  39. /**
  40. * Implements hook_theme().
  41. */
  42. function analytics_dashboard_theme($existing, $type, $theme, $path) {
  43. return array(
  44. 'analytics_dashboard_form' => array(
  45. 'render element' => 'form'
  46. )
  47. );
  48. }
  49. /**
  50. * Page callback for report page.
  51. */
  52. function analytics_dashboard_page() {
  53. module_load_include('inc', 'analytics_dashboard', 'analytics_dashboard.charts');
  54. module_load_include('inc', 'analytics_dashboard', 'analytics_dashboard.forms');
  55. $form = drupal_get_form('analytics_dashboard_form');
  56. $form = drupal_render($form);
  57. $charts = analytics_dashboard_get_charts();
  58. $visibles = variable_get('chart_visible', array());
  59. $ret = $form;
  60. $ret .= '<div id="charts">';
  61. foreach ($charts as $chart) {
  62. if (in_array($chart['id'], $visibles, TRUE)) {
  63. $ret .= $chart['markup'];
  64. }
  65. }
  66. $ret .= '</div>';
  67. return $ret;
  68. }
  69. /**
  70. * Retrieve the time period or interval from the URL
  71. */
  72. function _get_time_from_url() {
  73. // Get the option
  74. if (isset($_GET['option'])) {
  75. switch ($_GET['option']) {
  76. case 'custom':
  77. $from = strtotime($_GET['from']);
  78. $to = strtotime($_GET['to']);
  79. if (is_numeric($from) && is_numeric($to)) {
  80. // Move the 'to' date to 1 second before midnight
  81. return array($from, $to + 86399);
  82. }
  83. break;
  84. case 'period':
  85. $from = strtotime('-' . str_replace('_', ' ', filter_xss($_GET['period'])));
  86. if (is_numeric($from)) {
  87. return array($from, time());
  88. }
  89. }
  90. }
  91. else {
  92. return array(strtotime('-1 month'), time());
  93. }
  94. return FALSE;
  95. }
  96. /**
  97. * Fetch all available analytics_dashboard charts
  98. */
  99. function analytics_dashboard_get_charts() {
  100. $charts = module_invoke_all('analytics_dashboard');
  101. usort($charts, "_charts_sort");
  102. return $charts;
  103. }
  104. /**
  105. * Utility function for usort in analytics_dashboard_get_charts();
  106. */
  107. function _charts_sort($a, $b) {
  108. if ($a['weight'] == $b['weight']) {
  109. return 0;
  110. }
  111. return ($a['weight'] < $b['weight']) ? -1 : 1;
  112. }
  113. /**
  114. * Implements hook_analytics_dashboard().
  115. */
  116. function analytics_dashboard_analytics_dashboard() {
  117. module_load_include('inc', 'analytics_dashboard', 'analytics_dashboard.charts');
  118. return analytics_dashboard_charts();
  119. }
  120. /**
  121. * Theme wrapper for analytics_dashboard_form()
  122. */
  123. function theme_analytics_dashboard_form($variables) {
  124. $form = $variables['form'];
  125. $output = '';
  126. $output .= '<div id="analytics-dashboard-page">';
  127. $output .= '<div class="description">';
  128. $output .= t('Select a timeframe and click Update to see what\'s happening on your site during that time, as well as a total for all the activity during that timeframe.');
  129. $output .= '</div>';
  130. $output .= '<div class="analytics-dashboard-option-row">';
  131. $output .= drupal_render($form['option']['period']);
  132. $output .= '<span class="description">From:</span>';
  133. $output .= drupal_render($form['period']);
  134. $output .= '<span class="description">ago.</span>';
  135. $output .= '</div>';
  136. $output .= '<div class="analytics-dashboard-option-row">';
  137. $output .= drupal_render($form['option']['custom']);
  138. $output .= '<span class="description">From:</span>';
  139. $output .= drupal_render($form['custom_from']);
  140. $output .= '<span class="description">To:</span>';
  141. $output .= drupal_render($form['custom_to']);
  142. $output .= '<span class="description"><i>Format DD.MM.YYYY</i></span>';
  143. $output .= '</div>';
  144. $output .= drupal_render_children($form);
  145. $output .= '</div>';
  146. return $output;
  147. }
Error | ELMSLN API

Error

×

Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/elmsln_community/api.elmsln.org/includes/common.inc:2791) in drupal_send_headers() (line 1499 of /var/www/html/elmsln_community/api.elmsln.org/includes/bootstrap.inc).
  • Error: Call to undefined function apc_delete() in DrupalAPCCache->clear() (line 289 of /var/www/html/elmsln_community/api.elmsln.org/sites/all/modules/apc/drupal_apc_cache.inc).
The website encountered an unexpected error. Please try again later.