PageRenderTime 44ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 1ms

/ASTRA_Demo_Server/udrive/www/astra/interact/includes/editor/popups/insert_image.php

https://github.com/shafiqissani/ASTRA-College-Website
PHP | 395 lines | 348 code | 37 blank | 10 comment | 37 complexity | cf5a97eb52e3aa5151c83f0d1d78b427 MD5 | raw file
  1. <?php
  2. require_once('../../../local/config.inc.php');
  3. $file_dir_iframe_url="file_dir_iframe.php?allowed_file_types=jpeg,jpg,gif,png,zip";
  4. ?>
  5. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
  6. "http://www.w3.org/TR/html4/loose.dtd">
  7. <html>
  8. <head>
  9. <title>Choose Image</title>
  10. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  11. <script type="text/javascript">
  12. function onCancel() {
  13. __dlg_close(null);
  14. return false;
  15. };
  16. <?php
  17. readfile('popup'.(!empty($_GET['type'])?'_'.$_GET['type']:'').'.js');
  18. // if(!$_SESSION['current_user_key']) {
  19. // echo 'self.focus();</script></head><body><div align="center">You don\'t appear to be logged in<br />';
  20. // echo '<a href="javascript:onCancel()">Close this Window</a></div></body></html>';
  21. // exit;
  22. // }
  23. ?>
  24. self.focus();
  25. var img_params=["f_url","f_width","f_height"<?php if($_GET['basic']!=true) {echo ',"f_alt","f_border","f_align","f_vert","f_horiz"';} ?>];
  26. function dInit() {
  27. __dlg_init();
  28. var param = window.dialogArguments;
  29. document.getElementById("f_url").focus();
  30. if (param) {
  31. for (var i in img_params) {
  32. if (param[img_params[i]]!=undefined) {
  33. document.getElementById(img_params[i]).value = param[img_params[i]];
  34. }
  35. }
  36. showExisting(param["f_url"]);
  37. }
  38. document.getElementById("idir").src="<?php echo $file_dir_iframe_url;?>&trytofindurl="+document.getElementById("f_url").value;
  39. }
  40. function NewFile(url,nclicks) {
  41. if (nclicks&1) {
  42. var pre_image = document.getElementById("pre_image");
  43. var ipreview=document.getElementById("ipreview");
  44. ipreview.alt="Loading...";
  45. ipreview.src=null;
  46. pre_image.onload=newUpdate;
  47. pre_image.src=url;
  48. document.getElementById("f_url").value=url;
  49. }
  50. }
  51. function oldUpdate() {
  52. imgUpdate();
  53. <?php if($_GET['basic']!=true) echo 'checkSize();';?>
  54. }
  55. function newUpdate() {
  56. imgUpdate();
  57. resetSize();
  58. }
  59. function showExisting(url) {
  60. var pre_image = document.getElementById("pre_image");
  61. pre_image.onload=oldUpdate;
  62. pre_image.src=url;
  63. }
  64. function imgUpdate() {
  65. var ipreview = document.getElementById("ipreview");
  66. var pre_image = document.getElementById("pre_image");
  67. ipreview.alt="Loaded";
  68. var nwidth = pre_image.width;
  69. var nheight = pre_image.height;
  70. var factor;
  71. if (nwidth>0) {
  72. var premess=nwidth+"x"+nheight+" pixels";
  73. if (pre_image.fileSize) premess+=" &bull; "+Math.ceil(pre_image.fileSize>>10)+"KB ("+Math.ceil(pre_image.fileSize/5000)+"s@56K)";
  74. if ((factor=Math.min(228/nheight,304/nwidth))<1) {
  75. nwidth=Math.round(nwidth*factor);
  76. nheight=Math.round(nheight*factor);
  77. premess+=" &bull; shown at "+Math.round(factor*100)+"%";
  78. }
  79. premess+="<br />";} else premess="";
  80. document.getElementById("premess").innerHTML=premess;
  81. ipreview.src=pre_image.src;
  82. ipreview.width=nwidth;ipreview.height=nheight;
  83. <?php if($_GET['basic']!=true) echo 'document.getElementById("f_alt").focus();'; ?>
  84. }
  85. function checkSize() {
  86. var pre_image = document.getElementById("pre_image");
  87. if (document.getElementById("f_width").value!=pre_image.width)
  88. document.getElementById("wtit").style.fontWeight="bold";
  89. else document.getElementById("wtit").style.fontWeight="";
  90. if (document.getElementById("f_height").value!=pre_image.height)
  91. document.getElementById("htit").style.fontWeight="bold";
  92. else document.getElementById("htit").style.fontWeight="";
  93. }
  94. // Fired when the Reset Size button is clicked
  95. function resetSize() {
  96. var pre_image = document.getElementById("pre_image");
  97. if (pre_image.width>0) {
  98. document.getElementById("f_width").value=pre_image.width;
  99. document.getElementById("f_height").value=pre_image.height;
  100. }
  101. <?php if($_GET['basic']!=true) echo 'checkSize();'; ?>
  102. }
  103. // Fired when the width or height input texts change
  104. function sizeChanged(axe) {
  105. // Verifies if the aspect ration has to be mantained
  106. var pre_image = document.getElementById("pre_image");
  107. if (document.getElementById("chkLockRatio").checked && (pre_image.width>0)) {
  108. txtWidth = document.getElementById("f_width");
  109. txtHeight = document.getElementById("f_height");
  110. if ((axe) == "Width") {
  111. if (txtWidth.value != "") {
  112. if (! isNaN(txtWidth.value))
  113. txtHeight.value = Math.round( pre_image.height * ( txtWidth.value / pre_image.width ) ) ;
  114. }
  115. else txtHeight.value = "" ;
  116. } else
  117. if (txtHeight.value != "") {
  118. if (! isNaN(txtHeight.value))
  119. txtWidth.value = Math.round( pre_image.width * ( txtHeight.value / pre_image.height ) ) ;
  120. } else txtWidth.value = "" ;
  121. }
  122. checkSize();
  123. }
  124. function onOK() {
  125. var required = {
  126. "f_url": "You must enter the URL"
  127. <?php if($_GET['basic']!=true) echo ',"f_alt": "Please enter alternate text - this helps people who can\'t see images"'; ?>
  128. };
  129. for (var i in required) {
  130. var el = document.getElementById(i);
  131. if (!el.value) {
  132. alert(required[i]);
  133. el.focus();
  134. return false;
  135. }
  136. }
  137. // pass data back to the calling window
  138. var param = new Object();
  139. for (var i in img_params) {
  140. var id = img_params[i];
  141. var el = document.getElementById(id);
  142. // if(el.value.length)
  143. param[id] = el.value;
  144. }
  145. __dlg_close(param);
  146. return false;
  147. };
  148. </script>
  149. <style>
  150. HTML, BODY
  151. {
  152. FONT-FAMILY: Verdana;FONT-SIZE: xx-small;
  153. background: #E0E0E4;
  154. color: ButtonText;
  155. margin: 0px;
  156. padding: 0px;
  157. overflow:hidden;
  158. }
  159. TABLE
  160. {
  161. FONT-SIZE: xx-small;
  162. }
  163. INPUT
  164. {
  165. font:8pt verdana,arial,sans-serif;
  166. }
  167. select
  168. {
  169. font:8pt verdana,arial,sans-serif
  170. }
  171. body { padding: 5px; }
  172. select, input, button { font: 11px Tahoma,Verdana,sans-serif; }
  173. button { width: 70px; }
  174. form { padding: 0px; margin: 0px; }
  175. </style>
  176. </head>
  177. <body onload="dInit();">
  178. <div style="position:absolute; visibility: hidden;">
  179. <img id="pre_image">
  180. </div>
  181. <table width="100%" border="0" cellspacing="0" cellpadding="0">
  182. <tr>
  183. <td width="54%" rowspan="2" align="center" valign=<?php echo ($_GET['basic']==true)? '"middle"':'"top"'; ?> >
  184. <fieldset style="height:247px; background-color: #F6F6F6; padding: 0px;">
  185. <legend>
  186. Preview
  187. </legend>
  188. <table height="228" border="0" style="padding: 0px; margin: 0px">
  189. <tr>
  190. <td valign="middle" align="center">
  191. <img name="ipreview" align="middle" id="ipreview" alt="no image">
  192. </td>
  193. </tr>
  194. </table>
  195. </fieldset><input type="button" style="font-size:xx-small;float:right;padding:0px;margin:0px;" onClick="NewFile(document.getElementById('f_url').value,1)" value="Update">
  196. <div align="center" id="premess">
  197. <br />
  198. </div>
  199. <form action="" method="get">
  200. <table width="100%" border="0" cellspacing="0" cellpadding="0" style="margin-top:3px;">
  201. <tr>
  202. <td valign="top">
  203. <table border="0" width="100%" style="padding: 0px; margin: 0px">
  204. <tr>
  205. <td style="width: 20%; text-align: right">
  206. Image URL:
  207. </td>
  208. <td valign="top">
  209. <input name="url" type="text" id="f_url" title="Enter the image URL here" size="42">
  210. </td>
  211. </tr>
  212. <tr>
  213. <?php if($_GET['basic']!=true) { ?>
  214. <td style="color:red; width: 20%; text-align: right">
  215. Alt text:
  216. </td>
  217. <td valign="top">
  218. <input name="alt" type="text" id="f_alt" title="For browsers that don\'t support images" size="42">
  219. </td>
  220. <?php } ?>
  221. </tr>
  222. </table>
  223. <?php if($_GET['basic']==true) {
  224. echo '<input type="hidden" id="f_width"><input type="hidden" id="f_height"> ';
  225. } else { ?>
  226. <table align="center">
  227. <tr>
  228. <td>
  229. <fieldset style="margin-left:25px;padding-top:1px; padding-right:2px; padding-bottom:1px;">
  230. <legend>
  231. Alignment
  232. </legend>
  233. <select size="1" name="align" id="f_align" title="Positioning of this image">
  234. <option value="" selected="1">
  235. Not set
  236. </option>
  237. <option value="left">
  238. Left
  239. </option>
  240. <option value="right">
  241. Right
  242. </option>
  243. <option value="texttop">
  244. Texttop
  245. </option>
  246. <option value="absmiddle">
  247. Absmiddle
  248. </option>
  249. <option value="baseline">
  250. Baseline
  251. </option>
  252. <option value="absbottom">
  253. Absbottom
  254. </option>
  255. <option value="bottom">
  256. Bottom
  257. </option>
  258. <option value="middle">
  259. Middle
  260. </option>
  261. <option value="top">
  262. Top
  263. </option>
  264. </select>
  265. <br />
  266. <table>
  267. <tr>
  268. <td nowrap align="right">
  269. Border thickness:
  270. </td>
  271. <td>
  272. <input type="text" name="border" id="f_border" size="3" title="Leave empty for no border" value="1"/>
  273. </td>
  274. </tr>
  275. <tr>
  276. <td nowrap align="right">
  277. Horizontal Space:
  278. </td>
  279. <td>
  280. <input type="text" name="horiz" id="f_horiz" size="3" title="Horizontal padding - gap on left and right of image" />
  281. </td>
  282. </tr>
  283. <tr>
  284. <td nowrap align="right">
  285. Vertical Space:
  286. </td>
  287. <td>
  288. <input type="text" name="vert" id="f_vert" size="3" title="Vertical padding - gap on top and bottom of image"/>
  289. </td>
  290. </tr>
  291. </table>
  292. </fieldset>
  293. </td>
  294. <td valign="top" align="center">
  295. <fieldset style="margin-left: 12px; padding-bottom:2px;padding-top:0px;padding-right:2px;">
  296. <legend>
  297. Size
  298. </legend>
  299. <table>
  300. <tr>
  301. <td nowrap align="right" id="wtit">
  302. Width:
  303. </td>
  304. <td width="10">
  305. <input type="text" size="4" id="f_width" title="Display Width (does not affect actual image file)" onkeyup="sizeChanged('Width');">
  306. </td>
  307. </tr>
  308. <tr>
  309. <td nowrap align="right" id="htit">
  310. Height:
  311. </td>
  312. <td>
  313. <input type="text" size="4" id="f_height" title="Display Height (does not affect actual image file)" onkeyup="sizeChanged('Height');">
  314. </td>
  315. </tr>
  316. <tr>
  317. <td nowrap colspan="2" valign="top">
  318. <INPUT type="checkbox" class="CheckBox" checked id="chkLockRatio" title="When changing size above, keep aspect ratio of image correct (don't squish it)"> Lock Ratio
  319. </td>
  320. </tr>
  321. </table>
  322. <INPUT type="button" value="Reset Size" title="Reset width and height to that of the image file" onclick="resetSize();">
  323. </fieldset>
  324. </td>
  325. </tr>
  326. </table>
  327. <?php } ?>
  328. </td>
  329. </tr>
  330. </table>
  331. </form>
  332. </td>
  333. <td width="46%" valign="top">
  334. <fieldset style="background-color: #D2D2D8; padding: 0px; margin-bottom:4px;">
  335. <legend>
  336. Choose File
  337. </legend>
  338. <iframe name="idir" id="idir" frameborder="0" style="border : 0px; width: 100%; height: 400px;" src="about:blank" scrolling="no"> </iframe>
  339. </fieldset>
  340. </td>
  341. </tr>
  342. <tr>
  343. <td width="100%" align="right" valign="top">
  344. <button type="button" name="ok" onclick="return onOK();">
  345. OK
  346. </button>
  347. &nbsp;&nbsp;<button type="button" name="cancel" onclick="return onCancel();">
  348. Cancel
  349. </button>
  350. &nbsp;&nbsp;&nbsp;
  351. </td>
  352. </tr>
  353. </table>
  354. </body>
  355. </html>