| 1 |
<?php |
<?php |
| 2 |
// $Id: file_aliases.module,v 1.1 2009/03/31 22:55:28 deciphered Exp $ |
// $Id: file_aliases.module,v 1.1.2.1 2009/03/31 23:16:37 deciphered Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* Implementation of hook_menu(). |
* Implementation of hook_menu(). |
| 81 |
if (($alias = drupal_get_path_alias($filefield_paths_alias)) != $filefield_paths_alias) { |
if (($alias = drupal_get_path_alias($filefield_paths_alias)) != $filefield_paths_alias) { |
| 82 |
$file['name'] = $file['name'] == 'upload' ? 'files' : $file['name']; |
$file['name'] = $file['name'] == 'upload' ? 'files' : $file['name']; |
| 83 |
|
|
| 84 |
|
if (variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC) == FILE_DOWNLOADS_PRIVATE) { |
| 85 |
|
$file['field']['filepath'] = 'system/'. $file['field']['filepath']; |
| 86 |
|
} |
| 87 |
|
|
| 88 |
$node->content[$file['name']]['#value'] = str_replace($file['field']['filepath'], $alias, $node->content[$file['name']]['#value']); |
$node->content[$file['name']]['#value'] = str_replace($file['field']['filepath'], $alias, $node->content[$file['name']]['#value']); |
| 89 |
$node->content[$file['name']]['#value'] = str_replace($file['field']['description'], array_pop(explode('/', $alias)), $node->content[$file['name']]['#value']); |
$node->content[$file['name']]['#value'] = str_replace($file['field']['description'], array_pop(explode('/', $alias)), $node->content[$file['name']]['#value']); |
| 90 |
} |
} |
| 108 |
|
|
| 109 |
$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)); |
| 110 |
|
|
| 111 |
header('Content-Type: '. $result->filemime); |
if (variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC) == FILE_DOWNLOADS_PRIVATE) { |
| 112 |
readfile($result->filepath); |
file_download($result->filepath); |
| 113 |
|
} |
| 114 |
|
else { |
| 115 |
|
header('Content-Type: '. $result->filemime); |
| 116 |
|
readfile($result->filepath); |
| 117 |
|
} |
| 118 |
} |
} |