From 7f3f4af19a45e22a03cfcac8441f430954d283c2 Mon Sep 17 00:00:00 2001
From: lolandese <lolandese@210402.no-reply.drupal.org>
Date: Thu, 5 Feb 2015 09:47:58 +0100
Subject:  lolandese: Generated with Drush iq

---
 block/flickr_block.admin.inc   |   90 ++++++++++++++++++++
 block/flickr_block.module      |    3 +
 filter/flickr_filter.admin.inc |   61 ++++++++++++++
 filter/flickr_filter.module    |    3 +
 flickr.admin.inc               |  180 +---------------------------------------
 sets/flickr_sets.admin.inc     |   70 ++++++++++++++++
 sets/flickr_sets.module        |    3 +
 style/flickrstyle.admin.inc    |   10 ++-
 8 files changed, 240 insertions(+), 180 deletions(-)
 create mode 100644 block/flickr_block.admin.inc
 create mode 100644 filter/flickr_filter.admin.inc
 create mode 100644 sets/flickr_sets.admin.inc

diff --git a/block/flickr_block.admin.inc b/block/flickr_block.admin.inc
new file mode 100644
index 0000000..d616a7a
--- /dev/null
+++ b/block/flickr_block.admin.inc
@@ -0,0 +1,90 @@
+<?php
+/**
+ * @file
+ * The admin settings for the Flickr Block module.
+ */
+
+/**
+ * Implements hook_form_FORM_ID_alter().
+ */
+function flickr_block_form_flickr_admin_settings_alter(&$form, &$form_state) {
+  $form['#validate'][] = 'flickr_block_admin_settings_validate';
+  $form['block_settings'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Block options'),
+    '#description' => t('Clear the cache on form submit.'),
+    '#collapsible' => TRUE,
+    '#collapsed' => TRUE,
+  );
+  $form['block_settings']['flickr_block_hide_empty'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Hide empty blocks (no media found)'),
+    '#default_value' => variable_get('flickr_block_hide_empty', 0),
+    '#description' => t("Uncheck to see the block title and to access the contextual links. That little wheel you see when you hover over blocks to edit them in place."),
+  );
+  $form['block_settings']['flickr_block_heading'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Wrap the album title in an HTML heading tag (only for blocks)'),
+    '#required' => TRUE,
+    '#default_value' => variable_get('flickr_block_heading', 'h2'),
+    '#description' => t("Use 'p' for no style, e.g. 'h2' for a heading or 'none' to not display an album title."),
+    '#size' => 4,
+    '#maxlength' => 4,
+  );
+  $form['block_settings']['flickr_block_refresh_random'] = array(
+    '#type' => 'textfield',
+    '#field_prefix' => t('Refresh random blocks every'),
+    '#required' => TRUE,
+    '#default_value' => variable_get('flickr_block_refresh_random', 23),
+    '#field_suffix' => t('hours.'),
+    '#size' => 3,
+    '#maxlength' => 3,
+  );
+  $cache_warming = l(t('cache warming'), 'https://drupal.org/node/1576686/', array(
+    'attributes' => array(
+      'title' => t('Load Page Cache after cron Runs | Drupal.org'),
+      'target' => '_blank',
+    ),
+  ));
+  $form['block_settings']['flickr_block_refresh_others'] = array(
+    '#type' => 'textfield',
+    '#field_prefix' => t('Refresh other blocks every'),
+    '#required' => TRUE,
+    '#default_value' => variable_get('flickr_block_refresh_others', 31),
+    '#description' => t('It is recommended to set two different refresh values to avoid all blocks refresh together. Lower values impact performance negatively. Consider to use !cache_warming.', array('!cache_warming' => $cache_warming)),
+    '#field_suffix' => t('hours.'),
+    '#size' => 3,
+    '#maxlength' => 3,
+  );
+  $form['block_settings']['flickr_block_photos_per_set'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Number of photos per set'),
+    '#required' => TRUE,
+    '#default_value' => variable_get('flickr_block_photos_per_set', 6),
+    '#description' => t('The number indicates how many photos display per set on blocks that display multiple photosets. Clear the cache on form submit.'),
+    '#size' => 2,
+    '#maxlength' => 2,
+  );
+}
+
+
+/**
+ * Validate user input.
+ */
+function flickr_block_admin_settings_validate($form, &$form_state) {
+  $limit5 = trim($form_state['values']['flickr_block_refresh_random']);
+  $limit6 = trim($form_state['values']['flickr_block_refresh_others']);
+  $limit10 = trim($form_state['values']['flickr_block_photos_per_set']);
+  // Validate refresh rate random blocks.
+  if (!is_numeric($limit5) || $limit5 < 2) {
+    form_set_error('flickr_block_refresh_random', t('Set a number from 2 to 999.'));
+  }
+  // Validate refresh rate other blocks.
+  if (!is_numeric($limit6) || $limit6 < 2) {
+    form_set_error('flickr_block_refresh_others', t('Set a number from 2 to 999.'));
+  }
+  // Validate photos per set.
+  if (!is_numeric($limit10) || $limit10 < 1) {
+    form_set_error('flickr_block_photos_per_set', t('Set a number from 1 to 99.'));
+  }
+}
diff --git a/block/flickr_block.module b/block/flickr_block.module
index 907769e..0da2bc6 100644
--- a/block/flickr_block.module
+++ b/block/flickr_block.module
@@ -4,6 +4,9 @@
  * The Flickr block module
  */
 
+  // Load flickr_block.admin.inc from the flickr_block module.
+  module_load_include('inc', 'flickr_block', 'flickr_block.admin');
+
 /**
  * Implements hook_help().
  */
diff --git a/filter/flickr_filter.admin.inc b/filter/flickr_filter.admin.inc
new file mode 100644
index 0000000..8b3f781
--- /dev/null
+++ b/filter/flickr_filter.admin.inc
@@ -0,0 +1,61 @@
+<?php
+/**
+ * @file
+ * The admin settings for the Flickr Filter module.
+ */
+
+/**
+ * Implements hook_form_FORM_ID_alter().
+ */
+function flickr_filter_form_flickr_admin_settings_alter(&$form, &$form_state) {
+  $form['#validate'][] = 'flickr_filter_admin_settings_validate';
+  $form['filter_settings'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Filter options'),
+    '#description' => t('Clear the cache on form submit.'),
+    '#collapsible' => TRUE,
+    '#collapsed' => TRUE,
+  );
+  $form['filter_settings']['flickr_filter_default_size'] = array(
+    '#type' => 'select',
+    '#title' => t('Default size for single photos'),
+    '#default_value' => variable_get('flickr_filter_default_size', 'm'),
+    '#options' => array(
+      's' => t('s: 75 px square'),
+      't' => t('t: 100 px on longest side'),
+      'q' => t('q: 150 px square'),
+      'm' => t('m: 240 px on longest side'),
+      'n' => t('n: 320 px on longest side (!)'),
+      '-' => t('-: 500 px on longest side'),
+      'z' => t('z: 640 px on longest side'),
+      'c' => t('c: 800 px on longest side (!)'),
+      'b' => t('b: 1024 px on longest side'),
+    ),
+    '#description' => t('A default Flickr size to use if no size is specified, for example [flickr-photo:id=3711935987].<br />Clear the cache on form submit.<br />!: TAKE CARE, n (320px) and c (800px) sizes are missing on many "older" Flickr images!'),
+  );
+  $form['filter_settings']['flickr_filter_heading'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Wrap the album title in an HTML heading tag (only for the text filter)'),
+    '#required' => TRUE,
+    '#default_value' => variable_get('flickr_filter_heading', 'p'),
+    '#description' => t("Use 'p' for no style, e.g. 'h3' for a heading or 'none' to not display an album title."),
+    '#size' => 4,
+    '#maxlength' => 4,
+  );
+  // Offer the following setting if the ctools module is enabled.
+  if (module_exists('ctools')) {
+    $form['filter_settings']['flickr_filter_collapsible'] = array(
+      '#type' => 'checkbox',
+      '#title' => t("Collapsible filter tips (collapsed by default)"),
+      '#default_value' => variable_get('flickr_filter_collapsible', 1),
+      '#description' => t('Collapse the in-line help for the Flickr Filter text format under the body field on node edit forms.'),
+    );
+  }
+}
+
+/**
+ * Validate user input.
+ */
+function flickr_filter_admin_settings_validate($form, &$form_state) {
+  // Put validation rules here.
+}
diff --git a/filter/flickr_filter.module b/filter/flickr_filter.module
index 751989f..fc4b6b7 100644
--- a/filter/flickr_filter.module
+++ b/filter/flickr_filter.module
@@ -4,6 +4,9 @@
  * The Flickr filter module.
  */
 
+  // Load flickr_filter.admin.inc from the flickr_filter module.
+  module_load_include('inc', 'flickr_filter', 'flickr_filter.admin');
+
 /**
  * Implements hook_help().
  */
diff --git a/flickr.admin.inc b/flickr.admin.inc
index 2aecf5f..a8ce476 100644
--- a/flickr.admin.inc
+++ b/flickr.admin.inc
@@ -385,157 +385,12 @@ function flickr_admin_settings() {
     $form['advanced_settings']['flickr_curl2']['#disabled'] = TRUE;
     $form['advanced_settings']['flickr_curl2']['#description'] = t("Disabled because your server configuration only allows 'stream_socket_client' (not 'cURL')");
   }
-  if (module_exists('flickr_filter')) {
-    $form['filter_settings'] = array(
-      '#type' => 'fieldset',
-      '#title' => t('Filter options'),
-      '#description' => t('Clear the cache on form submit.'),
-      '#collapsible' => TRUE,
-      '#collapsed' => TRUE,
-    );
-    $form['filter_settings']['flickr_filter_default_size'] = array(
-      '#type' => 'select',
-      '#title' => t('Default size for single photos'),
-      '#default_value' => variable_get('flickr_filter_default_size', 'm'),
-      '#options' => array(
-        's' => t('s: 75 px square'),
-        't' => t('t: 100 px on longest side'),
-        'q' => t('q: 150 px square'),
-        'm' => t('m: 240 px on longest side'),
-        'n' => t('n: 320 px on longest side (!)'),
-        '-' => t('-: 500 px on longest side'),
-        'z' => t('z: 640 px on longest side'),
-        'c' => t('c: 800 px on longest side (!)'),
-        'b' => t('b: 1024 px on longest side'),
-      ),
-      '#description' => t('A default Flickr size to use if no size is specified, for example [flickr-photo:id=3711935987].<br />Clear the cache on form submit.<br />!: TAKE CARE, n (320px) and c (800px) sizes are missing on many "older" Flickr images!'),
-    );
-    $form['filter_settings']['flickr_filter_heading'] = array(
-      '#type' => 'textfield',
-      '#title' => t('Wrap the album title in an HTML heading tag (only for the text filter)'),
-      '#required' => TRUE,
-      '#default_value' => variable_get('flickr_filter_heading', 'p'),
-      '#description' => t("Use 'p' for no style, e.g. 'h3' for a heading or 'none' to not display an album title."),
-      '#size' => 4,
-      '#maxlength' => 4,
-    );
-    // Offer the following setting if the ctools module is enabled.
-    if (module_exists('ctools')) {
-      $form['filter_settings']['flickr_filter_collapsible'] = array(
-        '#type' => 'checkbox',
-        '#title' => t("Collapsible filter tips (collapsed by default)"),
-        '#default_value' => variable_get('flickr_filter_collapsible', 1),
-        '#description' => t('Collapse the in-line help for the Flickr Filter text format under the body field on node edit forms.'),
-      );
-    }
-  }
-  if (module_exists('flickr_block')) {
-    $form['block_settings'] = array(
-      '#type' => 'fieldset',
-      '#title' => t('Block options'),
-      '#description' => t('Clear the cache on form submit.'),
-      '#collapsible' => TRUE,
-      '#collapsed' => TRUE,
-    );
-    $form['block_settings']['flickr_block_hide_empty'] = array(
-      '#type' => 'checkbox',
-      '#title' => t('Hide empty blocks (no media found)'),
-      '#default_value' => variable_get('flickr_block_hide_empty', 0),
-      '#description' => t("Uncheck to see the block title and to access the contextual links. That little wheel you see when you hover over blocks to edit them in place."),
-    );
-    $form['block_settings']['flickr_block_heading'] = array(
-      '#type' => 'textfield',
-      '#title' => t('Wrap the album title in an HTML heading tag (only for blocks)'),
-      '#required' => TRUE,
-      '#default_value' => variable_get('flickr_block_heading', 'h2'),
-      '#description' => t("Use 'p' for no style, e.g. 'h2' for a heading or 'none' to not display an album title."),
-      '#size' => 4,
-      '#maxlength' => 4,
-    );
-    $form['block_settings']['flickr_block_refresh_random'] = array(
-      '#type' => 'textfield',
-      '#field_prefix' => t('Refresh random blocks every'),
-      '#required' => TRUE,
-      '#default_value' => variable_get('flickr_block_refresh_random', 23),
-      '#field_suffix' => t('hours.'),
-      '#size' => 3,
-      '#maxlength' => 3,
-    );
-    $cache_warming = l(t('cache warming'), 'https://drupal.org/node/1576686/', array(
-      'attributes' => array(
-        'title' => t('Load Page Cache after cron Runs | Drupal.org'),
-        'target' => '_blank',
-      ),
-    ));
-    $form['block_settings']['flickr_block_refresh_others'] = array(
-      '#type' => 'textfield',
-      '#field_prefix' => t('Refresh other blocks every'),
-      '#required' => TRUE,
-      '#default_value' => variable_get('flickr_block_refresh_others', 31),
-      '#description' => t('It is recommended to set two different refresh values to avoid all blocks refresh together. Lower values impact performance negatively. Consider to use !cache_warming.', array('!cache_warming' => $cache_warming)),
-      '#field_suffix' => t('hours.'),
-      '#size' => 3,
-      '#maxlength' => 3,
-    );
-    $form['block_settings']['flickr_block_photos_per_set'] = array(
-      '#type' => 'textfield',
-      '#title' => t('Number of photos per set'),
-      '#required' => TRUE,
-      '#default_value' => variable_get('flickr_block_photos_per_set', 6),
-      '#description' => t('The number indicates how many photos display per set on blocks that display multiple photosets. Clear the cache on form submit.'),
-      '#size' => 2,
-      '#maxlength' => 2,
-    );
-  }
-  if (module_exists('flickr_sets')) {
-    $form['photoset_settings'] = array(
-      '#type' => 'fieldset',
-      '#title' => t('Photoset options'),
-      '#description' => t('Clear the cache on form submit.'),
-      '#collapsible' => TRUE,
-      '#collapsed' => TRUE,
-    );
-    $form['photoset_settings']['flickr_sets_thumb_default_size'] = array(
-      '#type' => 'select',
-      '#title' => t('Size for the photo representing a set'),
-      '#default_value' => variable_get('flickr_sets_thumb_default_size', 's'),
-      '#options' => array(
-        's' => t('s: 75 px square'),
-        't' => t('t: 100 px on longest side'),
-        'q' => t('q: 150 px square'),
-        'm' => t('m: 240 px on longest side'),
-        'n' => t('n: 320 px on longest side (!)'),
-        '-' => t('-: 500 px on longest side'),
-        'z' => t('z: 640 px on longest side'),
-        'c' => t('c: 800 px on longest side (!)'),
-        'b' => t('b: 1024 px on longest side'),
-      ),
-      '#description' => t('!: TAKE CARE, n (320px) and c (800px) sizes are missing on many "older" Flickr images!'),
-    );
-    $form['photoset_settings']['flickr_sets_per_page'] = array(
-      '#type' => 'textfield',
-      '#title' => t('Number of photosets per page'),
-      '#required' => TRUE,
-      '#default_value' => variable_get('flickr_sets_per_page', 8),
-      '#description' => t('The number indicates how many photosets display on user profile pages at <em>flickr/%uid/sets</em>. Clear the cache on form submit.'),
-      '#size' => 2,
-      '#maxlength' => 2,
-    );
-    $form['photoset_settings']['flickr_sets_photos_per_set'] = array(
-      '#type' => 'textfield',
-      '#title' => t('Number of photos per set'),
-      '#required' => TRUE,
-      '#default_value' => variable_get('flickr_sets_photos_per_set', 6),
-      '#description' => t('The number indicates how many photos display in a set on user profile pages at <em>flickr/%uid/sets/%nsid</em>. Clear the cache on form submit.'),
-      '#size' => 2,
-      '#maxlength' => 2,
-    );
-  }
   $form['flickr_cc'] = array(
     '#type' => 'checkbox',
     '#title' => t("Flush all caches on form submit to see your changes instantly."),
     '#default_value' => variable_get('flickr_cc', 0),
     '#description' => t("Note that form submit will be slower and all your site content will be rebuilt. Your choice will be 'remembered' for your next visit to this configuration page."),
+    '#weight' => 99,
   );
 
   // Call submit_function() on form submission.
@@ -556,15 +411,6 @@ function flickr_admin_settings_validate($form, &$form_state) {
   $limit3 = trim($form_state['values']['flickr_metadata_suppress_on_small']);
   $limit4 = trim($form_state['values']['flickr_caption_padding']);
   $limit7 = trim($form_state['values']['flickr_per_page']);
-  if (module_exists('flickr_block')) {
-    $limit5 = trim($form_state['values']['flickr_block_refresh_random']);
-    $limit6 = trim($form_state['values']['flickr_block_refresh_others']);
-    $limit10 = trim($form_state['values']['flickr_block_photos_per_set']);
-  }
-  if (module_exists('flickr_sets')) {
-    $limit8 = trim($form_state['values']['flickr_sets_per_page']);
-    $limit9 = trim($form_state['values']['flickr_sets_photos_per_set']);
-  }
   if ($key && (preg_match('/^[A-Fa-f\d]{32}$/', $key) != 1)) {
     form_set_error('flickr_api_key', t('This does not appear to be a Flickr API key.'));
   }
@@ -597,30 +443,6 @@ function flickr_admin_settings_validate($form, &$form_state) {
   if (!is_numeric($limit7) || $limit7 < 20 || $limit7 > 500) {
     form_set_error('flickr_per_page', t('Set a number from 20 to 500.'));
   }
-  if (module_exists('flickr_block')) {
-    // Validate refresh rate random blocks.
-    if (!is_numeric($limit5) || $limit5 < 2) {
-      form_set_error('flickr_block_refresh_random', t('Set a number from 2 to 999.'));
-    }
-    // Validate refresh rate other blocks.
-    if (!is_numeric($limit6) || $limit6 < 2) {
-      form_set_error('flickr_block_refresh_others', t('Set a number from 2 to 999.'));
-    }
-    // Validate photos per set.
-    if (!is_numeric($limit10) || $limit10 < 1) {
-      form_set_error('flickr_block_photos_per_set', t('Set a number from 1 to 99.'));
-    }
-  }
-  if (module_exists('flickr_sets')) {
-    // Validate sets per page.
-    if (!is_numeric($limit8) || $limit8 < 1) {
-      form_set_error('flickr_sets_per_page', t('Set a number from 1 to 99.'));
-    }
-    // Validate photos per set.
-    if (!is_numeric($limit9) || $limit9 < 1) {
-      form_set_error('flickr_sets_photos_per_set', t('Set a number from 1 to 99.'));
-    }
-  }
 }
 
 /**
diff --git a/sets/flickr_sets.admin.inc b/sets/flickr_sets.admin.inc
new file mode 100644
index 0000000..97acbbc
--- /dev/null
+++ b/sets/flickr_sets.admin.inc
@@ -0,0 +1,70 @@
+<?php
+/**
+ * @file
+ * The admin settings for the Flickr Sets module.
+ */
+
+/**
+ * Implements hook_form_FORM_ID_alter().
+ */
+function flickr_sets_form_flickr_admin_settings_alter(&$form, &$form_state) {
+  $form['#validate'][] = 'flickr_sets_admin_settings_validate';
+  $form['photoset_settings'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Photoset options'),
+    '#description' => t('Clear the cache on form submit.'),
+    '#collapsible' => TRUE,
+    '#collapsed' => TRUE,
+  );
+  $form['photoset_settings']['flickr_sets_thumb_default_size'] = array(
+    '#type' => 'select',
+    '#title' => t('Size for the photo representing a set'),
+    '#default_value' => variable_get('flickr_sets_thumb_default_size', 's'),
+    '#options' => array(
+      's' => t('s: 75 px square'),
+      't' => t('t: 100 px on longest side'),
+      'q' => t('q: 150 px square'),
+      'm' => t('m: 240 px on longest side'),
+      'n' => t('n: 320 px on longest side (!)'),
+      '-' => t('-: 500 px on longest side'),
+      'z' => t('z: 640 px on longest side'),
+      'c' => t('c: 800 px on longest side (!)'),
+      'b' => t('b: 1024 px on longest side'),
+    ),
+    '#description' => t('!: TAKE CARE, n (320px) and c (800px) sizes are missing on many "older" Flickr images!'),
+  );
+  $form['photoset_settings']['flickr_sets_per_page'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Number of photosets per page'),
+    '#required' => TRUE,
+    '#default_value' => variable_get('flickr_sets_per_page', 8),
+    '#description' => t('The number indicates how many photosets display on user profile pages at <em>flickr/%uid/sets</em>. Clear the cache on form submit.'),
+    '#size' => 2,
+    '#maxlength' => 2,
+  );
+  $form['photoset_settings']['flickr_sets_photos_per_set'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Number of photos per set'),
+    '#required' => TRUE,
+    '#default_value' => variable_get('flickr_sets_photos_per_set', 6),
+    '#description' => t('The number indicates how many photos display in a set on user profile pages at <em>flickr/%uid/sets/%nsid</em>. Clear the cache on form submit.'),
+    '#size' => 2,
+    '#maxlength' => 2,
+  );
+}
+
+/**
+ * Validate user input.
+ */
+function flickr_sets_admin_settings_validate($form, &$form_state) {
+  $limit8 = trim($form_state['values']['flickr_sets_per_page']);
+  $limit9 = trim($form_state['values']['flickr_sets_photos_per_set']);
+  // Validate sets per page.
+  if (!is_numeric($limit8) || $limit8 < 1) {
+    form_set_error('flickr_sets_per_page', t('Set a number from 1 to 99.'));
+  }
+  // Validate photos per set.
+  if (!is_numeric($limit9) || $limit9 < 1) {
+    form_set_error('flickr_sets_photos_per_set', t('Set a number from 1 to 99.'));
+  }
+}
diff --git a/sets/flickr_sets.module b/sets/flickr_sets.module
index acfa722..1109d86 100644
--- a/sets/flickr_sets.module
+++ b/sets/flickr_sets.module
@@ -4,6 +4,9 @@
  * The Flickr sets module.
  */
 
+  // Load flickr_sets.admin.inc from the flickr_sets module.
+  module_load_include('inc', 'flickr_sets', 'flickr_sets.admin');
+
 /**
  * Implements hook_help().
  */
diff --git a/style/flickrstyle.admin.inc b/style/flickrstyle.admin.inc
index 373f638..6ad69c6 100644
--- a/style/flickrstyle.admin.inc
+++ b/style/flickrstyle.admin.inc
@@ -1,13 +1,14 @@
 <?php
 /**
  * @file
- * The admin settings for the Flickr Style module
+ * The admin settings for the Flickr Style module.
  */
 
 /**
  * Implements hook_form_FORM_ID_alter().
  */
 function flickrstyle_form_flickr_admin_settings_alter(&$form, &$form_state) {
+  $form['#validate'][] = 'flickrstyle_admin_settings_validate';
   // Do not display CSS styling options if the module's CSS is disabled.
   if (variable_get('flickr_css', 1)) {
     $options = array(
@@ -103,3 +104,10 @@ function flickrstyle_form_flickr_admin_settings_alter(&$form, &$form_state) {
     );
   }
 }
+
+/**
+ * Validate user input.
+ */
+function flickrstyle_admin_settings_validate($form, &$form_state) {
+  // Put validation rules here.
+}
-- 
1.7.9.5

