<?php
function insert_image()
{
global $c, $l;
$str = <<<FIM
<html style="width: 598; height: 208">
<head>
<meta http-equiv="content-type" content="text/html; encoding=iso-8859-1" />
<title>{$l['image']['title']}</title>
<script type="text/javascript">
function __dlg_onclose() {
if (!document.all) {
opener.Dialog._return(null);
}
};
function __dlg_init() {
if (!document.all) {
// init dialogArguments, as IE gets it
window.dialogArguments = opener.Dialog._arguments;
window.sizeToContent();
window.sizeToContent(); // for reasons beyond understanding,
// only if we call it twice we get the
// correct size.
window.addEventListener("unload", __dlg_onclose, true);
// center on parent
var px1 = opener.screenX;
var px2 = opener.screenX + opener.outerWidth;
var py1 = opener.screenY;
var py2 = opener.screenY + opener.outerHeight;
var x = (px2 - px1 - window.outerWidth) / 2;
var y = (py2 - py1 - window.outerHeight) / 2;
window.moveTo(x, y);
var body = document.body;
window.innerHeight = body.offsetHeight;
window.innerWidth = body.offsetWidth;
} else {
var body = document.body;
window.dialogHeight = body.offsetHeight + 50 + "px";
window.dialogWidth = body.offsetWidth + "px";
}
};
// closes the dialog and passes the return info upper.
function __dlg_close(val) {
if (document.all) { // IE
window.returnValue = val;
} else {
opener.Dialog._return(val);
}
window.close();
};
var preview_window = null;
function Init() {
__dlg_init();
document.getElementById("f_url").focus();
xPreview();
};
function onOK() {
var required = {
"f_url": "{$l['image']['no_url']}",
"f_alt": "{$l['image']['no_alt']}"
};
for (var i in required) {
var el = document.getElementById(i);
if (!el.value) {
alert(required[i]);
el.focus();
return false;
}
}
// pass data back to the calling window
var fields = ["f_url", "f_alt", "f_align", "f_border",
"f_horiz", "f_vert"];
var param = new Object();
for (var i in fields) {
var id = fields[i];
var el = document.getElementById(id);
param[id] = el.value;
}
if (preview_window) {
preview_window.close();
}
__dlg_close(param);
return false;
};
function onCancel() {
if (preview_window) {
preview_window.close();
}
__dlg_close(null);
return false;
};
function xPreview()
{
var iframe = xGetElementById('icol3');
if (!iframe) {//initialize
var div = xGetElementById('col3');
if (!div) {
return false;
}
var iframe = document.createElement("iframe");
iframe.id = 'icol3';
iframe.style.width="200px";
iframe.style.height="180px";
iframe.style.border="none";
div.appendChild(iframe);
}
var doc = iframe.contentWindow.document;
if (doc) {
if (document.dav.f_url.value.search(/\.(png|jpe?g|gif)$/) > -1) {
var img='<img src="' + document.dav.f_url.value + '" alt="' + document.dav.f_alt.value + '" align="' + document.dav.f_align.value + '" border="' + document.dav.f_border.value + '" hspace="' + document.dav.f_horiz.value + '" vspace="' + document.dav.f_vert.value + '" />';
} else {
if (document.dav.f_url.value != '') {
alert("{$l['image']['invalid_url']}");
document.dav.f_url.value = "";
}
var img='';
}
doc.open();
var html = "<html>\\n";
html += "<head>\\n";
html += "<style>body { margin: 0px; padding: 0px; border: 1px solid #666666; background: #aaaaaa; width:100%; height:100% }</style>\\n";
html += "</head>\\n";
html += "<body>\\n"+img;
html += "</body>\\n";
html += "</html>";
doc.write(html);
doc.close();
}
}
</script>
<script type="text/javascript" src="{$c['base_url']}/dav.js"></script>
<link rel="stylesheet" href="/dav/styles/dav.css" type="text/css" />
<style name="cssdyn" id="cssdyn" type="text/css"> </style>
</head>
<body onload="Init()" style="width: 598px; height: 208px">
<div id="col12" style="top: 10px">
<h3>{$l['image']['title']}</h3>
<form action="" method="get" name="dav">
<table border="0" width="100%" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td class="first" width="25%">{$l['image']['url']}</td>
<td colspan="3"><input type="text" name="url" id="f_url" class="textinput" style="width:75%" onChange="xPreview()" /><input type="button" class="submitinput" style="width: 22%" name="preview" onclick="pin_todo.action = 'setTimeout(\'xPreview();\', 100);document.dav.f_url.value=';pin_list_files(this, 'php:uris', '')" value=" ... " /></td>
</tr>
<tr>
<td class="first" style="width: 7em;white-space: nowrap">{$l['image']['alt']}</td>
<td colspan="3"><input type="text" class="textinput" name="alt" id="f_alt" style="width:100%" onChange="xPreview()" /><br /><br /></td>
</tr>
<tr>
<td width="25%" class="first">{$l['image']['align']}</td>
<td width="25%"><select size="1" class="textinput" name="align" id="f_align" onChange="xPreview()">
<option value="" >{$l["image"]["align-undef"]}</option>
<option value="left" >{$l["image"]["align-left"]}</option>
<option value="right" >{$l["image"]["align-right"]}</option>
<option value="texttop" >{$l["image"]["align-texttop"]}</option>
<option value="absmiddle">{$l["image"]["align-absmiddle"]}</option>
<option value="baseline" >{$l["image"]["align-baseline"]}</option>
<option value="absbottom">{$l["image"]["align-absbottom"]}</option>
<option value="bottom" >{$l["image"]["align-bottom"]}</option>
<option value="middle" >{$l["image"]["align-middle"]}</option>
<option value="top" >{$l["image"]["align-top"]}</option>
</select>
</td>
<td width="25%">{$l['image']['border']}</td>
<td width="25%"><input type="text" class="textinput" name="border" id="f_border" size="5" onChange="xPreview()" /></td>
</tr>
<tr>
<td width="25%" class="first">{$l['image']['hspace']}</td>
<td width="25%"><input type="text" class="textinput" name="horiz" id="f_horiz" size="5" onChange="xPreview()" /></td>
<td width="25%">{$l['image']['vspace']}</td>
<td width="25%"><input type="text" class="textinput" name="vert" id="f_vert" size="5" onChange="xPreview()" /></td>
</tr>
<tr>
<td> </td>
<td colspan="3">
<div style="margin-top: 10px;">
<input type="button" class="submitinput" name="ok" onclick="return onOK();" value="{$l['buttons']['insert']}" />
<input type="button" class="submitinput" name="cancel" onclick="return onCancel();" value="{$l['buttons']['cancel']}" />
</div>
</td>
</tr>
</tbody>
</table>
</form>
</div>
<div id="col3" style="top:10px;left: 370px">
</div>
</body>
</html>
FIM;
return $str;
}
?>