Support for randomized header image added to BP

This commit is contained in:
Garvin Hicking 2008-08-26 12:06:12 +00:00
parent 6778580422
commit 2a39208c26
3 changed files with 22 additions and 1 deletions

View File

@ -3,6 +3,11 @@
Version 1.4 ()
------------------------------------------------------------------------
* Bulletproof: Added support for custom, randomized header image.
If you enter a path (relative to the domain root, like
'/blog/uploads/'), any of the contained images will be rotated.
(garvinhicking)
* Added header('Status:...') calls so that some CGI installations
of apache emit proper headers (garvinhicking)

View File

@ -297,6 +297,22 @@ for ($i = 0; $i < $template_loaded_config['amount']; $i++) {
);
}
if ($template_loaded_config['headerimage'] != '' && is_dir($_SERVER['DOCUMENT_ROOT'] . '/' . $template_loaded_config['headerimage'])) {
$files = array();
if ($d = opendir($_SERVER['DOCUMENT_ROOT'] . '/' . $template_loaded_config['headerimage'])) {
while (($file = readdir($d)) !== false) {
if (preg_match('@(\.jpe?g|\.png|\.gif)$@i', $file) && !preg_match('@' . preg_quote($serendipity['thumbSuffix']) . '@i', $file)) {
$files[] = $file;
}
}
}
if (count($files) > 0) {
shuffle($files);
$serendipity['smarty']->assign('random_headerimage', $template_loaded_config['headerimage'] . '/' . $files[0]);
}
}
$serendipity['smarty']->assign_by_ref('navlinks', $navlinks);
// Allow colorset authors to include license and attribution data

View File

@ -34,7 +34,7 @@
{if $template_option.custheader == 'true'}
<style type="text/css">
#serendipity_banner {ldelim}
background-image: url({$template_option.headerimage});
background-image: url({$random_headerimage|@default:$template_option.headerimage});
background-position: {$template_option.headerposhor} {$template_option.headerposver};
{if $template_option.headertype == 'banner'}
background-repeat: no-repeat;