Index: trunk/wiki2xml/php/xml2odt.php |
— | — | @@ -27,6 +27,8 @@ |
28 | 28 | var $row_counter = array () ; |
29 | 29 | var $footnote_counter = 0 ; |
30 | 30 | var $article_counter = 0 ; |
| 31 | + var $footnote_index = array () ; |
| 32 | + var $footnote_text = array () ; |
31 | 33 | |
32 | 34 | function XML2ODT () { |
33 | 35 | $this->textstyle_current = new TextStyle ; |
— | — | @@ -41,9 +43,19 @@ |
42 | 44 | return $url ; |
43 | 45 | } |
44 | 46 | |
45 | | - function get_footnote_id () { |
46 | | - $this->footnote_counter++ ; |
47 | | - return $this->footnote_counter ; |
| 47 | + function get_footnote_id ( $name , &$text ) { |
| 48 | + $name = trim ( strtolower ( $name ) ) ; |
| 49 | + if ( $name != "" && isset ( $this->footnote_index[$name] ) ) { |
| 50 | + if ( trim ( $text ) == "" ) $text = $this->footnote_text[$name] ; |
| 51 | + return $this->footnote_index[$name] ; |
| 52 | + } else { |
| 53 | + $this->footnote_counter++ ; |
| 54 | + if ( $name != "" ) { |
| 55 | + $this->footnote_index[$name] = $this->footnote_counter ; |
| 56 | + $this->footnote_text[$name] = $text ; |
| 57 | + } |
| 58 | + return $this->footnote_counter ; |
| 59 | + } |
48 | 60 | } |
49 | 61 | |
50 | 62 | function get_image_frames () { |
— | — | @@ -494,38 +506,29 @@ |
495 | 507 | } |
496 | 508 | |
497 | 509 | function handle_extensions ( &$tree ) { |
498 | | - global $content_provider , $xml2odt ; |
| 510 | + global $content_provider , $xml2odt , $xmlg ; |
499 | 511 | $ret = "" ; |
500 | 512 | $name = strtolower ( $this->attrs['EXTENSION_NAME'] ) ; |
501 | | -# $ot = $tree->opentags ; |
502 | | -# $tree->opentags = array () ; |
503 | 513 | $sub = $this->sub_parse ( $tree ) ; |
504 | 514 | |
505 | 515 | if ( $name == "ref" ) { |
506 | | - $id = $xml2odt->get_footnote_id () ; |
| 516 | + if ( isset ( $this->attrs['NAME'] ) ) $fname = $this->attrs['NAME'] ; |
| 517 | + else $fname = "" ; |
| 518 | + $note_class = strtolower ( trim ( $xmlg["odt_footnote"] ) ) ; |
| 519 | + $note_style = ucfirst ( $note_class ) ; |
| 520 | + $id = $xml2odt->get_footnote_id ( $fname , $sub ) ; |
507 | 521 | $ret .= '<text:note text:id="ftn' . $id . |
508 | | - '" text:note-class="footnote"><text:note-citation>' . |
| 522 | + '" text:note-class="' . $note_class . '"><text:note-citation>' . |
509 | 523 | $id . |
510 | | - '</text:note-citation><text:note-body><text:p text:style-name="Footnote">' . |
511 | | - $sub . |
512 | | - '</text:p></text:note-body></text:note>' ; |
| 524 | + '</text:note-citation>' ; |
| 525 | + $ret .= '<text:note-body><text:p text:style-name="' . $note_style . '">' . |
| 526 | + $sub . |
| 527 | + '</text:p></text:note-body>' ; |
| 528 | + $ret .= '</text:note>' ; |
513 | 529 | } else { # Unhandeled extension |
514 | 530 | $ret = $sub ; |
515 | 531 | } |
516 | 532 | |
517 | | -/* |
518 | | - if ( $name == 'ref' ) |
519 | | - $sub .= $this->ensure_new ( 'para' , $tree ) ; |
520 | | - $sub .= $this->sub_parse ( $tree ) ; |
521 | | - while ( count ( $tree->opentags ) > 0 ) |
522 | | - $sub .= "</" . array_pop ( $tree->opentags ) . ">\n" ; |
523 | | - $tree->opentags = $ot ; |
524 | | - if ( $name == 'ref' ) { |
525 | | - $ret = '<footnote>' . $sub . '</footnote>' ; |
526 | | - } else { |
527 | | - $ret = $sub ; |
528 | | - } |
529 | | -*/ |
530 | 533 | return $ret ; |
531 | 534 | } |
532 | 535 | |
Index: trunk/wiki2xml/php/w2x.php |
— | — | @@ -30,7 +30,8 @@ |
31 | 31 | } |
32 | 32 | if ( isset ( $xmlg['zip_odt'] ) ) { |
33 | 33 | $optional[] = "<INPUT type='radio' name='output_format' value='odt_xml'>OpenOffice XML" ; |
34 | | - $optional[] = "<INPUT type='radio' name='output_format' value='odt'>OpenOffice ODT" ; |
| 34 | + $optional[] = "<INPUT type='radio' name='output_format' value='odt'>OpenOffice ODT" . |
| 35 | + "<input type='checkbox' name='odt_footnote' value='1'>References as endnotes (instead of footnotes)" ; |
35 | 36 | } |
36 | 37 | $optional = "<br/>" . implode ( "<br/>" , $optional ) ; |
37 | 38 | |
— | — | @@ -320,6 +321,7 @@ |
321 | 322 | # header("Content-type: application/xhtml+xml"); |
322 | 323 | echo $converter->articles2xhtml ( $xml , $xmlg ) ; |
323 | 324 | } else if ( $format == "odt" || $format == "odt_xml" ) { |
| 325 | + if ( isset ( $_REQUEST['odt_footnote'] ) ) $xmlg["odt_footnote"] = 'endnote' ; |
324 | 326 | if ( $xmlg['sourcedir'] == '.' ) $cwd = getcwd() ; |
325 | 327 | else $cwd = $xmlg['sourcedir'] ; |
326 | 328 | $template_file = $cwd . '/template.odt' ; |
Index: trunk/wiki2xml/php/default.php |
— | — | @@ -8,7 +8,7 @@ |
9 | 9 | $xmlg['is_windows'] = false ; |
10 | 10 | $xmlg['allow_get'] = false ; |
11 | 11 | $xmlg["use_toolserver_url"] = false ; |
12 | | - |
| 12 | +$xmlg["odt_footnote"] = 'footnote' ; |
13 | 13 | $xmlg["allow_xml_temp_files"] = true ; |
14 | 14 | $xmlg["use_xml_temp_files"] = false ; |
15 | 15 | |