summaryrefslogtreecommitdiff
path: root/lib/exe/css.php
diff options
context:
space:
mode:
authorGerry Weißbach <gerry.w@gammaproduction.de>2014-12-22 10:40:15 +0100
committerGerry Weißbach <gerry.w@gammaproduction.de>2014-12-22 10:40:15 +0100
commitfc30ac3acbd4e17e25955ccdd0c5539ee2c9beca (patch)
tree3d287ae466500a6072b84d14ff4911fa936d1479 /lib/exe/css.php
parentde4634ec87b1a277c1686990d993dafc43db05ed (diff)
parent8da2ebf4f4261eb8f54df5704b5d9af283b5402d (diff)
downloadrpg-fc30ac3acbd4e17e25955ccdd0c5539ee2c9beca.tar.gz
rpg-fc30ac3acbd4e17e25955ccdd0c5539ee2c9beca.tar.bz2
Merge branch 'master' into new_css.php
Diffstat (limited to 'lib/exe/css.php')
-rw-r--r--lib/exe/css.php45
1 files changed, 37 insertions, 8 deletions
diff --git a/lib/exe/css.php b/lib/exe/css.php
index 902996062..9f828feaa 100644
--- a/lib/exe/css.php
+++ b/lib/exe/css.php
@@ -53,7 +53,7 @@ function css_out(){
// if old 'default' userstyle setting exists, make it 'screen' userstyle for backwards compatibility
if (isset($config_cascade['userstyle']['default'])) {
- $config_cascade['userstyle']['screen'] = $config_cascade['userstyle']['default'];
+ $config_cascade['userstyle']['screen'] = array($config_cascade['userstyle']['default']);
}
// cache influencers
@@ -83,8 +83,10 @@ function css_out(){
$files[$mediatype] = array_merge($files[$mediatype], $styleini['stylesheets'][$mediatype]);
}
// load user styles
- if(isset($config_cascade['userstyle'][$mediatype])){
- $files[$mediatype][$config_cascade['userstyle'][$mediatype]] = DOKU_BASE;
+ if(!empty($config_cascade['userstyle'][$mediatype])) {
+ foreach($config_cascade['userstyle'][$mediatype] as $userstyle) {
+ $files[$mediatype][$userstyle] = DOKU_BASE;
+ }
}
$cache_files = array_merge($cache_files, array_keys($files[$mediatype]));
@@ -163,12 +165,15 @@ function css_out(){
* most of this function is error handling to show a nice useful error when
* LESS compilation fails
*
- * @param $css
+ * @param string $css
* @return string
*/
function css_parseless($css) {
+ global $conf;
+
$less = new lessc();
$less->importDir[] = DOKU_INC;
+ $less->setPreserveComments(!$conf['compress']);
if (defined('DOKU_UNITTEST')){
$less->importDir[] = TMP_DIR;
@@ -223,6 +228,10 @@ function css_parseless($css) {
* (sans the surrounding __ and with a ini_ prefix)
*
* @author Andreas Gohr <andi@splitbrain.org>
+ *
+ * @param string $css
+ * @param array $replacements array(placeholder => value)
+ * @return string
*/
function css_applystyle($css, $replacements) {
// we convert ini replacements to LESS variable names
@@ -251,6 +260,7 @@ function css_applystyle($css, $replacements) {
* the stylesheet modes
*
* @author Andreas Gohr <andi@splitbrain.org>
+ *
* @param string $tpl the used template
* @return array with keys 'stylesheets' and 'replacements'
*/
@@ -321,6 +331,10 @@ function css_styleini($tpl) {
* Amend paths used in replacement relative urls, refer FS#2879
*
* @author Chris Smith <chris@jalakai.co.uk>
+ *
+ * @param array $replacements with key-value pairs
+ * @param string $location
+ * @return array
*/
function css_fixreplacementurls($replacements, $location) {
foreach($replacements as $key => $value) {
@@ -404,6 +418,10 @@ function css_filetypes(){
/**
* Loads a given file and fixes relative URLs with the
* given location prefix
+ *
+ * @param string $file file system path
+ * @param string $location
+ * @return string
*/
function css_loadfile($file,$location=''){
$css_file = new DokuCssFile($file);
@@ -419,7 +437,7 @@ class DokuCssFile {
protected $filepath; // file system path to the CSS/Less file
protected $location; // base url location of the CSS/Less file
- private $relative_path = null;
+ protected $relative_path = null;
public function __construct($file) {
$this->filepath = $file;
@@ -452,7 +470,7 @@ class DokuCssFile {
*
* @return string relative file system path
*/
- private function getRelativePath(){
+ protected function getRelativePath(){
if (is_null($this->relative_path)) {
$basedir = array(DOKU_INC);
@@ -502,6 +520,9 @@ class DokuCssFile {
* Convert local image URLs to data URLs if the filesize is small
*
* Callback for preg_replace_callback
+ *
+ * @param array $match
+ * @return string
*/
function css_datauri($match){
global $conf;
@@ -529,9 +550,11 @@ function css_datauri($match){
* Returns a list of possible Plugin Styles (no existance check here)
*
* @author Andreas Gohr <andi@splitbrain.org>
+ *
+ * @param string $mediatype
+ * @return array
*/
function css_pluginstyles($mediatype='screen'){
- global $lang;
$list = array();
$plugins = plugin_list();
foreach ($plugins as $p){
@@ -550,6 +573,9 @@ function css_pluginstyles($mediatype='screen'){
* Very simple CSS optimizer
*
* @author Andreas Gohr <andi@splitbrain.org>
+ *
+ * @param string $css
+ * @return string
*/
function css_compress($css){
//strip comments through a callback
@@ -586,6 +612,9 @@ function css_compress($css){
* Keeps short comments (< 5 chars) to maintain typical browser hacks
*
* @author Andreas Gohr <andi@splitbrain.org>
+ *
+ * @param array $matches
+ * @return string
*/
function css_comment_cb($matches){
if(strlen($matches[2]) > 4) return '';
@@ -597,7 +626,7 @@ function css_comment_cb($matches){
*
* Strips one line comments but makes sure it will not destroy url() constructs with slashes
*
- * @param $matches
+ * @param array $matches
* @return string
*/
function css_onelinecomment_cb($matches) {