Ticket #2324: 2324.patch

File 2324.patch, 13.7 KB (added by jeremysolt, 16 years ago)

patch that adds toolbar item and custom dialog for source tag

  • fckeditor_config.js

     
    1212        ['Cut','Copy','Paste',/*'PasteText','PasteWord',*/'-','Print'],
    1313        ['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],
    1414        ['SpecialChar','Table','Image','Rule'],
    15         ['MW_Template','MW_Special','MW_Ref','MW_Math'],
     15        ['MW_Template','MW_Special','MW_Ref', 'MW_Source','MW_Math'],
    1616        '/',
    1717        ['FontFormat'],
    1818        ['Bold','Italic','Underline','StrikeThrough','-','Subscript','Superscript'],
     
    3636// FCKConfig.DisableObjectResizing = true ;
    3737
    3838FCKConfig.EditorAreaStyles = '\
    39 .FCK__MWTemplate, .FCK__MWRef, .FCK__MWSpecial, .FCK__MWReferences, .FCK__MWNowiki, .FCK__MWIncludeonly, .FCK__MWNoinclude, .FCK__MWOnlyinclude, .FCK__MWGallery \
     39.FCK__MWTemplate,. FCK__MWSource, .FCK__MWRef, .FCK__MWSpecial, .FCK__MWReferences, .FCK__MWNowiki, .FCK__MWIncludeonly, .FCK__MWNoinclude, .FCK__MWOnlyinclude, .FCK__MWGallery \
    4040{ \
    4141        border: 1px dotted #00F; \
    4242        background-position: center center; \
     
    4949        width: 20px; \
    5050        height: 15px; \
    5151} \
     52.FCK__MWSource \
     53{ \
     54        background-image: url(' + FCKConfig.PluginsPath + 'mediawiki/images/icon_source.gif); \
     55        width: 59px; \
     56        height: 15px; \
     57} \
    5258.FCK__MWRef \
    5359{ \
    5460        background-image: url(' + FCKConfig.PluginsPath + 'mediawiki/images/icon_ref.gif); \
  • FCKeditorParser.body.php

     
    7474        * @return string
    7575        */
    7676        function fck_genericTagHook( $str, $argv, $parser ) {
    77                 if (in_array($this->fck_mw_taghook, array("ref", "math", "references"))) {
     77                if (in_array($this->fck_mw_taghook, array("ref", "math", "references", "source"))) {
    7878                        $class = $this->fck_mw_taghook;
    7979                }
    8080                else {
  • mw12/FCKeditorParser_OldPP.body.php

     
    7575        * @return string
    7676        */
    7777        function fck_genericTagHook( $str, $argv, $parser ) {
    78                 if (in_array($this->fck_mw_taghook, array("ref", "math", "references"))) {
     78                if (in_array($this->fck_mw_taghook, array("ref", "math", "references", "source"))) {
    7979                        $class = $this->fck_mw_taghook;
    8080                }
    8181                else {
  • plugins/mediawiki/dialogs/source.html

     
     1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
     2<!--
     3 * FCKeditor - The text editor for Internet - http://www.fckeditor.net
     4 * Copyright (C) 2003-2007 Frederico Caldeira Knabben
     5 *
     6 * == BEGIN LICENSE ==
     7 *
     8 * Licensed under the terms of any of the following licenses at your
     9 * choice:
     10 *
     11 *  - GNU General Public License Version 2 or later (the "GPL")
     12 *    http://www.gnu.org/licenses/gpl.html
     13 *
     14 *  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
     15 *    http://www.gnu.org/licenses/lgpl.html
     16 *
     17 *  - Mozilla Public License Version 1.1 or later (the "MPL")
     18 *    http://www.mozilla.org/MPL/MPL-1.1.html
     19 *
     20 * == END LICENSE ==
     21 *
     22 * Link dialog window.
     23-->
     24<html>
     25<head>
     26        <title>Source Properties</title>
     27        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
     28        <meta name="robots" content="noindex, nofollow" />
     29        <script type="text/javascript">
     30
     31var oEditor             = window.parent.InnerDialogLoaded() ;
     32var FCK                 = oEditor.FCK ;
     33var FCKLang             = oEditor.FCKLang ;
     34var FCKConfig   = oEditor.FCKConfig ;
     35var FCKRegexLib = oEditor.FCKRegexLib ;
     36var FCKTools    = oEditor.FCKTools ;
     37
     38document.write( '<script src="' + FCKConfig.BasePath + 'dialog/common/fck_dialog_common.js" type="text/javascript"><\/script>' ) ;
     39
     40        </script>
     41        <script type="text/javascript">
     42
     43// Get the selected flash embed (if available).
     44var oFakeImage = FCK.Selection.GetSelectedElement() ;
     45var oSource ;
     46
     47if ( oFakeImage )
     48{
     49        if ( oFakeImage.tagName == 'IMG' && oFakeImage.getAttribute('_fck_mw_source') )
     50        {
     51                oSource = FCK.GetRealElement( oFakeImage ) ;
     52        }
     53        else
     54        {
     55                oFakeImage = null ;
     56        }
     57}
     58
     59window.onload = function()
     60{
     61        // Translate the dialog box texts.
     62        oEditor.FCKLanguageManager.TranslatePage(document) ;
     63
     64        // Load the selected link information (if any).
     65        LoadSelection() ;
     66
     67        // Activate the "OK" button.
     68        window.parent.SetOkButton( true ) ;
     69        window.parent.SetAutoSize( true ) ;
     70}
     71
     72function LoadSelection()
     73{
     74        if ( !oSource ) return ;
     75
     76        GetE('xSourceText').value = FCKTools.HTMLDecode( oSource.innerHTML ).replace(/fckLR/g,'\r\n').replace( /&quot;/g, '"' );
     77        GetE('xSourceLang').value = oSource.getAttribute( 'lang' ) ;
     78}
     79
     80//#### The OK button was hit.
     81function Ok()
     82{
     83        if ( !oSource )
     84        {
     85                oSource = FCK.EditorDocument.createElement( 'SPAN' ) ;
     86                oSource.className = 'fck_mw_source' ;
     87        }
     88       
     89        var sourceData = FCKTools.HTMLEncode(GetE('xSourceText').value.Trim().replace(/(\r\n|\n)/g, 'fckLR')).replace( /"/g, '&quot;' ) ;
     90        oSource.innerHTML = sourceData ;
     91        oSource.setAttribute( 'lang', GetE('xSourceLang').value.Trim() ) ;
     92
     93        if ( !oFakeImage )
     94        {
     95                oFakeImage      = oEditor.FCKDocumentProcessor_CreateFakeImage( 'FCK__MWSource', oSource ) ;
     96                oFakeImage.setAttribute( '_fck_mw_source', 'true', 0 ) ;
     97                oFakeImage      = FCK.InsertElement( oFakeImage ) ;
     98        }
     99
     100        return true ;
     101}
     102
     103        </script>
     104</head>
     105<body style="overflow: hidden">
     106        <div id="divInfo">
     107                <table cellpadding="0" cellspacing="0" border="0" width="100%" height="100%">
     108                        <tr>
     109                                <td>
     110                                        <span>Source Code</span>
     111                                </td>
     112                        </tr>
     113                        <tr>
     114                                <td height="100%">
     115                                        <textarea wrap=OFF id="xSourceText" style="width: 100%; height: 100%; font-family: Monospace"
     116                                                cols="50" rows="5"></textarea>
     117                                </td>
     118                        </tr>
     119                        <tr>
     120                                <td>
     121                                        Source Language<br />
     122                                        <input id="xSourceLang" type="text" size="15" />
     123                                </td>
     124                        </tr>
     125                </table>
     126        </div>
     127</body>
     128</html>
     129<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
     130<!--
     131 * FCKeditor - The text editor for Internet - http://www.fckeditor.net
     132 * Copyright (C) 2003-2007 Frederico Caldeira Knabben
     133 *
     134 * == BEGIN LICENSE ==
     135 *
     136 * Licensed under the terms of any of the following licenses at your
     137 * choice:
     138 *
     139 *  - GNU General Public License Version 2 or later (the "GPL")
     140 *    http://www.gnu.org/licenses/gpl.html
     141 *
     142 *  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
     143 *    http://www.gnu.org/licenses/lgpl.html
     144 *
     145 *  - Mozilla Public License Version 1.1 or later (the "MPL")
     146 *    http://www.mozilla.org/MPL/MPL-1.1.html
     147 *
     148 * == END LICENSE ==
     149 *
     150 * Link dialog window.
     151-->
     152<html>
     153<head>
     154        <title>Source Properties</title>
     155        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
     156        <meta name="robots" content="noindex, nofollow" />
     157        <script type="text/javascript">
     158
     159var oEditor             = window.parent.InnerDialogLoaded() ;
     160var FCK                 = oEditor.FCK ;
     161var FCKLang             = oEditor.FCKLang ;
     162var FCKConfig   = oEditor.FCKConfig ;
     163var FCKRegexLib = oEditor.FCKRegexLib ;
     164var FCKTools    = oEditor.FCKTools ;
     165
     166document.write( '<script src="' + FCKConfig.BasePath + 'dialog/common/fck_dialog_common.js" type="text/javascript"><\/script>' ) ;
     167
     168        </script>
     169        <script type="text/javascript">
     170
     171// Get the selected flash embed (if available).
     172var oFakeImage = FCK.Selection.GetSelectedElement() ;
     173var oSource ;
     174
     175if ( oFakeImage )
     176{
     177        if ( oFakeImage.tagName == 'IMG' && oFakeImage.getAttribute('_fck_mw_source') )
     178        {
     179                oSource = FCK.GetRealElement( oFakeImage ) ;
     180        }
     181        else
     182        {
     183                oFakeImage = null ;
     184        }
     185}
     186
     187window.onload = function()
     188{
     189        // Translate the dialog box texts.
     190        oEditor.FCKLanguageManager.TranslatePage(document) ;
     191
     192        // Load the selected link information (if any).
     193        LoadSelection() ;
     194
     195        // Activate the "OK" button.
     196        window.parent.SetOkButton( true ) ;
     197        window.parent.SetAutoSize( true ) ;
     198}
     199
     200function LoadSelection()
     201{
     202        if ( !oSource ) return ;
     203
     204        GetE('xSourceText').value = FCKTools.HTMLDecode( oSource.innerHTML ).replace(/fckLR/g,'\r\n').replace( /&quot;/g, '"' );
     205        GetE('xSourceLang').value = oSource.getAttribute( 'lang' ) ;
     206}
     207
     208//#### The OK button was hit.
     209function Ok()
     210{
     211        if ( !oSource )
     212        {
     213                oSource = FCK.EditorDocument.createElement( 'SPAN' ) ;
     214                oSource.className = 'fck_mw_source' ;
     215        }
     216       
     217        var sourceData = FCKTools.HTMLEncode(GetE('xSourceText').value.Trim().replace(/(\r\n|\n)/g, 'fckLR')).replace( /"/g, '&quot;' ) ;
     218        oSource.innerHTML = sourceData ;
     219        oSource.setAttribute( 'lang', GetE('xSourceLang').value.Trim() ) ;
     220
     221        if ( !oFakeImage )
     222        {
     223                oFakeImage      = oEditor.FCKDocumentProcessor_CreateFakeImage( 'FCK__MWSource', oSource ) ;
     224                oFakeImage.setAttribute( '_fck_mw_source', 'true', 0 ) ;
     225                oFakeImage      = FCK.InsertElement( oFakeImage ) ;
     226        }
     227
     228        return true ;
     229}
     230
     231        </script>
     232</head>
     233<body style="overflow: hidden">
     234        <div id="divInfo">
     235                <table cellpadding="0" cellspacing="0" border="0" width="100%" height="100%">
     236                        <tr>
     237                                <td>
     238                                        <span>Source Code</span>
     239                                </td>
     240                        </tr>
     241                        <tr>
     242                                <td height="100%">
     243                                        <textarea wrap=OFF id="xSourceText" style="width: 100%; height: 100%; font-family: Monospace"
     244                                                cols="50" rows="5"></textarea>
     245                                </td>
     246                        </tr>
     247                        <tr>
     248                                <td>
     249                                        Source Language<br />
     250                                        <input id="xSourceLang" type="text" size="15" />
     251                                </td>
     252                        </tr>
     253                </table>
     254        </div>
     255</body>
     256</html>
  • plugins/mediawiki/fckplugin.js

     
    4040tbButton.IconPath = FCKConfig.PluginsPath + 'mediawiki/images/tb_icon_ref.gif' ;
    4141FCKToolbarItems.RegisterItem( 'MW_Ref', tbButton ) ;
    4242
     43tbButton = new FCKToolbarButton( 'MW_Source', 'Source', 'Insert/Edit Source Code' ) ;
     44tbButton.IconPath = FCKConfig.PluginsPath + 'mediawiki/images/tb_icon_source.gif' ;
     45FCKToolbarItems.RegisterItem( 'MW_Source', tbButton ) ;
     46
    4347tbButton = new FCKToolbarButton( 'MW_Math', 'Formula', 'Insert/Edit Formula' ) ;
    4448tbButton.IconPath = FCKConfig.PluginsPath + 'mediawiki/images/tb_icon_math.gif' ;
    4549FCKToolbarItems.RegisterItem( 'MW_Math', tbButton ) ;
     
    5155// Override some dialogs.
    5256FCKCommands.RegisterCommand( 'MW_Template', new FCKDialogCommand( 'MW_Template', 'Template Properties', FCKConfig.PluginsPath + 'mediawiki/dialogs/template.html', 400, 330 ) ) ;
    5357FCKCommands.RegisterCommand( 'MW_Ref', new FCKDialogCommand( 'MW_Ref', 'Reference Properties', FCKConfig.PluginsPath + 'mediawiki/dialogs/ref.html', 400, 250 ) ) ;
     58FCKCommands.RegisterCommand( 'MW_Source', new FCKDialogCommand( 'MW_Source', 'Source Code Properties', FCKConfig.PluginsPath + 'mediawiki/dialogs/source.html', 400, 250 ) ) ;
    5459FCKCommands.RegisterCommand( 'MW_Math', new FCKDialogCommand( 'MW_Math', 'Formula', FCKConfig.PluginsPath + 'mediawiki/dialogs/math.html', 400, 300 ) ) ;
    5560FCKCommands.RegisterCommand( 'MW_Special', new FCKDialogCommand( 'MW_Special', 'Special Tag Properties', FCKConfig.PluginsPath + 'mediawiki/dialogs/special.html', 400, 330 ) ) ; //YC
    5661FCKCommands.RegisterCommand( 'Link', new FCKDialogCommand( 'Link', FCKLang.DlgLnkWindowTitle, FCKConfig.PluginsPath + 'mediawiki/dialogs/link.html', 400, 250 ) ) ;
     
    504509                                                case 'span' :
    505510                                                        switch ( htmlNode.className )
    506511                                                        {
     512                                                                case 'fck_mw_source' :
     513                                                                        var refLang = htmlNode.getAttribute( 'lang' ) ;
     514
     515                                                                        stringBuilder.push( '<source' ) ;
     516                                                                        stringBuilder.push( ' lang="' + refLang + '"' ) ;
     517                                                                        stringBuilder.push( '>' ) ;
     518                                                                        stringBuilder.push( FCKTools.HTMLDecode(htmlNode.innerHTML).replace(/fckLR/g,'\r\n') ) ;
     519                                                                        stringBuilder.push( '</source>' ) ;
     520                                                                        return ;
    507521                                                                case 'fck_mw_ref' :
    508522                                                                        var refName = htmlNode.getAttribute( 'name' ) ;
    509523
     
    821835                var className = null ;
    822836                switch ( eSpan.className )
    823837                {
     838                        case 'fck_mw_source' :
     839                                className = 'FCK__MWSource' ;
    824840                        case 'fck_mw_ref' :
    825                                 className = 'FCK__MWRef' ;
     841                                if (className == null)
     842                                        className = 'FCK__MWRef' ;
    826843                        case 'fck_mw_references' :
    827844                                if ( className == null )
    828845                                        className = 'FCK__MWReferences' ;
     
    898915                                contextMenu.AddSeparator() ;
    899916                                contextMenu.AddItem( 'MW_Ref', 'Reference Properties' ) ;
    900917                        }
     918                        if ( tag.getAttribute( '_fck_mw_source' ) )
     919                        {
     920                                contextMenu.AddSeparator() ;
     921                                contextMenu.AddItem( 'MW_Source', 'Source Code Properties' ) ;
     922                        }
    901923                        if ( tag.getAttribute( '_fck_mw_math' ) )
    902924                        {
    903925                                contextMenu.AddSeparator() ;
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy