现在我正在尝试使用代码,获得要使用和显示的图像列表以供选择,稍后我可以在启用tinymce的字段上显示该列表。
tinymce init block 类似于:
tinyMCE.init({
'theme' : "advanced",
'mode' : "textareas",
'theme_advanced_toolbar_location' : "top",
'content_css' : "/skins.css",
'editor_selector' : "mceEditor",
'plugins' : "autolink,lists,spellchecker,pagebreak,layer,table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras",
file_browser_callback : 'surveyImageBrowser',
'theme_advanced_toolbar_align' : "left",
'theme_advanced_resizing' : true,
'theme_advanced_statusbar_location' :'bottom'
});
我的 file_browser_callback 的“surveyImageBrowser”函数如下:
function surveyImageBrowser(field_name,url,type,win){
var cmsURL = '/local_image_folder';
var searchString = window.location.search;
if (searchString.length < 1) {
searchString = "?";
}
tinyMCE.activeEditor.windowManager.open({
file : cmsURL,
title : 'My File Browser',
width : 420,
height : 400,
resizable : "yes",
inline : "yes",
close_previous : "no"
}, {
window : win,
input : field_name
});
var win = tinyMCEPopup.getWindowArg("window");
var input = tinyMCEPopup.getWindowArg("input");
var res = tinyMCEPopup.getWindowArg("resizable");
var inline = tinyMCEPopup.getWindowArg("inline");
return false;
}
问题是我不想授予 URL 全局可见的权限 (htaccess),而是从 Perl 脚本获取图像列表,然后使用该列表。 Perl 脚本看起来像:
my $dir = '/local_images_folder';
opendir(DIR, $dir) or die $!;
while (my $file = readdir(DIR)) {
# Use a regular expression to ignore files beginning with a period
next if ($file =~ m/^\./);
print "$file\n";
}
closedir(DIR);
有人可以建议我需要对函数 imageSurveyBrowser 进行哪些更改才能使其在不提供 htaccess 的情况下工作
最佳答案
我建议您需要多一点耐心才能使其发挥作用。但最好的办法是跟随这个tiny_mce条目到底。中间不要放弃。我犯了这个错误,并为此付出了几天的挫败感
http://www.tinymce.com/wiki.php/TinyMCE3x:How-to_implement_a_custom_file_browser
关于javascript - TinyMCEfolder_browser_callback 生成列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23661271/