<?php
require_once './class.coverflow.php';
$width = 600;
$height = 400;
$coversArray = array(
/* imageSRC imageTITLE URL */
array( './covers/coverflow10.jpg', 'One image in flow', './covers/coverflow10.jpg' ) ,
array( './covers/coverflow11.jpg', 'One image in flow', './covers/coverflow11.jpg' ) ,
array( './covers/coverflow20.jpg', 'Two images in flow', './covers/coverflow20.jpg' ) ,
array( './covers/coverflow30.jpg', 'Three images in flow', './covers/coverflow30.jpg' ) ,
array( './covers/coverflow31.jpg', 'Three images in flow', './covers/coverflow31.jpg' ) ,
array( './covers/noges.jpg', 'Nõges (in English: Nettle)', './covers/noges.jpg' ) ,
array( './covers/lill.jpg', 'Lill, Liilia (in English: Flower, Lily)', './covers/lill.jpg' ) ,
array( './covers/saun.jpg', 'Saun (in English: Sauna)', './covers/saun.jpg' ) ,
array( './covers/tamm.jpg', 'Tamm (in English: Oak)', './covers/tamm.jpg' ) ,
array( './covers/koer.jpg', 'Lõke (in English: Bonfire)', './covers/koer.jpg' ) ,
array( './covers/kask.jpg', 'Kask (in English: Birch)', './covers/kask.jpg' ) ,
array( './covers/kits.jpg', 'Kits (in English: Goat)', './covers/kits.jpg' )
);
$countcoversArray = count($coversArray);
if( isset($_GET['cfp']) ) $centered = (int) $_GET['cfp'];
else $centered = 0;
if( $centered < 0 ) $centered = 0;
elseif( $centered < $countcoversArray );
else $centered = $countcoversArray-1;
$imageCachefileSrc = './cache/cfp_'. $centered .'.jpg';
$imageCachefileHtm = './cache/cfp_'. $centered .'.htm';
//$cov->set_htmlImagemapName('coverflow1');
$echoCoverFlowHTML = '';
if( !is_file( $imageCachefileSrc ) ) {
$cov = new coverflow($width,$height);
//$cov->set_reflectionHeight(4.5);
//$cov->set_bgWhite();
$cov->set_bgBlack();
foreach( $coversArray as $coverId => $cover ) {
if( $centered == $coverId ) {
$url = $cover[2];
$target='_blank';
} else {
$url = '?cfp=' . $coverId;
$target='_self';
}
$cov->set_cover($cover[0]);
$cov->set_htmlAtag($coverId, $cover[1], $url, $target );
}
$cov->set_coverCentered( $centered );
$cov->get_imageJpeg( $imageCachefileSrc );
//$cov->get_imagePng( $imageSrc );
$imageHtmlToCache =
'<h2>' . $coversArray[$centered][1] . '</h2>'
. '<img src="'. $imageCachefileSrc .'" usemap="'.$cov->get_htmlImagemapName()
.'" alt="_" width="'.$width.'" height="'.$height.'" border="0" />'
. $cov->get_htmlImagemap();
file_put_contents_($imageCachefileHtm, $imageHtmlToCache );
$echoCoverFlowHTML = $imageHtmlToCache;
} else {
$echoCoverFlowHTML = file_get_all ( $imageCachefileHtm );
}
//Invisible, 0x0 images
$BrowserCache = '';
for( $i = 0 ; $i < $countcoversArray; $i++ )
if( is_file( './cache/cfp_'. $i .'.jpg' ) )
$BrowserCache .= '<img src="./cache/cfp_'. $i .'.jpg" width="0" height="0" border="0" alt="" />';
echo
'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<?xml version="1.0" encoding="ISO-8859-1" ?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
<title>PHP Class coverFlow Example</title>
<style>
h2 { font-size:13pt;}
</style>
<body style="background:white;" >
<p style="margin: 0 0 0 0;padding:0 0 0 0;font-family:times;font-size:12pt;"><a href=".." style="color:#000000;text-decoration:none;"><<< Top Site</a></p>
<h1>PHP Class coverFlow Example</h1>
<p>Click on the centered image to see original or click on the smaller ones to move in gallery.</p>
'. $echoCoverFlowHTML
. $BrowserCache . '
</body>
</html>';
/////////////////////////////////////////////////////////////////////////////////
/**
* Write a string to a file.
* Uses function file_put_contents if available
* This function is binary-safe.
* For perfomance reasons by default multi-dimensional array supported in php4
*
* @author Uku-Kaarel Jõesaar http://ukj.pri.ee
* @param string $filename The file name where to write the data
* @param mixed $data The data to write. Can be either a string, an array or a stream resource.
* @param int $flags FILE_USE_INCLUDE_PATH, FILE_APPEND and/or LOCK_EX
* @param resource $context A context resource
* @return int
*/
function file_put_contents_($filename,$data,$flags=NULL,$context=NULL) {
//(PHP 5)
if(function_exists('file_put_contents'))
return file_put_contents($filename,$data,$flags,$context); //supports 1d arr
$flockr=TRUE;
$mode='wb';
$use_include_path=FALSE;
if($flags&FILE_USE_INCLUDE_PATH)$use_include_path=TRUE;
if($flags&FILE_APPEND)$mode='ab';
eval("\$handle=fopen(\$filename ,\$mode ,\$use_include_path".
(is_resource($context)?",\$context":'').");");
if(!$handle)
return FALSE;
//5.1.0 //PHP 4.0.1
if($flags&LOCK_EX)
$flockr=flock($handle,LOCK_EX);
if($flockr){
if(is_array($data))
if(function_exists('fwrite_array'))
$fwriter=fwrite_array($handle,$data);
else
$data=implode('',$data);
else
$fwriter=fwrite($handle,$data);
}
fclose($handle);
return $fwriter;
} //end file_put_contents_()
/**
* Read whole file into string
*
* @param string filename
* @return string FALSE if failure
*/
function file_get_all ( $filename ) {
if(!is_file( $filename )) return FALSE;
if(!is_readable( $filename )) return FALSE;
$r = @fopen($filename,'rb');
if(is_resource( $r )) {
fseek($r,0,SEEK_END);
$filesize = ftell($r);
rewind( $r );
$re = '';
if($filesize > 0) {
while (!feof($r)) {
$re .= @fread($r, 8192);
}
}
else
$re = '';
fclose( $r );
return $re;
}
return FALSE;
} //end file_get_all()
?>