Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

base-thread.inc.php

Go to the documentation of this file.
00001 <?
00010 abstract class BaseThread extends MyManager
00011 {
00015     private $contentId;
00016 
00020     public $ContentClass;
00021     
00025     public $count = null;
00026     
00035     function __construct($contentId, $class, $table = null, $objectType = null)
00036     {
00037         //who are we on?
00038         $this->contentId = $contentId;
00039         $this->ContentClass = $class;
00040 
00041         //default table..
00042         if ($table === null)
00043             $table = 'comments_' . strtolower($this->ContentClass);
00044 
00045         //just use base comments...
00046         if ($objectType === null)
00047             $objectType = $this->ContentClass . 'Comment';
00048 
00049         //construct
00050         parent::__construct($objectType, $table);
00051     }
00052 
00059     function getMainPageXml()
00060     {
00061         return <<<XML
00062             <page name="main" type="content" desc="the main page for the module">
00063                 <param name="content_id" type="int" />
00064             </page>
00065 XML;
00066     }
00067 
00071     public function initMainPage()
00072     {
00073         $this->contentId = $this->params('content_id'); 
00074     }
00075 
00079     public function drawMainPage()
00080     {
00081         $this->drawCommentTable();
00082     }
00083     
00089     function factory($data = null)
00090     {
00091         return new $this->objectType($data, $this->ContentClass);
00092     }
00093 
00097     function delete()
00098     {
00099         $rs = $this->search(array(
00100             'content_id' => $this->contentId
00101         ), -1);
00102 
00103         parent::delete($rs);
00104     }
00105 
00114     function getCommentCount($ids = null)
00115     {
00116         if ($this->count !== null)
00117             return $this->count;
00118 
00119         if (is_array($ids))
00120         {
00121             $comRs = dbQuery("
00122                 SELECT content_id, count(content_id) AS count
00123                 FROM {$this->object->tableName}
00124                 WHERE content_id IN (" . implode(',', $ids) . ")
00125                 GROUP BY content_id
00126             ");
00127             while ($comAr = dbFetchAssoc($comRs))
00128                 $ret[$comAr['content_id']] = $comAr['count'];
00129             return $ret;
00130         }
00131         else
00132         {
00133             $comRs = dbQuery("
00134                 SELECT id
00135                 FROM {$this->object->tableName}
00136                 WHERE content_id = '$this->contentId'
00137             ");
00138             return dbGetNumRows($comRs);
00139         }
00140     }
00141 
00146     function drawCommentSummary()
00147     {
00148         $comCount = $this->getCommentCount();
00149         
00150         echo "<span class=\"commentSummary\">\n";
00151         $url = $this->getUrl(strtolower($this->ContentClass) . ".view?id=$this->contentId") . "#comments";
00152         echo "<a href=\"$url\"><b>$comCount</b> " . Util::pluralize('comment', $comCount) . "</a>";
00153         echo "</span>\n";
00154     }
00155 
00161     function drawCommentTable()
00162     {
00163         echo "<div id=\"commentContainer\">\n";
00164 
00165         echo "<p>\n";
00166         $form = $this->object->createReplyForm($this->contentId);
00167         $form->drawAll();
00168         echo "</p>\n";
00169 
00170         echo "<a name=\"comments\">&nbsp;</a>";
00171         $this->drawComments();
00172         
00173         //do we want rss?
00174         if ($this->useRss)
00175             echo $this->getRssLink(".search?output=rss&content_id=$this->contentId", "Subscribe to comment RSS feed.");
00176         
00177         echo "\n</div>\n";
00178     }
00179 
00185     function getComments()
00186     {
00187         return $this->search(array(
00188             'content_id' => $this->contentId
00189         ), -1);
00190     }
00191 
00195     function drawComments()
00196     {
00197         $coms = $this->getComments();
00198         $this->object->drawChildComments($coms, 0);
00199     }
00200 
00204     function initSearchPage()
00205     {
00206         $this->contentId = $this->params('content_id');
00207         
00208         parent::initSearchPage();
00209     }
00210 
00215     function generateRss($params = array())
00216     {
00217         $rss = parent::generateRss($params);
00218         $rss->link = $this->getUrl(strtolower($this->ContentClass) . ".view?id=" . $this->contentId, null, true);
00219         $rss->title = Config::get('site_name') . " " . ucfirst($this->ContentClass) . " Comment Thread";
00220 
00221         return $rss;
00222     }
00223 
00231     public function getSearchParamXml()
00232     {
00233         $xml = '<param name="content_id" desc="the id of the content the comment thread is on" required="1" is_searchable="true" />';
00234         $xml .= parent::getSearchParamXml();
00235 
00236         return $xml;
00237     }
00238 }
00239 ?>

Generated on Fri Oct 27 12:26:40 2006 for BaseJumper by doxygen 1.3.9.1