&$plugin) { // Confirm correct structure in plugin if (!$plugin['indicator'] || (!$plugin['replacement'] && !$plugin['callback']) || ($plugin['callback'] && !function_exists($plugin['callback']))) { drupal_set_message(t('Freelinking plugin "!plugin" is invalid.', array('!plugin' => $name)), 'warning'); watchdog('filter', 'Freelinking plugin "!plugin" is invalid.', array('!plugin' => $name), WATCHDOG_WARNING); } // end if // Set "enabled" by format when explicitly set in format configuration.. $plugin_enabled = variable_get( 'freelinking_' . $name . '_enabled_format_' . $format, '' ); if ($plugin_enabled) { $plugin['enabled'] = $plugin_enabled; } // Rearrange weight scheme to use core comparison function. $plugin['#weight'] = $plugin['weight']; unset($plugin['weight']); // Set explicit defaults. $plugin += array('enabled' => TRUE, 'html' => TRUE); } // end foreach // element_sort() uses '#weight', the hash is added above to support this. uasort($freelinking, 'element_sort'); $plugins[$format] = $freelinking; return $freelinking; } // end freelinking_get_plugins() /** * Build a tooltip for internal content. * * Attempts to use description metatag, truncated to 200 characters. * * @param $type * Type of the Drupal object- such as node, comment, block. * * @param $id * ID of the Drupal object. Useful for querying. */ function freelinking_internal_tooltip($type, $id) { switch ($type) { case 'node': if (module_exists('nodewords')) { if (function_exists('nodewords_get_tags')) { $metatags = nodewords_get_tags('node', $id); $description = $metatags['description']; } } break; } $description = check_url($description); return truncate_utf8($description, 200, FALSE, TRUE); } /** * Get a configuration value for the current text being processed. * Configuration values may vary by format, or fall back to a general default. * * This allows the current value to be accessed without bouncing $format into * every plugin. * * @param $name * Get the setting from those tracked in freelinking_set_conf(). * * @return * A string of the value. * * @see freelinking_set_conf() */ function freelinking_get_conf($name) { return freelinking_set_conf($name); } /** * Calculate a configuration value based on a precedence of existing variables. * Format-specific before Freelinking before Drupal-wide. * * @param $name * Set the named setting. Examples: * - 'cache': boolean. True indicates the filter cache should be turned on. * - 'default_match': String. Mode of default syntax for freelinking. * * @param $format * Calculate the setting for the specified format. If the format is not specified, * will return the value from memory without calculating. * * @return * String of the computed value. */ function freelinking_set_conf($name, $format = NULL, $reset = FALSE) { static $conf; if ($conf[$name] && !$format) { return $conf[$name]; } // Specific format -> Freelinking Global -> Format Settings if ($name == 'cache') { $conf[$name] = variable_get('freelinking_' . $name . '_format_' . $format, variable_get('freelinking_' . $name, filter_format_allowcache($format))); } else { $conf[$name] = variable_get('freelinking_' . $name . '_format_' . $format, variable_get('freelinking_' . $name, FALSE)); } return $conf[$name]; }