Verfasst: Di 24. Jan 2006, 09:22
sorry, das war ein fehler meinerseits. die konfiguration findet nur während der definition statt. hier deshalb das angepasste modul. ich bin nicht dazu gekommen, alles zu überprüfen. das muss ich leider euch überlassen.
so wie das ganze jetzt ist, können die module - bis auf die bildaufrufe - identisch sein. also mit der klassendefinition. diese wird einfach nur dann ausgeführt, wenn das noch nicht geschehen ist.
hier also der neue output-code:
so wie das ganze jetzt ist, können die module - bis auf die bildaufrufe - identisch sein. also mit der klassendefinition. diese wird einfach nur dann ausgeführt, wenn das noch nicht geschehen ist.
hier also der neue output-code:
Code: Alles auswählen
<?php
/**
* $Revision: 1.1 $
* $Source: D:/cvs/cvsrepo/test/ContenidoModule462/picture/output.php,v $
* $Date: 2005/11/29 19:05:46 $
*/
/**
* picture
* @author Andreas Kummer
* @copyright Copyright © 2005, w3concepts AG
*/
if (!class_exists('picture')) {
class picture {
/**
* Klassenkonstruktor.
* @param String Absoluter Pfad zum Bild.
*/
function picture($bildpfad, $bildbreite, $bildhoehe, $bildzielpfad) {
global $cfgClient, $client;
if (empty($bildpfad)) return false;
$this->bildpfad = $bildpfad;
$this->link = $link;
/*
* Initialwerte fest legen
*/
$this->setIniValues($bildbreite, $bildhoehe, $bildzielpfad);
/*
* Datenbankverbind initialisieren
*/
$this->db = new DB_contenido();
/*
* Bildpfad und Dateiname ermitteln
*/
$dirname = dirname($bildpfad)."/";
$dirname = str_replace ($cfgClient[$client]['path']['htmlpath'].$cfgClient[$client]['upload'],'',$dirname);
$filename = basename($bildpfad);
/*
* Bildpfad setzen
*/
$this->path = $this->createImage($dirname,$filename);
/*
* Popup-Titel setzen
*/
$this->setPopupTitle();
}
function setIniValues($bildbreite, $bildhoehe, $bildzielpfad) {
global $cfgClient, $client;
// $bildzielpfad = "CMS_VALUE[0]";
$this->bildzielpfad['frontend'] = $cfgClient[$client]['path']['htmlpath'].$cfgClient[$client]['upload'].$bildzielpfad;
$this->bildzielpfad['backend'] = $cfgClient[$client]['path']['frontend'].$cfgClient[$client]['upload'].$bildzielpfad;
// $this->bildhoehe = "CMS_VALUE[1]";
// $this->bildbreite = "CMS_VALUE[2]";
$this->bildhoehe = $bildhoehe;
$this->bildbreite = $bildbreite;
if (empty($this->bildhoehe)) $this->bildhoehe = 100;
if (empty($this->bildbreite)) $this->bildbreite = 100;
}
function setPopupTitle() {
global $cfg, $idart, $lang;
$this->db->query("SELECT pagetitle FROM {$cfg['tab']['art_lang']} WHERE idart = $idart AND idlang = $lang");
$this->db->next_record();
$this->title = $this->db->f('pagetitle');
}
function createImage($dirname, $filename) {
global $cfgClient, $client;
$src_image_size = getimagesize($cfgClient[$client]['path']['frontend'].$cfgClient[$client]['upload'].$dirname.$filename);
$this->srchoehe = $src_image_size[1];
$this->srcbreite = $src_image_size[0];
if ($src_image_size[0]/$this->bildbreite < $src_image_size[1]/$this->bildhoehe) {
$resizeFactor = $src_image_size[1]/$this->bildhoehe;
} else {
$resizeFactor = $src_image_size[0]/$this->bildbreite;
}
$this->bildhoehe = round($src_image_size[1]/$resizeFactor);
$this->bildbreite = round($src_image_size[0]/$resizeFactor);
$bilddateiname = "{$this->bildbreite}_{$this->bildhoehe}_$filename.jpg";
if (!file_exists("{$this->bildzielpfad['backend']}$bilddateiname")) {
$dst_im = imagecreatetruecolor($this->bildbreite,$this->bildhoehe);
if ($src_image_size[2] == 1) {
$src_im = imagecreatefromGIF($cfgClient[$client]['path']['frontend'].$cfgClient[$client]['upload'].$dirname.$filename);
} elseif ($src_image_size[2] == 2) {
$src_im = ImageCreateFromJPEG($cfgClient[$client]['path']['frontend'].$cfgClient[$client]['upload'].$dirname.$filename);
} elseif ($src_image_size[2] == 3) {
$src_im = ImageCreateFromPNG($cfgClient[$client]['path']['frontend'].$cfgClient[$client]['upload'].$dirname.$filename);
} else {
$src_im = imagecreatefromgd($cfgClient[$client]['path']['frontend'].$cfgClient[$client]['upload'].$dirname.$filename);
}
imagecopyresampled ($dst_im,$src_im,0,0,0,0,$this->bildbreite,$this->bildhoehe,$src_image_size[0],$src_image_size[1]);
imagejpeg ($dst_im,$this->bildzielpfad['backend'].$bilddateiname,100);
}
return $this->bildzielpfad['frontend'].$bilddateiname;
}
function outputPicture($link,$target,$imgDescr = null, $linkDescr = null) {
global $edit;
if ($edit) {
$this->outputPictureEdit($link, $target, $imgDescr, $linkDescr);
return false;
}
if (empty($link) || empty($this->bildpfad)) return false;
$img = "<img src=\"{$this->path}\" border=\"0\" width=\"{$this->bildbreite}\" height=\"{$this->bildhoehe}\">";
$breite = $this->bildbreite;
if ($link != "http://") {
$img = sprintf('<a href="%s" target="%s">%s</a>',$link, $target, $img);
} elseif ($this->bildpfad != '') {
$img = "<a href=\"javascript:popup({$this->srcbreite},{$this->srchoehe},'{$this->bildpfad}&title={$this->title}');\"><img src=\"{$this->path}\" border=\"0\" width=\"{$this->bildbreite}\" height=\"{$this->bildhoehe}\" /></a>";
}
if (empty($imgDescr)) {
echo '<div style="margin-bottom:10px;"><div style="width:'.$breite.'px;border:1px solid #000; padding:1px;">'.$img.'</div></div>';
} else {
echo '<div style="margin-bottom:10px;"><div style="width:'.$breite.'px;border:1px solid #000; padding:1px;">'.$img.'</div><div class="imgDescr">'.$imgDescr.'</div></div>';
}
}
function outputPictureEdit($link, $target, $imgDescr, $linkDescr) {
if (!empty($this->path)) {
echo "<img src=\"{$this->path}\" border=\"0\" width=\"{$this->bildbreite}\" height=\"{$this->bildhoehe}\">";
}
echo "<br />";
echo $imgDescr;
echo "<br />";
echo $linkDescr;
echo "<br />";
}
}
}
if (!$edit) {
echo '<script type="text/javascript" src="js/pictureResized.js"></script>'."\n";
}
$bild1 = new picture("CMS_IMG[2]", "CMS_VALUE[2]", "CMS_VALUE[1]", "CMS_VALUE[0]"); // initialisierung
$bild1->outputPicture("CMS_LINK[2]","CMS_LINKTARGET[2]","CMS_IMGDESCR[2]","CMS_LINKDESCR[2]");
$bild2 = new picture("CMS_IMG[3]", "CMS_VALUE[2]", "CMS_VALUE[1]", "CMS_VALUE[0]"); // initialisierung
$bild2->outputPicture("CMS_LINK[3]","CMS_LINKTARGET[3]","CMS_IMGDESCR[3]","CMS_LINKDESCR[3]");
$bild3 = new picture("CMS_IMG[4]", "CMS_VALUE[2]", "CMS_VALUE[1]", "CMS_VALUE[0]"); // initialisierung
$bild3->outputPicture("CMS_LINK[4]","CMS_LINKTARGET[4]","CMS_IMGDESCR[4]","CMS_LINKDESCR[4]");
$bild4 = new picture("CMS_IMG[5]", "CMS_VALUE[2]", "CMS_VALUE[1]", "CMS_VALUE[0]"); // initialisierung
$bild4->outputPicture("CMS_LINK[5]","CMS_LINKTARGET[5]","CMS_IMGDESCR[5]","CMS_LINKDESCR[5]");
?>