From 253d4b48ec708eb42033862dc15c8576f44a48ed Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Wed, 1 Oct 2014 15:32:05 +0200 Subject: more PHPDocs, unused var, small bit code reformatting --- lib/plugins/popularity/helper.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'lib/plugins/popularity/helper.php') diff --git a/lib/plugins/popularity/helper.php b/lib/plugins/popularity/helper.php index eacde06d0..b4fb33b90 100644 --- a/lib/plugins/popularity/helper.php +++ b/lib/plugins/popularity/helper.php @@ -74,6 +74,7 @@ class helper_plugin_popularity extends Dokuwiki_Plugin { /** * Check if autosubmit is enabled + * * @return boolean TRUE if we should send data once a month, FALSE otherwise */ function isAutoSubmitEnabled(){ @@ -82,6 +83,7 @@ class helper_plugin_popularity extends Dokuwiki_Plugin { /** * Send the data, to the submit url + * * @param string $data The popularity data * @return string An empty string if everything worked fine, a string describing the error otherwise */ @@ -97,6 +99,8 @@ class helper_plugin_popularity extends Dokuwiki_Plugin { /** * Compute the last time the data was sent. If it has never been sent, we return 0. + * + * @return int */ function lastSentTime(){ $manualSubmission = @filemtime($this->popularityLastSubmitFile); @@ -107,6 +111,7 @@ class helper_plugin_popularity extends Dokuwiki_Plugin { /** * Gather all information + * * @return string The popularity data as a string */ function gatherAsString(){ @@ -124,6 +129,7 @@ class helper_plugin_popularity extends Dokuwiki_Plugin { /** * Gather all information + * * @return array The popularity data as an array */ function _gather(){ @@ -288,17 +294,24 @@ class helper_plugin_popularity extends Dokuwiki_Plugin { * * @author * @link http://de3.php.net/manual/en/ini.core.php#79564 + * + * @param string $v + * @return int|string */ function _to_byte($v){ $l = substr($v, -1); $ret = substr($v, 0, -1); switch(strtoupper($l)){ + /** @noinspection PhpMissingBreakStatementInspection */ case 'P': $ret *= 1024; + /** @noinspection PhpMissingBreakStatementInspection */ case 'T': $ret *= 1024; + /** @noinspection PhpMissingBreakStatementInspection */ case 'G': $ret *= 1024; + /** @noinspection PhpMissingBreakStatementInspection */ case 'M': $ret *= 1024; case 'K': -- cgit v1.2.3 From 79e79377626799a77c11aa7849cb9c64305590c8 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Wed, 7 Jan 2015 10:47:45 +0100 Subject: Remove error supression for file_exists() In an older version of PHP a file_exists() call would issue a warning when the file did not exist. This was fixed in later PHP releases. Since we require PHP 5.3 now, there's no need to supress any error here anymore. This might even give a minor performance boost. --- lib/plugins/popularity/helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/plugins/popularity/helper.php') diff --git a/lib/plugins/popularity/helper.php b/lib/plugins/popularity/helper.php index b4fb33b90..8673fb5af 100644 --- a/lib/plugins/popularity/helper.php +++ b/lib/plugins/popularity/helper.php @@ -78,7 +78,7 @@ class helper_plugin_popularity extends Dokuwiki_Plugin { * @return boolean TRUE if we should send data once a month, FALSE otherwise */ function isAutoSubmitEnabled(){ - return @file_exists($this->autosubmitFile); + return file_exists($this->autosubmitFile); } /** -- cgit v1.2.3 From 26e22ab837dcabe137a0912fcd2f96d0c35f48c8 Mon Sep 17 00:00:00 2001 From: Christopher Smith Date: Fri, 15 May 2015 19:03:34 +0200 Subject: Changes for PHP 7 Compatibility - replace PHP4 style class constructor function names (based on class name) with php 5 __construct() Also remove some '&' reference operators used with objects And add some object type hints --- lib/plugins/popularity/helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/plugins/popularity/helper.php') diff --git a/lib/plugins/popularity/helper.php b/lib/plugins/popularity/helper.php index 8673fb5af..e99f6a60c 100644 --- a/lib/plugins/popularity/helper.php +++ b/lib/plugins/popularity/helper.php @@ -30,7 +30,7 @@ class helper_plugin_popularity extends Dokuwiki_Plugin { var $popularityLastSubmitFile; - function helper_plugin_popularity(){ + function __construct(){ global $conf; $this->autosubmitFile = $conf['cachedir'].'/autosubmit.txt'; $this->autosubmitErrorFile = $conf['cachedir'].'/autosubmitError.txt'; -- cgit v1.2.3 From 5875e534bcbccf90fe3767fc77d8ea2a76aad9bd Mon Sep 17 00:00:00 2001 From: Guillaume Turri Date: Fri, 15 May 2015 15:49:11 +0200 Subject: 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'); } --- lib/plugins/popularity/helper.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'lib/plugins/popularity/helper.php') 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 * -- cgit v1.2.3