Abiword to prosty edytor ala word/openoffice writer tyle że prostszy. Do pobrania dla wielu systemów na
stronie aplikacji 
Poniższy skrypt przerobi plik abw na jako taki HTML

Wymaga PHP5+SimpleXML. Jeżeli plik zawiera grafiki to skryp będzie chciał je zapisać do bierzącego katalogu (wymagane uprawnienia zapisu)
<?php
echo '<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body>'; // read content
// tekst
$texts = $text[2];
// grafika
$extras = $extra[0];
{
// jeżeli są grafiki /załączniki to pojedź dalej
$xml = simplexml_load_string($extras);
$iter = 0;
{
foreach($xml->d as $d)
{
IF(ereg('image/([a-z]*)', $xml->d['mime-type'], $tab)) {
$filename = md5($xml->d[$iter]['name']); $images[$filename] = $filename.'.'.$tab[1];
file_put_contents($filename.'.'.$tab[1], $image_content);
$iter++;
}
}
// przerabiamy wywołania do grafik na img src
foreach($img[1] as $key => $val)
{
$texts = str_replace($img[0
][$key], '<img src="'.$images[$val].'">', $texts); }
}
}
// tabelki
preg_match_all('#<cell props="bot-attach:([0-9]*); left-attach:([0-9]*); right-attach:([0-9]*); top-attach:([0-9]*)">#es', $texts, $table); $tr = 0;
foreach($table[0] as $key => $val)
{
IF($tr != $table[4][$key])
{
$tr = $table[4][$key];
}
else
{
}
}
// wypunktowanie
preg_match_all('#<c props="([a-zA-Z0-9 _;:-]*) list-style:Bullet List; ([a-zA-Z0-9 _;:-]*)">(.*?)</c>#es', $texts, $li); foreach($li[0] as $key => $val)
{
$texts = str_replace($val, '<LI>'.$li[3
][$key].'</LI>', $texts); }
preg_match_all('#<p level="(.*?) list-style:Numbered List; ([a-zA-Z0-9 _;:-]*)">(.*?)</p>#es', $texts, $li2); foreach($li2[0] as $key => $val)
{
$texts = str_replace($val, '<LI>'.$li2[3
][$key].'</LI>', $texts); }
// czyszczenie, poprawki
$texts= preg_replace('#<field (.*?)></field>#es', '', $texts); $texts = strtr($texts, array('<c props' => '<div style', '</c>' => '</div>', 'props="' => 'style="', '</cell>' => '</td>', '<table>' => '<table border="1" width="100%"><tr>', '</table>' => '</tr></table>', '</field>' => '')); //highlight_string($texts);
//echo '<BR><BR><HR><BR>';
// kod HTML jest cienki ale ujdzie.. albo do Tidy albo do ręcznych poprawek
?>
</body></html>
Ten post edytował Riklaunim 19.09.2005, 20:08:40