function _biblio_filter_replace_callback in Bibliography Module 6.2
Same name and namespace in other branches
- 5 biblio.module \_biblio_filter_replace_callback()
- 6 biblio.module \_biblio_filter_replace_callback()
- 7 biblio.module \_biblio_filter_replace_callback()
- 7.2 biblio.module \_biblio_filter_replace_callback()
Helper function called from preg_replace_callback() above
Uses static vars to temporarily store footnotes found. In my understanding, this is not threadsafe?!
1 call to _biblio_filter_replace_callback()
- biblio_filter in ./
biblio.module - Implements hook_filter().
1 string reference to '_biblio_filter_replace_callback'
- biblio_filter in ./
biblio.module - Implements hook_filter().
File
- ./
biblio.module, line 2269 - Main file for Drupal module biblio.
Code
function _biblio_filter_replace_callback($matches, $op = '') {
static $n = 0;
static $store_matches = array();
$str = '';
if ($op == 'output footer') {
if ($n > 0) {
$str = '<hr /><h3>' . t('References') . '</h3>';
$str .= '<div class="references"><ol>';
for ($m = 1; $m <= $n; $m++) {
$str .= '<li id="reference' . $m . '"><a name="ref' . $m . '">' . _biblio_citekey_print($store_matches[$m - 1]) . " </a></li>\n\n";
}
$str .= '</ol></div>';
}
$n = 0;
$store_matches = array();
return $str;
}
//default op: act as called by preg_replace_callback()
$ref = array_search($matches[1], $store_matches);
if ($ref === FALSE) {
$n++;
array_push($store_matches, $matches[1]);
//$stores_matches[$matches[1]] = $n;
$ref = $n;
}
else {
$ref++;
}
$allowed_tags = array();
$title = filter_xss($matches[1], biblio_get_allowed_tags());
//html attribute cannot contain quotes
$title = str_replace('"', """, $title);
//remove newlines. Browsers don't support them anyway and they'll confuse line break converter in filter.module
$title = str_replace("\n", " ", $title);
$title = str_replace("\r", "", $title);
if (module_exists('hovertip')) {
$text = '<span hovertip="reference' . $ref . '"><a href="#ref' . $ref . '">[' . $ref . ']</a></span>';
$text .= '<span id="reference' . $ref . '" class="hovertip">' . _biblio_citekey_print($title) . '</span>';
}
else {
$text = '<a href="#ref' . $ref . '" title="Reference ' . $ref . '">[' . $ref . ']</a>';
}
return $text;
}