diff options
author | Anika Henke <anika@selfthinker.org> | 2013-11-02 13:10:14 +0000 |
---|---|---|
committer | Anika Henke <anika@selfthinker.org> | 2013-11-02 13:10:14 +0000 |
commit | c5393ecb1aa570830d21e9dc95b4c21cd9aa9c01 (patch) | |
tree | 96e8dc34468a325596a5f94c85e38374fbc4b9ba /lib/exe | |
parent | 71c1143e8785954ea00a62aeb755ca7d8fa47e56 (diff) | |
parent | 38d74b12176722ce52dc1905c13816a78a2551ee (diff) | |
download | rpg-c5393ecb1aa570830d21e9dc95b4c21cd9aa9c01.tar.gz rpg-c5393ecb1aa570830d21e9dc95b4c21cd9aa9c01.tar.bz2 |
Merge remote-tracking branch 'origin/master' into video-audio
Conflicts:
inc/parser/xhtml.php
Diffstat (limited to 'lib/exe')
-rw-r--r-- | lib/exe/ajax.php | 3 | ||||
-rw-r--r-- | lib/exe/css.php | 39 | ||||
-rw-r--r-- | lib/exe/detail.php | 8 | ||||
-rw-r--r-- | lib/exe/indexer.php | 26 | ||||
-rw-r--r-- | lib/exe/js.php | 10 | ||||
-rw-r--r-- | lib/exe/mediamanager.php | 3 |
6 files changed, 41 insertions, 48 deletions
diff --git a/lib/exe/ajax.php b/lib/exe/ajax.php index 9769503a7..6e2011cd9 100644 --- a/lib/exe/ajax.php +++ b/lib/exe/ajax.php @@ -219,10 +219,11 @@ function ajax_medialist(){ global $INPUT; $NS = cleanID($INPUT->post->str('ns')); + $sort = $INPUT->post->bool('recent') ? 'date' : 'natural'; if ($INPUT->post->str('do') == 'media') { tpl_mediaFileList(); } else { - tpl_mediaContent(true); + tpl_mediaContent(true, $sort); } } diff --git a/lib/exe/css.php b/lib/exe/css.php index 9e1e22e1a..6dfdf06e8 100644 --- a/lib/exe/css.php +++ b/lib/exe/css.php @@ -148,9 +148,6 @@ function css_out(){ // parse less $css = css_parseless($css); - // place all remaining @import statements at the top of the file - $css = css_moveimports($css); - // compress whitespace and comments if($conf['compress']){ $css = css_compress($css); @@ -460,29 +457,6 @@ function css_pluginstyles($mediatype='screen'){ } /** - * Move all @import statements in a combined stylesheet to the top so they - * aren't ignored by the browser. - * - * @author Gabriel Birke <birke@d-scribe.de> - */ -function css_moveimports($css) -{ - if(!preg_match_all('/@import\s+(?:url\([^)]+\)|"[^"]+")\s*[^;]*;\s*/', $css, $matches, PREG_OFFSET_CAPTURE)) { - return $css; - } - $newCss = ""; - $imports = ""; - $offset = 0; - foreach($matches[0] as $match) { - $newCss .= substr($css, $offset, $match[1] - $offset); - $imports .= $match[0]; - $offset = $match[1] + strlen($match[0]); - } - $newCss .= substr($css, $offset); - return $imports.$newCss; -} - -/** * Very simple CSS optimizer * * @author Andreas Gohr <andi@splitbrain.org> @@ -499,8 +473,19 @@ function css_compress($css){ $css = preg_replace('/ ?([;,{}\/]) ?/','\\1',$css); $css = preg_replace('/ ?: /',':',$css); + // number compression + $css = preg_replace('/([: ])0+(\.\d+?)0*((?:pt|pc|in|mm|cm|em|ex|px)\b|%)(?=[^\{]*[;\}])/', '$1$2$3', $css); // "0.1em" to ".1em", "1.10em" to "1.1em" + $css = preg_replace('/([: ])\.(0)+((?:pt|pc|in|mm|cm|em|ex|px)\b|%)(?=[^\{]*[;\}])/', '$1$2', $css); // ".0em" to "0" + $css = preg_replace('/([: ]0)0*(\.0*)?((?:pt|pc|in|mm|cm|em|ex|px)(?=[^\{]*[;\}])\b|%)/', '$1', $css); // "0.0em" to "0" + $css = preg_replace('/([: ]\d+)(\.0*)((?:pt|pc|in|mm|cm|em|ex|px)(?=[^\{]*[;\}])\b|%)/', '$1$3', $css); // "1.0em" to "1em" + $css = preg_replace('/([: ])0+(\d+|\d*\.\d+)((?:pt|pc|in|mm|cm|em|ex|px)(?=[^\{]*[;\}])\b|%)/', '$1$2$3', $css); // "001em" to "1em" + + // shorten attributes (1em 1em 1em 1em -> 1em) + $css = preg_replace('/(?<![\w\-])((?:margin|padding|border|border-(?:width|radius)):)([\w\.]+)( \2)+(?=[;\}]| !)/', '$1$2', $css); // "1em 1em 1em 1em" to "1em" + $css = preg_replace('/(?<![\w\-])((?:margin|padding|border|border-(?:width)):)([\w\.]+) ([\w\.]+) \2 \3(?=[;\}]| !)/', '$1$2 $3', $css); // "1em 2em 1em 2em" to "1em 2em" + // shorten colors - $css = preg_replace("/#([0-9a-fA-F]{1})\\1([0-9a-fA-F]{1})\\2([0-9a-fA-F]{1})\\3/", "#\\1\\2\\3",$css); + $css = preg_replace("/#([0-9a-fA-F]{1})\\1([0-9a-fA-F]{1})\\2([0-9a-fA-F]{1})\\3(?=[^\{]*[;\}])/", "#\\1\\2\\3", $css); return $css; } diff --git a/lib/exe/detail.php b/lib/exe/detail.php index 7008b126f..e3c81d877 100644 --- a/lib/exe/detail.php +++ b/lib/exe/detail.php @@ -9,10 +9,12 @@ $ID = cleanID($INPUT->str('id')); // this makes some general infos available as well as the info about the // "parent" page $INFO = array_merge(pageinfo(),mediainfo()); -trigger_event('DETAIL_STARTED', $tmp=array()); -//close session
-session_write_close();
+$tmp = array(); +trigger_event('DETAIL_STARTED', $tmp); + +//close session +session_write_close(); if($conf['allowdebug'] && $INPUT->has('debug')){ print '<pre>'; diff --git a/lib/exe/indexer.php b/lib/exe/indexer.php index 57bee8925..3ab117736 100644 --- a/lib/exe/indexer.php +++ b/lib/exe/indexer.php @@ -31,12 +31,12 @@ else header('Content-Type: text/plain'); $tmp = array(); // No event data $evt = new Doku_Event('INDEXER_TASKS_RUN', $tmp); if ($evt->advise_before()) { - runIndexer() or - runSitemapper() or - sendDigest() or - runTrimRecentChanges() or - runTrimRecentChanges(true) or - $evt->advise_after(); + runIndexer() or + runSitemapper() or + sendDigest() or + runTrimRecentChanges() or + runTrimRecentChanges(true) or + $evt->advise_after(); } if(!$output) { @@ -85,13 +85,13 @@ function runTrimRecentChanges($media_changes = false) { $out_lines = array(); for ($i=0; $i<count($lines); $i++) { - $log = parseChangelogLine($lines[$i]); - if ($log === false) continue; // discard junk - if ($log['date'] < $trim_time) { - $old_lines[$log['date'].".$i"] = $lines[$i]; // keep old lines for now (append .$i to prevent key collisions) - } else { - $out_lines[$log['date'].".$i"] = $lines[$i]; // definitely keep these lines - } + $log = parseChangelogLine($lines[$i]); + if ($log === false) continue; // discard junk + if ($log['date'] < $trim_time) { + $old_lines[$log['date'].".$i"] = $lines[$i]; // keep old lines for now (append .$i to prevent key collisions) + } else { + $out_lines[$log['date'].".$i"] = $lines[$i]; // definitely keep these lines + } } if (count($lines)==count($out_lines)) { diff --git a/lib/exe/js.php b/lib/exe/js.php index 4b4b598de..040b8874d 100644 --- a/lib/exe/js.php +++ b/lib/exe/js.php @@ -86,15 +86,20 @@ function js_out(){ // start output buffering and build the script ob_start(); + $json = new JSON(); // add some global variables print "var DOKU_BASE = '".DOKU_BASE."';"; print "var DOKU_TPL = '".tpl_basedir()."';"; + print "var DOKU_COOKIE_PARAM = " . $json->encode( + array( + 'path' => empty($conf['cookiedir']) ? DOKU_REL : $conf['cookiedir'], + 'secure' => $conf['securecookie'] && is_ssl() + )).";"; // FIXME: Move those to JSINFO print "var DOKU_UHN = ".((int) useHeading('navigation')).";"; print "var DOKU_UHC = ".((int) useHeading('content')).";"; // load JS specific translations - $json = new JSON(); $lang['js']['plugins'] = js_pluginstrings(); $templatestrings = js_templatestrings(); if(!empty($templatestrings)) { @@ -194,8 +199,7 @@ function js_pluginscripts(){ * * @author Gabriel Birke <birke@d-scribe.de> */ -function js_pluginstrings() -{ +function js_pluginstrings() { global $conf; $pluginstrings = array(); $plugins = plugin_list(); diff --git a/lib/exe/mediamanager.php b/lib/exe/mediamanager.php index d9e4a6b04..d94a24c74 100644 --- a/lib/exe/mediamanager.php +++ b/lib/exe/mediamanager.php @@ -34,7 +34,8 @@ $JSINFO = array('id' => '', 'namespace' => ''); $AUTH = $INFO['perm']; // shortcut for historical reasons - trigger_event('MEDIAMANAGER_STARTED',$tmp=array()); + $tmp = array(); + trigger_event('MEDIAMANAGER_STARTED', $tmp); session_write_close(); //close session // do not display the manager if user does not have read access |