title, ENT_QUOTES, "UTF-8") . "\"\n");
fwrite($fp, " description=\"" .
htmlspecialchars($this->description, ENT_QUOTES, "UTF-8") . "\"\n");
fwrite($fp, " image=\"" . $this->image . "\">\n");
fwrite($fp, " type=\"" . $this->type . "\"\n");
fwrite($fp, " paypalkey=\"" . $this->paypalkey . "\">\n");
fwrite($fp, " \n");
*/
}
public function show()
{
$str = "";
$str .= " url . "\">\n";
$str .= " ". $this->title . "\n";
$str .= " \n";
return $str;
}
public function DownloadSource($id, $title, $url)
{
$this->id = $id;
$this->title = $title;
$this->url = $url;
}
}
class DownloadItem {
public $id;
public $title;
public $description;
public $type;
public $value;
public $sources = array();
public function write($fp)
{
/*
fwrite($fp, " title, ENT_QUOTES, "UTF-8") . "\"\n");
fwrite($fp, " description=\"" .
htmlspecialchars($this->description, ENT_QUOTES, "UTF-8") . "\"\n");
fwrite($fp, " image=\"" . $this->image . "\">\n");
fwrite($fp, " type=\"" . $this->type . "\"\n");
fwrite($fp, " paypalkey=\"" . $this->paypalkey . "\">\n");
fwrite($fp, " \n");
*/
}
public function show()
{
global $VIDEO_WIDTH;
global $VIDEO_HEIGHT;
$VIDEO_WIDTH = 530;
$VIDEO_HEIGHT = 400;
$str = "";
$str .= "
\n";
return $str;
}
public function addSource($source)
{
$key = $source->id;
$this->sources[$key] = $source;
}
public function DownloadItem($id, $title, $description, $type, $value)
{
$this->id = $id;
$this->title = $title;
$this->description = $description;
$this->type = $type;
$this->value = $value;
}
}
class DownloadGroup {
public $id;
public $title;
public $items = array();
public function write($fp)
{
/*
fwrite($fp, " title, ENT_QUOTES, "UTF-8") . "\"\n");
fwrite($fp, " description=\"" .
htmlspecialchars($this->description, ENT_QUOTES, "UTF-8") . "\"\n");
fwrite($fp, " image=\"" . $this->image . "\">\n");
fwrite($fp, " type=\"" . $this->type . "\"\n");
fwrite($fp, " paypalkey=\"" . $this->paypalkey . "\">\n");
fwrite($fp, " \n");
*/
}
public function show()
{
$str = "";
$str .= " \n";
$str .= "
".$this->title."\n";
$str .= "
\n";
if($this->items) {
foreach($this->items as $i) {
$str .= $i->show();
}
}
$str .= "
\n";
$str .= "
\n";
return $str;
}
public function addItem($item)
{
$key = $item->id;
$this->items[$key] = $item;
}
public function DownloadGroup($id, $title)
{
$this->id = $id;
$this->title = $title;
$this->url = $url;
}
}
class Downloads {
private $file;
private $groups = array();
// Admin config
public $admin_title = "Downloads";
public $admin_submodules = array("Add Item" => "add",
"Edit Item" => "edit",
"Delete Item" => "delete");
public function admin($sub, $action, $vars)
{
switch($sub) {
case "add":
break;
case "edit":
break;
case "delete":
break;
}
}
public function run($params)
{
global $GLOBALS;
$str = "\n";
//foreach($params as $param => $value) {}
if($this->groups) {
foreach($this->groups as $group) {
$str .= $group->show();
}
}
$str .= "
\n";
return $str;
}
public function add($group) {
$key = $group->id;
$this->groups[$key] = $group;
}
public function write()
{
/*
$fp = fopen($this->file, "w");
fwrite($fp, "\n");
fwrite($fp, "\n");
foreach($this->discs as $disc) {
$disc->write($fp);
}
fwrite($fp, "\n");
fclose($fp);
*/
}
private function read()
{
$dom = new DomDocument;
$dom->preserveWhiteSpace = FALSE;
$dom->load($this->file);
$groups = $dom->getElementsByTagName('group');
if($groups) {
foreach($groups as $g) {
$group = new DownloadGroup($g->getAttribute('id'),
$g->getAttribute('title'));
$items = $g->getElementsByTagName('item');
if($items) {
foreach($items as $i) {
$item = new DownloadItem($i->getAttribute('id'),
$i->getAttribute('title'),
$i->getAttribute('description'),
$i->getAttribute('type'),
$i->getAttribute('value'));
$sources = $i->getElementsByTagName('source');
if($sources) {
foreach($sources as $s) {
$source = new DownloadSource($s->getAttribute('id'),
$s->getAttribute('title'),
$s->getAttribute('url'));
$item->addSource($source);
}
}
ksort($item->sources);
$group->addItem($item);
}
}
ksort($group->items);
$this->add($group);
}
}
ksort($this->groups);
}
public function Downloads($file)
{
$this->file = $file;
if(file_exists($file)) $this->read();
}
}
function downloads_init()
{
global $DATA_DIR;
return new Downloads($DATA_DIR . "/downloads.xml");
}
?>