* * @license General Public License version 2.0 or later */ /** * Implementation of hook_requirements(). * * Ensure the module is actually used in at least one filter. */ function url_replace_filter_requirements($phase) { if ($phase != 'runtime') { return array(); } $formats = _url_replace_filter_get_formats(); $filter_id = 'url_replace_filter/0'; $count = 0; foreach ($formats as $format) { if (!empty($format->{$filter_id})) { $count++; } } $req = array( 'title' => t('URL replace filter'), ); if ($count) { $req['value'] = format_plural($count, "Used in 1 format.", "Used in @count formats."); $req['severity'] = REQUIREMENT_OK; } else { $req['value'] = t('Module is enabled but no format uses its filter. You should disable the module or use the filter in at least one format.'); $req['severity'] = REQUIREMENT_INFO; } return array('url_replace_filter' => $req); } /** * Implementation of hook_disable(). * * - Flush filter cache to remove content cached with this filter. */ function url_replace_filter_disabled() { cache_clear_all('*', 'cache_filter', TRUE); } /** * Implementation of hook_uninstall(). * * - Remove all configuration variables for the module. * - Remove instances of the filter in all input formats. * - Flush filter cache to remove content cached with this filter. */ function url_replace_filter_uninstall() { // Delete configuration variables. foreach (array_keys($GLOBALS['conf']) as $name ) { if (strpos($name, 'url_replace_filter_') === 0) { variable_del($name); } } // Remove filter from input formats. $formats = _url_replace_filter_get_formats(); foreach ($formats as $format) { db_query("DELETE FROM {filters} WHERE module = 'url_replace_filter'"); } cache_clear_all('*', 'cache_filter', TRUE); }