/** * Converts a single article in MediaWiki format to XML */ function article2xml($title, &$text, $params = array()) { global $content_provider, $wiki2xml_authors; $ot = $title; $title = urlencode($title); $p = new wiki2xml(); $p->auto_fill_templates = $params['resolvetemplates']; $p->template_list = array(); foreach ($params['templates'] as $x) { $x = trim(ucfirst($x)); if ($x != "") { $p->template_list[] = $x; } } $xml = '<article'; if ($title != "") { $xml .= " title='{$title}'"; $content_provider->add_article(urldecode($ot)); } $xml .= '>'; $xml .= $p->parse($text); if (count($wiki2xml_authors) > 0) { $xml .= "<authors>"; foreach ($wiki2xml_authors as $author) { $xml .= "<author>{$author}</author>"; } $xml .= "</authors>"; } $xml .= "</article>"; return $xml; }
function p_restofcell(&$a, &$xml) { # Get substring for cell $b = $a; $sameline = true; $x = ""; $itables = 0; while ($b < $this->wl) { $c = $this->w[$b]; if ($c == "<" && $this->once($b, $x, "html")) { continue; } # Up front to catch pre and nowiki if ($c == "\n") { $sameline = false; } if ($c == "\n" && $this->nextis($b, "\n{|")) { $itables++; continue; } if ($c == "\n" && $itables > 0 && $this->nextis($b, "\n|}")) { $itables--; continue; } if ($c == "\n" && $this->nextis($b, "\n|", false) or $c == "\n" && $this->nextis($b, "\n!", false) or $c == "\n" && $this->nextis($b, "\n |", false) or $c == "\n" && $this->nextis($b, "\n !", false) or $c == "|" && $sameline && $this->nextis($b, "||", false) or $c == "!" && $sameline && $this->nextis($b, "!!", false)) { if ($itables == 0) { break; } $b += 2; } if ($c == "[" && $this->once($b, $x, "internal_link")) { continue; } if ($c == "{" && $this->once($b, $x, "template_variable")) { continue; } if ($c == "{" && $this->once($b, $x, "template")) { continue; } $b++; } # if ( $itables > 0 ) return false ; # Parse cell substring $s = substr($this->w, $a, $b - $a); $p = new wiki2xml(); $p->inherit($this); $x = $p->parse($s); if ($x == $this->errormessage) { return false; } $a = $b + 1; $xml .= $this->strip_single_paragraph($x); return true; }