function wiki_page_content(&$text, &$WS) { //WS->wiki_format is the wiki parser configuration array. //configure wiki parse with the editor switch ($WS->pagedata->editor) { case 'dfwiki': //dfwiki parse is already configured for use //the dfwiki editor, logically. return wiki_sintax_html_bis($text); break; case 'nwiki': //nwiki parse is already configured for use //the nwiki editor, logically. return parse_nwiki_text($text); break; case 'ewiki': //configure parse for emulate ewiki format. //del all format foreach ($WS->wiki_format as $key => $type) { unset($WS->wiki_format[$key]); } //put new parser params $WS->wiki_format['line'] = array('-----' => "<hr noshade=\"noshade\" />\n", '----' => "<hr noshade=\"noshade\" />\n", '---' => "<hr noshade=\"noshade\" />\n"); $WS->wiki_format['start-end'] = array("**" => array("<b>", "</b>"), "__" => array("<b>", "</b>"), "'''" => array("<b>", "</b>"), "''" => array("<i>", "</i>"), "��" => array("<BIG>", "</BIG>"), "##" => array("<SMALL>", "</SMALL>"), "==" => array("<tt>", "</tt>")); $WS->wiki_format['line-start'] = array(" " => " ", "\t" => " "); $WS->wiki_format['lists'] = array('*' => 'ul', '#' => 'ol'); $WS->wiki_format['links'] = array('internal' => array("[[", "]]"), 'external' => array("[", "]")); $WS->wiki_format['table'] = array('|' => 'td'); $WS->wiki_format['nowiki'] = array('<nowiki>', '</nowiki>'); $WS->wiki_format['line-start-enc'] = array('!!!' => array('<h1>', '</h1>'), '!!' => array('<h2>', '</h2>'), '!' => array('<h3>', '</h3>')); return wiki_sintax_html_bis($text); break; case 'htmleditor': //the parse will only recognize nowiki and links markup. $aux = $WS->wiki_format['links']; $aux2 = $WS->wiki_format['nowiki']; //del all format foreach ($WS->wiki_format as $key => $type) { unset($WS->wiki_format[$key]); } //restore links and nowiki. $WS->wiki_format['links'] = $aux; $WS->wiki_format['nowiki'] = $aux2; return wiki_sintax_html_bis($text); break; default: return wiki_sintax_html_bis($text); break; } //return wiki_sintax_html_bis($text); //end table }
function wikibook_to_tcpdf(&$bookname, &$booktext, &$mainrefs, $font_base, $font_base_size, $withheader, $withfooter, $doc_title, $doc_subtitle, $font_header) { global $USER; $tcpdf = new wikibookpdf(PDF_PAGE_ORIENTATION, 'mm', PDF_PAGE_FORMAT, true); $font_base = strtolower($font_base); $font_header = strtolower($font_header); configure_tcpdf($tcpdf, $withheader, $withfooter, $font_base, $font_base_size, $doc_title, $doc_subtitle, $font_header); $i = 0; while ($i < sizeof($booktext)) { $tcpdf->AddPage(); $tcpdf->SetLinkinName($tcpdf->AddLinkin(), $bookname[$i], '', $tcpdf->PageNo()); $text[$i] = parse_nwiki_text($booktext[$i]); $text[$i] = '<p><b>' . $bookname[$i] . '</b><br></p>' . $text[$i]; $text[$i] = str_replace(' %%% ', '<br>', $text[$i]); $text[$i] = str_replace("\n", '<br>', $text[$i]); $tcpdf->writeWikibookHTML($text[$i]); $i++; } // To copy inside the definitive "PDF" $array_name = $tcpdf->getLinkinName(); $array_link = $tcpdf->getLinkin(); $array_images = $tcpdf->getImages(); if (count($text) > 0) { $tag_text = preg_split('/(<[^>]+>)/Uu', $text[0], -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); //explodes the string $i = 0; $find = False; $first_ul = False; $ul = 0; $n = count($tag_text); while (!$find && $i < $n) { if (strtolower($tag_text[$i]) == '<ul>') { $ul++; $tag_text[$i] = '<ol>'; } else { if (strtolower($tag_text[$i]) == '</ul>') { $ul--; $tag_text[$i] = '</ol>'; } } if ($ul == 1 && !$first_ul) { $first_ul = True; } if ($first_ul && $ul == 0) { $find = True; } $i++; } $text[0] = implode("", $tag_text); } $tcpdf = new wikibookpdf(PDF_PAGE_ORIENTATION, 'mm', PDF_PAGE_FORMAT, true); // The "PDF" configure_tcpdf($tcpdf, $withheader, $withfooter, $font_base, $font_base_size, $doc_title, $doc_subtitle, $font_header); // The internal links $tcpdf->CopyLinkinName($array_name, $array_link); $tcpdf->setImages($array_images); unset($array_name); unset($array_link); unset($array_images); $i = 0; while ($i < sizeof($text)) { $tcpdf->AddPage(); $tcpdf->writeWikibookHTML($text[$i], '', '', true); $i++; } $tcpdf->Close(); // It doesn't be necessary $tcpdf->Output(str_replace(':', '_', $bookname[0]) . ".pdf", "D"); }