function CheckCid()
{
global $DB;
if (!$cid = $this->GetWebCid())
{
return false;
}
$table = $this->GetClassTable();
$query = "Select
id
From
" . PRE . $table . "
Where id = " . $cid;
if ($cid = $DB->getOne($query))
{
return $cid;
}
return false;
} function GetRealCid()
{
if ($id = $this->CheckId())
{
global $DB;
$class_id_name = $this->GetClassIdName();
$table = $this->GetTable();
$query = "Select
" . $class_id_name . "
From
" . PRE . $table . "
Where id = $id";
return $DB->getOne($query);
}
else
{
return $this->CheckCid();
}
} function GetClassTitle()
{
global $DB;
if (!$open_cid = $this->GetRealCid())
{
return false;
}
$query = "Select
level
From
" . PRE .$this->GetClassTable() . "
Where id = " . $open_cid;
$level = $DB->getOne($query);
$cid = explode(",", $level);
$id_num = count($cid);
for ($i = 0; $i < $id_num; $i++)
{
$query = "Select
id, classname
From
" . PRE .$this->GetClassTable() . "
Where id = " . $cid[$i];
$title_array[$i] = $DB->getRow($query);
}
return $title_array;
} function GetMemberTitle()
{
global $DB;
if (!$open_id = $this->CheckId())
{
return false;
}
$title = $this->GetTitleName();
$table = $this->GetTable();
$query = "Select
id, $title
From
" . PRE . $table . "
Where id = $open_id";
return $member = $DB->getRow($query);
} function WebTitleArray()
{
$class_title = $this->GetClassTitle();
$member_title = $this->GetMemberTitle();
if (!empty($class_title) && !empty($member_title))
{
$member_title = array($member_title);
return array_merge($class_title, $member_title);
}
elseif (!empty($class_title))
{
return $class_title;
}
return false;
} function GetTextTitle($front = "y", $link = " - ")
{
$title = isset($title) ? $title : "";
if (!$web_title_array = $this->WebTitleArray())
{
return false;
}
$num = count($web_title_array);
for ($i = 0; $i < $num; $i++)
{
if ($i == 0 && $front != "y")
{
$title = $web_title_array[$i][1];
}
else
{
$title .= $link . $web_title_array[$i][1];
}
}
return $title;
}
function GetLinkTitle($front = "y", $link = " <span style=\"color: #000000;\">»</span> ")
{
$title = isset($title) ? $title : "";
if (!$class_title_array = $this->GetClassTitle())
{
return false;
}
$class_num = count($class_title_array);
for ($i = 0; $i < $class_num; $i++)
{
if ($i == 0 && $front != "y")
{
$title = "<a href=\"" . MAIN_PAGE . "?" . $this->page . "=" . $this->GetWebPage() . "&cid=" . $class_title_array[$i][0] . "\">" . $class_title_array[$i][1] . "</a>";
}
else
{
$title .= $link . "<a href=\"" . MAIN_PAGE . "?" . $this->page . "=" . $this->GetWebPage() . "&cid=" . $class_title_array[$i][0] . "\">" . $class_title_array[$i][1] . "</a>";
}
}
if (!$member_title = $this->GetMemberTitle())
{
return $title;
}
else
{
return $title .= $link . "<a href=\"" . MAIN_PAGE . "?" . $this->page . "=" . $this->GetWebPage() . "&id=" . $member_title[0] . "\">" . $member_title[1] . "</a>";
}
}
}
好处感觉是不用再判断无效ID了,不过目前应用来看还有些不够,多指点
我一般都是全部写完了再添加注释,不好的习惯=_+