|
Posted by Koncept on 01/21/07 22:16
> OK Thanx for the Bash tips... This is a config file:
>
> ROOTDIR="/home/max/Development/current/website/sites/www.maccusfoto.nl/photo"
> SUBDIR="travel/spain"
> DIRLEVEL="2"
> GENERAL_TITLE="Spain"
> PAGES="47"
> STARTPAGE="travel"
> IMG_ALT="© Maxim Heijndijk"
>
> CAPTION_01="MONTSERRAT"
> CAPTION_02="MONTSERRAT - Wedding"
> CAPTION_03=""MONTSERRAT
> CAPTION_04="BARCELONA - Tibidabo"
> CAPTION_05="EL MASNOU - Fireworks, Ple de Riure del Masnou"
> CAPTION_06="EL MASNOU"
Something like this should work for you. I hope I got the logic correct
given your specs. I have to admit that I didn't really take a lot of
time to figure out exactly what you were doing with the shell script:
<?php
// Config options
$rootDir =
"/home/max/Development/current/website/sites/www.maccusfoto.nl/photo";
$subDir = "travel/spain";
$generalTitle = "Spain";
$startPage = "travel";
$imgAlt = "© Maxim Heijndijk";
$dirLevel = 2;
$pages = 47;
$captions = array(
'MONTSERRAT',
'MONTSERRAT - Wedding',
'MONTSERRAT',
'BARCELONA - Tibidabo',
'EL MASNOU - Fireworks, Ple de Riure del Masnou',
'EL MASNOU'
);
// check for root directory
if(!is_dir($rootDir)){
trigger_error("{$rootDir} not found. Check config.", E_USER_ERROR);
}
// create path structure
$dirPath=str_repeat("../",$dirLevel);
// Get the page request from $_GET
if(isset($_GET['page'])&&is_numeric($_GET['page'])){
$_GP=$_GET['page']>0?$_GET['page']:1;
} else{$_GP=1;}
// Assign next, previous and current variables
if($_GP>1&&$_GP<$pages){
list($p,$n,$c)=array($_GP-1,$_GP+1,$_GP);
} elseif($_GP==1){
list($p,$n,$c)=array($pages,2,1);
} elseif($_GP==$pages){
list($p,$n,$c)=array($_GP-1,1,$_GP);
}
// Prefix variables with "0" if value is less than 10
// since that seems to be the naming convention here.
$preName=$p<10?"0{$p}":$p;
$curName=$c<10?"0{$c}":$c;
$nxtName=$n<10?"0{$n}":$n;
// Check for the the source image...
if(!is_file($curImg="{$rootDir}/{$subDir}/{$curName}.jpg")){
trigger_error("Missing image file $curImg",E_USER_ERROR);
}
// Get image properties
list($x,$y,$type,$attr)=getimagesize($curImg);
// Get the photo caption for this image
$caption=$captions[$c-1];
// Send template to browser
echo <<<HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>{$generalTitle} - Photo {$curName}</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta http-equiv="refresh"
content="15;URL={$_SERVER['PHP_SELF']}?page={$n}" />
<meta name="author" content="Fotografie & Webdesign: Maxim
Heijndijk" />
<meta name="copyright" content="Fotografie & Webdesign: Maxim
Heijndijk" />
<link rel="stylesheet" type="text/css" href="{$dirPath}../index.css"
/>
</head>
<body oncontextmenu="return false">
<table summary="{$generalTitle} - Photo {$curName}"
align="center" cellspacing="0" cellpadding="0"
border="0" width="100%" class="caption">
<tr>
<!-- Previous -->
<td align="right" valign="bottom" width="10%">
<a href="{$_SERVER['PHP_SELF']}?page={$p}"><img
alt="Previous" src="{$dirPath}images/prev.gif"
border="0" width="22" height="24" /></a>
</td>
<!-- Current -->
<td align="center" valign="bottom" width="80%">
<a href="{$_SERVER['PHP_SELF']}?page={$n}"><img
alt="{$imgAlt}" src="images/{$curName}.jpg"
border="0" {$attr} /></a>
</td>
<!-- Next -->
<td align="left" valign="bottom" width="10%">
<a href="{$_SERVER['PHP_SELF']}?page={$n}"><img
alt="Next" src="{$dirPath}images/next.gif"
border="0" width="22" height="24" /></a>
</td>
</tr>
<tr>
<td align="center" nowrap="nowrap" valign="top"
width="100%" height="10%" colspan="3">
<br />
{$caption}
<br />
<br />
</td>
</tr>
</table>
</body>
</html>
HTML;
?>
--
Koncept <<
"The snake that cannot shed its skin perishes. So do the spirits who are
prevented from changing their opinions; they cease to be a spirit." -Nietzsche
Navigation:
[Reply to this message]
|