probleem met integratie jquery

Status
Niet open voor verdere reacties.

zodiak

Gebruiker
Lid geworden
9 okt 2008
Berichten
241
Hallo,

ik heb op mijn website een fotoalbum met php gemaakt en wanneer men een album selecteert krijgt met de thumbs te zien van de foto's in dit album. ik heb nu een tutorial gevonden voor wanneer men op een thumb klikt deze dan met jquery en lightbox opent. maar het lukt mij niet om dit te integreren. momenteel was het zo dat wanneer men op een thumb klikt dan met de functie window.open een nieuw scherm open ging met de eerste foto en dan vorige of volgende maar dit is niet zo mooi als wanneer ik het met dat ander zou kunnen doen. Kan iemand mij hier in helpen want vind echt niet wat ik moet aanpassen en waar ik dat moet doen om de integratie goed te krijgen.

mijn album paginas:

fotoalbum.php
PHP:
<?php

include("config.php");

if (isset($_GET['album'])) {

	$album = $_GET['album'];

} else {

	$album = ".";

}



if (isset($_GET['page'])) {

	$page = $_GET['page'];

} else {

	$page = 0;

}



$cols			= "4";	

$rows			= "3";			

$max_thumb_width	= "100";		

$max_thumb_height	= "70";			



$thumbs			= "$album/thumbs";	

$header			= eregi_replace("_", " ", $album);



if ($cols % 2 == 0) {

	$colspan = "";

} else {

	$colspan = "colspan=2";

}



?>



<html>

<head>

<title>Modo-eetcafe: Fotoalbum</title>

<link href="../../ike/modo.css" rel="stylesheet" type="text/css" />
<style type="text/css">
   body { margin: 0; padding: 0; background-color:#212121; color:#FFF; }
   A:link             { color: #FFF; text-decoration:none; }
A:visited          { color: #FFF; text-decoration:none;}
A:active           { color: #FFF; text-decoration:none;}
   
</style>
</head>



<body>


<div align="center">



<?php





if ($album != "" && !is_dir($album)) {



	

	echo "<h2>Fout:</h2>\n";

	echo "<p>Het door u gevraagde album bestaat niet. Selecteer een album uit de lijst hieronder.</p>\n";



	$album = ".";

}





$mydir = opendir($album);





$aantal_subdirs	= 0;

$aantal_fotos	= 0;



while ($filename = readdir($mydir)) {



	if (is_dir($album."/".$filename) && $filename != "." && $filename != ".." && $filename != "thumbs") {

		$subdir[$aantal_subdirs] = $filename;

		$aantal_subdirs++;

	}




	if (is_file ($album."/".$filename) && eregi("\.jpg$|\.jpeg$|\.gif$|\.bmp$|\.png$", $filename)) {

		$foto[$aantal_fotos] = $filename;

		$aantal_fotos++;

	}

}





closedir($mydir);




$map	= $album;

$i 	= 1;



$directory_tree[0] = $map;



while ($map != ".") {



	$last_slash_pos = strlen($map) - strpos(strrev($map), "/");

	$map = substr ($map, 0, $last_slash_pos - 1);



	$directory_tree[$i] = $map;

	$i++;



}




for ($i = count ($directory_tree) - 1 ; $i >= 0; $i--) {



	$last_slash_pos = strlen($directory_tree[$i]) - strpos(strrev($directory_tree[$i]), "/");

	$directory_name = substr($directory_tree[$i], $last_slash_pos);

	$directory_name = eregi_replace("_", " ", $directory_name);



	if ($directory_name != "") {

		echo "&nbsp;&nbsp; > &nbsp;&nbsp;";

	}



	echo "<a href=\"fotoalbum.php?album=$directory_tree[$i]&pid=1\">";



	if ($directory_name != "") {

		echo $directory_name;

	} else {

		echo "Fotoalbums";

	}

	echo "</a>";

}



echo "<hr><br>";




if ($aantal_subdirs > 0) {



	sort ($subdir);



	echo "<table>\n";

	for ($i =0; $i < $aantal_subdirs; $i++) {

		$directory_name = eregi_replace("_", " ", $subdir[$i]);

		echo "<tr><td><a href=\"fotoalbum.php?pid=1&album=$album/$subdir[$i]\">$directory_name</a></td></tr>\n";

	}

	echo "</table>";

}




if ($aantal_fotos > 0) {




	sort ($foto);




	$eerste_foto	= (($page * $cols * $rows) + 1);

	$laatste_foto	= (($page + 1) * $cols * $rows);




	echo "<table border=0 cellpadding=10 cellspacing=0><tr>\n";




	for ($i = $eerste_foto - 1; ($i < $aantal_fotos) && ($i < $laatste_foto); $i++) {



		ClearStatCache();




		$size = GetImageSize("$album/$foto[$i]");




		$size[0] = $size[0] + 165;

		$size[1] = $size[1] + 185;




		$file_size = fileSize("$album/$foto[$i]");

		$file_size = round($file_size / 1000) . "k";




		$display = eregi_replace(".jpg|.jpeg|.gif|.bmp|.png", "", $foto[$i]);

		$display = eregi_replace("_", " ", $display);



		echo ("<td $colspan><a href=\"$album/$foto[$i]\" onmouseover=\"window.status='Vergroten';return true;\"

			onmouseout=\"window.status=''; return true\"

		onclick=\"window.open('show_foto.php?album=$album&fotonr=$i', 'pix$i', 'width=$size[0], height=$size[1], innerwidth=$size[0], innerheight=$size[1], directories=no, location=no, menubar=no, scrollbars=yes, status=no, toolbar=no, resizable=yes, top=0, left=0, leftmargin=0, topmargin=0, marginwidth=0, marginheight=0, screenX=0, screenY=0' ); return false\">\n");


		$entry_without_ext = eregi_replace("\.jpg$|\.jpeg$|\.gif$|\.bmp$|\.png$", "", $foto[$i]);




		switch (true) {

			case (is_file($thumbs."/".$entry_without_ext.".jpg")):

				$thumbnail = $thumbs."/".$entry_without_ext.".jpg";

				break;



			case (is_file($thumbs."/".$entry_without_ext.".jpeg")):

				$thumbnail = $thumbs."/".$entry_without_ext.".jpeg";

				break;



			case (is_file($thumbs."/".$entry_without_ext.".gif")):

				$thumbnail = $thumbs."/".$entry_without_ext.".gif";

				break;



			case (is_file($thumbs."/".$entry_without_ext.".bmp")):

				$thumbnail = $thumbs."/".$entry_without_ext.".bmp";

				break;



			case (is_file($thumbs."/".$entry_without_ext.".png")):

				$thumbnail = $thumbs."/".$entry_without_ext.".png";

				break;



			default:

				$thumbnail = "";

		}



		if ($thumbnail == "") {


			if (! eregi("\.jpg$|\.jpeg$", $foto[$i])) {


				echo "Geen thumbnail beschikbaar...<br>\n";

			} else {





				if (! is_dir ($thumbs)) {

					mkdir("$thumbs");

				}



				set_time_limit(20);



				$photo = imagecreatefromjpeg ("$album/$foto[$i]");




				$photo_width         = imagesx ($photo);

				$photo_height        = imagesy ($photo);



				if ($photo_width > $max_thumb_width || $photo_height > $max_thumb_height) {




					if ($photo_width / $photo_height > $max_thumb_width / $max_thumb_height) {



						$new_thumb_width = $max_thumb_width;




						$value = $photo_width / $max_thumb_width;

						$new_thumb_height = round ($photo_height / $value);



					} else { 

						

						$new_thumb_height = $max_thumb_height;




						$value = $photo_height / $max_thumb_height;

						$new_thumb_width= round ($photo_width / $value);

					}



				} else {




					$new_thumb_width	= $photo_width;

					$new_thumb_height	= $photo_height;

				}




				$create_thumb = imagecreatetruecolor ($new_thumb_width, $new_thumb_height);




				imagecopyresampled (

					$create_thumb,

					$photo,

					0, 0, 0, 0,

					$new_thumb_width,

					$new_thumb_height,

					$photo_width,

					$photo_height);




				ImageJpeg ($create_thumb, $thumbs."/".$entry_without_ext.".jpg", 90);




				$thumbnail = $thumbs."/".$entry_without_ext.".jpg";



				Imagedestroy($photo);



			}	

		}		



		$thumbsize = GetImageSize($thumbnail);


		echo "<img src='$thumbnail' border=0 width=$thumbsize[0] height=$thumbsize[1] alt=$i>\n";







		if (($i % $cols) == $cols -1 ) {

			echo "</tr>\n<tr>\n";

		}



	}	



	$pages		= ($aantal_fotos / ($cols * $rows));

	$nextpage	= ($page + 1);

	$prevpage	= ($page - 1);



	

	if (($page + 1) < $pages) {



		$aantal_op_volgende = $aantal_fotos - $nextpage * $rows * $cols;




		if ($aantal_op_volgende > $rows * $cols) {

			$aantal_op_volgende = $rows * $cols;

		}




		if ($aantal_op_volgende == 1) {

			$volgende = "<a href='".$_SERVER["PHP_SELF"]."?album=$album&page=$nextpage&pid=1' target='_self'>Volgende foto </a>";

		} else {

			$volgende = "<a href=?album=$album&page=$nextpage&pid=1>Volgende ". $aantal_op_volgende ." foto's </a>";

		}

	} else {

		$volgende = "";

	}



	if (($page+1) > "1") {


		if ($rows * $cols > 1) {

			$vorige = "<a href=?album=$album&page=$prevpage&pid=1>Vorige ". ($rows * $cols) ." foto's </a>";

		} else {

			$vorige = "<a href=?album=$album&page=$prevpage&pid=1>Vorige foto </a>";

		}

	} else {

		$vorige = "";

	}



	if ($cols % 2 == 1) {

		$footer_colspan = "colspan=$cols";

	} else {

		$footer_colspan = "colspan=" . ($cols / 2);

	}



	echo "</tr><tr><td $footer_colspan align=right>	$vorige		</td>\n";

	echo "<td $footer_colspan align=left>		$volgende	</td>\n";

	echo "</tr>\n";

	echo "</table>\n";



} 	





?>



</div>

</body>

</html>

show_foto.php
PHP:
<?php 
include("config.php");

?> 

<html> 
<head> 
<title>Modo-eetcafe: foto's</title> 
<link href="../../ike/modo.css" rel="stylesheet" type="text/css" />
<style type="text/css">
   body { margin: 0; padding: 0; background-color:#212121; color:#FFF; }
   A:link             { color: #FFF; text-decoration:none; }
A:visited          { color: #FFF; text-decoration:none;}
A:active           { color: #FFF; text-decoration:none;}
   
</style>
 
</head> 

<body>

<div align="center"> 

<?php 


if (isset($_GET['album'])) { 
    $album = $_GET['album']; 
} else { 
    echo "<H2> Fout ! </H2>\n"; 
    echo "<p>Geen album aangevraagd.</p>\n"; 
    echo "</body></html>\n"; 
    exit; 
} 


if ($album != "" && !is_dir($album)) {  

    
    echo "<h2>Fout:</h2>\n"; 
    echo "<p>Het door u gevraagde album bestaat niet.</p>\n"; 
    echo "</body></html>\n"; 
    exit; 
} 

if (isset($_GET['fotonr'])) { 
    $fotonr = $_GET['fotonr']; 
} else { 
    $fotonr = 0; 
} 


$aantal_fotos    = 0; 


$mydir = opendir($album); 


while ($filename = readdir($mydir)) { 

     
    if (is_file ($album."/".$filename) && eregi("\.jpg$|\.jpeg$|\.gif$|\.bmp$|\.png$", $filename)) {  
        $foto[$aantal_fotos] = $filename; 
        $aantal_fotos++; 
    } 
}  

 
closedir($mydir); 

 
if ($aantal_fotos == 0) { 
    
    echo "<h2>Fout:</h2>\n"; 
    echo "<p>Er bestaan geen foto's in dit album...</p>\n"; 
    echo "</body></html>\n"; 
    exit; 
} 

if ($fotonr > $aantal_fotos) { 
     
    echo "<h2>Fout:</h2>\n"; 
    echo "<p>Gevraagde foto bestaat niet...</p>\n"; 
    echo "</body></html>\n"; 
    exit; 
} 

if ($fotonr < 0) { 
    
    echo "<h2>Fout:</h2>\n"; 
    echo "<p>Gevraagde foto bestaat niet...</p>\n"; 
    echo "</body></html>\n"; 
    exit; 
} 

     
sort ($foto); 

ClearStatCache();  

 
$size = GetImageSize("$album/$foto[$fotonr]");  
$size[0] = $size[0] + 35; 
$size[1] = $size[1] + 85; 

echo "<script type=\"text/javascript\" language=\"JavaScript\">\n"; 
echo "<!--\n"; 
echo "\twindow.resizeTo($size[0],$size[1]);\n"; 
echo "//-->\n"; 
echo "</script>\n"; 

     
$display = eregi_replace(".jpg|.jpeg|.gif|.bmp|.png", "", $foto[$fotonr]); 
$display = eregi_replace("_", " ", $display); 

echo "<table border=0>\n"; 
echo "<tr><td colspan=2>\n"; 
echo "<img src=\"$album/$foto[$fotonr]\" />\n"; 
echo "</td></tr>\n"; 

$nextfoto    = ($fotonr + 1);  
$prevfoto    = ($fotonr - 1);  


if ($nextfoto < $aantal_fotos) {  
    $volgende = "<a href=?album=$album&fotonr=$nextfoto>Volgende foto </a>";  
} else { 
    $volgende = "&nbsp;"; 
} 

if ($fotonr != 0) { 
    $vorige = "<a href=?album=$album&fotonr=$prevfoto>Vorige foto </a>";  
} else { 
    $vorige = "&nbsp;"; 
} 

 
echo "<tr><td align=right width=50%>    $vorige    &nbsp;&nbsp;    </td>\n"; 
echo "<td align=left width=50%>        &nbsp;&nbsp; $volgende    </td>\n"; 
echo "</tr>\n"; 
echo "</table>\n";  
?>  

</div> 
</body> 
</html>

in de bijlage zit het tutorial script dat ik om de 1 of andere reden niet geintegreerd/werkende krijg. Als het in de zelfde directory moet staan dan zou ik eventueel alles uit de verschillende mappen halen aangezien ik anders die mapnamen ook zie bij albums. of bestaat daar ook een andere oplossing voor?

alvast bedankt
 

Bijlagen

  • jquery.rar
    15,1 KB · Weergaven: 26
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan