Projet

Général

Profil

Paste
Télécharger (3,83 ko) Statistiques
| Branche: | Révision:

root / drupal7 / modules / file / file.install @ f581c0a8

1
<?php
2

    
3
/**
4
 * @file
5
 * Install, update and uninstall functions for File module.
6
 */
7

    
8
/**
9
 * Implements hook_field_schema().
10
 */
11
function file_field_schema($field) {
12
  return array(
13
    'columns' => array(
14
      'fid' => array(
15
        'description' => 'The {file_managed}.fid being referenced in this field.',
16
        'type' => 'int',
17
        'not null' => FALSE,
18
        'unsigned' => TRUE,
19
      ),
20
      'display' => array(
21
        'description' => 'Flag to control whether this file should be displayed when viewing content.',
22
        'type' => 'int',
23
        'size' => 'tiny',
24
        'unsigned' => TRUE,
25
        'not null' => TRUE,
26
        'default' => 1,
27
      ),
28
      'description' => array(
29
        'description' => 'A description of the file.',
30
        'type' => 'text',
31
        'not null' => FALSE,
32
      ),
33
    ),
34
    'indexes' => array(
35
      'fid' => array('fid'),
36
    ),
37
    'foreign keys' => array(
38
      'fid' => array(
39
        'table' => 'file_managed',
40
        'columns' => array('fid' => 'fid'),
41
      ),
42
    ),
43
  );
44
}
45

    
46
/**
47
 * Implements hook_requirements().
48
 *
49
 * Display information about getting upload progress bars working.
50
 */
51
function file_requirements($phase) {
52
  $requirements = array();
53

    
54
  // Check the server's ability to indicate upload progress.
55
  if ($phase == 'runtime') {
56
    $implementation = file_progress_implementation();
57
    $apache = strpos($_SERVER['SERVER_SOFTWARE'], 'Apache') !== FALSE;
58
    $fastcgi = strpos($_SERVER['SERVER_SOFTWARE'], 'mod_fastcgi') !== FALSE || strpos($_SERVER["SERVER_SOFTWARE"], 'mod_fcgi') !== FALSE;
59
    $description = NULL;
60
    if (!$apache) {
61
      $value = t('Not enabled');
62
      $description = t('Your server is not capable of displaying file upload progress. File upload progress requires an Apache server running PHP with mod_php.');
63
      $severity = REQUIREMENT_INFO;
64
    }
65
    elseif ($fastcgi) {
66
      $value = t('Not enabled');
67
      $description = t('Your server is not capable of displaying file upload progress. File upload progress requires PHP be run with mod_php and not as FastCGI.');
68
      $severity = REQUIREMENT_INFO;
69
    }
70
    elseif (!$implementation && extension_loaded('apc')) {
71
      $value = t('Not enabled');
72
      $description = t('Your server is capable of displaying file upload progress through APC, but it is not enabled. Add <code>apc.rfc1867 = 1</code> to your php.ini configuration. Alternatively, it is recommended to use <a href="http://pecl.php.net/package/uploadprogress">PECL uploadprogress</a>, which supports more than one simultaneous upload.');
73
      $severity = REQUIREMENT_INFO;
74
    }
75
    elseif (!$implementation) {
76
      $value = t('Not enabled');
77
      $description = t('Your server is capable of displaying file upload progress, but does not have the required libraries. It is recommended to install the <a href="http://pecl.php.net/package/uploadprogress">PECL uploadprogress library</a> (preferred) or to install <a href="http://us2.php.net/apc">APC</a>.');
78
      $severity = REQUIREMENT_INFO;
79
    }
80
    elseif ($implementation == 'apc') {
81
      $value = t('Enabled (<a href="http://php.net/manual/en/apc.configuration.php#ini.apc.rfc1867">APC RFC1867</a>)');
82
      $description = t('Your server is capable of displaying file upload progress using APC RFC1867. Note that only one upload at a time is supported. It is recommended to use the <a href="http://pecl.php.net/package/uploadprogress">PECL uploadprogress library</a> if possible.');
83
      $severity = REQUIREMENT_OK;
84
    }
85
    elseif ($implementation == 'uploadprogress') {
86
      $value = t('Enabled (<a href="http://pecl.php.net/package/uploadprogress">PECL uploadprogress</a>)');
87
      $severity = REQUIREMENT_OK;
88
    }
89
    $requirements['file_progress'] = array(
90
      'title' => t('Upload progress'),
91
      'value' => $value,
92
      'severity' => $severity,
93
      'description' => $description,
94
    );
95
  }
96

    
97
  return $requirements;
98
}