It's been a while since I wrote last time on this forum.
I had problem with website going blank almost two years ago and we had a discussion back then. At that time I solved problem by using str_replace.
Now I can offer you solution that probably will resolve this issue for good if you accept it.
I came on idea of using "Simple HTML DOM Parser" (I saw usage of it in some other plug-in).
You can download it from site http://simplehtmldom.sourceforge.net/ and it's licensed under MIT license.
So to short my story in file phocapdfcontent.pdf you include this library
Code: Select all
include_once(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_phocapdf'.DS.'helpers'.DS.'simple_html_dom.php');
Code: Select all
if ($doctype == 'html') {
$bodySite = JResponse::getBody();
$html = str_get_html($bodySite);
foreach($html->find('a') as $link){
if ($pdfDestination == 'I' || $pdfDestination == 'D') {
// Remome OnClick
if ($sefEnabled == 1) {
$pattern = '/<a(.+)href="(.*)\.pdf\?(.*)"(.+)onclick="(.*)"/Ui';
$replacement = '<a $1href="$2.pdf?format=phocapdf&$3"$4';
$link->outertext = preg_replace($pattern, $replacement, $link);
} else if ($sefEnabled == 2) {
$pattern = '/<a(.+)href="(.*)\.pdf(.*)"(.+)onclick="(.*)"/Ui';
$replacement = '<a $1href="$2.pdf?format=phocapdf$3"$4';
$link->outertext = preg_replace($pattern, $replacement, $link);
} else {
$pattern = '/<a(.+)href="(.*)format=pdf(.*)"(.+)onclick="(.*)"/Ui';
$replacement = '<a $1href="$2format=phocapdf$3"$4';
$link->outertext = preg_replace($pattern, $replacement, $link);
}
} else {
$browser = PhocaPDFHelperBrowser::browserDetection('browser');
if ($sefEnabled == 1) {
$pattern = '/<a(.+)href="(.*)\.pdf\?(.*)"(.+)onclick="(.*)"/Ui';
if ($browser == 'msie7' || $browser == 'msie8') {
$replacement = '<a $1href="$2.pdf?format=phocapdf&$3"$4 target="_blank"';
} else {
$replacement = '<a $1href="$2.pdf?format=phocapdf&$3"$4 onclick="$5"';
}
$link->outertext = preg_replace($pattern, $replacement, $link);
} else if ($sefEnabled == 2) {
$pattern = '/<a(.+)href="(.*)\.pdf(.*)"(.+)onclick="(.*)"/Ui';
if ($browser == 'msie7' || $browser == 'msie8') {
$replacement = '<a $1href="$2.pdf?format=phocapdf$3"$4 target="_blank"';
} else {
$replacement = '<a $1href="$2.pdf?format=phocapdf$3"$4 onclick="$5"';
}
$link->outertext = preg_replace($pattern, $replacement, $link);
} else {
$pattern = '/<a(.+)href="(.*)format=pdf(.*)"(.+)onclick="(.*)"/Ui';
if ($browser == 'msie7' || $browser == 'msie8') {
$replacement = '<a $1href="$2format=phocapdf$3"$4 target="_blank"';
} else {
$replacement = '<a $1href="$2format=phocapdf$3"$4 onclick="$5"';
}
$link->outertext = preg_replace($pattern, $replacement, $link);
}
}
}
$bodySite = $html;
unset($html);
JResponse::setBody($bodySite);
}
I hope that you can use something of this to solve problem.