summaryrefslogtreecommitdiff
path: root/utils/modules
diff options
context:
space:
mode:
authordeva <deva>2011-11-01 09:32:21 +0000
committerdeva <deva>2011-11-01 09:32:21 +0000
commit42c62cb041a2b2b95c9cda0c20fcf70334fd244c (patch)
tree38371eb37ff7348585ee84438b326c25055e2cbe /utils/modules
parent208e3b642149a9ac701a43397d31990f9b27ca79 (diff)
Rewl og krat... needs cleaning up - after port to GIT.origin
Diffstat (limited to 'utils/modules')
-rw-r--r--utils/modules/config.php23
-rw-r--r--utils/modules/discography.php480
-rw-r--r--utils/modules/downloads.php33
-rw-r--r--utils/modules/events.php47
-rw-r--r--utils/modules/gallery.php131
-rw-r--r--utils/modules/guestbook.php2
-rw-r--r--utils/modules/members.php3
-rw-r--r--utils/modules/reviews.php221
8 files changed, 722 insertions, 218 deletions
diff --git a/utils/modules/config.php b/utils/modules/config.php
index 13cdda1..dcdedda 100644
--- a/utils/modules/config.php
+++ b/utils/modules/config.php
@@ -43,12 +43,32 @@ class Config {
echo "The stylesheet has now been changed to \"". $this->value("css") . "\"";
$this->write();
break;
-
+ /*
+ case "css_test_start":
+ setCookie("testcss", $vars["css"]);
+ break;
+
+ case "css_test_stop":
+ deleteCookie("testcss");
+ break;
+ */
default:
$form = new Form("update");
$form->addWidget(new LineEdit("CSS file:", "css", $this->value("css", "CSS not yet set")));
$form->addWidget(new Button("Update"));
$form->render();
+ /*
+ if(!$testcss) {
+ $form = new Form("css_test_start");
+ $form->addWidget(new LineEdit("Test CSS file:", "css", ""));
+ $form->addWidget(new Button("Start CSS test"));
+ $form->render();
+ } else {
+ $form = new Form("css_test_stop");
+ $form->addWidget(new Button("Stop CSS test"));
+ $form->render();
+ }
+ */
break;
}
}
@@ -173,6 +193,7 @@ class Config {
public function value($name, $default = "")
{
+ if($GLOBALS["test"] == "1" && $name == "css") return "design/rotr/style.css";
if(isset($this->configs[$name])) return $this->configs[$name];
return $default;
}
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 @@
-<?php
-/* -*- Mode: php; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+<?php /* -*- Mode: php; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
global $UTIL_DIR;
include_once($UTIL_DIR . "/convert.php");
include_once($UTIL_DIR . "/markdown.php");
+include_once($UTIL_DIR . "/refs.php");
function time2str($t)
{
- $min = sprintf("%d", floor($t / 60));
- $sec = $t % 60;
- return sprintf("%d:%02d", $min ,$sec);
+ $min = sprintf("%d", floor($t / 60));
+ $sec = $t % 60;
+ 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;
+ $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;
- public $playtime;
- public $previewurl;
- public $lyrics;
-
- public function write($fp)
- {
- fwrite($fp, " <track title=\"" .
- htmlspecialchars($this->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, " <lyrics>".htmlspecialchars($this->lyrics, ENT_QUOTES, "UTF-8")."</lyrics>\n");
- fwrite($fp, " </track>\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, " <track title=\"" .
+ htmlspecialchars($this->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, " <lyrics>".
+ htmlspecialchars($this->lyrics, ENT_QUOTES, "UTF-8")."</lyrics>\n");
+ fwrite($fp, " </track>\n");
+ }
- public function show($disc)
- {
- global $GLOBALS;
-
- $page = $GLOBALS["page"];
- $str = "";
- $str .= " <div class=\"track\">\n";
-
- $str .= " <span class=\"preview\">\n";
- if($this->previewurl) {
- $str .= " <object type=\"application/x-shockwave-flash\" data=\"player_mp3_maxi.swf\" width=\"25\" height=\"12\">\n";
- $str .= " <param name=\"movie\" value=\"player_mp3_maxi.swf\"/>\n";
- $str .= " <param name=\"FlashVars\" value=\"mp3=".$this->previewurl."&amp;showslider=0&amp;width=25&amp;height=12&amp;skin=design/mors/chicken.jpg\"/>\n";
- $str .= " </object>\n";
- } else {
- }
- $str .= " </span>\n";
-
- $str .= " <span class=\"number\">".$this->number.". </span>\n";
- $str .= " <span class=\"title\">".$this->title."</span>\n";
- $str .= " <span class=\"playtime\">".time2str($this->playtime)."</span>\n";
- if($this->lyrics) {
- $str .= " <a href=\"?page=".$page."&amp;lyrics=".$disc."&amp;track=".$this->number."\">Lyrics</a>\n";
- }
- $str .= " </div>\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 .= " <div class=\"track\">\n";
+
+ $str .= " <span class=\"preview\">\n";
+ if($this->previewurl) {
+ $str .= " <object type=\"application/x-shockwave-flash\" ".
+ "data=\"player_mp3_maxi.swf\" width=\"25\" height=\"12\">\n";
+ $str .= " <param name=\"movie\" ".
+ "value=\"player_mp3_maxi.swf\"/>\n";
+ $str .= " <param name=\"FlashVars\" value=\"mp3=".
+ $this->previewurl."&amp;showslider=0&amp;width=25&amp;height=12&amp;".
+ "skin=design/rotr/chicken.jpg\"/>\n";
+ $str .= " </object>\n";
+ } else {
+ }
+ $str .= " </span>\n";
+
+ $str .= " <span class=\"number\">".$this->number.". </span>\n";
+ $str .= " <span class=\"title\">".$this->title."</span>\n";
+ $str .= " <span class=\"playtime\">".time2str($this->playtime).
+ "</span>\n";
+ if($this->lyrics) {
+ $str .= " <a href=\"?page=".$page."&amp;lyrics=".$disc.
+ "&amp;track=".$this->number."\">Lyrics</a>\n";
+ }
+ $str .= " </div>\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, " <disc title=\"" .
- htmlspecialchars($this->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, " <tracks>\n");
- if($this->tracks) {
- foreach($this->tracks as $track) {
- $track->write($fp);
- }
- }
- fwrite($fp, " </tracks>\n");
- fwrite($fp, " </disc>\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, " <disc title=\"" .
+ htmlspecialchars($this->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, " <tracks>\n");
+ if($this->tracks) {
+ foreach($this->tracks as $track) {
+ $track->write($fp);
+ }
+ }
+ fwrite($fp, " </tracks>\n");
+ if($this->refs) $this->refs->write($fp, " ");
+ 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 .= " <span class=\"record_title\">".$this->title." (".date("Y", $this->releasetime).")</span>\n";
- $str .= " <div class=\"cover\">\n";
- $str .= " <a href=\"".$this->cover."\">\n";
- $str .= " <img alt=\"".$this->title." cover\"\n";
- $str .= " src=\"?mode=imagecache&amp;uri=" . $this->cover . "&amp;mod=discography&amp;cat=cover\"/>\n";
- $str .= " </a>\n";
- $str .= " </div>\n";
- $str .= " <span class=\"label\">";
- if($this->releasetime > time()) $str .= "To be";
- else $str .= "Was";
- $str .= " released by ".htmlspecialchars_decode($this->releaser)." on ".date("F jS Y", $this->releasetime)."</span>\n";
- $str .= " <span class=\"tracklist_header\">";
- if($this->tracks && sizeof($this->tracks) > 1) {
- $str .= "Tracks:";
- } else {
- $str .= "Track:";
- }
- $str .= "</span>\n";
- $str .= " <div class=\"tracklist\">\n";
- $total = 0;
- if($this->tracks) {
- foreach($this->tracks as $track) {
+ public function show()
+ {
+ $str = "";
+
+ $str .= " <div class=\"disc\">\n";
+ $str .= " <span class=\"record_title\">".$this->title." (".
+ date("Y", $this->releasetime).")</span>\n";
+ $str .= " <div class=\"cover\">\n";
+ $str .= " <a href=\"".$this->cover."\">\n";
+ $str .= " <img alt=\"".$this->title." cover\"\n";
+ $str .= " src=\"?mode=imagecache&amp;uri=" .
+ $this->cover . "&amp;mod=discography&amp;cat=cover\"/>\n";
+ $str .= " </a>\n";
+ $str .= " </div>\n";
+ $str .= " <span class=\"label\">";
+ if($this->releasetime > time()) $str .= "To be";
+ else $str .= "Was";
+ $str .= " released by ".htmlspecialchars_decode($this->releaser)." on ".
+ date("F jS Y", $this->releasetime)."</span>\n";
+ $str .= " <span class=\"tracklist_header\">";
+ if($this->tracks && sizeof($this->tracks) > 1) {
+ $str .= "Tracks:";
+ } else {
+ $str .= "Track:";
+ }
+ $str .= "</span>\n";
+ $str .= " <div class=\"tracklist\">\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 .= " <span class=\"total_playtime\">Total playtime: ".time2str($total)."</span>\n";
- }
- $str .= " </div>\n";
- $str .= " <span class=\"description\">".Markdown(htmlspecialchars_decode($this->description))."</span>\n";
- $str .= " </div>\n";
-
- return $str;
+ }
+ }
+ if($this->tracks && sizeof($this->tracks) > 1) {
+ $str .= " <span class=\"total_playtime\">Total playtime: ".
+ time2str($total)."</span>\n";
+ }
+ $str .= " </div>\n";
+ $str .= " <span class=\"description\">".
+ Markdown(htmlspecialchars_decode($this->description))."</span>\n";
+
+ if($this->refs) $str .= $this->refs->show();
+
+ $str .= " </div>\n";
+
+ return $str;
+ }
+
+ public function showCompact()
+ {
+ $str = "";
+
+ $str .= " <div class=\"disc\">\n";
+ /*
+ $str .= " <span class=\"record_title\">".$this->title." (".
+ date("Y", $this->releasetime).")</span>\n";
+ */
+ $str .= " <div class=\"cover\">\n";
+ $str .= " <a href=\"?page=discography\">\n";
+ $str .= " <img alt=\"".$this->title." cover\"\n";
+ $str .= " src=\"?mode=imagecache&amp;uri=" .
+ $this->cover . "&amp;mod=discography&amp;cat=compactcover\"/>\n";
+ $str .= " </a>\n";
+ $str .= " </div>\n";
+ $str .= " <span class=\"label\">";
+ if($this->releasetime > time()) $str .= "Coming ".date("F jS Y", $this->releasetime);
+ else $str .= "Out now!";
+ $str .= "</span>\n";
+ $str .= " </div>\n";
+ $str .= "</div>\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 = "<div class=\"discography\">\n";
+ $str = "<div class=\"discography\">\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 .= "</div>\n";
+ $str .= "</div>\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, "<discography>\n");
foreach($this->discs as $disc) {
- $disc->write($fp);
+ $disc->write($fp);
}
fwrite($fp, "</discography>\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);
}
diff --git a/utils/modules/downloads.php b/utils/modules/downloads.php
index 99e9962..52c6736 100644
--- a/utils/modules/downloads.php
+++ b/utils/modules/downloads.php
@@ -68,6 +68,21 @@ class DownloadItem {
*/
}
+ public function showRef()
+ {
+ $str = "";
+
+ if($this->type == "youtube") {
+ $str .= "<a href=\"http://www.youtube.com/watch?v=".$this->value."\">Video: " . $this->title."</a>";
+ }
+
+ if($this->type == "vimeo") {
+ $str .= "<a href=\"http://www.vimeo.com/".$this->value."\">Video: " . $this->title."</a>";
+ }
+
+ return $str;
+ }
+
public function show()
{
global $VIDEO_WIDTH;
@@ -254,6 +269,20 @@ class Downloads {
*/
}
+ public function showRef($id)
+ {
+ $bleh = explode(",", $id);
+ $gid = $bleh[0];
+ $iid = $bleh[1];
+
+ $str = "";
+ if($this->groups[$gid] && $this->groups[$gid]->items[$iid]) {
+ $str .= $this->groups[$gid]->items[$iid]->showRef();
+ }
+
+ return $str;
+ }
+
private function read()
{
$dom = new DomDocument;
@@ -284,12 +313,12 @@ class Downloads {
}
}
- ksort($item->sources);
+ // ksort($item->sources);
$group->addItem($item);
}
}
- ksort($group->items);
+ // ksort($group->items);
$this->add($group);
}
}
diff --git a/utils/modules/events.php b/utils/modules/events.php
index 3bccce6..1bfcd5c 100644
--- a/utils/modules/events.php
+++ b/utils/modules/events.php
@@ -5,20 +5,23 @@ global $UTIL_DIR, $MODULES_DIR;
include_once($UTIL_DIR . "/convert.php");
include_once($UTIL_DIR . "/markdown.php");
include_once($MODULES_DIR . "/icons.php");
+include_once($UTIL_DIR . "/refs.php");
class Event {
public $title;
public $time;
public $description;
public $flyer;
+ public $refs;
public function write($fp)
{
fwrite($fp, " <event title=\"" .xmlenc($this->title) . "\"\n");
fwrite($fp, " time=\"" . xmlenc($this->time) . "\"\n");
- fwrite($fp, " flyer=\"" . xmlenc($this->flyer) . "\">");
- fwrite($fp, xmlenc($this->description));
- fwrite($fp, "</event>\n");
+ fwrite($fp, " flyer=\"" . xmlenc($this->flyer) . "\">\n");
+ fwrite($fp, " <description>".xmlenc($this->description)."</description>\n");
+ if($this->refs) $this->refs->write($fp, " ");
+ fwrite($fp, " </event>\n");
}
public function show($eventpage)
@@ -40,10 +43,17 @@ class Event {
$str .= " <img class=\"event_flyer\" alt=\"flyer\" src=\"".$icon->prefix.$icon->file."\"/>\n";
}
*/
+ if($this->refs) $str .= $this->refs->show();
+
$str .= "</div>\n";
return $str;
}
+ public function addRefs($refs)
+ {
+ $this->refs = $refs;
+ }
+
public function Event($title, $time, $description, $flyer = "")
{
$this->title = $title;
@@ -144,6 +154,8 @@ class Events {
$this->events[$vars["eventid"]]->time = DateTimeEdit::toTimestamp($vars, "time");
$this->events[$vars["eventid"]]->description = $vars["description"];
$this->events[$vars["eventid"]]->flyer = $vars["icon"];
+ $refs = refsGetRefsFromHidden($vars);
+ $this->events[$vars["eventid"]]->refs = $refs;
$this->write();
echo "\"" . $this->events[$vars["eventid"]]->title . "\" has now been edited.";
break;
@@ -151,6 +163,9 @@ class Events {
case "preview":
$event = new Event($vars["title"], DatetimeEdit::toTimestamp($vars, "time"),
$vars["description"], $vars["icon"]);
+ $refs = refsGetRefsFromWidget();
+ $event->addRefs($refs);
+
echo "<div class=\"preview\">\n";
echo "<div class=\"content\">\n";
echo $event->show($this->eventpage);
@@ -159,11 +174,13 @@ class Events {
echo "<p>Looking ok?</p>";
$form = new Form("add");
$form->addWidget(new Hidden($vars));
+ refsAddHiddenWidget($form, $refs);
$form->addWidget(new Button("yes"));
$form->render();
$form = new Form("retry");
$form->addWidget(new Hidden($vars));
+ refsAddHiddenWidget($form, $refs);
$form->addWidget(new Button("no"));
$form->render();
break;
@@ -178,13 +195,18 @@ class Events {
else $description = $this->events[$vars["eventid"]]->description;
if(isset($vars["icon"])) $icon = $vars["icon"];
else $icon = $this->events[$vars["eventid"]]->flyer;
-
+ if(isset($vars["refslist_hidden"])) $refs = refsGetFromHidden($vars);
+ else {
+ $refs = refsGetCommaListFromRefs($this->events[$vars["eventid"]]->refs);
+ }
+
$form = new Form("preview");
$form->addWidget(new Hidden($vars));
$form->addWidget(new LineEdit("Title", "title", $title));
$form->addWidget(new DateTimeEdit("Time", "time", $time));
$form->addWidget(new TextEdit("Description", "description", $description));
$form->addWidget(new ImageComboBox("Icon", "icon", $icon, new Icons($ICONS_DIR."/")));
+ refsAddWidget($form, $refs);
$form->addWidget(new Button("Update event"));
$form->render();
break;
@@ -415,10 +437,25 @@ class Events {
$this->eventpage = $events->getAttribute('eventpage');
foreach ($params as $param) {
+
+ $description = "";
+ $dess = $param->getElementsByTagName('description');
+ foreach($dess as $des) {
+ $description = $des->textContent;
+ }
+
$event = new Event($param->getAttribute('title'),
$param->getAttribute('time'),
- $param->textContent,
+ $description,
$param->getAttribute('flyer'));
+
+ $rs = $param->getElementsByTagName('refs');
+ foreach($rs as $r) {
+ $refs = new Refs($r);
+ $event->addRefs($refs);
+ break;
+ }
+
$this->add($event);
}
}
diff --git a/utils/modules/gallery.php b/utils/modules/gallery.php
index 3915a90..396cfd7 100644
--- a/utils/modules/gallery.php
+++ b/utils/modules/gallery.php
@@ -58,6 +58,15 @@ class Photo {
return $str;
}
+ public function showRef()
+ {
+ $str = "";
+ $str .= " <img style=\"vertical-align: middle;\" alt=\"".$this->title."\"\n";
+ $str .= " src=\"?mode=imagecache&amp;uri="
+ . $this->path . "/" . $this->image . "&amp;mod=gallery&amp;cat=reficon\"/>\n";
+ return $str;
+ }
+
public function Photo($path, $id, $title, $image)
{
$this->path = $path;
@@ -103,16 +112,33 @@ class Album {
{
global $page;
+ if(!$this->enabled) return "";
+
$str = "";
$str .= $indent."<span class=\"album\">\n";
+ // $str .= $indent." <a style=\"position: relative; top: -32px; text-decoration: none;\" class=\"album_back\" href=\"?page=".$page."\">&nbsp; &larr; Back to albums</a>\n";
$str .= $indent." <span class=\"album_title\">" . $this->title . "</span>\n";
+ $str .= $indent." <span class=\"album_copyright\">Copyright: " . $this->copyright . "</span>\n";
foreach($this->photos as $photo) {
$str .= $indent." <a class=\"photo_icon\" href=\"?page=".$page."&amp;a=".$this->id."&amp;p=".$photo->id."\">\n";
$str .= $photo->show($indent." ", "albumicon");
$str .= $indent." </a>\n";
}
- $str .= $indent."</span>\n";
+ $str .= $indent." <br/><a style=\"clear: both; text-decoration: none;\" class=\"album_back\" href=\"?page=".$page."\">&nbsp; &larr; Back to albums</a>\n";
+ // Back to gallery
+ /*
+ $str .= $indent." <a class=\"photo_icon\" href=\"?page=".$page."\">\n";
+ $str .= $indent."<span class=\"photo\">\n";
+ $str .= $indent." <span class=\"photo_image\">\n";
+ $str .= $indent." <img alt=\"Back to gallery\"\n";
+ $str .= $indent." src=\"?mode=imagecache&amp;uri=design/mors/home.png&amp;mod=gallery&amp;cat=albumicon\"/>\n";
+ $str .= $indent." </span>\n";
+ $str .= $indent." <span class=\"photo_caption\">" . $this->title . "</span>\n";
+ $str .= $indent."</span>\n";
+ $str .= $indent." </a>\n";
+ $str .= $indent."</span>\n";
+ */
return $str;
}
@@ -132,6 +158,20 @@ class Album {
return $str;
}
+ public function showRef()
+ {
+ global $page;
+
+ $str = "";
+
+ $str .= $indent."<a class=\"album\" href=\"?page=gallery&amp;a=".$this->id."\">\n";
+ $str .= $this->photos[$this->icon]->showRef() .
+ " " .$this->title . "\n";
+ $str .= $indent."</a>\n";
+
+ return $str;
+ }
+
public function showPhoto($indent, $photo)
{
global $GLOBALS;
@@ -192,7 +232,7 @@ class Album {
$this->title = $title;
$this->copyright = $copyright;
$this->icon = $icon;
- $this->enabled = $enabled == 'on';
+ $this->enabled = $enabled == "true" || $enabled == "on" || $enabled == "yes";
}
}
@@ -266,11 +306,20 @@ class Gallery {
global $ALBUMS_DIR;
switch($action) {
case "create":
- $album = new Album($this->getNextID(), $vars['title'], $vars['copyright'], "1", $vars['enabled']);
+ $baseid = $vars['id'];
+ $id = $baseid;
+ $idcnt = 1;
+ while(!$this->checkUniqueID($id)) {
+ $id = $baseid . "-" . $idcnt;
+ $idcnt++;
+ }
+
+ $album = new Album($id, $vars['title'], $vars['copyright'], "1", $vars['enabled']);
unpackImages($_FILES['images'], $album);
- $this->add($album);
+ $this->add($album);
$this->write();
echo $album->show("", "albumicon");
+
break;
case "select":
@@ -278,7 +327,8 @@ class Gallery {
$form = new Form("create");
$form->addWidget(new LineEdit("Album title:", "title"));
$form->addWidget(new LineEdit("Album copyright:", "copyright"));
- $form->addWidget(new CheckBox("Album enabled:", "enabled"));
+ $form->addWidget(new LineEdit("Album ID:", "id", $this->getNextID()));
+ $form->addWidget(new CheckBox("Album enabled:", "enabled"));
$form->addWidget(new FileUpload("Select image archive:", "images", "application/zip"));
$form->addWidget(new Button("Create"));
$form->render();
@@ -286,6 +336,48 @@ class Gallery {
}
}
+ public function admin_edit($action, $vars)
+ {
+ global $ALBUMS_DIR;
+ switch($action) {
+ case "update":
+ $album = $this->albums[$vars["id"]];
+
+ $album->title = $vars["title"];
+ $album->copyright = $vars["copyright"];
+ $album->enabled = $vars["enabled"] == "on";
+
+ $this->write();
+ break;
+
+ case "edit":
+ $album = $this->albums[$vars["id"]];
+
+ $form = new Form("update");
+ $form->addWidget(new LineEdit("Album title:", "title", $album->title));
+ $form->addWidget(new LineEdit("Album copyright:", "copyright", $album->copyright));
+ $form->addWidget(new LineEdit("Album ID:", "id", $album->id));
+ $form->addWidget(new CheckBox("Album enabled:", "enabled", $album->enabled));
+ $form->addWidget(new Button("Update"));
+ $form->render();
+ break;
+
+ case "select":
+ default:
+ $albumlist = array();
+ foreach($this->albums as $album) {
+ $albumlist[$album->title . " (".$album->id.")"] = $album->id;
+ }
+ krsort($albumlist);
+
+ $form = new Form("edit");
+ $form->addWidget(new ComboBox("Select album:", "id", "", $albumlist));
+ $form->addWidget(new Button("Edit"));
+ $form->render();
+ break;
+ }
+ }
+
public function admin_options($action, $vars)
{
switch($action) {
@@ -325,7 +417,7 @@ class Gallery {
$this->admin_new($action, $vars);
break;
case "edit":
- $this->admin_new($action, $vars);
+ $this->admin_edit($action, $vars);
break;
case "delete":
$this->admin_new($action, $vars);
@@ -356,7 +448,7 @@ class Gallery {
$str .= "\n<span class=\"albums\">\n";
foreach($this->albums as $album) {
- $str .= $album->showIcon(" ");
+ if($album->enabled) $str .= $album->showIcon(" ");
}
$str .= "</span>\n";
@@ -374,6 +466,12 @@ class Gallery {
return $str;
}
+ public function showRef($id)
+ {
+ if(!$this->albums[$id]) return "";
+ return $this->albums[$id]->showRef();
+ }
+
public function run($params)
{
global $a, $p;
@@ -413,17 +511,28 @@ class Gallery {
return $maxid + 1;
}
+ public function checkUniqueID($id)
+ {
+ foreach($this->albums as $album) {
+ if($album->id == $id) return false;
+ }
+ return true;
+ }
+
public function getImageSize($cat)
{
switch($cat) {
case "photo":
- return new ImageSize($this->maxwidth, $this->maxheight);
+ return new ImageSize($this->maxwidth, $this->maxheight, false);
case "randomimage":
- return new ImageSize($this->maxwidth_rand, $this->maxheight_rand);
+ return new ImageSize($this->maxwidth_rand, $this->maxheight_rand, true);
case "navicon":
- return new ImageSize($this->maxwidth_navicon, $this->maxheight_navicon);
+ return new ImageSize($this->maxwidth_navicon, $this->maxheight_navicon, true);
case "albumicon":
- return new ImageSize($this->maxwidth_icon, $this->maxheight_icon);
+ return new ImageSize($this->maxwidth_icon, $this->maxheight_icon, true);
+ case "reficon":
+ // return new ImageSize($this->maxwidth_reficon, $this->maxheight_reficon, true);
+ return new ImageSize(32, 24, true);
default:
die(404);
}
diff --git a/utils/modules/guestbook.php b/utils/modules/guestbook.php
index 92fe732..039cd2c 100644
--- a/utils/modules/guestbook.php
+++ b/utils/modules/guestbook.php
@@ -339,7 +339,7 @@ class Guestbook {
default:
if($show == "all") $showposts = -1;
- else $showposts = 7;
+ else $showposts = 12;
break;
}
}
diff --git a/utils/modules/members.php b/utils/modules/members.php
index 670de53..41f1979 100644
--- a/utils/modules/members.php
+++ b/utils/modules/members.php
@@ -1,5 +1,4 @@
-<?php
-/* -*- Mode: php; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+<?php /* -*- Mode: php; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
global $UTIL_DIR;
diff --git a/utils/modules/reviews.php b/utils/modules/reviews.php
new file mode 100644
index 0000000..8fa97b5
--- /dev/null
+++ b/utils/modules/reviews.php
@@ -0,0 +1,221 @@
+<?php /* -*- Mode: php; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+
+global $UTIL_DIR;
+
+include_once($UTIL_DIR . "/convert.php");
+include_once($UTIL_DIR . "/markdown.php");
+
+// See: http://www.loc.gov/standards/iso639-2/php/code_list.php
+function lang2text($lang)
+{
+
+ if(function_exists('locale_get_display_language'))
+ return locale_get_display_language($lang, 'en');
+
+ switch($lang) {
+ case "en": return "english";
+ case "da": return "danish";
+ case "nl": return "dutch";
+ case "bul": return "bulgarian";
+ case "fr": return "french";
+ case "it": return "italian";
+ default: return "unknown";
+ }
+}
+
+class Text {
+ public $text;
+ public $lang;
+ public $original;
+
+ public function show()
+ {
+ $str = "";
+
+ $prefix = "Original";
+ if(!$this->original) $prefix = "Translated";
+
+ $str .= "<div class=\"header\"><h3>".$prefix." ".lang2text($this->lang)." text</h3></div>\n";
+ $str .= markdown($this->text) . "\n";
+ return $str;
+ }
+
+ public function Text($text, $lang, $original)
+ {
+ $this->text = $text;
+ $this->lang = $lang;
+ $this->original = $original;
+ }
+}
+
+class Review {
+ public $title;
+ public $id;
+ public $src;
+ public $url;
+ public $texts = array();
+
+ public function write($fp)
+ {
+/*
+ fwrite($fp, " <track title=\"" .
+ htmlspecialchars($this->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, " <lyrics>".htmlspecialchars($this->lyrics, ENT_QUOTES, "UTF-8")."</lyrics>\n");
+ fwrite($fp, " </track>\n");
+*/
+ }
+
+ public function show()
+ {
+ $str = "";
+
+ // $str .= $this->id . "\n";
+ $str .= "<div class=\"header\"><h2>".$this->title."</h2></div>\n";
+ $str .= "<p>Origin: <em>".$this->src."</em> <a href=\"".$this->url."\">".$this->url."</a></p>\n";
+
+ foreach($this->texts as $text) {
+ if($text->original) {
+ $str .= $text->show();
+ break;
+ }
+ }
+
+ foreach($this->texts as $text) {
+ if(!$text->original) {
+ $str .= $text->show();
+ }
+ }
+
+ return $str;
+ }
+
+ public function showRef()
+ {
+ $str = "";
+ $str .= "<a href=\"?page=reviews&amp;rid=".
+ $this->id."\">".$this->title." from ".$this->src."</a>\n";
+ return $str;
+ }
+
+ public function add($text)
+ {
+ array_push($this->texts, $text);
+ }
+
+ public function Review($id, $title, $src, $url)
+ {
+ $this->id = $id;
+ $this->title = $title;
+ $this->src = $src;
+ $this->url = $url;
+ }
+}
+
+class Reviews {
+
+ private $file;
+ private $reviews = array();
+
+ // Admin config
+ public $admin_title = "Reviews";
+ public $admin_submodules = array();
+
+ public function admin($sub, $action, $vars)
+ {
+ switch($sub) {
+ case "delete":
+ break;
+ }
+ }
+
+ public function run($params)
+ {
+ global $GLOBALS;
+ $str = "";
+ foreach($this->reviews as $review) {
+ if($GLOBALS['rid'] == $review->id) {
+ $str .= $review->show();
+ }
+ }
+
+ return $str;
+ }
+
+ public function get($id)
+ {
+ return $this->reviews[$id];
+ }
+
+ public function showRef($id)
+ {
+ if(!$this->reviews[$id]) return "";
+ return $this->reviews[$id]->showRef();
+ }
+
+ public function add($review) {
+ $key = $review->id;
+ $this->reviews[$key] = $review;
+ }
+
+ public function write()
+ {
+ /*
+ $fp = fopen($this->file, "w");
+ fwrite($fp, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
+
+ fwrite($fp, "<discography>\n");
+ foreach($this->discs as $disc) {
+ $disc->write($fp);
+ }
+ fwrite($fp, "</discography>\n");
+
+ fclose($fp);
+ */
+ }
+
+ private function read()
+ {
+ $dom = new DomDocument;
+ $dom->preserveWhiteSpace = FALSE;
+ $dom->load($this->file);
+
+ $discography = $dom->documentElement;
+
+ $revs = $dom->getElementsByTagName('review');
+
+ foreach($revs as $rev) {
+ $review = new Review($rev->getAttribute('id'),
+ $rev->getAttribute('title'),
+ $rev->getAttribute('src'),
+ $rev->getAttribute('url'));
+
+ $ts = $rev->getElementsByTagName('text');
+ foreach($ts as $t) {
+ $text = new Text($t->textContent,
+ $t->getAttribute('lang'),
+ $t->getAttribute('original'));
+ $review->add($text);
+ }
+
+ $this->add($review);
+ }
+ }
+
+ public function Reviews($file)
+ {
+ $this->file = $file;
+ if(file_exists($file)) $this->read();
+ }
+
+}
+
+function reviews_init()
+{
+ global $DATA_DIR;
+ return new Reviews($DATA_DIR . "/reviews.xml");
+}
+
+?>