Last update: 31.03.2008 | © 2024 Julian von Mendel | Datenschutz
<?php
/* xml_extension class
* (C) 2006 Julian von Mendel (http://derjulian.net)
* License: LGPL
*/
class xml_image implements xml_widget
{
public $node;
public $xml ;
function __construct($node, $xml)
{
$this->node = $node;
$this->xml = $xml ;
}
public static function dtd()
{
return <<<DTD
DTD;
}
public function output($returntype = "xhtml")
{
if (!method_exists($this, $returntype))
{
return False;
}
$parse = $this->xml->attributes($this->node, array("path", "text", "signature", "width", "height", "float", "style", "sigstyle", "resize", "href"));
extract($parse["attributes_array"]);
// Thumbnail erzeugen
if ($resize != "" && $width != "" && $height != "")
{
if (!file_exists($path)) return "[image path doesn't exist.]";
$scale = ($resize == "scale");
$newpath = $this->xml->getDataItem("image_prefix").crc32($path).".jpg";
list($width, $height) = image::thumbnail($path, $newpath, $height, $width, $scale);
$width .= "px"; $height .= "px";
$path = $newpath;
}
// Externen Pfad bestimmen
$func = $this->xml->getDataItem("image_remote");
if ($func != "")
{
if (substr($func, 0, 9) == "callback:")
$remote = call_user_func(substr($func, 9), $path);
else
{
if (!substr_count($path, "://"))
{
$remote = str_replace("%s", $path, $func);
$remote = str_replace("%u", urlencode($path), $remote);
}
else
$remote = $path;
}
}
else
{
$remote = $path;
}
// Bildgroesse bestimmen
if ($float != "" && ($width == "" || $height == ""))
{
if (!file_exists($path)) return "[image path doesn't exist.]";
$imgdata = image::getimagesize($path);
$width = $imgdata[0];
$height = $imgdata[1];
}
$href = $this->xml->url($href);
return call_user_func(array($this, $returntype), $remote, $width, $height, $signature, $float, $style, $sigstyle, $text, $parse["attributes_string"], $href);
}
private function xhtml($remote, $width, $height, $signature, $float, $style, $sigstyle, $text, $str, $href)
{
if ($href != "")
{
$al = "<a href=\"".$href."\">";
$ar = "</a>";
}
else
{
$al = "";
$ar = "";
}
if ($float != "")
{
$float = "float:".$float.";";
}
if ($signature == "signature")
{
return "<div class=\"image_signature\" style=\"".$float.$sigstyle." width:".$width.";\">".$al."<img alt=\"".xml::mask($text)."\" style=\"width:".$width."; height:".$height.";".$style."\" src=\"".$remote."\"".$str." />".$ar."<p>".$al.xml::mask($text).$ar."</p></div>";
}
return $al."<img alt=\"".xml::mask($text)."\" style=\"width:".$width."; height:".$height.";".$float.$style."\" src=\"".$remote."\"".$str." />".$ar;
}
}
?>
© 2009 Julian von Mendel (http://derjulian.net) | Datum: 10.09.2024