make theme and javascript paths configurable (fixes #49)
This commit is contained in:
		
							parent
							
								
									631ec74b2b
								
							
						
					
					
						commit
						8f40d4554a
					
				
					 4 changed files with 12 additions and 9 deletions
				
			
		|  | @ -1,4 +1,5 @@ | ||||||
| logfile=gallery.log | logfile=gallery.log | ||||||
|  | basepath=/ | ||||||
| defaulttheme=default_horizontal | defaulttheme=default_horizontal | ||||||
| gallerydir=bilder | gallerydir=bilder | ||||||
| gallerypath=/bilder | gallerypath=/bilder | ||||||
|  |  | ||||||
|  | @ -50,9 +50,9 @@ require_once('theme.class.php'); | ||||||
| 
 | 
 | ||||||
| if (array_key_exists('theme', $_GET) && | if (array_key_exists('theme', $_GET) && | ||||||
|     preg_match('/^[a-zA-Z0-9_-]+$/', $_GET['theme'])) { |     preg_match('/^[a-zA-Z0-9_-]+$/', $_GET['theme'])) { | ||||||
|   $theme = new Theme($_GET['theme']); |   $theme = new Theme($_GET['theme'], $configuration); | ||||||
| } else { | } else { | ||||||
|   $theme = new Theme($configuration['defaulttheme']); |   $theme = new Theme($configuration['defaulttheme'], $configuration); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  |  | ||||||
|  | @ -56,6 +56,7 @@ class Theme { | ||||||
| 
 | 
 | ||||||
|   var $name; |   var $name; | ||||||
|   var $template; |   var $template; | ||||||
|  |   var $config; | ||||||
| 
 | 
 | ||||||
|   /** |   /** | ||||||
|    * Constructor for themes. Expects a theme name and initializes the |    * Constructor for themes. Expects a theme name and initializes the | ||||||
|  | @ -63,7 +64,7 @@ class Theme { | ||||||
|    * named theme's directory. |    * named theme's directory. | ||||||
|    * @param string $name the directory name of the theme |    * @param string $name the directory name of the theme | ||||||
|    */ |    */ | ||||||
|   function __construct($name) { |   function __construct($name, &$configuration) { | ||||||
|     $themeini = realpath(implode(DIRECTORY_SEPARATOR, |     $themeini = realpath(implode(DIRECTORY_SEPARATOR, | ||||||
|       array('themes', $name, 'theme.ini'))); |       array('themes', $name, 'theme.ini'))); | ||||||
|     if (!$themeini) { |     if (!$themeini) { | ||||||
|  | @ -74,20 +75,21 @@ class Theme { | ||||||
|     $this->themetype = $themeconfig['themetype']; |     $this->themetype = $themeconfig['themetype']; | ||||||
|     $this->previewsize = intval($themeconfig['previewsize']); |     $this->previewsize = intval($themeconfig['previewsize']); | ||||||
|     $this->thumbsize = intval($themeconfig['thumbsize']); |     $this->thumbsize = intval($themeconfig['thumbsize']); | ||||||
|  |     $this->config = $configuration; | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   function getTemplate() { |   function getTemplate() { | ||||||
|     if (!$this->template) { |     if (!$this->template) { | ||||||
|       $this->template = new Template(); |       $this->template = new Template(); | ||||||
|       $this->template->assign('themepath', |       $this->template->assign('themepath', | ||||||
|         implode(DIRECTORY_SEPARATOR, array('themes', $this->name))); |         implode(DIRECTORY_SEPARATOR, array($this->config['themepath'], $this->name))); | ||||||
|     } |     } | ||||||
|     return $this->template; |     return $this->template; | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   function display() { |   function display() { | ||||||
|     $this->template->display(implode(DIRECTORY_SEPARATOR, |     $this->template->display(implode(DIRECTORY_SEPARATOR, | ||||||
|       array('themes', $this->name, 'theme.php'))); |       array($this->config['themedir'], $this->name, 'theme.php'))); | ||||||
|   } |   } | ||||||
| } | } | ||||||
| ?>
 | ?>
 | ||||||
|  | @ -49,10 +49,10 @@ $gallery   = getCurrentGallery(); | ||||||
|  */ |  */ | ||||||
| $thumbinfo = getThumbNailInfo($gallery); | $thumbinfo = getThumbNailInfo($gallery); | ||||||
| 
 | 
 | ||||||
| $scripts = array('js/jquery.js', | $scripts = array($configuration['basepath'] . 'js/jquery.js', | ||||||
|                  'js/jquery.colorBlend.js', |                  $configuration['basepath'] . 'js/jquery.colorBlend.js', | ||||||
|                  'js/jquery.lightbox.js', |                  $configuration['basepath'] . 'js/jquery.lightbox.js', | ||||||
|                  'scripts/ourhandlers.js'); |                  $configuration['basepath'] . 'scripts/ourhandlers.js'); | ||||||
| $styles  = array(); | $styles  = array(); | ||||||
| 
 | 
 | ||||||
| $template = $theme->getTemplate(); | $template = $theme->getTemplate(); | ||||||
|  |  | ||||||
		Reference in a new issue