Move function in include/comment.php inside of the comment class. This lets us refer to

these functions like Comment:: making it clear they are static functions of the comment class
This commit is contained in:
Chris Morgan
2006-07-08 22:09:14 +00:00
committed by WineHQ
parent f05c05864e
commit 763ad58bcf
3 changed files with 238 additions and 244 deletions

View File

@@ -70,7 +70,7 @@ while ($oRow = mysql_fetch_object($commentIds))
$hResult = query_parameters($sQuery, $oRow->commentId);
/* call view_app_comment to display the comment */
$oComment_row = mysql_fetch_object($hResult);
view_app_comment($oComment_row);
Comment::view_app_comment($oComment_row);
}
/* display page selection links */

View File

@@ -186,37 +186,16 @@ class Comment {
}
return false;
}
}
/*
* Comment functions that are not part of the class
/**
* class static functions
*/
function forum_lookup_user($iUserId)
{
if ($iUserId > 0)
{
$oUser = new User($iUserId);
if($_SESSION['current']->isLoggedIn())
$sMailto = '<a href="mailto:' . $oUser->sEmail . '">' . $oUser->sRealname . '</a>';
else
$sMailto = $oUser->sRealname;
}
if (!$iUserId || !$oUser->isLoggedIn())
{
$sMailto = 'Anonymous';
}
return $sMailto;
}
/**
/**
* display a single comment (in $oRow)
*/
function view_app_comment($oRow)
{
function view_app_comment($oRow)
{
echo html_frame_start('','98%');
echo '<table width="100%" border="0" cellpadding="2" cellspacing="1">',"\n";
@@ -257,15 +236,14 @@ function view_app_comment($oRow)
echo "</table>\n";
echo html_frame_end();
}
}
/**
/**
* grab comments for appId / versionId
* if parentId is not -1 only comments for that thread are returned
*/
function grab_comments($versionId, $parentId = -1)
{
function grab_comments($versionId, $parentId = -1)
{
/* escape input so we can use query_appdb() without concern */
$versionId = mysql_real_escape_string($versionId);
$parentId = mysql_real_escape_string($parentId);
@@ -282,43 +260,39 @@ function grab_comments($versionId, $parentId = -1)
$hResult = query_appdb($qstring);
return $hResult;
}
}
/**
/**
* display nested comments
* handle is a db result set
*/
function do_display_comments_nested($hResult)
{
function do_display_comments_nested($hResult)
{
while($oRow = mysql_fetch_object($hResult))
{
view_app_comment($oRow);
$hResult2 = grab_comments($oRow->versionId, $oRow->commentId);
Comment::view_app_comment($oRow);
$hResult2 = Comment::grab_comments($oRow->versionId, $oRow->commentId);
if($hResult && mysql_num_rows($hResult2))
{
echo "<blockquote>\n";
do_display_comments_nested($hResult2);
Comment::do_display_comments_nested($hResult2);
echo "</blockquote>\n";
}
}
}
}
function display_comments_nested($versionId, $threadId)
{
$hResult = Comment::grab_comments($versionId, $threadId);
Comment::do_display_comments_nested($hResult);
}
function display_comments_nested($versionId, $threadId)
{
$hResult = grab_comments($versionId, $threadId);
do_display_comments_nested($hResult);
}
/**
/**
* display threaded comments
* handle is a db result set
*/
function do_display_comments_threaded($hResult, $is_main)
{
function do_display_comments_threaded($hResult, $is_main)
{
if (!$is_main)
echo "<ul>\n";
@@ -326,54 +300,50 @@ function do_display_comments_threaded($hResult, $is_main)
{
if ($is_main)
{
view_app_comment($oRow);
Comment::view_app_comment($oRow);
} else
{
echo '<li><a href="commentview.php?iAppId='.$oRow->appId.'&amp;iVersionId='.$oRow->versionId.'&iThreadId='.$oRow->parentId.'"> '.
$oRow->subject.' </a> by '.forum_lookup_user($oRow->userId).' on '.$oRow->time.' </li>'."\n";
}
$hResult2 = grab_comments($oRow->versionId, $oRow->commentId);
$hResult2 = Comment::grab_comments($oRow->versionId, $oRow->commentId);
if ($hResult2 && mysql_num_rows($hResult2))
{
echo "<blockquote>\n";
do_display_comments_threaded($hResult2, 0);
Comment::do_display_comments_threaded($hResult2, 0);
echo "</blockquote>\n";
}
}
if (!$is_main)
echo "</ul>\n";
}
}
function display_comments_threaded($versionId, $threadId = 0)
{
$hResult = Comment::grab_comments($versionId, $threadId);
function display_comments_threaded($versionId, $threadId = 0)
{
$hResult = grab_comments($versionId, $threadId);
Comment::do_display_comments_threaded($hResult, 1);
}
do_display_comments_threaded($hResult, 1);
}
/**
/**
* display flat comments
*/
function display_comments_flat($versionId)
{
$hResult = grab_comments($versionId);
function display_comments_flat($versionId)
{
$hResult = Comment::grab_comments($versionId);
if ($hResult)
{
while($oRow = mysql_fetch_object($hResult))
{
view_app_comment($oRow);
Comment::view_app_comment($oRow);
}
}
}
}
function view_app_comments($versionId, $threadId = 0)
{
function view_app_comments($versionId, $threadId = 0)
{
$aClean = array(); //array of filtered user input
$aClean['sCmode'] = makeSafe($_REQUEST['sCmode']);
@@ -399,7 +369,7 @@ function view_app_comments($versionId, $threadId = 0)
$sel[$_SESSION['current']->getPref("comments:mode", "threaded")] = 'selected';
echo '<td><form method="post" name="sMode" action="appview.php">',"\n";
echo "<b>Application Comments</b> $messageCount total comments ";
echo '<b>Mode</b> <select name="sCmode" onchange="document.smode.submit();">',"\n";
echo '<b>Mode</b> <select name="sCmode" onchange="document.sMode.submit();">',"\n";
echo ' <option value="flat" '.$sel['flat'].'>Flat</option>',"\n";
echo ' <option value="threaded" '.$sel['threaded'].'>Threaded</option>',"\n";
echo ' <option value="nested" '.$sel['nested'].'>Nested</option>',"\n";
@@ -440,16 +410,40 @@ function view_app_comments($versionId, $threadId = 0)
switch ($mode)
{
case "flat":
display_comments_flat($versionId);
Comment::display_comments_flat($versionId);
break;
case "nested":
display_comments_nested($versionId, $threadId);
Comment::display_comments_nested($versionId, $threadId);
break;
case "threaded":
display_comments_threaded($versionId, $threadId);
Comment::display_comments_threaded($versionId, $threadId);
break;
}
echo '</td></tr></table>',"\n";
}
}
/*
* Comment functions that are not part of the class
*/
function forum_lookup_user($iUserId)
{
if ($iUserId > 0)
{
$oUser = new User($iUserId);
if($_SESSION['current']->isLoggedIn())
$sMailto = '<a href="mailto:' . $oUser->sEmail . '">' . $oUser->sRealname . '</a>';
else
$sMailto = $oUser->sRealname;
}
if (!$iUserId || !$oUser->isLoggedIn())
{
$sMailto = 'Anonymous';
}
return $sMailto;
}
?>

View File

@@ -819,7 +819,7 @@ class Version {
}
// Comments Section
view_app_comments($this->iVersionId);
Comment::view_app_comments($this->iVersionId);
}
function lookup_name($versionId)