diff options
Diffstat (limited to 'utils/modules/gallery.php')
-rw-r--r-- | utils/modules/gallery.php | 51 |
1 files changed, 32 insertions, 19 deletions
diff --git a/utils/modules/gallery.php b/utils/modules/gallery.php index e9b2934..d2b751c 100644 --- a/utils/modules/gallery.php +++ b/utils/modules/gallery.php @@ -42,18 +42,18 @@ class Photo { htmlspecialchars($this->image, ENT_QUOTES, "UTF-8") . "\"/>\n"); } - public function show($indent, $maxwidth = 100, $maxheight = 100, $showbig = false) + public function show($indent, $cat) { $str = ""; $str .= $indent."<span class=\"photo\">\n"; - if($showbig) $str .= $indent." <a href=\"" . $this->path . "/" . $this->image . "\">\n"; + if($cat == "photo") $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&uri=" - . $this->path . "/" . $this->image . "&mw=".$maxwidth."&mh=".$maxheight."\"/>\n"; + . $this->path . "/" . $this->image . "&mod=gallery&cat=".$cat."\"/>\n"; $str .= $indent." </span>\n"; - if($showbig) $str .= $indent." </a>\n"; + if($cat == "photo") $str .= $indent." </a>\n"; $str .= $indent." <span class=\"photo_caption\">" . $this->title . "</span>\n"; $str .= $indent."</span>\n"; return $str; @@ -100,7 +100,7 @@ class Album { fwrite($fp, " </album>\n"); } - public function show($indent, $maxwidth, $maxheight) + public function show($indent) { global $page; @@ -109,7 +109,7 @@ class Album { $str .= $indent." <span class=\"album_title\">" . $this->title . "</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." ", $maxwidth, $maxheight); + $str .= $photo->show($indent." ", "albumicon"); $str .= $indent." </a>\n"; } $str .= $indent."</span>\n"; @@ -117,7 +117,7 @@ class Album { return $str; } - public function showIcon($indent, $maxwidth, $maxheight) + public function showIcon($indent) { global $page; @@ -126,14 +126,14 @@ class Album { $str .= $indent."<a class=\"album\" href=\"?page=".$page."&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 .= $this->photos[$this->icon]->show($indent." ", "albumicon"); $str .= $indent." </span>\n"; $str .= $indent."</a>\n"; return $str; } - public function showPhoto($indent, $photo, $maxwidth, $maxheight, $maxwidth_icon, $maxheight_icon) + public function showPhoto($indent, $photo) { global $GLOBALS; @@ -141,12 +141,12 @@ class Album { $str = ""; - $str = $this->photos[$photo]->show($indent, $maxwidth, $maxheight, true); + $str = $this->photos[$photo]->show($indent, "photo"); $str .= $indent."<span class=\"nav_icons\">\n"; if($this->photos[$photo - 1]) { $str .= $indent." <a class=\"nav_icon\" href=\"?page=gallery&a=".$album."&p=".($photo-1)."\">\n"; - $str .= $this->photos[$photo - 1]->show($indent." ", $maxwidth_icon, $maxheight_icon); + $str .= $this->photos[$photo - 1]->show($indent." ", "navicon"); $str .= $indent." </a>\n"; } else { $str .= $indent." <a class=\"nav_icon\" href=\"?page=gallery&a=".$album."\">\n"; @@ -160,7 +160,7 @@ class Album { if($this->photos[$photo + 1]) { $str .= $indent." <a class=\"nav_icon\" href=\"?page=gallery&a=".$album."&p=".($photo+1)."\">\n"; - $str .= $this->photos[$photo + 1]->show($indent." ", $maxwidth_icon, $maxheight_icon); + $str .= $this->photos[$photo + 1]->show($indent." ", "navicon"); $str .= $indent." </a>\n"; } else { $str .= $indent." <a class=\"nav_icon\" href=\"?page=gallery&a=".$album."\">\n"; @@ -269,7 +269,7 @@ class Gallery { unpackImages($_FILES['images'], $album); $this->add($album); $this->write(); - echo $album->show("", $this->maxwidth_icon, $this->maxheight_icon); + echo $album->show("", "albumicon"); break; case "select": @@ -339,7 +339,7 @@ class Gallery { $photo = array_rand($this->albums[$album]->photos); $str .= " <a class=\"random_photo_link\" href=\"?page=gallery&a=".$album."&p=".$photo."\">\n"; - $str .= $this->albums[$album]->photos[$photo]->show(" ", $this->maxwidth_rand, $this->maxheight_rand); + $str .= $this->albums[$album]->photos[$photo]->show(" ", "randomimage"); $str .= " </a>\n"; return $str; @@ -351,7 +351,7 @@ class Gallery { $str .= "\n<span class=\"albums\">\n"; foreach($this->albums as $album) { - $str .= $album->showIcon(" ", $this->maxwidth_icon, $this->maxheight_icon); + $str .= $album->showIcon(" "); } $str .= "</span>\n"; @@ -363,9 +363,7 @@ class Gallery { $str = ""; if($this->albums[$album]) { - $str .= $this->albums[$album]->showPhoto(" ", $photo, - $this->maxwidth, $this->maxheight, - $this->maxwidth_icon, $this->maxheight_icon); + $str .= $this->albums[$album]->showPhoto(" ", $photo); } return $str; @@ -387,7 +385,7 @@ class Gallery { default: 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); + $str .= $this->albums[$a]->show(" "); else $str .= $this->showAlbums(); break; } @@ -410,6 +408,21 @@ class Gallery { return $maxid + 1; } + public function getImageSize($cat) + { + switch($cat) { + case "photo": + return new ImageSize($this->maxwidth, $this->maxheight); + case "randomimage": + return new ImageSize($this->maxwidth_rand, $this->maxheight_rand); + case "navicon": + return new ImageSize($this->maxwidth_icon * 0.7, $this->maxheight_icon * 0.7); + default: + case "albumicon": + return new ImageSize($this->maxwidth_icon, $this->maxheight_icon); + } + } + public function write() { $fp = fopen($this->file, "w"); |