aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--_test/tests/inc/parser/renderer_resolveinterwiki.test.php18
-rw-r--r--inc/Cache/Cache.php13
-rw-r--r--inc/Cache/CacheInstructions.php2
-rw-r--r--inc/Search/Indexer.php4
-rw-r--r--inc/html.php2
-rw-r--r--inc/init.php4
-rw-r--r--inc/io.php2
-rw-r--r--inc/media.php4
-rw-r--r--inc/parser/renderer.php16
-rw-r--r--inc/parser/xhtml.php16
-rw-r--r--inc/template.php7
-rw-r--r--install.php4
-rw-r--r--lib/images/fileicons/index.php2
-rw-r--r--lib/images/smileys/index.php2
-rw-r--r--lib/plugins/extension/helper/extension.php4
-rw-r--r--lib/plugins/usermanager/_test/csv_import.test.php38
-rw-r--r--lib/tpl/dokuwiki/script.js11
-rw-r--r--lib/tpl/index.php2
18 files changed, 97 insertions, 54 deletions
diff --git a/_test/tests/inc/parser/renderer_resolveinterwiki.test.php b/_test/tests/inc/parser/renderer_resolveinterwiki.test.php
index 2cd23dfaa..ae23280cf 100644
--- a/_test/tests/inc/parser/renderer_resolveinterwiki.test.php
+++ b/_test/tests/inc/parser/renderer_resolveinterwiki.test.php
@@ -43,13 +43,27 @@ class Test_resolveInterwiki extends DokuWikiTest {
function testNonexisting() {
$Renderer = new Doku_Renderer();
$Renderer->interwiki = getInterwiki();
+ unset($Renderer->interwiki['default']);
$shortcut = 'nonexisting';
$reference = 'foo @+%/';
$url = $Renderer->_resolveInterWiki($shortcut, $reference);
- $expected = 'https://www.google.com/search?q=foo%20%40%2B%25%2F&btnI=lucky';
- $this->assertEquals($expected, $url);
+ $this->assertEquals('', $url);
+ $this->assertEquals('', $shortcut);
+ }
+
+ function testNonexistingWithDefault() {
+ $Renderer = new Doku_Renderer();
+ $Renderer->interwiki = getInterwiki();
+ $Renderer->interwiki['default'] = 'https://en.wikipedia.org/wiki/{NAME}';
+
+ $shortcut = 'nonexisting';
+ $reference = 'foo';
+ $url = $Renderer->_resolveInterWiki($shortcut, $reference);
+
+ $this->assertEquals('https://en.wikipedia.org/wiki/foo', $url);
+ $this->assertEquals('default', $shortcut);
}
}
diff --git a/inc/Cache/Cache.php b/inc/Cache/Cache.php
index ab64da5cb..af82e6bf6 100644
--- a/inc/Cache/Cache.php
+++ b/inc/Cache/Cache.php
@@ -78,9 +78,13 @@ class Cache
$this->depends = $depends;
$this->addDependencies();
- if ($this->_event) {
- return $this->stats(Event::createAndTrigger(
- $this->_event, $this, array($this, 'makeDefaultCacheDecision'))
+ if ($this->getEvent()) {
+ return $this->stats(
+ Event::createAndTrigger(
+ $this->getEvent(),
+ $this,
+ array($this, 'makeDefaultCacheDecision')
+ )
);
}
@@ -105,7 +109,6 @@ class Cache
*/
public function makeDefaultCacheDecision()
{
-
if ($this->_nocache) {
return false;
} // caching turned off
@@ -170,7 +173,7 @@ class Cache
return false;
}
- return io_savefile($this->cache, $data);
+ return io_saveFile($this->cache, $data);
}
/**
diff --git a/inc/Cache/CacheInstructions.php b/inc/Cache/CacheInstructions.php
index 3c4786105..acd02abae 100644
--- a/inc/Cache/CacheInstructions.php
+++ b/inc/Cache/CacheInstructions.php
@@ -41,6 +41,6 @@ class CacheInstructions extends \dokuwiki\Cache\CacheParser
return false;
}
- return io_savefile($this->cache, serialize($instructions));
+ return io_saveFile($this->cache, serialize($instructions));
}
}
diff --git a/inc/Search/Indexer.php b/inc/Search/Indexer.php
index 8770ac794..a29e5b28b 100644
--- a/inc/Search/Indexer.php
+++ b/inc/Search/Indexer.php
@@ -1000,7 +1000,7 @@ class Indexer {
if (!empty($lines))
fwrite($fh, "\n");
fclose($fh);
- if (isset($conf['fperm']))
+ if ($conf['fperm'])
chmod($fn.'.tmp', $conf['fperm']);
io_rename($fn.'.tmp', $fn.'.idx');
return true;
@@ -1067,7 +1067,7 @@ class Indexer {
fwrite($fh, $line);
}
fclose($fh);
- if (isset($conf['fperm']))
+ if ($conf['fperm'])
chmod($fn.'.tmp', $conf['fperm']);
io_rename($fn.'.tmp', $fn.'.idx');
return true;
diff --git a/inc/html.php b/inc/html.php
index 1287cb4e9..1f494d46b 100644
--- a/inc/html.php
+++ b/inc/html.php
@@ -1940,7 +1940,7 @@ function html_edit(){
if ($wr) {
// sets changed to true when previewed
- echo '<script type="text/javascript">/*<![CDATA[*/'. NL;
+ echo '<script>/*<![CDATA[*/'. NL;
echo 'textChanged = ' . ($mod ? 'true' : 'false');
echo '/*!]]>*/</script>' . NL;
} ?>
diff --git a/inc/init.php b/inc/init.php
index 69ef6f15a..f9bb53472 100644
--- a/inc/init.php
+++ b/inc/init.php
@@ -340,7 +340,7 @@ function init_files(){
$fh = @fopen($file,'a');
if($fh){
fclose($fh);
- if(!empty($conf['fperm'])) chmod($file, $conf['fperm']);
+ if($conf['fperm']) chmod($file, $conf['fperm']);
}else{
nice_die("$file is not writable. Check your permissions settings!");
}
@@ -405,7 +405,7 @@ function init_creationmodes(){
// check what is set automatically by the system on file creation
// and set the fperm param if it's not what we want
- $auto_fmode = 0666 & ~$umask;
+ $auto_fmode = $conf['fmode'] & ~$umask;
if($auto_fmode != $conf['fmode']) $conf['fperm'] = $conf['fmode'];
// check what is set automatically by the system on file creation
diff --git a/inc/io.php b/inc/io.php
index 18aae25e7..1dfabe845 100644
--- a/inc/io.php
+++ b/inc/io.php
@@ -252,7 +252,7 @@ function _io_saveFile($file, $content, $append) {
fclose($fh);
}
- if(!$fileexists and !empty($conf['fperm'])) chmod($file, $conf['fperm']);
+ if(!$fileexists and $conf['fperm']) chmod($file, $conf['fperm']);
return true;
}
diff --git a/inc/media.php b/inc/media.php
index ec40df5ef..cc29bd16c 100644
--- a/inc/media.php
+++ b/inc/media.php
@@ -2082,7 +2082,7 @@ function media_resize_image($file, $ext, $w, $h=0){
media_resize_imageIM($ext, $file, $info[0], $info[1], $local, $w, $h) ||
media_resize_imageGD($ext, $file, $info[0], $info[1], $local, $w, $h)
) {
- if(!empty($conf['fperm'])) @chmod($local, $conf['fperm']);
+ if($conf['fperm']) @chmod($local, $conf['fperm']);
return $local;
}
//still here? resizing failed
@@ -2149,7 +2149,7 @@ function media_crop_image($file, $ext, $w, $h=0){
if( $mtime > @filemtime($file) ||
media_crop_imageIM($ext,$file,$info[0],$info[1],$local,$cw,$ch,$cx,$cy) ||
media_resize_imageGD($ext,$file,$cw,$ch,$local,$cw,$ch,$cx,$cy) ){
- if(!empty($conf['fperm'])) @chmod($local, $conf['fperm']);
+ if($conf['fperm']) @chmod($local, $conf['fperm']);
return media_resize_image($local,$ext, $w, $h);
}
diff --git a/inc/parser/renderer.php b/inc/parser/renderer.php
index 6aba6506c..a03b84c8e 100644
--- a/inc/parser/renderer.php
+++ b/inc/parser/renderer.php
@@ -845,10 +845,13 @@ abstract class Doku_Renderer extends Plugin {
//get interwiki URL
if(isset($this->interwiki[$shortcut])) {
$url = $this->interwiki[$shortcut];
- } else {
- // Default to Google I'm feeling lucky
- $url = 'https://www.google.com/search?q={URL}&amp;btnI=lucky';
- $shortcut = 'go';
+ }elseif(isset($this->interwiki['default'])) {
+ $shortcut = 'default';
+ $url = $this->interwiki[$shortcut];
+ }else{
+ // not parsable interwiki outputs '' to make sure string manipluation works
+ $shortcut = '';
+ $url = '';
}
//split into hash and url part
@@ -880,8 +883,9 @@ abstract class Doku_Renderer extends Plugin {
'{PATH}' => $parsed['path'],
'{QUERY}' => $parsed['query'] ,
]);
- } else {
- //default
+ } else if($url != '') {
+ // make sure when no url is defined, we keep it null
+ // default
$url = $url.rawurlencode($reference);
}
//handle as wiki links
diff --git a/inc/parser/xhtml.php b/inc/parser/xhtml.php
index 662883416..169f4f9f4 100644
--- a/inc/parser/xhtml.php
+++ b/inc/parser/xhtml.php
@@ -1062,11 +1062,13 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
$link['url'] = $url;
$link['title'] = htmlspecialchars($link['url']);
- //output formatted
+ // output formatted
if($returnonly) {
+ if($url == '') return $link['name'];
return $this->_formatLink($link);
} else {
- $this->doc .= $this->_formatLink($link);
+ if($url == '') $this->doc .= $link['name'];
+ else $this->doc .= $this->_formatLink($link);
}
}
@@ -1248,9 +1250,17 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
list($shortcut, $reference) = explode('>', $src, 2);
$exists = null;
$src = $this->_resolveInterWiki($shortcut, $reference, $exists);
+ if($src == '' && empty($title)){
+ // make sure at least something will be shown in this case
+ $title = $reference;
+ }
}
list($src, $hash) = explode('#', $src, 2);
$noLink = false;
+ if($src == '') {
+ // only output plaintext without link if there is no src
+ $noLink = true;
+ }
$render = ($linking == 'linkonly') ? false : true;
$link = $this->_getMediaLinkConf($src, $title, $align, $width, $height, $cache, $render);
@@ -1637,7 +1647,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
if(!$render) {
// if the picture is not supposed to be rendered
// return the title of the picture
- if(!$title) {
+ if($title === null || $title === "") {
// just show the sourcename
$title = $this->_xmlEntities(\dokuwiki\Utf8\PhpString::basename(noNS($src)));
}
diff --git a/inc/template.php b/inc/template.php
index 1aeef1fee..798fea52e 100644
--- a/inc/template.php
+++ b/inc/template.php
@@ -332,7 +332,7 @@ function tpl_metaheaders($alt = true) {
// load stylesheets
$head['link'][] = array(
- 'rel' => 'stylesheet', 'type'=> 'text/css',
+ 'rel' => 'stylesheet',
'href'=> DOKU_BASE.'lib/exe/css.php?t='.rawurlencode($conf['template']).'&tseed='.$tseed
);
@@ -342,13 +342,12 @@ function tpl_metaheaders($alt = true) {
}
jsinfo();
$script .= 'var JSINFO = ' . json_encode($JSINFO).';';
- $head['script'][] = array('type'=> 'text/javascript', '_data'=> $script);
+ $head['script'][] = array('_data'=> $script);
// load jquery
$jquery = getCdnUrls();
foreach($jquery as $src) {
$head['script'][] = array(
- 'type' => 'text/javascript',
'charset' => 'utf-8',
'_data' => '',
'src' => $src,
@@ -357,7 +356,7 @@ function tpl_metaheaders($alt = true) {
// load our javascript dispatcher
$head['script'][] = array(
- 'type'=> 'text/javascript', 'charset'=> 'utf-8', '_data'=> '',
+ 'charset'=> 'utf-8', '_data'=> '',
'src' => DOKU_BASE.'lib/exe/js.php'.'?t='.rawurlencode($conf['template']).'&tseed='.$tseed,
) + ($conf['defer_js'] ? [ 'defer' => 'defer'] : []);
diff --git a/install.php b/install.php
index f77ddb55e..253cd3550 100644
--- a/install.php
+++ b/install.php
@@ -46,7 +46,7 @@ header('Content-Type: text/html; charset=utf-8');
<head>
<meta charset="utf-8" />
<title><?php echo $lang['i_installer']?></title>
- <style type="text/css">
+ <style>
body { width: 90%; margin: 0 auto; font: 84% Verdana, Helvetica, Arial, sans-serif; }
img { border: none }
br.cl { clear:both; }
@@ -56,7 +56,7 @@ header('Content-Type: text/html; charset=utf-8');
select.text, input.text { width: 30em; margin: 0 0.5em; }
a {text-decoration: none}
</style>
- <script type="text/javascript">
+ <script>
function acltoggle(){
var cb = document.getElementById('acl');
var fs = document.getElementById('acldep');
diff --git a/lib/images/fileicons/index.php b/lib/images/fileicons/index.php
index 8ec577593..d1f233e48 100644
--- a/lib/images/fileicons/index.php
+++ b/lib/images/fileicons/index.php
@@ -3,7 +3,7 @@
<head>
<title>Filetype icons</title>
- <style type="text/css">
+ <style>
body {
background-color: #ccc;
font-family: Arial;
diff --git a/lib/images/smileys/index.php b/lib/images/smileys/index.php
index c9c74872f..574966628 100644
--- a/lib/images/smileys/index.php
+++ b/lib/images/smileys/index.php
@@ -3,7 +3,7 @@
<head>
<title>Smileys</title>
- <style type="text/css">
+ <style>
body {
background-color: #ccc;
font-family: Arial;
diff --git a/lib/plugins/extension/helper/extension.php b/lib/plugins/extension/helper/extension.php
index 47fe87373..3e7087eba 100644
--- a/lib/plugins/extension/helper/extension.php
+++ b/lib/plugins/extension/helper/extension.php
@@ -1245,10 +1245,10 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin
closedir($dh);
return $ok;
} else {
- $exists = file_exists($dst);
+ $existed = file_exists($dst);
if (!@copy($src, $dst)) return false;
- if (!$exists && !empty($conf['fperm'])) chmod($dst, $conf['fperm']);
+ if (!$existed && $conf['fperm']) chmod($dst, $conf['fperm']);
@touch($dst, filemtime($src));
}
diff --git a/lib/plugins/usermanager/_test/csv_import.test.php b/lib/plugins/usermanager/_test/csv_import.test.php
index 6047a9342..13034a012 100644
--- a/lib/plugins/usermanager/_test/csv_import.test.php
+++ b/lib/plugins/usermanager/_test/csv_import.test.php
@@ -14,13 +14,14 @@ require_once(dirname(__FILE__).'/mocks.class.php');
*
* At present, users imported in individual tests remain in the user list for subsequent tests
*/
-class plugin_usermanager_csv_import_test extends DokuWikiTest {
-
+class plugin_usermanager_csv_import_test extends DokuWikiTest
+{
private $old_files;
protected $usermanager;
protected $importfile;
- function setUp() {
+ public function setUp()
+ {
$this->importfile = tempnam(TMP_DIR, 'csv');
$this->old_files = $_FILES;
@@ -38,16 +39,18 @@ class plugin_usermanager_csv_import_test extends DokuWikiTest {
parent::setUp();
}
- function tearDown() {
+ public function tearDown()
+ {
$_FILES = $this->old_files;
parent::tearDown();
}
- function doImportTest($importCsv, $expectedResult, $expectedNewUsers, $expectedFailures) {
+ public function doImportTest($importCsv, $expectedResult, $expectedNewUsers, $expectedFailures)
+ {
global $auth;
$before_users = $auth->retrieveUsers();
- io_savefile($this->importfile, $importCsv);
+ io_saveFile($this->importfile, $importCsv);
$result = $this->usermanager->tryImport();
$after_users = $auth->retrieveUsers();
@@ -69,7 +72,8 @@ class plugin_usermanager_csv_import_test extends DokuWikiTest {
$this->assertEquals($expectedFailures, $this->usermanager->getImportFailures()); // failures as expected
}
- function test_cantImport(){
+ public function test_cantImport()
+ {
global $auth;
$oldauth = $auth;
@@ -85,7 +89,8 @@ importuser,"Ford Prefect",ford@example.com,user
$auth = $oldauth;
}
- function test_import() {
+ public function test_import()
+ {
$csv = 'User,"Real Name",Email,Groups
importuser,"Ford Prefect",ford@example.com,user
';
@@ -100,7 +105,8 @@ importuser,"Ford Prefect",ford@example.com,user
$this->doImportTest($csv, true, $expected, array());
}
- function test_importExisting() {
+ public function test_importExisting()
+ {
$csv = 'User,"Real Name",Email,Groups
importuser,"Ford Prefect",ford@example.com,user
';
@@ -120,7 +126,8 @@ importuser,"Ford Prefect",ford@example.com,user
$this->doImportTest($csv, true, array(), $failures);
}
- function test_importUtf8() {
+ public function test_importUtf8()
+ {
$csv = 'User,"Real Name",Email,Groups
importutf8,"Førd Prefect",ford@example.com,user
';
@@ -138,7 +145,8 @@ importutf8,"Førd Prefect",ford@example.com,user
/**
* utf8: u+00F8 (ø) <=> 0xF8 :iso-8859-1
*/
- function test_importIso8859() {
+ public function test_importIso8859()
+ {
$csv = 'User,"Real Name",Email,Groups
importiso8859,"F'.chr(0xF8).'rd Prefect",ford@example.com,user
';
@@ -153,14 +161,16 @@ importiso8859,"F'.chr(0xF8).'rd Prefect",ford@example.com,user
$this->doImportTest($csv, true, $expected, array());
}
- private function stripPasswords($array){
+ private function stripPasswords($array)
+ {
foreach ($array as $user => $data) {
unset($array[$user]['pass']);
}
return $array;
}
- private function countPasswords($array){
+ private function countPasswords($array)
+ {
$count = 0;
foreach ($array as $user => $data) {
if (!empty($data['pass'])) {
@@ -169,6 +179,4 @@ importiso8859,"F'.chr(0xF8).'rd Prefect",ford@example.com,user
}
return $count;
}
-
}
-
diff --git a/lib/tpl/dokuwiki/script.js b/lib/tpl/dokuwiki/script.js
index 5a68e8b9c..88dae9023 100644
--- a/lib/tpl/dokuwiki/script.js
+++ b/lib/tpl/dokuwiki/script.js
@@ -71,10 +71,15 @@ jQuery(function(){
);
// increase sidebar length to match content (desktop mode only)
- var $sidebar = jQuery('.desktop #dokuwiki__aside');
- if($sidebar.length) {
+ var sidebar_height = jQuery('.desktop #dokuwiki__aside').height();
+ var pagetool_height = jQuery('.desktop #dokuwiki__pagetools ul:first').height();
+ // pagetools div has no height; ul has a height
+ var content_min = Math.max(sidebar_height || 0, pagetool_height || 0);
+
+ var content_height = jQuery('#dokuwiki__content div.page').height();
+ if(content_min && content_min > content_height) {
var $content = jQuery('#dokuwiki__content div.page');
- $content.css('min-height', $sidebar.height());
+ $content.css('min-height', content_min);
}
// blur when clicked
diff --git a/lib/tpl/index.php b/lib/tpl/index.php
index a3e9a8849..4d48d5127 100644
--- a/lib/tpl/index.php
+++ b/lib/tpl/index.php
@@ -18,7 +18,7 @@ require_once(DOKU_INC.'inc/init.php');
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Template Replacements</title>
- <style type="text/css">
+ <style>
body {
background-color: #fff;
color: #000;