You are here

function pathfilter_nodeapi in Path Filter 6.2

Same name and namespace in other branches
  1. 5.2 pathfilter.module \pathfilter_nodeapi()

Modifies submitted node body values. Replaces base_path() in images, hrefs, etc with 'internal:' on save. When editing a node, the body's 'internal:' strings are replaced with 'base_path()'.

File

./pathfilter.module, line 197
This filter takes internal Drupal paths in double quotes, written as e.g. "internal:node/99", and replaces them with the appropriate absolute http URL using Drupal's url() function [1]. E.g. for a site located at http://example.com/mysite

Code

function pathfilter_nodeapi(&$node, $op) {
  switch ($op) {
    case 'prepare':

      // Convert "internal:" and "files:" back into full URL of site for editing.
      // We convert back into 'node/#' if possible to keep from breaking URLs when an
      // alias changes
      _pathfilter_replace_links($node, '_pathfilter_replace_internal');
      break;
    case 'presave':

      /** We do more when we look for what to replace with 'internal:'
       * - Only want to replace items that are links, not text or data
       * - Check to see if they specified the hostname of the server */
      _pathfilter_replace_links($node, '_pathfilter_internalize');
      break;
  }
}