Forum OpenACS Development: Re: ad_form widget for textareas

Collapse
Posted by David Cotter on
To prove the concept I put one of the above controls into edit-this-page in about 20 minutes.

The one I picked, htmlArea, uses a BSD licence and is for IE5.5 only but has an alpha version for Mozilla 1.3 which I didn't look at. I'm sure all the others including Malte's suggestion are similar.

To put this into ETP I did the following:

  • Get the htmlArea zip file and unzip into /web/yourserver/www/htmlarea
  • In etp-master.tcl add the following
    
    set header_stuff "<script language=\"Javascript1.2\"><!-- // load htmlarea
    _editor_url = \"/htmlarea/\";                     // URL to htmlarea files
    var win_ie_ver = parseFloat(navigator.appVersion.split(\"MSIE\")\[1\]);
    if (navigator.userAgent.indexOf('Mac')        >= 0) { win_ie_ver = 0; }
    if (navigator.userAgent.indexOf('Windows CE') >= 0) { win_ie_ver = 0; }
    if (navigator.userAgent.indexOf('Opera')      >= 0) { win_ie_ver = 0; }
    if (win_ie_ver >= 5.5) {
     document.write('<scr' + 'ipt src=\"' +_editor_url+ 'editor.js\"');
     document.write(' language=\"Javascript1.2\"></scr' + 'ipt>');
    } else { document.write('<scr'+'ipt>function editor_generate() { return false; }</scr'+'ipt>'); }
    // --></script>
    "
    
  • In etp-master.adp add the following line (I added it just after <master>)
    
    <property name="header_stuff">@header_stuff@</property>
    
  • In etp-edit.tcl change the line:
    
        set widget "<textarea name=\"$attribute\" $html>[ad_quotehtml $value]</textarea>\n"
    
    to look like this:
    
        set widget "<textarea name=\"$attribute\" $html>[ad_quotehtml $value]</textarea>\n
        <script language=\"JavaScript1.2\" defer>
          editor_generate('$attribute');
          </script>"
    

    I'm not 100% about some of the templating stuff so it may not be the best way to modify pages

    That's it. To see it working with IE5.5 or greater go to: http://lin.alatto.com:8086/news-test and login as test@test.com with a password of test

    I think some of the other controls are better and some worse (e.g. in how they handle tables or images) but I think they're all pretty easy to integrate so it's a case of deciding on what one is the best.

  • Collapse
    Posted by Yves Goldberg on
    I can't locate the following in etp-edit.tcl:

    set widget "<textarea name=\"$attribute\" $html>[ad_quotehtml $value]</textarea>\n"

    anyone could update the modification to etp-edit.tcl in order to call htmlArea?

    TIA