From d5672d1de1dbdcb21aa9f965a7c033b00dcc0b3c Mon Sep 17 00:00:00 2001
From: thewilkybarkid <chriswilkinson84@gmail.com>
Date: Fri, 2 May 2014 16:07:41 +0100
Subject: [PATCH] Set up Focus On teasers

---
 src/cambridge/cambridge.install           |  9 +++
 src/cambridge_base.inc                    | 81 ++++++++++++++++++++++-
 src/cambridge_lite/cambridge_lite.install |  9 +++
 3 files changed, 97 insertions(+), 2 deletions(-)

diff --git a/src/cambridge/cambridge.install b/src/cambridge/cambridge.install
index 58f440e..77d916b 100644
--- a/src/cambridge/cambridge.install
+++ b/src/cambridge/cambridge.install
@@ -379,3 +379,12 @@ function cambridge_update_7103() {
     field_update_instance($instance);
   }
 }
+
+/**
+ * Set up Focus On teasers.
+ */
+function cambridge_update_7104() {
+  require_once 'cambridge_base.inc';
+
+  cambridge_base_set_up_focus_on_teasers();
+}
diff --git a/src/cambridge_base.inc b/src/cambridge_base.inc
index 792695b..52022d8 100644
--- a/src/cambridge_base.inc
+++ b/src/cambridge_base.inc
@@ -143,7 +143,8 @@ function cambridge_base_install() {
           'carousel' => 'carousel',
           'inline' => 'inline',
           'leading' => 'leading',
-          'sidebar_teaser' => 'sidebar_teaser'
+          'sidebar_teaser' => 'sidebar_teaser',
+          'small' => 'small',
         ),
         'max_filesize' => '',
         'max_resolution' => '',
@@ -192,6 +193,12 @@ function cambridge_base_install() {
           'settings' => array('image_style' => 'sidebar_teaser', 'image_link' => 'content'),
           'weight' => -1,
         ),
+        'focus_on_teaser' => array(
+          'label' => 'hidden',
+          'type' => 'image',
+          'settings' => array('image_style' => 'small', 'image_link' => 'content'),
+          'weight' => -1,
+        ),
       ),
     ),
     array(
@@ -210,7 +217,8 @@ function cambridge_base_install() {
           'carousel' => 'carousel',
           'inline' => 'inline',
           'leading' => 0,
-          'sidebar_teaser' => 'sidebar_teaser'
+          'sidebar_teaser' => 'sidebar_teaser',
+          'small' => 'small',
         ),
         'max_filesize' => '',
         'max_resolution' => '',
@@ -259,6 +267,12 @@ function cambridge_base_install() {
           'settings' => array('image_style' => 'sidebar_teaser', 'image_link' => ''),
           'weight' => -1,
         ),
+        'focus_on_teaser' => array(
+          'label' => 'hidden',
+          'type' => 'image',
+          'settings' => array('image_style' => 'small', 'image_link' => ''),
+          'weight' => -1,
+        ),
       ),
     ),
     array(
@@ -303,6 +317,11 @@ function cambridge_base_install() {
           'type' => 'link_default',
           'weight' => 1,
         ),
+        'focus_on_teaser' => array(
+          'label' => 'hidden',
+          'type' => 'link_default',
+          'weight' => 1,
+        ),
       ),
     ),
   );
@@ -569,3 +588,61 @@ function cambridge_base_install_configure_form_alter(&$form, $form_state) {
   // Only check for updates, no need for email notifications.
   $form['update_notifications']['update_status_module']['#default_value'] = array(1);
 }
+
+/**
+ * Set up Focus On teasers.
+ */
+function cambridge_base_set_up_focus_on_teasers() {
+  if (FALSE === module_exists('cambridge_teasers')) {
+    return;
+  }
+
+  // Update Page's image field.
+
+  if (FALSE !== node_type_get_name('page') && NULL !== $instance = field_info_instance('node', 'field_image', 'page')) {
+    $instance['display']['focus_on_teaser'] = array_merge(
+      $instance['display']['focus_on_teaser'],
+      array(
+        'label' => 'hidden',
+        'type' => 'image',
+        'settings' => array('image_style' => 'small', 'image_link' => 'content'),
+        'weight' => -1,
+      )
+    );
+    $instance['settings']['imagecrop']['small'] = 'small';
+
+    field_update_instance($instance);
+  }
+
+  // Update Link's image field.
+
+  if (FALSE !== node_type_get_name('link') && NULL !== $instance = field_info_instance('node', 'field_image', 'link')) {
+    $instance['display']['focus_on_teaser'] = array_merge(
+      $instance['display']['focus_on_teaser'],
+      array(
+        'label' => 'hidden',
+        'type' => 'image',
+        'settings' => array('image_style' => 'small', 'image_link' => ''),
+        'weight' => -1,
+      )
+    );
+    $instance['settings']['imagecrop']['small'] = 'small';
+
+    field_update_instance($instance);
+  }
+
+  // Update Link's link field.
+
+  if (FALSE !== node_type_get_name('link') && NULL !== $instance = field_info_instance('node', 'field_link', 'link')) {
+    $instance['display']['focus_on_teaser'] = array_merge(
+      $instance['display']['focus_on_teaser'],
+      array(
+        'label' => 'hidden',
+        'type' => 'link_default',
+        'weight' => 1,
+      )
+    );
+
+    field_update_instance($instance);
+  }
+}
diff --git a/src/cambridge_lite/cambridge_lite.install b/src/cambridge_lite/cambridge_lite.install
index 0b1c4c8..8e2a427 100644
--- a/src/cambridge_lite/cambridge_lite.install
+++ b/src/cambridge_lite/cambridge_lite.install
@@ -17,3 +17,12 @@ function cambridge_lite_install() {
 
   cambridge_base_install();
 }
+
+/**
+ * Set up Focus On teasers.
+ */
+function cambridge_lite_update_7100() {
+  require_once 'cambridge_base.inc';
+
+  cambridge_base_set_up_focus_on_teasers();
+}
-- 
GitLab