| 1 |
<?php
|
| 2 |
function phptemplate_tinymce_theme($init, $textarea_name, $theme_name, $is_running) {
|
| 3 |
static $access, $integrated;
|
| 4 |
|
| 5 |
if (!isset($access)) {
|
| 6 |
$access = function_exists('imce_access') && imce_access();
|
| 7 |
}
|
| 8 |
|
| 9 |
$init = theme_tinymce_theme($init, $textarea_name, $theme_name, $is_running);
|
| 10 |
|
| 11 |
if ($init && $access) {
|
| 12 |
$init['file_browser_callback'] = 'imceImageBrowser';
|
| 13 |
if (!isset($integrated)) {
|
| 14 |
$integrated = TRUE;
|
| 15 |
drupal_add_js("
|
| 16 |
function imceImageBrowser(field_name, url, type, win) {
|
| 17 |
tinyOpenerWin = win, tinyTargetField = field_name;
|
| 18 |
if (typeof tinyImceWin == 'undefined' || tinyImceWin.closed) {
|
| 19 |
tinyImceWin = window.open(Drupal.settings.basePath +'?q=imce', '', 'width=760,height=560,resizable=1');
|
| 20 |
tinyImceWin['imceOnLoad'] = function () {
|
| 21 |
tinyImceWin.imce.highlight(url.substr(url.lastIndexOf('/')+1));
|
| 22 |
tinyImceWin.imce.setSendTo(Drupal.t('Send to @app', {'@app': 'TinyMCE'}), function(file) {
|
| 23 |
window.focus();
|
| 24 |
tinyOpenerWin.focus();
|
| 25 |
$('#width', tinyOpenerWin.document).val(file.width);
|
| 26 |
$('#height', tinyOpenerWin.document).val(file.height);
|
| 27 |
$('#'+ tinyTargetField, tinyOpenerWin.document).val(file.url).focus();
|
| 28 |
});
|
| 29 |
}
|
| 30 |
}
|
| 31 |
else {
|
| 32 |
tinyImceWin.imce.highlight(url.substr(url.lastIndexOf('/')+1));
|
| 33 |
}
|
| 34 |
tinyImceWin.focus();
|
| 35 |
}
|
| 36 |
", 'inline');
|
| 37 |
}
|
| 38 |
}
|
| 39 |
|
| 40 |
return $init;
|
| 41 |
}
|
| 42 |
?>
|