Page 2 of 6
Re: Website goes blank!
Posted: 19 Aug 2009, 18:30
by F@re
Jan wrote:Hi, thank you for your information, yes the non system solution (find and replace link to pdf) is not good solution but didn't find any better
Maybe using ereg_replace will be better then preg_replace_callback.
Did you test it, does it work? If yes, I will try to change it and test it.
Can you share changes you have made?
Thank you, Jan
Of course I can share
I replaced original code
Code: Select all
if ($pdfDestination == 'I' || $pdfDestination == 'D') {
// Remome OnClick
//$bodySite = preg_replace_callback('/<a(.+)href="(.*)format=pdf(.*)"(.+)onclick="(.*)"/Ui', array('plgSystemPhocaPDFContent', 'phocaPDFCallbackOnClick'), $bodySite);
} else {
//$bodySite = preg_replace_callback('/<a(.+)href="(.*)format=pdf(.*)"/Ui', array('plgSystemPhocaPDFContent', 'phocaPDFCallback'), $bodySite);
// IE 7 bug
$bodySite = preg_replace_callback('/<a(.+)href="(.*)format=pdf(.*)"(.+)onclick="(.*)"/Ui', array('plgSystemPhocaPDFContent', 'phocaPDFCallbackOnClickIE'), $bodySite); //this line is causing blank page
}
with one simple line of code
Code: Select all
$bodySite = str_ireplace('?format=pdf','?format=phocapdf',$bodySite);
Since documentation is advise to use str_ireplace if there is no need for 'fancy' patterns. But if still you want to use complex pattern I would use
preg_replace since for POSIX Regex(ereg_function) appears that PHP is abandoning it from 5.3 version(so you would avoid future problems)
I'm guessing that my solution is not in any way the best solution since $bodySite contains whole code of page (so maybe somewhere else on the page will be '?format=pdf' ).
Also I'm still trying to figure out problem when SEF and suffix is on. SEF engine adds suffix based on format= part of query(then format should be .phocapdf) but it's not. I know that there is solution with template override of article/category-blog/section-blog content. But I guess that there should be more general solution for this problem also.
And one more thing (since I'm new to joomla coding and I'm still trying to fit all pieces together ). Is this plugin must belong to system category(maybe content?) ? If question is stupid just don't laugh
Re: Website goes blank!
Posted: 20 Aug 2009, 16:51
by Jan
Hi, thank you for sharing it.
Yes, there can be problem with str_ireplace because of whole content. But maybe I can add there some parameter to select the method (if you will know, there is no such string in content more, you can use str_ireplace which will be better then).
Is this plugin must belong to system category(maybe content?) ?
The links (PDF, Email, Print) are not parts of content, so system plugin needs to be used. If we would search the string 'format=pdf' in content (article) then we can use content plugin.
With preg_replace it can looks like:
Code: Select all
$pattern = '/<a(.+)href="(.*)format=pdf(.*)"(.+)onclick="(.*)"/Ui';
$replacement = '<a $1href="$2format=phocapdf$3"$4onclick="$5"';
$bodySite = preg_replace($pattern, $replacement, $bodySite);
Please try to test it with preg_replace, if this will be OK, I will change it in this plugin
Thank you, Jan
Jan
Re: Website goes blank!
Posted: 31 Aug 2009, 23:41
by F@re
Hello Jan,
Sorry for this big delay in my response. I was on vacation far away from PC
I see that you made modification to plugin. I tried modified version and guess what? It didn't work.
So again i looked for error. It's is same error like in case of callback function.
PREG_BACKTRACK_LIMIT_ERROR!
First I tried to change call to
eregi_replace. I lost lot of time because of this. I thought that pattern is same so I played around other installed pluginss thinking that maybe some of them are reason and why the hell link aren't rendered properly.
At the end I was again with this plugin, and then I realized that pattern isn't same(I already told that I'm not good in PHP
).
Pattern is way different for
eregi_replace so I decided to go again like the first time with
str_replace. It's good for me since chance that I will have .pdf in text on website is 0.1%.
But I decided to find out reason for fail call to preg_replace. After shutting down almost all plugins and modules(again and I'm talking about live site on web
) I found reason. My main menu module is reason. It's quite richfull superfish 3-level menu. It's rendered in one big html line (at least 6500 characters). And since it has many links ('<a href' part of pattern) I'm guessing that default limit is reached(I checked pcre.backtrack_limit and it has default value 100000 but obviously this is not enough).
Obviously one solution would be rewrite output for menu but I think that some solution should be found inside this plugin so that this can be avoided. If you think something let me know. I'm more than willing to help you. Until then I will use modified version on my way
Re: Website goes blank!
Posted: 04 Sep 2009, 23:42
by Jan
Hi, I have removed the callback functions see: 1.0.3 (you can set the method of SEF to find the link too) you need to upgrade the component to 1.0.2
Jan
Re: Website goes blank!
Posted: 05 Sep 2009, 21:59
by F@re
Jan wrote:Hi, I have removed the callback functions see: 1.0.3 (you can set the method of SEF to find the link too) you need to upgrade the component to 1.0.2
Jan
I'm was talking about version without callback(plugin 1.0.2).
Now I tried new component (1.0.2) and plugin 1.0.3.
Same story. Blank page.
Debugged error: PREG_BACKTRACK_LIMIT_ERROR
Cause of error: my main menu and bunch of links inside.
And again I will modify and use str_replace. This is one solution and is good for me.
I don't how memory/cpu demanding are arrays and loops in php but here is how I would try to solve this problem.
I would break whole body output into array by using end of line character(each element in array is one line of body). Then I would first probe each line for pdf link. After I confirm that link exist then I would use preg_replace. At the end join back whole array and that is new body. But again I say I'm new to php so I don't know how much of server resource operataion like this would take.
Re: Website goes blank!
Posted: 07 Sep 2009, 11:15
by ssnobben
Hi
I just want to say that I also get blank page for using Mosets Tree 2.1.2 seem like this is similar problem..
viewtopic.php?f=37&t=5764
Re: Website goes blank!
Posted: 12 Oct 2009, 12:09
by Lintzy
Hi, it also does not work with
Superfish Dropdown Menu
If it is enabled, I get a blank white page.
Re: Website goes blank!
Posted: 12 Oct 2009, 19:08
by Lintzy
That is odd. It is NOT jQuery from Suckerfish.
Just I have made an own topmenu, styled only with css ( and suckerfish module disabled). My own topmenu works good with enabled phoca pdf.plugin until submenu 1. When I activate submenu 2 I get a blank white page again. If I disable phoca.pdf plugin my menu works.
UL (Topmenu)
li -> ul (1. Submenu)
li -> ul (2. Submenu) <---- fails with activated pdf.plugin.
Re: Website goes blank!
Posted: 15 Oct 2009, 08:38
by Lintzy
No Fix for it?
Re: Website goes blank!
Posted: 16 Oct 2009, 20:46
by Jan
There is a problem
how to work this string: '/<a(.+)href="(.*)format=pdf(.*)"(.+)onclick="(.*)"/Ui with str_replace
Jan