Announcement

Do not use the forums to submit bug reports, feature requests or patches, submit a New Ticket instead.

#1 2005-05-05 22:59:34

g2010a
New member
Registered: 2005-03-28
Posts: 9

Linker: URL's with ampersand get messed

Hi, I modified the Linker plugin to access links from a database. 
The links are in the format: http://www.whatever.com/some.php?blah=meh&moo=ma
Upon hitting OK the appropriate link is created, but in the href all the '&' are turned into '&', as is appropriate for text... the only problem is that since they are in a link, the link breaks.
Is there a way to avoid the transformation without modifyin the function htmlEncode in htmlarea.js?
Thanks...

Offline

#2 2005-05-06 03:09:03

Foxx
Xinha Community Member
Registered: 2005-02-20
Posts: 41

Re: Linker: URL's with ampersand get messed

if you have your doctype set to XTHML (either strict or transitional), then & in URL's will be parsed correctly, your document won't even verify as valid XHTML without it...

Offline

#3 2005-05-06 05:01:50

goober
New member
Registered: 2005-05-06
Posts: 2

Re: Linker: URL's with ampersand get messed

How can I disable or remove individual controls (color buttons, font selector) from the tool bar?

Thanks

Offline

#4 2005-05-06 15:59:40

g2010a
New member
Registered: 2005-03-28
Posts: 9

Re: Linker: URL's with ampersand get messed

Foxx: Thanks, I'll try that.
Goober: To disable or remove individual controls you have to define which buttons you actually want, as part of javascript. So, for example,I include a file called "myInclude.js" in the HTML that contains Xinha, which consists of the following code:


// This file needs to be invoked from the HTML file initializing HTMLArea
//   

    xinha_editors = null;
    xinha_init    = null;
    xinha_config  = null;
    xinha_plugins = null;
    
    // This contains the names of textareas we will make into Xinha editors
    xinha_init = xinha_init ? xinha_init : function() {
        /** STEP 1 ***************************************************************
        * First, what are the plugins you will be using in the editors on this
        * page.  List all the plugins you will need, even if not all the editors
        * will use all the plugins.
        ************************************************************************/
        
        xinha_plugins = xinha_plugins ? xinha_plugins :
        [
        'FullScreen',
        'ListType',
        'ImageManager',
        'Linker'
        ]
        /*[
        'CharacterMap',
        'ContextMenu',
        'FullScreen',
        'ListType',
        'SpellChecker',
        'Stylist',
        'SuperClean',
        'TableOperations'
        ];*/
             // THIS BIT OF JAVASCRIPT LOADS THE PLUGINS, NO TOUCHING  :)
             if(!HTMLArea.loadPlugins(xinha_plugins, xinha_init)) return;
        
        /** STEP 2 ***************************************************************
        * Now, what are the names of the textareas you will be turning into
        * editors?
        ************************************************************************/
        
        xinha_editors = xinha_editors ? xinha_editors :
        [
        'myTextArea'
        ];
        
        /** STEP 3 ***************************************************************
        * We create a default configuration to be used by all the editors.
        * If you wish to configure some of the editors differently this will be
        * done in step 4.
        *
        * If you want to modify the default config you might do something like this.
        *
        *   xinha_config = new HTMLArea.Config();
        *   xinha_config.width  = 640;
        *   xinha_config.height = 350;
        *
        *************************************************************************/
        
        //xinha_config = xinha_config ? xinha_config : new HTMLArea.Config();
        xinha_config = new HTMLArea.Config();
        xinha_config.width = 620;
        xinha_config.height = 300;






        // *****************************************************************
        // *****************************************************************        
        // ***** THIS IS WHAT DEFINES WHICH BUTTONS YOU SHOW ***************
        // *****************************************************************
        // *****************************************************************
        xinha_config.toolbar =
        [    
            [ "popupeditor","separator","formatblock", "space",
              "bold", "italic", "underline", "strikethrough", "separator",
              "subscript", "superscript", "separator",
              "copy", "cut", "paste", "space", "undo", "redo", "separator",
              "popupeditor", "separator", "showhelp", "about" 
            ],
    
            [ "linebreak",
              "killword", "removeformat", "separator",
              "justifyleft", "justifycenter","justifyright", "separator",
              "insertorderedlist", "insertunorderedlist", "outdent", "indent", "separator",
              "inserthorizontalrule", "createlink", "insertimage", "inserttable", "separator",
              "htmlmode"
            ]
        ]
        /*Possible options
        [
               ["popupeditor","separator"],
               ["formatblock","fontname","fontsize","bold","italic","underline","strikethrough","separator"],
               ["forecolor","hilitecolor","textindicator","separator"],
               ["subscript","superscript"],
               ["linebreak","justifyleft","justifycenter","justifyright","justifyfull","separator"],
               ["insertorderedlist","insertunorderedlist","outdent","indent","separator"],
               ["inserthorizontalrule","createlink","insertimage","inserttable","separator"],
               ["killword","removeformat","toggleborders","lefttoright", "righttoleft", "separator","htmlmode"]
        ];
        */
        






        //styles taken from pfp <<- this is for my own benefit, you can get rid of it.
        xinha_config.pageStyle = 
            'table { font-size: 1em; } ' +
            'pfContentTable {  border-top: 1px solid black;  border-bottom: 1px solid black; } ' +
            'th { font-style:none; font-style: italic; text-align: left; } ' +
            'h1 { text-decoration:none; font-size: 1.3em; font-weight:700; text-align:center; } ' +
            'h2 { text-decoration:none; font-size: 1em; font-weight:700; text-align:center; } ' +
            'h3 { text-decoration:none; font-size: 1em; font-weight:700; } ' +
            'h4 { text-decoration:none; font-size: 1em; font-style:italic; } ' +
            'h5, h6, h7, h8, h9 { text-decoration:none;font-size: 1em;font-style:italic;  display:inline; }'
        ;
        
        xinha_config.formatblock = {
            "Heading 1": "h1",
            "Heading 2": "h2",
            "Heading 3": "h3",
            "Heading 4": "h4",
            "Heading 5": "h5",
            "Heading 6": "h6",
            "Normal": "p",
            "Formatted": "pre"
        };
        
        /*
        xinha_config.formatblock = {
              "&mdash; Überschrift &mdash;"  : '',
              "Absatz gross/h1": 'h1',
              "Absatz mittel/h2": 'h2',
              "Absatz grau/h3": 'h3',
              "Normal"   : 'p'
        };


         xinha_config.fontsize = {
             "&mdash; Grösse &mdash;"  : '',
             "1 (8 pt)" : '1',
             "2 (10 pt)": '2',
             "3 (12 pt)": '3',
             "4 (14 pt)": '4'
         };


         xinha_config.fontname = {
            "&mdash; Schriftart &mdash;"  : '',
            "Arial/ Helvetica" :           'arial,helvetica,sans-serif',
            "Courier New"      :           'courier new,courier,monospace',
            "Verdana"          :           'verdana,arial,helvetica,sans-serif'
         };*/

        
        /** STEP 3 ***************************************************************
        * We first create editors for the textareas.
        *
        * You can do this in two ways, either
        *
        *   xinha_editors   = HTMLArea.makeEditors(xinha_editors, xinha_config, xinha_plugins);
        *
        * if you want all the editor objects to use the same set of plugins, OR;
        *
        *   xinha_editors = HTMLArea.makeEditors(xinha_editors, xinha_config);
        *   xinha_editors['myTextArea'].registerPlugins(['Stylist','FullScreen']);
        *   xinha_editors['anotherOne'].registerPlugins(['CSS','SuperClean']);
        *
        * if you want to use a different set of plugins for one or more of the
        * editors.
        ************************************************************************/
        
        xinha_editors   = HTMLArea.makeEditors(xinha_editors, xinha_config, xinha_plugins);
        
        /** STEP 4 ***************************************************************
        * If you want to change the configuration variables of any of the
        * editors,  this is the place to do that, for example you might want to
        * change the width and height of one of the editors, like this...
        *
        *   xinha_editors.myTextArea.config.width  = 640;
        *   xinha_editors.myTextArea.config.height = 480;
        *
        ************************************************************************/
        
        
        /** STEP 5 ***************************************************************
        * Finally we "start" the editors, this turns the textareas into
        * Xinha editors.
        ************************************************************************/
        
        HTMLArea.startEditors(xinha_editors);
    }
    window.onload = xinha_init;
//EOF

Last edited by g2010a (2005-05-06 16:01:33)

Offline

#5 2005-05-09 10:00:33

niko
Xinha Authority
From: Salzburg/Austria
Registered: 2005-02-14
Posts: 338

Re: Linker: URL's with ampersand get messed

...having just & in an url is even invalid, it must be &

(don't know for which doctype this is true)


Niko

Offline

#6 2005-05-09 18:11:53

kimss
Xinha Pro
From: Sweden
Registered: 2005-04-05
Posts: 99
Website

Re: Linker: URL's with ampersand get messed

Almost true, this is correct :

<a href="sompage.php?a=b&c=d">Link</a>

However this is very wrong :

<script>
document.write('location: sompage.php?a=b&c=d');
</script>

Passing urls with javascript needs it to be a & not a &, probably since the URL is passed directly as is with javascript while the HTML is translated by the browser or something. However, javascript works pretty bad in this editor anyways so my problem shouldt appear, big_smile

Offline

Board footer

Powered by FluxBB