From 0df1774a43d8648668b71de934f88df6c3ed87a7 Mon Sep 17 00:00:00 2001
From: lolandese <lolandese@210402.no-reply.drupal.org>
Date: Fri, 19 Jun 2015 23:29:05 +0200
Subject:  lolandese: Generated with Drush iq

---
 block/flickr_block.admin.inc |    2 +
 flickr.admin.inc             |   38 ++++++++++-
 flickr.css                   |    4 ++
 flickr.module                |    5 +-
 flickr.php                   |  152 ++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 196 insertions(+), 5 deletions(-)
 create mode 100644 flickr.php

diff --git a/block/flickr_block.admin.inc b/block/flickr_block.admin.inc
index 2ccc42b..5b0e8e1 100644
--- a/block/flickr_block.admin.inc
+++ b/block/flickr_block.admin.inc
@@ -32,6 +32,7 @@ function flickr_block_form_flickr_admin_settings_alter(&$form, &$form_state) {
     '#field_suffix' => t('hours.'),
     '#size' => 3,
     '#maxlength' => 3,
+    '#attributes' => array('class' => array('flickr-form-align')),
   );
   $cache_warming = l(t('cache warming'), 'https://drupal.org/node/1576686/', array(
     'attributes' => array(
@@ -48,6 +49,7 @@ function flickr_block_form_flickr_admin_settings_alter(&$form, &$form_state) {
     '#field_suffix' => t('hours.'),
     '#size' => 3,
     '#maxlength' => 3,
+    '#attributes' => array('class' => array('flickr-form-align')),
   );
   $form['block_settings']['flickr_block_photos_per_set'] = array(
     '#type' => 'textfield',
diff --git a/flickr.admin.inc b/flickr.admin.inc
index b8a82b3..079c775 100644
--- a/flickr.admin.inc
+++ b/flickr.admin.inc
@@ -109,6 +109,7 @@ function flickr_admin_settings() {
     '#field_suffix' => t('px'),
     '#size' => 3,
     '#maxlength' => 3,
+    '#attributes' => array('class' => array('flickr-form-align')),
   );
   $form['info_settings']['flickr_metadata_suppress_on_small'] = array(
     '#type' => 'textfield',
@@ -119,6 +120,7 @@ function flickr_admin_settings() {
     '#field_suffix' => t('px'),
     '#size' => 3,
     '#maxlength' => 3,
+    '#attributes' => array('class' => array('flickr-form-align')),
   );
   $rubular = l(t('http://rubular.com/r/RhKjj9Thy1'), 'http://rubular.com/r/RhKjj9Thy1', array(
       'attributes' => array(
@@ -363,11 +365,41 @@ function flickr_admin_settings() {
       ),
   ));
   $form['css_settings']['flickr_css'] = array(
-    '#type' => 'checkbox',
-    '#title' => t('Use flickr.css'),
+    '#type' => 'radios',
+    '#title' => t('CSS source'),
+    '#options' => array(
+      0 => t("Exclude the module's CSS"),
+      1 => t("Use the module's default CSS"),
+      2 => t("Use the module's CSS with configurable settings (N.B.: Excluded from CSS aggregation)"),
+    ),
     '#default_value' => variable_get('flickr_css', 1),
-    '#description' => t("Uncheck to take care of the styling yourself in custom CSS.<br />If you use Flickr Filter, you might find the !autofloat_module useful.", array('!autofloat_module' => $autofloat_module)),
+    '#description' => t("Use configurable settings <strong>OR</strong> copy the used module's CSS files to your theme folder, make your changes and mention them in your [theme].info file.<br />If you use Flickr Filter, you might find the !autofloat_module useful.", array('!autofloat_module' => $autofloat_module)),
   );
+  $form['css_settings']['css_variables'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('CSS variables'),
+    '#collapsible' => TRUE,
+    '#collapsed' => TRUE,
+  );
+  if (variable_get('flickr_css', 1) == 2) {
+    $form['css_settings']['css_variables']['#collapsed'] = FALSE;
+    $form['css_settings']['css_variables']['flickr_capsize'] = array(
+      '#type' => 'textfield',
+      '#title' => t('Photo caption font size'),
+      '#default_value' => variable_get('flickr_capsize', 80),
+      '#description' => t('Relative to the font for normal text.'),
+      '#field_suffix' => t('%'),
+      '#size' => 3,
+      '#maxlength' => 3,
+      '#attributes' => array('class' => array('flickr-form-align')),
+    );
+  }
+  else {
+    $form['css_settings']['css_variables']['flickr_note'] = array(
+      '#markup' => t("Choose '<em>configurable settings</em>' above to get them exposed here. They consist of:
+        <ul><li>the photo caption font size</li></ul>"),
+    );
+  }
   $flickr_style = l(t('Flickr Style'), 'admin/modules', array(
       'attributes' => array(
         'title' => t('Extra configuration options.'),
diff --git a/flickr.css b/flickr.css
index 809bec6..1126fda 100644
--- a/flickr.css
+++ b/flickr.css
@@ -104,3 +104,7 @@ span.grayed-out {
 span.grayed-out-help {
   color: #666;
 }
+
+.flickr-form-align {
+  text-align: right;
+}
diff --git a/flickr.module b/flickr.module
index 47909a0..82d196b 100644
--- a/flickr.module
+++ b/flickr.module
@@ -23,8 +23,9 @@ function flickr_help($path, $arg) {
  */
 function flickr_page_build(&$page) {
   // Determine the setting to use flickr.css or not.
-  if (variable_get('flickr_css', 1)) {
-    drupal_add_css(drupal_get_path('module', 'flickr') . '/flickr.css', array(
+  if (variable_get('flickr_css')) {
+    $extension = variable_get('flickr_css') == 2 ? 'php' : 'css';
+    drupal_add_css(drupal_get_path('module', 'flickr') . '/flickr.' . $extension, array(
       'group' => CSS_DEFAULT,
       'every_page' => TRUE,
     ));
diff --git a/flickr.php b/flickr.php
new file mode 100644
index 0000000..464a6f5
--- /dev/null
+++ b/flickr.php
@@ -0,0 +1,152 @@
+<?php
+/**
+ * This as PHP 'disguised' CSS file allows for the use of Drupal defined
+ * variables inside CSS. There are some down sides:
+ * - The CSS won't get aggregated.
+ * - A Right-To-Left CSS style sheet will be ignored.
+ * - It has a slight performance impact.
+ *
+ * The regular CSS files are also provided with an option in the settings of the
+ * module to use CSS variables. If not, override CSS yourself by moving the CSS
+ * files to your theme folder and mention them in the [yourtheme].info file.
+ */
+
+  // Changes the header to be recognized as a CSS file instead of PHP.
+  header("Content-type: text/css; charset: UTF-8");
+
+  // Iterates up from the current folder until the Drupal root is found.
+  function dirroot() {
+    if ( strstr( __FILE__, $_SERVER['DOCUMENT_ROOT']) ) {
+      $dir = $_SERVER['DOCUMENT_ROOT'];
+    } else {
+      $dir = dirname(__FILE__);
+      while ( ! file_exists($dir . '/install.php') ) {
+        $dir = dirname($dir);
+      }
+    }
+    return $dir;
+  }
+
+  // Initializes Drupal's variable system.
+  define('DRUPAL_ROOT', dirroot());
+  require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
+  drupal_bootstrap(DRUPAL_BOOTSTRAP_VARIABLES);
+
+  // Sets the used variables in the CSS below.
+  $capsize = variable_get('flickr_capsize', 80);
+?>
+
+/**
+ * CSS part: Float images found in the target alternately right and left.
+ */
+
+.flickr-photo-img {
+  vertical-align: text-bottom;
+}
+
+.flickr-photo-box {
+  float: left;
+  width: 260px;
+  height: 260px;
+  padding: 10px;
+  text-align: center;
+}
+
+.flickr-photoset-img {
+  vertical-align: text-bottom;
+}
+
+.flickr-photoset-box {
+  float: left;
+  padding: 10px;
+  text-align: center;
+}
+
+span.flickr-wrap,
+span.flickr-photoset-single {
+  position: relative;
+  display: inline-block;
+  margin: 0 5px 5px 0;
+  vertical-align: top;
+}
+
+span.flickr-credit {
+  display: block;
+  overflow: hidden;
+  padding: 0 0 4px 4px;
+  font-size: <?php echo $capsize; ?>%;
+  line-height: 100%;
+}
+
+.flickr-slideshow {
+  position: relative;
+  overflow: hidden;
+  width: 100%;
+  height: 0;
+  /*Change percentage below to change ratio. Currently 16:9 (as most screens).*/
+  padding-bottom: 56.25%;
+}
+
+.flickr-slideshow object {
+  position: absolute;
+  top: 0;
+  left: 0;
+}
+
+.flickr-block-photosets .flickr-block-photoset {
+  margin-top: 0.5em;
+  padding-top: 0.5em;
+  border-top: 1px solid #dfdfdf;
+}
+
+span.floatleft {
+  float: left; /* LTR */
+  margin: 5px 5px 0 0; /* LTR */
+}
+span.floatright {
+  float: right; /* LTR */
+  margin: 5px 0 0 10px; /* LTR */
+}
+
+span.flickr-tags {
+  font-style: italic;
+}
+
+.flickr-wrap,
+.flickr-wrap img,
+.flickr-wrap .flickr-credit {
+  /*See http://stackoverflow.com/a/11390432/523688*/
+  -webkit-box-sizing: border-box;
+     -moz-box-sizing: border-box;
+          box-sizing: border-box;
+  max-width: 100%;
+}
+
+div.flickr-photoset {
+  clear: both;
+}
+
+span.flickr-empty {
+  display: inline-block;
+  margin: 10px;
+}
+
+.page-flickr-sets h1#page-title {
+  display: none;
+}
+
+.tips span.ctools-toggle {
+  float: none !important;
+}
+
+span.grayed-out {
+  color: darkgray;
+}
+
+span.grayed-out-help {
+  color: #666;
+}
+
+.flickr-form-align {
+  text-align: right;
+}
-- 
1.7.9.5

