diff options
author | Guillaume Turri <guillaume.turri@gmail.com> | 2015-05-15 15:49:11 +0200 |
---|---|---|
committer | Guillaume Turri <guillaume.turri@gmail.com> | 2015-05-27 07:26:01 +0200 |
commit | 5875e534bcbccf90fe3767fc77d8ea2a76aad9bd (patch) | |
tree | 26e81fb5aeeb190c3c6c24267906731388c6f60a /lib/plugins/popularity/helper.php | |
parent | 05790a01307aa347e77502603791afd84d62aa8b (diff) | |
download | rpg-5875e534bcbccf90fe3767fc77d8ea2a76aad9bd.tar.gz rpg-5875e534bcbccf90fe3767fc77d8ea2a76aad9bd.tar.bz2 |
Plugins can send usage data
They just need to register to the PLUGIN_USAGE_DATA event, and then to add
either a simple string, or an array of key / value. For example:
function register(Doku_Event_Handler $controller) {
$controller->register_hook('PLUGIN_USAGE_DATA', 'AFTER', $this, 'usage_data');
}
function usage_data(&$event){
$event->data['my_plugin_name'] = 'my usage data';
//or: $event->data['my_plugin_name'] = array ('k1' => 'v1', 'k2' => 'v2');
}
Diffstat (limited to 'lib/plugins/popularity/helper.php')
-rw-r--r-- | lib/plugins/popularity/helper.php | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/plugins/popularity/helper.php b/lib/plugins/popularity/helper.php index 8673fb5af..55264010f 100644 --- a/lib/plugins/popularity/helper.php +++ b/lib/plugins/popularity/helper.php @@ -253,9 +253,26 @@ class helper_plugin_popularity extends Dokuwiki_Plugin { $data['php_exectime'] = $phptime; $data['php_extension'] = get_loaded_extensions(); + // plugin usage data + $this->_add_plugin_usage_data($data); + return $data; } + protected function _add_plugin_usage_data(&$data){ + $pluginsData = array(); + trigger_event('PLUGIN_POPULARITY_DATA_SETUP', $pluginsData); + foreach($pluginsData as $plugin => $d){ + if ( is_array($d) ) { + foreach($d as $key => $value){ + $data['plugin_' . $plugin . '_' . $key] = $value; + } + } else { + $data['plugin_' . $plugin] = $d; + } + } + } + /** * Callback to search and count the content of directories in DokuWiki * |