From 8f40d4554a87e916c729f64e0072cffa28cd9cc6 Mon Sep 17 00:00:00 2001 From: Jan Dittberner Date: Sat, 11 Jul 2009 20:48:25 +0000 Subject: [PATCH] make theme and javascript paths configurable (fixes #49) --- gallery.ini.tmpl | 1 + includes/galleryfunctions.php | 4 ++-- includes/theme.class.php | 8 +++++--- index.php | 8 ++++---- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/gallery.ini.tmpl b/gallery.ini.tmpl index 71785c8..7360097 100644 --- a/gallery.ini.tmpl +++ b/gallery.ini.tmpl @@ -1,4 +1,5 @@ logfile=gallery.log +basepath=/ defaulttheme=default_horizontal gallerydir=bilder gallerypath=/bilder diff --git a/includes/galleryfunctions.php b/includes/galleryfunctions.php index 36ca5e2..69baf0e 100644 --- a/includes/galleryfunctions.php +++ b/includes/galleryfunctions.php @@ -50,9 +50,9 @@ require_once('theme.class.php'); if (array_key_exists('theme', $_GET) && preg_match('/^[a-zA-Z0-9_-]+$/', $_GET['theme'])) { - $theme = new Theme($_GET['theme']); + $theme = new Theme($_GET['theme'], $configuration); } else { - $theme = new Theme($configuration['defaulttheme']); + $theme = new Theme($configuration['defaulttheme'], $configuration); } /** diff --git a/includes/theme.class.php b/includes/theme.class.php index 6617f3c..33a0de7 100644 --- a/includes/theme.class.php +++ b/includes/theme.class.php @@ -56,6 +56,7 @@ class Theme { var $name; var $template; + var $config; /** * Constructor for themes. Expects a theme name and initializes the @@ -63,7 +64,7 @@ class Theme { * named theme's directory. * @param string $name the directory name of the theme */ - function __construct($name) { + function __construct($name, &$configuration) { $themeini = realpath(implode(DIRECTORY_SEPARATOR, array('themes', $name, 'theme.ini'))); if (!$themeini) { @@ -74,20 +75,21 @@ class Theme { $this->themetype = $themeconfig['themetype']; $this->previewsize = intval($themeconfig['previewsize']); $this->thumbsize = intval($themeconfig['thumbsize']); + $this->config = $configuration; } function getTemplate() { if (!$this->template) { $this->template = new Template(); $this->template->assign('themepath', - implode(DIRECTORY_SEPARATOR, array('themes', $this->name))); + implode(DIRECTORY_SEPARATOR, array($this->config['themepath'], $this->name))); } return $this->template; } function display() { $this->template->display(implode(DIRECTORY_SEPARATOR, - array('themes', $this->name, 'theme.php'))); + array($this->config['themedir'], $this->name, 'theme.php'))); } } ?> \ No newline at end of file diff --git a/index.php b/index.php index 9633429..bc0c3eb 100644 --- a/index.php +++ b/index.php @@ -49,10 +49,10 @@ $gallery = getCurrentGallery(); */ $thumbinfo = getThumbNailInfo($gallery); -$scripts = array('js/jquery.js', - 'js/jquery.colorBlend.js', - 'js/jquery.lightbox.js', - 'scripts/ourhandlers.js'); +$scripts = array($configuration['basepath'] . 'js/jquery.js', + $configuration['basepath'] . 'js/jquery.colorBlend.js', + $configuration['basepath'] . 'js/jquery.lightbox.js', + $configuration['basepath'] . 'scripts/ourhandlers.js'); $styles = array(); $template = $theme->getTemplate();