You are here

function intlinks_is_node_path in Internal Links 8

Same name and namespace in other branches
  1. 6 intlinks_common_functions.inc \intlinks_is_node_path()
  2. 7.2 intlinks_common_functions.inc \intlinks_is_node_path()
  3. 7 intlinks_common_functions.inc \intlinks_is_node_path()

Tests a path to see if it is a proper "normal Drupal path": node/[nid].

It also does some basic clean-up of the path internally, to save this being done in every block that looks at possible "normal Drupal paths".

Parameters

$path: A path passed to the function.

Return value

The node ID (does not test to see if the node is real or published) or FALSE, if the "node path" is actually a node/add, node/[nid]/edit, etc -type path (special system path related to nodes, but not actually to a node.

2 calls to intlinks_is_node_path()
_intlinks_process_bad_link in ./intlinks_hide_bad_links.inc
Processes regex matches of links for intlinks_hide_bad_filter_process().
_intlinks_title_process_link in ./intlinks_title_filter.inc
Process regex matches of links for intlinks_title_filter_process().

File

./intlinks_common_functions.inc, line 27
This file includes functions which are used in more than one of the filters included in the Internal Links (intlinks) module.

Code

function intlinks_is_node_path($path) {
  if (strpos($path, 'node/') === FALSE) {
    return FALSE;
  }

  // Trim any leading slash from original link.
  $path = ltrim($path, '/');

  // This function should also deal with the possibility that it was passed a
  // path that still has a "anchor" text appended to it. The part
  // after the slash should all be numeric for the next test.
  $path_parts = explode('#', $path);
  $path = $path_parts[0];

  // Now the path is trimmed of anything extraneous.
  $path_parts = explode('/', $path);
  if (count($path_parts) == 2 && ctype_digit($path_parts[1])) {

    // $path_parts[1] is the node id.
    return $path_parts[1];
  }
  else {
    return FALSE;
  }
}