source: branches/1.2/workflow/js/htmlarea/plugins/UploadImage/popups/insert_image.php @ 1349

Revision 1349, 17.1 KB checked in by niltonneto, 15 years ago (diff)

Ticket #561 - Inclusão do módulo Workflow faltante nessa versão.

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