SPAW editor på localhost
Jeg anvender SPAW editor med stor succes på forskellige sites.For at kunne udvikle lokalt inden upload, har jeg installeret IIS og PHP (4.3.7.) og vil gerne kunne anvende SPAW, men her løber jeg ind i problemer.
Jeg får følgende fejl:
Fatal error: Cannot instantiate non-existent class: spaw_wysiwyg in C:\Documents and Settings\Vinther Jensen.LAPTOP.000\Dokumenter\web\lms\editor.php on line 71
Det er i denne linie fejlen opstår:
$sw = new SPAW_Wysiwyg('spaw1',$contents,'dk' /*language*/, 'full' /*toolbar mode*/,'default' /*theme*/,'550px' /*width*/, '250px' /*height*/, 'css/lms.css' /*stylesheet file*/);
Her er lige hele 'editor.php' filen:
**********START***************
<?
// ================================================
// SPAW PHP WYSIWYG editor control
// ================================================
// Control usage demonstration file
// ================================================
// Developed: Alan Mendelevich, alan@solmetra.lt
// Copyright: Solmetra (c)2003 All rights reserved.
// ------------------------------------------------
// www.solmetra.com
// ================================================
// $Revision: 1.3 $, $Date: 2003/04/29 17:12:04 $
// ================================================
// this part determines the physical root of your website
// it's up to you how to do this
/*
if (!ereg('/$', $HTTP_SERVER_VARS['DOCUMENT_ROOT']))
{
$_root = $HTTP_SERVER_VARS['DOCUMENT_ROOT'].'/';
}
else
{
$_root = $HTTP_SERVER_VARS['DOCUMENT_ROOT'];
}
*/
$_root = "http://localhost/lms/";
// define('DR', $_root);
// unset($_root);
// set $spaw_root variable to the physical path were control resides
// don't forget to modify other settings in config/spaw_control.config.php
// namely $spaw_dir and $spaw_base_url most likely require your modification
// $spaw_root = DR.'spaweditor/';
$spaw_root = $_root.'spaweditor/';
// include the control file
include $spaw_root.'spaw_control.class.php';
// here we add some styles to styles dropdown
$spaw_dropdown_data['style']['default'] = 'No styles';
$spaw_dropdown_data['style']['style1'] = 'Style no. 1';
$spaw_dropdown_data['style']['style2'] = 'Style no. 2';
?>
<html>
<head>
</head>
<body>
<center>
<?php
$filename = $_GET['fil'];
$fd = fopen ($filename, "rb");
$contents = fread ($fd, filesize ($filename));
fclose ($fd);
?>
<form name=minform action="editor.php?action=do" method=post>
<input type=hidden name="txtfilnavn" value="<? echo $filename; ?>">
<?php
$sw = new SPAW_Wysiwyg('spaw1',$contents,'dk' /*language*/, 'full' /*toolbar mode*/,'default' /*theme*/,'550px' /*width*/, '250px' /*height*/, 'css/lms.css' /*stylesheet file*/);
$sw->show();
?>
<input type=submit value=Send>
</form>
</body>
</html>
**********SLUT****************
Jeg ved at der er "hul igennem" til 'spaw_control.class.php', hvor den pågældende class defineres. Hele filen kommer her:
***********START*********
<?php
// ================================================
// SPAW PHP WYSIWYG editor control
// ================================================
// Main control class
// ================================================
// Developed: Alan Mendelevich, alan@solmetra.lt
// Copyright: Solmetra (c)2003 All rights reserved.
// ------------------------------------------------
// www.solmetra.com
// ================================================
// v.1.0, 2003-03-25
// ================================================
if ($_SERVER["SERVER_NAME"] == "localhost")
{
$spaw_root = "http://localhost/lms/spaweditor/";
}
include $spaw_root.'config/spaw_control.config.php';
include $spaw_root.'class/toolbars.class.php';
include $spaw_root.'class/lang.class.php';
// instance counter (static)
$spaw_wysiwyg_instCount = 0;
class SPAW_Wysiwyg {
// controls name
var $control_name;
// value
var $value;
// holds control toolbar mode.
var $mode;
// editor dimensions;
var $height;
var $width;
// language object
var $lang;
// theme (skin)
var $theme;
// editor stylesheet
var $css_stylesheet;
// toolbar dropdown data
var $dropdown_data;
// toolbars
var $toolbars;
// constructor
function SPAW_Wysiwyg($control_name='richeditor', $value='', $lang='', $mode = '',
$theme='', $width='100%', $height='300px', $css_stylesheet='', $dropdown_data='')
{
global $spaw_dir;
global $spaw_wysiwyg_instCount;
global $spaw_default_theme;
global $spaw_default_css_stylesheet;
$spaw_wysiwyg_instCount++;
$this->control_name = $control_name;
$this->value = $value;
$this->width = $width;
$this->height = $height;
if ($css_stylesheet == '')
{
$this->css_stylesheet = $spaw_default_css_stylesheet;
}
else
{
$this->css_stylesheet = $css_stylesheet;
}
$this->getLang($lang);
if ($theme=='')
{
$this->theme = $spaw_default_theme;
}
else
{
$this->theme = $theme;
}
$this->mode = $mode;
$this->dropdown_data = $dropdown_data;
$this->getToolbar();
}
// sets _mode variable and fills toolbar items array
function setMode($value) {
$this->mode = $value;
}
// returns _mode value
function getMode() {
return($this->mode);
}
// set value/get value
function setValue($value) {
$this->value = $value;
}
function getValue() {
return($this->value);
}
// set height/get height
function setHeight($value) {
$this->height = $value;
}
function getHeight() {
return($this->height);
}
// set/get width
function setWidth($value) {
$this->width = $value;
}
function getWidth() {
return($this->width);
}
// set/get css_stylesheet
function setCssStyleSheet($value) {
$this->css_stylesheet = $value;
}
function getCssStyleSheet() {
return($this->css_stylesheet);
}
// outputs css and javascript code include
function getCssScript($inline = false)
{
// static method... use only once per page
global $spaw_dir;
global $spaw_inline_js;
global $spaw_root;
global $spaw_active_toolbar;
if ($spaw_inline_js)
{
// inline javascript
echo "<script language='JavaScript'>\n";
echo "<!--\n";
echo "var spaw_active_toolbar = ".($spaw_active_toolbar?"true":"false").";\n";
include($spaw_root.'class/script.js.php');
echo "//-->\n";
echo "</script>\n";
}
else
{
// external javascript
echo "<script language='JavaScript'>\n";
echo "<!--\n";
echo "var spaw_active_toolbar = ".($spaw_active_toolbar?"true":"false").";\n";
echo "//-->\n";
echo "</script>\n";
echo '<script language="JavaScript" src="'.$spaw_dir.'spaw_script.js.php"></script>'."\n\n";
}
}
// checks browser compatibility with the control
function checkBrowser()
{
global $HTTP_SERVER_VARS;
$browser = $HTTP_SERVER_VARS['HTTP_USER_AGENT'];
// check if msie
if (eregi("MSIE[^;]*",$browser,$msie))
{
// get version
if (eregi("[0-9]+\.[0-9]+",$msie[0],$version))
{
// check version
if ((float)$version[0]>=5.5)
{
// finally check if it's not opera impersonating ie
if (!eregi("opera",$browser))
{
return true;
}
}
}
}
return false;
}
// load language data
function getLang($lang='')
{
$this->lang = new SPAW_Lang($lang);
}
// load toolbars
function getToolbar()
{
$this->toolbars = new SPAW_Toolbars($this->lang,$this->control_name,$this->mode,$this->theme,$this->dropdown_data);
}
// returns html for wysiwyg control
function getHtml()
{
global $spaw_dir;
global $spaw_wysiwyg_instCount;
global $spaw_active_toolbar;
$n = $this->control_name;
// todo: make more customizable
$buf = '';
if ($this->checkBrowser())
{
if ($spaw_wysiwyg_instCount == 1)
{
$this->getCssScript();
}
// theme based css file and javascript
$buf.= '<script language="JavaScript" src="'.$spaw_dir.'lib/themes/'.$this->theme.'/js/toolbar.js.php"></script>';
$buf.= '<link rel="stylesheet" type="text/css" href="'.$spaw_dir.'lib/themes/'.$this->theme.'/css/toolbar.css">';
$buf.= '<table border="0" cellspacing="0" cellpadding="0" width="'.$this->getWidth().'">';
$buf.= '<tr>';
$buf .= '<td id="SPAW_'.$n.'_toolbar_top_design" class="SPAW_'.$this->theme.'_toolbar" colspan="3">';
$buf.= $this->toolbars->get('top');
$buf .= '</td>';
$buf .= '<td id="SPAW_'.$n.'_toolbar_top_html" class="SPAW_'.$this->theme.'_toolbar" colspan="3" style="display : none;">';
$buf.= $this->toolbars->get('top','html');
$buf .= '</td>';
$buf .= '</tr>';
$buf.= '<tr>';
$buf.= '<td id="SPAW_'.$n.'_toolbar_left_design" valign="top" class="SPAW_'.$this->theme.'_toolbar" >';
$buf.= $this->toolbars->get('left');
$buf .= '</td>';
$buf.= '<td id="SPAW_'.$n.'_toolbar_left_html" valign="top" class="SPAW_'.$this->theme.'_toolbar" style="display : none;">';
$buf.= $this->toolbars->get('left','html');
$buf .= '</td>';
$buf .= '<td align="left" valign="top" width="100%">';
//$buf.= '<input type="hidden" id="'.$n.'" name="'.$n.'">';
$buf.= '<textarea id="'.$n.'" name="'.$n.'" style="width:100%; height:'.$this->getHeight().'; display:none;" class="SPAW_'.$this->theme.'_editarea"></textarea>';
$buf.= '<input type="hidden" id="SPAW_'.$n.'_editor_mode" name="SPAW_'.$n.'_editor_mode" value="design">';
$buf.= '<input type="hidden" id="SPAW_'.$n.'_lang" value="'.$this->lang->lang.'">';
$buf.= '<input type="hidden" id="SPAW_'.$n.'_theme" value="'.$this->theme.'">';
$buf.= '<input type="hidden" id="SPAW_'.$n.'_borders" value="on">';
$buf.= '<iframe id="'.$n.'_rEdit" style="width:100%; height:'.$this->getHeight().'; direction:'.$this->lang->getDir().';" onLoad="SPAW_editorInit(\''.$n.'\',\''.htmlspecialchars($this->getCssStyleSheet()).'\',\''.$this->lang->getDir().'\');" class="SPAW_'.$this->theme.'_editarea" frameborder="no" style="direction : "></iframe><br>';
$buf.= "\n<script language=\"javascript\">\n<!--\n";
$tmpstr = str_replace("\r\n","\n",$this->getValue());
$tmpstr = str_replace("\r","\n",$tmpstr);
$content = explode("\n",$tmpstr);
$plus = "";
foreach ($content as $line)
{
$buf.="setTimeout('document.all.".$n.".value ".$plus."=\"".str_replace('"','"',str_replace("'","\'",$line))."\";',0);\n";
$plus = "+";
}
$buf.="setTimeout('document.all.".$n.".value = document.all.".$n.".value.replace(/"/g,\'\"\');',0);"."\n";
// $buf.='setTimeout("alert(document.all.'.$n.'.value);",0);'."\n";
// $buf.='setTimeout("'.$n.'_rEdit.document.body.innerHTML += document.all.'.$n.'.value;",0);'."\n";
// $buf.='setTimeout("SPAW_toggle_borders(\''.$n.'\',this[\''.$n.'_rEdit\'].document.body,null);",0);'."\n";
$buf.= '//--></script>';
$buf.= '</td>';
$buf.= '<td id="SPAW_'.$n.'_toolbar_right_design" valign="top" class="SPAW_'.$this->theme.'_toolbar">';
$buf.= $this->toolbars->get('right');
$buf .= '</td>';
$buf.= '<td id="SPAW_'.$n.'_toolbar_right_html" valign="top" class="SPAW_'.$this->theme.'_toolbar" style="display : none;">';
$buf.= $this->toolbars->get('right','html');
$buf .= '</td>';
$buf.= '</tr>';
$buf.= '<tr><td class="SPAW_'.$this->theme.'_toolbar"></td>';
$buf .= '<td id="SPAW_'.$n.'_toolbar_bottom_design" class="SPAW_'.$this->theme.'_toolbar" width="100%">';
$buf.= $this->toolbars->get('bottom');
$buf .= '</td>';
$buf .= '<td id="SPAW_'.$n.'_toolbar_bottom_html" class="SPAW_'.$this->theme.'_toolbar" width="100%" style="display : none;">';
$buf.= $this->toolbars->get('bottom','html');
$buf .= '</td>';
$buf .= '<td class="SPAW_'.$this->theme.'_toolbar"></td></tr>';
$buf.= '</table>';
}
else
{
// show simple text area
$buf = '<textarea cols="20" rows="5" name="'.$n.'" style="width:'.$this->getWidth().'; height:'.$this->getHeight().'">'.$this->getValue().'</textarea>';
}
return $buf;
}
// outputs wysiwyg control
function show()
{
echo $this->getHtml();
}
}
?>
************SLUT*********