function HookResourceofthedayHomeReplaceslideshow() { include_once dirname(__FILE__) . "/../inc/rotd_functions.php"; global $baseurl, $view_title_field; $rotd = get_resource_of_the_day(); if ($rotd === false) { return false; } # No ROTD, return false to disable hook and display standard slide show. # Get preview width $sizes = get_image_sizes($rotd, true); foreach ($sizes as $size) { if ($size["id"] == "pre") { $width = $size["width"]; break; } } # Fetch title $title = sql_value("select value from resource_data where resource='{$rotd}' and resource_type_field={$view_title_field}", ""); # Fetch caption $caption = sql_value("select value from resource_data where resource='{$rotd}' and resource_type_field=18", ""); # Show resource! $pre = get_resource_path($rotd, false, "pre", false, "jpg"); ?> <div class="HomePicturePanel RecordPanel" style="width: <?php echo $width; ?> px; padding-left: 3px;"> <a onClick="return CentralSpaceLoad(this,true);" href="<?php echo $baseurl; ?> /pages/view.php?ref=<?php echo $rotd; ?> "><img class="ImageBorder" style="margin-bottom: 10px;" src="<?php echo $pre; ?> " /></a> <br /> <h2 ><?php echo i18n_get_translated(htmlspecialchars($title)); ?> </h2> <?php echo $caption; ?> </div> <?php return true; }
/** * Back-end widget form. * * @see WP_Widget::form() * * @param array $instance Previously saved values from database. */ public function form($instance) { $sort = !empty($instance['sort']) ? esc_attr($instance['sort']) : ''; $image = !empty($instance['image']) ? esc_attr($instance['image']) : ''; $title = !empty($instance['title']) ? esc_attr($instance['title']) : ''; $alt = !empty($instance['alt']) ? esc_attr($instance['alt']) : ''; $text = !empty($instance['text']) ? $instance['text'] : ''; $url = !empty($instance['url']) ? esc_attr($instance['url']) : ''; $button = !empty($instance['button']) ? esc_attr($instance['button']) : ''; $size = !empty($instance['size']) ? esc_attr($instance['size']) : ''; $style = !empty($instance['style']) ? esc_attr($instance['style']) : ''; // Make the order array. if (!empty($sort)) { $fields = explode(',', $sort); } else { $fields = array('no-order'); } // Hide the image. if ($image != '') { $imageoptions = 'style="display:block;"'; } else { $imageoptions = 'style="display:none;"'; } ?> <p id="<?php echo $this->id . '-title'; ?> "> <label for="<?php echo $this->get_field_id('title'); ?> "><?php _e('Title', 'image-widget'); ?> : <input class="widefat" id="<?php echo $this->get_field_id('title'); ?> " name="<?php echo $this->get_field_name('title'); ?> " type="text" value="<?php echo esc_attr($title); ?> "> <small><?php _e('Give the widget a title (If you need one)', 'image-widget'); ?> .</small> </label> </p> <div class="widget-image-sortable"> <?php foreach ($fields as $field) { ?> <?php if ($field == $this->id . '-image' || $field === 'no-order') { ?> <p id="<?php echo $this->id . '-image'; ?> "> <label for="select-image"><?php _e('Select image', 'image-widget'); ?> : <button class="widefat button widget-control-save widget-image-select" name="select-image"><?php _e('Select image', 'image-widget'); ?> </button> <input class="widefat" id="<?php echo $this->get_field_id('image'); ?> " name="<?php echo $this->get_field_name('image'); ?> " type="hidden" value="<?php echo esc_attr($image); ?> "> <?php if (!empty($image)) { echo '<img class="imagePreview" src="' . esc_attr($image) . '">'; } else { echo '<img ' . $imageoptions . ' class="imagePreview" src="data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs%3D">'; } ?> </label> <a href="#" class="imageRemove"><?php _e('Remove Image', 'image-widget'); ?> </a> </p> <?php } ?> <?php if ($field == $this->id . '-text' || $field === 'no-order') { ?> <p id="<?php echo $this->id . '-text'; ?> "> <label for="<?php echo $this->get_field_id('text'); ?> "><?php _e('Text', 'image-widget'); ?> : <textarea rows="6" class="widefat" id="<?php echo $this->get_field_id('text'); ?> " name="<?php echo $this->get_field_name('text'); ?> "><?php echo format_to_edit($text); ?> </textarea> <small><?php _e('Add or edit a description for the widget', 'image-widget'); ?> .</small> </label> </p> <?php } ?> <?php if ($field == $this->id . '-button' || $field === 'no-order') { ?> <p id="<?php echo $this->id . '-button'; ?> "> <label for="<?php echo $this->get_field_id('button'); ?> "><?php _e('Button', 'image-widget'); ?> : <input class="widefat" id="<?php echo $this->get_field_id('button'); ?> " name="<?php echo $this->get_field_name('button'); ?> " type="text" value="<?php echo esc_attr($button); ?> "> <small><?php _e('Add a text that will be displayed in the button', 'image-widget'); ?> .</small> </label> </p> <?php } ?> <?php } ?> </div> <input class="widefat image-widget-sort-order" id="<?php echo $this->get_field_id('sort'); ?> " name="<?php echo $this->get_field_name('sort'); ?> " type="text" value="<?php echo esc_attr($sort); ?> "> <p> <label for="<?php echo $this->get_field_id('url'); ?> "><?php _e('Link', 'image-widget'); ?> : <input class="widefat" id="<?php echo $this->get_field_id('url'); ?> " name="<?php echo $this->get_field_name('url'); ?> " type="text" value="<?php echo esc_attr($url); ?> "> <small><?php _e('Add an url that the widget should refer to (Button and Image)', 'image-widget'); ?> .</small> </label> </p> <div class="non-sortable" <?php echo $imageoptions; ?> > <h4><?php _e('Widget Options', 'image-widget'); ?> </h4> <label for="<?php echo $this->get_field_id('alt'); ?> "><?php _e('Alternate Text', 'image-widget'); ?> : <input class="widefat" id="<?php echo $this->get_field_id('alt'); ?> " name="<?php echo $this->get_field_name('alt'); ?> " type="text" value="<?php echo esc_attr($alt); ?> "> <small><?php _e('Give the image a alt tag', 'image-widget'); ?> .</small> </label> <label for="<?php echo $this->get_field_id('style'); ?> "><?php _e('Image style', 'image-widget'); ?> : <select class='widefat' id="<?php echo $this->get_field_id('style'); ?> " name="<?php echo $this->get_field_name('style'); ?> "> <?php $img_styles = array('img-square' => __('Square', 'image-widget'), 'img-round' => __('Round', 'image-widget')); foreach ($img_styles as $img_style => $img_style_name) { ?> <option value="<?php echo $img_style; ?> " <?php selected($img_style, $style, true); ?> ><?php echo $img_style_name; ?> </option> <?php } ?> </select> <small><?php _e('Select a style for the image', 'image-widget'); ?> .</small> </label> <label for="<?php echo $this->get_field_id('size'); ?> "><?php _e('Image size', 'image-widget'); ?> : <select class='widefat' id="<?php echo $this->get_field_id('size'); ?> " name="<?php echo $this->get_field_name('size'); ?> "> <?php $img_sizes = get_image_sizes(); foreach ($img_sizes as $img_size => $image) { ?> <option value="<?php echo $img_size; ?> " <?php selected($size, $img_size, true); ?> ><?php echo $img_size; ?> </option> <?php } ?> </select> <small><?php _e('Select an image size', 'image-widget'); ?> .</small> </label> </div> <?php }
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 } else { # ----------------------------------- Show the PayPal integration instead ------------------------------------ $pricing_discounted=$pricing; # Copy the pricing, which may be group specific include "../include/config.php"; # Reinclude the config so that $pricing is now the default, and we can work out group discounts $resources=do_search("!collection" . $usercollection); $n=1; $paypal=""; $totalprice=0; $totalprice_ex_discount=0; foreach ($resources as $resource) { $sizes=get_image_sizes($resource["ref"]); $title=get_data_by_field($resource["ref"],$view_title_field); foreach ($sizes as $size) { if (getval("select_" . $resource["ref"],"")==$size["id"]) { $name=$size["name"]; $id=$size["id"]; if ($id=="") {$id="hpr";} # Add to total price if (array_key_exists($id,$pricing_discounted)) {$price=$pricing_discounted[$id];} else {$price=999;} # Add to ex-discount price also if (array_key_exists($id,$pricing)) {$price_ex_discount=$pricing[$id];} else {$price_ex_discount=999;} $totalprice_ex_discount+=$price_ex_discount;
/** * Generate image sizes defined for Timmy with TimberImageHelper. * * @param int $attachment_id The attachment ID for which all images should be resized * @return void */ private function timber_generate_sizes($attachment_id) { $img_sizes = get_image_sizes(); $attachment = get_post($attachment_id); // Timber needs the file src as an url $file_src = wp_get_attachment_url($attachment_id); /** * Delete all existing image sizes for that file. * * This way, when Regenerate Thumbnails will be used, * all non-registered image sizes will be deleted as well. * Because Timber creates image sizes when they’re needed, * we can safely do this. */ Timber\ImageHelper::delete_generated_files($file_src); foreach ($img_sizes as $key => $img_size) { if (!$this->timber_should_resize($attachment->post_parent, $img_size)) { continue; } $resize = $img_size['resize']; // Get values for the default image $crop = isset($resize[2]) ? $resize[2] : 'default'; $force = isset($resize[3]) ? $resize[3] : false; image_downsize($attachment_id, $key); if (isset($img_size['generate_srcset_sizes']) && false === $img_size['generate_srcset_sizes']) { continue; } // Generate additional image sizes used for srcset if (isset($img_size['srcset'])) { foreach ($img_size['srcset'] as $src) { // Get width and height for the additional src if (is_array($src)) { $width = $src[0]; $height = isset($src[1]) ? $src[1] : 0; } else { $width = (int) round($resize[0] * $src); $height = isset($resize[1]) ? (int) round($resize[1] * $src) : 0; } // For the new source, we use the same $crop and $force values as the default image self::resize($img_size, $file_src, $width, $height, $crop, $force); } } } }
<table cellpadding="0" cellspacing="0"> <tr <?php hook("downloadtableheaderattributes"); ?> > <?php $table_headers_drawn = false; $nodownloads = false; $counter = 0; $fulldownload = false; $showprice = $userrequestmode == 2 || $userrequestmode == 3; hook("additionalresourcetools"); if ($resource["has_image"] == 1 && $download_multisize) { # Restricted access? Show the request link. # List all sizes and allow the user to download them $sizes = get_image_sizes($ref, false, $resource["file_extension"]); for ($n = 0; $n < count($sizes); $n++) { # 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; } $counter++; # Should we allow this download? # If the download is allowed, show a download button, otherwise show a request button. $downloadthissize = resource_download_allowed($ref, $sizes[$n]["id"], $resource["resource_type"]); $headline = $sizes[$n]['id'] == '' ? str_replace_formatted_placeholder("%extension", $resource["file_extension"], $lang["originalfileoftype"]) : $sizes[$n]["name"]; $newHeadline = hook('replacesizelabel', '', array($ref, $resource, $sizes[$n])); if (!empty($newHeadline)) { $headline = $newHeadline;
function delete_resource($ref) { # Delete the resource, all related entries in tables and all files on disk if ($ref<0) {return false;} # Can't delete the template $resource=get_resource_data($ref); if (!$resource) {return false;} # Resource not found in database $current_state=$resource['archive']; global $resource_deletion_state; if (isset($resource_deletion_state) && $current_state!=3) # Really delete if already in the 'deleted' state. { # $resource_deletion_state is set. Do not delete this resource, instead move it to the specified state. sql_query("update resource set archive='" . $resource_deletion_state . "' where ref='" . $ref . "'"); # log this so that administrator can tell who requested deletion resource_log($ref,'x',''); # Remove the resource from any collections sql_query("delete from collection_resource where resource='$ref'"); return true; } # Get info # Is transcoding if ($resource['is_transcoding']==1) {return false;} # Can't delete when transcoding # Delete files first $extensions = array(); $extensions[]=$resource['file_extension']?$resource['file_extension']:"jpg"; $extensions[]=$resource['preview_extension']?$resource['preview_extension']:"jpg"; $extensions[]=$GLOBALS['ffmpeg_preview_extension']; $extensions[]='icc'; // also remove any extracted icc profiles $extensions=array_unique($extensions); foreach ($extensions as $extension) { $sizes=get_image_sizes($ref,true,$extension); foreach ($sizes as $size) { if (file_exists($size['path'])) {unlink($size['path']);} } } # Delete any alternative files $alternatives=get_alternative_files($ref); for ($n=0;$n<count($alternatives);$n++) { delete_alternative_file($ref,$alternatives[$n]['ref']); } // remove metadump file, and attempt to remove directory $dirpath = dirname(get_resource_path($ref, true, "", true)); if (file_exists("$dirpath/metadump.xml")){ unlink("$dirpath/metadump.xml"); } @rmdir($dirpath); // try to delete directory, but if it has stuff in it fail silently for now // fixme - should we try to handle if there are other random files still there? # Log the deletion of this resource for any collection it was in. $in_collections=sql_query("select * from collection_resource where resource = '$ref'"); if (count($in_collections)>0){ if (!function_exists("collection_log")){include ("collections_functions.php");} for($n=0;$n<count($in_collections);$n++) { collection_log($in_collections[$n]['collection'],'d',$in_collections[$n]['resource']); } } hook("beforedeleteresourcefromdb"); # Delete all database entries sql_query("delete from resource where ref='$ref'"); sql_query("delete from resource_data where resource='$ref'"); sql_query("delete from resource_dimensions where resource='$ref'"); sql_query("delete from resource_keyword where resource='$ref'"); sql_query("delete from resource_related where resource='$ref' or related='$ref'"); sql_query("delete from collection_resource where resource='$ref'"); sql_query("delete from resource_custom_access where resource='$ref'"); sql_query("delete from external_access_keys where resource='$ref'"); sql_query("delete from resource_alt_files where resource='$ref'"); hook("afterdeleteresource"); return true; }
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; }
/** * Get size information for a specific image size. * * @uses get_image_sizes() * @param string $size The image size for which to retrieve data. * @return bool|array $size Size data about an image size or false if the size doesn't exist. */ function get_image_size($size) { $sizes = get_image_sizes(); if (isset($sizes[$size])) { return $sizes[$size]; } return false; }
$output = ''; foreach (get_intermediate_image_sizes() as $_size) { if (in_array($_size, array('thumbnail', 'medium', 'medium_large', 'large'))) { $sizes[$_size]['width'] = get_option("{$_size}_size_w"); $sizes[$_size]['height'] = get_option("{$_size}_size_h"); $sizes[$_size]['crop'] = (bool) get_option("{$_size}_crop"); } elseif (isset($_wp_additional_image_sizes[$_size])) { $sizes[$_size] = array('width' => $_wp_additional_image_sizes[$_size]['width'], 'height' => $_wp_additional_image_sizes[$_size]['height'], 'crop' => $_wp_additional_image_sizes[$_size]['crop']); } } foreach ($sizes as $image_size => $image_size_data) { $crop = ''; if (is_array($image_size_data['crop'])) { $crop = 'true ' . $image_size_data['crop'][0] . '-' . $image_size_data['crop'][0]; } else { $crop = $image_size_data['crop'] ? 'true auto' : 'false'; } $output .= '<tr><td>' . $image_size . '</td><td> ' . $image_size_data['width'] . 'x' . $image_size_data['height'] . '</td><td>Croop: ' . $crop . '</td></tr> '; } return '<table>' . $output . '</table>'; } // Check favicon existence. $ico_path = get_stylesheet_directory() . '/favicon.ico'; $favicon = false !== get_transient('site_favicon') ? get_transient('site_favicon') : '<span class="wp-ui-text-notification dashicons dashicons-warning"></span> No data'; $favicon_status = wps_file_exist($ico_path) ? '<span class="dashicons dashicons-yes wp-ui-text-highlight"></span>' : '<span class="wp-ui-text-notification dashicons dashicons-warning"></span> Missing'; echo get_development_data(); echo '<br/>'; echo 'Favicon in theme root: ' . $favicon_status . ' | transient: ' . $favicon; echo '<br/>'; echo 'Available image sizes: ' . get_image_sizes();
/** * Back-end widget form. * * @see WP_Widget::form() * * @param array $instance Previously saved values from database. */ public function form($instance) { $sort = !empty($instance['sort']) ? esc_attr($instance['sort']) : ''; $image = !empty($instance['image']) ? esc_attr($instance['image']) : ''; $title = !empty($instance['title']) ? esc_attr($instance['title']) : ''; $alt = !empty($instance['alt']) ? esc_attr($instance['alt']) : ''; $url = !empty($instance['url']) ? esc_attr($instance['url']) : ''; $button = !empty($instance['button']) ? esc_attr($instance['button']) : ''; $size = !empty($instance['size']) ? esc_attr($instance['size']) : ''; // Make the order array. if (!empty($sort)) { $fields = explode(',', $sort); } else { $fields = array('no-order'); } // Hide the image. if ($image != '') { $imageoptions = 'style="display:block;"'; } else { $imageoptions = 'style="display:none;"'; } ?> <p id="<?php echo $this->id . '-title'; ?> "> <label for="<?php echo $this->get_field_id('title'); ?> "><?php _e('Title', 'image-widget'); ?> : <input class="widefat" id="<?php echo $this->get_field_id('title'); ?> " name="<?php echo $this->get_field_name('title'); ?> " type="text" value="<?php echo esc_attr($title); ?> "> <small><?php _e('Give the widget a title (If you need one)', 'image-widget'); ?> .</small> </label> </p> <div class="widget-image-sortable"> <?php foreach ($fields as $field) { ?> <?php if ($field == $this->id . '-image' || $field === 'no-order') { ?> <p id="<?php echo $this->id . '-image'; ?> "> <label for="select-image"><?php _e('Select image', 'image-widget'); ?> : <button class="widefat button widget-control-save widget-image-select" name="select-image"><?php _e('Select image', 'image-widget'); ?> </button> <input class="widefat" id="<?php echo $this->get_field_id('image'); ?> " name="<?php echo $this->get_field_name('image'); ?> " type="hidden" value="<?php echo esc_attr($image); ?> "> <?php $src = wp_get_attachment_image_src($attachment_id, $size, $icon); if (!empty($image)) { echo '<img class="imagePreview" src="' . esc_attr($image) . '">'; } else { echo '<img ' . $imageoptions . ' class="imagePreview" src="data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs%3D">'; } ?> </label> <a href="#" class="imageRemove"><?php _e('Remove Image', 'image-widget'); ?> </a> </p> <?php } ?> <?php if ($field == $this->id . '-button' || $field === 'no-order') { ?> <p id="<?php echo $this->id . '-button'; ?> "> <label for="<?php echo $this->get_field_id('button'); ?> "><?php _e('Button', 'image-widget'); ?> : <input class="widefat" id="<?php echo $this->get_field_id('button'); ?> " name="<?php echo $this->get_field_name('button'); ?> " type="text" value="<?php echo esc_attr($button); ?> "> <small><?php _e('Add a text that will be displayed in the button', 'image-widget'); ?> .</small> </label> </p> <?php } ?> <?php } ?> </div> <input class="widefat image-widget-sort-order" id="<?php echo $this->get_field_id('sort'); ?> " name="<?php echo $this->get_field_name('sort'); ?> " type="text" value="<?php echo esc_attr($sort); ?> "> <p> <label for="<?php echo $this->get_field_id('url'); ?> "><?php _e('Link', 'image-widget'); ?> : <input class="widefat" id="<?php echo $this->get_field_id('url'); ?> " name="<?php echo $this->get_field_name('url'); ?> " type="text" value="<?php echo esc_attr($url); ?> "> <small><?php _e('Add an url that the widget should refer to (Button and Image)', 'image-widget'); ?> .</small> </label> </p> <div class="non-sortable" <?php echo $imageoptions; ?> > <h4><?php _e('Widget Options', 'image-widget'); ?> </h4> <label for="<?php echo $this->get_field_id('alt'); ?> "><?php _e('Alternate Text', 'image-widget'); ?> : <input class="widefat" id="<?php echo $this->get_field_id('alt'); ?> " name="<?php echo $this->get_field_name('alt'); ?> " type="text" value="<?php echo esc_attr($alt); ?> "> <small><?php _e('Give the image a alt tag', 'image-widget'); ?> .</small> </label> <label for="<?php echo $this->get_field_id('size'); ?> "><?php _e('Image size', 'image-widget'); ?> : <select class='widefat' id="<?php echo $this->get_field_id('size'); ?> " name="<?php echo $this->get_field_name('size'); ?> "> <?php $img_sizes = get_image_sizes(); foreach ($img_sizes as $img_size => $image) { ?> <option value="<?php echo $img_size; ?> " <?php selected($size, $img_size, true); ?> ><?php echo $img_size; ?> </option> <?php } ?> </select> <small><?php _e('Select an image size', 'image-widget'); ?> .</small> </label> </div> <style> .widget-image-sortable p { background: #e9e9e9; position: relative; padding: 15px; border: 1px solid #ccc; } .widget-image-sortable .imageRemove { font-size: .75em; } .widget-image-sortable .imagePreview { display: block; border: 1px solid #BBBBBB; max-width: 100%; height: auto; margin-top: 15px; } .widget-image-sortable button.widget-image-select { padding-top: 20px; padding-bottom: 20px; line-height: 0; } .widget-image-sortable label, .non-sortable label { display: block; margin-bottom: 15px; } .non-sortable h4 { font-size: 16px; margin: 10px 0; } .widget-image-sortable label:last-child { margin-bottom: 0; } .widget-image-sortable .ui-sortable-helper { background: #fff; } .widget-image-sortable .non-sortable { background: #b1b1b1; padding: 15px; } </style> <?php }
$query = new WP_Query($loop_args); if (!empty($posts_clauses) && function_exists('posts_clauses')) { remove_filter('posts_clauses', $posts_clauses); } if ($carousel) { wp_enqueue_script('owl.carousel'); wp_enqueue_style('owl.carousel'); } if ($query->have_posts()) { $options = get_option(AZEXO_THEME_NAME); if ($only_content) { $size = array('width' => '', 'height' => ''); } else { $thumbnail_size = isset($options[$template . '_thumbnail_size']) && !empty($options[$template . '_thumbnail_size']) ? $options[$template . '_thumbnail_size'] : 'large'; azexo_add_image_size($thumbnail_size); $size = get_image_sizes($thumbnail_size); } print '<div class="posts-list-wrapper">'; if (!empty($title)) { print '<div class="list-title"><h3>' . $title . '</h3></div>'; } print '<div class="posts-list ' . ($only_content ? '' : str_replace('_', '-', $template)) . ' ' . ($carousel ? 'owl-carousel' : '') . ' ' . ($posts_per_item == 1 ? 'item-as-post' : '') . esc_attr($css_class) . '" data-width="' . $size['width'] . '" data-height="' . $size['height'] . '" data-margin="' . $item_margin . '">'; $number = 0; global $post; $original = $post; while ($query->have_posts()) { $query->the_post(); if ($carousel && $number == 0) { print '<div class="item">'; } if ($only_content) {
/** * Get srcset and sizes for a TimberImage. * * @param Timber\Image|int $timber_image Instance of TimberImage or Attachment ID * @param string $size Size key of the image to return * @return string Image srcset and sizes attributes */ function get_timber_image_responsive_src($timber_image, $size) { $timber_image = Timmy::get_timber_image($timber_image); // Directly return source when we have an SVG or GIF image. if (in_array($timber_image->post_mime_type, ['image/svg+xml', 'image/gif'], true)) { return ' src="' . $timber_image->src . '"'; } if (!$timber_image) { return false; } $img_sizes = get_image_sizes(); $resize = $img_sizes[$size]['resize']; list($file_src, $width, $height, $crop, $force, $max_width, $max_height, $oversize, ) = Timmy::get_image_params($timber_image, $img_sizes[$size]); $srcset = array(); // Get proper width_key to handle width values of 0 $width_key = Timmy::get_width_key($width, $height, $timber_image); // Add the image source with the width as the key so they can be sorted later. $srcset[$width_key] = Timmy::resize($img_sizes[$size], $file_src, $width, $height, $crop, $force) . ' ' . $width_key . 'w'; // Add additional image sizes to srcset. if (isset($img_sizes[$size]['srcset'])) { foreach ($img_sizes[$size]['srcset'] as $src) { // Get width and height for the additional src if (is_array($src)) { $width = $src[0]; $height = isset($src[1]) ? $src[1] : 0; } else { $width = (int) round($resize[0] * $src); $height = isset($resize[1]) ? (int) round($resize[1] * $src) : 0; } // Bail out if the current size’s width is bigger than available width if (!$oversize['allow'] && ($width > $max_width || 0 === $width && $height > $max_height)) { continue; } $width_key = Timmy::get_width_key($width, $height, $timber_image); // For the new source, we use the same $crop and $force values as the default image $srcset[$width_key] = Timmy::resize($img_sizes[$size], $file_src, $width, $height, $crop, $force) . ' ' . $width_key . 'w'; } } // Sort entries from smallest to highest ksort($srcset); // Build sizes attribute string $attr_str = ''; /** * Check for 'sizes' option in image configuration. * Before v0.10.0, this was just `sizes'. * * @since 0.10.0 */ if (isset($img_sizes[$size]['sizes'])) { $attr_str = ' sizes="' . $img_sizes[$size]['sizes'] . '"'; /** * For backwards compatibility * @deprecated since 0.10.0 */ } else { if (isset($img_sizes[$size]['size'])) { $attr_str = ' sizes="' . $img_sizes[$size]['size'] . '"'; } } /** * Set max-width|max-height in px to prevent the image to be displayed bigger than it is * * @since 0.10.0 */ if (!$oversize['allow'] && $oversize['style_attr']) { if ('width' === $oversize['style_attr']) { $attr_str = ' style="width:' . $max_width . 'px;"'; } else { if ('height' === $oversize['style_attr']) { $attr_str = ' style="height:' . $max_height . 'px;"'; } } } // Return the HTML attribute string return ' srcset="' . implode(', ', $srcset) . '"' . $attr_str; }
set_time_limit(60 * 60 * 1); ini_set("track_errors", "on"); #error_reporting(0); # This script moves any non-scrambled resources over to the scrambled URL. exit("You must manually enable this script."); # prevent accidental use! ?> <html> <body> <?php $resources = sql_query("select ref,file_extension from resource order by ref desc"); for ($n = 0; $n < count($resources); $n++) { $ref = $resources[$n]["ref"]; $extension = $resources[$n]["file_extension"]; if ($extension == "") { $extension = "jpg"; } $sizes = get_image_sizes($ref, true, $extension, false); for ($m = 0; $m < count($sizes); $m++) { $path = get_resource_path($ref, true, $sizes[$m]["id"], false, $extension, false); if (file_exists($path)) { $newpath = get_resource_path($ref, true, $sizes[$m]["id"], true, $extension, true); echo "<li>{$ref} - old path={$path}, new path={$newpath}"; rename($path, $newpath); } } } ?> </body> </html>