From b2a9bf43afa2aaf845368ea04beef56f2ed035de Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Thu, 1 Oct 2009 12:43:30 -0700 Subject: Change gallery::find_file to not assume that the absolute path is relative to the document root. Instead ignore all th path parts until one of application, modules, themes, or libs is found. Fixes ticket #827 --- modules/gallery/helpers/gallery.php | 13 ++++++++++++- modules/gallery/libraries/Gallery_View.php | 6 ++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/modules/gallery/helpers/gallery.php b/modules/gallery/helpers/gallery.php index b6d4fee0..37a08d08 100644 --- a/modules/gallery/helpers/gallery.php +++ b/modules/gallery/helpers/gallery.php @@ -96,7 +96,18 @@ class gallery_Core { return "lib/$file"; } - return is_string($file_name) ? substr($file_name, strlen(DOCROOT)) : $file_name; + if (is_string($file_name)) { + // make relative to DOCROOT + $parts = explode("/", $file_name); + foreach ($parts as $idx => $part) { + if (in_array($part, array("application", "modules", "themes", "lib"))) { + break; + } + unset($parts[$idx]); + } + $file_name = implode("/", $parts); + } + return $file_name; } } \ No newline at end of file diff --git a/modules/gallery/libraries/Gallery_View.php b/modules/gallery/libraries/Gallery_View.php index 253a314f..bdfd2fc9 100644 --- a/modules/gallery/libraries/Gallery_View.php +++ b/modules/gallery/libraries/Gallery_View.php @@ -85,13 +85,11 @@ class Gallery_View_Core extends View { if (empty($contents)) { $contents = ""; - $docroot_len = strlen(DOCROOT); foreach (array_keys($paths) as $path) { - $relative = substr($path, $docroot_len); if ($type == "css") { - $contents .= "/* $relative */\n" . $this->process_css($path) . "\n"; + $contents .= "/* $path */\n" . $this->process_css($path) . "\n"; } else { - $contents .= "/* $relative */\n" . file_get_contents($path) . "\n"; + $contents .= "/* $path */\n" . file_get_contents($path) . "\n"; } } -- cgit v1.2.3