Archived
1
0
Fork 0

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

This commit is contained in:
Jan Dittberner 2009-07-11 15:13:40 +00:00
parent fcea03a800
commit ded7232146
3 changed files with 43 additions and 24 deletions

View file

@ -28,6 +28,8 @@
* <http://www.gnu.org/licenses/>. * <http://www.gnu.org/licenses/>.
*/ */
require('includes/template.class.php');
/** /**
* Theme class. * Theme class.
*/ */
@ -52,6 +54,9 @@ class Theme {
*/ */
var $thumbsize; var $thumbsize;
var $name;
var $template;
/** /**
* Constructor for themes. Expects a theme name and initializes the * Constructor for themes. Expects a theme name and initializes the
* internal state of the instance from the 'theme.ini' file in the * internal state of the instance from the 'theme.ini' file in the
@ -62,9 +67,24 @@ class Theme {
$themeconfig = parse_ini_file( $themeconfig = parse_ini_file(
realpath(implode(DIRECTORY_SEPARATOR, realpath(implode(DIRECTORY_SEPARATOR,
array('themes', $name, 'theme.ini')))); array('themes', $name, 'theme.ini'))));
$this->name = $name;
$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']);
} }
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')));
}
} }
?> ?>

View file

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

View file

@ -6,6 +6,22 @@
<title><?php echo $content['title']; ?></title> <title><?php echo $content['title']; ?></title>
<style type="text/css"> <style type="text/css">
<?php print($content['inlinestyle']); ?> <?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> </style>
<?php foreach ($content['styles'] as $style) { ?> <?php foreach ($content['styles'] as $style) { ?>
<link rel="stylesheet" type="text/css" href="<?php echo $style; ?>" /> <link rel="stylesheet" type="text/css" href="<?php echo $style; ?>" />