function _footnotes_replace_callback_textile in Footnotes 6
Same name and namespace in other branches
- 5.2 footnotes.module \_footnotes_replace_callback_textile()
 - 5 footnotes.module \_footnotes_replace_callback_textile()
 - 6.2 footnotes.module \_footnotes_replace_callback_textile()
 
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 _footnotes_replace_callback_textile()
- footnotes_filter in ./
footnotes.module  - Implementation of hook_filter().
 
1 string reference to '_footnotes_replace_callback_textile'
- footnotes_filter in ./
footnotes.module  - Implementation of hook_filter().
 
File
- ./
footnotes.module, line 207  - The Footnotes module is a filter that can be used to insert automatically numbered footnotes into Drupal texts.
 
Code
function _footnotes_replace_callback_textile($matches, $op = '') {
  static $n = 0;
  static $store_matches = array();
  $str = '';
  if ($op == 'output footer') {
    if ($n > 0) {
      $str = '';
      for ($m = 1; $m <= $n; $m++) {
        $str .= "fn{$m}. " . $store_matches[$m - 1] . "\n\n";
      }
    }
    $n = 0;
    $store_matches = array();
    return $str;
  }
  //default op: act as called by preg_replace_callback()
  array_push($store_matches, $matches[1]);
  $n++;
  return '[' . $n . ']';
}