aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/lib/plugins/popularity/helper.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/plugins/popularity/helper.php')
-rw-r--r--lib/plugins/popularity/helper.php43
1 files changed, 22 insertions, 21 deletions
diff --git a/lib/plugins/popularity/helper.php b/lib/plugins/popularity/helper.php
index 506126a35..b3393d24b 100644
--- a/lib/plugins/popularity/helper.php
+++ b/lib/plugins/popularity/helper.php
@@ -1,5 +1,6 @@
<?php
+use dokuwiki\Extension\AuthPlugin;
use dokuwiki\HTTP\DokuHTTPClient;
use dokuwiki\Extension\Event;
@@ -39,9 +40,9 @@ class helper_plugin_popularity extends Dokuwiki_Plugin
public function __construct()
{
global $conf;
- $this->autosubmitFile = $conf['cachedir'].'/autosubmit.txt';
- $this->autosubmitErrorFile = $conf['cachedir'].'/autosubmitError.txt';
- $this->popularityLastSubmitFile = $conf['cachedir'].'/lastSubmitTime.txt';
+ $this->autosubmitFile = $conf['cachedir'] . '/autosubmit.txt';
+ $this->autosubmitErrorFile = $conf['cachedir'] . '/autosubmitError.txt';
+ $this->popularityLastSubmitFile = $conf['cachedir'] . '/lastSubmitTime.txt';
}
/**
@@ -64,7 +65,7 @@ class helper_plugin_popularity extends Dokuwiki_Plugin
{
$error = '';
$httpClient = new DokuHTTPClient();
- $status = $httpClient->sendRequest($this->submitUrl, array('data' => $data), 'POST');
+ $status = $httpClient->sendRequest($this->submitUrl, ['data' => $data], 'POST');
if (! $status) {
$error = $httpClient->error;
}
@@ -95,9 +96,9 @@ class helper_plugin_popularity extends Dokuwiki_Plugin
$string = '';
foreach ($data as $key => $val) {
if (is_array($val)) foreach ($val as $v) {
- $string .= hsc($key)."\t".hsc($v)."\n";
+ $string .= hsc($key) . "\t" . hsc($v) . "\n";
} else {
- $string .= hsc($key)."\t".hsc($val)."\n";
+ $string .= hsc($key) . "\t" . hsc($val) . "\n";
}
}
return $string;
@@ -132,7 +133,7 @@ class helper_plugin_popularity extends Dokuwiki_Plugin
global $conf;
/** @var $auth DokuWiki_Auth_Plugin */
global $auth;
- $data = array();
+ $data = [];
$phptime = ini_get('max_execution_time');
@set_time_limit(0);
$pluginInfo = $this->getInfo();
@@ -152,7 +153,7 @@ class helper_plugin_popularity extends Dokuwiki_Plugin
// number and size of pages
$list = $this->initEmptySearchList();
- search($list, $conf['datadir'], array($this, 'searchCountCallback'), array('all'=>false), '');
+ search($list, $conf['datadir'], [$this, 'searchCountCallback'], ['all' => false], '');
$data['page_count'] = $list['file_count'];
$data['page_size'] = $list['file_size'];
$data['page_biggest'] = $list['file_max'];
@@ -165,7 +166,7 @@ class helper_plugin_popularity extends Dokuwiki_Plugin
// number and size of media
$list = $this->initEmptySearchList();
- search($list, $conf['mediadir'], array($this, 'searchCountCallback'), array('all'=>true));
+ search($list, $conf['mediadir'], [$this, 'searchCountCallback'], ['all' => true]);
$data['media_count'] = $list['file_count'];
$data['media_size'] = $list['file_size'];
$data['media_biggest'] = $list['file_max'];
@@ -177,7 +178,7 @@ class helper_plugin_popularity extends Dokuwiki_Plugin
// number and size of cache
$list = $this->initEmptySearchList();
- search($list, $conf['cachedir'], array($this, 'searchCountCallback'), array('all'=>true));
+ search($list, $conf['cachedir'], [$this, 'searchCountCallback'], ['all' => true]);
$data['cache_count'] = $list['file_count'];
$data['cache_size'] = $list['file_size'];
$data['cache_biggest'] = $list['file_max'];
@@ -187,7 +188,7 @@ class helper_plugin_popularity extends Dokuwiki_Plugin
// number and size of index
$list = $this->initEmptySearchList();
- search($list, $conf['indexdir'], array($this, 'searchCountCallback'), array('all'=>true));
+ search($list, $conf['indexdir'], [$this, 'searchCountCallback'], ['all' => true]);
$data['index_count'] = $list['file_count'];
$data['index_size'] = $list['file_size'];
$data['index_biggest'] = $list['file_max'];
@@ -197,7 +198,7 @@ class helper_plugin_popularity extends Dokuwiki_Plugin
// number and size of meta
$list = $this->initEmptySearchList();
- search($list, $conf['metadir'], array($this, 'searchCountCallback'), array('all'=>true));
+ search($list, $conf['metadir'], [$this, 'searchCountCallback'], ['all' => true]);
$data['meta_count'] = $list['file_count'];
$data['meta_size'] = $list['file_size'];
$data['meta_biggest'] = $list['file_max'];
@@ -207,7 +208,7 @@ class helper_plugin_popularity extends Dokuwiki_Plugin
// number and size of attic
$list = $this->initEmptySearchList();
- search($list, $conf['olddir'], array($this, 'searchCountCallback'), array('all'=>true));
+ search($list, $conf['olddir'], [$this, 'searchCountCallback'], ['all' => true]);
$data['attic_count'] = $list['file_count'];
$data['attic_size'] = $list['file_size'];
$data['attic_biggest'] = $list['file_max'];
@@ -217,18 +218,18 @@ class helper_plugin_popularity extends Dokuwiki_Plugin
unset($list);
// user count
- if ($auth && $auth->canDo('getUserCount')) {
+ if ($auth instanceof AuthPlugin && $auth->canDo('getUserCount')) {
$data['user_count'] = $auth->getUserCount();
}
// calculate edits per day
- $list = (array) @file($conf['metadir'].'/_dokuwiki.changes');
+ $list = (array) @file($conf['metadir'] . '/_dokuwiki.changes');
$count = count($list);
if ($count > 2) {
$first = (int) substr(array_shift($list), 0, 10);
$last = (int) substr(array_pop($list), 0, 10);
- $dur = ($last - $first)/(60*60*24); // number of days in the changelog
- $data['edits_per_day'] = $count/$dur;
+ $dur = ($last - $first) / (60 * 60 * 24); // number of days in the changelog
+ $data['edits_per_day'] = $count / $dur;
}
unset($list);
@@ -244,7 +245,7 @@ class helper_plugin_popularity extends Dokuwiki_Plugin
$data['os'] = PHP_OS;
$data['webserver'] = $_SERVER['SERVER_SOFTWARE'];
$data['php_version'] = phpversion();
- $data['php_sapi'] = php_sapi_name();
+ $data['php_sapi'] = PHP_SAPI;
$data['php_memory'] = php_to_byte(ini_get('memory_limit'));
$data['php_exectime'] = $phptime;
$data['php_extension'] = get_loaded_extensions();
@@ -262,7 +263,7 @@ class helper_plugin_popularity extends Dokuwiki_Plugin
*/
protected function addPluginUsageData(&$data)
{
- $pluginsData = array();
+ $pluginsData = [];
Event::createAndTrigger('PLUGIN_POPULARITY_DATA_SETUP', $pluginsData);
foreach ($pluginsData as $plugin => $d) {
if (is_array($d)) {
@@ -297,8 +298,8 @@ class helper_plugin_popularity extends Dokuwiki_Plugin
//only search txt files if 'all' option not set
if ($opts['all'] || substr($file, -4) == '.txt') {
- $size = filesize($base.'/'.$file);
- $date = filemtime($base.'/'.$file);
+ $size = filesize($base . '/' . $file);
+ $date = filemtime($base . '/' . $file);
$data['file_count']++;
$data['file_size'] += $size;
if (!isset($data['file_min']) || $data['file_min'] > $size) $data['file_min'] = $size;