#107 closed Bug (wontfix)
Impossible to use PHP inside tag definitions
Reported by: | Owned by: | ||
---|---|---|---|
Priority: | Normal | Milestone: | |
Component: | General | Version: | FCKeditor 2.4 |
Keywords: | CantFix | Cc: |
Description
It seems the ternary operator ('?') can be confused with the PHP closing tag ('?>') when embedding PHP code in the edited content.
I have enabled the Protected code option for PHP, and for the most part the PHP is left alone. However, whenever I use the ternary operator to generate options within HTML tags, the next PHP closing tag is interpreted as closing the HTML tag. For example the code
<input type="radio" name="stype" <?php echo ($i == 0) ? (" on") : ("") ; ?> id="stype<?php echo $i; ?>" value="<?php echo $subsDetail['type'] ; ?>" />
becomes
<input type="radio" name="stype" value="on" /> id="stype<?=$i?>" value="<?php echo $subsDetail['type'] ; ?>" />
after switching from the source.
This is not the end of the world as I can just use if/else statements instead, it is a pain however.
Change History (5)
comment:1 Changed 18 years ago by
comment:2 Changed 18 years ago by
Component: | Server : PHP → General |
---|---|
Keywords: | CantFix added; ternary removed |
Owner: | Frederico Caldeira Knabben deleted |
The fact is that the ProtectedSource feature will not work inside tags declarations.
To protect content, FCKeditor uses a Regex to remove it from the original source, moving it to an Array. The original protected source is then replaced with a HTML comment, like <!-- PS:n -->, where "n" is the index of the protected data in the Array. The problem is that a comment is not allowed inside a tag declaration, and so the HTML gets broken in your case.
I don't see other ways to protect part of the original data, so I don't believe a fix for it will be ever available. So, when using FCKeditor, users must be aware of this limitation and work accordingly to it. So, your code must be rewritten... something like:
<?php echo '<input type="radio" name="stype" ' . ( ($i == 0) ? (" on") : ("") ) . ' id="stype' . $i . '" value="' . $subsDetail['type'] . '" />' ; ?>
comment:3 Changed 18 years ago by
Summary: | Ternary operator confused with PHP closing tag → Impossible to use PHP inside tag definitions |
---|
comment:4 Changed 18 years ago by
Resolution: | → wontfix |
---|---|
Status: | new → closed |
comment:5 Changed 18 years ago by
https://sourceforge.net/tracker/index.php?func=detail&aid=1342945&group_id=75348&atid=543656 has been marked as dup.
On further inspection (I apologise for being hasty) it seems it is not the ternary operator, but some PHP blocks within an HTML input tag. I have some examples here:
is left untouched.
However
becomes
However if I swap the order of parameters in the second example:
it leaves the first two blocks alone and just messes up the last block:
(it has, however changed the order of some of the parameters...)