use a simple template system to allow theming (fixes #32)
commit 502c8903b4c7eb09d36c4fedb86deec8689fe7c6 Author: Jan Dittberner <jan@dittberner.info> Date: Sat Jul 11 00:20:03 2009 +0200 * extract html part of index.php into the first default theme commit cddcc777bba2efecdcad0f3b130e7e5e6b1e2a73 Author: Jan Dittberner <jan@dittberner.info> Date: Fri Jul 10 23:38:32 2009 +0200 * add a template class
This commit is contained in:
parent
0cdd30bb05
commit
0ed421b1ce
5 changed files with 155 additions and 72 deletions
63
includes/template.class.php
Normal file
63
includes/template.class.php
Normal file
|
@ -0,0 +1,63 @@
|
|||
<?php
|
||||
/**
|
||||
* @file simple template system for ScrollingJQueryGallery
|
||||
*
|
||||
* @author Jan Dittberner <jan@dittberner.info>
|
||||
*
|
||||
* @version $Id$
|
||||
*
|
||||
* Copyright (c) 2009 Jan Dittberner
|
||||
* Jan Dittberner IT-Consulting & -Solutions
|
||||
* Cottbuser Str. 1, D-01129 Dresden
|
||||
*
|
||||
* This file is part of the ScrollingJQueryGallery component of the
|
||||
* gnuviech-server.de Websitetools
|
||||
*
|
||||
* ScrollingJQueryGallery is free software: you can redistribute it
|
||||
* and/or modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* ScrollingJQueryGallery is distributed in the hope that it will be
|
||||
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with ScrollingJQueryGallery. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class provides a simple template mechanism. It was inspired by
|
||||
* http://mylittlehomepage.net/ueber-den-sinn-von-php-template-engines
|
||||
* (german).
|
||||
*/
|
||||
class Template {
|
||||
/**
|
||||
* associative array containing the template content.
|
||||
* @var array
|
||||
*/
|
||||
var $content;
|
||||
|
||||
/**
|
||||
* Assign a value to the template.
|
||||
* @param string $name variable name
|
||||
* @param mixed $value variable value
|
||||
*/
|
||||
function assign($name, $value) {
|
||||
$this->content[$name] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the given template file.
|
||||
* @param string $template template file name
|
||||
*/
|
||||
function display($template) {
|
||||
if($this->content) {
|
||||
$content = $this->content;
|
||||
}
|
||||
include($template);
|
||||
}
|
||||
}
|
||||
?>
|
102
index.php
102
index.php
|
@ -6,7 +6,7 @@
|
|||
* @author Jan Dittberner <jan@dittberner.info>, Jeremias Arnstadt
|
||||
* <douth024@googlemail.com>
|
||||
*
|
||||
* @version \$Id$
|
||||
* @version $Id$
|
||||
*
|
||||
* Copyright (c) 2008, 2009 Jan Dittberner
|
||||
* Jan Dittberner IT-Consulting & -Solutions
|
||||
|
@ -35,7 +35,7 @@
|
|||
/**
|
||||
* Inkludiert die Funktionsbibliothek.
|
||||
*/
|
||||
require 'includes/galleryfunctions.php';
|
||||
require('includes/galleryfunctions.php');
|
||||
|
||||
/**
|
||||
* Name der aktuellen Galerie.
|
||||
|
@ -47,24 +47,19 @@ $gallery = getCurrentGallery();
|
|||
*/
|
||||
$thumbinfo = getThumbNailInfo($gallery);
|
||||
|
||||
?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<title><?php print getGalleryTitle($thumbinfo); ?></title>
|
||||
<link rel="stylesheet" type="text/css" href="css/main.css" />
|
||||
<link rel="stylesheet" href="css/format.css" type="text/css" />
|
||||
<link rel="stylesheet" href="css/jquery.lightbox.css" type="text/css" />
|
||||
<script src="js/jquery.js" type="text/javascript" ></script>
|
||||
<script src="js/jquery.colorBlend.js" type="text/javascript"></script>
|
||||
<script src="js/jquery.lightbox.js" type="text/javascript" ></script>
|
||||
<script src="scripts/ourhandlers.js" type="text/javascript" ></script>
|
||||
<style type="text/css">
|
||||
<?php
|
||||
printf("#scrollable { width:%dpx; }", $thumbinfo[0]);
|
||||
?>
|
||||
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]);
|
||||
|
||||
$inlinestyles .= <<<EOD
|
||||
a {
|
||||
font-size: 9px;
|
||||
}
|
||||
|
@ -80,54 +75,19 @@ a:hover {
|
|||
a:active {
|
||||
text-decoration: none;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<!-- container -->
|
||||
<div id="container">
|
||||
<div id="content">
|
||||
<ul id="menu"><?php
|
||||
foreach (getGalleryLinks() as $data) {
|
||||
printf('<li class="menu%s"><a class="menu" href="%s">%s </a></li>',
|
||||
($data['gallery'] == $gallery) ? ' active' : '',
|
||||
$data['url'], $data['label']);
|
||||
} ?></ul>
|
||||
<div id="content_container">
|
||||
<div id="slider">
|
||||
<div id="arrleft"><img src="css/grafiken/aro-lft.png" alt="nach links"
|
||||
width="10" height="65" /></div>
|
||||
<div id="imgscroller"><div id="scrollable"><?php
|
||||
// zeigt die eingelesenen Thumnails an
|
||||
foreach (getAllThumbnails($thumbinfo) as $thumbdata) {
|
||||
printf('<div class="thumbnail"><img src="%s" alt="%s" %s /></div>',
|
||||
$thumbdata['src'], $thumbdata['alt'], $thumbdata['sizes']);
|
||||
}
|
||||
?></div></div>
|
||||
<div id="arrright"><img src="css/grafiken/aro-rt.png" alt="nach rechts"
|
||||
width="10" height="65" /></div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="content_sub">
|
||||
<div id="content_main">
|
||||
<div class="bildposition"><?php
|
||||
// bindet die Bilder in den Hauptbereich ein
|
||||
$data = getFirstPreview($thumbinfo);
|
||||
printf('<a class="lightbox" title="%s" href="%s" rel="lightbox">' .
|
||||
'<img id="contentimg" src="%s" alt="%s" %s /></a>',
|
||||
$data['title'], $data['full'], $data['src'], $data['alt'],
|
||||
$data['sizes']);
|
||||
?></div>
|
||||
</div>
|
||||
<div id="content_nav">
|
||||
<img id="backbtn" src="css/grafiken/back.png" alt="back" class="back" width="10" height="10" /><img id="fwdbtn" src="css/grafiken/next.png" alt="next" class="next" width="10" height="10" />
|
||||
</div>
|
||||
<div class="imgdescription" id="imagedescription"><?php
|
||||
// liest die Bildbeschreibung für das jeweilige Bild (wenn definiert)
|
||||
print getFirstDescription($thumbinfo);
|
||||
?></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /container -->
|
||||
</body>
|
||||
</html>
|
||||
EOD;
|
||||
|
||||
$template->assign('scripts', $scripts);
|
||||
$template->assign('styles', $styles);
|
||||
$template->assign('inlinestyle', $inlinestyles);
|
||||
$template->assign('title', getGalleryTitle($thumbinfo));
|
||||
$template->assign('gallerylinks', getGalleryLinks());
|
||||
$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->display('themes/default_horizontal/theme.php');
|
||||
|
||||
?>
|
60
themes/default_horizontal/theme.php
Normal file
60
themes/default_horizontal/theme.php
Normal file
|
@ -0,0 +1,60 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $content['lang'] ; ?>">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<title><?php echo $content['title']; ?></title>
|
||||
<style type="text/css">
|
||||
<?php print($content['inlinestyle']); ?>
|
||||
</style>
|
||||
<?php foreach ($content['styles'] as $style) { ?>
|
||||
<link rel="stylesheet" type="text/css" href="<?php echo $style; ?>" />
|
||||
<?php } ?>
|
||||
<link rel="stylesheet" type="text/css" href="<?php echo $content['themepath']; ?>/css/main.css" />
|
||||
<link rel="stylesheet" type="text/css" href="<?php echo $content['themepath']; ?>/css/format.css" />
|
||||
<?php foreach ($content['scripts'] as $script) { ?>
|
||||
<script type="text/javascript" src="<?php echo $script; ?>"></script>
|
||||
<?php } ?>
|
||||
</head>
|
||||
<body>
|
||||
<div id="container">
|
||||
<div id="content">
|
||||
<ul id="menu"><?php
|
||||
foreach ($content['gallerylinks'] as $data) {
|
||||
printf('<li class="menu%s"><a class="menu" href="%s">%s </a></li>',
|
||||
($data['gallery'] == $gallery) ? ' active' : '',
|
||||
$data['url'], $data['label']);
|
||||
} ?></ul>
|
||||
<div id="content_container">
|
||||
<div id="slider">
|
||||
<div id="arrleft"><img src="css/grafiken/aro-lft.png" alt="nach links" width="10" height="65" /></div>
|
||||
<div id="imgscroller"><div id="scrollable"><?php
|
||||
// show Thumnails an
|
||||
foreach ($content['thumbnails'] as $thumbdata) {
|
||||
?><div class="thumbnail"><img src="<?php echo $thumbdata['src']; ?>" alt="<?php echo $thumbdata['alt']; ?>" <?php echo $thumbdata['sizes']; ?> /></div><?php
|
||||
} ?></div></div>
|
||||
<div id="arrright"><img src="css/grafiken/aro-rt.png" alt="nach rechts" width="10" height="65" /></div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="content_sub">
|
||||
<div id="content_main">
|
||||
<div class="bildposition"><?php
|
||||
// bindet die Bilder in den Hauptbereich ein
|
||||
$data = $content['firstpreview'];
|
||||
printf('<a class="lightbox" title="%s" href="%s" rel="lightbox">' .
|
||||
'<img id="contentimg" src="%s" alt="%s" %s /></a>',
|
||||
$data['title'], $data['full'], $data['src'], $data['alt'],
|
||||
$data['sizes']);
|
||||
?></div>
|
||||
</div>
|
||||
<div id="content_nav">
|
||||
<img id="backbtn" src="css/grafiken/back.png" alt="back" class="back" width="10" height="10" /><img id="fwdbtn" src="css/grafiken/next.png" alt="next" class="next" width="10" height="10" />
|
||||
</div>
|
||||
<div class="imgdescription" id="imagedescription"><?php
|
||||
echo $content['firstdescription'];
|
||||
?></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
Reference in a new issue