aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/lib/plugins/popularity
diff options
context:
space:
mode:
Diffstat (limited to 'lib/plugins/popularity')
-rw-r--r--lib/plugins/popularity/action.php16
-rw-r--r--lib/plugins/popularity/admin.php22
-rw-r--r--lib/plugins/popularity/helper.php64
3 files changed, 40 insertions, 62 deletions
diff --git a/lib/plugins/popularity/action.php b/lib/plugins/popularity/action.php
index d5ec0f5c5..24f3c750f 100644
--- a/lib/plugins/popularity/action.php
+++ b/lib/plugins/popularity/action.php
@@ -13,20 +13,26 @@ class action_plugin_popularity extends Dokuwiki_Action_Plugin {
/**
* @var helper_plugin_popularity
*/
- var $helper;
+ protected $helper;
- function __construct(){
+ public function __construct(){
$this->helper = $this->loadHelper('popularity', false);
}
/**
* Register its handlers with the dokuwiki's event controller
*/
- function register(Doku_Event_Handler $controller) {
+ public function register(Doku_Event_Handler $controller) {
$controller->register_hook('INDEXER_TASKS_RUN', 'AFTER', $this, '_autosubmit', array());
}
- function _autosubmit(Doku_Event &$event, $param){
+ /**
+ * Event handler
+ *
+ * @param Doku_Event $event
+ * @param $param
+ */
+ public function _autosubmit(Doku_Event &$event, $param){
//Do we have to send the data now
if ( !$this->helper->isAutosubmitEnabled() || $this->_isTooEarlyToSubmit() ){
return;
@@ -53,7 +59,7 @@ class action_plugin_popularity extends Dokuwiki_Action_Plugin {
* Check if it's time to send autosubmit data
* (we should have check if autosubmit is enabled first)
*/
- function _isTooEarlyToSubmit(){
+ protected function _isTooEarlyToSubmit(){
$lastSubmit = $this->helper->lastSentTime();
return $lastSubmit + 24*60*60*30 > time();
}
diff --git a/lib/plugins/popularity/admin.php b/lib/plugins/popularity/admin.php
index c474238cc..763347167 100644
--- a/lib/plugins/popularity/admin.php
+++ b/lib/plugins/popularity/admin.php
@@ -10,31 +10,33 @@ class admin_plugin_popularity extends DokuWiki_Admin_Plugin {
/**
* @var helper_plugin_popularity
*/
- var $helper;
- var $sentStatus = null;
+ protected $helper;
+ protected $sentStatus = null;
- function __construct(){
+ public function __construct(){
$this->helper = $this->loadHelper('popularity', false);
}
/**
* return prompt for admin menu
+ * @param $language
+ * @return string
*/
- function getMenuText($language) {
+ public function getMenuText($language) {
return $this->getLang('name');
}
/**
* return sort order for position in admin menu
*/
- function getMenuSort() {
+ public function getMenuSort() {
return 2000;
}
/**
* Accessible for managers
*/
- function forAdminOnly() {
+ public function forAdminOnly() {
return false;
}
@@ -42,7 +44,7 @@ class admin_plugin_popularity extends DokuWiki_Admin_Plugin {
/**
* handle user request
*/
- function handle() {
+ public function handle() {
global $INPUT;
//Send the data
@@ -61,7 +63,7 @@ class admin_plugin_popularity extends DokuWiki_Admin_Plugin {
* Enable or disable autosubmit
* @param bool $enable If TRUE, it will enable autosubmit. Else, it will disable it.
*/
- function _enableAutosubmit( $enable ){
+ protected function _enableAutosubmit( $enable ){
if ( $enable ){
io_saveFile( $this->helper->autosubmitFile, ' ');
} else {
@@ -72,7 +74,7 @@ class admin_plugin_popularity extends DokuWiki_Admin_Plugin {
/**
* Output HTML form
*/
- function html() {
+ public function html() {
global $INPUT;
if ( ! $INPUT->has('data') ){
@@ -115,7 +117,7 @@ class admin_plugin_popularity extends DokuWiki_Admin_Plugin {
* @param string $data The popularity data, if it has already been computed. NULL otherwise.
* @return string The form, as an html string
*/
- function buildForm($submissionMode, $data = null){
+ protected function buildForm($submissionMode, $data = null){
$url = ($submissionMode === 'browser' ? $this->helper->submitUrl : script());
if ( is_null($data) ){
$data = $this->helper->gatherAsString();
diff --git a/lib/plugins/popularity/helper.php b/lib/plugins/popularity/helper.php
index b81ab7005..2545d18bc 100644
--- a/lib/plugins/popularity/helper.php
+++ b/lib/plugins/popularity/helper.php
@@ -9,28 +9,28 @@ class helper_plugin_popularity extends Dokuwiki_Plugin {
/**
* The url where the data should be sent
*/
- var $submitUrl = 'http://update.dokuwiki.org/popularity.php';
+ public $submitUrl = 'http://update.dokuwiki.org/popularity.php';
/**
* Name of the file which determine if the the autosubmit is enabled,
* and when it was submited for the last time
*/
- var $autosubmitFile;
+ public $autosubmitFile;
/**
* File where the last error which happened when we tried to autosubmit, will be log
*/
- var $autosubmitErrorFile;
+ public $autosubmitErrorFile;
/**
* Name of the file which determine when the popularity data was manually
* submitted for the last time
* (If this file doesn't exist, the data has never been sent)
*/
- var $popularityLastSubmitFile;
+ public $popularityLastSubmitFile;
- function __construct(){
+ public function __construct(){
global $conf;
$this->autosubmitFile = $conf['cachedir'].'/autosubmit.txt';
$this->autosubmitErrorFile = $conf['cachedir'].'/autosubmitError.txt';
@@ -38,46 +38,11 @@ class helper_plugin_popularity extends Dokuwiki_Plugin {
}
/**
- * Return methods of this helper
- *
- * @return array with methods description
- */
- function getMethods(){
- $result = array();
- $result[] = array(
- 'name' => 'isAutoSubmitEnabled',
- 'desc' => 'Check if autosubmit is enabled',
- 'params' => array(),
- 'return' => array('result' => 'bool')
- );
- $result[] = array(
- 'name' => 'sendData',
- 'desc' => 'Send the popularity data',
- 'params' => array('data' => 'string'),
- 'return' => array()
- );
- $result[] = array(
- 'name' => 'gatherAsString',
- 'desc' => 'Gather the popularity data',
- 'params' => array(),
- 'return' => array('data' => 'string')
- );
- $result[] = array(
- 'name' => 'lastSentTime',
- 'desc' => 'Compute the last time popularity data was sent',
- 'params' => array(),
- 'return' => array('data' => 'int')
- );
- return $result;
-
- }
-
- /**
* Check if autosubmit is enabled
*
* @return boolean TRUE if we should send data once a month, FALSE otherwise
*/
- function isAutoSubmitEnabled(){
+ public function isAutoSubmitEnabled(){
return file_exists($this->autosubmitFile);
}
@@ -87,7 +52,7 @@ class helper_plugin_popularity extends Dokuwiki_Plugin {
* @param string $data The popularity data
* @return string An empty string if everything worked fine, a string describing the error otherwise
*/
- function sendData($data){
+ public function sendData($data){
$error = '';
$httpClient = new DokuHTTPClient();
$status = $httpClient->sendRequest($this->submitUrl, array('data' => $data), 'POST');
@@ -102,7 +67,7 @@ class helper_plugin_popularity extends Dokuwiki_Plugin {
*
* @return int
*/
- function lastSentTime(){
+ public function lastSentTime(){
$manualSubmission = @filemtime($this->popularityLastSubmitFile);
$autoSubmission = @filemtime($this->autosubmitFile);
@@ -114,7 +79,7 @@ class helper_plugin_popularity extends Dokuwiki_Plugin {
*
* @return string The popularity data as a string
*/
- function gatherAsString(){
+ public function gatherAsString(){
$data = $this->_gather();
$string = '';
foreach($data as $key => $val){
@@ -132,7 +97,7 @@ class helper_plugin_popularity extends Dokuwiki_Plugin {
*
* @return array The popularity data as an array
*/
- function _gather(){
+ protected function _gather(){
global $conf;
/** @var $auth DokuWiki_Auth_Plugin */
global $auth;
@@ -259,6 +224,11 @@ class helper_plugin_popularity extends Dokuwiki_Plugin {
return $data;
}
+ /**
+ * Triggers event to let plugins add their own data
+ *
+ * @param $data
+ */
protected function _add_plugin_usage_data(&$data){
$pluginsData = array();
trigger_event('PLUGIN_POPULARITY_DATA_SETUP', $pluginsData);
@@ -284,7 +254,7 @@ class helper_plugin_popularity extends Dokuwiki_Plugin {
* @param array $opts option array as given to search()
* @return bool
*/
- function _search_count(&$data,$base,$file,$type,$lvl,$opts){
+ protected function _search_count(&$data,$base,$file,$type,$lvl,$opts){
// traverse
if($type == 'd'){
if($data['dir_nest'] < $lvl) $data['dir_nest'] = $lvl;
@@ -315,7 +285,7 @@ class helper_plugin_popularity extends Dokuwiki_Plugin {
* @param string $v
* @return int|string
*/
- function _to_byte($v){
+ protected function _to_byte($v){
$l = substr($v, -1);
$ret = substr($v, 0, -1);
switch(strtoupper($l)){