You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
78 lines
2.9 KiB
Plaintext
78 lines
2.9 KiB
Plaintext
13 years ago
|
<?php
|
||
|
class Comment
|
||
|
{
|
||
|
public $id = 0;
|
||
|
public $body = "";
|
||
|
public $message = "";
|
||
|
public $author = "";
|
||
|
public $date = "";
|
||
|
public $level = 0;
|
||
|
public $itemid = 0;
|
||
|
public $section = "";
|
||
|
public $children = array();
|
||
|
public $linecount = 0;
|
||
|
|
||
|
public function __construct($mid,$level)
|
||
|
{
|
||
|
$this->id = $mid;
|
||
|
$res = mysql_query("SELECT * FROM comments WHERE `Id`='$mid'");
|
||
|
$row = mysql_fetch_array($res);
|
||
|
$this->body = nl2br(trim(htmlentities(stripslashes($row['Body']))));
|
||
|
$this->author = strip_tags(stripslashes($row['Name']));
|
||
|
$this->date = strip_tags(stripslashes($row['Posted']));
|
||
|
$this->section = strip_tags(stripslashes($row['Section']));
|
||
|
$this->itemid = strip_tags(stripslashes($row['ItemId']));
|
||
|
$this->linecount = strip_tags(stripslashes($row['LineCount']));
|
||
|
$this->level = $level;
|
||
|
$res = mysql_query("SELECT * FROM comments WHERE `ParentId`='$mid' AND `Visible`='1' ORDER BY `Posted` ASC");
|
||
|
while($row=mysql_fetch_array($res))
|
||
|
{
|
||
|
$this->children[] = new Comment($row['Id'],$level+1);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public function draw()
|
||
|
{
|
||
|
global $lang;
|
||
|
echo("<a name=\"comment-{$this->id}\"></a>");
|
||
|
if($this->linecount == 1)
|
||
|
{
|
||
|
echo("<div class=\"comment small\" style=\"margin-left: ".(35*$this->level)."px;\">
|
||
|
<span class=\"smallcomment\"><strong>{$this->author}</strong> {$this->body}</span>
|
||
|
<a class=\"hidden small\" href=\"#\" onclick=\"$('reply{$this->id}').style.display='block'; return false;\">Reply</a>
|
||
|
<a class=\"hidden small\" href=\"".curPageURL()."#comment-{$this->id}\">Permalink</a>
|
||
|
<div class=\"hiddenreply\" id=\"reply{$this->id}\">
|
||
|
<form method=\"POST\" action=\"?p=comments&c={$this->section}&i={$this->itemid}&pid={$this->id}\">
|
||
|
<strong>{$lang[37]}:</strong> <input type=\"text\" name=\"author\" value=\"Anonymous\"><button class=\"hiddenreply\" name=\"submit\" type=\"submit\">{$lang[39]}</button><br>
|
||
|
<strong>{$lang[38]}:</strong><br><textarea name=\"body\" class=\"reply\"></textarea>
|
||
|
</form>
|
||
|
</div>
|
||
|
</div>");
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
echo("<div class=\"comment\" style=\"margin-left: ".(35*$this->level)."px;\">
|
||
|
<strong class=\"hidden\">{$this->author} - <i>{$this->date}</i></strong>
|
||
|
{$this->body}
|
||
|
<!-- replybox -->
|
||
|
<div class=\"commentlinks\">
|
||
|
<a class=\"hidden\" href=\"#\" onclick=\"$('reply{$this->id}').style.display='block'; return false;\">Reply</a>
|
||
|
<a class=\"hidden small\" href=\"".curPageURL()."#comment-{$this->id}\">Permalink</a>
|
||
|
</div>
|
||
|
<div class=\"hiddenreply\" id=\"reply{$this->id}\">
|
||
|
<form method=\"POST\" action=\"?p=comments&c={$this->section}&i={$this->itemid}&pid={$this->id}\">
|
||
|
<strong>{$lang[37]}:</strong> <input type=\"text\" name=\"author\" value=\"Anonymous\"><button class=\"hiddenreply\" name=\"submit\" type=\"submit\">{$lang[39]}</button><br>
|
||
|
<strong>{$lang[38]}:</strong><br><textarea name=\"body\" class=\"reply\"></textarea>
|
||
|
</form>
|
||
|
</div>
|
||
|
</div>");
|
||
|
}
|
||
|
foreach($this->children as $child)
|
||
|
{
|
||
|
$child->draw();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
?>
|
||
|
|