diff options
author | deva <deva> | 2011-11-01 09:32:21 +0000 |
---|---|---|
committer | deva <deva> | 2011-11-01 09:32:21 +0000 |
commit | 42c62cb041a2b2b95c9cda0c20fcf70334fd244c (patch) | |
tree | 38371eb37ff7348585ee84438b326c25055e2cbe /utils | |
parent | 208e3b642149a9ac701a43397d31990f9b27ca79 (diff) |
Rewl og krat... needs cleaning up - after port to GIT.origin
Diffstat (limited to 'utils')
-rw-r--r-- | utils/admin.php | 4 | ||||
-rw-r--r-- | utils/forms.php | 66 | ||||
-rw-r--r-- | utils/imagecache.php | 56 | ||||
-rw-r--r-- | utils/mail.php | 4 | ||||
-rw-r--r-- | utils/modules.php | 4 | ||||
-rw-r--r-- | utils/modules/config.php | 23 | ||||
-rw-r--r-- | utils/modules/discography.php | 480 | ||||
-rw-r--r-- | utils/modules/downloads.php | 33 | ||||
-rw-r--r-- | utils/modules/events.php | 47 | ||||
-rw-r--r-- | utils/modules/gallery.php | 131 | ||||
-rw-r--r-- | utils/modules/guestbook.php | 2 | ||||
-rw-r--r-- | utils/modules/members.php | 3 | ||||
-rw-r--r-- | utils/modules/reviews.php | 221 | ||||
-rw-r--r-- | utils/refs.php | 139 |
14 files changed, 955 insertions, 258 deletions
diff --git a/utils/admin.php b/utils/admin.php index df3a9df..6b8b8e0 100644 --- a/utils/admin.php +++ b/utils/admin.php @@ -1,6 +1,6 @@ <?php /* -*- Mode: php; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ ?> <div class="admin" id="admin"> - <span class="header windowtitle">Admin</span> + <span class="mainheader windowtitle">Admin</span> <div class="button close"><a href="?page=">X</a></div> <?php global $loggedin; @@ -15,7 +15,7 @@ global $DATA_DIR; $user = $users->findUser($UID); ?> <a class="logout" href="?page=admin&action=logout">Logout <span class="user"><?php echo $UID;?></span></a> -<div class="menu"> +<div class="adminmenu"> <?php include_once($UTIL_DIR . "/modules.php"); diff --git a/utils/forms.php b/utils/forms.php index 39e1a4c..d6fdada 100644 --- a/utils/forms.php +++ b/utils/forms.php @@ -89,14 +89,19 @@ class CheckBox { { $this->label = $label; $this->name = $name; - $this->value = $value; + if($value == true || $value == "on" || $value == "true" || $value == "yes") + $this->value = "checked "; + else + $this->value = ""; } public function render($indent = "") { $str = $indent . "<div class=\"input\">\n"; - $str .= $indent . " <div class=\"label\">". xmlenc($this->label) ."</div>\n"; - $str .= $indent . " <div class=\"widget\"><input type=\"checkbox\" name=\"vars[".$this->name."]\" value=\"".xmlenc($this->value)."\"/></div>\n"; + $str .= $indent . " <div class=\"label\">". xmlenc($this->label) ."</div>\n"; + $str .= $indent . " <div class=\"widget\">". + "<input type=\"checkbox\" name=\"vars[".$this->name."]\" ".$this->value."value=\"on\"/>". + "</div>\n"; $str .= $indent . "</div>\n"; return $str; } @@ -132,7 +137,7 @@ class ComboBox { class Hidden { public $values; - + public function Hidden($values) { $this->values = $values; @@ -280,13 +285,14 @@ class ImageComboBox { class ListEditor { public $label, $name, $namewidget, $valuewidget, $values; - public function ListEditor($label, $name, $namewidget, $valuewidget, $values = array()) + public function ListEditor($label, $name, $namewidget, $valuewidget, $values = array(), $commalist = false) { $this->label = $label; $this->name = $name; $this->namewidget = $namewidget; $this->valuewidget = $valuewidget; $this->values = $values; + $this->commalist = $commalist; } public function render($indent = "") @@ -354,11 +360,17 @@ class ListEditor { $str .= $indent . "}\n"; $str .= $indent . "//-->\n"; $str .= $indent . "</script>\n"; - $str .= $indent . "<select multiple size=\"8\" id=\"items\" name=\"".$this->name."[]\">\n"; - if(sizeof($this->values)) { - foreach($this->values as $key => $val) { - $str .= $indent . " <option value=\"".$key.":".$val."\">".$key.":".$val."</option>\n"; - } + $str .= $indent . "<select style=\"min-width: 200px;\" multiple size=\"8\" id=\"items\" name=\"".$this->name."[]\">\n"; + if($this->values) { + if($this->commalist) { + foreach($this->values as $val) { + $str .= $indent . " <option value=\"".$val."\">".$val."</option>\n"; + } + } else { + foreach($this->values as $key => $val) { + $str .= $indent . " <option value=\"".$key.":".$val."\">".$key.":".$val."</option>\n"; + } + } } $str .= $indent . "</select><br/>\n"; $str .= $indent . "<div class=\"button\" button onclick=\"moveUp()\">/\</div><br/>\n"; @@ -373,12 +385,38 @@ class ListEditor { public function splitValues($values) { $out = array(); - foreach($values as $value) { - $vals = explode(":", $value); - $out[$vals[0]]=$vals[1]; - } + if($values) { + foreach($values as $value) { + $vals = explode(":", $value); + + /* + $out[$vals[0]]=$vals[1]; + */ + + $_keys = array_keys($out); + $_vals = array_values($out); + + array_push($_keys, $vals[0]); + array_push($_vals, $vals[1]); + + $out = array_combine($_keys, $_vals); + } + } return $out; } + + function combineValues($values) + { + $out = array(); + if($values) { + foreach($values as $k => $v) { + $value = $k.":".$v; + array_push($out, $value); + } + } + return $out; + } + } class MultiList { diff --git a/utils/imagecache.php b/utils/imagecache.php index 3f91d79..5adf54c 100644 --- a/utils/imagecache.php +++ b/utils/imagecache.php @@ -7,16 +7,38 @@ include_once($UTIL_DIR . "/modules.php"); class ImageSize { public $width; public $height; + public $cut; - public function ImageSize($w, $h) + public function ImageSize($w, $h, $c) { $this->width = $w; $this->height = $h; + $this->cut = $c; } }; -function rescale($image, $width, $height) +function rescale_nocut($image, $maxwidth, $maxheight) { + $width = imagesx($image); + $height = imagesy($image); + + if($width <= $maxwidth && $height <= $maxheight) return $image; + + $scale = 1; + if($width > $maxwidth) $scale = $width / $maxwidth; + if($height / $scale > $maxheight) $scale = $height / $maxheight; + + $image_p = imagecreatetruecolor($width / $scale, $height / $scale); + imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width / $scale, + $height / $scale, $width, $height); + + return $image_p; +} + +function rescale($image, $width, $height, $cut) +{ + if($cut == false) return rescale_nocut($image, $width, $height); + $aspect = $width / $height; $w = imagesx($image); @@ -60,27 +82,19 @@ function errorImage($message) function getCachedImage($filename, $mod, $cat) { - global $modules; - loadModule($mod); - if(!$modules[$mod]) die(404); - if(!method_exists($modules[$mod], "getImageSize")) die(404); + $module = loadModule($mod); + if(!$module) die(404); + if(!method_exists($module, "getImageSize")) die(404); - $size = $modules[$mod]->getImageSize($cat); + $size = $module->getImageSize($cat); $maxwidth = $size->width; $maxheight = $size->height; + $cut = $size->cut; - /* - if($mod == "discography") { - if($cat == "cover") { $maxwidth = 100; $maxheight = 100; } - } - if($mod == "gallery") { - if($cat == "randomimage") { $maxwidth = 100; $maxheight = 100; } - if($cat == "photo") { $maxwidth = 100; $maxheight = 100; } - if($cat == "albumicon") { $maxwidth = 100; $maxheight = 100; } - } - */ global $IMAGECACHE, $JPEG_CACHE_QUALITY; - $fullfilename = $IMAGECACHE . "/" . $maxwidth . ":" . $maxheight . ":". urlencode($filename); + $cutstr = "uncut"; + if($cut) $cutstr = "cut"; + $fullfilename = $IMAGECACHE . "/" . $maxwidth . ":" . $maxheight . ":" . $cutstr . ":" . urlencode($filename); // Test the storage dir if(!file_exists($IMAGECACHE)) { @@ -106,21 +120,21 @@ function getCachedImage($filename, $mod, $cat) case ".jpg": $image = imagecreatefromjpeg(urldecode($filename)); if(!$image) errorImage("Could not read: ". $filename); - $image = rescale($image, $maxwidth, $maxheight); + $image = rescale($image, $maxwidth, $maxheight, $cut); imagejpeg($image, $fullfilename, $JPEG_CACHE_QUALITY); break; case ".gif": $image = imagecreatefromgif(urldecode($filename)); if(!$image) errorImage("Could not read: ". $filename); - $image = rescale($image, $maxwidth, $maxheight); + $image = rescale($image, $maxwidth, $maxheight, $cut); imagegif($image, $fullfilename); break; case ".png": $image = imagecreatefrompng(urldecode($filename)); if(!$image) errorImage("Could not read: ". $filename); - $image = rescale($image, $maxwidth, $maxheight); + $image = rescale($image, $maxwidth, $maxheight, $cut); imagepng($image, $fullfilename); break; diff --git a/utils/mail.php b/utils/mail.php index 02d1b7f..f0d46ac 100644 --- a/utils/mail.php +++ b/utils/mail.php @@ -16,8 +16,8 @@ class Email { $headers = "From: " . $sender . "\r\n"; $headers .= "Reply-To: " . $replyto . "\r\n"; $headers .= "Content-Type: text/plain; charset=iso-8859-1\r\n"; - $headers .= "X-Mailer: PHP/" . phpversion(); - + // $headers .= "X-Mailer: PHP/" . phpversion(); + $headers .= "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.13) Gecko/20101207 Thunderbird/3.1.7"; return mail($this->email, utf8_decode($subject), utf8_decode($message), $headers); } } diff --git a/utils/modules.php b/utils/modules.php index c363e6d..4718f95 100644 --- a/utils/modules.php +++ b/utils/modules.php @@ -26,16 +26,18 @@ function loadModule($modulename) global $MODULES_DIR; global $modules; - $modulefile = $MODULES_DIR . "/" . $modulename . ".php"; if(!$modules[$modulename]) { + $modulefile = $MODULES_DIR . "/" . $modulename . ".php"; if(file_exists($modulefile)) { include_once($modulefile); $module = call_user_func($modulename . "_init"); $modules[$modulename] = $module; } else { // Module does not exist. + return; } } + return $modules[$modulename]; } function loadAllModules() 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."&showslider=0&width=25&height=12&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."&lyrics=".$disc."&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."&showslider=0&width=25&height=12&". + "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."&lyrics=".$disc. + "&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&uri=" . $this->cover . "&mod=discography&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&uri=" . + $this->cover . "&mod=discography&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&uri=" . + $this->cover . "&mod=discography&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&uri=" + . $this->path . "/" . $this->image . "&mod=gallery&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."\"> ← 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."&a=".$this->id."&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."\"> ← 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&uri=design/mors/home.png&mod=gallery&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&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&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"); +} + +?> diff --git a/utils/refs.php b/utils/refs.php new file mode 100644 index 0000000..0589cff --- /dev/null +++ b/utils/refs.php @@ -0,0 +1,139 @@ +<?php /* -*- Mode: php; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ + +include_once($UTIL_DIR . "/modules.php"); + +class Ref { + public $mod; + public $id; + + function show() + { + $str = ""; + $module = loadModule($this->mod); + if($module && method_exists($module, "showRef")) { + $str .= "<div class=\"ref\">\n"; + $str .= /*"[".$this->mod."] - ".*/$module->showRef($this->id); + $str .= "</div>\n"; + } + return $str; + } + + function Ref($mod, $id) + { + $this->mod = $mod; + $this->id = $id; + } +} + +class Refs { + public $refs = array(); + + function show() + { + $str = ""; + $str .= "<div class=\"refs\">\n"; + $str .= " <div class=\"refs_header\">References:</div>\n"; + foreach($this->refs as $ref) { + $str .= $ref->show(); + } + $str .= "</div>"; + return $str; + } + + public function write($fp, $indent) + { + if($this->refs) { + fwrite($fp, $indent."<refs>\n"); + foreach($this->refs as $ref) { + fwrite($fp, $indent." <ref mod=\"".$ref->mod."\" id=\"".$ref->id."\"/>\n"); + } + fwrite($fp, $indent."</refs>\n"); + } + } + + public function add($ref) + { + array_push($this->refs, $ref); + } + + public function Refs($refsnode = NULL) + { + if(!$refsnode) return; + + $refs = $refsnode->getElementsByTagName('ref'); + foreach($refs as $r) { + $ref = new Ref($r->getAttribute('mod'), + $r->getAttribute('id')); + $this->add($ref); + } + + } + +} + +function refsAddWidget($form, $refslist) +{ + $form->addWidget(new ListEditor("References:", "refslist", + new LineEdit("ID", "ref_id"), + new LineEdit("Module", "ref_mod"), + $refslist, true)); +} + +function refsAddHiddenWidget($form, $lst) +{ + $vallst = array(); + $vallst["refslist_hidden"] = serialize(refsGetCommaListFromRefs($lst)); + $form->addWidget(new Hidden($vallst)); +} + +function refsGetFromHidden($vals) +{ + $refslist = unserialize($vals["refslist_hidden"]); + return $refslist; +} + +function refsGetCommaListFromRefs($refs) +{ + $lst = array(); + foreach($refs->refs as $ref) { + array_push($lst, $ref->mod.":".$ref->id); + } + return $lst; +} + +function refsGetRefsFromHidden($vals) +{ + $r = refsGetFromHidden($vals); + + $refs = new Refs(); + foreach($r as $k => $val) { + $v = explode(":", $val); + $refmod = $v[0]; + $refid = $v[1]; + $ref = new Ref($refmod, $refid); + $refs->add($ref); + } + + return $refs; +} + +function refsGetRefsFromWidget() +{ + $lst = refsGetValuesFromWidget(); + $refs = new Refs(); + foreach($lst as $val) { + $v = explode(":", $val); + $refmod = $v[0]; + $refid = $v[1]; + $ref = new Ref($refmod, $refid); + $refs->add($ref); + } + return $refs; +} + +function refsGetValuesFromWidget() +{ + global $GLOBALS; + return $GLOBALS["refslist"]; +} +?>
\ No newline at end of file |