/[drupal]/contributions/modules/mimedetect/mimedetect.admin.inc
ViewVC logotype

Contents of /contributions/modules/mimedetect/mimedetect.admin.inc

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


Revision 1.3 - (show annotations) (download) (as text)
Wed Apr 15 20:28:25 2009 UTC (7 months, 2 weeks ago) by drewish
Branch: MAIN
CVS Tags: HEAD
Changes since 1.2: +1 -1 lines
File MIME type: text/x-php
First step in updating for Drupal 7.x.
1 <?php
2
3 function mimedetect_settings() {
4 // Check if fileinfo is available so we don't present the file options if
5 // they can't use them
6 if (extension_loaded('fileinfo')) {
7 $form['file'] = array(
8 '#markup' => t("The MimeDetect module is using PHP's fileinfo extension to detect MIME types. There are no settings for the extension.")
9 );
10 }
11 else {
12 $form['file'] = array(
13 '#type' => 'fieldset',
14 '#title' => t("UNIX 'file' command"),
15 );
16 $form['file']['mimedetect_enable_file_binary'] = array(
17 '#type' => 'checkbox',
18 '#title' => t("Use UNIX 'file' command to detect mime type?"),
19 '#description' => t("The UNIX 'file' command will be used for mime detection only if the PHP Fileinfo extension is not installed or fails to load."),
20 '#default_value' => variable_get('mimedetect_enable_file_binary', FALSE),
21 );
22 $form['file']['mimedetect_file_binary'] = array(
23 '#type' => 'textfield',
24 '#title' => t("Path to the 'file' command"),
25 '#description' => t("The path to the executable 'file' binary."),
26 '#default_value' => variable_get('mimedetect_file_binary','/usr/bin/file'),
27 );
28 $form = system_settings_form($form);
29 }
30 return $form;
31 }
32
33 function mimedetect_settings_validate($form_id, &$form_state) {
34 // Test file binary settings.
35 if ($form_state['values']['mimedetect_enable_file_binary']) {
36 if (empty($form_state['values']['mimedetect_file_binary'])) {
37 form_set_error('mimedetect_file_binary', t("You must specify the path to the 'file' binary if it is enabled."));
38 }
39 if (!is_executable($form_state['values']['mimedetect_file_binary'])) {
40 if (!file_exists($form_state['values']['mimedetect_file_binary'])) {
41 form_set_error('mimedetect_file_binary', t("The path %path does not exist or is not readable by your webserver.", array('%path' => $form_state['values']['mimedetect_file_binary'])));
42 }
43 else {
44 form_set_error('mimedetect_file_binary', t("%path is not executable by your webserver.", array('%path' => $form_state['values']['mimedetect_file_binary'])));
45 }
46 }
47 }
48 }

  ViewVC Help
Powered by ViewVC 1.1.2