From 38479cbba628ee76a92ff5f3c974cfa8e6ce9e61 Mon Sep 17 00:00:00 2001 From: Dominik Eckelmann Date: Thu, 29 Nov 2012 16:06:43 +0100 Subject: some coding style improvements - removed some dead/unused code - fixed phpdoc - added typing on methods --- lib/plugins/acl/admin.php | 7 ------- lib/plugins/config/settings/config.class.php | 7 +++---- lib/plugins/info/syntax.php | 20 +++----------------- lib/plugins/plugin/admin.php | 22 ++++------------------ lib/plugins/plugin/classes/ap_download.class.php | 4 +--- lib/plugins/plugin/classes/ap_manage.class.php | 6 +----- lib/plugins/plugin/classes/ap_update.class.php | 2 -- lib/plugins/popularity/action.php | 6 +++++- lib/plugins/popularity/admin.php | 8 ++++++-- lib/plugins/popularity/helper.php | 10 ++++++---- lib/plugins/revert/admin.php | 2 -- lib/plugins/syntax.php | 14 +++++++------- lib/plugins/usermanager/admin.php | 5 +---- 13 files changed, 37 insertions(+), 76 deletions(-) diff --git a/lib/plugins/acl/admin.php b/lib/plugins/acl/admin.php index 1197892f2..0d9cd742a 100644 --- a/lib/plugins/acl/admin.php +++ b/lib/plugins/acl/admin.php @@ -173,8 +173,6 @@ class admin_plugin_acl extends DokuWiki_Admin_Plugin { * @author Andreas Gohr */ function html() { - global $ID; - echo '
'.NL; echo '

'.$this->getLang('admin_acl').'

'.NL; echo '
'.NL; @@ -208,7 +206,6 @@ class admin_plugin_acl extends DokuWiki_Admin_Plugin { * @author Andreas Gohr */ function _get_opts($addopts=null){ - global $ID; $opts = array( 'do'=>'admin', 'page'=>'acl', @@ -230,7 +227,6 @@ class admin_plugin_acl extends DokuWiki_Admin_Plugin { global $ID; global $lang; - $dir = $conf['datadir']; $ns = $this->ns; if(empty($ns)){ $ns = dirname(str_replace(':','/',$ID)); @@ -326,7 +322,6 @@ class admin_plugin_acl extends DokuWiki_Admin_Plugin { * @author Andreas Gohr */ function _html_detail(){ - global $conf; global $ID; echo '
'.NL; @@ -493,7 +488,6 @@ class admin_plugin_acl extends DokuWiki_Admin_Plugin { * @author Andreas Gohr */ function _html_list_acl($item){ - global $ID; $ret = ''; // what to display if($item['label']){ @@ -764,7 +758,6 @@ class admin_plugin_acl extends DokuWiki_Admin_Plugin { * @author Andreas Gohr */ function _html_select(){ - global $conf; $inlist = false; if($this->who && diff --git a/lib/plugins/config/settings/config.class.php b/lib/plugins/config/settings/config.class.php index 8c48018d7..a30a0605b 100644 --- a/lib/plugins/config/settings/config.class.php +++ b/lib/plugins/config/settings/config.class.php @@ -369,7 +369,7 @@ if (!class_exists('setting')) { * update setting with user provided value $input * if value fails error check, save it * - * @return true if changed, false otherwise (incl. on error) + * @return boolean true if changed, false otherwise (incl. on error) */ function update($input) { if (is_null($input)) return false; @@ -426,7 +426,6 @@ if (!class_exists('setting')) { if ($fmt=='php') { // translation string needs to be improved FIXME - $tr = array("\n"=>'\n', "\r"=>'\r', "\t"=>'\t', "\\" => '\\\\', "'" => '\\\''); $tr = array("\\" => '\\\\', "'" => '\\\''); $out = '$'.$var."['".$this->_out_key()."'] = '".strtr($this->_local, $tr)."';\n"; @@ -538,7 +537,7 @@ if (!class_exists('setting_email')) { * update setting with user provided value $input * if value fails error check, save it * - * @return true if changed, false otherwise (incl. on error) + * @return boolean true if changed, false otherwise (incl. on error) */ function update($input) { if (is_null($input)) return false; @@ -574,7 +573,7 @@ if (!class_exists('setting_richemail')) { * update setting with user provided value $input * if value fails error check, save it * - * @return true if changed, false otherwise (incl. on error) + * @return boolean true if changed, false otherwise (incl. on error) */ function update($input) { if (is_null($input)) return false; diff --git a/lib/plugins/info/syntax.php b/lib/plugins/info/syntax.php index 9aedbf0aa..d813aa23a 100644 --- a/lib/plugins/info/syntax.php +++ b/lib/plugins/info/syntax.php @@ -15,20 +15,6 @@ if(!defined('DOKU_INC')) die(); */ class syntax_plugin_info extends DokuWiki_Syntax_Plugin { - /** - * return some info - */ - function getInfo(){ - return array( - 'author' => 'Andreas Gohr', - 'email' => 'andi@splitbrain.org', - 'date' => '2008-09-12', - 'name' => 'Info Plugin', - 'desc' => 'Displays information about various DokuWiki internals', - 'url' => 'http://dokuwiki.org/plugin:info', - ); - } - /** * What kind of syntax are we? */ @@ -114,7 +100,7 @@ class syntax_plugin_info extends DokuWiki_Syntax_Plugin { * * uses some of the original renderer methods */ - function _plugins_xhtml($type, &$renderer){ + function _plugins_xhtml($type, Doku_Renderer &$renderer){ global $lang; $renderer->doc .= '
    '; @@ -152,7 +138,7 @@ class syntax_plugin_info extends DokuWiki_Syntax_Plugin { * * uses some of the original renderer methods */ - function _helpermethods_xhtml(&$renderer){ + function _helpermethods_xhtml(Doku_Renderer &$renderer){ global $lang; $plugins = plugin_list('helper'); @@ -237,7 +223,7 @@ class syntax_plugin_info extends DokuWiki_Syntax_Plugin { /** * Adds a TOC item */ - function _addToTOC($text, $level, &$renderer){ + function _addToTOC($text, $level, Doku_Renderer_xhtml &$renderer){ global $conf; if (($level >= $conf['toptoclevel']) && ($level <= $conf['maxtoclevel'])){ diff --git a/lib/plugins/plugin/admin.php b/lib/plugins/plugin/admin.php index b2108f185..8b1ee3c7d 100644 --- a/lib/plugins/plugin/admin.php +++ b/lib/plugins/plugin/admin.php @@ -33,6 +33,10 @@ class admin_plugin_plugin extends DokuWiki_Admin_Plugin { var $disabled = 0; var $plugin = ''; var $cmd = ''; + + /** + * @var ap_manage + */ var $handler = NULL; var $functions = array('delete','update',/*'settings',*/'info'); // require a plugin name @@ -43,27 +47,9 @@ class admin_plugin_plugin extends DokuWiki_Admin_Plugin { var $error = ''; function admin_plugin_plugin() { - global $conf; $this->disabled = plugin_isdisabled('plugin'); } - /** - * return some info - */ - function getInfo(){ - $disabled = ($this->disabled) ? '(disabled)' : ''; - - return array( - 'author' => 'Christopher Smith', - 'email' => 'chris@jalakai.co.uk', - 'date' => '2009-11-11', - 'name' => 'Plugin Manager', - 'desc' => "Manage Plugins, including automated plugin installer $disabled", - 'url' => 'http://www.dokuwiki.org/plugin:plugin', - ); - } - - /** * return sort order for position in admin menu */ diff --git a/lib/plugins/plugin/classes/ap_download.class.php b/lib/plugins/plugin/classes/ap_download.class.php index 0eb567c80..3cc455867 100644 --- a/lib/plugins/plugin/classes/ap_download.class.php +++ b/lib/plugins/plugin/classes/ap_download.class.php @@ -7,7 +7,6 @@ class ap_download extends ap_manage { * Initiate the plugin download */ function process() { - global $lang; global $INPUT; $plugin_url = $INPUT->str('url'); @@ -45,7 +44,6 @@ class ap_download extends ap_manage { * Process the downloaded file */ function download($url, $overwrite=false) { - global $lang; // check the url $matches = array(); if (!preg_match("/[^\/]*$/", $url, $matches) || !$matches[0]) { @@ -241,7 +239,7 @@ class ap_download extends ap_manage { * if neither bz, gz or zip are recognized, tar is assumed. * * @author Andreas Gohr - * @returns false if the file can't be read, otherwise an "extension" + * @returns boolean|string false if the file can't be read, otherwise an "extension" */ function guess_archive($file){ $fh = fopen($file,'rb'); diff --git a/lib/plugins/plugin/classes/ap_manage.class.php b/lib/plugins/plugin/classes/ap_manage.class.php index 28579cbe9..3ec740dae 100644 --- a/lib/plugins/plugin/classes/ap_manage.class.php +++ b/lib/plugins/plugin/classes/ap_manage.class.php @@ -69,7 +69,6 @@ class ap_manage { } function html_pluginlist() { - global $ID; global $plugin_protected; foreach ($this->manager->plugin_list as $plugin) { @@ -195,11 +194,8 @@ class ap_manage { closedir($dh); return @rmdir($path); - } else { - return @unlink($path); } - - return false; + return @unlink($path); } diff --git a/lib/plugins/plugin/classes/ap_update.class.php b/lib/plugins/plugin/classes/ap_update.class.php index c43429a1b..5d7f6cb08 100644 --- a/lib/plugins/plugin/classes/ap_update.class.php +++ b/lib/plugins/plugin/classes/ap_update.class.php @@ -5,8 +5,6 @@ class ap_update extends ap_download { var $overwrite = true; function process() { - global $lang; - $plugin_url = $this->plugin_readlog($this->plugin, 'url'); $this->download($plugin_url, $this->overwrite); return ''; diff --git a/lib/plugins/popularity/action.php b/lib/plugins/popularity/action.php index 1c7a2f65d..f0cbb771b 100644 --- a/lib/plugins/popularity/action.php +++ b/lib/plugins/popularity/action.php @@ -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(){ @@ -22,7 +26,7 @@ class action_plugin_popularity extends Dokuwiki_Action_Plugin { $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; diff --git a/lib/plugins/popularity/admin.php b/lib/plugins/popularity/admin.php index 474a09ef9..deb8048f4 100644 --- a/lib/plugins/popularity/admin.php +++ b/lib/plugins/popularity/admin.php @@ -14,6 +14,10 @@ if(!defined('DOKU_INC')) die(); */ class admin_plugin_popularity extends DokuWiki_Admin_Plugin { var $version; + + /** + * @var helper_plugin_popularity + */ var $helper; var $sentStatus = null; @@ -118,9 +122,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()); diff --git a/lib/plugins/popularity/helper.php b/lib/plugins/popularity/helper.php index 34521021d..5bbeddba0 100644 --- a/lib/plugins/popularity/helper.php +++ b/lib/plugins/popularity/helper.php @@ -29,6 +29,8 @@ class helper_plugin_popularity extends Dokuwiki_Plugin { */ var $popularityLastSubmitFile; + var $version; + function helper_plugin_popularity(){ global $conf; @@ -69,7 +71,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,7 +80,7 @@ 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 = ''; @@ -102,7 +104,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,7 +121,7 @@ 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; diff --git a/lib/plugins/revert/admin.php b/lib/plugins/revert/admin.php index 958cf5acf..fcdaa230d 100644 --- a/lib/plugins/revert/admin.php +++ b/lib/plugins/revert/admin.php @@ -73,8 +73,6 @@ class admin_plugin_revert extends DokuWiki_Admin_Plugin { * Start the reversion process */ function _revert($revert,$filter){ - global $conf; - echo '

    '; echo '

    '.$this->getLang('revstart').'

    '; diff --git a/lib/plugins/syntax.php b/lib/plugins/syntax.php index 8b94493e4..552cc747a 100644 --- a/lib/plugins/syntax.php +++ b/lib/plugins/syntax.php @@ -84,13 +84,13 @@ class DokuWiki_Syntax_Plugin extends Doku_Parser_Mode { * * Usually you should only need the $match param. * - * @param $match string The text matched by the patterns - * @param $state int The lexer state for the match - * @param $pos int The character position of the matched text - * @param $handler Doku_Handler Reference to the Doku_Handler object - * @return array Return an array with all data you want to use in render + * @param string $match The text matched by the patterns + * @param int $state The lexer state for the match + * @param int $pos The character position of the matched text + * @param Doku_Handler $handler Reference to the Doku_Handler object + * @return array Return an array with all data you want to use in render */ - function handle($match, $state, $pos, &$handler){ + function handle($match, $state, $pos, Doku_Handler &$handler){ trigger_error('handle() not implemented in '.get_class($this), E_USER_WARNING); } @@ -117,7 +117,7 @@ class DokuWiki_Syntax_Plugin extends Doku_Parser_Mode { * @param $data array data created by handler() * @return boolean rendered correctly? */ - function render($format, &$renderer, $data) { + function render($format, Doku_Renderer &$renderer, $data) { trigger_error('render() not implemented in '.get_class($this), E_USER_WARNING); } diff --git a/lib/plugins/usermanager/admin.php b/lib/plugins/usermanager/admin.php index 30b65debb..cf8963e64 100644 --- a/lib/plugins/usermanager/admin.php +++ b/lib/plugins/usermanager/admin.php @@ -73,8 +73,6 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { * handle user request */ function handle() { - global $ID; - if (is_null($this->_auth)) return false; // extract the command and any specific parameters @@ -308,7 +306,6 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { function _htmlInputField($id, $name, $label, $value, $cando, $indent=0) { $class = $cando ? '' : ' class="disabled"'; - $disabled = $cando ? '' : ' disabled="disabled"'; echo str_pad('',$indent); if($name == 'userpass'){ @@ -549,7 +546,7 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { /** * retrieve & clean user data from the form * - * @return array(user, password, full name, email, array(groups)) + * @return array (user, password, full name, email, array(groups)) */ function _retrieveUser($clean=true) { global $auth; -- cgit v1.2.3