00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
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
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
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 ?>