function display($row, $sublist = false) { // as this is an object, it is responsible for displaying itself // $row tells us what row of the display we are up to // so we know what color it should be // $sublist tells us whether we are on the main page // or the message page. Message pages should have // $sublist = true. // On a sublist, all messages are expanded and there are // no "+" or "-" symbols. // if this is the empty root node skip displaying if ($this->m_depth > -1) { //color alternate rows echo '<tr><td bgcolor = '; if ($row % 2) { echo "'#cccccc'>"; } else { echo "'#ffffff'>"; } // indent replies to the depth of nesting for ($i = 0; $i < $this->m_depth; $i++) { echo "<img src = 'images/spacer.gif' height = 22\n width = 22 alt = '' valign = 'bottom' />"; } // display + or - or a spacer if (!$sublist && $this->m_children && sizeof($this->m_childlist)) { // we are expanded - offer button to collapse echo "<a href = 'index.php?collapse=" . $this->m_postid . "#{$this->m_postid}'\n ><img src = 'images/minus.gif' valign = 'bottom' \n height = 22 width = 22 alt = 'Collapse Thread' border = 0 /></a>"; } else { if (!$sublist && $this->m_children) { // we are collapsed - offer button to expand echo "<a href = 'index.php?expand=" . $this->m_postid . "#{$this->m_postid}'><img src = 'images/plus.gif' \n height = 22 width = 22 alt = 'Expand Thread' border = 0></a>"; } else { // we have no children, or are in a sublist, do not give button echo "<img src = 'images/spacer.gif' height = 22 width = 22 \n alt = '' valign = 'bottom' />"; } } echo " <a name = {$this->m_postid} ><a href = \n 'view_post.php?postid={$this->m_postid}'>{$this->m_title} - \n {$this->m_poster} - " . reformat_date($this->m_posted) . '</a>'; echo '</td></tr>'; // increment row counter to alternate colors $row++; } // call display on each of this node's children // note a node will only have children in its list if expanded $num_children = sizeof($this->m_childlist); for ($i = 0; $i < $num_children; $i++) { $row = $this->m_childlist[$i]->display($row, $sublist); } return $row; }
function display($row, $sublist = false) { // as this is an object, it is responsible for displaying itself // $row tells us what row of the display we are up to // so we know what color it should be // $sublist tells us whether we are on the main page // or the message page. Message pages should have // $sublist = true. // On a sublist, all messages are expanded and there are // no "+" or "-" symbols. // if this is the empty root node skip displaying if ($this->m_depth > -1) { //color alternate rows echo "<tr><td bgcolor=\""; if ($row % 2) { echo "#cccccc\">"; } else { echo "#ffffff\">"; } // indent replies to the depth of nesting for ($i = 0; $i < $this->m_depth; $i++) { echo "<img src=\"images/spacer.gif\" height=\"22\"\n width=\"22\" alt=\"\" valign=\"bottom\" />"; } // display + or - or a spacer if (!$sublist && $this->m_children && sizeof($this->m_childlist)) { // we're on the main page, have some children, and they're expanded // we are expanded - offer button to collapse echo "<a href=\"index.php?collapse=" . $this->m_postid . "#" . $this->m_postid . "\"><img\n src=\"images/minus.gif\" valign=\"bottom\" height=\"22\"\n width=\"22\" alt=\"Collapse Thread\" border=\"0\" /></a>\n"; } else { if (!$sublist && $this->m_children) { // we are collapsed - offer button to expand echo "<a href=\"index.php?expand=" . $this->m_postid . "#" . $this->m_postid . "\"><img\n src=\"images/plus.gif\" valign=\"bottom\" height=\"22\"\n width=\"22\" alt=\"Expand Thread\" border=\"0\" /></a>\n"; } else { // we have no children, or are in a sublist, do not give button echo "<img src=\"images/spacer.gif\" height=\"22\" width=\"22\"\n alt=\"\" valign=\"bottom\"/>\n"; } } echo "<a name=\"" . $this->m_postid . "\"><a href=\n \"view_post.php?postid=" . $this->m_postid . "\">" . $this->m_title . " - " . $this->m_poster . " - " . reformat_date($this->m_posted) . "</a></td></tr>"; // increment row counter to alternate colors $row++; } // call display on each of this node's children // note a node will only have children in its list if expanded $num_children = sizeof($this->m_childlist); for ($i = 0; $i < $num_children; $i++) { $row = $this->m_childlist[$i]->display($row, $sublist); } return $row; }
function display($courseid, $user, $row, $sublist = false) { // as this is an object, it is responsible for displaying itself // $row tells us what row of the display we are up to // so we know what color it should be // $sublist tells us whether we are on the main page // or the message page. Message pages should have // $sublist = true. // On a sublist, all messages are expanded and there are // no "+" or "-" symbols. // if this is the empty root node skip displaying if ($this->m_depth > -1) { //color alternate rows echo "<tr><td bgcolor=\""; if ($row % 2) { echo "#cccccc\">"; } else { echo "#ffffff\">"; } // indent replies to the depth of nesting // for($i = 0; $i < $this->m_depth; $i++) { // echo "<img src=\"images/spacer.gif\" height=\"22\" // width=\"22\" alt=\"\" valign=\"bottom\" />"; // } if (!$sublist && $this->m_children && sizeof($this->m_childlist)) { // we are expanded - offer button to collapse echo "<a href=\"forum.php?collapse=" . $this->m_postid . "#" . $this->m_postid . "\"><img\n src=\"./images/minus.png\" valign=\"bottom\" height=\"22\"\n width=\"22\" alt=\"Collapse Thread\" border=\"0\" /></a>\n"; } else { if (!$sublist && $this->m_children) { // we are collapsed - offer button to expand echo "<a href=\"forum.php?expand=" . $this->m_postid . "#" . $this->m_postid . "\"><img\n src=\"./images/plus.png\" valign=\"bottom\" height=\"22\"\n width=\"22\" alt=\"Expand Thread\" border=\"0\" /></a>\n"; } } // display + or - or a spacer $post = get_post($this->m_postid); $post_parent = $post['postid']; $_SESSION['parent'] = $post_parent; // echo $_SESSION['parent']; // echo "$this->m_postid"; // echo "$post_parent"; ?> <script> function $(el) {return document.getElementById(el)}; function response(obj,post_parent) { var v_user = '******'valid_user']; ?> '; if(!v_user){ alert("请先登录"); return false; } else{ var oComment = obj.parentNode; var txt = obj.innerHTML; // var i = <?php echo $post_parent; ?> ; // document.write(i); var h_parent = $("parent"); h_parent.value = post_parent; if (txt == '回复') { $("response").style.display = "inline"; } else { $("response").style.display = "none"; } // oComment.appendChild($("response")); oComment.appendChild($("form")); return true; } } </script> <table cellpadding="0" cellspacing="0" border="0" width="100%" style="font-family:'微软雅黑';font-size:15px;"> <tr> <td align="left"> <?php for ($i = -1; $i < $this->m_depth; $i++) { ?> <?php } ?> <?php // display + or - or a spacer $conn = db_connect(); $muser = $this->m_poster; $query = "select m_identity from t_user where m_user='******'"; $result = $conn->query($query); if (!$result) { return false; } if ($result->num_rows > 0) { $this_row = $result->fetch_array(); // echo $this_row[0]; } if ("1" == $this_row[0]) { echo "老师:"; } else { echo "学生:"; } echo $this->m_poster; ?> </td> <td align="right"> <?php echo reformat_date($this->m_posted); ?> </td> </tr> <tr> <td colspan="2"> <?php for ($i = -1; $i < $this->m_depth; $i++) { ?> <?php } ?> <?php echo nl2br($post['message']); ?> </td> </tr> <tr> <td colspan="2" style="text-align:right"> <div onclick="response(this,<?php echo $post_parent; ?> );" style="color:blue;cursor:pointer;">回复</div> </td> </tr> </tr> </table> <?php // increment row counter to alternate colors // $row++; } // call display on each of this node's children // note a node will only have children in its list if expanded $num_children = sizeof($this->m_childlist); for ($i = 0; $i < $num_children; $i++) { $row = $this->m_childlist[$i]->display($chapterid, $user, $row, $sublist); } return $row; }