### OPTIONS ###
$default_item = "home";
### declarations and var setup
$query=(!empty($_GET["q"])?$_GET["q"]:$_POST["q"]);
$decode=(!empty($_GET["d"])?$_GET["d"]:$_POST["d"]);
$filename=(!empty($_GET["f"])?$_GET["f"]:$_POST["f"]);
$item=(!empty($_GET["i"])?$_GET["i"]:$_POST["i"]);
$string=(!empty($_GET["s"])?$_GET["s"]:$_POST["s"]);
if(!empty($filename)) $f=$filename; else {$f="datas/".$default_item.".txt.gz";$item=$default_item;}
include ("./classes/class.wiki2xhtml.php");
include_once('./classes/xhtml2pdf.php');
class xhtml2pdf_new extends xhtml2pdf
{
function xhtml2pdf_new($xhtml, $cssfile)
{
$this->currentattr = array();
$this->depth = -1; # la première balise (html) aura la profondeur 0
$this->readytodisplayablock = 1;
if (file_exists('html.css'))
$content = file_get_contents('html.css');
else
{echo "html.css doesn't exist";return -1; }
$this->css = new ccss;
$this->css->read($content);
if (file_exists($cssfile))
$content = file_get_contents($cssfile);
else
{echo "$cssfile doesn't exist";return -1; }
$this->css->read($content);
$this->myfpdf = new XFPDF();
$this->myfpdf->SetFont('Arial','',12);
$this->myfpdf->AddPage();
$this->xml_parser = xml_parser_create();
xml_set_object($this->xml_parser, $this);
xml_set_element_handler($this->xml_parser, "begintag", "endtag");
xml_set_character_data_handler($this->xml_parser, "handledata");
//$content = file_get_contents($xhtmlfile);
$content = $xhtml;
xml_parse($this->xml_parser, $content);
xml_parser_free($this->xml_parser);
}
function output()
{
$this->myfpdf->Output();
}
}
### Functions and class extends
class wiki2xhtml_new extends wiki2xhtml
{
function wiki2xhtml_new()
{
parent::wiki2xhtml();
$this->setOpt('active_auto_urls',1); # Activation de la reconnaissance d'url
$this->setOpt('active_macros',1); # Activation des macros «««..»»»
$this->setOpt('active_wikiwords',1); # Activation des mots wiki
$this->setOpt('words_pattern','((?setOpt('mail_pattern','/^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})$/');
$this->setOpt('url_pattern','/^(?registerFunction('macro:w',array($this,'__macroWikiWords'));
}
function parseWikiWord($str,&$tag,&$attr,&$type)
{
// $tag = 'span';
// $attr = ' class="wiki" onclick="wLink(this);" title="'.$str.'"';
$tag = 'a';
$attr = ' href="./?'.$str.'"';
return $str;
}
function parseMacro($str,&$tag,&$attr,&$type)
{
$data = $this->__splitTagsAttr($str);
if (count($data) == 1)
{
$item = trim($str);
$content = $str;
}
elseif (count($data) > 1)
{
$item = $data[0];
$content = trim($data[1]);
}
$tag = 'span';
$attr = ' class="wiki" onclick="wLink(this);" title="'.$content.'"';
$str = $item;
return $str;
}
function __specialUrls()
{
$res['#^google://(.*)$#'] = 'http://www.google.com/search?q=$1&start=0&start=0';
$res['#^wikipedia://(.*)$#'] = 'http://en.wikipedia.org/wiki/$1';
$res['#^wiki://(.*)$#'] = './?$1';
return $res;
}
function InsertLinks ( $Text )
{
$Result = preg_replace( $Expr, "$0", $Text );
return $Result;
}
function __macroWikiWords($s)
{
//return ''.$s.'';
return ''.$s.'';
}
}
function seems_utf8($Str)
{
for ($i=0; $iread());
sort($my_files);
while ($file=next($my_files)) {
if (ereg("^.*\.txt\.gz$", $file)) {
$ret []= $file;
}
}
$data_dir_obj->close();
foreach($ret as $r) {
$itm=basename($r, ".item.gz");
$new[$r]=$itm;
}
return $new;
}
function get_backlinks($item){}
function get_last_num($f){}
###
### Main
$wiki = new wiki2xhtml_new();
if (!file_exists($f)) {touch ($f);chmod($f,0666);}
if (!$decode) $res = $wiki->transform(@implode("",@gzfile($f))); //xhtml coded version
else $res = @implode("",@gzfile($f)); //brute wiki coded version
if (!empty($res)) $tmp= $res;
else $tmp="empty page";
$xhtml="
Livewiki ".$item."
Pascal Guimier - ARTIS-TIC
Livewiki ".$item."
$tmp
";
$test = & new xhtml2pdf_new ($xhtml, 'test.css');
$test->output();
?>