InsertImage.aspx
上传用户:simon2hong
上传日期:2021-11-18
资源大小:16746k
文件大小:18k
源码类别:

OA系统

开发平台:

C#

  1. <%@ Page Language="C#" Inherits="CuteEditor.Dialogs.FileBrowserPage" %>
  2. <%@ Register TagPrefix="CE" Assembly="CuteEditor" Namespace="CuteEditor" %>
  3. <script runat="server">
  4. override protected void OnInit(EventArgs args)
  5. {
  6. if(Context.Request.QueryString["IsFrame"]==null)
  7. {
  8. string FrameSrc="InsertImage.Aspx?IsFrame=1&"+Request.ServerVariables["QUERY_STRING"];
  9. CuteEditor.CEU.WriteDialogOuterFrame(Context,"[[InsertImage]]",FrameSrc);
  10. Context.Response.End();
  11. }
  12. base.OnInit(args);
  13. }
  14. </script>
  15. <%
  16. string QUERY_STRING=Request.ServerVariables["QUERY_STRING"];
  17. %>
  18. <html xmlns="http://www.w3.org/1999/xhtml">
  19. <head>
  20. <meta http-equiv="Page-Enter" content="blendTrans(Duration=0.1)" />
  21. <meta http-equiv="Page-Exit" content="blendTrans(Duration=0.1)" />
  22. <meta http-equiv="Cache-Control" content="no-cache" />
  23. <meta http-equiv="Pragma" content="no-cache" />
  24. <title>Insert Image</title>
  25. <meta http-equiv="EXPIRES" content="0" />
  26. <link href="Load.ashx?type=style&file=dialog.css" type="text/css" rel="stylesheet" />
  27. <!--[if IE]>
  28. <link href="Load.ashx?type=style&file=IE.css" type="text/css" rel="stylesheet" />
  29. <![endif]-->
  30. <script type="text/javascript" src="Load.ashx?type=dialogscript&file=DialogHead.js"></script>
  31. <script type="text/javascript">
  32. var OxO9fb6=[]; function PostBackAction(){ <%=Page.ClientScript.GetPostBackEventReference(hiddenAction,"")%> ;}  ;
  33. </script>
  34. <style type="text/css">
  35. .row { HEIGHT: 22px }
  36. .cb { VERTICAL-ALIGN: middle }
  37. .itemimg { VERTICAL-ALIGN: middle }
  38. .editimg { VERTICAL-ALIGN: middle }
  39. .cell1 { VERTICAL-ALIGN: middle }
  40. .cell2 { VERTICAL-ALIGN: middle }
  41. .cell3 { PADDING-RIGHT: 4px; VERTICAL-ALIGN: middle; TEXT-ALIGN: right }
  42. .cb { }
  43. </style>
  44. </head>
  45. <body>
  46. <form runat="server" enctype="multipart/form-data" id="Form1">
  47. <!-- start hidden -->
  48. <input type="hidden" runat="server" id="hiddenDirectory" name="hiddenDirectory" />
  49. <input type="hidden" runat="server" id="hiddenFile" name="hiddenFile" /> 
  50. <input type="hidden" runat="server" enableviewstate="false" id="hiddenAlert" name="hiddenAlert" />
  51. <input type="hidden" runat="server" enableviewstate="false" id="hiddenAction" onserverchange="hiddenAction_ServerChange" name="hiddenAction" /> 
  52. <input type="hidden" runat="server" enableviewstate="false" id="hiddenActionData" name="hiddenActionData" />
  53. <!-- end hidden -->
  54. <table border="0" cellspacing="2" cellpadding="0" width="100%">
  55. <tr>
  56. <td style="width:20">
  57. <asp:Image id="Image1" Runat="server" ImageUrl="../Load.ashx?type=image&file=openfolder.gif"></asp:Image>
  58. </td>
  59. <td style="width:240" class="normal">
  60. <asp:Label Runat="server" id="FolderDescription"></asp:Label>
  61. </td>
  62. <td>
  63. <asp:ImageButton id="CreateDir" BorderWidth="1" Runat="server" AlternateText="[[Createdirectory]]" ImageUrl="../Load.ashx?type=image&file=newfolder.gif"
  64. onMouseOver="CuteEditor_ColorPicker_ButtonOver(this);" Visible="true" OnClick="CreateDir_Click" />
  65. <asp:ImageButton id="Copy" BorderWidth="1" Runat="server" AlternateText="[[Copyfiles]]" ImageUrl="../Load.ashx?type=image&file=Copy.gif"
  66. onMouseOver="CuteEditor_ColorPicker_ButtonOver(this);" Visible="true" OnClick="Copy_Click" />
  67. <asp:ImageButton id="Move" BorderWidth="1" Runat="server" AlternateText="[[Movefiles]]" ImageUrl="../Load.ashx?type=image&file=move.gif"
  68. onMouseOver="CuteEditor_ColorPicker_ButtonOver(this);" Visible="true" OnClick="Move_Click" />
  69. <img src="../Load.ashx?type=image&file=zoom_in.gif" onclick="Zoom_In();" alt="[[ZoomIn]]"
  70. class="dialogButton" onmouseover="CuteEditor_ColorPicker_ButtonOver(this);" />
  71. <img src="../Load.ashx?type=image&file=zoom_out.gif" onclick="Zoom_Out();" alt="[[ZoomOut]]"
  72. class="dialogButton" onmouseover="CuteEditor_ColorPicker_ButtonOver(this);" />
  73. <img src="../Load.ashx?type=image&file=bestfit.gif" onclick="BestFit();" alt="[[BestFit]]"
  74. class="dialogButton" onmouseover="CuteEditor_ColorPicker_ButtonOver(this);" />
  75. <img src="../Load.ashx?type=image&file=Actualsize.gif" onclick="Actualsize();" alt="[[ActualSize]]"
  76. class="dialogButton" onmouseover="CuteEditor_ColorPicker_ButtonOver(this);" />
  77. <img src="../Load.ashx?type=image&file=resize.gif" id="img_AutoThumbnail" onclick="AutoThumbnail();"
  78. alt="[[AutoThumbnail]]" class="dialogButton" onmouseover="CuteEditor_ColorPicker_ButtonOver(this);" />
  79. <% if(secset.AllowModify) {%>
  80. <img class="dialogButton" onmouseover="CuteEditor_ColorPicker_ButtonOver(this);" id="img_ImageEditor"
  81. src="../Load.ashx?type=image&file=imageeditor.gif" onclick="ImageEditor();" alt="[[ImageEditor]]" />
  82. <%
  83. }
  84. else
  85. {
  86. %>
  87. <img class="CuteEditorButtonDisabled" onmouseover="CuteEditor_ColorPicker_ButtonOver(this);"
  88. src="../Load.ashx?type=image&file=imageeditor.gif" alt="[[ImageEditor]]" />
  89. <%
  90. }
  91. %>
  92. </td>
  93. </tr>
  94. </table>
  95. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  96. <tr>
  97. <td valign="top" style="white-space:nowrap; width:280">
  98. <div style="BORDER: 1.5pt inset;  VERTICAL-ALIGN: middle; OVERFLOW: auto; WIDTH: 280; HEIGHT: 250px; Padding:0; BACKGROUND-COLOR: white">
  99. <asp:Table id="FoldersAndFiles" Runat="server" CellSpacing="1" CellPadding="0" Width="100%"
  100. CssClass="sortable">
  101. <asp:TableRow BackColor="#f0f0f0">
  102. <asp:TableHeaderCell Width="16px">
  103. <asp:ImageButton id="Delete" Runat="server" AlternateText="[[Deletefiles]]" onMouseOver="CuteEditor_ColorPicker_ButtonOver(this);"
  104. ImageUrl="../Load.ashx?type=image&file=s_cut.gif" Visible="true" OnClick="Delete_Click" />
  105. </asp:TableHeaderCell>
  106. <asp:TableHeaderCell Width="16px">
  107. <asp:ImageButton id="DoRefresh" Runat="server" AlternateText="[[Refresh]]" ImageUrl="../Load.ashx?type=image&file=s_refresh.gif"
  108. onMouseOver="CuteEditor_ColorPicker_ButtonOver(this);" Visible="true" OnClick="DoRefresh_Click" />
  109. </asp:TableHeaderCell>
  110. <asp:TableHeaderCell id="name_Cell" Wrap="True" Width="145px" CssClass="filelistHeadCol" Font-Bold="False">[[Name]]</asp:TableHeaderCell>
  111. <asp:TableHeaderCell id="size_Cell" Width="62px" CssClass="filelistHeadCol" Font-Bold="False">[[Count]]/[[Size]]</asp:TableHeaderCell>
  112. <asp:TableHeaderCell id="op_Cell" Width="16px">&nbsp;</asp:TableHeaderCell>
  113. <asp:TableHeaderCell id="op_space" Width="1px"></asp:TableHeaderCell>
  114. </asp:TableRow>
  115. </asp:Table>
  116. </div>
  117. </td>
  118. <td valign="top" style="white-space:nowrap; width:326">
  119. <div style="border:1.5pt inset; Padding:0; vertical-align: top; overflow: auto; width:100%; HEIGHT: 250px; BACKGROUND-COLOR: white;">
  120. <div id="divpreview" style="BACKGROUND-COLOR: white; height:100%;width:100%">
  121. <img id="img_demo" alt="" src="../Load.ashx?type=image&file=1x1.gif" />
  122. </div>
  123. </div>
  124. </td>
  125. </tr>
  126. <tr>
  127. <td colspan="2" style="height:2">
  128. </td>
  129. </tr>
  130. </table>
  131. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  132. <tr>
  133. <td valign="top">
  134. <fieldset>
  135. <legend>[[Layout]]</legend>
  136. <table border="0" cellpadding="2" cellspacing="0" width="100%">
  137. <tr>
  138. <td style="width:72;white-space:nowrap">[[Alignment]]:</td>
  139. <td style="text-align:left">
  140. <select name="ImgAlign" style="WIDTH : 80px" id="Align" onchange="do_preview()" onpropertychange="do_preview()">
  141. <option id="optNotSet" selected="selected" value="">[[Notset]]</option>
  142. <option id="optLeft" value="left">[[Left]]</option>
  143. <option id="optRight" value="right">[[Right]]</option>
  144. <option id="optTexttop" value="textTop">[[Texttop]]</option>
  145. <option id="optAbsMiddle" value="absMiddle">[[Absmiddle]]</option>
  146. <option id="optBaseline" value="baseline">[[Baseline]]</option>
  147. <option id="optAbsBottom" value="absBottom">[[Absbottom]]</option>
  148. <option id="optBottom" value="bottom">[[Bottom]]</option>
  149. <option id="optMiddle" value="middle">[[Middle]]</option>
  150. <option id="optTop" value="top">[[Top]]</option>
  151. </select>
  152. </td>
  153. </tr>
  154. <tr>
  155. <td>[[Bordersize]]:</td>
  156. <td style="text-align:left">
  157. <input type="text" size="2" name="Border" onchange="do_preview()" onpropertychange="do_preview()"
  158. onkeypress="return CancelEventIfNotDigit()" style="WIDTH : 80px" id="Border" />
  159. </td>
  160. </tr>
  161. <tr>
  162. <td>[[Bordercolor]]:</td>
  163. <td style="text-align:left">
  164. <input type="text" id="bordercolor" name="bordercolor" size="7" style='WIDTH:57px;behavior:url(Load.ashx?type=htc&file=ColorPicker.htc)'
  165. oncolorchange="bordercolor.value=this.selectedColor; bordercolor.style.backgroundColor=this.selectedColor;bordercolor_Preview.style.backgroundColor=this.selectedColor" />
  166. <img alt="[[Preview]]" src="../Load.ashx?type=image&file=colorpicker.gif" id="bordercolor_Preview"
  167. style='behavior:url(Load.ashx?type=htc&file=ColorPicker.htc); vertical-align:inherit' oncolorchange="bordercolor.value=this.selectedColor; bordercolor.style.backgroundColor=this.selectedColor;bordercolor_Preview.style.backgroundColor=this.selectedColor" />
  168. </td>
  169. </tr>
  170. <tr>
  171. <td colspan="2">
  172. <table border="0" cellpadding="0" cellspacing="0" class="normal">
  173. <tr>
  174. <td style="width:100; white-space:nowrap" >[[Width]]:</td>
  175. <td>
  176.             <input type="text" size="2" id="inp_width" onkeyup="checkConstrains('width');" onkeypress="return CancelEventIfNotDigit()"
  177.             style="WIDTH:80px" />
  178. </td>
  179. <td rowspan="2" align="right" valign="middle">
  180.     <img src="../Load.ashx?type=image&file=locked.gif" id="imgLock" width="25" height="32" alt="[[ConstrainProportions]]" />
  181. </td>
  182. </tr>
  183. <tr>
  184. <td>[[Height]]:</td>
  185. <td>
  186. <input type="text" size="2" id="inp_height" onkeyup="checkConstrains('height');" onkeypress="return CancelEventIfNotDigit()"
  187. style="WIDTH : 80px" />
  188. </td>
  189. </tr>
  190. <tr>
  191. <td colspan="2">
  192.     <input type="checkbox" id="constrain_prop" checked="checked" onclick="javascript:toggleConstrains();" />
  193.     [[ConstrainProportions]]
  194. </td>
  195. </tr>
  196. </table>
  197. </td>
  198. </tr>
  199. </table>
  200. </fieldset>
  201. <fieldset>
  202. <legend>[[Spacing]]</legend>
  203. <table border="0" cellpadding="4" cellspacing="0" width="100%">
  204. <tr>
  205. <td>
  206. <table border="0" cellpadding="1" cellspacing="0" class="normal" width="100%">
  207. <tr>
  208. <td valign="middle" style="width:100; white-space:nowrap">[[Horizontal]]:</td>
  209. <td><input type="text" size="2" name="HSpace" onchange="do_preview()" onpropertychange="do_preview()"
  210. onkeypress="return CancelEventIfNotDigit()" style="WIDTH:80px" id="HSpace" />
  211. </td>
  212. </tr>
  213. <tr>
  214. <td valign="middle">[[Vertical]]:</td>
  215. <td><input type="text" size="2" name="VSpace" onchange="do_preview()" onpropertychange="do_preview()"
  216. onkeypress="return CancelEventIfNotDigit()" style="WIDTH:80px" id="VSpace" /></td>
  217. </tr>
  218. </table>
  219. </td>
  220. </tr>
  221. </table>
  222. </fieldset>
  223. </td>
  224. <td style="width:2"></td>
  225. <td valign="top">
  226. <fieldset>
  227. <legend>[[Insert]]</legend>
  228. <table border="0" cellpadding="4" cellspacing="0">
  229. <tr>
  230. <td>
  231. <table border="0" cellpadding="1" cellspacing="0" class="normal">
  232. <tr>
  233. <td valign="middle">
  234. [[Url]]:</td>
  235. <td colspan="3">
  236. <input type="text" id="TargetUrl" onchange="do_preview()" onpropertychange="do_preview()"
  237. size="43" name="TargetUrl" runat="server" /></td>
  238. <td></td>
  239. </tr>
  240. <tr>
  241. <td valign="middle">[[Alternate]]:</td>
  242. <td valign="middle"><input type="text" id="AlternateText" size="22" name="AlternateText" /></td>
  243. <td valign="middle" style="white-space:nowrap" >&nbsp;[[ID]]:</td>
  244. <td><input type="text" id="inp_id" size="12" /></td>
  245. <td></td>
  246. </tr>
  247. <tr>
  248. <td valign="middle" style="white-space:nowrap" >[[longDesc]]:</td>
  249. <td valign="middle" colspan="3"><input type="text" id="longDesc" size="43" name="longDesc" /></td>
  250. <td><img alt="" src="../Load.ashx?type=image&file=Accessibility.gif" /></td>
  251. </tr>
  252. </table>
  253. </td>
  254. </tr>
  255. </table>
  256. </fieldset>
  257. <fieldset id="fieldsetUpload">
  258. <legend>
  259. [[Upload]] ([[MaxFileSizeAllowed]]
  260. <%= CuteEditor.Impl.FileStorage.FormatSize(secset.MaxImageSize * 1024)%>
  261. )</legend>
  262. <table border="0" cellspacing="2" cellpadding="0" width="100%" class="normal">
  263. <tr>
  264. <td style="width:8">
  265. </td>
  266. </tr>
  267. <tr>
  268. <td valign="top" style="FONT-SIZE: 8pt; vertical-align: middle; FONT-FAMILY: MS Sans Serif">
  269. <CE:UploadSingleFile id="InputFile" runat="server"></CE:UploadSingleFile>
  270. </td>
  271. </tr>
  272. <tr>
  273. <td style="width:5">
  274. </td>
  275. </tr>
  276. <tr>
  277. <td>
  278.     <ul style="margin-top:0; margin-bottom:0;">
  279. <% if(secset.RestrictUploadedImageDimension) {%>
  280. <li>
  281. [[MaxImagedImension]]
  282. <%= secset.MaxImageWidth%>
  283. x
  284. <%= secset.MaxImageHeight%>
  285. [[pixels]].
  286. </li>
  287. <li>
  288. [[AutomaticImageResizeOnOff]]
  289. <%= secset.AutoResizeUploadedImages? "[[on]]":"[[off]]" %>
  290. .</li>
  291. <%}%>
  292. <li>
  293. <span style="white-space:nowrap">[[MaxFolderSizeAllowed]]:
  294. <%= CuteEditor.Impl.FileStorage.FormatSize(secset.MaxImageFolderSize * 1024)%>.
  295. [[Used]]: <%= CuteEditor.Impl.FileStorage.FormatSize(fs.GetDirectorySize(fs.VirtualRoot)) %>
  296. <span style="background-color:green;height:3px;width:40px;font-size:3px"><span style="background-color:red;height:3px;width:<%= GetUsedSpaceBarWidth() %>px;font-size:3px">
  297. </span></span>
  298. </span>
  299. </li>
  300. </ul>
  301. </td>
  302. </tr>
  303. </table>
  304. </fieldset>
  305. <div style="padding-top:4px;">
  306. <input class="inputbuttoninsert" type="button" value="[[Insert]]" onclick="do_insert()" id="Button1" />
  307. &nbsp;&nbsp;&nbsp; 
  308. <input class="inputbuttoncancel" type="button" value="[[Cancel]]" onclick="do_cancel()" id="Button2" />
  309. </div>
  310. </td>
  311. </tr>
  312. </table>
  313. </form>
  314. <script runat="server">
  315. protected override void InitOfType()
  316. {
  317. this.Context.Response.Cache.SetCacheability(HttpCacheability.NoCache);
  318. fs.VirtualRoot=CuteEditor.EditorUtility.ProcessWebPath(Context,null,secset.ImageGalleryPath).TrimEnd('/')+"/";
  319. }
  320. protected override void GetFiles(ArrayList files)
  321. {
  322. foreach (string ext in secset.ImageFilters)
  323. {
  324. if (ext == null || ext.Length == 0) continue;
  325. files.AddRange(fs.GetFileItems(CurrentDirectory, secset.FileNamePrefix + "*" + ext));
  326. }
  327. }
  328. protected override bool AllowFileName(string filename)
  329. {
  330. filename = filename.ToLower();
  331. foreach (string ext in secset.ImageFilters)
  332. {
  333. if (ext == null || ext.Length == 0) continue;
  334. if(filename.EndsWith(ext.ToLower()))
  335. return true;
  336. }
  337. return false;
  338. }
  339.     
  340. protected int GetUsedSpaceBarWidth()
  341. {
  342. int w = Convert.ToInt32(40*fs.GetDirectorySize(fs.VirtualRoot)/(secset.MaxImageFolderSize * 1024));
  343. if(w<1)
  344. w=1;
  345. if(w>40)
  346. w=40;
  347. return w;      
  348. }
  349. protected override string CheckUploadData(ref byte[] data)
  350. {            
  351.       
  352. if (fs.GetDirectorySize(fs.VirtualRoot) >= secset.MaxImageFolderSize * 1024)
  353. return "Image folder size exceeds the limit: "+ CuteEditor.Impl.FileStorage.FormatSize(secset.MaxImageFolderSize * 1024);
  354. System.Drawing.Image img;
  355. try
  356. {
  357. img = System.Drawing.Image.FromStream(new System.IO.MemoryStream(data));
  358. }
  359. catch
  360. {
  361. return "Image is in the wrong format.";
  362. }
  363. //let base class to implement
  364. /*
  365.         
  366. if (data.Length >= secset.MaxImageSize * 1024)
  367. return "Image size exceeds "+CuteEditor.Impl.FileStorage.FormatSize(secset.MaxImageSize * 1024)+" limit: "+ CuteEditor.Impl.FileStorage.FormatSize(data.Length);
  368. if(secset.RestrictUploadedImageDimension)
  369. {
  370. if(secset.AutoResizeUploadedImages)
  371. {
  372. return null;//let base class implement the secset.AutoResizeUploadedImages
  373. }
  374. else
  375. {
  376. if ((img.Width > secset.MaxImageWidth) || ((img.Height > secset.MaxImageHeight)))
  377. return String.Format("Image dimension ({0} x {1} pixels) exceeding limits.", img.Width, img.Height);
  378. }
  379. }
  380. */
  381. return null;
  382. }
  383. </script>
  384. </body>
  385. <script type="text/javascript" src="Load.ashx?type=dialogscript&file=DialogFoot.js"></script>
  386. <script type="text/javascript" src="Load.ashx?type=dialogscript&file=Dialog_InsertImage.js"></script>
  387. </html>