diff options
Diffstat (limited to 'modules/gallery')
-rw-r--r-- | modules/gallery/helpers/gallery_theme.php | 20 | ||||
-rw-r--r-- | modules/gallery/libraries/Gallery_View.php | 66 |
2 files changed, 37 insertions, 49 deletions
diff --git a/modules/gallery/helpers/gallery_theme.php b/modules/gallery/helpers/gallery_theme.php index f245ea31..998eb289 100644 --- a/modules/gallery/helpers/gallery_theme.php +++ b/modules/gallery/helpers/gallery_theme.php @@ -22,12 +22,12 @@ class gallery_theme_Core { $session = Session::instance(); $buf = ""; if ($session->get("debug")) { - $theme->css("modules/gallery/css/debug.css"); + $theme->css("debug.css"); } if (($theme->page_type == "album" || $theme->page_type == "photo") && access::can("edit", $theme->item())) { - $theme->css("modules/gallery/css/quick.css"); - $theme->script("modules/gallery/js/quick.js"); + $theme->css("quick.css"); + $theme->script("quick.js"); } if (module::is_active("rss")) { @@ -43,9 +43,9 @@ class gallery_theme_Core { } if ($session->get("l10n_mode", false)) { - $theme->css("modules/gallery/css/l10n_client.css"); - $theme->script("lib/jquery.cookie.js"); - $theme->script("modules/gallery/js/l10n_client.js"); + $theme->css("l10n_client.css"); + $theme->script("jquery.cookie.js"); + $theme->script("l10n_client.js"); } return $buf; @@ -80,13 +80,13 @@ class gallery_theme_Core { static function admin_head($theme) { $session = Session::instance(); if ($session->get("debug")) { - $theme->css("modules/gallery/css/debug.css"); + $theme->css("debug.css"); } if ($session->get("l10n_mode", false)) { - $theme->css("modules/gallery/css/l10n_client.css"); - $theme->script("lib/jquery.cookie.js"); - $theme->script("modules/gallery/js/l10n_client.js"); + $theme->css("l10n_client.css"); + $theme->script("jquery.cookie.js"); + $theme->script("l10n_client.js"); } } diff --git a/modules/gallery/libraries/Gallery_View.php b/modules/gallery/libraries/Gallery_View.php index 31231ca6..219cc883 100644 --- a/modules/gallery/libraries/Gallery_View.php +++ b/modules/gallery/libraries/Gallery_View.php @@ -27,24 +27,20 @@ class Gallery_View_Core extends View { * @param $file the relative path to a script from the gallery3 directory */ public function script($file) { - $this->scripts[$file] = 1; - } - - /** - * Add a script to the combined scripts list. - * @param $file the relative path to a script from the base of the active theme - * @param - */ - public function theme_script($file) { - $file = "themes/{$this->theme_name}/$file"; - $this->scripts[$file] = 1; + $base_file = str_replace(".js", "", $file); + if (($path = Kohana::find_file("js", $base_file, false, "js")) || + file_exists($path = DOCROOT . "lib/$file")) { + $this->scripts[$path] = 1; + } else { + Kohana::log("error", "Can't find script file: $file"); + } } /** * Provide a url to a resource within the current theme. This allows us to refer to theme * resources without naming the theme itself which makes themes easier to copy. */ - public function theme_url($path, $absolute_url=false) { + public function url($path, $absolute_url=false) { $arg = "themes/{$this->theme_name}/$path"; return $absolute_url ? url::abs_file($arg) : url::file($arg); } @@ -53,27 +49,23 @@ 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 */ - public function css($file, $theme_relative=false) { - $this->css[$file] = 1; - } - - /** - * Add a css file to the combined css list. - * @param $file the relative path to a script from the base of the active theme - * @param - */ - public function theme_css($file) { - $file = "themes/{$this->theme_name}/$file"; - $this->css[$file] = 1; + 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")) { + $this->css[$path] = 1; + } else { + Kohana::log("error", "Can't find css file: $file"); + } } /** * Combine a series of files into a single one and cache it in the database. */ - protected function combine_files($files, $type) { + protected function combine_files($paths, $type) { $links = array(); - if (empty($files)) { + if (empty($paths)) { return; } @@ -81,16 +73,10 @@ class Gallery_View_Core extends View { // entries. $key = array(url::abs_file("")); - foreach (array_keys($files) as $file) { - $path = DOCROOT . $file; - if (file_exists($path)) { - $stats = stat($path); - $links[$file] = $path; - // 7 == size, 9 == mtime, see http://php.net/stat - $key[] = "$file $stats[7] $stats[9]"; - } else { - Kohana::log("error", "missing file ($type): $file"); - } + foreach (array_keys($paths) as $path) { + $stats = stat($path); + // 7 == size, 9 == mtime, see http://php.net/stat + $key[] = "$path $stats[7] $stats[9]"; } $key = md5(join(" ", $key)); @@ -99,11 +85,13 @@ class Gallery_View_Core extends View { if (empty($contents)) { $contents = ""; - foreach ($links as $file => $link) { + $docroot_len = strlen(DOCROOT); + foreach (array_keys($paths) as $path) { + $relative = substr($path, $docroot_len); if ($type == "css") { - $contents .= "/* $file */\n" . $this->process_css($link) . "\n"; + $contents .= "/* $relative */\n" . $this->process_css($path) . "\n"; } else { - $contents .= "/* $file */\n" . file_get_contents($link) . "\n"; + $contents .= "/* $relative */\n" . file_get_contents($path) . "\n"; } } |