< < < Click here to go back to the main site

List of available files:

basecode/
    > Gallery.php
    > Photograph.php
    > gallerybuilder.php
    > Video.php
    > GallerySection.php
    > includer.php
    > GalleryItem.php
    > GalleryNavigationData.php
pictures/
templates/
    style/
        > gallery.css
    > footer.txt
    images/
    > header.txt
    > contact.txt
> index.php
> opensource.php
> gpl.txt

Showing source of: ./basecode/Photograph.php


<?php

    
/***************************************************************************
     * jpbGallery 1.0.0 Copyright (c) 2007 Jean-Philippe Barbeau
     * Contact: jp $at> jpbarbeau $dot> com
     ***************************************************************************
     * This file is part of the jpbGallery project.
     *
     * jpbGallery 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.
     * 
     * jpbGallery 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 this program.  If not, see <http://www.gnu.org/licenses/>.
    -***************************************************************************/

    
define('BASE_TOP_MARGIN'17);
    
define('BASE_BTM_MARGIN'7);


    class 
Photograph extends GalleryItem
    
{
        
        private 
$m_s_fNumber;
        private 
$m_s_ISO;
        private 
$m_s_exposure/* Positive values: 1/NNN; Negative values: NNN seconds. */
        
private $m_s_focalLength;
        private 
$m_description;
        private 
$m_fileName;
        private 
$m_tWd;
        private 
$m_tHe;
        private 
$m_pWd;
        private 
$m_pHe;
        private 
$m_title;
        
        
        public function 
__construct($fileName$title$description$tWidth 200$tHeight 150$pWidth 800$pHeight 600)
        {
            
$this->m_description $description;
            
$this->m_fileName $fileName;
            
$this->m_title $title;
            
            
$this->m_s_fNumber null;
            
$this->m_s_ISO null;
            
$this->m_s_exposure null;
            
$this->m_s_focalLength null;
            
            
$this->m_tWd $tWidth;
            
$this->m_tHe $tHeight;
            
$this->m_pWd $pWidth;
            
$this->m_pHe $pHeight;
        }
        
        public function 
__get($member)
        {
            
/* Gets any m_s_-prefixed member of the class */
            
try
            {
                
$memberString "m_s_$member";
                return 
$this->$memberString;
            }
            
            catch (
Exception $e)
            {
                throw new 
Exception("Unknown member " $member ".");
            }
        }
        
        public function 
__set($member$value)
        {
            
/* Sets any m_s_-prefixed member of the class */
            
            
try
            {
                
$memberString "m_s_$member";
                
$this->$memberString $value;
                return 
$value;
            }
            
            catch (
Exception $e)
            {
                throw new 
Exception("Unknown member " $member ".");
            }
        }
        
        public function 
toHTML(GalleryNavigationData $navData null)
        {
            
$result "";
            
            if (
is_null($navData)) 
            {
                
/* If there is no navData, assume that we need to print a thumnail preview */
                
$result .= '<img class="photograph" src="' htmlspecialchars($this->m_fileName) . '.S.JPG" ';
                
$result .= 'alt="' htmlspecialchars($this->m_fileName) . '" style="width: ' . (int) $this->m_tWd 'px; ';
                
$result .= 'height: ' . (int) $this->m_tHe 'px; margin-top: ' . (int) ((150 $this->m_tHe) / BASE_TOP_MARGIN) . 'px; ';
                
$result .= 'margin-bottom: ' . (int) ((150 $this->m_tHe) / BASE_BTM_MARGIN 2) . 'px;" />';
            }
            
            else
            {
                
/* Else, print the fill-size photograph with some fancy rounded corners and navigation */
                
                /* Do the fancy corners/borders only if we have an height and width specified */
                
$doCorners $this->m_pWd && $this->m_pHe 0;
                
                
$result .= '<div id="imageholder">';
                
                
$this->doNavigation($result$navDatafalse);
                
                if (
$doCorners)
                {
                    
$result .= '<img alt="" id="imgbordertopleft" src="./templates/images/imgbordertopleft.png" />';
                    
$result .= '<img alt="" id="imgbordertop" style="width: ' . (int) $this->m_pWd 'px;" src="./templates/images/imgbordertop.png" />';
                    
$result .= '<img alt="" id="imgbordertopright" src="./templates/images/imgbordertopright.png" /><br />';
                    
$result .= '<img alt="" id="imgborderleft" style="height: ' . (int) $this->m_pHe 'px;" src="./templates/images/imgborderleft.png" />';
                }
                
                
$result .= '<img class="photograph" src="' htmlspecialchars($this->m_fileName) . '" alt="' htmlspecialchars($this->m_title) . '" ';
                
                if (
$doCorners)
                {
                    
$result .= 'style="width: ' . (int) $this->m_pWd 'px; height: ' . (int) $this->m_pHe 'px;" ';
                }
                
                
$result .= '/>';
                
                if (
$doCorners)
                {
                    
$result .= '<img alt="" id="imgborderright" style="height: ' . (int) $this->m_pHe 'px;" src="./templates/images/imgborderright.png" /><br />';
                    
$result .= '<img alt="" id="imgborderbotleft" src="./templates/images/imgborderbotleft.png" />';
                    
$result .= '<img alt="" id="imgborderbot" style="width: ' . (int) $this->m_pWd 'px;" src="./templates/images/imgborderbot.png" />';
                    
$result .= '<img alt="" id="imbborderbotright" src="./templates/images/imgborderbotright.png" />';
                }
                
                
$this->doNavigation($result$navDatatrue);
                
                
$result .= '</div>';
            }
            
            return 
$result;
        }
        
        private function 
doNavigation(& $resultGalleryNavigationData $navData$isBottom)
        {
            
$margin_top $isBottom 50 0;
            
$margin_bottom 50;
            
            
$result .= '<table class="navigation" cellspacing="0" cellpadding="0" style="margin-bottom: ' $margin_bottom 'px; margin-top: ' $margin_top 'px;"><tr>';
            
$result .= '<td colspan="3"><div class="navtopwidget">  </div></td></tr><tr>';
            
            
$result .= '<td style="text-align: left; padding-left: 12px;"><form action="./">';
            
$result .= '<input type="submit" value="&lt; Prev." /><input type="hidden" name="photoid" value="' . (int) $navData->getPrevious() . '" />';
            
$result .= '</form></td>';
            
$result .= '<td style="text-align: center;"><form action="./"><input type="submit" value="-- Home --" /></form></td>';
            
$result .= '<td style="text-align: right; padding-right: 12px;"><form action="./">';
            
$result .= '<input type="submit" value="Next &gt;" /><input type="hidden" name="photoid" value="' . (int) $navData->getNext() . '" />';
            
$result .= '</form></td>';
            
            if (
$isBottom)
            {
                
/* Write more information */
                
$result .= '</tr><tr>';
                
$result .= '<td colspan="3" class="navinfo" style="font-style: italic;">' htmlspecialchars($this->m_description) . '</td>';
                
$result .= '</tr><tr>';
                
$result .= '<td colspan="3" class="navinfo">Sony DSC-H5&nbsp; |&nbsp; F' number_format(round($this->m_s_fNumber1), 1'.''') . ', ';
                
                if (
$this->m_s_exposure 0)
                {
                    
$result .= round(-$this->m_s_exposure2) . '\'\'';
                }
                
                else
                {
                    
$result .= '1/' round($this->m_s_exposure) . 'th';
                }
                
                
$xZoom round($this->m_s_focalLength 351);
                
                
$result .= ', ISO&nbsp;' $this->m_s_ISO ', ' round($this->m_s_focalLength) . '&nbsp;<acronym title="In 35mm terms. (~' .$xZoom 'X)">mm</acronym>.';
                
                
$result .= '</td>';
            }
            
            
$result .= '</tr><tr><td colspan="3"><div class="navbottomwidget">  </div></td>';
            
$result .= '</tr></table>';
        }
        
        public function 
__destruct()
        {
        }
        
    };


?>

< < < Click here to go back to the main site