Forum closed. New forum available at http://community.wymeditor.org/

Enable/disable editor by session or user

Support forum for WYMeditor.

Enable/disable editor by session or user

Postby NickMDal on Tue Jul 07, 2009 11:04 pm

Hi. We are running WYM in our wikimedia installation. Is it possible to enable and disable the editor by user by session (reverting to regular wikicode)?

I am not a developer but need to find out if we need to have this coded or if there is a ready-made way to do this. Thanks for help.
NickMDal
 
Posts: 3
Joined: Tue Jul 07, 2009 10:49 pm

Re: Enable/disable editor by session or user

Postby matthoughton on Wed Jul 08, 2009 5:56 pm

Could you check the session prior to running the javascript?

I do this in PHP by having a function to display the javascript:
Code: Select all
function wymEditor() {
      ?>
         <script type="text/javascript" src="jquery/jquery.js"></script>
         <script type="text/javascript" src="wymeditor/jquery.wymeditor.js"></script>

         <script type="text/javascript">

   jQuery(function() {

    jQuery('.wymeditor').wymeditor({
        skin: 'twopanels',
      //we customize the XHTML structure of WYMeditor by overwriting
      //the value of boxHtml. In this example, "CONTAINERS" and
      //"CLASSES" have been moved from "wym_area_right" to "wym_area_top":
      boxHtml:   "<div class='wym_box'>"
              + "<div class='wym_area_top'>"
              + WYMeditor.TOOLS
              + WYMeditor.CONTAINERS
              + "</div>"
              + "<div class='wym_area_left'></div>"
              + "<div class='wym_area_main''>"
              + WYMeditor.HTML
              + WYMeditor.IFRAME
              + WYMeditor.STATUS
              + "</div>"
              + "<div class='wym_area_bottom'>"
              + "</div>"
              + "</div>",
      //postInit is a function called when WYMeditor instance is ready
      //wym is the WYMeditor instance
      postInit: function(wym) {
            jQuery(wym._box).find(wym._options.iframeSelector)
                .css('height', '250px')
               


        }
    });
});

</script>
   <?php    
   }


Then depending on the session vars, you could choose not to run this function, leaving the user input as a text box.

e.g.

Code: Select all
if($_SESSION['user_wym']=='1') wymEditor();
matthoughton
 
Posts: 24
Joined: Thu Feb 12, 2009 10:28 pm

Re: Enable/disable editor by session or user

Postby NickMDal on Wed Jul 08, 2009 11:49 pm

Thanks. This is very helpful.

I hate to ask such a basic question, but if the javascript function is bypassed, will the standard mediawiki editor then be automatically displayed? I guess this is not a mediawiki forum but I am just hoping to pass on what I can as a feature request for our site.
NickMDal
 
Posts: 3
Joined: Tue Jul 07, 2009 10:49 pm

Re: Enable/disable editor by session or user

Postby matthoughton on Thu Jul 09, 2009 4:05 pm

Sorry I don't know how mediawiki works. If you could show code for the mediawiki implementation I may be able to advise you further. Alternatively, I don't know if anyone else on the forum knows it?
matthoughton
 
Posts: 24
Joined: Thu Feb 12, 2009 10:28 pm

Re: Enable/disable editor by session or user

Postby mr_lundis on Thu Jul 09, 2009 8:03 pm

I think (if someone) Jacopo is the man to ask. He's the author of the WYMeditor plug-in for MediaWiki.
Jonatan Lundin - designer, developer and forum moderator. You should follow me on Twitter!
mr_lundis
 
Posts: 335
Joined: Sun Dec 02, 2007 10:59 am
Location: Sweden

Re: Enable/disable editor by session or user

Postby NickMDal on Thu Jul 09, 2009 9:07 pm

Thanks. This is very helpful.
NickMDal
 
Posts: 3
Joined: Tue Jul 07, 2009 10:49 pm

Re: Enable/disable editor by session or user

Postby Jacopo on Wed Jun 30, 2010 8:30 am

Hi NickMDal, sorry for this over-long delay, I haven't been checking the forum for a while. It might be irrelevant by now, but I thought answering couldn't hurt.

There is a preference for disabling the visual editor, it's called "wpWantTraditionalEditor" and should show up in the user preference page. It could also be done via Javascript by setting the traditional editing checkbox before the script kicks in, but the preference is probably a cleaner approach.

As for support, I maintain the extension and intend to keep it up to date (I use it on an internal wiki), but I don't have much time to add new features.
Jacopo
 
Posts: 5
Joined: Fri Aug 29, 2008 5:22 pm
Location: Pisa & Milan


Return to Support

Who is online

Users browsing this forum: No registered users and 2 guests