/[drupal]/contributions/modules/file_aliases/file_aliases.module
ViewVC logotype

Diff of /contributions/modules/file_aliases/file_aliases.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.1.2.1, Tue Mar 31 23:16:37 2009 UTC revision 1.1.2.2, Wed Apr 1 01:06:05 2009 UTC
# Line 1  Line 1 
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().
# Line 81  function file_aliases_nodeapi(&$node, $o Line 81  function file_aliases_nodeapi(&$node, $o
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            }            }
# Line 104  function file_aliases_load_fid($fid) { Line 108  function file_aliases_load_fid($fid) {
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  }  }

Legend:
Removed from v.1.1.2.1  
changed lines
  Added in v.1.1.2.2

  ViewVC Help
Powered by ViewVC 1.1.2