Exemple #1
0
/**
 * Creates and returns the relative path of an image thumbnail using the dynamic folder and dynamic file expressions
 * @param string $dynamicFolder the folder name (may be a tNG dynamic expression)
 * @param string $dynamicFileName the file name (may be a tNG dynamic expression)
 * @param integer $width the width of the thumbnail to be created
 * @param integer $height the width of the thumbnail to be created
 * @param boolean $proportional specify if the thumbnail preserve the proportions of the original image
 * @return string
 *         the relative path to the image file, 
 *         empty if the dynamicFileName is empty or if the thumbnail could ne be created
 */
function tNG_showDynamicThumbnail($siteRootPath, $dynamicFolder, $dynamicFileName, $width, $height, $proportional)
{
    $id = 'KT_thumbnail' . md5($siteRootPath . '_' . $dynamicFolder . '_' . $dynamicFileName . '_' . $width . '_' . $height . '_' . $proportional);
    if (!isset($GLOBALS[$id]) || !is_object($GLOBALS[$id])) {
        $objDynamicThumb1 = new tNG_DynamicThumbnail($siteRootPath, $id);
        $objDynamicThumb1->setFolder($dynamicFolder);
        $objDynamicThumb1->setRenameRule($dynamicFileName);
        $objDynamicThumb1->setResize($width, $height, $proportional);
        $GLOBALS[$id] = $objDynamicThumb1;
    }
    return $GLOBALS[$id]->Execute();
}
$listFolder->setBaseFolder($folder);
$listFolder->setFolder("");
$listFolder->setAllowedExtensions(implode(',', $uploadHash['allowedExtensions']));
$listFolder->setOrder('name', 'ASC');
//create the fake recordset
if (isset($isMysql)) {
    $tmp = $listFolder->Execute();
    if (!is_resource($tmp)) {
        die('Internal error');
    }
    $rsFiles = new KT_Recordset($tmp);
} else {
    $rsFiles = $listFolder->Execute();
    if (!is_object($rsFiles)) {
        die('Internal error');
    }
}
$totalRows_rsFiles = $rsFiles->RecordCount();
// end folder recordset
if (isset($uploadHash['thumbnail']['width']) && isset($uploadHash['thumbnail']['height']) || isset($uploadHash['thumbnail']['popupWidth']) && isset($uploadHash['thumbnail']['popupHeight'])) {
    $objDynamicThumb1 = new tNG_DynamicThumbnail("../../../", "KT_thumbnail_" . $reference);
    $objDynamicThumb1->setFolder($folder);
    $objDynamicThumb1->setRenameRule("{rsFiles.name}");
    if (isset($uploadHash['thumbnail']['width']) && isset($uploadHash['thumbnail']['height'])) {
        $objDynamicThumb1->setResize($uploadHash['thumbnail']['width'], $uploadHash['thumbnail']['height'], true);
    }
    if (isset($uploadHash['thumbnail']['popupWidth']) && isset($uploadHash['thumbnail']['popupHeight'])) {
        $objDynamicThumb1->setPopupSize($uploadHash['thumbnail']['popupWidth'], $uploadHash['thumbnail']['popupHeight'], true);
        $objDynamicThumb1->setPopupNavigation(false);
    }
}