[ Index ]

PHP Cross Reference of Drupal 6 (gatewave)

title

Body

[close]

/sites/all/modules/image/contrib/image_import/ -> image_import.admin.inc (source)

   1  <?php
   2  // $Id: image_import.admin.inc,v 1.3.2.1 2010/08/03 17:43:00 sun Exp $
   3  
   4  /**
   5   * Form builder function for Image Import settings form.
   6   */
   7  function image_import_admin_settings() {
   8    $form['image_import_path'] = array(
   9      '#type' => 'textfield',
  10      '#title' => t('Import path'),
  11      '#default_value' => variable_get('image_import_path', file_directory_temp() . '/image'),
  12      '#description' => t("The directory to import image nodes from. Drupal will need to have write access to this directory so we can move the file.") .'<br />'
  13        . t("<strong>Note:</strong> a path begining with a <kbd>/</kbd> indicates the path is relative to the server's root, one starting without specifies a path relative to Drupal's root. I.e. <kbd>/tmp/image</kbd> would be the temp directory off the root while <kbd>tmp/image</kbd> would be inside Drupal's directory."),
  14      '#required' => TRUE,
  15    );
  16    $form = system_settings_form($form);
  17    // Apply our validation and submit handlers to the submit button.
  18    $form['buttons']['submit']['#validate'][] = 'image_import_admin_settings_submit_validate';
  19    $form['buttons']['submit']['#submit'][] = 'image_import_admin_settings_submit_submit';
  20    $form['buttons']['submit']['#submit'][] = 'system_settings_form_submit';
  21    return $form;
  22  }
  23  
  24  /**
  25   * Form validation handler for Image Import settings form.
  26   *
  27   * Checks the existence of the directory specified in $form_element.
  28   *
  29   * @see system_check_directory()
  30   */
  31  function image_import_admin_settings_submit_validate($form, &$form_state) {
  32    $import_dir = $form_state['values']['image_import_path'];
  33    file_check_directory($import_dir, 0, 'image_import_path');
  34    $image_dir = variable_get('image_file_path', file_directory_path() . '/image');
  35    if (realpath($import_dir) == realpath($image_dir)) {
  36      form_set_error('image_import_path', t("You can't import from the image module's directory. The import deletes the original files so you would just be asking for trouble."));
  37    }
  38  }
  39  
  40  /**
  41   * Form submit handler for Image Import settings form.
  42   */
  43  function image_import_admin_settings_submit_submit($form, &$form_state) {
  44    // Ensure that 'image_import_path' variable contains no trailing slash.
  45    $form_state['values']['image_import_path'] = rtrim($form_state['values']['image_import_path'], '/');
  46  
  47    drupal_set_message(t("Your settings are configured correctly, you can import images <a href='!image_import_page'>here</a>.", array('!image_import_page' => url('admin/content/image_import'))));
  48  }
  49  


Generated: Thu Mar 24 11:18:33 2011 Cross-referenced by PHPXref 0.7