function HookFormat_chooserCollection_downloadSize_is_available($resource, $path, $size)
{
    if (!supportsInputFormat($resource['file_extension'])) {
        # Let the caller decide whether the file is available
        return false;
    }
    $sizes = get_all_image_sizes();
    # Filter out the largest one
    $maxSize = null;
    $maxWidth = 0;
    for ($n = 0; $n < count($sizes); $n++) {
        if ($maxWidth < (int) $sizes[$n]['width']) {
            $maxWidth = (int) $sizes[$n]['width'];
            $maxSize = $sizes[$n]['id'];
        }
    }
    return $size != $maxSize;
}
示例#2
0
function HookFormat_chooserViewReplacedownloadoptions()
{
    global $resource, $ref, $counter, $headline, $lang, $download_multisize, $showprice, $save_as, $direct_link_previews, $hide_restricted_download_sizes, $format_chooser_output_formats, $baseurl_short, $search, $offset, $k, $order_by, $sort, $archive, $direct_download;
    $inputFormat = $resource['file_extension'];
    if ($resource["has_image"] != 1 || !$download_multisize || $save_as || !supportsInputFormat($inputFormat)) {
        return false;
    }
    $defaultFormat = getDefaultOutputFormat($inputFormat);
    $tableHeadersDrawn = false;
    ?>
<table cellpadding="0" cellspacing="0"><?php 
    hook("formatchooserbeforedownloads");
    $sizes = get_image_sizes($ref, false, $resource['file_extension'], false);
    $downloadCount = 0;
    $originalSize = -1;
    # Show original file download
    for ($n = 0; $n < count($sizes); $n++) {
        $downloadthissize = resource_download_allowed($ref, $sizes[$n]["id"], $resource["resource_type"]);
        $counter++;
        if ($sizes[$n]['id'] != '') {
            if ($downloadthissize) {
                $downloadCount++;
            }
            continue;
        }
        # Is this the original file? Set that the user can download the original file
        # so the request box does not appear.
        $fulldownload = false;
        if ($sizes[$n]["id"] == "") {
            $fulldownload = true;
        }
        $originalSize = $sizes[$n];
        $headline = $lang['collection_download_original'];
        if ($direct_link_previews && $downloadthissize) {
            $headline = make_download_preview_link($ref, $sizes[$n]);
        }
        if ($hide_restricted_download_sizes && !$downloadthissize && !checkperm("q")) {
            continue;
        }
        if (!$tableHeadersDrawn) {
            show_table_headers($showprice);
            $tableHeadersDrawn = true;
        }
        ?>
<tr class="DownloadDBlend" id="DownloadBox<?php 
        echo $n;
        ?>
">
		<td class="DownloadFileName"><h2><?php 
        echo $headline;
        ?>
</h2><p><?php 
        echo $sizes[$n]["filesize"];
        if (is_numeric($sizes[$n]["width"])) {
            echo preg_replace('/^<p>/', ', ', get_size_info($sizes[$n]), 1);
        }
        ?>
</p><td class="DownloadFileFormat"><?php 
        echo str_replace_formatted_placeholder("%extension", $resource["file_extension"], $lang["field-fileextension"]);
        ?>
</td><?php 
        if ($showprice) {
            ?>
<td><?php 
            echo get_display_price($ref, $sizes[$n]);
            ?>
</td><?php 
        }
        add_download_column($ref, $sizes[$n], $downloadthissize);
    }
    # Add drop down for all other sizes
    $closestSize = 0;
    if ($downloadCount > 0) {
        if (!$tableHeadersDrawn) {
            show_table_headers($showprice);
        }
        ?>
<tr class="DownloadDBlend">
		<td class="DownloadFileSizePicker"><select id="size"><?php 
        $sizes = get_all_image_sizes();
        # Filter out all sizes that are larger than our image size, but not the closest one
        for ($n = 0; $n < count($sizes); $n++) {
            if (intval($sizes[$n]['width']) >= intval($originalSize['width']) && intval($sizes[$n]['height']) >= intval($originalSize['height']) && ($closestSize == 0 || $closestSize > (int) $sizes[$n]['width'])) {
                $closestSize = (int) $sizes[$n]['width'];
            }
        }
        for ($n = 0; $n < count($sizes); $n++) {
            if (intval($sizes[$n]['width']) != $closestSize && intval($sizes[$n]['width']) > intval($originalSize['width']) && intval($sizes[$n]['height']) > intval($originalSize['height'])) {
                unset($sizes[$n]);
            }
        }
        foreach ($sizes as $n => $size) {
            # Only add choice if allowed
            $downloadthissize = resource_download_allowed($ref, $size["id"], $resource["resource_type"]);
            if (!$downloadthissize) {
                continue;
            }
            $name = $size['name'];
            if ($size['width'] == $closestSize) {
                $name = $lang['format_chooser_original_size'];
            }
            ?>
<option value="<?php 
            echo $n;
            ?>
"><?php 
            echo $name;
            ?>
</option><?php 
        }
        ?>
</select><p id="sizeInfo"></p></td><?php 
        if ($showprice) {
            ?>
<td>-</td><?php 
        }
        ?>
<td class="DownloadFileFormatPicker" style="vertical-align: top;"><select id="format"><?php 
        foreach ($format_chooser_output_formats as $format) {
            ?>
<option value="<?php 
            echo $format;
            ?>
" <?php 
            if ($format == $defaultFormat) {
                ?>
selected="selected"<?php 
            }
            ?>
><?php 
            echo str_replace_formatted_placeholder("%extension", $format, $lang["field-fileextension"]);
            ?>
</option><?php 
        }
        ?>
</select><?php 
        showProfileChooser();
        ?>
</td>
		<td class="DownloadButton"><a id="convertDownload" onClick="return CentralSpaceLoad(this,true);"><?php 
        echo $lang['action-download'];
        ?>
</a></td>
		</tr><?php 
    }
    ?>
</table><?php 
    hook("formatchooseraftertable");
    if ($downloadCount > 0) {
        ?>
<script type="text/javascript">
		// Store size info in JavaScript array
		var sizeInfo = {
			<?php 
        foreach ($sizes as $n => $size) {
            if ($size['width'] == $closestSize) {
                $size = $originalSize;
            }
            ?>
			<?php 
            echo $n;
            ?>
: {
				'info': '<?php 
            echo get_size_info($size, $originalSize);
            ?>
',
				'id': '<?php 
            echo $size['id'];
            ?>
',
			},
			<?php 
        }
        ?>
		};
		function updateSizeInfo() {
			var selected = jQuery('select#size').find(":selected").val();
			jQuery('#sizeInfo').html(sizeInfo[selected]['info']);
		}
		function updateDownloadLink() {
			var index = jQuery('select#size').find(":selected").val();
			var selectedFormat = jQuery('select#format').find(":selected").val();
			var profile = jQuery('select#profile').find(":selected").val();
			if (profile)
				profile = "&profile=" + profile;
			else
				profile = '';

			basePage = 'pages/download_progress.php?ref=<?php 
        echo $ref;
        ?>
&ext='
					+ selectedFormat.toLowerCase() + profile + '&size=' + sizeInfo[index]['id']
					+ '&search=<?php 
        echo urlencode($search);
        ?>
&offset=<?php 
        echo $offset;
        ?>
'
					+ '&k=<?php 
        echo $k;
        ?>
&archive=<?php 
        echo $archive;
        ?>
&sort='
					+ '<?php 
        echo $sort;
        ?>
&order_by=<?php 
        echo $order_by;
        ?>
';

			jQuery('a#convertDownload').attr('href', '<?php 
        echo $baseurl_short;
        if (!$direct_download) {
            echo 'pages/terms.php?ref=' . $ref . '&search=' . $search . '&k=' . $k . '&url=';
        }
        ?>
' + <?php 
        echo $direct_download ? 'basePage' : 'encodeURIComponent(basePage)';
        ?>
					);
		}
		jQuery(document).ready(function() {
			updateSizeInfo();
			updateDownloadLink();
		});
		jQuery('select#size').change(function() {
			updateSizeInfo();
			updateDownloadLink();
		});
		jQuery('select#format').change(function() {
			updateDownloadLink();
		});
		jQuery('select#profile').change(function() {
			updateDownloadLink();
		});
	</script><?php 
    }
    return true;
}
}
?>

<?php 
hook("collectiondownloadmessage");
if (!hook('replacesizeoptions')) {
    ?>
<div class="Question">
<label for="downloadsize"><?php 
    echo $lang["downloadsize"];
    ?>
</label>
<div class="tickset">
<?php 
    $maxaccess = collection_max_access($collection);
    $sizes = get_all_image_sizes(false, $maxaccess >= 1);
    $available_sizes = array_reverse($available_sizes, true);
    # analyze available sizes and present options
    ?>
<select name="size" class="stdwidth" id="downloadsize"><?php 
    function display_size_option($sizeID, $sizeName, $fordropdown = true)
    {
        global $available_sizes, $lang, $result;
        if ($fordropdown) {
            ?>
<option value="<?php 
            echo htmlspecialchars($sizeID);
            ?>
"><?php 
            echo $sizeName;
        }
function HookEmbedslideshowCollection_shareExtra_share_options()
{
    global $ref, $lang, $baseurl, $embedslideshow_min_size, $embedslideshow_max_size;
    ?>
	<li><a onClick="return CentralSpaceLoad(this,true);" href="collection_share.php?ref=<?php 
    echo $ref;
    ?>
&embedslideshow=true"><?php 
    echo $lang["embedslideshow"];
    ?>
</a></li>
	<?php 
    if (getval("embedslideshow", "") != "") {
        ?>
		<p><?php 
        echo $lang["embedslideshow_action_description"];
        ?>
</p>
				
		<div class="Question">		
		<label><?php 
        echo $lang["embedslideshow_size"];
        ?>
</label>
		<select name="size" class="stdwidth">
		<?php 
        $sizes = get_all_image_sizes(true);
        foreach ($sizes as $size) {
            if ($size["width"] <= $embedslideshow_max_size && $size["width"] >= $embedslideshow_min_size) {
                # Slideshow size is max of height/width so that all images will fit within the slideshow area (for default installs height/width is the same anyway though)
                ?>
				<option value="<?php 
                echo $size["id"];
                ?>
" <?php 
                if ($size["id"] == getval("size", "pre")) {
                    ?>
selected<?php 
                }
                ?>
><?php 
                echo str_replace(array("%name", "%pixels"), array($size["name"], max($size["width"], $size["height"])), $lang["sizename_pixels"]);
                ?>
</option>
				<?php 
            }
        }
        ?>
		</select>
		<div class="clearerleft"></div>
		</div>		

		<div class="Question">		
		<label><?php 
        echo $lang["embedslideshow_transitiontime"];
        ?>
</label>
		<select name="transition" class="stdwidth">
		<option value="0"><?php 
        echo $lang["embedslideshow_notransition"];
        ?>
</option>
		<?php 
        for ($n = 1; $n < 20; $n++) {
            ?>
		<option value="<?php 
            echo $n;
            ?>
" <?php 
            if ($n == getval("transition", "4")) {
                ?>
selected<?php 
            }
            ?>
><?php 
            echo str_replace("?", $n, $lang["embedslideshow_seconds"]);
            ?>
</option>
		<?php 
        }
        ?>
		</select>
		<div class="clearerleft"></div>
		</div>	

		<div class="Question">		
		<label><?php 
        echo $lang["embedslideshow_maximise_option"];
        ?>
</label>
		<input type="checkbox" value="1" name="maximise" <?php 
        if (isset($_POST["maximise"]) && $_POST["maximise"] == "1") {
            ?>
checked<?php 
        }
        ?>
>
		<div class="clearerleft"></div>
		</div>		

		<div class="QuestionSubmit" style="padding-top:0;margin-top:0;">
		<label for="buttons"> </label>
		<input name="generateslideshow" type="submit" value="&nbsp;&nbsp;<?php 
        echo $lang["generateslideshowhtml"];
        ?>
&nbsp;&nbsp;" />
		</div>
		<?php 
    }
    if (getval("generateslideshow", "") != "") {
        # Create a new external access key
        $key = generate_collection_access_key($ref, 0, $lang["slideshow"], 1, '');
        # Find image size
        $sizes = get_all_image_sizes(true);
        foreach ($sizes as $size) {
            if ($size["id"] == getval("size", "")) {
                break;
            }
        }
        # Slideshow size is max of height/width so that all images will fit within the slideshow area (for default installs height/width is the same anyway though)
        $width = max($size["width"], $size["height"]);
        $height = $width;
        $width_w_border = $width + 8;
        //expands width to display border
        $height += 48;
        // Enough space for controls
        # Create embed code
        $embed = "";
        if ($width < 850 && getval("maximise", "") == 1) {
            # Maxmimise function only necessary for < screen size slideshows
            $embed .= "\n\t\t\t<div id=\"embedslideshow_back_" . $ref . "\" style=\"display:none;position:absolute;top:0;left:0;width:100%;height:100%;min-height: 100%;background-color:#000;opacity: .5;filter: alpha(opacity=50);\"></div>\n\t\t\t<div id=\"embedslideshow_minimise_" . $ref . "\" style=\"position:absolute;top:5px;left:20px;background-color:white;border:1px solid black;display:none;color:black\"><a style=\"color:#000\" href=\"#\" onClick=\"\n\t\t\tvar ed=document.getElementById('embedslideshow_" . $ref . "');\n\t\t\ted.width='" . $width_w_border . "';\n\t\t\ted.height='" . $height . "';\t\t\n\t\t\ted.style.position='relative';\n\t\t\ted.style.top='0';\n\t\t\ted.style.left='0';\n\t\t\ted.src='" . $baseurl . "/plugins/embedslideshow/pages/viewer.php?ref={$ref}&key={$key}&size=" . getval("size", "") . "&transition=" . getval("transition", "") . "&width=" . $width . "&height=" . $height . "';\n\t\t\tdocument.getElementById('embedslideshow_minimise_" . $ref . "').style.display='none';\n\t\t\tdocument.getElementById('embedslideshow_maximise_" . $ref . "').style.display='block';\t\n\t\t\tdocument.getElementById('embedslideshow_back_" . $ref . "').style.display='none';\n\t\t\t\">" . $lang["embedslideshow_minimise"] . "</a></div>\n\t\t\t<div id=\"embedslideshow_maximise_" . $ref . "\" class=\"embedslideshow_maximise\"><a href=\"#\" onClick=\"\n\t\t\tvar ed=document.getElementById('embedslideshow_" . $ref . "');\n\t\t\ted.width='858';\n\t\t\ted.height='898';\n\t\t\ted.style.position='absolute';\n\t\t\ted.style.top='20px';\n\t\t\ted.style.left='20px';\n\t\t\ted.src='" . $baseurl . "/plugins/embedslideshow/pages/viewer.php?ref={$ref}&key={$key}&size=scr&width=850&transition=" . getval("transition", "") . "';\n\t\t\ted.style.zIndex=999;\n\t\t\tdocument.getElementById('embedslideshow_minimise_" . $ref . "').style.display='block';\n\t\t\tdocument.getElementById('embedslideshow_maximise_" . $ref . "').style.display='none';\t\n\t\t\tdocument.getElementById('embedslideshow_back_" . $ref . "').style.display='block';\t\n\t\t\t\">" . $lang["embedslideshow_maximise"] . "</a></div>";
        }
        $embed .= "<iframe id=\"embedslideshow_" . $ref . "\" Style=\"background-color:#fff;cursor: pointer;\" width=\"{$width_w_border}\" height=\"{$height}\" src=\"" . $baseurl . "/plugins/embedslideshow/pages/viewer.php?ref={$ref}&key={$key}&size=" . getval("size", "") . "&transition=" . getval("transition", "") . "&width={$width}&height={$height}\" frameborder=0 scrolling=no>Your browser does not support frames.</iframe>";
        # Compress embed HTML.
        $embed = str_replace("\n", " ", $embed);
        $embed = str_replace("\t", " ", $embed);
        while (strpos($embed, "  ") !== false) {
            $embed = str_replace("  ", " ", $embed);
        }
        ?>
		<div class="Question">		
		<label><?php 
        echo $lang["slideshowhtml"];
        ?>
</label>
		<textarea style="width:535px;height:120px;"><?php 
        echo htmlspecialchars($embed);
        ?>
</textarea>
		<div class="clearerleft"></div>
		</div>

		<div class="Question">		
		<label><?php 
        echo $lang["embedslideshow_directlink"];
        ?>
</label>
		<div class="Fixed"><a href="<?php 
        echo $baseurl;
        ?>
/plugins/embedslideshow/pages/viewer.php?ref=<?php 
        echo $ref;
        ?>
&key=<?php 
        echo $key;
        ?>
&size=<?php 
        echo getval("size", "");
        ?>
&transition=<?php 
        echo getval("transition", "");
        ?>
&width=<?php 
        echo $width;
        ?>
&height=<?php 
        echo $height;
        ?>
" target="_blank"><?php 
        echo $lang["embedslideshow_directlinkopen"];
        ?>
</a></div>
		<div class="clearerleft"></div>
		</div>
				
		<div class="Question">		
		<label><?php 
        echo $lang["slideshowpreview"];
        ?>
</label>
			<div class="Fixed">
			<?php 
        echo $embed;
        ?>
			</div>
		<div class="clearerleft"></div>
		</div>
		
		<?php 
    }
    return true;
}
    if (!$contact_sheet_include_header) {
        ?>
selected<?php 
    }
    ?>
><?php 
    echo $lang["no"];
    ?>
</option>
	</select>
	<div class="clearerleft"> </div>
	</div>
<?php 
}
if ($contact_sheet_single_select_size) {
    $sizes = get_all_image_sizes(false, false);
    ?>
	<div id="size_options" class="Question" style="display:none">
	<label><?php 
    echo $lang["contact_sheet-single_select_size"];
    ?>
</label>
	<select class="shrtwidth" name="ressize" id="ressize" onChange="jQuery().rsContactSheet('revert');">
	<?php 
    foreach ($sizes as $size) {
        echo '    <option value="' . $size['id'] . '"' . ($size['id'] == 'lpr' ? ' selected' : '') . '>' . htmlspecialchars($size['name']) . '</option>';
    }
    ?>
	
	
	</select>
示例#6
0
function HookFormat_chooserViewReplacedownloadoptions()
{
    global $resource, $ref, $counter, $headline, $lang, $download_multisize, $showprice, $save_as, $direct_link_previews, $hide_restricted_download_sizes, $format_chooser_output_formats, $baseurl_short, $search, $offset, $k, $order_by, $sort, $archive, $direct_download;
    $inputFormat = $resource['file_extension'];
    if ($resource["has_image"] != 1 || !$download_multisize || $save_as || !supportsInputFormat($inputFormat)) {
        return false;
    }
    $defaultFormat = getDefaultOutputFormat($inputFormat);
    $tableHeadersDrawn = false;
    ?>
<table cellpadding="0" cellspacing="0"><?php 
    hook("formatchooserbeforedownloads");
    $sizes = get_image_sizes($ref, false, $resource['file_extension'], false);
    $downloadCount = 0;
    $originalSize = -1;
    # Show original file download
    for ($n = 0; $n < count($sizes); $n++) {
        $downloadthissize = resource_download_allowed($ref, $sizes[$n]["id"], $resource["resource_type"]);
        $counter++;
        if ($sizes[$n]['id'] != '') {
            if ($downloadthissize) {
                $downloadCount++;
            }
            continue;
        }
        # Is this the original file? Set that the user can download the original file
        # so the request box does not appear.
        $fulldownload = false;
        if ($sizes[$n]["id"] == "") {
            $fulldownload = true;
        }
        $originalSize = $sizes[$n];
        $headline = $lang['collection_download_original'];
        if ($direct_link_previews && $downloadthissize) {
            $headline = make_download_preview_link($ref, $sizes[$n]);
        }
        if ($hide_restricted_download_sizes && !$downloadthissize && !checkperm("q")) {
            continue;
        }
        if (!$tableHeadersDrawn) {
            show_table_headers($showprice);
            $tableHeadersDrawn = true;
        }
        ?>
<tr class="DownloadDBlend" id="DownloadBox<?php 
        echo $n;
        ?>
">
		<td class="DownloadFileName"><h2><?php 
        echo $headline;
        ?>
</h2><p><?php 
        echo $sizes[$n]["filesize"];
        if (is_numeric($sizes[$n]["width"])) {
            echo preg_replace('/^<p>/', ', ', get_size_info($sizes[$n]), 1);
        }
        ?>
</p><td class="DownloadFileFormat"><?php 
        echo str_replace_formatted_placeholder("%extension", $resource["file_extension"], $lang["field-fileextension"]);
        ?>
</td><?php 
        if ($showprice) {
            ?>
<td><?php 
            echo get_display_price($ref, $sizes[$n]);
            ?>
</td><?php 
        }
        add_download_column($ref, $sizes[$n], $downloadthissize);
    }
    # Add drop down for all other sizes
    $closestSize = 0;
    if ($downloadCount > 0) {
        if (!$tableHeadersDrawn) {
            show_table_headers($showprice);
        }
        ?>
<tr class="DownloadDBlend">
		<td class="DownloadFileSizePicker"><select id="size"><?php 
        $sizes = get_all_image_sizes();
        # Filter out all sizes that are larger than our image size, but not the closest one
        for ($n = 0; $n < count($sizes); $n++) {
            if (intval($sizes[$n]['width']) >= intval($originalSize['width']) && intval($sizes[$n]['height']) >= intval($originalSize['height']) && ($closestSize == 0 || $closestSize > (int) $sizes[$n]['width'])) {
                $closestSize = (int) $sizes[$n]['width'];
            }
        }
        for ($n = 0; $n < count($sizes); $n++) {
            if (intval($sizes[$n]['width']) != $closestSize && intval($sizes[$n]['width']) > intval($originalSize['width']) && intval($sizes[$n]['height']) > intval($originalSize['height'])) {
                unset($sizes[$n]);
            }
        }
        foreach ($sizes as $n => $size) {
            # Only add choice if allowed
            $downloadthissize = resource_download_allowed($ref, $size["id"], $resource["resource_type"]);
            if (!$downloadthissize) {
                continue;
            }
            $name = $size['name'];
            if ($size['width'] == $closestSize) {
                $name = $lang['format_chooser_original_size'];
            }
            ?>
<option value="<?php 
            echo $n;
            ?>
"><?php 
            echo $name;
            ?>
</option><?php 
        }
        ?>
</select><p id="sizeInfo"></p></td><?php 
        if ($showprice) {
            ?>
<td>-</td><?php 
        }
        ?>
<td class="DownloadFileFormatPicker" style="vertical-align: top;"><select id="format"><?php 
        foreach ($format_chooser_output_formats as $format) {
            ?>
<option value="<?php 
            echo $format;
            ?>
" <?php 
            if ($format == $defaultFormat) {
                ?>
selected="selected"<?php 
            }
            ?>
><?php 
            echo str_replace_formatted_placeholder("%extension", $format, $lang["field-fileextension"]);
            ?>
</option><?php 
        }
        ?>
</select><?php 
        showProfileChooser();
        ?>
</td>
		<td class="DownloadButton"><a id="convertDownload" onClick="return CentralSpaceLoad(this,true);"><?php 
        echo $lang['action-download'];
        ?>
</a></td>
		</tr><?php 
    }
    ?>
</table><?php 
    hook("formatchooseraftertable");
    if ($downloadCount > 0) {
        ?>
<script type="text/javascript">
			// Store size info in JavaScript array
			var sizeInfo = {
				<?php 
        foreach ($sizes as $n => $size) {
            if ($size['width'] == $closestSize) {
                $size = $originalSize;
            }
            ?>
				<?php 
            echo $n;
            ?>
: {
					'info': '<?php 
            echo get_size_info($size, $originalSize);
            ?>
',
					'id': '<?php 
            echo $size['id'];
            ?>
',
				},
				<?php 
        }
        ?>
			};
			function updateSizeInfo() {
				var selected = jQuery('select#size').find(":selected").val();
				jQuery('#sizeInfo').html(sizeInfo[selected]['info']);
			}
			function updateDownloadLink() {
				var index = jQuery('select#size').find(":selected").val();
				var selectedFormat = jQuery('select#format').find(":selected").val();
				var profile = jQuery('select#profile').find(":selected").val();
				if (profile)
					profile = "&profile=" + profile;
				else
					profile = '';

				basePage = 'pages/download_progress.php?ref=<?php 
        echo $ref;
        ?>
&ext='
						+ selectedFormat.toLowerCase() + profile + '&size=' + sizeInfo[index]['id']
						+ '&search=<?php 
        echo urlencode($search);
        ?>
&offset=<?php 
        echo $offset;
        ?>
'
						+ '&k=<?php 
        echo $k;
        ?>
&archive=<?php 
        echo $archive;
        ?>
&sort='
						+ '<?php 
        echo $sort;
        ?>
&order_by=<?php 
        echo $order_by;
        ?>
';

				jQuery('a#convertDownload').attr('href', '<?php 
        echo $baseurl_short;
        if (!$direct_download) {
            echo 'pages/terms.php?ref=' . $ref . '&search=' . $search . '&k=' . $k . '&url=';
        }
        ?>
' + <?php 
        echo $direct_download ? 'basePage' : 'encodeURIComponent(basePage)';
        ?>
						);
			}
			jQuery(document).ready(function() {
				updateSizeInfo();
				updateDownloadLink();
			});
			jQuery('select#size').change(function() {
				updateSizeInfo();
				updateDownloadLink();
			});
			jQuery('select#format').change(function() {
				updateDownloadLink();
			});
			jQuery('select#profile').change(function() {
				updateDownloadLink();
			});
		</script>
		<?php 
    }
    global $access, $alt_types_organize, $alternative_file_previews, $userrequestmode;
    # Alternative files listing
    $alt_access = hook("altfilesaccess");
    if ($access == 0) {
        $alt_access = true;
    }
    # open access (not restricted)
    if ($alt_access) {
        $alt_order_by = "";
        $alt_sort = "";
        if ($alt_types_organize) {
            $alt_order_by = "alt_type";
            $alt_sort = "asc";
        }
        $altfiles = get_alternative_files($ref, $alt_order_by, $alt_sort);
        hook("processaltfiles");
        $last_alt_type = "-";
        ?>
	<table>
	<?php 
        for ($n = 0; $n < count($altfiles); $n++) {
            $alt_type = $altfiles[$n]['alt_type'];
            if ($alt_types_organize) {
                if ($alt_type != $last_alt_type) {
                    $alt_type_header = $alt_type;
                    if ($alt_type_header == "") {
                        $alt_type_header = $lang["alternativefiles"];
                    }
                    hook("viewbeforealtheader");
                    ?>
				<tr class="DownloadDBlend">
				<td colspan="3" id="altfileheader"><h2><?php 
                    echo $alt_type_header;
                    ?>
</h2></td>
				</tr>
				<?php 
                }
                $last_alt_type = $alt_type;
            } else {
                if ($n == 0) {
                    hook("viewbeforealtheader");
                    ?>
			<tr>
			<td colspan="3" id="altfileheader"><?php 
                    echo $lang["alternativefiles"];
                    ?>
</td>
			</tr>
			<?php 
                }
            }
            $alt_thm = "";
            $alt_pre = "";
            if ($alternative_file_previews) {
                $alt_thm_file = get_resource_path($ref, true, "col", false, "jpg", -1, 1, false, "", $altfiles[$n]["ref"]);
                if (file_exists($alt_thm_file)) {
                    # Get web path for thumb (pass creation date to help cache refresh)
                    $alt_thm = get_resource_path($ref, false, "col", false, "jpg", -1, 1, false, $altfiles[$n]["creation_date"], $altfiles[$n]["ref"]);
                }
                $alt_pre_file = get_resource_path($ref, true, "pre", false, "jpg", -1, 1, false, "", $altfiles[$n]["ref"]);
                if (file_exists($alt_pre_file)) {
                    # Get web path for preview (pass creation date to help cache refresh)
                    $alt_pre = get_resource_path($ref, false, "pre", false, "jpg", -1, 1, false, $altfiles[$n]["creation_date"], $altfiles[$n]["ref"]);
                }
            }
            ?>
		<tr class="DownloadDBlend" <?php 
            if ($alt_pre != "" && isset($alternative_file_previews_mouseover) && $alternative_file_previews_mouseover) {
                ?>
onMouseOver="orig_preview=jQuery('#previewimage').attr('src');orig_width=jQuery('#previewimage').width();jQuery('#previewimage').attr('src','<?php 
                echo $alt_pre;
                ?>
');jQuery('#previewimage').width(orig_width);" onMouseOut="jQuery('#previewimage').attr('src',orig_preview);"<?php 
            }
            ?>
>
		<td class="DownloadFileName">
		<?php 
            if (!hook("renderaltthumb")) {
                ?>
		<?php 
                if ($alt_thm != "") {
                    ?>
<a href="<?php 
                    echo $baseurl_short;
                    ?>
pages/preview.php?ref=<?php 
                    echo urlencode($ref);
                    ?>
&alternative=<?php 
                    echo $altfiles[$n]["ref"];
                    ?>
&k=<?php 
                    echo urlencode($k);
                    ?>
&search=<?php 
                    echo urlencode($search);
                    ?>
&offset=<?php 
                    echo urlencode($offset);
                    ?>
&order_by=<?php 
                    echo urlencode($order_by);
                    ?>
&sort=<?php 
                    echo urlencode($sort);
                    ?>
&archive=<?php 
                    echo urlencode($archive);
                    ?>
&<?php 
                    echo hook("previewextraurl");
                    ?>
"><img src="<?php 
                    echo $alt_thm;
                    ?>
" class="AltThumb"></a><?php 
                }
                ?>
		<?php 
            }
            ?>
		<h2 class="breakall"><?php 
            echo htmlspecialchars($altfiles[$n]["name"]);
            ?>
</h2>
		<p><?php 
            echo htmlspecialchars($altfiles[$n]["description"]);
            ?>
</p>
		</td>
		<td class="DownloadFileSize"><?php 
            echo formatfilesize($altfiles[$n]["file_size"]);
            ?>
</td>
		
		<?php 
            if ($userrequestmode == 2 || $userrequestmode == 3) {
                ?>
<td></td><?php 
            }
            # Blank spacer column if displaying a price above (basket mode).
            ?>
		
		<?php 
            if ($access == 0) {
                ?>
		<td class="DownloadButton">
		<?php 
                if (!$direct_download || $save_as) {
                    if (!hook("downloadbuttonreplace")) {
                        ?>
<a <?php 
                        if (!hook("downloadlink", "", array("ref=" . $ref . "&alternative=" . $altfiles[$n]["ref"] . "&k=" . $k . "&ext=" . $altfiles[$n]["file_extension"]))) {
                            ?>
href="<?php 
                            echo $baseurl_short;
                            ?>
pages/terms.php?ref=<?php 
                            echo urlencode($ref);
                            ?>
&k=<?php 
                            echo urlencode($k);
                            ?>
&search=<?php 
                            echo urlencode($search);
                            ?>
&url=<?php 
                            echo urlencode("pages/download_progress.php?ref=" . $ref . "&ext=" . $altfiles[$n]["file_extension"] . "&k=" . $k . "&alternative=" . $altfiles[$n]["ref"] . "&search=" . urlencode($search) . "&offset=" . $offset . "&archive=" . $archive . "&sort=" . $sort . "&order_by=" . urlencode($order_by));
                            ?>
"<?php 
                        }
                        ?>
 onClick="return CentralSpaceLoad(this,true);"><?php 
                        echo $lang["action-download"];
                        ?>
</a><?php 
                    }
                } else {
                    ?>
			<a href="#" onclick="directDownload('<?php 
                    echo $baseurl_short;
                    ?>
pages/download_progress.php?ref=<?php 
                    echo urlencode($ref);
                    ?>
&ext=<?php 
                    echo $altfiles[$n]["file_extension"];
                    ?>
&k=<?php 
                    echo urlencode($k);
                    ?>
&alternative=<?php 
                    echo $altfiles[$n]["ref"];
                    ?>
')"><?php 
                    echo $lang["action-download"];
                    ?>
</a>
		<?php 
                }
                // end if direct_download
                ?>
</td></td>
		<?php 
            } else {
                ?>
		<td class="DownloadButton DownloadDisabled"><?php 
                echo $lang["access1"];
                ?>
</td>
		<?php 
            }
            ?>
		</tr>
		<?php 
        }
        hook("morealtdownload");
        ?>
   	</table>
   	<?php 
    }
    # --- end of alternative files listing
    return true;
}