Wrong image with couple Phoca Galley Plugins in article

Phoca Gallery plugins - plugins for Phoca Gallery extension
zocha
Phoca Member
Phoca Member
Posts: 23
Joined: 12 Nov 2008, 14:25

Wrong image with couple Phoca Galley Plugins in article

Post by zocha »

Hello,

I have to put couple separate images in my article, so I've created something like (code copied from #_content by mysqldump):

Code: Select all

{phocagallery view=category|categoryid=6|\r\nimageid=49|limitstart=0|limitcount=2|\r\nfontcolor=#B88A00|bgcolor=#FFBF00|bgcolorhover=#BFFF00|imagebgcolor=#FFD24D|\r\nbordercolor=#B88A00|bordercolorhover=#86B300|\r\ndetail=3|displayname=0|displaydetail=0|displaydownload=0|displaybuttons=0|float=left}\r\n\r\n{phocagallery view=category|categoryid=6|\r\nimageid=51|limitstart=0|limitcount=2|\r\nfontcolor=#B88A00|bgcolor=#FFBF00|bgcolorhover=#BFFF00|imagebgcolor=#FFD24D|\r\nbordercolor=#B88A00|bordercolorhover=#86B300|\r\ndetail=3|displayname=0|displaydetail=0|displaydownload=0|displaybuttons=0|float=left}\r\n\r\n{phocagallery view=category|categoryid=6|\r\nimageid=50|limitstart=0|limitcount=2|\r\nfontcolor=#B88A00|bgcolor=#FFBF00|bgcolorhover=#BFFF00|imagebgcolor=#FFD24D|\r\nbordercolor=#B88A00|bordercolorhover=#86B300|\r\ndetail=3|displayname=0|displaydetail=0|displaydownload=0|displaybuttons=0|float=left}\r\n\r\n{phocagallery view=category|categoryid=6|\r\nimageid=52|limitstart=0|limitcount=2|\r\nfontcolor=#B88A00|bgcolor=#FFBF00|bgcolorhover=#BFFF00|imagebgcolor=#FFD24D|\r\nbordercolor=#B88A00|bordercolorhover=#86B300|\r\ndetail=3|displayname=0|displaydetail=0|displaydownload=0|displaybuttons=0|float=left}\r\nNew prototypes\r\n<hr id="system-readmore" />\r\nArticle details...
Sorry for the form, but it would be impossible to show the error cause and the resolution otherways.

The code was created by copying from Displaying Phoca Gallery Plugin page. It worked well in couple articles with 2 or 3 images, but suddenly with the code above I've got very strange results - I've go 6 images, but really it was images 49 and 51 repeated 3 times. I've thought that it's because of "limitcount=2", but after changing it to "limitcount=1", I've got image 49 repeated 4 times.

Eventually I've removed all "\r\n"s from within the plugin code, so I've got:

Code: Select all

{phocagallery view=category|categoryid=6|imageid=49|limitstart=0|limitcount=2|fontcolor=#B88A00|bgcolor=#FFBF00|bgcolorhover=#BFFF00|imagebgcolor=#FFD24D|bordercolor=#B88A00|bordercolorhover=#86B300|detail=3|displayname=0|displaydetail=0|displaydownload=0|displaybuttons=0|float=left}\r\n\r\n{phocagallery view=category|categoryid=6|imageid=51|limitstart=0|limitcount=2|fontcolor=#B88A00|bgcolor=#FFBF00|bgcolorhover=#BFFF00|imagebgcolor=#FFD24D|bordercolor=#B88A00|bordercolorhover=#86B300|detail=3|displayname=0|displaydetail=0|displaydownload=0|displaybuttons=0|float=left}\r\n\r\n{phocagallery view=category|categoryid=6|imageid=50|limitstart=0|limitcount=2|fontcolor=#B88A00|bgcolor=#FFBF00|bgcolorhover=#BFFF00|imagebgcolor=#FFD24D|bordercolor=#B88A00|bordercolorhover=#86B300|detail=3|displayname=0|displaydetail=0|displaydownload=0|displaybuttons=0|float=left}\r\n\r\n{phocagallery view=category|categoryid=6|imageid=52|limitstart=0|limitcount=2|fontcolor=#B88A00|bgcolor=#FFBF00|bgcolorhover=#BFFF00|imagebgcolor=#FFD24D|bordercolor=#B88A00|bordercolorhover=#86B300|detail=3|displayname=0|displaydetail=0|displaydownload=0|displaybuttons=0|float=left}\r\nNew prototypes\r\n<hr id="system-readmore" />\r\nArticle details...
and suddenly everything starts to work just fine. After I've found resolution of my problem, I've searched the forum and found that one of your first answers in most problems is to remove all spaces from within plugin call code. So my suggestion is to remove all break lines (<br>) from the example codes of Displaying Phoca Gallery Plugin page, because they are translated to "\r\n" code when pasted into Joomla content editor. I thing it would save me, you and others many hours of fighting with such problems.

Best regards,
Łukasz Indeka
Łukasz Indeka
Joomla VirtueMart
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48402
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Wrong image with couple Phoca Galley Plugins in article

Post by Jan »

Hi I will take a look at it - to add some str_replace or other method...

but now you should add:

{phocagallery view=category|categoryid=6|imageid=49|limitstart=0|limitcount=2|...

not:
{phocagallery view=category|
categoryid=6|
imageid=49|
limitstart=0|
limitcount=2|

without any spaces, any break lines, etc... the problem is, Phoca Gallery plugin doesn't check the saving of article, so if such \r\n characters will be added while saving article, Phoca Gallery plugin can only remove these characters before it will be displayed but it can be problematic...

Jan
If you find Phoca extensions useful, please support the project
zocha
Phoca Member
Phoca Member
Posts: 23
Joined: 12 Nov 2008, 14:25

Re: Wrong image with couple Phoca Galley Plugins in article

Post by zocha »

Hi,

I've looked at the code of PhocaGallery Plugin and found:

Code: Select all

		$regex_one		= '/({phocagallery\s*)(.*?)(})/si';
		$regex_all		= '/{phocagallery\s*.*?}/si';
When I've did massive changes of phocagallery settings in my db, I've used Python with following code:

Code: Select all

pat = re.compile("""
        (?P<before>^.*)                                         # Skip everything before
        (?P<header>{phocagallery[ ]view=category\|categoryid=)  # Skip plugin header and common things
        (?P<catid>[X]+)                                         # Category ID
        (?P<middle>\|\\r\\nimageid=)                            # Skip middle
        "(?P<images>[^"]*)"                                     # Images addresses
        (?P<footer>\|[^}]+})                                    # Skip plugin footer common things
        (?P<after>.*$)                                          # Skip everything after
        """, re.VERBOSE|re.MULTILINE|re.DOTALL)
Everytime I've got only one, first match. But the most important part (I think) is [^}]+ (line with comment "Skip plugin footer common things"). I think, that if you replace .*? with [^}]* and allow multiline in regexp pattern modifiers, you probably would get better results. I've not checked it! It's only my idea. I've had problems when I've created my regexp with multiple instances of phocagalelry plugin in one article and that was the sollution.
Łukasz Indeka
Joomla VirtueMart
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48402
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Wrong image with couple Phoca Galley Plugins in article

Post by Jan »

Hi, will it work on frontpage too (where e.g. 10 articles with with different instances of Phoca Gallery plugin appear)?

Jan
If you find Phoca extensions useful, please support the project
zocha
Phoca Member
Phoca Member
Posts: 23
Joined: 12 Nov 2008, 14:25

Re: Wrong image with couple Phoca Galley Plugins in article

Post by zocha »

Jan wrote:Hi, will it work on frontpage too (where e.g. 10 articles with with different instances of Phoca Gallery plugin appear)?
Hi,

Probably it will work, but the time... could be a problem. I haven't tested it against time consumption because time wasn't problem in my situation.

Maybe we just stop to discuss it as there probably would be hard to find good and fast solution, but instead please change the code of https://www.phoca.cz/documents/14-phoca- ... ery-plugin from:

Code: Select all

<p><b>Images displaying</b></p>
<p><img height="12" alt="" width="6" src="https://www.phoca.cz/documentation/images/documentation/lt.gif" />phocagallery view=category|categoryid=2|<br />
imageid=0|limitstart=0|limitcount=2|<br />
fontcolor=#B88A00|bgcolor=#FFBF00|bgcolorhover=#BFFF00|imagebgcolor=#FFD24D|<br />
bordercolor=#B88A00|bordercolorhover=#86B300|<br />
detail=1|displayname=1|displaydetail=1|displaydownload=1|float=right<img alt="" src="https://www.phoca.cz/documentation/images/documentation/gt.gif" /></p>
into:

Code: Select all

<p><b>Images displaying</b></p>
<p><img height="12" alt="" width="6" src="https://www.phoca.cz/documentation/images/documentation/lt.gif" />phocagallery view=category|categoryid=2|imageid=0|limitstart=0|limitcount=2|fontcolor=#B88A00|bgcolor=#FFBF00|bgcolorhover=#BFFF00|imagebgcolor=#FFD24D|bordercolor=#B88A00|bordercolorhover=#86B300|detail=1|displayname=1|displaydetail=1|displaydownload=1|float=right<img alt="" src="https://www.phoca.cz/documentation/images/documentation/gt.gif" /></p>
... And maybe put there Red bold text for people like me that there should be no spaces or end of line characters between the brackets. :P
Łukasz Indeka
Joomla VirtueMart
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48402
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Wrong image with couple Phoca Galley Plugins in article

Post by Jan »

Hi, there are break lines because of site length, but I will paste there a warning about line breaks :-)
If you find Phoca extensions useful, please support the project
Post Reply