diff options
author | Gerry Weißbach <gerry.w@gammaproduction.de> | 2014-12-22 10:31:30 +0100 |
---|---|---|
committer | Gerry Weißbach <gerry.w@gammaproduction.de> | 2014-12-22 10:31:30 +0100 |
commit | 8da2ebf4f4261eb8f54df5704b5d9af283b5402d (patch) | |
tree | 9c63975e3898c949e1784e30e81a5ed3da7fca93 /lib/exe | |
parent | 5e7f4d50cbbc788c9c0483a0a2ff1b536e4ffe8c (diff) | |
parent | 1bf4abb07f65e28578bae98aad457cb768d8b44f (diff) | |
download | rpg-8da2ebf4f4261eb8f54df5704b5d9af283b5402d.tar.gz rpg-8da2ebf4f4261eb8f54df5704b5d9af283b5402d.tar.bz2 |
Merge remote-tracking branch 'splitbrain/master'
Diffstat (limited to 'lib/exe')
-rw-r--r-- | lib/exe/css.php | 45 | ||||
-rw-r--r-- | lib/exe/detail.php | 3 | ||||
-rw-r--r-- | lib/exe/indexer.php | 7 | ||||
-rw-r--r-- | lib/exe/js.php | 58 | ||||
-rw-r--r-- | lib/exe/xmlrpc.php | 13 |
5 files changed, 100 insertions, 26 deletions
diff --git a/lib/exe/css.php b/lib/exe/css.php index 6c1d60751..b1065f518 100644 --- a/lib/exe/css.php +++ b/lib/exe/css.php @@ -52,7 +52,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 @@ -82,8 +82,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])); @@ -162,12 +164,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; @@ -222,6 +227,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 @@ -250,6 +259,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' */ @@ -320,6 +330,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) { @@ -403,6 +417,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); @@ -418,7 +436,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; @@ -451,7 +469,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); @@ -501,6 +519,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; @@ -528,9 +549,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){ @@ -549,6 +572,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 @@ -585,6 +611,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 ''; @@ -596,7 +625,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) { diff --git a/lib/exe/detail.php b/lib/exe/detail.php index cd3f362ad..cc29d5b87 100644 --- a/lib/exe/detail.php +++ b/lib/exe/detail.php @@ -5,6 +5,7 @@ require_once(DOKU_INC.'inc/init.php'); $IMG = getID('media'); $ID = cleanID($INPUT->str('id')); +$REV = $INPUT->int('rev'); // this makes some general info available as well as the info about the // "parent" page @@ -35,7 +36,7 @@ $ERROR = false; $AUTH = auth_quickaclcheck($IMG); if($AUTH >= AUTH_READ){ // check if image exists - $SRC = mediaFN($IMG); + $SRC = mediaFN($IMG,$REV); if(!@file_exists($SRC)){ //doesn't exist! http_status(404); diff --git a/lib/exe/indexer.php b/lib/exe/indexer.php index 3ab117736..89c4b7cd0 100644 --- a/lib/exe/indexer.php +++ b/lib/exe/indexer.php @@ -51,8 +51,9 @@ exit; /** * Trims the recent changes cache (or imports the old changelog) as needed. * - * @param media_changes If the media changelog shall be trimmed instead of - * the page changelog + * @param bool $media_changes If the media changelog shall be trimmed instead of + * the page changelog + * @return bool * * @author Ben Coburn <btcoburn@silicodon.net> */ @@ -83,7 +84,7 @@ function runTrimRecentChanges($media_changes = false) { io_saveFile($fn.'_tmp', ''); // presave tmp as 2nd lock $trim_time = time() - $conf['recent_days']*86400; $out_lines = array(); - + $old_lines = array(); for ($i=0; $i<count($lines); $i++) { $log = parseChangelogLine($lines[$i]); if ($log === false) continue; // discard junk diff --git a/lib/exe/js.php b/lib/exe/js.php index bec12ef7a..793104e81 100644 --- a/lib/exe/js.php +++ b/lib/exe/js.php @@ -72,8 +72,10 @@ function js_out(){ // add possible plugin scripts and userscript $files = array_merge($files,js_pluginscripts()); - if(isset($config_cascade['userscript']['default'])){ - $files[] = $config_cascade['userscript']['default']; + if(!empty($config_cascade['userscript']['default'])) { + foreach($config_cascade['userscript']['default'] as $userscript) { + $files[] = $userscript; + } } $cache_files = array_merge($files, getConfigFiles('main')); @@ -154,6 +156,8 @@ function js_out(){ * Load the given file, handle include calls and print it * * @author Andreas Gohr <andi@splitbrain.org> + * + * @param string $file filename path to file */ function js_load($file){ if(!@file_exists($file)) return; @@ -189,6 +193,8 @@ function js_load($file){ * Returns a list of possible Plugin Scripts (no existance check here) * * @author Andreas Gohr <andi@splitbrain.org> + * + * @return array */ function js_pluginscripts(){ $list = array(); @@ -206,6 +212,8 @@ function js_pluginscripts(){ * - Nothing is returned for plugins without an entry for $lang['js'] * * @author Gabriel Birke <birke@d-scribe.de> + * + * @return array */ function js_pluginstrings() { global $conf; @@ -231,6 +239,8 @@ function js_pluginstrings() { * * - $lang['js'] must be an array. * - Nothing is returned for template without an entry for $lang['js'] + * + * @return array */ function js_templatestrings() { global $conf; @@ -252,6 +262,9 @@ function js_templatestrings() { * as newline * * @author Andreas Gohr <andi@splitbrain.org> + * + * @param string $string + * @return string */ function js_escape($string){ return str_replace('\\\\n','\\n',addslashes($string)); @@ -261,6 +274,8 @@ function js_escape($string){ * Adds the given JavaScript code to the window.onload() event * * @author Andreas Gohr <andi@splitbrain.org> + * + * @param string $func */ function js_runonstart($func){ echo "jQuery(function(){ $func; });".NL; @@ -275,6 +290,9 @@ function js_runonstart($func){ * @author Nick Galbreath <nickg@modp.com> * @author Andreas Gohr <andi@splitbrain.org> * @link http://code.google.com/p/jsstrip/ + * + * @param string $s + * @return string */ function js_compress($s){ $s = ltrim($s); // strip all initial whitespace @@ -289,7 +307,11 @@ function js_compress($s){ // items that don't need spaces next to them $chars = "^&|!+\-*\/%=\?:;,{}()<>% \t\n\r'\"[]"; - $regex_starters = array("(", "=", "[", "," , ":", "!"); + // items which need a space if the sign before and after whitespace is equal. + // E.g. '+ ++' may not be compressed to '+++' --> syntax error. + $ops = "+-"; + + $regex_starters = array("(", "=", "[", "," , ":", "!", "&", "|"); $whitespaces_chars = array(" ", "\t", "\n", "\r", "\0", "\x0B"); @@ -389,19 +411,27 @@ function js_compress($s){ // whitespaces if( $ch == ' ' || $ch == "\r" || $ch == "\n" || $ch == "\t" ){ - // leading spaces - if($i+1 < $slen && (strpos($chars,$s[$i+1]) !== false)){ - $i = $i + 1; - continue; - } - // trailing spaces - // if this ch is space AND the last char processed - // is special, then skip the space $lch = substr($result,-1); - if($lch && (strpos($chars,$lch) !== false)){ - $i = $i + 1; - continue; + + // Only consider deleting whitespace if the signs before and after + // are not equal and are not an operator which may not follow itself. + if ((!$lch || $s[$i+1] == ' ') + || $lch != $s[$i+1] + || strpos($ops,$s[$i+1]) === false) { + // leading spaces + if($i+1 < $slen && (strpos($chars,$s[$i+1]) !== false)){ + $i = $i + 1; + continue; + } + // trailing spaces + // if this ch is space AND the last char processed + // is special, then skip the space + if($lch && (strpos($chars,$lch) !== false)){ + $i = $i + 1; + continue; + } } + // else after all of this convert the "whitespace" to // a single space. It will get appended below $ch = ' '; diff --git a/lib/exe/xmlrpc.php b/lib/exe/xmlrpc.php index c09daa17c..61a68281f 100644 --- a/lib/exe/xmlrpc.php +++ b/lib/exe/xmlrpc.php @@ -23,6 +23,11 @@ class dokuwiki_xmlrpc_server extends IXR_Server { $this->IXR_Server(); } + /** + * @param string $methodname + * @param array $args + * @return IXR_Error|mixed + */ function call($methodname, $args){ try { $result = $this->remote->call($methodname, $args); @@ -40,10 +45,18 @@ class dokuwiki_xmlrpc_server extends IXR_Server { } } + /** + * @param string|int $data iso date(yyyy[-]mm[-]dd[ hh:mm[:ss]]) or timestamp + * @return IXR_Date + */ function toDate($data) { return new IXR_Date($data); } + /** + * @param string $data + * @return IXR_Base64 + */ function toFile($data) { return new IXR_Base64($data); } |