? 897822-30.patch
? README
? skinr.897822-30.patch
? skinr.documentation.patch
? skinr.install.patch
? skinr.install.patch.1
? skinr.php_info_1.patch
Index: skinr.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/skinr/skinr.module,v
retrieving revision 1.28
diff -u -p -F '^f' -r1.28 skinr.module
--- skinr.module	15 Oct 2010 07:06:17 -0000	1.28
+++ skinr.module	16 Oct 2010 19:44:26 -0000
@@ -22,7 +22,7 @@ function skinr_help($path, $arg) {
  */
 function skinr_init() {
   module_load_include('inc', 'skinr', 'skinr.handlers');
-  skinr_module_include('skinr.inc');
+  skinr_module_include('skinr.plugin.inc');
 }
 
 /**
@@ -404,6 +404,106 @@ function skinr_get_module_apis() {
   return $cache;
 }
 
+/**
+ * Get a list of filenames and location for skins.
+ */
+function skinr_get_skinr_files() {
+  // Find *.skinr.inc files in skins, modules and themes folders.
+  $mask = '/\.skinr.inc$/';
+  $files = drupal_system_listing($mask, 'skins');
+  $files = $files = array_merge($files, drupal_system_listing($mask, 'themes'));
+  $files = $files = array_merge($files, drupal_system_listing($mask, 'modules'));
+
+  // If our filename contains multiple dots in the extension, for example
+  // filename.skinr.inc, we need to fix the name and key.
+  $info = array();
+  foreach ($files as $skinset) {
+    $key = substr($skinset->name, 0, -6);
+    $skinset->name = $key;
+    $info[$key] = $skinset;
+  }
+
+  return $info;
+}
+
+/**
+ * Load all skins.
+ */
+function skinr_load_all_info() {
+  $info = skinr_get_skinr_files();
+
+  $return = array();
+  foreach ($info as $skinset) {
+    if (!empty($skinset)) {
+      $result = skinr_load_info($skinset->name, $skinset);
+      if (isset($result) && is_array($result)) {
+        $return = array_merge_recursive($return, $result);
+      }
+      elseif (isset($result)) {
+        $return[$skinset->name] = $result;
+      }
+    }
+  }
+
+  return $return;
+}
+
+/**
+ * Load a skin.
+ */
+function skinr_load_info($skin, $skinset = NULL) {
+  if (is_null($skinset)) {
+    $info = skinr_get_skinr_files();
+    if (!empty($info[$skin])) {
+      $skinset = $info[$skin];
+    }
+    else {
+      return FALSE;
+    }
+  }
+
+  if (is_file($skinset->filename)) {
+    require_once $skinset->filename;
+
+    $function = $skinset->name .'_skinr_info';
+    $skinset->info = call_user_func_array($function, array());
+    if (!isset($skinset->info)) {
+      return FALSE;
+    }
+    if (!is_array($skinset->info)) {
+      $skinset->info = array($skinset->info);
+    }
+
+    foreach ($skinset->info as $key => $info) {
+      $skinset->info[$key] += skinr_skins_default();
+
+      // Give the screenshot proper path information.
+      if (!empty($skinset->info[$key]['screenshot'])) {
+        $skinset->info[$key]['screenshot'] = dirname($skinset->filename) .'/'. $skinset->info[$key]['screenshot'];
+      }
+
+      // Give all css and js files proper path information.
+      _skinr_add_paths_to_files($skinset->info[$key]['skinr'], dirname($skinset->filename));
+
+      // Invoke hook_skinr_info_alter() to give installed modules a chance to
+      // modify the data in the .skinr.inc files if necessary.
+      drupal_alter('skinr_info', $skinset->info[$key], $skinset);
+
+      // @todo In the future we might want to disable the below code to allow
+      //       multiple skinsets in a single file. This would require
+      //       substantial re-writing of certain pieces of code.
+      $skinset->info = $skinset->info[$key];
+      break;
+      // End code to remove.
+    }
+
+    return $skinset;
+  }
+  else {
+    return FALSE;
+  }
+}
+
 // -----------------------------------------------------------------------
 // Skinr data handling functions.
 
@@ -635,69 +735,10 @@ function skinr_skin_default() {
 }
 
 /**
- * Retrieves all the Skinr skins from theme parents. Theme skins
- * will override any skins of the same name from its parents.
- */
-function skinr_inherited_skins($theme) {
-  $themes = list_themes();
-
-  $all_skins = $skins = array();
-  $base_theme = (!empty($themes[$theme]->info['base theme'])) ? $themes[$theme]->info['base theme'] : '';
-  while ($base_theme) {
-    $all_skins[] = (!empty($themes[$base_theme]->info['skinr'])) ? (array)$themes[$base_theme]->info['skinr'] : array();
-    $base_theme = (!empty($themes[$base_theme]->info['base theme'])) ? $themes[$base_theme]->info['base theme'] : '';
-  }
-  array_reverse($all_skins);
-  foreach ($all_skins as $new_skin) {
-    $skins = array_merge($skins, $new_skin);
-  }
-  return $skins;
-}
-
-/**
- * Helper function to scan and collect skin .info data.
+ * Helper function to process a skin or theme .skinr.inc file.
  *
- * @return
- *   An associative array of skins information.
- */
-function _skinr_rebuild_skinset_data() {
-  // Find skins.
-  $mask = '/\.info$/';
-  $directory = 'skins';
-  $skinsets = drupal_system_listing($mask, $directory, 'name', 0);
-
-  // Find skins in theme folders.
-  $themes = list_themes();
-  foreach ($themes as $theme) {
-    $dir = dirname($theme->filename) . '/' . $directory;
-    $skinsets = array_merge($skinsets, file_scan_directory($dir, $mask, array('.', '..', 'CVS'), 0, TRUE, 'name', 1));
-  }
-
-  // Set defaults for skinset info.
-  $defaults = skinr_skins_default();
-
-  foreach ($skinsets as $key => $skinset) {
-    $skinsets[$key]->filename = $skinset->uri;
-    $skinsets[$key]->info = drupal_parse_info_file($skinset->uri) + $defaults;
-
-    // Give the screenshot proper path information.
-    if (!empty($skinsets[$key]->info['screenshot'])) {
-      $skinsets[$key]->info['screenshot'] = dirname($skinsets[$key]->uri) . '/' . $skinsets[$key]->info['screenshot'];
-    }
-
-    // Invoke hook_skinr_info_alter() to give installed modules a chance to
-    // modify the data in the .info files if necessary.
-    $type = 'skinset';
-    drupal_alter('skinr_info', $skinsets[$key]->info, $skinsets[$key], $type);
-    
-    // @todo Give the stylesheets and scripts proper path information, or leave 'till later?
-  }
-
-  return $skinsets;
-}
-
-/**
- * Helper function to process a skin or theme .info file.
+ * @param $info
+ *    Needs to be documented.
  *
  * @return
  *    A skinset.
@@ -708,6 +749,7 @@ function _skinr_skinset($info) {
     'skins' => array(),
   );
 
+   // @todo Account for $info->info being an array.
   if (!empty($info->info['skinr'])) {
     $path_root = dirname($info->filename);
 
@@ -731,11 +773,6 @@ function _skinr_skinset($info) {
       }
     }
 
-    // Inherit skins from parent theme, if inherit_skins is set to true.
-    if (!empty($skinset['options']['inherit_skins'])) {
-      $skinr_info = array_merge(skinr_inherited_skins($info->name), $skinr_info);
-    }
-
     $defaults = skinr_skin_default();
 
     foreach ($skinr_info as $id => $skin) {
@@ -776,7 +813,7 @@ function _skinr_skinset($info) {
 }
 
 /**
- * Helper function to prepend a path to an array of stylesheets or scripts in a .info file.
+ * Helper function to prepend a path to an array of stylesheets or scripts in a .skinr.inc file.
  *
  * @param $files
  *   A an array of filenames that need the path prepended.
@@ -811,40 +848,26 @@ function _skinr_add_path_to_files($files
 }
 
 /**
- * Helper function to process an array of skins or themes .info files.
+ * Helper function to process an array of skins or themes .skinr.inc files.
  *
- * @param $type
- *   Either 'theme' or 'skinset'.
+ * @param $refresh
+ *   Whether to reload the list of skinsets from the database or not.
  *
  * @return
  *    An array of skinsets.
  */
-function skinr_skinsets($type) {
+function skinr_skinsets() {
   $skinsets = &drupal_static(__FUNCTION__, array('theme' => array(), 'skinset' => array()));
   // @todo drupal_static_reset('skinr_skinsets');
 
-  if (empty($skinsets[$type])) {
+  if (empty($skinsets)) {
     $themes = list_themes();
 
-    if ($type == 'theme') {
-      foreach ($themes as $theme) {
-        $skinset = new StdClass();
-        $skinset->filename = $theme->filename;
-        $skinset->name = $theme->name;
-        $skinset->status = $theme->status ? 1 : 0;
-        $skinset->info = $theme->info;
-
-        $skinsets[$type][$skinset->name] = $skinset;
-      }
-    }
-    elseif ($type == 'skinset') {
-      $result = db_query("SELECT * FROM {skinr_skinsets}");
-      foreach ($result as $skinset) {
-        if (file_exists($skinset->filename)) {
-          $skinset->info = unserialize($skinset->info);
-
-          $skinsets[$type][$skinset->name] = $skinset;
-        }
+    $result = db_query("SELECT * FROM {skinr_skinsets}");
+    foreach ($result as $skinset) {
+      if (file_exists($skinset->filename)) {
+        $skinset->info = unserialize($skinset->info);
+        $skinsets[$skinset->name] = $skinset;
       }
     }
 
@@ -853,8 +876,34 @@ function skinr_skinsets($type) {
       $default_status[$theme->name] = $theme->name;
     }
 
-    foreach ($skinsets[$type] as $key => $skinset) {
-      $skinset->type = $type;
+    foreach ($skinsets as $key => $skinset) {
+      if (isset($themes[$key])) {
+        $skinset->type = 'theme';
+        $skinset->status = !empty($theme->status) ? 1 : 0;
+      }
+      else {
+        $skinset->type = 'skinset';
+      }
+
+      // Inherit skins from base theme, if inherit_skins is set to true.
+      // @todo Account for $skinset->info being an array.
+      if (!empty($skinset->info['skinr']['options']['inherit_skins'])) {
+        // Merge base theme and current.
+        $inheriting = TRUE;
+        $merged_skins = array();
+        $current_skinset = $skinset;
+        while ($inheriting) {
+          $inheriting = FALSE;
+          if (!empty($current_skinset->info['base theme'])) {
+            if (!empty($skinsets[$current_skinset->info['base theme']])) {
+              $current_skinset = $skinsets[$current_skinset->info['base theme']];
+              $merged_skins = array_merge($current_skinset->info['skinr'], $merged_skins);
+              $inheriting = TRUE;
+            }
+          }
+        }
+        $skinset->info['skinr'] = array_merge($merged_skins, $skinset->info['skinr']);
+      }
 
       $additional = _skinr_skinset($skinset);
       $skinset->options = $additional['options'];
@@ -867,7 +916,7 @@ function skinr_skinsets($type) {
     }
   }
 
-  return $skinsets[$type];
+  return $skinsets;
 }
 
 /**
@@ -901,8 +950,20 @@ function skinr_skinset_statuses($skinset
  *   Array of all available skinsets and their data.
  */
 function skinr_rebuild_skinset_data() {
-  $skinsets = _skinr_rebuild_skinset_data();
+  $skinsets = skinr_load_all_info();
   skinr_get_files_database($skinsets);
+
+  $themes = list_themes();
+  foreach ($skinsets as $key => $skinset) {
+    if (isset($themes[$key])) {
+      $skinset->status = !empty($themes[$key]->status) ? 1 : 0;
+      $skinset->type = 'theme';
+    }
+    else {
+      $skinset->type = 'skinset';
+    }
+  }
+
   skinr_update_files_database($skinsets);
   return $skinsets;
 }
@@ -1028,19 +1089,20 @@ function skinr_skin_data() {
   $cache = &drupal_static(__FUNCTION__);
 
   if (is_null($cache)) {
-    $skins_skinsets  = skinr_skinsets('skinset');
-    $themes_skinsets = skinr_skinsets('theme');
+    $skinsets = skinr_skinsets();
 
     // Need to merge all skins skinsets into a single list of skins.
     // Also merge in the groups information.
     $additional_skins = array();
     $groups = array();
-    foreach ($skins_skinsets as $key => $skinset) {
-      if (!empty($skinset->skins) && $skinset->status == 1) {
-        $additional_skins += $skinset->skins;
-      }
-      if (!empty($skinset->options['groups'])) {
-        $groups += $skinset->options['groups'];
+    foreach ($skinsets as $key => $skinset) {
+      if ($skinset->type == 'skinset') {
+        if (!empty($skinset->skins) && $skinset->status == 1) {
+          $additional_skins += $skinset->skins;
+        }
+        if (!empty($skinset->options['groups'])) {
+          $groups += $skinset->options['groups'];
+        }
       }
     }
 
@@ -1052,16 +1114,18 @@ function skinr_skin_data() {
         continue;
       }
 
-      if (isset($themes_skinsets[$theme->name])) {
-        $cache[$theme->name] = $themes_skinsets[$theme->name];
+      if (!empty($skinsets[$theme->name])) {
+        $cache[$theme->name] = $skinsets[$theme->name];
         $cache[$theme->name]->skins += $additional_skins;
         $cache[$theme->name]->options['groups'] += $groups;
       }
       else {
-        $cache[$theme->name] = array(
-          'options' => array('groups' => $groups),
-          'skins' => $additional_skins,
-        );
+        $cache[$theme->name] = new StdClass();
+        $cache[$theme->name]->name = $theme->name;
+        $cache[$theme->name]->status = 1;
+        $cache[$theme->name]->type = 'theme';
+        $cache[$theme->name]->skins = $additional_skins;
+        $cache[$theme->name]->options = array('groups' => $groups);
       }
     }
   }
Index: skinr_ui.admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/skinr/skinr_ui.admin.inc,v
retrieving revision 1.14
diff -u -p -F '^f' -r1.14 skinr_ui.admin.inc
--- skinr_ui.admin.inc	14 Oct 2010 23:09:30 -0000	1.14
+++ skinr_ui.admin.inc	16 Oct 2010 19:44:26 -0000
@@ -117,6 +117,10 @@ function skinr_ui_filter_form() {
 /**
  * Returns HTML for a skinr administration filter selector.
  *
+ * @todo
+ *   This needs to used theme_exposed_filters(). This code is atrocious and also
+ *   gone from Drupal 7.
+ *
  * @param $variables
  *   An associative array containing:
  *   - form: A render element representing the form.
@@ -139,14 +143,14 @@ function theme_skinr_ui_filters($variabl
 
   if (!empty($form['status']) && count(element_children($form['status']))) {
     $output .= '<dl class="multiselect">' . (!empty($form['current']) ? '<dt><em>' . t('and') . '</em> ' . t('where') . '</dt>' : '');
-  
+
     $output .= '<dd>';
-  
+
     foreach (element_children($form['status']) as $key) {
       $output .= drupal_render($form['status'][$key]);
     }
     $output .= '</dd>';
-  
+
     $output .= '</dl>';
   }
   $output .= drupal_render($form['actions']);
@@ -470,9 +474,8 @@ function skinr_ui_admin_skinsets($form, 
 
   uasort($skinsets, 'skinr_ui_sort_by_info_name');
 
-
   $form['skinsets'] = array('#tree' => TRUE);
-  
+
   // Iterate through each of the skinsets.
   foreach ($skinsets as $name => $skinset) {
     $extra = array();
@@ -537,7 +540,6 @@ function _skinr_ui_admin_skinsets_build_
   $form['screenshot'] = array(
     '#markup' => file_exists($info['screenshot']) ? theme('image', array('path' => $info['screenshot'], 'alt' => t('Screenshot for %theme theme', array('%theme' => $info['name'])), 'attributes' => array('class' => 'screenshot'), 'getsize' => FALSE)) : t('no screenshot'),
   );
-  
   $form['name'] = array(
     '#markup' => $info['name'],
   );
@@ -608,7 +610,7 @@ function skinr_ui_sort_by_info_name($a, 
 function skinr_ui_admin_skinsets_submit($form, &$form_state) {
   // Store list of previously enabled themes and disable all themes.
   $old_skinset_list = $new_skinset_list = array();
-  foreach (skinr_skinsets('skinset') as $skinset) {
+  foreach (skinr_skinsets() as $skinset) {
     if ($skinset->status) {
       $old_skinset_list[] = $skinset->name;
     }
@@ -725,27 +727,31 @@ function theme_skinr_ui_admin_skinsets_i
 function skinr_ui_admin_skinsets_settings($form, $form_state, $skinset_name) {
   $form = array();
 
-  $skinsets = skinr_skinsets('skinset');
+  $skinsets = skinr_skinsets();
   if (!empty($skinsets[$skinset_name])) {
     $skinset = $skinsets[$skinset_name];
-  
+
     $themes = list_themes();
+    $use_themes = array();
     ksort($themes);
-  
+
     $form['skins'] = array('#tree' => TRUE);
-    
+
     // Iterate through each of the skinsets.
     foreach ($skinset->skins as $name => $skin) {
       foreach ($themes as $theme) {
-        if (!$theme->status) {
+        if (!$theme->status || ($skinset->type == 'theme' && $skinset->name != $theme->name)) {
           continue;
         }
-        
+        $use_themes[$theme->name] = $theme->info['name'];
+
         // Create a row entry for this skinset.
         $form['skins'][$theme->name][$name] = _skinr_ui_admin_skinsets_settings_build_row($skin, $theme->name);
       }
     }
-  
+
+    $form['#themes'] = $use_themes;
+
     // Add basic information to the fieldsets.
     $current_theme = skinr_current_theme(TRUE);
     foreach (element_children($form['skins']) as $theme_name) {
@@ -868,7 +874,6 @@ function theme_skinr_ui_admin_skinsets_s
  * Process skinr_ui_admin_skinsets_settings form submissions.
  */
 function skinr_ui_admin_skinsets_settings_submit($form, &$form_state) {
-  dpm($form_state['values']);
   if ($form_state['values']['op'] == t('Save configuration')) {
     $statuses = array();
     foreach ($form_state['values']['skins'] as $theme => $skins) {
Index: skinr_ui.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/skinr/skinr_ui.module,v
retrieving revision 1.14
diff -u -p -F '^f' -r1.14 skinr_ui.module
--- skinr_ui.module	15 Oct 2010 07:06:17 -0000	1.14
+++ skinr_ui.module	16 Oct 2010 19:44:26 -0000
@@ -60,17 +60,19 @@ function skinr_ui_menu() {
     'parent' => 'admin/appearance/skinr/skins',
     'weight' => -1,
   );
-  foreach (skinr_skinsets('skinset') as $skinset) {
-    $items['admin/appearance/skinr/skins/settings/'. $skinset->name] = array(
-      'title' => $skinset->info['name'],
-      'description' => 'Manage which options are available for each Skin when changing Skinr settings.',
-      'page callback' => 'drupal_get_form',
-      'page arguments' => array('skinr_ui_admin_skinsets_settings', $skinset->name),
-      'access arguments' => array('administer site configuration'),
-      'file' => 'skinr_ui.admin.inc',
-      'type' => MENU_LOCAL_TASK,
-      'parent' => 'admin/appearance/skinr/skins',
-    );
+  foreach (skinr_skinsets() as $skinset) {
+    if (!empty($skinset->type) && $skinset->type == 'skinset') {
+      $items['admin/appearance/skinr/skins/settings/'. $skinset->name] = array(
+        'title' => $skinset->info['name'],
+        'description' => 'Manage which options are available for each Skin when changing Skinr settings.',
+        'page callback' => 'drupal_get_form',
+        'page arguments' => array('skinr_ui_admin_skinsets_settings', $skinset->name),
+        'access arguments' => array('administer site configuration'),
+        'file' => 'skinr_ui.admin.inc',
+        'type' => MENU_LOCAL_TASK,
+        'parent' => 'admin/appearance/skinr/skins',
+      );
+    }
   }
 
   // Rules.
Index: modules/block.skinr.inc
===================================================================
RCS file: modules/block.skinr.inc
diff -N modules/block.skinr.inc
--- modules/block.skinr.inc	15 Oct 2010 21:11:55 -0000	1.12
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,143 +0,0 @@
-<?php
-// $Id: block.skinr.inc,v 1.12 2010/10/15 21:11:55 moonray Exp $
-/**
- * @file
- * Provide skinr handling for block.module
- */
-
-/**
- * @defgroup skinr_block_module block.module handlers
- *
- * @{
- */
-
-/**
- * Implementation of hook_skinr_config().
- */
-function block_skinr_config() {
-  $data['block']['form']['block_admin_configure'] = array(
-    'index_handler' => 'block_skinr_form_index_handler',
-    'preprocess_hook_callback' => 'block_skinr_preprocess_hook_callback',
-    'title' => t('block settings'),
-    'skinr_weight' => 0,
-    'collapsed' => FALSE,
-  );
-  $data['block']['form']['block_add_block_form'] = array(
-    'index_handler' => 'block_skinr_form_index_handler',
-    'preprocess_hook_callback' => 'block_skinr_preprocess_hook_callback',
-    'title' => t('block settings'),
-    'skinr_weight' => 0,
-    'collapsed' => FALSE,
-  );
-  $data['block']['form']['skinr_ui_form'] = array(
-    'preprocess_hook_callback' => 'block_skinr_preprocess_hook_callback',
-    'title' => t('block settings'),
-    'collapsed' => FALSE,
-  );
-  $data['block']['preprocess']['block'] = array(
-    'index_handler' => 'block_skinr_preprocess_index_handler',
-  );
-  $data['block']['contextual_links']['block'] = array(
-    'contextual_links_handler' => 'block_skinr_contextual_links',
-  );
-
-  return $data;
-}
-
-/**
- * Skinr form index handler.
- *
- * @param $op
- *   What kind of action is being performed. Possible values:
- *   - "form": the form elements for Skinr are being inserted in a form
- *   - "submit": the form has been submitted.
- * @param &$form
- *   - For "form", passes in the $form parameter from hook_form_alter().
- *   - For "submit", passes in the $form parameter from hook_form_submit().
- * @param $form_state
- *   - For "form", passes in the $form_state parameter from hook_form_alter().
- *   - For "submit", passes in the $form_state parameter from hook_form_submit().
- * @return
- *   The index where we can find our values in Skinrs data structure.
- */
-function block_skinr_form_index_handler($op, &$form, $form_state) {
-  switch ($op) {
-    case 'form':
-      return $form['module']['#value'] . '-' . $form['delta']['#value'];
-
-    case 'submit':
-      return $form_state['values']['module'] . '-' . $form_state['values']['delta'];
-  }
-}
-
-/**
- * Skinr preprocess_hook_callback.
- *
- * @param &$form
- *   Passes in the $form parameter from hook_form_alter().
- * @param $form_state
- *   Passes in the $form_state parameter from hook_form_alter().
- * @return
- *   The preprocess_hook we wish to use.
- */
-function block_skinr_preprocess_hook_callback(&$form, $form_state) {
-  $preprocess_hooks = array();
-
-  if (empty($form['module']['#value']) && !empty($form['skinr']['sid']['#value'])) {
-    $result = db_select('block', 'b')
-      ->fields('b')
-      ->distinct()
-      ->where('CONCAT(b.module, \'-\', b.delta) = :identifier', array(':identifier' => $form['skinr']['sid']['#value']))
-      ->range(0, 1)
-      ->execute();
-    foreach ($result as $block) {
-      $preprocess_hooks[] = 'block_'. $block->module;
-    }
-  }
-  else {
-    $preprocess_hooks[] = 'block_'. $form['module']['#value'];
-  }
-  $preprocess_hooks[] = 'block';
-
-  return $preprocess_hooks;
-}
-
-/**
- * Skinr preprocess index handler.
- *
- * @param &$variables
- *   Passes in the $variables parameter from module_preprocess().
- * @return
- *   The index where we can find our values in Skinrs data structure. If an
- *   array is returned, it will loop through each index in Skinr's data
- *   structure and merge the returned classes.
- */
-function block_skinr_preprocess_index_handler(&$variables) {
-  return $variables['block']->module . '-' . $variables['block']->delta;
-}
-
-/**
- * Skinr contextual links handler.
- *
- * @param &$variables
- *   Passes in the $variables parameter from skinr_preprocess().
- * @return
- *   An array. Each value is an array that forms the function arguments for
- *   menu_contextual_links(). For example:
- *   @code
- *     array(
- *       'admin/appearance/skinr/edit', array('system', 'navigation')),
- *     )
- *   @endcode
- */
-function block_skinr_contextual_links(&$variables) {
-  $links = array();
-  $links['skinr-block'] = array(
-    'admin/appearance/skinr/edit/nojs', array('block', $variables['block']->module . '-' . $variables['block']->delta),
-  );
-  return $links;
-}
-
-/**
- * @}
- */
Index: modules/block.skinr.plugin.inc
===================================================================
RCS file: modules/block.skinr.plugin.inc
diff -N modules/block.skinr.plugin.inc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ modules/block.skinr.plugin.inc	16 Oct 2010 19:44:26 -0000
@@ -0,0 +1,143 @@
+<?php
+// $Id: block.skinr.inc,v 1.12 2010/10/15 21:11:55 moonray Exp $
+/**
+ * @file
+ * Provide skinr handling for block.module
+ */
+
+/**
+ * @defgroup skinr_block_module block.module handlers
+ *
+ * @{
+ */
+
+/**
+ * Implementation of hook_skinr_config().
+ */
+function block_skinr_config() {
+  $data['block']['form']['block_admin_configure'] = array(
+    'index_handler' => 'block_skinr_form_index_handler',
+    'preprocess_hook_callback' => 'block_skinr_preprocess_hook_callback',
+    'title' => t('block settings'),
+    'skinr_weight' => 0,
+    'collapsed' => FALSE,
+  );
+  $data['block']['form']['block_add_block_form'] = array(
+    'index_handler' => 'block_skinr_form_index_handler',
+    'preprocess_hook_callback' => 'block_skinr_preprocess_hook_callback',
+    'title' => t('block settings'),
+    'skinr_weight' => 0,
+    'collapsed' => FALSE,
+  );
+  $data['block']['form']['skinr_ui_form'] = array(
+    'preprocess_hook_callback' => 'block_skinr_preprocess_hook_callback',
+    'title' => t('block settings'),
+    'collapsed' => FALSE,
+  );
+  $data['block']['preprocess']['block'] = array(
+    'index_handler' => 'block_skinr_preprocess_index_handler',
+  );
+  $data['block']['contextual_links']['block'] = array(
+    'contextual_links_handler' => 'block_skinr_contextual_links',
+  );
+
+  return $data;
+}
+
+/**
+ * Skinr form index handler.
+ *
+ * @param $op
+ *   What kind of action is being performed. Possible values:
+ *   - "form": the form elements for Skinr are being inserted in a form
+ *   - "submit": the form has been submitted.
+ * @param &$form
+ *   - For "form", passes in the $form parameter from hook_form_alter().
+ *   - For "submit", passes in the $form parameter from hook_form_submit().
+ * @param $form_state
+ *   - For "form", passes in the $form_state parameter from hook_form_alter().
+ *   - For "submit", passes in the $form_state parameter from hook_form_submit().
+ * @return
+ *   The index where we can find our values in Skinrs data structure.
+ */
+function block_skinr_form_index_handler($op, &$form, $form_state) {
+  switch ($op) {
+    case 'form':
+      return $form['module']['#value'] . '-' . $form['delta']['#value'];
+
+    case 'submit':
+      return $form_state['values']['module'] . '-' . $form_state['values']['delta'];
+  }
+}
+
+/**
+ * Skinr preprocess_hook_callback.
+ *
+ * @param &$form
+ *   Passes in the $form parameter from hook_form_alter().
+ * @param $form_state
+ *   Passes in the $form_state parameter from hook_form_alter().
+ * @return
+ *   The preprocess_hook we wish to use.
+ */
+function block_skinr_preprocess_hook_callback(&$form, $form_state) {
+  $preprocess_hooks = array();
+
+  if (empty($form['module']['#value']) && !empty($form['skinr']['sid']['#value'])) {
+    $result = db_select('block', 'b')
+      ->fields('b')
+      ->distinct()
+      ->where('CONCAT(b.module, \'-\', b.delta) = :identifier', array(':identifier' => $form['skinr']['sid']['#value']))
+      ->range(0, 1)
+      ->execute();
+    foreach ($result as $block) {
+      $preprocess_hooks[] = 'block_'. $block->module;
+    }
+  }
+  else {
+    $preprocess_hooks[] = 'block_'. $form['module']['#value'];
+  }
+  $preprocess_hooks[] = 'block';
+
+  return $preprocess_hooks;
+}
+
+/**
+ * Skinr preprocess index handler.
+ *
+ * @param &$variables
+ *   Passes in the $variables parameter from module_preprocess().
+ * @return
+ *   The index where we can find our values in Skinrs data structure. If an
+ *   array is returned, it will loop through each index in Skinr's data
+ *   structure and merge the returned classes.
+ */
+function block_skinr_preprocess_index_handler(&$variables) {
+  return $variables['block']->module . '-' . $variables['block']->delta;
+}
+
+/**
+ * Skinr contextual links handler.
+ *
+ * @param &$variables
+ *   Passes in the $variables parameter from skinr_preprocess().
+ * @return
+ *   An array. Each value is an array that forms the function arguments for
+ *   menu_contextual_links(). For example:
+ *   @code
+ *     array(
+ *       'admin/appearance/skinr/edit', array('system', 'navigation')),
+ *     )
+ *   @endcode
+ */
+function block_skinr_contextual_links(&$variables) {
+  $links = array();
+  $links['skinr-block'] = array(
+    'admin/appearance/skinr/edit/nojs', array('block', $variables['block']->module . '-' . $variables['block']->delta),
+  );
+  return $links;
+}
+
+/**
+ * @}
+ */
Index: modules/comment.skinr.inc
===================================================================
RCS file: modules/comment.skinr.inc
diff -N modules/comment.skinr.inc
--- modules/comment.skinr.inc	2 Jun 2010 13:16:58 -0000	1.9
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,140 +0,0 @@
-<?php
-// $Id: comment.skinr.inc,v 1.9 2010/06/02 13:16:58 moonray Exp $
-/**
- * @file
- * Provide skinr handling for comment.module
- */
-
-/**
- * @defgroup skinr_comment_module comment.module handlers
- *
- * @{
- */
-
-/**
- * Implementation of hook_skinr_config().
- */
-function comment_skinr_config() {
-  $data['comment']['form']['node_type_form'] = array(
-    'index_handler' => 'comment_skinr_form_index_handler',
-    'preprocess_hook_callback' => 'comment_skinr_preprocess_hook_callback',
-    'title' => t('comment settings'),
-    'weight' => 1,
-  );
-  $data['comment']['form']['skinr_ui_form'] = array(
-    'preprocess_hook_callback' => 'comment_skinr_preprocess_hook_callback',
-    'title' => t('comment settings'),
-    'skinr_weight' => 2,
-    'collapsed' => FALSE,
-  );
-  $data['comment']['preprocess']['comment_wrapper'] = array(
-    'index_handler' => 'comment_skinr_preprocess_index_handler',
-  );
-  $data['comment']['contextual_links']['comment_wrapper'] = array(
-    'contextual_links_handler' => 'comment_skinr_contextual_links',
-  );
-
-  return $data;
-}
-
-/**
- * Skinr form index handler.
- *
- * @param $op
- *   What kind of action is being performed. Possible values:
- *   - "form": the form elements for Skinr are being inserted in a form
- *   - "submit": the form has been submitted.
- * @param &$form
- *   - For "form", passes in the $form parameter from hook_form_alter().
- *   - For "submit", passes in the $form parameter from hook_form_submit().
- * @param $form_state
- *   - For "form", passes in the $form_state parameter from hook_form_alter().
- *   - For "submit", passes in the $form_state parameter from hook_form_submit().
- * @return
- *   The index where we can find our values in Skinrs data structure.
- */
-function comment_skinr_form_index_handler($op, &$form, &$form_state) {
-  switch ($op) {
-    case 'form':
-      return $form['#node_type']->type;
-
-    case 'submit':
-      // Clear old variable before we set a new one if the node type has changed
-      if ($form_state['values']['old_type'] != $form_state['values']['type']) {
-        foreach ($form_state['values']['skinr_settings']['comment_group'] as $theme_name => $theme_data) {
-          $skinr = new stdClass();
-          $skinr->theme = $theme_name;
-          $skinr->module = 'comment';
-          $skinr->sid = $form_state['values']['old_type'];
-          $skinr->skins = array();
-
-          skinr_set($skinr);
-        }
-      }
-    return $form_state['values']['type'];
-  }
-}
-
-/**
- * Skinr preprocess_hook_callback.
- *
- * @param &$form
- *   Passes in the $form parameter from hook_form_alter().
- * @param $form_state
- *   Passes in the $form_state parameter from hook_form_alter().
- * @return
- *   The preprocess_hook we wish to use.
- */
-function comment_skinr_preprocess_hook_callback(&$form, $form_state) {
-  $preprocess_hooks = array();
-
-  if (!isset($form['#node_type']->type) && !empty($form['skinr']['sid']['#value'])) {
-    $preprocess_hooks[] = 'comment_wrapper_' . $form['skinr']['sid']['#value'];
-  }
-  else {
-    $preprocess_hooks[] = 'comment_wrapper_' . $form['#node_type']->type;
-  }
-  $preprocess_hooks[] = 'comment_wrapper';
-
-  return $preprocess_hooks;
-}
-
-/**
- * Skinr preprocess index handler.
- *
- * @param &$variables
- *   Passes in the $variables parameter from skinr_preprocess().
- * @return
- *   The index where we can find our values in Skinrs data structure. If an
- *   array is returned, it will loop through each index in Skinr's data
- *   structure and merge the returned classes.
- */
-function comment_skinr_preprocess_index_handler(&$variables) {
-  return $variables['node']->type;
-}
-
-/**
- * Skinr contextual links handler.
- *
- * @param &$variables
- *   Passes in the $variables parameter from skinr_preprocess().
- * @return
- *   An array. Each value is an array that forms the function arguments for
- *   menu_contextual_links(). For example:
- *   @code
- *     array(
- *       'admin/appearance/skinr/edit', array('system', 'navigation')),
- *     )
- *   @endcode
- */
-function comment_skinr_contextual_links(&$variables) {
-  $links = array();
-  $links['skinr-comment'] = array(
-    'admin/appearance/skinr/edit/nojs', array('comment', $variables['node']->type),
-  );
-  return $links;
-}
-
-/**
- * @}
- */
Index: modules/comment.skinr.plugin.inc
===================================================================
RCS file: modules/comment.skinr.plugin.inc
diff -N modules/comment.skinr.plugin.inc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ modules/comment.skinr.plugin.inc	16 Oct 2010 19:44:26 -0000
@@ -0,0 +1,140 @@
+<?php
+// $Id: comment.skinr.inc,v 1.9 2010/06/02 13:16:58 moonray Exp $
+/**
+ * @file
+ * Provide skinr handling for comment.module
+ */
+
+/**
+ * @defgroup skinr_comment_module comment.module handlers
+ *
+ * @{
+ */
+
+/**
+ * Implementation of hook_skinr_config().
+ */
+function comment_skinr_config() {
+  $data['comment']['form']['node_type_form'] = array(
+    'index_handler' => 'comment_skinr_form_index_handler',
+    'preprocess_hook_callback' => 'comment_skinr_preprocess_hook_callback',
+    'title' => t('comment settings'),
+    'weight' => 1,
+  );
+  $data['comment']['form']['skinr_ui_form'] = array(
+    'preprocess_hook_callback' => 'comment_skinr_preprocess_hook_callback',
+    'title' => t('comment settings'),
+    'skinr_weight' => 2,
+    'collapsed' => FALSE,
+  );
+  $data['comment']['preprocess']['comment_wrapper'] = array(
+    'index_handler' => 'comment_skinr_preprocess_index_handler',
+  );
+  $data['comment']['contextual_links']['comment_wrapper'] = array(
+    'contextual_links_handler' => 'comment_skinr_contextual_links',
+  );
+
+  return $data;
+}
+
+/**
+ * Skinr form index handler.
+ *
+ * @param $op
+ *   What kind of action is being performed. Possible values:
+ *   - "form": the form elements for Skinr are being inserted in a form
+ *   - "submit": the form has been submitted.
+ * @param &$form
+ *   - For "form", passes in the $form parameter from hook_form_alter().
+ *   - For "submit", passes in the $form parameter from hook_form_submit().
+ * @param $form_state
+ *   - For "form", passes in the $form_state parameter from hook_form_alter().
+ *   - For "submit", passes in the $form_state parameter from hook_form_submit().
+ * @return
+ *   The index where we can find our values in Skinrs data structure.
+ */
+function comment_skinr_form_index_handler($op, &$form, &$form_state) {
+  switch ($op) {
+    case 'form':
+      return $form['#node_type']->type;
+
+    case 'submit':
+      // Clear old variable before we set a new one if the node type has changed
+      if ($form_state['values']['old_type'] != $form_state['values']['type']) {
+        foreach ($form_state['values']['skinr_settings']['comment_group'] as $theme_name => $theme_data) {
+          $skinr = new stdClass();
+          $skinr->theme = $theme_name;
+          $skinr->module = 'comment';
+          $skinr->sid = $form_state['values']['old_type'];
+          $skinr->skins = array();
+
+          skinr_set($skinr);
+        }
+      }
+    return $form_state['values']['type'];
+  }
+}
+
+/**
+ * Skinr preprocess_hook_callback.
+ *
+ * @param &$form
+ *   Passes in the $form parameter from hook_form_alter().
+ * @param $form_state
+ *   Passes in the $form_state parameter from hook_form_alter().
+ * @return
+ *   The preprocess_hook we wish to use.
+ */
+function comment_skinr_preprocess_hook_callback(&$form, $form_state) {
+  $preprocess_hooks = array();
+
+  if (!isset($form['#node_type']->type) && !empty($form['skinr']['sid']['#value'])) {
+    $preprocess_hooks[] = 'comment_wrapper_' . $form['skinr']['sid']['#value'];
+  }
+  else {
+    $preprocess_hooks[] = 'comment_wrapper_' . $form['#node_type']->type;
+  }
+  $preprocess_hooks[] = 'comment_wrapper';
+
+  return $preprocess_hooks;
+}
+
+/**
+ * Skinr preprocess index handler.
+ *
+ * @param &$variables
+ *   Passes in the $variables parameter from skinr_preprocess().
+ * @return
+ *   The index where we can find our values in Skinrs data structure. If an
+ *   array is returned, it will loop through each index in Skinr's data
+ *   structure and merge the returned classes.
+ */
+function comment_skinr_preprocess_index_handler(&$variables) {
+  return $variables['node']->type;
+}
+
+/**
+ * Skinr contextual links handler.
+ *
+ * @param &$variables
+ *   Passes in the $variables parameter from skinr_preprocess().
+ * @return
+ *   An array. Each value is an array that forms the function arguments for
+ *   menu_contextual_links(). For example:
+ *   @code
+ *     array(
+ *       'admin/appearance/skinr/edit', array('system', 'navigation')),
+ *     )
+ *   @endcode
+ */
+function comment_skinr_contextual_links(&$variables) {
+  $links = array();
+  $links['skinr-comment'] = array(
+    'admin/appearance/skinr/edit/nojs', array('comment', $variables['node']->type),
+  );
+  return $links;
+}
+
+/**
+ * @}
+ */
Index: modules/node.skinr.inc
===================================================================
RCS file: modules/node.skinr.inc
diff -N modules/node.skinr.inc
--- modules/node.skinr.inc	2 Jun 2010 13:16:58 -0000	1.9
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,138 +0,0 @@
-<?php
-// $Id: node.skinr.inc,v 1.9 2010/06/02 13:16:58 moonray Exp $
-/**
- * @file
- * Provide skinr handling for node.module
- */
-
-/**
- * @defgroup skinr_node_module node.module handlers
- *
- * @{
- */
-
-/**
- * Implementation of hook_skinr_config().
- */
-function node_skinr_config() {
-  $data['node']['form']['node_type_form'] = array(
-    'index_handler' => 'node_skinr_form_index_handler',
-    'preprocess_hook_callback' => 'node_skinr_preprocess_hook_callback',
-    'title' => t('node settings'),
-  );
-  $data['node']['form']['skinr_ui_form'] = array(
-    'preprocess_hook_callback' => 'node_skinr_preprocess_hook_callback',
-    'title' => t('node settings'),
-    'collapsed' => FALSE,
-  );
-  $data['node']['preprocess']['node'] = array(
-    'index_handler' => 'node_skinr_preprocess_index_handler',
-  );
-  $data['node']['contextual_links']['node'] = array(
-    'contextual_links_handler' => 'node_skinr_contextual_links',
-  );
-
-  return $data;
-}
-
-/**
- * Skinr form index handler.
- *
- * @param $op
- *   What kind of action is being performed. Possible values:
- *   - "form": the form elements for Skinr are being inserted in a form
- *   - "submit": the form has been submitted.
- * @param &$form
- *   - For "form", passes in the $form parameter from hook_form_alter().
- *   - For "submit", passes in the $form parameter from hook_form_submit().
- * @param $form_state
- *   - For "form", passes in the $form_state parameter from hook_form_alter().
- *   - For "submit", passes in the $form_state parameter from hook_form_submit().
- * @return
- *   The index where we can find our values in Skinrs data structure.
- */
-function node_skinr_form_index_handler($op, &$form, $form_state) {
-  switch ($op) {
-    case 'form':
-      return $form['#node_type']->type;
-
-    case 'submit':
-      // Clear old variable before we set a new one if the node type has changed
-      if ($form_state['values']['old_type'] != $form_state['values']['type']) {
-        foreach ($form_state['values']['skinr_settings']['node_group'] as $theme_name => $theme_data) {
-          $skinr = new stdClass();
-          $skinr->theme = $theme_name;
-          $skinr->module = 'node';
-          $skinr->sid = $form_state['values']['old_type'];
-          $skinr->skins = array();
-
-          skinr_set($skinr);
-        }
-      }
-    return $form_state['values']['type'];
-  }
-}
-
-/**
- * Skinr preprocess_hook_callback.
- *
- * @param &$form
- *   Passes in the $form parameter from hook_form_alter().
- * @param $form_state
- *   Passes in the $form_state parameter from hook_form_alter().
- * @return
- *   The preprocess_hook we wish to use.
- */
-function node_skinr_preprocess_hook_callback(&$form, $form_state) {
-  $preprocess_hooks = array();
-
-  if (!isset($form['#node_type']->type) && !empty($form['skinr']['sid']['#value'])) {
-    $preprocess_hooks[] = 'node_' . $form['skinr']['sid']['#value'];
-  }
-  else {
-    $preprocess_hooks[] = 'node_' . $form['#node_type']->type;
-  }
-  $preprocess_hooks[] = 'node';
-
-  return $preprocess_hooks;
-}
-
-/**
- * Skinr preprocess index handler.
- *
- * @param &$variables
- *   Passes in the $variables parameter from module_preprocess().
- * @return
- *   The index where we can find our values in Skinrs data structure. If an
- *   array is returned, it will loop through each index in Skinr's data
- *   structure and merge the returned classes.
- */
-function node_skinr_preprocess_index_handler(&$variables) {
-  return $variables['node']->type;
-}
-
-/**
- * Skinr contextual links handler.
- *
- * @param &$variables
- *   Passes in the $variables parameter from skinr_preprocess().
- * @return
- *   An array. Each value is an array that forms the function arguments for
- *   menu_contextual_links(). For example:
- *   @code
- *     array(
- *       'admin/appearance/skinr/edit', array('system', 'navigation')),
- *     )
- *   @endcode
- */
-function node_skinr_contextual_links(&$variables) {
-  $links = array();
-  $links['skinr-node'] = array(
-    'admin/appearance/skinr/edit/nojs', array('node', $variables['node']->type),
-  );
-  return $links;
-}
-
-/**
- * @}
- */
Index: modules/node.skinr.plugin.inc
===================================================================
RCS file: modules/node.skinr.plugin.inc
diff -N modules/node.skinr.plugin.inc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ modules/node.skinr.plugin.inc	16 Oct 2010 19:44:26 -0000
@@ -0,0 +1,138 @@
+<?php
+// $Id: node.skinr.inc,v 1.9 2010/06/02 13:16:58 moonray Exp $
+/**
+ * @file
+ * Provide skinr handling for node.module
+ */
+
+/**
+ * @defgroup skinr_node_module node.module handlers
+ *
+ * @{
+ */
+
+/**
+ * Implementation of hook_skinr_config().
+ */
+function node_skinr_config() {
+  $data['node']['form']['node_type_form'] = array(
+    'index_handler' => 'node_skinr_form_index_handler',
+    'preprocess_hook_callback' => 'node_skinr_preprocess_hook_callback',
+    'title' => t('node settings'),
+  );
+  $data['node']['form']['skinr_ui_form'] = array(
+    'preprocess_hook_callback' => 'node_skinr_preprocess_hook_callback',
+    'title' => t('node settings'),
+    'collapsed' => FALSE,
+  );
+  $data['node']['preprocess']['node'] = array(
+    'index_handler' => 'node_skinr_preprocess_index_handler',
+  );
+  $data['node']['contextual_links']['node'] = array(
+    'contextual_links_handler' => 'node_skinr_contextual_links',
+  );
+
+  return $data;
+}
+
+/**
+ * Skinr form index handler.
+ *
+ * @param $op
+ *   What kind of action is being performed. Possible values:
+ *   - "form": the form elements for Skinr are being inserted in a form
+ *   - "submit": the form has been submitted.
+ * @param &$form
+ *   - For "form", passes in the $form parameter from hook_form_alter().
+ *   - For "submit", passes in the $form parameter from hook_form_submit().
+ * @param $form_state
+ *   - For "form", passes in the $form_state parameter from hook_form_alter().
+ *   - For "submit", passes in the $form_state parameter from hook_form_submit().
+ * @return
+ *   The index where we can find our values in Skinrs data structure.
+ */
+function node_skinr_form_index_handler($op, &$form, $form_state) {
+  switch ($op) {
+    case 'form':
+      return $form['#node_type']->type;
+
+    case 'submit':
+      // Clear old variable before we set a new one if the node type has changed
+      if ($form_state['values']['old_type'] != $form_state['values']['type']) {
+        foreach ($form_state['values']['skinr_settings']['node_group'] as $theme_name => $theme_data) {
+          $skinr = new stdClass();
+          $skinr->theme = $theme_name;
+          $skinr->module = 'node';
+          $skinr->sid = $form_state['values']['old_type'];
+          $skinr->skins = array();
+
+          skinr_set($skinr);
+        }
+      }
+    return $form_state['values']['type'];
+  }
+}
+
+/**
+ * Skinr preprocess_hook_callback.
+ *
+ * @param &$form
+ *   Passes in the $form parameter from hook_form_alter().
+ * @param $form_state
+ *   Passes in the $form_state parameter from hook_form_alter().
+ * @return
+ *   The preprocess_hook we wish to use.
+ */
+function node_skinr_preprocess_hook_callback(&$form, $form_state) {
+  $preprocess_hooks = array();
+
+  if (!isset($form['#node_type']->type) && !empty($form['skinr']['sid']['#value'])) {
+    $preprocess_hooks[] = 'node_' . $form['skinr']['sid']['#value'];
+  }
+  else {
+    $preprocess_hooks[] = 'node_' . $form['#node_type']->type;
+  }
+  $preprocess_hooks[] = 'node';
+
+  return $preprocess_hooks;
+}
+
+/**
+ * Skinr preprocess index handler.
+ *
+ * @param &$variables
+ *   Passes in the $variables parameter from module_preprocess().
+ * @return
+ *   The index where we can find our values in Skinrs data structure. If an
+ *   array is returned, it will loop through each index in Skinr's data
+ *   structure and merge the returned classes.
+ */
+function node_skinr_preprocess_index_handler(&$variables) {
+  return $variables['node']->type;
+}
+
+/**
+ * Skinr contextual links handler.
+ *
+ * @param &$variables
+ *   Passes in the $variables parameter from skinr_preprocess().
+ * @return
+ *   An array. Each value is an array that forms the function arguments for
+ *   menu_contextual_links(). For example:
+ *   @code
+ *     array(
+ *       'admin/appearance/skinr/edit', array('system', 'navigation')),
+ *     )
+ *   @endcode
+ */
+function node_skinr_contextual_links(&$variables) {
+  $links = array();
+  $links['skinr-node'] = array(
+    'admin/appearance/skinr/edit/nojs', array('node', $variables['node']->type),
+  );
+  return $links;
+}
+
+/**
+ * @}
+ */
Index: modules/panels.skinr.inc
===================================================================
RCS file: modules/panels.skinr.inc
diff -N modules/panels.skinr.inc
--- modules/panels.skinr.inc	2 Jun 2010 13:16:58 -0000	1.13
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,413 +0,0 @@
-<?php
-// $Id: panels.skinr.inc,v 1.13 2010/06/02 13:16:58 moonray Exp $
-/**
- * @file
- * Provide skinr handling for panels.module.
- */
-
-/**
- * @defgroup skinr_panels_module panels.module handlers.
- *
- * @{
- */
-
-/**
- * Implementation of hook_skinr_config().
- */
-function panels_skinr_config() {
-  $data['panels']['form']['panels_edit_style_settings_form'] = array(
-    'index_handler' => 'panels_skinr_form_index_handler',
-    'data_handler' => 'panels_skinr_data_handler',
-    'submit_handler' => 'panels_skinr_submit_handler_settings',
-    'preprocess_hook_callback' => 'panels_skinr_preprocess_hook_callback',
-    'title' => t('panel pane settings'),
-    'skinr_weight' => 0,
-    'collapsed' => FALSE,
-  );
-  // AJAX form.
-  $data['panels']['form']['skinr_ui_form'] = array(
-    'preprocess_hook_callback' => 'panels_skinr_ajax_preprocess_hook_callback',
-    'title' => t('panel pane settings'),
-    'collapsed' => FALSE,
-  );
-  // Panel pages.
-  $data['panels']['form']['page_manager_save_page_form'] = array(
-    'access_handler' => 'panels_skinr_access_handler_display',
-    'submit_handler' => 'panels_skinr_submit_handler_display',
-  );
-  // Content form for panel pages.
-  $data['panels']['form']['panels_panel_context_edit_content'] = array(
-    'access_handler' => 'panels_skinr_access_handler_display',
-    'submit_handler' => 'panels_skinr_submit_handler_display',
-  );
-  // Mini panels.
-  $data['panels']['form']['panels_edit_display_form'] = array(
-    'access_handler' => 'panels_skinr_access_handler_display',
-    'submit_handler' => 'panels_skinr_submit_handler_display',
-  );
-  $data['panels']['preprocess']['panels_pane'] = array(
-    'index_handler' => 'panels_skinr_preprocess_index_handler',
-  );
-
-  return $data;
-}
-
-/**
- * Skinr form index handler.
- *
- * @param $op
- *   What kind of action is being performed. Possible values:
- *   - "form": the form elements for Skinr are being inserted in a form
- *   - "submit": the form has been submitted.
- * @param &$form
- *   - For "form", passes in the $form parameter from hook_form_alter().
- *   - For "submit", passes in the $form parameter from hook_form_submit().
- * @param $form_state
- *   - For "form", passes in the $form_state parameter from hook_form_alter().
- *   - For "submit", passes in the $form_state parameter from hook_form_submit().
- * @return
- *   The index where we can find our values in Skinrs data structure.
- */
-function panels_skinr_form_index_handler($op, &$form, $form_state) {
-  switch ($op) {
-    case 'form':
-    case 'submit':
-      switch ($form['#parameters'][1]['type']) {
-        case 'display':
-          return 'display-' . $form['#parameters'][1]['display']->did;
-        case 'panel':
-          return 'display-' . $form['#parameters'][1]['display']->did . '-panel-' . $form['#parameters'][1]['pid'];
-        case 'pane':
-          return 'display-' . $form['#parameters'][1]['display']->did . '-pane-' . $form['#parameters'][1]['pid'];
-      }
-  }
-}
-
-/**
- * Skinr access handler.
- *
- * @param $op
- *   What kind of action is being performed. Possible values:
- *   - "access skinr": access to edit skinr's selector
- *   - "access skinr classes": access to edit skinr's additional classes
- * @param &$form
- *   Passes in the $form parameter from hook_form_alter().
- * @param $form_state
- *   Passes in the $form_state parameter from hook_form_alter().
- * @return
- *   TRUE if we get access, FALSE if we don't.
- */
-function panels_skinr_access_handler_display($op, &$form, $form_state) {
-  // We don't want the skinr settings form to appear on this form. We only want
-  // to intercept it so we can save our cached data.
-
-  // Since we're not using the form, we won't get our form submitter, so let's
-  // add it manually.
-
-  $form_id = $form['form_id']['#value'];
-
-  switch ($form_id) {
-    case 'panels_panel_context_edit_content':
-      // Update and save button
-
-      // Only add submit handler once.
-      if (!in_array('skinr_ui_form_submit', $form['#submit'])) {
-        $form['#submit'][] = 'skinr_ui_form_submit';
-      }
-      break;
-
-    case 'page_manager_save_page_form':
-      // Submitting a panel page.
-
-      // Only add submit handler once.
-      if (!in_array('skinr_ui_form_submit', $form['#submit'])) {
-        $form['#submit'][] = 'skinr_ui_form_submit';
-      }
-      if (isset($form['save']['#submit']) && !in_array('skinr_ui_form_submit', $form['save']['#submit'])) {
-        $form['save']['#submit'][] = 'skinr_ui_form_submit';
-      }
-      if (isset($form['cancel']['#submit']) && !in_array('skinr_ui_form_submit', $form['cancel']['#submit'])) {
-        $form['cancel']['#submit'][] = 'skinr_ui_form_submit';
-      }
-      break;
-
-    case 'panels_edit_display_form':
-      // Only add submit handler once.
-      if (!in_array('skinr_ui_form_submit', $form['#submit'])) {
-        $form['#submit'][] = 'skinr_ui_form_submit';
-      }
-      if (isset($form['buttons']['submit']['#submit']) && !in_array('skinr_ui_form_submit', $form['buttons']['submit']['#submit'])) {
-        $form['buttons']['submit']['#submit'][] = 'skinr_ui_form_submit';
-      }
-      break;
-
-    default:
-      // We only want to save or cancel on these other forms if we're dealing with a panel_page.
-      if ($form_state['task']['name'] == 'panel_page') {
-        // Only add submit handler once
-        if (!in_array('skinr_ui_form_submit', $form['#submit'])) {
-          $form['#submit'][] = 'skinr_ui_form_submit';
-        }
-        if (isset($form['buttons']['cancel']['#submit']) && !in_array('skinr_ui_form_submit', $form['buttons']['cancel']['#submit'])) {
-          $form['buttons']['cancel']['#submit'][] = 'skinr_ui_form_submit';
-        }
-      }
-      break;
-  }
-
-  return FALSE;
-}
-
-/**
- * Skinr data handler.
- * This is the data that populates the skinr form.
- *
- * @param &$form
- *   Passes in the $form parameter from hook_form_submit().
- * @param $form_state
- *   Passes in the $form_state parameter from hook_form_submit().
- * @param $module
- *   The module that is currently being processed.
- * @param $form_settings
- *   The settings from hook_skinr_config() for the form that's currently being
- *   processed.
- * @return
- *   TRUE if we get access, FALSE if we don't.
- */
-function panels_skinr_data_handler(&$form, $form_state, $theme, $module, $form_settings) {
-  // Ensure we have the required index_handler.
-  if (empty($form_settings['index_handler'])) {
-    trigger_error(sprintf("No index_handler was found for form_id '%s' in module '%s'.", $form_id, $module), E_USER_ERROR);
-  }
-  $index = skinr_handler('form_index_handler', 'form', $form_settings['index_handler'], $form, $form_state);
-
-  // Fetch skinr data for this view from cache.
-  ctools_include('object-cache');
-
-  if ($skinr_data = ctools_object_cache_get('skinr', $form_state['display']->did, TRUE)) {
-    if (isset($skinr_data[$theme][$index])) {
-      return $skinr_data[$theme][$index];
-    }
-    else {
-      return array();
-    }
-  }
-
-  // No data exists in cache, so let's grab it from the regular source.
-  return skinr_get($theme, $module, $index);
-}
-
-/**
- * Skinr submit handler.
- *
- * @param $op
- *   What kind of action is being performed. Possible values:
- *   - "access skinr": access to edit skinr's selector
- *   - "access skinr classes": access to edit skinr's additional classes
- * @param &$form
- *   Passes in the $form parameter from hook_form_alter().
- * @param $form_state
- *   Passes in the $form_state parameter from hook_form_alter().
- * @return
- *   TRUE if we get access, FALSE if we don't.
- */
-function panels_skinr_submit_handler_settings(&$form, $form_state, $module, $form_settings) {
-  foreach ($form_state['values']['skinr_settings'][$module . '_group'] as $theme_name => $theme) {
-    if ((isset($theme['widgets']) && count($theme['widgets'])) || isset($theme['_additional'])) {
-      $hook  = $module;
-      $sid   = skinr_handler('form_index_handler', 'submit', $form_settings['index_handler'], $form, $form_state);
-
-      // Key doesn't exist properly for new displays. Perhaps we should inject a timestamp based key into the display object
-      // and use that for reference on the final submit? If it works...
-
-      $value = array();
-
-      if (is_array($theme['widgets'])) {
-        foreach ($theme['widgets'] as $skin_id => $skin_value) {
-          $value[$skin_id] = $skin_value;
-        }
-      }
-
-      if (isset($theme['_additional'])) {
-        $theme['_additional'] = trim($theme['_additional']);
-        if (!empty($theme['_additional'])) {
-          $value['_additional'] = $theme['_additional'];
-        }
-      }
-
-      if (isset($theme['_template'])) {
-        $theme['_template'] = trim($theme['_template']);
-        if (!empty($theme['_template'])) {
-          $value['_template'] = $theme['_template'];
-        }
-      }
-
-      if (empty($sid)) {
-        // We didn't receive a valid sid, so raise an error.
-        drupal_set_message(t("Skinr settings weren't saved due to an error."), 'error');
-      }
-
-      // Save skinr_settings for this panel display in cache.
-      ctools_include('object-cache');
-      if (!$skinr_data = ctools_object_cache_get('skinr', $form_state['display']->did, TRUE)) {
-        $skinr_data = array();
-        // Fetch skinr data.
-        $skinr = skinr_get($theme_name);
-        if (isset($skinr[$module])) {
-          foreach ($skinr[$module] as $skinr_key => $skinr_value) {
-            if (drupal_substr($skinr_key, 0, drupal_strlen('display-' . $form_state['display']->did)) == 'display-' . $form_state['display']->did) {
-              $skinr_data[$theme_name][$skinr_key] = $skinr_value;
-            }
-          }
-        }
-      }
-      $skinr_data[$theme_name][$sid] = $value;
-      ctools_object_cache_set('skinr', $form_state['display']->did, $skinr_data);
-    }
-  }
-}
-
-/**
- * @todo remove values from skinr if a display is deleted
- */
-function panels_skinr_submit_handler_display(&$form, $form_state, $module, $form_settings) {
-  $form_id = $form_state['values']['form_id'];
-
-  // Include ctools' object cache files.
-  ctools_include('object-cache');
-
-  if ($form_state['values']['op'] == t('Save') || $form_state['values']['op'] == t('Update and save')) {
-    switch ($form_id) {
-      case 'panels_panel_context_edit_content':
-      case 'page_manager_save_page_form':
-        // Panel page.
-        foreach ($form_state['page']->handler_info as $id => $info) {
-          if ($info['changed']) {
-            _panels_skinr_save_and_clear_cache($form_state['page']->handlers[$id]->conf['did']);
-          }
-        }
-        break;
-
-      case 'panels_edit_display_form':
-        // Mini panels.
-        _panels_skinr_save_and_clear_cache($form_state['display']->did);
-        break;
-    }
-  }
-  elseif ($form_state['values']['op'] == t('Cancel')) {
-    switch ($form_id) {
-      case 'page_manager_save_page_form':
-        // Panel page.
-        foreach ($form_state['page']->handler_info as $id => $info) {
-          if ($info['changed']) {
-            ctools_object_cache_clear('skinr', $form_state['page']->handlers[$id]->conf['did']);
-          }
-        }
-        break;
-
-      case 'panels_edit_display_form':
-        // Mini panels.
-        ctools_object_cache_clear('skinr', $form_state['display']->did);
-        break;
-    }
-  }
-}
-
-function _panels_skinr_save_and_clear_cache($did) {
-  if ($skinr_data = ctools_object_cache_get('skinr', $did, TRUE)) {
-    foreach ($skinr_data as $theme_name => $theme) {
-      foreach ($theme as $sid => $skins) {
-        $skinr = new stdClass();
-        $skinr->theme = $theme_name;
-        $skinr->module = 'panels';
-        $skinr->sid = $sid;
-        $skinr->skins = $skins;
-
-        skinr_set($skinr);
-      }
-    }
-    ctools_object_cache_clear('skinr', $did);
-  }
-}
-
-/**
- * Skinr preprocess_hook_callback.
- *
- * @param &$form
- *   Passes in the $form parameter from hook_form_alter().
- * @param $form_state
- *   Passes in the $form_state parameter from hook_form_alter().
- * @return
- *   The preprocess_hook we wish to use.
- */
-function panels_skinr_preprocess_hook_callback(&$form, $form_state) {
-  switch ($form['#parameters'][1]['type']) {
-    case 'display':
-      return 'panels_display';
-    case 'panel':
-      return 'panels_panel';
-    case 'pane':
-      return 'panels_pane';
-  }
-}
-
-/**
- * Skinr preprocess_hook_callback.
- *
- * @param &$form
- *   Passes in the $form parameter from hook_form_alter().
- * @param $form_state
- *   Passes in the $form_state parameter from hook_form_alter().
- * @return
- *   The preprocess_hook we wish to use.
- */
-function panels_skinr_ajax_preprocess_hook_callback(&$form, $form_state) {
-  if (strpos($form['skinr']['sid']['#value'], '-panel-') !== FALSE) {
-    return 'panels_panel';
-  }
-  elseif (strpos($form['skinr']['sid']['#value'], '-pane-') !== FALSE) {
-    return 'panels_pane';
-  }
-  else {
-    return 'panels_display';
-  }
-}
-
-/**
- * Skinr preprocess index handler.
- *
- * @param &$variables
- *   Passes in the $variables parameter from module_preprocess().
- * @return
- *   The index where we can find our values in Skinrs data structure. If an
- *   array is returned, it will loop through each index in Skinr's data
- *   structure and merge the returned classes.
- */
-function panels_skinr_preprocess_index_handler(&$variables) {
-  $index = '';
-  if (isset($variables['pane']->style['style']) && $variables['pane']->style['style'] == 'skinr') {
-    $index = 'display-' . $variables['pane']->did . '-pane-' . $variables['pane']->pid;
-  }
-  return $index;
-}
-
-//----------------------------------------------------------------------------
-// Panels hooks.
-
-/**
- * Implementation of hook_ctools_plugin_directory() to let the system know
- * we implement panels plugins.
- */
-function skinr_ctools_plugin_directory($module, $plugin) {
-  // Safety: go away if CTools is not at an appropriate version.
-  if (!module_invoke('ctools', 'api_version', PANELS_REQUIRED_CTOOLS_API)) {
-    return;
-  }
-  if ($module == 'panels') {
-    return 'modules/panels';
-  }
-}
-
-/**
- * @}
- */
Index: modules/panels.skinr.plugin.inc
===================================================================
RCS file: modules/panels.skinr.plugin.inc
diff -N modules/panels.skinr.plugin.inc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ modules/panels.skinr.plugin.inc	16 Oct 2010 19:44:26 -0000
@@ -0,0 +1,413 @@
+<?php
+// $Id: panels.skinr.inc,v 1.13 2010/06/02 13:16:58 moonray Exp $
+/**
+ * @file
+ * Provide skinr handling for panels.module.
+ */
+
+/**
+ * @defgroup skinr_panels_module panels.module handlers.
+ *
+ * @{
+ */
+
+/**
+ * Implementation of hook_skinr_config().
+ */
+function panels_skinr_config() {
+  $data['panels']['form']['panels_edit_style_settings_form'] = array(
+    'index_handler' => 'panels_skinr_form_index_handler',
+    'data_handler' => 'panels_skinr_data_handler',
+    'submit_handler' => 'panels_skinr_submit_handler_settings',
+    'preprocess_hook_callback' => 'panels_skinr_preprocess_hook_callback',
+    'title' => t('panel pane settings'),
+    'skinr_weight' => 0,
+    'collapsed' => FALSE,
+  );
+  // AJAX form.
+  $data['panels']['form']['skinr_ui_form'] = array(
+    'preprocess_hook_callback' => 'panels_skinr_ajax_preprocess_hook_callback',
+    'title' => t('panel pane settings'),
+    'collapsed' => FALSE,
+  );
+  // Panel pages.
+  $data['panels']['form']['page_manager_save_page_form'] = array(
+    'access_handler' => 'panels_skinr_access_handler_display',
+    'submit_handler' => 'panels_skinr_submit_handler_display',
+  );
+  // Content form for panel pages.
+  $data['panels']['form']['panels_panel_context_edit_content'] = array(
+    'access_handler' => 'panels_skinr_access_handler_display',
+    'submit_handler' => 'panels_skinr_submit_handler_display',
+  );
+  // Mini panels.
+  $data['panels']['form']['panels_edit_display_form'] = array(
+    'access_handler' => 'panels_skinr_access_handler_display',
+    'submit_handler' => 'panels_skinr_submit_handler_display',
+  );
+  $data['panels']['preprocess']['panels_pane'] = array(
+    'index_handler' => 'panels_skinr_preprocess_index_handler',
+  );
+
+  return $data;
+}
+
+/**
+ * Skinr form index handler.
+ *
+ * @param $op
+ *   What kind of action is being performed. Possible values:
+ *   - "form": the form elements for Skinr are being inserted in a form
+ *   - "submit": the form has been submitted.
+ * @param &$form
+ *   - For "form", passes in the $form parameter from hook_form_alter().
+ *   - For "submit", passes in the $form parameter from hook_form_submit().
+ * @param $form_state
+ *   - For "form", passes in the $form_state parameter from hook_form_alter().
+ *   - For "submit", passes in the $form_state parameter from hook_form_submit().
+ * @return
+ *   The index where we can find our values in Skinrs data structure.
+ */
+function panels_skinr_form_index_handler($op, &$form, $form_state) {
+  switch ($op) {
+    case 'form':
+    case 'submit':
+      switch ($form['#parameters'][1]['type']) {
+        case 'display':
+          return 'display-' . $form['#parameters'][1]['display']->did;
+        case 'panel':
+          return 'display-' . $form['#parameters'][1]['display']->did . '-panel-' . $form['#parameters'][1]['pid'];
+        case 'pane':
+          return 'display-' . $form['#parameters'][1]['display']->did . '-pane-' . $form['#parameters'][1]['pid'];
+      }
+  }
+}
+
+/**
+ * Skinr access handler.
+ *
+ * @param $op
+ *   What kind of action is being performed. Possible values:
+ *   - "access skinr": access to edit skinr's selector
+ *   - "access skinr classes": access to edit skinr's additional classes
+ * @param &$form
+ *   Passes in the $form parameter from hook_form_alter().
+ * @param $form_state
+ *   Passes in the $form_state parameter from hook_form_alter().
+ * @return
+ *   TRUE if we get access, FALSE if we don't.
+ */
+function panels_skinr_access_handler_display($op, &$form, $form_state) {
+  // We don't want the skinr settings form to appear on this form. We only want
+  // to intercept it so we can save our cached data.
+
+  // Since we're not using the form, we won't get our form submitter, so let's
+  // add it manually.
+
+  $form_id = $form['form_id']['#value'];
+
+  switch ($form_id) {
+    case 'panels_panel_context_edit_content':
+      // Update and save button
+
+      // Only add submit handler once.
+      if (!in_array('skinr_ui_form_submit', $form['#submit'])) {
+        $form['#submit'][] = 'skinr_ui_form_submit';
+      }
+      break;
+
+    case 'page_manager_save_page_form':
+      // Submitting a panel page.
+
+      // Only add submit handler once.
+      if (!in_array('skinr_ui_form_submit', $form['#submit'])) {
+        $form['#submit'][] = 'skinr_ui_form_submit';
+      }
+      if (isset($form['save']['#submit']) && !in_array('skinr_ui_form_submit', $form['save']['#submit'])) {
+        $form['save']['#submit'][] = 'skinr_ui_form_submit';
+      }
+      if (isset($form['cancel']['#submit']) && !in_array('skinr_ui_form_submit', $form['cancel']['#submit'])) {
+        $form['cancel']['#submit'][] = 'skinr_ui_form_submit';
+      }
+      break;
+
+    case 'panels_edit_display_form':
+      // Only add submit handler once.
+      if (!in_array('skinr_ui_form_submit', $form['#submit'])) {
+        $form['#submit'][] = 'skinr_ui_form_submit';
+      }
+      if (isset($form['buttons']['submit']['#submit']) && !in_array('skinr_ui_form_submit', $form['buttons']['submit']['#submit'])) {
+        $form['buttons']['submit']['#submit'][] = 'skinr_ui_form_submit';
+      }
+      break;
+
+    default:
+      // We only want to save or cancel on these other forms if we're dealing with a panel_page.
+      if ($form_state['task']['name'] == 'panel_page') {
+        // Only add submit handler once
+        if (!in_array('skinr_ui_form_submit', $form['#submit'])) {
+          $form['#submit'][] = 'skinr_ui_form_submit';
+        }
+        if (isset($form['buttons']['cancel']['#submit']) && !in_array('skinr_ui_form_submit', $form['buttons']['cancel']['#submit'])) {
+          $form['buttons']['cancel']['#submit'][] = 'skinr_ui_form_submit';
+        }
+      }
+      break;
+  }
+
+  return FALSE;
+}
+
+/**
+ * Skinr data handler.
+ * This is the data that populates the skinr form.
+ *
+ * @param &$form
+ *   Passes in the $form parameter from hook_form_submit().
+ * @param $form_state
+ *   Passes in the $form_state parameter from hook_form_submit().
+ * @param $module
+ *   The module that is currently being processed.
+ * @param $form_settings
+ *   The settings from hook_skinr_config() for the form that's currently being
+ *   processed.
+ * @return
+ *   TRUE if we get access, FALSE if we don't.
+ */
+function panels_skinr_data_handler(&$form, $form_state, $theme, $module, $form_settings) {
+  // Ensure we have the required index_handler.
+  if (empty($form_settings['index_handler'])) {
+    trigger_error(sprintf("No index_handler was found for form_id '%s' in module '%s'.", $form_id, $module), E_USER_ERROR);
+  }
+  $index = skinr_handler('form_index_handler', 'form', $form_settings['index_handler'], $form, $form_state);
+
+  // Fetch skinr data for this view from cache.
+  ctools_include('object-cache');
+
+  if ($skinr_data = ctools_object_cache_get('skinr', $form_state['display']->did, TRUE)) {
+    if (isset($skinr_data[$theme][$index])) {
+      return $skinr_data[$theme][$index];
+    }
+    else {
+      return array();
+    }
+  }
+
+  // No data exists in cache, so let's grab it from the regular source.
+  return skinr_get($theme, $module, $index);
+}
+
+/**
+ * Skinr submit handler.
+ *
+ * @param $op
+ *   What kind of action is being performed. Possible values:
+ *   - "access skinr": access to edit skinr's selector
+ *   - "access skinr classes": access to edit skinr's additional classes
+ * @param &$form
+ *   Passes in the $form parameter from hook_form_alter().
+ * @param $form_state
+ *   Passes in the $form_state parameter from hook_form_alter().
+ * @return
+ *   TRUE if we get access, FALSE if we don't.
+ */
+function panels_skinr_submit_handler_settings(&$form, $form_state, $module, $form_settings) {
+  foreach ($form_state['values']['skinr_settings'][$module . '_group'] as $theme_name => $theme) {
+    if ((isset($theme['widgets']) && count($theme['widgets'])) || isset($theme['_additional'])) {
+      $hook  = $module;
+      $sid   = skinr_handler('form_index_handler', 'submit', $form_settings['index_handler'], $form, $form_state);
+
+      // Key doesn't exist properly for new displays. Perhaps we should inject a timestamp based key into the display object
+      // and use that for reference on the final submit? If it works...
+
+      $value = array();
+
+      if (is_array($theme['widgets'])) {
+        foreach ($theme['widgets'] as $skin_id => $skin_value) {
+          $value[$skin_id] = $skin_value;
+        }
+      }
+
+      if (isset($theme['_additional'])) {
+        $theme['_additional'] = trim($theme['_additional']);
+        if (!empty($theme['_additional'])) {
+          $value['_additional'] = $theme['_additional'];
+        }
+      }
+
+      if (isset($theme['_template'])) {
+        $theme['_template'] = trim($theme['_template']);
+        if (!empty($theme['_template'])) {
+          $value['_template'] = $theme['_template'];
+        }
+      }
+
+      if (empty($sid)) {
+        // We didn't receive a valid sid, so raise an error.
+        drupal_set_message(t("Skinr settings weren't saved due to an error."), 'error');
+      }
+
+      // Save skinr_settings for this panel display in cache.
+      ctools_include('object-cache');
+      if (!$skinr_data = ctools_object_cache_get('skinr', $form_state['display']->did, TRUE)) {
+        $skinr_data = array();
+        // Fetch skinr data.
+        $skinr = skinr_get($theme_name);
+        if (isset($skinr[$module])) {
+          foreach ($skinr[$module] as $skinr_key => $skinr_value) {
+            if (drupal_substr($skinr_key, 0, drupal_strlen('display-' . $form_state['display']->did)) == 'display-' . $form_state['display']->did) {
+              $skinr_data[$theme_name][$skinr_key] = $skinr_value;
+            }
+          }
+        }
+      }
+      $skinr_data[$theme_name][$sid] = $value;
+      ctools_object_cache_set('skinr', $form_state['display']->did, $skinr_data);
+    }
+  }
+}
+
+/**
+ * @todo remove values from skinr if a display is deleted
+ */
+function panels_skinr_submit_handler_display(&$form, $form_state, $module, $form_settings) {
+  $form_id = $form_state['values']['form_id'];
+
+  // Include ctools' object cache files.
+  ctools_include('object-cache');
+
+  if ($form_state['values']['op'] == t('Save') || $form_state['values']['op'] == t('Update and save')) {
+    switch ($form_id) {
+      case 'panels_panel_context_edit_content':
+      case 'page_manager_save_page_form':
+        // Panel page.
+        foreach ($form_state['page']->handler_info as $id => $info) {
+          if ($info['changed']) {
+            _panels_skinr_save_and_clear_cache($form_state['page']->handlers[$id]->conf['did']);
+          }
+        }
+        break;
+
+      case 'panels_edit_display_form':
+        // Mini panels.
+        _panels_skinr_save_and_clear_cache($form_state['display']->did);
+        break;
+    }
+  }
+  elseif ($form_state['values']['op'] == t('Cancel')) {
+    switch ($form_id) {
+      case 'page_manager_save_page_form':
+        // Panel page.
+        foreach ($form_state['page']->handler_info as $id => $info) {
+          if ($info['changed']) {
+            ctools_object_cache_clear('skinr', $form_state['page']->handlers[$id]->conf['did']);
+          }
+        }
+        break;
+
+      case 'panels_edit_display_form':
+        // Mini panels.
+        ctools_object_cache_clear('skinr', $form_state['display']->did);
+        break;
+    }
+  }
+}
+
+function _panels_skinr_save_and_clear_cache($did) {
+  if ($skinr_data = ctools_object_cache_get('skinr', $did, TRUE)) {
+    foreach ($skinr_data as $theme_name => $theme) {
+      foreach ($theme as $sid => $skins) {
+        $skinr = new stdClass();
+        $skinr->theme = $theme_name;
+        $skinr->module = 'panels';
+        $skinr->sid = $sid;
+        $skinr->skins = $skins;
+
+        skinr_set($skinr);
+      }
+    }
+    ctools_object_cache_clear('skinr', $did);
+  }
+}
+
+/**
+ * Skinr preprocess_hook_callback.
+ *
+ * @param &$form
+ *   Passes in the $form parameter from hook_form_alter().
+ * @param $form_state
+ *   Passes in the $form_state parameter from hook_form_alter().
+ * @return
+ *   The preprocess_hook we wish to use.
+ */
+function panels_skinr_preprocess_hook_callback(&$form, $form_state) {
+  switch ($form['#parameters'][1]['type']) {
+    case 'display':
+      return 'panels_display';
+    case 'panel':
+      return 'panels_panel';
+    case 'pane':
+      return 'panels_pane';
+  }
+}
+
+/**
+ * Skinr preprocess_hook_callback.
+ *
+ * @param &$form
+ *   Passes in the $form parameter from hook_form_alter().
+ * @param $form_state
+ *   Passes in the $form_state parameter from hook_form_alter().
+ * @return
+ *   The preprocess_hook we wish to use.
+ */
+function panels_skinr_ajax_preprocess_hook_callback(&$form, $form_state) {
+  if (strpos($form['skinr']['sid']['#value'], '-panel-') !== FALSE) {
+    return 'panels_panel';
+  }
+  elseif (strpos($form['skinr']['sid']['#value'], '-pane-') !== FALSE) {
+    return 'panels_pane';
+  }
+  else {
+    return 'panels_display';
+  }
+}
+
+/**
+ * Skinr preprocess index handler.
+ *
+ * @param &$variables
+ *   Passes in the $variables parameter from module_preprocess().
+ * @return
+ *   The index where we can find our values in Skinrs data structure. If an
+ *   array is returned, it will loop through each index in Skinr's data
+ *   structure and merge the returned classes.
+ */
+function panels_skinr_preprocess_index_handler(&$variables) {
+  $index = '';
+  if (isset($variables['pane']->style['style']) && $variables['pane']->style['style'] == 'skinr') {
+    $index = 'display-' . $variables['pane']->did . '-pane-' . $variables['pane']->pid;
+  }
+  return $index;
+}
+
+//----------------------------------------------------------------------------
+// Panels hooks.
+
+/**
+ * Implementation of hook_ctools_plugin_directory() to let the system know
+ * we implement panels plugins.
+ */
+function skinr_ctools_plugin_directory($module, $plugin) {
+  // Safety: go away if CTools is not at an appropriate version.
+  if (!module_invoke('ctools', 'api_version', PANELS_REQUIRED_CTOOLS_API)) {
+    return;
+  }
+  if ($module == 'panels') {
+    return 'modules/panels';
+  }
+}
+
+/**
+ * @}
+ */
Index: modules/skinr.skinr.inc
===================================================================
RCS file: modules/skinr.skinr.inc
diff -N modules/skinr.skinr.inc
--- modules/skinr.skinr.inc	2 Jun 2010 13:16:58 -0000	1.6
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,168 +0,0 @@
-<?php
-// $Id: skinr.skinr.inc,v 1.6 2010/06/02 13:16:58 moonray Exp $
-/**
- * @file
- * Provide skinr handling for page level rules.
- */
-
-/**
- * @defgroup skinr page rule handlers
- *
- * @{
- */
-
-/**
- * Implementation of hook_skinr_config().
- */
-function skinr_skinr_config() {
-  $data['rules']['form']['skinr_rule_edit'] = array(
-    'index_handler' => 'rules_skinr_form_index_handler',
-    'preprocess_hook_callback' => 'rules_skinr_preprocess_hook_callback',
-    'title' => t('rule settings'),
-    'skinr_weight' => 0,
-    'collapsed' => FALSE,
-  );
-  $data['rules']['form']['skinr_ui_form'] = array(
-    'preprocess_hook_callback' => 'rules_skinr_preprocess_hook_callback',
-    'title' => t('rule settings'),
-    'collapsed' => FALSE,
-  );
-  $data['rules']['preprocess']['html'] = array(
-    'index_handler' => 'rules_skinr_preprocess_index_handler',
-  );
-  $data['rules']['preprocess']['region'] = array(
-    'index_handler' => 'rules_skinr_preprocess_index_handler',
-  );
-  $data['rules']['contextual_links']['html'] = array(
-    'contextual_links_handler' => 'rules_skinr_contextual_links',
-  );
-  $data['rules']['contextual_links']['region'] = array(
-    'contextual_links_handler' => 'rules_skinr_contextual_links',
-  );
-
-  return $data;
-}
-
-/**
- * Skinr form index handler.
- *
- * @param $op
- *   What kind of action is being performed. Possible values:
- *   - "form": the form elements for Skinr are being inserted in a form
- *   - "submit": the form has been submitted.
- * @param &$form
- *   - For "form", passes in the $form parameter from hook_form_alter().
- *   - For "submit", passes in the $form parameter from hook_form_submit().
- * @param $form_state
- *   - For "form", passes in the $form_state parameter from hook_form_alter().
- *   - For "submit", passes in the $form_state parameter from hook_form_submit().
- * @return
- *   The index where we can find our values in Skinr's data structure.
- */
-function rules_skinr_form_index_handler($op, &$form, $form_state) {
-  switch ($op) {
-    case 'form':
-      if (!empty($form['rule']['rid']['#value'])) {
-        return $form['rule']['rid']['#value'];
-      }
-      else {
-        return 0;
-      }
-
-    case 'submit':
-      return $form_state['values']['rid'];
-  }
-}
-
-/**
- * Skinr preprocess_hook_callback.
- *
- * @param &$form
- *   Passes in the $form parameter from hook_form_alter().
- * @param $form_state
- *   Passes in the $form_state parameter from hook_form_alter().
- * @return
- *   The preprocess_hook we wish to use.
- */
-function rules_skinr_preprocess_hook_callback(&$form, $form_state) {
-  if (!empty($form['rule'])) {
-    return $form['rule']['rule_type']['#value'];
-  }
-  else {
-    $rule = skinr_rule_load($form['skinr']['sid']['#value']);
-    return $rule->rule_type;
-  }
-}
-
-/**
- * Skinr preprocess index handler.
- *
- * @param &$variables
- *   Passes in the $variables parameter from module_preprocess().
- * @return
- *   The index where we can find our values in Skinrs data structure. If an
- *   array is returned, it will loop through each index in Skinr's data
- *   structure and merge the returned classes.
- */
-function rules_skinr_preprocess_index_handler(&$variables) {
-  if (!empty($variables['region'])) {
-    $rule_type = 'region__' . $variables['region'];
-  }
-  else {
-    $rule_type = 'page';
-  }
-  $rules = skinr_rule_load_multiple(array(), array('rule_type' => $rule_type));
-
-  // Find any page level skinr options and return an array of them.
-  $indices = array();
-  foreach ($rules as $rule) {
-    if (skinr_rule_visible($rule->rid)) {
-      $indices[] = $rule->rid;
-    }
-  }
-  return $indices;
-}
-
-/**
- * Skinr contextual links handler.
- *
- * @param &$variables
- *   Passes in the $variables parameter from skinr_preprocess().
- * @return
- *   An associative array. Each value is an array that forms the function
- *   arguments for menu_contextual_links(). For example:
- *   @code
- *    $links = array(
- *      'skinr-modulename' => array(
- *        'admin/appearance/skinr/edit', array('system', 'navigation')),
- *      ),
- *      'skinr-modulename-1' => array(
- *        'admin/appearance/skinr/edit', array('system', 'something-else')),
- *      ),
- *    );
- *   @endcode
- */
-function rules_skinr_contextual_links(&$variables) {
-  if (!empty($variables['region'])) {
-    $rule_type = 'region__' . $variables['region'];
-  }
-  else {
-    $rule_type = 'page';
-  }
-  $rules = skinr_rule_load_multiple(array(), array('rule_type' => 'page'));
-  $links = array();
-  $counter = 1;
-
-  foreach ($rules as $rule) {
-    if (skinr_rule_visible($rule->rid)) {
-      $links['skinr-rule-' . $counter++] = array(
-        'admin/config/skinr/edit/nojs', array('page', $rule->rid),
-      );
-    }
-  }
-  return $links;
-}
-
-/**
- * @}
- */
Index: modules/skinr.skinr.plugin.inc
===================================================================
RCS file: modules/skinr.skinr.plugin.inc
diff -N modules/skinr.skinr.plugin.inc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ modules/skinr.skinr.plugin.inc	16 Oct 2010 19:44:27 -0000
@@ -0,0 +1,168 @@
+<?php
+// $Id: skinr.skinr.inc,v 1.6 2010/06/02 13:16:58 moonray Exp $
+/**
+ * @file
+ * Provide skinr handling for page level rules.
+ */
+
+/**
+ * @defgroup skinr page rule handlers
+ *
+ * @{
+ */
+
+/**
+ * Implementation of hook_skinr_config().
+ */
+function skinr_skinr_config() {
+  $data['rules']['form']['skinr_rule_edit'] = array(
+    'index_handler' => 'rules_skinr_form_index_handler',
+    'preprocess_hook_callback' => 'rules_skinr_preprocess_hook_callback',
+    'title' => t('rule settings'),
+    'skinr_weight' => 0,
+    'collapsed' => FALSE,
+  );
+  $data['rules']['form']['skinr_ui_form'] = array(
+    'preprocess_hook_callback' => 'rules_skinr_preprocess_hook_callback',
+    'title' => t('rule settings'),
+    'collapsed' => FALSE,
+  );
+  $data['rules']['preprocess']['html'] = array(
+    'index_handler' => 'rules_skinr_preprocess_index_handler',
+  );
+  $data['rules']['preprocess']['region'] = array(
+    'index_handler' => 'rules_skinr_preprocess_index_handler',
+  );
+  $data['rules']['contextual_links']['html'] = array(
+    'contextual_links_handler' => 'rules_skinr_contextual_links',
+  );
+  $data['rules']['contextual_links']['region'] = array(
+    'contextual_links_handler' => 'rules_skinr_contextual_links',
+  );
+
+  return $data;
+}
+
+/**
+ * Skinr form index handler.
+ *
+ * @param $op
+ *   What kind of action is being performed. Possible values:
+ *   - "form": the form elements for Skinr are being inserted in a form
+ *   - "submit": the form has been submitted.
+ * @param &$form
+ *   - For "form", passes in the $form parameter from hook_form_alter().
+ *   - For "submit", passes in the $form parameter from hook_form_submit().
+ * @param $form_state
+ *   - For "form", passes in the $form_state parameter from hook_form_alter().
+ *   - For "submit", passes in the $form_state parameter from hook_form_submit().
+ * @return
+ *   The index where we can find our values in Skinr's data structure.
+ */
+function rules_skinr_form_index_handler($op, &$form, $form_state) {
+  switch ($op) {
+    case 'form':
+      if (!empty($form['rule']['rid']['#value'])) {
+        return $form['rule']['rid']['#value'];
+      }
+      else {
+        return 0;
+      }
+
+    case 'submit':
+      return $form_state['values']['rid'];
+  }
+}
+
+/**
+ * Skinr preprocess_hook_callback.
+ *
+ * @param &$form
+ *   Passes in the $form parameter from hook_form_alter().
+ * @param $form_state
+ *   Passes in the $form_state parameter from hook_form_alter().
+ * @return
+ *   The preprocess_hook we wish to use.
+ */
+function rules_skinr_preprocess_hook_callback(&$form, $form_state) {
+  if (!empty($form['rule'])) {
+    return $form['rule']['rule_type']['#value'];
+  }
+  else {
+    $rule = skinr_rule_load($form['skinr']['sid']['#value']);
+    return $rule->rule_type;
+  }
+}
+
+/**
+ * Skinr preprocess index handler.
+ *
+ * @param &$variables
+ *   Passes in the $variables parameter from module_preprocess().
+ * @return
+ *   The index where we can find our values in Skinrs data structure. If an
+ *   array is returned, it will loop through each index in Skinr's data
+ *   structure and merge the returned classes.
+ */
+function rules_skinr_preprocess_index_handler(&$variables) {
+  if (!empty($variables['region'])) {
+    $rule_type = 'region__' . $variables['region'];
+  }
+  else {
+    $rule_type = 'page';
+  }
+  $rules = skinr_rule_load_multiple(array(), array('rule_type' => $rule_type));
+
+  // Find any page level skinr options and return an array of them.
+  $indices = array();
+  foreach ($rules as $rule) {
+    if (skinr_rule_visible($rule->rid)) {
+      $indices[] = $rule->rid;
+    }
+  }
+  return $indices;
+}
+
+/**
+ * Skinr contextual links handler.
+ *
+ * @param &$variables
+ *   Passes in the $variables parameter from skinr_preprocess().
+ * @return
+ *   An associative array. Each value is an array that forms the function
+ *   arguments for menu_contextual_links(). For example:
+ *   @code
+ *    $links = array(
+ *      'skinr-modulename' => array(
+ *        'admin/appearance/skinr/edit', array('system', 'navigation')),
+ *      ),
+ *      'skinr-modulename-1' => array(
+ *        'admin/appearance/skinr/edit', array('system', 'something-else')),
+ *      ),
+ *    );
+ *   @endcode
+ */
+function rules_skinr_contextual_links(&$variables) {
+  if (!empty($variables['region'])) {
+    $rule_type = 'region__' . $variables['region'];
+  }
+  else {
+    $rule_type = 'page';
+  }
+  $rules = skinr_rule_load_multiple(array(), array('rule_type' => 'page'));
+  $links = array();
+  $counter = 1;
+
+  foreach ($rules as $rule) {
+    if (skinr_rule_visible($rule->rid)) {
+      $links['skinr-rule-' . $counter++] = array(
+        'admin/config/skinr/edit/nojs', array('page', $rule->rid),
+      );
+    }
+  }
+  return $links;
+}
+
+/**
+ * @}
+ */
Index: modules/views.skinr.inc
===================================================================
RCS file: modules/views.skinr.inc
diff -N modules/views.skinr.inc
--- modules/views.skinr.inc	2 Jun 2010 13:16:58 -0000	1.8
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,351 +0,0 @@
-<?php
-// $Id: views.skinr.inc,v 1.8 2010/06/02 13:16:58 moonray Exp $
-
-/**
- * @file
- * Provide skinr handling for node.module
- */
-
-/**
- * @defgroup skinr_node_module node.module handlers
- *
- * @{
- */
-
-/**
- * Implementation of hook_skinr_config().
- */
-function views_skinr_config() {
-  $data['views']['form']['views_ui_edit_display_form'] = array(
-    'index_handler' => 'views_skinr_form_index_handler',
-    'access_handler' => 'views_skinr_access_handler_display',
-    'data_handler' => 'views_skinr_data_handler',
-    'submit_handler' => 'views_skinr_submit_handler_display',
-    'submit_handler_attach_to' => array('buttons', 'submit', '#submit'),
-    'preprocess_hook_callback' => 'views_skinr_preprocess_hook_callback',
-    'title' => t('views style settings'),
-    'skinr_weight' => 0,
-    'collapsed' => FALSE,
-  );
-  $data['views']['form']['views_ui_edit_view_form'] = array(
-    'access_handler' => 'views_skinr_access_handler_view',
-    'submit_handler' => 'views_skinr_submit_handler_view',
-  );
-  $data['views']['form']['skinr_ui_form'] = array(
-    'index_handler' => 'skinr_ajax_index_handler',
-    'preprocess_hook_callback' => 'views_skinr_preprocess_hook_callback',
-    'title' => t('views style settings'),
-    'collapsed' => FALSE,
-  );
-  $data['views']['preprocess']['views_view'] = array(
-    'index_handler' => 'views_skinr_preprocess_index_handler',
-  );
-
-  return $data;
-}
-
-/**
- * Skinr form index handler.
- *
- * @param $op
- *   What kind of action is being performed. Possible values:
- *   - "form": the form elements for Skinr are being inserted in a form
- *   - "submit": the form has been submitted.
- * @param &$form
- *   - For "form", passes in the $form parameter from hook_form_alter().
- *   - For "submit", passes in the $form parameter from hook_form_submit().
- * @param $form_state
- *   - For "form", passes in the $form_state parameter from hook_form_alter().
- *   - For "submit", passes in the $form_state parameter from hook_form_submit().
- * @return
- *   The index where we can find our values in Skinrs data structure.
- */
-function views_skinr_form_index_handler($op, &$form, $form_state) {
-  switch ($op) {
-    case 'form':
-      $default = $form_state['view']->display_handler->is_defaulted('style_options');
-      if ($default) {
-        return 'view-'. $form_state['view']->name .'-display-default';
-      }
-      else {
-        return 'view-'. $form_state['view']->name .'-display-'. $form_state['view']->current_display;
-      }
-
-    case 'submit':
-      // Can't use display_handler->is_defaulted('style_options') on submit
-      $default = ($form_state['#section'] == 'default-style_options');
-      if ($default) {
-        return 'view-'. $form_state['view']->name .'-display-default';
-      }
-      else {
-        return 'view-'. $form_state['view']->name .'-display-'. $form_state['display_id'];
-      }
-  }
-}
-
-/**
- * Skinr access handler.
- *
- * @param $op
- *   What kind of action is being performed. Possible values:
- *   - "access skinr": access to edit skinr's selector
- *   - "access skinr classes": access to edit skinr's additional classes
- * @param &$form
- *   Passes in the $form parameter from hook_form_alter().
- * @param $form_state
- *   Passes in the $form_state parameter from hook_form_alter().
- * @return
- *   TRUE if we get access, FALSE if we don't.
- */
-function views_skinr_access_handler_display($op, &$form, $form_state) {
-  if ($access = skinr_access_handler($op, $form, $form_state)) {
-    // Views uses the same form_id for all forms, but it sets a $section
-    // variable to distinguish between them. So only show the skinr settings
-    // form on the style options form.
-    if ($form_state['section'] != 'style_options') {
-      $access = FALSE;
-    }
-  }
-
-  return $access;
-}
-
-function views_skinr_access_handler_view($op, &$form, $form_state) {
-  // We don't want the skinr settings form to appear on this form. We only want
-  // to intercept it so we can save our cached data.
-
-  // Since we're not using the form, we won't get our form submitter, so let's
-  // add it manually.
-
-  // Only add submit handler once
-  if (!in_array('skinr_ui_form_submit', $form['#submit'])) {
-    $form['#submit'][] = 'skinr_ui_form_submit';
-  }
-  // Special for views
-  if (isset($form['buttons']['save']['#submit']) && !in_array('skinr_ui_form_submit', $form['buttons']['save']['#submit'])) {
-    $form['buttons']['save']['#submit'][] = 'skinr_ui_form_submit';
-  }
-  if (isset($form['buttons']['cancel']['#submit']) && !in_array('skinr_ui_form_submit', $form['buttons']['cancel']['#submit'])) {
-    // Need to make this happen before views' submit handler because it hijacks
-    // things and does a drupal_goto(). That effectively prevents any other
-    // submit handlers from being processed.
-    array_unshift($form['buttons']['cancel']['#submit'], 'skinr_ui_form_submit');
-  }
-
-  return FALSE;
-}
-
-/**
- * Skinr data handler.
- * This is the data that populates the skinr form.
- *
- * @param &$form
- *   Passes in the $form parameter from hook_form_submit().
- * @param $form_state
- *   Passes in the $form_state parameter from hook_form_submit().
- * @param $module
- *   The module that is currently being processed.
- * @param $form_settings
- *   The settings from hook_skinr_config() for the form that's currently being
- *   processed.
- * @return
- *   A skinr object.
- */
-function views_skinr_data_handler(&$form, $form_state, $theme, $module, $form_settings) {
-  // Ensure we have the required index_handler
-  if (empty($form_settings['index_handler'])) {
-    trigger_error(sprintf("No index_handler was found for form_id '%s' in module '%s'.", $form_id, $module), E_USER_ERROR);
-  }
-  $index = skinr_handler('form_index_handler', 'form', $form_settings['index_handler'], $form, $form_state);
-
-  // Fetch skinr data for this view from cache
-  views_include('cache');
-
-  if ($skinrs = views_object_cache_get('skinr', $form_state['view']->name)) {
-    if (isset($skinrs[$theme][$index])) {
-      $skinr = new stdClass();
-      $skinr->theme = $theme;
-      $skinr->module = $module;
-      $skinr->sid = $index;
-      $skinr->skins = $skinrs[$theme][$index];
-
-      return $skinr;
-    }
-    else {
-      return array();
-    }
-  }
-
-  // No data exists in cache, so let's grab it from the regular source
-  return skinr_get($theme, $module, $index);
-}
-
-/**
- * Skinr submit handler.
- *
- * @param $op
- *   What kind of action is being performed. Possible values:
- *   - "access skinr": access to edit skinr's selector
- *   - "access skinr classes": access to edit skinr's additional classes
- * @param &$form
- *   Passes in the $form parameter from hook_form_alter().
- * @param $form_state
- *   Passes in the $form_state parameter from hook_form_alter().
- * @return
- *   TRUE if we get access, FALSE if we don't.
- */
-function views_skinr_submit_handler_display(&$form, $form_state, $module, $form_settings) {
-  foreach ($form_state['values']['skinr_settings'][$module .'_group'] as $theme_name => $theme) {
-    if ((isset($theme['widgets']) && count($theme['widgets'])) || isset($theme['_additional'])) {
-      $sid   = skinr_handler('form_index_handler', 'submit', $form_settings['index_handler'], $form, $form_state);
-      $value = array();
-
-      if (is_array($theme['widgets'])) {
-        foreach ($theme['widgets'] as $skin_id => $skin_value) {
-          $value[$skin_id] = $skin_value;
-        }
-      }
-
-      if (isset($theme['_additional'])) {
-        $theme['_additional'] = trim($theme['_additional']);
-        if (!empty($theme['_additional'])) {
-          $value['_additional'] = $theme['_additional'];
-        }
-      }
-
-      if (isset($theme['_template'])) {
-        $theme['_template'] = trim($theme['_template']);
-        if (!empty($theme['_template'])) {
-          $value['_template'] = $theme['_template'];
-        }
-      }
-
-      if (empty($sid)) {
-        // We didn't receive a valid sid, so raise an error
-        drupal_set_message(t("Skinr settings weren't saved due to an error."), 'error');
-      }
-
-      // Save skinr_settings for this view in cache
-      views_include('cache');
-      if (!$skinrs = views_object_cache_get('skinr', $form_state['view']->name, TRUE)) {
-        $skinrs = array();
-        // Fetch skinr data
-        $skinr = skinr_get($theme_name);
-        if (isset($skinr[$module])) {
-          foreach ($skinr[$module] as $skinr_key => $skinr_value) {
-            if (drupal_substr($skinr_key, 0, drupal_strlen('view-'. $form_state['view']->name)) == 'view-'. $form_state['view']->name) {
-              $skinrs[$theme_name][$skinr_key] = $skinr_value;
-            }
-          }
-        }
-      }
-      $skinrs[$theme_name][$sid] = $value;
-      views_object_cache_set('skinr', $form_state['view']->name, $skinrs);
-    }
-  }
-}
-
-function views_skinr_submit_handler_view(&$form, $form_state, $module, $form_settings) {
-  switch ($form_state['values']['op']) {
-    case t('Save'):
-      // Fetch skinr data for this view from cache
-      views_include('cache');
-
-      if ($skinrs = views_object_cache_get('skinr', $form_state['view']->name, TRUE)) {
-        foreach ($skinrs as $theme_name => $theme) {
-          foreach ($theme as $sid => $skins) {
-            $skinr = new stdClass();
-            $skinr->theme = $theme_name;
-            $skinr->module = $module;
-            $skinr->sid = $sid;
-            $skinr->skins = $skins;
-
-            skinr_set($skinr);
-          }
-        }
-        views_object_cache_clear('skinr', $form_state['view']->name);
-      }
-      break;
-    case t('Cancel'):
-      // Remove our data from views cache
-      views_include('cache');
-
-      views_object_cache_clear('skinr', $form_state['view']->name);
-      break;
-  }
-}
-
-/**
- * Skinr form preprocess_hook callback.
- *
- * @param &$form
- *   Passes in the $form parameter from hook_form_alter().
- * @param $form_state
- *   Passes in the $form_state parameter from hook_form_alter().
- * @return
- *   The preprocess_hook we wish to use.
- */
-function views_skinr_preprocess_hook_callback(&$form, $form_state) {
-  $preprocess_hooks = array('views_view');
-
-  if (!empty($form_state['view']) && !empty($form_state['view']->name)) {
-    $view = $form_state['view'];
-  }
-  elseif(isset($form['skinr']['sid']['#value'])) {
-    $sidinfo = _views_skinr_sidinfo($form['skinr']['sid']['#value']);
-    if ($view = views_get_view($sidinfo['view'])) {
-      $view->execute_display($sidinfo['display']);
-    }
-  }
-
-  if (!empty($view)) {
-    $display = $view->display[$view->current_display];
-
-    // Create list of suggested templates.
-    $preprocess_hooks = views_theme_functions('views_view', $view, $display);
-    // Fetch additional style based suggested templates.
-    $additional_hooks = views_theme_functions($view->style_plugin->definition['theme'], $view, $display);
-
-    $preprocess_hooks = array_merge($additional_hooks, $preprocess_hooks);
-  }
-
-  return $preprocess_hooks;
-}
-
-function _views_skinr_sidinfo($sid) {
-  // view-[view_name]-display-[display_name]
-  $pos = strpos($sid, '-display-');
-  if ($pos !== FALSE) {
-    $sidinfo = array();
-    $sidinfo['view'] = substr($sid, strlen('view-'), $pos - strlen('view-'));
-    $sidinfo['display'] = substr($sid, $pos + strlen('-display-'));
-
-    return $sidinfo;
-  }
-
-  return FALSE;
-}
-
-/**
- * Skinr preprocess index handler.
- *
- * @param &$variables
- *   Passes in the $variables parameter from module_preprocess().
- * @return
- *   The index where we can find our values in Skinrs data structure. If an
- *   array is returned, it will loop through each index in Skinr's data
- *   structure and merge the returned classes.
- */
-function views_skinr_preprocess_index_handler(&$variables) {
-  $default = $variables['view']->display_handler->is_defaulted('style_options');
-  if ($default) {
-    return 'view-'. $variables['view']->name .'-display-default';
-  }
-  else {
-    return 'view-'. $variables['view']->name .'-display-'. $variables['view']->current_display;
-  }
-}
-
-/**
- * @}
- */
Index: modules/views.skinr.plugin.inc
===================================================================
RCS file: modules/views.skinr.plugin.inc
diff -N modules/views.skinr.plugin.inc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ modules/views.skinr.plugin.inc	16 Oct 2010 19:44:27 -0000
@@ -0,0 +1,351 @@
+<?php
+// $Id: views.skinr.inc,v 1.8 2010/06/02 13:16:58 moonray Exp $
+
+/**
+ * @file
+ * Provide skinr handling for node.module
+ */
+
+/**
+ * @defgroup skinr_node_module node.module handlers
+ *
+ * @{
+ */
+
+/**
+ * Implementation of hook_skinr_config().
+ */
+function views_skinr_config() {
+  $data['views']['form']['views_ui_edit_display_form'] = array(
+    'index_handler' => 'views_skinr_form_index_handler',
+    'access_handler' => 'views_skinr_access_handler_display',
+    'data_handler' => 'views_skinr_data_handler',
+    'submit_handler' => 'views_skinr_submit_handler_display',
+    'submit_handler_attach_to' => array('buttons', 'submit', '#submit'),
+    'preprocess_hook_callback' => 'views_skinr_preprocess_hook_callback',
+    'title' => t('views style settings'),
+    'skinr_weight' => 0,
+    'collapsed' => FALSE,
+  );
+  $data['views']['form']['views_ui_edit_view_form'] = array(
+    'access_handler' => 'views_skinr_access_handler_view',
+    'submit_handler' => 'views_skinr_submit_handler_view',
+  );
+  $data['views']['form']['skinr_ui_form'] = array(
+    'index_handler' => 'skinr_ajax_index_handler',
+    'preprocess_hook_callback' => 'views_skinr_preprocess_hook_callback',
+    'title' => t('views style settings'),
+    'collapsed' => FALSE,
+  );
+  $data['views']['preprocess']['views_view'] = array(
+    'index_handler' => 'views_skinr_preprocess_index_handler',
+  );
+
+  return $data;
+}
+
+/**
+ * Skinr form index handler.
+ *
+ * @param $op
+ *   What kind of action is being performed. Possible values:
+ *   - "form": the form elements for Skinr are being inserted in a form
+ *   - "submit": the form has been submitted.
+ * @param &$form
+ *   - For "form", passes in the $form parameter from hook_form_alter().
+ *   - For "submit", passes in the $form parameter from hook_form_submit().
+ * @param $form_state
+ *   - For "form", passes in the $form_state parameter from hook_form_alter().
+ *   - For "submit", passes in the $form_state parameter from hook_form_submit().
+ * @return
+ *   The index where we can find our values in Skinrs data structure.
+ */
+function views_skinr_form_index_handler($op, &$form, $form_state) {
+  switch ($op) {
+    case 'form':
+      $default = $form_state['view']->display_handler->is_defaulted('style_options');
+      if ($default) {
+        return 'view-'. $form_state['view']->name .'-display-default';
+      }
+      else {
+        return 'view-'. $form_state['view']->name .'-display-'. $form_state['view']->current_display;
+      }
+
+    case 'submit':
+      // Can't use display_handler->is_defaulted('style_options') on submit
+      $default = ($form_state['#section'] == 'default-style_options');
+      if ($default) {
+        return 'view-'. $form_state['view']->name .'-display-default';
+      }
+      else {
+        return 'view-'. $form_state['view']->name .'-display-'. $form_state['display_id'];
+      }
+  }
+}
+
+/**
+ * Skinr access handler.
+ *
+ * @param $op
+ *   What kind of action is being performed. Possible values:
+ *   - "access skinr": access to edit skinr's selector
+ *   - "access skinr classes": access to edit skinr's additional classes
+ * @param &$form
+ *   Passes in the $form parameter from hook_form_alter().
+ * @param $form_state
+ *   Passes in the $form_state parameter from hook_form_alter().
+ * @return
+ *   TRUE if we get access, FALSE if we don't.
+ */
+function views_skinr_access_handler_display($op, &$form, $form_state) {
+  if ($access = skinr_access_handler($op, $form, $form_state)) {
+    // Views uses the same form_id for all forms, but it sets a $section
+    // variable to distinguish between them. So only show the skinr settings
+    // form on the style options form.
+    if ($form_state['section'] != 'style_options') {
+      $access = FALSE;
+    }
+  }
+
+  return $access;
+}
+
+function views_skinr_access_handler_view($op, &$form, $form_state) {
+  // We don't want the skinr settings form to appear on this form. We only want
+  // to intercept it so we can save our cached data.
+
+  // Since we're not using the form, we won't get our form submitter, so let's
+  // add it manually.
+
+  // Only add submit handler once
+  if (!in_array('skinr_ui_form_submit', $form['#submit'])) {
+    $form['#submit'][] = 'skinr_ui_form_submit';
+  }
+  // Special for views
+  if (isset($form['buttons']['save']['#submit']) && !in_array('skinr_ui_form_submit', $form['buttons']['save']['#submit'])) {
+    $form['buttons']['save']['#submit'][] = 'skinr_ui_form_submit';
+  }
+  if (isset($form['buttons']['cancel']['#submit']) && !in_array('skinr_ui_form_submit', $form['buttons']['cancel']['#submit'])) {
+    // Need to make this happen before views' submit handler because it hijacks
+    // things and does a drupal_goto(). That effectively prevents any other
+    // submit handlers from being processed.
+    array_unshift($form['buttons']['cancel']['#submit'], 'skinr_ui_form_submit');
+  }
+
+  return FALSE;
+}
+
+/**
+ * Skinr data handler.
+ * This is the data that populates the skinr form.
+ *
+ * @param &$form
+ *   Passes in the $form parameter from hook_form_submit().
+ * @param $form_state
+ *   Passes in the $form_state parameter from hook_form_submit().
+ * @param $module
+ *   The module that is currently being processed.
+ * @param $form_settings
+ *   The settings from hook_skinr_config() for the form that's currently being
+ *   processed.
+ * @return
+ *   A skinr object.
+ */
+function views_skinr_data_handler(&$form, $form_state, $theme, $module, $form_settings) {
+  // Ensure we have the required index_handler
+  if (empty($form_settings['index_handler'])) {
+    trigger_error(sprintf("No index_handler was found for form_id '%s' in module '%s'.", $form_id, $module), E_USER_ERROR);
+  }
+  $index = skinr_handler('form_index_handler', 'form', $form_settings['index_handler'], $form, $form_state);
+
+  // Fetch skinr data for this view from cache
+  views_include('cache');
+
+  if ($skinrs = views_object_cache_get('skinr', $form_state['view']->name)) {
+    if (isset($skinrs[$theme][$index])) {
+      $skinr = new stdClass();
+      $skinr->theme = $theme;
+      $skinr->module = $module;
+      $skinr->sid = $index;
+      $skinr->skins = $skinrs[$theme][$index];
+
+      return $skinr;
+    }
+    else {
+      return array();
+    }
+  }
+
+  // No data exists in cache, so let's grab it from the regular source
+  return skinr_get($theme, $module, $index);
+}
+
+/**
+ * Skinr submit handler.
+ *
+ * @param $op
+ *   What kind of action is being performed. Possible values:
+ *   - "access skinr": access to edit skinr's selector
+ *   - "access skinr classes": access to edit skinr's additional classes
+ * @param &$form
+ *   Passes in the $form parameter from hook_form_alter().
+ * @param $form_state
+ *   Passes in the $form_state parameter from hook_form_alter().
+ * @return
+ *   TRUE if we get access, FALSE if we don't.
+ */
+function views_skinr_submit_handler_display(&$form, $form_state, $module, $form_settings) {
+  foreach ($form_state['values']['skinr_settings'][$module .'_group'] as $theme_name => $theme) {
+    if ((isset($theme['widgets']) && count($theme['widgets'])) || isset($theme['_additional'])) {
+      $sid   = skinr_handler('form_index_handler', 'submit', $form_settings['index_handler'], $form, $form_state);
+      $value = array();
+
+      if (is_array($theme['widgets'])) {
+        foreach ($theme['widgets'] as $skin_id => $skin_value) {
+          $value[$skin_id] = $skin_value;
+        }
+      }
+
+      if (isset($theme['_additional'])) {
+        $theme['_additional'] = trim($theme['_additional']);
+        if (!empty($theme['_additional'])) {
+          $value['_additional'] = $theme['_additional'];
+        }
+      }
+
+      if (isset($theme['_template'])) {
+        $theme['_template'] = trim($theme['_template']);
+        if (!empty($theme['_template'])) {
+          $value['_template'] = $theme['_template'];
+        }
+      }
+
+      if (empty($sid)) {
+        // We didn't receive a valid sid, so raise an error
+        drupal_set_message(t("Skinr settings weren't saved due to an error."), 'error');
+      }
+
+      // Save skinr_settings for this view in cache
+      views_include('cache');
+      if (!$skinrs = views_object_cache_get('skinr', $form_state['view']->name, TRUE)) {
+        $skinrs = array();
+        // Fetch skinr data
+        $skinr = skinr_get($theme_name);
+        if (isset($skinr[$module])) {
+          foreach ($skinr[$module] as $skinr_key => $skinr_value) {
+            if (drupal_substr($skinr_key, 0, drupal_strlen('view-'. $form_state['view']->name)) == 'view-'. $form_state['view']->name) {
+              $skinrs[$theme_name][$skinr_key] = $skinr_value;
+            }
+          }
+        }
+      }
+      $skinrs[$theme_name][$sid] = $value;
+      views_object_cache_set('skinr', $form_state['view']->name, $skinrs);
+    }
+  }
+}
+
+function views_skinr_submit_handler_view(&$form, $form_state, $module, $form_settings) {
+  switch ($form_state['values']['op']) {
+    case t('Save'):
+      // Fetch skinr data for this view from cache
+      views_include('cache');
+
+      if ($skinrs = views_object_cache_get('skinr', $form_state['view']->name, TRUE)) {
+        foreach ($skinrs as $theme_name => $theme) {
+          foreach ($theme as $sid => $skins) {
+            $skinr = new stdClass();
+            $skinr->theme = $theme_name;
+            $skinr->module = $module;
+            $skinr->sid = $sid;
+            $skinr->skins = $skins;
+
+            skinr_set($skinr);
+          }
+        }
+        views_object_cache_clear('skinr', $form_state['view']->name);
+      }
+      break;
+    case t('Cancel'):
+      // Remove our data from views cache
+      views_include('cache');
+
+      views_object_cache_clear('skinr', $form_state['view']->name);
+      break;
+  }
+}
+
+/**
+ * Skinr form preprocess_hook callback.
+ *
+ * @param &$form
+ *   Passes in the $form parameter from hook_form_alter().
+ * @param $form_state
+ *   Passes in the $form_state parameter from hook_form_alter().
+ * @return
+ *   The preprocess_hook we wish to use.
+ */
+function views_skinr_preprocess_hook_callback(&$form, $form_state) {
+  $preprocess_hooks = array('views_view');
+
+  if (!empty($form_state['view']) && !empty($form_state['view']->name)) {
+    $view = $form_state['view'];
+  }
+  elseif(isset($form['skinr']['sid']['#value'])) {
+    $sidinfo = _views_skinr_sidinfo($form['skinr']['sid']['#value']);
+    if ($view = views_get_view($sidinfo['view'])) {
+      $view->execute_display($sidinfo['display']);
+    }
+  }
+
+  if (!empty($view)) {
+    $display = $view->display[$view->current_display];
+
+    // Create list of suggested templates.
+    $preprocess_hooks = views_theme_functions('views_view', $view, $display);
+    // Fetch additional style based suggested templates.
+    $additional_hooks = views_theme_functions($view->style_plugin->definition['theme'], $view, $display);
+
+    $preprocess_hooks = array_merge($additional_hooks, $preprocess_hooks);
+  }
+
+  return $preprocess_hooks;
+}
+
+function _views_skinr_sidinfo($sid) {
+  // view-[view_name]-display-[display_name]
+  $pos = strpos($sid, '-display-');
+  if ($pos !== FALSE) {
+    $sidinfo = array();
+    $sidinfo['view'] = substr($sid, strlen('view-'), $pos - strlen('view-'));
+    $sidinfo['display'] = substr($sid, $pos + strlen('-display-'));
+
+    return $sidinfo;
+  }
+
+  return FALSE;
+}
+
+/**
+ * Skinr preprocess index handler.
+ *
+ * @param &$variables
+ *   Passes in the $variables parameter from module_preprocess().
+ * @return
+ *   The index where we can find our values in Skinrs data structure. If an
+ *   array is returned, it will loop through each index in Skinr's data
+ *   structure and merge the returned classes.
+ */
+function views_skinr_preprocess_index_handler(&$variables) {
+  $default = $variables['view']->display_handler->is_defaulted('style_options');
+  if ($default) {
+    return 'view-'. $variables['view']->name .'-display-default';
+  }
+  else {
+    return 'view-'. $variables['view']->name .'-display-'. $variables['view']->current_display;
+  }
+}
+
+/**
+ * @}
+ */
