danielebarchiesi@0: TRUE, danielebarchiesi@0: ); danielebarchiesi@0: danielebarchiesi@0: return $plugins; danielebarchiesi@0: } danielebarchiesi@0: danielebarchiesi@0: /** danielebarchiesi@0: * This hook is used to inform the CTools plugin system about the location of a danielebarchiesi@0: * directory that should be searched for files containing plugins of a danielebarchiesi@0: * particular type. CTools invokes this same hook for all plugins, using the danielebarchiesi@0: * two passed parameters to indicate the specific type of plugin for which it danielebarchiesi@0: * is searching. danielebarchiesi@0: * danielebarchiesi@0: * The $plugin_type parameter is self-explanatory - it is the string name of the danielebarchiesi@0: * plugin type (e.g., Panels' 'layouts' or 'styles'). The $owner parameter is danielebarchiesi@0: * necessary because CTools internally namespaces plugins by the module that danielebarchiesi@0: * owns them. This is an extension of Drupal best practices on avoiding global danielebarchiesi@0: * namespace pollution by prepending your module name to all its functions. danielebarchiesi@0: * Consequently, it is possible for two different modules to create a plugin danielebarchiesi@0: * type with exactly the same name and have them operate in harmony. In fact, danielebarchiesi@0: * this system renders it impossible for modules to encroach on other modules' danielebarchiesi@0: * plugin namespaces. danielebarchiesi@0: * danielebarchiesi@0: * Given this namespacing, it is important that implementations of this hook danielebarchiesi@0: * check BOTH the $owner and $plugin_type parameters before returning a path. danielebarchiesi@0: * If your module does not implement plugins for the requested module/plugin danielebarchiesi@0: * combination, it is safe to return nothing at all (or NULL). As a convenience, danielebarchiesi@0: * it is also safe to return a path that does not exist for plugins your module danielebarchiesi@0: * does not implement - see form 2 for a use case. danielebarchiesi@0: * danielebarchiesi@0: * Note that modules implementing a plugin also must implement this hook to danielebarchiesi@0: * instruct CTools as to the location of the plugins. See form 3 for a use case. danielebarchiesi@0: * danielebarchiesi@0: * The conventional structure to return is "plugins/$plugin_type" - that is, a danielebarchiesi@0: * 'plugins' subdirectory in your main module directory, with individual danielebarchiesi@0: * directories contained therein named for the plugin type they contain. danielebarchiesi@0: * danielebarchiesi@0: * @param string $owner danielebarchiesi@0: * The system name of the module owning the plugin type for which a base danielebarchiesi@0: * directory location is being requested. danielebarchiesi@0: * @param string $plugin_type danielebarchiesi@0: * The name of the plugin type for which a base directory is being requested. danielebarchiesi@0: * @return string danielebarchiesi@0: * The path where CTools' plugin system should search for plugin files, danielebarchiesi@0: * relative to your module's root. Omit leading and trailing slashes. danielebarchiesi@0: */ danielebarchiesi@0: function hook_ctools_plugin_directory($owner, $plugin_type) { danielebarchiesi@0: // Form 1 - for a module implementing only the 'content_types' plugin owned danielebarchiesi@0: // by CTools, this would cause the plugin system to search the danielebarchiesi@0: // /plugins/content_types directory for .inc plugin files. danielebarchiesi@0: if ($owner == 'ctools' && $plugin_type == 'content_types') { danielebarchiesi@0: return 'plugins/content_types'; danielebarchiesi@0: } danielebarchiesi@0: danielebarchiesi@0: // Form 2 - if your module implements only Panels plugins, and has 'layouts' danielebarchiesi@0: // and 'styles' plugins but no 'cache' or 'display_renderers', it is OK to be danielebarchiesi@0: // lazy and return a directory for a plugin you don't actually implement (so danielebarchiesi@0: // long as that directory doesn't exist). This lets you avoid ugly in_array() danielebarchiesi@0: // logic in your conditional, and also makes it easy to add plugins of those danielebarchiesi@0: // types later without having to change this hook implementation. danielebarchiesi@0: if ($owner == 'panels') { danielebarchiesi@0: return "plugins/$plugin_type"; danielebarchiesi@0: } danielebarchiesi@0: danielebarchiesi@0: // Form 3 - CTools makes no assumptions about where your plugins are located, danielebarchiesi@0: // so you still have to implement this hook even for plugins created by your danielebarchiesi@0: // own module. danielebarchiesi@0: if ($owner == 'mymodule') { danielebarchiesi@0: // Yes, this is exactly like Form 2 - just a different reasoning for it. danielebarchiesi@0: return "plugins/$plugin_type"; danielebarchiesi@0: } danielebarchiesi@0: // Finally, if nothing matches, it's safe to return nothing at all (or NULL). danielebarchiesi@0: } danielebarchiesi@0: danielebarchiesi@0: /** danielebarchiesi@0: * Alter a plugin before it has been processed. danielebarchiesi@0: * danielebarchiesi@0: * This hook is useful for altering flags or other information that will be danielebarchiesi@0: * used or possibly overriden by the process hook if defined. danielebarchiesi@0: * danielebarchiesi@0: * @param $plugin danielebarchiesi@0: * An associative array defining a plugin. danielebarchiesi@0: * @param $info danielebarchiesi@0: * An associative array of plugin type info. danielebarchiesi@0: */ danielebarchiesi@0: function hook_ctools_plugin_pre_alter(&$plugin, &$info) { danielebarchiesi@0: // Override a function defined by the plugin. danielebarchiesi@0: if ($info['type'] == 'my_type') { danielebarchiesi@0: $plugin['my_flag'] = 'new_value'; danielebarchiesi@0: } danielebarchiesi@0: } danielebarchiesi@0: danielebarchiesi@0: /** danielebarchiesi@0: * Alter a plugin after it has been processed. danielebarchiesi@0: * danielebarchiesi@0: * This hook is useful for overriding the final values for a plugin after it danielebarchiesi@0: * has been processed. danielebarchiesi@0: * danielebarchiesi@0: * @param $plugin danielebarchiesi@0: * An associative array defining a plugin. danielebarchiesi@0: * @param $info danielebarchiesi@0: * An associative array of plugin type info. danielebarchiesi@0: */ danielebarchiesi@0: function hook_ctools_plugin_post_alter(&$plugin, &$info) { danielebarchiesi@0: // Override a function defined by the plugin. danielebarchiesi@0: if ($info['type'] == 'my_type') { danielebarchiesi@0: $plugin['my_function'] = 'new_function'; danielebarchiesi@0: } danielebarchiesi@0: } danielebarchiesi@0: danielebarchiesi@0: /** danielebarchiesi@0: * Alter the list of modules/themes which implement a certain api. danielebarchiesi@0: * danielebarchiesi@0: * The hook named here is just an example, as the real existing hooks are named danielebarchiesi@0: * for example 'hook_views_api_alter'. danielebarchiesi@0: * danielebarchiesi@0: * @param array $list danielebarchiesi@0: * An array of informations about the implementors of a certain api. danielebarchiesi@0: * The key of this array are the module names/theme names. danielebarchiesi@0: */ danielebarchiesi@0: function hook_ctools_api_hook_alter(&$list) { danielebarchiesi@0: // Alter the path of the node implementation. danielebarchiesi@0: $list['node']['path'] = drupal_get_path('module', 'node'); danielebarchiesi@0: } danielebarchiesi@0: danielebarchiesi@0: /** danielebarchiesi@0: * Alter the available functions to be used in ctools math expression api. danielebarchiesi@0: * danielebarchiesi@0: * One usecase would be to create your own function in your module and danielebarchiesi@0: * allow to use it in the math expression api. danielebarchiesi@0: * danielebarchiesi@0: * @param $functions danielebarchiesi@0: * An array which has the functions as value. danielebarchiesi@0: */ danielebarchiesi@0: function hook_ctools_math_expression_functions_alter(&$functions) { danielebarchiesi@0: // Allow to convert from degrees to radiant. danielebarchiesi@0: $functions[] = 'deg2rad'; danielebarchiesi@0: } danielebarchiesi@0: danielebarchiesi@0: /** danielebarchiesi@0: * Alter everything. danielebarchiesi@0: * danielebarchiesi@0: * @param $info danielebarchiesi@0: * An associative array containing the following keys: danielebarchiesi@0: * - content: The rendered content. danielebarchiesi@0: * - title: The content's title. danielebarchiesi@0: * - no_blocks: A boolean to decide if blocks should be displayed. danielebarchiesi@0: * @param $page danielebarchiesi@0: * If TRUE then this renderer owns the page and can use theme('page') danielebarchiesi@0: * for no blocks; if false, output is returned regardless of any no danielebarchiesi@0: * blocks settings. danielebarchiesi@0: * @param $context danielebarchiesi@0: * An associative array containing the following keys: danielebarchiesi@0: * - args: The raw arguments behind the contexts. danielebarchiesi@0: * - contexts: The context objects in use. danielebarchiesi@0: * - task: The task object in use. danielebarchiesi@0: * - subtask: The subtask object in use. danielebarchiesi@0: * - handler: The handler object in use. danielebarchiesi@0: */ danielebarchiesi@0: function hook_ctools_render_alter(&$info, &$page, &$context) { danielebarchiesi@0: if ($context['handler']->name == 'my_handler') { danielebarchiesi@0: ctools_add_css('my_module.theme', 'my_module'); danielebarchiesi@0: } danielebarchiesi@0: } danielebarchiesi@0: danielebarchiesi@0: /** danielebarchiesi@0: * Alter a content plugin subtype. danielebarchiesi@0: * danielebarchiesi@0: * While content types can be altered via hook_ctools_plugin_pre_alter() or danielebarchiesi@0: * hook_ctools_plugin_post_alter(), the subtypes that content types rely on danielebarchiesi@0: * are special and require their own hook. danielebarchiesi@0: * danielebarchiesi@0: * This hook can be used to add things like 'render last' or change icons danielebarchiesi@0: * or categories or to rename content on specific sites. danielebarchiesi@0: */ danielebarchiesi@0: function hook_ctools_content_subtype_alter($subtype, $plugin) { danielebarchiesi@0: $subtype['render last'] = TRUE; danielebarchiesi@0: } danielebarchiesi@0: danielebarchiesi@0: /** danielebarchiesi@0: * Alter the definition of an entity context plugin. danielebarchiesi@0: * danielebarchiesi@0: * @param array $plugin danielebarchiesi@0: * An associative array defining a plugin. danielebarchiesi@0: * @param array $entity danielebarchiesi@0: * The entity info array of a specific entity type. danielebarchiesi@0: * @param string $plugin_id danielebarchiesi@0: * The plugin ID, in the format NAME:KEY. danielebarchiesi@0: */ danielebarchiesi@0: function hook_ctools_entity_context_alter(&$plugin, &$entity, $plugin_id) { danielebarchiesi@0: ctools_include('context'); danielebarchiesi@0: switch ($plugin_id) { danielebarchiesi@0: case 'entity_id:taxonomy_term': danielebarchiesi@0: $plugin['no ui'] = TRUE; danielebarchiesi@0: case 'entity:user': danielebarchiesi@0: $plugin = ctools_get_context('user'); danielebarchiesi@0: unset($plugin['no ui']); danielebarchiesi@0: unset($plugin['no required context ui']); danielebarchiesi@0: break; danielebarchiesi@0: } danielebarchiesi@0: } danielebarchiesi@0: danielebarchiesi@0: /** danielebarchiesi@0: * Alter the definition of entity context plugins. danielebarchiesi@0: * danielebarchiesi@0: * @param array $plugins danielebarchiesi@0: * An associative array of plugin definitions, keyed by plugin ID. danielebarchiesi@0: * danielebarchiesi@0: * @see hook_ctools_entity_context_alter() danielebarchiesi@0: */ danielebarchiesi@0: function hook_ctools_entity_contexts_alter(&$plugins) { danielebarchiesi@0: $plugins['entity_id:taxonomy_term']['no ui'] = TRUE; danielebarchiesi@0: } danielebarchiesi@0: danielebarchiesi@0: /** danielebarchiesi@0: * Change cleanstring settings. danielebarchiesi@0: * danielebarchiesi@0: * @param array $settings danielebarchiesi@0: * An associative array of cleanstring settings. danielebarchiesi@0: * danielebarchiesi@0: * @see ctools_cleanstring() danielebarchiesi@0: */ danielebarchiesi@0: function hook_ctools_cleanstring_alter(&$settings) { danielebarchiesi@0: // Convert all strings to lower case. danielebarchiesi@0: $settings['lower case'] = TRUE; danielebarchiesi@0: } danielebarchiesi@0: danielebarchiesi@0: /** danielebarchiesi@0: * Change cleanstring settings for a specific clean ID. danielebarchiesi@0: * danielebarchiesi@0: * @param array $settings danielebarchiesi@0: * An associative array of cleanstring settings. danielebarchiesi@0: * danielebarchiesi@0: * @see ctools_cleanstring() danielebarchiesi@0: */ danielebarchiesi@0: function hook_ctools_cleanstring_CLEAN_ID_alter(&$settings) { danielebarchiesi@0: // Convert all strings to lower case. danielebarchiesi@0: $settings['lower case'] = TRUE; danielebarchiesi@0: } danielebarchiesi@0: danielebarchiesi@0: /** danielebarchiesi@0: * @} End of "addtogroup hooks". danielebarchiesi@0: */