我有一个CKEditor插件的问题。我需要PHP代码来使用MySQL数据库和CMS (WebsiteBaker)给我的几个变量。CKEditor插件应该会打开一个新的对话框,给出几个在part中定义的链接供你选择。在plugin.js中,代码
CKEDITOR.dialog.add('wbdropletsdlg', this.path + 'dialogs/wbdroplets.php');运行良好-但不是在“真正的”UNIX服务器上,只在XAMPP (Windows7)上。在wblink.php中,有PHP部分和CKEditor所必需的JavaScript部分。
我尝试在plugin.js中将代码更改为
CKEDITOR.dialog.add('wbdropletsdlg', this.path + 'dialogs/wbdroplets.js');把JavaScript放进去
CKEDITOR.dialog.add( 'wbdropletsdlg', function( editor ) {
CKEDITOR.scriptLoader.load(this.path + "wbdroplets.php");
return {
title: editor.lang.wbdroplets.name,
minWidth: 280,
minHeight: 80,
contents: [
{
id: 'tab1',
label: 'Tab1',
title: 'Tab1',
elements : [{
id: 'wbdroplets',
type: 'select',
label: "Droplets",
labelLayout:'horizontal',
widths:['20%','80%'],
style: 'width: 150px; margin-left: 10px; margin-top:-3px;',
validate : function() { },
items: list,
onMouseUp: function() {
/**
* code to display the description of the droplets ...
*
*/
desc_list;
var droplet_name = this.getValue();
var ref = document.getElementById("droplet_info");
ref.innerHTML = info[droplet_name];
},
onShow: function() {
this.onMouseUp();
}
} , {
id: 'droplet_info_box',
type: 'html',
label: 'Info',
labelLayout:'horizontal',
widths:['20%','80%'],
style: "display: inline; " +
"float: left; " +
"margin-left: 0; " +
"padding-left: 10px; " +
"width: 250px !important; " +
"height: 100px;" +
"white-space: normal !important;",
html: "<div id='droplet_info'>Hello</div>"
} ]
}
],
onOk: function() {
/**
* Getting the value of our droplet-select
*
*/
var droplet_name = this.getContentElement("tab1", "wbdroplets").getInputElement().getValue();
editor = this.getParentEditor();
editor.fire('paste', { 'text' : droplet_name } );
return true;
},
resizable: 2
};
} );在PHP文件中,代码
require(WB_PATH.'/framework/class.admin.php');
admin = new admin('Pages', 'pages_modify', false);
global $database;
$get_droplet = $database->query("SELECT * FROM `".TABLE_PREFIX."mod_droplets` where `active`=1 ORDER BY `name`");
$list = "[";
$desc_list = "var info = new Array();";
if($get_droplet->numRows() > 0) {
while($droplet = $get_droplet->fetchRow()) {
$title = stripslashes($droplet['name']);
$desc = stripslashes($droplet['description']);
$comm = stripslashes($droplet['comments']);
$list .= "\n['".$title."', '[[".$title."]]'],";
$desc_list .= "info['[[".$title."]]']='".trim($desc)."<br /><br />".trim($comm)."';";
}
$list = substr( $list, 0, -1 );
}
$list .= "]";
$desc_list .= "\n";
function script($list)
{
$out = "<script type=\"text/javascript\">";
$out .= "//<![CDATA[\n";
$out .= $list;
$out .= $desc_list;
$out .= "\n//]]>";
$out .= "</script>\n";
return $out;
}但是CKEditor插件没有打开-火狐控制台显示“列表未定义”。
非常感谢你的帮助。
发布于 2010-04-24 05:16:10
scriptLoader有第二个参数,它是加载所请求的脚本时要执行的回调函数。如果你在你的计算机上开发,它可能会足够快地返回数据,但在生产环境中,它预计会有一些延迟,所以这就是为什么它在一种情况下工作,在另一种情况下失败的原因。
https://stackoverflow.com/questions/2701970
复制相似问题