ich schreibe zurzeit gerade das Bildergalleriemodul um. Es sollte zusätzlich zum "grossen Bild" Kommentar eingefügt werden können. Ich habe eine weitere Tabelle bild in der Contenido Datenbank erstellt. Dort gibte es 3 Spalten eine ID, der Pfad des Bildes und der Kommentar (text). Der Input der Gallery bleibt sich. Der Output habe ich wie folgt geändert:
Code: Alles auswählen
<?
// Bildergalerie
// Imageresize über ImageMagick *ODER* GD
// Version: 15.01.2004
// Kommenatrversion 9.9.04
//
// Author: Large Green Wood vgl. http://www.contenido.de/front_dev/upload/1ImageGal.txt
// Abgeändert mit Kommentar Christian Bachmann
echo "<p>\n";
// ANFANG OUTPUT
$imagedir="CMS_VALUE[2]";
$thumbnails="CMS_VALUE[3]";
$imagetypes=explode(";","CMS_VALUE[4]");
$rows="CMS_VALUE[6]";
$cols="CMS_VALUE[5]";
$thb_x_size="CMS_VALUE[7]";
$thb_y_size="CMS_VALUE[8]";
$image_idcat="CMS_VALUE[0]";
$image_idside="CMS_VALUE[1]";
$im_path="CMS_VALUE[9]";
//-- config ende -------------------------------------
function is_image($filename,$typearray) {
reset($typearray);
while($val=each($typearray)) {
if (strstr($filename,$val[value])!==false) {
return true;
}
}
}
// verkleinert ein Bild auf die angegebene Breite (bei Querformat) oder Höhe (bei Hochformat)
// Seitenverhältnisse werden beibehalten
function resizeImageGD($sourceFile, $targetFile, $newwidth=50, $newheight=50){
$source = ImageCreateFromJpeg($sourceFile);
$width = ImageSx($source);
$height = ImageSy($source);
if ($width > $height){ // Querformat
$newheight = $height*($newwidth/$width);
}else{ // Hochformat
$newwidth = $width*($newheight/$height);
}
$target = ImageCreateTrueColor($newwidth,$newheight);
// ÄNDERUNG vgl. Forums-Beitrag imagecopyresized ($target, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
imagecopyresampled ($target, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
ImageJPEG($target,$targetFile,100);
}
//-- functions ende ----------------------------------
if (!isset($mmstart)) {
$mmstart=0;
}
// Anzeige eines Bildes oder Übersicht?
if ($subfile!="") {
//Wenn neuer Kommentar, dann in Datenbank einfügen
if(isset($_POST["text"] )){
$sql ="Insert INTO bild VALUES(NULL,'".$subfile."','".$_POST["text"]."')";
$db->query($sql);
$_POST["text"] ="";
}
// Bild anzeigen
echo "<left><a style=\"font-family: Arial, Helvetica, sans-serif; font-size: 12px; color: #879779;\" href=\"javascript:history.back()\">zurück</a></left>";
echo "<br>";
echo "<img src=\"$subfile\"><br>";
$sql ="Select text FROM bild WHERE pfad='$subfile'";
//Kommentar anzeigen
$db->query($sql);
while ($db->next_record()) {
echo" ".$db->f("text")."<br>";
}
//Reoladlink erstellen
$reload=$sess->url("client=$client&lang=$lang&subid=$subid&idcat=$idcat&idart=$idart&idside=$idside&subfile=".$subfile);
//Formular für Kommentareingabe:
echo"
<form name='form1' method='post' action='".$PHP_SELF."?".$reload."'>
<p>Text Eintragen:
<input type='text' name='text'>
</p>
<p>
<input type='submit' name='Submit' value='Abschicken'>
</p>
</form>";
echo "<left><a style=\"font-family: Arial, Helvetica, sans-serif; font-size: 12px; color: #879779;\" href=\"javascript:history.back()\">zurück</a></left>";
} else {
// Gallery anzeigen
$handle=opendir($imagedir);
echo "<table>";
$n=0;
$filearray=Array();
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != ".." && is_image($file,$imagetypes)) {
$filearray[]=$file;
}
}
reset($filearray);
// skip images...
for ($n=0;$n<$mmstart;$n++)
$ffile=each($filearray);
$n=0;
while ($ffile=each($filearray)) {
$file=$ffile[value];
// generate thumbnail, if nessesairy. Now THIS is fun :)
// natuerlich nur, wenn imagemagick vorhanden ist...
if (!file_exists($thumbnails."/thb_".$file) ) {
if ($im_path!="") {
$cmd=$im_path."/convert -scale ".$thb_x_size."x".$thb_y_size." ".$imagedir."/".$file." ".$thumbnails."/thb_".$file;
exec($cmd);
// nochmal prüfen!
$thumbnail=file_exists($thumbnails."/thb_".$file);
} else{
// Bilder mit GD verkleinern
@ini_set("max_execution_time", 120);
@resizeImageGD($imagedir."/".$file, $thumbnails."/thb_".$file, $thb_x_size,$thb_y_size);
$thumbnail=file_exists($thumbnails."/thb_".$file);
}
} else
$thumbnail=true;
if ($n%$cols==0)
echo "<tr>\n";
if ($image_idcat!=0)
$url=$sess->url("front_content.php?client=$client&lang=$lang&subid=$subid&idcatside=$image_idcat&subfile=".rawurlencode($imagedir."/".$file));
else
$url=$sess->url("front_content.php?client=$client&lang=$lang&subid=$subid&idcat=$idcat&idart=$idart&idside=$idside&subfile=".rawurlencode($imagedir."/".$file));
echo "<td valign=\"middle\" align=\"center\" width=\"$thb_x_size\" height=\"$thb_y_size\"><a href=\"$url\">".($thumbnail ? "<img src=\"$thumbnails/thb_$file\" border=\"0\">":"$file")."</a></td>\n";
$n++;
if ($n%$cols==0)
echo "</tr>\n";
// nur solange wie's not tut...
if ($n>=$rows*$cols)
break;
}
echo "<tr> <td colspan=\"$cols\" align=\"center\">";
if ($mmstart>0) {
$url=$sess->url("front_content.php?client=$client&lang=$lang&idcat=$idcat&idart=$idart&subid=$subid&idside=$idside&mmstart=".($mmstart-$rows*$cols));
echo "<a style=\"font-family: Arial, Helvetica, sans-serif; font-size: 12px; color: #879779;\" href=\"$url\"> vorherige Bilder...</a>";
}
echo "<span style=\"font-family: Arial, Helvetica, sans-serif; font-size: 12px; color: #879779;\">| zeige Bilder ".($mmstart+1)." - ".($mmstart+$n)." | </span>";
if ($n+$mmstart<count($filearray)) {
$url=$sess->url("front_content.php?client=$client&lang=$lang&idcat=$idcat&idart=$idart&subid=$subid&idside=$idside&mmstart=".($mmstart+$rows*$cols));
echo "<a style=\"font-family: Arial, Helvetica, sans-serif; font-size: 12px; color: #879779;\" href=\"$url\"> weitere Bilder...</a>";
}
echo "</tr>\n";
echo "</table>";
} // Ende Gallery anzeigen
echo "</p>";
?>
Ich habe jedoch zwei Probleme: Wenn man nach dem Eintragen eines Kommentares reloaded, wird der Kommentar nochmals eingefügt. Der Javascript history back funktioniert nicht. Wie würded ihr dieses Problem lösen? Würded ihr auch ein weiteres File erstellen?
Gruss Crazy