summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordeva <deva>2010-01-27 15:11:09 +0000
committerdeva <deva>2010-01-27 15:11:09 +0000
commit657b191f6b4ae00d714fffe6911d8999d0a99873 (patch)
treedf216764496df3457420a0f7d378603bb00b6205
parent8aafefe813e22db63b3a4b502a3e8d0a335b775e (diff)
Major update of gallery module. Now we actually use span tags for the css layout engine to use.
-rw-r--r--utils/modules/gallery.php142
1 files changed, 108 insertions, 34 deletions
diff --git a/utils/modules/gallery.php b/utils/modules/gallery.php
index 74a0ba0..308f10a 100644
--- a/utils/modules/gallery.php
+++ b/utils/modules/gallery.php
@@ -2,8 +2,6 @@
/* -*- Mode: php; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
include_once($UTIL_DIR . "/convert.php");
-include_once($UTIL_DIR . "/markdown.php");
-include_once($UTIL_DIR . "/modules.php");
function isJpeg($file)
{
@@ -35,22 +33,27 @@ class Photo {
public function write($fp)
{
fwrite($fp, " <photo id=\"" .
- htmlspecialchars($this->id, ENT_QUOTES, "UTF-8") . "\"\n");
+ htmlspecialchars($this->id, ENT_QUOTES, "UTF-8") . "\"\n");
fwrite($fp, " title=\"" .
- htmlspecialchars($this->title, ENT_QUOTES, "UTF-8") . "\"\n");
+ htmlspecialchars($this->title, ENT_QUOTES, "UTF-8") . "\"\n");
fwrite($fp, " image=\"" .
- htmlspecialchars($this->image, ENT_QUOTES, "UTF-8") . "\"/>\n");
+ htmlspecialchars($this->image, ENT_QUOTES, "UTF-8") . "\"/>\n");
}
- public function show($maxwidth = 100, $maxheight = 100, $showbig = false)
+ public function show($indent, $maxwidth = 100, $maxheight = 100, $showbig = false)
{
- $str = "<p>\n";
- if($showbig) $str .= " <a href=\"" . $this->path . "/" . $this->image . "\">\n";
-
- $str .= " <img src=\"?mode=imagecache&amp;uri=" . $this->path . "/" . $this->image . "&amp;mw=".$maxwidth."&amp;mh=".$maxheight."\"\"/><br/>\n";
- if($showbig) $str .= " </a>\n";
- $str .= " " . $this->title . "\n";
- $str .= "</p>\n";
+ $str = "";
+ $str .= $indent."<span class=\"photo\">\n";
+ if($showbig) $str .= $indent." <a href=\"" . $this->path . "/" . $this->image . "\">\n";
+
+ $str .= $indent." <span class=\"photo_image\">\n";
+ $str .= $indent." <img alt=\"".$this->title."\"\n";
+ $str .= $indent." src=\"?mode=imagecache&amp;uri="
+ . $this->path . "/" . $this->image . "&amp;mw=".$maxwidth."&amp;mh=".$maxheight."\"/>\n";
+ $str .= $indent." </span>\n";
+ if($showbig) $str .= $indent." </a>\n";
+ $str .= $indent." <span class=\"photo_caption\">" . $this->title . "</span>\n";
+ $str .= $indent."</span>\n";
return $str;
}
@@ -95,24 +98,76 @@ class Album {
fwrite($fp, " </album>\n");
}
- public function show($maxwidth, $maxheight)
+ public function show($indent, $maxwidth, $maxheight)
{
global $page;
- $str = "<p>\n";
- //$str .= " <img src=\"?mode=imagecache&amp;uri=" . $this->getPath() . "/" . $this->photos[$this->icon]->image . "&amp;mw=".($maxwidth/2)."&amp;mh=".($maxheight/2)."\"\"/><br/>\n";
- //$str .= "<img src=\"" . $this->getPath() . "/" . $this->photos[$this->icon]->image . "\" width=\"64\"/>\n";
- $str .= "<strong>" . $this->title . "</strong>\n";
- $str .= "</p>\n";
+
+ $str = "";
+ $str .= $indent."<span class=\"album\">\n";
+ $str .= $indent." <span class=\"album_title\">" . $this->title . "</span>\n";
foreach($this->photos as $photo) {
- $str .= "<a href=\"?page=".$page."&amp;a=".$this->id."&amp;p=".$photo->id."\">".$photo->show($maxwidth, $maxheight)."</a>";
+ $str .= $indent." <a class=\"photo_icon\" href=\"?page=".$page."&amp;a=".$this->id."&amp;p=".$photo->id."\">\n";
+ $str .= $photo->show($indent." ", $maxwidth, $maxheight);
+ $str .= $indent." </a>\n";
}
+ $str .= $indent."</span>\n";
+
return $str;
}
- public function showIcon($maxwidth, $maxheight)
+ public function showIcon($indent, $maxwidth, $maxheight)
{
global $page;
- return "<a href=\"?page=".$page."&amp;a=".$this->id."\">".$this->title . $this->photos[$this->icon]->show($maxwidth, $maxheight)."</a>\n";
+
+ $str = "";
+
+ $str .= $indent."<a class=\"album\" href=\"?page=".$page."&amp;a=".$this->id."\">\n";
+ $str .= $indent." <span class=\"album_title\">".$this->title."</span>\n";
+ $str .= $indent." <span class=\"album_icon\">\n";
+ $str .= $this->photos[$this->icon]->show($indent." ", $maxwidth, $maxheight);
+ $str .= $indent." </span>\n";
+ $str .= $indent."</a>\n";
+
+ return $str;
+ }
+
+ public function showPhoto($indent, $photo, $maxwidth, $maxheight, $maxwidth_icon, $maxheight_icon)
+ {
+ global $GLOBALS;
+
+ $album = $this->id;
+
+ $str = "";
+
+ $str = $this->photos[$photo]->show($indent, $maxwidth, $maxheight, true);
+
+ $str .= $indent."<span class=\"nav_icons\">\n";
+ if($this->photos[$photo - 1]) {
+ $str .= $indent." <a class=\"nav_icon\" href=\"?page=gallery&amp;a=".$album."&amp;p=".($photo-1)."\">\n";
+ $str .= $this->photos[$photo - 1]->show($indent." ", $maxwidth_icon, $maxheight_icon);
+ $str .= $indent." </a>\n";
+ } else {
+ $str .= $indent." <a class=\"nav_icon\" href=\"?page=gallery&amp;a=".$album."\">\n";
+ $str .= $indent." <img src=\"gfx/stop.png\"/>\n";
+ $str .= $indent." </a>\n";
+ }
+
+ $str .= $indent." <a class=\"nav_icon\" href=\"?page=gallery&amp;a=".$album."\">\n";
+ $str .= $indent." <img src=\"gfx/home.png\"/>\n";
+ $str .= $indent." </a>\n";
+
+ if($this->photos[$photo + 1]) {
+ $str .= $indent." <a class=\"nav_icon\" href=\"?page=gallery&amp;a=".$album."&amp;p=".($photo+1)."\">\n";
+ $str .= $this->photos[$photo + 1]->show($indent." ", $maxwidth_icon, $maxheight_icon);
+ $str .= $indent." </a>\n";
+ } else {
+ $str .= $indent." <a class=\"nav_icon\" href=\"?page=gallery&amp;a=".$album."\">\n";
+ $str .= $indent." <img src=\"gfx/stop.png\"/>\n";
+ $str .= $indent." </a>\n";
+ }
+ $str .= $indent."</span>\n";
+
+ return $str;
}
public function getPath()
@@ -212,7 +267,7 @@ class Gallery {
unpackImages($_FILES['images'], $album);
$this->add($album);
$this->write();
- echo $album->show($this->maxwidth_icon, $this->maxheight_icon);
+ echo $album->show("", $this->maxwidth_icon, $this->maxheight_icon);
break;
case "select":
@@ -273,31 +328,44 @@ class Gallery {
public function showRandomPhoto()
{
+ $str = "";
+
srand((float) microtime() * 10000000);
if(sizeof($this->albums) == 0) return "";
$album = array_rand($this->albums);
if(sizeof($this->albums[$album]->photos) == 0) return "";
$photo = array_rand($this->albums[$album]->photos);
- return "<a href=\"?page=gallery&amp;a=".$album."&amp;p=".$photo."\">".$this->albums[$album]->photos[$photo]->show($this->maxwidth_rand, $this->maxheight_rand)."</a>";
+
+ $str .= " <a class=\"random_photo_link\" href=\"?page=gallery&amp;a=".$album."&amp;p=".$photo."\">\n";
+ $str .= $this->albums[$album]->photos[$photo]->show(" ", $this->maxwidth_rand, $this->maxheight_rand);
+ $str .= " </a>\n";
+
+ return $str;
}
public function showAlbums()
{
$str = "";
+
+ $str .= "\n<span class=\"albums\">\n";
foreach($this->albums as $album) {
- $str .= $album->showIcon($this->maxwidth_icon, $this->maxheight_icon);
+ $str .= $album->showIcon(" ", $this->maxwidth_icon, $this->maxheight_icon);
}
+ $str .= "</span>\n";
+
return $str;
}
public function showPhoto($album, $photo)
{
- $str = $this->albums[$album]->photos[$photo]->show($this->maxwidth, $this->maxheight, true);
- if($this->albums[$album]->photos[$photo - 1])
- $str .= "<a href=\"?page=gallery&amp;a=".$album."&amp;p=".($photo-1)."\">". $this->albums[$album]->photos[$photo - 1]->show($this->maxwidth_icon, $this->maxheight_icon) . "</a>";
- $str .= "<a href=\"?page=gallery&amp;a=".$album."\"><img src=\"snot.jpg\"/></a>";
- if($this->albums[$album]->photos[$photo + 1])
- $str .= "<a href=\"?page=gallery&amp;a=".$album."&amp;p=".($photo+1)."\">".$this->albums[$album]->photos[$photo + 1]->show($this->maxwidth_icon, $this->maxheight_icon)."</a>";
+ $str = "";
+
+ if($this->albums[$album]) {
+ $str .= $this->albums[$album]->showPhoto(" ", $photo,
+ $this->maxwidth, $this->maxheight,
+ $this->maxwidth_icon, $this->maxheight_icon);
+ }
+
return $str;
}
@@ -306,18 +374,24 @@ class Gallery {
global $a, $p;
$str = "";
+
+ $str .= "\n<span class=\"gallery\">\n";
foreach($params as $param) {
switch($param) {
default:
- if($p != "" && $a != "") return $this->showPhoto($a, $p);
- if($a != "") return $this->albums[$a]->show($this->maxwidth_icon, $this->maxheight_icon);
- return $this->showAlbums();
+ if($p != "" && $a != "") $str .= $this->showPhoto($a, $p);
+ else if($a != "" && $this->albums[$a] && $p == "")
+ $str .= $this->albums[$a]->show(" ", $this->maxwidth_icon, $this->maxheight_icon);
+ else $str .= $this->showAlbums();
+ break;
case "random":
$str .= $this->showRandomPhoto();
break;
}
}
+ $str .= "</span>\n";
+
return $str;
}