diff options
-rw-r--r-- | modules/gallery/helpers/gallery.php | 15 | ||||
-rw-r--r-- | modules/gallery/libraries/Gallery_View.php | 16 |
2 files changed, 19 insertions, 12 deletions
diff --git a/modules/gallery/helpers/gallery.php b/modules/gallery/helpers/gallery.php index d4f733e4..033bf4bd 100644 --- a/modules/gallery/helpers/gallery.php +++ b/modules/gallery/helpers/gallery.php @@ -83,14 +83,21 @@ class gallery_Core { * Provide a wrapper function for Kohana::find_file, that first strips the extension and * then calls the Kohana::find_file supply that extension * @param string directory to search in - * @param string filename to look for (without extension) - * @param boolean file required - * @return the file relative to the DOCROOT + * @param string filename to look for + * @param boolean file required (optional: default false) + * @param boolean make the file name relative (optiona: default false) + * @return array if the type is config, i18n or l10n + * @return string if the file is found (relative to the DOCROOT) + * @return FALSE if the file is not found */ static function find_file($directory, $file, $required=false) { $file_name = substr($file, 0, -strlen($ext = strrchr($file, '.'))); $file_name = Kohana::find_file($directory, $file_name, $required, substr($ext, 1)); - return substr($file_name, strlen(DOCROOT)); + if (!$file_name && file_exists(DOCROOT . "lib/$file")) { + return "lib/$file"; + } + + return is_string($file_name) ? substr($file_name, strlen(DOCROOT)) : $file_name; } static function site_menu($menu, $theme) { diff --git a/modules/gallery/libraries/Gallery_View.php b/modules/gallery/libraries/Gallery_View.php index 219cc883..f3fa970b 100644 --- a/modules/gallery/libraries/Gallery_View.php +++ b/modules/gallery/libraries/Gallery_View.php @@ -24,12 +24,12 @@ class Gallery_View_Core extends View { /** * Add a script to the combined scripts list. - * @param $file the relative path to a script from the gallery3 directory + * @param $file the file name or path of the script to include. if a path is specified then + * the location needs to be DOCROOT/lib. Just specifying a file name will result + * in searching the hierarchical file system. */ public function script($file) { - $base_file = str_replace(".js", "", $file); - if (($path = Kohana::find_file("js", $base_file, false, "js")) || - file_exists($path = DOCROOT . "lib/$file")) { + if (($path = gallery::find_file("js", $file, false))) { $this->scripts[$path] = 1; } else { Kohana::log("error", "Can't find script file: $file"); @@ -47,12 +47,12 @@ class Gallery_View_Core extends View { /** * Add a css file to the combined css list. - * @param $file the relative path to a script from the gallery3 directory + * @param $file the file name or path of a css file to include. if a path is specified then + * the location needs to be DOCROOT/lib. Just specifying a file name will result + * in searching the hierarchical file system. */ public function css($file) { - $base_file = str_replace(".css", "", $file); - if (($path = Kohana::find_file("css", $base_file, false, "css")) || - file_exists($path = DOCROOT . "lib/$file")) { + if (($path = gallery::find_file("css", $file, false))) { $this->css[$path] = 1; } else { Kohana::log("error", "Can't find css file: $file"); |