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

Comments.php

Go to the documentation of this file.
00001 <?php
00002 /* $Id: Comments.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  */
00021 
00030 class Comments
00031 {
00036         var $comments;
00037         var $prefix;
00038 
00039         var $_init;
00040         var $_source;
00041         var $_modulesrc;
00047         var $_module;
00048 
00055         function Comments($source = null)
00056         {
00057                 if (!$this->_init)
00058                 {
00059                         $this->_init = true;
00060                         $this->prefix = realpath(dirname(__FILE__)."/../");
00061                         // Get source module...
00062                         list($src, $module) = generateModule("comments", $source);
00063                         $this->_source = $src;
00064                         if ($module != null)
00065                         {
00066                                 $this->_modulesrc = $this->prefix."/modules/$module.php";
00067                                 $this->_class = "Comments_".strtoupper(substr(strstr($module, "_"), 1));
00068                         }
00069                         // Load module..
00070                         if (file_exists($this->_modulesrc))
00071                         {
00072                                 require_once ($this->_modulesrc);
00073                                 $this->_module = new $this->_class;
00074                         }
00075                 }
00076         }
00077 
00087         function loadComments($for)
00088         {
00089                 if (get_class($this->_module) == strtolower($this->_class))
00090                 {
00091                         $this->_module->loadComments($this->_source, $for);
00092                         $this->mergeVars();
00093                 }
00094         }
00095 
00103         function addComment($data)
00104         {
00105                 if (get_class($this->_module) == strtolower($this->_class))
00106                 {
00107                         $this->_module->addComment($this->_source, $data);
00108                         $this->mergeVars();
00109                 }
00110         }
00111 
00120         function canAdd($for)
00121         {
00122                 if (get_class($this->_module) == strtolower($this->_class))
00123                 {
00124                         return $this->_module->canAdd($this->_source, $for);
00125                 }
00126         }
00127         
00133         function hasComments()
00134         {
00135                 return is_array($this->comments);
00136         }
00137 
00147         function getComments()
00148         {
00149                 return $this->comments;
00150         }
00151         
00156         function mergeVars()
00157         {
00158                 $this->comments = $this->_module->comments;
00159         }
00160 }
00161 ?>

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