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); $hResult = query_parameters($sQuery, $oRow->commentId);
/* call view_app_comment to display the comment */ /* call view_app_comment to display the comment */
$oComment_row = mysql_fetch_object($hResult); $oComment_row = mysql_fetch_object($hResult);
view_app_comment($oComment_row); Comment::view_app_comment($oComment_row);
} }
/* display page selection links */ /* display page selection links */

View File

@@ -186,37 +186,16 @@ class Comment {
} }
return false; return false;
} }
}
/**
* class static functions
/*
* 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;
}
/** /**
* display a single comment (in $oRow) * display a single comment (in $oRow)
*/ */
function view_app_comment($oRow) function view_app_comment($oRow)
{ {
echo html_frame_start('','98%'); echo html_frame_start('','98%');
echo '<table width="100%" border="0" cellpadding="2" cellspacing="1">',"\n"; echo '<table width="100%" border="0" cellpadding="2" cellspacing="1">',"\n";
@@ -259,7 +238,6 @@ function view_app_comment($oRow)
echo html_frame_end(); echo html_frame_end();
} }
/** /**
* grab comments for appId / versionId * grab comments for appId / versionId
* if parentId is not -1 only comments for that thread are returned * if parentId is not -1 only comments for that thread are returned
@@ -284,7 +262,6 @@ function grab_comments($versionId, $parentId = -1)
return $hResult; return $hResult;
} }
/** /**
* display nested comments * display nested comments
* handle is a db result set * handle is a db result set
@@ -293,26 +270,23 @@ function do_display_comments_nested($hResult)
{ {
while($oRow = mysql_fetch_object($hResult)) while($oRow = mysql_fetch_object($hResult))
{ {
view_app_comment($oRow); Comment::view_app_comment($oRow);
$hResult2 = grab_comments($oRow->versionId, $oRow->commentId); $hResult2 = Comment::grab_comments($oRow->versionId, $oRow->commentId);
if($hResult && mysql_num_rows($hResult2)) if($hResult && mysql_num_rows($hResult2))
{ {
echo "<blockquote>\n"; echo "<blockquote>\n";
do_display_comments_nested($hResult2); Comment::do_display_comments_nested($hResult2);
echo "</blockquote>\n"; echo "</blockquote>\n";
} }
} }
} }
function display_comments_nested($versionId, $threadId) function display_comments_nested($versionId, $threadId)
{ {
$hResult = grab_comments($versionId, $threadId); $hResult = Comment::grab_comments($versionId, $threadId);
Comment::do_display_comments_nested($hResult);
do_display_comments_nested($hResult);
} }
/** /**
* display threaded comments * display threaded comments
* handle is a db result set * handle is a db result set
@@ -326,18 +300,18 @@ function do_display_comments_threaded($hResult, $is_main)
{ {
if ($is_main) if ($is_main)
{ {
view_app_comment($oRow); Comment::view_app_comment($oRow);
} else } else
{ {
echo '<li><a href="commentview.php?iAppId='.$oRow->appId.'&amp;iVersionId='.$oRow->versionId.'&iThreadId='.$oRow->parentId.'"> '. 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"; $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)) if ($hResult2 && mysql_num_rows($hResult2))
{ {
echo "<blockquote>\n"; echo "<blockquote>\n";
do_display_comments_threaded($hResult2, 0); Comment::do_display_comments_threaded($hResult2, 0);
echo "</blockquote>\n"; echo "</blockquote>\n";
} }
} }
@@ -346,34 +320,30 @@ function do_display_comments_threaded($hResult, $is_main)
echo "</ul>\n"; echo "</ul>\n";
} }
function display_comments_threaded($versionId, $threadId = 0) function display_comments_threaded($versionId, $threadId = 0)
{ {
$hResult = grab_comments($versionId, $threadId); $hResult = Comment::grab_comments($versionId, $threadId);
do_display_comments_threaded($hResult, 1); Comment::do_display_comments_threaded($hResult, 1);
} }
/** /**
* display flat comments * display flat comments
*/ */
function display_comments_flat($versionId) function display_comments_flat($versionId)
{ {
$hResult = grab_comments($versionId); $hResult = Comment::grab_comments($versionId);
if ($hResult) if ($hResult)
{ {
while($oRow = mysql_fetch_object($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 = array(); //array of filtered user input
$aClean['sCmode'] = makeSafe($_REQUEST['sCmode']); $aClean['sCmode'] = makeSafe($_REQUEST['sCmode']);
@@ -399,7 +369,7 @@ function view_app_comments($versionId, $threadId = 0)
$sel[$_SESSION['current']->getPref("comments:mode", "threaded")] = 'selected'; $sel[$_SESSION['current']->getPref("comments:mode", "threaded")] = 'selected';
echo '<td><form method="post" name="sMode" action="appview.php">',"\n"; echo '<td><form method="post" name="sMode" action="appview.php">',"\n";
echo "<b>Application Comments</b> $messageCount total comments "; 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="flat" '.$sel['flat'].'>Flat</option>',"\n";
echo ' <option value="threaded" '.$sel['threaded'].'>Threaded</option>',"\n"; echo ' <option value="threaded" '.$sel['threaded'].'>Threaded</option>',"\n";
echo ' <option value="nested" '.$sel['nested'].'>Nested</option>',"\n"; echo ' <option value="nested" '.$sel['nested'].'>Nested</option>',"\n";
@@ -440,16 +410,40 @@ function view_app_comments($versionId, $threadId = 0)
switch ($mode) switch ($mode)
{ {
case "flat": case "flat":
display_comments_flat($versionId); Comment::display_comments_flat($versionId);
break; break;
case "nested": case "nested":
display_comments_nested($versionId, $threadId); Comment::display_comments_nested($versionId, $threadId);
break; break;
case "threaded": case "threaded":
display_comments_threaded($versionId, $threadId); Comment::display_comments_threaded($versionId, $threadId);
break; break;
} }
echo '</td></tr></table>',"\n"; 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 // Comments Section
view_app_comments($this->iVersionId); Comment::view_app_comments($this->iVersionId);
} }
function lookup_name($versionId) function lookup_name($versionId)