summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--_test/tests/lib/exe/css_at_import_less.test.php78
-rw-r--r--_test/tests/lib/exe/css_css_loadfile.test.php42
-rw-r--r--inc/config_cascade.php3
-rw-r--r--inc/farm.php2
-rw-r--r--inc/html.php14
-rw-r--r--inc/pageutils.php3
-rw-r--r--inc/template.php12
-rw-r--r--lib/exe/css.php86
-rw-r--r--lib/images/_deprecated.txt12
-rw-r--r--lib/images/arrow_down.gifbin273 -> 0 bytes
-rw-r--r--lib/images/arrow_up.gifbin274 -> 0 bytes
-rw-r--r--lib/images/at.gifbin57 -> 0 bytes
-rw-r--r--lib/images/close.pngbin137 -> 0 bytes
-rw-r--r--lib/images/del.pngbin355 -> 0 bytes
-rw-r--r--lib/images/edit.gifbin142 -> 0 bytes
-rw-r--r--lib/images/list-minus.gifbin64 -> 0 bytes
-rw-r--r--lib/images/list-plus.gifbin67 -> 0 bytes
-rw-r--r--lib/images/pencil.pngbin391 -> 0 bytes
18 files changed, 184 insertions, 68 deletions
diff --git a/_test/tests/lib/exe/css_at_import_less.test.php b/_test/tests/lib/exe/css_at_import_less.test.php
new file mode 100644
index 000000000..4a6efcf44
--- /dev/null
+++ b/_test/tests/lib/exe/css_at_import_less.test.php
@@ -0,0 +1,78 @@
+<?php
+
+require_once DOKU_INC.'lib/exe/css.php';
+
+class css_at_import_less_test extends DokuWikiTest {
+
+ protected $file = '';
+ protected $import = '';
+
+ public function setUpFiles($subdir = '') {
+
+ $dir = TMP_DIR . $subdir;
+ if (!is_dir($dir)) {
+ mkdir($dir, 0777, true);
+ }
+ if (!is_dir($dir)) {
+ $this->markTestSkipped('Could not create directory.');
+ }
+
+ $this->file = tempnam($dir, 'css');
+
+ $import = '';
+ do {
+ if ($import) unlink($import);
+ $import = tempnam($dir, 'less');
+ $ok = rename($import, $import.'.less');
+ } while (!$ok);
+
+ $this->import = $import.'.less';
+ }
+
+ private function csstest($input, $expected_css, $expected_less) {
+ $location = "http://test.com/";
+ io_saveFile($this->file, $input);
+ $css = css_loadfile($this->file, $location);
+ $less = css_parseless($css);
+ $this->assertEquals($expected_css, $css);
+ $this->assertEquals($expected_less, $less);
+ }
+
+ public function test_basic() {
+ $this->setUpFiles();
+
+ $import = preg_replace('#(^.*[/])#','',$this->import);
+ $in_css = '@import "'.$import.'";';
+ $in_less = '@foo: "bar";
+content: @foo;';
+
+ $expected_css = '@import "/'.$import.'";';
+ $expected_less = 'content: "bar";';
+
+ io_saveFile($this->import, $in_less);
+ $this->csstest($in_css, $expected_css, $expected_less);
+ }
+
+ public function test_subdirectory() {
+ $this->setUpFiles('/foo/bar');
+
+ $import = preg_replace('#(^.*[/])#','',$this->import);
+ $in_css = '@import "'.$import.'";';
+ $in_less = '@foo: "bar";
+content: @foo;';
+
+ $expected_css = '@import "/foo/bar/'.$import.'";';
+ $expected_less = 'content: "bar";';
+
+ io_saveFile($this->import, $in_less);
+ $this->csstest($in_css, $expected_css, $expected_less);
+ }
+
+ public function tearDown() {
+ unlink($this->file);
+ unlink($this->import);
+ unset($this->file, $this->import);
+ }
+}
+
+//Setup VIM: ex: et ts=4 sw=4 :
diff --git a/_test/tests/lib/exe/css_css_loadfile.test.php b/_test/tests/lib/exe/css_css_loadfile.test.php
index c89b69b2c..624becd29 100644
--- a/_test/tests/lib/exe/css_css_loadfile.test.php
+++ b/_test/tests/lib/exe/css_css_loadfile.test.php
@@ -3,13 +3,16 @@
require_once DOKU_INC.'lib/exe/css.php';
class css_css_loadfile_test extends DokuWikiTest {
+
+ protected $file = '';
+
public function setUp() {
- $this->file = tempnam('/tmp', 'css');
+ $this->file = tempnam(TMP_DIR, 'css');
}
private function csstest($input, $output = null, $location = 'http://www.example.com/') {
io_saveFile($this->file, $input);
- $this->assertEquals(css_loadfile($this->file, $location), (is_null($output) ? $input : $output));
+ $this->assertEquals((is_null($output) ? $input : $output), css_loadfile($this->file, $location));
}
public function test_url_relative() {
@@ -32,11 +35,15 @@ class css_css_loadfile_test extends DokuWikiTest {
public function test_import_relative() {
$this->csstest('@import "test/test.png";', '@import "http://www.example.com/test/test.png";');
$this->csstest('@import \'test/test.png\';', '@import \'http://www.example.com/test/test.png\';');
+ $this->csstest('@import url(test/test.png);', '@import url(http://www.example.com/test/test.png);');
+ $this->csstest('@import url("test/test.png");', '@import url("http://www.example.com/test/test.png");');
}
public function test_import_absolute() {
$this->csstest('@import "/test/test.png";');
$this->csstest('@import \'/test/test.png\';');
+ $this->csstest('@import url(/test/test.png);');
+ $this->csstest('@import url("/test/test.png");');
}
public function test_import_with_protocol() {
@@ -44,6 +51,37 @@ class css_css_loadfile_test extends DokuWikiTest {
$this->csstest('@import "https://www.test.com/test/test.png";');
$this->csstest('@import \'http://www.test.com/test/test.png\';');
$this->csstest('@import \'https://www.test.com/test/test.png\';');
+ $this->csstest('@import url(http://www.test.com/test/test.png);');
+ $this->csstest('@import url("http://www.test.com/test/test.png");');
+ }
+
+ public function test_less_basic() {
+ $this->csstest('@import "test.less"', '@import "/test.less"');
+ $this->csstest('@import "/test.less"', '@import "/test.less"');
+ $this->csstest('@import "foo/test.less"', '@import "/foo/test.less"');
+ $this->csstest('@import url(http://test.less)');
+ }
+
+ // more expected use, where less @import(ed) from e.g. lib/plugins/plugin_name
+ public function test_less_subdirectories() {
+
+ unlink($this->file);
+
+ $dir = TMP_DIR.'/foo/bar';
+ if (!is_dir($dir)) {
+ mkdir($dir, 0777, true);
+ }
+ if (!is_dir($dir)) {
+ $this->markTestSkipped('Could not create directory.');
+ }
+
+ $this->file = tempnam($dir, 'css');
+
+ $this->csstest('@import "test.less"', '@import "/foo/bar/test.less"');
+ $this->csstest('@import \'test.less\'', '@import \'/foo/bar/test.less\'');
+ $this->csstest('@import url(test.less)', '@import url(/foo/bar/test.less)');
+
+ $this->csstest('@import "abc/test.less"', '@import "/foo/bar/abc/test.less"');
}
public function tearDown() {
diff --git a/inc/config_cascade.php b/inc/config_cascade.php
index e1ab0eead..2c4f1612b 100644
--- a/inc/config_cascade.php
+++ b/inc/config_cascade.php
@@ -50,9 +50,6 @@ $config_cascade = array_merge(
),
'userstyle' => array(
'screen' => DOKU_CONF.'userstyle.css',
- // @deprecated 2012-04-09: rtl will cease to be a mode of its own,
- // please use "[dir=rtl]" in any css file in all, screen or print mode instead
- 'rtl' => DOKU_CONF.'userrtl.css',
'print' => DOKU_CONF.'userprint.css',
'feed' => DOKU_CONF.'userfeed.css',
'all' => DOKU_CONF.'userall.css',
diff --git a/inc/farm.php b/inc/farm.php
index 54692928d..cee61816c 100644
--- a/inc/farm.php
+++ b/inc/farm.php
@@ -135,9 +135,7 @@ $config_cascade = array(
),
),
'userstyle' => array(
- 'default' => DOKU_CONF.'userstyle.css', // 'default' was renamed to 'screen' on 2011-02-26, so will be deprecated in the next version
'screen' => DOKU_CONF.'userstyle.css',
- 'rtl' => DOKU_CONF.'userrtl.css', // deprecated since version after 2012-04-09
'print' => DOKU_CONF.'userprint.css',
'feed' => DOKU_CONF.'userfeed.css',
'all' => DOKU_CONF.'userall.css',
diff --git a/inc/html.php b/inc/html.php
index bbe29e371..7f473cdb6 100644
--- a/inc/html.php
+++ b/inc/html.php
@@ -28,20 +28,6 @@ function html_wikilink($id,$name=null,$search=''){
}
/**
- * Helps building long attribute lists
- *
- * @deprecated Use buildAttributes instead
- * @author Andreas Gohr <andi@splitbrain.org>
- */
-function html_attbuild($attributes){
- $ret = '';
- foreach ( $attributes as $key => $value ) {
- $ret .= $key.'="'.formText($value).'" ';
- }
- return trim($ret);
-}
-
-/**
* The loginform
*
* @author Andreas Gohr <andi@splitbrain.org>
diff --git a/inc/pageutils.php b/inc/pageutils.php
index 60f326e04..c8d3cf4bb 100644
--- a/inc/pageutils.php
+++ b/inc/pageutils.php
@@ -94,9 +94,8 @@ function getID($param='id',$clean=true){
* @author Andreas Gohr <andi@splitbrain.org>
* @param string $raw_id The pageid to clean
* @param boolean $ascii Force ASCII
- * @param boolean $media DEPRECATED
*/
-function cleanID($raw_id,$ascii=false,$media=false){
+function cleanID($raw_id,$ascii=false){
global $conf;
static $sepcharpat = null;
diff --git a/inc/template.php b/inc/template.php
index 41f398016..60e178d1a 100644
--- a/inc/template.php
+++ b/inc/template.php
@@ -1694,18 +1694,6 @@ function tpl_includeFile($file) {
}
/**
- * Returns icon from data/media root directory if it exists, otherwise
- * the one in the template's image directory.
- *
- * @deprecated Use tpl_getMediaFile() instead
- * @author Anika Henke <anika@selfthinker.org>
- */
-function tpl_getFavicon($abs = false, $fileName = 'favicon.ico') {
- $look = array(":wiki:$fileName", ":$fileName", "images/$fileName");
- return tpl_getMediaFile($look, $abs);
-}
-
-/**
* Returns <link> tag for various icon types (favicon|mobile|generic)
*
* @author Anika Henke <anika@selfthinker.org>
diff --git a/lib/exe/css.php b/lib/exe/css.php
index af7f9e4f1..c2540cc03 100644
--- a/lib/exe/css.php
+++ b/lib/exe/css.php
@@ -84,16 +84,6 @@ function css_out(){
if(isset($config_cascade['userstyle'][$mediatype])){
$files[$mediatype][$config_cascade['userstyle'][$mediatype]] = DOKU_BASE;
}
- // load rtl styles
- // note: this adds the rtl styles only to the 'screen' media type
- // @deprecated 2012-04-09: rtl will cease to be a mode of its own,
- // please use "[dir=rtl]" in any css file in all, screen or print mode instead
- if ($mediatype=='screen') {
- if($lang['direction'] == 'rtl'){
- if (isset($styleini['stylesheets']['rtl'])) $files[$mediatype] = array_merge($files[$mediatype], $styleini['stylesheets']['rtl']);
- if (isset($config_cascade['userstyle']['rtl'])) $files[$mediatype][$config_cascade['userstyle']['rtl']] = DOKU_BASE;
- }
- }
$cache_files = array_merge($cache_files, array_keys($files[$mediatype]));
}
@@ -173,6 +163,12 @@ function css_out(){
*/
function css_parseless($css) {
$less = new lessc();
+ $less->importDir[] = DOKU_INC;
+
+ if (defined('DOKU_UNITTEST')){
+ $less->importDir[] = TMP_DIR;
+ }
+
try {
return $less->compile($css);
} catch(Exception $e) {
@@ -400,18 +396,69 @@ function css_filetypes(){
* given location prefix
*/
function css_loadfile($file,$location=''){
- if(!@file_exists($file)) return '';
- $css = io_readFile($file);
- if(!$location) return $css;
+ $css_file = new DokuCssFile($file);
+ return $css_file->load($location);
+}
- $css = preg_replace('#(url\([ \'"]*)(?!/|data:|http://|https://| |\'|")#','\\1'.$location,$css);
- $css = preg_replace('#(@import\s+[\'"])(?!/|data:|http://|https://)#', '\\1'.$location, $css);
+class DokuCssFile {
- return $css;
+ protected $filepath;
+ protected $location;
+ private $relative_path = null;
+
+ public function __construct($file) {
+ $this->filepath = $file;
+ }
+
+ public function load($location='') {
+ if (!@file_exists($this->filepath)) return '';
+
+ $css = io_readFile($this->filepath);
+ if (!$location) return $css;
+
+ $this->location = $location;
+
+ $css = preg_replace_callback('#(url\( *)([\'"]?)(.*?)(\2)( *\))#',array($this,'replacements'),$css);
+ $css = preg_replace_callback('#(@import\s+)([\'"])(.*?)(\2)#',array($this,'replacements'),$css);
+
+ return $css;
+ }
+
+ private function getRelativePath(){
+
+ if (is_null($this->relative_path)) {
+ $basedir = array(DOKU_INC);
+ if (defined('DOKU_UNITTEST')) {
+ $basedir[] = realpath(TMP_DIR);
+ }
+ $regex = '#^('.join('|',$basedir).')#';
+
+ $this->relative_path = preg_replace($regex, '', dirname($this->filepath));
+ }
+
+ return $this->relative_path;
+ }
+
+ public function replacements($match) {
+
+ if (preg_match('#^(/|data:|https?://)#',$match[3])) {
+ return $match[0];
+ }
+ else if (substr($match[3],-5) == '.less') {
+ if ($match[3]{0} != '/') {
+ $match[3] = $this->getRelativePath() . '/' . $match[3];
+ }
+ }
+ else {
+ $match[3] = $this->location . $match[3];
+ }
+
+ return join('',array_slice($match,1));
+ }
}
/**
- * Converte local image URLs to data URLs if the filesize is small
+ * Convert local image URLs to data URLs if the filesize is small
*
* Callback for preg_replace_callback
*/
@@ -454,11 +501,6 @@ function css_pluginstyles($mediatype='screen'){
$list[DOKU_PLUGIN."$p/style.css"] = DOKU_BASE."lib/plugins/$p/";
$list[DOKU_PLUGIN."$p/style.less"] = DOKU_BASE."lib/plugins/$p/";
}
- // @deprecated 2012-04-09: rtl will cease to be a mode of its own,
- // please use "[dir=rtl]" in any css file in all, screen or print mode instead
- if($lang['direction'] == 'rtl'){
- $list[DOKU_PLUGIN."$p/rtl.css"] = DOKU_BASE."lib/plugins/$p/";
- }
}
return $list;
}
diff --git a/lib/images/_deprecated.txt b/lib/images/_deprecated.txt
index bccea2049..a347f8b3c 100644
--- a/lib/images/_deprecated.txt
+++ b/lib/images/_deprecated.txt
@@ -1,12 +1,2 @@
-== @deprecated 2012-10-06 ==
-
-arrow_down.gif
-arrow_up.gif
-at.gif
-close.png
-del.png
-edit.gif
-list-minus.gif
-list-plus.gif
-pencil.png
+(none)
diff --git a/lib/images/arrow_down.gif b/lib/images/arrow_down.gif
deleted file mode 100644
index ff13b9585..000000000
--- a/lib/images/arrow_down.gif
+++ /dev/null
Binary files differ
diff --git a/lib/images/arrow_up.gif b/lib/images/arrow_up.gif
deleted file mode 100644
index d491c18db..000000000
--- a/lib/images/arrow_up.gif
+++ /dev/null
Binary files differ
diff --git a/lib/images/at.gif b/lib/images/at.gif
deleted file mode 100644
index 8bdf40d54..000000000
--- a/lib/images/at.gif
+++ /dev/null
Binary files differ
diff --git a/lib/images/close.png b/lib/images/close.png
deleted file mode 100644
index 4ccef0603..000000000
--- a/lib/images/close.png
+++ /dev/null
Binary files differ
diff --git a/lib/images/del.png b/lib/images/del.png
deleted file mode 100644
index e59ded55f..000000000
--- a/lib/images/del.png
+++ /dev/null
Binary files differ
diff --git a/lib/images/edit.gif b/lib/images/edit.gif
deleted file mode 100644
index a2a23de7b..000000000
--- a/lib/images/edit.gif
+++ /dev/null
Binary files differ
diff --git a/lib/images/list-minus.gif b/lib/images/list-minus.gif
deleted file mode 100644
index 36902f159..000000000
--- a/lib/images/list-minus.gif
+++ /dev/null
Binary files differ
diff --git a/lib/images/list-plus.gif b/lib/images/list-plus.gif
deleted file mode 100644
index adc3fac8a..000000000
--- a/lib/images/list-plus.gif
+++ /dev/null
Binary files differ
diff --git a/lib/images/pencil.png b/lib/images/pencil.png
deleted file mode 100644
index 78142b61e..000000000
--- a/lib/images/pencil.png
+++ /dev/null
Binary files differ