1. 论坛系统升级为Xenforo,欢迎大家测试!
    排除公告

疯了!!FCKeditord整合的问题!!!

本帖由 vicke2006-01-17 发布。版面名称:后端开发

  1. vicke

    vicke New Member

    注册:
    2005-12-20
    帖子:
    2,348
    赞:
    24
    调用代码如下:(不知道对不对)

    PHP:
    <?php
    if($_POST["ADD"]){
    $Content=$_POST['EditorDefault'];
    echo 
    $Content;
    //变量$Content就是我们在FCKeditord里面编辑的内容,这里可以将其保存到数据库里面
    }
    ?>

    <textarea FCKeditor="true" id="ADD" name="news_content"></textarea>
    <?php
    //引入在线编辑器
    include("../FCKeditor/fckeditor.php") ;
    ?>
    <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" language="javascript">
    <?php
    $oFCKeditor 
    = new FCKeditor ;
    // FCKeditor所在目录
    $oFCKeditor->BasePath '../FCKeditor/' ;
    // 将FCKeditor实例化
    $oFCKeditor->CreateFCKeditor'EditorDefault''700'300 ) ;
    ?>
    想和这个文本域整合:

    PHP:
    <table width="660" border="0" align="center" cellpadding="0" cellspacing="0">
                    <
    tr>
                      <
    td><textarea FCKeditor="true" id="editor1" name="news_content"></textarea>   </tr>
                  </
    table>

    也就是说 news_editor 写入数据库的值 = FCKeditor所录入的数据

    另:更新页面应该怎么样呢?

    还请各位指教 一二 小弟在这多谢了!
     
    #1 vicke, 2006-01-17
    最后编辑: 2006-01-17
  2. vicke

    vicke New Member

    注册:
    2005-12-20
    帖子:
    2,348
    赞:
    24
    帮帮忙哈 多谢了哈
     
  3. vicke

    vicke New Member

    注册:
    2005-12-20
    帖子:
    2,348
    赞:
    24
    :mad: 都跑那去了,没人帮俺一把吗?
     
  4. vicke

    vicke New Member

    注册:
    2005-12-20
    帖子:
    2,348
    赞:
    24
    小叶 帮忙哈

    帝国那去了,这事情帝国拿手不?
     
  5. 小叶

    小叶 New Member

    注册:
    2005-09-04
    帖子:
    17,941
    赞:
    33
    HTML在线编辑器FCKeditor全攻略
    最近一个项目有个功能是论文在线提交,需要用到HTML在线编辑器。很显然,这是一个复杂的功能,我首先想到去下载一个现成而且成熟的代码来,可以直接使用最好,不能也可以自己模仿再改进J

    通过搜索,决定选择FCKeditor。其官方主页为:http://www.fckeditor.net/
    FCKeditor符合我的要求:
    1. 开源,免费,功能强大,易于使用,也可很方便地改写源代码;
    2. 兼容多种浏览器,如IE 5.5+ (Windows), Firefox 1.0+, Mozilla 1.3+ and Nescape 7+;
    3. 多语言支持,因为要开发的网站是国际会议网站,需要面对多国的访问者,这点也非常重要;
    4. 可与PHP集成。
    下面是安装调试的整个过程及个人的一些体会:
    1. 阅读使用文档。FCKeditor的文档放在http://wiki.fckeditor.net,依次阅读Installation和Developer's Guide/Integration/PHP,看看如何安装并和PHP集成。
    2. 下载源码包(选择最新版本2.0),解压并上传到服务器的合适路径下,解压缩。
    3. 访问http://yourhost/FCKediter/_samples/default.html 测试一下是否安装成功。若成功会看到FCKeditor的运行画面,有多个Sample可供选择,测试。 我只选择了PHP部分的Sample,特别注意,里面有一个Multi-language support的例子,哈,这正是我所需要的!
    4. 接下来看看如何与PHP相结合:

    happytest.php
     
  6. 小叶

    小叶 New Member

    注册:
    2005-09-04
    帖子:
    17,941
    赞:
    33
    [​IMG]

    我们如何处理FCKeditor的表单POST的变量呢?
    在happytest.php中,建立了一个名为FCKeditor1的实例,则将生成一个$_POST[‘FCKeditor1’]变量,我们只需在savedata.php中读取出变量值即可。
    savedata.php
    <?
    $sValue = stripslashes( $_POST['FCKeditor1'] ) ;
    echo $sValue;
    ?>
    以上我们得到的是表单中没有套用格式的文字,如果我们想得到最终生成的HTML代码,则需要将
    改成
    $oFCKeditor->CreateHTML() ;


    FCKeditor的详细配置说明:
    FCKeditor 2.0的主要配置文件为FCKeditor\fckconfig.js,其中几个重要的配置项目如下:
    一.改变配置文件:
    $oFCKeditor->Config['CustomConfigurationsPath'] = '/myconfig.js' ;
    使用这行代码,可以将配置文件放置于FCKeditor目录之外
    注意原来的配置文件fckconfig.js不可删除,必须仍然放置于FCKeidtor目录下。另外,改变配置之后,要清除浏览器的缓存,否则不会看到最新的页面。如果你使用的是IE,可以按Ctrl+F5强制刷新。
    二. 工具栏的配置
    默认情况下,FCKeditor会调用默认的工具栏按钮,FCKConfig.ToolbarSets["Default"]这个数组的每个元素对应一个工具,大家可以根据自己的需要进行增减。
    三. 文字样式设置(Style)
    FCKeditor所预设的样式有Image on right,Image on Left,Title,Code等等,如果你有自己常用到的特殊的格式,你可以自己来添加。需要修改的文件有:
    fckconfig.js
    FCKConfig.FontFormats =
    editor/_source/classes/fcktoolbarfontformatcombo.js
    var oNames =
    editor/js/fckeditorcode_ie_2.js and /editor/js/fckeditorcode_gecko_2.js
    var oNames=
    editor/lang/下你选择的语言文件
    FontFormats
    Styles的配置文件是个XML文件,即fckstyles.xml,当然你也可以自己新建一个XML文件并指定配置文件为自己的XML文件。
    在配置的js中,修改FCKConfig.StylesXmlPath = '../myfckstyles.xml' ;
    <?xml version="1.0" encoding="utf-8" ?>
    <Styles >
    <Style name="My Image" element="img">
    <Attribute name="style" value="padding: 5px" />
    <Attribute name="border" value="2" />
    </Style >
    <Style name="Italic" element="em" />
    <Style name="Title" element="span">
    <Attribute name="class" value="Title" />
    </Style >
    <Style name="Title H3" element="h3" />
    </Styles>
    四. 配置模板
    模板配置可以参考fcktemplates.xml,自己定义,然后设置为默认的模板配置文件:
    FCKConfig.TemplatesXmlPath = '/mytemplates.xml' ;
     
  7. vicke

    vicke New Member

    注册:
    2005-12-20
    帖子:
    2,348
    赞:
    24
    谢谢! 先看看先
     
  8. vicke

    vicke New Member

    注册:
    2005-12-20
    帖子:
    2,348
    赞:
    24
    还是没搞定

    帮忙写一下呗

    页面代码如下
    PHP:
    <?php require_once('../Connections/connNews.php'); ?>
    <?php
    // *** Restrict Access To Page: Grant or deny access to this page
    $FF_authorizedUsers=" ";
    $FF_authFailedURL="../index.php";
    $FF_grantAccess=0;
    session_start();
    if (isset(
    $HTTP_SESSION_VARS["MM_Username"])) {
      if (
    true || !(isset($HTTP_SESSION_VARS["MM_UserAuthorization"])) || $HTTP_SESSION_VARS["MM_UserAuthorization"]=="" || strpos($FF_authorizedUsers$HTTP_SESSION_VARS["MM_UserAuthorization"])) {
        
    $FF_grantAccess 1;
      }
    }
    if (!
    $FF_grantAccess) {
      
    $FF_qsChar "?";
      if (
    strpos($FF_authFailedURL"?")) $FF_qsChar "&";
      
    $FF_referrer $HTTP_SERVER_VARS['PHP_SELF'];
      if (isset(
    $HTTP_SERVER_VARS['QUERY_STRING']) && strlen($HTTP_SERVER_VARS['QUERY_STRING']) > 0$FF_referrer .= "?" $HTTP_SERVER_VARS['QUERY_STRING'];
      
    $FF_authFailedURL $FF_authFailedURL $FF_qsChar "accessdenied=" urlencode($FF_referrer);
      
    header("Location: $FF_authFailedURL");
      exit;
    }

    function 
    GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue ""
    {
      
    $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;

      switch (
    $theType) {
        case 
    "text":
          
    $theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
          break;    
        case 
    "long":
        case 
    "int":
          
    $theValue = ($theValue != "") ? intval($theValue) : "NULL";
          break;
        case 
    "double":
          
    $theValue = ($theValue != "") ? "'" doubleval($theValue) . "'" "NULL";
          break;
        case 
    "date":
          
    $theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
          break;
        case 
    "defined":
          
    $theValue = ($theValue != "") ? $theDefinedValue $theNotDefinedValue;
          break;
      }
      return 
    $theValue;
    }

    $editFormAction $_SERVER['PHP_SELF'];
    if (isset(
    $_SERVER['QUERY_STRING'])) {
      
    $editFormAction .= "?" htmlentities($_SERVER['QUERY_STRING']);
    }

    if ((isset(
    $_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
      
    $insertSQL sprintf("INSERT INTO newsdata (news_time, news_type, news_title, news_editor, news_img, news_content) VALUES (%s, %s, %s, %s, %s, %s)",
                           
    GetSQLValueString($_POST['news_time'], "date"),
                           
    GetSQLValueString($_POST['news_type'], "text"),
                           
    GetSQLValueString($_POST['news_title'], "text"),
                           
    GetSQLValueString($_POST['news_editor'], "text"),
                           
    GetSQLValueString($_POST['news_img'], "text"),
                           
    GetSQLValueString($_POST['news_content'], "text"));

      
    mysql_select_db($database_connNews$connNews);
      
    $Result1 mysql_query($insertSQL$connNews) or die(mysql_error());

      
    $insertGoTo "index1.php";
      if (isset(
    $_SERVER['QUERY_STRING'])) {
        
    $insertGoTo .= (strpos($insertGoTo'?')) ? "&" "?";
        
    $insertGoTo .= $_SERVER['QUERY_STRING'];
      }
      
    header(sprintf("Location: %s"$insertGoTo));
    }
    ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>新闻添加页面</title>
    <style type="text/css">
    <!--
    .STYLE1 {color: #FF0000}
    .txt {
        font-family: "宋体";
        font-size: 12px;
        font-weight: 100;
        color: #FF0000;
        background-color: #FFFFFF;
        border: 1px solid #CCCCCC;
    }
    .biaoge {
        font-family: "宋体";
        font-size: 18px;
        font-weight: 100;
        color: #CCCCCC;
        margin: 1px;
    }
    </head>

    <body>
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td><form id="form1" name="form1" method="POST" action="<?php echo $editFormAction?>">
          <table width="700" border="0" align="center" cellpadding="0" cellspacing="0" class="txt">
            <tr>
              <td width="183"><img src="../imges/newsxx_r3_c1.gif" width="183" height="54" /></td>
              <td width="517"><input name="news_title" type="text" class="biaoge" id="news_title" /></td>
            </tr>
            <tr>
              <td><img src="../imges/newsxx_r5_c1.gif" width="183" height="54" /></td>
              <td><input name="news_editor" type="text" class="biaoge" id="news_editor" /></td>
            </tr>
            <tr>
              <td><img src="../imges/newsxx_r2_c1.gif" width="183" height="54" /></td>
              <td><input name="news_time" type="text" class="biaoge" id="news_time" value="<?echo date("y-m-d G:i:s")?>" /></td>
            </tr>
            <tr>
              <td rowspan="2"><img src="../imges/news_admin_index_r4_c3.gif" width="183" height="54" /></td>
              <td><input name="news_img" type="radio" value="1.gif" checked="checked" /> 
                <img src="../imges/img/1.gif" width="20" height="20" /> <input type="radio" name="news_img" value="2.gif" />
                <img src="../imges/img/2.gif" width="20" height="20" /> <input type="radio" name="news_img" value="3.gif" />
                <img src="../imges/img/3.gif" width="20" height="20" /> <input type="radio" name="news_img" value="4.gif" />
                <img src="../imges/img/4.gif" width="20" height="20" /> <input type="radio" name="news_img" value="5.gif" />
                <img src="../imges/img/5.gif" width="20" height="20" /> <input type="radio" name="news_img" value="6.gif" />
                <img src="../imges/img/6.gif" width="20" height="20" /> <input type="radio" name="news_img" value="7.gif" />
                <img src="../imges/img/7.gif" width="20" height="20" /> <input type="radio" name="news_img" value="8.gif" />
                <img src="../imges/img/8.gif" width="20" height="20" /> <input type="radio" name="news_img" value="9.gif" />
                <img src="../imges/img/9.gif" width="20" height="20" /> </td>
            </tr>
            
            <tr>
              <td><input type="radio" name="news_img" value="10.gif" />
                <img src="../imges/img/10.gif" width="20" height="20" /> <input type="radio" name="news_img" value="11.gif" />
                <img src="../imges/img/11.gif" width="20" height="20" /> <input type="radio" name="news_img" value="12.gif" />
                <img src="../imges/img/12.gif" width="22" height="29" /> <input type="radio" name="news_img" value="13.gif" />
                <img src="../imges/img/13.gif" width="16" height="16" />
                 <input type="radio" name="news_img" value="14.gif" />
                <img src="../imges/img/14.gif" width="16" height="16" />  <input type="radio" name="news_img" value="15.gif" />
                <img src="../imges/img/15.gif" width="16" height="16" /> <input type="radio" name="news_img" value="16.gif" />
                <img src="../imges/img/16.gif" width="16" height="16" /> <input type="radio" name="news_img" value="17.gif" />
                <img src="../imges/img/17.gif" width="16" height="18" /> <input type="radio" name="news_img" value="18.gif" />
                <img src="../imges/img/18.gif" width="16" height="16" /></td>
            </tr>
            
            <tr>
              <td><img src="../imges/newsxx_r7_c1.gif" width="183" height="54" /></td>
              <td><div align="center"><span class="STYLE1">别忘记选一下这个数据类型:</span>
                <select name="news_type" id="news_type">
                    <option value="[站点公告]">站点公告</option>
                    <option value="[情感类..]">情感类</option>
                    <option value="[技术类..]">技术类</option>
                    <option value="[日记类..]">日记类</option>
                    </select>
              </div></td>
            </tr>
    \\  想把FCKeditord显示在这里
    \\  news_content 为传入数据库的值   
        </table>
            <table width="700" border="0" align="center" cellpadding="0" cellspacing="0">
              <tr>
                <td><textarea dmxedit="true" id="news_content" name="news_content"></textarea></td>
              </tr>
            </table>
            <p align="center">
              <input type="submit" name="Submit" value="完 成 提 交" />
                     
              <input type="reset" name="Submit2" value="重 新 输 入" />
            </p>
            <input type="hidden" name="MM_insert" value="form1">
        </form>
        </td>
      </tr>
      <tr>
        <td><div align="center"><img src="../imges/newsxx_r9_c1.gif" width="600" height="46" /></div></td>
      </tr>
    </table>
    <table width="700" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td width="350"><div align="center"><a href="index.php"><img src="../imges/news_admin_index_r4_c2.gif" width="175" height="71" border="0" /></a></div></td>
        <td width="350"><div align="center"><a href="../index.php"><img src="../imges/news_admin_index_r6_c3.gif" width="175" height="71" border="0" /></a></div></td>
      </tr>
    </table>
    <p>&nbsp;</p>
    </body>
    </html>

     
  9. vicke

    vicke New Member

    注册:
    2005-12-20
    帖子:
    2,348
    赞:
    24
    还是搞不定 来人哈 帮帮俺
     
  10. Henry

    Henry New Member

    注册:
    2005-09-04
    帖子:
    1,166
    赞:
    4
    自带的samples 把各种类型的使用都在放里面,察看一下就可以了。 有必要胡思乱想发帖自问吗
     
  11. vicke

    vicke New Member

    注册:
    2005-12-20
    帖子:
    2,348
    赞:
    24
    我自己都迷糊了,搞了一天 还是木结果

    楼上 帮忙看下好吗?:D

    给你添加和更新页面的源代码 帮俺改改 多谢啦 !:p