summaryrefslogtreecommitdiff
path: root/utils/modules/gallery.php
diff options
context:
space:
mode:
Diffstat (limited to 'utils/modules/gallery.php')
-rw-r--r--utils/modules/gallery.php131
1 files changed, 120 insertions, 11 deletions
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);
}