class user_getHeaderPic {
var $cObj;
var $bildfeld;
var $conf;
var $subpath;
var $datum;
var $docroot;
var $debuginfo ="
";
//konstruktor
function user_getHeaderPic() {
unset($this->bildfeld);
unset($this->conf);
unset($this->subpath);
unset($this->datum);
$this->datum = getdate();
}
function main($content,$conf){
$start = microtime(true);
$tag = $this->datum[mday];
$monat = $this->datum[mon];
$jahr = $this->datum[year];
$this->debuginfo .= "Heutiges Datum: ".$tag.".".$monat.".".$jahr."
";
// globale variablenzuweisung
$this->conf = $conf;
$this->subpath = $GLOBALS['TSFE']->id.'/';
// lokale variablen
$mainpath = 'uploads/tx_bnseasons/';
// override season
if($this->conf["season"] == "auto") {
$this->debuginfo .= "Auto-Modus
Umstellung Winter: ".$this->conf["wday"].".".$this->conf["wmonth"]."
";
$this->debuginfo .= "Umstellung Sommer: ".$this->conf["sday"].".".$this->conf["smonth"]."
";
$this->conf["season"] = "sommer";
if($monat > $this->conf["wmonth"] || $monat < $this->conf["smonth"]) $this->conf["season"] = "winter";
if($monat == $this->conf["wmonth"]) if($tag > $this->conf["wday"]) $this->conf["season"] = "winter";
if($monat == $this->conf["smonth"]) if($tag < $this->conf["sday"]) $this->conf["season"] = "winter";
$this->debuginfo .= "Ermittelte Jahreszeit: ".$this->conf["season"];
}
$seasonpath = $this->conf["season"].'/';
// ermittle bildfeld in der seitenstruktur, gucke als erstes auf aktueller seite nach
$this->getFallbackField($GLOBALS['TSFE']->id);
if($this->bildfeld != 'false') {
//print_r('Ermitteltes Feld: '.$ergebnis);
$pics = explode(",", $this->bildfeld);
$this->debuginfo .= "
Gefundene Bilder: ".$this->bildfeld."
";
// auslesemodus random
if($this->conf["mode"] == 'random') shuffle($pics);
} else return "Keine Bilder bis Rootlevel gefunden";
// wieviele bilder sollen ausgegeben werden?
if($this->conf["mode"] == 'random' || $this->conf["mode"] == 'sort') {
if(count($pics) > $this->conf["picCount"]) $anzahlbilder = $this->conf["picCount"]; else $anzahlbilder = count($pics);
for($count = 0; $count < $anzahlbilder; $count++)
{
$bild = $pics[$count];
// override falls fpgallery-modus
if($this->conf["amode"] == "fpgallery") {
$thumblink .= '
';
$ausgabe = $thumblink;
} else {
$imgPath = $this->getImageResource($mainpath.$seasonpath.$this->subpath.$bild);
$ausgabe .= $this->wrapPics($this->conf["amode"], $imgPath);
}
}
}
if($this->conf["mode"] == 'single') {
$bild = $pics[$this->conf["listNum"]];
$imgPath = $this->getImageResource($mainpath.$seasonpath.$this->subpath.$bild);
$ausgabe .= $this->wrapPics($this->conf["amode"], $imgPath);
}
if($this->conf["amode"] == "supersized" || $this->conf["amode"] == "raw") $ausgabe = substr($ausgabe,0,-1);
if($this->conf["wrapSsJs"] == "true" && $this->conf["amode"] == "supersized") $ausgabe = $this->wrapSs($ausgabe);
$end = microtime(true);
$this->debuginfo .= $end-$start.' Sekunden Ausführungszeit
';
if($this->conf["debug"]) var_dump($this->debuginfo);
return $ausgabe;
}
function wrapPics($mode, $imgPath) {
$imgInfo = getimagesize($imgPath);
$bildw = $imgInfo[0];
$bildh = $imgInfo[1];
switch ($mode) {
case 'raw':
return $imgPath.",";
break;
case 'full':
return "
page[title]."' title='".$GLOBALS['TSFE']->page[title]."' width='".$bildw."' height='".$bildh."' />";
break;
case 'nosize':
return "
page[title]."' title='".$GLOBALS['TSFE']->page[title]."' />";
break;
case 'supersized':
return "{image : '".$imgPath."' , thumb : ''},";
break;
default: return "
page[title]."' title='".$GLOBALS['TSFE']->page[title]."' width='".$bildw."' height='".$bildh."' />";
}
}
function wrapSs($input) {
$output = '';
$output .= "";
return $output;
}
function getFallbackField($currentId) {
$where = "uid = ".$currentId;
$table = pages;
$fields = "uid, pid, tx_bnseasons_sommerbilder, tx_bnseasons_winterbilder";
$this->debuginfo .= "
Suche nach Bildern bei ID: ".$currentId." in Tabelle pages: ";
$res = $GLOBALS["TYPO3_DB"]->exec_SELECTquery($fields,$table,$where);
while($row = $GLOBALS["TYPO3_DB"]->sql_fetch_assoc($res)){
$sommerbilder = $row['tx_bnseasons_sommerbilder'];
$winterbilder = $row['tx_bnseasons_winterbilder'];
$pid = $row['pid'];
$uid = $row['uid'];
}
if($sommerbilder == '' && $winterbilder == '') {$this->debuginfo .= "Keine Bilder gefunden";} else {$this->subpath = $uid.'/';}
if($sommerbilder != '' && $this->conf["season"] == 'sommer') {$this->bildfeld = $sommerbilder; $this->debuginfo .= "Sommerbilder gefunden"; return true;}
if($winterbilder != '' && $this->conf["season"] == 'winter') {$this->bildfeld = $winterbilder; $this->debuginfo .= "Winterbilder gefunden"; return true;}
if($pid == 0) {$this->bildfeld = 'false'; return false;} else {$this->getFallbackField($pid);}
}
function getImageResource($origpfad){
$this->debuginfo .= "Ermitteltes Bild: ".$origpfad."
";
$img = array();
$img['file']=$origpfad;
$img['file.']['maxW']=$this->conf['maxW'];
$img['file.']['maxH']=$this->conf['maxH'];
$img['file.']['width']=$this->conf['width'];
$img['file.']['height']=$this->conf['height'];
return $this->cObj->IMG_RESOURCE($img);
}
function getImageThumb($origpfad){
$this->debuginfo .= "Generiere Thumbnail: ".$origpfad."
";
$img = array();
$img['file']=$origpfad;
$img['file.']['maxW']=$this->conf['tmaxW'];
$img['file.']['maxH']=$this->conf['tmaxH'];
$img['file.']['width']=$this->conf['twidth'];
$img['file.']['height']=$this->conf['theight'];
return $this->cObj->IMG_RESOURCE($img);
}
}
?>
The Financial Holding Company HAKA, based in Bressanone (Brixen) – Italy