Opened 18 years ago
Closed 18 years ago
#1437 closed Bug (fixed)
Patch to properly handle MW Special Tags
| Reported by: | barns | Owned by: | |
|---|---|---|---|
| Priority: | Normal | Milestone: | |
| Component: | Project : MediaWiki+FCKeditor | Version: | |
| Keywords: | HasPatch | Cc: |
Description
Replace the line breaks in special tags to be sure not to lose them in IE6. Also give the special tags a common class to be able to identify them in fckplugins.js and replace it by an image, like templates.
In FCKeditorParser.body.php:
private function fck_addToStrtr($text) {
$key = 'Fckmw'.$this->fck_mw_strtr_span_counter.'fckmw';
$this->fck_mw_strtr_span_counter++;
$this->fck_mw_strtr_span[$key] = str_replace(array("\r\n", "\n", "\r"),"fckLR",$text);
return $key;
}
function fck_genericTagHook( $str, $argv, $parser ) {
if (empty($argv)) {
$ret = "<span class=\"fck_mw_special\" _fck_mw_customtag=\"true\" _fck_mw_tagname=\"".$this->fck_mw_taghook."\">"; //YC
}
else {
$ret = "<span class=\"fck_mw_special\" _fck_mw_customtag=\"true\" _fck_mw_tagname=\"".$this->fck_mw_taghook."\""; //YC
In FCKeditorSajax.body.php:
function wfSajaxSearchSpecialTagFCKeditor($empty)
{
global $wgParser;
$ret = "";
foreach ($wgParser->getTags() as $h) {
if (!in_array($h, array("pre"))) {
$ret .= $h ."\n";
}
}
return $ret;
}
In fckplugin.js:
tbButton = new FCKToolbarButton( 'MW_Special', 'Special Tag', 'Insert/Edit Special Tag' ) ;
tbButton.IconPath = FCKConfig.PluginsPath + 'mediawiki/images/tb_icon_special.gif' ;
FCKToolbarItems.RegisterItem( 'MW_Special', tbButton ) ;
FCKCommands.RegisterCommand( 'MW_Special', new FCKDialogCommand( 'MW_Special', 'Special Tag Properties', FCKConfig.PluginsPath + 'mediawiki/dialogs/special.html', 400, 330 ) ) ; //YC
---------------------------------
// Text Node.
case 3 :
var parentIsSpecialTag = htmlNode.parentNode.className.IEquals( 'fck_mw_special', 'fck_mw_template' ) ; //YC
var textValue = htmlNode.nodeValue;
if ( !parentIsSpecialTag ) //YC
{
if (!this._IsInPre(htmlNode))
textValue = textValue.replace( /[\n\t]/g, ' ' ) ;
textValue = FCKTools.HTMLEncode( textValue ) ;
textValue = textValue.replace( /\u00A0/g, ' ' ) ;
if ( !htmlNode.previousSibling ||
( stringBuilder.length > 0 && stringBuilder[ stringBuilder.length - 1 ].EndsWith( '\n' ) ) )
{
textValue = textValue.LTrim() ;
}
if ( !htmlNode.nextSibling )
textValue = textValue.RTrim() ;
textValue = textValue.replace( / {2,}/g, ' ' ) ;
if ( this._IsInsideCell )
textValue = textValue.replace( /\|/g, '|' ) ;
}
else
{
textValue = FCKTools.HTMLDecode(textValue).replace(/fckLR/g,'\r\n');
}
---------------------------------
// MediaWiki document processor.
FCKDocumentProcessor.AppendNew().ProcessDocument = function( document )
{
// Templates and magic words.
var aSpans = document.getElementsByTagName( 'SPAN' ) ;
var eSpan ;
var i = aSpans.length - 1 ;
while ( i >= 0 && ( eSpan = aSpans[i--] ) )
{
var className = null ;
switch ( eSpan.className )
{
case 'fck_mw_ref' :
className = 'FCK__MWRef' ;
case 'fck_mw_references' :
if ( className == null )
className = 'FCK__MWReferences' ;
case 'fck_mw_template' :
if ( className == null ) //YC
className = 'FCK__MWTemplate' ; //YC
case 'fck_mw_magic' :
if ( className == null )
className = 'FCK__MWMagicWord' ;
case 'fck_mw_special' : //YC
if ( className == null )
className = 'FCK__MWSpecial' ;
---------------------------------
// Context menu for templates.
FCK.ContextMenu.RegisterListener({
AddItems : function( contextMenu, tag, tagName )
{
if ( tagName == 'IMG' )
{
if ( tag.getAttribute( '_fck_mw_template' ) )
{
contextMenu.AddSeparator() ;
contextMenu.AddItem( 'MW_Template', 'Template Properties' ) ;
}
if ( tag.getAttribute( '_fck_mw_magic' ) )
{
contextMenu.AddSeparator() ;
contextMenu.AddItem( 'MW_MagicWord', 'Modify Redirect' ) ;
}
if ( tag.getAttribute( '_fck_mw_special' ) ) //YC
{
contextMenu.AddSeparator() ;
contextMenu.AddItem( 'MW_Special', 'Special Tag Properties' ) ;
}
Dialog special.html in attachment.
Attachments (1)
Change History (3)
Changed 18 years ago by
| Attachment: | special.html added |
|---|
comment:1 Changed 18 years ago by
| Keywords: | HasPatch added |
|---|
comment:2 Changed 18 years ago by
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |

Dialog for special tags