forumhtml.class
来自「GForge 3.0 协作开发平台 支持CVS, mailing lists, 」· CLASS 代码 · 共 359 行
CLASS
359 行
<?php/** * GForge Forums Facility * * Copyright 2002 GForge, LLC * http://gforge.org/ * * @version $Id: ForumHTML.class,v 1.17 2003/02/16 04:07:50 rts Exp $ *//* Message Forums By Tim Perdue, Sourceforge, 11/99 Massive rewrite by Tim Perdue 7/2000 (nested/views/save) Complete OO rewrite by Tim Perdue 12/2002*/require_once('pre.php');require_once('www/news/news_utils.php');function forum_header($params) { global $DOCUMENT_ROOT,$HTML,$group_id,$forum_name,$forum_id,$sys_datefmt,$sys_news_group,$Language,$f; $params['group']=$group_id; $params['toptab']='forums'; /* bastardization for news Show icon bar unless it's a news forum */ if ($group_id == $sys_news_group) { //this is a news item, not a regular forum if ($forum_id) { /* Show this news item at the top of the page */ $sql="SELECT * FROM news_bytes WHERE forum_id='$forum_id'"; $result=db_query($sql); $params['group']=db_result($result,0,'group_id'); $params['toptab']='news'; $HTML->header($params); echo '<table><tr><td valign="top">'; if (!$result || db_numrows($result) < 1) { echo ' <h3>'.$Language->getText('forum_utils','nonewsitem').'</h3>'; } else { $user = user_get_object(db_result($result,0,'submitted_by')); echo ' <strong>'.$Language->getText('forum_utils','postedby').':</strong> '.$user->getRealName().'<br /> <strong>'.$Language->getText('forum_utils','date').':</strong> '. date($sys_datefmt,db_result($result,0,'date')).'<br /> <strong>'.$Language->getText('forum_utils','summary').':</strong> <a href="/forum/forum.php?forum_id='.db_result($result,0,'forum_id').'">'. db_result($result,0,'summary').'</a> <p> '. (util_make_links(nl2br(db_result($result,0,'details')))); echo '</p>'; } echo '</td><td valign="top" width="35%">'; echo $HTML->boxTop($Language->getText('forum_utils','latest')); echo news_show_latest($sys_news_group,5,false); echo $HTML->boxBottom(); echo '</td></tr></table>'; } else { site_project_header($params); } } else { site_project_header($params); } /* Show horizontal forum links */ if ($f && $forum_id) { echo '<h3>'.$Language->getText('forum_utils','discussionforum').' <a href="/forum/forum.php?forum_id='.$forum_id.'">'.$f->getName().'</a></h3>'; } echo '<p><strong>'; if (session_loggedin() ) { if ($f) { if ($f->isMonitoring()) { echo '<a href="/forum/monitor.php?forum_id='.$forum_id.'&group_id='.$group_id.'&stop=1">' . html_image('ic/xmail16w.png','20','20',array()).' '.$Language->getText('forum_utils','stopmonitor').'</a> | '; } else { echo '<a href="/forum/monitor.php?forum_id='.$forum_id.'&group_id='.$group_id.'&start=1">' . html_image('ic/mail16w.png','20','20',array()).' '.$Language->getText('forum_utils','monitor').'</a> | '; } echo '<a href="/forum/save.php?forum_id='.$forum_id.'&group_id='.$group_id.'">' . html_image('ic/save.png','24','24',array()) .' '.$Language->getText('forum_utils','saveplace').'</a> | '; } } if ($f && $forum_id) { echo '<a href="/forum/new.php?forum_id='.$forum_id.'&group_id='.$group_id.'">' . html_image('ic/write16w.png','20','20',array('alt'=>$Language->getText('forum_message','thread'))) .' '. $Language->getText('forum_message','thread').'</a> | '; } echo ' <a href="/forum/admin/?group_id='.$group_id.'">'.$Language->getText('forum_utils','admin').'</a></strong>'; echo '</p>';}function forum_footer($params) { site_project_footer($params);}/** Wrap many forum functions in this class**/class ForumHTML extends Error { /** * The Forum object. * * @var object $Forum */ var $Forum; function ForumHTML(&$Forum) { $this->Error(); if (!$Forum || !is_object($Forum)) { $this->setError('ForumMessage:: No Valid Forum Object'); return false; } if ($Forum->isError()) { $this->setError('ForumMessage:: '.$Forum->getErrorMessage()); return false; } $this->Forum =& $Forum; return true; } function showNestedMessage ( &$msg ) { /* accepts a database result handle to display a single message in the format appropriate for the nested messages */ global $sys_datefmt,$Language; /* See if this message is new or not If so, highlite it in bold */ if ($this->Forum->getSavedDate() < $msg->getPostDate()) { $bold_begin='<strong>'; $bold_end='</strong>'; } $ret_val = ' <table border="0"> <tr> <td bgcolor="#dddddd" nowrap="nowrap">'.$Language->getText('forum_utils','by').' <a href="/users/'. $msg->getPosterName() .'/">'. $msg->getPosterRealName() .'</a>'. '<br /><a href="/forum/message.php?msg_id='. $msg->getID() .'">'. html_image('ic/msg.png',"10","12",array("border"=>"0")) . $bold_begin. $msg->getSubject() .' [ '.$Language->getText('forum_utils','reply').' ]'. $bold_end .'</a> '. '<br />'. date($sys_datefmt,$msg->getPostDate()) .' </td> </tr> <tr> <td> '. util_make_links( nl2br( $msg->getBody() ) ) .' </td> </tr> </table>'; return $ret_val; } function showNestedMessages ( &$msg_arr, $msg_id ) { global $total_rows,$sys_datefmt; $rows=count($msg_arr["$msg_id"]); $ret_val=''; if ($msg_arr["$msg_id"] && $rows > 0) { $ret_val .= ' <ul><li style="list-style: none">'; /* iterate and show the messages in this result for each message, recurse to show any submessages */ for ($i=($rows-1); $i >= 0; $i--) { // increment the global total count $total_rows++; // show the actual nested message $ret_val .= $this->showNestedMessage ($msg_arr["$msg_id"][$i]).'<p />'; if ($msg_arr["$msg_id"][$i]->hasFollowups()) { // Call yourself if there are followups $ret_val .= $this->showNestedMessages ( $msg_arr,$msg_arr["$msg_id"][$i]->getID() ); } } $ret_val .= ' </li></ul>'; } else { //$ret_val .= "<p><strong>no messages actually follow up to $msg_id</strong>"; } return $ret_val; } function showSubmessages(&$msg_arr, $msg_id, $level) { /* Recursive. Selects this message's id in this thread, then checks if any messages are nested underneath it. If there are, it calls itself, incrementing $level $level is used for indentation of the threads. */ global $total_rows,$sys_datefmt,$forum_id,$current_message; $rows=count($msg_arr["$msg_id"]);//echo "<p>ShowSubmessages() $msg_id | $rows"; if ($rows > 0) { for ($i=($rows-1); $i >= 0; $i--) { /* Is this row's background shaded or not? */ $total_rows++; $ret_val .= ' <tr '. $GLOBALS['HTML']->boxGetAltRowStyle($total_rows) .'><td nowrap="nowrap">'; /* How far should it indent? */ for ($i2=0; $i2<$level; $i2++) { $ret_val .= ' '; } /* If it this is the message being displayed, don't show a link to it */ if ($current_message != $msg_arr["$msg_id"][$i]->getID()) { $ah_begin='<a href="/forum/message.php?msg_id='. $msg_arr["$msg_id"][$i]->getID() .'">'; $ah_end='</a>'; } else { $ah_begin=''; $ah_end=''; } $ret_val .= $ah_begin . html_image('ic/msg.png',"10","12",array("border"=>"0")); /* See if this message is new or not */ if ($this->Forum->getSavedDate() < $msg_arr["$msg_id"][$i]->getPostDate()) { $bold_begin='<strong>'; $bold_end='</strong>'; } else { $bold_begin=''; $bold_end=''; } $ret_val .= $bold_begin.$msg_arr["$msg_id"][$i]->getSubject() .$bold_end.$ah_end.'</td>'. '<td>'. $msg_arr["$msg_id"][$i]->getPosterRealName() .'</td>'. '<td>'.date($sys_datefmt, $msg_arr["$msg_id"][$i]->getPostDate() ).'</td></tr>'; if ($msg_arr["$msg_id"][$i]->hasFollowups() > 0) { /* Call yourself, incrementing the level */ $ret_val .= $this->showSubmessages($msg_arr,$msg_arr["$msg_id"][$i]->getID(),($level+1)); } } } return $ret_val; } function showPostForm($thread_id=0, $is_followup_to=0, $subject="") { global $REQUEST_URI,$Language; if (session_loggedin() || $this->Forum->allowAnonymous()) { if ($subject) { //if this is a followup, put a RE: before it if needed if (!eregi('RE:',$subject,$test)) { $subject ='RE: '.$subject; } } ?> <div align="center"> <form action="/forum/forum.php?forum_id=<?php echo $this->Forum->getID(); ?>" method="post"> <input type="hidden" name="post_message" value="y" /> <input type="hidden" name="thread_id" value="<?php echo $thread_id; ?>" /> <input type="hidden" name="msg_id" value="<?php echo $is_followup_to; ?>" /> <input type="hidden" name="is_followup_to" value="<?php echo $is_followup_to; ?>" /> <table> <tr> <td><strong><?php echo $Language->getText('forum_utils','subject'); ?></strong><?php echo utils_requiredField(); ?><br /> <input type="text" name="subject" value="<?php echo $subject; ?>" size="45" maxlength="45" /> </td></tr> <tr><td><strong><?php echo $Language->getText('forum_utils','message'); ?></strong><?php echo utils_requiredField(); ?><br /> <textarea name="body" rows="10" cols="50"></textarea> </td></tr> <tr><td align="center"> <strong><font color="red"><?php echo $Language->getText('forum_utils','htmltag'); ?></font></strong> <p> <?php if (!session_loggedin()) { echo '<strong><font color="red">'.$Language->getText('forum_utils','postanon').' <a href="/account/login.php?return_to='. urlencode($REQUEST_URI) .'">['.$Language->getText('forum_utils','loggedin').']</a></font></strong>'; } ?> <br /> <input type="submit" name="submit" value="<?php echo $Language->getText('forum_utils','postcomment'); echo ((!session_loggedin())?' '.$Language->getText('forum_utils','anonymously'):''); ?>" /><?php echo ((session_loggedin()) ? ' <input type="checkbox" value="1" name="monitor" /> '.$Language->getText('forum_message','receive_followups').'.' : ''); ?> </p> </td></tr></table> </form> </div> <?php } else { echo "<div align=\"center\">"; echo '<h3><font color="red">'; echo $Language->getText('forum_utils','couldpostif',array('<a href="/account/login.php?return_to='.urlencode($REQUEST_URI).' ">','</a>')); echo '</font></h3>'; echo "</div>"; } }}/* $messagelink='http://'.$GLOBALS[sys_default_domain].'/forum/message.php?msg_id='.$msg_id; $messagesender=db_result($result,0, 'user_name'); $messagebody=util_line_wrap(util_unconvert_htmlspecialchars(db_result($result,0, 'body'))); $messagesys=$GLOBALS['sys_name']; $messagemonitor='http://'.$GLOBALS[sys_default_domain].'/forum/monitor.php?forum_id='.$forum_id; $body = stripcslashes($Language->getText('forum_utils', 'mailmonitor', array($messagelink, $messagesender, $messagebody, $messagesys, $messagemonitor))); /* $body = "\nRead and respond to this message at: ". "\nhttp://$GLOBALS[sys_default_domain]/forum/message.php?msg_id=".$msg_id. "\nBy: " . db_result($result,0, 'user_name') . "\n\n" . util_line_wrap(util_unconvert_htmlspecialchars(db_result($result,0, 'body'))). "\n\n______________________________________________________________________". "\nYou are receiving this email because you elected to monitor this forum.". "\nTo stop monitoring this forum, login to ".$GLOBALS['sys_name']." and visit: ". "\nhttp://$GLOBALS[sys_default_domain]/forum/monitor.php?forum_id=$forum_id"; * / $subject="[" .db_result($result,0,'unix_group_name'). " - " . db_result($result,0,'forum_name')."] ".util_unconvert_htmlspecialchars(db_result($result,0,'subject')); util_handle_message(array_unique($tolist),$subject,$body,$send_all_posts_to);*/?>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?