| 1 |
<?php |
<?php |
| 2 |
// $Id: file_aliases.module,v 1.1.4.1 2009/03/31 04:20:32 deciphered Exp $ |
// $Id: file_aliases.module,v 1.1 2009/03/31 22:55:28 deciphered Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* Implementation of hook_menu(). |
* Implementation of hook_menu(). |
| 71 |
if ($ffp['#settings'][$file['name']]['filealias']['display'] == TRUE) { |
if ($ffp['#settings'][$file['name']]['filealias']['display'] == TRUE) { |
| 72 |
$filefield_paths_alias = 'filefield_paths/alias/'. $file['field']['fid']; |
$filefield_paths_alias = 'filefield_paths/alias/'. $file['field']['fid']; |
| 73 |
if (($alias = drupal_get_path_alias($filefield_paths_alias)) != $filefield_paths_alias) { |
if (($alias = drupal_get_path_alias($filefield_paths_alias)) != $filefield_paths_alias) { |
| 74 |
$relative_dir = ''; |
$path = (variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC) == FILE_DOWNLOADS_PUBLIC) |
| 75 |
|
? '' |
| 76 |
|
: base_path(); |
| 77 |
|
|
| 78 |
foreach (explode('/', file_directory_path()) as $dir) { |
foreach (explode('/', file_directory_path()) as $dir) { |
| 79 |
$relative_dir .= '../'; |
$path .= '../'; |
| 80 |
} |
} |
| 81 |
|
|
| 82 |
$file['field']['filepath'] = $relative_dir . $alias; |
$file['field']['filepath'] = $path . $alias; |
| 83 |
$file['field']['filename'] = array_pop(explode('/', $alias)); |
$file['field']['filename'] = array_pop(explode('/', $alias)); |
| 84 |
} |
} |
| 85 |
} |
} |
| 97 |
|
|
| 98 |
$result = db_fetch_object(db_query("SELECT filemime, filepath FROM {files} WHERE fid = %d", $fid)); |
$result = db_fetch_object(db_query("SELECT filemime, filepath FROM {files} WHERE fid = %d", $fid)); |
| 99 |
|
|
| 100 |
header('Content-Type: '. $result->filemime); |
if (variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC) == FILE_DOWNLOADS_PRIVATE) { |
| 101 |
readfile($result->filepath); |
file_download($result->filepath); |
| 102 |
|
} |
| 103 |
|
else { |
| 104 |
|
header('Content-Type: '. $result->filemime); |
| 105 |
|
readfile($result->filepath); |
| 106 |
|
} |
| 107 |
} |
} |