17 require_once SQ_LIB_PATH.
'/html_form/html_form.inc';
36 var $static_screens = Array(
39 'force_unlock' => TRUE,
40 'lock_type' =>
'menu',
42 'permissions' => Array(
43 'name' =>
'Permissions',
44 'force_unlock' => FALSE,
45 'lock_type' =>
'permissions',
49 'force_unlock' => TRUE,
50 'lock_type' =>
'workflow',
54 'force_unlock' => TRUE,
55 'lock_type' =>
'roles',
57 'metadataSchemas' => Array(
58 'name' =>
'Metadata Schemas',
59 'force_unlock' => TRUE,
60 'lock_type' =>
'metadata',
64 'force_unlock' => TRUE,
65 'lock_type' =>
'metadata',
67 'dependants' => Array(
68 'name' =>
'Dependants',
69 'force_unlock' => TRUE,
70 'lock_type' =>
'none',
74 'force_unlock' => TRUE,
75 'lock_type' =>
'links',
79 'force_unlock' => TRUE,
84 'force_unlock' => TRUE,
85 'lock_type' =>
'none',
89 'force_unlock' => TRUE,
90 'lock_type' =>
'none',
94 'force_unlock' => TRUE,
95 'lock_type' =>
'none',
97 'lookupValues' => Array(
98 'name' =>
'Lookup Settings',
99 'force_unlock' => FALSE,
100 'lock_type' =>
'lookupValues',
104 'force_unlock' => TRUE,
105 'lock_type' =>
'menu',
109 'force_unlock' => FALSE,
110 'lock_type' =>
'all',
139 $wa = $asset->writeAccess(
'lookups');
141 $paths = $asset->getWebPaths();
143 foreach ($paths as $path) {
145 text_box($prefix.
'_paths[]', $path, 25);
152 if ($wa) text_box($prefix.
'_paths[]',
'', 25);
171 $admin_access = $asset->adminAccess(
'lookups');
173 $remap_manager = $GLOBALS[
'SQ_SYSTEM']->am->getSystemAsset(
'remap_manager');
174 $remap_urls = $remap_manager->getRemapURLs($asset);
176 if (empty($remap_urls)) {
177 echo translate(
'no_associated_remaps');
182 $total_assets = count($remap_urls);
183 $num_pages = ceil($total_assets / $num_per_page);
185 $page_num = array_get_index($_POST, $prefix.
'_remap_urls_page', 1);
186 $page_num = max($page_num, 1);
187 $page_num = min($page_num, $num_pages);
189 if ($num_pages == 1) {
190 $page_tag = translate(
'page_number', $page_num, $num_pages);
192 $page_tag = translate(
'page_number_with_pager', $page_num, $num_pages, $prefix.
'_remap_urls_page');
194 $asset_count_tag = translate(
'item_range', ($page_num - 1) * $num_per_page + 1, min($total_assets, $page_num * $num_per_page), $total_assets, strtolower(translate(
'remap_entries')));
196 $remap_urls = array_slice($remap_urls, ($page_num - 1) * $num_per_page, $num_per_page);
199 'first' =>
'<<',
200 'previous' =>
'<',
203 'last' =>
'>>',
207 $links[
'first'] =
'<a title="'.translate(
'pagination_go_to_first').
'" style="text-decoration: none; color: #fff" href="#" onClick="return sq_pager_jump(\''.$prefix.
'_remap_urls_page\', 1)">'.$links[
'first'].
'</a>';
208 $links[
'previous'] =
'<a title="'.translate(
'pagination_go_to_previous').
'" style="text-decoration: none; color: #fff" href="#" onClick="return sq_pager_jump(\''.$prefix.
'_remap_urls_page\', '.($page_num - 1).
')">'.$links[
'previous'].
'</a>';
210 $links[
'first'] =
'<span title="'.translate(
'pagination_cannot_go_further_back').
'." style="color: #333">'.$links[
'first'].
'</span>';
211 $links[
'previous'] =
'<span title="'.translate(
'pagination_cannot_go_further_back').
'." style="color: #333">'.$links[
'previous'].
'</span>';
214 if ($page_num < $num_pages) {
215 $links[
'last'] =
'<a title="'.translate(
'pagination_go_to_last').
'" style="text-decoration: none; color: #fff" href="#" onClick="return sq_pager_jump(\''.$prefix.
'_remap_urls_page\', '.$num_pages.
')">'.$links[
'last'].
'</a>';
216 $links[
'next'] =
'<a title="'.translate(
'pagination_go_to_next').
'" style="text-decoration: none; color: #fff" href="#" onClick="return sq_pager_jump(\''.$prefix.
'_remap_urls_page\', '.($page_num + 1).
')">'.$links[
'next'].
'</a>';
218 $links[
'last'] =
'<span title="'.translate(
'pagination_cannot_go_further_forward').
'." style="color: #333">'.$links[
'last'].
'</span>';
219 $links[
'next'] =
'<span title="'.translate(
'pagination_cannot_go_further_forward').
'." style="color: #333">'.$links[
'next'].
'</span>';
222 hidden_field($prefix.
'_remap_urls_page', $page_num); ?>
224 <table
class=
"sq-backend-table">
225 <tr
class=
"sq-backend-table-row">
226 <td
class=
"sq-backend-table-header-header"><?php echo implode(
' ', $links) ?></td>
227 <td
class=
"sq-backend-table-header-header" colspan=
"<?php echo ($admin_access === TRUE) ? 5 : 4 ?>" style=
"text-align: right; font-weight: normal"><?php echo $asset_count_tag; ?></span></td>
230 <td
class=
"sq-backend-table-header"><?php echo translate(
'url'); ?></td>
231 <td
class=
"sq-backend-table-header"><?php echo translate(
'remap_url'); ?></td>
232 <td
class=
"sq-backend-table-header"><?php echo translate(
'expires'); ?></td>
233 <td
class=
"sq-backend-table-header"><?php echo translate(
'type'); ?></td>
237 <td
class=
"sq-backend-table-header">
239 check_box($prefix.
'_select_all',
'1', FALSE,
"check_all(document.main_form, '{$prefix}_delete_remap', this.checked);");
240 label(translate(
'delete_question'), $prefix.
'_select_all');
246 <td
class=
"sq-backend-table-header"><?php echo translate(
'never_delete'); ?></td>
249 foreach ($remap_urls as $url_info) {
250 if (empty($url_info[
'expires'])) {
251 $expires = translate(
'never');
253 $expires = $GLOBALS[
'SQ_SYSTEM']->datetime(iso8601_ts($url_info[
'expires']));
257 <td
class=
"sq-backend-table-cell"><?php echo $url_info[
'url']; ?></td>
258 <td
class=
"sq-backend-table-cell"><?php echo $url_info[
'remap_url']; ?></td>
259 <td
class=
"sq-backend-table-cell"><?php echo $expires; ?></td>
260 <td
class=
"sq-backend-table-cell"><?php echo ((
int)$url_info[
'auto_remap'] === 1) ? translate(
'automatic') : (($url_info[
'auto_remap'] === NULL) ? translate(
'unknown') : translate(
'manual')); ?></td>
264 <td
class=
"sq-backend-table-cell">
266 check_box($prefix.
'_delete_remap['.$url_info[
'url'].
']', 1, FALSE,
'', $url_info[
'never_delete'] ?
'disabled' :
'');
273 <td
class=
"sq-backend-table-cell"><img src=
"<?php echo sq_web_path('lib')."/web/images/
".($url_info['never_delete'] ? "tick.gif
" : "cross.gif
"); ?>" width=
"15" height=
"15" /></td>
282 return $admin_access;
299 if (!isset($_POST[$prefix.
'_paths']))
return FALSE;
305 $auto_add_remaps = isset($_POST[$prefix.
'_remap_upon_webpath_change']);
307 if (!$asset->saveWebPaths(array_values($_POST[$prefix.
'_paths']), $auto_add_remaps)) {
311 $hh = $GLOBALS[
'SQ_SYSTEM']->getHipoHerder();
312 $vars = Array(
'assetids' => Array($asset->id));
313 $hh->queueHipo(
'hipo_job_update_lookups', $vars);
332 if (!$asset->adminAccess(
'lookups'))
return FALSE;
334 $GLOBALS[
'SQ_SYSTEM']->changeDatabaseConnection(
'db2');
335 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'BEGIN');
337 if (isset($_POST[$prefix.
'_delete_remap'])) {
338 $urls = array_keys($_POST[$prefix.
'_delete_remap']);
340 $remap_manager = $GLOBALS[
'SQ_SYSTEM']->am->getSystemAsset(
'remap_manager');
341 $remap_urls = $remap_manager->getRemapURLs($asset);
343 foreach ($remap_urls as $url_info) {
344 foreach ($urls as $index => $url_to_delete) {
345 if ($url_info[
'url'] === $url_to_delete && $url_info[
'never_delete']) {
346 unset($urls[$index]);
352 $bind_vars = Array(
'urls' => $urls);
355 throw new Exception(
'Unable to delete remaps due to database error: '.$e->getMessage());
359 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'COMMIT');
360 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
379 $urls = $asset->getLookups();
381 echo translate(
'no_associated_urls');
383 usort($urls, create_function(
'$a, $b',
'return strcmp($a[\'url\'], $b[\'url\']);'));
384 foreach ($urls as $data) {
386 echo
'http://'.$data[
'url'],
'<br/>';
388 if ($data[
'https']) {
389 echo
'https://'.$data[
'url'],
'<br/>';
394 if ($asset->force_secure ===
'1') {
396 $o->note(translate(
'force_secure_set_on_asset'));
414 if (!$asset->adminAccess(
'lookups'))
return FALSE;
416 $urls = $asset->getURLs();
418 $o->openField(translate(
'url_remappings'));
419 label(translate(
'url_remap_no_associated_asset_urls'));
425 foreach ($urls as $url) {
426 if ($url[
'http'] == 1) {
427 $contents[
'http://'.$url[
'url']] =
'http://'.$url[
'url'];
429 if ($url[
'https'] == 1) {
430 $contents[
'https://'.$url[
'url']] =
'https://'.$url[
'url'];
434 $remap_manager = $GLOBALS[
'SQ_SYSTEM']->am->getSystemAsset(
'remap_manager');
435 $never_delete = ($remap_manager->attr(
'never_delete_remap_default') == FALSE) ? 0 : 1;
437 $o->openField(translate(
'old_url'));
438 text_box($prefix.
'_add_remap_old_url',
'', 50);
441 $o->openField(translate(
'new_url'));
442 combo_box($prefix.
'_add_remap_new_url', $contents);
443 $o->note(translate(
'url_remap_explanation'));
446 $o->openField(translate(
'expires'));
447 text_box($prefix.
'_add_remap_expires_days',
'', 5);
448 label(translate(
'days'), $prefix.
'_add_remap_expires_days');
451 $o->openField(translate(
'never_delete'));
452 check_box($prefix.
'_add_remap_never_delete', TRUE, $never_delete);
470 if (!$asset->adminAccess(
'lookups'))
return FALSE;
473 if (!isset($_POST[$prefix.
'_add_remap_old_url']) || !isset($_POST[$prefix.
'_add_remap_new_url'])) {
476 $old_url = trim($_POST[$prefix.
'_add_remap_old_url']);
477 $new_url = trim($_POST[$prefix.
'_add_remap_new_url']);
480 if (empty($old_url))
return FALSE;
482 if (isset($_POST[$prefix.
'_add_remap_expires_days'])) {
483 $expires_days = (int)$_POST[$prefix.
'_add_remap_expires_days'];
484 if ($expires_days > 0) {
485 $expires = strtotime(
'+ '.$expires_days.
' days');
489 $remap_manager = $GLOBALS[
'SQ_SYSTEM']->am->getSystemAsset(
'remap_manager');
490 $never_delete = isset($_POST[$prefix.
'_add_remap_never_delete']) ? 1 : 0;
491 $remap_manager->addRemapURL($old_url, $new_url, $expires, $never_delete, FALSE);
508 return $GLOBALS[
'SQ_SYSTEM']->getWorkflowManager()->isWorkflowComplete($asset->id);
530 $links = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($asset->id, SQ_LINK_NOTICE,
'', FALSE,
'major', $link_value);
532 $link = $GLOBALS[
'SQ_SYSTEM']->am->getLink($asset->id, SQ_LINK_NOTICE,
'', FALSE, $link_value);
533 $links = empty($link) ? Array() : Array($link);
536 if (empty($field_name)) {
537 $field_name = $asset->getPrefix().
'_'.str_replace(
' ',
'_', strtolower($link_value));
540 if (!$asset->writeAccess(
'links')) {
542 echo
'<i>'.translate(
'none').
'</i>';
544 foreach ($links as $link) {
545 echo get_asset_tag_line($link[
'minorid']);
552 foreach ($links as $link) {
553 $current[] = $link[
'minorid'];
555 multiple_asset_finder($field_name, $current, $type_codes);
557 $current = empty($links) ? 0 : $links[0][
'minorid'];
558 asset_finder($field_name, $current, $type_codes);
579 if (empty($field_name)) {
580 $field_name = $asset->getPrefix().
'_'.str_replace(
' ',
'_', strtolower($link_value));
582 if (!isset($_POST[$field_name]))
return FALSE;
586 $submitted_minorids = Array();
587 foreach ($_POST[$field_name] as $elt) {
588 if (!empty($elt[
'assetid'])) {
589 $submitted_minorids[] = $elt[
'assetid'];
592 $submitted_minorids = array_unique($submitted_minorids);
594 $existing_minorids = Array();
595 $to_delete = Array();
596 $links = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($asset->id, SQ_LINK_NOTICE,
'', FALSE,
'major', $link_value);
597 foreach ($links as $link) {
598 if (in_array($link[
'minorid'], $submitted_minorids)) {
599 $existing_minorids[] = $link[
'minorid'];
601 $to_delete[] = $link[
'linkid'];
604 $to_add = array_diff($submitted_minorids, $existing_minorids);
605 $to_delete = array_unique($to_delete);
607 if (empty($to_add) && empty($to_delete)) {
611 $GLOBALS[
'SQ_SYSTEM']->changeDatabaseConnection(
'db2');
612 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'BEGIN');
615 foreach ($to_add as $schemaid) {
616 $schema = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($schemaid);
617 if (!$GLOBALS[
'SQ_SYSTEM']->am->createAssetLink($asset, $schema, SQ_LINK_NOTICE, $link_value)) {
623 foreach ($to_delete as $linkid) {
624 if (!$GLOBALS[
'SQ_SYSTEM']->am->deleteAssetLink($linkid)) {
630 $GLOBALS[
'SQ_SYSTEM']->doTransaction($success ?
'COMMIT' :
'ROLLBACK');
631 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
635 $link = $GLOBALS[
'SQ_SYSTEM']->am->getLink($asset->id, SQ_LINK_NOTICE,
'', FALSE, $link_value);
638 if (!empty($link) && $link[
'minorid'] == $_POST[$field_name][
'assetid']) {
642 $GLOBALS[
'SQ_SYSTEM']->changeDatabaseConnection(
'db2');
643 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'BEGIN');
648 $success = (bool) $asset->deleteLink($link[
'linkid']);
651 if ($success && !empty($_POST[$field_name][
'assetid'])) {
652 $selected_asset = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($_POST[$field_name][
'assetid']);
653 if (!is_null($selected_asset)) {
654 $success = (bool) $asset->createLink($selected_asset, SQ_LINK_NOTICE, $link_value);
658 $GLOBALS[
'SQ_SYSTEM']->doTransaction($success ?
'COMMIT' :
'ROLLBACK');
659 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
677 return $GLOBALS[
'SQ_SYSTEM']->am->installed(
'search_manager');
692 return ($asset->id == 0);
724 $write_access = $asset->writeAccess(
'lookups');
729 $o->openField(translate(
'web_paths_auto_add_remaps'));
730 $rm = $GLOBALS[
'SQ_SYSTEM']->am->getSystemAsset(
'remap_manager');
731 $remap_upon_webpath_change = $rm->attr(
'remap_upon_webpath_change');
734 check_box($prefix.
'_remap_upon_webpath_change', TRUE, $remap_upon_webpath_change);
736 $o->note(translate(
'web_paths_auto_add_remaps_note'));
741 return $write_access;
758 $editable_link_types = Array(
759 SQ_LINK_TYPE_1 => link_type_name(SQ_LINK_TYPE_1),
760 SQ_LINK_TYPE_2 => link_type_name(SQ_LINK_TYPE_2),
763 if (isset($_REQUEST[
'parent_assetid'])){
764 $restricted_sites = $GLOBALS[
'SQ_SYSTEM']->getUserPrefs(
'site',
'SQ_CHILD_CREATE_LINK_TYPE_2_RESTRICT');
765 $parent_sites = array_keys($GLOBALS[
'SQ_SYSTEM']->am->getParents($_REQUEST[
'parent_assetid'],
'site'));
766 $asset_info = $GLOBALS[
'SQ_SYSTEM']->am->getAssetInfo($_REQUEST[
'parent_assetid'],
'site');
767 if (!empty($asset_info)) $parent_sites[] = $_REQUEST[
'parent_assetid'];
769 if (array_intersect($restricted_sites, $parent_sites) != Array()) {
770 unset($editable_link_types[SQ_LINK_TYPE_1]);
771 $_REQUEST[
'link_type'] = SQ_LINK_TYPE_2;
776 $o->openField(translate(
'link_type'));
777 combo_box(
'link_type', $editable_link_types, FALSE, isset($_REQUEST[
'link_type']) ? $_REQUEST[
'link_type'] : SQ_LINK_TYPE_1);