Browse Source

move more theme related functionality into the theme class (addresses #46)

master
Jan Dittberner 13 years ago
parent
commit
ded7232146
  1. 22
      includes/theme.class.php
  2. 29
      index.php
  3. 16
      themes/default_horizontal/theme.php

22
includes/theme.class.php

@ -28,6 +28,8 @@
* <http://www.gnu.org/licenses/>.
*/
require('includes/template.class.php');
/**
* Theme class.
*/
@ -52,6 +54,9 @@ class Theme {
*/
var $thumbsize;
var $name;
var $template;
/**
* Constructor for themes. Expects a theme name and initializes the
* internal state of the instance from the 'theme.ini' file in the
@ -61,10 +66,25 @@ class Theme {
function __construct($name) {
$themeconfig = parse_ini_file(
realpath(implode(DIRECTORY_SEPARATOR,
array('themes', $name, 'theme.ini'))));
array('themes', $name, 'theme.ini'))));
$this->name = $name;
$this->themetype = $themeconfig['themetype'];
$this->previewsize = intval($themeconfig['previewsize']);
$this->thumbsize = intval($themeconfig['thumbsize']);
}
function getTemplate() {
if (!$this->template) {
$this->template = new Template();
$this->template->assign('themepath',
implode(DIRECTORY_SEPARATOR, array('themes', $this->name)));
}
return $this->template;
}
function display() {
$this->template->display(implode(DIRECTORY_SEPARATOR,
array('themes', $this->name, 'theme.php')));
}
}
?>

29
index.php

@ -47,35 +47,19 @@ $gallery = getCurrentGallery();
*/
$thumbinfo = getThumbNailInfo($gallery);
require('includes/template.class.php');
$template = new Template();
$scripts = array('js/jquery.js',
'js/jquery.colorBlend.js',
'js/jquery.lightbox.js',
'scripts/ourhandlers.js');
$styles = array('css/jquery.lightbox.css');
$inlinestyles = sprintf("\n#scrollable { width:%dpx; }\n", $thumbinfo[0]);
$template = $theme->getTemplate();
$inlinestyles .= <<<EOD
a {
font-size: 9px;
}
a:link {
text-decoration: none;
}
a:visited {
text-decoration: none;
}
a:hover {
text-decoration: none;
}
a:active {
text-decoration: none;
if ($theme->themetype == 'horizontal') {
$inlinestyles = sprintf("\n#scrollable { width:%dpx; }\n", $thumbinfo[0]);
} else {
$inlinestyles = sprintf("\n#scrollable { height:%dpx; }\n", $thumbinfo[0]);
}
EOD;
$template->assign('scripts', $scripts);
$template->assign('styles', $styles);
@ -86,9 +70,8 @@ $template->assign('thumbnails', getAllThumbnails($thumbinfo));
$template->assign('firstpreview', getFirstPreview($thumbinfo));
$template->assign('firstdescription', getFirstDescription($thumbinfo));
$template->assign('lang', 'de');
$template->assign('themepath', 'themes/default_horizontal');
$template->assign('gallery', $gallery);
$template->display('themes/default_horizontal/theme.php');
$theme->display();
?>

16
themes/default_horizontal/theme.php

@ -6,6 +6,22 @@
<title><?php echo $content['title']; ?></title>
<style type="text/css">
<?php print($content['inlinestyle']); ?>
a {
font-size: 9px;
}
a:link {
text-decoration: none;
}
a:visited {
text-decoration: none;
}
a:hover {
text-decoration: none;
}
a:active {
text-decoration: none;
}
</style>
<?php foreach ($content['styles'] as $style) { ?>
<link rel="stylesheet" type="text/css" href="<?php echo $style; ?>" />

Loading…
Cancel
Save