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

Configuration.php

Go to the documentation of this file.
00001 <?php
00002 /* $Id: Configuration.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  */
00029 class Configuration
00030 {
00034         var $prefix;
00035         var $file;
00036         var $albums;
00037         var $nesting;
00038         var $schemes;
00039         var $scheme;
00040 
00044         var $_init;
00045         var $_modulesrc;
00046         var $_class;
00047         var $_source;
00053         var $_module;
00054 
00061         function Configuration($source = null, $module = null)
00062         {
00063                 if (!$this->_init)
00064                 {
00065                         $this->_init = true;
00066                         $this->prefix = realpath(dirname(__FILE__)."/../");
00067                         if ($source == null && $module == null)
00068                         {
00069                                 list($source, $module) = generateModule("config");
00070                         }
00071                         $this->_source = $source;
00072                         if ($module != null)
00073                         {
00074                                 $this->_modulesrc = $this->prefix."/modules/$module.php";
00075                                 $this->_class = "Configuration_".strtoupper(substr(strstr($module, "_"), 1));
00076                         }
00077                         if (file_exists($this->_modulesrc))
00078                         {
00079                                 require_once ($this->_modulesrc);
00080                                 $this->_module = new $this->_class;
00081                         }
00082                 }
00083         }
00084 
00089         function loadData()
00090         {
00091                 $this->_module->loadData($this->_source);
00092                 $this->mergeVars();
00093         }
00094         
00099         function createFile()
00100         {
00101                 $this->_module->createFile($_REQUEST);
00102                 $this->mergeVars();
00103         }
00104 
00114         function option($name, $value = null, $save = false)
00115         {
00116                 $options = array_keys($this->schemes[$this->scheme]);
00117                 if (!in_array($name, $options) || $save == true)
00118                 {
00119                         $this->schemes[$this->scheme][$name] = $value;
00120                 }
00121                 return $this->schemes[$this->scheme][$name];
00122         }
00123 
00128         function getNesting()
00129         {
00130                 return $this->nesting;
00131         }
00132         
00138         function getAlbum($album)
00139         {
00140                 return $this->albums[$album];
00141         }
00142         
00146         function mergeVars()
00147         {
00148                 $this->file = $this->_module->file;
00149                 $this->albums = $this->_module->albums;
00150                 $this->nesting = $this->_module->nesting;
00151                 $this->schemes = $this->_module->schemes;
00152                 $this->scheme = "default"; // FIXME: parse albums, etc. to resolve active options scheme!
00153         }
00154 }
00155 ?>

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