-
Notifications
You must be signed in to change notification settings - Fork 0
/
islandora_usage_stats_charts.module
134 lines (129 loc) · 5.99 KB
/
islandora_usage_stats_charts.module
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<?php
/**
* @file
* The main Islandora Usage Stats Charts module file.
*/
// Includes blocks.
require_once dirname(__FILE__) . '/includes/blocks.inc';
/**
* Implements hook_menu().
*/
function islandora_usage_stats_charts_menu() {
$items['admin/islandora/tools/islandora_usage_stats_charts'] = array(
'title' => 'Islandora Usage Stats Charts',
'description' => 'Configure the Islandora Usage Stats Charts module.',
'page callback' => 'drupal_get_form',
'page arguments' => array('islandora_usage_stats_charts_admin_settings'),
'access arguments' => array('administer site configuration'),
'type' => MENU_NORMAL_ITEM,
);
return $items;
}
/**
* Admin form definition.
*/
function islandora_usage_stats_charts_admin_settings() {
module_load_include('inc', 'islandora_usage_stats_charts', 'includes/utilities');
$form = array();
$form['islandora_usage_stats_charts_javascript_url'] = array(
'#type' => 'textfield',
'#size' => '100',
'#title' => t('Chart.js library URL'),
'#default_value' => variable_get('islandora_usage_stats_charts_javascript_url', 'https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.2/Chart.bundle.js'),
);
$form['islandora_usage_stats_charts_views_color'] = array(
'#type' => 'textfield',
'#size' => '10',
'#title' => t('Color of "views" bar in chart'),
'#default_value' => variable_get('islandora_usage_stats_charts_views_color', '#002db3'),
'#description' => t('You can use hexadecimal, RGB, or HSL color values.'),
);
$form['islandora_usage_stats_charts_downloads_color'] = array(
'#type' => 'textfield',
'#size' => '10',
'#title' => t('Color of "downloads" bar in chart'),
'#default_value' => variable_get('islandora_usage_stats_charts_downloads_color', '#99b3ff'),
'#description' => t('You can use hexadecimal, RGB, or HSL color values.'),
);
$form['islandora_usage_stats_charts_max_chart_width'] = array(
'#type' => 'textfield',
'#size' => '10',
'#title' => t('Maximum width of chart, with units'),
'#default_value' => variable_get('islandora_usage_stats_charts_max_chart_width', '50em'),
'#description' => t('E.g. 50em, 400px. Leave blank to allow the chart to fill the parent div.'),
);
$form['islandora_usage_stats_charts_limit_chart_height'] = array(
'#type' => 'checkbox',
'#title' => t('Limit chart height to its width'),
'#default_value' => variable_get('islandora_usage_stats_charts_limit_chart_height', 1),
'#description' => t("Wide variations in monthly usage stats can result in charts that have a very high vertical dimension. Checking this option will ensure that the chart's height does not exceed its width."),
);
$form['islandora_usage_stats_charts_collapsed'] = array(
'#type' => 'checkbox',
'#title' => t('Collapse chart blocks by default'),
'#default_value' => variable_get('islandora_usage_stats_charts_collapsed', 1),
'#description' => t("Users can still toggle the collapse."),
);
if (module_exists('islandora_usage_stats_csv')) {
$form['islandora_usage_stats_charts_show_csv_download_link'] = array(
'#type' => 'checkbox',
'#title' => t('Show link to download stats CSV file'),
'#default_value' => variable_get('islandora_usage_stats_charts_show_csv_download_link', 1),
);
}
$form['islandora_usage_stats_charts_months_to_show'] = array(
'#type' => 'textfield',
'#size' => '10',
'#title' => t("Maximum number of months' data to show in chart"),
'#default_value' => variable_get('islandora_usage_stats_charts_months_to_show', '6'),
'#description' => t("If the number of months for which data is available is lower than this setting, the lower number of months is used. Stats are shown from the day of the first month corresponding to the day the user views the chart; for example, if this setting is '6' and the chart is viewed on July 10th, the first month's stats will start at February 10th."),
);
$form['islandora_usage_stats_charts_show_datastreams_downloads'] = array(
'#type' => 'checkbox',
'#title' => t('Show datastream download stats'),
'#default_value' => variable_get('islandora_usage_stats_charts_show_datastreams_downloads', 0),
);
if (module_exists('islandora_usage_stats_csv')) {
$other_setting_note = t("This setting should be the same as the 'Omit from datastream reports' setting used by Islandora Usage Stats CSV.");
}
else {
$other_setting_note = '';
}
$form['islandora_usage_stats_charts_dsids_to_skip'] = array(
'#type' => 'textfield',
'#size' => '100',
'#title' => t('Omit from downloads stats'),
'#default_value' => variable_get('islandora_usage_stats_charts_dsids_to_skip', 'RELS-EXT,RELS-INT,TECHMD,MODS,DC'),
'#description' => t("Comma-separated list of datastream IDs to exclude from 'downloads' usage stats. All other datastreams will be included. If left blank, all datastreams will be included. !other_setting_note", array('!other_setting_note' => $other_setting_note)),
);
$form['islandora_usage_stats_charts_cmodels'] = array(
'#title' => t("Allowed content models"),
'#type' => 'fieldset',
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$cmodels = islandora_usage_stats_charts_get_cmodels();
$form['islandora_usage_stats_charts_cmodels']['islandora_usage_stats_charts_allowed_cmodels'] = array(
'#type' => 'checkboxes',
'#options' => $cmodels,
'#default_value' => variable_get('islandora_usage_stats_charts_allowed_cmodels', array()),
'#description' => t("Block showing usage stats chart will only show up for objects with the selected content models."),
);
return system_settings_form($form);
}
/**
* Implements hook_theme().
*/
function islandora_usage_stats_charts_theme() {
return array(
'islandora_usage_stats_charts' => array(
'variables' => array(
'collapsed' => NULL,
'content' => NULL,
'csv_link' => NULL,
),
'path' => drupal_get_path('module', 'islandora_usage_stats_charts') . '/theme',
'template' => 'islandora_usage_stats_charts',
),
);
}