TinyPortal

Development => Support => Topic started by: SniffTheGlove on May 26, 2010, 07:39:05 PM

Title: V0.9.8 - Apostrophes in PHP based Articles
Post by: SniffTheGlove on May 26, 2010, 07:39:05 PM
I have tried to search for an answer but the Search facility has been temporary disabled.

I am still using v0.9.8 (waiting for SMF to go gold and then for TP to be SMF2 Compliant)

I have created an Article using ADD PHP.

I am pulling out a text field of a MySQL DB and storing it as a variable, the data is stored in the DB fields with apostrophe's encoded as &# 039; (Space is there just for this post but not there in the actual code) using htmlentites.

Now one of the lines of php code in the article searches the variable for the encoded apostrophe and then puts a backslahes before it like \&# 039; (Again ignore the space)

I need the apostrophes like this as after being processed the variable is then sent to a javascript script where the \ is removed and the variable is displayed by the script.

I have to have the apostrophes re-encoded like this else the javascript see's it as a text delimiter.

Now the actual problem is that TP is running the article fine after I press SAVE however if I go and re-open the article for editing the code the code shown in the article body text box &# 039; is no longer present as it has been converted to an actual apostrophe and then further SAVE just breaks the code.

How can I get TP to keep the actual code correct with &# 039; as it should be when going to redit the code

Thaanks
Title: Re: V0.9.8 - Apostrophes in PHP based Articles
Post by: lurkalot on May 26, 2010, 08:23:31 PM
If I understand you correctly which is pretty rare for a  :idiot2: like me.

Have you tried turning off the WYSIWYG editor? 

Admin / Tinyportal / Settings / Use the WYSIWYG editor?  Yes/No.
Title: Re: V0.9.8 - Apostrophes in PHP based Articles
Post by: SniffTheGlove on May 26, 2010, 09:27:21 PM
There is no editor running, the Add PHP Article page just has..

Use PHP in Article ticked
Title Text Box
Body Text Box
Show on front page
Category

Title: Re: V0.9.8 - Apostrophes in PHP based Articles
Post by: IchBin on May 27, 2010, 10:22:51 PM
I'm sure part of the reason that TP parses special characters into htmlentities is for security. You'll probably haven't to do some decoding of your own if you want to change it. I'd take a look at the decode funciton.
htmlspecialchars_decode()