diff options
author | deva <deva> | 2010-01-25 15:45:36 +0000 |
---|---|---|
committer | deva <deva> | 2010-01-25 15:45:36 +0000 |
commit | 3b632ba6ef388405f3f21edeb1bf83f1ed0a71f9 (patch) | |
tree | c7217fcc6da9a37751c7a0fedc42aa664c999608 /utils/modules | |
parent | 24e070a294aba51f85bc0120fd25e16426347d64 (diff) |
Added lyrics. Modfied layout. Added markup of textual sections. Reworked xml format.
Diffstat (limited to 'utils/modules')
-rw-r--r-- | utils/modules/discography.php | 92 |
1 files changed, 79 insertions, 13 deletions
diff --git a/utils/modules/discography.php b/utils/modules/discography.php index 9913113..478fdc0 100644 --- a/utils/modules/discography.php +++ b/utils/modules/discography.php @@ -11,6 +11,16 @@ function time2str($t) return sprintf("%d:%02d", $min ,$sec); } +function createNewlines($in) +{ + $str = ""; + $head = substr($in, 0, strpos($in, "\n")); + $tail = substr($in, strpos($in, "\n")+1); + $str .= "<div class=\"header\"><h2 class=\"lyrics_header\"><div class=\"header_text\">".$head."</div></h2></div>\n"; + $str .= str_replace("\n", "<br/>\n", $tail); + return $str; +} + class Track { public $title; public $number; @@ -29,8 +39,20 @@ class Track { fwrite($fp, " </track>\n"); } - public function show() + public function showLyrics() + { + $str = ""; + if($this->lyrics) { + $str .= createNewlines(htmlspecialchars_decode($this->lyrics)); + } + return $str; + } + + public function show($disc) { + global $GLOBALS; + + $page = $GLOBALS["page"]; $str = ""; $str .= " <div class=\"track\">\n"; @@ -48,7 +70,7 @@ class Track { $str .= " <div class=\"title\">".$this->title."</div>\n"; $str .= " <div class=\"playtime\">".time2str($this->playtime)."</div>\n"; if($this->lyrics) { - $str .= " <a href=\"?page=lyrics&name=morsetsanguis\">Lyrics</a>\n"; + $str .= " <a href=\"?page=".$page."&lyrics=".$disc."&track=".$this->number."\">Lyrics</a>\n"; } $str .= " </div>\n"; @@ -92,34 +114,56 @@ class Disc { fwrite($fp, " </disc>\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 .= " <div class=\"disc\">\n"; + $str .= " <div class=\"record_title\">".$this->title." (".date("Y", $this->releasetime).")</div>\n"; $str .= " <div class=\"cover\">\n"; $str .= " <a href=\"".$this->cover."\">\n"; $str .= " <img alt=\"".$this->title." cover\"\n"; $str .= " src=\"?mode=imagecache&uri=" . $this->cover . "&mw=200&mh=200\"/>\n"; $str .= " </a>\n"; $str .= " </div>\n"; - $str .= " <div class=\"record_title\">".$this->title." (".date("Y", $this->releasetime).")</div>\n"; $str .= " <div class=\"label\">"; if($this->releasetime > time()) $str .= "To be"; else $str .= "Was"; - $str .= " released on ".$this->releaser.", ".date("F jS Y", $this->releasetime)."</div>\n"; - $str .= " <div class=\"traclist_header\">Tracks:</div>\n"; + $str .= " released by ".htmlspecialchars_decode($this->releaser)." on ".date("F jS Y", $this->releasetime)."</div>\n"; + $str .= " <div class=\"tracklist_header\">"; + if($this->tracks && sizeof($this->tracks) > 1) { + $str .= "Tracks:"; + } else { + $str .= "Track:"; + } + $str .= "</div>\n"; $str .= " <div class=\"tracklist\">\n"; $total = 0; - if($this->tracks) { + if($this->tracks) { foreach($this->tracks as $track) { - $str .= $track->show(); + $str .= $track->show($this->releasetime); $total += $track->playtime; } } - $str .= " <div class=\"total_playtime\">Total playtime: ".time2str($total)."</div>\n"; + if($this->tracks && sizeof($this->tracks) > 1) { + $str .= " <div class=\"total_playtime\">Total playtime: ".time2str($total)."</div>\n"; + } $str .= " </div>\n"; - $str .= " <div class=\"description\">".$this->description."</div>\n"; + $str .= " <div class=\"description\">".Markdown(htmlspecialchars_decode($this->description))."</div>\n"; $str .= " </div>\n"; return $str; @@ -165,11 +209,27 @@ class Discography { public function run($params) { + global $GLOBALS; + $str = "<div class=\"discography\">\n"; - if($this->discs) { - foreach($this->discs as $disc) { - $str .= $disc->show(); + $lyrics = $GLOBALS["lyrics"]; + $number = $GLOBALS["track"]; + + 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(); + } } } @@ -205,9 +265,15 @@ class Discography { $discs = $dom->getElementsByTagName('disc'); foreach($discs as $d) { + $description = ""; + $dess = $d->getElementsByTagName('description'); + foreach($dess as $des) { + $description = $des->textContent; + } + $disc = new Disc($d->getAttribute('title'), $d->getAttribute('releasetime'), - $d->getAttribute('description'), + $description, $d->getAttribute('cover'), $d->getAttribute('releaser')); |