Upgrade to 2013-11-18

This commit is contained in:
Hannes Magnusson
2013-11-27 14:14:38 -08:00
parent 3c0160f699
commit cdff732dcc
567 changed files with 79658 additions and 30177 deletions

View File

@ -9,6 +9,10 @@ require_once(DOKU_PLUGIN.'action.php');
require_once(DOKU_PLUGIN.'popularity/admin.php');
class action_plugin_popularity extends Dokuwiki_Action_Plugin {
/**
* @var helper_plugin_popularity
*/
var $helper;
function action_plugin_popularity(){
@ -18,11 +22,11 @@ class action_plugin_popularity extends Dokuwiki_Action_Plugin {
/**
* Register its handlers with the dokuwiki's event controller
*/
function register(&$controller) {
function register(Doku_Event_Handler $controller) {
$controller->register_hook('INDEXER_TASKS_RUN', 'AFTER', $this, '_autosubmit', array());
}
function _autosubmit(&$event, $param){
function _autosubmit(Doku_Event &$event, $param){
//Do we have to send the data now
if ( !$this->helper->isAutosubmitEnabled() || $this->_isTooEarlyToSubmit() ){
return;
@ -31,7 +35,6 @@ class action_plugin_popularity extends Dokuwiki_Action_Plugin {
//Actually send it
$status = $this->helper->sendData( $this->helper->gatherAsString() );
if ( $status !== '' ){
//If an error occured, log it
io_saveFile( $this->helper->autosubmitErrorFile, $status );

View File

@ -13,15 +13,15 @@ if(!defined('DOKU_INC')) die();
* need to inherit from this class
*/
class admin_plugin_popularity extends DokuWiki_Admin_Plugin {
var $version;
/**
* @var helper_plugin_popularity
*/
var $helper;
var $sentStatus = null;
function admin_plugin_popularity(){
$this->helper = $this->loadHelper('popularity', false);
$pluginInfo = $this->getInfo();
$this->version = $pluginInfo['date'];
}
/**
@ -50,15 +50,17 @@ class admin_plugin_popularity extends DokuWiki_Admin_Plugin {
* handle user request
*/
function handle() {
global $INPUT;
//Send the data
if ( isset($_REQUEST['data']) ){
$this->sentStatus = $this->helper->sendData( $_REQUEST['data'] );
if ( $INPUT->has('data') ){
$this->sentStatus = $this->helper->sendData( $INPUT->str('data') );
if ( $this->sentStatus === '' ){
//Update the last time we sent the data
touch ( $this->helper->popularityLastSubmitFile );
}
//Deal with the autosubmit option
$this->_enableAutosubmit( isset($_REQUEST['autosubmit']) );
$this->_enableAutosubmit( $INPUT->has('autosubmit') );
}
}
@ -78,7 +80,9 @@ class admin_plugin_popularity extends DokuWiki_Admin_Plugin {
* Output HTML form
*/
function html() {
if ( ! isset($_REQUEST['data']) ){
global $INPUT;
if ( ! $INPUT->has('data') ){
echo $this->locale_xhtml('intro');
//If there was an error the last time we tried to autosubmit, warn the user
@ -106,7 +110,7 @@ class admin_plugin_popularity extends DokuWiki_Admin_Plugin {
//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', $_REQUEST['data']);
echo $this->buildForm('browser', $INPUT->str('data'));
}
}
}
@ -114,9 +118,9 @@ class admin_plugin_popularity extends DokuWiki_Admin_Plugin {
/**
* Build the form which presents the data to be sent
* @param string $submit How is the data supposed to be sent? (may be: 'browser' or 'server')
* @param string $submissionMode How is the data supposed to be sent? (may be: 'browser' or 'server')
* @param string $data The popularity data, if it has already been computed. NULL otherwise.
* @return The form, as an html string
* @return string The form, as an html string
*/
function buildForm($submissionMode, $data = null){
$url = ($submissionMode === 'browser' ? $this->helper->submitUrl : script());
@ -135,7 +139,7 @@ class admin_plugin_popularity extends DokuWiki_Admin_Plugin {
$form .= '<label for="autosubmit">'
.'<input type="checkbox" name="autosubmit" id="autosubmit" '
.($this->helper->isAutosubmitEnabled() ? 'checked' : '' )
.'/>' . $this->getLang('autosubmit') .'<br />'
.'/> ' . $this->getLang('autosubmit') .'<br />'
.'</label>'
.'<input type="hidden" name="do" value="admin" />'
.'<input type="hidden" name="page" value="popularity" />';

View File

@ -37,6 +37,11 @@ class helper_plugin_popularity extends Dokuwiki_Plugin {
$this->popularityLastSubmitFile = $conf['cachedir'].'/lastSubmitTime.txt';
}
/**
* Return methods of this helper
*
* @return array with methods description
*/
function getMethods(){
$result = array();
$result[] = array(
@ -69,7 +74,7 @@ class helper_plugin_popularity extends Dokuwiki_Plugin {
/**
* Check if autosubmit is enabled
* @return TRUE if we should send data once a month, FALSE otherwise
* @return boolean TRUE if we should send data once a month, FALSE otherwise
*/
function isAutoSubmitEnabled(){
return @file_exists($this->autosubmitFile);
@ -78,12 +83,12 @@ class helper_plugin_popularity extends Dokuwiki_Plugin {
/**
* Send the data, to the submit url
* @param string $data The popularity data
* @return An empty string if everything worked fine, a string describing the error otherwise
* @return string An empty string if everything worked fine, a string describing the error otherwise
*/
function sendData($data){
$error = '';
$httpClient = new DokuHTTPClient();
$status = $httpClient->sendRequest($this->submitUrl, $data, 'POST');
$status = $httpClient->sendRequest($this->submitUrl, array('data' => $data), 'POST');
if ( ! $status ){
$error = $httpClient->error;
}
@ -102,7 +107,7 @@ class helper_plugin_popularity extends Dokuwiki_Plugin {
/**
* Gather all information
* @return The popularity data as a string
* @return string The popularity data as a string
*/
function gatherAsString(){
$data = $this->_gather();
@ -119,19 +124,21 @@ class helper_plugin_popularity extends Dokuwiki_Plugin {
/**
* Gather all information
* @return The popularity data as an array
* @return array The popularity data as an array
*/
function _gather(){
global $conf;
/** @var $auth DokuWiki_Auth_Plugin */
global $auth;
$data = array();
$phptime = ini_get('max_execution_time');
@set_time_limit(0);
$pluginInfo = $this->getInfo();
// version
$data['anon_id'] = md5(auth_cookiesalt());
$data['version'] = getVersion();
$data['popversion'] = $this->version;
$data['popversion'] = $pluginInfo['date'];
$data['language'] = $conf['lang'];
$data['now'] = time();
$data['popauto'] = (int) $this->isAutoSubmitEnabled();
@ -143,7 +150,7 @@ class helper_plugin_popularity extends Dokuwiki_Plugin {
// number and size of pages
$list = array();
search($list,$conf['datadir'],array($this,'_search_count'),'','');
search($list,$conf['datadir'],array($this,'_search_count'),array('all'=>false),'');
$data['page_count'] = $list['file_count'];
$data['page_size'] = $list['file_size'];
$data['page_biggest'] = $list['file_max'];
@ -243,6 +250,17 @@ class helper_plugin_popularity extends Dokuwiki_Plugin {
return $data;
}
/**
* Callback to search and count the content of directories in DokuWiki
*
* @param array &$data Reference to the result data structure
* @param string $base Base usually $conf['datadir']
* @param string $file current file or directory relative to $base
* @param string $type Type either 'd' for directory or 'f' for file
* @param int $lvl Current recursion depht
* @param array $opts option array as given to search()
* @return bool
*/
function _search_count(&$data,$base,$file,$type,$lvl,$opts){
// traverse
if($type == 'd'){

View File

@ -1,7 +1,7 @@
base popularity
author Andreas Gohr
email andi@splitbrain.org
date 2011-08-18
date 2012-11-29
name Popularity Feedback Plugin
desc Send anonymous data about your wiki to the developers.
desc Send anonymous data about your wiki to the DokuWiki developers
url http://www.dokuwiki.org/plugin:popularity