You are here

function freelinking_get_freelink in Freelinking 7.3

Same name and namespace in other branches
  1. 6.3 freelinking.utilities.inc \freelinking_get_freelink()

Process the target text into a link with the specified plugin.

Parameters

$plugin: The name of the plugin to be used to render the link.

$target: The target text extracted from the freelink. Array.

$format: The format id currently invoking the Freelinking filter. Might be used in the future to tweak plugin behavior.

$rendered: Boolean value. If true, link will be returned as rendered HTML. If false, link will be returned as arguments for l().

Return value

An array as per the arguments of l() or a string of HTML markup.

See also

l()

1 call to freelinking_get_freelink()
_freelinking_process in ./freelinking.module
Implements filter process callback

File

./freelinking.utilities.inc, line 32
Freelinking ver. 3 Utilities

Code

function freelinking_get_freelink($plugin, $target, $format = 'all', $rendered = TRUE) {
  $plugins = freelinking_get_plugins($format);
  $link = _freelinking_build_freelink($plugins, $plugin, $target);
  if (!$rendered || !is_array($link)) {
    return $link;
  }
  if (isset($link['failover'])) {
    if ($link['failover'] == 'error') {
      return theme('freelink_error', array(
        'plugin' => $plugin,
        'message' => $link['message'],
      ));
    }
    if ($link['failover'] == 'NONE') {
      return FALSE;
    }
  }
  if (function_exists('theme_freelink_' . $plugin)) {

    // TODO Please change this theme call to use an associative array for the $variables parameter.
    return theme('freelink_' . $plugin, array(
      'link' => $link,
    ));
  }
  return theme('freelink', array(
    'plugin' => $plugin,
    'link' => $link,
  ));
}