title = $title;
$this->href = $href;
$this->icon = $icon;
}
public function show()
{
echo "
\n";
}
}
class LinkGroup {
public $title;
public $id;
private $links = array();
public function LinkGroup($title, $id) {
$this->title = $title;
$this->id = $id;
}
public function add($link) {
$key = $link->title;
$this->links[$key] = $link;
}
public function show()
{
echo "\n";
echo "
". htmlspecialchars_decode($this->title, ENT_QUOTES) . "
\n";
foreach($this->links as $link) {
$link->show();
}
echo "
\n";
}
}
class Links {
private $file;
private $groups = array();
public function add($group) {
$key = $group->title;
$this->groups[$key] = $group;
}
/*
public function write()
{
$fp = fopen($this->file, "w");
fwrite($fp, "\n");
fwrite($fp, "\n");
foreach($this->links as $link) {
fwrite($fp, " title, ENT_QUOTES, "UTF-8") . "\"\n");
fwrite($fp, " href=\"" .
htmlspecialchars($link->href, ENT_QUOTES, "UTF-8") . "\">\n");
fwrite($fp, " icon=\"" .
htmlspecialchars($link->icon, ENT_QUOTES, "UTF-8") . "\">\n");
fwrite($fp, " \n");
}
fwrite($fp, " \n");
fclose($fp);
}
*/
public function show($groupid)
{
foreach($this->groups as $group) {
if($groupid == $group->id || $groupid == "all") $group->show();
}
}
private function read()
{
$dom = new DomDocument;
$dom->preserveWhiteSpace = FALSE;
$dom->load($this->file);
$xmlgroups = $dom->getElementsByTagName('group');
foreach ($xmlgroups as $xmlgroup) {
$group = new LinkGroup($xmlgroup->getAttribute('name'),
$xmlgroup->getAttribute('id'));
$xmllinks = $xmlgroup->getElementsByTagName('link');
foreach ($xmllinks as $xmllink) {
$link = new Link($xmllink->getAttribute('title'),
$xmllink->getAttribute('href'),
$xmllink->getAttribute('icon'));
$group->add($link);
}
$this->add($group);
}
// Key sort
// ksort($this->events);
}
public function Links($file)
{
$this->file = $file;
$this->read();
}
}
?>