function file_aliases_nodeapi in File Aliases 6
Same name and namespace in other branches
- 5 file_aliases.module \file_aliases_nodeapi()
Implements hook_nodeapi().
File
- ./
file_aliases.module, line 114 - Contains core functions for the File Aliases module.
Code
function file_aliases_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
switch ($op) {
case 'view':
if (($ffp = filefield_paths_get_fields($node, $op)) == FALSE) {
break;
}
$count = array();
foreach ($ffp['#files'] as &$file) {
if ($ffp['#settings'][$file['name']]['filealias']['display'] == TRUE) {
$filefield_paths_alias = 'filefield_paths/alias/' . $file['field']['fid'];
if (($alias = drupal_get_path_alias($filefield_paths_alias)) != $filefield_paths_alias) {
// Calculate relative path.
$path = variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC) == FILE_DOWNLOADS_PUBLIC ? '' : '../../';
if (empty($path)) {
foreach (explode('/', file_directory_path()) as $dir) {
$path .= '../';
}
}
// Invoke file_aliases_hook_process().
if (function_exists($function = 'file_aliases_' . $file['module'] . '_process')) {
$function($node, $file, $path, $alias, $count);
}
}
}
}
break;
}
}