From 1e2c59485b8396275abde11d047a4a42a4e4e335 Mon Sep 17 00:00:00 2001 From: Christopher Smith Date: Tue, 26 Nov 2013 19:39:05 +0000 Subject: improved comments for code associated with PR#407 & PR#408 --- lib/exe/css.php | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) (limited to 'lib/exe') diff --git a/lib/exe/css.php b/lib/exe/css.php index c2540cc03..c96dedd37 100644 --- a/lib/exe/css.php +++ b/lib/exe/css.php @@ -312,6 +312,11 @@ function css_styleini($tpl) { ); } +/** + * Amend paths used in replacement relative urls, refer FS#2879 + * + * @author Chris Smith + */ function css_fixreplacementurls($replacements, $location) { foreach($replacements as $key => $value) { $replacements[$key] = preg_replace('#(url\([ \'"]*)(?!/|data:|http://|https://| |\'|")#','\\1'.$location,$value); @@ -400,16 +405,29 @@ function css_loadfile($file,$location=''){ return $css_file->load($location); } +/** + * Helper class to abstract loading of css/less files + * + * @author Chris Smith + */ class DokuCssFile { - protected $filepath; - protected $location; + protected $filepath; // file system path to the CSS/Less file + protected $location; // base url location of the CSS/Less file private $relative_path = null; public function __construct($file) { $this->filepath = $file; } + /** + * Load the contents of the css/less file and adjust any relative paths/urls (relative to this file) to be + * relative to the dokuwiki root: the web root (DOKU_BASE) for most files; the file system root (DOKU_INC) + * for less files. + * + * @param string $location base url for this file + * @return string the CSS/Less contents of the file + */ public function load($location='') { if (!@file_exists($this->filepath)) return ''; @@ -424,10 +442,17 @@ class DokuCssFile { return $css; } + /** + * Get the relative file system path of this file, relative to dokuwiki's root folder, DOKU_INC + * + * @return string relative file system path + */ private function getRelativePath(){ if (is_null($this->relative_path)) { $basedir = array(DOKU_INC); + + // during testing, files may be found relative to a second base dir, TMP_DIR if (defined('DOKU_UNITTEST')) { $basedir[] = realpath(TMP_DIR); } @@ -439,16 +464,26 @@ class DokuCssFile { return $this->relative_path; } + /** + * preg_replace callback to adjust relative urls from relative to this file to relative + * to the appropriate dokuwiki root location as described in the code + * + * @param array see http://php.net/preg_replace_callback + * @return string see http://php.net/preg_replace_callback + */ public function replacements($match) { + // not a relative url? - no adjustment required if (preg_match('#^(/|data:|https?://)#',$match[3])) { return $match[0]; } + // a less file import? - requires a file system location else if (substr($match[3],-5) == '.less') { if ($match[3]{0} != '/') { $match[3] = $this->getRelativePath() . '/' . $match[3]; } } + // everything else requires a url adjustment else { $match[3] = $this->location . $match[3]; } -- cgit v1.2.3 From 77450f4001bc641f7a724ae5e5c2f71b44c022d1 Mon Sep 17 00:00:00 2001 From: lisps Date: Wed, 27 Nov 2013 09:38:06 +0100 Subject: media image can be resized by height (without width) --- lib/exe/fetch.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/exe') diff --git a/lib/exe/fetch.php b/lib/exe/fetch.php index 5967494bf..f33b3f2f8 100644 --- a/lib/exe/fetch.php +++ b/lib/exe/fetch.php @@ -78,8 +78,8 @@ if (defined('SIMPLE_TEST')) { unset($evt); //handle image resizing/cropping - if((substr($MIME, 0, 5) == 'image') && $WIDTH) { - if($HEIGHT) { + if((substr($MIME, 0, 5) == 'image') && ($WIDTH || $HEIGHT)) { + if($HEIGHT && $WDITH) { $data['file'] = $FILE = media_crop_image($data['file'], $EXT, $WIDTH, $HEIGHT); } else { $data['file'] = $FILE = media_resize_image($data['file'], $EXT, $WIDTH, $HEIGHT); -- cgit v1.2.3 From 138bfd16df9cb583107097f32be288b8705cd035 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Fri, 17 Jan 2014 15:36:34 +0100 Subject: localize jQuery UI date picker FS#2912 --- lib/exe/js.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lib/exe') diff --git a/lib/exe/js.php b/lib/exe/js.php index 040b8874d..04413b409 100644 --- a/lib/exe/js.php +++ b/lib/exe/js.php @@ -44,6 +44,7 @@ function js_out(){ DOKU_INC.'lib/scripts/jquery/jquery.cookie.js', DOKU_INC."lib/scripts/jquery/jquery-ui$min.js", DOKU_INC."lib/scripts/jquery/jquery-migrate$min.js", + DOKU_INC.'inc/lang/'.$conf['lang'].'/jquery.ui.datepicker.js', DOKU_INC."lib/scripts/fileuploader.js", DOKU_INC."lib/scripts/fileuploaderextended.js", DOKU_INC.'lib/scripts/helpers.js', @@ -112,6 +113,7 @@ function js_out(){ // load files foreach($files as $file){ + if(!file_exists($file)) continue; $ismin = (substr($file,-7) == '.min.js'); $debugjs = ($conf['allowdebug'] && strpos($file, DOKU_INC.'lib/scripts/') !== 0); -- cgit v1.2.3 From d2affc245d260133a8e9734ad309e5ceba8f42b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gerry=20Wei=C3=9Fbach?= Date: Mon, 27 Jan 2014 10:08:48 +0100 Subject: Use original filename for Content-Disposition In most cases this change will have no effect, but noes the response will use the filename that was originally requested. The downloaded filename can be modified to something different as well. E.g. the siteexport plugin will make use of it. --- lib/exe/fetch.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/exe') diff --git a/lib/exe/fetch.php b/lib/exe/fetch.php index f33b3f2f8..16426938f 100644 --- a/lib/exe/fetch.php +++ b/lib/exe/fetch.php @@ -89,7 +89,7 @@ if (defined('SIMPLE_TEST')) { // finally send the file to the client $evt = new Doku_Event('MEDIA_SENDFILE', $data); if($evt->advise_before()) { - sendFile($data['file'], $data['mime'], $data['download'], $data['cache'], $data['ispublic']); + sendFile($data['file'], $data['orig'], $data['mime'], $data['download'], $data['cache'], $data['ispublic']); } // Do something after the download finished. $evt->advise_after(); // will not be emitted on 304 or x-sendfile -- cgit v1.2.3 From a0e46368e9ad87d959bd921504ced42bc3d5b4bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gerry=20Wei=C3=9Fbach?= Date: Mon, 27 Jan 2014 10:21:08 +0100 Subject: Re-order parameters to not break other callers --- lib/exe/fetch.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/exe') diff --git a/lib/exe/fetch.php b/lib/exe/fetch.php index 16426938f..5f82ad0e0 100644 --- a/lib/exe/fetch.php +++ b/lib/exe/fetch.php @@ -89,7 +89,7 @@ if (defined('SIMPLE_TEST')) { // finally send the file to the client $evt = new Doku_Event('MEDIA_SENDFILE', $data); if($evt->advise_before()) { - sendFile($data['file'], $data['orig'], $data['mime'], $data['download'], $data['cache'], $data['ispublic']); + sendFile($data['file'], $data['mime'], $data['download'], $data['cache'], $data['ispublic'], $data['orig']); } // Do something after the download finished. $evt->advise_after(); // will not be emitted on 304 or x-sendfile -- cgit v1.2.3 From 73f25ac04a7caaa8cdb07bfc71e807f46f227f97 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sun, 2 Feb 2014 17:52:32 +0100 Subject: fix error on CSS includes on windows The regex wasn't properly escaped here which lead to problems when the path contains backslashes. This is the root cause of the bug reported at https://github.com/cosmocode/edittable/issues/19 --- lib/exe/css.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib/exe') diff --git a/lib/exe/css.php b/lib/exe/css.php index c96dedd37..f273b7ee4 100644 --- a/lib/exe/css.php +++ b/lib/exe/css.php @@ -456,8 +456,9 @@ class DokuCssFile { if (defined('DOKU_UNITTEST')) { $basedir[] = realpath(TMP_DIR); } - $regex = '#^('.join('|',$basedir).')#'; + $basedir = array_map('preg_quote_cb', $basedir); + $regex = '/^('.join('|',$basedir).')/'; $this->relative_path = preg_replace($regex, '', dirname($this->filepath)); } -- cgit v1.2.3 From 343aa1749f17e62fa68e26193011a5051025881a Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Fri, 14 Feb 2014 13:12:58 +0100 Subject: fix global $AUTH hiding $auth --- lib/exe/detail.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/exe') diff --git a/lib/exe/detail.php b/lib/exe/detail.php index cd3f362ad..9981c1d02 100644 --- a/lib/exe/detail.php +++ b/lib/exe/detail.php @@ -32,8 +32,8 @@ if($conf['allowdebug'] && $INPUT->has('debug')){ $ERROR = false; // check image permissions -$AUTH = auth_quickaclcheck($IMG); -if($AUTH >= AUTH_READ){ +$AUTHLEVEL = auth_quickaclcheck($IMG); +if($AUTHLEVEL >= AUTH_READ){ // check if image exists $SRC = mediaFN($IMG); if(!@file_exists($SRC)){ -- cgit v1.2.3 From 4f1a1db1539e819e5c40ec14453c4c709810e1bd Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Fri, 14 Feb 2014 13:44:40 +0100 Subject: Revert "fix global $AUTH hiding $auth" Yes, it's hiding $auth, but detail templates might depend on that. We need to fix this properly. This reverts commit 343aa1749f17e62fa68e26193011a5051025881a. --- lib/exe/detail.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/exe') diff --git a/lib/exe/detail.php b/lib/exe/detail.php index 9981c1d02..cd3f362ad 100644 --- a/lib/exe/detail.php +++ b/lib/exe/detail.php @@ -32,8 +32,8 @@ if($conf['allowdebug'] && $INPUT->has('debug')){ $ERROR = false; // check image permissions -$AUTHLEVEL = auth_quickaclcheck($IMG); -if($AUTHLEVEL >= AUTH_READ){ +$AUTH = auth_quickaclcheck($IMG); +if($AUTH >= AUTH_READ){ // check if image exists $SRC = mediaFN($IMG); if(!@file_exists($SRC)){ -- cgit v1.2.3 From af4684ac7612e83f2381ef2fc4146358a5a04114 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sat, 15 Feb 2014 11:12:55 +0100 Subject: move geshi highlighting to it's own LESS file --- lib/exe/css.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'lib/exe') diff --git a/lib/exe/css.php b/lib/exe/css.php index f273b7ee4..537885c89 100644 --- a/lib/exe/css.php +++ b/lib/exe/css.php @@ -70,6 +70,10 @@ function css_out(){ $files[$mediatype] = array(); // load core styles $files[$mediatype][DOKU_INC.'lib/styles/'.$mediatype.'.css'] = DOKU_BASE.'lib/styles/'; + if($mediatype == 'screen') { + $files[$mediatype][DOKU_INC.'lib/styles/geshi.less'] = DOKU_BASE.'lib/styles/'; + } + // load jQuery-UI theme if ($mediatype == 'screen') { $files[$mediatype][DOKU_INC.'lib/scripts/jquery/jquery-ui-theme/smoothness.css'] = DOKU_BASE.'lib/scripts/jquery/jquery-ui-theme/'; -- cgit v1.2.3 From 3593102dfd174c90f99e841f66b60269bfb03be9 Mon Sep 17 00:00:00 2001 From: Anika Henke Date: Sat, 15 Feb 2014 11:37:01 +0000 Subject: included geshi styles per @import, removed from lib/exe/css --- lib/exe/css.php | 3 --- 1 file changed, 3 deletions(-) (limited to 'lib/exe') diff --git a/lib/exe/css.php b/lib/exe/css.php index 537885c89..cab7384b2 100644 --- a/lib/exe/css.php +++ b/lib/exe/css.php @@ -70,9 +70,6 @@ function css_out(){ $files[$mediatype] = array(); // load core styles $files[$mediatype][DOKU_INC.'lib/styles/'.$mediatype.'.css'] = DOKU_BASE.'lib/styles/'; - if($mediatype == 'screen') { - $files[$mediatype][DOKU_INC.'lib/styles/geshi.less'] = DOKU_BASE.'lib/styles/'; - } // load jQuery-UI theme if ($mediatype == 'screen') { -- cgit v1.2.3