Code
<?php
require("Cogent.php");
/**
* PicsPane
* A class for generating HTML tables of images by scanning a directory
* containing folders of image files. For each directory found, PicsPane
* will add an album (top-level div) with a heading of that name.
*
* Outline:
* PicsPane("<directory name>")
* PicsPane->run(); // runs HTML output for all images found, organized by album
*
* The CSS id of the top-level div is "pics", in accordance with the formatting scheme that I
* use for my website. For other applications, just define the "pics" properties as desired
*
* Author: Jonathan Scholz
* 2/3/2010
*/
class PicsPane extends Cogent
{
/**
* Generates HTML for a grid from nested divs for the images found
* in each album
*/
protected function generate($dir, $files){
// write heading for this project
if ($this->depth == 0) {
print '<h3 id="'.$dir.'">'.$dir."</h3>\n";
}
// count elements in array
$numpics = count($files);
// loop over pics array to apply css container properties & links to highres versions:
for ($pic=0; $pic < $numpics; $pic++) {
print '<a href="'.$this->rootdir.'/'.$dir.'/'.$files[$pic].'" '. // set target
'onClick="_gaq.push(["_trackEvent", "Picture", "Viewed", "'.$files[$pic].'"]);">'. // install tracker
'<img class="thumb" src="'.$this->rootdir.'/'.$dir.'/'.$files[$pic]. // set content
'" /></a>'."\n";
}
}
} // End: class PicsPane
?>
About me