summaryrefslogtreecommitdiff
path: root/lib/exe
diff options
context:
space:
mode:
authorlisps <stummp@loewen.de>2014-02-17 23:15:36 +0100
committerlisps <stummp@loewen.de>2014-02-17 23:15:36 +0100
commitd90a79c0ee1837353622e4b2abb0753ca09dffd2 (patch)
tree554da8dc13606efc2bc1ea7fe3697a5ff87d02e5 /lib/exe
parentf2643d9ff318af1d2fbb6249e929212381959247 (diff)
parenta83975113c7725a13144b3e65bfb58c8447d37d7 (diff)
downloadrpg-d90a79c0ee1837353622e4b2abb0753ca09dffd2.tar.gz
rpg-d90a79c0ee1837353622e4b2abb0753ca09dffd2.tar.bz2
Merge remote-tracking branch 'origin/diff_navigation' into revisions
Conflicts: inc/parser/xhtml.php
Diffstat (limited to 'lib/exe')
-rw-r--r--lib/exe/css.php43
-rw-r--r--lib/exe/fetch.php6
-rw-r--r--lib/exe/js.php2
3 files changed, 45 insertions, 6 deletions
diff --git a/lib/exe/css.php b/lib/exe/css.php
index c2540cc03..cab7384b2 100644
--- a/lib/exe/css.php
+++ b/lib/exe/css.php
@@ -70,6 +70,7 @@ function css_out(){
$files[$mediatype] = array();
// load core styles
$files[$mediatype][DOKU_INC.'lib/styles/'.$mediatype.'.css'] = 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/';
@@ -312,6 +313,11 @@ function css_styleini($tpl) {
);
}
+/**
+ * Amend paths used in replacement relative urls, refer FS#2879
+ *
+ * @author Chris Smith <chris@jalakai.co.uk>
+ */
function css_fixreplacementurls($replacements, $location) {
foreach($replacements as $key => $value) {
$replacements[$key] = preg_replace('#(url\([ \'"]*)(?!/|data:|http://|https://| |\'|")#','\\1'.$location,$value);
@@ -400,16 +406,29 @@ function css_loadfile($file,$location=''){
return $css_file->load($location);
}
+/**
+ * Helper class to abstract loading of css/less files
+ *
+ * @author Chris Smith <chris@jalakai.co.uk>
+ */
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,31 +443,49 @@ 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);
}
- $regex = '#^('.join('|',$basedir).')#';
+ $basedir = array_map('preg_quote_cb', $basedir);
+ $regex = '/^('.join('|',$basedir).')/';
$this->relative_path = preg_replace($regex, '', dirname($this->filepath));
}
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];
}
diff --git a/lib/exe/fetch.php b/lib/exe/fetch.php
index 5967494bf..5f82ad0e0 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);
@@ -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['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
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);