? 711664_deprecate_global_definiton_hook.patch ? 711664_optional_global_definiton_hook.patch Index: API.txt =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/ctools/API.txt,v retrieving revision 1.5.2.14 diff -u -p -r1.5.2.14 API.txt --- API.txt 23 Feb 2010 23:14:53 -0000 1.5.2.14 +++ API.txt 27 Feb 2010 00:47:02 -0000 @@ -5,13 +5,15 @@ API version 1.4: Allow themes to provide APIs which includes default pages of all types. Intorduce ctools_css_add_css() to allow private file systems to have generated CSS. Introduce initial build of stylizer.inc to allow UI configurable styles. - Introduce 'cache warming' feature. Use 'ctools-use-ajax-cache' or + Introduce 'cache warming' feature. Use 'ctools-use-ajax-cache' or 'ctools-use-modal-cache'. Doing so will cause content to be fetched via AJAX on page load and kept warm in a cache for instant responses to clicks. Generalized ctools_add_css(). Generalized ctools_add_js(). Generalized ctools_image_path(). + Make global hooks for plugin definition optional through a 'use hooks' + plugin option. API version 1.3.2: Introduce 'export callback' to individual fields in export.inc @@ -40,13 +42,13 @@ API version 1.1.1: Introduce ctools_set_page_token(). API version 1.1.0: - delegator module destroyed, replaced by page manager. All 'task' and 'task_handler' plugins + delegator module destroyed, replaced by page manager. All 'task' and 'task_handler' plugins now owned by page_manager. Update plugin hooks accordingly. The filename for defaults for pages and handlers should now be MODULE.pages_default.inc The task_type plugin has been removed. - Task handlers no longer have a separate UI. While task handlers can still + Task handlers no longer have a separate UI. While task handlers can still be separated from pages for other purposes, they will probably need to implement their own UI to do it. Index: help/plugins-creating.html =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/ctools/help/plugins-creating.html,v retrieving revision 1.9 diff -u -p -r1.9 plugins-creating.html --- help/plugins-creating.html 22 Jun 2009 02:27:19 -0000 1.9 +++ help/plugins-creating.html 27 Feb 2010 00:47:02 -0000 @@ -69,6 +69,8 @@ The following information can be specifi
If set to TRUE, then the plugin will look for a .info file instead of a .inc. Internally, this will look exactly the same, though obviously a .info file cannot contain functions. This can be good for styles that may not need to contain code.
extension
Can be used to change the extension on a file. By default the extension will be "inc", though it will default to "info" if "info files" is set to true. Do not include the dot in the extension if changing it, that will be added automatically.
+
use hooks
+
Use to enable support for plugin definition hooks instead of plugin definition files.
In addition, there is a 'module', 'type' and 'hook' settings; these are for internal use of the plugin system and you should not change these. @@ -145,7 +147,7 @@ Or like this: ), -An example, for 'plugin_example' type +An example, for 'plugin_example' type
 $plugin = array(
Index: includes/plugins.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/ctools/includes/plugins.inc,v
retrieving revision 1.18.2.13
diff -u -p -r1.18.2.13 plugins.inc
--- includes/plugins.inc	26 Feb 2010 21:35:12 -0000	1.18.2.13
+++ includes/plugins.inc	27 Feb 2010 00:47:02 -0000
@@ -1,5 +1,5 @@
 data)) {
+      // Cache load succeeded so use the cached plugin list.
       $plugins[$module][$type]   = $cache->data;
-      $all_hooks[$module][$type] = TRUE;
-      $all_files[$module][$type] = TRUE;
+      // Set $setup to true so we know things where loaded.
+      $setup[$module][$type]     = TRUE;
     }
     else {
-      $write_cache = TRUE;
+      // Cache load failed so store that we need to build and write the cache.
+      $build_cache = TRUE;
     }
   }
 
-  // Always load all hooks if we need them.
-  if (!isset($all_hooks[$module][$type])) {
-    $all_hooks[$module][$type] = TRUE;
+  // Always load all hooks if we need them. Note we only need them now if the
+  // plugin asks for them. We can assume that if we have plugins we've already
+  // called the global hook.
+  if (!empty($info[$module][$type]['use hooks']) && empty($plugins[$module][$type])) {
     $plugins[$module][$type] = ctools_plugin_load_hooks($info[$module][$type]);
   }
 
-  // First, see if it's in our hooks before we even bother.
-  if ($id && array_key_exists($id, $plugins[$module][$type])) {
-    return $plugins[$module][$type][$id];
-  }
-
   // Then see if we should load all files. We only do this if we
-  // want a list of all plugins.
-  if ((!$id || $info[$module][$type]['cache']) && empty($all_files[$module][$type])) {
-    $all_files[$module][$type] = TRUE;
+  // want a list of all plugins or there was a cache miss.
+  if (empty($setup[$module][$type]) && ($build_cache || !$id)) {
+    $setup[$module][$type] = TRUE;
     $plugins[$module][$type] = array_merge($plugins[$module][$type], ctools_plugin_load_includes($info[$module][$type]));
   }
 
   // If we were told earlier that this is cacheable and the cache was
   // empty, give something back.
-  if (!empty($write_cache)) {
+  if ($build_cache) {
     cache_set("plugins:$module:$type", $plugins[$module][$type], $info[$module][$type]['cache table']);
   }
 
@@ -557,6 +560,7 @@ function ctools_plugin_get_info($module,
     'type' => $type,
     'cache' => FALSE,
     'cache table' => 'cache',
+    'use hooks' => FALSE,
     'defaults' => array(),
     'hook' => $module . '_' . $type,
     'load themes' => FALSE,