18 require_once SQ_CORE_PACKAGE_PATH.
'/page/page_edit_fns.inc';
41 parent::__construct();
42 $this->static_screens[
'details'][
'force_unlock'] = FALSE;
59 $options = $asset->attr(
'url_rewriting_options');
61 foreach ($options as $i => $v) {
72 if ($asset->writeAccess(
'attributes')) {
74 radio_button($prefix.
'_rewrite_type',
'none', ($overall ==
'none'),
'',
'id="'.$prefix.
'_rewrite_type_none"');
75 label(translate(
'cms_remote_content_tunneling_rule_none'), $prefix.
'_rewrite_type_none');
78 radio_button($prefix.
'_rewrite_type',
'all', ($overall ==
'all'),
'',
'id="'.$prefix.
'_rewrite_type_all"');
79 label(translate(
'cms_remote_content_tunneling_rule_all'), $prefix.
'_rewrite_type_all');
80 echo
'<br /> ';
81 echo translate(
'cms_remote_content_tunneling_rule_all_note');
84 radio_button($prefix.
'_rewrite_type',
'some', ($overall ==
'some'),
'',
'id="'.$prefix.
'_rewrite_type_some"');
85 label(translate(
'cms_remote_content_tunneling_rule_some'), $prefix.
'_rewrite_type_some');
88 $pf = $prefix.
'_rewrite_some_options';
91 <div style=
"margin-left: 5ex" id=
"<?php echo $prefix; ?>_rewrite_type_some_options">
92 <input type=
"checkbox" name=
"<?php echo $pf; ?>[]" value=
"remote_url" id=
"<?php echo $pf; ?>_remote_url" <?php
if ($options[
'remote_url']) echo
'checked="checked"'; ?> <?php
if ($overall !=
'some') echo
'disabled="disabled"'; ?> />
93 <label
for=
"<?php echo $pf; ?>_remote_url"><?php echo translate(
'cms_remote_content_tunneling_option_remote_url'); ?></label>
96 <input type=
"checkbox" name=
"<?php echo $pf; ?>[]" value=
"remote_domain" id=
"<?php echo $pf; ?>_remote_domain" <?php echo $options[
'remote_domain'] ?
'checked="checked"' :
''; ?> <?php
if ($overall !=
'some') echo
'disabled="disabled"'; ?> />
97 <label
for=
"<?php echo $pf; ?>_remote_domain"><?php echo translate(
'cms_remote_content_tunneling_option_remote_domain'); ?></label>
100 <input type=
"checkbox" name=
"<?php echo $pf; ?>[]" value=
"white_list" id=
"<?php echo $pf; ?>_white_list" <?php
if ($options[
'white_list']) echo
'checked="checked"'; ?> <?php
if ($overall !=
'some') echo
'disabled="disabled"'; ?> />
101 <label
for=
"<?php echo $pf; ?>_white_list"><?php echo translate(
'cms_remote_content_tunneling_option_white_list'); ?></label>
103 <textarea name=
"<?php echo $prefix.'_white_list'; ?>" onfocus=
"document.getElementById('<?php echo $pf; ?>_white_list').checked = true" <?php
if ($overall !=
'some') echo
'disabled="disabled"'; ?>><?php
104 $urls = $asset->attr(
'url_white_list');
105 echo (is_array($urls)) ? implode(
"\n", $urls) :
'';
107 <br /><em>(Enter one URL per line)</em>
110 <script type=
"text/javascript"><!--
111 var onclickfn =
new Function(
"toggleOptionDisplay(this);");
112 var inputs = document.getElementsByName(
'<?php echo $prefix; ?>_rewrite_type');
113 for (var i=0; i < inputs.length; i++) {
114 inputs[i].onclick = onclickfn;
116 function toggleOptionDisplay(checkbox)
118 var siblings = document.getElementsByName(checkbox.name);
119 for (var j=0; j < siblings.length; j++) {
120 var container = document.getElementById(siblings[j].
id+
'_options');
121 if (container == null)
continue;
122 var tags = [
'INPUT',
'SELECT',
'TEXTAREA'];
124 var inputs = container.getElementsByTagName(tags[t]);
125 for (var i=0; i < inputs.length; i++) {
126 inputs[i].disabled = (siblings[j] != checkbox);
139 echo translate(
'cms_remote_content_tunneling_rule_'.$overall);
140 if ($overall ==
'some') {
141 echo
'<ul style="margin-top: 3px">';
142 foreach (Array(
'remote_url',
'remote_domain',
'white_list') as $type) {
143 if ($options[$type]) {
144 echo
'<li>'.translate(
'cms_remote_content_tunneling_option_'.$type);
145 if ($type ==
'white_list') {
146 echo
'<br />'.implode(
'<br />', $asset->attr(
'url_white_list'));
183 if ($asset->writeAccess()) {
184 $options = $asset->attr(
'url_rewriting_options');
185 if (isset($_POST[$prefix.
'_white_list'])) {
186 $white_list = explode(
"\n", trim($_POST[$prefix.
'_white_list']));
188 foreach ($white_list as $i => $v) {
189 if (empty($v)) unset($white_list[$i]);
190 if (FALSE !== ($x = strpos(substr($v, 0, 7),
'://'))) {
191 $white_list[$i] = substr($v, $x+3);
194 $asset->setAttrValue(
'url_white_list', $white_list);
196 switch ($_POST[$prefix.
'_rewrite_type']) {
198 foreach ($options as $i => $v) {
199 $options[$i] = FALSE;
201 $options[
'all'] = TRUE;
204 foreach ($options as $i => $v) {
205 $options[$i] = FALSE;
209 $posted_options = array_get_index($_POST, $prefix.
'_rewrite_some_options', Array());
210 foreach ($options as $i => $v) {
211 $options[$i] = in_array($i, $posted_options);
213 if (empty($white_list)) {
214 $options[
'white_list'] = FALSE;
218 $asset->setAttrValue(
'url_rewriting_options', $options);
241 ?><table width=
"100%" class=
"sq-backend-table">
245 if ($asset->writeAccess(
'attributes')) {
246 ?><th>Delete</th><?php
249 foreach ($asset->attr(
'post_variables') as $index => $variable) {
251 <td><?php echo $variable[
'name']; ?></td>
252 <td><?php echo $variable[
'value']; ?></td><?php
253 if ($asset->writeAccess(
'attributes')) {
254 ?><td><?php check_box($prefix.
'_delete['.$index.
']'); ?></td><?php
278 if (!$asset->writeAccess(
'attributes'))
return FALSE;
281 text_box($prefix.
'_name',
'');
283 text_box($prefix.
'_value',
'', 50);
303 $post_variables = $asset->attr(
'post_variables');
305 $delete_variables = Array();
306 if (isset($_POST[$prefix.
'_delete'])) {
307 $delete_variables = array_keys($_POST[$prefix.
'_delete']);
311 foreach ($delete_variables as $index) {
312 unset($post_variables[$index]);
315 $create_variables = Array();
316 if (isset($_POST[$prefix.
'_name']) && !empty($_POST[$prefix.
'_name'])) {
317 $create_variables[trim($_POST[$prefix.
'_name'])] = $_POST[$prefix.
'_value'];
321 foreach ($create_variables as $name => $value) {
323 if (strpos(print_r($post_variables, TRUE),
'[name] => '.$name.
"\n") === FALSE) {
326 $post_variables[] = Array(
331 trigger_localised_error(
'CMS0059', E_USER_NOTICE);
334 return $asset->setAttrValue(
'post_variables', $post_variables);
351 $write_access = $asset->writeAccess(
'attributes');
353 $tag_replacements = $asset->attr(
'tag_replacements');
354 if (!empty($tag_replacements) || $write_access) {
356 <table width=
"100%" class=
"sq-backend-table">
357 <tr><th><?php echo translate(
'cms_remote_content_tag'); ?></th><th><?php echo translate(
'cms_remote_content_start_tag'); ?></th><th><?php echo translate(
'cms_remote_content_end_tag'); ?></th><th><?php echo translate(
'cms_remote_content_remove_contents'); ?></th><?php echo (($write_access && !empty($tag_replacements)) ?
'<th>'.translate(
'delete').
'</th>' :
''); ?></tr>
360 foreach ($tag_replacements as $tag => $tag_info) {
364 <td><?php text_box($prefix.
'_tag_replacments[reps]['.$tag.
'][tag]', $tag, 30); ?></td>
365 <td><?php text_box($prefix.
'_tag_replacments[reps]['.$tag.
'][start_tag]', $tag_info[
'start_tag'], 30); ?></td>
366 <td><?php text_box($prefix.
'_tag_replacments[reps]['.$tag.
'][end_tag]', $tag_info[
'end_tag'], 30); ?></td>
367 <td><?php check_box($prefix.
'_tag_replacments[reps]['.$tag.
'][remove_content]', TRUE, ($tag_info[
'remove_content'] ? TRUE : FALSE)); ?></td>
368 <td><?php check_box($prefix.
'_tag_replacments[reps]['.$tag.
'][delete]'); ?>
374 <td><?php echo htmlspecialchars($tag); ?></td>
375 <td><?php echo htmlspecialchars($tag_info[
'start_tag']); ?></td>
376 <td><?php echo htmlspecialchars($tag_info[
'end_tag']); ?></td>
377 <td><?php echo ($tag_info[
'remove_content'] ? translate(
'yes') : translate(
'no')); ?></td>
382 }
else if (!$write_access) {
383 echo translate(
'cms_remote_content_no_tag_replacements');
389 <td><?php text_box($prefix.
'_tag_replacments[reps][new][tag]',
'', 30); ?></td>
390 <td><?php text_box($prefix.
'_tag_replacments[reps][new][start_tag]',
'', 30); ?></td>
391 <td><?php text_box($prefix.
'_tag_replacments[reps][new][end_tag]',
'', 30); ?></td>
392 <td><?php check_box($prefix.
'_tag_replacments[reps][new][remove_content]'); ?></td>
393 <?php echo (!empty($tag_replacements) ?
'<td> </td>' :
''); ?>
416 $reps = $_POST[$prefix.
'_tag_replacments'][
'reps'];
418 $replacements = Array();
419 foreach ($reps as $rep_info) {
420 if (isset($rep_info[
'delete']) || empty($rep_info[
'tag'])) {
424 $remove_content = FALSE;
425 if (isset($rep_info[
'remove_content'])) {
426 $remove_content = TRUE;
429 $replacements[$rep_info[
'tag']] = Array(
430 'start_tag' => $rep_info[
'start_tag'],
431 'end_tag' => $rep_info[
'end_tag'],
432 'remove_content' => $remove_content,
436 if (!$asset->setAttrValue(
'tag_replacements', $replacements)) {