Seite 1 von 6

neues modul :: picture

Verfasst: Di 29. Nov 2005, 17:15
von kummer
hallo zusammen

wir haben ein neues modul anzubieten (unter GNU / GPL). es gab das auch schon vorher (nicht unter GPL) und jetzt neu für die 4.6.2 angepasst.

das modul akzeptiert eine variable anzahl bilder, die es für die ausgabe auf die konfigurierten masse reduziert und an die standardausgabe ausgibt. auf klick auf das bild wird es in originalgrösse angezeigt (als popup) und auf die gleiche weise wieder geschlossen.

input

Code: Alles auswählen

?><?php
/**
  * $Revision: 1.3 $
  * $Source: D:/cvs/cvsrepo/test/PPI_Nade/module/picture/input.php,v $
  * $Date: 2005/11/29 16:10:51 $
  */

/**
 * picture
 * @author Andreas Kummer
 * @copyright Copyright &copy; 2005 w3concepts AG
 */

if (!class_exists('pictureInput')) {
	
	class pictureInput {
	
		function pictureInput($pfad) {
			$this->pfad = $pfad;
			$this->pathlen = strlen($this->pfad);
		}
	
		function getPath($root,$level = 0) {
			$content = $this->readDir($root);
	
			foreach ($content as $file) {
				if (is_dir($root.$file)) {
					$verzeichnis = substr($root,$this->pathlen);
					$returnvalue["{$verzeichnis}{$file}/"] = str_repeat("&nbsp;",$level * 5).$file;
					$returnvalue = array_merge($returnvalue,$this->getPath($root.$file."/",$level+1));
				}
			}
	
			return $returnvalue;
		}
	
		function readDir($path) {
			$handle = opendir($path);
	
			while ($file = readdir ($handle)) {
				if ($file != "." && $file != "..") $returnvalue[] = $file;
			}
			closedir($handle);
	
			return $returnvalue;
		}
	
		function makeSelect($preselection) {
			$pfad = $this->getPath($this->pfad);
	
			foreach ($pfad as $key => $value) {
				echo "$key :: $value<br/>\n";
				if ($preselection == $key) {
					echo "<option value=\"$key\" selected=\"selected\">$value</option>";
				} else {
					echo "<option value=\"$key\">$value</option>";
				}
			}
		}
	}
}

$pfad = new pictureInput($cfgClient[$client]['path']['frontend'].$cfgClient[$client]['upload']);

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

echo "<tr><td>Bildzielpfad:</td>";
echo "<td><select size=\"1\" name=\"CMS_VAR[0]\" />";
$pfad->makeSelect("CMS_VALUE[0]");
echo "</td>";

echo "<tr><td>Maximale Bildhöhe [px]:</td>";
echo "<td><input type=\"text\" name=\"CMS_VAR[1]\" value=\"CMS_VALUE[1]\" size=\"3\" /></td>";

echo "<tr><td>Maximale Bildbreite [px]:</td>";
echo "<td><input type=\"text\" name=\"CMS_VAR[2]\" value=\"CMS_VALUE[2]\" size=\"3\" /></td>";

echo "</table>";
output

Code: Alles auswählen

<?php
/**
  * $Revision: 1.4 $
  * $Source: D:/cvs/cvsrepo/test/PPI_Nade/module/picture/output.php,v $
  * $Date: 2005/11/28 17:03:08 $
  */

/**
 * picture
 * @author Andreas Kummer
 * @copyright Copyright &copy; 2005, w3concepts AG
 */

if (!class_exists('picture')) {
	
	class picture {
	
		/**
		 * Klassenkonstruktor.
		 * @param String  Absoluter Pfad zum Bild.
		 */
		function picture($bildpfad) {
	
			global $cfgClient, $client;
			
			if (empty($bildpfad)) return false;
			
			$this->bildpfad = $bildpfad;
			$this->link = $link;
	
			/*
			 * Initialwerte fest legen
			 */
			$this->setIniValues();
			
			/*
			 * 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() {
	
			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]";
			
			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]"); // initialisierung
$bild1->outputPicture("CMS_LINK[2]","CMS_LINKTARGET[2]","CMS_IMGDESCR[2]","CMS_LINKDESCR[2]");

$bild2 = new picture("CMS_IMG[3]"); // initialisierung
$bild2->outputPicture("CMS_LINK[3]","CMS_LINKTARGET[3]","CMS_IMGDESCR[3]","CMS_LINKDESCR[3]");

$bild3 = new picture("CMS_IMG[4]"); // initialisierung
$bild3->outputPicture("CMS_LINK[4]","CMS_LINKTARGET[4]","CMS_IMGDESCR[4]","CMS_LINKDESCR[4]");	

$bild4 = new picture("CMS_IMG[5]"); // initialisierung
$bild4->outputPicture("CMS_LINK[5]","CMS_LINKTARGET[5]","CMS_IMGDESCR[5]","CMS_LINKDESCR[5]");	
?>
folgende beiden codes gehören in das verzeichnis /cms/js

pictureResized.php

Code: Alles auswählen

<html>

	<head>
		<title><?php echo $_GET['title']; ?></title>
	</head>
	
	<body leftmargin="0" marginwidth="0" topmargin="0" marginheight="0">

		<img src="<?php echo $_GET['path']; ?>" onClick="self.close();"/>

	</body>
	
</html>
pictureResized.js

Code: Alles auswählen

function popup(w,h,site) {
	x = screen.availWidth/2-w/2;
	y = screen.availHeight/2-h/2;
	popupWindow = window.open('js/pictureResized.php?path='+site,'','width='+w+',height='+h+',left='+x+',top='+y+',screenX='+x+',screenY='+y);
}
ich hoffe, das hilft dem einen oder anderen weiter.

gruss,
andreas

Verfasst: Di 29. Nov 2005, 20:03
von peanut
Hallo Andreas

Dieses Modul geht nicht mit der Bildfunktion der News Artikelliste oder ist das nun implementiert ?

Danke
Gruss
Peanut

Verfasst: Di 29. Nov 2005, 22:08
von mvf
peanut hat geschrieben:Hallo Andreas

Dieses Modul geht nicht mit der Bildfunktion der News Artikelliste oder ist das nun implementiert ?

Danke
Gruss
Peanut
habe das modul noch nicht getestet, bin grade dabei ;) aber wenn ich es recht verstehe, dann werden module doch über templates im layout eingebunden.

wie ist deine frage dann zu verstehen? modul im modul einbinden :?:

wenn du meinst, dass bei dem standard newsmodul kein image mit ausgegeben wird, das liegt am fehlenden {IMG} tag im html-template, gibts aber auch einen thread dafür

Verfasst: Di 29. Nov 2005, 23:02
von re-flexion
Hi Guido,

kannst du bitte mal den Link zu dem entsprechenden Thread posten - wäre klasse - danke schön :-)

Verfasst: Di 29. Nov 2005, 23:10
von mvf
re-flexion hat geschrieben:Hi Guido,

kannst du bitte mal den Link zu dem entsprechenden Thread posten - wäre klasse - danke schön :-)
jaja die liebe 'suche' (fauler sack ;) :lol: )

http://contenido.org/forum/viewtopic.ph ... +newsmodul

Verfasst: Di 29. Nov 2005, 23:22
von re-flexion
:cry:

schnief... hatte es einfach nicht gesehen - daher habe ich jetzt die Brille aufgesetzt :shock:

Danke schön :D

Verfasst: Di 29. Nov 2005, 23:38
von mvf
re-flexion hat geschrieben::cry:

schnief... hatte es einfach nicht gesehen - daher habe ich jetzt die Brille aufgesetzt :shock:

Danke schön :D
na dann, hauptsache du hast dein image ;)

happy contenido-ing

Verfasst: Di 29. Nov 2005, 23:43
von re-flexion
yeppa, danke schön - werde umgehend wieder mal alles diesbezüglich geben ;-)

Verfasst: Mi 30. Nov 2005, 05:28
von jost
Bei mir werden leider keine Bilder ausgegeben, wenn ich das Template, in welches das Modul integriert ist, konfiguriere, kann ich das Zielverzeichnis (wo also die Originalbilder liegen) auswählen, abe rnach dem Anklicken des Häkchens zeigt mir der Editor quasi vier Bildmodule (image/link) untereinander an. Im Frontend wird gleich gar nix ausgegeben. Please help, oder habe ich was übersehen und ich muss im Editor noch was machen???

Verfasst: Mi 30. Nov 2005, 05:44
von mvf
jost hat geschrieben:... zeigt mir der Editor quasi vier Bildmodule (image/link) untereinander an.
und genau da machst du im editor weiter click aufimage und wähle dein bild. ist eben ein picture modul und keine gallery wenn ich es recht verstehe.

Verfasst: Mi 30. Nov 2005, 06:19
von jost
Stümmt. Hatte ich verwechselt. Jetzt muss ich nur noch rausfinden, wo ich die Anzahl der Bilder ändern kann...

Verfasst: Mi 30. Nov 2005, 08:14
von kummer
im modul selber. die untersten zeilen erzeugen die bilder. du kannst dann soviele machen wie du willst. du kannst z.b. auch eine tabelle erstellen, und die bilder in die einzelnen zellen einpflegen. da hast du volle freiheiten.

Verfasst: Mi 30. Nov 2005, 10:57
von jost
Alles klar, "funzt" wie eine Eins, wie eine Eins plus.

Verfasst: Di 13. Dez 2005, 23:33
von mvf
wofür steht in der konfiguration der

'Bildzielpfad' ???

egal was ich dort auswähle bilder kann ich aus allen ordnern im upload nutzen ???

Verfasst: Di 13. Dez 2005, 23:39
von #ayshe
Hallo Andreas,

kannst Du bitte mal Deinen fachmännischen Blick auf diesen Thread werfen:
http://contenido.org/forum/viewtopic.php?p=64669#64669

Gruß,
Ayshe