Hi,
Do you like to add WYSIWYG editors to garage module ?
![](https://xoops.org/uploads/smil3dbd4d6422f04.gif)
You need to modifiy 4 files:
1. Edit xoops_version.php and add before ?> :
// Use WYSIWYG Editors?
$modversion['config'][19]['name'] = 'form_options';
$modversion['config'][19]['title'] = '_MI_EDITOR';
$modversion['config'][19]['description'] = '_MI_LIST_EDITORS';
$modversion['config'][19]['formtype'] = 'select';
$modversion['config'][19]['valuetype'] = 'text';
$modversion['config'][19]['default'] = 'dhtml';
$modversion['config'][19]['options'] = array( 'DHTML editor' => 'dhtml',
'Spaw editor' => 'spaw',
'HtmlArea Editor' => 'htmlarea',
'Koivi editor' => 'koivi',
'FCK Editor' => 'fckeditor',
'Inbetween' => 'inbetween',
'TinyEditor' => 'tiny');
2. Edit modules/garage/include/functions.php and add before ?> :
function getEditor($caption, $name, $value = "", $width = '100%', $height ='400px', $supplemental='', $dhtml = true){
global $xoopsModuleConfig;
$editor = false;
$x22=false;
$xv=str_replace('XOOPS ','',XOOPS_VERSION);
if(substr($xv,2,1)=='2') {
$x22=true;
}
$editor_configs=array();
$editor_configs["name"] =$name;
$editor_configs["value"] = $value;
$editor_configs["rows"] = 35;
$editor_configs["cols"] = 60;
$editor_configs["width"] = "100%";
$editor_configs["height"] = "400px";
switch(strtolower($xoopsModuleConfig['form_options'])){
case 'tiny' :
if (!$xoops22) {
if ( is_readable(XOOPS_ROOT_PATH . "/class/xoopseditor/tinyeditor/formtinyeditortextarea.php")) {
include_once(XOOPS_ROOT_PATH . "/class/xoopseditor/tinyeditor/formtinyeditortextarea.php");
$editor = new XoopsFormTinyeditorTextArea(array('caption'=>$caption, 'name'=>$name, 'value'=>$value, 'width'=>'100%', 'height'=>'400px'));
} else {
if ($dhtml) {
$editor = new XoopsFormDhtmlTextArea($caption, $name, $value, 20, 60);
} else {
$editor = new XoopsFormTextArea($caption, $name, $value, 7, 60);
}
}
} else {
$editor = new XoopsFormEditor($caption, "tinyeditor", $editor_configs);
}
break;
case 'inbetween' :
if (!$xoops22) {
if ( is_readable(XOOPS_ROOT_PATH . "/class/xoopseditor/inbetween/forminbetweentextarea.php")) {
include_once(XOOPS_ROOT_PATH . "/class/xoopseditor/inbetween/forminbetweentextarea.php");
$editor = new XoopsFormInbetweenTextArea(array('caption'=> $caption, 'name'=>$name, 'value'=>$value, 'width'=>'100%', 'height'=>'300px'),true);
} else {
if ($dhtml) {
$editor = new XoopsFormDhtmlTextArea($caption, $name, $value, 20, 60);
} else {
$editor = new XoopsFormTextArea($caption, $name, $value, 7, 60);
}
}
} else {
$editor = new XoopsFormEditor($caption, "inbetween", $editor_configs);
}
break;
case 'fckeditor' :
if (!$xoops22) {
if ( is_readable(XOOPS_ROOT_PATH . "/class/xoopseditor/FCKeditor/formfckeditor.php")) {
include_once(XOOPS_ROOT_PATH . "/class/xoopseditor/FCKeditor/formfckeditor.php");
$editor = new XoopsFormFckeditor($editor_configs,true);
} else {
if ($dhtml) {
$editor = new XoopsFormDhtmlTextArea($caption, $name, $value, 20, 60);
} else {
$editor = new XoopsFormTextArea($caption, $name, $value, 7, 60);
}
}
} else {
$editor = new XoopsFormEditor($caption, "fckeditor", $editor_configs);
}
break;
case 'koivi' :
if (!$xoops22) {
if ( is_readable(XOOPS_ROOT_PATH . "/class/wysiwyg/formwysiwygtextarea.php")) {
include_once(XOOPS_ROOT_PATH . "/class/wysiwyg/formwysiwygtextarea.php");
$editor = new XoopsFormWysiwygTextArea($caption, $name, $value, '100%', '400px');
} else {
if ($dhtml) {
$editor = new XoopsFormDhtmlTextArea($caption, $name, $value, 20, 60);
} else {
$editor = new XoopsFormTextArea($caption, $name, $value, 7, 60);
}
}
} else {
$editor = new XoopsFormEditor($caption, "koivi", $editor_configs);
}
break;
case "spaw":
if(!$xoops22) {
if (is_readable(XOOPS_ROOT_PATH . "/class/spaw/formspaw.php")) {
include_once(XOOPS_ROOT_PATH . "/class/spaw/formspaw.php");
$editor = new XoopsFormSpaw($caption, $name, $value);
} else {
if ($dhtml) {
$editor = new XoopsFormDhtmlTextArea($caption, $name, $value, 20, 60);
} else {
$editor = new XoopsFormTextArea($caption, $name, $value, 7, 60);
}
}
} else {
$editor = new XoopsFormEditor($caption, "spaw", $editor_configs);
}
break;
case "htmlarea":
if(!$xoops22) {
if ( is_readable(XOOPS_ROOT_PATH . "/class/htmlarea/formhtmlarea.php")) {
include_once(XOOPS_ROOT_PATH . "/class/htmlarea/formhtmlarea.php");
$editor = new XoopsFormHtmlarea($caption, $name, $value);
} else {
if ($dhtml) {
$editor = new XoopsFormDhtmlTextArea($caption, $name, $value, 20, 60);
} else {
$editor = new XoopsFormTextArea($caption, $name, $value, 7, 60);
}
}
} else {
$editor = new XoopsFormEditor($caption, "htmlarea", $editor_configs);
}
break;
default :
if ($dhtml) {
$editor = new XoopsFormDhtmlTextArea($caption, $name, $value, 20, 60);
} else {
$editor = new XoopsFormTextArea($caption, $name, $value, 7, 60);
}
break;
}
return $editor;
}
3. Edit modules/garage/garage.php and replace any
new XoopsFormDhtmlTextArea with
getEditor .
4. Add the following lines to language/english/modinfo.php:
define("_MI_EDITOR","Editor to use:");
define("_MI_LIST_EDITORS","Select the editor to use.");
5. Update garage module.