From 82c73c423e7675e900af520e529af5792236050d Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Mon, 15 Oct 2012 16:22:42 +0000 Subject: [PATCH] patch for minify to support EGroupware set up as an alias, which is a common setup --- phpgwapi/inc/min/config.php | 7 +++++++ phpgwapi/inc/min/lib/Minify/Controller/MinApp.php | 10 +++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/phpgwapi/inc/min/config.php b/phpgwapi/inc/min/config.php index 1e636bfb26..276e61a932 100755 --- a/phpgwapi/inc/min/config.php +++ b/phpgwapi/inc/min/config.php @@ -152,6 +152,13 @@ $min_serveOptions['minApp']['groupsOnly'] = false; */ $min_symlinks = array(); +/** + * Configure an alias for EGroupware, as it is common setup + * + * Requires patched lib/Minify/Controller/MinApp.php, to understand aliases defined as symlink! + */ +list($sitePrefix) = explode('/phpgwapi/inc/min/', $_SERVER['REQUEST_URI']); +$min_symlinks['//'.ltrim($sitePrefix, '/')] = dirname(dirname(dirname(__DIR__))); /** * If you upload files from Windows to a non-Windows server, Windows may report diff --git a/phpgwapi/inc/min/lib/Minify/Controller/MinApp.php b/phpgwapi/inc/min/lib/Minify/Controller/MinApp.php index 9a683b446e..aca53f6793 100755 --- a/phpgwapi/inc/min/lib/Minify/Controller/MinApp.php +++ b/phpgwapi/inc/min/lib/Minify/Controller/MinApp.php @@ -136,10 +136,18 @@ class Minify_Controller_MinApp extends Minify_Controller_Base { foreach ((array)$cOptions['allowDirs'] as $allowDir) { $allowDirs[] = realpath(str_replace('//', $_SERVER['DOCUMENT_ROOT'] . '/', $allowDir)); } + $base_path = $_SERVER['DOCUMENT_ROOT'].$base; + // check base against symlinks to support aliases configured via symlinks + if (!(file_exists($base_path) && is_dir($base_path) && realpath($base_path) !== false) && + isset($options['minifierOptions']['text/css']['symlinks'][$t='//'.trim($base, '/')]) && + ($base_path = realpath($options['minifierOptions']['text/css']['symlinks'][$t]))) { + $base_path .= '/'; + $allowDirs[] = $base_path; + } $basenames = array(); // just for cache id foreach ($files as $file) { $uri = $base . $file; - $path = $_SERVER['DOCUMENT_ROOT'] . $uri; + $path = $base_path . $file; $realpath = realpath($path); if (false === $realpath || ! is_file($realpath)) { $this->log("The path \"{$path}\" (realpath \"{$realpath}\") could not be found (or was not a file)");