HINWEIS: Das ist kein offizieller Code, es gibt dort bereits ungetestete Modifizierungen für die nächste Version!
Code: Alles auswählen
<?php
/***********************************************
* CONTENIDO MODUL - OUTPUT
*
* Modulname : Galleriffic
* Author : Andreas Dinkelacker
* Copyright : Andreas Dinkelacker
* Created :
* Version :
* License : GNU/GPLv2 only (http://www.gnu.org/licenses/gpl-2.0.html#TOC1)
************************************************/
$value0="CMS_VALUE[0]"; //Bilder pro Seite
$value1="CMS_VALUE[1]"; // Breite der Galerie
$value2="CMS_VALUE[2]"; // Bildgroesse
$value3="CMS_VALUE[3]"; // Thumbgroesse
$value4="CMS_VALUE[4]"; // Ordner
$value5="CMS_VALUE[5]"; // eigene Image Groesse
$value6="CMS_VALUE[6]"; // eigene Image Breite
$value7="CMS_VALUE[7]"; // eigene Image Hoehe
$value8="CMS_VALUE[8]"; // eigene Thumb Groesse
$value9="CMS_VALUE[9]"; // eigene Thumb Breite
$value10="CMS_VALUE[10]"; // eigene Thumb Hoehe
$value11="CMS_VALUE[11]"; // Sichtbarkeit inaktiver Bilder
$value12="CMS_VALUE[12]"; // Caching
$value15="CMS_VALUE[15]"; // delete original file after resizing
$value16="CMS_VALUE[16]"; // Anzahl Spalten
$value17="CMS_VALUE[17]"; // Anordnung Navigation und Bild
$value18="CMS_VALUE[18]"; // Ausrichtung der Anzeige
$value19="CMS_VALUE[19]"; // Position Steuerelemente
$value20="CMS_VALUE[20]"; // Position Anzeige
$value21="CMS_VALUE[21]"; // Position Bild-Infobox
$value22="CMS_VALUE[22]"; // Quadratische Thumbs (Seitenverhaeltnis anpassen)
if ($value22!="true") $value22="false";
// Check if mod_rewrite may be active
if (substr_count($_SERVER[REQUEST_URI],"front_content.php")==0) {
$modRewrite=1;
$modRewriteFiller="?";
$phpSelf=str_replace("?".$_SERVER[QUERY_STRING],"",$_SERVER[REQUEST_URI]);
} else {
$modRewrite=0;
$modRewriteFiller="&";
$idcat=strip_tags($_GET[idcat]);
$idart=strip_tags($_GET[idart]);
$idcatart=strip_tags($_GET[idcatart]);
if ($idcat!="" && $idcat!=0) {
$artCat='idcat='.$idcat;
} elseif ($idart!="" && $idart!=0) {
$artCat='idart='.$idart;
} elseif ($idcatart!="" && $idcatart!=0) {
$artCat='idcatart='.$idcatart;
}
$phpSelf=$_SERVER[PHP_SELF].'?'.$artCat;
}
if ($_GET[filename]!="") {
$fileName=strip_tags($_GET[filename]);
$absPath=$cfgClient[$client]['upload'].$value4.$filename;
$fileSize=@filesize($absPath);
header("Content-type: ".getMime($absPath));
header("Content-Length: ".$fileSize);
header("Content-Disposition: attachment; filename=\"".$fileName."\"");
ob_clean();
flush();
readfile($absPath);
exit();
}
cInclude('classes', 'class.template.php');
$tpl = new Template;
$tpl->reset();
if ($value5!=1) {
$iSize=explode("x",$value2);
// Image height */
$iHeight=$iSize[1];
// Image width
$iWidth=$iSize[0];
} else {
// Image height
$iHeight=$value7;
// Image width
$iWidth=$value6;
}
if ($value8!=1) {
$tSize=explode("x",$value3);
// Thumb height
$tHeight=$tSize[1];
// Thumb width
$tWidth=$tSize[0];
} else {
// Thumb height
$tHeight=$value10;
// Thumb width
$tWidth=$value9;
}
// Set standard width which is set in the site properties.
// Necessary if there is an image which is bigger than this values
// (makes problems on resizing)
$iWidthSettings=$iWidth;
$tWidthSettings=$tWidth;
if ($value16=="A") {
// first calculate image size and thumb sizes to get the correct value
$restWidth=round($value1-$iWidthSettings-10,0);
$numOfThumbs=round($restWidth/($tWidthSettings+6),0);
} elseif ($value16>0) $numOfThumbs=$value16;
elseif ($value16==0) $numOfThumbs=$value0;
$naviWidth=round(($tWidthSettings*$numOfThumbs)+($numOfThumbs*17),0);
/*
The following variables will build the content of the gallery.
The divs must be separated to ensure more layout configuration.
*/
$contentDivStart='<div id="gallery-adv" class="gal_content"><div id="loading-adv" class="loader"></div>';
$contentControlsAdv='<div id="controls-adv" class="controls"></div>';
$contentSlideshowAdv='<div id="slideshow-adv" class="slideshow"></div>';
$contentCaptionAdv='<div id="caption-adv" class="embox"></div>';
$contentDivEnd='</div>';
$checkArr=array();
$allnones=0;
if (!in_array($value19,$checkArr)) if ($value19=="none") $allnones+=1; else array_push($checkArr,$value19);
if (!in_array($value20,$checkArr)) if ($value20=="none") $allnones+=1; else array_push($checkArr,$value20);
if (!in_array($value21,$checkArr)) if ($value21=="none") $allnones+=1; else array_push($checkArr,$value21);
if (sizeof($checkArr)<bcsub(3,$allnones)) $contentDivs=$contentDivStart.$contentControlsAdv.$contentLoadingAdv.$contentSlideshowAdv.$contentCaptionAdv.$contentDivEnd;
else {
$contentDivs=$contentDivStart;
if ($value19=="top") $contentDivs.=$contentControlsAdv;
elseif ($value20=="top") $contentDivs.=$contentSlideshowAdv;
elseif ($value21=="top") $contentDivs.=$contentCaptionAdv;
if ($value19=="middle") $contentDivs.=$contentControlsAdv;
elseif ($value20=="middle") $contentDivs.=$contentSlideshowAdv;
elseif ($value21=="middle") $contentDivs.=$contentCaptionAdv;
if ($value19=="bottom") $contentDivs.=$contentControlsAdv;
elseif ($value20=="bottom") $contentDivs.=$contentSlideshowAdv;
elseif ($value21=="bottom") $contentDivs.=$contentCaptionAdv;
}
/*
Define the alignment of the elements
*/
if ($value17=="lr") {
$naviPos='float:left;position:absolute;';
$contentPos='float:right;';
$galleryAlign='width:'.$value1.'px;position:relative;';
$tpl->set('s','CONTENTTOP',$contentDivs);
$tpl->set('s','CONTENTBOTTOM','');
} elseif ($value17=="rl") {
$naviPos='float:right;position:absolute;margin-left:'.bcadd($iWidth,20,0).'px;';
$contentPos='float:left;';
$galleryAlign='width:'.round($iWidth+10,0).'px;position:relative;';
$tpl->set('s','CONTENTTOP',$contentDivs);
$tpl->set('s','CONTENTBOTTOM','');
} elseif ($value17=="ou") {
$naviPos="width:".$value1."px";
$contentPos="";
$tpl->set('s','CONTENTBOTTOM','<br clear="all"/>'.$contentDivs);
$tpl->set('s','CONTENTTOP','');
$galleryAlign='width:'.round($iWidth+10,0).'px;position:relative;';
$numOfThumbs=substr(round($value1/($tWidth+6),2),0,-3);
echo $numOfThumbs;
} elseif ($value17=="uo") {
$naviPos="width:".$value1."px";
$contentPos="";
$tpl->set('s','CONTENTTOP',$contentDivs);
$tpl->set('s','CONTENTBOTTOM','');
$galleryAlign='width:'.round($iWidth+10,0).'px;position:relative;';
$numOfThumbs=substr(round($value1/($tWidth+6),2),0,-3);
}
if ($value18=="l") {
$galleryAlign.="left:0px;";
} elseif ($value18=="r") {
$galleryAlign.="right:0px;";
} elseif ($value18=="c") {
if ($value17=="uo" || $value17=="ou") {
if ($iWidth>$naviWidth) $thisWidth=round($iWidth+30,0);
else $thisWidth=$naviWidth;
} else $thisWidth=round($iWidth+$naviWidth+30,0);
$galleryAlign='width:'.$thisWidth.'px;position:relative;';
$galleryAlign.="left:50%;margin-left:-".round($thisWidth/2,0)."px;";
}
// Read the images
$fContent=scandir($cfgClient[$client]['upload'].$value4);
$countFiles=0;
foreach ($fContent as $key => $file) {
if (is_file($cfgClient[$client]['upload'].$value4.$file)) {
$fileId=mysql_fetch_assoc(mysql_query("SELECT * FROM ".$cfg[tab][upl]." WHERE filename='".$file."'"));
$fileId=$fileId[idupl];
$fileMeta=mysql_fetch_assoc(mysql_query("SELECT * FROM ".$cfg[tab][upl_meta]." WHERE idupl='".$fileId."'"));
if ($fileMeta[medianame]!="") $medianame=urldecode($fileMeta[medianame]);
else $medianame=$file;
if ($fileMeta[description]!="") $description=urldecode($fileMeta[description]);
else $description="";
$tpl->set('d', 'HREFORIGINAL', $phpSelf.$modRewriteFiller.'filename='.$file);
// Scale image to thumb size and to smaller size
// the next lines are necessary, that if the original file was
// replaced, the file now is resized again
$iWidth=$iWidthSettings;
$scaledThumb=cApiImgScale($cfgClient[$client]['upload'].$value4.$file, $tWidth, $tHeight, false, false, $value12);
// right here the decision is made, whether the thumbs should be quadratic
// or resized within keeping the aspect ratio
if ($value22=="true") {
$scaledThumb=str_replace($cfgClient[$client]['path']['htmlpath'],"",$scaledThumb);
$scaledThumbSize=@getimagesize($scaledThumb);
if ($scaledThumbSize[0]>$scaledThumbSize[1]) {$tmpHeight=$scaledThumbSize[1];$tmpWidth=$scaledThumbSize[1];}
else {$tmpWidth=$scaledThumbSize[0];$tmpHeight=$scaledThumbSize[0];}
$scaledThumb=cApiImgScale($scaledThumb, $tmpWidth, $tmpHeight, true, false, $value12);
}
$scaledImage=cApiImgScale($cfgClient[$client]['upload'].$value4.$file, $iWidth, $iHeight, false, false, $value12);
if ($value15==1) {
$scaledImage=strrchr($scaledImage,"/");
if (unlink($cfgClient[$client]['upload'].$value4.$file) && copy($cfgClient[$client]["path"]["frontend"]."cache".$scaledImage, $cfgClient[$client]["upl"]["path"].$value4.$file)) {
@unlink($cfgClient[$client]["path"]["frontend"]."cache".$scaledImage);
chmod($cfgClient[$client]["upl"]["path"].$value4.$file,0757);
$scaledImage=$cfgClient[$client]["htmlpath"]["frontend"].$cfgClient[$client]['upload'].$value4.$file;
}
}
$imgSize=getimagesize(str_replace($cfgClient[$client]["path"]["htmlpath"], $cfgClient[$client]["path"]["frontend"], $scaledImage));
if ($imgSize[0]<$iWidth) $iWidth=$imgSize[0];
$file=str_replace("/","",strrchr($scaledImage,"/"));
$tpl->set('d', 'HREFTHUMB', $scaledThumb);
$tpl->set('d', 'HREFRESIZE', $scaledImage);
$tpl->set('d', 'TITLE', $medianame);
$tpl->set('d', 'DOWNLOADORIGINAL', mi18n("Download"));
$tpl->set('d', 'DESCRIPTION', $description);
$tpl->set('s', 'NAVIWIDTH', $naviWidth);
$tpl->set('s', 'CONTENTPOS', $contentPos);
$tpl->set('s', 'CLOSEDIV', $contentDivEnd);
$tpl->set('s', 'NAVIPOS', $naviPos);
$tpl->set('s', 'GALLERYSETTINGS', $galleryAlign);
//$tpl->set('s', 'CONTENTWIDTH', round($iWidth+$naviWidth+50,0).'px');
$tpl->set('s', 'CONTENTWIDTH', $value1.'px');
$tpl->set('s', 'CONTROLWIDTH', $iWidth.'px');
$tpl->next();
$countFiles++;
}
}
$tpl->generate('templates/galleriffic.html');
// finally set the images per site to all images if CMS_VALUE[0] is set to 0
if ($value0==0) $value0=$countFiles;
function getMime($filename) {
$mime_types = array(
// images
'png' => 'image/png',
'jpe' => 'image/jpeg',
'jpeg' => 'image/jpeg',
'jpg' => 'image/jpeg',
'gif' => 'image/gif',
'bmp' => 'image/bmp',
'ico' => 'image/vnd.microsoft.icon',
'tiff' => 'image/tiff',
'tif' => 'image/tiff',
'svg' => 'image/svg+xml',
'svgz' => 'image/svg+xml'
);
$ext = strtolower(array_pop(explode('.',$filename)));
return $mime_types[$ext];
}
?>
<script type="text/javascript">
// Initially set opacity on thumbs and add
// additional styling for hover effect on thumbs
var onMouseOutOpacity = <?php echo $value11; ?>;
$('#thumbs-adv ul.thumbs li').css('opacity', onMouseOutOpacity)
.hover(
function () {
$(this).not('.selected').fadeTo('fast', 5.0);
},
function () {
$(this).not('.selected').fadeTo('fast', onMouseOutOpacity);
}
);
$(document).ready(function() {
// Initialize Advanced Galleriffic Gallery
var galleryAdv = $('#gallery-adv').galleriffic('#thumbs-adv', {
delay: 2000,
numThumbs: <?php echo $value0; ?>,
preloadAhead: <?php echo $value0; ?>,
enableTopPager: true,
enableBottomPager: true,
imageContainerSel: '#slideshow-adv',
controlsContainerSel: '#controls-adv',
captionContainerSel: '#caption-adv',
loadingContainerSel: '#loading-adv',
renderSSControls: true,
renderNavControls: true,
playLinkText: '<?php echo mi18n("Slideshow starten");?>',
pauseLinkText: '<?php echo mi18n("Slideshow anhalten");?>',
prevLinkText: '‹ <?php echo mi18n("Vorheriges Bild");?>',
nextLinkText: '<?php echo mi18n("Nächstes Bild");?> ›',
nextPageLinkText: '›',
prevPageLinkText: '‹',
lastPageLinkText: '»',
firstPageLinkText: '«',
enableHistory: true,
autoStart: false,
onChange: function(prevIndex, nextIndex) {
$('#thumbs-adv ul.thumbs').children()
.eq(prevIndex).fadeTo('fast', onMouseOutOpacity).end()
.eq(nextIndex).fadeTo('fast', 1.0);
},
onTransitionOut: function(callback) {
$('#slideshow-adv, #caption-adv').fadeOut('fast', callback);
},
onTransitionIn: function() {
$('#slideshow-adv, #caption-adv').fadeIn('fast');
},
onPageTransitionOut: function(callback) {
$('#thumbs-adv ul.thumbs').fadeOut('fast', callback);
},
onPageTransitionIn: function() {
$('#thumbs-adv ul.thumbs').fadeIn('fast');
}
});
});
</script>