Browse Source

contrib modules security updates

Bachir Soussi Chiadmi 2 years ago
parent
commit
747127f643
100 changed files with 1674 additions and 575 deletions
  1. 4 2
      sites/all/modules/block_class/README.txt
  2. 0 74
      sites/all/modules/block_class/block_class.features.inc
  3. 8 5
      sites/all/modules/block_class/block_class.info
  4. 109 65
      sites/all/modules/block_class/block_class.install
  5. 47 69
      sites/all/modules/block_class/block_class.module
  6. 329 0
      sites/all/modules/block_class/block_class.test
  7. 37 0
      sites/all/modules/block_class/tests/block_class_fe_block_test.features.fe_block_settings.inc
  8. 15 0
      sites/all/modules/block_class/tests/block_class_fe_block_test.info
  9. 5 0
      sites/all/modules/block_class/tests/block_class_fe_block_test.module
  10. 8 10
      sites/all/modules/colorbox/README.txt
  11. 11 3
      sites/all/modules/colorbox/colorbox-insert-image.tpl.php
  12. 30 4
      sites/all/modules/colorbox/colorbox.admin.inc
  13. 17 2
      sites/all/modules/colorbox/colorbox.api.php
  14. 4 4
      sites/all/modules/colorbox/colorbox.info
  15. 5 3
      sites/all/modules/colorbox/colorbox.install
  16. 8 0
      sites/all/modules/colorbox/colorbox.make
  17. 0 9
      sites/all/modules/colorbox/colorbox.make.example
  18. 58 27
      sites/all/modules/colorbox/colorbox.module
  19. 75 16
      sites/all/modules/colorbox/colorbox.theme.inc
  20. 11 11
      sites/all/modules/colorbox/drush/colorbox.drush.inc
  21. 24 7
      sites/all/modules/colorbox/js/colorbox.js
  22. 10 1
      sites/all/modules/colorbox/js/colorbox_inline.js
  23. 10 1
      sites/all/modules/colorbox/js/colorbox_load.js
  24. 33 11
      sites/all/modules/colorbox/styles/default/colorbox_style.css
  25. 1 2
      sites/all/modules/colorbox/styles/default/colorbox_style.js
  26. 28 7
      sites/all/modules/colorbox/styles/plain/colorbox_style.css
  27. 2 2
      sites/all/modules/colorbox/styles/plain/colorbox_style.js
  28. 28 8
      sites/all/modules/colorbox/styles/stockholmsyndrome/colorbox_style.css
  29. 3 3
      sites/all/modules/colorbox/styles/stockholmsyndrome/colorbox_style.js
  30. 9 2
      sites/all/modules/colorbox/views/colorbox_handler_field_colorbox.inc
  31. 3 3
      sites/all/modules/ctools/bulk_export/bulk_export.info
  32. 3 4
      sites/all/modules/ctools/ctools.info
  33. 75 1
      sites/all/modules/ctools/ctools.module
  34. 3 3
      sites/all/modules/ctools/ctools_access_ruleset/ctools_access_ruleset.info
  35. 3 3
      sites/all/modules/ctools/ctools_ajax_sample/ctools_ajax_sample.info
  36. 1 1
      sites/all/modules/ctools/ctools_ajax_sample/ctools_ajax_sample.module
  37. 3 3
      sites/all/modules/ctools/ctools_custom_content/ctools_custom_content.info
  38. 17 0
      sites/all/modules/ctools/ctools_custom_content/plugins/export_ui/ctools_custom_content_ui.class.php
  39. 3 3
      sites/all/modules/ctools/ctools_plugin_example/ctools_plugin_example.info
  40. 10 1
      sites/all/modules/ctools/includes/content.inc
  41. 12 0
      sites/all/modules/ctools/includes/context-admin.inc
  42. 5 9
      sites/all/modules/ctools/includes/context.inc
  43. 6 4
      sites/all/modules/ctools/includes/css.inc
  44. 1 1
      sites/all/modules/ctools/includes/export.inc
  45. 1 2
      sites/all/modules/ctools/includes/fields.inc
  46. 1 1
      sites/all/modules/ctools/includes/jump-menu.inc
  47. 2 2
      sites/all/modules/ctools/includes/math-expr.inc
  48. 1 0
      sites/all/modules/ctools/includes/modal.inc
  49. 6 4
      sites/all/modules/ctools/includes/plugins.inc
  50. 1 1
      sites/all/modules/ctools/includes/stylizer.inc
  51. 2 1
      sites/all/modules/ctools/includes/uuid.inc
  52. 32 19
      sites/all/modules/ctools/js/dependent.js
  53. 157 27
      sites/all/modules/ctools/js/modal.js
  54. 43 0
      sites/all/modules/ctools/js/states-show.js
  55. 1 1
      sites/all/modules/ctools/js/stylizer.js
  56. 14 2
      sites/all/modules/ctools/page_manager/page_manager.admin.inc
  57. 3 3
      sites/all/modules/ctools/page_manager/page_manager.info
  58. 12 3
      sites/all/modules/ctools/page_manager/page_manager.module
  59. 1 1
      sites/all/modules/ctools/page_manager/plugins/tasks/node_edit.inc
  60. 3 4
      sites/all/modules/ctools/page_manager/plugins/tasks/node_view.inc
  61. 2 2
      sites/all/modules/ctools/page_manager/plugins/tasks/page.admin.inc
  62. 49 9
      sites/all/modules/ctools/plugins/arguments/term.inc
  63. 74 0
      sites/all/modules/ctools/plugins/content_types/comment/comment_created.inc
  64. 1 1
      sites/all/modules/ctools/plugins/content_types/comment/comment_links.inc
  65. 1 1
      sites/all/modules/ctools/plugins/content_types/comment/comment_reply_form.inc
  66. 30 1
      sites/all/modules/ctools/plugins/content_types/custom/custom.inc
  67. 24 18
      sites/all/modules/ctools/plugins/content_types/entity_context/entity_field.inc
  68. 47 5
      sites/all/modules/ctools/plugins/content_types/form/entity_form_field.inc
  69. 1 1
      sites/all/modules/ctools/plugins/content_types/node/node.inc
  70. 1 1
      sites/all/modules/ctools/plugins/content_types/node_context/node_attachments.inc
  71. 1 1
      sites/all/modules/ctools/plugins/content_types/node_context/node_book_children.inc
  72. 1 1
      sites/all/modules/ctools/plugins/content_types/node_context/node_book_nav.inc
  73. 1 18
      sites/all/modules/ctools/plugins/content_types/node_context/node_comment_form.inc
  74. 2 2
      sites/all/modules/ctools/plugins/content_types/node_context/node_comment_wrapper.inc
  75. 1 1
      sites/all/modules/ctools/plugins/content_types/node_context/node_comments.inc
  76. 1 1
      sites/all/modules/ctools/plugins/content_types/node_context/node_content.inc
  77. 1 1
      sites/all/modules/ctools/plugins/content_types/node_context/node_links.inc
  78. 1 1
      sites/all/modules/ctools/plugins/content_types/node_context/node_type_desc.inc
  79. 3 0
      sites/all/modules/ctools/plugins/content_types/page/page_title.inc
  80. 4 3
      sites/all/modules/ctools/plugins/content_types/term_context/term_description.inc
  81. 1 1
      sites/all/modules/ctools/plugins/content_types/term_context/term_list.inc
  82. 1 1
      sites/all/modules/ctools/plugins/content_types/user_context/profile_fields.inc
  83. 1 1
      sites/all/modules/ctools/plugins/content_types/user_context/user_profile.inc
  84. 1 1
      sites/all/modules/ctools/plugins/content_types/user_context/user_signature.inc
  85. 1 1
      sites/all/modules/ctools/plugins/content_types/vocabulary_context/vocabulary_terms.inc
  86. 3 1
      sites/all/modules/ctools/plugins/contexts/user.inc
  87. 4 4
      sites/all/modules/ctools/plugins/contexts/user_edit_form.inc
  88. 7 1
      sites/all/modules/ctools/plugins/export_ui/ctools_export_ui.class.php
  89. 1 1
      sites/all/modules/ctools/plugins/relationships/entity_from_field.inc
  90. 3 3
      sites/all/modules/ctools/stylizer/stylizer.info
  91. 34 24
      sites/all/modules/ctools/term_depth/plugins/access/term_depth.inc
  92. 3 3
      sites/all/modules/ctools/term_depth/term_depth.info
  93. 3 3
      sites/all/modules/ctools/tests/ctools_export_test/ctools_export_test.info
  94. 3 3
      sites/all/modules/ctools/tests/ctools_plugin_test.info
  95. 1 1
      sites/all/modules/ctools/tests/plugins/cached/ctoolsCachedPluginArray.class.php
  96. 1 1
      sites/all/modules/ctools/tests/plugins/cached/ctoolsCachedPluginArray2.class.php
  97. 1 1
      sites/all/modules/ctools/tests/plugins/not_cached/ctoolsNotCachedPluginArray.class.php
  98. 4 0
      sites/all/modules/ctools/views_content/plugins/content_types/views_panes.inc
  99. 1 1
      sites/all/modules/ctools/views_content/plugins/views/views_content.views.inc
  100. 0 0
      sites/all/modules/ctools/views_content/views_content.info

+ 4 - 2
sites/all/modules/block_class/README.txt

@@ -2,7 +2,8 @@
 Block Class
 http://drupal.org/project/block_class
 -----
-Block Class was developed and is maintained by Four Kitchens <http://fourkitchens.com>.
+Block Class was developed and is maintained by Four Kitchens
+<http://fourkitchens.com>.
 
 
 =====
@@ -10,4 +11,5 @@ Installation
 -----
 
 1. Enable the module
-2. To add a class to a block, simply visit that block's configuration page at Administration > Structure > Blocks
+2. To add a class to a block, simply visit that block's configuration page at
+Administration > Structure > Blocks

+ 0 - 74
sites/all/modules/block_class/block_class.features.inc

@@ -1,74 +0,0 @@
-<?php
-
-/**
- * Implements hook_features_export_options().
- */
-function block_class_features_export_options() {
-  $query = db_select('block_class', 'bc');
-  $query->addExpression("CONCAT(bc.module, ':', bc.delta)");
-  $blocks = $query->execute()->fetchAllKeyed(0, 0);
-
-  natcasesort($blocks);
-  return $blocks;
-}
-
-/**
- * Implements hook_features_export().
- */
-function block_class_features_export($data, &$export, $module_name = '') {
-  $pipe = array();
-
-  $export['dependencies']['features'] = 'features';
-  $export['dependencies']['block_class'] = 'block_class';
-
-  foreach ($data as $component) {
-    $export['features']['block_class'][$component] = $component;
-  }
-
-  return $pipe;
-}
-
-/**
- * Implements hook_features_export_render().
- */
-function block_class_features_export_render($module, $data) {
-  $query = db_select('block_class', 'bc');
-  $query->addExpression("CONCAT(bc.module, ':', bc.delta)", 'id');
-  $query->addField('bc', 'css_class');
-  $classes = $query->execute()->fetchAllKeyed(1, 0);
-
-  $code = array();
-  foreach ($data as $id) {
-    if (isset($classes[$id])) {
-      list($module, $delta) = explode(':', $id);
-      $css_classes = $classes[$id];
-      $code[$id] = compact('module', 'delta', 'css_classes');
-    }
-  }
-
-  $code = "  return ". features_var_export($code, '  ') .";";
-
-  return array('block_class_features_default_class' => $code);
-}
-
-/**
- * Implements hook_features_revert().
- */
-function block_class_features_revert($module) {
-  block_class_features_rebuild($module);
-}
-
-/**
- * Implements hook_features_rebuild().
- */
-function block_class_features_rebuild($module) {
-  $blocks = module_invoke($module, 'block_class_features_default_class');
-  if ($blocks) {
-    foreach($blocks as $block) {
-      db_delete('block_class')->condition('module', $block['module'])->condition('delta', $block['delta'])->execute();
-      if (!empty($block['css_classes'])) {
-        $id = db_insert('block_class')->fields(array('module' => $block['module'], 'delta' => $block['delta'], 'css_class' => $block['css_classes']))->execute();
-      }
-    }
-  }
-}

+ 8 - 5
sites/all/modules/block_class/block_class.info

@@ -2,12 +2,15 @@ name = Block Class
 description = Allows assigning CSS classes to blocks.
 core = 7.x
 
-files[] = block_class.install
-files[] = block_class.module
+dependencies[] = block
+files[] = block_class.test
+test_dependencies[] = context
+test_dependencies[] = features (2.x)
+test_dependencies[] = features_extra
 
-; Information added by drupal.org packaging script on 2012-10-04
-version = "7.x-1.2+3-dev"
+; Information added by Drupal.org packaging script on 2015-12-18
+version = "7.x-2.3"
 core = "7.x"
 project = "block_class"
-datestamp = "1349309175"
+datestamp = "1450415951"
 

+ 109 - 65
sites/all/modules/block_class/block_class.install

@@ -6,102 +6,146 @@
  */
 
 /**
- * Implementation of hook_schema().
+ * Implements hook_install().
  */
-function block_class_schema() {
-  $schema['block_class'] = array(
-    'fields' => array(
-      'module' => array(
+function block_class_install() {
+  $schema['block'] = array();
+  block_class_schema_alter($schema);
+  foreach ($schema['block']['fields'] as $field => $spec) {
+    if (db_field_exists('block', $field)) {
+      watchdog('system', 'Module install: Attempt to recreate field: "%field", when it already exists.', array('%field' => $field), WATCHDOG_WARNING);
+    }
+    else {
+      db_add_field('block', $field, $spec);
+    }
+  }
+}
+
+/**
+ * Implements hook_uninstall().
+ */
+function block_class_uninstall() {
+  $schema['block'] = array();
+  block_class_schema_alter($schema);
+  foreach ($schema['block']['fields'] as $field => $specs) {
+    db_drop_field('block', $field);
+  }
+}
+
+/**
+ * Implements hook_schema_alter().
+ *
+ * Other modules, such as i18n_block also modify the block database table.
+ */
+function block_class_schema_alter(&$schema) {
+  if (isset($schema['block'])) {
+    $schema['block']['fields']['css_class'] = array(
+      'type' => 'varchar',
+      'length' => 255,
+      'not null' => TRUE,
+      'default' => '',
+      'description' => 'String containing the classes for the block.',
+    );
+  }
+}
+
+/**
+ * Alters the structure of {block_class} schema.
+ */
+function block_class_update_7100() {
+  // Check if the block_class table exists to prevent installation profiles
+  // from running this update for versions without the block_class table.
+  if (db_table_exists('block_class')) {
+    // Update the schema.
+    db_drop_primary_key('block_class');
+
+    db_change_field('block_class', 'module', 'module',
+      array(
         'type' => 'varchar',
-        'length' => 64,
+        'length' => '64',
         'not null' => TRUE,
         'default' => '',
         'description' => 'The module to which the block belongs.',
-      ),
-      'delta' => array(
+      )
+    );
+
+    db_change_field('block_class', 'delta', 'delta',
+      array(
         'type' => 'varchar',
-        'length' => 32,
+        'length' => '32',
         'not null' => TRUE,
         'default' => '',
         'description' => "The ID of the module's block.",
-      ),
-      'css_class' => array(
+      )
+    );
+
+    db_change_field('block_class', 'css_class', 'css_class',
+      array(
         'type' => 'varchar',
-        'length' => 255,
+        'length' => '255',
         'not null' => TRUE,
         'default' => '',
         'description' => 'String containing the classes for the block.',
-      ),
-    ),
-    'primary key' => array('module', 'delta'),
-  );
+      )
+    );
 
-  return $schema;
+    // Restore the primary key.
+    db_add_primary_key('block_class', array('module', 'delta'));
+  }
 }
 
 /**
- * Alters the structure of {block_class} schema.
+ * Fix too long primary key length in {block_class}.
  */
-function block_class_update_7100() {
-  // Update the schema.
-  db_drop_primary_key('block_class');
+function block_class_update_7101() {
+  // Ensure the block_class table exists, which is not true for all versions.
+  if (db_table_exists('block_class')) {
+    // Drop current primary key.
+    db_drop_primary_key('block_class');
 
-  db_change_field('block_class', 'module', 'module',
-    array(
+    db_change_field('block_class', 'module', 'module', array(
       'type' => 'varchar',
-      'length' => '255',
+      'length' => 64,
       'not null' => TRUE,
       'default' => '',
       'description' => 'The module to which the block belongs.',
-    )
-  );
-
-  db_change_field('block_class', 'delta', 'delta',
-    array(
+    ));
+    db_change_field('block_class', 'delta', 'delta', array(
       'type' => 'varchar',
-      'length' => '255',
+      'length' => 32,
       'not null' => TRUE,
       'default' => '',
       'description' => "The ID of the module's block.",
-    )
-  );
+    ));
 
-  db_change_field('block_class', 'css_class', 'css_class',
-    array(
-      'type' => 'varchar',
-      'length' => '255',
-      'not null' => TRUE,
-      'default' => '',
-      'description' => 'String containing the classes for the block.',
-    )
-  );
-
-  // Restore the primary key.
-  db_add_primary_key('block_class', array('module', 'delta'));
+    // Create new primary key.
+    db_add_primary_key('block_class', array('module', 'delta'));
+  }
 }
 
 /**
- * Fix too long primary key length in {block_class}.
+ * Migration from block_class table to new field css_class in core block table.
  */
-function block_class_update_7101() {
-  // Drop current primary key.
-  db_drop_primary_key('block_class');
-
-  db_change_field('block_class', 'module', 'module', array(
-    'type' => 'varchar',
-    'length' => 64,
-    'not null' => TRUE,
-    'default' => '',
-    'description' => 'The module to which the block belongs.',
-  ));
-  db_change_field('block_class', 'delta', 'delta', array(
-    'type' => 'varchar',
-    'length' => 32,
-    'not null' => TRUE,
-    'default' => '',
-    'description' => "The ID of the module's block.",
-  ));
+function block_class_update_7103() {
+  if (!db_field_exists('block', 'block_class')) {
+    $schema['block'] = array();
+    block_class_schema_alter($schema);
+    foreach ($schema['block']['fields'] as $field => $specs) {
+      db_add_field('block', $field, $specs);
+    }
+  }
 
-  // Create new primary key.
-  db_add_primary_key('block_class', array('module', 'delta'));
+  if (db_table_exists('block_class')) {
+    // Migrate all existing records from block_class table to block table.
+    $result = db_query('SELECT css_class, module, delta FROM {block_class}');
+    while ($record = $result->fetchObject()) {
+      db_update('block')
+        ->fields(array('css_class' => $record->css_class))
+        ->condition('module', $record->module)
+        ->condition('delta', $record->delta)
+        ->execute();
+    }
+    // Remove the block_class table.
+    db_drop_table('block_class');
+  }
 }

+ 47 - 69
sites/all/modules/block_class/block_class.module

@@ -1,6 +1,16 @@
 <?php
 
 /**
+ * @file
+ * Enhanced control over the CSS Classes of any Block.
+ *
+ * Block Class allows users to add classes to any block through the block's
+ * configuration interface. This implementation is based on an alteration of
+ * the Core block database table to leverage the Core Block API functions,
+ * objects and structure.
+ */
+
+/**
  * Implements hook_permission().
  */
 function block_class_permission() {
@@ -12,37 +22,25 @@ function block_class_permission() {
   );
 }
 
-/*
+/**
+ * Implements theme_preprocess_block().
+ *
  * Extend block's classes with any user defined classes.
  */
 function block_class_preprocess_block(&$vars) {
   $block = $vars['block'];
-
-  /* The original code: */
-  //$classes = block_class($block);
-  //$vars['classes_array'] = array_merge($vars['classes_array'], explode(' ', $classes));
-
-  /* Replaced with the following so it doesn't fire that many queries if you have a lot of blocks */
-  static $_block_class_blocks_classes;
-
-  if (! isset ($_block_class_blocks_classes)) {
-    $_block_class_blocks_classes = array();
-    $result = db_query('SELECT css_class, module, delta FROM {block_class}');
-    while ($record = $result->fetchObject()) {
-      $_block_class_blocks_classes[$record->module][$record->delta] = $record->css_class;
+  if (!empty($block->css_class)) {
+    $classes_array = explode(' ', $block->css_class);
+    foreach ($classes_array as $class) {
+      $vars['classes_array'][] = drupal_clean_css_identifier($class, array());
     }
   }
-
-  if (isset($_block_class_blocks_classes[$block->module][$block->delta])) {
-    $classes = $_block_class_blocks_classes[$block->module][$block->delta];
-    $vars['classes_array'] = array_merge($vars['classes_array'], explode(' ', $classes));
-  }
 }
 
-
-/*
+/**
+ * Implements hook_preprocess_HOOK().
+ *
  * Extend panel block's classes with any user defined classes.
- * Implements hook_preprocess_hook()
  */
 function block_class_preprocess_panels_pane(&$vars) {
   if ($vars['pane']->type != 'block') {
@@ -52,42 +50,32 @@ function block_class_preprocess_panels_pane(&$vars) {
   $block_parts = explode('-', $vars['pane']->subtype);
   // Load the block based on the block parts.
   $block = block_load($block_parts[0], $block_parts[1]);
-  // Return block_class classes as string.
-  $css_class = block_class($block);
   // Add a generic 'module type' pane class.
   $vars['classes_array'][] = drupal_html_class('pane-' . $block->module);
   // Add $css_class to the $classes_array.
-  $vars['classes_array'][] = $css_class;
-}
-
-
-/**
- * Return classes as string
- */
-function block_class($block) {
-  $ret = db_query('SELECT css_class FROM {block_class} WHERE module = :module AND delta = :delta', array(':module' => $block->module, ':delta' => $block->delta))->fetchField();
-  return $ret ? check_plain ($ret) : '';
+  if (!empty($block->css_class)) {
+    $classes_array = explode(' ', $block->css_class);
+    foreach ($classes_array as $class) {
+      $vars['classes_array'][] = drupal_clean_css_identifier($class, array());
+    }
+  }
 }
 
-
 /**
- * Alter block edit form
+ * Implements hook_form_alter().
+ *
+ * Alter block edit form to add configuration field.
  */
 function block_class_form_alter(&$form, &$form_state, $form_id) {
-  if (user_access('administer block classes') && $form_id == 'block_admin_configure' || $form_id == 'block_add_block_form') {
-    $block = new stdClass;
-    $block->module = $form['module']['#value'];
-    $block->delta = $form['delta']['#value'];
-    $css_class = block_class($block);
-
-    // Create a more technical description for users with administer blocks permission.
-    $description = t('Customize the styling of this block by adding CSS classes. Separate multiple classes by spaces.');
+  if (user_access('administer block classes') && ($form_id == 'block_admin_configure' || $form_id == 'block_add_block_form')) {
+    // Load statically cached block object used to display the form.
+    $block = block_load($form['module']['#value'], $form['delta']['#value']);
 
     $form['settings']['css_class'] = array(
       '#type' => 'textfield',
       '#title' => t('CSS class(es)'),
-      '#default_value' => $css_class,
-      '#description' => t('Separate classes with a space.'),
+      '#default_value' => isset($block->css_class) ? $block->css_class : '',
+      '#description' => t('Customize the styling of this block by adding CSS classes. Separate multiple classes by spaces.'),
       '#maxlength' => 255,
     );
 
@@ -95,34 +83,24 @@ function block_class_form_alter(&$form, &$form_state, $form_id) {
   }
 }
 
-
 /**
- * Save supplied class.
+ * Helper function: additional submit callback for block configuration pages.
+ *
+ * Save supplied CSS classes.
  */
 function block_class_form_submit($form, &$form_state) {
   if ($form_state['values']['form_id'] == 'block_admin_configure' || $form_state['values']['form_id'] == 'block_add_block_form') {
-    if (isset($form_state['values']['css_class']) && user_access('administer blocks')) {
-      $module = $form_state['values']['module'];
-      $delta = $form_state['values']['delta'];
-      $class = $form_state['values']['css_class'];
-      db_delete('block_class')->condition('module', $module)->condition('delta', $delta)->execute();
-      if (!empty($class)) {
-        $id = db_insert('block_class')->fields(array('module' => $module, 'delta' => $delta, 'css_class' => $class))->execute();
+    // Only save if value has changed.
+    if (isset($form_state['values']['css_class']) && $form['settings']['css_class']['#default_value'] != $form_state['values']['css_class'] && user_access('administer blocks')) {
+      db_update('block')
+        ->fields(array('css_class' => $form_state['values']['css_class']))
+        ->condition('module', $form_state['values']['module'])
+        ->condition('delta', $form_state['values']['delta'])
+        ->execute();
+      // Flush all context module cache to use the updated css_class.
+      if (module_exists('context')) {
+        cache_clear_all('context', 'cache', TRUE);
       }
     }
   }
 }
-
-/**
- * Implements hook_features_api().
- */
-function block_class_features_api() {
-  return array(
-    'block_class' => array(
-      'name' => t('Block class'),
-      'feature_source' => TRUE,
-      'default_hook' => 'block_class_features_default_class',
-      'file' => drupal_get_path('module', 'block_class') . '/block_class.features.inc',
-    ),
-  );
-}

+ 329 - 0
sites/all/modules/block_class/block_class.test

@@ -0,0 +1,329 @@
+<?php
+
+/**
+ * @file
+ * Test the Block Class module.
+ */
+
+/**
+ * Provides common functionality for the Block Class test classes.
+ */
+class BlockClassTestCase extends DrupalWebTestCase {
+
+  /**
+   * User object to perform site browsing
+   * @var object
+   */
+  protected $privilegedUser;
+
+  /**
+   * Machine name of the module providing the block coupled with delta.
+   * @var string
+   */
+  protected $module = 'system';
+
+  /**
+   * Block delta as provided by its module.
+   * @var string
+   */
+  protected $delta = 'main';
+
+  /**
+   * Permissions required by the user to perform the tests.
+   * @var array
+   */
+  protected $permissions = array(
+    'administer blocks',
+    'administer block classes',
+  );
+
+  /**
+   * Enable modules and create user with specific permissions.
+   *
+   * By default Test Cases are carried on the "Main page content" Block.
+   */
+  public function setUp() {
+    // Merge inherited classes modules, see FieldUITestCase for an example.
+    $modules = func_get_args();
+    if (isset($modules[0]) && is_array($modules[0])) {
+      $modules = $modules[0];
+    }
+    $modules[] = 'block_class';
+    parent::setUp($modules);
+
+    // Authenticate test user.
+    $this->privilegedUser = $this->drupalCreateUser($this->permissions);
+    $this->drupalLogin($this->privilegedUser);
+  }
+
+  /**
+   * Update Block CSS class and assert whether it is found when displayed.
+   *
+   * @param bool $anon
+   *   (optional) Set to TRUE to view block with anon user, defaults to TRUE.
+   * @param string $module
+   *   (optional) Machine name of the module Defaults to
+   *   $this->module if set to NULL.
+   * @param string $delta
+   *   (optional) Block delta as provided by its module. Defaults to
+   *   $this->delta if set to NULL.
+   */
+  public function assertUpdateBlockClass($anon = FALSE, $module = NULL, $delta = NULL) {
+    // Initialize $module and $delta by default if no value is provided.
+    if (!isset($module)) {
+      $module = $this->module;
+    }
+    if (!isset($delta)) {
+      $delta = $this->delta;
+    }
+    // Test with three random class names.
+    $css_classes = implode(' ', array(
+      $this->randomName(8),
+      $this->randomName(8),
+      $this->randomName(8),
+    ));
+    // Update Block CSS class field.
+    $this->drupalPost("admin/structure/block/manage/$module/$delta/configure", array('css_class' => $css_classes), t('Save block'));
+    // Check Block configuration was saved successfully.
+    $this->assertText(t('The block configuration has been saved.'));
+    // Browse to the homepage.
+    $this->drupalGet('');
+    // Log out if the test is for anonymous user.
+    if ($anon) {
+      $this->drupalLogout();
+      // Browse back to the homepage.
+      $this->drupalGet('');
+    }
+    // Check if the Block CSS classes could be found.
+    $this->assertPattern('/class=\"(.*?)' . $css_classes . '(.*?)\"/', format_string('The CSS classes were found: @css_classes', array('@css_classes' => $css_classes)));
+    // Login again after testing with the anonumous user.
+    if ($anon) {
+      $this->drupalLogin($this->privilegedUser);
+    }
+  }
+}
+
+/**
+ * Test the update and display of the CSS class for a Block.
+ */
+class BlockClassUpdateDisplayTestCase extends BlockClassTestCase {
+
+  /**
+   * Implements DrupalWebTestCase::getInfo().
+   */
+  public static function getInfo() {
+    return array(
+      'name' => 'Block CSS class update and display',
+      'description' => 'Test the update of a Block CSS class field and the display for the Main Page Content Block.',
+      'group' => 'Block Class',
+    );
+  }
+
+  /**
+   * Update and display a Block multiple times to ensure CSS class is found.
+   *
+   * A Block is updated and displayed several times and with logged in or
+   * anonymous user, with Block cache turned enabled or disabled.
+   */
+  public function testUpdateDisplayClass() {
+    // Edit the block, change the class and check if the CSS classes are found.
+    $this->assertUpdateBlockClass();
+
+    // Now, turn on caching programmatically and set it to 15 min expiry.
+    variable_set('block_cache', TRUE);
+    variable_set('cache_lifetime', 900);
+    variable_set('page_cache_maximum_age', 900);
+
+    // Edit the block, change the class and check with the anonymous user.
+    $this->assertUpdateBlockClass(TRUE);
+
+    // Edit the block, change the class and check with the anonymous user.
+    $this->assertUpdateBlockClass(TRUE);
+  }
+}
+
+/**
+ * Test Block Class permissions.
+ */
+class BlockClassPermissionTestCase extends BlockClassTestCase {
+
+  /**
+   * Implements DrupalWebTestCase::getInfo().
+   */
+  public static function getInfo() {
+    return array(
+      'name' => 'Administer block classes permission',
+      'description' => 'Test the permission added by the module to administer block classes.',
+      'group' => 'Block Class',
+    );
+  }
+
+  /**
+   * Enable modules and create user with specific permissions.
+   */
+  public function setUp() {
+    // Remove the 'administer block classes' permission from the base class.
+    $this->permissions = array('administer blocks');
+    parent::setUp();
+  }
+
+  /**
+   * Ensure Block CSS classes field is only visible with the right permissions.
+   *
+   * Test if a user without 'administer block classes' permission has access to
+   * the Block CSS classes field on the block configuration page.
+   */
+  public function testPermission() {
+    // Browse to the "Main page content" block editing form page.
+    $this->drupalGet("admin/structure/block/manage/{$this->module}/{$this->delta}/configure");
+    // Check that the css_class field couldn't be found.
+    // If the field is not found, it can't be submitted through drupalPost.
+    $this->assertNoFieldById('css_class', 'The Css classes field was not found on the page.');
+  }
+}
+
+/**
+ * Test Block Class integration with Context.
+ */
+class BlockClassContextTestCase extends BlockClassUpdateDisplayTestCase {
+
+  /**
+   * Implements DrupalWebTestCase::getInfo().
+   */
+  public static function getInfo() {
+    return array(
+      'name' => 'Integration with Context',
+      'description' => 'Test the integration of Block Class with the Context module and the update/display of a Block CSS class.',
+      // Include required contributed modules context and ctools for the test.
+      'dependencies' => array('context', 'ctools'),
+      'group' => 'Block Class',
+    );
+  }
+
+  /**
+   * Enable modules and create user with specific permissions.
+   */
+  public function setUp() {
+    // Override default module and delta to test with the "Who's online" block.
+    $this->module = 'user';
+    $this->delta = 'online';
+    // Include the Context module and its dependencies to be loaded.
+    parent::setUp('context');
+    // Initialize a test context with the test block.
+    $this->initializeContext();
+  }
+
+  /**
+   * Helper function to initialize a test Context with a test block.
+   */
+  public function initializeContext() {
+    // Import a basic context exported through the admin interface.
+    $context = new stdClass();
+    $context->disabled = FALSE;
+    $context->api_version = 3;
+    $context->name = 'front';
+    $context->description = 'Frontpage Context';
+    $context->tag = '';
+    $context->conditions = array(
+      'path' => array(
+        'values' => array(
+          '<front>' => '<front>',
+        ),
+      ),
+    );
+    $context->reactions = array(
+      'block' => array(
+        'blocks' => array(
+          $this->module . '-' . $this->delta => array(
+            'module' => $this->module,
+            'delta' => $this->delta,
+            'region' => 'content',
+            'weight' => '-10',
+          ),
+        ),
+      ),
+    );
+    $context->condition_mode = 0;
+
+    // Translatables
+    // Included for use with string extractors like potx.
+    t('Frontpage Context');
+
+    // Save the context.
+    context_save($context);
+  }
+}
+
+/**
+ * Test Block Class integration with Features through FE Block.
+ */
+class BlockClassFeaturesTestCase extends BlockClassTestCase {
+
+  /**
+   * Implements DrupalWebTestCase::getInfo().
+   */
+  public static function getInfo() {
+    return array(
+      'name' => 'Integration with Features',
+      'description' => 'Test the integration of Block Class with Features through the FE Block module and the update/display of a Block CSS class.',
+      // Include Features related modules required for this Test Case.
+      'dependencies' => array('features', 'ctools', 'fe_block'),
+      'group' => 'Block Class',
+    );
+  }
+
+  /**
+   * Enable modules and create user with specific permissions.
+   */
+  public function setUp() {
+    // Override default module and delta to test with the "Who's online" block.
+    $this->module = 'user';
+    $this->delta = 'online';
+    // Include all Features related modules and Test Helper feature.
+	parent::setUp('block_class_fe_block_test');
+  }
+
+  /**
+   * Test how Block Class reacts when exported to a Feature with FE Block.
+   *
+   * Helper Feature's Block configuration settings are imported, updated and
+   * the display is tested several times, before reverting the feature.
+   */
+  public function testFeatureDisplayClass() {
+    // Block classes exported to the Test Feature module.
+    $test_classes = 'fe_block-class1 fe_block-class2 fe_block-class3';
+    // Test helper feature machine name.
+    $test_feature = 'block_class_fe_block_test';
+
+    // Browse to the front page and check Block's CSS classes configuration.
+    $this->drupalGet('');
+    // Check if feature's Block CSS classes could be found.
+    $this->assertPattern('/class=\"(.*?)' . $test_classes . '(.*?)\"/', format_string('The CSS classes from exported feature were found: @css_classes', array('@css_classes' => $test_classes)));
+
+    // Check Block's configuration form css_class field value.
+    $this->drupalGet("admin/structure/block/manage/{$this->module}/{$this->delta}/configure");
+    $this->assertFieldByName('css_class', $test_classes, format_string('The CSS classes from exported feature were found for the field <em>css_class</em> in the Block\'s configuration page: @css_classes', array('@css_classes' => $test_classes)));
+
+    // Run a standard Update/Display Test check with Anon.
+    $this->assertUpdateBlockClass(TRUE);
+
+    // Ensure Feature's state is overriden for 'fe_block_settings' component.
+    module_load_include('inc', 'features', 'features.export');
+    $test_feature_state = features_get_storage($test_feature);
+    $this->assertFalse(empty($test_feature_state), 'The state of the <em>Block Class FE Block Integration Test Helper</em> feature is <strong>Overridden</strong>.');
+    $test_feature_states = features_get_component_states(array($test_feature));
+    $this->assertFalse(empty($test_feature_states[$test_feature]['fe_block_settings']), 'The state of the <em>fe_block_settings</em> component of the <em>Block Class FE Block Integration Test Helper</em> feature is <strong>Overridden</strong>.');
+
+    // Revert feature and check again.
+    features_revert_module($test_feature);
+
+    // Browse to the front page and check Block's CSS classes configuration.
+    $this->drupalGet('');
+    // Check if feature's Block CSS classes could be found.
+    $this->assertPattern('/class=\"(.*?)' . $test_classes . '(.*?)\"/', format_string('After reverting the feature, the CSS classes from exported feature were found: @css_classes', array('@css_classes' => $test_classes)));
+
+    // Check Block's configuration form css_class field value.
+    $this->drupalGet("admin/structure/block/manage/{$this->module}/{$this->delta}/configure");
+    $this->assertFieldByName('css_class', $test_classes, format_string('After reverting the feature, the CSS classes from exported feature were found for the field <em>css_class</em> in the Block\'s configuration page: @css_classes', array('@css_classes' => $test_classes)));
+  }
+}

+ 37 - 0
sites/all/modules/block_class/tests/block_class_fe_block_test.features.fe_block_settings.inc

@@ -0,0 +1,37 @@
+<?php
+/**
+ * @file
+ * block_class_fe_block_test.features.fe_block_settings.inc
+ */
+
+/**
+ * Implements hook_default_fe_block_settings().
+ */
+function block_class_fe_block_test_default_fe_block_settings() {
+  $export = array();
+
+  $export['version'] = '2.0';
+
+  $export['user-online'] = array(
+    'cache' => -1,
+    'css_class' => 'fe_block-class1 fe_block-class2 fe_block-class3',
+    'custom' => 0,
+    'delta' => 'online',
+    'module' => 'user',
+    'node_types' => array(),
+    'pages' => '<front>',
+    'roles' => array(),
+    'themes' => array(
+      'bartik' => array(
+        'region' => 'content',
+        'status' => 1,
+        'theme' => 'bartik',
+        'weight' => -7,
+      ),
+    ),
+    'title' => 'Block Class Test Who\'s Online with FE Block',
+    'visibility' => 1,
+  );
+
+  return $export;
+}

+ 15 - 0
sites/all/modules/block_class/tests/block_class_fe_block_test.info

@@ -0,0 +1,15 @@
+name = Block Class FE Block Integration Test Helper
+description = Helper module for testing the integration of Block Class with Features through the FE Block module.
+core = 7.x
+package = Features
+dependencies[] = fe_block
+features[fe_block_settings][] = user-online
+features[features_api][] = api:2
+hidden = TRUE
+
+; Information added by Drupal.org packaging script on 2015-12-18
+version = "7.x-2.3"
+core = "7.x"
+project = "block_class"
+datestamp = "1450415951"
+

+ 5 - 0
sites/all/modules/block_class/tests/block_class_fe_block_test.module

@@ -0,0 +1,5 @@
+<?php
+/**
+ * @file
+ * Drupal needs this blank file.
+ */

+ 8 - 10
sites/all/modules/colorbox/README.txt

@@ -32,15 +32,13 @@ The Colorbox module:
 
 The Colorbox plugin:
 
-* Supports images, image groups, slideshow, ajax, inline, and
-  iframed content.
-* Appearance is controlled through CSS so users can restyle the box.
-* Preloads background images and can preload upcoming images in a
-  photo group.
-* Generates W3C valid XHTML and adds no JS global variables and
-  passes JSLint.
-* Tested in Firefox 2 & 3, Safari 3 & 4, Opera 9, Chrome,
-  Internet Explorer 6, 7, 8.
+* Supports photos, grouping, slideshow, ajax, inline, and iframed content.
+* Appearance is controlled through CSS so it can be restyled.
+* Preloads upcoming images in a photo group.
+* Completely unobtrusive, options are set in the JS and require no
+  changes to existing HTML.
+* Compatible with: jQuery 1.3.2+ in Firefox, Safari, Chrome, Opera,
+  Internet Explorer 7+.
 * Released under the MIT License.
 
 
@@ -91,7 +89,7 @@ Make any CSS adjustments to your "colorbox_mycolorbox.css" file.
 Load images from custom links in a Colorbox:
 --------------------------------------------
 
-Add the class "colorbox" to the link and point the src to the image
+Add the class "colorbox" to the link and point its href attribute to the image
 you want to display in the Colorbox.
 
 

+ 11 - 3
sites/all/modules/colorbox/colorbox-insert-image.tpl.php

@@ -6,9 +6,12 @@
  *
  * Available variables:
  * - $item: The complete item being inserted.
- * - $image_path: The URL to the image.
- * - $link_path: The URL to the image that Colorbox should open.
+ * - $url: The URL to the image.
+ * - $path: The URL to the image that Colorbox should open.
  * - $class: A set of classes assigned to this image (if any).
+ * - $width: The width of the image (if known).
+ * - $height: The height of the image (if known).
+ * - $style_name: The Image style being used.
  * - $gallery_id: The ID of the Colorbox gallery.
  *
  * Note that ALT and Title fields should not be filled in here, instead they
@@ -19,6 +22,11 @@
  * - __alt__: The ALT text, intended for use in the <img> tag.
  * - __title__: The Title text, intended for use in the <img> tag.
  * - __description__: A description of the image, sometimes used as a caption.
+ * - __filename__: The file name.
+ * - __[token]_or_filename__: Any of the above tokens if available, otherwise
+ *   use the file's name. i.e. __title_or_filename__.
  */
 ?>
-<a href="<?php print $link_path; ?>" title="__title__" class="colorbox colorbox-insert-image" rel="<?php print $gallery_id; ?>"><img typeof="foaf:Image" src="<?php print $image_path; ?>" alt="__alt__" title="__title__" class="<?php print $class; ?>" /></a>
+<a href="<?php print $path; ?>" title="__title__" class="colorbox colorbox-insert-image" data-colorbox-gallery="<?php print $gallery_id; ?>">
+  <img src="<?php print $url; ?>" <?php if ($width && $height): ?>width="<?php print $width; ?>" height="<?php print $height; ?>" <?php endif; ?>alt="__alt__" title="__title__" class="<?php print $class; ?>" />
+</a>

+ 30 - 4
sites/all/modules/colorbox/colorbox.admin.inc

@@ -44,7 +44,7 @@ function colorbox_admin_settings() {
     '#type' => 'checkbox',
     '#title' => t('Enable Colorbox load'),
     '#default_value' => variable_get('colorbox_load', 0),
-    '#description' => t('This enables custom links that can open forms and paths in a Colorbox. Add the class "colorbox-load" to the link and build the url like this for forms "/colorbox/form/[form_id]?destination=some_path&width=500&height=500" and like this for paths "[path]?width=500&height=500&iframe=true" or "[path]?width=500&height=500" if you don\'t want an iframe. Other modules may activate this for easy Colorbox integration.'),
+    '#description' => t('This enables custom links that can open forms and paths in a Colorbox. Add the class "colorbox-load" to the link and build the url like this for paths "[path]?width=500&height=500&iframe=true" or "[path]?width=500&height=500" if you don\'t want an iframe. Other modules may activate this for easy Colorbox integration.'),
   );
   $form['colorbox_extra_features']['colorbox_inline'] = array(
     '#type' => 'checkbox',
@@ -143,7 +143,7 @@ function colorbox_admin_settings() {
     '#type' => 'checkbox',
     '#title' => t('Overlay close'),
     '#default_value' => variable_get('colorbox_overlayclose', 1),
-    '#description' => t('Enable closing ColorBox by clicking on the background overlay.'),
+    '#description' => t('Enable closing Colorbox by clicking on the background overlay.'),
   );
   $form['colorbox_custom_settings']['colorbox_maxwidth'] = array(
     '#type' => 'textfield',
@@ -177,7 +177,7 @@ function colorbox_admin_settings() {
     '#type' => 'checkbox',
     '#title' => t('Fixed'),
     '#default_value' => variable_get('colorbox_fixed', 1),
-    '#description' => t('If the ColorBox should be displayed in a fixed position within the visitor\'s viewport or relative to the document.'),
+    '#description' => t('If the Colorbox should be displayed in a fixed position within the visitor\'s viewport or relative to the document.'),
   );
 
   $form['colorbox_custom_settings']['colorbox_slideshow_settings'] = array(
@@ -198,7 +198,7 @@ function colorbox_admin_settings() {
   $form['colorbox_custom_settings']['colorbox_scrolling'] = array(
     '#type' => 'radios',
     '#title' => t('Scrollbars'),
-    '#options' => array(0 => t('Off'), 1 => t('On')),
+    '#options' => array(1 => t('On'), 0 => t('Off')),
     '#default_value' => variable_get('colorbox_scrolling', 1),
     '#description' => t('If false, Colorbox will hide scrollbars for overflowing content. This could be used on conjunction with the resize method for a smoother transition if you are appending content to an already open instance of Colorbox.'),
   );
@@ -250,6 +250,32 @@ function colorbox_admin_settings() {
     '#collapsible' => TRUE,
     '#collapsed' => TRUE,
   );
+  $form['colorbox_advanced_settings']['colorbox_unique_token'] = array(
+    '#type' => 'radios',
+    '#title' => t('Unique per-request gallery token'),
+    '#options' => array(1 => t('On'), 0 => t('Off')),
+    '#default_value' => variable_get('colorbox_unique_token', 1),
+    '#description' => t('If On (default), Colorbox will add a unique per-request token to the gallery id to avoid images being added manually to galleries. The token was added as a security fix but some see the old behavoiur as an feature and this settings makes it possible to remove the token.'),
+  );
+  $form['colorbox_advanced_settings']['colorbox_mobile_detect'] = array(
+    '#type' => 'radios',
+    '#title' => t('Mobile detection'),
+    '#options' => array(1 => t('On'), 0 => t('Off')),
+    '#default_value' => variable_get('colorbox_mobile_detect', 1),
+    '#description' => t('If On (default), Colorbox will not be active for devices with the max width set below.'),
+  );
+  $form['colorbox_advanced_settings']['colorbox_mobile_device_width'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Device with'),
+    '#default_value' => variable_get('colorbox_mobile_device_width', '480px'),
+    '#size' => 30,
+    '#description' => t('Set the mobile device max with. Default: 480px.'),
+    '#states' => array(
+      'visible' => array(
+        ':input[name="colorbox_mobile_detect"]' => array('value' => '1'),
+      ),
+    ),
+  );
   $form['colorbox_advanced_settings']['colorbox_caption_trim'] = array(
     '#type' => 'radios',
     '#title' => t('Caption shortening'),

+ 17 - 2
sites/all/modules/colorbox/colorbox.api.php

@@ -10,11 +10,11 @@
  *
  * Implements hook_colorbox_settings_alter().
  *
- * @param $settings
+ * @param array $settings
  *   An associative array of Colorbox settings. See the
  *   @link http://colorpowered.com/colorbox/ Colorbox documentation @endlink
  *   for the full list of supported parameters.
- * @param $style
+ * @param string $style
  *   The name of the active style plugin. If $style is 'none', no Colorbox
  *   theme will be loaded.
  */
@@ -27,3 +27,18 @@ function hook_colorbox_settings_alter(&$settings, &$style) {
     $style = 'mystyle';
   }
 }
+
+/**
+ * Allows to override activation of Colorbox for the current URL.
+ *
+ * @param bool $active
+ *   A boolean indicating whether colorbox should be active for the current
+ *   URL or not.
+ */
+function hook_colorbox_active_alter(&$active) {
+  $path = drupal_get_path_alias($_GET['q']);
+  if (drupal_match_path($path, 'admin/config/colorbox_test')) {
+    // Enable colorbox for this URL.
+    $active = TRUE;
+  }
+}

+ 4 - 4
sites/all/modules/colorbox/colorbox.info

@@ -1,14 +1,14 @@
 name = Colorbox
 description = A light-weight, customizable lightbox plugin for jQuery 1.4.3+.
-dependencies[] = libraries (2.x)
+dependencies[] = libraries (>=2.x)
 core = 7.x
 configure = admin/config/media/colorbox
 
 files[] = views/colorbox_handler_field_colorbox.inc
 
-; Information added by drupal.org packaging script on 2013-02-13
-version = "7.x-2.3+2-dev"
+; Information added by Drupal.org packaging script on 2016-06-06
+version = "7.x-2.12"
 core = "7.x"
 project = "colorbox"
-datestamp = "1360716175"
+datestamp = "1465255741"
 

+ 5 - 3
sites/all/modules/colorbox/colorbox.install

@@ -14,13 +14,15 @@ function colorbox_requirements($phase) {
   if ($phase == 'runtime') {
     $t = get_t();
     $library = libraries_detect('colorbox');
+    $error_type = isset($library['error']) ? drupal_ucfirst($library['error']) : '';
+    $error_message = isset($library['error message']) ? $library['error message'] : '';
 
     if (empty($library['installed'])) {
       $requirements['colorbox_plugin'] = array(
         'title' => $t('Colorbox plugin'),
-        'value' => $t('At least @a', array('@a' => COLORBOX_MIN_PLUGIN_VERSION)),
+        'value' => $t('@e: At least @a', array('@e' => $error_type, '@a' => COLORBOX_MIN_PLUGIN_VERSION)),
         'severity' => REQUIREMENT_ERROR,
-        'description' => $t('You need to download the !colorbox, extract the archive and place the colorbox directory in the %path directory on your server.', array('!colorbox' => l($t('Colorbox plugin'), $library['download url']), '%path' => 'sites/all/libraries')),
+        'description' => $t('!error You need to download the !colorbox, extract the archive and place the colorbox directory in the %path directory on your server.', array('!error' => $error_message, '!colorbox' => l($t('Colorbox plugin'), $library['download url']), '%path' => 'sites/all/libraries')),
       );
     }
     elseif (version_compare($library['version'], COLORBOX_MIN_PLUGIN_VERSION, '>=')) {
@@ -47,7 +49,7 @@ function colorbox_requirements($phase) {
  * Implements hook_uninstall().
  */
 function colorbox_uninstall() {
-  db_query("DELETE FROM {variable} WHERE name LIKE 'colorbox_%'");
+  db_delete('variable')->condition('name', db_like('colorbox_') . '%', 'LIKE')->execute();
 }
 
 /**

+ 8 - 0
sites/all/modules/colorbox/colorbox.make

@@ -0,0 +1,8 @@
+core = 7.x
+api = 2
+
+libraries[colorbox][type] = "libraries"
+libraries[colorbox][download][type] = "file"
+libraries[colorbox][download][url] = "https://github.com/jackmoore/colorbox/archive/1.x.zip"
+libraries[colorbox][directory_name] = "colorbox"
+libraries[colorbox][destination] = "libraries"

+ 0 - 9
sites/all/modules/colorbox/colorbox.make.example

@@ -1,9 +0,0 @@
-; $Id$
-
-core = 7.x
-api = 2
-
-libraries[colorbox][download][type] = "get"
-libraries[colorbox][download][url] = "http://colorpowered.com/colorbox/colorbox.zip"
-libraries[colorbox][directory_name] = "colorbox"
-libraries[colorbox][destination] = "libraries"

+ 58 - 27
sites/all/modules/colorbox/colorbox.module

@@ -6,9 +6,9 @@
  */
 
 /**
- * The default path to the Colorbox directory.
+ * The minimum required version of the Colorbox plugin.
  */
-define('COLORBOX_MIN_PLUGIN_VERSION', '1.3.21.1');
+define('COLORBOX_MIN_PLUGIN_VERSION', '1.6.1');
 
 
 /**
@@ -32,6 +32,7 @@ function colorbox_theme() {
         'widget' => NULL,
       ),
       'template' => 'colorbox-insert-image',
+      'pattern' => 'colorbox_insert_image__[a-z0-9_]+',
       'file' => 'colorbox.theme.inc',
     ),
 
@@ -43,6 +44,7 @@ function colorbox_theme() {
         'node' => NULL,  // Left for legacy support.
         'field' => array(),
         'display_settings' => array(),
+        'delta' => null,
       ),
       'file' => 'colorbox.theme.inc',
     ),
@@ -54,8 +56,8 @@ function colorbox_theme() {
  */
 function colorbox_init() {
   // Do not load colorbox during the Drupal installation process, e.g. if part
-  // of installation profiles.
-  if (!drupal_installation_attempted()) {
+  // of installation profiles. Only add the JavaScript and CSS on specified paths.
+  if (!drupal_installation_attempted() && _colorbox_active()) {
     _colorbox_doheader();
   }
 }
@@ -77,10 +79,10 @@ function colorbox_libraries_info() {
   $libraries['colorbox'] = array(
     'name' => 'Colorbox plugin',
     'vendor url' => 'http://www.jacklmoore.com/colorbox',
-    'download url' => 'http://www.jacklmoore.com/colorbox',
+    'download url' => 'https://github.com/jackmoore/colorbox/archive/1.x.zip',
     'version arguments' => array(
       'file' => 'jquery.colorbox-min.js',
-      'pattern' => '@ColorBox v([0-9\.a-z]+)@',
+      'pattern' => '@(?i:Colorbox)\sv?([0-9\.a-z]+)@',
       'lines' => 5,
     ),
     'files' => array(
@@ -130,7 +132,7 @@ function colorbox_menu() {
 /**
  * Check if Colorbox should be active for the current URL.
  *
- * @return
+ * @return bool
  *   TRUE if Colorbox should be active for the current page.
  */
 function _colorbox_active() {
@@ -140,7 +142,7 @@ function _colorbox_active() {
     return FALSE;
   }
 
-  // Code from the block_list funtion in block.module.
+  // Code from the block_list function in block.module.
   $path = drupal_get_path_alias($_GET['q']);
   $colorbox_pages = variable_get('colorbox_pages', "admin*\nimagebrowser*\nimg_assist*\nimce*\nnode/add/*\nnode/*/edit\nprint/*\nprintpdf/*\nsystem/ajax\nsystem/ajax/*");
   // Compare with the internal and path alias (if any).
@@ -150,6 +152,9 @@ function _colorbox_active() {
   }
   $page_match = variable_get('colorbox_visibility', 0) == 0 ? !$page_match : $page_match;
 
+  // Allow other modules to change the state of colorbox for the current URL.
+  drupal_alter('colorbox_active', $page_match);
+
   return $page_match;
 }
 
@@ -161,9 +166,6 @@ function _colorbox_doheader() {
   if ($already_added) {
     return; // Don't add the JavaScript and CSS multiple times.
   }
-  if (!_colorbox_active()) {
-    return; // Don't add the JavaScript and CSS on specified paths.
-  }
 
   // Insert options and translated strings as javascript settings.
   if (variable_get('colorbox_custom_settings_activate', 0)) {
@@ -176,10 +178,10 @@ function _colorbox_doheader() {
       'slideshowSpeed' => variable_get('colorbox_slideshowspeed', 2500),
       'slideshowStart' => variable_get('colorbox_text_start', 'start slideshow'),
       'slideshowStop' => variable_get('colorbox_text_stop', 'stop slideshow'),
-      'current' => variable_get('colorbox_text_current', '{current} of {total}'),
-      'previous' => variable_get('colorbox_text_previous', '« Prev'),
-      'next' => variable_get('colorbox_text_next', 'Next »'),
-      'close' => variable_get('colorbox_text_close', 'Close'),
+      'current' => strip_tags(variable_get('colorbox_text_current', '{current} of {total}')),
+      'previous' => strip_tags(variable_get('colorbox_text_previous', '« Prev')),
+      'next' => strip_tags(variable_get('colorbox_text_next', 'Next »')),
+      'close' => strip_tags(variable_get('colorbox_text_close', 'Close')),
       'overlayClose' => variable_get('colorbox_overlayclose', 1) ? TRUE : FALSE,
       'maxWidth' => variable_get('colorbox_maxwidth', '98%'),
       'maxHeight' => variable_get('colorbox_maxheight', '98%'),
@@ -187,6 +189,8 @@ function _colorbox_doheader() {
       'initialHeight' => variable_get('colorbox_initialheight', '250'),
       'fixed' => variable_get('colorbox_fixed', 1) ? TRUE : FALSE,
       'scrolling' => variable_get('colorbox_scrolling', 1) ? TRUE : FALSE,
+      'mobiledetect' => variable_get('colorbox_mobile_detect', 1) ? TRUE : FALSE,
+      'mobiledevicewidth' => variable_get('colorbox_mobile_device_width', '480px'),
     );
   }
   else {
@@ -199,6 +203,8 @@ function _colorbox_doheader() {
       'maxWidth' => '98%',
       'maxHeight' => '98%',
       'fixed' => TRUE,
+      'mobiledetect' => variable_get('colorbox_mobile_detect', 1) ? TRUE : FALSE,
+      'mobiledevicewidth' => variable_get('colorbox_mobile_device_width', '480px'),
     );
   }
 
@@ -213,7 +219,9 @@ function _colorbox_doheader() {
 
   // Add and initialise the Colorbox plugin.
   $variant = variable_get('colorbox_compression_type', 'minified');
-  libraries_load('colorbox', $variant);
+  if (module_exists('libraries')) {
+    libraries_load('colorbox', $variant);
+  }
   drupal_add_js($path . '/js/colorbox.js');
 
   // Add JS and CSS based on selected style.
@@ -251,6 +259,7 @@ function colorbox_field_formatter_info() {
       'field types' => array('image'),
       'settings' => array(
         'colorbox_node_style' => '',
+        'colorbox_node_style_first' => '',
         'colorbox_image_style' => '',
         'colorbox_gallery' => 'post',
         'colorbox_gallery_custom' => '',
@@ -280,6 +289,14 @@ function colorbox_field_formatter_settings_form($field, $instance, $view_mode, $
     '#options' => $image_styles_hide,
     '#description' => t('Image style to use in the content.'),
   );
+  $element['colorbox_node_style_first'] = array(
+    '#title' => t('Content image style for first image'),
+    '#type' => 'select',
+    '#default_value' => $settings['colorbox_node_style_first'],
+    '#empty_option' => t('No special style.'),
+    '#options' => $image_styles,
+    '#description' => t('Image style to use in the content for the first image.'),
+  );
   $element['colorbox_image_style'] = array(
     '#title' => t('Colorbox image style'),
     '#type' => 'select',
@@ -306,15 +323,12 @@ function colorbox_field_formatter_settings_form($field, $instance, $view_mode, $
   );
   $element['colorbox_gallery_custom'] = array(
     '#title' => t('Custom gallery'),
-    '#type' => 'machine_name',
+    '#type' => 'textfield',
     '#maxlength' => 32,
     '#default_value' => $settings['colorbox_gallery_custom'],
-    '#description' => t('All images on a page with the same gallery value (rel attribute) will be grouped together. It must only contain lowercase letters, numbers, and underscores.'),
+    '#description' => t('All images on a page with the same gallery value (rel attribute) will be grouped together. It must only contain lowercase letters, numbers, hyphen and underscores.'),
+    '#element_validate' => array('colorbox_gallery_custom_validate'),
     '#required' => FALSE,
-    '#machine_name' => array(
-      'exists' => 'colorbox_gallery_exists',
-      'error' => t('The custom gallery field must only contain lowercase letters, numbers, and underscores.'),
-    ),
     '#states' => array(
       'visible' => array(
         ':input[name$="[settings_edit_form][settings][colorbox_gallery]"]' => array('value' => 'custom'),
@@ -335,7 +349,7 @@ function colorbox_field_formatter_settings_form($field, $instance, $view_mode, $
     '#type' => 'select',
     '#default_value' => $settings['colorbox_caption'],
     '#options' => $caption,
-    '#description' => t('Automatic will use the first none empty value of the title, the alt text and the content title.'),
+    '#description' => t('Automatic will use the first non-empty value of the title, the alt text and the content title.'),
   );
   $element['colorbox_caption_custom'] = array(
     '#title' => t('Custom caption'),
@@ -354,7 +368,7 @@ function colorbox_field_formatter_settings_form($field, $instance, $view_mode, $
       '#type' => 'fieldset',
       '#title' => t('Replacement patterns'),
       '#theme' => 'token_tree',
-      '#token_types' => array($instance['entity_type'], 'file'),
+      '#token_types' => array_merge(array_keys($field['bundles']),array('file')),
       '#recursion_limit' => $recursion_limit,
       '#dialog' => TRUE,
       '#states' => array(
@@ -381,6 +395,15 @@ function colorbox_field_formatter_settings_form($field, $instance, $view_mode, $
 }
 
 /**
+ * Validate function for colorbox_gallery_custom.
+ */
+function colorbox_gallery_custom_validate($element, &$form_state) {
+  if (!empty($element['#value']) && !preg_match('!^[a-z0-9_-]+$!', $element['#value'])) {
+    form_error($element, t('%name must only contain lowercase letters, numbers, hyphen and underscores.', array('%name' => $element['#title'])));
+  }
+}
+
+/**
  * Implements hook_field_formatter_settings_summary().
  */
 function colorbox_field_formatter_settings_summary($field, $instance, $view_mode) {
@@ -404,6 +427,10 @@ function colorbox_field_formatter_settings_summary($field, $instance, $view_mode
     $summary[] = t('Content image style: Original image');
   }
 
+  if (isset($image_styles[$settings['colorbox_node_style_first']])) {
+    $summary[] = t('Content image style of first image: @style', array('@style' => $image_styles[$settings['colorbox_node_style_first']]));
+  }
+
   if (isset($image_styles[$settings['colorbox_image_style']])) {
     $summary[] = t('Colorbox image style: @style', array('@style' => $image_styles[$settings['colorbox_image_style']]));
   }
@@ -455,6 +482,7 @@ function colorbox_field_formatter_view($entity_type, $entity, $field, $instance,
         '#node' => $entity, // Left for legacy support.
         '#field' => $field,
         '#display_settings' => $display['settings'],
+        '#delta' => $delta,
       );
     }
   }
@@ -464,11 +492,14 @@ function colorbox_field_formatter_view($entity_type, $entity, $field, $instance,
 
 /**
  * Implements hook_insert_styles().
+ *
+ * @return array
  */
 function colorbox_insert_styles() {
   $insert_styles = array();
   foreach (image_styles() as $key => $style) {
-    $insert_styles['colorbox__' . $key] = array('label' => t('Colorbox @style', array('@style' => $style['name'])));
+    $label = isset($style['label']) ? $style['label'] : $style['name'];
+    $insert_styles['colorbox__' . $key] = array('label' => t('Colorbox @style', array('@style' => $label)));
   }
 
   return $insert_styles;
@@ -479,13 +510,13 @@ function colorbox_insert_styles() {
  */
 function colorbox_insert_content($item, $style, $widget) {
   list($item['module_name'], $item['style_name']) = explode('__', $style['name'], 2);
-  return theme('colorbox_insert_image', array('item' => $item, 'widget' => $widget));
+  return theme(array('colorbox_insert_image__' . str_replace('-', '_', $item['style_name']), 'colorbox_insert_image'), array('item' => $item, 'widget' => $widget));
 }
 
 /**
  * Machine names normally need to be unique but that does not apply to galleries.
  *
- * @return
+ * @return false
  *   Always FALSE
  */
 function colorbox_gallery_exists() {

+ 75 - 16
sites/all/modules/colorbox/colorbox.theme.inc

@@ -8,15 +8,19 @@
 /**
  * Returns HTML for an Colorbox image field formatter.
  *
- * @param $variables
+ * @param array $variables
  *   An associative array containing:
  *   - item: An array of image data.
  *   - image_style: An optional image style.
  *   - path: An array containing the link 'path' and link 'options'.
  *
+ * @return string
+ *   An HTML string representing the themed output.
+ *
  * @ingroup themeable
  */
 function theme_colorbox_image_formatter($variables) {
+  static $gallery_token = NULL;
   $item = $variables['item'];
   $entity_type = $variables['entity_type'];
   $entity = $variables['entity'];
@@ -25,16 +29,40 @@ function theme_colorbox_image_formatter($variables) {
 
   $image = array(
     'path' => $item['uri'],
-    'alt' => $item['alt'],
-    'title' => $item['title'],
+    'alt' => isset($item['alt']) ? $item['alt'] : '',
+    'title' => isset($item['title']) ? $item['title'] : '',
     'style_name' => $settings['colorbox_node_style'],
   );
 
+  if ($variables['delta'] == 0 && !empty($settings['colorbox_node_style_first'])) {
+    $image['style_name'] = $settings['colorbox_node_style_first'];
+  }
+
   if (isset($item['width']) && isset($item['height'])) {
     $image['width'] = $item['width'];
     $image['height'] = $item['height'];
   }
 
+  if (isset($item['attributes'])) {
+    $image['attributes'] = $item['attributes'];
+  }
+
+  // Allow image attributes to be overridden.
+  if (isset($variables['item']['override']['attributes'])) {
+    foreach (array('width', 'height', 'alt', 'title') as $key) {
+      if (isset($variables['item']['override']['attributes'][$key])) {
+        $image[$key] = $variables['item']['override']['attributes'][$key];
+        unset($variables['item']['override']['attributes'][$key]);
+      }
+    }
+    if (isset($image['attributes'])) {
+      $image['attributes'] = $variables['item']['override']['attributes'] + $image['attributes'];
+    }
+    else {
+      $image['attributes'] = $variables['item']['override']['attributes'];
+    }
+  }
+
   $entity_title = entity_label($entity_type, $entity);
 
   switch ($settings['colorbox_caption']) {
@@ -99,6 +127,16 @@ function theme_colorbox_image_formatter($variables) {
       $gallery_id = '';
   }
 
+  // If gallery id is not empty add unique per-request token to avoid images being added manually to galleries.
+  if (!empty($gallery_id) && variable_get('colorbox_unique_token', 1)) {
+    // Check if gallery token has already been set, we need to reuse the token for the whole request.
+    if (is_null($gallery_token)) {
+      // We use a short token since randomness is not critical.
+      $gallery_token = drupal_random_key(8);
+    }
+    $gallery_id = $gallery_id . '-' . $gallery_token;
+  }
+
   if ($style_name = $settings['colorbox_image_style']) {
     $path = image_style_url($style_name, $image['path']);
   }
@@ -112,13 +150,16 @@ function theme_colorbox_image_formatter($variables) {
 /**
  * Returns HTML for an image using a specific Colorbox image style.
  *
- * @param $variables
+ * @param array $variables
  *   An associative array containing:
  *   - image: image item as array.
  *   - path: The path of the image that should be displayed in the Colorbox.
  *   - title: The title text that will be used as a caption in the Colorbox.
  *   - gid: Gallery id for Colorbox image grouping.
  *
+ * @return string
+ *   An HTML string containing a link to the given path.
+ *
  * @ingroup themeable
  */
 function theme_colorbox_imagefield($variables) {
@@ -135,45 +176,63 @@ function theme_colorbox_imagefield($variables) {
     $image = theme('image', $variables['image']);
   }
 
-  $options = array(
+  $options = drupal_parse_url($variables['path']);
+  $options += array(
     'html' => TRUE,
     'attributes' => array(
       'title' => $variables['title'],
       'class' => $class,
-      'rel' => $variables['gid'],
-    )
+      'data-colorbox-gallery' => $variables['gid'],
+    ),
   );
 
-  return l($image, $variables['path'], $options);
+  return l($image, $options['path'], $options);
 }
 
 /**
  * Preprocess variables for the colorbox-insert-image.tpl.php file.
+ *
+ * @param array $variables
  */
 function template_preprocess_colorbox_insert_image(&$variables) {
-  $class = array();
-  $file = file_load($variables['item']['fid']);
+  $item = $variables['item'];
+  $variables['file'] = file_load($item['fid']);
+  $variables['style_name'] = $item['style_name'];
+  $variables['width'] = isset($item['width']) ? $item['width'] : NULL;
+  $variables['height'] = isset($item['height']) ? $item['height'] : NULL;
 
+  // Determine dimensions of the image after the image style transformations.
+  image_style_transform_dimensions($variables['style_name'], $variables);
+
+  $class = array();
   if (!empty($variables['widget']['settings']['insert_class'])) {
     $class = explode(' ', $variables['widget']['settings']['insert_class']);
   }
-  $class[] = 'image-' . $variables['item']['style_name'];
+  $class[] = 'image-' . $variables['style_name'];
 
   foreach ($class as $key => $value) {
     $class[$key] = drupal_html_class($value);
   }
 
-  $variables['image_path'] = image_style_url($variables['item']['style_name'], $file->uri);
+  $variables['class'] = implode(' ', $class);
+
+  $variables['uri'] = image_style_path($variables['style_name'], $variables['file']->uri);
+  $absolute = isset($variables['widget']['settings']['insert_absolute']) ? $variables['widget']['settings']['insert_absolute'] : NULL;
+  $variables['url'] = insert_create_url($variables['uri'], $absolute, variable_get('clean_url'));
+
+  // http://drupal.org/node/1923336
+  if (function_exists('image_style_path_token')) {
+    $token_query = array(IMAGE_DERIVATIVE_TOKEN => image_style_path_token($variables['style_name'], $variables['file']->uri));
+    $variables['url'] .= (strpos($variables['url'], '?') !== FALSE ? '&' : '?') . drupal_http_build_query($token_query);
+  }
 
   if ($style_name = variable_get('colorbox_image_style', '')) {
-    $variables['link_path'] = image_style_url($style_name, $file->uri);
+    $variables['path'] = image_style_url($style_name, $variables['file']->uri);
   }
   else {
-    $variables['link_path'] = file_create_url($file->uri);
+    $variables['path'] = file_create_url($variables['file']->uri);
   }
 
-  $variables['class'] = implode(' ', $class);
-
   $variables['gallery_id'] = '';
   switch (variable_get('colorbox_insert_gallery', 0)) {
     case 0:

+ 11 - 11
sites/all/modules/colorbox/drush/colorbox.drush.inc

@@ -23,7 +23,7 @@ define('COLORBOX_DOWNLOAD_PREFIX', 'colorbox-');
  *
  * See `drush topic docs-commands` for a list of recognized keys.
  *
- * @return
+ * @return array
  *   An associative array describing your command(s).
  */
 function colorbox_drush_command() {
@@ -49,10 +49,10 @@ function colorbox_drush_command() {
  * This function is called whenever a drush user calls
  * 'drush help <name-of-your-command>'
  *
- * @param
+ * @param string $section
  *   A string with the help section (prepend with 'drush:')
  *
- * @return
+ * @return string
  *   A string with the help text for your command.
  */
 function colorbox_drush_help($section) {
@@ -63,14 +63,14 @@ function colorbox_drush_help($section) {
 }
 
 /**
- * Implements drush_MODULE_post_pm_enable().
+ * Implements drush_MODULE_pre_pm_enable().
  */
-// function drush_colorbox_post_pm_enable() {
-//   $modules = func_get_args();
-//   if (in_array('colorbox', $modules)) {
-//     drush_colorbox_plugin();
-//   }
-// }
+function drush_colorbox_pre_pm_enable() {
+   $modules = drush_get_context('PM_ENABLE_MODULES');
+   if (in_array('colorbox', $modules) && !drush_get_option('skip')) {
+     drush_colorbox_plugin();
+   }
+}
 
 /**
  * Command to download the Colorbox plugin.
@@ -99,7 +99,7 @@ function drush_colorbox_plugin() {
     $filename = basename($filepath);
     $dirname = COLORBOX_DOWNLOAD_PREFIX . basename($filepath, '.zip');
 
-     // Remove any existing Colorbox plugin directory
+    // Remove any existing Colorbox plugin directory
     if (is_dir($dirname) || is_dir('colorbox')) {
       drush_delete_dir($dirname, TRUE);
       drush_delete_dir('colorbox', TRUE);

+ 24 - 7
sites/all/modules/colorbox/js/colorbox.js

@@ -2,19 +2,36 @@
 
 Drupal.behaviors.initColorbox = {
   attach: function (context, settings) {
-    if (!$.isFunction($.colorbox)) {
+    if (!$.isFunction($.colorbox) || typeof settings.colorbox === 'undefined') {
       return;
     }
+
+    if (settings.colorbox.mobiledetect && window.matchMedia) {
+      // Disable Colorbox for small screens.
+      var mq = window.matchMedia("(max-device-width: " + settings.colorbox.mobiledevicewidth + ")");
+      if (mq.matches) {
+        return;
+      }
+    }
+
+    // Use "data-colorbox-gallery" if set otherwise use "rel".
+    settings.colorbox.rel = function () {
+      if ($(this).data('colorbox-gallery')) {
+        return $(this).data('colorbox-gallery');
+      }
+      else {
+        return $(this).attr('rel');
+      }
+    };
+
     $('.colorbox', context)
       .once('init-colorbox')
       .colorbox(settings.colorbox);
+
+    $(context).bind('cbox_complete', function () {
+      Drupal.attachBehaviors('#cboxLoadedContent');
+    });
   }
 };
 
-{
-  $(document).bind('cbox_complete', function () {
-    Drupal.attachBehaviors('#cboxLoadedContent');
-  });
-}
-
 })(jQuery);

+ 10 - 1
sites/all/modules/colorbox/js/colorbox_inline.js

@@ -2,9 +2,18 @@
 
 Drupal.behaviors.initColorboxInline = {
   attach: function (context, settings) {
-    if (!$.isFunction($.colorbox)) {
+    if (!$.isFunction($.colorbox) || typeof settings.colorbox === 'undefined') {
       return;
     }
+
+    if (settings.colorbox.mobiledetect && window.matchMedia) {
+      // Disable Colorbox for small screens.
+      var mq = window.matchMedia("(max-device-width: " + settings.colorbox.mobiledevicewidth + ")");
+      if (mq.matches) {
+        return;
+      }
+    }
+
     $.urlParam = function(name, url){
       if (name == 'fragment') {
         var results = new RegExp('(#[^&#]*)').exec(url);

+ 10 - 1
sites/all/modules/colorbox/js/colorbox_load.js

@@ -2,9 +2,18 @@
 
 Drupal.behaviors.initColorboxLoad = {
   attach: function (context, settings) {
-    if (!$.isFunction($.colorbox)) {
+    if (!$.isFunction($.colorbox) || typeof settings.colorbox === 'undefined') {
       return;
     }
+
+    if (settings.colorbox.mobiledetect && window.matchMedia) {
+      // Disable Colorbox for small screens.
+      var mq = window.matchMedia("(max-device-width: " + settings.colorbox.mobiledevicewidth + ")");
+      if (mq.matches) {
+        return;
+      }
+    }
+
     $.urlParams = function (url) {
       var p = {},
           e,

+ 33 - 11
sites/all/modules/colorbox/styles/default/colorbox_style.css

@@ -1,5 +1,5 @@
 /**
- * ColorBox Core Style:
+ * Colorbox Core Style:
  * The following CSS is consistent between example themes and should not be altered.
  */
 #colorbox, #cboxOverlay, #cboxWrapper {
@@ -22,6 +22,7 @@
 }
 #cboxLoadedContent {
   overflow: auto;
+  -webkit-overflow-scrolling: touch;
 }
 #cboxTitle {
   margin: 0;
@@ -33,9 +34,26 @@
   width: 100%;
   height: 100%;
 }
+/**
+ * These elements are buttons, and may need to have additional
+ * styles reset to avoid unwanted base styles.
+ */
 #cboxPrevious, #cboxNext, #cboxClose, #cboxSlideshow {
+  border: 0;
+  padding: 0;
+  margin: 0;
+  overflow: visible;
+  width: auto;
+  background: none;
   cursor: pointer;
 }
+/**
+ * Avoid outlines on :active (mouseclick),
+ * but preserve outlines on :focus (tabbed navigating)
+ */
+#cboxPrevious:active, #cboxNext:active, #cboxClose:active, #cboxSlideshow:active {
+  outline: 0;
+}
 .cboxPhoto {
   float: left;
   margin: auto;
@@ -49,8 +67,10 @@
   display: block;
   border: 0;
 }
+/* Reset box sizing to content-box if theme is using border-box. */
 #colorbox, #cboxContent, #cboxLoadedContent {
   -moz-box-sizing: content-box;
+  -webkit-box-sizing: content-box;
   box-sizing: content-box;
 }
 
@@ -62,8 +82,9 @@
 #cboxOverlay {
   background: #000;
 }
-
-#colorBox {}
+#colorbox {
+  outline: 0;
+}
   #cboxWrapper {
     background: #fff;
     -moz-border-radius: 5px;
@@ -101,7 +122,6 @@
     #cboxContent {
       background: #fff;
       overflow: hidden;
-      font: 12px "Lucida Grande", Verdana, Arial, sans-serif;
     }
       #cboxError {
         padding: 50px;
@@ -118,6 +138,8 @@
         color: #535353;
         width: 100%;
         padding: 4px 6px;
+        -moz-box-sizing: border-box;
+        -webkit-box-sizing: border-box;
         box-sizing: border-box;
       }
       #cboxCurrent {
@@ -130,7 +152,7 @@
         position: absolute;
         bottom: 0px;
         right: 30px;
-        background: url(images/controls.png) -75px -50px no-repeat;
+        background: url(images/controls.png) no-repeat -75px -50px;
         width: 25px;
         height: 25px;
         text-indent: -9999px;
@@ -142,19 +164,19 @@
         position: absolute;
         bottom: 0px;
         right: 30px;
-        background: url(images/controls.png) -49px -50px no-repeat;
+        background: url(images/controls.png) no-repeat -25px -50px;
         width: 25px;
         height: 25px;
         text-indent: -9999px;
       }
       .cboxSlideshow_off #cboxSlideshow:hover {
-        background-position: -25px -50px;
+        background-position: -49px -50px;
       }
       #cboxPrevious {
         position: absolute;
         bottom: 0;
         left: 0;
-        background: url(images/controls.png) -75px 0px no-repeat;
+        background: url(images/controls.png) no-repeat -75px 0px;
         width: 25px;
         height: 25px;
         text-indent: -9999px;
@@ -166,7 +188,7 @@
         position: absolute;
         bottom: 0;
         left: 27px;
-        background: url(images/controls.png) -50px 0px no-repeat;
+        background: url(images/controls.png) no-repeat -50px 0px;
         width: 25px;
         height: 25px;
         text-indent: -9999px;
@@ -178,13 +200,13 @@
         background: #fff;
       }
       #cboxLoadingGraphic {
-        background: url(images/loading_animation.gif) center center no-repeat;
+        background: url(images/loading_animation.gif) no-repeat center center;
       }
       #cboxClose {
         position: absolute;
         bottom: 0;
         right: 0;
-        background: url(images/controls.png) -25px 0px no-repeat;
+        background: url(images/controls.png) no-repeat -25px 0px;
         width: 25px;
         height: 25px;
         text-indent: -9999px;

+ 1 - 2
sites/all/modules/colorbox/styles/default/colorbox_style.js

@@ -2,10 +2,9 @@
 
 Drupal.behaviors.initColorboxDefaultStyle = {
   attach: function (context, settings) {
-    $(document).bind('cbox_complete', function () {
+    $(context).bind('cbox_complete', function () {
       // Only run if there is a title.
       if ($('#cboxTitle:empty', context).length == false) {
-        setTimeout(function () { $('#cboxTitle', context).slideUp() }, 1500);
         $('#cboxLoadedContent img', context).bind('mouseover', function () {
           $('#cboxTitle', context).slideDown();
         });

+ 28 - 7
sites/all/modules/colorbox/styles/plain/colorbox_style.css

@@ -1,5 +1,5 @@
 /**
- * ColorBox Core Style:
+ * Colorbox Core Style:
  * The following CSS is consistent between example themes and should not be altered.
  */
 #colorbox, #cboxOverlay, #cboxWrapper {
@@ -22,6 +22,7 @@
 }
 #cboxLoadedContent {
   overflow: auto;
+  -webkit-overflow-scrolling: touch;
 }
 #cboxTitle {
   margin: 0;
@@ -33,9 +34,26 @@
   width: 100%;
   height: 100%;
 }
+/**
+ * These elements are buttons, and may need to have additional
+ * styles reset to avoid unwanted base styles.
+ */
 #cboxPrevious, #cboxNext, #cboxClose, #cboxSlideshow {
+  border: 0;
+  padding: 0;
+  margin: 0;
+  overflow: visible;
+  width: auto;
+  background: none;
   cursor: pointer;
 }
+/**
+ * Avoid outlines on :active (mouseclick),
+ * but preserve outlines on :focus (tabbed navigating)
+ */
+#cboxPrevious:active, #cboxNext:active, #cboxClose:active, #cboxSlideshow:active {
+  outline: 0;
+}
 .cboxPhoto {
   float: left;
   margin: auto;
@@ -49,8 +67,10 @@
   display: block;
   border: 0;
 }
+/* Reset box sizing to content-box if theme is using border-box. */
 #colorbox, #cboxContent, #cboxLoadedContent {
   -moz-box-sizing: content-box;
+  -webkit-box-sizing: content-box;
   box-sizing: content-box;
 }
 
@@ -62,12 +82,12 @@
 #cboxOverlay {
   background: #000;
 }
-
-#colorBox {}
+#colorbox {
+  outline: 0;
+}
   #cboxWrapper {}
     #cboxContent {
       overflow: hidden;
-      font: 12px "Lucida Grande", Verdana, Arial, sans-serif;
     }
       #cboxContent, .cboxPhoto {
         -webkit-border-radius: 5px;
@@ -87,6 +107,7 @@
         width: 100%;
         padding: 4px 6px;
         -moz-box-sizing: border-box;
+        -webkit-box-sizing: border-box;
         box-sizing: border-box;
         -webkit-border-bottom-right-radius: 5px;
         -webkit-border-bottom-left-radius: 5px;
@@ -100,12 +121,12 @@
         background: #fff;
       }
       #cboxLoadingGraphic {
-        background: url(images/loading_animation.gif) center center no-repeat;
+        background: url(images/loading_animation.gif) no-repeat center center;
       }
-      .cbox-close-plain {
+      #cboxClose.cbox-close-plain {
         position: absolute;
         font-size: 20px;
-        line-height: 18px;;
+        line-height: 18px;
         text-align: center;
         color: rgba(255, 255, 255, 0.7);
         background: rgba(0, 0, 0, 0.5);

+ 2 - 2
sites/all/modules/colorbox/styles/plain/colorbox_style.js

@@ -2,7 +2,7 @@
 
 Drupal.behaviors.initColorboxPlainStyle = {
   attach: function (context, settings) {
-    $(document).bind('cbox_complete', function () {
+    $(context).bind('cbox_complete', function () {
       // Make all the controls invisible.
       $('#cboxCurrent, #cboxSlideshow, #cboxPrevious, #cboxNext', context).addClass('element-invisible');
       // Replace "Close" with "×" and show.
@@ -24,7 +24,7 @@ Drupal.behaviors.initColorboxPlainStyle = {
         }
       });
     });
-    $(document).bind('cbox_closed', function () {
+    $(context).bind('cbox_closed', function () {
       $('#cboxClose', context).removeClass('cbox-close-plain');
     });
   }

+ 28 - 8
sites/all/modules/colorbox/styles/stockholmsyndrome/colorbox_style.css

@@ -1,5 +1,5 @@
 /**
- * ColorBox Core Style:
+ * Colorbox Core Style:
  * The following CSS is consistent between example themes and should not be altered.
  */
 #colorbox, #cboxOverlay, #cboxWrapper {
@@ -22,6 +22,7 @@
 }
 #cboxLoadedContent {
   overflow: auto;
+  -webkit-overflow-scrolling: touch;
 }
 #cboxTitle {
   margin: 0;
@@ -33,9 +34,26 @@
   width: 100%;
   height: 100%;
 }
+/**
+ * These elements are buttons, and may need to have additional
+ * styles reset to avoid unwanted base styles.
+ */
 #cboxPrevious, #cboxNext, #cboxClose, #cboxSlideshow {
+  border: 0;
+  padding: 0;
+  margin: 0;
+  overflow: visible;
+  width: auto;
+  background: none;
   cursor: pointer;
 }
+/**
+ * Avoid outlines on :active (mouseclick),
+ * but preserve outlines on :focus (tabbed navigating)
+ */
+#cboxPrevious:active, #cboxNext:active, #cboxClose:active, #cboxSlideshow:active {
+  outline: 0;
+}
 .cboxPhoto {
   float: left;
   margin: auto;
@@ -49,8 +67,10 @@
   display: block;
   border: 0;
 }
+/* Reset box sizing to content-box if theme is using border-box. */
 #colorbox, #cboxContent, #cboxLoadedContent {
   -moz-box-sizing: content-box;
+  -webkit-box-sizing: content-box;
   box-sizing: content-box;
 }
 
@@ -61,7 +81,6 @@
  */
 #cboxOverlay {
   background: #000;
-  opacity: 0.4 !important;
 }
 
 #colorbox {
@@ -75,6 +94,7 @@
   -webkit-border-bottom-right-radius: 9px;
   border-bottom-left-radius: 9px;
   border-bottom-right-radius: 9px;
+  outline: 0;
 }
 #colorbox, #colorbox div {
   overflow: visible; /* Required by the close button. */
@@ -118,7 +138,6 @@
     #cboxContent {
       background: #fff;
       overflow: hidden;
-      font: 11px Arial, sans-serif;
       margin-bottom: 28px;
     }
       #cboxError {
@@ -132,8 +151,9 @@
         height: 38px;
         color: #313131;
         padding: 0 140px 0 15px;
-        display: table-cell;
+        display: table-cell !important;
         vertical-align: middle;
+        float: none !important;
       }
       #cboxCurrent {
         position: absolute;
@@ -158,7 +178,7 @@
         position: absolute;
         bottom: -26px;
         right: 45px;
-        background: url(images/controls.png) 0 -48px no-repeat;
+        background: url(images/controls.png) no-repeat 0 -48px;
         width: 21px;
         height: 15px;
         text-indent: -9999px;
@@ -170,7 +190,7 @@
         position: absolute;
         bottom: -26px;
         right: 15px;
-        background: url(images/controls.png) 0 -29px no-repeat;
+        background: url(images/controls.png) no-repeat 0 -29px;
         width: 21px;
         height: 15px;
         text-indent: -9999px;
@@ -182,13 +202,13 @@
         background: #e6e6e6;
       }
       #cboxLoadingGraphic {
-        background: url(images/loading_animation.gif) center center no-repeat;
+        background: url(images/loading_animation.gif) no-repeat center center;
       }
       #cboxClose {
         position: absolute;
         top: -10px;
         right: -10px;
-        background: url(images/controls.png) 0px 0px no-repeat;
+        background: url(images/controls.png) no-repeat 0px 0px;
         width: 25px;
         height: 25px;
         text-indent: -9999px;

+ 3 - 3
sites/all/modules/colorbox/styles/stockholmsyndrome/colorbox_style.js

@@ -2,15 +2,15 @@
 
 Drupal.behaviors.initColorboxStockholmsyndromeStyle = {
   attach: function (context, settings) {
-    $(document).bind('cbox_open', function () {
+    $(context).bind('cbox_open', function () {
       // Hide close button initially.
       $('#cboxClose', context).css('opacity', 0);
     });
-    $(document).bind('cbox_load', function () {
+    $(context).bind('cbox_load', function () {
       // Hide close button. (It doesn't handle the load animation well.)
       $('#cboxClose', context).css('opacity', 0);
     });
-    $(document).bind('cbox_complete', function () {
+    $(context).bind('cbox_complete', function () {
       // Show close button with a delay.
       $('#cboxClose', context).fadeTo('fast', 0, function () {$(this).css('opacity', 1)});
     });

+ 9 - 2
sites/all/modules/colorbox/views/colorbox_handler_field_colorbox.inc

@@ -109,7 +109,7 @@ If you would like to have the characters %5B and %5D please use the html entity
     $form['custom_gid'] = array(
       '#type' => 'textfield',
       '#title' => t('Custom Colorbox gallery'),
-      '#description' => t('Enable Colorbox gallery with a given string as gallery. Overrides the automatically generated gallery id above.'),
+      '#description' => t('Enable Colorbox gallery with a given string as gallery. Overrides the automatically generated gallery id above. You may enter data from this view as per the "Replacement patterns" below.'),
       '#default_value' => $this->options['custom_gid'],
       '#weight' => -8,
     );
@@ -162,12 +162,19 @@ If you would like to have the characters %5B and %5D please use the html entity
     $tokens = $this->get_render_tokens($this->options['alter']);
     $popup = filter_xss_admin($this->options['popup']);
     $caption = filter_xss_admin($this->options['caption']);
+    $gallery = filter_xss_admin($this->options['custom_gid']);
     $popup = strtr($popup, $tokens);
     $caption = strtr($caption, $tokens);
+    $gallery = drupal_html_class(strtr($gallery, $tokens));
+
+    // Return nothing if popup is empty.
+    if (empty($popup)) {
+      return;
+    }
 
     $width = $this->options['width'] ? $this->options['width'] : '';
     $height = $this->options['height'] ? $this->options['height'] : '';
-    $gallery_id = !empty($this->options['custom_gid']) ? $this->options['custom_gid'] : ($this->options['gid'] ? 'gallery-' . $this->view->name : '');
+    $gallery_id = !empty($gallery) ? $gallery : ($this->options['gid'] ? 'gallery-' . $this->view->name : '');
     $link_text = $tokens["[{$this->options['trigger_field']}]"];
     $link_options = array(
       'html' => TRUE,

+ 3 - 3
sites/all/modules/ctools/bulk_export/bulk_export.info

@@ -6,9 +6,9 @@ package = Chaos tool suite
 version = CTOOLS_MODULE_VERSION
 
 
-; Information added by Drupal.org packaging script on 2015-03-18
-version = "7.x-1.7"
+; Information added by Drupal.org packaging script on 2016-08-17
+version = "7.x-1.10"
 core = "7.x"
 project = "ctools"
-datestamp = "1426696183"
+datestamp = "1471454104"
 

+ 3 - 4
sites/all/modules/ctools/ctools.info

@@ -2,16 +2,15 @@ name = Chaos tools
 description = A library of helpful tools by Merlin of Chaos.
 core = 7.x
 package = Chaos tool suite
-version = CTOOLS_MODULE_VERSION
 files[] = includes/context.inc
 files[] = includes/css-cache.inc
 files[] = includes/math-expr.inc
 files[] = includes/stylizer.inc
 files[] = tests/css_cache.test
 
-; Information added by Drupal.org packaging script on 2015-03-18
-version = "7.x-1.7"
+; Information added by Drupal.org packaging script on 2016-08-17
+version = "7.x-1.10"
 core = "7.x"
 project = "ctools"
-datestamp = "1426696183"
+datestamp = "1471454104"
 

+ 75 - 1
sites/all/modules/ctools/ctools.module

@@ -23,7 +23,7 @@ define('CTOOLS_API_VERSION', '2.0.8');
  *   ; Requires CTools v7.x-1.4 or newer.
  *   dependencies[] = ctools (>=1.4)
  */
-define('CTOOLS_MODULE_VERSION', '7.x-1.7');
+define('CTOOLS_MODULE_VERSION', '7.x-1.10');
 
 /**
  * Test the CTools API version.
@@ -618,6 +618,27 @@ function ctools_registry_files_alter(&$files, $indexed_modules) {
 }
 
 // -----------------------------------------------------------------------
+// FAPI hooks that must be in the .module file.
+
+/**
+ * Alter the comment form to get a little more control over it.
+ */
+function ctools_form_comment_form_alter(&$form, &$form_state) {
+  if (!empty($form_state['ctools comment alter'])) {
+    // Force the form to post back to wherever we are.
+    $form['#action'] = url($_GET['q'], array('fragment' => 'comment-form'));
+    if (empty($form['#submit'])) {
+      $form['#submit'] = array('comment_form_submit');
+    }
+    $form['#submit'][] = 'ctools_node_comment_form_submit';
+  }
+}
+
+function ctools_node_comment_form_submit(&$form, &$form_state) {
+  $form_state['redirect'][0] = $_GET['q'];
+}
+
+// -----------------------------------------------------------------------
 // CTools hook implementations.
 
 /**
@@ -737,6 +758,12 @@ function ctools_process(&$variables, $hook) {
     $variables['classes_array'] = array_diff($variables['classes_array'], $remove_classes);
   }
 
+  // Update the classes within the attributes array to match the classes array
+  if (isset($variables['attributes_array']['class'])) {
+    $variables['attributes_array']['class'] = $variables['classes_array'];
+    $variables['attributes'] = $variables['attributes_array'] ? drupal_attributes($variables['attributes_array']) : '';
+  }
+
   // Since this runs after template_process(), we need to re-implode the
   // classes array.
   $variables['classes'] = implode(' ', $variables['classes_array']);
@@ -1018,3 +1045,50 @@ function ctools_ctools_entity_context_alter(&$plugin, &$entity, $plugin_id) {
     }
   }
 }
+
+/**
+ * Implements hook_field_create_field().
+ */
+function ctools_field_create_field($field) {
+  ctools_flush_field_caches();
+}
+
+/**
+ * Implements hook_field_create_instance().
+ */
+function ctools_field_create_instance($instance) {
+  ctools_flush_field_caches();
+}
+/**
+ * Implements hook_field_delete_field().
+ */
+function ctools_field_delete_field($field) {
+  ctools_flush_field_caches();
+}
+/**
+ * Implements hook_field_delete_instance().
+ */
+function ctools_field_delete_instance($instance) {
+  ctools_flush_field_caches();
+}
+/**
+ * Implements hook_field_update_field().
+ */
+function ctools_field_update_field($field, $prior_field, $has_data) {
+  ctools_flush_field_caches();
+}
+
+/**
+ * Implements hook_field_update_instance().
+ */
+function ctools_field_update_instance($instance, $prior_instance) {
+  ctools_flush_field_caches();
+}
+
+/**
+ * Clear field related caches.
+ */
+function ctools_flush_field_caches() {
+  // Clear caches of 'Entity field' content type plugin.
+  cache_clear_all('ctools_entity_field_content_type_content_types', 'cache');
+}

+ 3 - 3
sites/all/modules/ctools/ctools_access_ruleset/ctools_access_ruleset.info

@@ -5,9 +5,9 @@ package = Chaos tool suite
 version = CTOOLS_MODULE_VERSION
 dependencies[] = ctools
 
-; Information added by Drupal.org packaging script on 2015-03-18
-version = "7.x-1.7"
+; Information added by Drupal.org packaging script on 2016-08-17
+version = "7.x-1.10"
 core = "7.x"
 project = "ctools"
-datestamp = "1426696183"
+datestamp = "1471454104"
 

+ 3 - 3
sites/all/modules/ctools/ctools_ajax_sample/ctools_ajax_sample.info

@@ -5,9 +5,9 @@ version = CTOOLS_MODULE_VERSION
 dependencies[] = ctools
 core = 7.x
 
-; Information added by Drupal.org packaging script on 2015-03-18
-version = "7.x-1.7"
+; Information added by Drupal.org packaging script on 2016-08-17
+version = "7.x-1.10"
 core = "7.x"
 project = "ctools"
-datestamp = "1426696183"
+datestamp = "1471454104"
 

+ 1 - 1
sites/all/modules/ctools/ctools_ajax_sample/ctools_ajax_sample.module

@@ -524,7 +524,7 @@ function ctools_ajax_sample_wizard_next(&$form_state) {
 }
 
 /**
- * Handle the 'finish' click on teh add/edit pane form wizard.
+ * Handle the 'finish' click on the add/edit pane form wizard.
  *
  * All we need to do is set a flag so the return can handle adding
  * the pane.

+ 3 - 3
sites/all/modules/ctools/ctools_custom_content/ctools_custom_content.info

@@ -5,9 +5,9 @@ package = Chaos tool suite
 version = CTOOLS_MODULE_VERSION
 dependencies[] = ctools
 
-; Information added by Drupal.org packaging script on 2015-03-18
-version = "7.x-1.7"
+; Information added by Drupal.org packaging script on 2016-08-17
+version = "7.x-1.10"
 core = "7.x"
 project = "ctools"
-datestamp = "1426696183"
+datestamp = "1471454104"
 

+ 17 - 0
sites/all/modules/ctools/ctools_custom_content/plugins/export_ui/ctools_custom_content_ui.class.php

@@ -23,6 +23,22 @@ class ctools_custom_content_ui extends ctools_export_ui {
       '#title' => t('Title'),
     );
 
+    $form['title_heading'] = array(
+      '#title' => t('Title heading'),
+      '#type' => 'select',
+      '#default_value' => isset($form_state['item']->settings['title_heading']) ? $form_state['item']->settings['title_heading'] : 'h2',
+      '#options' => array(
+        'h1' => t('h1'),
+        'h2' => t('h2'),
+        'h3' => t('h3'),
+        'h4' => t('h4'),
+        'h5' => t('h5'),
+        'h6' => t('h6'),
+        'div' => t('div'),
+        'span' => t('span'),
+      ),
+    );
+
     $form['body'] = array(
       '#type' => 'text_format',
       '#title' => t('Body'),
@@ -43,6 +59,7 @@ class ctools_custom_content_ui extends ctools_export_ui {
 
     // Since items in our settings are not in the schema, we have to do these manually:
     $form_state['item']->settings['title'] = $form_state['values']['title'];
+    $form_state['item']->settings['title_heading'] = $form_state['values']['title_heading'];
     $form_state['item']->settings['body'] = $form_state['values']['body']['value'];
     $form_state['item']->settings['format'] = $form_state['values']['body']['format'];
     $form_state['item']->settings['substitute'] = $form_state['values']['substitute'];

+ 3 - 3
sites/all/modules/ctools/ctools_plugin_example/ctools_plugin_example.info

@@ -8,9 +8,9 @@ dependencies[] = page_manager
 dependencies[] = advanced_help
 core = 7.x
 
-; Information added by Drupal.org packaging script on 2015-03-18
-version = "7.x-1.7"
+; Information added by Drupal.org packaging script on 2016-08-17
+version = "7.x-1.10"
 core = "7.x"
 project = "ctools"
-datestamp = "1426696183"
+datestamp = "1471454104"
 

+ 10 - 1
sites/all/modules/ctools/includes/content.inc

@@ -341,7 +341,16 @@ function ctools_content_editable($type, $subtype, $conf) {
     return FALSE;
   }
 
-  if ($function = ctools_plugin_get_function($subtype, 'check editable')) {
+  $function = FALSE;
+  
+  if (!empty($subtype['check editable'])) {
+    $function = ctools_plugin_get_function($subtype, 'check editable');
+  }
+  elseif (!empty($type['check editable'])) {
+    $function = ctools_plugin_get_function($type, 'check editable');
+  }
+
+  if ($function) {
     return $function($type, $subtype, $conf);
   }
 

+ 12 - 0
sites/all/modules/ctools/includes/context-admin.inc

@@ -736,6 +736,15 @@ function ctools_edit_context_form_defaults($form, &$form_state) {
     '#default_value' => $conf['keyword'],
   );
 
+  if ($type_info['key'] == 'requiredcontexts') {
+    $form['optional'] = array(
+      '#type' => 'checkbox',
+      '#title' => t('Context is optional'),
+      '#default_value' => !empty($form_state['conf']['optional']),
+      '#description' => t('This context need not be present for the component to function.'),
+    );
+  }
+
   $form['#submit'][] = 'ctools_edit_context_form_defaults_submit';
 
   return $form;
@@ -752,6 +761,9 @@ function ctools_edit_context_form_defaults_submit(&$form, &$form_state) {
     $form_state['conf']['default'] = $form_state['values']['default'];
     $form_state['conf']['title'] = $form_state['values']['title'];
   }
+  if ($form_state['type info']['key'] == 'requiredcontexts') {
+    $form_state['conf']['optional'] = $form_state['values']['optional'];
+  }
 
   $form_state['conf']['identifier'] = $form_state['values']['identifier'];
   $form_state['conf']['keyword'] = $form_state['values']['keyword'];

+ 5 - 9
sites/all/modules/ctools/includes/context.inc

@@ -42,7 +42,7 @@ class ctools_context {
   var $restrictions = array();
   var $empty = FALSE;
 
-  function ctools_context($type = 'none', $data = NULL) {
+  function __construct($type = 'none', $data = NULL) {
     $this->type  = $type;
     $this->data  = $data;
     $this->title = t('Unknown context');
@@ -119,7 +119,7 @@ class ctools_context_required {
    * @param ...
    *   One or more keywords to use for matching which contexts are allowed.
    */
-  function ctools_context_required($title) {
+  function __construct($title) {
     $args = func_get_args();
     $this->title = array_shift($args);
 
@@ -204,10 +204,6 @@ class ctools_context_required {
  */
 class ctools_context_optional extends ctools_context_required {
   var $required = FALSE;
-  function ctools_context_optional() {
-    $args = func_get_args();
-    call_user_func_array(array($this, 'ctools_context_required'), $args);
-  }
 
   /**
    * Add the 'empty' context which is possible for optional
@@ -216,7 +212,7 @@ class ctools_context_optional extends ctools_context_required {
     $context = new ctools_context('any');
     $context->title      = t('No context');
     $context->identifier = t('No context');
-    $contexts = array_merge(array('empty' => $context), $contexts);
+    $contexts['empty'] = $context;
   }
 
   function filter($contexts) {
@@ -1163,7 +1159,7 @@ function ctools_context_match_required_contexts($required, $contexts) {
   }
 
   foreach ($required as $r) {
-    $context = clone(array_shift($contexts));
+    $context = clone array_shift($contexts);
     $context->identifier = $r['identifier'];
     $context->page_title = isset($r['title']) ? $r['title'] : '';
     $context->keyword    = $r['keyword'];
@@ -1505,7 +1501,7 @@ function ctools_access($settings, $contexts = array()) {
       return TRUE;
     }
     else if (!$pass && $settings['logic'] == 'and') {
-      // Fail if 'and' and htis rule failed.
+      // Fail if 'and' and this rule failed.
       return FALSE;
     }
   }

+ 6 - 4
sites/all/modules/ctools/includes/css.inc

@@ -172,10 +172,12 @@ function ctools_css_cache($css, $filter = TRUE) {
   // @todo Is this slow? Does it matter if it is?
   $filename = $path . '/' . md5($css) . '.css';
 
-  // This will do renames if the file already exists, ensuring we don't
-  // accidentally overwrite other files who share the same md5. Yes this
-  // is a very miniscule chance but it's safe.
-  $filename = file_unmanaged_save_data($css, $filename);
+  // Generally md5 is considered unique enough to sign file downloads.
+  // So this replaces already existing files based on the assumption that two
+  // files with the same hash are identical content wise.
+  // If we rename, the cache folder can potentially fill up with thousands of
+  // files with the same content.
+  $filename = file_unmanaged_save_data($css, $filename, FILE_EXISTS_REPLACE);
 
   return $filename;
 }

+ 1 - 1
sites/all/modules/ctools/includes/export.inc

@@ -1227,7 +1227,7 @@ function ctools_export_default_to_hook_code($schema, $table, $names, $name) {
     $output .= "  \${$export['identifier']}s = array();\n\n";
     foreach ($objects as $object) {
       $output .= ctools_export_crud_export($table, $object, '  ');
-      $output .= "  \${$export['identifier']}s['" . check_plain($object->$export['key']) . "'] = \${$export['identifier']};\n\n";
+      $output .= "  \${$export['identifier']}s['" . check_plain($object->{$export['key']}) . "'] = \${$export['identifier']};\n\n";
     }
     $output .= "  return \${$export['identifier']}s;\n";
     $output .= "}\n";

+ 1 - 2
sites/all/modules/ctools/includes/fields.inc

@@ -137,7 +137,7 @@ function ctools_fields_get_field_formatter_settings_form($field, $formatter_type
  */
 function ctools_fields_get_field_formatter_info($fields) {
   $info = array();
-  $field_info = module_invoke_all('field_formatter_info');
+  $field_info = field_info_formatter_types();
   foreach ($fields as $field) {
     foreach ($field_info as $format_name => $formatter_info) {
       if (in_array($field['type'], $formatter_info['field types'])) {
@@ -145,7 +145,6 @@ function ctools_fields_get_field_formatter_info($fields) {
       }
     }
   }
-  drupal_alter('field_formatter_info', $info);
   return $info;
 }
 

+ 1 - 1
sites/all/modules/ctools/includes/jump-menu.inc

@@ -51,7 +51,7 @@ function ctools_jump_menu($form, &$form_st