From d908520b7ebde8e209a5db89a505f959ad6b76c4 Mon Sep 17 00:00:00 2001 From: deva Date: Tue, 23 Feb 2010 09:21:02 +0000 Subject: New imagecache generation system. --- utils/modules/gallery.php | 51 +++++++++++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 19 deletions(-) (limited to 'utils/modules/gallery.php') 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."\n"; - if($showbig) $str .= $indent." path . "/" . $this->image . "\">\n"; + if($cat == "photo") $str .= $indent." path . "/" . $this->image . "\">\n"; $str .= $indent." \n"; $str .= $indent." \"".$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." \n"; - if($showbig) $str .= $indent." \n"; + if($cat == "photo") $str .= $indent." \n"; $str .= $indent." " . $this->title . "\n"; $str .= $indent."\n"; return $str; @@ -100,7 +100,7 @@ class Album { fwrite($fp, " \n"); } - public function show($indent, $maxwidth, $maxheight) + public function show($indent) { global $page; @@ -109,7 +109,7 @@ class Album { $str .= $indent." " . $this->title . "\n"; foreach($this->photos as $photo) { $str .= $indent." id."&p=".$photo->id."\">\n"; - $str .= $photo->show($indent." ", $maxwidth, $maxheight); + $str .= $photo->show($indent." ", "albumicon"); $str .= $indent." \n"; } $str .= $indent."\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."id."\">\n"; $str .= $indent." ".$this->title."\n"; $str .= $indent." \n"; - $str .= $this->photos[$this->icon]->show($indent." ", $maxwidth, $maxheight); + $str .= $this->photos[$this->icon]->show($indent." ", "albumicon"); $str .= $indent." \n"; $str .= $indent."\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."\n"; if($this->photos[$photo - 1]) { $str .= $indent." \n"; - $str .= $this->photos[$photo - 1]->show($indent." ", $maxwidth_icon, $maxheight_icon); + $str .= $this->photos[$photo - 1]->show($indent." ", "navicon"); $str .= $indent." \n"; } else { $str .= $indent." \n"; @@ -160,7 +160,7 @@ class Album { if($this->photos[$photo + 1]) { $str .= $indent." \n"; - $str .= $this->photos[$photo + 1]->show($indent." ", $maxwidth_icon, $maxheight_icon); + $str .= $this->photos[$photo + 1]->show($indent." ", "navicon"); $str .= $indent." \n"; } else { $str .= $indent." \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 .= " \n"; - $str .= $this->albums[$album]->photos[$photo]->show(" ", $this->maxwidth_rand, $this->maxheight_rand); + $str .= $this->albums[$album]->photos[$photo]->show(" ", "randomimage"); $str .= " \n"; return $str; @@ -351,7 +351,7 @@ class Gallery { $str .= "\n\n"; foreach($this->albums as $album) { - $str .= $album->showIcon(" ", $this->maxwidth_icon, $this->maxheight_icon); + $str .= $album->showIcon(" "); } $str .= "\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"); -- cgit v1.2.3