r14265 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r14264‎ | r14265 | r14266 >
Date:12:19, 17 May 2006
Author:magnusmanske
Status:old
Tags:
Comment:
Footnote update, can now create endnotes instead
Modified paths:
  • /trunk/wiki2xml/php/default.php (modified) (history)
  • /trunk/wiki2xml/php/w2x.php (modified) (history)
  • /trunk/wiki2xml/php/xml2odt.php (modified) (history)

Diff [purge]

Index: trunk/wiki2xml/php/xml2odt.php
@@ -27,6 +27,8 @@
2828 var $row_counter = array () ;
2929 var $footnote_counter = 0 ;
3030 var $article_counter = 0 ;
 31+ var $footnote_index = array () ;
 32+ var $footnote_text = array () ;
3133
3234 function XML2ODT () {
3335 $this->textstyle_current = new TextStyle ;
@@ -41,9 +43,19 @@
4244 return $url ;
4345 }
4446
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+ }
4860 }
4961
5062 function get_image_frames () {
@@ -494,38 +506,29 @@
495507 }
496508
497509 function handle_extensions ( &$tree ) {
498 - global $content_provider , $xml2odt ;
 510+ global $content_provider , $xml2odt , $xmlg ;
499511 $ret = "" ;
500512 $name = strtolower ( $this->attrs['EXTENSION_NAME'] ) ;
501 -# $ot = $tree->opentags ;
502 -# $tree->opentags = array () ;
503513 $sub = $this->sub_parse ( $tree ) ;
504514
505515 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 ) ;
507521 $ret .= '<text:note text:id="ftn' . $id .
508 - '" text:note-class="footnote"><text:note-citation>' .
 522+ '" text:note-class="' . $note_class . '"><text:note-citation>' .
509523 $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>' ;
513529 } else { # Unhandeled extension
514530 $ret = $sub ;
515531 }
516532
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 -*/
530533 return $ret ;
531534 }
532535
Index: trunk/wiki2xml/php/w2x.php
@@ -30,7 +30,8 @@
3131 }
3232 if ( isset ( $xmlg['zip_odt'] ) ) {
3333 $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)" ;
3536 }
3637 $optional = "<br/>" . implode ( "<br/>" , $optional ) ;
3738
@@ -320,6 +321,7 @@
321322 # header("Content-type: application/xhtml+xml");
322323 echo $converter->articles2xhtml ( $xml , $xmlg ) ;
323324 } else if ( $format == "odt" || $format == "odt_xml" ) {
 325+ if ( isset ( $_REQUEST['odt_footnote'] ) ) $xmlg["odt_footnote"] = 'endnote' ;
324326 if ( $xmlg['sourcedir'] == '.' ) $cwd = getcwd() ;
325327 else $cwd = $xmlg['sourcedir'] ;
326328 $template_file = $cwd . '/template.odt' ;
Index: trunk/wiki2xml/php/default.php
@@ -8,7 +8,7 @@
99 $xmlg['is_windows'] = false ;
1010 $xmlg['allow_get'] = false ;
1111 $xmlg["use_toolserver_url"] = false ;
12 -
 12+$xmlg["odt_footnote"] = 'footnote' ;
1313 $xmlg["allow_xml_temp_files"] = true ;
1414 $xmlg["use_xml_temp_files"] = false ;
1515

Status & tagging log