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/>.
*/
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
@ -62,9 +67,24 @@ class Theme {
$themeconfig = parse_ini_file(
realpath(implode(DIRECTORY_SEPARATOR,
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')));
}
}
?>

View file

@ -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;
if ($theme->themetype == 'horizontal') {
$inlinestyles = sprintf("\n#scrollable { width:%dpx; }\n", $thumbinfo[0]);
} 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('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();
?>

View file

@ -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; ?>" />