I've been trying to do the same thing with the xt-content module, following the doc instructions and getting a blank form (not a blank page) when the editor is included.
Win2K SP4
Apache 1.3.29
MySQL 4.0.18
PHP 4.3.4
Sorry for the length of this post, but it's the result of some serious debugging. I started putting in echo statements in the code because even with PHP debugging turned on there are no debugging traces, and isolated it to the location in formwysiwygtextarea.php in the render() function where it includes functions.inc.php. I got it to render the editor form by accident and after much experimentation I do not understand what is going on here.
Here's my conversion of xt-content from SPAW to KOIVI -
1) in admin_header.php, after
include_once XOOPS_ROOT_PATH.'/class/xoopsformloader.php';
I added
// -------------------------------------------------------------------------
// KOIVI WYSIWYG Class
include_once XOOPS_ROOT_PATH.'/class/wysiwyg/formwysiwygtextarea.php';
// -------------------------------------------------------------------------
2) in index.php
for the "submit" case I have
if ($xoopsModuleConfig['xt_wysiwyg'] == '1') {
echo '
case[submit] :: xoopsModuleConfig>>xt_wysiwyg [1]';
/*
// SPAW Config
$spaw_root = XOOPS_ROOT_PATH.'/modules/xt_conteudo/admin/spaw/';
include $spaw_root.'spaw_control.class.php';
if (checkBrowser()) {
ob_start();
$sw = new SPAW_Wysiwyg('message',$message);
$sw->show();
$form->addElement(new XoopsFormLabel(_TC2_CONTENT, ob_get_contents()));
ob_end_clean();
} else {
$t_area = new XoopsFormDhtmlTextArea(_TC2_CONTENT, 'message', '', 37, 35);
$form->addElement($t_area);
}
*/
// ------------------------------------------------------------------------
// Replace with KOIVI Editor
$t_area = new XoopsFormWysiwygTextArea( _TC2_CONTENT, 'message', '' , '100%', '400px', '');
$t_area->setUrl("/class/wysiwyg");
$form->addElement( $t_area );
// ------------------------------------------------------------------------
} else {
$t_area = new XoopsFormDhtmlTextArea(_TC2_CONTENT, 'message', '', 37, 35);
$form->addElement($t_area);
}
and for the "edit" case I have
if ($xoopsModuleConfig['xt_wysiwyg'] == '1') {
echo '
case[edit] :: xoopsModuleConfig>>xt_wysiwyg [1]';
/*
// SPAW Config
$spaw_root = XOOPS_ROOT_PATH.'/modules/xt_conteudo/admin/spaw/';
include $spaw_root.'spaw_control.class.php';
if (checkBrowser()) {
ob_start();
$sw = new SPAW_Wysiwyg('message',$message);
$sw->show();
$form->addElement(new XoopsFormLabel(_TC2_CONTENT, ob_get_contents()));
ob_end_clean();
} else {
$t_area = new XoopsFormDhtmlTextArea(_TC2_CONTENT, 'message', $message, 37, 35);
$form->addElement($t_area);
}
*/
// ------------------------------------------------------------------------
// Replace with KOIVI Editor
$t_area = new XoopsFormWysiwygTextArea( _TC2_CONTENT, 'message', $message , '100%', '400px', '');
$t_area->setUrl("/class/wysiwyg");
$form->addElement( $t_area );
// ------------------------------------------------------------------------
} else {
$t_area = new XoopsFormDhtmlTextArea(_TC2_CONTENT, 'message', $message, 37, 35);
$form->addElement($t_area);
}
My debugging version of KOIVI WYSIWYG code contains the following -
In formwysiwygtextarea.php, the beginning of the render() function looks like this:
function render()
{
echo '
XoopsFormWysiwygTextArea>>render()';
//include files
include_once 'include/functions.inc.php';
include_once getLanguage($this->getUrl());
global $koivi_editor_instances;
echo '
koivi_instances:='.$koivi_editor_instances;
$width=$this->getWidth();
$height=$this->getHeight();
In functions.inc.php, the three functions begin like this:
// URL: http://www.myweb.ne.jp/, https://xoops.org/, http://www.xoopscube.jp/ //
// Project: The XOOPS Project //
// ------------------------------------------------------------------------- //
echo '
trace :: 1';
function getMainfile($url)
{
echo "
getMainfile() :: $url";
$mpath='';
for ($i=0;$i<strlen($url);$i++)
{
if ($url[$i]=='/')$mpath.='../';
}
return $mpath.'mainfile.php';
}
echo '
trace :: 2';
function getLanguage($url)
{
echo "
getLanguage() :: $url";
global $xoopsConfig;
if(file_exists(XOOPS_ROOT_PATH.''.$url.'/language/'.$xoopsConfig['language'].'/lang.php'))
return ''.XOOPS_ROOT_PATH.''.$url.'/language/'.$xoopsConfig['language'].'/lang.php';
else return ''.XOOPS_ROOT_PATH.''.$url.'/language/english/lang.php';
}
echo '
trace :: 3';
echo '
$_SERVER['HTTP_USER_AGENT']';
function CheckBrowser($get_isie=true)
{
echo "
CheckBrowser() :: $get_isie";
global $_SERVER;
$comp=false;
$isie=false;
Note particularly the echo traces both inside and between the functions.
Now for the confusing part...
When I change the echo for the User Agent to use double-quotes
echo "
$_SERVER[\'HTTP_USER_AGENT\']";
(with or without the escape on the single-quotes) it changes the behavior of the system.
Using a single-quoted string, the output is
--------
case[submit] :: xoopsModuleConfig>>xt_wysiwyg [1]
XoopsFormWysiwygTextArea>>render()
trace :: 1
trace :: 2
trace :: 3
$_SERVER['HTTP_USER_AGENT']
--------
Tracing occurs in the include file, but the editor form does not render.
Using the double-quoted string, the output is
--------
case[submit] :: xoopsModuleConfig>>xt_wysiwyg [1]
XoopsFormWysiwygTextArea>>render()
getLanguage() :: /class/wysiwyg
koivi_instances:=1
--------
No tracing in the include file, but the editor form renders and is functional.
What seems to force the rendering of the editor almost looks like a PHP bug, or perhaps it's actually in the render() function itself, because these statements work
echo '
'.$_SERVER[\'HTTP_USER_AGENT\'];
echo "
$_SERVER[\'HTTP_USER_AGENT\']";
echo "
$_SERVER['HTTP_USER_AGENT']";
but these do not
echo '
'.$_SERVER['HTTP_USER_AGENT'];
echo '
'.$_SERVER;
So, I can force rendering by putting in a certain kind of server variable evaluation statement after the getLanguage() function, and outside the function boundaries in open PHP code. Putting it any place before that in the file does not work. But this is a serious hack. Does anyone see what is really going on here, and how it should be fixed?