Verfasst: Mi 3. Dez 2008, 10:11
Hallo GaMbIt,
ich habe mal deine Änderungen versucht einzubauen aber ich bekommen trotzdem immer nur den Medianamen und die Beschreibung aus der upl und nicht aus der upl_meta - so scheint es zumindest.
Änder ich in der englischen Sprache die Description des Bildes - so wir mir auf beiden Sprache die veränderte Description angezeigt - und nicht blos für englisch.
Hast du mir einen Tipp was falsch läuft?
Grüße
matt
ich habe mal deine Änderungen versucht einzubauen aber ich bekommen trotzdem immer nur den Medianamen und die Beschreibung aus der upl und nicht aus der upl_meta - so scheint es zumindest.
Änder ich in der englischen Sprache die Description des Bildes - so wir mir auf beiden Sprache die veränderte Description angezeigt - und nicht blos für englisch.
Hast du mir einen Tipp was falsch läuft?
Grüße
matt
Code: Alles auswählen
<?php
cInclude("includes", "functions.api.images.php");
/* Gallery variables */
$bRecursive = false;
/* Input variables customized */
$iWidth_crop = "CMS_VALUE[7]";
$iHeight_crop = "CMS_VALUE[8]";
if ($iWidth_crop == 0) {
$iWidth_crop = '';
}
if ($iHeight_crop == 0) {
$iHeight_crop = '';
}
/* Cropping ? */
$iCrop = "CMS_VALUE[9]";
/* Input variables */
$iWidth = "CMS_VALUE[0]";
$iHeight = "CMS_VALUE[1]";
if ($iWidth == 0) {
$iWidth = 300;
}
if ($iHeight == 0) {
$iHeight = 300;
}
$iColumns = "CMS_VALUE[2]";
if ($iColumns == 0) {
$iColumns = 2;
}
$iRows = "CMS_VALUE[3]";
if ($iRows == 0) {
$iRows = 2;
}
$sPath = "CMS_VALUE[4]";
if ($sPath=='') {
$sPath = $cfgClient[$client]["path"]["frontend"] . $cfgClient[$client]["upl"]["frontendpath"] . "referenzen/";
} else {
$sPath = $cfgClient[$client]["path"]["frontend"] . $cfgClient[$client]["upl"]["frontendpath"] . "CMS_VALUE[4]";
$sPath_normal = "CMS_VALUE[4]";
}
$sort = "CMS_VALUE[5]";
if( $sort == "asc" ) {
$sort = SORT_ASC;
} else {
$sort = SORT_DESC;
}
$words = "CMS_VALUE[6]";
if (isset($start)) {
$iCurrentPage = $start;
} else {
$iCurrentPage = 1;
}
$aValidExtensions = array("jpg", "jpeg", "gif", "png");
$iImagesPerPage = $iRows * $iColumns;
/* Read all gallery files */
$aGalleryFiles = scanDirectory($sPath, $bRecursive);
array_multisort($aGalleryFiles, $sort, SORT_STRING);
if (is_array($aGalleryFiles)) {
/* Filter out non-images */
foreach ($aGalleryFiles as $key => $aGalleryFile) {
$sExtension = strtolower(getFileExtension($aGalleryFile));
if (!in_array($sExtension, $aValidExtensions)) {
unset($aGalleryFiles[$key]);
}
}
/* Calculate effective variables */
$iFileCount = count($aGalleryFiles);
$iPages = ceil($iFileCount / $iImagesPerPage);
$aImagesToDisplay = array_slice($aGalleryFiles, ($iCurrentPage - 1) * $iImagesPerPage, $iImagesPerPage);
$oImageTpl = new Template;
$oGalleryTpl = new Template;
$oEmptyImageTpl = new Template;
$aRenderedImages = array();
$iRow = 0;
$iImagesRendered = 0;
foreach ($aImagesToDisplay as $sImageToDisplay) {
$count++;
/* Do Scaling */
/* ### Customized - changes by GaMbIt ### */
/* Image scale */
$sScaledImage_cr = cApiImgScale($sImageToDisplay, $iWidth, $iHeight, false, false);
/* path */
$sScaledImage_cr = str_replace($cfgClient[$client]["path"]["htmlpath"],"",$sScaledImage_cr);
/* Image crop */
if (($iWidth_crop != 0) && ($iHeight_crop != 0)) {
$sScaledImage = cApiImgScale($sScaledImage_cr, $iWidth_crop, $iHeight_crop, true, true);
/* path */
$sScaledImage = str_replace($cfgClient[$client]["path"]["htmlpath"],"",$sScaledImage);
} else {
$sScaledImage = $sScaledImage_cr;
}
/* ### End custom changes by GaMbIt ### */
$link = str_replace($cfgClient[$client]['path']['frontend'],$cfgClient['htmlpath'],$sImageToDisplay);
$media = pl_getImageDescription($sImageToDisplay);
$media_name = $media["media"];
$link_description = $media["desc"];
$description = $link_description;
if ($words != "" || $words != 0) {
# Cutting text but preserving words and entities
if(strlen($link_description) > $words){
$description = htmlentities(capiStrTrimAfterWord($link_description, $words)."...");
} else {
$description = "";
}
}
if( $media_name != "" && $link_description != "") {
$link_description = $media_name.': '.$link_description;
} elseif( $media_name != "" ) {
$link_description = $link_description;
} elseif( $description != "" ) {
$link_description = $link_description;
$media_name = " ";
}
elseif( $media_name == "" ) {
$media_name = " ";
}
#if($count == $iFileCount)
#{
$count2 = ' id="ref_'.$count.'"';
#}
#else {}
$oImageTpl->reset();
$oImageTpl->set("s", "FILE", $sScaledImage);
$oImageTpl->set("s", "WIDTH", $iWidth);
$oImageTpl->set("s", "HEIGHT", $iHeight);
$oImageTpl->set("s", "LINK", $link);
$oImageTpl->set("s", "MEDIANAME", $media_name);
$oImageTpl->set("s", "DESCRIPTION", $description);
$oImageTpl->set("s", "LINKDESCRIPTION", $link_description);
$oImageTpl->set("s", "ID", $count2);
$aRenderedImages[] = $oImageTpl->generate($cfgClient[$client]["path"]["frontend"] . "templates/lightbox-gallery_image.html", true, false);
$iImagesRendered++;
if ($iImagesRendered == $iColumns) {
$oGalleryTpl->set("d", "COLUMNS", implode("", $aRenderedImages));
$oGalleryTpl->set("d", "PATH", $sPath_normal);
$oGalleryTpl->next();
$iImagesRendered = 0;
$aRenderedImages = array();
}
}
if (count($aRenderedImages) < $iColumns && count($aRenderedImages) > 0) {
$iEmptyCells = $iColumns - count($aRenderedImages);
$oEmptyImageTpl->set("s", "WIDTH", $iWidth);
$oEmptyImageTpl->set("s", "HEIGHT", $iHeight);
$sEmptyCells = str_repeat($oEmptyImageTpl->generate($cfgClient[$client]["path"]["frontend"] . "templates/lightbox-gallery_empty.html", true, false),$iEmptyCells);
$oGalleryTpl->set("d", "COLUMNS", implode("", $aRenderedImages) . $sEmptyCells);
$oGalleryTpl->next();
}
$aLinks = array();
if ($iCurrentPage > 1) {
$oPreviousTpl = new Template;
$oPreviousTpl->set("s", "LINK", $cfgClient[$client]["path"]["htmlpath"] . sprintf("front_content.php?idcatart=%s&start=%s", $idcatart, $iCurrentPage - 1));
$oPreviousTpl->set("s", "TITLE", mi18n("Zur�ck"));
$aLinks[] = $oPreviousTpl->generate($cfgClient[$client]["path"]["frontend"] . "templates/lightbox-gallery_link.html", true, false);
}
if (($iCurrentPage < $iPages) && $iCurrentPage) {
$oNextTpl = new Template;
$oNextTpl->set("s", "LINK", $cfgClient[$client]["path"]["htmlpath"] . sprintf("front_content.php?idcatart=%s&start=%s", $idcatart, $iCurrentPage + 1));
$oNextTpl->set("s", "TITLE", mi18n("Vor"));
$aLinks[] = $oNextTpl->generate($cfgClient[$client]["path"]["frontend"] . "templates/lightbox-gallery_link.html", true, false);
}
$oGalleryTpl->set("s", "NAVIGATION", implode("", $aLinks));
$oGalleryTpl->generate($cfgClient[$client]["path"]["frontend"] . "templates/lightbox-gallery.html", false, false);
}
function pl_getImageDescription($idupl) {
global $cfg, $cfgClient, $db, $client, $lang;
$cApiClient= new cApiClient($client);
$language_separator= $cApiClient->getProperty('language', 'separator');
if ($language_separator == "") {
//Sanity, if module used in client without set client setting
$language_separator= "§§§";
$cApiClient->setProperty('language', 'separator', $language_separator);
}
if (is_numeric($idupl)) {
//ID is a number
# $query= "SELECT description FROM " . $cfg["tab"]["upl"] . " WHERE idupl = " . $idupl;
$query= "SELECT u.description, m.medianame FROM " . $cfg["tab"]["upl"] . " u INNER JOIN " . $cfg["tab"]["upl_meta"] . " m ON u.idupl = m.idupl WHERE idupl = " . $idupl;
} else {
//ID is a string
$path_parts= pathinfo($idupl);
$upload= $cfgClient[$client]['upl']['frontendpath'];
$len= strlen($upload);
$pos= strpos($idupl, $upload);
$dirname= substr($path_parts['dirname'], $pos + $len) . '/';
# $query= "SELECT description FROM " . $cfg["tab"]["upl"] . " WHERE (dirname = '" . $dirname . "') AND (filename='" . $path_parts['basename'] . "') AND (filetype='" . $path_parts['extension'] . "')";
$query = "SELECT u.description, m.medianame FROM " . $cfg["tab"]["upl"] . " u INNER JOIN " . $cfg["tab"]["upl_meta"] . " m ON u.idupl = m.idupl WHERE (u.dirname = '" . $dirname . "') AND (u.filename='" . $path_parts['basename'] . "') AND (u.filetype='" . $path_parts['extension'] . "')";
}
$db->query($query);
if ($db->next_record()) {
# return htmlspecialchars(urldecode($db->f("description")));
return array("desc" => htmlspecialchars(urldecode($db->f("description"))),
"media" => htmlspecialchars(urldecode($db->f("medianame")))
);
} else {
return '';
}
}
?>