aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/lib/plugins/popularity
diff options
context:
space:
mode:
Diffstat (limited to 'lib/plugins/popularity')
-rw-r--r--lib/plugins/popularity/action.php19
-rw-r--r--lib/plugins/popularity/admin.php56
-rw-r--r--lib/plugins/popularity/helper.php43
3 files changed, 59 insertions, 59 deletions
diff --git a/lib/plugins/popularity/action.php b/lib/plugins/popularity/action.php
index fac610735..16b1a21cc 100644
--- a/lib/plugins/popularity/action.php
+++ b/lib/plugins/popularity/action.php
@@ -1,13 +1,16 @@
<?php
+
+use dokuwiki\Extension\ActionPlugin;
+use dokuwiki\Extension\EventHandler;
+use dokuwiki\Extension\Event;
+
/**
* Popularity Feedback Plugin
*
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
*/
-
-class action_plugin_popularity extends DokuWiki_Action_Plugin
+class action_plugin_popularity extends ActionPlugin
{
-
/**
* @var helper_plugin_popularity
*/
@@ -19,18 +22,18 @@ class action_plugin_popularity extends DokuWiki_Action_Plugin
}
/** @inheritdoc */
- public function register(Doku_Event_Handler $controller)
+ public function register(EventHandler $controller)
{
- $controller->register_hook('INDEXER_TASKS_RUN', 'AFTER', $this, 'autosubmit', array());
+ $controller->register_hook('INDEXER_TASKS_RUN', 'AFTER', $this, 'autosubmit', []);
}
/**
* Event handler
*
- * @param Doku_Event $event
+ * @param Event $event
* @param $param
*/
- public function autosubmit(Doku_Event &$event, $param)
+ public function autosubmit(Event $event, $param)
{
//Do we have to send the data now
if (!$this->helper->isAutosubmitEnabled() || $this->isTooEarlyToSubmit()) {
@@ -61,6 +64,6 @@ class action_plugin_popularity extends DokuWiki_Action_Plugin
protected function isTooEarlyToSubmit()
{
$lastSubmit = $this->helper->lastSentTime();
- return $lastSubmit + 24*60*60*30 > time();
+ return $lastSubmit + 24 * 60 * 60 * 30 > time();
}
}
diff --git a/lib/plugins/popularity/admin.php b/lib/plugins/popularity/admin.php
index 61d8cc3bf..f9adcf045 100644
--- a/lib/plugins/popularity/admin.php
+++ b/lib/plugins/popularity/admin.php
@@ -1,16 +1,18 @@
<?php
+
+use dokuwiki\Extension\AdminPlugin;
+
/**
* Popularity Feedback Plugin
*
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author Andreas Gohr <andi@splitbrain.org>
*/
-class admin_plugin_popularity extends DokuWiki_Admin_Plugin
+class admin_plugin_popularity extends AdminPlugin
{
-
/** @var helper_plugin_popularity */
protected $helper;
- protected $sentStatus = null;
+ protected $sentStatus;
/**
* admin_plugin_popularity constructor.
@@ -88,7 +90,6 @@ class admin_plugin_popularity extends DokuWiki_Admin_Plugin
if (! $INPUT->has('data')) {
echo $this->locale_xhtml('intro');
-
//If there was an error the last time we tried to autosubmit, warn the user
if ($this->helper->isAutoSubmitEnabled()) {
if (file_exists($this->helper->autosubmitErrorFile)) {
@@ -96,26 +97,21 @@ class admin_plugin_popularity extends DokuWiki_Admin_Plugin
echo io_readFile($this->helper->autosubmitErrorFile);
}
}
-
flush();
echo $this->buildForm('server');
-
//Print the last time the data was sent
$lastSent = $this->helper->lastSentTime();
if ($lastSent !== 0) {
echo $this->getLang('lastSent') . ' ' . datetime_h($lastSent);
}
+ } elseif ($this->sentStatus === '') {
+ //If we successfully send the data
+ echo $this->locale_xhtml('submitted');
} else {
- //If we just submitted the form
- if ($this->sentStatus === '') {
- //If we successfully sent the data
- echo $this->locale_xhtml('submitted');
- } else {
- //If we failed to submit the data, try directly with the browser
- echo $this->getLang('submissionFailed') . $this->sentStatus . '<br />';
- echo $this->getLang('submitDirectly');
- echo $this->buildForm('browser', $INPUT->str('data'));
- }
+ //If we failed to submit the data, try directly with the browser
+ echo $this->getLang('submissionFailed') . $this->sentStatus . '<br />';
+ echo $this->getLang('submitDirectly');
+ echo $this->buildForm('browser', $INPUT->str('data'));
}
}
@@ -133,25 +129,25 @@ class admin_plugin_popularity extends DokuWiki_Admin_Plugin
$data = $this->helper->gatherAsString();
}
- $form = '<form method="post" action="'. $url .'" accept-charset="utf-8">'
- .'<fieldset style="width: 60%;">'
- .'<textarea class="edit" rows="10" cols="80" readonly="readonly" name="data">'
- .$data
- .'</textarea><br />';
+ $form = '<form method="post" action="' . $url . '" accept-charset="utf-8">'
+ . '<fieldset style="width: 60%;">'
+ . '<textarea class="edit" rows="10" cols="80" readonly="readonly" name="data">'
+ . $data
+ . '</textarea><br />';
//If we submit via the server, we give the opportunity to suscribe to the autosubmission option
if ($submissionMode !== 'browser') {
$form .= '<label for="autosubmit">'
- .'<input type="checkbox" name="autosubmit" id="autosubmit" '
- .($this->helper->isAutosubmitEnabled() ? 'checked' : '' )
- .'/> ' . $this->getLang('autosubmit') .'<br />'
- .'</label>'
- .'<input type="hidden" name="do" value="admin" />'
- .'<input type="hidden" name="page" value="popularity" />';
+ . '<input type="checkbox" name="autosubmit" id="autosubmit" '
+ . ($this->helper->isAutosubmitEnabled() ? 'checked' : '' )
+ . '/> ' . $this->getLang('autosubmit') . '<br />'
+ . '</label>'
+ . '<input type="hidden" name="do" value="admin" />'
+ . '<input type="hidden" name="page" value="popularity" />';
}
- $form .= '<button type="submit">'.$this->getLang('submit').'</button>'
- .'</fieldset>'
- .'</form>';
+ $form .= '<button type="submit">' . $this->getLang('submit') . '</button>'
+ . '</fieldset>'
+ . '</form>';
return $form;
}
}
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;