怎样获取FCKeditor中的值?

zhengbin_007 2006-12-14 11:48:08
我用的是FCKeditor2.23数据提交后...

用$content=$_POST['content'];//获取不到客户端输入的值...用过这个编辑器
的朋友告诉下啊...

fckeditor.php 代码如下:


class FCKeditor
{
var $InstanceName ;
var $BasePath ;
var $Width ;
var $Height ;
var $ToolbarSet ;
var $Value ;
var $Config ;

// PHP 5 Constructor (by Marcus Bointon <coolbru@users.sourceforge.net>)
function __construct( $instanceName )
{
$this->InstanceName = $instanceName ;
$this->BasePath = '/fckeditor/' ;
$this->Width = '100%' ;
$this->Height = '200' ;
$this->ToolbarSet = 'Default' ;
$this->Value = '' ;

$this->Config = array() ;
}

// PHP 4 Contructor
function FCKeditor( $instanceName )
{
$this->__construct( $instanceName ) ;
}

function Create()
{
echo $this->CreateHtml() ;
}

function CreateHtml()
{
$HtmlValue = htmlspecialchars( $this->Value ) ;

$Html = '<div>' ;

if ( $this->IsCompatible() )
{
if ( isset( $_GET['fcksource'] ) && $_GET['fcksource'] == "true" )
$File = 'fckeditor.original.html' ;
else
$File = 'fckeditor.html' ;

$Link = "{$this->BasePath}editor/{$File}?InstanceName={$this->InstanceName}" ;

if ( $this->ToolbarSet != '' )
$Link .= "&Toolbar={$this->ToolbarSet}" ;

// Render the linked hidden field.
$Html .= "<input type=\"hidden\" id=\"{$this->InstanceName}\" name=\"{$this->InstanceName}\" value=\"{$HtmlValue}\" style=\"display:none\" />" ;

// Render the configurations hidden field.
$Html .= "<input type=\"hidden\" id=\"{$this->InstanceName}___Config\" value=\"" . $this->GetConfigFieldString() . "\" style=\"display:none\" />" ;

// Render the editor IFRAME.
$Html .= "<iframe id=\"{$this->InstanceName}___Frame\" src=\"{$Link}\" width=\"{$this->Width}\" height=\"{$this->Height}\" frameborder=\"0\" scrolling=\"no\"></iframe>" ;
}
else
{
if ( strpos( $this->Width, '%' ) === false )
$WidthCSS = $this->Width . 'px' ;
else
$WidthCSS = $this->Width ;

if ( strpos( $this->Height, '%' ) === false )
$HeightCSS = $this->Height . 'px' ;
else
$HeightCSS = $this->Height ;

$Html .= "<textarea name=\"{$this->InstanceName}\" rows=\"4\" cols=\"40\" style=\"width: {$WidthCSS}; height: {$HeightCSS}\">{$HtmlValue}</textarea>" ;
}

$Html .= '</div>' ;

return $Html ;
}

function IsCompatible()
{
global $HTTP_USER_AGENT ;

if ( isset( $HTTP_USER_AGENT ) )
$sAgent = $HTTP_USER_AGENT ;
else
$sAgent = $_SERVER['HTTP_USER_AGENT'] ;

if ( strpos($sAgent, 'MSIE') !== false && strpos($sAgent, 'mac') === false && strpos($sAgent, 'Opera') === false )
{
$iVersion = (float)substr($sAgent, strpos($sAgent, 'MSIE') + 5, 3) ;
return ($iVersion >= 5.5) ;
}
else if ( strpos($sAgent, 'Gecko/') !== false )
{
$iVersion = (int)substr($sAgent, strpos($sAgent, 'Gecko/') + 6, 8) ;
return ($iVersion >= 20030210) ;
}
else
return false ;
}

function GetConfigFieldString()
{
$sParams = '' ;
$bFirst = true ;

foreach ( $this->Config as $sKey => $sValue )
{
if ( $bFirst == false )
$sParams .= '&' ;
else
$bFirst = false ;

if ( $sValue === true )
$sParams .= $this->EncodeConfig( $sKey ) . '=true' ;
else if ( $sValue === false )
$sParams .= $this->EncodeConfig( $sKey ) . '=false' ;
else
$sParams .= $this->EncodeConfig( $sKey ) . '=' . $this->EncodeConfig( $sValue ) ;
}

return $sParams ;
}

function EncodeConfig( $valueToEncode )
{
$chars = array(
'&' => '%26',
'=' => '%3D',
'"' => '%22' ) ;

return strtr( $valueToEncode, $chars ) ;
}
}
$oFCKeditor = new FCKeditor('content') ;//实例化
$oFCKeditor->BasePath = 'fckeditor/';//这个路径一定要和上面那个引入路径一致,否则会报错:找不到fckeditor.html页面
//$oFCKeditor->Value = '' ;
$oFCKeditor->Width = '100%' ;
$oFCKeditor->Height = '350' ;
$oFCKeditor->Create() ;

--------------------
index.html //内容添加页面
<form method="post" action="upload.php" enctype="multipart/form-data">
<td>
<textarea name="content" style="display:none">
</textarea>
<iframe width="100%" id=content height="350" src="./templates/admin/fckeditor.php?id=content&style=standard" >

</iframe>
</td>

---------------
upload.php


$content=$_POST['content'];//没有值...

要把值用xml来保存...那么内容包括图片数据,这些数据能正常保存吗.怎么保存

...全文
935 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
blueprints 2010-05-31
  • 打赏
  • 举报
回复
$content=$_POST['FCKeditor']
其中"FCKeditor"是实例fckeditor时的参数名
zhengbin_007 2006-12-20
  • 打赏
  • 举报
回复
to: foolbirdflyfirst()

问题解决了,太感谢你了...待会给你分啊..同时也要感谢CSDN上的所有朋友
foolbirdflyfirst 2006-12-20
  • 打赏
  • 举报
回复
漏了$smarty->display(tpl路径)
foolbirdflyfirst 2006-12-20
  • 打赏
  • 举报
回复
article.php:
-------------
echo $_POST['content'];//it will output the values

$editor = new FCKeditor('content');
$smarty = new Smarty;
//______________________________________________________________
//editor config:

$editor->BasePath = 'FCKeditor/';
$editor->Width = '50%';
$editor->Height = 500;
$editor->ToolbarSet = 'Default';
$editor->Value = "";
//_____________________________________________________________
$smarty->assign_by_ref("editor",$editor);


article.php(tpl):
---------------
<form name="articlePost" method="post" action="article.php">
<table><tr><td>{$editor->Create()}</td></table>
</form>
zhengbin_007 2006-12-20
  • 打赏
  • 举报
回复
有谁做过在smarty 模板下使用Fckeditor 在线编辑器的....

要能获取内容的...给个例子吧.
visam168 2006-12-14
  • 打赏
  • 举报
回复
我也出现同样情况,帮顶了。。。。。关注中
zhengbin_007 2006-12-14
  • 打赏
  • 举报
回复
to:yueliangdao0608((深圳)PHP和MYSQL电话:13424263101/QQ:38257291)

这样只是把多行文本框显示出来..跟这没关系啊.
foolbirdflyfirst 2006-12-14
  • 打赏
  • 举报
回复
<?php
$oFCKeditor = new FCKeditor('content') ;//实例化
$oFCKeditor->BasePath = 'fckeditor/';//这个路径一定要和上面那个引入路径一致,否则会报错:找不到fckeditor.html页面
//$oFCKeditor->Value = '' ;
$oFCKeditor->Width = '100%' ;
$oFCKeditor->Height = '350' ;
?>
<form method="post" action="upload.php" enctype="multipart/form-data">
<?php
$oFCKeditor->Create() ;
<?
</form>
懒得去死 2006-12-14
  • 打赏
  • 举报
回复
<textarea name="content" style="display:block">
</textarea>

21,886

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧