1
steinj14
How to change or hack default xoops editor?
  • 2006/3/11 3:35

  • steinj14

  • Just popping in

  • Posts: 5

  • Since: 2005/2/10


I want to change from the DHTML editor (at least for everyone but admin) so I don't have all the buttons showing (e.g., url, email, image, image manager, etc.). I noticed on this form you have an option DHTML or Compact for the form type. Is there a setting somewhere in the configuration that will make the default Compact instead of DHTML? If it's not a setting, what template or php script do I need to hack? I know this shouldn't be hard, but I've been digging in the forums and faqs and code for two days without luck. Thanks in advance!

2
sceilig
Re: How to change or hack default xoops editor?
  • 2006/3/14 11:01

  • sceilig

  • Just popping in

  • Posts: 53

  • Since: 2006/3/1 1


steinj14,
Im in the same boat as you, and I think there are a lot of others squeezed into this "how to change the default editor" boat. I too have searched long and hard through the forums for a good solution but it appears to be vague.

I do acknowledge that not all modules are compliant with the wysiwyg editors so changing the default editor might cause problems with some modules? What I dont understand is why this editor was chosen as "default" in the first place - Ive used a plethora of wysiwyg textarea editors with no trouble but this default editor aint one bit user friendly. If spaw, fckeditor or tinymce were chosen as the default one then I think there would be a lot less frustration for many XOOPS users.

Some modules allow you to change the editor in the module preferences but other modules like Extended Profiles do not. I have been tinkering with the code for that module but as yet havent been able to switch the editor.

I feel the code may be similar to the one described in this XOOPS hack
https://xoops.org/modules/news/article.php?storyid=2597
Quote:

==== HACK ====================================
In /modules/system/blocks/system_blocks.php
around line 56, you will find the following line:

$form->addElement(new XoopsFormDhtmlTextArea(_MB_SYSTEM_CONTENT, 'options[0]', htmlspecialchars($ts->stripSlashesGPC($options[0]), ENT_QUOTES), 15, 60));


Change it to:

$theEditor = new XoopsFormWysiwygTextArea(array());
$theEditor->setName('options[0]');
$form->addElement($theEditor);

================================================



If would be wonderful if one of you XOOPS experts could help us and many others with a detailed way of going about changing the default editor in a module or systemwide.

thanks!

3
jonniUK
Re: How to change or hack default xoops editor?
  • 2006/3/14 21:46

  • jonniUK

  • Just popping in

  • Posts: 8

  • Since: 2005/1/31


I am using XOOPS 2.2.4
I have made all suggested changes but do not see any effect.
What do i need to do to use any Wysiwyg Editor in XOOPS?
Is there any setting i need to changes?

4
steinj14
Re: How to change or hack default xoops editor?
  • 2006/3/15 21:13

  • steinj14

  • Just popping in

  • Posts: 5

  • Since: 2005/2/10


Following up from my original post - I think I finally found the files to hack. The hack I implemented keeps all the XOOPS editor buttons visible if you are logged in as "admin". Otherwise it strips out all the buttons and just displays the textarea box.

The file
{XOOPSBASE}/class/xoopsform/formdhtmltextarea.php
affects the News item submission form in the News module, and the Post Comment and Reply forms in the xcGallery module.
The file
{XOOPSBASE}/include/xoopscodes.php
affects the Upload Picture form in the xcGallery module and the Post form in the Forum module.

It seems very strange to me that the modules (core and add-on) are not consistent with how they implement the XOOPS default editor. I would think I should have only had to hack one file, and that would be used by all modules.

Here's the hack for function "xoopsCodeTarea" in xoopscodes.php
----------------------------------------------------
function xoopsCodeTarea($textarea_id$cols=60$rows=15$suffix=null)
{
    
$hiddentext = isset($suffix) ? 'xoopsHiddenText'.trim($suffix) : 'xoopsHiddenText';
    
//Hack for url, email ...., the anchor is for having a link on [_More...]
        
    //HACK: UNLESS USER IS ADMIN, COMMENT OUT THE SPECIAL XOOPSCODE DHTML BUTTONS BECAUSE MAKES PAGE TOO 
    //   CLUTTERED AND TOO COMPLICATED FOR USERS WHEN ADDING COMMENTS, FORUMS, PICTURES, ETC. (3/13/06 JMS).
    
    //GET THE USER ID OF THE LOGGED IN USER - ADDED THIS SECTION 3/13/06 JMS.
    
global $xoopsUser;
    if (
$xoopsUser) {
      
//User is logged in, display welcome message
      
$uname $xoopsUser->getVar('uname');
      
//$upw = $xoopsUser->getVar('pass');
      
$uid $xoopsUser->getVar('uid');
    }
    
    
// ADMIN USER ID IS 1.  ADDED THIS USER CHECK IF/ELSE CODE 3/13/06 JMS.
    
if ($uid == 1) {
             ...
the rest of the function code goes here...

    
// IF USER IS NOT ADMIN, JUST SHOW TEXT AREA.
    
} else {    
        echo 
"n";
        
//Hack smilies move for bold, italic ...
        
$areacontent = isset( $GLOBALS[$textarea_id] ) ? $GLOBALS[$textarea_id] : '';
            
        echo 
".$textarea_id."' name='".$textarea_id."' cols='$cols' rows='$rows'>".$areacontent."n";
        
//Fin du hack    
    
}    

}



Use the same structure for the "render" function in formdhtmltextarea.php - the else code is listed below:
----------------------------------------------------
// IF USER IS NOT ADMIN, JUST SHOW TEXT AREA.    
        
} else {
            
$ret ".$this->getName()."' name='".$this->getName()."' onselect="xoopsSavePosition('".$this->getName()."');" onclick="xoopsSavePosition('".$this->getName()."');" onkeyup="xoopsSavePosition('".$this->getName()."');" cols='".$this->getCols()."' rows='".$this->getRows()."'".$this->getExtra().">".$this->getValue()."n";
            
$ret .= $this->_renderSmileys();
            return 
$ret;        
        }

Login

Who's Online

300 user(s) are online (222 user(s) are browsing Support Forums)


Members: 0


Guests: 300


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits