BloggerAds

2007年5月7日 星期一

所見即所得-「FCKeditor」

目前幫朋友看看「所見即所得」的功能如何套用在一般表單的輸入應用上,「FCKeditor」-就是它,當然還有其他的案子是寫「所見即所得」的,只是這次是使用FCKeditor。

官方網站:http://www.fckeditor.net

至於授權的部份...
FCKeditor - The text editor for Internet - http://www.fckeditor.net
Copyright (C) 2003-2007 Frederico Caldeira Knabben

Licensed under the terms of any of the following licenses at your
choice:

- GNU General Public License Version 2 or later (the "GPL")
http://www.gnu.org/licenses/gpl.html
(See Appendix A)

- GNU Lesser General Public License Version 2.1 or later (the "LGPL")
http://www.gnu.org/licenses/lgpl.html
(See Appendix B)

- Mozilla Public License Version 1.1 or later (the "MPL")
http://www.mozilla.org/MPL/MPL-1.1.html
(See Appendix C)

You are not required to, but if you want to explicitly declare the
license you have chosen to be bound to when using, reproducing,
modifying and distributing this software, just include a text file
titled "legal.txt" in your version of this software, indicating your
license choice. In any case, your choice will not restrict any
recipient of your version of this software to use, reproduce, modify
and distribute this software under any of the above licenses.
所以只要不修改、延伸、分配新的版本,感覺上就比較沒有什麼關係了!

怎麼使用咧?...
自官方網站直接抓下來後,直接看[_sample]的資料夾裡面有各種網站程式語言的資料夾,像我!選的就是PHP由伺服器運算後丟HTML檔給Client端的電腦看,不過大流量的話,比較建議直接使用HTML或JavaScript語法來實現!

或許是PHP的關係,所以只要修改欄位的名字及一些簡單的設定,如:
$sBasePath ='http://127.0.0.1/FCKeditor/'; //這是要放這工具的起始路徑。
$oFCKeditor = new FCKeditor('pd_event') ; //這是此欄位的名字-pd_event。
$oFCKeditor->Value = '請在此輸入!' ; //這是此欄位預設的值。
$oFCKeditor->ToolbarSet = "Default"; //你的編輯工具有兩種選項-'Basic'精簡的;"Default"是預設的什麼都來的選項,比較多。

開網頁看看原始碼!
發現有使用到iframe,所以不支援iframe的瀏覽器,可要退散嚕!下面是原始碼...
<div><input type="hidden" id="pd_event" name="pd_event" value="請在此輸入!" style="display:none" /><input type="hidden" id="pd_event___Config" value="" style="display:none" /><iframe id="pd_event___Frame" src="http://127.0.0.1/FCKeditor/editor/fckeditor.html?InstanceName=pd_event&amp;Toolbar=Default" width="100%" height="200" frameborder="0" scrolling="no"></iframe></div>

不難發現有用隱形的文字輸入欄位存放著參數-pd_event___Config、pd_event;
用iframe使用fckeditor.html這文件帶入InstanceName、Toolbar而顯示結果內容。

那表單送出後會得到什麼?
會得到一段HTML語法!那也請使用POST去讀取欄位內容!

好嚕,分析個優缺點:
這樣子的話....
缺點:
若這種欄位多了起來,我想開網頁的速度比較慢吧!因為要等iframe開好才是完整的頁面!
所以有幾個這種欄位就要等幾個這iframe頁面Loading完嚕。
優點:
容易置入!新的工具,是需要學習時間的,這有包好成一段程式,只要修改參數,可以很容易的應用在你所需要的表單上。

沒有留言: