| [ Index ] |
PHP Cross Reference of Moodle 1.9.3 [Build 15-Oct-2008] |
[Summary view] [Print] [Text view]
1 <?php // $Id: insert_image.php,v 1.9 2007/01/27 23:23:44 skodak Exp $ 2 3 require("../../../../config.php"); 4 5 $id = optional_param('id', SITEID, PARAM_INT); 6 7 require_login($id); 8 require_capability('moodle/course:managefiles', get_context_instance(CONTEXT_COURSE, $id)); 9 10 @header('Content-Type: text/html; charset=utf-8'); 11 12 $upload_max_filesize = get_max_upload_file_size($CFG->maxbytes); 13 14 ?> 15 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 16 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 17 <html> 18 <head> 19 <meta http-equiv="content-type" content="text/html; charset=utf-8" /> 20 <title><?php print_string("insertimage","editor");?></title> 21 <script type="text/javascript" src="popup.js"></script> 22 <script type="text/javascript"> 23 //<![CDATA[ 24 var preview_window = null; 25 26 function Init() { 27 __dlg_init(); 28 var param = window.dialogArguments; 29 if (param) { 30 var alt = param["f_url"].substring(param["f_url"].lastIndexOf('/') + 1); 31 document.getElementById("f_url").value = param["f_url"]; 32 document.getElementById("f_alt").value = param["f_alt"] ? param["f_alt"] : alt; 33 document.getElementById("f_border").value = parseInt(param["f_border"] || 0); 34 document.getElementById("f_align").value = param["f_align"]; 35 document.getElementById("f_vert").value = param["f_vert"] != -1 ? param["f_vert"] : 0; 36 document.getElementById("f_horiz").value = param["f_horiz"] != -1 ? param["f_horiz"] : 0; 37 document.getElementById("f_width").value = param["f_width"]; 38 document.getElementById("f_height").value = param["f_height"]; 39 window.ipreview.location.replace('preview.php?id='+ <?php print($id);?> +'&imageurl='+ param.f_url); 40 } 41 document.getElementById("f_url").focus(); 42 }; 43 44 function onOK() { 45 var required = { 46 "f_url": "<?php print_string("mustenterurl", "editor");?>", 47 "f_alt": "<?php print_string("pleaseenteralt", "editor");?>" 48 }; 49 for (var i in required) { 50 var el = document.getElementById(i); 51 if (!el.value) { 52 alert(required[i]); 53 el.focus(); 54 return false; 55 } 56 } 57 // pass data back to the calling window 58 var fields = ["f_url", "f_alt", "f_align", "f_border", 59 "f_horiz", "f_vert","f_width","f_height"]; 60 var param = new Object(); 61 for (var i in fields) { 62 var id = fields[i]; 63 var el = document.getElementById(id); 64 param[id] = el.value; 65 } 66 if (preview_window) { 67 preview_window.close(); 68 } 69 __dlg_close(param); 70 return false; 71 }; 72 73 function onCancel() { 74 if (preview_window) { 75 preview_window.close(); 76 } 77 __dlg_close(null); 78 return false; 79 }; 80 81 function onPreview() { 82 var f_url = document.getElementById("f_url"); 83 var url = f_url.value; 84 if (!url) { 85 alert("<?php print_string("enterurlfirst","editor");?>"); 86 f_url.focus(); 87 return false; 88 } 89 var img = new Image(); 90 img.src = url; 91 var win = null; 92 if (!document.all) { 93 win = window.open("about:blank", "ha_imgpreview", "toolbar=no,menubar=no,personalbar=no,innerWidth=100,innerHeight=100,scrollbars=no,resizable=yes"); 94 } else { 95 win = window.open("about:blank", "ha_imgpreview", "channelmode=no,directories=no,height=100,width=100,location=no,menubar=no,resizable=yes,scrollbars=no,toolbar=no"); 96 } 97 preview_window = win; 98 var doc = win.document; 99 var body = doc.body; 100 if (body) { 101 body.innerHTML = ""; 102 body.style.padding = "0px"; 103 body.style.margin = "0px"; 104 var el = doc.createElement("img"); 105 el.src = url; 106 107 var table = doc.createElement("table"); 108 body.appendChild(table); 109 table.style.width = "100%"; 110 table.style.height = "100%"; 111 var tbody = doc.createElement("tbody"); 112 table.appendChild(tbody); 113 var tr = doc.createElement("tr"); 114 tbody.appendChild(tr); 115 var td = doc.createElement("td"); 116 tr.appendChild(td); 117 td.style.textAlign = "center"; 118 119 td.appendChild(el); 120 win.resizeTo(el.offsetWidth + 30, el.offsetHeight + 30); 121 } 122 win.focus(); 123 return false; 124 }; 125 126 function checkvalue(elm,formname) { 127 var el = document.getElementById(elm); 128 if(!el.value) { 129 alert("Nothing to do!"); 130 el.focus(); 131 return false; 132 } 133 } 134 135 function submit_form(dothis) { 136 if(dothis == "delete") { 137 window.ibrowser.document.dirform.action.value = "delete"; 138 } 139 if(dothis == "move") { 140 window.ibrowser.document.dirform.action.value = "move"; 141 } 142 if(dothis == "zip") { 143 window.ibrowser.document.dirform.action.value = "zip"; 144 } 145 146 window.ibrowser.document.dirform.submit(); 147 return false; 148 } 149 150 //]]> 151 </script> 152 <style type="text/css"> 153 html, body { 154 margin: 2px; 155 background-color: rgb(212,208,200); 156 font-family: Tahoma, Verdana, sans-serif; 157 font-size: 11px; 158 } 159 .title { 160 background-color: #ddddff; 161 padding: 5px; 162 border-bottom: 1px solid black; 163 font-family: Tahoma, sans-serif; 164 font-weight: bold; 165 font-size: 14px; 166 color: black; 167 } 168 td, input, select, button { 169 font-family: Tahoma, Verdana, sans-serif; 170 font-size: 11px; 171 } 172 button { width: 70px; } 173 .space { padding: 2px; } 174 form { margin-bottom: 0px; margin-top: 0px; } 175 </style> 176 </head> 177 <body onload="Init()"> 178 <div class="title"><?php print_string("insertimage","editor");?></div> 179 <div class="space"></div> 180 <div class="space"></div> 181 <div class="space"></div> 182 <form action="" method="get" id="first"> 183 <table width="100%" border="0" cellspacing="0" cellpadding="0"> 184 <tr> 185 <td width="15%" align="right"><?php print_string("imageurl","editor");?>:</td> 186 <td width="60%"><input name="f_url" type="text" id="f_url" style="width: 100%;" /></td> 187 <td width="23%" align="center"> 188 <button name="btnOK" type="button" id="btnOK" onclick="return onOK();"><?php print_string("ok","editor") ?></button></td> 189 </tr> 190 <tr> 191 <td align="right"><?php print_string("alternatetext","editor");?>:</td> 192 <td><input name="f_alt" type="text" id="f_alt" style="width: 100%;" /></td> 193 <td align="center"> 194 <button name="btnCancel" type="button" id="btnCancel" onclick="return onCancel();"><?php print_string("cancel","editor") ?></button></td> 195 </tr> 196 </table> 197 <div class="space"></div> 198 <table width="100%" border="0" cellspacing="0" cellpadding="0"> 199 <tr> 200 <td width="32%" valign="top"> 201 <fieldset><legend><?php print_string("layout","editor");?></legend> 202 <div class="space"></div> 203 <table width="100%" border="0" cellspacing="0" cellpadding="0"> 204 <tr> 205 <td width="40%" align="right"><?php print_string("alignment","editor");?>:</td> 206 <td width="60%"> 207 <select size="1" name="f_align" id="f_align" 208 title="Positioning of this image"> 209 <option value="" ><?php print_string("notset","editor") ?></option> 210 <option value="left" ><?php print_string("left","editor") ?></option> 211 <option value="right" ><?php print_string("right","editor") ?></option> 212 <option value="texttop" ><?php print_string("texttop","editor") ?></option> 213 <option value="middle" ><?php print_string("middle","editor") ?></option> 214 <option value="baseline" selected="1" ><?php print_string("baseline","editor") ?></option> 215 <option value="absbottom" ><?php print_string("absbottom","editor") ?></option> 216 <option value="bottom" ><?php print_string("bottom","editor") ?></option> 217 <option value="middle" ><?php print_string("middle","editor") ?></option> 218 <option value="top" ><?php print_string("top","editor") ?></option> 219 </select></td> 220 </tr> 221 <tr> 222 <td width="40%" align="right"><?php print_string("borderthickness","editor") ?>:</td> 223 <td width="60%"> 224 <input type="text" id="f_border" name="f_border" size="5" /></td> 225 </tr> 226 </table><div class="space"></div> 227 </fieldset> </td> 228 <td width="34%" valign="top"> 229 <fieldset><legend><?php print_string("spacing","editor");?></legend> 230 <div class="space"></div> 231 <table width="100%" border="0" cellspacing="0" cellpadding="0"> 232 <tr> 233 <td width="40%" align="right"><?php print_string("horizontal","editor");?>: </td> 234 <td width="60%"> 235 <input name="f_horiz" type="text" id="f_horiz" size="5" /> 236 </td> 237 </tr> 238 <tr> 239 <td width="40%" align="right"><?php print_string("vertical","editor");?>:</td> 240 <td width="60%"> 241 <input name="f_vert" type="text" id="f_vert" size="5" /></td> 242 </tr> 243 </table><div class="space"></div></fieldset></td> 244 <td width="34%" valign="top"> 245 <fieldset><legend><?php print_string("size","editor");?></legend> 246 <div class="space"></div> 247 <table width="100%" border="0" cellspacing="0" cellpadding="0"> 248 <tr> 249 <td width="40%" align="right"><?php print_string("width","editor");?>:</td> 250 <td width="60%"> 251 <input name="f_width" type="text" id="f_width" size="5" /> 252 </td> 253 </tr> 254 <tr> 255 <td width="40%" align="right"><?php print_string("height","editor");?>:</td> 256 <td width="60%"> 257 <input name="f_height" type="text" id="f_height" size="5" /></td> 258 </tr> 259 </table><div class="space"></div> 260 </fieldset></td> 261 </tr> 262 </table></form> 263 <table width="100%" border="0" cellspacing="0" cellpadding="0"> 264 <tr> 265 <td width="55%" valign="top"><?php 266 print_string("filebrowser","editor"); 267 echo "<br />"; 268 echo "<iframe id=\"ibrowser\" name=\"ibrowser\" src=\"{$CFG->wwwroot}/lib/editor/htmlarea/coursefiles.php?usecheckboxes=1&id=$id\" style=\"width: 100%; height: 200px;\"></iframe>"; 269 ?> 270 </td> 271 <td width="45%" valign="top"><?php print_string("preview","editor");?>:<br /> 272 <iframe id="ipreview" name="ipreview" src="about:blank" style="width: 100%; height: 200px;"></iframe> 273 </td> 274 </tr> 275 </table> 276 <table width="100%" border="0" cellspacing="0" cellpadding="0"> 277 <tr> 278 <td width="55%"><div class="space"></div> 279 <?php if(has_capability('moodle/course:managefiles', get_context_instance(CONTEXT_COURSE, $id))) { ?> 280 <table border="0" cellpadding="2" cellspacing="0"> 281 <tr><td><?php print_string("selection","editor");?>: </td> 282 <td><form id="idelete"> 283 <input name="btnDelete" type="submit" id="btnDelete" value="<?php print_string("delete","editor");?>" onclick="return submit_form('delete');" /></form></td> 284 <td><form id="imove"> 285 <input name="btnMove" type="submit" id="btnMove" value="<?php print_string("move","editor");?>" onclick="return submit_form('move');" /></td> 286 <td><form id="izip"> 287 <input name="btnZip" type="submit" id="btnZip" value="<?php print_string("zip","editor");?>" onclick="return submit_form('zip');" /></form></td> 288 <td><form method="post" action="../coursefiles.php" target="ibrowser"> 289 <input type="hidden" name="id" value="<?php print($id);?>" /> 290 <input type="hidden" name="wdir" value="" /> 291 <input type="hidden" id="irename" name="file" value="" /> 292 <input type="hidden" name="action" value="rename" /> 293 <input type="hidden" name="sesskey" value="<?php p($USER->sesskey) ?>" /> 294 <input name="btnRename" type="submit" id="btnRename" value="<?php print_string("rename","editor");?>" /></form></td> 295 <tr></table> 296 <br /> 297 <?php 298 } else { 299 print ""; 300 } ?> 301 </td> 302 <td width="45%" rowspan="2" valign="top"><fieldset> 303 <legend><?php print_string("properties","editor");?></legend> 304 <div class="space"></div> 305 <div class="space"></div> 306 <?php print_string("size","editor");?>: 307 <input type="text" id="isize" name="isize" size="10" style="background: transparent; border: none;" /> 308 <?php print_string("type","editor");?>: <input type="text" id="itype" name="itype" size="10" style="background: transparent; border: none;" /> 309 <div class="space"></div> 310 <div class="space"></div> 311 </fieldset></td> 312 </tr> 313 <tr> 314 <td height="22"> 315 <form id="cfolder" action="../coursefiles.php" method="post" target="ibrowser"> 316 <input type="hidden" name="id" value="<?php print($id);?>" /> 317 <input type="hidden" name="wdir" value="" /> 318 <input type="hidden" name="action" value="mkdir" /> 319 <input type="hidden" name="sesskey" value="<?php p($USER->sesskey) ?>" /> 320 <input name="name" type="text" id="foldername" size="35" /> 321 <input name="btnCfolder" type="submit" id="btnCfolder" value="<?php print_string("createfolder","editor");?>" onclick="return checkvalue('foldername','cfolder');" /> 322 </form> 323 <div class="space"></div> 324 <form action="../coursefiles.php?id=<?php print($id);?>" method="post" enctype="multipart/form-data" target="ibrowser" id="uploader"> 325 <input type="hidden" name="MAX_FILE_SIZE" value="<?php print($upload_max_filesize);?>" /> 326 <input type="hidden" name="id" VALUE="<?php print($id);?>" /> 327 <input type="hidden" name="wdir" value="" /> 328 <input type="hidden" name="action" value="upload" /> 329 <input type="hidden" name="sesskey" value="<?php p($USER->sesskey) ?>" /> 330 <input type="file" name="userfile" id="userfile" size="35" /> 331 <input name="save" type="submit" id="save" onclick="return checkvalue('userfile','uploader');" value="<?php print_string("upload","editor");?>" /> 332 </form> 333 </td> 334 </tr> 335 </table> 336 <p> </p> 337 </body> 338 </html>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed Jan 14 11:33:29 2009 | Cross-referenced by PHPXref 0.7 |