function _openid_link_href

Pull the href attribute out of an html link element.

1 call to _openid_link_href()
_openid_xrds_discovery in drupal/core/modules/openid/openid.module
OpenID discovery method: perform a XRDS discovery.

File

drupal/core/modules/openid/openid.inc, line 385
OpenID utility functions.

Code

function _openid_link_href($rel, $html) {
  $html_dom = new DOMDocument();
  if (@$html_dom
    ->loadHTML($html)) {
    $html_element = simplexml_import_dom($html_dom);
    if (isset($html_element->head->link)) {
      foreach ($html_element->head->link as $link) {

        // The rel attribute contains a space-separated list of case-insensitive
        // link types.
        if (preg_match('@(?:\\s|^)' . preg_quote($rel, '@') . '(?:\\s|$)@i', $link['rel'])) {
          return trim($link['href']);
        }
      }
    }
  }
  return FALSE;
}