Index: footnotes.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/footnotes/footnotes.module,v
retrieving revision 1.14.2.2
diff -u -r1.14.2.2 footnotes.module
--- footnotes.module 12 Aug 2008 20:17:53 -0000 1.14.2.2
+++ footnotes.module 19 Nov 2009 00:17:57 -0000
@@ -256,32 +256,50 @@
$value = $n;
}
- // Remove illegal characters from $value so it can be used as an HTML id attribute.
- $value_id = preg_replace('|[^\w\-]|', '', $value);
-
- // Create a sanitized version of $text that is suitable for using as HTML attribute
- // value. (In particular, as the title attribute to the footnote link.)
- $allowed_tags = array();
- $text_clean = filter_xss($matches['2'], $allowed_tags);
- // HTML attribute cannot contain quotes
- $text_clean = str_replace('"', """, $text_clean);
- // Remove newlines. Browsers don't support them anyway and they'll confuse line break converter in filter.module
- $text_clean = str_replace("\n", " ", $text_clean);
- $text_clean = str_replace("\r", "", $text_clean);
-
-
- // Create a footnote item as an array.
- $fn = array(
- 'value' => $value,
- 'text' => $matches[2],
- 'text_clean' => $text_clean,
- 'fn_id' => 'footnote' . $value_id . '_' . $randstr,
- 'ref_id' => 'footnoteref' . $value_id . '_' . $randstr
- );
+ // Did the pattern match anything between the and tag?
+ if($matches['2']){
+ // Create a sanitized version of $text that is suitable for using as HTML attribute
+ // value. (In particular, as the title attribute to the footnote link.)
+ $allowed_tags = array();
+ $text_clean = filter_xss($matches['2'], $allowed_tags);
+ // HTML attribute cannot contain quotes
+ $text_clean = str_replace('"', """, $text_clean);
+ // Remove newlines. Browsers don't support them anyway and they'll confuse line break converter in filter.module
+ $text_clean = str_replace("\n", " ", $text_clean);
+ $text_clean = str_replace("\r", "", $text_clean);
+
+ // Create a footnote item as an array.
+ $fn = array(
+ 'value' => $value,
+ 'text' => $matches[2],
+ 'text_clean' => $text_clean,
+ 'fn_id' => 'footnote' . $randstr,
+ 'ref_id' => array('footnoteref' . $randstr)
+ );
+
+ // Store the footnote item.
+ array_push( $store_matches, $fn );
+
+ } else {
+ //$matches['2'] = empty = we have same footnote second time or user make mistake
+ //so garbage in - garbage out
+ foreach ($store_matches as $key=>$fn) {
+ if ($fn['value']==$value) { //we found same symbol as before
+ $store_matches[$key]['ref_id'][]='footnoteref' . $randstr; //collect one more link
+ $fn['ref_id']=array('footnoteref' . $randstr); //local copy of $fn...
+ break; //We have found that searched
+ }
+ }
+ //!!!!!!!!!!!!!!!!
+ //We have not found a footnote. What to do?
+ //1. trigger_error(); ??
+ //2. Make empty footnote ??
+ //3. Ignore it.
+ return '';
+ }
- // Store the footnote item.
- array_push( $store_matches, $fn );
// Return the item themed into a footnote link.
+ //$fn - new or updated
return theme('footnote_link',$fn);
}
@@ -364,7 +382,7 @@
* footnote listing, used to allow links to the list from the body
*/
function theme_footnote_link($fn) {
- return '';
}
@@ -386,7 +404,14 @@
$str = '
\n";