Commit 1d2a23e8 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Modify Skype & Twitter filters to deal with TinyMCE 3 formatting

parent 2ea9d1d4
......@@ -6,15 +6,15 @@ class HTMLPurifier_Filter_Skype extends HTMLPurifier_Filter
public $name = 'Skype';
public function preFilter($html, $config, $context) {
$pre_regex = '#<script\b[^>]+?\bsrc="http://download.skype.com/share/skypebuttons/js/skypeCheck.js"[^>]*>\s*</script>'.
'\s*<a\b[^>]+?\bhref="skype:([^?"<>]+)\?call"[^>]*>\s*(<img\s+src="http://(download|mystatus)\.skype\.com/[^<>]+>)\s*</a>#s';
$pre_replace = '<span class="skype-button"><span class="skype-name">\1</span>\2</span>';
$pre_regex = '#<script\b[^>]+?\bsrc="http://download.skype.com/share/skypebuttons/js/skypeCheck.js"[^<>]*>\s*</script>'.
'\s*<a\b[^<>]+?\bhref="skype:([^?"<>]+)\?call"[^>]*>\s*<img\b[^<>]+?\b(src="http://(download|mystatus)\.skype\.com/[^<>]+>)\s*</a>#s';
$pre_replace = '<span class="skype-button"><span class="skype-name">\1</span><img \2</span>';
return preg_replace($pre_regex, $pre_replace, $html);
}
public function postFilter($html, $config, $context) {
$post_regex = '#<span class="skype-button"><span class="skype-name">([a-zA-Z0-9_,\.-]+)</span>'.
'(<img\s+src="http://(download|mystatus)\.skype\.com/[\sa-zA-Z0-9"=_.:;!™-]+>)</span>#';
'(<img\s+src="http://(download|mystatus)\.skype\.com/[\s/a-zA-Z0-9"=_.:;!™-]+>)</span>#';
$post_replace = '<script type="text/javascript" src="http://download.skype.com/share/skypebuttons/js/skypeCheck.js"></script><a href="skype:\1?call">\2</a>';
return preg_replace($post_regex, $post_replace, $html);
}
......
......@@ -24,8 +24,8 @@ class HTMLPurifier_Filter_Twitter extends HTMLPurifier_Filter
public function postFilter($html, $config, $context) {
$post_regex = array(
'#<span class="twitter-updates-js"><span class="title">([^<]+)</span><span class="username">([a-zA-Z0-9_]+)</span><span class="count">(\d+)</span></span>#',
'#<span class="twitter-badge-flash">([a-zA-Z0-9_=&\.,-]+)</span>#',
'#<span class="twitter-timeline-badge-flash">([a-zA-Z0-9_=&\.,-]+)</span>#',
'#<span class="twitter-badge-flash">(([a-zA-Z0-9_=&\.,-]+|&amp;)+)</span>#',
'#<span class="twitter-timeline-badge-flash">(([a-zA-Z0-9_=&\.,-]+|&amp;)+)</span>#',
);
$post_replace = array(
'<div id="twitter_div"><h2 class="sidebar-title">\1</h2><ul id="twitter_update_list"></ul></div>'.
......
......@@ -174,6 +174,7 @@ tinyMCE.init({
content_css : {$content_css},
forced_root_block : "",
force_p_newlines : false,
apply_source_formatting: false,
//document_base_url: {$jswwwroot},
relative_urls: false
});
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment