You are here

function shrinktheweb_admin_settings in ShrinkTheWeb 7

Same name and namespace in other branches
  1. 6 shrinktheweb.admin.inc \shrinktheweb_admin_settings()
1 string reference to 'shrinktheweb_admin_settings'
shrinktheweb_menu in ./shrinktheweb.module
Implementation of hook_menu().

File

./shrinktheweb.admin.inc, line 114

Code

function shrinktheweb_admin_settings() {
  module_load_include('inc', 'shrinktheweb', 'shrinktheweb.api');
  $aAccountInfo = shrinktheweb_getAccountInfo();
  $response_status = $aAccountInfo['stw_response_status'];
  $inside_pages = $aAccountInfo['stw_inside_pages'];
  $custom_size = $aAccountInfo['stw_custom_size'];
  $full_length = $aAccountInfo['stw_full_length'];
  $custom_delay = $aAccountInfo['stw_custom_delay'];
  $custom_quality = $aAccountInfo['stw_custom_quality'];
  $custom_resolution = $aAccountInfo['stw_custom_resolution'];
  $custom_messages = $aAccountInfo['stw_custom_messages'];
  $form = array();
  $form['shrinktheweb_clearcache'] = array(
    '#type' => 'fieldset',
    '#title' => t('ShrinkTheWeb Clear Cache'),
    '#collapsible' => FALSE,
    '#collapsed' => FALSE,
  );
  $form['shrinktheweb_clearcache']['shrinktheweb_clear_imagecache'] = array(
    '#type' => 'checkbox',
    '#title' => t('Clear captured shots'),
    '#default_value' => FALSE,
    '#description' => t('By selecting this checkbox all cached thumbshots gets deleted'),
    '#disabled' => FALSE,
  );
  $form['shrinktheweb_clearcache']['shrinktheweb_clear_errorcache'] = array(
    '#type' => 'checkbox',
    '#title' => t('Clear Error Images'),
    '#default_value' => FALSE,
    '#description' => t('By selecting this checkbox all cached error images gets deleted'),
    '#disabled' => FALSE,
  );
  $form['shrinktheweb_info'] = array(
    '#type' => 'fieldset',
    '#title' => t('ShrinkTheWeb Information'),
    '#collapsible' => FALSE,
    '#collapsed' => FALSE,
  );
  $form['shrinktheweb_info']['shrinktheweb_get_account'] = array(
    '#type' => 'item',
    '#title' => t('Get Account'),
    '#description' => t('You can get your "Access Key" and "Secret Key" by signing up for automated screenshots at: <a target="_blank" href="http://www.shrinktheweb.com/">ShrinkTheWeb</a>'),
  );
  $form['shrinktheweb_info']['shrinktheweb_referrer_list'] = array(
    '#type' => 'item',
    '#title' => t('Referrer List'),
    '#description' => t('By default, you must add your server\'s IP address to <a href="http://www.shrinktheweb.com/content/how-do-i-lock-my-account.html" target="_blank">ShrinkTheWeb\'s "Allowed Referrers" list</a>'),
  );
  $form['shrinktheweb_keys'] = array(
    '#type' => 'fieldset',
    '#title' => t('ShrinkTheWeb API keys'),
    '#collapsible' => FALSE,
    '#collapsed' => FALSE,
  );
  $form['shrinktheweb_keys']['shrinktheweb_access_key'] = array(
    '#type' => 'textfield',
    '#title' => t('Access key'),
    '#default_value' => variable_get('shrinktheweb_access_key', ''),
    '#required' => TRUE,
  );
  $form['shrinktheweb_keys']['shrinktheweb_secret_key'] = array(
    '#type' => 'textfield',
    '#title' => t('Secret key'),
    '#default_value' => variable_get('shrinktheweb_secret_key', ''),
    '#required' => TRUE,
  );
  if (variable_get('shrinktheweb_access_key', '') == '' || variable_get('shrinktheweb_secret_key', '') == '' || $response_status != 'Success') {
    $form['shrinktheweb_keys']['shrinktheweb_status'] = array(
      '#type' => 'item',
      '#title' => t('Invalid account credentials detected'),
      '#description' => t('Please enter your account credentials and make sure they are correct'),
    );
  }
  else {
    $form['shrinktheweb_options'] = array(
      '#type' => 'fieldset',
      '#title' => t('ShrinkTheWeb Options'),
      '#collapsible' => FALSE,
      '#collapsed' => FALSE,
    );
    $form['shrinktheweb_options']['shrinktheweb_enable_https'] = array(
      '#type' => 'select',
      '#title' => t('Enable HTTP Secure (HTTPS)'),
      '#options' => array(
        0 => t('Disable'),
        1 => t('Enable'),
      ),
      '#default_value' => variable_get('shrinktheweb_enable_https', 0),
      '#required' => TRUE,
    );
    $form['shrinktheweb_options']['shrinktheweb_inside_pages'] = array(
      '#type' => 'checkbox',
      '#title' => t('Inside Page Captures'),
      '#default_value' => $inside_pages == 1 ? TRUE : FALSE,
      '#description' => $inside_pages == 0 ? t('Upgrade required to use this feature') : t('i.e. not just homepages and sub-domains, auto selected if you have purchased this pro package'),
      '#disabled' => TRUE,
    );
    $form['shrinktheweb_options']['shrinktheweb_thumb_size'] = array(
      '#type' => 'select',
      '#title' => t('Default Thumbnail size'),
      '#options' => array(
        'mcr' => t('mcr'),
        'tny' => t('tny'),
        'vsm' => t('vsm'),
        'sm' => t('sm'),
        'lg' => t('lg'),
        'xlg' => t('xlg'),
      ),
      '#default_value' => variable_get('shrinktheweb_thumb_size', 'lg'),
      '#required' => TRUE,
      '#description' => t('width: mcr 75px, tny 90px, vsm 100px, sm 120px, lg 200px, xlg 320px'),
    );
    $form['shrinktheweb_options']['shrinktheweb_thumb_size_custom'] = array(
      '#type' => 'textfield',
      '#title' => t('Custom Width'),
      '#default_value' => $custom_size == 0 && $full_length == 0 ? '' : variable_get('shrinktheweb_thumb_size_custom', ''),
      '#description' => $custom_size == 0 && $full_length == 0 ? t('Upgrade required to use this feature') : t('Enter your custom image width, this will override default size'),
      '#size' => 10,
      '#disabled' => $custom_size == 1 || $full_length == 1 ? FALSE : TRUE,
    );
    $form['shrinktheweb_options']['shrinktheweb_full_size'] = array(
      '#type' => 'checkbox',
      '#title' => t('Full-Length capture'),
      '#default_value' => $full_length == 0 ? FALSE : variable_get('shrinktheweb_full_size', FALSE),
      '#description' => $full_length == 0 ? t('Upgrade required to use this feature') : '',
      '#disabled' => $full_length == 1 ? FALSE : TRUE,
    );
    $form['shrinktheweb_options']['shrinktheweb_max_height'] = array(
      '#type' => 'textfield',
      '#title' => t('Max height'),
      '#default_value' => $full_length == 0 ? '' : variable_get('shrinktheweb_max_height', ''),
      '#description' => $full_length == 0 ? t('Upgrade required to use this feature') : t('use if you want to set maxheight for fullsize capture'),
      '#size' => 10,
      '#disabled' => $full_length == 1 ? FALSE : TRUE,
    );
    $form['shrinktheweb_options']['shrinktheweb_native_res'] = array(
      '#type' => 'textfield',
      '#title' => t('Native resolution'),
      '#default_value' => $custom_resolution == 0 ? '' : variable_get('shrinktheweb_native_res', ''),
      '#description' => $custom_resolution == 0 ? t('Upgrade required to use this feature') : t('i.e. 640 for 640x480'),
      '#size' => 10,
      '#disabled' => $custom_resolution == 1 ? FALSE : TRUE,
    );
    $form['shrinktheweb_options']['shrinktheweb_widescreen_y'] = array(
      '#type' => 'textfield',
      '#title' => t('Widescreen resolution Y'),
      '#default_value' => $custom_resolution == 0 ? '' : variable_get('shrinktheweb_widescreen_y', ''),
      '#description' => $custom_resolution == 0 ? t('Upgrade required to use this feature') : t('i.e. 900 for 1440x900 if 1440 is set for Native resolution'),
      '#size' => 10,
      '#disabled' => $custom_resolution == 1 ? FALSE : TRUE,
    );
    $form['shrinktheweb_options']['shrinktheweb_delay'] = array(
      '#type' => 'textfield',
      '#title' => t('Delay After Load'),
      '#default_value' => $custom_delay == 0 ? '' : variable_get('shrinktheweb_delay', ''),
      '#description' => $custom_delay == 0 ? t('Upgrade required to use this feature') : t('max. 45'),
      '#size' => 10,
      '#disabled' => $custom_delay == 1 ? FALSE : TRUE,
    );
    $form['shrinktheweb_options']['shrinktheweb_quality'] = array(
      '#type' => 'textfield',
      '#title' => t('Quality'),
      '#default_value' => $custom_quality == 0 ? '' : variable_get('shrinktheweb_quality', ''),
      '#description' => $custom_quality == 0 ? t('Upgrade required to use this feature') : t('0 .. 100'),
      '#size' => 10,
      '#disabled' => $custom_quality == 1 ? FALSE : TRUE,
    );
    $form['shrinktheweb_adv_options'] = array(
      '#type' => 'fieldset',
      '#title' => t('ShrinkTheWeb Advanced Options'),
      '#collapsible' => FALSE,
      '#collapsed' => FALSE,
    );
    $form['shrinktheweb_adv_options']['shrinktheweb_cache_days'] = array(
      '#type' => 'textfield',
      '#title' => t('Cache days'),
      '#default_value' => variable_get('shrinktheweb_cache_days', 3),
      '#description' => t('How many days the images are valid in your cache, Enter 0 (zero) to never update screenshots once cached or -1 to disable caching and always use embedded method instead'),
      '#size' => 10,
    );
    $form['shrinktheweb_adv_options']['shrinktheweb_thumbs_folder'] = array(
      '#type' => 'textfield',
      '#title' => t('Thumbnails folder'),
      '#default_value' => variable_get('shrinktheweb_thumbs_folder', 'shrinktheweb_thumbnails'),
      '#required' => TRUE,
      '#description' => t('This is a subfolder of the "File system path" folder.'),
    );
    $form['shrinktheweb_adv_options']['shrinktheweb_custom_msg_url'] = array(
      '#type' => 'textfield',
      '#title' => t('Custom Messages URL'),
      '#default_value' => $custom_messages == 0 ? '' : variable_get('shrinktheweb_custom_msg_url', ''),
      '#description' => $custom_messages == 0 ? t('Upgrade required to use this feature') : t('specify the URL where your custom message images are stored'),
      '#size' => 10,
      '#disabled' => $custom_messages == 1 ? FALSE : TRUE,
    );
    $form['shrinktheweb_adv_options']['shrinktheweb_debug'] = array(
      '#type' => 'checkbox',
      '#title' => t('Debug'),
      '#default_value' => variable_get('shrinktheweb_debug', FALSE),
      '#description' => t('Store debug info in database'),
    );
  }
  $form['#submit'][] = 'shrinktheweb_admin_settings_submit';
  return system_settings_form($form);
}