function _pathologic_abs_regex in Pathologic 5
Same name and namespace in other branches
- 6 pathologic.module \_pathologic_abs_regex()
- 6.2 pathologic.module \_pathologic_abs_regex()
Return the hard part of the regular expression to be used when making paths relative. $attr will probably be either 'href' or 'src'.
1 call to _pathologic_abs_regex()
- pathologic_filter in ./
pathologic.module - Implementation of hook_filter().
File
- ./
pathologic.module, line 75
Code
function _pathologic_abs_regex($attr, $format) {
static $pathstr = FALSE;
if ($pathstr === FALSE) {
$paths_field = trim(variable_get("filter_pathologic_abs_paths_{$format}", ''));
if ($paths_field !== '') {
// Get rid of spirious white space on each line
$paths = array_map('trim', explode("\n", $paths_field));
}
else {
$paths = array();
}
$paths[] = _pathologic_url('<front>');
// It's possible the user entered the path for the current site in the box,
// especially if the DB contents are shared between two different servers
// (likely if it's a testing/production server thing). This won't screw up
// the regex, but it will unnecessarily complicate it, so let's remove
// duplicates from the array.
$paths = array_unique($paths);
$pathstr = ')="(' . implode('/?(index.php)?(\\?q=)?|', $paths) . '/?(index.php)?(\\?q=)?)([^"]*)"`';
// $pathstr now looks like:
// )="(http://abcde.fgh//?(index.php)?(\?q=)?|http://edcba.hgf//?(index.php)?(\?q=)?)([^"]*)";
}
return '`(' . $attr . $pathstr;
// Returned value looks like:
// (href)="(http://abcde.fgh//?(index.php)?(\?q=)?|http://edcba.hgf//?(index.php)?(\?q=)?)([^"]*)"
// We want to match the attribute so that the callback
// _pathologic_abs_to_rel() below can return a value with the attribute
// without special trickery or creating duplicate functions.
}