Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
insert_image.php
1 <?php
26 require_once dirname(__FILE__).'/../../../../core/include/init.inc';
27 if (empty($GLOBALS['SQ_SYSTEM']->user) || !($GLOBALS['SQ_SYSTEM']->user->canAccessBackend() || $GLOBALS['SQ_SYSTEM']->user->type() == 'simple_edit_user')){
28  exit;
29 }
30 ?>
31 <html>
32  <head>
33  <title>Insert Image</title>
34 
35  <script type="text/javascript" src="../../core/popup.js"></script>
36 
37  <script type="text/javascript">
38  var preview_window = null;
39 
40  function Init() {
41  __dlg_init("insertImage");
42  document.getElementById("f_url").focus();
43  };
44 
45  function onOK() {
46  var required = {
47  "f_url": "You must enter the URL",
48  "f_alt": "Please enter the alternate text"
49  };
50  for (var i in required) {
51  var el = document.getElementById(i);
52  if (!el.value) {
53  alert(required[i]);
54  el.focus();
55  return false;
56  }
57  }
58  // pass data back to the calling window
59  var fields = ["f_url", "f_alt", "f_align", "f_border",
60  "f_horiz", "f_vert"];
61  var param = new Object();
62  for (var i in fields) {
63  var id = fields[i];
64  var el = document.getElementById(id);
65  param[id] = el.value;
66  }
67  if (preview_window) {
68  preview_window.close();
69  }
70  __dlg_close("insertImage", param);
71  return false;
72  };
73 
74  function onCancel() {
75  if (preview_window) {
76  preview_window.close();
77  }
78  __dlg_close("insertImage", null);
79  return false;
80  };
81 
82  function onPreview() {
83  alert(js_translate('preview_needs_rewritten'));
84  var f_url = document.getElementById("f_url");
85  var url = f_url.value;
86  if (!url) {
87  alert("You have to enter an URL first");
88  f_url.focus();
89  return false;
90  }
91  var img = new Image();
92  img.src = url;
93  var win = null;
94  if (!document.all) {
95  win = window.open("about:blank", "ha_imgpreview", "toolbar=no,menubar=no,personalbar=no,innerWidth=100,innerHeight=100,scrollbars=no,resizable=yes");
96  } else {
97  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");
98  }
99  preview_window = win;
100  var doc = win.document;
101  var body = doc.body;
102  if (body) {
103  body.innerHTML = "";
104  body.style.padding = "0px";
105  body.style.margin = "0px";
106  var el = doc.createElement("img");
107  el.src = url;
108 
109  var table = doc.createElement("table");
110  body.appendChild(table);
111  table.style.width = "100%";
112  table.style.height = "100%";
113  var tbody = doc.createElement("tbody");
114  table.appendChild(tbody);
115  var tr = doc.createElement("tr");
116  tbody.appendChild(tr);
117  var td = doc.createElement("td");
118  tr.appendChild(td);
119  td.style.textAlign = "center";
120 
121  td.appendChild(el);
122  win.resizeTo(el.offsetWidth + 30, el.offsetHeight + 30);
123  }
124  win.focus();
125  return false;
126  };
127  </script>
128 
129  <style type="text/css">
130  html, body {
131  background: ButtonFace;
132  color: ButtonText;
133  font: 11px Tahoma,Verdana,sans-serif;
134  margin: 0px;
135  padding: 0px;
136  }
137  body { padding: 5px; }
138  table {
139  font: 11px Tahoma,Verdana,sans-serif;
140  }
141  form p {
142  margin-top: 5px;
143  margin-bottom: 5px;
144  }
145  .fl { width: 9em; float: left; padding: 2px 5px; text-align: right; }
146  .fr { width: 6em; float: left; padding: 2px 5px; text-align: right; }
147  fieldset { padding: 0px 10px 5px 5px; }
148  select, input, button { font: 11px Tahoma,Verdana,sans-serif; }
149  button { width: 70px; }
150  .space { padding: 2px; }
151 
152  .title { background: #ddf; color: #000; font-weight: bold; font-size: 120%; padding: 3px 10px; margin-bottom: 10px;
153  border-bottom: 1px solid black; letter-spacing: 2px;
154  }
155  form { padding: 0px; margin: 0px; }
156  </style>
157  </head>
158 
159  <body onload="Init()">
160  <div class="title"><?php echo translate('insert_image'); ?></div>
161  <form action="" method="get">
162  <table border="0" width="100%" style="padding: 0px; margin: 0px">
163  <tbody>
164  <tr>
165  <td style="width: 7em; text-align: right"><?php echo translate('image_url'); ?>:</td>
166  <td>
167  <input type="text" name="url" id="f_url" style="width:75%" title="Enter the image URL here" value="<?php echo htmlspecialchars($_REQUEST['f_url']) ?>" />
168  <button name="preview" onclick="return onPreview();" title="Preview the image in a new window"><?php echo translate('preview'); ?></button>
169  </td>
170  </tr>
171  <tr>
172  <td style="width: 7em; text-align: right">Alternate text:</td>
173  <td><input type="text" name="alt" id="f_alt" style="width:100%" title="For browsers that don't support images" value="<?php echo htmlspecialchars($_REQUEST['f_alt']) ?>" /></td>
174  </tr>
175  </tbody>
176  </table>
177 
178  <p />
179 
180  <fieldset style="float: left; margin-left: 5px;">
181  <legend><?php echo translate('layout'); ?></legend>
182 
183  <div class="space"></div>
184 
185  <div class="fl"><?php echo translate('alignment'); ?>:</div>
186  <select size="1" name="align" id="f_align" title="Positioning of this image">
187  <?php
188  if (!isset($_REQUEST['f_align'])) $_REQUEST['f_align'] = 'baseline';
189  $options_array = Array( '' => 'Not set',
190  'left' => 'Left',
191  'right' => 'Right',
192  'texttop' => 'Texttop',
193  'absmiddle' => 'Absmiddle',
194  'baseline' => 'Baseline',
195  'absbottom' => 'Absbottom',
196  'bottom' => 'Bottom',
197  'middle' => 'Middle',
198  'top' => 'Top'
199  );
200  foreach ($options_array as $value => $text) {
201  ?><option value="<?php echo $value?>" <?php echo ($_REQUEST['f_align'] == $value) ? 'selected="1"' : ''?>><?php echo $text?></option><?php
202  }
203  ?>
204  </select>
205 
206  <p />
207 
208  <div class="fl"><?php echo translate('border_thickness'); ?>:</div>
209  <input type="text" name="border" id="f_border" size="5"
210  title="Leave empty for no border" value="<?php echo htmlspecialchars($_REQUEST['f_border']) ?>" />
211 
212  <div class="space"></div>
213  </fieldset>
214 
215  <fieldset style="float:right; margin-right: 5px;">
216  <legend><?php echo translate('spacing'); ?></legend>
217 
218  <div class="space"></div>
219 
220  <div class="fr"><?php echo translate('horizontal'); ?>:</div>
221  <input type="text" name="horiz" id="f_horiz" size="5" title="Horizontal padding" value="<?php echo htmlspecialchars($_REQUEST['f_horiz']) ?>" />
222 
223  <p />
224 
225  <div class="fr"><?php echo translate('vertical'); ?>:</div>
226  <input type="text" name="vert" id="f_vert" size="5" title="Vertical padding" value="<?php echo htmlspecialchars($_REQUEST['f_vert']) ?>" />
227 
228  <div class="space"></div>
229  </fieldset>
230 
231  <div style="margin-top: 85px; text-align: right;">
232  <hr />
233  <button type="button" name="ok" onclick="return onOK();"><?php echo translate('ok'); ?></button>
234  <button type="button" name="cancel" onclick="return onCancel();"><?php echo translate('cancel'); ?></button>
235  </div>
236  </form>
237  </body>
238 </html>