Index: url_replace_filter.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/url_replace_filter/url_replace_filter.module,v retrieving revision 1.1.2.2 diff -u -p -r1.1.2.2 url_replace_filter.module --- url_replace_filter.module 14 Aug 2007 03:02:53 -0000 1.1.2.2 +++ url_replace_filter.module 6 May 2008 15:31:23 -0000 @@ -33,7 +33,13 @@ function _url_replace_filter_process($te if ($setting['original']) { $pattern = '!((]*href)|(]*src))\s*=\s*"'. preg_quote($setting['original']) .'!iU'; if (preg_match_all($pattern, $text, $matches)) { - $replacement = str_replace('%baseurl', rtrim(base_path(), '/'), $setting['replacement']); + if (variable_get('url_replace_filter_absolute', 0)) { + global $base_url; + $base = $base_url; + } else { + $base = rtrim(base_path(), '/'); + } + $replacement = str_replace('%baseurl', $base, $setting['replacement']); foreach ($matches[0] as $key => $match) { $text = str_replace($match, $matches[1][$key] .'="'. $replacement, $text); } @@ -102,4 +108,39 @@ function theme_url_replace_filter_settin $output .= t('

Enter original base URLs and their replacements. Matching is case-insensitive. You may use %baseurl in the replacement string to insert your site\'s base URL (without the trailing slash).

Warning: To avoid unexpected results, you must include trailing slashes in both the original and replacement strings.

Warning: Replacements are executed in the order you give them. Place the most specific URLs first. For example, http://example.com/somepath/ should be replaced before http://example.com/.

If you need more replacement rules, more fields will be added after saving the settings.

'); $output .= drupal_render($form); return $output; +} + +/** + * Implement hook_menu to point to the module settings + * + * @param $may_cache + * @return array + */ +function url_replace_filter_menu($may_cache) { + $admin_access = user_access('administer filters'); + $items = array(); + if ($may_cache) { + $items[] = array( + 'path' => 'admin/settings/url_replace_filter', + 'title' => t('URL Replacement'), + 'description' => t('Settings for the url_replace_filter module.'), + 'callback' => 'drupal_get_form', + 'callback arguments' => array('url_replace_filter_admin_settings'), + 'access' => $admin_access, + ); + } + + return $items; +} + +function url_replace_filter_admin_settings() { + $form = array(); + $form['url_replace_filter_absolute'] = array( + '#title' => t('Output absolute paths'), + '#description' => t('If this parameter is checked, %base will be replaced by the site full absolute URL, like %full. Otherwise, it will be replaced by the local component of the absolute URL, like %local.', array('%full' => 'http://www.example.com/site_base', '%local' => '/site_base')), + '#type' => 'checkbox', + '#default_value' => variable_get('url_replace_filter_absolute', 0), + ); + + return system_settings_form($form); } \ No newline at end of file