Index: flickr.css
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/flickr/flickr.css,v
retrieving revision 1.4
diff -u -b -u -p -r1.4 flickr.css
--- flickr.css	24 Mar 2008 19:56:09 -0000	1.4
+++ flickr.css	21 May 2009 23:30:38 -0000
@@ -37,3 +37,9 @@
 .flickr-photoset-title {}
 
 .flickr-photoset-count {}
+
+/** Override for Drupal's default block, 95% width textfields on node forms. */
+.node-form .flickrfield_flickrid {
+  display: inline;
+  width: auto;
+}
Index: field/flickrfield.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/flickr/field/flickrfield.module,v
retrieving revision 1.4.2.1
diff -u -b -u -p -r1.4.2.1 flickrfield.module
--- field/flickrfield.module	30 Jan 2009 10:39:01 -0000	1.4.2.1
+++ field/flickrfield.module	21 May 2009 23:30:39 -0000
@@ -34,6 +34,10 @@ function flickrfield_field_info() {
       'label' => 'Flickr Photo',
       'description' => t('Store Flickr Photo or Photoset ids and display the photos in nodes and views.'),
     ),
+    'flickrfield_photoset' => array(
+      'label' => 'Flickr photo set',
+      'description' => t('Field for storing a reference to a Flickr photo set.'),
+    )
   );
 }
 
@@ -43,11 +47,18 @@ function flickrfield_field_info() {
 function flickrfield_field_settings($op, $field) {
   switch ($op) {
     case 'database columns':
+      if ($field['type'] == 'flickrfield') {
       $columns = array(
         'id' => array('type' => 'varchar', 'length' => 64, 'not null' => FALSE, 'sortable' => TRUE),
         'type' => array('type' => 'varchar', 'length' => 10, 'not null' => FALSE, 'sortable' => TRUE),
         'nsid' => array('type' => 'varchar', 'length' => 64, 'not null' => FALSE, 'sortable' => TRUE),
       );
+      }
+      else if ($field['type'] == 'flickrfield_photoset') {
+        $columns = array(
+          'flickrid' => array('type' => 'varchar', 'length' => 64, 'not null' => FALSE, 'sortable' => TRUE),
+        );
+      }
       return $columns;
   }
 }
@@ -65,6 +76,14 @@ function flickrfield_widget_info() {
         'default value' => CONTENT_CALLBACK_DEFAULT,
       ),
     ),
+    'flickrfield_flickrid' => array(
+      'label' => 'Flickr Id',
+      'field types' => array('flickrfield_photoset'),
+      'multiple values' => CONTENT_HANDLE_CORE,
+      'callbacks' => array(
+        'default value' => CONTENT_CALLBACK_DEFAULT,
+      ),
+    )
   );
 }
 
@@ -75,6 +94,11 @@ function flickrfield_elements() {
       '#columns' => array('type', 'id', 'uid'),
       '#process' => array('flickrfield_process'),
     ),
+    'flickrfield_flickrid' => array(
+      '#input' => TRUE,
+      '#columns' => array('flickrid'),
+      '#process' => array('flickrfield_flickrid_process'),
+    )
   );
 }
 
@@ -111,11 +135,30 @@ function flickrfield_process($element, $
   return $element;
 }
 
+function flickrfield_flickrid_process($element, $edit, $form_state, $form) {
+  $element['flickrid'] = array(
+    '#type' => 'textfield',
+    '#title' => $element['#title'],
+    '#description' => $element['#description'],
+    '#required' => $element['#required'],
+    '#field_prefix' => t('Flickr ID: '),
+    '#default_value' => !empty($element['#value']['flickrid']) ? $element['#value']['flickrid'] : '',
+    '#size' => 20,
+    '#maxlength' => 20,
+    '#attributes' => array('class' => 'flickrfield_flickrid'),
+  );
+  return $element;
+}
+
 /**
  * Implementation of hook_content_is_empty().
  */
 function flickrfield_content_is_empty($item, $field) {
+  if ($field['type'] == 'flickrfield') {
   return empty($item['id']);
+  } else if ($field['type'] == 'flickrfield_photoset') {
+    return empty($item['flickrid']);
+  }
 }
 
 /**
@@ -123,12 +166,37 @@ function flickrfield_content_is_empty($i
  */
 function flickrfield_field_formatter_info() {
   require_once(drupal_get_path('module', 'flickr') .'/flickr.inc');
-  foreach (flickr_photo_sizes() as $size => $info) {
+  $sizes = flickr_photo_sizes();
+  // Formatters for general Flickr CCK field.
+  foreach ($sizes as $size => $info) {
     $formatters[$size] = array(
       'label' => $info['label'],
       'field types' => array('flickrfield'),
       );
   }
+  // Formatters for Flickr photoset CCK field.
+  foreach ($sizes as $size => $info) {
+    $formatters['photoset_primaryphoto_size'. $size .'_nolink'] = array(
+      'label' => t('Primary set photo at size "@size"', array('@size' => $info['label'])),
+      'field types' => array('flickrfield_photoset'),
+    );
+    $formatters['photoset_primaryphoto_size'. $size .'_linknode'] = array(
+      'label' => t('Primary set photo at size "@size" with link to node', array('@size' => $info['label'])),
+      'field types' => array('flickrfield_photoset'),
+    );
+    $formatters['photoset_primaryphoto_size'. $size .'_linkflickrcomset'] = array(
+      'label' => t('Primary set photo at size "@size" with link to set on Flickr.com', array('@size' => $info['label'])),
+      'field types' => array('flickrfield_photoset'),
+    );
+  }
+  $formatters['photoset_flickrcomslideshow'] = array(
+    'label' => 'Embedded Flickr.com flash slideshow',
+    'field types' => array('flickrfield_photoset'),
+  );
+  $formatters['photoset_flickrcomsetlink'] = array(
+    'label' => 'Link to photo set on Flickr.com',
+    'field types' => array('flickrfield_photoset'),
+  );
   return $formatters;
 }
 
@@ -143,6 +211,19 @@ function flickrfield_theme() {
       'arguments' => array('element'),
       'function' => 'theme_flickrfield_field_formatter',
       );
+    // Theme function for the primary photo formatters of a Flickr photo set.
+    $themes['flickrfield_formatter_photoset_primaryphoto_size'. $size .'_nolink'] = array(
+      'arguments' => array('element'),
+      'function' => 'theme_flickrfield_formatter_photoset_primaryphoto',
+    );
+    $themes['flickrfield_formatter_photoset_primaryphoto_size'. $size .'_linknode'] = array(
+      'arguments' => array('element'),
+      'function' => 'theme_flickrfield_formatter_photoset_primaryphoto',
+    );
+    $themes['flickrfield_formatter_photoset_primaryphoto_size'. $size .'_linkflickrcomset'] = array(
+      'arguments' => array('element'),
+      'function' => 'theme_flickrfield_formatter_photoset_primaryphoto',
+    );
   }
   return $themes + array(
     'flickrfield_photo' => array(
@@ -154,6 +235,18 @@ function flickrfield_theme() {
     'flickrfield' => array(
       'arguments' => array('element'),
     ),
+    'flickrfield_flickrid' => array(
+      'arguments' => array('element'),
+    ),
+    'flickrfield_photoset_primaryphoto' => array(
+      'arguments' => array('element'),
+    ),
+    'flickrfield_formatter_photoset_flickrcomslideshow' => array(
+      'arguments' => array('element'),
+    ),
+    'flickrfield_formatter_photoset_flickrcomsetlink' => array(
+      'arguments' => array('element'),
+    ),
   );
 }
 
@@ -184,6 +277,59 @@ function theme_flickrfield_field_formatt
 }
 
 /**
+ * Theme a Flickr photo set as the primary photo of that set.
+ */
+function theme_flickrfield_formatter_photoset_primaryphoto($element) {
+  require_once(drupal_get_path('module', 'flickr') .'/flickr.inc');
+  if (empty($element['#item']['flickrid'])) {
+    return;
+  }
+  $formatter_info = explode('_', $element['#formatter']);
+  $set_data = flickr_photoset_get_info($element['#item']['flickrid']);
+  $set_url = flickr_photoset_page_url($set_data['owner'], $set_data['id']);
+  $size = substr($formatter_info[2], -1);
+  $img = flickr_img($set_data, $size);
+  switch ($formatter_info[3]) {
+    case 'linknode':
+      $link = 'node/'. $element['#node']->nid;
+      break;
+    case 'linkflickrcomset':
+      $link = $set_url;
+      break;
+    default:
+      $link = NULL;
+      break;
+  }
+  $title = is_array($photo_data['title']) ? $photo_data['title']['_content'] : $photo_data['title'];
+
+  return theme('flickrfield_photoset_primaryphoto', $img, $link, $set_url, $size, $title);
+}
+
+/**
+ * Theme a Flickr photo set as an embedded Flickr.com flash slideshow.
+ */
+function theme_flickrfield_formatter_photoset_flickrcomslideshow($element) {
+  require_once(drupal_get_path('module', 'flickr') .'/flickr.inc');
+  if (empty($element['#item']['flickrid'])) {
+    return;
+  }
+  $set_id = $element['#item']['flickrid'];
+  $src = 'http://www.flickr.com/slideShow/index.gne?set_id='. $set_id;
+  return '<div class="flickr-photoset-slideshow">'
+    .'<iframe align="center" src="' . $src .'" frameBorder="0" width="500" scrolling="no" height="500"></iframe>'
+    .'</div>';
+}
+
+/**
+ * Theme a Flickr photo set as a simple link to the photo set page on Flickr.com.
+ */
+function theme_flickrfield_formatter_photoset_flickrcomsetlink($element) {
+  $set_data = flickr_photoset_get_info($element['#item']['flickrid']);
+  $set_url = flickr_photoset_page_url($set_data['owner'], $set_data['id']);
+  return l($set_url, $set_url);
+}
+
+/**
  * Flickrfield photo themes.
  *
  * If we are not on the node, make the photo link back to the node,
@@ -215,6 +361,27 @@ function theme_flickrfield_photoset($img
 }
 
 /**
+ * Theme function for showing a primary photo of a photo set with optional link.
+ * Also includes a link to Flickr.com photo set page to comply with terms of service.
+ * @param $img HTML code for image
+ * @param $link link to which the image should link to
+ * @param $set_url url of the photo set on Flickr.com
+ * @param $size the flickr size of the image
+ * @param $title title to use for the link
+ * @return unknown_type
+ */
+function theme_flickrfield_photoset_primaryphoto($img, $link, $set_url, $size, $title) {
+  if ($link) {
+    $output = '<div class="flickr-photoset-img">'. l($img, $link, array('attributes' => array('title' => $title), 'html' => TRUE)) . '</div>';
+  }
+  else {
+    $output = '<div class="flickr-photoset-img">'. $img .'</div>';
+  }
+  $output .= '<div class="flickr-citation">'. l(t('Source: Flickr'), $set_url) .'</div>';
+  return $output;
+}
+
+/**
  * Theme for the form element.
  * 
  * The form is already rendered by the child elements by the time it comes back here,
@@ -233,3 +400,13 @@ function theme_flickrfield($element) {
   );
   return theme('fieldset', $fieldset);
 }
+
+/**
+ * Theme function for the Flickr ID form element.
+ *
+ * The textfield is already rendered by the textfield theme
+ * and the html output lives in $element['#children'].
+ */
+function theme_flickrfield_flickrid($element) {
+  return $element['#children'];
+}
