You are here

function printfriendly_admin_settings in PrintFriendly & PDF 7.3

Same name and namespace in other branches
  1. 7.5 printfriendly.admin.inc \printfriendly_admin_settings()
  2. 7 printfriendly.admin.inc \printfriendly_admin_settings()
  3. 7.2 printfriendly.admin.inc \printfriendly_admin_settings()
  4. 7.4 printfriendly.admin.inc \printfriendly_admin_settings()

Menu callback administration settings for general options.

1 string reference to 'printfriendly_admin_settings'
printfriendly_menu in ./printfriendly.module
Implements hook_menu().

File

./printfriendly.admin.inc, line 11
Administrative page callbacks for Service Links module.

Code

function printfriendly_admin_settings() {
  if (substr($_SERVER['REMOTE_ADDR'], 0, 4) == '127.' || $_SERVER['REMOTE_ADDR'] == '::1') {
    drupal_set_message(t('It appears that your site is running on a local
    server. PrintFriendly service requires a remotely-accessible web site
    to function.'), 'warning', FALSE);
  }
  $form['printfriendly_types'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Content Types'),
    '#description' => t('Configure where the printfriendly button should appear.'),
    '#options' => node_type_get_names(),
    '#default_value' => variable_get('printfriendly_types', array()),
  );
  $form['printfriendly_display'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Button display'),
    '#description' => t('Select content displays that the button should appear.'),
    '#options' => array(
      'teaser' => t('Teaser'),
      'full' => t('Full content page'),
    ),
    '#default_value' => array_filter(variable_get('printfriendly_display')),
  );

  // Add more features here
  $form['printfriendly_features'] = array(
    '#type' => 'fieldset',
    '#title' => t('Features'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );
  $icon = '';
  if (!empty(variable_get('printfriendly_page_custom_header'))) {
    $icon = 'custom_logo';
  }
  else {
    $icon = 'default_logo';
  }
  $form['printfriendly_features']['printfriendly_page_header'] = array(
    '#type' => 'select',
    '#title' => t('Page header'),
    '#options' => array(
      'default_logo' => 'My Website Icon',
      'custom_logo' => 'Upload an Image',
    ),
    '#default_value' => $icon,
  );
  $form['printfriendly_features']['printfriendly_page_custom_header'] = array(
    '#type' => 'textfield',
    '#title' => t('Enter URL'),
    '#description' => t('Put full path of the file like http://devt.drupalchamp.org/sites/default/files/drupal-logo.png'),
    '#states' => array(
      'invisible' => array(
        ':input[name="printfriendly_page_header"]' => array(
          array(
            'value' => t('default_logo'),
          ),
        ),
      ),
    ),
    '#default_value' => variable_get('printfriendly_page_custom_header', ''),
  );
  $form['printfriendly_features']['printfriendly_tagline'] = array(
    '#type' => 'textfield',
    '#title' => t('Header tagline'),
    '#default_value' => variable_get('printfriendly_tagline', ''),
    '#description' => t('Add a specific tagline to the header.'),
    '#states' => array(
      'invisible' => array(
        ':input[name="printfriendly_page_header"]' => array(
          array(
            'value' => t('default_logo'),
          ),
        ),
      ),
    ),
  );
  $form['printfriendly_features']['printfriendly_click_delete'] = array(
    '#type' => 'select',
    '#title' => t('Click-to-delete'),
    '#options' => array(
      '0' => 'Allow',
      '1' => 'Not Allow',
    ),
    '#default_value' => variable_get('printfriendly_click_delete', '0'),
  );
  $form['printfriendly_features']['printfriendly_images'] = array(
    '#type' => 'select',
    '#title' => t('Images'),
    '#options' => array(
      '0' => 'Include',
      '1' => 'Exclude',
    ),
    '#default_value' => variable_get('printfriendly_images', '0'),
  );
  $form['printfriendly_features']['printfriendly_image_style'] = array(
    '#type' => 'select',
    '#title' => t('Image style'),
    '#options' => array(
      'right' => 'Align Right',
      'left' => 'Align Left',
      'none' => 'Align None',
      'block' => 'Center/Block',
    ),
    '#default_value' => variable_get('printfriendly_image_style', 'right'),
  );
  $form['printfriendly_features']['printfriendly_email'] = array(
    '#type' => 'select',
    '#title' => t('Email'),
    '#options' => array(
      '0' => 'Allow',
      '1' => 'Not Allow',
    ),
    '#default_value' => variable_get('printfriendly_email', '0'),
  );
  $form['printfriendly_features']['printfriendly_pdf'] = array(
    '#type' => 'select',
    '#title' => t('PDF'),
    '#options' => array(
      '0' => 'Allow',
      '1' => 'Not Allow',
    ),
    '#default_value' => variable_get('printfriendly_pdf', '0'),
  );
  $form['printfriendly_features']['printfriendly_print'] = array(
    '#type' => 'select',
    '#title' => t('Print'),
    '#options' => array(
      '0' => 'Allow',
      '1' => 'Not Allow',
    ),
    '#default_value' => variable_get('printfriendly_print', '0'),
  );
  $form['printfriendly_features']['printfriendly_custom_css'] = array(
    '#type' => 'textfield',
    '#description' => t('Put full path of the file like http://devt.drupalchamp.org/sites/default/files/printfriendly.css'),
    '#title' => t('Custom css url'),
    '#default_value' => variable_get('printfriendly_custom_css', ''),
  );
  $form['printfriendly_features']['printfriendly_website_protocol'] = array(
    '#type' => 'select',
    '#title' => t('Website protocol'),
    '#options' => array(
      'http' => 'HTTP',
      'https' => 'HTTPS',
    ),
    '#default_value' => variable_get('printfriendly_website_protocol', 'http'),
  );

  /*-----------------------------------------------------------*/
  $img_path = drupal_get_path('module', 'printfriendly') . '/images';
  $results = file_scan_directory($img_path, '/^.*\\.(gif|png|jpg|GIF|PNG|JPG)$/');
  $options = array();
  foreach ($results as $image) {
    $options[$image->filename] = theme('image', array(
      'path' => $image->uri,
    ));
  }
  ksort($options);
  $form['printfriendly_image'] = array(
    '#type' => 'radios',
    '#title' => t('Choose button'),
    '#options' => $options,
    '#default_value' => variable_get('printfriendly_image', 'button-print-grnw20.png'),
  );
  $form['support-link'] = array(
    '#markup' => t('Need help or have suggestions? !support-email.', array(
      '!support-email' => l(t('Support@PrintFriendly.com'), 'mailto:support@printfriendly.com', array(
        'absolute' => TRUE,
        'query' => array(
          'subject' => 'Support for PrintFriendly Drupal module',
        ),
      )),
    )),
    '#weight' => 1000,
  );
  $form['#submit'][] = 'printfriendly_admin_settings_submit';
  return system_settings_form($form);
}