function _filefield_paths_replace_pattern in File (Field) Paths 6
Same name and namespace in other branches
- 6.2 includes/fix_references.inc \_filefield_paths_replace_pattern()
Run regular expression over all available text-based fields.
2 calls to _filefield_paths_replace_pattern()
- filefield_paths_filefield_paths_process_file in ./
filefield_paths.module - Implements hook_filefield_paths_process_file().
- pathfilter_filefield_paths_process_file in modules/
pathfilter.inc - Implements hook_filefield_paths_process_file().
File
- ./
filefield_paths.module, line 535 - Contains core functions for the FileField Paths module.
Code
function _filefield_paths_replace_pattern($pattern, &$node, &$update) {
$fields = _filefield_paths_text_fields($node);
// Loop through all fields and process filter.
foreach ($fields as $field => &$data) {
${$field} = preg_match("/{$pattern['regex']}/s", $data) ? preg_replace("/{$pattern['regex']}/s", $pattern['replace'], $data) : preg_replace("/{$pattern['regex_enc']}/s", $pattern['replace'], $data);
if (${$field} != $data) {
$data = ${$field};
// Mark node for update.
if ($field == 'body' || $field == 'teaser') {
$update->node = TRUE;
}
}
}
}