patch for minify to support EGroupware set up as an alias, which is a common setup

This commit is contained in:
Ralf Becker 2012-10-15 16:22:42 +00:00
parent 019a84cd17
commit 82c73c423e
2 changed files with 16 additions and 1 deletions

View File

@ -152,6 +152,13 @@ $min_serveOptions['minApp']['groupsOnly'] = false;
*/ */
$min_symlinks = array(); $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 * If you upload files from Windows to a non-Windows server, Windows may report

View File

@ -136,10 +136,18 @@ class Minify_Controller_MinApp extends Minify_Controller_Base {
foreach ((array)$cOptions['allowDirs'] as $allowDir) { foreach ((array)$cOptions['allowDirs'] as $allowDir) {
$allowDirs[] = realpath(str_replace('//', $_SERVER['DOCUMENT_ROOT'] . '/', $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 $basenames = array(); // just for cache id
foreach ($files as $file) { foreach ($files as $file) {
$uri = $base . $file; $uri = $base . $file;
$path = $_SERVER['DOCUMENT_ROOT'] . $uri; $path = $base_path . $file;
$realpath = realpath($path); $realpath = realpath($path);
if (false === $realpath || ! is_file($realpath)) { if (false === $realpath || ! is_file($realpath)) {
$this->log("The path \"{$path}\" (realpath \"{$realpath}\") could not be found (or was not a file)"); $this->log("The path \"{$path}\" (realpath \"{$realpath}\") could not be found (or was not a file)");