2008-08-28 00:04:20 +02:00
|
|
|
<?php
|
|
|
|
/**
|
2008-08-28 16:53:31 +02:00
|
|
|
* @file
|
|
|
|
* Funktionen für den Aufbau der Bildergalerie.
|
|
|
|
*
|
|
|
|
* @author Jan Dittberner <jan@dittberner.info>
|
|
|
|
* @version \$Id$
|
2008-08-28 00:04:20 +02:00
|
|
|
*
|
2009-07-11 21:14:36 +02:00
|
|
|
* Copyright (c) 2007, 2008, 2009 Jan Dittberner <jan@dittberner.info>
|
2008-08-28 00:04:20 +02:00
|
|
|
* Jan Dittberner IT-Consulting & -Solutions,
|
|
|
|
* Cottbuser Str. 1, D-01129 Dresden
|
|
|
|
*
|
|
|
|
* This file is part of the ScrollingJQueryGallery component of the
|
|
|
|
* gnuviech-server.de Websitetools
|
|
|
|
*
|
|
|
|
* ScrollingJQueryGallery is free software: you can redistribute it
|
|
|
|
* and/or modify it under the terms of the GNU General Public License as
|
|
|
|
* published by the Free Software Foundation, either version 3 of the
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* ScrollingJQueryGallery is distributed in the hope that it will be
|
|
|
|
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with ScrollingJQueryGallery. If not, see
|
|
|
|
* <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
define(IMAGESEC, "images");
|
|
|
|
define(GALLERYSEC, "gallery");
|
|
|
|
define(GALLERY_RE, '/^[\w\d _-]+$/');
|
|
|
|
|
2009-07-31 21:20:07 +02:00
|
|
|
define(SCALE_WIDTH, 0);
|
|
|
|
define(SCALE_HEIGHT, 1);
|
|
|
|
define(SCALE_BOTH, 2);
|
|
|
|
|
2009-07-11 22:48:17 +02:00
|
|
|
$basedir = realpath(implode(DIRECTORY_SEPARATOR, array(dirname(__file__), '..')));
|
|
|
|
$inifile = implode(DIRECTORY_SEPARATOR, array($basedir, 'gallery.ini'));
|
|
|
|
|
|
|
|
if (!file_exists($inifile)) {
|
|
|
|
die("required $inifile not found.");
|
2009-07-10 22:55:45 +02:00
|
|
|
}
|
2009-07-11 22:48:17 +02:00
|
|
|
$configuration = parse_ini_file($inifile);
|
2009-07-10 22:55:45 +02:00
|
|
|
if (array_key_exists('logfile', $configuration)) {
|
|
|
|
error_reporting(E_ALL);
|
|
|
|
ini_set('display_errors', 0);
|
|
|
|
ini_set('log_errors', 1);
|
|
|
|
ini_set('error_log', $configuration['logfile']);
|
|
|
|
}
|
|
|
|
|
2009-07-11 13:53:43 +02:00
|
|
|
require_once('theme.class.php');
|
2009-07-11 17:13:48 +02:00
|
|
|
|
|
|
|
if (array_key_exists('theme', $_GET) &&
|
|
|
|
preg_match('/^[a-zA-Z0-9_-]+$/', $_GET['theme'])) {
|
2009-07-11 22:48:25 +02:00
|
|
|
$theme = new Theme($_GET['theme'], $configuration);
|
2009-07-11 17:13:48 +02:00
|
|
|
} else {
|
2009-07-11 22:48:25 +02:00
|
|
|
$theme = new Theme($configuration['defaulttheme'], $configuration);
|
2009-07-11 17:13:48 +02:00
|
|
|
}
|
2009-07-11 13:53:43 +02:00
|
|
|
|
2008-08-28 16:53:31 +02:00
|
|
|
/**
|
|
|
|
* Prüft, ob eine Galerie mit dem übergebenen Namen existiert.
|
|
|
|
*
|
|
|
|
* @param $galleryname Galeriename
|
|
|
|
*
|
|
|
|
* @return @c true, wenn die Galerie existiert und einen erlaubten
|
|
|
|
* Verzeichnisnamen hat, sonst @c false
|
|
|
|
*/
|
2008-08-28 00:04:20 +02:00
|
|
|
function galleryExists($galleryname) {
|
2009-07-11 22:48:17 +02:00
|
|
|
global $configuration;
|
|
|
|
|
2008-08-28 00:04:20 +02:00
|
|
|
return preg_match(GALLERY_RE, $galleryname) &&
|
2009-07-11 22:48:17 +02:00
|
|
|
realpath($configuration['gallerydir'] . DIRECTORY_SEPARATOR . $galleryname);
|
2008-08-28 00:04:20 +02:00
|
|
|
}
|
|
|
|
|
2008-08-28 16:53:31 +02:00
|
|
|
/**
|
|
|
|
* Liefert geparste Konfigurationsinformationen zu einer Galerie oder
|
|
|
|
* die globale Konfiguration. Die Konfigurationsdaten einer Galerie
|
|
|
|
* stehen in der Datei @c galleryinfo.ini in dem Verzeichnis der
|
|
|
|
* Galerie. Die globale Konfiguration liegt in der gleichnamigen Datei
|
|
|
|
* im Elternverzeichnis der Galerien.
|
|
|
|
*
|
|
|
|
* @param $galleryname Galeriename oder @c null, wenn die globale
|
|
|
|
* Konfiguration geparst werden soll
|
|
|
|
*
|
|
|
|
* @return Ergebnis von @c parse_ini_file() oder ein leeres Array,
|
|
|
|
* wenn keine Konfigurationsdatei vorhanden ist
|
|
|
|
*/
|
2008-08-28 00:04:20 +02:00
|
|
|
function getGalleryConfig($galleryname = null) {
|
2009-07-11 22:48:17 +02:00
|
|
|
global $configuration;
|
|
|
|
|
2008-08-28 00:04:20 +02:00
|
|
|
if ($galleryname) {
|
2009-07-11 22:48:17 +02:00
|
|
|
$filepath = realpath(implode(DIRECTORY_SEPARATOR,
|
|
|
|
array($configuration['gallerydir'], $galleryname,
|
|
|
|
'galleryinfo.ini')));
|
2008-08-28 00:04:20 +02:00
|
|
|
} else {
|
2009-07-11 22:48:17 +02:00
|
|
|
$filepath = realpath(implode(DIRECTORY_SEPARATOR,
|
|
|
|
array($configuration['gallerydir'], 'galleryinfo.ini')));
|
2008-08-28 00:04:20 +02:00
|
|
|
}
|
|
|
|
if (is_file($filepath)) {
|
|
|
|
return parse_ini_file($filepath, true);
|
|
|
|
}
|
|
|
|
return array();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2008-08-28 16:53:31 +02:00
|
|
|
* Holt die Bildinformationen zu einem Bild.
|
2008-08-28 00:04:20 +02:00
|
|
|
*
|
|
|
|
* @param $imagename Bildname
|
2008-08-28 16:53:31 +02:00
|
|
|
*
|
2008-08-28 00:04:20 +02:00
|
|
|
* @param $galleryname Galleriename
|
2008-08-28 16:53:31 +02:00
|
|
|
*
|
|
|
|
* @return assoziatives Array mit folgenden Feldern
|
|
|
|
* @li @a name Bildname
|
|
|
|
* @li @a data Label des Bildes
|
|
|
|
* @li @a preview relative URL des Vorschaubildes
|
|
|
|
* @li @a full relative URL des Vollbildes
|
2008-08-28 00:04:20 +02:00
|
|
|
*/
|
2008-08-28 22:06:19 +02:00
|
|
|
function getImageInfo($galleryname, $imagename) {
|
2009-07-11 22:48:17 +02:00
|
|
|
global $theme, $configuration;
|
2009-07-11 21:14:36 +02:00
|
|
|
|
2008-08-28 20:17:57 +02:00
|
|
|
$label = getImageLabel($galleryname, $imagename);
|
|
|
|
$gallerylabel = getGalleryLabel($galleryname);
|
2009-07-31 21:20:07 +02:00
|
|
|
$scaledimage = getScaledImage($galleryname, $imagename,
|
|
|
|
$theme->previewsize, SCALE_BOTH);
|
|
|
|
$scaledsize = getimagesize($configuration['gallerydir'] .
|
|
|
|
DIRECTORY_SEPARATOR . $scaledimage);
|
2008-08-28 00:04:20 +02:00
|
|
|
return array("name" => $imagename,
|
2008-08-28 22:06:19 +02:00
|
|
|
"label" => $label,
|
2009-07-31 21:20:07 +02:00
|
|
|
"preview" => array($configuration['gallerypath'] . '/' .
|
|
|
|
$scaledimage, $scaledsize[0], $scaledsize[1]),
|
2009-07-11 22:48:17 +02:00
|
|
|
"full" => implode('/', array($configuration['gallerypath'],
|
|
|
|
$galleryname, $imagename)),
|
2008-08-28 20:17:57 +02:00
|
|
|
"title" => sprintf("%s :: %s", $gallerylabel, $label)
|
2008-08-28 00:04:20 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2008-08-28 16:53:31 +02:00
|
|
|
/**
|
|
|
|
* Liefert das Label zu einem Bild. Wenn es in der @a images-Sektion
|
|
|
|
* der Datei @c galleryinfo.ini der angegebenen Galerie einen Eintrag
|
|
|
|
* mit dem übergebenen Bildnamen gibt, wird dieser zurückgegeben,
|
|
|
|
* ansonsten der Bildname selbst.
|
|
|
|
*
|
|
|
|
* @param $galleryname Galeriename
|
|
|
|
*
|
|
|
|
* @param $imagename Bildname
|
|
|
|
*
|
|
|
|
* @return Label zu dem Bild
|
|
|
|
*/
|
2008-08-28 00:04:20 +02:00
|
|
|
function getImageLabel($galleryname, $imagename) {
|
2009-07-11 22:48:17 +02:00
|
|
|
global $configuration;
|
|
|
|
|
|
|
|
$gallerypath = realpath($configuration['gallerydir'] . DIRECTORY_SEPARATOR . $galleryname);
|
2008-08-28 00:04:20 +02:00
|
|
|
if (empty($gallerypath) || !is_dir($gallerypath)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
$filepath = $gallerypath . DIRECTORY_SEPARATOR . $imagename;
|
|
|
|
if (!is_file($filepath)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
$inidata = getGalleryConfig($galleryname);
|
|
|
|
$value = $inidata[IMAGESEC][$imagename];
|
|
|
|
if ($value) {
|
|
|
|
return $value;
|
|
|
|
}
|
|
|
|
return $imagename;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2008-08-28 20:17:57 +02:00
|
|
|
* Liefert das Label der Galerie. Das Label wird aus dem Wert @a title
|
|
|
|
* der Sektion @a gallery der @c galleryinfo.ini der Galerie
|
|
|
|
* geholt. Falls dieser Wert nicht definiert ist, wird der Name der
|
|
|
|
* Galerie zurückgegeben.
|
|
|
|
*
|
|
|
|
* @param $galleryname Galeriename
|
|
|
|
*
|
|
|
|
* @return Label der Galerie
|
|
|
|
*/
|
|
|
|
function getGalleryLabel($galleryname) {
|
|
|
|
$inidata = getGalleryConfig($galleryname);
|
|
|
|
if ($inidata[GALLERYSEC]['title']) {
|
|
|
|
$label = $inidata[GALLERYSEC]['title'];
|
|
|
|
} else {
|
|
|
|
$label = $galleryname;
|
|
|
|
}
|
|
|
|
return $label;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Liefert die aktuelle Galerie. Die Galerie kann entweder im
|
|
|
|
* GET-Parameter @c galleryname stehen, als Wert @a default in der
|
|
|
|
* Sektion @a gallery der zentralen @c galleryinfo.ini angegeben
|
2009-07-11 22:48:17 +02:00
|
|
|
* werden oder es wird das erste Unterverzeichnis von @c gallerydir
|
2008-08-28 20:17:57 +02:00
|
|
|
* verwendet.
|
2008-08-28 16:53:31 +02:00
|
|
|
*
|
|
|
|
* @return Galeriename
|
2008-08-28 00:04:20 +02:00
|
|
|
*/
|
|
|
|
function getCurrentGallery() {
|
2009-07-11 22:48:17 +02:00
|
|
|
global $configuration;
|
|
|
|
|
2009-07-10 22:55:45 +02:00
|
|
|
if (array_key_exists('galleryname', $_GET) &&
|
|
|
|
galleryExists($_GET["galleryname"])) {
|
2008-08-28 00:04:20 +02:00
|
|
|
return $_GET["galleryname"];
|
|
|
|
}
|
2009-07-11 22:48:17 +02:00
|
|
|
$filepath = realpath($configuration['gallerydir'] . DIRECTORY_SEPARATOR . 'galleryinfo.ini');
|
2008-08-28 00:04:20 +02:00
|
|
|
if (!empty($filepath)) {
|
|
|
|
$inidata = getGalleryConfig();
|
|
|
|
if (galleryExists($inidata[GALLERYSEC]["default"])) {
|
|
|
|
return $inidata[GALLERYSEC]["default"];
|
|
|
|
}
|
|
|
|
}
|
2009-07-11 22:48:17 +02:00
|
|
|
foreach (glob(realpath($configuration['gallerydir']) . DIRECTORY_SEPARATOR . '*', GLOB_ONLYDIR) as $directory) {
|
2008-08-28 00:04:20 +02:00
|
|
|
$basename = basename($directory);
|
|
|
|
if (galleryExists($basename)) {
|
|
|
|
return $basename;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2008-08-28 16:53:31 +02:00
|
|
|
/**
|
|
|
|
* Liefert eine skalierte Version zu dem übergebenen Bild der
|
|
|
|
* übergebenen Galerie und generiert dieses bei Bedarf.
|
|
|
|
*
|
|
|
|
* @param $galleryname Galeriename
|
|
|
|
*
|
|
|
|
* @param $basename Bildname
|
|
|
|
*
|
|
|
|
* @param $maxdim maximale Breite oder Höhe des skalierten Bildes in
|
|
|
|
* Pixeln
|
|
|
|
*
|
|
|
|
* @param $scaleheight Angabe ob die Höhe oder die Breite für den
|
|
|
|
* Maximalwert beachtet werden soll, wenn dieser Parameter @c true
|
|
|
|
* ist, wird die Höhe auf @a $maxdim skaliert, ansonsten die Breite
|
|
|
|
*
|
2009-07-11 22:48:17 +02:00
|
|
|
* @return Pfad des skalierten Bildes relativ zu @a gallerydir
|
2008-08-28 16:53:31 +02:00
|
|
|
*/
|
2009-07-31 21:20:07 +02:00
|
|
|
function getScaledImage($galleryname, $basename, $maxdim, $scaletype) {
|
2009-07-11 22:48:17 +02:00
|
|
|
global $configuration;
|
|
|
|
|
2008-08-28 00:04:20 +02:00
|
|
|
if ($maxdim == 0) {
|
|
|
|
debug_print_backtrace();
|
|
|
|
}
|
2009-07-11 22:48:17 +02:00
|
|
|
$gallerydir = realpath($configuration['gallerydir'] . DIRECTORY_SEPARATOR . $galleryname);
|
2009-07-31 21:20:07 +02:00
|
|
|
$originalfile = $gallerydir . DIRECTORY_SEPARATOR . $basename;
|
|
|
|
switch($scaletype) {
|
|
|
|
case SCALE_WIDTH:
|
|
|
|
$scaleheight = false;
|
|
|
|
break;
|
|
|
|
case SCALE_HEIGHT:
|
|
|
|
$scaleheight = true;
|
|
|
|
break;
|
|
|
|
case SCALE_BOTH:
|
|
|
|
$originalsize = getimagesize($originalfile);
|
|
|
|
$scaleheight = ($originalsize[1] > $originalsize[0]);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
header('Content-Type: text/plain');
|
|
|
|
debug_print_backtrace();
|
|
|
|
die('Unknown scaletype');
|
|
|
|
}
|
|
|
|
|
2008-08-28 00:04:20 +02:00
|
|
|
if ($scaleheight) {
|
2009-07-15 23:32:11 +02:00
|
|
|
$scaleddir = sprintf("scaled_x%d", $maxdim);
|
2008-08-28 00:04:20 +02:00
|
|
|
} else {
|
2009-07-15 23:32:11 +02:00
|
|
|
$scaleddir = sprintf("scaled%dx_", $maxdim);
|
2008-08-28 00:04:20 +02:00
|
|
|
}
|
2009-07-15 23:32:11 +02:00
|
|
|
$scaleddirpath = implode(DIRECTORY_SEPARATOR,
|
|
|
|
array($configuration['gallerydir'], $galleryname, $scaleddir));
|
2008-08-28 00:04:20 +02:00
|
|
|
if (!is_dir($scaleddirpath)) {
|
|
|
|
// versuchen das Thumbnail-Verzeichnis anzulegen
|
|
|
|
$mkdir = @mkdir($scaleddirpath, 0755);
|
|
|
|
if (!$mkdir) {
|
2009-07-10 22:55:45 +02:00
|
|
|
trigger_error("could not create directory $scaleddirpath.\n",
|
|
|
|
E_USER_WARNING);
|
2009-07-15 23:32:11 +02:00
|
|
|
return $galleryname . '/' . $basename;
|
2008-08-28 00:04:20 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$scaledimage = $scaleddirpath . DIRECTORY_SEPARATOR . $basename;
|
|
|
|
if (!is_file($scaledimage)) {
|
|
|
|
// Datei erzeugen
|
|
|
|
$origimage = imagecreatefromjpeg($originalfile);
|
|
|
|
$origx = imagesx($origimage);
|
|
|
|
$origy = imagesy($origimage);
|
|
|
|
if ($scaleheight) {
|
|
|
|
$scaleratio = $origy / (1.0 * $maxdim);
|
|
|
|
$newy = $maxdim;
|
|
|
|
$newx = (int) $origx / $scaleratio;
|
|
|
|
} else {
|
|
|
|
$scaleratio = $origx / (1.0 * $maxdim);
|
|
|
|
$newx = $maxdim;
|
|
|
|
$newy = (int) $origy / $scaleratio;
|
|
|
|
}
|
|
|
|
$newimage = imagecreatetruecolor($newx, $newy);
|
|
|
|
imagecopyresampled($newimage, $origimage, 0, 0, 0, 0, $newx, $newy,
|
|
|
|
$origx, $origy);
|
|
|
|
imagejpeg($newimage, $scaledimage, 90);
|
|
|
|
}
|
2009-07-15 23:32:11 +02:00
|
|
|
return implode('/', array($galleryname, $scaleddir, $basename));
|
2008-08-28 00:04:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gibt die Informationen über Vorschaubilder zurück.
|
|
|
|
*
|
2008-08-28 16:53:31 +02:00
|
|
|
* @param $galleryname Galeriename
|
|
|
|
*
|
|
|
|
* @return Array mit drei Elementen, dessen erstes Element die
|
|
|
|
* aufsummierte Breite der Einzelbilder, dessen zweites Element der
|
|
|
|
* Galeriename und dessen drittes Element ein assoziatives Array mit
|
|
|
|
* den Bildnamen als Keys und Arrays mit dem Pfadnamen das Thumbnails
|
|
|
|
* und dem Ergebnis von getimagesize() als Werten ist.
|
2008-08-28 00:04:20 +02:00
|
|
|
*/
|
|
|
|
function getThumbNailInfo($galleryname) {
|
2009-07-11 22:48:17 +02:00
|
|
|
global $theme, $configuration;
|
2009-07-11 21:14:36 +02:00
|
|
|
|
2008-08-28 00:04:20 +02:00
|
|
|
$thumbsizes = array();
|
2009-07-11 21:14:36 +02:00
|
|
|
$thumbdimsum = 2;
|
2009-07-31 21:20:07 +02:00
|
|
|
$scaletype = ($theme->themetype == 'horizontal') ? SCALE_HEIGHT : SCALE_WIDTH;
|
2009-07-11 22:48:17 +02:00
|
|
|
foreach (glob(realpath($configuration['gallerydir'] . DIRECTORY_SEPARATOR .
|
2008-08-28 00:04:20 +02:00
|
|
|
$galleryname) . DIRECTORY_SEPARATOR .
|
|
|
|
'*.jp{e,}g', GLOB_BRACE) as $filename) {
|
|
|
|
$basename = basename($filename);
|
2009-07-31 21:20:07 +02:00
|
|
|
$thumbfile = getScaledImage($galleryname, $basename, $theme->thumbsize,
|
|
|
|
$scaletype);
|
2009-07-11 22:48:17 +02:00
|
|
|
if ($thumbsize = getimagesize(realpath($configuration['gallerydir'] .
|
2008-08-28 00:04:20 +02:00
|
|
|
DIRECTORY_SEPARATOR .
|
|
|
|
$thumbfile))) {
|
|
|
|
$thumbsizes[$basename] = array($thumbfile, $thumbsize);
|
2009-07-11 21:14:36 +02:00
|
|
|
if ($theme->themetype == 'horizontal') {
|
|
|
|
$thumbdimsum = $thumbdimsum + $thumbsize[0] + 3;
|
|
|
|
} else {
|
|
|
|
$thumbdimsum = $thumbdimsum + $thumbsize[1] + 3;
|
|
|
|
}
|
2008-08-28 00:04:20 +02:00
|
|
|
}
|
|
|
|
}
|
2009-07-11 21:14:36 +02:00
|
|
|
return array($thumbdimsum, $galleryname, $thumbsizes);
|
2008-08-28 00:04:20 +02:00
|
|
|
}
|
|
|
|
|
2008-08-28 16:53:31 +02:00
|
|
|
/**
|
|
|
|
* Gibt die Links zu den existierenden Galerien zurück.
|
|
|
|
*
|
|
|
|
* @return Array, welches je Gallerie ein assoziatives Array mit den
|
|
|
|
* Keys @a gallery, @a label und @a url enthält. Die Labels für die
|
|
|
|
* Galerien werden aus dem @a title-Feld der @a gallery-Sektion der @c
|
|
|
|
* galleryinfo.ini ausgelesen. Wenn diese Feld nicht gesetzt ist, wird
|
|
|
|
* der Galeriename verwendet.
|
|
|
|
*
|
|
|
|
* @see galleryExists()
|
|
|
|
* @see getGalleryConfig()
|
|
|
|
*/
|
2008-08-28 00:04:20 +02:00
|
|
|
function getGalleryLinks() {
|
2009-07-11 22:48:17 +02:00
|
|
|
global $configuration;
|
|
|
|
|
2008-08-28 16:53:31 +02:00
|
|
|
$retval = array();
|
2009-07-11 22:48:17 +02:00
|
|
|
foreach (glob(realpath($configuration['gallerydir']) . DIRECTORY_SEPARATOR . '*',
|
2008-08-28 16:53:31 +02:00
|
|
|
GLOB_ONLYDIR) as $directory) {
|
|
|
|
$basename = basename($directory);
|
|
|
|
if (galleryExists($basename)) {
|
2009-07-11 21:14:44 +02:00
|
|
|
$urlparams = array();
|
|
|
|
$urlparams['galleryname'] = $basename;
|
|
|
|
if (array_key_exists('theme', $_GET)) {
|
|
|
|
$urlparams['theme'] = $_GET['theme'];
|
|
|
|
}
|
|
|
|
$parts = array();
|
|
|
|
foreach ($urlparams as $key => $value) {
|
|
|
|
$parts[] = sprintf("%s=%s", $key, urlencode($value));
|
|
|
|
}
|
|
|
|
$url = sprintf('index.php?%s',
|
|
|
|
implode(ini_get('arg_separator.output'), $parts));
|
2008-08-28 20:17:57 +02:00
|
|
|
$retval[] = array('gallery' => $basename,
|
|
|
|
'label' => getGalleryLabel($basename),
|
2009-07-11 21:14:44 +02:00
|
|
|
'url' => htmlspecialchars($url));
|
2008-08-28 16:53:31 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return $retval;
|
2008-08-28 00:04:20 +02:00
|
|
|
}
|
|
|
|
|
2008-08-28 16:53:31 +02:00
|
|
|
/**
|
2008-08-28 22:01:14 +02:00
|
|
|
* Gibt für die Ausgabe aufbereitete Informationen über die
|
|
|
|
* Thumbnail-Bilder die in @a $thumbinfo definiert sind zurück.
|
2008-08-28 16:53:31 +02:00
|
|
|
*
|
|
|
|
* @param &$thumbinfo Referenz auf ein Array, wie es von
|
|
|
|
* getThumbNailInfo() zurückgegeben wird
|
|
|
|
*
|
2008-08-28 22:01:14 +02:00
|
|
|
* @return ein Array mit einem assoziativen Array pro Thumbnail-Bild
|
|
|
|
* mit den Keys @a src, @a sizes und @a alt, die jeweils die relative
|
|
|
|
* URL des Thumbnail-Bildes, die Größenangaben für ein img-Tag sowie
|
|
|
|
* die Angaben für das alt-Attribut eines img-Tags enthalten
|
2008-08-28 16:53:31 +02:00
|
|
|
*
|
|
|
|
* @see getThumbNailInfo()
|
|
|
|
*/
|
2008-08-28 22:01:14 +02:00
|
|
|
function getAllThumbnails(&$thumbinfo) {
|
2009-07-11 22:48:17 +02:00
|
|
|
global $configuration;
|
|
|
|
|
2008-08-28 22:01:14 +02:00
|
|
|
$retval = array();
|
2008-08-28 00:04:20 +02:00
|
|
|
foreach ($thumbinfo[2] as $basename => $data) {
|
2009-07-15 23:32:11 +02:00
|
|
|
$retval[] = array('src' => $configuration['gallerypath'] . '/' . $data[0],
|
2008-08-28 22:01:14 +02:00
|
|
|
'sizes' => $data[1][3],
|
|
|
|
'alt' => getImageLabel($thumbinfo[1], $basename));
|
2008-08-28 00:04:20 +02:00
|
|
|
}
|
2008-08-28 22:01:14 +02:00
|
|
|
return $retval;
|
2008-08-28 00:04:20 +02:00
|
|
|
}
|
|
|
|
|
2008-08-28 16:53:31 +02:00
|
|
|
/**
|
2008-08-28 22:01:14 +02:00
|
|
|
* Gibt die Daten für das erste Vorschaubild aus @a $thumbinfo zurück.
|
2008-08-28 16:53:31 +02:00
|
|
|
*
|
|
|
|
* @param &$thumbinfo Referenz auf ein Array, wie es von
|
|
|
|
* getThumbNailInfo() zurückgegeben wird
|
|
|
|
*
|
2008-08-28 22:01:14 +02:00
|
|
|
* @return ein assoziatives Array mit den Keys @a title, @a full, @a
|
|
|
|
* src, @a alt und @a sizes jeweils mit den Werten Titel des Bildes,
|
|
|
|
* relative URL der Vollbildansicht, relative URL des Vorschaubildes,
|
|
|
|
* Alternativtext für das Bild und Größenangaben des Bildes für ein
|
|
|
|
* img-Tag
|
2008-08-28 16:53:31 +02:00
|
|
|
*
|
|
|
|
* @see getThumbNailInfo()
|
|
|
|
*/
|
2008-08-28 22:01:14 +02:00
|
|
|
function getFirstPreview(&$thumbinfo) {
|
2009-07-11 22:48:17 +02:00
|
|
|
global $theme, $configuration;
|
2009-07-11 21:14:36 +02:00
|
|
|
|
2008-08-28 22:01:14 +02:00
|
|
|
reset($thumbinfo[2]);
|
|
|
|
$basename = key($thumbinfo[2]);
|
|
|
|
$data = current($thumbinfo[2]);
|
|
|
|
$galleryname = $thumbinfo[1];
|
2009-07-15 23:32:11 +02:00
|
|
|
$fullname = $configuration['gallerypath'] . '/' . $galleryname . '/' . $basename;
|
2008-08-28 22:01:14 +02:00
|
|
|
$scaledimage = getScaledImage($galleryname, $basename,
|
2009-07-31 21:20:07 +02:00
|
|
|
$theme->previewsize, SCALE_BOTH);
|
2009-07-11 22:48:17 +02:00
|
|
|
$scaledimagesize = getimagesize(realpath($configuration['gallerydir'] .
|
2008-08-28 22:01:14 +02:00
|
|
|
DIRECTORY_SEPARATOR .
|
|
|
|
$scaledimage));
|
|
|
|
$label = getImageLabel($galleryname, $basename);
|
|
|
|
return array('title' => $label,
|
|
|
|
'full' => $fullname,
|
2009-07-15 23:32:11 +02:00
|
|
|
'src' => $configuration['gallerypath'] . '/' . $scaledimage,
|
2008-08-28 22:01:14 +02:00
|
|
|
'alt' => $label,
|
|
|
|
'sizes' => $scaledimagesize[3]);
|
2008-08-28 00:04:20 +02:00
|
|
|
}
|
|
|
|
|
2008-08-28 16:53:31 +02:00
|
|
|
/**
|
2008-08-28 22:01:14 +02:00
|
|
|
* Gibt die Beschreibung des ersten Bildes aus @a $thumbinfo zurück.
|
2008-08-28 16:53:31 +02:00
|
|
|
*
|
|
|
|
* @param &$thumbinfo Referenz auf ein Array, wie es von
|
|
|
|
* getThumbNailInfo() zurückgegeben wird
|
|
|
|
*
|
2008-08-28 22:01:14 +02:00
|
|
|
* @return HTML-kodierte Beschreibung des Bildes
|
2008-08-28 16:53:31 +02:00
|
|
|
*
|
|
|
|
* @see getThumbNailInfo()
|
|
|
|
*/
|
2008-08-28 22:01:14 +02:00
|
|
|
function getFirstDescription(&$thumbinfo) {
|
|
|
|
reset($thumbinfo[2]);
|
|
|
|
return htmlentities(getImageLabel($thumbinfo[1], key($thumbinfo[2])));
|
2008-08-28 00:04:20 +02:00
|
|
|
}
|
2008-08-28 20:17:57 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gibt den Titeltext für die Galerie aus.
|
|
|
|
*
|
|
|
|
* @param &$thumbinfo Referenz auf ein Array, wie es von
|
|
|
|
* getThumbNailInfo() zurückgegeben wird
|
|
|
|
*
|
|
|
|
* @return Inhalt für das title-Tag auf der Ausgabeseite
|
|
|
|
*/
|
|
|
|
function getGalleryTitle(&$thumbinfo) {
|
|
|
|
foreach ($thumbinfo[2] as $basename => $data) {
|
|
|
|
return htmlentities(sprintf("%s :: %s", getGalleryLabel($thumbinfo[1]),
|
|
|
|
getImageLabel($thumbinfo[1], $basename)));
|
|
|
|
}
|
|
|
|
}
|