本文整理汇总了PHP中str_replace_formatted_placeholder函数的典型用法代码示例。如果您正苦于以下问题:PHP str_replace_formatted_placeholder函数的具体用法?PHP str_replace_formatted_placeholder怎么用?PHP str_replace_formatted_placeholder使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了str_replace_formatted_placeholder函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: HookFormat_chooserCollection_downloadReplaceuseoriginal
function HookFormat_chooserCollection_downloadReplaceuseoriginal()
{
global $format_chooser_output_formats, $lang;
$defaultFormat = getDefaultOutputFormat();
?>
<div class="Question">
<label for="downloadformat"><?php
echo $lang["downloadformat"];
?>
</label>
<select name="ext" class="stdwidth" id="downloadformat">
<?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>
<div class="clearerleft"> </div></div><?php
return true;
}
示例2: HookFormat_chooserCollection_downloadReplaceuseoriginal
function HookFormat_chooserCollection_downloadReplaceuseoriginal()
{
global $format_chooser_output_formats, $format_chooser_profiles, $lang, $use_zip_extension;
$disabled = '';
$submitted = getvalescaped('submitted', null);
if (!empty($submitted)) {
$disabled = ' disabled="disabled"';
}
# Replace the existing ajax_download() with our own that disables our widgets, too
if ($use_zip_extension) {
?>
<script>
var originalDownloadFunction = ajax_download;
ajax_download = function() {
originalDownloadFunction();
jQuery('#downloadformat').attr('disabled', 'disabled');
jQuery('#profile').attr('disabled', 'disabled');
}
</script><?php
}
?>
<div class="Question">
<input type=hidden name="useoriginal" value="yes" />
<label for="downloadformat"><?php
echo $lang["downloadformat"];
?>
</label>
<select name="ext" class="stdwidth" id="downloadformat"<?php
echo $disabled;
?>
>
<option value="" selected="selected"><?php
echo $lang['format_chooser_keep_format'];
?>
</option>
<?php
foreach ($format_chooser_output_formats as $format) {
?>
<option value="<?php
echo $format;
?>
"><?php
echo str_replace_formatted_placeholder("%extension", $format, $lang["field-fileextension"]);
?>
</option><?php
}
?>
</select>
<div class="clearerleft"> </div></div><?php
if (!empty($format_chooser_profiles)) {
?>
<div class="Question">
<label for="profile"><?php
echo $lang['format_chooser_choose_profile'];
?>
</label>
<?php
showProfileChooser('stdwidth');
?>
<div class="clearerleft"> </div></div><?php
}
return true;
}
示例3: foreach
$count_restypes = 0;
foreach ($related_restypes as $rtype) {
if (in_array($rtype, $relatedtypes_shown)) {
// Don't show this type again.
continue;
}
$restypename = sql_value("select name as value from resource_type where ref = '{$rtype}'", "");
$restypename = lang_or_i18n_get_translated($restypename, "resourcetype-", "-2");
?>
<!--Panel for related resources-->
<div class="RecordBox">
<div class="RecordPanel">
<div id="RelatedResources">
<div class="RecordResouce">
<div class="Title"><?php
echo str_replace_formatted_placeholder("%restype%", $restypename, $lang["relatedresources-restype"]);
?>
</div>
<?php
# loop and display the results by file extension
for ($n = 0; $n < count($result); $n++) {
if ($result[$n]["resource_type"] == $rtype) {
$rref = $result[$n]["ref"];
$title = $result[$n]["field" . $view_title_field];
$access = get_resource_access($rref);
$use_watermark = check_use_watermark();
# swap title fields if necessary
if (isset($metadata_template_title_field) && isset($metadata_template_resource_type)) {
if ($result[$n]['resource_type'] == $metadata_template_resource_type) {
$title = $result[$n]["field" . $metadata_template_title_field];
}
示例4: get_nopreview_icon
# Show the no-preview icon
?>
<img src="<?php
echo $baseurl_short;
?>
gfx/<?php
echo get_nopreview_icon($resource["resource_type"], $resource["file_extension"], true);
?>
" />
<br />
<?php
}
if ($resource["file_extension"] != "") {
?>
<strong><?php
echo str_replace_formatted_placeholder("%extension", $resource["file_extension"], $lang["cell-fileoftype"]) . " (" . formatfilesize(@filesize_unlimited(get_resource_path($ref, true, "", false, $resource["file_extension"]))) . ")";
?>
</strong><?php
if (checkperm("w") && $resource["has_image"] == 1 && file_exists($wmpath)) {
?>
<a href="#" onclick="jQuery('#wmpreview').toggle();jQuery('#preview').toggle();if (jQuery(this).text()=='<?php
echo $lang['showwatermark'];
?>
'){jQuery(this).text('<?php
echo $lang['hidewatermark'];
?>
');} else {jQuery(this).text('<?php
echo $lang['showwatermark'];
?>
');}"><?php
echo $lang['showwatermark'];
示例5: get_resource_path
<div class="Fixed">
<?php
if ($resource["has_image"]==1)
{
?><img align="top" src="<?php echo get_resource_path($ref,false,($edit_large_preview?"pre":"thm"),false,$resource["preview_extension"],-1,1,checkperm("w"))?>" class="ImageBorder" style="margin-right:10px;"/><br />
<?php
}
else
{
# Show the no-preview icon
?>
<img src="../gfx/<?php echo get_nopreview_icon($resource["resource_type"],$resource["file_extension"],true)?>" />
<br />
<?php
}
if ($resource["file_extension"]!="") { ?><strong><?php echo str_replace_formatted_placeholder("%extension", $resource["file_extension"], $lang["cell-fileoftype"]) . " (" . formatfilesize(@filesize_unlimited(get_resource_path($ref,true,"",false,$resource["file_extension"]))) . ")" ?></strong><br /><?php } ?>
<?php if ($resource["has_image"]!=1) { ?>
<a href="<?php echo $baseurl_short?>pages/upload.php?ref=<?php echo urlencode($ref) ?>&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) ?>&upload_a_file=true" onClick="return CentralSpaceLoad(this,true);">> <?php echo $lang["uploadafile"]?></a>
<?php } else { ?>
<a href="<?php echo $baseurl_short?>pages/upload_<?php echo $top_nav_upload_type ?>.php?ref=<?php echo urlencode($ref) ?>&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) ?>&replace_resource=<?php echo urlencode($ref) ?>&resource_type=<?php echo $resource['resource_type']?>" onClick="return CentralSpaceLoad(this,true);">> <?php echo $lang["replacefile"]?></a>
<?php hook("afterreplacefile"); ?>
<?php } ?>
<?php if (! $disable_upload_preview) { ?><br />
<a href="<?php echo $baseurl_short?>pages/upload_preview.php?ref=<?php echo urlencode($ref) ?>&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) ?>" onClick="return CentralSpaceLoad(this,true);">> <?php echo $lang["uploadpreview"]?></a><?php } ?>
<?php if (! $disable_alternative_files) { ?><br />
<a href="<?php echo $baseurl_short?>pages/alternative_files.php?ref=<?php echo urlencode($ref) ?>&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) ?>" onClick="return CentralSpaceLoad(this,true);">> <?php echo $lang["managealternativefiles"]?></a><?php } ?>
<?php if ($allow_metadata_revert){?><br />
<a href="<?php echo $baseurl_short?>pages/edit.php?ref=<?php echo urlencode($ref) ?>&exif=true&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) ?>" onClick="return confirm('<?php echo $lang["confirm-revertmetadata"]?>');">>
<?php echo $lang["action-revertmetadata"]?></a><?php } ?>
<?php hook("afterfileoptions"); ?>
示例6: array_unique
for ($n = 0; $n < count($result); $n++) {
$related_file_extension = $result[$n]["file_extension"];
$related_file_extensions[] = $related_file_extension;
}
#reduce extensions array to unique values
$related_file_extensions = array_unique($related_file_extensions);
$count_extensions = 0;
foreach ($related_file_extensions as $rext) {
?>
<!--Panel for related resources-->
<div class="RecordBox">
<div class="RecordPanel">
<div class="RecordResouce">
<div class="Title"><?php
echo str_replace_formatted_placeholder("%extension", $rext, $lang["relatedresources-filename_extension"]);
?>
</div>
<?php
# loop and display the results by file extension
for ($n = 0; $n < count($result); $n++) {
if ($result[$n]["file_extension"] == $rext) {
$rref = $result[$n]["ref"];
$title = $result[$n]["field" . $view_title_field];
# swap title fields if necessary
if (isset($metadata_template_title_field) && isset($metadata_template_resource_type)) {
if ($result[$n]['resource_type'] == $metadata_template_resource_type) {
$title = $result[$n]["field" . $metadata_template_title_field];
}
}
?>
示例7: CentralSpaceLoad
" onClick="return CentralSpaceLoad(this,true);" <?php
if (!$infobox) {
?>
title="<?php
echo str_replace(array("\"", "'"), "", htmlspecialchars(i18n_get_translated($value)));
?>
"<?php
}
//end if infobox
?>
><?php
}
//end link
echo format_display_field($value);
if ($show_extension_in_search) {
echo " " . str_replace_formatted_placeholder("%extension", $result[$n]["file_extension"], $lang["fileextension"]);
}
if ($x == 0) {
// add link if necessary
?>
</a><?php
}
//end link
?>
</div></div>
<?php
}
/* end hook replaceresourcepanelinfolarge */
?>
<?php
// normal behavior
示例8: HookInplaceeditAllReplaceresourcepanelinfolarge
function HookInplaceeditAllReplaceresourcepanelinfolarge()
{
global $x, $value, $show_extension_in_search, $infobox, $url, $result, $ref, $df, $in_place_editable, $n;
if (!in_array($df[$x]['ref'], $in_place_editable)) {
return false;
}
# Should this field be displayed?
if (!in_array($df[$x]['ref'], $in_place_editable) || checkperm("F*") && !checkperm("F-" . $df[$x]["ref"]) && !($ref < 0 && checkperm("P" . $df[$x]["ref"])) || checkperm("F" . $df[$x]["ref"]) || $ref < 0 && $df[$x]["hide_when_uploading"] && $df[$x]["required"] == 0) {
return false;
}
?>
<div class="ResourcePanelInfo"><div class="extended">
<a class="editablefield" olddata-pk="<?php
echo htmlspecialchars($value);
?>
" data-pk="<?php
echo $df[$x]['ref'];
?>
" rel="<?php
echo urlencode($ref);
?>
" id="title<?php
echo htmlspecialchars($ref);
?>
" href="#">
<?php
echo format_display_field($value);
if ($show_extension_in_search) {
echo " " . str_replace_formatted_placeholder("%extension", $result[$n]["file_extension"], $lang["fileextension-inside-brackets"]);
}
?>
</a></div></div>
<?php
return true;
}
示例9: lang_or_i18n_get_translated
elseif($sort_relations_by_restype){
$count_restypes=0;
foreach($related_restypes as $rtype){
if(in_array($rtype,$relatedtypes_shown))
{
// Don't show this type again.
continue;
}
$restypename=sql_value("select name as value from resource_type where ref = '$rtype'","");
$restypename = lang_or_i18n_get_translated($restypename, "resourcetype-", "-2");
?><!--Panel for related resources-->
<div class="RecordBox">
<div class="RecordPanel">
<div id="RelatedResources">
<div class="RecordResouce">
<div class="Title"><?php echo str_replace_formatted_placeholder("%restype%", $restypename, $lang["relatedresources-restype"]); ?></div>
<?php
# loop and display the results by file extension
for ($n=0;$n<count($result);$n++)
{
if ($result[$n]["resource_type"]==$rtype){
$rref=$result[$n]["ref"];
$title=$result[$n]["field".$view_title_field];
$access=get_resource_access($rref);
$use_watermark=check_use_watermark();
# swap title fields if necessary
if (isset($metadata_template_title_field) && isset($metadata_template_resource_type))
{
if ($result[$n]['resource_type']==$metadata_template_resource_type)
{
示例10: get_resource_type_name
}
$resource_type = $resource['resource_type'];
$type_name = get_resource_type_name($resource_type);
$image = get_resource_path($ref, true, "", false, $ext);
if (!file_exists($image)) {
die($lang['error']);
}
#test if filetype is supported by exiftool
$command = $exiftool_fullpath . " -listf";
$formats = run_command($command);
$ext = strtoupper($ext);
if (strlen(strstr($formats, $ext)) < 2) {
die(str_replace_formatted_placeholder("%extension", $ext, $lang['filetypenotsupported']));
}
if (in_array(strtolower($ext), $exiftool_no_process)) {
die(str_replace_formatted_placeholder("%extension", $ext, $lang['exiftoolprocessingdisabledforfiletype']));
}
#build array of writable tags
$command = $exiftool_fullpath . " -listw";
$writable_tags = run_command($command);
$writable_tags = strtolower(str_replace("\n", "", $writable_tags));
$writable_tags_array = explode(" ", $writable_tags);
$command = $exiftool_fullpath . " -ver";
$exiftool_version = run_command($command);
if ($exiftool_version >= 7.4) {
#build array of writable formats
$command = $exiftool_fullpath . " -listwf";
$writable_formats = run_command($command);
$writable_formats = str_replace("\n", "", $writable_formats);
$writable_formats_array = explode(" ", $writable_formats);
$file_writability = in_array($ext, $writable_formats_array);
示例11: elseif
} elseif (count($searched_resource_types_names_array) == 0 && count($searched_collection_types_names_array) > 0) {
# Only (one or more) collection types are selected
$searchtitle = str_replace_formatted_placeholder("%collectiontypes%", $searched_collection_types_names_array, $lang["no_resourcetypes-collections"], false, $lang["collectiontypes_separator"]);
} elseif (count($searched_resource_types_names_array) > 0 && count($searched_collection_types_names_array) > 0) {
# Both resource types and collection types are selected
# Step 1: Replace %resourcetypes%
$searchtitle = $lang["all"] . " " . implode($lang["resourcetypes_separator"] . " ", $searched_resource_types_names_array);
//$searchtitle = str_replace_formatted_placeholder("%resourcetypes%", $searched_resource_types_names_array, $lang["resourcetypes-collections"], false, //$lang["resourcetypes_separator"]);
# Step 2: Replace %collectiontypes%
$searchtitle = str_replace_formatted_placeholder("%collectiontypes%", $searched_collection_types_names_array, $searchtitle, false, $lang["collectiontypes_separator"]);
} else {
# No resource types and no collection types are selected – show all resource types and all collection types
# Step 1: Replace %resourcetypes%
$searchtitle = str_replace_formatted_placeholder("%resourcetypes%", $lang["all-resourcetypes"], $lang["resourcetypes-collections"], false, $lang["resourcetypes_separator"]);
# Step 2: Replace %collectiontypes%
$searchtitle = str_replace_formatted_placeholder("%collectiontypes%", $lang["all-collectiontypes"], $searchtitle, false, $lang["collectiontypes_separator"]);
}
$search_title = '<h1 class="searchcrumbs"><a href="' . $baseurl_short . 'pages/search.php?search=" onClick="return CentralSpaceLoad(this,true);">' . $searchtitle . '</a></h1> ';
} elseif (substr($search, 0, 5) == "!last") {
$searchq = substr($search, 5);
$searchq = explode(",", $searchq);
$searchq = $searchq[0];
if (!is_numeric($searchq)) {
$searchq = 1000;
}
# 'Last' must be a number. SQL injection filter.
$search_title = '<h1 class="searchcrumbs"><a href="' . $baseurl_short . 'pages/search.php?search=!last' . $searchq . $parameters_string . '" onClick="return CentralSpaceLoad(this,true);">' . str_replace('%qty', $searchq, $lang["n_recent"]) . '</a>' . $searchcrumbs . '</h1> ';
} elseif (substr($search, 0, 8) == "!related") {
$resource = substr($search, 8);
$resource = explode(",", $resource);
$resource = $resource[0];
示例12: str_replace_formatted_placeholder
if($sort_relations_by_filetype){
#build array of related resources' file extensions
for ($n=0;$n<count($result);$n++){
$related_file_extension=$result[$n]["file_extension"];
$related_file_extensions[]=$related_file_extension;
}
#reduce extensions array to unique values
$related_file_extensions=array_unique($related_file_extensions);
$count_extensions=0;
foreach($related_file_extensions as $rext){
?><!--Panel for related resources-->
<div class="RecordBox">
<div class="RecordPanel">
<div class="RecordResouce">
<div class="Title"><?php echo str_replace_formatted_placeholder("%extension", $rext, $lang["relatedresources-filename_extension"]); ?></div>
<?php
# loop and display the results by file extension
for ($n=0;$n<count($result);$n++)
{
if ($result[$n]["file_extension"]==$rext){
$rref=$result[$n]["ref"];
$title=$result[$n]["field".$view_title_field];
# swap title fields if necessary
if (isset($metadata_template_title_field) && isset($metadata_template_resource_type))
{
if ($result[$n]['resource_type']==$metadata_template_resource_type)
{
$title=$result[$n]["field".$metadata_template_title_field];
示例13: if
# swap title fields if necessary
if (isset($metadata_template_resource_type) && isset ($metadata_template_title_field)){
if (($df[$x]['ref']==$view_title_field) && ($result[$n]['resource_type']==$metadata_template_resource_type)){
$value=$result[$n]['field'.$metadata_template_title_field];
}
}
?>
<?php
// extended css behavior
if ( in_array($df[$x]['ref'],$thumbs_display_extended_fields) &&
( (isset($metadata_template_title_field) && $df[$x]['ref']!=$metadata_template_title_field) || !isset($metadata_template_title_field) ) ){ ?>
<?php if (!hook("replaceresourcepanelinfo")){?>
<div class="ResourcePanelInfo"><div class="extended">
<?php if ($x==0){ // add link if necessary ?><a href="<?php echo $url?>" onClick="return CentralSpaceLoad(this,true);" <?php if (!$infobox) { ?>title="<?php echo str_replace(array("\"","'"),"",htmlspecialchars(i18n_get_translated($value)))?>"<?php } //end if infobox ?>><?php } //end link
echo format_display_field($value);
?><?php if ($show_extension_in_search) { ?><?php echo " " . str_replace_formatted_placeholder("%extension", $result[$n]["file_extension"], $lang["fileextension-inside-brackets"])?><?php } ?><?php if ($x==0){ // add link if necessary ?></a><?php } //end link?> </div></div>
<?php } /* end hook replaceresourcepanelinfo */?>
<?php
// normal behavior
} else if ( (isset($metadata_template_title_field)&&$df[$x]['ref']!=$metadata_template_title_field) || !isset($metadata_template_title_field) ) {?>
<div class="ResourcePanelInfo"><?php if ($x==0){ // add link if necessary ?><a href="<?php echo $url?>" onClick="return CentralSpaceLoad(this,true);" <?php if (!$infobox) { ?>title="<?php echo str_replace(array("\"","'"),"",htmlspecialchars(i18n_get_translated($value)))?>"<?php } //end if infobox ?>><?php } //end link?><?php echo highlightkeywords(tidy_trim(TidyList(i18n_get_translated($value)),$search_results_title_trim),$search,$df[$x]['partial_index'],$df[$x]['name'],$df[$x]['indexed'])?><?php if ($x==0){ // add link if necessary ?></a><?php } //end link?> </div><div class="clearer"></div>
<?php } ?>
<?php
}
?>
<!-- Checkboxes -->
<div class="ResourcePanelIcons">
<?php if(!hook("thumbscheckboxes")){?>
<?php if ($use_checkboxes_for_selection){?><input type="checkbox" id="check<?php echo htmlspecialchars($ref)?>" class="checkselect" <?php if (in_array($ref,$collectionresources)){ ?>checked<?php } ?> onclick="if (jQuery('#check<?php echo htmlspecialchars($ref)?>').attr('checked')=='checked'){ AddResourceToCollection(<?php echo htmlspecialchars($ref)?>); } else if (jQuery('#check<?php echo htmlspecialchars($ref)?>').attr('checked')!='checked'){ RemoveResourceFromCollection(<?php echo htmlspecialchars($ref)?>); }"> <?php } ?>
示例14: HookFormat_chooserViewReplacedownloadoptions
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'];
//.........这里部分代码省略.........
示例15: HookFormat_chooserViewReplacedownloadoptions
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'];
//.........这里部分代码省略.........