You are here

function img_assist_admin_settings in Image Assist 5

Same name and namespace in other branches
  1. 5.3 img_assist.module \img_assist_admin_settings()
  2. 5.2 img_assist.module \img_assist_admin_settings()
  3. 6.2 img_assist.module \img_assist_admin_settings()
  4. 6 img_assist.module \img_assist_admin_settings()

Implementation of hook_settings().

1 string reference to 'img_assist_admin_settings'
img_assist_menu in ./img_assist.module
Implementation of hook_menu().

File

./img_assist.module, line 176
Image Assist module

Code

function img_assist_admin_settings() {

  // Access settings.
  $form['access'] = array(
    '#type' => 'fieldset',
    '#title' => t('Access settings'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );
  $form['access']['img_assist_paths_type'] = array(
    '#type' => 'radios',
    '#title' => t('Display Image assist on paths'),
    '#default_value' => variable_get('img_assist_paths_type', 2),
    '#options' => array(
      t('on specific paths'),
      t('not on specific paths'),
      t('all paths'),
    ),
  );
  $form['access']['img_assist_paths'] = array(
    '#type' => 'textarea',
    '#title' => t('Paths'),
    '#default_value' => variable_get('img_assist_paths', "node/*\ncomment/*"),
    '#cols' => 40,
    '#rows' => 5,
    '#description' => t("Enter one page per line as Drupal paths. The '*' character is a wildcard. Example paths are %blog for the blog page and %blog-wildcard for every personal blog. %front is the front page.", array(
      '%blog' => 'blog',
      '%blog-wildcard' => 'blog/*',
      '%front' => '<front>',
    )),
  );
  $form['access']['img_assist_textareas_type'] = array(
    '#type' => 'radios',
    '#title' => t('Display Image assist on text areas'),
    '#default_value' => variable_get('img_assist_textareas_type', 2),
    '#options' => array(
      t('Show on every textarea except the listed textareas.'),
      t('Show on only the listed textareas.'),
      t('Show on all textareas.'),
    ),
  );
  $form['access']['img_assist_textareas'] = array(
    '#type' => 'textarea',
    '#title' => t('Text areas'),
    '#default_value' => variable_get('img_assist_textareas', "edit-body\nedit-comment"),
    '#cols' => 40,
    '#rows' => 5,
    '#description' => t("Enter one text area form-id per line. Form-id's are used by Drupal to typify them, which allows themers and coders to modify certain form fields, but not all. Find form-id's using this method: view the source of the webpage, then search for the string that's just above the text area and you'll see the form-id nearby. The '*' character is a wildcard. For example, you can specify all CCK fields as %cck-example.", array(
      '%cck-example' => 'edit-field-*',
    )),
  );
  $form['access']['img_assist_link'] = array(
    '#type' => 'select',
    '#title' => t('Textarea image link'),
    '#default_value' => variable_get('img_assist_link', 1),
    '#options' => array(
      'icon' => t('Show icon'),
      'text' => t('Show text link'),
      'none' => t('Do not show a link'),
    ),
    '#description' => t('Choose what to show under the textareas for which Image assist is enabled.'),
  );
  if (module_exists('taxonomy')) {
    $vocs = array(
      0 => '<' . t('none') . '>',
    );
    foreach (taxonomy_get_vocabularies() as $vid => $voc) {
      $vocs[$vid] = $voc->name;
    }
    if (count($vocs) > 1) {
      $form['access']['img_assist_vocabs'] = array(
        '#type' => 'select',
        '#multiple' => TRUE,
        '#title' => t('Select the vocabularies to use for Image assist'),
        '#default_value' => variable_get('img_assist_vocabs', array()),
        '#options' => $vocs,
        '#description' => t('Select the vocabularies you want to be able to filter thumbnails by. This setting changes the behavior of Image assist at startup from loading all image thumbnails to displaying a list of image names until a filter is chosen.'),
      );
    }
  }

  // Image settings.
  $form['image'] = array(
    '#type' => 'fieldset',
    '#title' => t('Image settings'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );
  $form['image']['img_assist_preview_count'] = array(
    '#type' => 'textfield',
    '#title' => t('Maximum number of thumbnails per page'),
    '#default_value' => variable_get('img_assist_preview_count', 8),
    '#size' => 6,
    '#maxlength' => 6,
    '#description' => t('Enter the number of images to display in the thumbnail browser. If there are more images, next and previous links will be displayed.'),
  );
  $form['image']['img_assist_max_size'] = array(
    '#type' => 'textfield',
    '#title' => t('Maximum inline image size allowed'),
    '#default_value' => variable_get('img_assist_max_size', '640x640'),
    '#size' => 9,
    '#maxlength' => 9,
    '#description' => t('Enter the number of maximum image dimensions to display with Image assist. This is a way to prevent users from breaking your layouts. This is applied when the filter tag is processed, so it will affect existing images. If an existing image exceeds these dimensions, a smaller derivative of the image will be substituted (or a smaller version will be created if you have allowed Image assist to create its own derivatives).'),
  );
  if (function_exists('image_get_sizes')) {
    $max_size = explode('x', variable_get('img_assist_max_size', '640x640'));
    $oversize_count = 0;
    foreach (image_get_sizes() as $key => $size) {
      $dimensions = $size['width'] . 'x' . $size['height'];
      if (!empty($size['width']) && $size['width'] <= $max_size[0] || !empty($size['height']) && $size['height'] <= $max_size[1]) {
        $derivatives[$dimensions] = $size['label'];
      }
      elseif ($key == IMAGE_THUMBNAIL) {

        // Thumbnail option is shown even if it is larger than maximum size.
        $derivatives[$dimensions] = $size['label'];
      }
      else {
        $oversize_count++;
      }
      $allsizes[$key] = $size['label'];
    }
    $form['image']['img_assist_popup_label'] = array(
      '#type' => 'select',
      '#title' => t('Popup size'),
      '#default_value' => variable_get('img_assist_popup_label', IMAGE_PREVIEW),
      '#options' => $allsizes,
      '#description' => t('Select the size of the image that is popped up.'),
    );
    $oversize_alert = $oversize_count ? '<br /><strong>' . format_plural($oversize_count, '1 image size is not being shown because it exceeds the the maximum inline image size setting (see above).', '@count image sizes are not being shown because they exceed the the maximum inline image size setting (see above).') . '</strong>' : '';
    $form['image']['img_assist_default_label'] = array(
      '#type' => 'select',
      '#title' => t('Default size for inline images'),
      '#default_value' => variable_get('img_assist_default_label', '100x100'),
      '#options' => $derivatives,
      '#description' => t('Select a derivative to be used by default for inline images.') . $oversize_alert,
    );
  }
  $form['image']['img_assist_create_derivatives'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Creation of image derivatives'),
    '#default_value' => variable_get('img_assist_create_derivatives', array(
      'properties',
      'custom_all',
      'custom_advanced',
    )),
    '#options' => array(
      'properties' => t('Create 200x200 images for the image properties window (useful if the thumbnail size is small).'),
      'custom_advanced' => t('Allow users with %access permission to create custom size inline images.', array(
        '%access' => 'access advanced options',
      )),
      'custom_all' => t('Allow all users to create custom size inline images.'),
    ),
    '#description' => t('These options allow Image assist to generate its custom image sizes (in the same manner as image.module) when a user would prefer a different size from the default image sizes defined in the image.module settings.'),
  );

  // Other properties.
  $form['properties'] = array(
    '#type' => 'fieldset',
    '#title' => t('Other Properties'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );
  $form['properties']['img_assist_default_link_behavior'] = array(
    '#type' => 'select',
    '#title' => t('Default link behavior'),
    '#default_value' => variable_get('img_assist_default_link_behavior', 'none'),
    '#options' => array(
      'none' => t('Not a link'),
      'node' => t('Link to image page'),
      'popup' => t('Open in popup window'),
      'url' => t('Go to URL'),
    ),
    '#description' => t('The link behavior can be overridden when inserting images by users with the proper permissions, but these defaults will still be used for everyone else.'),
  );
  $form['properties']['img_assist_default_link_url'] = array(
    '#type' => 'textfield',
    '#title' => t('Default URL'),
    '#default_value' => variable_get('img_assist_default_link_url', 'http://'),
    '#size' => 30,
    '#maxlength' => 255,
    '#description' => t('The default URL is used when Go to URL is choosen as the link behavior.'),
  );
  $form['properties']['img_assist_default_insert_mode'] = array(
    '#type' => 'select',
    '#title' => t('Default insert mode'),
    '#default_value' => variable_get('img_assist_default_insert_mode', 'none'),
    '#options' => array(
      'filtertag' => t('Filter Tag'),
      'html' => t('HTML Code'),
    ),
    '#description' => t('The insert behavior can be overridden by users with the %permission permission when inserting images.  <strong>Warning:</strong> If images are inserted as HTML, Image Assist is not able to correct a link or image URL afterwards.  Please also note that users will not be able to edit already inserted images when using HTML code and the TinyMCE plugin.', array(
      '%permission' => t('access advanced options'),
    )),
  );
  $form['properties']['img_assist_load_title'] = array(
    '#type' => 'radios',
    '#title' => t('Preload image title'),
    '#default_value' => variable_get('img_assist_load_title', 1),
    '#options' => array(
      t('Disabled'),
      t('Enabled'),
    ),
    '#description' => t('If enabled, the title from the image will be loaded as the bolded caption by default.'),
  );
  $form['properties']['img_assist_load_description'] = array(
    '#type' => 'radios',
    '#title' => t('Preload image description'),
    '#default_value' => variable_get('img_assist_load_description', 1),
    '#options' => array(
      t('Disabled'),
      t('Enabled'),
    ),
    '#description' => t('If enabled, the body text from the image will be loaded as the caption by default.'),
  );

  // Image display settings.
  $form['display'] = array(
    '#type' => 'fieldset',
    '#title' => t('Display settings'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );
  $form['display']['img_assist_page_styling'] = array(
    '#type' => 'select',
    '#title' => t('Include img_assist.css on all pages for styling inline images?'),
    '#default_value' => variable_get('img_assist_page_styling', 'yes'),
    '#options' => array(
      'yes' => t('yes'),
      'no' => t('no'),
    ),
    '#description' => t('Advanced users can customize their theme\'s CSS file so that inclusion of the img_assist.css file will not be necessary. See notes at the bottom of img_assist.css for details.'),
  );
  return system_settings_form($form);
}