2011-10-29 21 views
1

我需要將TinyMCE和圖像上傳按鈕對話框與我自己的web應用程序集成在一起 - 但我需要使用一些自定義變量將圖像上傳到我的PHP代碼中。 我的PHP調用與下面的激活碼tinyMCE.init:如何集成TinyMCE按鈕並通過變量傳遞

發起的PHP代碼(觸發編輯器)......

<?php 

$js=' 
tinyMCE.init({ 
    mode : "textareas", 
    theme : "advanced", 
    plugins : "spellchecker,advhr,table,addimg", 
    theme_advanced_buttons1 :  "cut,copy,paste,|,bold,italic,underline,|,justifyleft,justifycenter,justifyright,formatselect,zoom, blockquote,|,bullist,numlist,|,outdent,indent,|,undo,redo,|,link,unlink,anchor,addimg,|,code,preview,|,forecolor,backcolor", 
    theme_advanced_buttons2 : "tablecontrols,|,spellchecker,advhr,removeformat,|,sub,sup,|,charmap,visualaid", 
    theme_advanced_buttons3 : "",  
    theme_advanced_toolbar_location : "top", 
    theme_advanced_toolbar_align : "left", 
    theme_advanced_statusbar_location : "bottom", 
    theme_advanced_resizing : true, 
    content_css : "'.config::siteurl.'/css/myStyle.css" 
}); 

....這將激活編輯器自定義按鈕「 addimg「;當我點擊addimg自定義按鈕時,它按照預期觸發自定義dialog.htm;但我需要的是,這dialog.htm包含我的變量,這樣當表單發送則接收PHP可以利用它們

dialog.htm形式...

. 
. 
. 
<form id='file_upload_form' name='file_upload_form' enctype='multipart/form-data'  action='myUploader.php' method='POST'> 
    <input type='text' name='MySpecialId’ value='xxxx'> 
    <table width=100%> 
    <tr valign=top> 
    <td width=100>Please choose a file: </td> 
    <td align=left> 
     <input style='width: 100%;' id='myFile' name='myFile' type='file'> 
    </td> 
    </tr> 
</table> 
</form> 
. 
. 

的問題是如何能我從原始PHP調用者獲得一個值到dialog.htm中,以便在上面的表單中設置MySpecialId值?我想我可以使用dialog.js的AddImgDialog.init()js方法來設置表單,但再次如何讓TinyMCE工具欄通過調用PHP中的值傳遞給自定義按鈕dialog.js?

例如

var AddImgDialog = { 
    init : function() { 
    alert('My passed through value is xxxxx'); 
}, 
. 
. 

任何提示? 感謝 TD

回答

4

您可以設置在tinyMCE.init(),例如你的變量:

tinyMCE.init({ 
    mode : "textareas", 
    /*more settings*/ 
    myVariable:12345 
}); 

這個變量將通過在dialog.htm訪問tinyMCE.settings.myVariable
要使輸入更容易可達給它一個ID,例如myInputID。 現在您可以設置該值(在輸入之後的某處放置以下說明)

document.getElementById('myInputID').value=tinyMCE.settings.myVariable;