[ Index ] |
|
Code source de eGroupWare 1.2.106-2 |
1 <?php 2 /*********************************************************************** 3 ** Title.........: Image Manager for HTMLArea 3.0 Alpha, PHP Version 4 ** Version.......: 1.01 5 ** Author........: Xiang Wei ZHUO <wei@zhuo.org> 6 ** Filename......: insert_image.php 7 ** Last changed..: 8 Mar 2003 8 ** Notes.........: Configuration in config.inc.php 9 10 - FIXME Only compatible with IE 5.5+ 11 12 ***********************************************************************/ 13 14 /* $id */ 15 16 include 'ImageManager/config.inc.php'; 17 $no_dir = false; 18 if(!is_dir($BASE_DIR)) { 19 $no_dir = true; 20 } 21 22 // _debug_array($_GET); 23 // die(); 24 function dirs($dir,$abs_path) 25 { 26 $d = dir($dir); 27 $dirs = array(); 28 while (false !== ($entry = $d->read())) 29 { 30 if(is_dir($dir.'/'.$entry) && substr($entry,0,1) != '.') 31 { 32 $path['path'] = $dir.'/'.$entry; 33 $path['name'] = $entry; 34 $dirs[$entry] = $path; 35 } 36 } 37 $d->close(); 38 39 ksort($dirs); 40 for($i=0; $i<count($dirs); $i++) 41 { 42 $name = key($dirs); 43 $current_dir = $abs_path.'/'.$dirs[$name]['name']; 44 echo "<option value=\"$current_dir\">$current_dir</option>\n"; 45 dirs($dirs[$name]['path'],$current_dir); 46 next($dirs); 47 } 48 } 49 50 51 52 53 ?> 54 <html style="width: 580; height: 440;"> 55 <head> 56 <title>Insert Image</title> 57 <script type="text/javascript" src="popup.js"></script> 58 <script type="text/javascript" src="../../../dialog.js"></script> 59 <script type="text/javascript"> 60 var preview_window = null; 61 62 function Init() { 63 64 __dlg_init(); 65 var doc = MM_findObj("f_url"); 66 67 if(doc != null) { 68 doc.focus(); 69 } 70 }; 71 72 function onOK() { 73 var required = { 74 "f_url": "You must enter the URL", 75 "f_alt": "Please enter the alternate text" 76 }; 77 for (var i in required) { 78 var el = MM_findObj(i); 79 if (!el.value) { 80 alert(required[i]); 81 el.focus(); 82 return false; 83 } 84 } 85 // pass data back to the calling window 86 var fields = ["f_url", "f_alt", "f_align", "f_border", 87 "f_horiz", "f_vert", "f_width", "f_height"]; 88 var param = new Object(); 89 for (var i in fields) { 90 var id = fields[i]; 91 var el = MM_findObj(id); 92 if(id == "f_url") 93 // param[id] = "<? echo 'http://'.$_SERVER['SERVER_NAME']; ?>" + el.value; 94 param[id] = "" + el.value; 95 else 96 param[id] = el.value; 97 } 98 if (preview_window) { 99 preview_window.close(); 100 } 101 //alert(param); 102 __dlg_close(param); 103 return false; 104 }; 105 106 function onCancel() { 107 if (preview_window) { 108 preview_window.close(); 109 } 110 __dlg_close(null); 111 return false; 112 }; 113 114 </script> 115 <style type="text/css"> 116 html, body { 117 background: ButtonFace; 118 color: ButtonText; 119 font: 11px Tahoma,Verdana,sans-serif; 120 margin: 0px; 121 padding: 0px; 122 } 123 body { padding: 5px; } 124 table { 125 font: 11px Tahoma,Verdana,sans-serif; 126 } 127 form p { 128 margin-top: 5px; 129 margin-bottom: 5px; 130 } 131 .fl { width: 9em; float: left; padding: 2px 5px; text-align: right; } 132 .fr { width: 6em; float: left; padding: 2px 5px; text-align: right; } 133 fieldset { padding: 0px 10px 5px 5px; } 134 select, input, button { font: 11px Tahoma,Verdana,sans-serif; } 135 button { width: 70px; } 136 .space { padding: 2px; } 137 138 .title { background: #ddf; color: #000; font-weight: bold; font-size: 120%; padding: 3px 10px; margin-bottom: 10px; 139 border-bottom: 1px solid black; letter-spacing: 2px; 140 } 141 form { padding: 0px; margin: 0px; } 142 </style> 143 <style type="text/css"> 144 <!-- 145 .buttonHover { 146 border: 1px solid; 147 border-color: ButtonHighlight ButtonShadow ButtonShadow ButtonHighlight; 148 cursor: hand; 149 } 150 .buttonOut 151 { 152 border: 1px solid ButtonFace; 153 } 154 155 .separator { 156 position: relative; 157 margin: 3px; 158 border-left: 1px solid ButtonShadow; 159 border-right: 1px solid ButtonHighlight; 160 width: 0px; 161 height: 16px; 162 padding: 0px; 163 } 164 .manager 165 { 166 } 167 .statusLayer 168 { 169 background:#FFFFFF; 170 border: 1px solid #CCCCCC; 171 } 172 .statusText { 173 font-family: Verdana, Arial, Helvetica, sans-serif; 174 font-size: 15px; 175 font-weight: bold; 176 color: #6699CC; 177 text-decoration: none; 178 } 179 --> 180 </style> 181 <script language="JavaScript" type="text/JavaScript"> 182 <!-- 183 function pviiClassNew(obj, new_style) { //v2.6 by PVII 184 obj.className=new_style; 185 } 186 function goUpDir() 187 { 188 var selection = document.forms[0].dirPath; 189 var dir = selection.options[selection.selectedIndex].value; 190 if(dir != '/') 191 { 192 imgManager.goUp(); 193 changeLoadingStatus('load'); 194 } 195 196 } 197 198 function updateDir(selection) 199 { 200 var newDir = selection.options[selection.selectedIndex].value; 201 imgManager.changeDir(newDir); 202 changeLoadingStatus('load'); 203 } 204 205 function newFolder() 206 { 207 var selection = document.forms[0].dirPath; 208 var dir = selection.options[selection.selectedIndex].value; 209 Dialog("ImageManager/newFolder.html", function(param) { 210 if (!param) { // user must have pressed Cancel 211 return false; 212 } 213 else 214 { 215 var folder = param['f_foldername']; 216 if (folder && folder != '') { 217 imgManager.newFolder(dir,folder); 218 } 219 } 220 }, null); 221 } 222 223 function toggleConstrains(constrains) 224 { 225 if(constrains.checked) 226 { 227 document.locked_img.src = "ImageManager/locked.gif"; 228 checkConstrains('width') 229 } 230 else 231 { 232 document.locked_img.src = "ImageManager/unlocked.gif"; 233 } 234 } 235 236 function checkConstrains(changed) 237 { 238 //alert(document.form1.constrain_prop); 239 var constrained = document.form1.constrain_prop.checked; 240 241 if(constrained) 242 { 243 var orginal_width = parseInt(document.form1.orginal_width.value); 244 var orginal_height = parseInt(document.form1.orginal_height.value); 245 246 var width = parseInt(document.form1.f_width.value); 247 var height = parseInt(document.form1.f_height.value); 248 249 if(orginal_width > 0 && orginal_height > 0) 250 { 251 if(changed == 'width' && width > 0) { 252 document.form1.f_height.value = parseInt((width/orginal_width)*orginal_height); 253 } 254 255 if(changed == 'height' && height > 0) { 256 document.form1.f_width.value = parseInt((height/orginal_height)*orginal_width); 257 } 258 } 259 260 } 261 262 } 263 264 function MM_findObj(n, d) { //v4.01 265 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { 266 d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} 267 if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n]; 268 for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); 269 if(!x && d.getElementById) x=d.getElementById(n); return x; 270 } 271 272 function P7_Snap() { //v2.62 by PVII 273 var x,y,ox,bx,oy,p,tx,a,b,k,d,da,e,el,args=P7_Snap.arguments;a=parseInt(a); 274 for (k=0; k<(args.length-3); k+=4) 275 if ((g=MM_findObj(args[k]))!=null) { 276 el=eval(MM_findObj(args[k+1])); 277 a=parseInt(args[k+2]);b=parseInt(args[k+3]); 278 x=0;y=0;ox=0;oy=0;p="";tx=1;da="document.all['"+args[k]+"']"; 279 if(document.getElementById) { 280 d="document.getElementsByName('"+args[k]+"')[0]"; 281 if(!eval(d)) {d="document.getElementById('"+args[k]+"')";if(!eval(d)) {d=da;}} 282 }else if(document.all) {d=da;} 283 if (document.all || document.getElementById) { 284 while (tx==1) {p+=".offsetParent"; 285 if(eval(d+p)) {x+=parseInt(eval(d+p+".offsetLeft"));y+=parseInt(eval(d+p+".offsetTop")); 286 }else{tx=0;}} 287 ox=parseInt(g.offsetLeft);oy=parseInt(g.offsetTop);var tw=x+ox+y+oy; 288 if(tw==0 || (navigator.appVersion.indexOf("MSIE 4")>-1 && navigator.appVersion.indexOf("Mac")>-1)) { 289 ox=0;oy=0;if(g.style.left){x=parseInt(g.style.left);y=parseInt(g.style.top); 290 }else{var w1=parseInt(el.style.width);bx=(a<0)?-5-w1:-10; 291 a=(Math.abs(a)<1000)?0:a;b=(Math.abs(b)<1000)?0:b; 292 x=document.body.scrollLeft + event.clientX + bx; 293 y=document.body.scrollTop + event.clientY;}} 294 }else if (document.layers) {x=g.x;y=g.y;var q0=document.layers,dd=""; 295 for(var s=0;s<q0.length;s++) {dd='document.'+q0[s].name; 296 if(eval(dd+'.document.'+args[k])) {x+=eval(dd+'.left');y+=eval(dd+'.top');break;}}} 297 if(el) {e=(document.layers)?el:el.style; 298 var xx=parseInt(x+ox+a),yy=parseInt(y+oy+b); 299 if(navigator.appName=="Netscape" && parseInt(navigator.appVersion)>4){xx+="px";yy+="px";} 300 if(navigator.appVersion.indexOf("MSIE 5")>-1 && navigator.appVersion.indexOf("Mac")>-1){ 301 xx+=parseInt(document.body.leftMargin);yy+=parseInt(document.body.topMargin); 302 xx+="px";yy+="px";}e.left=xx;e.top=yy;}} 303 } 304 305 function MM_showHideLayers() { //v6.0 306 var i,p,v,obj,args=MM_showHideLayers.arguments; 307 for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2]; 308 if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; } 309 obj.visibility=v; } 310 } 311 312 function changeLoadingStatus(state) 313 { 314 var statusText = null; 315 if(state == 'load') { 316 statusText = 'Loading Images'; 317 } 318 else if(state == 'upload') { 319 statusText = 'Uploading Files'; 320 } 321 if(statusText != null) { 322 var obj = MM_findObj('loadingStatus'); 323 if (obj != null && obj.innerHTML != null) 324 obj.innerHTML = statusText; 325 MM_showHideLayers('loading','','show') 326 } 327 } 328 329 function refresh() 330 { 331 var selection = document.forms[0].dirPath; 332 updateDir(selection); 333 } 334 335 336 //--> 337 </script> 338 </head> 339 <body onload="Init(); P7_Snap('dirPath','loading',120,70);"> 340 <div class="title">Insert Image</div> 341 <form action="ImageManager/images.php" name="form1" method="post" target="imgManager" enctype="multipart/form-data"> 342 <div id="loading" style="position:absolute; left:200px; top:130px; width:184px; height:48px; z-index:1" class="statusLayer"> 343 <table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0"> 344 <tr> 345 <td><div align="center"><span id="loadingStatus" class="statusText">Loading Images</span><img src="ImageManager/dots.gif" width="22" height="12"></div></td> 346 </tr> 347 </table> 348 </div> 349 <table width="100%" border="0" align="center" cellspacing="2" cellpadding="2"> 350 <tr> 351 <td align="center"> <fieldset> 352 <legend>Image Manager</legend> 353 <table width="99%" align="center" border="0" cellspacing="2" cellpadding="2"> 354 <tr> 355 <td><table border="0" cellspacing="1" cellpadding="3"> 356 <tr> 357 <td>Directory</td> 358 <td> 359 <select name="dirPath" id="dirPath" style="width:30em" onChange="updateDir(this)"> 360 <option value="/">/</option> 361 <?php 362 if($no_dir == false) 363 { 364 dirs($BASE_DIR,''); 365 } 366 ?> 367 </select> 368 </td> 369 <td class="buttonOut" onMouseOver="pviiClassNew(this,'buttonHover')" onMouseOut="pviiClassNew(this,'buttonOut')"> 370 <a href="#" onClick="javascript:goUpDir();"><img src="ImageManager/btnFolderUp.gif" width="15" height="15" border="0" alt="Up"></a></td> 371 <? if ($SAFE_MODE == false) { ?> 372 <td><div class="separator"></div></td> 373 <td class="buttonOut" onMouseOver="pviiClassNew(this,'buttonHover')" onMouseOut="pviiClassNew(this,'buttonOut')"> 374 <a href="#" onClick="javascript:newFolder();"><img src="ImageManager/btnFolderNew.gif" width="15" height="15" border="0" alt="New Folder"></a></td> 375 <? } ?> 376 </tr> 377 </table></td> 378 </tr> 379 <tr> 380 <td align="center" bgcolor="white"><div name="manager" class="manager"> 381 <iframe src="ImageManager/images.php" name="imgManager" id="imgManager" width="520" height="150" marginwidth="0" marginheight="0" align="top" scrolling="auto" frameborder="0" hspace="0" vspace="0" background="white"></iframe> 382 </div> 383 </td> 384 </tr> 385 </table> 386 </fieldset></td> 387 </tr> 388 <tr> 389 <td><table border="0" align="center" cellpadding="2" cellspacing="2"> 390 <tr> 391 <td nowrap><div align="right">Image File </div></td> 392 <td><input name="url" id="f_url" type="text" style="width:20em" size="30"></td> 393 <td rowspan="3"> </td> 394 <td><div align="right">Width </div></td> 395 <td><input name="width" id="f_width" type="text" size="5" style="width:4em" onChange="javascript:checkConstrains('width');"></td> 396 <td rowspan="2"><img src="ImageManager/locked.gif" name="locked_img" width="25" height="32" id="locked_img" alt="Locked"></td> 397 <td rowspan="3"> </td> 398 <td><div align="right">V Space</div></td> 399 <td><input name="vert" id="f_vert" type="text" size="5" style="width:4em"></td> 400 </tr> 401 <tr> 402 <td nowrap><div align="right">Alt </div></td> 403 <td><input type="text" style="width:20em" name="alt" id="f_alt"></td> 404 <td><div align="right">Height </div></td> 405 <td><input name="height" id="f_height" type="text" size="5" style="width:4em" onChange="javascript:checkConstrains('height');"></td> 406 <td><div align="right">H Space</div></td> 407 <td><input name="horiz" id="f_horiz" type="text" size="5" style="width:4em"></td> 408 </tr> 409 <tr> 410 <td><div align="right">Upload </div></td> 411 <td><input type="file" name="upload" id="upload"> 412 <input type="submit" style="width:5em" value="Upload" onClick="javascript:changeLoadingStatus('upload');" /> 413 </td> 414 <td><div align="right">Align</div></td> 415 <td colspan="2"><select name="align" ID="f_align" style="width:7em"> 416 <OPTION id="optNotSet" value=""> Not set </OPTION> 417 <OPTION id="optLeft" value="left"> Left </OPTION> 418 <OPTION id="optRight" value="right"> Right </OPTION> 419 <OPTION id="optTexttop" value="textTop"> Texttop </OPTION> 420 <OPTION id="optAbsMiddle" value="absMiddle"> Absmiddle </OPTION> 421 <OPTION id="optBaseline" value="baseline" SELECTED> Baseline </OPTION> 422 <OPTION id="optAbsBottom" value="absBottom"> Absbottom </OPTION> 423 <OPTION id="optBottom" value="bottom"> Bottom </OPTION> 424 <OPTION id="optMiddle" value="middle"> Middle </OPTION> 425 <OPTION id="optTop" value="top"> Top </OPTION> 426 </select></td> 427 <td><div align="right">Border</div></td> 428 <td><input name="border" id="f_border" type="text" size="5" style="width:4em"></td> 429 </tr> 430 <tr> 431 <td colspan="3"> </td> 432 <td><div align="right"> 433 <input type="hidden" name="orginal_width" id="orginal_width"> 434 <input type="hidden" name="orginal_height" id="orginal_height"> 435 <input type="checkbox" name="constrain_prop" id="constrain_prop" checked onClick="javascript:toggleConstrains(this);"> 436 </div></td> 437 <td colspan="5">Constrain Proportions</td> 438 </tr> 439 </table> 440 441 </td> 442 </tr> 443 <tr> 444 <td><div style="text-align: right;"> 445 <hr /> 446 <button type="button" name="ok" onclick="return refresh();">Refresh</button> 447 <button type="button" name="ok" onclick="return onOK();">OK</button> 448 <button type="button" name="cancel" onclick="return onCancel();">Cancel</button> 449 </div></td> 450 </tr> 451 </table> 452 </form> 453 </body> 454 </html>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 17:20:01 2007 | par Balluche grâce à PHPXref 0.7 |