PHP forum posts, books knowledge can not understand AH rely on ~, please help me,
Functions for loading, contructing and
Displaying the tree is in this file
Class TreeNode
{
Each node in the tree has member variables containing
All the data for a post except the body of the message
Public $m _postid;
Public $m _title;
Public $m _poster;
Public $m _posted;
Public $m _children;
Public $m _childlist;
Public $m _depth;
Public function __construct ($postid, $title, $poster, $posted, $children,
$expand, $depth, $expanded, $sublist)
{
The constructor sets up the member variables, and more
Importantly recursively creates lower parts of the tree
$this->m_postid = $postid;
$this->m_title = $title;
$this->m_poster = $poster;
$this->m_posted = $posted;
$this->m_children = $children;
$this->m_childlist = Array ();
$this->m_depth = $depth;
We are below this node if it
Has children and was marked to be expanded
Sublists is always expanded
if ($sublist | | $expand) && $children)
{
$conn = Db_connect ();
$query = "SELECT * from header where parent = $postid ORDER by posted";
$result = $conn->query ($query);
for ($count =0; $row = @ $result->fetch_assoc (); $count + +)
{
if ($sublist | | $expanded [$row [' PostID ']] = = true)
$expand = true;
Else
$expand = false;
$this->m_childlist[$count]= New TreeNode ($row [' PostID '], $row [' title '],
$row [' poster '], $row [' posted '],
$row [' Children '], $expand,
$depth +1, $expanded, $sublist);
}
}
}
function display ($row, $sublist = False)
{
As is a object, it is responsible for displaying itself
$row tells us what row of the display we is 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 has
$sublist = True.
On a sublist, all messages is 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 '";
Else
echo "' #ffffff ' >";
Indent replies to the depth of nesting