示例#1
1
/**
 * Override theme_file_entity_download_link().
 */
function europa_file_entity_download_link($variables)
{
    $file = $variables['file'];
    // Submit the language along witht the file.
    $langcode = $GLOBALS['language_content']->language;
    if (!empty($langcode)) {
        $file->language = $langcode;
    }
    $uri = file_entity_download_uri($file);
    return _europa_file_markup($file, $uri);
}
<?php

if (isset($_GET['test-files'])) {
    print_r(get_defined_vars());
    exit;
}
$extension = pathinfo($filename, PATHINFO_EXTENSION);
$hfilesize = atento_get_human_size($filesize);
$view = file_create_url($uri);
$file = $elements['#file'];
$uri_download = file_entity_download_uri($file);
$download = url($uri_download['path'], $uri_download['options']);
$file_thumbnail = '&nbsp;';
if ($type == 'image') {
    $vars = array('style_name' => 'file_preview', 'path' => $uri, 'width' => $width, 'height' => $height);
    $file_thumbnail = theme_image_style($vars);
    $vars2 = $vars;
    $vars2['style_name'] = 'full';
    $dimensions = array('width' => $vars2['width'], 'height' => $vars2['height']);
    image_style_transform_dimensions($vars2['style_name'], $dimensions);
    $vars2['width'] = $dimensions['width'];
    $vars2['height'] = $dimensions['height'];
    $vars2['path'] = image_style_url($vars2['style_name'], $vars2['path']);
    $view = $vars2['path'];
    $data_size = "{$vars2['width']}x{$vars2['height']}";
} else {
    // Get Image for Extension
    $file_thumbnail = atento_get_extension_image($extension);
}
$filename_print = check_plain($filename);
if (isset($file->description) && !empty($file->description)) {
 /**
  * Overrides LinkitSearchPluginEntity::createPath().
  *
  * If 'Direct download' is enabled, make the link point to the file entity
  * download endpoint.
  */
 function createPath($entity)
 {
     $url_type = isset($this->conf['url_type']) ? $this->conf['url_type'] : $this->getDefaultUrlType();
     // We can only support the download type if we have version 2.x of the file_entity module.
     if ($url_type == LINKIT_FILE_URL_TYPE_DOWNLOAD && !(module_exists('file_entity') && function_exists('file_entity_download_uri'))) {
         $url_type = $this->getDefaultUrlType();
     }
     switch ($url_type) {
         case LINKIT_FILE_URL_TYPE_DIRECT:
             // Check if this is a local file.
             $wrapper = file_stream_wrapper_get_instance_by_uri($entity->uri);
             if ($wrapper instanceof DrupalLocalStreamWrapper) {
                 // Create a relative URL to the local file.
                 // See https://www.drupal.org/node/837794.
                 $path = $wrapper->getDirectoryPath() . '/' . file_uri_target($entity->uri);
             } else {
                 $path = file_create_url($entity->uri);
             }
             // Process the uri with the insert plugin.
             return linkit_get_insert_plugin_processed_path($this->profile, $path, array('language' => (object) array('language' => FALSE)));
         case LINKIT_FILE_URL_TYPE_DOWNLOAD:
             $uri = file_entity_download_uri($entity);
             // Hack for LINKIT_URL_METHOD_RAW, which won't include the options that
             // we pass to linkit_get_insert_plugin_processed_path().
             if (isset($uri['options']['query']['token']) && $this->profile->data['insert_plugin']['url_method'] == LINKIT_URL_METHOD_RAW) {
                 return $uri['path'] . '?token=' . rawurlencode($uri['options']['query']['token']);
             }
             // Process the uri with the insert plugin.
             return linkit_get_insert_plugin_processed_path($this->profile, $uri['path'], $uri['options']);
         case LINKIT_FILE_URL_TYPE_ENTITY:
             // Pass back to the parent if the user wants entity urls.
             return parent::createPath($entity);
     }
 }