Hi,
ich habe versucht ein fertiges gallerie script für eine homepage anzupassen. wenn man auf ein bild von der gallerie klickt wird es in voller größe im selben fenster dargestellt. ich möchte das dieses bild aber in einem neuen fenster angezeigt wird.dank google weiß ich das ich bei
a href= als ziel target=_blank
eintragen muss ich hab das auch probiert aber leider funktioniert es nicht. Ich habe auch in diesem Forum ein ähnliches Thema gefunden, leider kann ich es nicht richtig umsetzen
meine php kenntnisse sind anfänger.
ich hoffe ihr könnt mir helfen
vielen dank !
lg. mana
ich habe versucht ein fertiges gallerie script für eine homepage anzupassen. wenn man auf ein bild von der gallerie klickt wird es in voller größe im selben fenster dargestellt. ich möchte das dieses bild aber in einem neuen fenster angezeigt wird.dank google weiß ich das ich bei
a href= als ziel target=_blank
eintragen muss ich hab das auch probiert aber leider funktioniert es nicht. Ich habe auch in diesem Forum ein ähnliches Thema gefunden, leider kann ich es nicht richtig umsetzen
meine php kenntnisse sind anfänger.
PHP-Code:
<?php
/*
MINIGAL NANO
- A PHP/HTML/CSS based image gallery script
This script and included files are subject to licensing from Creative Commons (http://creativecommons.org/licenses/by-sa/2.5/)
You may use, edit and redistribute this script, as long as you pay tribute to the original author by NOT removing the linkback to www.minigal.dk ("Powered by MiniGal Nano x.x.x")
MiniGal Nano is created by Thomas Rybak
Copyright 2010 by Thomas Rybak
Support: www.minigal.dk
Community: www.minigal.dk/forum
Please enjoy this free script!
*/
// Do not edit below this section unless you know what you are doing!
//error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);
$version = "0.2.3";
include("config.php");
//DEFINE DEFAULT VARIABLES
$page_navigation = "";
$breadcrumb_navigation = "";
$thumbnails = "";
$new = "";
$images = "";
//Make gallery integrateable inside subfolder 'minigalnano'
if ($integrate == 1) define("GALLERY_ROOT", "minigalnano/");
else define("GALLERY_ROOT", "");
//FUNCTIONS
function is_directory($filepath) {
// $filepath must be the entire system path to the file
if (!@opendir($filepath)) return FALSE;
else {
return TRUE;
closedir($filepath);
}
}
function padstring($name) {
global $label_max_length;
if (strlen($name) > $label_max_length) {
return substr($name,0,$label_max_length) . "...";
} else return $name;
}
function getfirstImage($dirname) {
$imageName = false;
$ext = array("jpg", "png", "jpeg", "gif", "JPG", "PNG", "GIF", "JPEG");
if($handle = opendir($dirname))
{
while(false !== ($file = readdir($handle)))
{
$lastdot = strrpos($file, '.');
$extension = substr($file, $lastdot + 1);
if ($file[0] != '.' && in_array($extension, $ext)) break;
}
$imageName = $file;
closedir($handle);
}
return($imageName);
}
// CHECK FOR NEW VERSION
$file = fopen ("http://www.minigal.dk/minigalnano_version.php", "r");
$new_version_exist = "";
$server_version = fgets ($file, 1024);
if (strlen($server_version) == 5 ) { //If string retrieved is exactly 5 chars then continue
if (version_compare($server_version, $version, '>')) $new_version_exist = "<div class='newversion'><a href='http://www.minigal.dk/minigal-nano.html' target='_blank'><img src='images/update.png' alt='MiniGal $server_version available!' /></a></div>"; //Set new version flag
}
fclose($file);
$thumbdir = rtrim('photos' . "/" .$_REQUEST["dir"],"/");
$thumbdir = str_replace("/..", "", $thumbdir); // Prevent looking at any up-level folders
$currentdir = GALLERY_ROOT . $thumbdir;
?>
<?php
//READ FILES AND FOLDERS
$files = array();
$dirs = array();
if ($handle = opendir($currentdir))
{
while (false !== ($file = readdir($handle)))
{
if (is_directory($currentdir . "/" . $file))
{
if ($file != "." && $file != ".." )
{
// Set thumbnail to folder.jpg if found:
if (file_exists(GALLERY_ROOT . "photos/" . $file . "/folder.jpg"))
{
$dirs[] = array(
"name" => $file,
"date" => filemtime($currentdir . "/" . $file),
"html" => "<li><a href='?dir=" . ltrim($_GET['dir'] . "/" . $file, "/") . "'><em>" . padstring($file) . "</em><span></span><img src='" . GALLERY_ROOT . "createthumb.php?filename=photos/" . $file . "/folder.jpg&size=$thumb_size' alt='$label_loading' /></a></li>");
} else
{
//Set thumbnail to first image found (if any):
unset ($firstimage);
$firstimage = getfirstImage("$currentdir/" . $file);
if ($firstimage != "") {
$dirs[] = array(
"name" => $file,
"date" => filemtime($currentdir . "/" . $file),
"html" => "<li><a href='?dir=" . ltrim($_GET['dir'] . "/" . $file, "/") . "'><em>" . padstring($file) . "</em><span></span><img src='" . GALLERY_ROOT . "createthumb.php?filename=$thumbdir/" . $file . "/" . $firstimage . "&size=$thumb_size' alt='$label_loading' /></a></li>");
} else {
//If no folder.jpg or image is found, then display default icon:
$dirs[] = array(
"name" => $file,
"date" => filemtime($currentdir . "/" . $file),
"html" => "<li><a href='?dir=" . ltrim($_GET['dir'] . "/" . $file, "/") . "'><em>" . padstring($file) . "</em><span></span><img src='" . GALLERY_ROOT . "images/folder_" . strtolower($folder_color) . ".png' width='$thumb_size' height='$thumb_size' alt='$label_loading' /></a></li>");
}
}
}
}
// Load images into array
if ($file != "." && $file != ".." && $file != "folder.jpg" && (eregi("jpg", $file) OR eregi("gif", $file) OR eregi("png", $file)))
{
$files[] = array (
"name" => $file,
"date" => filemtime($currentdir . "/" . $file),
"html" => "<li><a href='" . $currentdir . "/" . $file . "' rel='lightbox[billeder]'><span></span><img src='" . GALLERY_ROOT . "createthumb.php?filename=" . $thumbdir . "/" . $file . "&size=$thumb_size' alt='$label_loading' /></a></li>");
}
}
closedir($handle);
} else die("Could not open $currentdir for reading");
//SORT FILES AND FOLDERS
if (sizeof($dirs) > 0)
{
foreach ($dirs as $key => $row)
{
if($row["name"] == "") unset($dirs[$key]); //Delete empty array entries
$name[$key] = strtolower($row['name']);
}
array_multisort($name, SORT_ASC, $dirs);
}
if (sizeof($files) > 0)
{
foreach ($files as $key => $row)
{
if($row["name"] == "") unset($files[$key]); //Delete empty array entries
$name[$key] = strtolower($row['name']);
}
array_multisort($name, SORT_ASC, $files);
}
//OFFSET DETERMINATION
$offset_start = ($_GET["page"] * $thumbs_pr_page) - $thumbs_pr_page;
if (!isset($_GET["page"])) $offset_start = 0;
$offset_end = $offset_start + $thumbs_pr_page;
if ($offset_end > sizeof($dirs) + sizeof($files)) $offset_end = sizeof($dirs) + sizeof($files);
if ($_GET["page"] == "all")
{
$offset_start = 0;
$offset_end = sizeof($dirs) + sizeof($files);
}
//PAGE NAVIGATION
if (!isset($_GET["page"])) $_GET["page"] = 1;
if (sizeof($dirs) + sizeof($files) > $thumbs_pr_page)
{
$page_navigation .= "$label_page ";
for ($i=1; $i <= ceil((sizeof($files) + sizeof($dirs)) / $thumbs_pr_page); $i++)
{
if ($_GET["page"] == $i)
$page_navigation .= "$i";
else
$page_navigation .= "<a href='?dir=" . $_GET["dir"] . "&page=" . ($i) . "'>" . $i . "</a>";
if ($i != ceil((sizeof($files) + sizeof($dirs)) / $thumbs_pr_page)) $page_navigation .= " | ";
}
//Insert link to view all images
if ($_GET["page"] == "all") $page_navigation .= " | $label_all";
else $page_navigation .= " | <a href='?dir=" . $_GET["dir"] . "&page=all'>$label_all</a>";
}
//BREADCRUMB NAVIGATION
if ($_GET['dir'] != "")
{
$breadcrumb_navigation .= "<a href='?dir='>" . $label_home . "</a> > ";
$navitems = explode("/", $_REQUEST['dir']);
for($i = 0; $i < sizeof($navitems); $i++)
{
if ($i == sizeof($navitems)-1) $breadcrumb_navigation .= $navitems[$i];
else
{
$breadcrumb_navigation .= "<a href='?dir=";
for ($x = 0; $x <= $i; $x++)
{
$breadcrumb_navigation .= $navitems[$x];
if ($x < $i) $breadcrumb_navigation .= "/";
}
$breadcrumb_navigation .= "'>" . $navitems[$i] . "</a> > ";
}
}
} else $breadcrumb_navigation .= $label_home;
//Include hidden links for all images BEFORE current page so lightbox is able to browse images on different pages
for ($y = 0; $y < $offset_start - sizeof($dirs); $y++)
{
$breadcrumb_navigation .= "<a href='" . $currentdir . "/" . $files[$y]["name"] . "' rel='lightbox[billeder]' class='hidden'></a>";
}
// DISPLAY FOLDERS
if (count($dirs) + count($files) == 0) $thumbnails .= "<li>$label_noimages</li>"; //Display 'no images' text
$offset_current = $offset_start;
for ($x = $offset_start; $x < sizeof($dirs) && $x < $offset_end; $x++)
{
$offset_current++;
$thumbnails .= $dirs[$x]["html"];
}
// DISPLAY FILES
for ($i = $offset_start - sizeof($dirs); $i < $offset_end && $offset_current < $offset_end; $i++)
{
if ($i >= 0)
{
$offset_current++;
$thumbnails .= $files[$i]["html"];
}
}
//Include hidden links for all images AFTER current page so lightbox is able to browse images on different pages
for ($y = $i; $y < sizeof($files); $y++)
{
$page_navigation .= "<a href='" . $currentdir . "/" . $files[$y]["name"] . "' rel='lightbox[billeder]' class='hidden'></a>";
}
//PROCESS TEMPLATE FILE
$templatefile = GALLERY_ROOT . "templates/" . $templatefile . ".html";
if(!$fd = fopen($templatefile, "r"))
{
echo "Template $templatefile not found!";
exit();
}
else
{
$template = fread ($fd, filesize ($templatefile));
fclose ($fd);
$template = stripslashes($template);
$template = eregi_replace("<% title %>", $title, $template);
$template = eregi_replace("<% author %>", $author, $template);
$template = eregi_replace("<% gallery_root %>", GALLERY_ROOT, $template);
$template = eregi_replace("<% images %>", "$images", $template);
$template = eregi_replace("<% thumbnails %>", "$thumbnails", $template);
$template = eregi_replace("<% breadcrumb_navigation %>", "$breadcrumb_navigation", $template);
$template = eregi_replace("<% page_navigation %>", "$page_navigation", $template);
$template = eregi_replace("<% bgcolor %>", "$backgroundcolor", $template);
$template = eregi_replace("<% gallery_width %>", "$gallery_width", $template);
$template = eregi_replace("<% version %>", "$version<br />$new_version_exist" . $new, $template);
echo "$template";
}
?>
vielen dank !
lg. mana
Kommentar