diff options
Diffstat (limited to 'modules/gallery/libraries')
-rw-r--r-- | modules/gallery/libraries/Gallery_View.php | 35 | ||||
-rw-r--r-- | modules/gallery/libraries/Theme_View.php | 3 |
2 files changed, 37 insertions, 1 deletions
diff --git a/modules/gallery/libraries/Gallery_View.php b/modules/gallery/libraries/Gallery_View.php index e21e83d8..7000d3de 100644 --- a/modules/gallery/libraries/Gallery_View.php +++ b/modules/gallery/libraries/Gallery_View.php @@ -20,6 +20,7 @@ class Gallery_View_Core extends View { protected $theme_name = null; protected $scripts = array(); + protected $css = array(); /** * Add a script to the combined scripts list. @@ -86,4 +87,38 @@ class Gallery_View_Core extends View { return "<script type=\"text/javascript\" src=\"" . url::site("combined/javascript/$key") . "\"></script>"; } + + /** + * 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; + } + + /** + * Combine a series of Javascript files into a single one and cache it in the database, then + * return a single <script> element to refer to it. + */ + protected function combine_css() { + $links = array(); + $key = ""; + foreach (array_keys($this->css) as $file) { + $links[] = "<link media=\"screen, projection\" rel=\"stylesheet\" type=\"text/css\" href=\"" . + url::file($file) . "\" />"; + + } + return implode("\n", $links); + } + }
\ No newline at end of file diff --git a/modules/gallery/libraries/Theme_View.php b/modules/gallery/libraries/Theme_View.php index 8e320f44..bc8e540a 100644 --- a/modules/gallery/libraries/Theme_View.php +++ b/modules/gallery/libraries/Theme_View.php @@ -201,8 +201,8 @@ class Theme_View_Core extends Gallery_View { array("gallery_theme", $function), array_merge(array($this), $args)); } - } + foreach (module::active() as $module) { if ($module->name == "gallery") { continue; @@ -216,6 +216,7 @@ class Theme_View_Core extends Gallery_View { } if ($function == "head") { + array_unshift($blocks, $this->combine_css()); array_unshift($blocks, $this->combine_script()); } |