Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
insert_link.php
1 <?php
25 require_once dirname(__FILE__).'/../../../../core/include/init.inc';
26 require_once SQ_LIB_PATH.'/html_form/html_form.inc';
27 require_once SQ_FUDGE_PATH.'/var_serialise/var_serialise.inc';
28 
29 if (empty($GLOBALS['SQ_SYSTEM']->user) || !($GLOBALS['SQ_SYSTEM']->user->canAccessBackend() || $GLOBALS['SQ_SYSTEM']->user->type() == 'simple_edit_user')){
30  exit;
31 }
32 
33 // URL protocol options
34 $pref = $GLOBALS['SQ_SYSTEM']->getUserPrefs('content_type_wysiwyg', 'SQ_WYSIWYG_LINK_TYPES');
35 
36 $url_protocol_options = Array('' => '');
37 $url_protocol_combo_box = Array('' => '');
38 foreach ($pref as $pref_el) {
39  $url_protocol_options[$pref_el['type']] = $pref_el['template'];
40  $url_protocol_combo_box[$pref_el['type']] = $pref_el['type'];
41 }
42 
43 $new_window_bool_options = Array(
44  'toolbar' => 'Show Tool Bar',
45  'menubar' => 'Show Menu Bars',
46  'location' => 'Show Location Bar',
47  'status' => 'Show Status Bar',
48  'scrollbars' => 'Show Scroll Bars',
49  'resizable' => 'Allow Resizing',
50  );
51 
52 if (!isset($_GET['assetid'])) {
53  $_GET['assetid'] = 0;
54 } else {
55  preg_match('/^([0-9A-Z:]*)/i', $_GET['assetid'], $matches);
56  $_GET['assetid'] = isset($matches[1]) ? $matches[1] : $_GET['assetid'];
57 }
58 if (!isset($_GET['url'])) $_GET['url'] = 0;
59 if (!isset($_GET['protocol'])) $_GET['protocol'] = '';
60 if (!isset($_GET['status_text'])) {
61  $_GET['status_text'] = '';
62 }
63 if (!isset($_GET['link_title'])) {
64  $_GET['link_title'] = '';
65 }
66 if (!isset($_GET['target'])) $_GET['target'] = '';
67 if (!isset($_GET['new_window'])) {
68  $_GET['new_window'] = 0;
69 }
70 if (!isset($_GET['class_name'])) {
71  $_GET['class_name'] = '';
72 }
73 if (!isset($_GET['id_name'])) {
74  $_GET['id_name'] = '';
75 }
76 if (!isset($_GET['show_summary'])) {
77  $_GET['show_summary'] = 0;
78 }
79 
80 
81 if (strpos($_GET['assetid'], '#') !== FALSE) {
82  list($_GET['assetid'], $_GET['anchor']) = explode('#', $_GET['assetid']);
83 }
84 
85 // If we have an anchor, it will have been stuck in the URL, so break it away
86 if (strpos($_GET['url'], '#') !== FALSE) {
87  list($_GET['url'], $_GET['anchor']) = explode('#', $_GET['url']);
88 } else {
89  $_GET['anchor'] = '';
90 }
91 
92 if (!isset($_GET['new_window'])) {
93  foreach ($new_window_bool_options as $option => $option_text) {
94  $_GET['new_window_options'][$options] = 0;
95  }
96 } else {
97  $_GET['new_window_options'] = var_unserialise($_GET['new_window_options']);
98 }
99 
100 // we have the assetid lets try to get the asset
101 $option_selected = 'all_asset';
102 if (isset($_GET['assetid']) && $_GET['assetid']) {
103  $asset_linked = $GLOBALS['SQ_SYSTEM']->am->getAsset($_GET['assetid']);
104  if (!is_null($asset_linked)) {
105  if ($asset_linked instanceof Link) {
106  $option_selected = 'link_manager';
107  } else if ($asset_linked instanceof Page_Redirect) {
108  $option_selected = 'redirect';
109  }
110  }
111 }
112 ?>
113 
114 <html style="width: 750px; height: 488px; ">
115  <head>
116  <title>Insert Link</title>
117  <?php
118  // add required js translation files, as we are using asset finder
119  $include_list = Array(sq_web_path('lib').'/js/translation.js');
120 
121  $locales = $GLOBALS['SQ_SYSTEM']->lm->getCumulativeLocaleParts($GLOBALS['SQ_SYSTEM']->lm->getCurrentLocale());
122 
123  foreach ($locales as $locale) {
124  if (file_exists(SQ_DATA_PATH.'/public/system/core/js_strings.'.$locale.'.js')) {
125  $include_list[] = sq_web_path('data').'/system/core/js_strings.'.$locale.'.js';
126  }
127  }
128 
129  foreach ($include_list as $link) {
130  ?><script type="text/javascript" src="<?php echo $link; ?>"></script>
131  <?php
132  }
133  ?>
134  <script type="text/javascript" src="../../core/popup.js"></script>
135  <script type="text/javascript" src="<?php echo sq_web_path('lib').'/asset_map/javaExternalCall.js' ?>"></script>
136  <script type="text/javascript" src="<?php echo sq_web_path('fudge').'/var_serialise/var_serialise.js' ?>"></script>
137  <script type="text/javascript" src="<?php echo sq_web_path('lib').'/html_form/html_form.js' ?>"></script>
138  <script type="text/javascript" src="<?php echo sq_web_path('lib').'/js/general.js' ?>"></script>
139  <script type="text/javascript" src="<?php echo sq_web_path('lib').'/js/tooltip.js' ?>"></script>
140 
141  <script type="text/javascript">
142  function getFocus() {
143  setTimeout('self.focus()',100);
144  };
145 
146  var new_window_bool_options = new Array('<?php echo implode("','", array_keys($new_window_bool_options))?>');
147 
148  function Init() {
149  __dlg_init("matrixInsertLink");
150  enable_new_window(document.main_form, <?php echo preg_replace('/[\'"\(\);\[\]{}<>=]+/', '', $_GET['new_window']); ?>);
151 
152 
153  var patterns = {<?php
154  $url_protocol_options_sorted = $url_protocol_options;
155  uasort($url_protocol_options_sorted, create_function('$a,$b', 'return strlen($b) - strlen($a);'));
156 
157  foreach ($url_protocol_options_sorted as $label => $pattern) {
158  $pattern_array[] = '\''.addslashes($label).'\': \''.str_replace('%%link%%', '([^#]*)', addslashes($pattern)).'\'';
159  }
160 
161  echo implode($pattern_array, ', ');
162  ?>};
163 
164  // loop through each pattern
165  for (label in patterns) {
166  e = patterns[label];
167  // Add hash
168  e = '^' + e + '(#(.*))?$';
169  var re = new RegExp(e, '');
170  // we need to make sure that the url does'nt have any single quote
171  var results = re.exec('<?php echo str_replace("'", '%27', $_GET['url']); ?>');
172  if (results) {
173  break;
174  }
175  }
176 
177  if (results) {
178  setUrl(label, results[1]);
179  } else {
180  // we need to make sure that the url does not have any single quote
181  setUrl('', '<?php echo str_replace("'", '%27', $_GET['url']); ?>');
182  }
183  };
184 
185  function onOK() {
186  // pass data back to the calling window
187  var fields = ["url"];
188  var param = new Object();
189  var f = document.main_form;
190 
191  // check for the manual entering in the asset picker
192  if ((form_element_value(f.url_link) == '') && (form_element_value(f.anchor) == '') &&
193  (((f.elements["assetid[assetid]"].value != '') && (f.elements["assetid[assetid]"].value != 0)) ||
194  ((f.elements["page_redirect_assetid[assetid]"].value != '') && (f.elements["page_redirect_assetid[assetid]"].value != 0)) ||
195  ((f.elements["link_assetid[assetid]"].value != '') && (f.elements["link_assetid[assetid]"].value != 0))
196  )) {
197  setUrl();
198  }
199 
200  // check if there is just an anchor in there
201  if ((form_element_value(f.url_link) == '') && (form_element_value(f.anchor) != '')) {
202  param["url"] = '#' + form_element_value(f.anchor);
203  } else {
204  var patterns = {<?php
205  foreach ($url_protocol_options as $label => $pattern) {
206  $pattern_array[] = '\''.addslashes($label).'\': \''.addslashes($pattern).'\'';
207  }
208 
209  echo implode($pattern_array, ', ');
210  ?>};
211  if (form_element_value(f.url_protocol) == '') {
212  param["url"] = form_element_value(f.url_link)
213  } else {
214  param["url"] = patterns[form_element_value(f.url_protocol)].replace('%%link%%', form_element_value(f.url_link));
215  }
216  param["url"] += (form_element_value(f.anchor) == '' ? '' : '#' + form_element_value(f.anchor));
217  }
218  param["status_text"] = form_element_value(f.status_text);
219  param["link_title"] = form_element_value(f.link_title);
220  param["target"] = form_element_value(f.target);
221  param["new_window"] = form_element_value(f.new_window);
222  param["class_name"] = form_element_value(f.class_name);
223  param["id_name"] = form_element_value(f.id_name);
224  param["show_summary"] = form_element_value(f.show_summary);
225  param["assetid"] = f.elements["assetid[assetid]"].value;
226 
227  param["new_window_options"] = new Object();
228  param["new_window_options"]["width"] = form_element_value(f.width);
229  param["new_window_options"]["height"] = form_element_value(f.height);
230  for (var i=0; i < new_window_bool_options.length; i++) {
231  param["new_window_options"][new_window_bool_options[i]] = (f.elements[new_window_bool_options[i]].checked) ? 1 : 0;
232  }
233 
234  __dlg_close("matrixInsertLink", param);
235  return false;
236  };
237 
238  function onCancel() {
239  __dlg_close("matrixInsertLink", null);
240  return false;
241  };
242 
243  function setUrl(protocol, link) {
244  var f = document.main_form;
245 
246  if (protocol != null) highlight_combo_value(f.url_protocol, protocol);
247  if (link != null) {
248  f.url_link.value = link;
249  } else {
250  var assetid = '';
251  if (f.elements["assetid[assetid]"].value != undefined && f.elements["assetid[assetid]"].value != '<?php echo $_GET['assetid']; ?>' && f.elements["assetid[assetid]"].value != '') {
252  assetid = f.elements["assetid[assetid]"].value;
253  } else if (f.elements["link_assetid[assetid]"].value != undefined && f.elements["link_assetid[assetid]"].value != '<?php echo $_GET['assetid']; ?>' && f.elements["link_assetid[assetid]"].value != '') {
254  assetid = '%globals_asset_attribute_link_url:'+ f.elements["link_assetid[assetid]"].value +'%';
255  } else if (f.elements["page_redirect_assetid[assetid]"].value != undefined && f.elements["page_redirect_assetid[assetid]"].value != '<?php echo $_GET['assetid']; ?>' && f.elements["page_redirect_assetid[assetid]"].value != '') {
256  assetid = '%globals_asset_attribute_redirect_url:'+ f.elements["page_redirect_assetid[assetid]"].value +'%';
257  }
258 
259  // Selected asset's type code
260  var asset_type = '';
261  if (f.elements["assetid[type_code]"].value != '') {
262  asset_type = f.elements["assetid[type_code]"].value;
263  } else if (f.elements["link_assetid[type_code]"].value != '') {
264  asset_type = f.elements["link_assetid[type_code]"].value;
265  } else if (f.elements["page_redirect_assetid[type_code]"].value != '') {
266  asset_type = f.elements["page_redirect_assetid[type_code]"].value;
267  }
268  if (asset_type != '') {
269  // Disable the irrelevant asset type option based on the currently selected asset
270  asset_type = asset_type.toLowerCase();
271  options = f.elements["asset_type_selector"].getElementsByTagName("option");
272  for(var i=0; i<options.length; i++) {
273  options[i].disabled = false;
274  if (asset_type != 'link' && options[i].value == 'link_manager') {
275  options[i].disabled = true;
276  } else if (asset_type != 'page_redirect' && options[i].value == 'redirect') {
277  options[i].disabled = true;
278  }
279  }
280  }
281 
282  if (assetid != '') {
283  // shadow asset
284  if (assetid.search('globals_asset_attribute') != -1) {
285  f.url_link.value = assetid;
286  } else {
287  if (assetid.search(/:/) != -1) {
288  f.url_link.value = './?a=' + assetid + '$';
289  } else {
290  f.url_link.value = './?a=' + assetid;
291  }
292  }
293  highlight_combo_value(f.url_protocol, '');
294  }
295  }
296  setTimeout('self.focus()',100);
297  };
298 
299  function enable_new_window(f, enable) {
300  var bg_colour = '#' + ((enable == 2) ? 'ffffff' : 'c0c0c0');
301 
302  // make sure that the new window box says what it's supposed to
303  highlight_combo_value(f.new_window, enable);
304 
305  f.target.disabled = (enable != 0);
306 
307  var disable = (enable != 2);
308  f.width.disabled = disable;
309  f.height.disabled = disable;
310  f.width.style.backgroundColor = bg_colour;
311  f.height.style.backgroundColor = bg_colour;
312  for (var i=0; i < new_window_bool_options.length; i++) {
313  f.elements[new_window_bool_options[i]].disabled = disable;
314  }
315  };
316 
317  function reset_type_selector()
318  {
319  // Enable all the asset selector options (default)
320  options = document.main_form.elements["asset_type_selector"].getElementsByTagName("option");
321  for(var i=0; i<options.length; i++) {
322  options[i].disabled = false;
323  }
324 
325  document.getElementById('assetid[type_code]').value = '';
326  document.getElementById('link_assetid[type_code]').value = '';
327  document.getElementById('page_redirect_assetid[type_code]').value = '';
328 
329  };
330 
331  </script>
332 
333  <style type="text/css">
334  html, body {
335  background: #FCFCFC;
336  color: #000000;
337  font: 11px Tahoma,Verdana,sans-serif;
338  margin: 0px;
339  padding: 0px;
340  }
341 
342  table {
343  font: 11px Tahoma,Verdana,sans-serif;
344  }
345 
346  form#main-form {
347  padding: 5px;
348  clear: right;
349  }
350 
351  #quick-search {
352  font: 11px Tahoma,Verdana,sans-serif;
353  letter-spacing: 0;
354  float: right;
355  padding-right: 12px;
356  }
357 
358  #quick-search #quick-search-for {
359  font: 11px Arial,Verdana,sans-serif;
360  border: 1px solid black;
361  padding: 1px 3px;
362  }
363 
364  #quick-search #quick-search-for-label {
365  font: 11px Arial,Verdana,sans-serif;
366  color: #999;
367  }
368 
369 
370  /* main popup title */
371  .title {
372  background: #402F48;
373  color: #FFFFFF;
374  font-weight: bold;
375  font-size: 120%;
376  padding: 6px 10px;
377  margin-bottom: 10px;
378  border-bottom: 1px solid black;
379  letter-spacing: 4px;
380  }
381 
382  /* fieldset styles */
383  fieldset {
384  padding: 0px 10px 5px 5px;
385  border-color: #725B7D;
386  }
387 
388  .fl { width: 9em; float: left; padding: 2px 5px; text-align: right; }
389  .fr { width: 7em; float: left; padding: 2px 5px; text-align: right; }
390 
391  /* form and form fields */
392  form { padding: 0px; margin: 0px; }
393 
394  select, input, button {
395  font: 11px Tahoma,Verdana,sans-serif;
396  }
397 
398  button {
399  width: 70px;
400  }
401 
402  /* colour picker button styles */
403  .buttonColor, .buttonColor-hilite {
404  cursor: default;
405  border: 1px solid;
406  border-color: #9E86AA #725B7D #725B7D #9E86AA;
407  }
408 
409  .buttonColor-hilite {
410  border-color: #402F48;
411  }
412 
413  .buttonColor-chooser, .buttonColor-nocolor, .buttonColor-nocolor-hilite {
414  height: 0.6em;
415  border: 1px solid;
416  padding: 0px 1em;
417  border-color: ButtonShadow ButtonHighlight ButtonHighlight ButtonShadow;
418  }
419 
420  .buttonColor-nocolor, .buttonColor-nocolor-hilite { padding: 0px; }
421  .buttonColor-nocolor-hilite { background: #402F48; color: #FFFFFF; }
422 
423  /* Popup styles (for backend search feature) */
424 
425  #new-message-popup, #search-wait-popup {
426  position: absolute;
427  right: 10px;
428  top: 0;
429  width: 300px;
430  background-color: white;
431  border: 2px solid black;
432  font: normal 10px Arial,Verdana,sans-serif;
433  display: none;
434  }
435 
436  #new-message-popup-titlebar, #search-wait-popup-titlebar {
437  font-weight: bold;
438  padding: 5px;
439  }
440 
441  #new-message-popup-close, #search-wait-popup-close {
442  float: right;
443  }
444 
445  #new-message-popup-close a, #search-wait-popup-close a {
446  color: black;
447  text-decoration: none;
448  }
449 
450  #new-message-popup-details, #search-wait-popup-details {
451  padding: 5px;
452  }
453 
454  div.search-result {
455  padding: 0;
456  margin: 5px;
457  }
458 
459  div.search-result-blurb {
460  padding: 0;
461  margin: 5px;
462  font-weight: bold;
463  }
464 
465  div.search-result-pager {
466  padding: 0;
467  margin: 5px;
468  text-align: center;
469  }
470 
471  div.search-result-detail {
472  padding: 0;
473  padding-left: 15px;
474  margin: 5px;
475  display: none;
476  }
477 
478  a.search-result-expand-link {
479  text-decoration: none;
480  top: 0px;
481  left: 0px;
482  height: 10px;
483  font-size: 14px;
484  margin-top: 0px;
485  font-weight: bold;
486  text-decoration: none;
487  color: #33B9E6;
488  }
489 
490  .search-result-expand-div {
491  float: left;
492  width: 22px;
493  font-weight: bold;
494  background-color: white;
495  white-space: nowrap;
496  }
497 
498  .search-result-entry {
499  margin-top: 5px;
500  text-indent: -38px;
501  padding-left: 50px;
502  }
503 
504  .sq-backend-search-failed-table {
505  border: 2px solid #594165;
506  border-collapse: collapse;
507  background-color: #ECECEC;
508  }
509 
510  .sq-backend-search-failed-heading, .sq-backend-search-failed-body {
511  color: #342939;
512  background-color: #ececec;
513  font-family: Arial, Verdana, Helvetica, sans-serif;
514  font-size: 10px;
515  vertical-align: top;
516  padding: 5px;
517  text-decoration: none;
518  font-weight: bold;
519  }
520 
521  .sq-backend-search-failed-body {
522  color: #342939;
523  font-weight: normal;
524  }
525 
526  .sq-backend-search-results-table {
527  border: 2px solid #594165;
528  border-collapse: collapse;
529  background-color: #ECECEC;
530  }
531 
532  .sq-backend-search-results-heading, .sq-backend-search-results-body {
533  color: #342939;
534  background-color: #FFFFFF;
535  font-family: Arial, Verdana, Helvetica, sans-serif;
536  font-size: 10px;
537  vertical-align: top;
538  padding: 5px;
539  text-decoration: none;
540  font-weight: bold;
541  }
542 
543  .sq-backend-search-results-heading {
544  background-color: #F0F0E6;
545  }
546 
547  .sq-backend-search-results-highlight {
548  background-color: yellow;
549  }
550 
551  .sq-backend-search-results-body {
552  color: #342939;
553  font-weight: normal;
554  }
555  </style>
556  </head>
557 
558  <body onload="Javascript: Init();" onUnload="Javascript: asset_finder_onunload();">
559  <form action="" method="get" name="main_form" id="main-form">
560  <table>
561  <tr>
562  <td valign="top">
563  <?php
564  include_once(SQ_LIB_PATH.'/asset_map/asset_map.inc');
565  $asset_map =& new Asset_Map();
566  $asset_map->embedAssetMap('simple', 200, 400);
567  ?>
568  </td>
569  <td valign="top">
570  <table width="100%">
571  <tr>
572  <td>
573  <table width="100%" cellspacing="0" cellpadding="0">
574  <tr>
575  <td valign="top" width="100%">
576  <fieldset>
577  <legend><b><?php echo translate('general'); ?></b></legend>
578  <table style="width:100%">
579  <tr>
580  <td class="label"><?php echo translate('protocol'); ?>:</td>
581  <td><?php
582  combo_box('url_protocol', $url_protocol_combo_box, $_GET['protocol'], 'style="font-family: courier new; font-size: 11px;"'); ?></td>
583  <td class="label"><?php echo translate('link'); ?>:</td>
584  <td><?php text_box('url_link', $_GET['url'], 40, 0)?></td>
585  </tr>
586  <tr>
587  <td class="lable"><?php echo translate('asset_type').':'; ?></td>
588  <td colspan="3">
589  <?php
590  $asset_selector = Array(
591  'all_assets' => 'Any Asset',
592  'link_manager' => 'Link Asset',
593  'redirect' => 'Redirect Page Asset',
594  );
595 
596  $object_type = 'this.form.asset_type_selector.value';
597  $object_span1 = 'document.getElementById(\'asset_finder_all\')';
598  $object_span2 = 'document.getElementById(\'asset_finder_link_asset\')';
599  $object_span3 = 'document.getElementById(\'asset_finder_redirect_asset\')';
600  $js = 'onChange="chooseSourceType('.$object_type.', '.$object_span1.', '.$object_span2.', '.$object_span3.');"';
601  ?>
602  <script type="text/javascript">
603  function chooseSourceType(type, span_all, span_link_manager, span_redirect_page) {
604  all_asset_picker = document.getElementById('assetid[assetid]');
605  all_asset_picker_id = document.getElementById('sq_asset_finder_assetid_assetid');
606  all_asset_picker_label = document.getElementById('sq_asset_finder_assetid_label');
607 
608  link_asset_picker = document.getElementById('link_assetid[assetid]');
609  link_asset_picker_id = document.getElementById('sq_asset_finder_link_assetid_assetid');
610  link_asset_picker_label = document.getElementById('sq_asset_finder_link_assetid_label');
611 
612  redirect_asset_picker = document.getElementById('page_redirect_assetid[assetid]');
613  redirect_asset_picker_id = document.getElementById('sq_asset_finder_page_redirect_assetid_assetid');
614  redirect_asset_picker_label = document.getElementById('sq_asset_finder_page_redirect_assetid_label');
615  var selected_assetid = '';
616  var selected_label = '';
617  if (all_asset_picker_id.value != '') {
618  selected_assetid = all_asset_picker_id.value;
619  selected_label = all_asset_picker_label.value;
620  } else if (link_asset_picker_id.value != '') {
621  selected_assetid = link_asset_picker_id.value;
622  selected_label = link_asset_picker_label.value;
623  } else if (redirect_asset_picker_id.value != '') {
624  selected_assetid = redirect_asset_picker_id.value;
625  selected_label = redirect_asset_picker_label.value;
626  }
627 
628  if (type == 'all_assets') {
629  all_asset_picker.value=selected_assetid;
630  all_asset_picker.disabled=false;
631  all_asset_picker_id.value=selected_assetid;
632  all_asset_picker_id.disabled=false;
633  all_asset_picker_label.value=selected_label;
634  span_all.style.display='block';
635  span_all.disabled=false;
636  span_link_manager.style.display='none';
637  span_link_manager.disabled=true;
638  link_asset_picker.value='';
639  link_asset_picker.disabled=true;
640  link_asset_picker_id.value='';
641  link_asset_picker_id.disabled=true;
642  link_asset_picker_label.value='';
643  span_redirect_page.style.display='none';
644  span_redirect_page.disabled=true;
645  redirect_asset_picker.value='';
646  redirect_asset_picker.disabled=true;
647  redirect_asset_picker_id.value='';
648  redirect_asset_picker_id.disabled=true;
649  redirect_asset_picker_label.value='';
650 
651  } else if (type == 'link_manager') {
652  all_asset_picker.value='';
653  all_asset_picker.disabled=true;
654  all_asset_picker_id.value='';
655  all_asset_picker_id.disabled=true;
656  all_asset_picker_label.value='';
657  span_all.style.display='none';
658  span_all.disabled=true;
659  span_link_manager.style.display='block';
660  span_link_manager.disabled=false;
661  link_asset_picker.value=selected_assetid;
662  link_asset_picker.disabled=false;
663  link_asset_picker_id.value=selected_assetid;
664  link_asset_picker_id.disabled=false;
665  link_asset_picker_label.value=selected_label;
666  span_redirect_page.style.display='none';
667  span_redirect_page.disabled=true;
668  redirect_asset_picker.value='';
669  redirect_asset_picker.disabled=true;
670  redirect_asset_picker_id.value='';
671  redirect_asset_picker_id.disabled=true;
672  redirect_asset_picker_label.value='';
673 
674  } else {
675  all_asset_picker.value='';
676  all_asset_picker.disabled=true;
677  all_asset_picker_id.value='';
678  all_asset_picker_id.disabled=true;
679  all_asset_picker_label.value='';
680  span_all.style.display='none';
681  span_all.disabled=true;
682  span_link_manager.style.display='none';
683  span_link_manager.disabled=true;
684  link_asset_picker.value='';
685  link_asset_picker.disabled=true;
686  link_asset_picker_id.value='';
687  link_asset_picker_id.disabled=true;
688  link_asset_picker_label.value='';
689  span_redirect_page.style.display='block';
690  span_redirect_page.disabled=false;
691  redirect_asset_picker.value=selected_assetid;
692  redirect_asset_picker.disabled=false;
693  redirect_asset_picker_id.value=selected_assetid;
694  redirect_asset_picker_id.disabled=false;
695  redirect_asset_picker_label.value=selected_label;
696  }
697  setUrl();
698  }
699  </script>
700  <?php
701  combo_box('asset_type_selector', $asset_selector, FALSE, $option_selected, 0, $js);
702 
703  ?>
704  </td>
705  </tr>
706  <tr>
707  <td class="label"><?php echo translate('select_asset'); ?>:</td>
708  <td colspan="3">
709  <span id="asset_finder_all" style="display:block">
710  <?php asset_finder('assetid', $_GET['assetid'], Array(), '', FALSE, 'setUrl'); ?>
711  </span>
712  <span id="asset_finder_link_asset" style="display:none">
713  <?php asset_finder('link_assetid', $_GET['assetid'], Array('link' => 'I'), '', FALSE, 'setUrl'); ?>
714  </span>
715  <span id="asset_finder_redirect_asset" style="display:none">
716  <?php asset_finder('page_redirect_assetid', $_GET['assetid'], Array('page_redirect' => 'I'), '', FALSE, 'setUrl'); ?>
717  <script type="text/javascript">
718  // Add event listener for Asset Selector's clear button
719  var all_clr_btn = document.getElementById('sq_asset_finder_assetid_clear_btn');
720  var link_clr_btn = document.getElementById('sq_asset_finder_link_assetid_clear_btn');
721  var page_redirect_clr_btn = document.getElementById('sq_asset_finder_page_redirect_assetid_clear_btn');
722  if (all_clr_btn.addEventListener) {
723  all_clr_btn.addEventListener('click', reset_type_selector, false);
724  link_clr_btn.addEventListener('click', reset_type_selector, false);
725  page_redirect_clr_btn.addEventListener('click', reset_type_selector, false);
726  } else if (all_clr_btn.attachEvent) {
727  // IE browser
728  all_clr_btn.attachEvent('onclick', reset_type_selector);
729  link_clr_btn.attachEvent('onclick', reset_type_selector);
730  page_redirect_clr_btn.attachEvent('onclick', reset_type_selector);
731 
732  }
733  </script>
734  </span>
735  </td>
736  </tr>
737  <tr>
738  <td class="label"><?php echo translate('anchor_name'); ?>:</td>
739  <td colspan="3"><?php text_box('anchor', $_GET['anchor'], 40, 0) ?></td>
740  </tr>
741  </table>
742  </fieldset>
743  </td>
744  </tr>
745  </table>
746  </td>
747  </tr>
748  <tr>
749  <td>
750  <table width="100%" cellspacing="0" cellpadding="0">
751  <tr>
752  <td valign="top" width="100%">
753  <fieldset>
754  <legend><?php echo translate('options'); ?></legend>
755  <table style="width:100%">
756  <tr>
757  <td class="label"><?php echo translate('id_name_text'); ?>:</td>
758  <td><?php text_box('id_name', $_GET['id_name'], 15); ?></td>
759  <td class="label"><?php echo translate('class_name_text'); ?>:</td>
760  <td><?php text_box('class_name', $_GET['class_name'], 15); ?></td>
761  </tr>
762  <tr>
763  <td class="label"><?php echo translate('title'); ?>:</td>
764  <td colspan="2"><?php text_box('link_title', $_GET['link_title'], 50); ?></td>
765  <td><?php
766  echo translate('include_summary').':';
767  check_box('show_summary', 1, $_GET['show_summary']); ?>
768  </td>
769  </tr>
770  </table>
771  </fieldset>
772  </td>
773  </tr>
774  </table>
775  </td>
776  </tr>
777  <tr>
778  <td>
779  <table width="100%" cellspacing="0" cellpadding="0">
780  <tr>
781  <td valign="top" width="100%">
782  <fieldset>
783  <legend><?php echo translate('new_window_options'); ?></legend>
784  <table style="width:100%">
785  <tr>
786  <td class="label" valign="top"><?php echo translate('target'); ?>:</td>
787  <td><?php text_box('target', $_GET['target']); ?></td>
788  </tr>
789  <tr>
790  <td class="label" rowspan="2" valign="top"><?php echo translate('new_window'); ?>:</td>
791  <td><?php combo_box('new_window', Array('0' => translate('no'), '1' => translate('yes'), '2' => translate('advanced')), FALSE, $_GET['new_window'], 1, 'onChange="javascript: enable_new_window(this.form, form_element_value(this));"'); ?></td>
792  </tr>
793  <tr>
794  <td>
795  <table border="0" cellspacing="0" cellpadding="0">
796  <tr>
797  <?php
798  $count = 0;
799  foreach ($new_window_bool_options as $var => $name) {
800  $count++;
801  ?>
802  <td width="33%">
803  <input type="checkbox" value="1" name="<?php echo $var?>" <?php echo ($_GET['new_window_options'][$var]) ? 'checked' : '';?>>
804  <?php echo $name?>
805  </td>
806  <?php
807  if ($count % 2 == 0) echo '</tr><tr>';
808  }
809  ?>
810  </tr>
811  <tr>
812  <td colspan="3">
813  <?php echo translate('size'); ?> : <input type="text" value="<?php echo htmlspecialchars($_GET['new_window_options']['width']) ?>" size="3" name="width"> (w) x <input type="text" value="<?php echo htmlspecialchars($_GET['new_window_options']['height']) ?>" size="3" name="height"> (h)
814  </td>
815  </tr>
816  </table>
817  </td>
818  </tr>
819  </table>
820  </fieldset>
821  </td>
822  </tr>
823  </table>
824  </td>
825  </tr>
826  </table>
827 
828  <div style="margin-top: 5px; text-align: right;">
829  <hr />
830  <button type="button" name="ok" onclick="return onOK();"><?php echo translate('ok'); ?></button>
831  <button type="button" name="cancel" onclick="return onCancel();"><?php echo translate('cancel'); ?></button>
832  </div>
833  </td>
834  <tr>
835  </table>
836  </form>
837 
838  <!-- Search results -->
839  <div id="new-message-popup"><div id="new-message-popup-titlebar"><div id="new-message-popup-close">[ <a href="#" onclick="document.getElementById('new-message-popup').style.display = 'none'; return false;">x</a> ]</div><span id="new-message-popup-title">Searched for ''</span></div>
840  <div id="new-message-popup-details"></div>
841  </div>
842  <div id="search-wait-popup"><div id="search-wait-popup-titlebar"><div id="search-wait-popup-close">[ <a href="#" onclick="document.getElementById('search-wait-popup').style.display = 'none'; return false;">x</a> ]</div><span id="search-wait-popup-title">Search in Progress</span></div>
843  <div id="search-wait-popup-details">Your search is being processed, please wait...</div>
844  </div>
845 
846  <script type="text/javascript"><!--
847  var current = 1;
848  var results_per_page = <?php echo $GLOBALS['SQ_SYSTEM']->getUserPrefs('search_manager', 'SQ_SEARCH_BACKEND_PAGE_SIZE') !== FALSE ? $GLOBALS['SQ_SYSTEM']->getUserPrefs('search_manager', 'SQ_SEARCH_BACKEND_PAGE_SIZE') : 5; ?>;
849  var total_results = 0;
850 
851  function jump_to_search_results(page) {
852  // Show the correct page
853  document.getElementById("search-result-page-" + current).style.display = 'none';
854  document.getElementById("search-result-page-" + page).style.display = 'block';
855 
856  // Update page start and end markers
857  document.getElementById("sq-search-results-page-start").innerHTML = (results_per_page * (page - 1)) + 1;
858  document.getElementById("sq-search-results-page-end").innerHTML = Math.min(total_results, results_per_page * page);
859 
860  for (i = ((page - 1) * results_per_page) + 1; i <= Math.min(total_results, page * results_per_page); i++) {
861  // collapse the new page when page is switched, so they're
862  // back to just the tag lines
863  document.getElementById("search-result-" + i + "-expand-link").innerHTML = '+';
864  document.getElementById("search-result-" + i + "-detail").style.display = 'none';
865  }
866 
867  current = page;
868  }
869 
870  function set_asset_finder_from_search(assetid, label, url, linkid) {
871  document.cookie = 'lastSelectedAssetId=' + escape(assetid);
872 
873  ASSET_FINDER_OBJ.set_hidden_field('assetid[assetid]', assetid);
874  ASSET_FINDER_OBJ.set_hidden_field('assetid[url]', url);
875  ASSET_FINDER_OBJ.set_hidden_field('assetid[linkid]', linkid);
876  ASSET_FINDER_OBJ.set_text_field('sq_asset_finder_assetid_label', (assetid == 0) ? '' : label + ' (Id : #' + assetid + ')');
877 
878  document.getElementById("new-message-popup").style.display = 'none';
879  setUrl('', './?a=' + assetid);
880  }
881 
882  // --></script>
883  </body>
884 </html>