diff options
Diffstat (limited to 'inc')
-rw-r--r-- | inc/HTTPClient.php | 2 | ||||
-rw-r--r-- | inc/JpegMeta.php | 2 | ||||
-rw-r--r-- | inc/actions.php | 3 | ||||
-rw-r--r-- | inc/auth.php | 20 | ||||
-rw-r--r-- | inc/common.php | 8 | ||||
-rw-r--r-- | inc/html.php | 6 | ||||
-rw-r--r-- | inc/indexer.php | 25 | ||||
-rw-r--r-- | inc/init.php | 6 | ||||
-rw-r--r-- | inc/io.php | 2 | ||||
-rw-r--r-- | inc/lang/da/lang.php | 13 | ||||
-rw-r--r-- | inc/lang/zh/lang.php | 6 | ||||
-rw-r--r-- | inc/mail.php | 8 | ||||
-rw-r--r-- | inc/pageutils.php | 2 | ||||
-rw-r--r-- | inc/parser/handler.php | 7 | ||||
-rw-r--r-- | inc/parserutils.php | 8 | ||||
-rw-r--r-- | inc/plugincontroller.class.php | 118 | ||||
-rw-r--r-- | inc/pluginutils.php | 61 | ||||
-rw-r--r-- | inc/search.php | 50 | ||||
-rw-r--r-- | inc/subscription.php | 2 | ||||
-rw-r--r-- | inc/template.php | 14 |
20 files changed, 263 insertions, 100 deletions
diff --git a/inc/HTTPClient.php b/inc/HTTPClient.php index b2621bdbb..96954fb47 100644 --- a/inc/HTTPClient.php +++ b/inc/HTTPClient.php @@ -553,7 +553,7 @@ class HTTPClient { }while($r_line != "\r\n" && $r_line != "\n"); $this->_debug('SSL Tunnel Response',$r_headers); - if(preg_match('/^HTTP\/1\.0 200/i',$r_headers)){ + if(preg_match('/^HTTP\/1\.[01] 200/i',$r_headers)){ if (stream_socket_enable_crypto($socket, true, STREAM_CRYPTO_METHOD_SSLv3_CLIENT)) { $requesturl = $requestinfo['path']; return true; diff --git a/inc/JpegMeta.php b/inc/JpegMeta.php index 231fda083..cb1772736 100644 --- a/inc/JpegMeta.php +++ b/inc/JpegMeta.php @@ -975,7 +975,7 @@ class JpegMeta { if ($capture) { if ($length) - $this->_markers[$count]['data'] =& fread($this->_fp, $length); + $this->_markers[$count]['data'] = fread($this->_fp, $length); else $this->_markers[$count]['data'] = ""; } diff --git a/inc/actions.php b/inc/actions.php index bf124c887..5a59d852d 100644 --- a/inc/actions.php +++ b/inc/actions.php @@ -164,7 +164,8 @@ function act_dispatch(){ $pluginlist = plugin_list('admin'); if (in_array($page, $pluginlist)) { // attempt to load the plugin - if ($plugin =& plugin_load('admin',$page) !== null){ + + if (($plugin = plugin_load('admin',$page)) !== null){ /** @var DokuWiki_Admin_Plugin $plugin */ if($plugin->forAdminOnly() && !$INFO['isadmin']){ // a manager tried to load a plugin that's for admins only diff --git a/inc/auth.php b/inc/auth.php index 36fc7d086..0d42c8673 100644 --- a/inc/auth.php +++ b/inc/auth.php @@ -139,10 +139,10 @@ function auth_loadACL() { $out = array(); foreach($acl as $line) { $line = trim($line); - if($line{0} == '#') continue; + if(empty($line) || ($line{0} == '#')) continue; // skip blank lines & comments list($id,$rest) = preg_split('/\s+/',$line,2); - // substitue user wildcard first (its 1:1) + // substitute user wildcard first (its 1:1) if(strstr($line, '%USER%')){ // if user is not logged in, this ACL line is meaningless - skip it if (!isset($_SERVER['REMOTE_USER'])) continue; @@ -808,14 +808,14 @@ function auth_nameencode($name, $skip_group = false) { if(!isset($cache[$name][$skip_group])) { if($skip_group && $name{0} == '@') { - $cache[$name][$skip_group] = '@'.preg_replace( - '/([\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f])/e', - "'%'.dechex(ord(substr('\\1',-1)))", substr($name, 1) + $cache[$name][$skip_group] = '@'.preg_replace_callback( + '/([\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f])/', + 'auth_nameencode_callback', substr($name, 1) ); } else { - $cache[$name][$skip_group] = preg_replace( - '/([\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f])/e', - "'%'.dechex(ord(substr('\\1',-1)))", $name + $cache[$name][$skip_group] = preg_replace_callback( + '/([\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f])/', + 'auth_nameencode_callback', $name ); } } @@ -823,6 +823,10 @@ function auth_nameencode($name, $skip_group = false) { return $cache[$name][$skip_group]; } +function auth_nameencode_callback($matches) { + return '%'.dechex(ord(substr($matches[1],-1))); +} + /** * Create a pronouncable password * diff --git a/inc/common.php b/inc/common.php index 866e0aadd..32771285b 100644 --- a/inc/common.php +++ b/inc/common.php @@ -64,7 +64,7 @@ function getSecurityToken() { */ function checkSecurityToken($token = null) { global $INPUT; - if(!$_SERVER['REMOTE_USER']) return true; // no logged in user, no need for a check + if(empty($_SERVER['REMOTE_USER'])) return true; // no logged in user, no need for a check if(is_null($token)) $token = $INPUT->str('sectok'); if(getSecurityToken() != $token) { @@ -474,13 +474,13 @@ function ml($id = '', $more = '', $direct = true, $sep = '&', $abs = false) if(is_array($more)) { // add token for resized images - if($more['w'] || $more['h'] || $isexternalimage){ + if(!empty($more['w']) || !empty($more['h']) || $isexternalimage){ $more['tok'] = media_get_token($id,$more['w'],$more['h']); } // strip defaults for shorter URLs if(isset($more['cache']) && $more['cache'] == 'cache') unset($more['cache']); - if(!$more['w']) unset($more['w']); - if(!$more['h']) unset($more['h']); + if(empty($more['w'])) unset($more['w']); + if(empty($more['h'])) unset($more['h']); if(isset($more['id']) && $direct) unset($more['id']); $more = buildURLparams($more, $sep); } else { diff --git a/inc/html.php b/inc/html.php index 03e9dc751..bbe29e371 100644 --- a/inc/html.php +++ b/inc/html.php @@ -428,7 +428,7 @@ function html_revisions($first=0, $media_id = false){ global $conf; global $lang; $id = $ID; - /* we need to get one additionally log entry to be able to + /* we need to get one additional log entry to be able to * decide if this is the last page or is there another one. * see html_recent() */ @@ -1661,7 +1661,7 @@ function html_admin(){ global $ID; global $INFO; global $conf; - /** @var auth_basic $auth */ + /** @var DokuWiki_Auth_Plugin $auth */ global $auth; // build menu of admin functions from the plugins that handle them @@ -1669,7 +1669,7 @@ function html_admin(){ $menu = array(); foreach ($pluginlist as $p) { /** @var DokuWiki_Admin_Plugin $obj */ - if($obj =& plugin_load('admin',$p) === null) continue; + if(($obj = plugin_load('admin',$p)) === null) continue; // check permissions if($obj->forAdminOnly() && !$INFO['isadmin']) continue; diff --git a/inc/indexer.php b/inc/indexer.php index 8f0ba7ec6..658fb966b 100644 --- a/inc/indexer.php +++ b/inc/indexer.php @@ -10,7 +10,7 @@ if(!defined('DOKU_INC')) die('meh.'); // Version tag used to force rebuild on upgrade -define('INDEXER_VERSION', 6); +define('INDEXER_VERSION', 7); // set the minimum token length to use in the index (note, this doesn't apply to numeric tokens) if (!defined('IDX_MINWORDLENGTH')) define('IDX_MINWORDLENGTH',2); @@ -215,7 +215,7 @@ class Doku_Indexer { foreach (array_keys($words) as $wlen) { $word_idx = $this->getIndex('w', $wlen); foreach ($words[$wlen] as $word => $freq) { - $wid = array_search($word, $word_idx); + $wid = array_search($word, $word_idx, true); if ($wid === false) { $wid = count($word_idx); $word_idx[] = $word; @@ -296,7 +296,7 @@ class Doku_Indexer { foreach ($values as $val) { $val = (string)$val; if ($val !== "") { - $id = array_search($val, $metawords); + $id = array_search($val, $metawords, true); if ($id === false) { $id = count($metawords); $metawords[$id] = $val; @@ -352,13 +352,13 @@ class Doku_Indexer { $pages = $this->getPages(); - $id = array_search($oldpage, $pages); + $id = array_search($oldpage, $pages, true); if ($id === false) { $this->unlock(); return 'page is not in index'; } - $new_id = array_search($newpage, $pages); + $new_id = array_search($newpage, $pages, true); if ($new_id !== false) { // make sure the page is not in the index anymore if ($this->deletePageNoLock($newpage) !== true) { @@ -397,9 +397,9 @@ class Doku_Indexer { // change the relation references index $metavalues = $this->getIndex($key, '_w'); - $oldid = array_search($oldvalue, $metavalues); + $oldid = array_search($oldvalue, $metavalues, true); if ($oldid !== false) { - $newid = array_search($newvalue, $metavalues); + $newid = array_search($newvalue, $metavalues, true); if ($newid !== false) { // free memory unset ($metavalues); @@ -600,7 +600,7 @@ class Doku_Indexer { foreach ($wordlist as $i => $word) { if ((!is_numeric($word) && strlen($word) < IDX_MINWORDLENGTH) - || array_search($word, $stopwords) !== false) + || array_search($word, $stopwords, true) !== false) unset($wordlist[$i]); } return array_values($wordlist); @@ -771,7 +771,7 @@ class Doku_Indexer { foreach(array_keys(preg_grep('/'.$re.'/', $words)) as $i) $value_ids[$i][] = $val; } else { - if (($i = array_search($val, $words)) !== false) + if (($i = array_search($val, $words, true)) !== false) $value_ids[$i][] = $val; } } @@ -874,7 +874,7 @@ class Doku_Indexer { // handle exact search if (isset($tokenlength[$ixlen])) { foreach ($tokenlength[$ixlen] as $xword) { - $wid = array_search($xword, $word_idx); + $wid = array_search($xword, $word_idx, true); if ($wid !== false) { $wids[$ixlen][] = $wid; foreach ($tokens[$xword] as $w) @@ -1017,8 +1017,9 @@ class Doku_Indexer { return false; } } - if ($conf['dperm']) + if (!empty($conf['dperm'])) { chmod($lock, $conf['dperm']); + } return $status; } @@ -1152,7 +1153,7 @@ class Doku_Indexer { */ protected function addIndexKey($idx, $suffix, $value) { $index = $this->getIndex($idx, $suffix); - $id = array_search($value, $index); + $id = array_search($value, $index, true); if ($id === false) { $id = count($index); $index[$id] = $value; diff --git a/inc/init.php b/inc/init.php index 30eb1b251..a937b934d 100644 --- a/inc/init.php +++ b/inc/init.php @@ -267,10 +267,10 @@ function init_lang($langCode) { $lang = array(); //load the language files - require_once(DOKU_INC.'inc/lang/en/lang.php'); + require(DOKU_INC.'inc/lang/en/lang.php'); if ($langCode && $langCode != 'en') { if (file_exists(DOKU_INC."inc/lang/$langCode/lang.php")) { - require_once(DOKU_INC."inc/lang/$langCode/lang.php"); + require(DOKU_INC."inc/lang/$langCode/lang.php"); } } } @@ -288,7 +288,7 @@ function init_files(){ $fh = @fopen($file,'a'); if($fh){ fclose($fh); - if($conf['fperm']) chmod($file, $conf['fperm']); + if(!empty($conf['fperm'])) chmod($file, $conf['fperm']); }else{ nice_die("$file is not writable. Check your permissions settings!"); } diff --git a/inc/io.php b/inc/io.php index 4bd7c3364..eff0279ac 100644 --- a/inc/io.php +++ b/inc/io.php @@ -393,7 +393,7 @@ function io_mkdir_p($target){ return io_mkdir_ftp($dir); }else{ $ret = @mkdir($target,$conf['dmode']); // crawl back up & create dir tree - if($ret && $conf['dperm']) chmod($target, $conf['dperm']); + if($ret && !empty($conf['dperm'])) chmod($target, $conf['dperm']); return $ret; } } diff --git a/inc/lang/da/lang.php b/inc/lang/da/lang.php index f36c43fdb..6fe56929d 100644 --- a/inc/lang/da/lang.php +++ b/inc/lang/da/lang.php @@ -1,8 +1,8 @@ <?php + /** - * danish language file - * * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) + * * @author koeppe <koeppe@kazur.dk> * @author Jon Bendtsen <bendtsen@diku.dk> * @author Lars Næsbye Christensen <larsnaesbye@stud.ku.dk> @@ -14,6 +14,7 @@ * @author rasmus@kinnerup.com * @author Michael Pedersen subben@gmail.com * @author Mikael Lyngvig <mikael@lyngvig.org> + * @author Soren Birk <soer9648@hotmail.com> */ $lang['encoding'] = 'utf-8'; $lang['direction'] = 'ltr'; @@ -57,6 +58,7 @@ $lang['btn_revert'] = 'Reetablér'; $lang['btn_register'] = 'Registrér'; $lang['btn_apply'] = 'Anvend'; $lang['btn_media'] = 'Media Manager'; +$lang['btn_deleteuser'] = 'Fjern Min Konto'; $lang['loggedinas'] = 'Logget ind som'; $lang['user'] = 'Brugernavn'; $lang['pass'] = 'Adgangskode'; @@ -68,6 +70,7 @@ $lang['fullname'] = 'Fulde navn'; $lang['email'] = 'E-mail'; $lang['profile'] = 'Brugerprofil'; $lang['badlogin'] = 'Brugernavn eller adgangskode var forkert.'; +$lang['badpassconfirm'] = 'Kodeordet var desværre forkert'; $lang['minoredit'] = 'Mindre ændringer'; $lang['draftdate'] = 'Kladde automatisk gemt d.'; $lang['nosecedit'] = 'Siden blev ændret i mellemtiden, sektions information var for gammel, hentede hele siden i stedet.'; @@ -84,6 +87,9 @@ $lang['profna'] = 'Denne wiki understøtter ikke ændring af prof $lang['profnochange'] = 'Ingen ændringer, intet modificeret.'; $lang['profnoempty'] = 'Tomt navn eller e-mail adresse er ikke tilladt.'; $lang['profchanged'] = 'Brugerprofil opdateret korrekt.'; +$lang['profnodelete'] = 'Denne wiki supporterer ikke sletning af brugere'; +$lang['profdeleteuser'] = 'Slet Konto'; +$lang['profdeleted'] = 'Din brugerkonto er blevet slettet fra denne wiki'; $lang['pwdforget'] = 'Har du glemt dit adgangskode? Få et nyt'; $lang['resendna'] = 'Denne wiki understøtter ikke udsendelse af nyt adgangskode.'; $lang['resendpwd'] = 'Vælg ny adgangskode for'; @@ -198,6 +204,7 @@ $lang['user_tools'] = 'Brugerværktøjer'; $lang['site_tools'] = 'Webstedsværktøjer'; $lang['page_tools'] = 'Sideværktøjer'; $lang['skip_to_content'] = 'hop til indhold'; +$lang['sidebar'] = 'Sidebjælke'; $lang['mail_newpage'] = 'dokument tilføjet:'; $lang['mail_changed'] = 'dokument ændret:'; $lang['mail_subscribe_list'] = 'sider ændret i navnerum'; @@ -292,6 +299,8 @@ $lang['i_pol1'] = 'Offentlig Wiki (alle kan læse, kun registrere $lang['i_pol2'] = 'Lukket Wiki (kun for registerede brugere kan læse, skrive og overføre)'; $lang['i_retry'] = 'Forsøg igen'; $lang['i_license'] = 'Vælg venligst licensen du vil tilføje dit indhold under:'; +$lang['i_license_none'] = 'Vis ikke licensinformationer'; +$lang['i_pop_field'] = 'Hjælp os venligst med at forbedre oplevelsen af DokuWiki:'; $lang['recent_global'] = 'Du ser lige nu ændringerne i <b>%s</b> navnerummet. Du kan også <a href="%s">se de sidste ændringer for hele wiki siden </a>'; $lang['years'] = '%d år siden'; $lang['months'] = '%d måned siden'; diff --git a/inc/lang/zh/lang.php b/inc/lang/zh/lang.php index a6c95143f..a125e11e7 100644 --- a/inc/lang/zh/lang.php +++ b/inc/lang/zh/lang.php @@ -17,6 +17,7 @@ * @author Shuo-Ting Jian <shoting@gmail.com> * @author Rachel <rzhang0802@gmail.com> * @author Donald <donaldtcong@gmail.com> + * @author Yangyu Huang <yangyu.huang@gmail.com> */ $lang['encoding'] = 'utf-8'; $lang['direction'] = 'ltr'; @@ -60,6 +61,7 @@ $lang['btn_revert'] = '恢复'; $lang['btn_register'] = '注册'; $lang['btn_apply'] = '应用'; $lang['btn_media'] = '媒体管理器'; +$lang['btn_deleteuser'] = '移除我的账户'; $lang['loggedinas'] = '登录为'; $lang['user'] = '用户名'; $lang['pass'] = '密码'; @@ -88,7 +90,11 @@ $lang['profna'] = '本维基不支持修改个人信息'; $lang['profnochange'] = '没有改动,不进行操作。'; $lang['profnoempty'] = '不允许使用空的用户名或邮件地址。'; $lang['profchanged'] = '用户信息更新成功。'; +$lang['profnodelete'] = '这个 wiki 不支持删除用户'; $lang['profdeleteuser'] = '删除账号'; +$lang['profdeleted'] = '你的用户已经从这个 wiki 中删除'; +$lang['profconfdelete'] = '我希望删除我的账户。<br/>这项操作无法撤销。'; +$lang['profconfdeletemissing'] = '确认框未勾选'; $lang['pwdforget'] = '忘记密码?立即获取新密码'; $lang['resendna'] = '本维基不支持二次发送密码。'; $lang['resendpwd'] = '设置新密码用于'; diff --git a/inc/mail.php b/inc/mail.php index d0ea651bf..0b60c0a5b 100644 --- a/inc/mail.php +++ b/inc/mail.php @@ -284,10 +284,9 @@ function mail_quotedprintable_encode($sText,$maxlen=74,$bEmulate_imap_8bit=true) // for EBCDIC safeness encode !"#$@[\]^`{|}~, // for complete safeness encode every character :) if ($bEmulate_imap_8bit) - $sRegExp = '/[^\x20\x21-\x3C\x3E-\x7E]/e'; + $sRegExp = '/[^\x20\x21-\x3C\x3E-\x7E]/'; - $sReplmt = 'sprintf( "=%02X", ord ( "$0" ) ) ;'; - $sLine = preg_replace( $sRegExp, $sReplmt, $sLine ); + $sLine = preg_replace_callback( $sRegExp, 'mail_quotedprintable_encode_callback', $sLine ); // encode x09,x20 at lineends { @@ -330,3 +329,6 @@ function mail_quotedprintable_encode($sText,$maxlen=74,$bEmulate_imap_8bit=true) return implode(MAILHEADER_EOL,$aLines); } +function mail_quotedprintable_encode_callback($matches){ + return sprintf( "=%02X", ord ( $matches[0] ) ) ; +} diff --git a/inc/pageutils.php b/inc/pageutils.php index bf79daa7d..60f326e04 100644 --- a/inc/pageutils.php +++ b/inc/pageutils.php @@ -396,7 +396,7 @@ function resolve_id($ns,$id,$clean=true){ // if the id starts with a dot we need to handle the // relative stuff - if($id{0} == '.'){ + if($id && $id{0} == '.'){ // normalize initial dots without a colon $id = preg_replace('/^(\.+)(?=[^:\.])/','\1:',$id); // prepend the current namespace diff --git a/inc/parser/handler.php b/inc/parser/handler.php index 1de981b48..8ae991209 100644 --- a/inc/parser/handler.php +++ b/inc/parser/handler.php @@ -70,7 +70,7 @@ class Doku_Handler { */ function plugin($match, $state, $pos, $pluginname){ $data = array($match); - $plugin =& plugin_load('syntax',$pluginname); + $plugin = plugin_load('syntax',$pluginname); if($plugin != null){ $data = $plugin->handle($match, $state, $pos, $this); } @@ -653,8 +653,8 @@ function Doku_Handler_Parse_Media($match) { //parse width and height if(preg_match('#(\d+)(x(\d+))?#i',$param,$size)){ - ($size[1]) ? $w = $size[1] : $w = null; - ($size[3]) ? $h = $size[3] : $h = null; + !empty($size[1]) ? $w = $size[1] : $w = null; + !empty($size[3]) ? $h = $size[3] : $h = null; } else { $w = null; $h = null; @@ -1432,6 +1432,7 @@ class Doku_Handler_Table { class Doku_Handler_Block { var $calls = array(); var $skipEol = false; + var $inParagraph = false; // Blocks these should not be inside paragraphs var $blockOpen = array( diff --git a/inc/parserutils.php b/inc/parserutils.php index 56161af44..b67daaabb 100644 --- a/inc/parserutils.php +++ b/inc/parserutils.php @@ -625,7 +625,8 @@ function & p_get_renderer($mode) { $rclass = "Doku_Renderer_$rname"; if( class_exists($rclass) ) { - return new $rclass(); + $Renderer = new $rclass(); + return $Renderer; } // try default renderer first: @@ -641,10 +642,7 @@ function & p_get_renderer($mode) { $Renderer = new $rclass(); }else{ // Maybe a plugin/component is available? - list($plugin, $component) = $plugin_controller->_splitName($rname); - if (!$plugin_controller->isdisabled($plugin)){ - $Renderer =& $plugin_controller->load('renderer',$rname); - } + $Renderer = $plugin_controller->load('renderer',$rname); if(!isset($Renderer) || is_null($Renderer)){ msg("No renderer '$rname' found for mode '$mode'",-1); diff --git a/inc/plugincontroller.class.php b/inc/plugincontroller.class.php index c825870cd..d80cd4c9e 100644 --- a/inc/plugincontroller.class.php +++ b/inc/plugincontroller.class.php @@ -11,15 +11,15 @@ if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); class Doku_Plugin_Controller { - var $list_bytype = array(); - var $tmp_plugins = array(); - var $plugin_cascade = array('default'=>array(),'local'=>array(),'protected'=>array()); - var $last_local_config_file = ''; + protected $list_bytype = array(); + protected $tmp_plugins = array(); + protected $plugin_cascade = array('default'=>array(),'local'=>array(),'protected'=>array()); + protected $last_local_config_file = ''; /** * Populates the master list of plugins */ - function __construct() { + public function __construct() { $this->loadConfig(); $this->_populateMasterList(); } @@ -34,11 +34,13 @@ class Doku_Plugin_Controller { * false to only return enabled plugins, * true to return both enabled and disabled plugins * - * @return array of plugin names + * @return array of + * - plugin names when $type = '' + * - or plugin component names when a $type is given * * @author Andreas Gohr <andi@splitbrain.org> */ - function getList($type='',$all=false){ + public function getList($type='',$all=false){ // request the complete list if (!$type) { @@ -64,9 +66,9 @@ class Doku_Plugin_Controller { * @param $name string name of the plugin to load * @param $new bool true to return a new instance of the plugin, false to use an already loaded instance * @param $disabled bool true to load even disabled plugins - * @return objectreference the plugin object or null on failure + * @return DokuWiki_Plugin|DokuWiki_Syntax_Plugin|null the plugin object or null on failure */ - function load($type,$name,$new=false,$disabled=false){ + public function load($type,$name,$new=false,$disabled=false){ //we keep all loaded plugins available in global scope for reuse global $DOKU_PLUGINS; @@ -108,26 +110,59 @@ class Doku_Plugin_Controller { return $DOKU_PLUGINS[$type][$name]; } - function isdisabled($plugin) { + /** + * Whether plugin is disabled + * + * @param string $plugin name of plugin + * @return bool; true disabled, false enabled + */ + public function isdisabled($plugin) { return empty($this->tmp_plugins[$plugin]); } - function disable($plugin) { + /** + * Disable the plugin + * + * @param string $plugin name of plugin + * @return bool; true saving succeed, false saving failed + */ + public function disable($plugin) { if(array_key_exists($plugin,$this->plugin_cascade['protected'])) return false; $this->tmp_plugins[$plugin] = 0; return $this->saveList(); } - function enable($plugin) { + /** + * Enable the plugin + * + * @param string $plugin name of plugin + * @return bool; true saving succeed, false saving failed + */ + public function enable($plugin) { if(array_key_exists($plugin,$this->plugin_cascade['protected'])) return false; $this->tmp_plugins[$plugin] = 1; return $this->saveList(); } - function get_directory($plugin) { + /** + * Returns directory name of plugin + * + * @param string $plugin name of plugin + * @return string name of directory + */ + public function get_directory($plugin) { return $plugin; } + /** + * Returns cascade of the config files + * + * @return array with arrays of plugin configs + */ + public function getCascade() { + return $this->plugin_cascade; + } + protected function _populateMasterList() { global $conf; @@ -169,6 +204,13 @@ class Doku_Plugin_Controller { } } + /** + * Includes the plugin config $files + * and returns the entries of the $plugins array set in these files + * + * @param array $files list of files to include, latter overrides previous + * @return array with entries of the $plugins arrays of the included files + */ protected function checkRequire($files) { $plugins = array(); foreach($files as $file) { @@ -179,14 +221,15 @@ class Doku_Plugin_Controller { return $plugins; } - function getCascade() { - return $this->plugin_cascade; - } - /** * Save the current list of plugins + * + * @param bool $forceSave; + * false to save only when config changed + * true to always save + * @return bool; true saving succeed, false saving failed */ - function saveList($forceSave = false) { + protected function saveList($forceSave = false) { global $conf; if (empty($this->tmp_plugins)) return false; @@ -206,7 +249,7 @@ class Doku_Plugin_Controller { $backup = $file.'.bak'; if (@file_exists($backup)) @unlink($backup); if (!@copy($file,$backup)) return false; - if ($conf['fperm']) chmod($backup, $conf['fperm']); + if (!empty($conf['fperm'])) chmod($backup, $conf['fperm']); } //check if can open for writing, else restore return io_saveFile($file,$out); @@ -216,9 +259,10 @@ class Doku_Plugin_Controller { /** * Rebuild the set of local plugins + * * @return array array of plugins to be saved in end($config_cascade['plugins']['local']) */ - function rebuildLocal() { + protected function rebuildLocal() { //assign to local variable to avoid overwriting $backup = $this->tmp_plugins; //Can't do anything about protected one so rule them out completely @@ -238,7 +282,7 @@ class Doku_Plugin_Controller { * Build the list of plugins and cascade * */ - function loadConfig() { + protected function loadConfig() { global $config_cascade; foreach(array('default','protected') as $type) { if(array_key_exists($type,$config_cascade['plugins'])) @@ -253,7 +297,18 @@ class Doku_Plugin_Controller { $this->tmp_plugins = array_merge($this->plugin_cascade['default'],$this->plugin_cascade['local'],$this->plugin_cascade['protected']); } - function _getListByType($type, $enabled) { + /** + * Returns a list of available plugin components of given type + * + * @param string $type, plugin_type name; + * the type of plugin to return, + * @param bool $enabled; + * true to return enabled plugins, + * false to return disabled plugins + * + * @return array of plugin components of requested type + */ + protected function _getListByType($type, $enabled) { $master_list = $enabled ? array_keys(array_filter($this->tmp_plugins)) : array_keys(array_filter($this->tmp_plugins,array($this,'negate'))); $plugins = array(); @@ -278,14 +333,29 @@ class Doku_Plugin_Controller { return $plugins; } - function _splitName($name) { + /** + * Split name in a plugin name and a component name + * + * @param string $name + * @return array with + * - plugin name + * - and component name when available, otherwise empty string + */ + protected function _splitName($name) { if (array_search($name, array_keys($this->tmp_plugins)) === false) { return explode('_',$name,2); } return array($name,''); } - function negate($input) { + + /** + * Returns inverse boolean value of the input + * + * @param mixed $input + * @return bool inversed boolean value of input + */ + protected function negate($input) { return !(bool) $input; } } diff --git a/inc/pluginutils.php b/inc/pluginutils.php index 7c37d4f7f..894bbefb6 100644 --- a/inc/pluginutils.php +++ b/inc/pluginutils.php @@ -14,31 +14,92 @@ if(!defined('DOKU_PLUGIN_NAME_REGEX')) define('DOKU_PLUGIN_NAME_REGEX', '[a-zA-Z /** * Original plugin functions, remain for backwards compatibility */ + +/** + * Return list of available plugins + * + * @param string $type type of plugins; empty string for all + * @param bool $all; true to retrieve all, false to retrieve only enabled plugins + * @return array with plugin names or plugin component names + */ function plugin_list($type='',$all=false) { + /** @var $plugin_controller Doku_Plugin_Controller */ global $plugin_controller; return $plugin_controller->getList($type,$all); } + +/** + * Returns plugin object + * Returns only new instances of a plugin when $new is true or if plugin is not Singleton, + * otherwise an already loaded instance. + * + * @param $type string type of plugin to load + * @param $name string name of the plugin to load + * @param $new bool true to return a new instance of the plugin, false to use an already loaded instance + * @param $disabled bool true to load even disabled plugins + * @return DokuWiki_Plugin|DokuWiki_Syntax_Plugin|null the plugin object or null on failure + */ function plugin_load($type,$name,$new=false,$disabled=false) { + /** @var $plugin_controller Doku_Plugin_Controller */ global $plugin_controller; return $plugin_controller->load($type,$name,$new,$disabled); } + +/** + * Whether plugin is disabled + * + * @param string $plugin name of plugin + * @return bool; true disabled, false enabled + */ function plugin_isdisabled($plugin) { + /** @var $plugin_controller Doku_Plugin_Controller */ global $plugin_controller; return $plugin_controller->isdisabled($plugin); } + +/** + * Enable the plugin + * + * @param string $plugin name of plugin + * @return bool; true saving succeed, false saving failed + */ function plugin_enable($plugin) { + /** @var $plugin_controller Doku_Plugin_Controller */ global $plugin_controller; return $plugin_controller->enable($plugin); } + +/** + * Disable the plugin + * + * @param string $plugin name of plugin + * @return bool; true saving succeed, false saving failed + */ function plugin_disable($plugin) { + /** @var $plugin_controller Doku_Plugin_Controller */ global $plugin_controller; return $plugin_controller->disable($plugin); } + +/** + * Returns directory name of plugin + * + * @param string $plugin name of plugin + * @return string name of directory + */ function plugin_directory($plugin) { + /** @var $plugin_controller Doku_Plugin_Controller */ global $plugin_controller; return $plugin_controller->get_directory($plugin); } + +/** + * Returns cascade of the config files + * + * @return array with arrays of plugin configs + */ function plugin_getcascade() { + /** @var $plugin_controller Doku_Plugin_Controller */ global $plugin_controller; return $plugin_controller->getCascade(); } diff --git a/inc/search.php b/inc/search.php index 884aa7b23..c2d31b959 100644 --- a/inc/search.php +++ b/inc/search.php @@ -9,14 +9,15 @@ if(!defined('DOKU_INC')) die('meh.'); /** - * recurse direcory + * Recurse directory * * This function recurses into a given base directory * and calls the supplied function for each file and directory * - * @param array ref $data The results of the search are stored here + * @param array &$data The results of the search are stored here * @param string $base Where to start the search * @param callback $func Callback (function name or array with object,method) + * @param array $opts option array will be given to the Callback * @param string $dir Current directory beyond $base * @param int $lvl Recursion Level * @param mixed $sort 'natural' to use natural order sorting (default); 'date' to sort by filemtime; leave empty to skip sorting. @@ -68,12 +69,12 @@ function search(&$data,$base,$func,$opts,$dir='',$lvl=1,$sort='natural'){ * decide if this directory should be traversed (true) or not (false) * The function has to accept the following parameters: * - * &$data - Reference to the result data structure - * $base - Base usually $conf['datadir'] - * $file - current file or directory relative to $base - * $type - Type either 'd' for directory or 'f' for file - * $lvl - Current recursion depht - * $opts - option array as given to search() + * array &$data - Reference to the result data structure + * string $base - Base usually $conf['datadir'] + * string $file - current file or directory relative to $base + * string $type - Type either 'd' for directory or 'f' for file + * int $lvl - Current recursion depht + * array $opts - option array as given to search() * * return values for files are ignored * @@ -110,7 +111,7 @@ function search_index(&$data,$base,$file,$type,$lvl,$opts){ $opts = array( 'pagesonly' => true, 'listdirs' => true, - 'listfiles' => !$opts['nofiles'], + 'listfiles' => empty($opts['nofiles']), 'sneakyacl' => $conf['sneaky_index'], // Hacky, should rather use recmatch 'depth' => preg_match('#^'.preg_quote($file, '#').'(/|$)#','/'.$opts['ns']) ? 0 : -1 @@ -334,6 +335,15 @@ function pathID($path,$keeptxt=false){ * showhidden bool show hidden files too * firsthead bool return first heading for pages * + * @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 if this directory should be traversed (true) or not (false) + * return value is ignored for files + * * @author Andreas Gohr <gohr@cosmocode.de> */ function search_universal(&$data,$base,$file,$type,$lvl,$opts){ @@ -367,7 +377,7 @@ function search_universal(&$data,$base,$file,$type,$lvl,$opts){ } // check ACL - if(!$opts['skipacl']){ + if(empty($opts['skipacl'])){ if($type == 'd'){ $item['perm'] = auth_quickaclcheck($item['id'].':*'); }else{ @@ -379,17 +389,17 @@ function search_universal(&$data,$base,$file,$type,$lvl,$opts){ // are we done here maybe? if($type == 'd'){ - if(!$opts['listdirs']) return $return; - if(!$opts['skipacl'] && $opts['sneakyacl'] && $item['perm'] < AUTH_READ) return false; //neither list nor recurse - if($opts['dirmatch'] && !preg_match('/'.$opts['dirmatch'].'/',$file)) return $return; - if($opts['nsmatch'] && !preg_match('/'.$opts['nsmatch'].'/',$item['ns'])) return $return; + if(empty($opts['listdirs'])) return $return; + if(empty($opts['skipacl']) && !empty($opts['sneakyacl']) && $item['perm'] < AUTH_READ) return false; //neither list nor recurse + if(!empty($opts['dirmatch']) && !preg_match('/'.$opts['dirmatch'].'/',$file)) return $return; + if(!empty($opts['nsmatch']) && !preg_match('/'.$opts['nsmatch'].'/',$item['ns'])) return $return; }else{ - if(!$opts['listfiles']) return $return; - if(!$opts['skipacl'] && $item['perm'] < AUTH_READ) return $return; - if($opts['pagesonly'] && (substr($file,-4) != '.txt')) return $return; - if(!$opts['showhidden'] && isHiddenPage($item['id'])) return $return; - if($opts['filematch'] && !preg_match('/'.$opts['filematch'].'/',$file)) return $return; - if($opts['idmatch'] && !preg_match('/'.$opts['idmatch'].'/',$item['id'])) return $return; + if(empty($opts['listfiles'])) return $return; + if(empty($opts['skipacl']) && $item['perm'] < AUTH_READ) return $return; + if(!empty($opts['pagesonly']) && (substr($file,-4) != '.txt')) return $return; + if(empty($opts['showhidden']) && isHiddenPage($item['id'])) return $return; + if(!empty($opts['filematch']) && !preg_match('/'.$opts['filematch'].'/',$file)) return $return; + if(!empty($opts['idmatch']) && !preg_match('/'.$opts['idmatch'].'/',$item['id'])) return $return; } // still here? prepare the item diff --git a/inc/subscription.php b/inc/subscription.php index ecbc9ef19..ddf2f39e6 100644 --- a/inc/subscription.php +++ b/inc/subscription.php @@ -62,7 +62,7 @@ class Subscription { return false; } - if($conf['dperm']) chmod($lock, $conf['dperm']); + if(!empty($conf['dperm'])) chmod($lock, $conf['dperm']); return true; } diff --git a/inc/template.php b/inc/template.php index c08767e52..b42c9d934 100644 --- a/inc/template.php +++ b/inc/template.php @@ -223,7 +223,7 @@ function tpl_toc($return = false) { if(in_array($class, $pluginlist)) { // attempt to load the plugin /** @var $plugin DokuWiki_Admin_Plugin */ - $plugin =& plugin_load('admin', $class); + $plugin = plugin_load('admin', $class); } } if( ($plugin !== null) && (!$plugin->forAdminOnly() || $INFO['isadmin']) ) { @@ -257,7 +257,7 @@ function tpl_admin() { if(in_array($class, $pluginlist)) { // attempt to load the plugin /** @var $plugin DokuWiki_Admin_Plugin */ - $plugin =& plugin_load('admin', $class); + $plugin = plugin_load('admin', $class); } } @@ -401,7 +401,7 @@ function tpl_metaheaders($alt = true) { // make $INFO and other vars available to JavaScripts $json = new JSON(); $script = "var NS='".$INFO['namespace']."';"; - if($conf['useacl'] && $_SERVER['REMOTE_USER']) { + if($conf['useacl'] && !empty($_SERVER['REMOTE_USER'])) { $script .= "var SIG='".toolbar_signature()."';"; } $script .= 'var JSINFO = '.$json->encode($JSINFO).';'; @@ -680,12 +680,12 @@ function tpl_get_action($type) { } break; case 'register': - if($_SERVER['REMOTE_USER']) { + if(!empty($_SERVER['REMOTE_USER'])) { return false; } break; case 'resendpwd': - if($_SERVER['REMOTE_USER']) { + if(!empty($_SERVER['REMOTE_USER'])) { return false; } break; @@ -1412,7 +1412,7 @@ function tpl_actiondropdown($empty = '', $button = '>') { echo '<div class="no">'; echo '<input type="hidden" name="id" value="'.$ID.'" />'; if($REV) echo '<input type="hidden" name="rev" value="'.$REV.'" />'; - if ($_SERVER['REMOTE_USER']) { + if (!empty($_SERVER['REMOTE_USER'])) { echo '<input type="hidden" name="sectok" value="'.getSecurityToken().'" />'; } @@ -1794,7 +1794,7 @@ function tpl_classes() { 'dokuwiki', 'mode_'.$ACT, 'tpl_'.$conf['template'], - $_SERVER['REMOTE_USER'] ? 'loggedIn' : '', + !empty($_SERVER['REMOTE_USER']) ? 'loggedIn' : '', $INFO['exists'] ? '' : 'notFound', ($ID == $conf['start']) ? 'home' : '', ); |