允许 fckeditor 2 中的样式属性与 php 集成
我还没有找到解决这个问题的实际方法。
在 FCKeditor 2 中,当使用 PHP 集成方法时,传递到编辑器的任何 html 元素都将剥离 css 样式。
因此,这:
<div style="color:#000;background:blue">hello</div>
最终会这样:
<div>hello</div>
我可以确认编辑器在保存时会正确传递样式,但是如果将其加载到编辑器中,它会被删除,因此在第二次保存时会被删除。
唯一的两个解决方案(不幸的是这不是我的解决方案)是使用 Javascript Integration(它不适合我的编码结构)或关闭 Magic Quotes。虽然我想关闭魔术引号,因为不建议依赖它,但我目前没有时间浏览我相当大的代码库以确保这样做不会破坏其他地方的东西。
所以,我想问如何使用启用了魔术引号的 PHP 集成通过 FCKeditor 2 来解决这个问题?我已经从 fckeditor.js 中的 FCKConfig.RemoveAttributes 中删除了“样式”。
请不要提供诸如“升级到 CKeditor”、“使用 javascript 集成”和“关闭魔术引号”之类的解决方案,因为这会违背本文的目的。感谢您的帮助,希望找到解决方案能够帮助许多其他遇到同样问题的人。
大卫
I am yet to find an actual solution to this problem.
In FCKeditor 2, when using PHP integration method, any html element that is passed to the editor will have the css styling stripped form it.
Therefore this:
<div style="color:#000;background:blue">hello</div>
will end up as this:
<div>hello</div>
I can confirm that the editor will pass the styling correctly upon saving it, but if you load it into the editor, it is stripped out and thus on 2nd save, is removed.
The only 2 solutions, which unfortunately aren't solutions for me, are to either use Javascript Integration, which doesn't work with my coding structure or to turn off Magic Quotes. While I would like to turn off magic quotes as its not recommended to rely on it, I don't have the time at the moment to go through my rather large code base to ensure that doing this won't break something somewhere else.
So, I am asking how this can be resolved with FCKeditor 2 using PHP integration with magic quotes enabled? I have already removed 'style' from FCKConfig.RemoveAttributes in fckeditor.js
Please don't offer solutions like "upgrade to CKeditor", "use javascript integration" and "turn off magic quotes" as that would defeat the purpose of this post. Thank you for any help and hopefully it finding a solution will help many others with the same problem.
David
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
比@Marek的答案更直接 -
在 PHP 端,您可以使用 检测是否启用了魔术引号,而不是关闭魔术引号
get_magic_quotes_gpc()
,并使用stripslashes()
撤消它们(如果存在)。To be more direct than @Marek's answer -
Instead of turning off magic quotes, on the PHP side you can detect if magic quotes are enabled using
get_magic_quotes_gpc()
, and usestripslashes()
to undo them if they are.您可以在运行时撤消魔术引号,请参阅示例#2:
http:// /www.php.net/manual/en/security.magicquotes.disabling.php
You can undo the magic quotes at runtime, see Example #2:
http://www.php.net/manual/en/security.magicquotes.disabling.php