Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members   Related Pages  

Album.php

Go to the documentation of this file.
00001 <?php
00002 /* $Id: Album.php,v 1.2 2003/10/03 15:27:40 mikko Exp $ */
00003 /*
00004  * ImaComm - a web based photo album software
00005  * Copyright (C) 2003, Mikko Kokkonen
00006  *
00007  * This program is free software; you can redistribute it and/or modify
00008  * it under the terms of the GNU General Public License as published by
00009  * the Free Software Foundation; either version 2 of the License, or (at
00010  * your option) any later version.
00011  * 
00012  * This program is distributed in the hope that it will be useful, but
00013  * WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * General Public License for more details.
00016  * 
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00020  */
00031 class Album
00032 {
00037         var $prefix;
00042         var $attributes;
00043         var $photos;
00044         var $thumbnails;
00045         var $visited;
00046         var $captions;
00052         var $title;
00053         var $logo;
00054         var $_modulesrc;
00055         var $_source;
00056         var $_class;
00060         var $_module;
00061         var $_init;
00071         function Album($source = null, $module = null)
00072         {
00073                 if (!$this->_init)
00074                 {
00075                         $this->_init = true;
00076                         $this->prefix = realpath(dirname(__FILE__)."/../");
00077                         // Get source module...
00078                         list($src, $module) = generateModule("album", $source);
00079                         $this->_source = $src;
00080                         if ($module != null)
00081                         {
00082                                 $this->_modulesrc = $this->prefix."/modules/$module.php";
00083                                 $this->_class = "Album_".strtoupper(substr(strstr($module, "_"), 1));
00084                         }
00085                         // Load module..
00086                         if (file_exists($this->_modulesrc))
00087                         {
00088                                 require_once ($this->_modulesrc);
00089                                 $this->_module = new $this->_class;
00090                         }
00091                 }
00092         }
00093 
00106         function loadData()
00107         {
00108                 if (get_class($this->_module) == strtolower($this->_class))
00109                 {
00110                         if (file_exists($this->_source))
00111                         {
00112                                 $this->_module->loadData($this->_source);
00113                                 $this->mergeVars();
00114                         }
00115                 }
00116         }
00117 
00123         function ID()
00124         {
00125                 return $this->id;
00126         }
00127         
00134         function attribute($name)
00135         {
00136                 return $this->attributes[$name];
00137         }
00138         
00144         function logo()
00145         {
00146                 global $settings;
00147                 
00148                 $logo = $settings->attribute("albums")."/".$this->ID()."/".$this->attribute("logo");
00149                 
00150                 return "<img src=\"$logo\" alt=\"\" border=\"0\" />";
00151         }
00152 
00159         function thumbnail($photo)
00160         {
00161                 global $settings;
00162                 
00163                 $pi = pathinfo($photo);
00164 
00165                 $thumb = $settings->attribute("albums")."/".$this->ID()."/".$this->thumbnails[$this->photoID($photo)];
00166 
00167                 $buf = "<img src=\"$thumb\" alt=\"[$thumb]\" />";
00168 
00169                 return $buf;
00170         }
00171 
00178         function photo($photo)
00179         {
00180                 global $settings;
00181                 
00182                 $photo_src = $settings->attribute("albums")."/".$this->ID()."/".$this->photos[$photo];
00183 
00184                 $buf .= "<img src=\"$photo_src\" alt=\"$photo_src\" />";
00185 
00186                 return $buf;
00187         }
00188         
00195         function caption($photo)
00196         {
00197                 return $this->captions[$photo];
00198         }
00199         
00206         function visited($photo)
00207         {
00208                 return $this->visited[$photo];
00209         }
00210         
00218         function photoID($photo)
00219         {
00220                 return array_search($photo, $this->photos);
00221         }
00222         
00228         function mergeVars()
00229         {
00230                 $this->id = $this->_module->id;
00231                 $this->attributes = $this->_module->attributes;
00232                 $this->photos = $this->_module->photos;
00233                 $this->thumbnails = $this->_module->thumbnails;
00234                 $this->captions = $this->_module->captions;
00235                 $this->visited = $this->_module->visited;
00236         }
00237 }
00238 
00250 function get_albumdata($album)
00251 {
00252         global $albumdata, $config;
00253 
00254         if (get_class($albumdata) != "album" || $albumdata->id != $album)
00255         {
00256                 $albumdata = new Album($config->albums[$album]['source']);
00257                 $albumdata->loadData();
00258         }
00259 
00260         return $albumdata;
00261 }
00262 ?>

Generated on Sun Oct 19 11:08:00 2003 for ImaComm by doxygen1.3