Author: alessio.soldano(a)jboss.com
Date: 2008-01-23 05:19:17 -0500 (Wed, 23 Jan 2008)
New Revision: 5511
Modified:
projects/wiki/extensions/wiki2xml/content_provider.php
projects/wiki/extensions/wiki2xml/xml2docbook_xml.php
Log:
[JBWS-1961] Patching anchor support:
- each docbook section is now given its proper id according to the mediawiki convention
- links also include anchor part
- fixed article existence check to correctly use anchors
Modified: projects/wiki/extensions/wiki2xml/content_provider.php
===================================================================
--- projects/wiki/extensions/wiki2xml/content_provider.php 2008-01-22 17:04:22 UTC (rev
5510)
+++ projects/wiki/extensions/wiki2xml/content_provider.php 2008-01-23 10:19:17 UTC (rev
5511)
@@ -6,15 +6,32 @@
var $article_list = array () ;
var $authors = array () ;
var $block_file_download = false ;
+ var $section_list = array ();
function get_wiki_text ( $title , $do_cache = false ) { return "" ; } # dummy
function get_template_text ( $title ) { return "" ; } # dummy
function add_article ( $title ) {
$this->article_list[] = urlencode ( trim ( $title ) ) ;
+ $this->section_list[$title] = array();
}
+ function get_section_id ($article, $section) {
+ $id = "";
+ if (isset($this->section_list[$article][$section])) {
+ $this->section_list[$article][$section] =
$this->section_list[$article][$section] + 1;
+ $id = $section . "_" . $this->section_list[$article][$section];
+ } else {
+ $this->section_list[$article][$section] = 1;
+ $id = $section;
+ }
+ return $article . "_" . urlencode($id);
+ }
+
function is_an_article ( $title ) {
+ if (strpos($title,'#'))
+ $title = substr($title,0,strpos($title,'#'));
+ $title = str_replace ( "_" , " " , $title ) ;
$title = urlencode ( trim ( $title ) ) ;
return in_array ( $title , $this->article_list ) ;
}
Modified: projects/wiki/extensions/wiki2xml/xml2docbook_xml.php
===================================================================
--- projects/wiki/extensions/wiki2xml/xml2docbook_xml.php 2008-01-22 17:04:22 UTC (rev
5510)
+++ projects/wiki/extensions/wiki2xml/xml2docbook_xml.php 2008-01-23 10:19:17 UTC (rev
5511)
@@ -200,6 +200,7 @@
else $link = " ({$link})" ;
$link = "" . $this->link_target . $link . "" ;
} else {
+
if ( $content_provider->is_an_article ( $this->link_target ) ) {
$lt = $this->internal_id ( trim ( $this->link_target ) ) ;
$lt = str_replace ( "+" , "_" , $lt ) ;
@@ -323,7 +324,8 @@
if ( $level < $wanted ) {
array_push ( $tree->sections , 0 ) ;
} else {
- $ret .= $this->ensure_new ( "section" , $tree ,
"<section>" ) ;
+ $id = $this->internal_id (
$content_provider->get_section_id($root->attrs['TITLE'],$this->children["0"])
) ;
+ $ret .= $this->ensure_new ( "section" , $tree , "<section
id='{$id}'>" ) ;
array_push ( $tree->sections , 1 ) ;
}
}
Show replies by date