You are here

function apachesolr_l in Apache Solr Search 6

Same name and namespace in other branches
  1. 8 apachesolr.module \apachesolr_l()
  2. 5.2 apachesolr.module \apachesolr_l()
  3. 6.3 apachesolr.module \apachesolr_l()
  4. 6.2 apachesolr.module \apachesolr_l()
  5. 7 apachesolr.module \apachesolr_l()

A replacement for l()

  • doesn't add the 'active' class
  • retains all $_GET parameters that ApacheSolr may not be aware of
  • if set, $options['query'] MUST be an array

Return value

an HTML string containing a link to the given path.

See also

http://api.drupal.org/api/function/l/6 for parameters and options.

3 calls to apachesolr_l()
theme_apachesolr_facet_link in ./apachesolr.module
theme_apachesolr_sort_link in ./apachesolr.module
theme_apachesolr_unclick_link in ./apachesolr.module

File

./apachesolr.module, line 1799
Integration with the Apache Solr search application.

Code

function apachesolr_l($text, $path, $options = array()) {

  // Merge in defaults.
  $options += array(
    'attributes' => array(),
    'html' => FALSE,
    'query' => array(),
  );

  // Don't need this, and just to be safe.
  unset($options['attributes']['title']);

  // Double encode + characters for clean URL Apache quirks.
  if (variable_get('clean_url', '0')) {
    $path = str_replace('+', '%2B', $path);
  }

  // Retain GET parameters that ApacheSolr knows nothing about.
  $query = apachesolr_current_query();
  $get = array_diff_key($_GET, array(
    'q' => 1,
    'page' => 1,
  ), $options['query'], $query
    ->get_url_queryvalues());
  $options['query'] += $get;
  return '<a href="' . check_url(url($path, $options)) . '"' . drupal_attributes($options['attributes']) . '>' . ($options['html'] ? $text : check_plain(html_entity_decode($text))) . '</a>';
}