From 42c62cb041a2b2b95c9cda0c20fcf70334fd244c Mon Sep 17 00:00:00 2001 From: deva Date: Tue, 1 Nov 2011 09:32:21 +0000 Subject: Rewl og krat... needs cleaning up - after port to GIT. --- utils/modules/discography.php | 480 +++++++++++++++++++++++++----------------- 1 file changed, 284 insertions(+), 196 deletions(-) (limited to 'utils/modules/discography.php') diff --git a/utils/modules/discography.php b/utils/modules/discography.php index 3bbce99..d390a3b 100644 --- a/utils/modules/discography.php +++ b/utils/modules/discography.php @@ -1,92 +1,100 @@ -

".$head."

\n"; - $str .= str_replace("\n", "
\n", $tail); - return $str; + $str = ""; + $head = substr($in, 0, strpos($in, "\n")); + $tail = substr($in, strpos($in, "\n")+1); + $str .= "

". + "
".$head."

\n"; + $str .= str_replace("\n", "
\n", $tail); + return $str; } class Track { - public $title; - public $number; - public $playtime; - public $previewurl; - public $lyrics; - - public function write($fp) - { - fwrite($fp, " title, ENT_QUOTES, "UTF-8") . "\"\n"); - fwrite($fp, " number=\"" . $this->number . "\"\n"); - fwrite($fp, " playtime=\"" . $this->playtime . "\"\n"); - fwrite($fp, " previewurl=\"" . $this->previewurl . "\">\n"); - fwrite($fp, " ".htmlspecialchars($this->lyrics, ENT_QUOTES, "UTF-8")."\n"); - fwrite($fp, " \n"); - } + public $title; + public $number; + public $playtime; + public $previewurl; + public $lyrics; - public function showLyrics() - { - $str = ""; - if($this->lyrics) { - $str .= createNewlines(htmlspecialchars_decode($this->lyrics)); - } - return $str; - } + public function write($fp) + { + fwrite($fp, " title, ENT_QUOTES, "UTF-8") . "\"\n"); + fwrite($fp, " number=\"" . $this->number . "\"\n"); + fwrite($fp, " playtime=\"" . $this->playtime . "\"\n"); + fwrite($fp, " previewurl=\"" . $this->previewurl . "\">\n"); + fwrite($fp, " ". + htmlspecialchars($this->lyrics, ENT_QUOTES, "UTF-8")."\n"); + fwrite($fp, " \n"); + } - public function show($disc) - { - global $GLOBALS; - - $page = $GLOBALS["page"]; - $str = ""; - $str .= "
\n"; - - $str .= " \n"; - if($this->previewurl) { - $str .= " \n"; - $str .= " \n"; - $str .= " previewurl."&showslider=0&width=25&height=12&skin=design/mors/chicken.jpg\"/>\n"; - $str .= " \n"; - } else { - } - $str .= " \n"; - - $str .= " ".$this->number.". \n"; - $str .= " ".$this->title."\n"; - $str .= " ".time2str($this->playtime)."\n"; - if($this->lyrics) { - $str .= " number."\">Lyrics\n"; - } - $str .= "
\n"; - - return $str; - } + public function showLyrics() + { + $str = ""; + if($this->lyrics) { + $str .= createNewlines(htmlspecialchars_decode($this->lyrics)); + } + return $str; + } - public function Track($title, $number, $playtime, $previewurl, $lyrics) - { - $this->title = $title; - $this->number = $number; - $this->playtime = $playtime; - $this->previewurl = $previewurl; - $this->lyrics = $lyrics; - } + public function show($disc) + { + global $GLOBALS; + + $page = $GLOBALS["page"]; + $str = ""; + $str .= "
\n"; + + $str .= " \n"; + if($this->previewurl) { + $str .= " \n"; + $str .= " \n"; + $str .= " previewurl."&showslider=0&width=25&height=12&". + "skin=design/rotr/chicken.jpg\"/>\n"; + $str .= " \n"; + } else { + } + $str .= " \n"; + + $str .= " ".$this->number.". \n"; + $str .= " ".$this->title."\n"; + $str .= " ".time2str($this->playtime). + "\n"; + if($this->lyrics) { + $str .= " Lyrics\n"; + } + $str .= "
\n"; + + return $str; + } + + public function Track($title, $number, $playtime, $previewurl, $lyrics) + { + $this->title = $title; + $this->number = $number; + $this->playtime = $playtime; + $this->previewurl = $previewurl; + $this->lyrics = $lyrics; + } } class Disc { @@ -94,88 +102,137 @@ class Disc { public $releasetime; public $description; public $cover; - public $releaser; - public $tracks = array(); - - public function write($fp) - { - fwrite($fp, " title, ENT_QUOTES, "UTF-8") . "\"\n"); - fwrite($fp, " releasetime=\"" . $this->releasetime . "\"\n"); - fwrite($fp, " description=\"" . - htmlspecialchars($this->description, ENT_QUOTES, "UTF-8") . "\"\n"); - fwrite($fp, " cover=\"" . $this->cover . "\"\n"); - fwrite($fp, " releaser=\"" . $this->releaser . "\">\n"); - fwrite($fp, " \n"); - if($this->tracks) { - foreach($this->tracks as $track) { - $track->write($fp); - } - } - fwrite($fp, " \n"); - fwrite($fp, " \n"); - } + public $releaser; + public $tracks = array(); + // public $reviews = array(); + public $refs; - public function showLyrics($number) - { - $str = ""; - if($this->tracks) { - foreach($this->tracks as $track) { - if($track->number == $number) { - $str .= $track->showLyrics(); - break; - } - } - } - return $str; + public function write($fp) + { + fwrite($fp, " title, ENT_QUOTES, "UTF-8") . "\"\n"); + fwrite($fp, " releasetime=\"" . $this->releasetime . "\"\n"); + fwrite($fp, " description=\"" . + htmlspecialchars($this->description, ENT_QUOTES, "UTF-8") . "\"\n"); + fwrite($fp, " cover=\"" . $this->cover . "\"\n"); + fwrite($fp, " releaser=\"" . $this->releaser . "\">\n"); + fwrite($fp, " \n"); + if($this->tracks) { + foreach($this->tracks as $track) { + $track->write($fp); + } + } + fwrite($fp, " \n"); + if($this->refs) $this->refs->write($fp, " "); + fwrite($fp, " \n"); + } + + public function showLyrics($number) + { + $str = ""; + if($this->tracks) { + foreach($this->tracks as $track) { + if($track->number == $number) { + $str .= $track->showLyrics(); + break; } + } + } + return $str; + } - public function show() - { - $str = ""; - - $str .= "
\n"; - $str .= " ".$this->title." (".date("Y", $this->releasetime).")\n"; - $str .= " \n"; - $str .= " "; - if($this->releasetime > time()) $str .= "To be"; - else $str .= "Was"; - $str .= " released by ".htmlspecialchars_decode($this->releaser)." on ".date("F jS Y", $this->releasetime)."\n"; - $str .= " "; - if($this->tracks && sizeof($this->tracks) > 1) { - $str .= "Tracks:"; - } else { - $str .= "Track:"; - } - $str .= "\n"; - $str .= "
\n"; - $total = 0; - if($this->tracks) { - foreach($this->tracks as $track) { + public function show() + { + $str = ""; + + $str .= "
\n"; + $str .= " ".$this->title." (". + date("Y", $this->releasetime).")\n"; + $str .= " \n"; + $str .= " "; + if($this->releasetime > time()) $str .= "To be"; + else $str .= "Was"; + $str .= " released by ".htmlspecialchars_decode($this->releaser)." on ". + date("F jS Y", $this->releasetime)."\n"; + $str .= " "; + if($this->tracks && sizeof($this->tracks) > 1) { + $str .= "Tracks:"; + } else { + $str .= "Track:"; + } + $str .= "\n"; + $str .= "
\n"; + $total = 0; + if($this->tracks) { + foreach($this->tracks as $track) { $str .= $track->show($this->releasetime); $total += $track->playtime; - } - } - if($this->tracks && sizeof($this->tracks) > 1) { - $str .= " Total playtime: ".time2str($total)."\n"; - } - $str .= "
\n"; - $str .= " ".Markdown(htmlspecialchars_decode($this->description))."\n"; - $str .= "
\n"; - - return $str; + } + } + if($this->tracks && sizeof($this->tracks) > 1) { + $str .= " Total playtime: ". + time2str($total)."\n"; + } + $str .= "
\n"; + $str .= " ". + Markdown(htmlspecialchars_decode($this->description))."\n"; + + if($this->refs) $str .= $this->refs->show(); + + $str .= "
\n"; + + return $str; + } + + public function showCompact() + { + $str = ""; + + $str .= "
\n"; + /* + $str .= " ".$this->title." (". + date("Y", $this->releasetime).")\n"; + */ + $str .= " \n"; + $str .= " "; + if($this->releasetime > time()) $str .= "Coming ".date("F jS Y", $this->releasetime); + else $str .= "Out now!"; + $str .= "\n"; + $str .= "
\n"; + $str .= "\n"; + + return $str; } - public function addTrack($track) - { - $key = $track->number; - $this->tracks[$key] = $track; - } + public function addTrack($track) + { + $key = $track->number; + $this->tracks[$key] = $track; + } + /* + public function addReview($review) + { + $key = $review->id; + $this->reviews[$key] = $review; + } + */ + + public function addRefs($refs) + { + $this->refs = $refs; + } public function Disc($title, $releasetime, $description, $cover, $releaser) { @@ -195,8 +252,8 @@ class Discography { // Admin config public $admin_title = "Discography"; public $admin_submodules = array("Add Disc" => "add", - "Edit Disc" => "edit", - "Delete Disc" => "delete"); + "Edit Disc" => "edit", + "Delete Disc" => "delete"); public function admin($sub, $action, $vars) { switch($sub) { @@ -211,36 +268,55 @@ class Discography { public function run($params) { - global $GLOBALS; + global $GLOBALS; - $str = "
\n"; + $str = "
\n"; - $lyrics = $GLOBALS["lyrics"]; - $number = $GLOBALS["track"]; + foreach($params as $param => $value) { + switch($param) { + case "latest": + $id = -1; + foreach($this->discs as $disc) { + if($disc->releasetime > $id) $id = $disc->releasetime; + } + if($id != -1) { + $disc = $this->discs[$id]; + return $str .= $disc->showCompact(); + } + break; + + default: + $lyrics = $GLOBALS["lyrics"]; + $number = $GLOBALS["track"]; + + //foreach($params as $param => $value) {} + + if($lyrics && $number) { + if($this->discs) { + foreach($this->discs as $disc) { + if($disc->releasetime == $lyrics) { + $str .= $disc->showLyrics($number); + break; + } + } + } + } else { + if($this->discs) { + foreach($this->discs as $disc) { + $str .= $disc->show(); + } + } + } - //foreach($params as $param => $value) {} + break; + } + } - if($lyrics && $number) { - if($this->discs) { - foreach($this->discs as $disc) { - if($disc->releasetime == $lyrics) { - $str .= $disc->showLyrics($number); - break; - } - } - } - } else { - if($this->discs) { - foreach($this->discs as $disc) { - $str .= $disc->show(); - } - } - } - $str .= "
\n"; + $str .= "
\n"; - return $str; + return $str; } public function add($disc) { @@ -248,15 +324,18 @@ class Discography { $this->discs[$key] = $disc; } - public function getImageSize($cat) - { - switch($cat) { - case "cover": - return new ImageSize($this->coverwidth, $this->coverheight); - default: - die(404); - } - } + public function getImageSize($cat) + { + switch($cat) { + case "cover": + return new ImageSize($this->coverwidth, $this->coverheight, true); + case "compactcover": + // return new ImageSize($this->compactcoverwidth, $this->compactcoverheight, true); + return new ImageSize(150, 150, true); + default: + die(404); + } + } public function write() { @@ -265,7 +344,7 @@ class Discography { fwrite($fp, "\n"); foreach($this->discs as $disc) { - $disc->write($fp); + $disc->write($fp); } fwrite($fp, "\n"); @@ -274,32 +353,34 @@ class Discography { private function read() { + $reviews = loadModule("reviews"); + $dom = new DomDocument; $dom->preserveWhiteSpace = FALSE; $dom->load($this->file); - $discography = $dom->documentElement; + $discography = $dom->documentElement; - $this->coverwidth = $discography->getAttribute('coverwidth'); - $this->coverheight = $discography->getAttribute('coverheight'); + $this->coverwidth = $discography->getAttribute('coverwidth'); + $this->coverheight = $discography->getAttribute('coverheight'); $discs = $dom->getElementsByTagName('disc'); foreach($discs as $d) { - $description = ""; - $dess = $d->getElementsByTagName('description'); - foreach($dess as $des) { + $description = ""; + $dess = $d->getElementsByTagName('description'); + foreach($dess as $des) { $description = $des->textContent; - } + } $disc = new Disc($d->getAttribute('title'), - $d->getAttribute('releasetime'), - $description, - $d->getAttribute('cover'), - $d->getAttribute('releaser')); + $d->getAttribute('releasetime'), + $description, + $d->getAttribute('cover'), + $d->getAttribute('releaser')); - $tracks = $d->getElementsByTagName('track'); - foreach($tracks as $t) { + $tracks = $d->getElementsByTagName('track'); + foreach($tracks as $t) { $lyrics = ""; $ls = $t->getElementsByTagName('lyrics'); foreach($ls as $l) { @@ -311,9 +392,16 @@ class Discography { $t->getAttribute('playtime'), $t->getAttribute('previewurl'), $lyrics); - + $disc->addTrack($track); - } + } + + $rs = $d->getElementsByTagName('refs'); + foreach($rs as $r) { + $refs = new Refs($r); + $disc->addRefs($refs); + break; + } $this->add($disc); } -- cgit v1.2.3