summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Perry <matt@mattperry.com>2013-08-22 01:01:41 -0700
committerMatt Perry <matt@mattperry.com>2013-08-22 01:01:41 -0700
commit7ef8e99fe605c5da36ab6b5d317b22fcd17f665b (patch)
tree2245231ac0dcbeea7084a751f89699e3307133f2
parent104262381eb89124eb900397f5054fde8e3d5658 (diff)
downloadrpg-7ef8e99fe605c5da36ab6b5d317b22fcd17f665b.tar.gz
rpg-7ef8e99fe605c5da36ab6b5d317b22fcd17f665b.tar.bz2
Fix CodeSniffer violations
Change indentation to ensure code confirms to CodeSniffer rules.
-rwxr-xr-xbin/dwpage.php8
-rwxr-xr-xbin/striplangs.php2
-rwxr-xr-xbin/wantedpages.php2
-rw-r--r--inc/DifferenceEngine.php2
-rw-r--r--inc/auth.php26
-rw-r--r--inc/html.php22
-rw-r--r--inc/parser/handler.php190
-rw-r--r--inc/parser/lexer.php42
-rw-r--r--inc/parser/metadata.php724
-rw-r--r--inc/parser/parser.php8
-rw-r--r--inc/parser/renderer.php10
-rw-r--r--inc/parser/xhtml.php26
-rw-r--r--inc/phpseclib/Math_BigInteger.php2
-rw-r--r--lib/plugins/action.php10
-rw-r--r--lib/plugins/config/admin.php488
-rw-r--r--lib/plugins/config/settings/config.class.php1478
-rw-r--r--lib/plugins/config/settings/extra.class.php270
-rw-r--r--lib/plugins/safefnrecode/action.php2
-rw-r--r--lib/plugins/syntax.php48
-rw-r--r--lib/plugins/usermanager/admin.php286
20 files changed, 1823 insertions, 1823 deletions
diff --git a/bin/dwpage.php b/bin/dwpage.php
index bc9c0f6bb..96f6d3ef9 100755
--- a/bin/dwpage.php
+++ b/bin/dwpage.php
@@ -13,7 +13,7 @@ require_once DOKU_INC.'inc/cliopts.php';
function usage($action) {
switch ( $action ) {
case 'checkout':
- print "Usage: dwpage.php [opts] checkout <wiki:page> [working_file]
+ print "Usage: dwpage.php [opts] checkout <wiki:page> [working_file]
Checks out a file from the repository, using the wiki id and obtaining
a lock for the page.
@@ -30,7 +30,7 @@ function usage($action) {
";
break;
case 'commit':
- print "Usage: dwpage.php [opts] -m \"Msg\" commit <working_file> <wiki:page>
+ print "Usage: dwpage.php [opts] -m \"Msg\" commit <working_file> <wiki:page>
Checks in the working_file into the repository using the specified
wiki id, archiving the previous version.
@@ -46,7 +46,7 @@ function usage($action) {
";
break;
case 'lock':
- print "Usage: dwpage.php [opts] lock <wiki:page>
+ print "Usage: dwpage.php [opts] lock <wiki:page>
Obtains or updates a lock for a wiki page
@@ -59,7 +59,7 @@ function usage($action) {
";
break;
case 'unlock':
- print "Usage: dwpage.php [opts] unlock <wiki:page>
+ print "Usage: dwpage.php [opts] unlock <wiki:page>
Removes a lock for a wiki page.
diff --git a/bin/striplangs.php b/bin/striplangs.php
index 40cef5063..ac95626c9 100755
--- a/bin/striplangs.php
+++ b/bin/striplangs.php
@@ -127,7 +127,7 @@ if ( $OPTS->has('k') or $OPTS->has('keep') ) {
// ! always enforce 'en' lang when using '--keep' (DW relies on it)
if ( !isset($langs['en']) ) {
- $langs[]='en';
+ $langs[]='en';
}
} elseif ( $OPTS->has('e') or $OPTS->has('english') ) {
// '--english' was specified strip everything besides 'en'
diff --git a/bin/wantedpages.php b/bin/wantedpages.php
index 30171fc15..16ff32b72 100755
--- a/bin/wantedpages.php
+++ b/bin/wantedpages.php
@@ -92,7 +92,7 @@ function dw_internal_links($page) {
$mid = $ins[1][0];
resolve_pageid($cns,$mid,$exists);
if ( !$exists ) {
- list($mid) = explode('#',$mid); //record pages without hashs
+ list($mid) = explode('#',$mid); //record pages without hashs
$links[] = $mid;
}
}
diff --git a/inc/DifferenceEngine.php b/inc/DifferenceEngine.php
index 07df7a4be..3c955cf88 100644
--- a/inc/DifferenceEngine.php
+++ b/inc/DifferenceEngine.php
@@ -826,7 +826,7 @@ class DiffFormatter {
* @param $str string Text string to escape
* @return string The escaped string.
*/
- function _escape($str){
+ function _escape($str){
return $str;
}
}
diff --git a/inc/auth.php b/inc/auth.php
index 696456cfc..8be270bfc 100644
--- a/inc/auth.php
+++ b/inc/auth.php
@@ -48,15 +48,15 @@ function auth_setup() {
// try to load auth backend from plugins
foreach ($plugin_controller->getList('auth') as $plugin) {
- if ($conf['authtype'] === $plugin) {
- $auth = $plugin_controller->load('auth', $plugin);
- break;
- } elseif ('auth' . $conf['authtype'] === $plugin) {
- // matches old auth backends (pre-Weatherwax)
- $auth = $plugin_controller->load('auth', $plugin);
- msg('Your authtype setting is deprecated. You must set $conf[\'authtype\'] = "auth' . $conf['authtype'] . '"'
- . ' in your configuration (see <a href="https://www.dokuwiki.org/auth">Authentication Backends</a>)',-1,'','',MSG_ADMINS_ONLY);
- }
+ if ($conf['authtype'] === $plugin) {
+ $auth = $plugin_controller->load('auth', $plugin);
+ break;
+ } elseif ('auth' . $conf['authtype'] === $plugin) {
+ // matches old auth backends (pre-Weatherwax)
+ $auth = $plugin_controller->load('auth', $plugin);
+ msg('Your authtype setting is deprecated. You must set $conf[\'authtype\'] = "auth' . $conf['authtype'] . '"'
+ . ' in your configuration (see <a href="https://www.dokuwiki.org/auth">Authentication Backends</a>)',-1,'','',MSG_ADMINS_ONLY);
+ }
}
if(!isset($auth) || !$auth){
@@ -65,10 +65,10 @@ function auth_setup() {
}
if ($auth->success == false) {
- // degrade to unauthenticated user
- unset($auth);
- auth_logoff();
- msg($lang['authtempfail'], -1);
+ // degrade to unauthenticated user
+ unset($auth);
+ auth_logoff();
+ msg($lang['authtempfail'], -1);
return false;
}
diff --git a/inc/html.php b/inc/html.php
index a2a726406..03e9dc751 100644
--- a/inc/html.php
+++ b/inc/html.php
@@ -1240,20 +1240,20 @@ function html_diff($text='',$intro=true,$type=null){
}
function html_insert_softbreaks($diffhtml) {
- // search the diff html string for both:
- // - html tags, so these can be ignored
- // - long strings of characters without breaking characters
- return preg_replace_callback('/<[^>]*>|[^<> ]{12,}/','html_softbreak_callback',$diffhtml);
+ // search the diff html string for both:
+ // - html tags, so these can be ignored
+ // - long strings of characters without breaking characters
+ return preg_replace_callback('/<[^>]*>|[^<> ]{12,}/','html_softbreak_callback',$diffhtml);
}
function html_softbreak_callback($match){
- // if match is an html tag, return it intact
- if ($match[0]{0} == '<') return $match[0];
+ // if match is an html tag, return it intact
+ if ($match[0]{0} == '<') return $match[0];
- // its a long string without a breaking character,
- // make certain characters into breaking characters by inserting a
- // breaking character (zero length space, U+200B / #8203) in front them.
- $regex = <<< REGEX
+ // its a long string without a breaking character,
+ // make certain characters into breaking characters by inserting a
+ // breaking character (zero length space, U+200B / #8203) in front them.
+ $regex = <<< REGEX
(?(?= # start a conditional expression with a positive look ahead ...
&\#?\\w{1,6};) # ... for html entities - we don't want to split them (ok to catch some invalid combinations)
&\#?\\w{1,6}; # yes pattern - a quicker match for the html entity, since we know we have one
@@ -1262,7 +1262,7 @@ function html_softbreak_callback($match){
)+ # end conditional expression
REGEX;
- return preg_replace('<'.$regex.'>xu','\0&#8203;',$match[0]);
+ return preg_replace('<'.$regex.'>xu','\0&#8203;',$match[0]);
}
/**
diff --git a/inc/parser/handler.php b/inc/parser/handler.php
index 1cf32aaed..b2d0f9df4 100644
--- a/inc/parser/handler.php
+++ b/inc/parser/handler.php
@@ -35,8 +35,8 @@ class Doku_Handler {
$this->CallWriter->finalise();
if ( $this->status['section'] ) {
- $last_call = end($this->calls);
- array_push($this->calls,array('section_close',array(), $last_call[2]));
+ $last_call = end($this->calls);
+ array_push($this->calls,array('section_close',array(), $last_call[2]));
}
if ( $this->rewriteBlocks ) {
@@ -75,7 +75,7 @@ class Doku_Handler {
$data = $plugin->handle($match, $state, $pos, $this);
}
if ($data !== false) {
- $this->addPluginCall($pluginname,$data,$state,$pos,$match);
+ $this->addPluginCall($pluginname,$data,$state,$pos,$match);
}
return true;
}
@@ -190,8 +190,8 @@ class Doku_Handler {
// footnotes can not be nested - however due to limitations in lexer it can't be prevented
// we will still enter a new footnote mode, we just do nothing
if ($this->_footnote) {
- $this->_addCall('cdata',array($match), $pos);
- break;
+ $this->_addCall('cdata',array($match), $pos);
+ break;
}
$this->_footnote = true;
@@ -203,8 +203,8 @@ class Doku_Handler {
case DOKU_LEXER_EXIT:
// check whether we have already exitted the footnote mode, can happen if the modes were nested
if (!$this->_footnote) {
- $this->_addCall('cdata',array($match), $pos);
- break;
+ $this->_addCall('cdata',array($match), $pos);
+ break;
}
$this->_footnote = false;
@@ -433,7 +433,7 @@ class Doku_Handler {
//decide which kind of link it is
if ( preg_match('/^[a-zA-Z0-9\.]+>{1}.*$/u',$link[0]) ) {
- // Interwiki
+ // Interwiki
$interwiki = explode('>',$link[0],2);
$this->_addCall(
'interwikilink',
@@ -441,35 +441,35 @@ class Doku_Handler {
$pos
);
}elseif ( preg_match('/^\\\\\\\\[^\\\\]+?\\\\/u',$link[0]) ) {
- // Windows Share
+ // Windows Share
$this->_addCall(
'windowssharelink',
array($link[0],$link[1]),
$pos
);
}elseif ( preg_match('#^([a-z0-9\-\.+]+?)://#i',$link[0]) ) {
- // external link (accepts all protocols)
+ // external link (accepts all protocols)
$this->_addCall(
'externallink',
array($link[0],$link[1]),
$pos
);
}elseif ( preg_match('<'.PREG_PATTERN_VALID_EMAIL.'>',$link[0]) ) {
- // E-Mail (pattern above is defined in inc/mail.php)
+ // E-Mail (pattern above is defined in inc/mail.php)
$this->_addCall(
'emaillink',
array($link[0],$link[1]),
$pos
);
}elseif ( preg_match('!^#.+!',$link[0]) ){
- // local link
+ // local link
$this->_addCall(
'locallink',
array(substr($link[0],1),$link[1]),
$pos
);
}else{
- // internal link
+ // internal link
$this->_addCall(
'internallink',
array($link[0],$link[1]),
@@ -520,10 +520,10 @@ class Doku_Handler {
$p['details'] = (preg_match('/\b(desc|detail)/',$params));
if (preg_match('/\b(\d+)([dhm])\b/',$params,$match)) {
- $period = array('d' => 86400, 'h' => 3600, 'm' => 60);
- $p['refresh'] = max(600,$match[1]*$period[$match[2]]); // n * period in seconds, minimum 10 minutes
+ $period = array('d' => 86400, 'h' => 3600, 'm' => 60);
+ $p['refresh'] = max(600,$match[1]*$period[$match[2]]); // n * period in seconds, minimum 10 minutes
} else {
- $p['refresh'] = 14400; // default to 4 hours
+ $p['refresh'] = 14400; // default to 4 hours
}
$this->_addCall('rss',array($link,$p),$pos);
@@ -1034,7 +1034,7 @@ class Doku_Handler_Preformatted {
break;
case 'preformatted_end':
if (trim($this->text)) {
- $this->CallWriter->writeCall(array('preformatted',array($this->text),$this->pos));
+ $this->CallWriter->writeCall(array('preformatted',array($this->text),$this->pos));
}
// see FS#1699 & FS#1652, add 'eol' instructions to ensure proper triggering of following p_open
$this->CallWriter->writeCall(array('eol',array(),$this->pos));
@@ -1289,116 +1289,116 @@ class Doku_Handler_Table {
$call = $this->tableCalls[$key];
switch ($call[0]) {
- case 'tablerow_open':
+ case 'tablerow_open':
- $lastRow++;
- $lastCell = 0;
- break;
+ $lastRow++;
+ $lastCell = 0;
+ break;
- case 'tablecell_open':
- case 'tableheader_open':
+ case 'tablecell_open':
+ case 'tableheader_open':
- $lastCell++;
- $cellKey[$lastRow][$lastCell] = $key;
- break;
+ $lastCell++;
+ $cellKey[$lastRow][$lastCell] = $key;
+ break;
- case 'table_align':
+ case 'table_align':
- $prev = in_array($this->tableCalls[$key-1][0], array('tablecell_open', 'tableheader_open'));
- $next = in_array($this->tableCalls[$key+1][0], array('tablecell_close', 'tableheader_close'));
- // If the cell is empty, align left
- if ($prev && $next) {
- $this->tableCalls[$key-1][1][1] = 'left';
+ $prev = in_array($this->tableCalls[$key-1][0], array('tablecell_open', 'tableheader_open'));
+ $next = in_array($this->tableCalls[$key+1][0], array('tablecell_close', 'tableheader_close'));
+ // If the cell is empty, align left
+ if ($prev && $next) {
+ $this->tableCalls[$key-1][1][1] = 'left';
- // If the previous element was a cell open, align right
- } elseif ($prev) {
- $this->tableCalls[$key-1][1][1] = 'right';
+ // If the previous element was a cell open, align right
+ } elseif ($prev) {
+ $this->tableCalls[$key-1][1][1] = 'right';
- // If the next element is the close of an element, align either center or left
- } elseif ( $next) {
- if ( $this->tableCalls[$cellKey[$lastRow][$lastCell]][1][1] == 'right' ) {
- $this->tableCalls[$cellKey[$lastRow][$lastCell]][1][1] = 'center';
- } else {
- $this->tableCalls[$cellKey[$lastRow][$lastCell]][1][1] = 'left';
- }
+ // If the next element is the close of an element, align either center or left
+ } elseif ( $next) {
+ if ( $this->tableCalls[$cellKey[$lastRow][$lastCell]][1][1] == 'right' ) {
+ $this->tableCalls[$cellKey[$lastRow][$lastCell]][1][1] = 'center';
+ } else {
+ $this->tableCalls[$cellKey[$lastRow][$lastCell]][1][1] = 'left';
+ }
- }
+ }
- // Now convert the whitespace back to cdata
- $this->tableCalls[$key][0] = 'cdata';
- break;
+ // Now convert the whitespace back to cdata
+ $this->tableCalls[$key][0] = 'cdata';
+ break;
- case 'colspan':
+ case 'colspan':
- $this->tableCalls[$key-1][1][0] = false;
+ $this->tableCalls[$key-1][1][0] = false;
- for($i = $key-2; $i >= $cellKey[$lastRow][1]; $i--) {
+ for($i = $key-2; $i >= $cellKey[$lastRow][1]; $i--) {
- if ( $this->tableCalls[$i][0] == 'tablecell_open' || $this->tableCalls[$i][0] == 'tableheader_open' ) {
+ if ( $this->tableCalls[$i][0] == 'tablecell_open' || $this->tableCalls[$i][0] == 'tableheader_open' ) {
- if ( false !== $this->tableCalls[$i][1][0] ) {
- $this->tableCalls[$i][1][0]++;
- break;
- }
+ if ( false !== $this->tableCalls[$i][1][0] ) {
+ $this->tableCalls[$i][1][0]++;
+ break;
+ }
+ }
}
- }
- $toDelete[] = $key-1;
- $toDelete[] = $key;
- $toDelete[] = $key+1;
- break;
+ $toDelete[] = $key-1;
+ $toDelete[] = $key;
+ $toDelete[] = $key+1;
+ break;
- case 'rowspan':
+ case 'rowspan':
- if ( $this->tableCalls[$key-1][0] == 'cdata' ) {
- // ignore rowspan if previous call was cdata (text mixed with :::) we don't have to check next call as that wont match regex
- $this->tableCalls[$key][0] = 'cdata';
+ if ( $this->tableCalls[$key-1][0] == 'cdata' ) {
+ // ignore rowspan if previous call was cdata (text mixed with :::) we don't have to check next call as that wont match regex
+ $this->tableCalls[$key][0] = 'cdata';
- } else {
+ } else {
- $spanning_cell = null;
- for($i = $lastRow-1; $i > 0; $i--) {
+ $spanning_cell = null;
+ for($i = $lastRow-1; $i > 0; $i--) {
- if ( $this->tableCalls[$cellKey[$i][$lastCell]][0] == 'tablecell_open' || $this->tableCalls[$cellKey[$i][$lastCell]][0] == 'tableheader_open' ) {
+ if ( $this->tableCalls[$cellKey[$i][$lastCell]][0] == 'tablecell_open' || $this->tableCalls[$cellKey[$i][$lastCell]][0] == 'tableheader_open' ) {
- if ($this->tableCalls[$cellKey[$i][$lastCell]][1][2] >= $lastRow - $i) {
- $spanning_cell = $i;
- break;
- }
+ if ($this->tableCalls[$cellKey[$i][$lastCell]][1][2] >= $lastRow - $i) {
+ $spanning_cell = $i;
+ break;
+ }
+ }
}
- }
- if (is_null($spanning_cell)) {
- // No spanning cell found, so convert this cell to
- // an empty one to avoid broken tables
- $this->tableCells[$key][1][1] = '';
- continue;
- }
- $this->tableCalls[$cellKey[$spanning_cell][$lastCell]][1][2]++;
+ if (is_null($spanning_cell)) {
+ // No spanning cell found, so convert this cell to
+ // an empty one to avoid broken tables
+ $this->tableCells[$key][1][1] = '';
+ continue;
+ }
+ $this->tableCalls[$cellKey[$spanning_cell][$lastCell]][1][2]++;
- $this->tableCalls[$key-1][1][2] = false;
+ $this->tableCalls[$key-1][1][2] = false;
- $toDelete[] = $key-1;
- $toDelete[] = $key;
- $toDelete[] = $key+1;
- }
- break;
+ $toDelete[] = $key-1;
+ $toDelete[] = $key;
+ $toDelete[] = $key+1;
+ }
+ break;
- case 'tablerow_close':
+ case 'tablerow_close':
- // Fix broken tables by adding missing cells
- while (++$lastCell < $this->maxCols) {
- array_splice($this->tableCalls, $key, 0, array(
- array('tablecell_open', array(1, null, 1), $call[2]),
- array('cdata', array(''), $call[2]),
- array('tablecell_close', array(), $call[2])));
- $key += 3;
- }
+ // Fix broken tables by adding missing cells
+ while (++$lastCell < $this->maxCols) {
+ array_splice($this->tableCalls, $key, 0, array(
+ array('tablecell_open', array(1, null, 1), $call[2]),
+ array('cdata', array(''), $call[2]),
+ array('tablecell_close', array(), $call[2])));
+ $key += 3;
+ }
- break;
+ break;
}
}
diff --git a/inc/parser/lexer.php b/inc/parser/lexer.php
index b5bcb9612..9fe1be583 100644
--- a/inc/parser/lexer.php
+++ b/inc/parser/lexer.php
@@ -176,25 +176,25 @@ class Doku_LexerParallelRegex {
*/
switch($elt) {
- case '(':
- $pattern .= '\(';
- break;
- case ')':
- if ($level > 0)
- $level--; /* closing (? */
- else
- $pattern .= '\\';
- $pattern .= ')';
- break;
- case '(?':
- $level++;
- $pattern .= '(?';
- break;
- default:
- if (substr($elt, 0, 1) == '\\')
- $pattern .= $elt;
- else
- $pattern .= str_replace('/', '\/', $elt);
+ case '(':
+ $pattern .= '\(';
+ break;
+ case ')':
+ if ($level > 0)
+ $level--; /* closing (? */
+ else
+ $pattern .= '\\';
+ $pattern .= ')';
+ break;
+ case '(?':
+ $level++;
+ $pattern .= '(?';
+ break;
+ default:
+ if (substr($elt, 0, 1) == '\\')
+ $pattern .= $elt;
+ else
+ $pattern .= str_replace('/', '\/', $elt);
}
}
$this->_patterns[$i] = "($pattern)";
@@ -513,8 +513,8 @@ class Doku_Lexer {
// modes starting with plugin_ are all handled by the same
// handler but with an additional parameter
if(substr($handler,0,7)=='plugin_'){
- list($handler,$plugin) = explode('_',$handler,2);
- return $this->_parser->$handler($content, $is_match, $pos, $plugin);
+ list($handler,$plugin) = explode('_',$handler,2);
+ return $this->_parser->$handler($content, $is_match, $pos, $plugin);
}
return $this->_parser->$handler($content, $is_match, $pos);
diff --git a/inc/parser/metadata.php b/inc/parser/metadata.php
index 7d186e069..2d9da823d 100644
--- a/inc/parser/metadata.php
+++ b/inc/parser/metadata.php
@@ -23,448 +23,448 @@ require_once DOKU_INC . 'inc/parser/renderer.php';
*/
class Doku_Renderer_metadata extends Doku_Renderer {
- var $doc = '';
- var $meta = array();
- var $persistent = array();
+ var $doc = '';
+ var $meta = array();
+ var $persistent = array();
- var $headers = array();
- var $capture = true;
- var $store = '';
- var $firstimage = '';
+ var $headers = array();
+ var $capture = true;
+ var $store = '';
+ var $firstimage = '';
- function getFormat(){
- return 'metadata';
- }
-
- function document_start(){
- global $ID;
-
- $this->headers = array();
-
- // external pages are missing create date
- if(!$this->persistent['date']['created']){
- $this->persistent['date']['created'] = filectime(wikiFN($ID));
+ function getFormat(){
+ return 'metadata';
}
- if(!isset($this->persistent['user'])){
- $this->persistent['user'] = '';
- }
- if(!isset($this->persistent['creator'])){
- $this->persistent['creator'] = '';
+
+ function document_start(){
+ global $ID;
+
+ $this->headers = array();
+
+ // external pages are missing create date
+ if(!$this->persistent['date']['created']){
+ $this->persistent['date']['created'] = filectime(wikiFN($ID));
+ }
+ if(!isset($this->persistent['user'])){
+ $this->persistent['user'] = '';
+ }
+ if(!isset($this->persistent['creator'])){
+ $this->persistent['creator'] = '';
+ }
+ // reset metadata to persistent values
+ $this->meta = $this->persistent;
}
- // reset metadata to persistent values
- $this->meta = $this->persistent;
- }
- function document_end(){
- global $ID;
+ function document_end(){
+ global $ID;
- // store internal info in metadata (notoc,nocache)
- $this->meta['internal'] = $this->info;
+ // store internal info in metadata (notoc,nocache)
+ $this->meta['internal'] = $this->info;
- if (!isset($this->meta['description']['abstract'])){
- // cut off too long abstracts
- $this->doc = trim($this->doc);
- if (strlen($this->doc) > 500)
- $this->doc = utf8_substr($this->doc, 0, 500).'…';
- $this->meta['description']['abstract'] = $this->doc;
- }
+ if (!isset($this->meta['description']['abstract'])){
+ // cut off too long abstracts
+ $this->doc = trim($this->doc);
+ if (strlen($this->doc) > 500)
+ $this->doc = utf8_substr($this->doc, 0, 500).'…';
+ $this->meta['description']['abstract'] = $this->doc;
+ }
- $this->meta['relation']['firstimage'] = $this->firstimage;
+ $this->meta['relation']['firstimage'] = $this->firstimage;
+
+ if(!isset($this->meta['date']['modified'])){
+ $this->meta['date']['modified'] = filemtime(wikiFN($ID));
+ }
- if(!isset($this->meta['date']['modified'])){
- $this->meta['date']['modified'] = filemtime(wikiFN($ID));
}
- }
+ function toc_additem($id, $text, $level) {
+ global $conf;
- function toc_additem($id, $text, $level) {
- global $conf;
+ //only add items within configured levels
+ if($level >= $conf['toptoclevel'] && $level <= $conf['maxtoclevel']){
+ // the TOC is one of our standard ul list arrays ;-)
+ $this->meta['description']['tableofcontents'][] = array(
+ 'hid' => $id,
+ 'title' => $text,
+ 'type' => 'ul',
+ 'level' => $level-$conf['toptoclevel']+1
+ );
+ }
- //only add items within configured levels
- if($level >= $conf['toptoclevel'] && $level <= $conf['maxtoclevel']){
- // the TOC is one of our standard ul list arrays ;-)
- $this->meta['description']['tableofcontents'][] = array(
- 'hid' => $id,
- 'title' => $text,
- 'type' => 'ul',
- 'level' => $level-$conf['toptoclevel']+1
- );
}
- }
-
- function header($text, $level, $pos) {
- if (!isset($this->meta['title'])) $this->meta['title'] = $text;
+ function header($text, $level, $pos) {
+ if (!isset($this->meta['title'])) $this->meta['title'] = $text;
- // add the header to the TOC
- $hid = $this->_headerToLink($text,'true');
- $this->toc_additem($hid, $text, $level);
+ // add the header to the TOC
+ $hid = $this->_headerToLink($text,'true');
+ $this->toc_additem($hid, $text, $level);
- // add to summary
- if ($this->capture && ($level > 1)) $this->doc .= DOKU_LF.$text.DOKU_LF;
- }
+ // add to summary
+ if ($this->capture && ($level > 1)) $this->doc .= DOKU_LF.$text.DOKU_LF;
+ }
- function section_open($level){}
- function section_close(){}
+ function section_open($level){}
+ function section_close(){}
- function cdata($text){
- if ($this->capture) $this->doc .= $text;
- }
+ function cdata($text){
+ if ($this->capture) $this->doc .= $text;
+ }
- function p_open(){
- if ($this->capture) $this->doc .= DOKU_LF;
- }
+ function p_open(){
+ if ($this->capture) $this->doc .= DOKU_LF;
+ }
- function p_close(){
- if ($this->capture){
- if (strlen($this->doc) > 250) $this->capture = false;
- else $this->doc .= DOKU_LF;
+ function p_close(){
+ if ($this->capture){
+ if (strlen($this->doc) > 250) $this->capture = false;
+ else $this->doc .= DOKU_LF;
+ }
}
- }
- function linebreak(){
- if ($this->capture) $this->doc .= DOKU_LF;
- }
+ function linebreak(){
+ if ($this->capture) $this->doc .= DOKU_LF;
+ }
- function hr(){
- if ($this->capture){
- if (strlen($this->doc) > 250) $this->capture = false;
- else $this->doc .= DOKU_LF.'----------'.DOKU_LF;
+ function hr(){
+ if ($this->capture){
+ if (strlen($this->doc) > 250) $this->capture = false;
+ else $this->doc .= DOKU_LF.'----------'.DOKU_LF;
+ }
}
- }
- /**
- * Callback for footnote start syntax
- *
- * All following content will go to the footnote instead of
- * the document. To achieve this the previous rendered content
- * is moved to $store and $doc is cleared
- *
- * @author Andreas Gohr <andi@splitbrain.org>
- */
- function footnote_open() {
- if ($this->capture){
- // move current content to store and record footnote
- $this->store = $this->doc;
- $this->doc = '';
+ /**
+ * Callback for footnote start syntax
+ *
+ * All following content will go to the footnote instead of
+ * the document. To achieve this the previous rendered content
+ * is moved to $store and $doc is cleared
+ *
+ * @author Andreas Gohr <andi@splitbrain.org>
+ */
+ function footnote_open() {
+ if ($this->capture){
+ // move current content to store and record footnote
+ $this->store = $this->doc;
+ $this->doc = '';
+ }
}
- }
- /**
- * Callback for footnote end syntax
- *
- * All rendered content is moved to the $footnotes array and the old
- * content is restored from $store again
- *
- * @author Andreas Gohr
- */
- function footnote_close() {
- if ($this->capture){
- // restore old content
- $this->doc = $this->store;
- $this->store = '';
- }
- }
-
- function listu_open(){
- if ($this->capture) $this->doc .= DOKU_LF;
- }
-
- function listu_close(){
- if ($this->capture && (strlen($this->doc) > 250)) $this->capture = false;
- }
-
- function listo_open(){
- if ($this->capture) $this->doc .= DOKU_LF;
- }
-
- function listo_close(){
- if ($this->capture && (strlen($this->doc) > 250)) $this->capture = false;
- }
-
- function listitem_open($level){
- if ($this->capture) $this->doc .= str_repeat(DOKU_TAB, $level).'* ';
- }
-
- function listitem_close(){
- if ($this->capture) $this->doc .= DOKU_LF;
- }
-
- function listcontent_open(){}
- function listcontent_close(){}
-
- function unformatted($text){
- if ($this->capture) $this->doc .= $text;
- }
-
- function preformatted($text){
- if ($this->capture) $this->doc .= $text;
- }
-
- function file($text, $lang = null, $file = null){
- if ($this->capture){
- $this->doc .= DOKU_LF.$text;
- if (strlen($this->doc) > 250) $this->capture = false;
- else $this->doc .= DOKU_LF;
- }
- }
-
- function quote_open(){
- if ($this->capture) $this->doc .= DOKU_LF.DOKU_TAB.'"';
- }
-
- function quote_close(){
- if ($this->capture){
- $this->doc .= '"';
- if (strlen($this->doc) > 250) $this->capture = false;
- else $this->doc .= DOKU_LF;
- }
- }
-
- function code($text, $language = NULL, $file = null){
- if ($this->capture){
- $this->doc .= DOKU_LF.$text;
- if (strlen($this->doc) > 250) $this->capture = false;
- else $this->doc .= DOKU_LF;
- }
- }
+ /**
+ * Callback for footnote end syntax
+ *
+ * All rendered content is moved to the $footnotes array and the old
+ * content is restored from $store again
+ *
+ * @author Andreas Gohr
+ */
+ function footnote_close() {
+ if ($this->capture){
+ // restore old content
+ $this->doc = $this->store;
+ $this->store = '';
+ }
+ }
- function acronym($acronym){
- if ($this->capture) $this->doc .= $acronym;
- }
+ function listu_open(){
+ if ($this->capture) $this->doc .= DOKU_LF;
+ }
- function smiley($smiley){
- if ($this->capture) $this->doc .= $smiley;
- }
+ function listu_close(){
+ if ($this->capture && (strlen($this->doc) > 250)) $this->capture = false;
+ }
- function entity($entity){
- if ($this->capture) $this->doc .= $entity;
- }
+ function listo_open(){
+ if ($this->capture) $this->doc .= DOKU_LF;
+ }
- function multiplyentity($x, $y){
- if ($this->capture) $this->doc .= $x.'×'.$y;
- }
+ function listo_close(){
+ if ($this->capture && (strlen($this->doc) > 250)) $this->capture = false;
+ }
- function singlequoteopening(){
- global $lang;
- if ($this->capture) $this->doc .= $lang['singlequoteopening'];
- }
+ function listitem_open($level){
+ if ($this->capture) $this->doc .= str_repeat(DOKU_TAB, $level).'* ';
+ }
- function singlequoteclosing(){
- global $lang;
- if ($this->capture) $this->doc .= $lang['singlequoteclosing'];
- }
+ function listitem_close(){
+ if ($this->capture) $this->doc .= DOKU_LF;
+ }
- function apostrophe() {
- global $lang;
- if ($this->capture) $this->doc .= $lang['apostrophe'];
- }
+ function listcontent_open(){}
+ function listcontent_close(){}
- function doublequoteopening(){
- global $lang;
- if ($this->capture) $this->doc .= $lang['doublequoteopening'];
- }
+ function unformatted($text){
+ if ($this->capture) $this->doc .= $text;
+ }
- function doublequoteclosing(){
- global $lang;
- if ($this->capture) $this->doc .= $lang['doublequoteclosing'];
- }
+ function preformatted($text){
+ if ($this->capture) $this->doc .= $text;
+ }
- function camelcaselink($link) {
- $this->internallink($link, $link);
- }
+ function file($text, $lang = null, $file = null){
+ if ($this->capture){
+ $this->doc .= DOKU_LF.$text;
+ if (strlen($this->doc) > 250) $this->capture = false;
+ else $this->doc .= DOKU_LF;
+ }
+ }
- function locallink($hash, $name = NULL){}
+ function quote_open(){
+ if ($this->capture) $this->doc .= DOKU_LF.DOKU_TAB.'"';
+ }
- /**
- * keep track of internal links in $this->meta['relation']['references']
- */
- function internallink($id, $name = NULL){
- global $ID;
+ function quote_close(){
+ if ($this->capture){
+ $this->doc .= '"';
+ if (strlen($this->doc) > 250) $this->capture = false;
+ else $this->doc .= DOKU_LF;
+ }
+ }
- if(is_array($name)) {
- $this->_firstimage($name['src']);
- if ($name['type'] == 'internalmedia') $this->_recordMediaUsage($name['src']);
+ function code($text, $language = NULL, $file = null){
+ if ($this->capture){
+ $this->doc .= DOKU_LF.$text;
+ if (strlen($this->doc) > 250) $this->capture = false;
+ else $this->doc .= DOKU_LF;
+ }
}
- $parts = explode('?', $id, 2);
- if (count($parts) === 2) {
- $id = $parts[0];
+ function acronym($acronym){
+ if ($this->capture) $this->doc .= $acronym;
}
+ function smiley($smiley){
+ if ($this->capture) $this->doc .= $smiley;
+ }
- $default = $this->_simpleTitle($id);
+ function entity($entity){
+ if ($this->capture) $this->doc .= $entity;
+ }
- // first resolve and clean up the $id
- resolve_pageid(getNS($ID), $id, $exists);
- list($page, $hash) = explode('#', $id, 2);
+ function multiplyentity($x, $y){
+ if ($this->capture) $this->doc .= $x.'×'.$y;
+ }
- // set metadata
- $this->meta['relation']['references'][$page] = $exists;
- // $data = array('relation' => array('isreferencedby' => array($ID => true)));
- // p_set_metadata($id, $data);
+ function singlequoteopening(){
+ global $lang;
+ if ($this->capture) $this->doc .= $lang['singlequoteopening'];
+ }
- // add link title to summary
- if ($this->capture){
- $name = $this->_getLinkTitle($name, $default, $id);
- $this->doc .= $name;
+ function singlequoteclosing(){
+ global $lang;
+ if ($this->capture) $this->doc .= $lang['singlequoteclosing'];
}
- }
- function externallink($url, $name = NULL){
- if(is_array($name)) {
- $this->_firstimage($name['src']);
- if ($name['type'] == 'internalmedia') $this->_recordMediaUsage($name['src']);
+ function apostrophe() {
+ global $lang;
+ if ($this->capture) $this->doc .= $lang['apostrophe'];
}
- if ($this->capture){
- $this->doc .= $this->_getLinkTitle($name, '<' . $url . '>');
+ function doublequoteopening(){
+ global $lang;
+ if ($this->capture) $this->doc .= $lang['doublequoteopening'];
}
- }
- function interwikilink($match, $name = NULL, $wikiName, $wikiUri){
- if(is_array($name)) {
- $this->_firstimage($name['src']);
- if ($name['type'] == 'internalmedia') $this->_recordMediaUsage($name['src']);
+ function doublequoteclosing(){
+ global $lang;
+ if ($this->capture) $this->doc .= $lang['doublequoteclosing'];
}
- if ($this->capture){
- list($wikiUri, $hash) = explode('#', $wikiUri, 2);
- $name = $this->_getLinkTitle($name, $wikiUri);
- $this->doc .= $name;
+ function camelcaselink($link) {
+ $this->internallink($link, $link);
}
- }
- function windowssharelink($url, $name = NULL){
- if(is_array($name)) {
- $this->_firstimage($name['src']);
- if ($name['type'] == 'internalmedia') $this->_recordMediaUsage($name['src']);
+ function locallink($hash, $name = NULL){}
+
+ /**
+ * keep track of internal links in $this->meta['relation']['references']
+ */
+ function internallink($id, $name = NULL){
+ global $ID;
+
+ if(is_array($name)) {
+ $this->_firstimage($name['src']);
+ if ($name['type'] == 'internalmedia') $this->_recordMediaUsage($name['src']);
+ }
+
+ $parts = explode('?', $id, 2);
+ if (count($parts) === 2) {
+ $id = $parts[0];
+ }
+
+
+ $default = $this->_simpleTitle($id);
+
+ // first resolve and clean up the $id
+ resolve_pageid(getNS($ID), $id, $exists);
+ list($page, $hash) = explode('#', $id, 2);
+
+ // set metadata
+ $this->meta['relation']['references'][$page] = $exists;
+ // $data = array('relation' => array('isreferencedby' => array($ID => true)));
+ // p_set_metadata($id, $data);
+
+ // add link title to summary
+ if ($this->capture){
+ $name = $this->_getLinkTitle($name, $default, $id);
+ $this->doc .= $name;
+ }
}
- if ($this->capture){
- if ($name) $this->doc .= $name;
- else $this->doc .= '<'.$url.'>';
+ function externallink($url, $name = NULL){
+ if(is_array($name)) {
+ $this->_firstimage($name['src']);
+ if ($name['type'] == 'internalmedia') $this->_recordMediaUsage($name['src']);
+ }
+
+ if ($this->capture){
+ $this->doc .= $this->_getLinkTitle($name, '<' . $url . '>');
+ }
}
- }
- function emaillink($address, $name = NULL){
- if(is_array($name)) {
- $this->_firstimage($name['src']);
- if ($name['type'] == 'internalmedia') $this->_recordMediaUsage($name['src']);
+ function interwikilink($match, $name = NULL, $wikiName, $wikiUri){
+ if(is_array($name)) {
+ $this->_firstimage($name['src']);
+ if ($name['type'] == 'internalmedia') $this->_recordMediaUsage($name['src']);
+ }
+
+ if ($this->capture){
+ list($wikiUri, $hash) = explode('#', $wikiUri, 2);
+ $name = $this->_getLinkTitle($name, $wikiUri);
+ $this->doc .= $name;
+ }
}
- if ($this->capture){
- if ($name) $this->doc .= $name;
- else $this->doc .= '<'.$address.'>';
+ function windowssharelink($url, $name = NULL){
+ if(is_array($name)) {
+ $this->_firstimage($name['src']);
+ if ($name['type'] == 'internalmedia') $this->_recordMediaUsage($name['src']);
+ }
+
+ if ($this->capture){
+ if ($name) $this->doc .= $name;
+ else $this->doc .= '<'.$url.'>';
+ }
}
- }
- function internalmedia($src, $title=NULL, $align=NULL, $width=NULL,
- $height=NULL, $cache=NULL, $linking=NULL){
- if ($this->capture && $title) $this->doc .= '['.$title.']';
- $this->_firstimage($src);
- $this->_recordMediaUsage($src);
- }
+ function emaillink($address, $name = NULL){
+ if(is_array($name)) {
+ $this->_firstimage($name['src']);
+ if ($name['type'] == 'internalmedia') $this->_recordMediaUsage($name['src']);
+ }
- function externalmedia($src, $title=NULL, $align=NULL, $width=NULL,
- $height=NULL, $cache=NULL, $linking=NULL){
- if ($this->capture && $title) $this->doc .= '['.$title.']';
- $this->_firstimage($src);
- }
+ if ($this->capture){
+ if ($name) $this->doc .= $name;
+ else $this->doc .= '<'.$address.'>';
+ }
+ }
- function rss($url,$params) {
- $this->meta['relation']['haspart'][$url] = true;
+ function internalmedia($src, $title=NULL, $align=NULL, $width=NULL,
+ $height=NULL, $cache=NULL, $linking=NULL){
+ if ($this->capture && $title) $this->doc .= '['.$title.']';
+ $this->_firstimage($src);
+ $this->_recordMediaUsage($src);
+ }
- $this->meta['date']['valid']['age'] =
- isset($this->meta['date']['valid']['age']) ?
- min($this->meta['date']['valid']['age'],$params['refresh']) :
- $params['refresh'];
- }
+ function externalmedia($src, $title=NULL, $align=NULL, $width=NULL,
+ $height=NULL, $cache=NULL, $linking=NULL){
+ if ($this->capture && $title) $this->doc .= '['.$title.']';
+ $this->_firstimage($src);
+ }
- //----------------------------------------------------------
- // Utils
+ function rss($url,$params) {
+ $this->meta['relation']['haspart'][$url] = true;
- /**
- * Removes any Namespace from the given name but keeps
- * casing and special chars
- *
- * @author Andreas Gohr <andi@splitbrain.org>
- */
- function _simpleTitle($name){
- global $conf;
+ $this->meta['date']['valid']['age'] =
+ isset($this->meta['date']['valid']['age']) ?
+ min($this->meta['date']['valid']['age'],$params['refresh']) :
+ $params['refresh'];
+ }
- if(is_array($name)) return '';
-
- if($conf['useslash']){
- $nssep = '[:;/]';
- }else{
- $nssep = '[:;]';
- }
- $name = preg_replace('!.*'.$nssep.'!','',$name);
- //if there is a hash we use the anchor name only
- $name = preg_replace('!.*#!','',$name);
- return $name;
- }
-
- /**
- * Creates a linkid from a headline
- *
- * @param string $title The headline title
- * @param boolean $create Create a new unique ID?
- * @author Andreas Gohr <andi@splitbrain.org>
- */
- function _headerToLink($title, $create=false) {
- if($create){
- return sectionID($title,$this->headers);
- }else{
- $check = false;
- return sectionID($title,$check);
- }
- }
-
- /**
- * Construct a title and handle images in titles
- *
- * @author Harry Fuecks <hfuecks@gmail.com>
- */
- function _getLinkTitle($title, $default, $id=NULL) {
- global $conf;
-
- $isImage = false;
- if (is_array($title)){
- if($title['title']) return '['.$title['title'].']';
- } else if (is_null($title) || trim($title)==''){
- if (useHeading('content') && $id){
- $heading = p_get_first_heading($id,METADATA_DONT_RENDER);
- if ($heading) return $heading;
- }
- return $default;
- } else {
- return $title;
+ //----------------------------------------------------------
+ // Utils
+
+ /**
+ * Removes any Namespace from the given name but keeps
+ * casing and special chars
+ *
+ * @author Andreas Gohr <andi@splitbrain.org>
+ */
+ function _simpleTitle($name){
+ global $conf;
+
+ if(is_array($name)) return '';
+
+ if($conf['useslash']){
+ $nssep = '[:;/]';
+ }else{
+ $nssep = '[:;]';
+ }
+ $name = preg_replace('!.*'.$nssep.'!','',$name);
+ //if there is a hash we use the anchor name only
+ $name = preg_replace('!.*#!','',$name);
+ return $name;
}
- }
- function _firstimage($src){
- if($this->firstimage) return;
- global $ID;
+ /**
+ * Creates a linkid from a headline
+ *
+ * @param string $title The headline title
+ * @param boolean $create Create a new unique ID?
+ * @author Andreas Gohr <andi@splitbrain.org>
+ */
+ function _headerToLink($title, $create=false) {
+ if($create){
+ return sectionID($title,$this->headers);
+ }else{
+ $check = false;
+ return sectionID($title,$check);
+ }
+ }
- list($src,$hash) = explode('#',$src,2);
- if(!media_isexternal($src)){
- resolve_mediaid(getNS($ID),$src, $exists);
+ /**
+ * Construct a title and handle images in titles
+ *
+ * @author Harry Fuecks <hfuecks@gmail.com>
+ */
+ function _getLinkTitle($title, $default, $id=NULL) {
+ global $conf;
+
+ $isImage = false;
+ if (is_array($title)){
+ if($title['title']) return '['.$title['title'].']';
+ } else if (is_null($title) || trim($title)==''){
+ if (useHeading('content') && $id){
+ $heading = p_get_first_heading($id,METADATA_DONT_RENDER);
+ if ($heading) return $heading;
+ }
+ return $default;
+ } else {
+ return $title;
+ }
}
- if(preg_match('/.(jpe?g|gif|png)$/i',$src)){
- $this->firstimage = $src;
+
+ function _firstimage($src){
+ if($this->firstimage) return;
+ global $ID;
+
+ list($src,$hash) = explode('#',$src,2);
+ if(!media_isexternal($src)){
+ resolve_mediaid(getNS($ID),$src, $exists);
+ }
+ if(preg_match('/.(jpe?g|gif|png)$/i',$src)){
+ $this->firstimage = $src;
+ }
}
- }
- function _recordMediaUsage($src) {
- global $ID;
+ function _recordMediaUsage($src) {
+ global $ID;
- list ($src, $hash) = explode('#', $src, 2);
- if (media_isexternal($src)) return;
- resolve_mediaid(getNS($ID), $src, $exists);
- $this->meta['relation']['media'][$src] = $exists;
- }
+ list ($src, $hash) = explode('#', $src, 2);
+ if (media_isexternal($src)) return;
+ resolve_mediaid(getNS($ID), $src, $exists);
+ $this->meta['relation']['media'][$src] = $exists;
+ }
}
//Setup VIM: ex: et ts=4 :
diff --git a/inc/parser/parser.php b/inc/parser/parser.php
index 4af1cd333..064178a54 100644
--- a/inc/parser/parser.php
+++ b/inc/parser/parser.php
@@ -621,7 +621,7 @@ class Doku_Parser_Mode_acronym extends Doku_Parser_Mode {
var $pattern = '';
function Doku_Parser_Mode_acronym($acronyms) {
- usort($acronyms,array($this,'_compare'));
+ usort($acronyms,array($this,'_compare'));
$this->acronyms = $acronyms;
}
@@ -652,12 +652,12 @@ class Doku_Parser_Mode_acronym extends Doku_Parser_Mode {
$a_len = strlen($a);
$b_len = strlen($b);
if ($a_len > $b_len) {
- return -1;
+ return -1;
} else if ($a_len < $b_len) {
- return 1;
+ return 1;
}
- return 0;
+ return 0;
}
}
diff --git a/inc/parser/renderer.php b/inc/parser/renderer.php
index 7df369478..4f99c668d 100644
--- a/inc/parser/renderer.php
+++ b/inc/parser/renderer.php
@@ -74,12 +74,12 @@ class Doku_Renderer extends DokuWiki_Plugin {
*/
function nest($instructions) {
- foreach ( $instructions as $instruction ) {
- // execute the callback against ourself
- if (method_exists($this,$instruction[0])) {
- call_user_func_array(array($this, $instruction[0]), $instruction[1] ? $instruction[1] : array());
+ foreach ( $instructions as $instruction ) {
+ // execute the callback against ourself
+ if (method_exists($this,$instruction[0])) {
+ call_user_func_array(array($this, $instruction[0]), $instruction[1] ? $instruction[1] : array());
+ }
}
- }
}
// dummy closing instruction issued by Doku_Handler_Nest, normally the syntax mode should
diff --git a/inc/parser/xhtml.php b/inc/parser/xhtml.php
index 84a999e56..84d837c08 100644
--- a/inc/parser/xhtml.php
+++ b/inc/parser/xhtml.php
@@ -116,11 +116,11 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
$alt = array_keys($this->footnotes, "@@FNT$id");
if (count($alt)) {
- foreach ($alt as $ref) {
- // set anchor and backlink for the other footnotes
- $this->doc .= ', <sup><a href="#fnt__'.($ref+1).'" id="fn__'.($ref+1).'" class="fn_bot">';
- $this->doc .= ($ref+1).')</a></sup> '.DOKU_LF;
- }
+ foreach ($alt as $ref) {
+ // set anchor and backlink for the other footnotes
+ $this->doc .= ', <sup><a href="#fnt__'.($ref+1).'" id="fn__'.($ref+1).'" class="fn_bot">';
+ $this->doc .= ($ref+1).')</a></sup> '.DOKU_LF;
+ }
}
// add footnote markup and close this footnote
@@ -367,12 +367,12 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
global $conf;
if($conf['phpok']){
- ob_start();
- eval($text);
- $this->doc .= ob_get_contents();
- ob_end_clean();
+ ob_start();
+ eval($text);
+ $this->doc .= ob_get_contents();
+ ob_end_clean();
} else {
- $this->doc .= p_xhtml_cached_geshi($text, 'php', $wrapper);
+ $this->doc .= p_xhtml_cached_geshi($text, 'php', $wrapper);
}
}
@@ -392,9 +392,9 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
global $conf;
if($conf['htmlok']){
- $this->doc .= $text;
+ $this->doc .= $text;
} else {
- $this->doc .= p_xhtml_cached_geshi($text, 'html4strict', $wrapper);
+ $this->doc .= p_xhtml_cached_geshi($text, 'html4strict', $wrapper);
}
}
@@ -543,7 +543,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
/**
*/
function camelcaselink($link) {
- $this->internallink($link,$link);
+ $this->internallink($link,$link);
}
diff --git a/inc/phpseclib/Math_BigInteger.php b/inc/phpseclib/Math_BigInteger.php
index 0bbedb207..55379770d 100644
--- a/inc/phpseclib/Math_BigInteger.php
+++ b/inc/phpseclib/Math_BigInteger.php
@@ -3246,7 +3246,7 @@ class Math_BigInteger {
if (!$t) {
// see HAC 4.49 "Note (controlling the error probability)"
- if ($length >= 163) { $t = 2; } // floor(1300 / 8)
+ if ($length >= 163) { $t = 2; } // floor(1300 / 8)
else if ($length >= 106) { $t = 3; } // floor( 850 / 8)
else if ($length >= 81 ) { $t = 4; } // floor( 650 / 8)
else if ($length >= 68 ) { $t = 5; } // floor( 550 / 8)
diff --git a/lib/plugins/action.php b/lib/plugins/action.php
index a2ad969d7..04b4f07a6 100644
--- a/lib/plugins/action.php
+++ b/lib/plugins/action.php
@@ -14,10 +14,10 @@ if(!defined('DOKU_INC')) die();
*/
class DokuWiki_Action_Plugin extends DokuWiki_Plugin {
- /**
- * Registers a callback function for a given event
- */
- function register(Doku_Event_Handler $controller) {
+ /**
+ * Registers a callback function for a given event
+ */
+ function register(Doku_Event_Handler $controller) {
trigger_error('register() not implemented in '.get_class($this), E_USER_WARNING);
- }
+ }
}
diff --git a/lib/plugins/config/admin.php b/lib/plugins/config/admin.php
index 29529760c..404560548 100644
--- a/lib/plugins/config/admin.php
+++ b/lib/plugins/config/admin.php
@@ -38,168 +38,168 @@ class admin_plugin_config extends DokuWiki_Admin_Plugin {
* handle user request
*/
function handle() {
- global $ID, $INPUT;
+ global $ID, $INPUT;
- if (!$this->_restore_session()) return $this->_close_session();
- if ($INPUT->int('save') != 1) return $this->_close_session();
- if (!checkSecurityToken()) return $this->_close_session();
+ if (!$this->_restore_session()) return $this->_close_session();
+ if ($INPUT->int('save') != 1) return $this->_close_session();
+ if (!checkSecurityToken()) return $this->_close_session();
- if (is_null($this->_config)) { $this->_config = new configuration($this->_file); }
+ if (is_null($this->_config)) { $this->_config = new configuration($this->_file); }
- // don't go any further if the configuration is locked
- if ($this->_config->_locked) return $this->_close_session();
+ // don't go any further if the configuration is locked
+ if ($this->_config->_locked) return $this->_close_session();
- $this->_input = $INPUT->arr('config');
+ $this->_input = $INPUT->arr('config');
- while (list($key) = each($this->_config->setting)) {
- $input = isset($this->_input[$key]) ? $this->_input[$key] : NULL;
- if ($this->_config->setting[$key]->update($input)) {
- $this->_changed = true;
+ while (list($key) = each($this->_config->setting)) {
+ $input = isset($this->_input[$key]) ? $this->_input[$key] : NULL;
+ if ($this->_config->setting[$key]->update($input)) {
+ $this->_changed = true;
+ }
+ if ($this->_config->setting[$key]->error()) $this->_error = true;
}
- if ($this->_config->setting[$key]->error()) $this->_error = true;
- }
- if ($this->_changed && !$this->_error) {
- $this->_config->save_settings($this->getPluginName());
+ if ($this->_changed && !$this->_error) {
+ $this->_config->save_settings($this->getPluginName());
- // save state & force a page reload to get the new settings to take effect
- $_SESSION['PLUGIN_CONFIG'] = array('state' => 'updated', 'time' => time());
- $this->_close_session();
- send_redirect(wl($ID,array('do'=>'admin','page'=>'config'),true,'&'));
- exit();
- } elseif(!$this->_error) {
- $this->_config->touch_settings(); // just touch to refresh cache
- }
+ // save state & force a page reload to get the new settings to take effect
+ $_SESSION['PLUGIN_CONFIG'] = array('state' => 'updated', 'time' => time());
+ $this->_close_session();
+ send_redirect(wl($ID,array('do'=>'admin','page'=>'config'),true,'&'));
+ exit();
+ } elseif(!$this->_error) {
+ $this->_config->touch_settings(); // just touch to refresh cache
+ }
- $this->_close_session();
+ $this->_close_session();
}
/**
* output appropriate html
*/
function html() {
- $allow_debug = $GLOBALS['conf']['allowdebug']; // avoid global $conf; here.
- global $lang;
- global $ID;
-
- if (is_null($this->_config)) { $this->_config = new configuration($this->_file); }
- $this->setupLocale(true);
-
- print $this->locale_xhtml('intro');
-
- ptln('<div id="config__manager">');
-
- if ($this->_config->locked)
- ptln('<div class="info">'.$this->getLang('locked').'</div>');
- elseif ($this->_error)
- ptln('<div class="error">'.$this->getLang('error').'</div>');
- elseif ($this->_changed)
- ptln('<div class="success">'.$this->getLang('updated').'</div>');
-
- // POST to script() instead of wl($ID) so config manager still works if
- // rewrite config is broken. Add $ID as hidden field to remember
- // current ID in most cases.
- ptln('<form action="'.script().'" method="post">');
- ptln('<div class="no"><input type="hidden" name="id" value="'.$ID.'" /></div>');
- formSecurityToken();
- $this->_print_h1('dokuwiki_settings', $this->getLang('_header_dokuwiki'));
-
- $undefined_settings = array();
- $in_fieldset = false;
- $first_plugin_fieldset = true;
- $first_template_fieldset = true;
- foreach($this->_config->setting as $setting) {
- if (is_a($setting, 'setting_hidden')) {
- // skip hidden (and undefined) settings
- if ($allow_debug && is_a($setting, 'setting_undefined')) {
- $undefined_settings[] = $setting;
- } else {
- continue;
- }
- } else if (is_a($setting, 'setting_fieldset')) {
- // config setting group
- if ($in_fieldset) {
- ptln(' </table>');
- ptln(' </div>');
- ptln(' </fieldset>');
- } else {
- $in_fieldset = true;
- }
- if ($first_plugin_fieldset && substr($setting->_key, 0, 10)=='plugin'.CM_KEYMARKER) {
- $this->_print_h1('plugin_settings', $this->getLang('_header_plugin'));
- $first_plugin_fieldset = false;
- } else if ($first_template_fieldset && substr($setting->_key, 0, 7)=='tpl'.CM_KEYMARKER) {
- $this->_print_h1('template_settings', $this->getLang('_header_template'));
- $first_template_fieldset = false;
- }
- ptln(' <fieldset id="'.$setting->_key.'">');
- ptln(' <legend>'.$setting->prompt($this).'</legend>');
- ptln(' <div class="table">');
- ptln(' <table class="inline">');
- } else {
- // config settings
- list($label,$input) = $setting->html($this, $this->_error);
-
- $class = $setting->is_default() ? ' class="default"' : ($setting->is_protected() ? ' class="protected"' : '');
- $error = $setting->error() ? ' class="value error"' : ' class="value"';
- $icon = $setting->caution() ? '<img src="'.DOKU_PLUGIN_IMAGES.$setting->caution().'.png" alt="'.$setting->caution().'" title="'.$this->getLang($setting->caution()).'" />' : '';
-
- ptln(' <tr'.$class.'>');
- ptln(' <td class="label">');
- ptln(' <span class="outkey">'.$setting->_out_key(true, true).'</span>');
- ptln(' '.$icon.$label);
- ptln(' </td>');
- ptln(' <td'.$error.'>'.$input.'</td>');
- ptln(' </tr>');
+ $allow_debug = $GLOBALS['conf']['allowdebug']; // avoid global $conf; here.
+ global $lang;
+ global $ID;
+
+ if (is_null($this->_config)) { $this->_config = new configuration($this->_file); }
+ $this->setupLocale(true);
+
+ print $this->locale_xhtml('intro');
+
+ ptln('<div id="config__manager">');
+
+ if ($this->_config->locked)
+ ptln('<div class="info">'.$this->getLang('locked').'</div>');
+ elseif ($this->_error)
+ ptln('<div class="error">'.$this->getLang('error').'</div>');
+ elseif ($this->_changed)
+ ptln('<div class="success">'.$this->getLang('updated').'</div>');
+
+ // POST to script() instead of wl($ID) so config manager still works if
+ // rewrite config is broken. Add $ID as hidden field to remember
+ // current ID in most cases.
+ ptln('<form action="'.script().'" method="post">');
+ ptln('<div class="no"><input type="hidden" name="id" value="'.$ID.'" /></div>');
+ formSecurityToken();
+ $this->_print_h1('dokuwiki_settings', $this->getLang('_header_dokuwiki'));
+
+ $undefined_settings = array();
+ $in_fieldset = false;
+ $first_plugin_fieldset = true;
+ $first_template_fieldset = true;
+ foreach($this->_config->setting as $setting) {
+ if (is_a($setting, 'setting_hidden')) {
+ // skip hidden (and undefined) settings
+ if ($allow_debug && is_a($setting, 'setting_undefined')) {
+ $undefined_settings[] = $setting;
+ } else {
+ continue;
+ }
+ } else if (is_a($setting, 'setting_fieldset')) {
+ // config setting group
+ if ($in_fieldset) {
+ ptln(' </table>');
+ ptln(' </div>');
+ ptln(' </fieldset>');
+ } else {
+ $in_fieldset = true;
+ }
+ if ($first_plugin_fieldset && substr($setting->_key, 0, 10)=='plugin'.CM_KEYMARKER) {
+ $this->_print_h1('plugin_settings', $this->getLang('_header_plugin'));
+ $first_plugin_fieldset = false;
+ } else if ($first_template_fieldset && substr($setting->_key, 0, 7)=='tpl'.CM_KEYMARKER) {
+ $this->_print_h1('template_settings', $this->getLang('_header_template'));
+ $first_template_fieldset = false;
+ }
+ ptln(' <fieldset id="'.$setting->_key.'">');
+ ptln(' <legend>'.$setting->prompt($this).'</legend>');
+ ptln(' <div class="table">');
+ ptln(' <table class="inline">');
+ } else {
+ // config settings
+ list($label,$input) = $setting->html($this, $this->_error);
+
+ $class = $setting->is_default() ? ' class="default"' : ($setting->is_protected() ? ' class="protected"' : '');
+ $error = $setting->error() ? ' class="value error"' : ' class="value"';
+ $icon = $setting->caution() ? '<img src="'.DOKU_PLUGIN_IMAGES.$setting->caution().'.png" alt="'.$setting->caution().'" title="'.$this->getLang($setting->caution()).'" />' : '';
+
+ ptln(' <tr'.$class.'>');
+ ptln(' <td class="label">');
+ ptln(' <span class="outkey">'.$setting->_out_key(true, true).'</span>');
+ ptln(' '.$icon.$label);
+ ptln(' </td>');
+ ptln(' <td'.$error.'>'.$input.'</td>');
+ ptln(' </tr>');
+ }
}
- }
- ptln(' </table>');
- ptln(' </div>');
- if ($in_fieldset) {
- ptln(' </fieldset>');
- }
+ ptln(' </table>');
+ ptln(' </div>');
+ if ($in_fieldset) {
+ ptln(' </fieldset>');
+ }
- // show undefined settings list
- if ($allow_debug && !empty($undefined_settings)) {
- function _setting_natural_comparison($a, $b) { return strnatcmp($a->_key, $b->_key); }
- usort($undefined_settings, '_setting_natural_comparison');
- $this->_print_h1('undefined_settings', $this->getLang('_header_undefined'));
- ptln('<fieldset>');
- ptln('<div class="table">');
- ptln('<table class="inline">');
- $undefined_setting_match = array();
- foreach($undefined_settings as $setting) {
- if (preg_match('/^(?:plugin|tpl)'.CM_KEYMARKER.'.*?'.CM_KEYMARKER.'(.*)$/', $setting->_key, $undefined_setting_match)) {
- $undefined_setting_key = $undefined_setting_match[1];
- } else {
- $undefined_setting_key = $setting->_key;
- }
- ptln(' <tr>');
- ptln(' <td class="label"><span title="$meta[\''.$undefined_setting_key.'\']">$'.$this->_config->_name.'[\''.$setting->_out_key().'\']</span></td>');
- ptln(' <td>'.$this->getLang('_msg_'.get_class($setting)).'</td>');
- ptln(' </tr>');
+ // show undefined settings list
+ if ($allow_debug && !empty($undefined_settings)) {
+ function _setting_natural_comparison($a, $b) { return strnatcmp($a->_key, $b->_key); }
+ usort($undefined_settings, '_setting_natural_comparison');
+ $this->_print_h1('undefined_settings', $this->getLang('_header_undefined'));
+ ptln('<fieldset>');
+ ptln('<div class="table">');
+ ptln('<table class="inline">');
+ $undefined_setting_match = array();
+ foreach($undefined_settings as $setting) {
+ if (preg_match('/^(?:plugin|tpl)'.CM_KEYMARKER.'.*?'.CM_KEYMARKER.'(.*)$/', $setting->_key, $undefined_setting_match)) {
+ $undefined_setting_key = $undefined_setting_match[1];
+ } else {
+ $undefined_setting_key = $setting->_key;
+ }
+ ptln(' <tr>');
+ ptln(' <td class="label"><span title="$meta[\''.$undefined_setting_key.'\']">$'.$this->_config->_name.'[\''.$setting->_out_key().'\']</span></td>');
+ ptln(' <td>'.$this->getLang('_msg_'.get_class($setting)).'</td>');
+ ptln(' </tr>');
+ }
+ ptln('</table>');
+ ptln('</div>');
+ ptln('</fieldset>');
}
- ptln('</table>');
- ptln('</div>');
- ptln('</fieldset>');
- }
- // finish up form
- ptln('<p>');
- ptln(' <input type="hidden" name="do" value="admin" />');
- ptln(' <input type="hidden" name="page" value="config" />');
+ // finish up form
+ ptln('<p>');
+ ptln(' <input type="hidden" name="do" value="admin" />');
+ ptln(' <input type="hidden" name="page" value="config" />');
- if (!$this->_config->locked) {
- ptln(' <input type="hidden" name="save" value="1" />');
- ptln(' <input type="submit" name="submit" class="button" value="'.$lang['btn_save'].'" accesskey="s" />');
- ptln(' <input type="reset" class="button" value="'.$lang['btn_reset'].'" />');
- }
+ if (!$this->_config->locked) {
+ ptln(' <input type="hidden" name="save" value="1" />');
+ ptln(' <input type="submit" name="submit" class="button" value="'.$lang['btn_save'].'" accesskey="s" />');
+ ptln(' <input type="reset" class="button" value="'.$lang['btn_reset'].'" />');
+ }
- ptln('</p>');
+ ptln('</p>');
- ptln('</form>');
- ptln('</div>');
+ ptln('</form>');
+ ptln('</div>');
}
/**
@@ -207,28 +207,28 @@ class admin_plugin_config extends DokuWiki_Admin_Plugin {
*/
function _restore_session() {
- // dokuwiki closes the session before act_dispatch. $_SESSION variables are all set,
- // however they can't be changed without starting the session again
- if (!headers_sent()) {
- session_start();
- $this->_session_started = true;
- }
+ // dokuwiki closes the session before act_dispatch. $_SESSION variables are all set,
+ // however they can't be changed without starting the session again
+ if (!headers_sent()) {
+ session_start();
+ $this->_session_started = true;
+ }
- if (!isset($_SESSION['PLUGIN_CONFIG'])) return true;
+ if (!isset($_SESSION['PLUGIN_CONFIG'])) return true;
- $session = $_SESSION['PLUGIN_CONFIG'];
- unset($_SESSION['PLUGIN_CONFIG']);
+ $session = $_SESSION['PLUGIN_CONFIG'];
+ unset($_SESSION['PLUGIN_CONFIG']);
- // still valid?
- if (time() - $session['time'] > 120) return true;
+ // still valid?
+ if (time() - $session['time'] > 120) return true;
- switch ($session['state']) {
- case 'updated' :
- $this->_changed = true;
- return false;
- }
+ switch ($session['state']) {
+ case 'updated' :
+ $this->_changed = true;
+ return false;
+ }
- return true;
+ return true;
}
function _close_session() {
@@ -237,62 +237,62 @@ class admin_plugin_config extends DokuWiki_Admin_Plugin {
function setupLocale($prompts=false) {
- parent::setupLocale();
- if (!$prompts || $this->_localised_prompts) return;
+ parent::setupLocale();
+ if (!$prompts || $this->_localised_prompts) return;
- $this->_setup_localised_plugin_prompts();
- $this->_localised_prompts = true;
+ $this->_setup_localised_plugin_prompts();
+ $this->_localised_prompts = true;
}
function _setup_localised_plugin_prompts() {
- global $conf;
-
- $langfile = '/lang/'.$conf['lang'].'/settings.php';
- $enlangfile = '/lang/en/settings.php';
+ global $conf;
+
+ $langfile = '/lang/'.$conf['lang'].'/settings.php';
+ $enlangfile = '/lang/en/settings.php';
+
+ if ($dh = opendir(DOKU_PLUGIN)) {
+ while (false !== ($plugin = readdir($dh))) {
+ if ($plugin == '.' || $plugin == '..' || $plugin == 'tmp' || $plugin == 'config') continue;
+ if (is_file(DOKU_PLUGIN.$plugin)) continue;
+
+ if (@file_exists(DOKU_PLUGIN.$plugin.$enlangfile)){
+ $lang = array();
+ @include(DOKU_PLUGIN.$plugin.$enlangfile);
+ if ($conf['lang'] != 'en') @include(DOKU_PLUGIN.$plugin.$langfile);
+ foreach ($lang as $key => $value){
+ $this->lang['plugin'.CM_KEYMARKER.$plugin.CM_KEYMARKER.$key] = $value;
+ }
+ }
+
+ // fill in the plugin name if missing (should exist for plugins with settings)
+ if (!isset($this->lang['plugin'.CM_KEYMARKER.$plugin.CM_KEYMARKER.'plugin_settings_name'])) {
+ $this->lang['plugin'.CM_KEYMARKER.$plugin.CM_KEYMARKER.'plugin_settings_name'] =
+ ucwords(str_replace('_', ' ', $plugin));
+ }
+ }
+ closedir($dh);
+ }
- if ($dh = opendir(DOKU_PLUGIN)) {
- while (false !== ($plugin = readdir($dh))) {
- if ($plugin == '.' || $plugin == '..' || $plugin == 'tmp' || $plugin == 'config') continue;
- if (is_file(DOKU_PLUGIN.$plugin)) continue;
+ // the same for the active template
+ $tpl = $conf['template'];
- if (@file_exists(DOKU_PLUGIN.$plugin.$enlangfile)){
+ if (@file_exists(tpl_incdir().$enlangfile)){
$lang = array();
- @include(DOKU_PLUGIN.$plugin.$enlangfile);
- if ($conf['lang'] != 'en') @include(DOKU_PLUGIN.$plugin.$langfile);
+ @include(tpl_incdir().$enlangfile);
+ if ($conf['lang'] != 'en') @include(tpl_incdir().$langfile);
foreach ($lang as $key => $value){
- $this->lang['plugin'.CM_KEYMARKER.$plugin.CM_KEYMARKER.$key] = $value;
+ $this->lang['tpl'.CM_KEYMARKER.$tpl.CM_KEYMARKER.$key] = $value;
}
- }
-
- // fill in the plugin name if missing (should exist for plugins with settings)
- if (!isset($this->lang['plugin'.CM_KEYMARKER.$plugin.CM_KEYMARKER.'plugin_settings_name'])) {
- $this->lang['plugin'.CM_KEYMARKER.$plugin.CM_KEYMARKER.'plugin_settings_name'] =
- ucwords(str_replace('_', ' ', $plugin));
- }
}
- closedir($dh);
- }
-
- // the same for the active template
- $tpl = $conf['template'];
- if (@file_exists(tpl_incdir().$enlangfile)){
- $lang = array();
- @include(tpl_incdir().$enlangfile);
- if ($conf['lang'] != 'en') @include(tpl_incdir().$langfile);
- foreach ($lang as $key => $value){
- $this->lang['tpl'.CM_KEYMARKER.$tpl.CM_KEYMARKER.$key] = $value;
+ // fill in the template name if missing (should exist for templates with settings)
+ if (!isset($this->lang['tpl'.CM_KEYMARKER.$tpl.CM_KEYMARKER.'template_settings_name'])) {
+ $this->lang['tpl'.CM_KEYMARKER.$tpl.CM_KEYMARKER.'template_settings_name'] =
+ ucwords(str_replace('_', ' ', $tpl));
}
- }
-
- // fill in the template name if missing (should exist for templates with settings)
- if (!isset($this->lang['tpl'.CM_KEYMARKER.$tpl.CM_KEYMARKER.'template_settings_name'])) {
- $this->lang['tpl'.CM_KEYMARKER.$tpl.CM_KEYMARKER.'template_settings_name'] =
- ucwords(str_replace('_', ' ', $tpl));
- }
- return true;
+ return true;
}
/**
@@ -301,59 +301,59 @@ class admin_plugin_config extends DokuWiki_Admin_Plugin {
* @author Ben Coburn <btcoburn@silicodon.net>
*/
function getTOC() {
- if (is_null($this->_config)) { $this->_config = new configuration($this->_file); }
- $this->setupLocale(true);
-
- $allow_debug = $GLOBALS['conf']['allowdebug']; // avoid global $conf; here.
-
- // gather toc data
- $has_undefined = false;
- $toc = array('conf'=>array(), 'plugin'=>array(), 'template'=>null);
- foreach($this->_config->setting as $setting) {
- if (is_a($setting, 'setting_fieldset')) {
- if (substr($setting->_key, 0, 10)=='plugin'.CM_KEYMARKER) {
- $toc['plugin'][] = $setting;
- } else if (substr($setting->_key, 0, 7)=='tpl'.CM_KEYMARKER) {
- $toc['template'] = $setting;
- } else {
- $toc['conf'][] = $setting;
- }
- } else if (!$has_undefined && is_a($setting, 'setting_undefined')) {
- $has_undefined = true;
+ if (is_null($this->_config)) { $this->_config = new configuration($this->_file); }
+ $this->setupLocale(true);
+
+ $allow_debug = $GLOBALS['conf']['allowdebug']; // avoid global $conf; here.
+
+ // gather toc data
+ $has_undefined = false;
+ $toc = array('conf'=>array(), 'plugin'=>array(), 'template'=>null);
+ foreach($this->_config->setting as $setting) {
+ if (is_a($setting, 'setting_fieldset')) {
+ if (substr($setting->_key, 0, 10)=='plugin'.CM_KEYMARKER) {
+ $toc['plugin'][] = $setting;
+ } else if (substr($setting->_key, 0, 7)=='tpl'.CM_KEYMARKER) {
+ $toc['template'] = $setting;
+ } else {
+ $toc['conf'][] = $setting;
+ }
+ } else if (!$has_undefined && is_a($setting, 'setting_undefined')) {
+ $has_undefined = true;
+ }
}
- }
- // build toc
- $t = array();
+ // build toc
+ $t = array();
- $t[] = html_mktocitem('configuration_manager', $this->getLang('_configuration_manager'), 1);
- $t[] = html_mktocitem('dokuwiki_settings', $this->getLang('_header_dokuwiki'), 1);
- foreach($toc['conf'] as $setting) {
- $name = $setting->prompt($this);
- $t[] = html_mktocitem($setting->_key, $name, 2);
- }
- if (!empty($toc['plugin'])) {
- $t[] = html_mktocitem('plugin_settings', $this->getLang('_header_plugin'), 1);
- }
- foreach($toc['plugin'] as $setting) {
- $name = $setting->prompt($this);
- $t[] = html_mktocitem($setting->_key, $name, 2);
- }
- if (isset($toc['template'])) {
- $t[] = html_mktocitem('template_settings', $this->getLang('_header_template'), 1);
- $setting = $toc['template'];
- $name = $setting->prompt($this);
- $t[] = html_mktocitem($setting->_key, $name, 2);
- }
- if ($has_undefined && $allow_debug) {
- $t[] = html_mktocitem('undefined_settings', $this->getLang('_header_undefined'), 1);
- }
+ $t[] = html_mktocitem('configuration_manager', $this->getLang('_configuration_manager'), 1);
+ $t[] = html_mktocitem('dokuwiki_settings', $this->getLang('_header_dokuwiki'), 1);
+ foreach($toc['conf'] as $setting) {
+ $name = $setting->prompt($this);
+ $t[] = html_mktocitem($setting->_key, $name, 2);
+ }
+ if (!empty($toc['plugin'])) {
+ $t[] = html_mktocitem('plugin_settings', $this->getLang('_header_plugin'), 1);
+ }
+ foreach($toc['plugin'] as $setting) {
+ $name = $setting->prompt($this);
+ $t[] = html_mktocitem($setting->_key, $name, 2);
+ }
+ if (isset($toc['template'])) {
+ $t[] = html_mktocitem('template_settings', $this->getLang('_header_template'), 1);
+ $setting = $toc['template'];
+ $name = $setting->prompt($this);
+ $t[] = html_mktocitem($setting->_key, $name, 2);
+ }
+ if ($has_undefined && $allow_debug) {
+ $t[] = html_mktocitem('undefined_settings', $this->getLang('_header_undefined'), 1);
+ }
- return $t;
+ return $t;
}
function _print_h1($id, $text) {
- ptln('<h1 id="'.$id.'">'.$text.'</h1>');
+ ptln('<h1 id="'.$id.'">'.$text.'</h1>');
}
diff --git a/lib/plugins/config/settings/config.class.php b/lib/plugins/config/settings/config.class.php
index 6de560128..0b9fa8103 100644
--- a/lib/plugins/config/settings/config.class.php
+++ b/lib/plugins/config/settings/config.class.php
@@ -11,500 +11,500 @@ if(!defined('CM_KEYMARKER')) define('CM_KEYMARKER','____');
if (!class_exists('configuration')) {
- class configuration {
-
- var $_name = 'conf'; // name of the config variable found in the files (overridden by $config['varname'])
- var $_format = 'php'; // format of the config file, supported formats - php (overridden by $config['format'])
- var $_heading = ''; // heading string written at top of config file - don't include comment indicators
- var $_loaded = false; // set to true after configuration files are loaded
- var $_metadata = array(); // holds metadata describing the settings
- var $setting = array(); // array of setting objects
- var $locked = false; // configuration is considered locked if it can't be updated
- var $show_disabled_plugins = false;
-
- // configuration filenames
- var $_default_files = array();
- var $_local_files = array(); // updated configuration is written to the first file
- var $_protected_files = array();
-
- var $_plugin_list = null;
-
- /**
- * constructor
- */
- function configuration($datafile) {
- global $conf, $config_cascade;
-
- if (!@file_exists($datafile)) {
- msg('No configuration metadata found at - '.htmlspecialchars($datafile),-1);
- return;
- }
- $meta = array();
- include($datafile);
+ class configuration {
- if (isset($config['varname'])) $this->_name = $config['varname'];
- if (isset($config['format'])) $this->_format = $config['format'];
- if (isset($config['heading'])) $this->_heading = $config['heading'];
+ var $_name = 'conf'; // name of the config variable found in the files (overridden by $config['varname'])
+ var $_format = 'php'; // format of the config file, supported formats - php (overridden by $config['format'])
+ var $_heading = ''; // heading string written at top of config file - don't include comment indicators
+ var $_loaded = false; // set to true after configuration files are loaded
+ var $_metadata = array(); // holds metadata describing the settings
+ var $setting = array(); // array of setting objects
+ var $locked = false; // configuration is considered locked if it can't be updated
+ var $show_disabled_plugins = false;
- $this->_default_files = $config_cascade['main']['default'];
- $this->_local_files = $config_cascade['main']['local'];
- $this->_protected_files = $config_cascade['main']['protected'];
+ // configuration filenames
+ var $_default_files = array();
+ var $_local_files = array(); // updated configuration is written to the first file
+ var $_protected_files = array();
- $this->locked = $this->_is_locked();
- $this->_metadata = array_merge($meta, $this->get_plugintpl_metadata($conf['template']));
- $this->retrieve_settings();
- }
+ var $_plugin_list = null;
- function retrieve_settings() {
- global $conf;
- $no_default_check = array('setting_fieldset', 'setting_undefined', 'setting_no_class');
+ /**
+ * constructor
+ */
+ function configuration($datafile) {
+ global $conf, $config_cascade;
- if (!$this->_loaded) {
- $default = array_merge($this->get_plugintpl_default($conf['template']), $this->_read_config_group($this->_default_files));
- $local = $this->_read_config_group($this->_local_files);
- $protected = $this->_read_config_group($this->_protected_files);
+ if (!@file_exists($datafile)) {
+ msg('No configuration metadata found at - '.htmlspecialchars($datafile),-1);
+ return;
+ }
+ $meta = array();
+ include($datafile);
- $keys = array_merge(array_keys($this->_metadata),array_keys($default), array_keys($local), array_keys($protected));
- $keys = array_unique($keys);
+ if (isset($config['varname'])) $this->_name = $config['varname'];
+ if (isset($config['format'])) $this->_format = $config['format'];
+ if (isset($config['heading'])) $this->_heading = $config['heading'];
- $param = null;
- foreach ($keys as $key) {
- if (isset($this->_metadata[$key])) {
- $class = $this->_metadata[$key][0];
+ $this->_default_files = $config_cascade['main']['default'];
+ $this->_local_files = $config_cascade['main']['local'];
+ $this->_protected_files = $config_cascade['main']['protected'];
- if($class && class_exists('setting_'.$class)){
- $class = 'setting_'.$class;
- } else {
- if($class != '') {
- $this->setting[] = new setting_no_class($key,$param);
+ $this->locked = $this->_is_locked();
+ $this->_metadata = array_merge($meta, $this->get_plugintpl_metadata($conf['template']));
+ $this->retrieve_settings();
+ }
+
+ function retrieve_settings() {
+ global $conf;
+ $no_default_check = array('setting_fieldset', 'setting_undefined', 'setting_no_class');
+
+ if (!$this->_loaded) {
+ $default = array_merge($this->get_plugintpl_default($conf['template']), $this->_read_config_group($this->_default_files));
+ $local = $this->_read_config_group($this->_local_files);
+ $protected = $this->_read_config_group($this->_protected_files);
+
+ $keys = array_merge(array_keys($this->_metadata),array_keys($default), array_keys($local), array_keys($protected));
+ $keys = array_unique($keys);
+
+ $param = null;
+ foreach ($keys as $key) {
+ if (isset($this->_metadata[$key])) {
+ $class = $this->_metadata[$key][0];
+
+ if($class && class_exists('setting_'.$class)){
+ $class = 'setting_'.$class;
+ } else {
+ if($class != '') {
+ $this->setting[] = new setting_no_class($key,$param);
+ }
+ $class = 'setting';
+ }
+
+ $param = $this->_metadata[$key];
+ array_shift($param);
+ } else {
+ $class = 'setting_undefined';
+ $param = null;
+ }
+
+ if (!in_array($class, $no_default_check) && !isset($default[$key])) {
+ $this->setting[] = new setting_no_default($key,$param);
+ }
+
+ $this->setting[$key] = new $class($key,$param);
+ $this->setting[$key]->initialize($default[$key],$local[$key],$protected[$key]);
}
- $class = 'setting';
- }
- $param = $this->_metadata[$key];
- array_shift($param);
- } else {
- $class = 'setting_undefined';
- $param = null;
+ $this->_loaded = true;
}
+ }
- if (!in_array($class, $no_default_check) && !isset($default[$key])) {
- $this->setting[] = new setting_no_default($key,$param);
- }
+ function save_settings($id, $header='', $backup=true) {
+ global $conf;
- $this->setting[$key] = new $class($key,$param);
- $this->setting[$key]->initialize($default[$key],$local[$key],$protected[$key]);
- }
+ if ($this->locked) return false;
- $this->_loaded = true;
- }
- }
-
- function save_settings($id, $header='', $backup=true) {
- global $conf;
+ // write back to the last file in the local config cascade
+ $file = end($this->_local_files);
- if ($this->locked) return false;
+ // backup current file (remove any existing backup)
+ if (@file_exists($file) && $backup) {
+ if (@file_exists($file.'.bak')) @unlink($file.'.bak');
+ if (!io_rename($file, $file.'.bak')) return false;
+ }
- // write back to the last file in the local config cascade
- $file = end($this->_local_files);
+ if (!$fh = @fopen($file, 'wb')) {
+ io_rename($file.'.bak', $file); // problem opening, restore the backup
+ return false;
+ }
- // backup current file (remove any existing backup)
- if (@file_exists($file) && $backup) {
- if (@file_exists($file.'.bak')) @unlink($file.'.bak');
- if (!io_rename($file, $file.'.bak')) return false;
- }
+ if (empty($header)) $header = $this->_heading;
- if (!$fh = @fopen($file, 'wb')) {
- io_rename($file.'.bak', $file); // problem opening, restore the backup
- return false;
- }
+ $out = $this->_out_header($id,$header);
- if (empty($header)) $header = $this->_heading;
+ foreach ($this->setting as $setting) {
+ $out .= $setting->out($this->_name, $this->_format);
+ }
- $out = $this->_out_header($id,$header);
+ $out .= $this->_out_footer();
- foreach ($this->setting as $setting) {
- $out .= $setting->out($this->_name, $this->_format);
- }
+ @fwrite($fh, $out);
+ fclose($fh);
+ if($conf['fperm']) chmod($file, $conf['fperm']);
+ return true;
+ }
- $out .= $this->_out_footer();
+ /**
+ * Update last modified time stamp of the config file
+ */
+ function touch_settings(){
+ if ($this->locked) return false;
+ $file = end($this->_local_files);
+ return @touch($file);
+ }
- @fwrite($fh, $out);
- fclose($fh);
- if($conf['fperm']) chmod($file, $conf['fperm']);
- return true;
- }
+ function _read_config_group($files) {
+ $config = array();
+ foreach ($files as $file) {
+ $config = array_merge($config, $this->_read_config($file));
+ }
- /**
- * Update last modified time stamp of the config file
- */
- function touch_settings(){
- if ($this->locked) return false;
- $file = end($this->_local_files);
- return @touch($file);
- }
+ return $config;
+ }
- function _read_config_group($files) {
- $config = array();
- foreach ($files as $file) {
- $config = array_merge($config, $this->_read_config($file));
- }
+ /**
+ * return an array of config settings
+ */
+ function _read_config($file) {
- return $config;
- }
+ if (!$file) return array();
- /**
- * return an array of config settings
- */
- function _read_config($file) {
+ $config = array();
- if (!$file) return array();
+ if ($this->_format == 'php') {
- $config = array();
+ if(@file_exists($file)){
+ $contents = @php_strip_whitespace($file);
+ }else{
+ $contents = '';
+ }
+ $pattern = '/\$'.$this->_name.'\[[\'"]([^=]+)[\'"]\] ?= ?(.*?);(?=[^;]*(?:\$'.$this->_name.'|$))/s';
+ $matches=array();
+ preg_match_all($pattern,$contents,$matches,PREG_SET_ORDER);
- if ($this->_format == 'php') {
+ for ($i=0; $i<count($matches); $i++) {
+ $value = $matches[$i][2];
- if(@file_exists($file)){
- $contents = @php_strip_whitespace($file);
- }else{
- $contents = '';
- }
- $pattern = '/\$'.$this->_name.'\[[\'"]([^=]+)[\'"]\] ?= ?(.*?);(?=[^;]*(?:\$'.$this->_name.'|$))/s';
- $matches=array();
- preg_match_all($pattern,$contents,$matches,PREG_SET_ORDER);
- for ($i=0; $i<count($matches); $i++) {
- $value = $matches[$i][2];
+ // correct issues with the incoming data
+ // FIXME ... for now merge multi-dimensional array indices using ____
+ $key = preg_replace('/.\]\[./',CM_KEYMARKER,$matches[$i][1]);
- // correct issues with the incoming data
- // FIXME ... for now merge multi-dimensional array indices using ____
- $key = preg_replace('/.\]\[./',CM_KEYMARKER,$matches[$i][1]);
+ // handle arrays
+ if(preg_match('/^array ?\((.*)\)/', $value, $match)){
+ $arr = explode(',', $match[1]);
+ // remove quotes from quoted strings & unescape escaped data
+ $len = count($arr);
+ for($j=0; $j<$len; $j++){
+ $arr[$j] = trim($arr[$j]);
+ $arr[$j] = preg_replace('/^(\'|")(.*)(?<!\\\\)\1$/s','$2',$arr[$j]);
+ $arr[$j] = strtr($arr[$j], array('\\\\'=>'\\','\\\''=>'\'','\\"'=>'"'));
+ }
- // handle arrays
- if(preg_match('/^array ?\((.*)\)/', $value, $match)){
- $arr = explode(',', $match[1]);
+ $value = $arr;
+ }else{
+ // remove quotes from quoted strings & unescape escaped data
+ $value = preg_replace('/^(\'|")(.*)(?<!\\\\)\1$/s','$2',$value);
+ $value = strtr($value, array('\\\\'=>'\\','\\\''=>'\'','\\"'=>'"'));
+ }
- // remove quotes from quoted strings & unescape escaped data
- $len = count($arr);
- for($j=0; $j<$len; $j++){
- $arr[$j] = trim($arr[$j]);
- $arr[$j] = preg_replace('/^(\'|")(.*)(?<!\\\\)\1$/s','$2',$arr[$j]);
- $arr[$j] = strtr($arr[$j], array('\\\\'=>'\\','\\\''=>'\'','\\"'=>'"'));
+ $config[$key] = $value;
+ }
}
- $value = $arr;
- }else{
- // remove quotes from quoted strings & unescape escaped data
- $value = preg_replace('/^(\'|")(.*)(?<!\\\\)\1$/s','$2',$value);
- $value = strtr($value, array('\\\\'=>'\\','\\\''=>'\'','\\"'=>'"'));
- }
-
- $config[$key] = $value;
+ return $config;
}
- }
- return $config;
- }
+ function _out_header($id, $header) {
+ $out = '';
+ if ($this->_format == 'php') {
+ $out .= '<'.'?php'."\n".
+ "/*\n".
+ " * ".$header."\n".
+ " * Auto-generated by ".$id." plugin\n".
+ " * Run for user: ".$_SERVER['REMOTE_USER']."\n".
+ " * Date: ".date('r')."\n".
+ " */\n\n";
+ }
- function _out_header($id, $header) {
- $out = '';
- if ($this->_format == 'php') {
- $out .= '<'.'?php'."\n".
- "/*\n".
- " * ".$header."\n".
- " * Auto-generated by ".$id." plugin\n".
- " * Run for user: ".$_SERVER['REMOTE_USER']."\n".
- " * Date: ".date('r')."\n".
- " */\n\n";
- }
-
- return $out;
- }
+ return $out;
+ }
- function _out_footer() {
- $out = '';
- if ($this->_format == 'php') {
- $out .= "\n// end auto-generated content\n";
- }
+ function _out_footer() {
+ $out = '';
+ if ($this->_format == 'php') {
+ $out .= "\n// end auto-generated content\n";
+ }
- return $out;
- }
+ return $out;
+ }
- // configuration is considered locked if there is no local settings filename
- // or the directory its in is not writable or the file exists and is not writable
- function _is_locked() {
- if (!$this->_local_files) return true;
+ // configuration is considered locked if there is no local settings filename
+ // or the directory its in is not writable or the file exists and is not writable
+ function _is_locked() {
+ if (!$this->_local_files) return true;
- $local = $this->_local_files[0];
+ $local = $this->_local_files[0];
- if (!is_writable(dirname($local))) return true;
- if (@file_exists($local) && !is_writable($local)) return true;
+ if (!is_writable(dirname($local))) return true;
+ if (@file_exists($local) && !is_writable($local)) return true;
- return false;
- }
+ return false;
+ }
- /**
- * not used ... conf's contents are an array!
- * reduce any multidimensional settings to one dimension using CM_KEYMARKER
- */
- function _flatten($conf,$prefix='') {
+ /**
+ * not used ... conf's contents are an array!
+ * reduce any multidimensional settings to one dimension using CM_KEYMARKER
+ */
+ function _flatten($conf,$prefix='') {
- $out = array();
+ $out = array();
- foreach($conf as $key => $value) {
- if (!is_array($value)) {
- $out[$prefix.$key] = $value;
- continue;
- }
+ foreach($conf as $key => $value) {
+ if (!is_array($value)) {
+ $out[$prefix.$key] = $value;
+ continue;
+ }
+
+ $tmp = $this->_flatten($value,$prefix.$key.CM_KEYMARKER);
+ $out = array_merge($out,$tmp);
+ }
- $tmp = $this->_flatten($value,$prefix.$key.CM_KEYMARKER);
- $out = array_merge($out,$tmp);
+ return $out;
}
- return $out;
- }
+ function get_plugin_list() {
+ if (is_null($this->_plugin_list)) {
+ $list = plugin_list('',$this->show_disabled_plugins);
- function get_plugin_list() {
- if (is_null($this->_plugin_list)) {
- $list = plugin_list('',$this->show_disabled_plugins);
+ // remove this plugin from the list
+ $idx = array_search('config',$list);
+ unset($list[$idx]);
- // remove this plugin from the list
- $idx = array_search('config',$list);
- unset($list[$idx]);
+ trigger_event('PLUGIN_CONFIG_PLUGINLIST',$list);
+ $this->_plugin_list = $list;
+ }
- trigger_event('PLUGIN_CONFIG_PLUGINLIST',$list);
- $this->_plugin_list = $list;
- }
+ return $this->_plugin_list;
+ }
- return $this->_plugin_list;
- }
+ /**
+ * load metadata for plugin and template settings
+ */
+ function get_plugintpl_metadata($tpl){
+ $file = '/conf/metadata.php';
+ $class = '/conf/settings.class.php';
+ $metadata = array();
+
+ foreach ($this->get_plugin_list() as $plugin) {
+ $plugin_dir = plugin_directory($plugin);
+ if (@file_exists(DOKU_PLUGIN.$plugin_dir.$file)){
+ $meta = array();
+ @include(DOKU_PLUGIN.$plugin_dir.$file);
+ @include(DOKU_PLUGIN.$plugin_dir.$class);
+ if (!empty($meta)) {
+ $metadata['plugin'.CM_KEYMARKER.$plugin.CM_KEYMARKER.'plugin_settings_name'] = array('fieldset');
+ }
+ foreach ($meta as $key => $value){
+ if ($value[0]=='fieldset') { continue; } //plugins only get one fieldset
+ $metadata['plugin'.CM_KEYMARKER.$plugin.CM_KEYMARKER.$key] = $value;
+ }
+ }
+ }
- /**
- * load metadata for plugin and template settings
- */
- function get_plugintpl_metadata($tpl){
- $file = '/conf/metadata.php';
- $class = '/conf/settings.class.php';
- $metadata = array();
-
- foreach ($this->get_plugin_list() as $plugin) {
- $plugin_dir = plugin_directory($plugin);
- if (@file_exists(DOKU_PLUGIN.$plugin_dir.$file)){
- $meta = array();
- @include(DOKU_PLUGIN.$plugin_dir.$file);
- @include(DOKU_PLUGIN.$plugin_dir.$class);
- if (!empty($meta)) {
- $metadata['plugin'.CM_KEYMARKER.$plugin.CM_KEYMARKER.'plugin_settings_name'] = array('fieldset');
- }
- foreach ($meta as $key => $value){
- if ($value[0]=='fieldset') { continue; } //plugins only get one fieldset
- $metadata['plugin'.CM_KEYMARKER.$plugin.CM_KEYMARKER.$key] = $value;
- }
- }
- }
-
- // the same for the active template
- if (@file_exists(tpl_incdir().$file)){
- $meta = array();
- @include(tpl_incdir().$file);
- @include(tpl_incdir().$class);
- if (!empty($meta)) {
- $metadata['tpl'.CM_KEYMARKER.$tpl.CM_KEYMARKER.'template_settings_name'] = array('fieldset');
- }
- foreach ($meta as $key => $value){
- if ($value[0]=='fieldset') { continue; } //template only gets one fieldset
- $metadata['tpl'.CM_KEYMARKER.$tpl.CM_KEYMARKER.$key] = $value;
+ // the same for the active template
+ if (@file_exists(tpl_incdir().$file)){
+ $meta = array();
+ @include(tpl_incdir().$file);
+ @include(tpl_incdir().$class);
+ if (!empty($meta)) {
+ $metadata['tpl'.CM_KEYMARKER.$tpl.CM_KEYMARKER.'template_settings_name'] = array('fieldset');
+ }
+ foreach ($meta as $key => $value){
+ if ($value[0]=='fieldset') { continue; } //template only gets one fieldset
+ $metadata['tpl'.CM_KEYMARKER.$tpl.CM_KEYMARKER.$key] = $value;
+ }
+ }
+
+ return $metadata;
}
- }
- return $metadata;
- }
+ /**
+ * load default settings for plugins and templates
+ */
+ function get_plugintpl_default($tpl){
+ $file = '/conf/default.php';
+ $default = array();
+
+ foreach ($this->get_plugin_list() as $plugin) {
+ $plugin_dir = plugin_directory($plugin);
+ if (@file_exists(DOKU_PLUGIN.$plugin_dir.$file)){
+ $conf = array();
+ @include(DOKU_PLUGIN.$plugin_dir.$file);
+ foreach ($conf as $key => $value){
+ $default['plugin'.CM_KEYMARKER.$plugin.CM_KEYMARKER.$key] = $value;
+ }
+ }
+ }
- /**
- * load default settings for plugins and templates
- */
- function get_plugintpl_default($tpl){
- $file = '/conf/default.php';
- $default = array();
-
- foreach ($this->get_plugin_list() as $plugin) {
- $plugin_dir = plugin_directory($plugin);
- if (@file_exists(DOKU_PLUGIN.$plugin_dir.$file)){
- $conf = array();
- @include(DOKU_PLUGIN.$plugin_dir.$file);
- foreach ($conf as $key => $value){
- $default['plugin'.CM_KEYMARKER.$plugin.CM_KEYMARKER.$key] = $value;
- }
- }
- }
-
- // the same for the active template
- if (@file_exists(tpl_incdir().$file)){
- $conf = array();
- @include(tpl_incdir().$file);
- foreach ($conf as $key => $value){
- $default['tpl'.CM_KEYMARKER.$tpl.CM_KEYMARKER.$key] = $value;
+ // the same for the active template
+ if (@file_exists(tpl_incdir().$file)){
+ $conf = array();
+ @include(tpl_incdir().$file);
+ foreach ($conf as $key => $value){
+ $default['tpl'.CM_KEYMARKER.$tpl.CM_KEYMARKER.$key] = $value;
+ }
+ }
+
+ return $default;
}
- }
- return $default;
}
-
- }
}
if (!class_exists('setting')) {
- class setting {
+ class setting {
- var $_key = '';
- var $_default = null;
- var $_local = null;
- var $_protected = null;
+ var $_key = '';
+ var $_default = null;
+ var $_local = null;
+ var $_protected = null;
- var $_pattern = '';
- var $_error = false; // only used by those classes which error check
- var $_input = null; // only used by those classes which error check
- var $_caution = null; // used by any setting to provide an alert along with the setting
- // valid alerts, 'warning', 'danger', 'security'
- // images matching the alerts are in the plugin's images directory
+ var $_pattern = '';
+ var $_error = false; // only used by those classes which error check
+ var $_input = null; // only used by those classes which error check
+ var $_caution = null; // used by any setting to provide an alert along with the setting
+ // valid alerts, 'warning', 'danger', 'security'
+ // images matching the alerts are in the plugin's images directory
- static protected $_validCautions = array('warning','danger','security');
+ static protected $_validCautions = array('warning','danger','security');
- function setting($key, $params=null) {
- $this->_key = $key;
+ function setting($key, $params=null) {
+ $this->_key = $key;
- if (is_array($params)) {
- foreach($params as $property => $value) {
- $this->$property = $value;
- }
+ if (is_array($params)) {
+ foreach($params as $property => $value) {
+ $this->$property = $value;
+ }
+ }
}
- }
-
- /**
- * receives current values for the setting $key
- */
- function initialize($default, $local, $protected) {
- if (isset($default)) $this->_default = $default;
- if (isset($local)) $this->_local = $local;
- if (isset($protected)) $this->_protected = $protected;
- }
- /**
- * update changed setting with user provided value $input
- * - if changed value fails error check, save it to $this->_input (to allow echoing later)
- * - if changed value passes error check, set $this->_local to the new value
- *
- * @param mixed $input the new value
- * @return boolean true if changed, false otherwise (incl. on error)
- */
- function update($input) {
- if (is_null($input)) return false;
- if ($this->is_protected()) return false;
-
- $value = is_null($this->_local) ? $this->_default : $this->_local;
- if ($value == $input) return false;
-
- if ($this->_pattern && !preg_match($this->_pattern,$input)) {
- $this->_error = true;
- $this->_input = $input;
- return false;
+ /**
+ * receives current values for the setting $key
+ */
+ function initialize($default, $local, $protected) {
+ if (isset($default)) $this->_default = $default;
+ if (isset($local)) $this->_local = $local;
+ if (isset($protected)) $this->_protected = $protected;
}
- $this->_local = $input;
- return true;
- }
+ /**
+ * update changed setting with user provided value $input
+ * - if changed value fails error check, save it to $this->_input (to allow echoing later)
+ * - if changed value passes error check, set $this->_local to the new value
+ *
+ * @param mixed $input the new value
+ * @return boolean true if changed, false otherwise (incl. on error)
+ */
+ function update($input) {
+ if (is_null($input)) return false;
+ if ($this->is_protected()) return false;
- /**
- * @return array(string $label_html, string $input_html)
- */
- function html(&$plugin, $echo=false) {
- $value = '';
- $disable = '';
-
- if ($this->is_protected()) {
- $value = $this->_protected;
- $disable = 'disabled="disabled"';
- } else {
- if ($echo && $this->_error) {
- $value = $this->_input;
- } else {
$value = is_null($this->_local) ? $this->_default : $this->_local;
- }
- }
+ if ($value == $input) return false;
- $key = htmlspecialchars($this->_key);
- $value = formText($value);
+ if ($this->_pattern && !preg_match($this->_pattern,$input)) {
+ $this->_error = true;
+ $this->_input = $input;
+ return false;
+ }
- $label = '<label for="config___'.$key.'">'.$this->prompt($plugin).'</label>';
- $input = '<textarea rows="3" cols="40" id="config___'.$key.'" name="config['.$key.']" class="edit" '.$disable.'>'.$value.'</textarea>';
- return array($label,$input);
- }
+ $this->_local = $input;
+ return true;
+ }
- /**
- * generate string to save setting value to file according to $fmt
- */
- function out($var, $fmt='php') {
+ /**
+ * @return array(string $label_html, string $input_html)
+ */
+ function html(&$plugin, $echo=false) {
+ $value = '';
+ $disable = '';
- if ($this->is_protected()) return '';
- if (is_null($this->_local) || ($this->_default == $this->_local)) return '';
+ if ($this->is_protected()) {
+ $value = $this->_protected;
+ $disable = 'disabled="disabled"';
+ } else {
+ if ($echo && $this->_error) {
+ $value = $this->_input;
+ } else {
+ $value = is_null($this->_local) ? $this->_default : $this->_local;
+ }
+ }
- $out = '';
+ $key = htmlspecialchars($this->_key);
+ $value = formText($value);
- if ($fmt=='php') {
- $tr = array("\\" => '\\\\', "'" => '\\\'');
+ $label = '<label for="config___'.$key.'">'.$this->prompt($plugin).'</label>';
+ $input = '<textarea rows="3" cols="40" id="config___'.$key.'" name="config['.$key.']" class="edit" '.$disable.'>'.$value.'</textarea>';
+ return array($label,$input);
+ }
- $out = '$'.$var."['".$this->_out_key()."'] = '".strtr( cleanText($this->_local), $tr)."';\n";
- }
+ /**
+ * generate string to save setting value to file according to $fmt
+ */
+ function out($var, $fmt='php') {
- return $out;
- }
+ if ($this->is_protected()) return '';
+ if (is_null($this->_local) || ($this->_default == $this->_local)) return '';
- function prompt(&$plugin) {
- $prompt = $plugin->getLang($this->_key);
- if (!$prompt) $prompt = htmlspecialchars(str_replace(array('____','_'),' ',$this->_key));
- return $prompt;
- }
+ $out = '';
- function is_protected() { return !is_null($this->_protected); }
- function is_default() { return !$this->is_protected() && is_null($this->_local); }
- function error() { return $this->_error; }
+ if ($fmt=='php') {
+ $tr = array("\\" => '\\\\', "'" => '\\\'');
- function caution() {
- if (!empty($this->_caution)) {
- if (!in_array($this->_caution, setting::$_validCautions)) {
- trigger_error('Invalid caution string ('.$this->_caution.') in metadata for setting "'.$this->_key.'"', E_USER_WARNING);
- return false;
+ $out = '$'.$var."['".$this->_out_key()."'] = '".strtr( cleanText($this->_local), $tr)."';\n";
}
- return $this->_caution;
+
+ return $out;
}
- // compatibility with previous cautionList
- // TODO: check if any plugins use; remove
- if (!empty($this->_cautionList[$this->_key])) {
- $this->_caution = $this->_cautionList[$this->_key];
- unset($this->_cautionList);
- return $this->caution();
+ function prompt(&$plugin) {
+ $prompt = $plugin->getLang($this->_key);
+ if (!$prompt) $prompt = htmlspecialchars(str_replace(array('____','_'),' ',$this->_key));
+ return $prompt;
}
- return false;
- }
- function _out_key($pretty=false,$url=false) {
- if($pretty){
- $out = str_replace(CM_KEYMARKER,"»",$this->_key);
- if ($url && !strstr($out,'»')) {//provide no urls for plugins, etc.
- if ($out == 'start') //one exception
- return '<a href="http://www.dokuwiki.org/config:startpage">'.$out.'</a>';
- else
- return '<a href="http://www.dokuwiki.org/config:'.$out.'">'.$out.'</a>';
+ function is_protected() { return !is_null($this->_protected); }
+ function is_default() { return !$this->is_protected() && is_null($this->_local); }
+ function error() { return $this->_error; }
+
+ function caution() {
+ if (!empty($this->_caution)) {
+ if (!in_array($this->_caution, setting::$_validCautions)) {
+ trigger_error('Invalid caution string ('.$this->_caution.') in metadata for setting "'.$this->_key.'"', E_USER_WARNING);
+ return false;
+ }
+ return $this->_caution;
+ }
+ // compatibility with previous cautionList
+ // TODO: check if any plugins use; remove
+ if (!empty($this->_cautionList[$this->_key])) {
+ $this->_caution = $this->_cautionList[$this->_key];
+ unset($this->_cautionList);
+
+ return $this->caution();
+ }
+ return false;
+ }
+
+ function _out_key($pretty=false,$url=false) {
+ if($pretty){
+ $out = str_replace(CM_KEYMARKER,"»",$this->_key);
+ if ($url && !strstr($out,'»')) {//provide no urls for plugins, etc.
+ if ($out == 'start') //one exception
+ return '<a href="http://www.dokuwiki.org/config:startpage">'.$out.'</a>';
+ else
+ return '<a href="http://www.dokuwiki.org/config:'.$out.'">'.$out.'</a>';
+ }
+ return $out;
+ }else{
+ return str_replace(CM_KEYMARKER,"']['",$this->_key);
}
- return $out;
- }else{
- return str_replace(CM_KEYMARKER,"']['",$this->_key);
}
}
- }
}
@@ -612,178 +612,178 @@ if (!class_exists('setting_array')) {
}
if (!class_exists('setting_string')) {
- class setting_string extends setting {
- function html(&$plugin, $echo=false) {
- $value = '';
- $disable = '';
-
- if ($this->is_protected()) {
- $value = $this->_protected;
- $disable = 'disabled="disabled"';
- } else {
- if ($echo && $this->_error) {
- $value = $this->_input;
- } else {
- $value = is_null($this->_local) ? $this->_default : $this->_local;
- }
- }
+ class setting_string extends setting {
+ function html(&$plugin, $echo=false) {
+ $value = '';
+ $disable = '';
+
+ if ($this->is_protected()) {
+ $value = $this->_protected;
+ $disable = 'disabled="disabled"';
+ } else {
+ if ($echo && $this->_error) {
+ $value = $this->_input;
+ } else {
+ $value = is_null($this->_local) ? $this->_default : $this->_local;
+ }
+ }
- $key = htmlspecialchars($this->_key);
- $value = htmlspecialchars($value);
+ $key = htmlspecialchars($this->_key);
+ $value = htmlspecialchars($value);
- $label = '<label for="config___'.$key.'">'.$this->prompt($plugin).'</label>';
- $input = '<input id="config___'.$key.'" name="config['.$key.']" type="text" class="edit" value="'.$value.'" '.$disable.'/>';
- return array($label,$input);
+ $label = '<label for="config___'.$key.'">'.$this->prompt($plugin).'</label>';
+ $input = '<input id="config___'.$key.'" name="config['.$key.']" type="text" class="edit" value="'.$value.'" '.$disable.'/>';
+ return array($label,$input);
+ }
}
- }
}
if (!class_exists('setting_password')) {
- class setting_password extends setting_string {
+ class setting_password extends setting_string {
- var $_code = 'plain'; // mechanism to be used to obscure passwords
+ var $_code = 'plain'; // mechanism to be used to obscure passwords
- function update($input) {
- if ($this->is_protected()) return false;
- if (!$input) return false;
+ function update($input) {
+ if ($this->is_protected()) return false;
+ if (!$input) return false;
- if ($this->_pattern && !preg_match($this->_pattern,$input)) {
- $this->_error = true;
- $this->_input = $input;
- return false;
- }
+ if ($this->_pattern && !preg_match($this->_pattern,$input)) {
+ $this->_error = true;
+ $this->_input = $input;
+ return false;
+ }
- $this->_local = conf_encodeString($input,$this->_code);
- return true;
- }
+ $this->_local = conf_encodeString($input,$this->_code);
+ return true;
+ }
- function html(&$plugin, $echo=false) {
+ function html(&$plugin, $echo=false) {
- $value = '';
- $disable = $this->is_protected() ? 'disabled="disabled"' : '';
+ $value = '';
+ $disable = $this->is_protected() ? 'disabled="disabled"' : '';
- $key = htmlspecialchars($this->_key);
+ $key = htmlspecialchars($this->_key);
- $label = '<label for="config___'.$key.'">'.$this->prompt($plugin).'</label>';
- $input = '<input id="config___'.$key.'" name="config['.$key.']" autocomplete="off" type="password" class="edit" value="" '.$disable.' />';
- return array($label,$input);
+ $label = '<label for="config___'.$key.'">'.$this->prompt($plugin).'</label>';
+ $input = '<input id="config___'.$key.'" name="config['.$key.']" autocomplete="off" type="password" class="edit" value="" '.$disable.' />';
+ return array($label,$input);
+ }
}
- }
}
if (!class_exists('setting_email')) {
- class setting_email extends setting_string {
- var $_multiple = false;
- var $_placeholders = false;
-
- /**
- * update setting with user provided value $input
- * if value fails error check, save it
- *
- * @return boolean true if changed, false otherwise (incl. on error)
- */
- function update($input) {
- if (is_null($input)) return false;
- if ($this->is_protected()) return false;
-
- $value = is_null($this->_local) ? $this->_default : $this->_local;
- if ($value == $input) return false;
- if($input === ''){
- $this->_local = $input;
- return true;
- }
- $mail = $input;
+ class setting_email extends setting_string {
+ var $_multiple = false;
+ var $_placeholders = false;
- if($this->_placeholders){
- // replace variables with pseudo values
- $mail = str_replace('@USER@','joe',$mail);
- $mail = str_replace('@NAME@','Joe Schmoe',$mail);
- $mail = str_replace('@MAIL@','joe@example.com',$mail);
- }
+ /**
+ * update setting with user provided value $input
+ * if value fails error check, save it
+ *
+ * @return boolean true if changed, false otherwise (incl. on error)
+ */
+ function update($input) {
+ if (is_null($input)) return false;
+ if ($this->is_protected()) return false;
- // multiple mail addresses?
- if ($this->_multiple) {
- $mails = array_filter(array_map('trim', explode(',', $mail)));
- } else {
- $mails = array($mail);
- }
+ $value = is_null($this->_local) ? $this->_default : $this->_local;
+ if ($value == $input) return false;
+ if($input === ''){
+ $this->_local = $input;
+ return true;
+ }
+ $mail = $input;
- // check them all
- foreach ($mails as $mail) {
- // only check the address part
- if(preg_match('#(.*?)<(.*?)>#', $mail, $matches)){
- $addr = $matches[2];
- }else{
- $addr = $mail;
+ if($this->_placeholders){
+ // replace variables with pseudo values
+ $mail = str_replace('@USER@','joe',$mail);
+ $mail = str_replace('@NAME@','Joe Schmoe',$mail);
+ $mail = str_replace('@MAIL@','joe@example.com',$mail);
}
- if (!mail_isvalid($addr)) {
- $this->_error = true;
- $this->_input = $input;
- return false;
+ // multiple mail addresses?
+ if ($this->_multiple) {
+ $mails = array_filter(array_map('trim', explode(',', $mail)));
+ } else {
+ $mails = array($mail);
}
- }
- $this->_local = $input;
- return true;
+ // check them all
+ foreach ($mails as $mail) {
+ // only check the address part
+ if(preg_match('#(.*?)<(.*?)>#', $mail, $matches)){
+ $addr = $matches[2];
+ }else{
+ $addr = $mail;
+ }
+
+ if (!mail_isvalid($addr)) {
+ $this->_error = true;
+ $this->_input = $input;
+ return false;
+ }
+ }
+
+ $this->_local = $input;
+ return true;
+ }
}
- }
}
/**
* @deprecated 2013-02-16
*/
if (!class_exists('setting_richemail')) {
- class setting_richemail extends setting_email {
- function update($input) {
- $this->_placeholders = true;
- return parent::update($input);
- }
- }
+ class setting_richemail extends setting_email {
+ function update($input) {
+ $this->_placeholders = true;
+ return parent::update($input);
+ }
+ }
}
if (!class_exists('setting_numeric')) {
- class setting_numeric extends setting_string {
- // This allows for many PHP syntax errors...
- // var $_pattern = '/^[-+\/*0-9 ]*$/';
- // much more restrictive, but should eliminate syntax errors.
- var $_pattern = '/^[-+]? *[0-9]+ *(?:[-+*] *[0-9]+ *)*$/';
- var $_min = null;
- var $_max = null;
-
- function update($input) {
- $local = $this->_local;
- $valid = parent::update($input);
- if ($valid && !(is_null($this->_min) && is_null($this->_max))) {
- $numeric_local = (int) eval('return '.$this->_local.';');
- if ((!is_null($this->_min) && $numeric_local < $this->_min) ||
- (!is_null($this->_max) && $numeric_local > $this->_max)) {
- $this->_error = true;
- $this->_input = $input;
- $this->_local = $local;
- $valid = false;
+ class setting_numeric extends setting_string {
+ // This allows for many PHP syntax errors...
+ // var $_pattern = '/^[-+\/*0-9 ]*$/';
+ // much more restrictive, but should eliminate syntax errors.
+ var $_pattern = '/^[-+]? *[0-9]+ *(?:[-+*] *[0-9]+ *)*$/';
+ var $_min = null;
+ var $_max = null;
+
+ function update($input) {
+ $local = $this->_local;
+ $valid = parent::update($input);
+ if ($valid && !(is_null($this->_min) && is_null($this->_max))) {
+ $numeric_local = (int) eval('return '.$this->_local.';');
+ if ((!is_null($this->_min) && $numeric_local < $this->_min) ||
+ (!is_null($this->_max) && $numeric_local > $this->_max)) {
+ $this->_error = true;
+ $this->_input = $input;
+ $this->_local = $local;
+ $valid = false;
+ }
}
+ return $valid;
}
- return $valid;
- }
- function out($var, $fmt='php') {
+ function out($var, $fmt='php') {
- if ($this->is_protected()) return '';
- if (is_null($this->_local) || ($this->_default == $this->_local)) return '';
+ if ($this->is_protected()) return '';
+ if (is_null($this->_local) || ($this->_default == $this->_local)) return '';
- $out = '';
+ $out = '';
- if ($fmt=='php') {
- $local = $this->_local === '' ? "''" : $this->_local;
- $out .= '$'.$var."['".$this->_out_key()."'] = ".$local.";\n";
- }
+ if ($fmt=='php') {
+ $local = $this->_local === '' ? "''" : $this->_local;
+ $out .= '$'.$var."['".$this->_out_key()."'] = ".$local.";\n";
+ }
- return $out;
+ return $out;
+ }
}
- }
}
if (!class_exists('setting_numericopt')) {
@@ -794,309 +794,309 @@ if (!class_exists('setting_numericopt')) {
}
if (!class_exists('setting_onoff')) {
- class setting_onoff extends setting_numeric {
+ class setting_onoff extends setting_numeric {
- function html(&$plugin) {
- $value = '';
- $disable = '';
+ function html(&$plugin) {
+ $value = '';
+ $disable = '';
- if ($this->is_protected()) {
- $value = $this->_protected;
- $disable = ' disabled="disabled"';
- } else {
- $value = is_null($this->_local) ? $this->_default : $this->_local;
- }
+ if ($this->is_protected()) {
+ $value = $this->_protected;
+ $disable = ' disabled="disabled"';
+ } else {
+ $value = is_null($this->_local) ? $this->_default : $this->_local;
+ }
- $key = htmlspecialchars($this->_key);
- $checked = ($value) ? ' checked="checked"' : '';
+ $key = htmlspecialchars($this->_key);
+ $checked = ($value) ? ' checked="checked"' : '';
- $label = '<label for="config___'.$key.'">'.$this->prompt($plugin).'</label>';
- $input = '<div class="input"><input id="config___'.$key.'" name="config['.$key.']" type="checkbox" class="checkbox" value="1"'.$checked.$disable.'/></div>';
- return array($label,$input);
- }
+ $label = '<label for="config___'.$key.'">'.$this->prompt($plugin).'</label>';
+ $input = '<div class="input"><input id="config___'.$key.'" name="config['.$key.']" type="checkbox" class="checkbox" value="1"'.$checked.$disable.'/></div>';
+ return array($label,$input);
+ }
- function update($input) {
- if ($this->is_protected()) return false;
+ function update($input) {
+ if ($this->is_protected()) return false;
- $input = ($input) ? 1 : 0;
- $value = is_null($this->_local) ? $this->_default : $this->_local;
- if ($value == $input) return false;
+ $input = ($input) ? 1 : 0;
+ $value = is_null($this->_local) ? $this->_default : $this->_local;
+ if ($value == $input) return false;
- $this->_local = $input;
- return true;
+ $this->_local = $input;
+ return true;
+ }
}
- }
}
if (!class_exists('setting_multichoice')) {
- class setting_multichoice extends setting_string {
- var $_choices = array();
-
- function html(&$plugin) {
- $value = '';
- $disable = '';
- $nochoice = '';
-
- if ($this->is_protected()) {
- $value = $this->_protected;
- $disable = ' disabled="disabled"';
- } else {
- $value = is_null($this->_local) ? $this->_default : $this->_local;
- }
+ class setting_multichoice extends setting_string {
+ var $_choices = array();
- // ensure current value is included
- if (!in_array($value, $this->_choices)) {
- $this->_choices[] = $value;
- }
- // disable if no other choices
- if (!$this->is_protected() && count($this->_choices) <= 1) {
- $disable = ' disabled="disabled"';
- $nochoice = $plugin->getLang('nochoice');
- }
+ function html(&$plugin) {
+ $value = '';
+ $disable = '';
+ $nochoice = '';
- $key = htmlspecialchars($this->_key);
+ if ($this->is_protected()) {
+ $value = $this->_protected;
+ $disable = ' disabled="disabled"';
+ } else {
+ $value = is_null($this->_local) ? $this->_default : $this->_local;
+ }
- $label = '<label for="config___'.$key.'">'.$this->prompt($plugin).'</label>';
+ // ensure current value is included
+ if (!in_array($value, $this->_choices)) {
+ $this->_choices[] = $value;
+ }
+ // disable if no other choices
+ if (!$this->is_protected() && count($this->_choices) <= 1) {
+ $disable = ' disabled="disabled"';
+ $nochoice = $plugin->getLang('nochoice');
+ }
- $input = "<div class=\"input\">\n";
- $input .= '<select class="edit" id="config___'.$key.'" name="config['.$key.']"'.$disable.'>'."\n";
- foreach ($this->_choices as $choice) {
- $selected = ($value == $choice) ? ' selected="selected"' : '';
- $option = $plugin->getLang($this->_key.'_o_'.$choice);
- if (!$option && isset($this->lang[$this->_key.'_o_'.$choice])) $option = $this->lang[$this->_key.'_o_'.$choice];
- if (!$option) $option = $choice;
+ $key = htmlspecialchars($this->_key);
- $choice = htmlspecialchars($choice);
- $option = htmlspecialchars($option);
- $input .= ' <option value="'.$choice.'"'.$selected.' >'.$option.'</option>'."\n";
- }
- $input .= "</select> $nochoice \n";
- $input .= "</div>\n";
+ $label = '<label for="config___'.$key.'">'.$this->prompt($plugin).'</label>';
- return array($label,$input);
- }
+ $input = "<div class=\"input\">\n";
+ $input .= '<select class="edit" id="config___'.$key.'" name="config['.$key.']"'.$disable.'>'."\n";
+ foreach ($this->_choices as $choice) {
+ $selected = ($value == $choice) ? ' selected="selected"' : '';
+ $option = $plugin->getLang($this->_key.'_o_'.$choice);
+ if (!$option && isset($this->lang[$this->_key.'_o_'.$choice])) $option = $this->lang[$this->_key.'_o_'.$choice];
+ if (!$option) $option = $choice;
+
+ $choice = htmlspecialchars($choice);
+ $option = htmlspecialchars($option);
+ $input .= ' <option value="'.$choice.'"'.$selected.' >'.$option.'</option>'."\n";
+ }
+ $input .= "</select> $nochoice \n";
+ $input .= "</div>\n";
+
+ return array($label,$input);
+ }
- function update($input) {
- if (is_null($input)) return false;
- if ($this->is_protected()) return false;
+ function update($input) {
+ if (is_null($input)) return false;
+ if ($this->is_protected()) return false;
- $value = is_null($this->_local) ? $this->_default : $this->_local;
- if ($value == $input) return false;
+ $value = is_null($this->_local) ? $this->_default : $this->_local;
+ if ($value == $input) return false;
- if (!in_array($input, $this->_choices)) return false;
+ if (!in_array($input, $this->_choices)) return false;
- $this->_local = $input;
- return true;
+ $this->_local = $input;
+ return true;
+ }
}
- }
}
if (!class_exists('setting_dirchoice')) {
- class setting_dirchoice extends setting_multichoice {
+ class setting_dirchoice extends setting_multichoice {
- var $_dir = '';
+ var $_dir = '';
- function initialize($default,$local,$protected) {
+ function initialize($default,$local,$protected) {
- // populate $this->_choices with a list of directories
- $list = array();
+ // populate $this->_choices with a list of directories
+ $list = array();
- if ($dh = @opendir($this->_dir)) {
- while (false !== ($entry = readdir($dh))) {
- if ($entry == '.' || $entry == '..') continue;
- if ($this->_pattern && !preg_match($this->_pattern,$entry)) continue;
+ if ($dh = @opendir($this->_dir)) {
+ while (false !== ($entry = readdir($dh))) {
+ if ($entry == '.' || $entry == '..') continue;
+ if ($this->_pattern && !preg_match($this->_pattern,$entry)) continue;
- $file = (is_link($this->_dir.$entry)) ? readlink($this->_dir.$entry) : $this->_dir.$entry;
- if (is_dir($file)) $list[] = $entry;
- }
- closedir($dh);
- }
- sort($list);
- $this->_choices = $list;
+ $file = (is_link($this->_dir.$entry)) ? readlink($this->_dir.$entry) : $this->_dir.$entry;
+ if (is_dir($file)) $list[] = $entry;
+ }
+ closedir($dh);
+ }
+ sort($list);
+ $this->_choices = $list;
- parent::initialize($default,$local,$protected);
+ parent::initialize($default,$local,$protected);
+ }
}
- }
}
if (!class_exists('setting_hidden')) {
- class setting_hidden extends setting {
- // Used to explicitly ignore a setting in the configuration manager.
- }
+ class setting_hidden extends setting {
+ // Used to explicitly ignore a setting in the configuration manager.
+ }
}
if (!class_exists('setting_fieldset')) {
- class setting_fieldset extends setting {
- // A do-nothing class used to detect the 'fieldset' type.
- // Used to start a new settings "display-group".
- }
+ class setting_fieldset extends setting {
+ // A do-nothing class used to detect the 'fieldset' type.
+ // Used to start a new settings "display-group".
+ }
}
if (!class_exists('setting_undefined')) {
- class setting_undefined extends setting_hidden {
- // A do-nothing class used to detect settings with no metadata entry.
- // Used internaly to hide undefined settings, and generate the undefined settings list.
- }
+ class setting_undefined extends setting_hidden {
+ // A do-nothing class used to detect settings with no metadata entry.
+ // Used internaly to hide undefined settings, and generate the undefined settings list.
+ }
}
if (!class_exists('setting_no_class')) {
- class setting_no_class extends setting_undefined {
- // A do-nothing class used to detect settings with a missing setting class.
- // Used internaly to hide undefined settings, and generate the undefined settings list.
- }
+ class setting_no_class extends setting_undefined {
+ // A do-nothing class used to detect settings with a missing setting class.
+ // Used internaly to hide undefined settings, and generate the undefined settings list.
+ }
}
if (!class_exists('setting_no_default')) {
- class setting_no_default extends setting_undefined {
- // A do-nothing class used to detect settings with no default value.
- // Used internaly to hide undefined settings, and generate the undefined settings list.
- }
+ class setting_no_default extends setting_undefined {
+ // A do-nothing class used to detect settings with no default value.
+ // Used internaly to hide undefined settings, and generate the undefined settings list.
+ }
}
if (!class_exists('setting_multicheckbox')) {
- class setting_multicheckbox extends setting_string {
+ class setting_multicheckbox extends setting_string {
- var $_choices = array();
- var $_combine = array();
+ var $_choices = array();
+ var $_combine = array();
- function update($input) {
- if ($this->is_protected()) return false;
+ function update($input) {
+ if ($this->is_protected()) return false;
- // split any combined values + convert from array to comma separated string
- $input = ($input) ? $input : array();
- $input = $this->_array2str($input);
+ // split any combined values + convert from array to comma separated string
+ $input = ($input) ? $input : array();
+ $input = $this->_array2str($input);
- $value = is_null($this->_local) ? $this->_default : $this->_local;
- if ($value == $input) return false;
+ $value = is_null($this->_local) ? $this->_default : $this->_local;
+ if ($value == $input) return false;
+
+ if ($this->_pattern && !preg_match($this->_pattern,$input)) {
+ $this->_error = true;
+ $this->_input = $input;
+ return false;
+ }
- if ($this->_pattern && !preg_match($this->_pattern,$input)) {
- $this->_error = true;
- $this->_input = $input;
- return false;
+ $this->_local = $input;
+ return true;
}
- $this->_local = $input;
- return true;
- }
+ function html(&$plugin, $echo=false) {
- function html(&$plugin, $echo=false) {
+ $value = '';
+ $disable = '';
- $value = '';
- $disable = '';
+ if ($this->is_protected()) {
+ $value = $this->_protected;
+ $disable = 'disabled="disabled"';
+ } else {
+ if ($echo && $this->_error) {
+ $value = $this->_input;
+ } else {
+ $value = is_null($this->_local) ? $this->_default : $this->_local;
+ }
+ }
- if ($this->is_protected()) {
- $value = $this->_protected;
- $disable = 'disabled="disabled"';
- } else {
- if ($echo && $this->_error) {
- $value = $this->_input;
- } else {
- $value = is_null($this->_local) ? $this->_default : $this->_local;
- }
- }
+ $key = htmlspecialchars($this->_key);
- $key = htmlspecialchars($this->_key);
+ // convert from comma separated list into array + combine complimentary actions
+ $value = $this->_str2array($value);
+ $default = $this->_str2array($this->_default);
- // convert from comma separated list into array + combine complimentary actions
- $value = $this->_str2array($value);
- $default = $this->_str2array($this->_default);
+ $input = '';
+ foreach ($this->_choices as $choice) {
+ $idx = array_search($choice, $value);
+ $idx_default = array_search($choice,$default);
- $input = '';
- foreach ($this->_choices as $choice) {
- $idx = array_search($choice, $value);
- $idx_default = array_search($choice,$default);
+ $checked = ($idx !== false) ? 'checked="checked"' : '';
- $checked = ($idx !== false) ? 'checked="checked"' : '';
+ // ideally this would be handled using a second class of "default", however IE6 does not
+ // correctly support CSS selectors referencing multiple class names on the same element
+ // (e.g. .default.selection).
+ $class = (($idx !== false) == (false !== $idx_default)) ? " selectiondefault" : "";
- // ideally this would be handled using a second class of "default", however IE6 does not
- // correctly support CSS selectors referencing multiple class names on the same element
- // (e.g. .default.selection).
- $class = (($idx !== false) == (false !== $idx_default)) ? " selectiondefault" : "";
+ $prompt = ($plugin->getLang($this->_key.'_'.$choice) ?
+ $plugin->getLang($this->_key.'_'.$choice) : htmlspecialchars($choice));
- $prompt = ($plugin->getLang($this->_key.'_'.$choice) ?
- $plugin->getLang($this->_key.'_'.$choice) : htmlspecialchars($choice));
+ $input .= '<div class="selection'.$class.'">'."\n";
+ $input .= '<label for="config___'.$key.'_'.$choice.'">'.$prompt."</label>\n";
+ $input .= '<input id="config___'.$key.'_'.$choice.'" name="config['.$key.'][]" type="checkbox" class="checkbox" value="'.$choice.'" '.$disable.' '.$checked."/>\n";
+ $input .= "</div>\n";
- $input .= '<div class="selection'.$class.'">'."\n";
- $input .= '<label for="config___'.$key.'_'.$choice.'">'.$prompt."</label>\n";
- $input .= '<input id="config___'.$key.'_'.$choice.'" name="config['.$key.'][]" type="checkbox" class="checkbox" value="'.$choice.'" '.$disable.' '.$checked."/>\n";
- $input .= "</div>\n";
+ // remove this action from the disabledactions array
+ if ($idx !== false) unset($value[$idx]);
+ if ($idx_default !== false) unset($default[$idx_default]);
+ }
- // remove this action from the disabledactions array
- if ($idx !== false) unset($value[$idx]);
- if ($idx_default !== false) unset($default[$idx_default]);
- }
+ // handle any remaining values
+ $other = join(',',$value);
- // handle any remaining values
- $other = join(',',$value);
+ $class = (count($default == count($value)) && (count($value) == count(array_intersect($value,$default)))) ?
+ " selectiondefault" : "";
- $class = (count($default == count($value)) && (count($value) == count(array_intersect($value,$default)))) ?
- " selectiondefault" : "";
+ $input .= '<div class="other'.$class.'">'."\n";
+ $input .= '<label for="config___'.$key.'_other">'.$plugin->getLang($key.'_other')."</label>\n";
+ $input .= '<input id="config___'.$key.'_other" name="config['.$key.'][other]" type="text" class="edit" value="'.htmlspecialchars($other).'" '.$disable." />\n";
+ $input .= "</div>\n";
- $input .= '<div class="other'.$class.'">'."\n";
- $input .= '<label for="config___'.$key.'_other">'.$plugin->getLang($key.'_other')."</label>\n";
- $input .= '<input id="config___'.$key.'_other" name="config['.$key.'][other]" type="text" class="edit" value="'.htmlspecialchars($other).'" '.$disable." />\n";
- $input .= "</div>\n";
+ $label = '<label>'.$this->prompt($plugin).'</label>';
+ return array($label,$input);
+ }
- $label = '<label>'.$this->prompt($plugin).'</label>';
- return array($label,$input);
- }
+ /**
+ * convert comma separated list to an array and combine any complimentary values
+ */
+ function _str2array($str) {
+ $array = explode(',',$str);
+
+ if (!empty($this->_combine)) {
+ foreach ($this->_combine as $key => $combinators) {
+ $idx = array();
+ foreach ($combinators as $val) {
+ if (($idx[] = array_search($val, $array)) === false) break;
+ }
+
+ if (count($idx) && $idx[count($idx)-1] !== false) {
+ foreach ($idx as $i) unset($array[$i]);
+ $array[] = $key;
+ }
+ }
+ }
- /**
- * convert comma separated list to an array and combine any complimentary values
- */
- function _str2array($str) {
- $array = explode(',',$str);
-
- if (!empty($this->_combine)) {
- foreach ($this->_combine as $key => $combinators) {
- $idx = array();
- foreach ($combinators as $val) {
- if (($idx[] = array_search($val, $array)) === false) break;
- }
-
- if (count($idx) && $idx[count($idx)-1] !== false) {
- foreach ($idx as $i) unset($array[$i]);
- $array[] = $key;
- }
+ return $array;
}
- }
- return $array;
- }
+ /**
+ * convert array of values + other back to a comma separated list, incl. splitting any combined values
+ */
+ function _array2str($input) {
- /**
- * convert array of values + other back to a comma separated list, incl. splitting any combined values
- */
- function _array2str($input) {
+ // handle other
+ $other = trim($input['other']);
+ $other = !empty($other) ? explode(',',str_replace(' ','',$input['other'])) : array();
+ unset($input['other']);
- // handle other
- $other = trim($input['other']);
- $other = !empty($other) ? explode(',',str_replace(' ','',$input['other'])) : array();
- unset($input['other']);
+ $array = array_unique(array_merge($input, $other));
- $array = array_unique(array_merge($input, $other));
+ // deconstruct any combinations
+ if (!empty($this->_combine)) {
+ foreach ($this->_combine as $key => $combinators) {
- // deconstruct any combinations
- if (!empty($this->_combine)) {
- foreach ($this->_combine as $key => $combinators) {
+ $idx = array_search($key,$array);
+ if ($idx !== false) {
+ unset($array[$idx]);
+ $array = array_merge($array, $combinators);
+ }
+ }
+ }
- $idx = array_search($key,$array);
- if ($idx !== false) {
- unset($array[$idx]);
- $array = array_merge($array, $combinators);
- }
+ return join(',',array_unique($array));
}
- }
-
- return join(',',array_unique($array));
}
- }
}
if (!class_exists('setting_regex')){
- class setting_regex extends setting_string {
+ class setting_regex extends setting_string {
var $_delimiter = '/'; // regex delimiter to be used in testing input
var $_pregflags = 'ui'; // regex pattern modifiers to be used in testing input
diff --git a/lib/plugins/config/settings/extra.class.php b/lib/plugins/config/settings/extra.class.php
index e4b97eb01..954178bc1 100644
--- a/lib/plugins/config/settings/extra.class.php
+++ b/lib/plugins/config/settings/extra.class.php
@@ -6,204 +6,204 @@
*/
if (!class_exists('setting_sepchar')) {
- class setting_sepchar extends setting_multichoice {
+ class setting_sepchar extends setting_multichoice {
- function setting_sepchar($key,$param=NULL) {
- $str = '_-.';
- for ($i=0;$i<strlen($str);$i++) $this->_choices[] = $str{$i};
+ function setting_sepchar($key,$param=NULL) {
+ $str = '_-.';
+ for ($i=0;$i<strlen($str);$i++) $this->_choices[] = $str{$i};
- // call foundation class constructor
- $this->setting($key,$param);
+ // call foundation class constructor
+ $this->setting($key,$param);
+ }
}
- }
}
if (!class_exists('setting_savedir')) {
- class setting_savedir extends setting_string {
+ class setting_savedir extends setting_string {
- function update($input) {
- if ($this->is_protected()) return false;
+ function update($input) {
+ if ($this->is_protected()) return false;
- $value = is_null($this->_local) ? $this->_default : $this->_local;
- if ($value == $input) return false;
+ $value = is_null($this->_local) ? $this->_default : $this->_local;
+ if ($value == $input) return false;
- if (!init_path($input)) {
- $this->_error = true;
- $this->_input = $input;
- return false;
- }
+ if (!init_path($input)) {
+ $this->_error = true;
+ $this->_input = $input;
+ return false;
+ }
- $this->_local = $input;
- return true;
+ $this->_local = $input;
+ return true;
+ }
}
- }
}
if (!class_exists('setting_authtype')) {
- class setting_authtype extends setting_multichoice {
+ class setting_authtype extends setting_multichoice {
- function initialize($default,$local,$protected) {
- global $plugin_controller;
+ function initialize($default,$local,$protected) {
+ global $plugin_controller;
- // retrieve auth types provided by plugins
- foreach ($plugin_controller->getList('auth') as $plugin) {
- $this->_choices[] = $plugin;
- }
-
- parent::initialize($default,$local,$protected);
- }
-
- function update($input) {
- global $plugin_controller;
-
- // is an update possible/requested?
- $local = $this->_local; // save this, parent::update() may change it
- if (!parent::update($input)) return false; // nothing changed or an error caught by parent
- $this->_local = $local; // restore original, more error checking to come
-
- // attempt to load the plugin
- $auth_plugin = $plugin_controller->load('auth', $input);
-
- // @TODO: throw an error in plugin controller instead of returning null
- if (is_null($auth_plugin)) {
- $this->_error = true;
- msg('Cannot load Auth Plugin "' . $input . '"', -1);
- return false;
- }
+ // retrieve auth types provided by plugins
+ foreach ($plugin_controller->getList('auth') as $plugin) {
+ $this->_choices[] = $plugin;
+ }
- // verify proper instantiation (is this really a plugin?) @TODO use instanceof? implement interface?
- if (is_object($auth_plugin) && !method_exists($auth_plugin, 'getPluginName')) {
- $this->_error = true;
- msg('Cannot create Auth Plugin "' . $input . '"', -1);
- return false;
+ parent::initialize($default,$local,$protected);
}
- // did we change the auth type? logout
- global $conf;
- if($conf['authtype'] != $input) {
- msg('Authentication system changed. Please re-login.');
- auth_logoff();
+ function update($input) {
+ global $plugin_controller;
+
+ // is an update possible/requested?
+ $local = $this->_local; // save this, parent::update() may change it
+ if (!parent::update($input)) return false; // nothing changed or an error caught by parent
+ $this->_local = $local; // restore original, more error checking to come
+
+ // attempt to load the plugin
+ $auth_plugin = $plugin_controller->load('auth', $input);
+
+ // @TODO: throw an error in plugin controller instead of returning null
+ if (is_null($auth_plugin)) {
+ $this->_error = true;
+ msg('Cannot load Auth Plugin "' . $input . '"', -1);
+ return false;
+ }
+
+ // verify proper instantiation (is this really a plugin?) @TODO use instanceof? implement interface?
+ if (is_object($auth_plugin) && !method_exists($auth_plugin, 'getPluginName')) {
+ $this->_error = true;
+ msg('Cannot create Auth Plugin "' . $input . '"', -1);
+ return false;
+ }
+
+ // did we change the auth type? logout
+ global $conf;
+ if($conf['authtype'] != $input) {
+ msg('Authentication system changed. Please re-login.');
+ auth_logoff();
+ }
+
+ $this->_local = $input;
+ return true;
}
-
- $this->_local = $input;
- return true;
}
- }
}
if (!class_exists('setting_im_convert')) {
- class setting_im_convert extends setting_string {
+ class setting_im_convert extends setting_string {
- function update($input) {
- if ($this->is_protected()) return false;
+ function update($input) {
+ if ($this->is_protected()) return false;
- $input = trim($input);
+ $input = trim($input);
- $value = is_null($this->_local) ? $this->_default : $this->_local;
- if ($value == $input) return false;
+ $value = is_null($this->_local) ? $this->_default : $this->_local;
+ if ($value == $input) return false;
- if ($input && !@file_exists($input)) {
- $this->_error = true;
- $this->_input = $input;
- return false;
- }
+ if ($input && !@file_exists($input)) {
+ $this->_error = true;
+ $this->_input = $input;
+ return false;
+ }
- $this->_local = $input;
- return true;
+ $this->_local = $input;
+ return true;
+ }
}
- }
}
if (!class_exists('setting_disableactions')) {
- class setting_disableactions extends setting_multicheckbox {
+ class setting_disableactions extends setting_multicheckbox {
- function html(&$plugin, $echo=false) {
- global $lang;
+ function html(&$plugin, $echo=false) {
+ global $lang;
- // make some language adjustments (there must be a better way)
- // transfer some DokuWiki language strings to the plugin
- if (!$plugin->localised) $this->setupLocale();
- $plugin->lang[$this->_key.'_revisions'] = $lang['btn_revs'];
+ // make some language adjustments (there must be a better way)
+ // transfer some DokuWiki language strings to the plugin
+ if (!$plugin->localised) $this->setupLocale();
+ $plugin->lang[$this->_key.'_revisions'] = $lang['btn_revs'];
- foreach ($this->_choices as $choice)
- if (isset($lang['btn_'.$choice])) $plugin->lang[$this->_key.'_'.$choice] = $lang['btn_'.$choice];
+ foreach ($this->_choices as $choice)
+ if (isset($lang['btn_'.$choice])) $plugin->lang[$this->_key.'_'.$choice] = $lang['btn_'.$choice];
- return parent::html($plugin, $echo);
+ return parent::html($plugin, $echo);
+ }
}
- }
}
if (!class_exists('setting_compression')) {
- class setting_compression extends setting_multichoice {
+ class setting_compression extends setting_multichoice {
- var $_choices = array('0'); // 0 = no compression, always supported
+ var $_choices = array('0'); // 0 = no compression, always supported
- function initialize($default,$local,$protected) {
+ function initialize($default,$local,$protected) {
- // populate _choices with the compression methods supported by this php installation
- if (function_exists('gzopen')) $this->_choices[] = 'gz';
- if (function_exists('bzopen')) $this->_choices[] = 'bz2';
+ // populate _choices with the compression methods supported by this php installation
+ if (function_exists('gzopen')) $this->_choices[] = 'gz';
+ if (function_exists('bzopen')) $this->_choices[] = 'bz2';
- parent::initialize($default,$local,$protected);
+ parent::initialize($default,$local,$protected);
+ }
}
- }
}
if (!class_exists('setting_license')) {
- class setting_license extends setting_multichoice {
+ class setting_license extends setting_multichoice {
- var $_choices = array(''); // none choosen
+ var $_choices = array(''); // none choosen
- function initialize($default,$local,$protected) {
- global $license;
+ function initialize($default,$local,$protected) {
+ global $license;
- foreach($license as $key => $data){
- $this->_choices[] = $key;
- $this->lang[$this->_key.'_o_'.$key] = $data['name'];
- }
+ foreach($license as $key => $data){
+ $this->_choices[] = $key;
+ $this->lang[$this->_key.'_o_'.$key] = $data['name'];
+ }
- parent::initialize($default,$local,$protected);
+ parent::initialize($default,$local,$protected);
+ }
}
- }
}
if (!class_exists('setting_renderer')) {
- class setting_renderer extends setting_multichoice {
- var $_prompts = array();
+ class setting_renderer extends setting_multichoice {
+ var $_prompts = array();
- function initialize($default,$local,$protected) {
- $format = $this->_format;
+ function initialize($default,$local,$protected) {
+ $format = $this->_format;
- foreach (plugin_list('renderer') as $plugin) {
- $renderer =& plugin_load('renderer',$plugin);
- if (method_exists($renderer,'canRender') && $renderer->canRender($format)) {
- $this->_choices[] = $plugin;
+ foreach (plugin_list('renderer') as $plugin) {
+ $renderer =& plugin_load('renderer',$plugin);
+ if (method_exists($renderer,'canRender') && $renderer->canRender($format)) {
+ $this->_choices[] = $plugin;
- $info = $renderer->getInfo();
- $this->_prompts[$plugin] = $info['name'];
- }
- }
-
- parent::initialize($default,$local,$protected);
- }
+ $info = $renderer->getInfo();
+ $this->_prompts[$plugin] = $info['name'];
+ }
+ }
- function html(&$plugin, $echo=false) {
-
- // make some language adjustments (there must be a better way)
- // transfer some plugin names to the config plugin
- if (!$plugin->localised) $this->setupLocale();
+ parent::initialize($default,$local,$protected);
+ }
- foreach ($this->_choices as $choice) {
- if (!isset($plugin->lang[$this->_key.'_o_'.$choice])) {
- if (!isset($this->_prompts[$choice])) {
- $plugin->lang[$this->_key.'_o_'.$choice] = sprintf($plugin->lang['renderer__core'],$choice);
- } else {
- $plugin->lang[$this->_key.'_o_'.$choice] = sprintf($plugin->lang['renderer__plugin'],$this->_prompts[$choice]);
- }
+ function html(&$plugin, $echo=false) {
+
+ // make some language adjustments (there must be a better way)
+ // transfer some plugin names to the config plugin
+ if (!$plugin->localised) $this->setupLocale();
+
+ foreach ($this->_choices as $choice) {
+ if (!isset($plugin->lang[$this->_key.'_o_'.$choice])) {
+ if (!isset($this->_prompts[$choice])) {
+ $plugin->lang[$this->_key.'_o_'.$choice] = sprintf($plugin->lang['renderer__core'],$choice);
+ } else {
+ $plugin->lang[$this->_key.'_o_'.$choice] = sprintf($plugin->lang['renderer__plugin'],$this->_prompts[$choice]);
+ }
+ }
+ }
+ return parent::html($plugin, $echo);
}
- }
- return parent::html($plugin, $echo);
}
- }
}
diff --git a/lib/plugins/safefnrecode/action.php b/lib/plugins/safefnrecode/action.php
index aae11c437..9127f8df2 100644
--- a/lib/plugins/safefnrecode/action.php
+++ b/lib/plugins/safefnrecode/action.php
@@ -15,7 +15,7 @@ class action_plugin_safefnrecode extends DokuWiki_Action_Plugin {
public function register(Doku_Event_Handler $controller) {
- $controller->register_hook('INDEXER_TASKS_RUN', 'BEFORE', $this, 'handle_indexer_tasks_run');
+ $controller->register_hook('INDEXER_TASKS_RUN', 'BEFORE', $this, 'handle_indexer_tasks_run');
}
diff --git a/lib/plugins/syntax.php b/lib/plugins/syntax.php
index b7839b2b2..6aa403b61 100644
--- a/lib/plugins/syntax.php
+++ b/lib/plugins/syntax.php
@@ -137,7 +137,7 @@ class DokuWiki_Syntax_Plugin extends Doku_Parser_Mode {
$idx = array_search(substr(get_class($this), 7), (array) $this->allowedModes);
if ($idx !== false) {
- unset($this->allowedModes[$idx]);
+ unset($this->allowedModes[$idx]);
}
$this->allowedModesSetup = true;
}
@@ -169,9 +169,9 @@ class DokuWiki_Syntax_Plugin extends Doku_Parser_Mode {
* @return string string in appropriate language or english if not available
*/
function getLang($id) {
- if (!$this->localised) $this->setupLocale();
+ if (!$this->localised) $this->setupLocale();
- return (isset($this->lang[$id]) ? $this->lang[$id] : '');
+ return (isset($this->lang[$id]) ? $this->lang[$id] : '');
}
/**
@@ -184,7 +184,7 @@ class DokuWiki_Syntax_Plugin extends Doku_Parser_Mode {
* @return string parsed contents of the wiki page in xhtml format
*/
function locale_xhtml($id) {
- return p_cached_output($this->localFN($id));
+ return p_cached_output($this->localFN($id));
}
/**
@@ -193,17 +193,17 @@ class DokuWiki_Syntax_Plugin extends Doku_Parser_Mode {
* plugin equivalent of localFN()
*/
function localFN($id) {
- global $conf;
- $plugin = $this->getPluginName();
- $file = DOKU_CONF.'/plugin_lang/'.$plugin.'/'.$conf['lang'].'/'.$id.'.txt';
- if (!@file_exists($file)){
- $file = DOKU_PLUGIN.$plugin.'/lang/'.$conf['lang'].'/'.$id.'.txt';
- if(!@file_exists($file)){
- //fall back to english
- $file = DOKU_PLUGIN.$plugin.'/lang/en/'.$id.'.txt';
+ global $conf;
+ $plugin = $this->getPluginName();
+ $file = DOKU_CONF.'/plugin_lang/'.$plugin.'/'.$conf['lang'].'/'.$id.'.txt';
+ if (!@file_exists($file)){
+ $file = DOKU_PLUGIN.$plugin.'/lang/'.$conf['lang'].'/'.$id.'.txt';
+ if(!@file_exists($file)){
+ //fall back to english
+ $file = DOKU_PLUGIN.$plugin.'/lang/en/'.$id.'.txt';
+ }
}
- }
- return $file;
+ return $file;
}
/**
@@ -214,16 +214,16 @@ class DokuWiki_Syntax_Plugin extends Doku_Parser_Mode {
function setupLocale() {
if ($this->localised) return;
- global $conf; // definitely don't invoke "global $lang"
- $path = DOKU_PLUGIN.$this->getPluginName().'/lang/';
-
- $lang = array();
- // don't include once, in case several plugin components require the same language file
- @include($path.'en/lang.php');
- if ($conf['lang'] != 'en') @include($path.$conf['lang'].'/lang.php');
-
- $this->lang = $lang;
- $this->localised = true;
+ global $conf; // definitely don't invoke "global $lang"
+ $path = DOKU_PLUGIN.$this->getPluginName().'/lang/';
+
+ $lang = array();
+ // don't include once, in case several plugin components require the same language file
+ @include($path.'en/lang.php');
+ if ($conf['lang'] != 'en') @include($path.$conf['lang'].'/lang.php');
+
+ $this->lang = $lang;
+ $this->localised = true;
}
// configuration methods
diff --git a/lib/plugins/usermanager/admin.php b/lib/plugins/usermanager/admin.php
index 762daa6b9..a0e77065e 100644
--- a/lib/plugins/usermanager/admin.php
+++ b/lib/plugins/usermanager/admin.php
@@ -41,13 +41,13 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin {
$this->setupLocale();
if (!isset($auth)) {
- $this->disabled = $this->lang['noauth'];
+ $this->disabled = $this->lang['noauth'];
} else if (!$auth->canDo('getUsers')) {
- $this->disabled = $this->lang['nosupport'];
+ $this->disabled = $this->lang['nosupport'];
} else {
- // we're good to go
- $this->_auth = & $auth;
+ // we're good to go
+ $this->_auth = & $auth;
}
@@ -95,31 +95,31 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin {
}
if ($cmd != "search") {
- $this->_start = $INPUT->int('start', 0);
- $this->_filter = $this->_retrieveFilter();
+ $this->_start = $INPUT->int('start', 0);
+ $this->_filter = $this->_retrieveFilter();
}
switch($cmd){
- case "add" : $this->_addUser(); break;
- case "delete" : $this->_deleteUser(); break;
- case "modify" : $this->_modifyUser(); break;
- case "edit" : $this->_editUser($param); break;
- case "search" : $this->_setFilter($param);
- $this->_start = 0;
- break;
- case "export" : $this->_export(); break;
- case "import" : $this->_import(); break;
- case "importfails" : $this->_downloadImportFailures(); break;
+ case "add" : $this->_addUser(); break;
+ case "delete" : $this->_deleteUser(); break;
+ case "modify" : $this->_modifyUser(); break;
+ case "edit" : $this->_editUser($param); break;
+ case "search" : $this->_setFilter($param);
+ $this->_start = 0;
+ break;
+ case "export" : $this->_export(); break;
+ case "import" : $this->_import(); break;
+ case "importfails" : $this->_downloadImportFailures(); break;
}
$this->_user_total = $this->_auth->canDo('getUserCount') ? $this->_auth->getUserCount($this->_filter) : -1;
// page handling
switch($cmd){
- case 'start' : $this->_start = 0; break;
- case 'prev' : $this->_start -= $this->_pagesize; break;
- case 'next' : $this->_start += $this->_pagesize; break;
- case 'last' : $this->_start = $this->_user_total; break;
+ case 'start' : $this->_start = 0; break;
+ case 'prev' : $this->_start -= $this->_pagesize; break;
+ case 'next' : $this->_start += $this->_pagesize; break;
+ case 'last' : $this->_start = $this->_user_total; break;
}
$this->_validatePagination();
}
@@ -151,9 +151,9 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin {
ptln("<div class=\"level2\">");
if ($this->_user_total > 0) {
- ptln("<p>".sprintf($this->lang['summary'],$this->_start+1,$this->_last,$this->_user_total,$this->_auth->getUserCount())."</p>");
+ ptln("<p>".sprintf($this->lang['summary'],$this->_start+1,$this->_last,$this->_user_total,$this->_auth->getUserCount())."</p>");
} else {
- ptln("<p>".sprintf($this->lang['nonefound'],$this->_auth->getUserCount())."</p>");
+ ptln("<p>".sprintf($this->lang['nonefound'],$this->_auth->getUserCount())."</p>");
}
ptln("<form action=\"".wl($ID)."\" method=\"post\">");
formSecurityToken();
@@ -174,25 +174,25 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin {
ptln(" </thead>");
if ($this->_user_total) {
- ptln(" <tbody>");
- foreach ($user_list as $user => $userinfo) {
- extract($userinfo);
- $groups = join(', ',$grps);
- ptln(" <tr class=\"user_info\">");
- ptln(" <td class=\"centeralign\"><input type=\"checkbox\" name=\"delete[".$user."]\" ".$delete_disable." /></td>");
- if ($editable) {
- ptln(" <td><a href=\"".wl($ID,array('fn[edit]['.hsc($user).']' => 1,
- 'do' => 'admin',
- 'page' => 'usermanager',
- 'sectok' => getSecurityToken())).
- "\" title=\"".$this->lang['edit_prompt']."\">".hsc($user)."</a></td>");
- } else {
- ptln(" <td>".hsc($user)."</td>");
+ ptln(" <tbody>");
+ foreach ($user_list as $user => $userinfo) {
+ extract($userinfo);
+ $groups = join(', ',$grps);
+ ptln(" <tr class=\"user_info\">");
+ ptln(" <td class=\"centeralign\"><input type=\"checkbox\" name=\"delete[".$user."]\" ".$delete_disable." /></td>");
+ if ($editable) {
+ ptln(" <td><a href=\"".wl($ID,array('fn[edit]['.hsc($user).']' => 1,
+ 'do' => 'admin',
+ 'page' => 'usermanager',
+ 'sectok' => getSecurityToken())).
+ "\" title=\"".$this->lang['edit_prompt']."\">".hsc($user)."</a></td>");
+ } else {
+ ptln(" <td>".hsc($user)."</td>");
+ }
+ ptln(" <td>".hsc($name)."</td><td>".hsc($mail)."</td><td>".hsc($groups)."</td>");
+ ptln(" </tr>");
}
- ptln(" <td>".hsc($name)."</td><td>".hsc($mail)."</td><td>".hsc($groups)."</td>");
- ptln(" </tr>");
- }
- ptln(" </tbody>");
+ ptln(" </tbody>");
}
ptln(" <tbody>");
@@ -226,29 +226,29 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin {
$style = $this->_edit_user ? " class=\"edit_user\"" : "";
if ($this->_auth->canDo('addUser')) {
- ptln("<div".$style.">");
- print $this->locale_xhtml('add');
- ptln(" <div class=\"level2\">");
+ ptln("<div".$style.">");
+ print $this->locale_xhtml('add');
+ ptln(" <div class=\"level2\">");
- $this->_htmlUserForm('add',null,array(),4);
+ $this->_htmlUserForm('add',null,array(),4);
- ptln(" </div>");
- ptln("</div>");
+ ptln(" </div>");
+ ptln("</div>");
}
if($this->_edit_user && $this->_auth->canDo('UserMod')){
- ptln("<div".$style." id=\"scroll__here\">");
- print $this->locale_xhtml('edit');
- ptln(" <div class=\"level2\">");
+ ptln("<div".$style." id=\"scroll__here\">");
+ print $this->locale_xhtml('edit');
+ ptln(" <div class=\"level2\">");
- $this->_htmlUserForm('modify',$this->_edit_user,$this->_edit_userdata,4);
+ $this->_htmlUserForm('modify',$this->_edit_user,$this->_edit_userdata,4);
- ptln(" </div>");
- ptln("</div>");
+ ptln(" </div>");
+ ptln("</div>");
}
if ($this->_auth->canDo('addUser')) {
- $this->_htmlImportForm();
+ $this->_htmlImportForm();
}
ptln("</div>");
}
@@ -265,10 +265,10 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin {
$notes = array();
if ($user) {
- extract($userdata);
- if (!empty($grps)) $groups = join(',',$grps);
+ extract($userdata);
+ if (!empty($grps)) $groups = join(',',$grps);
} else {
- $notes[] = sprintf($this->lang['note_group'],$conf['defaultgroup']);
+ $notes[] = sprintf($this->lang['note_group'],$conf['defaultgroup']);
}
ptln("<form action=\"".wl($ID)."\" method=\"post\">",$indent);
@@ -287,14 +287,14 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin {
$this->_htmlInputField($cmd."_usergroups","usergroups",$this->lang["user_groups"],$groups,$this->_auth->canDo("modGroups"),$indent+6);
if ($this->_auth->canDo("modPass")) {
- if ($cmd == 'add') {
- $notes[] = $this->lang['note_pass'];
- }
- if ($user) {
- $notes[] = $this->lang['note_notify'];
- }
+ if ($cmd == 'add') {
+ $notes[] = $this->lang['note_pass'];
+ }
+ if ($user) {
+ $notes[] = $this->lang['note_notify'];
+ }
- ptln("<tr><td><label for=\"".$cmd."_usernotify\" >".$this->lang["user_notify"].": </label></td><td><input type=\"checkbox\" id=\"".$cmd."_usernotify\" name=\"usernotify\" value=\"1\" /></td></tr>", $indent);
+ ptln("<tr><td><label for=\"".$cmd."_usernotify\" >".$this->lang["user_notify"].": </label></td><td><input type=\"checkbox\" id=\"".$cmd."_usernotify\" name=\"usernotify\" value=\"1\" /></td></tr>", $indent);
}
ptln(" </tbody>",$indent);
@@ -317,11 +317,11 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin {
ptln(" </table>",$indent);
if ($notes) {
- ptln(" <ul class=\"notes\">");
- foreach ($notes as $note) {
- ptln(" <li><span class=\"li\">".$note."</span></li>",$indent);
- }
- ptln(" </ul>");
+ ptln(" <ul class=\"notes\">");
+ foreach ($notes as $note) {
+ ptln(" <li><span class=\"li\">".$note."</span></li>",$indent);
+ }
+ ptln(" </ul>");
}
ptln(" </div>",$indent);
ptln("</form>",$indent);
@@ -366,7 +366,7 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin {
ptln("<input type=\"hidden\" name=\"start\" value=\"".$this->_start."\" />",$indent);
foreach ($this->_filter as $key => $filter) {
- ptln("<input type=\"hidden\" name=\"filter[".$key."]\" value=\"".hsc($filter)."\" />",$indent);
+ ptln("<input type=\"hidden\" name=\"filter[".$key."]\" value=\"".hsc($filter)."\" />",$indent);
}
}
@@ -432,52 +432,52 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin {
if (empty($user)) return false;
if ($this->_auth->canDo('modPass')){
- if (empty($pass)){
- if($INPUT->has('usernotify')){
- $pass = auth_pwgen($user);
- } else {
- msg($this->lang['add_fail'], -1);
- return false;
+ if (empty($pass)){
+ if($INPUT->has('usernotify')){
+ $pass = auth_pwgen($user);
+ } else {
+ msg($this->lang['add_fail'], -1);
+ return false;
+ }
}
- }
} else {
- if (!empty($pass)){
- msg($this->lang['add_fail'], -1);
- return false;
- }
+ if (!empty($pass)){
+ msg($this->lang['add_fail'], -1);
+ return false;
+ }
}
if ($this->_auth->canDo('modName')){
- if (empty($name)){
- msg($this->lang['add_fail'], -1);
- return false;
- }
+ if (empty($name)){
+ msg($this->lang['add_fail'], -1);
+ return false;
+ }
} else {
- if (!empty($name)){
- return false;
- }
+ if (!empty($name)){
+ return false;
+ }
}
if ($this->_auth->canDo('modMail')){
- if (empty($mail)){
- msg($this->lang['add_fail'], -1);
- return false;
- }
+ if (empty($mail)){
+ msg($this->lang['add_fail'], -1);
+ return false;
+ }
} else {
- if (!empty($mail)){
- return false;
- }
+ if (!empty($mail)){
+ return false;
+ }
}
if ($ok = $this->_auth->triggerUserMod('create', array($user,$pass,$name,$mail,$grps))) {
- msg($this->lang['add_ok'], 1);
+ msg($this->lang['add_ok'], 1);
- if ($INPUT->has('usernotify') && $pass) {
- $this->_notifyUser($user,$pass);
- }
+ if ($INPUT->has('usernotify') && $pass) {
+ $this->_notifyUser($user,$pass);
+ }
} else {
- msg($this->lang['add_fail'], -1);
+ msg($this->lang['add_fail'], -1);
}
return $ok;
@@ -503,12 +503,12 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin {
$count = $this->_auth->triggerUserMod('delete', array($selected));
if ($count == count($selected)) {
- $text = str_replace('%d', $count, $this->lang['delete_ok']);
- msg("$text.", 1);
+ $text = str_replace('%d', $count, $this->lang['delete_ok']);
+ msg("$text.", 1);
} else {
- $part1 = str_replace('%d', $count, $this->lang['delete_ok']);
- $part2 = str_replace('%d', (count($selected)-$count), $this->lang['delete_fail']);
- msg("$part1, $part2",-1);
+ $part1 = str_replace('%d', $count, $this->lang['delete_ok']);
+ $part2 = str_replace('%d', (count($selected)-$count), $this->lang['delete_fail']);
+ msg("$part1, $part2",-1);
}
// invalidate all sessions
@@ -529,8 +529,8 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin {
// no user found?
if (!$userdata) {
- msg($this->lang['edit_usermissing'],-1);
- return false;
+ msg($this->lang['edit_usermissing'],-1);
+ return false;
}
$this->_edit_user = $user;
@@ -559,18 +559,18 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin {
$changes = array();
if ($newuser != $olduser) {
- if (!$this->_auth->canDo('modLogin')) { // sanity check, shouldn't be possible
- msg($this->lang['update_fail'],-1);
- return false;
- }
+ if (!$this->_auth->canDo('modLogin')) { // sanity check, shouldn't be possible
+ msg($this->lang['update_fail'],-1);
+ return false;
+ }
- // check if $newuser already exists
- if ($this->_auth->getUserData($newuser)) {
- msg(sprintf($this->lang['update_exists'],$newuser),-1);
- $re_edit = true;
- } else {
- $changes['user'] = $newuser;
- }
+ // check if $newuser already exists
+ if ($this->_auth->getUserData($newuser)) {
+ msg(sprintf($this->lang['update_exists'],$newuser),-1);
+ $re_edit = true;
+ } else {
+ $changes['user'] = $newuser;
+ }
}
// generate password if left empty and notification is on
@@ -588,18 +588,18 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin {
$changes['grps'] = $newgrps;
if ($ok = $this->_auth->triggerUserMod('modify', array($olduser, $changes))) {
- msg($this->lang['update_ok'],1);
+ msg($this->lang['update_ok'],1);
- if ($INPUT->has('usernotify') && $newpass) {
- $notify = empty($changes['user']) ? $olduser : $newuser;
- $this->_notifyUser($notify,$newpass);
- }
+ if ($INPUT->has('usernotify') && $newpass) {
+ $notify = empty($changes['user']) ? $olduser : $newuser;
+ $this->_notifyUser($notify,$newpass);
+ }
- // invalidate all sessions
- io_saveFile($conf['cachedir'].'/sessionpurge',time());
+ // invalidate all sessions
+ io_saveFile($conf['cachedir'].'/sessionpurge',time());
} else {
- msg($this->lang['update_fail'],-1);
+ msg($this->lang['update_fail'],-1);
}
if (!empty($re_edit)) {
@@ -615,13 +615,13 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin {
function _notifyUser($user, $password, $status_alert=true) {
if ($sent = auth_sendPassword($user,$password)) {
- if ($status_alert) {
- msg($this->lang['notify_ok'], 1);
- }
+ if ($status_alert) {
+ msg($this->lang['notify_ok'], 1);
+ }
} else {
- if ($status_alert) {
- msg($this->lang['notify_fail'], -1);
- }
+ if ($status_alert) {
+ msg($this->lang['notify_fail'], -1);
+ }
}
return $sent;
@@ -656,12 +656,12 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin {
$this->_filter = array();
if ($op == 'new') {
- list($user,$pass,$name,$mail,$grps) = $this->_retrieveUser(false);
+ list($user,$pass,$name,$mail,$grps) = $this->_retrieveUser(false);
- if (!empty($user)) $this->_filter['user'] = $user;
- if (!empty($name)) $this->_filter['name'] = $name;
- if (!empty($mail)) $this->_filter['mail'] = $mail;
- if (!empty($grps)) $this->_filter['grps'] = join('|',$grps);
+ if (!empty($user)) $this->_filter['user'] = $user;
+ if (!empty($name)) $this->_filter['name'] = $name;
+ if (!empty($mail)) $this->_filter['mail'] = $mail;
+ if (!empty($grps)) $this->_filter['grps'] = join('|',$grps);
}
}
@@ -684,7 +684,7 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin {
function _validatePagination() {
if ($this->_start >= $this->_user_total) {
- $this->_start = $this->_user_total - $this->_pagesize;
+ $this->_start = $this->_user_total - $this->_pagesize;
}
if ($this->_start < 0) $this->_start = 0;
@@ -701,10 +701,10 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin {
$buttons['start'] = $buttons['prev'] = ($this->_start == 0) ? $disabled : '';
if ($this->_user_total == -1) {
- $buttons['last'] = $disabled;
- $buttons['next'] = '';
+ $buttons['last'] = $disabled;
+ $buttons['next'] = '';
} else {
- $buttons['last'] = $buttons['next'] = (($this->_start + $this->_pagesize) >= $this->_user_total) ? $disabled : '';
+ $buttons['last'] = $buttons['next'] = (($this->_start + $this->_pagesize) >= $this->_user_total) ? $disabled : '';
}
return $buttons;
@@ -803,9 +803,9 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin {
// save import failures into the session
if (!headers_sent()) {
- session_start();
- $_SESSION['import_failures'] = $this->_import_failures;
- session_write_close();
+ session_start();
+ $_SESSION['import_failures'] = $this->_import_failures;
+ session_write_close();
}
}