17 require_once SQ_PACKAGES_PATH.
'/cms/listing_engine/listing_engine_edit_fns.inc';
39 parent::__construct();
40 $this->static_screens[
'details'][
'lock_type'] =
'content';
41 $this->static_screens[
'details'][
'force_unlock'] = FALSE;
59 function paintRootAsset(&$asset, &$o, $prefix, $category=
'', $read_only=FALSE)
62 if (!empty($category)) $link_value .=
'_'.$category;
63 $root_link = $GLOBALS[
'SQ_SYSTEM']->am->getLink($asset->id, SQ_LINK_NOTICE,
'asset', FALSE, $link_value);
66 $write_access = FALSE;
68 $write_access = $asset->writeAccess(
'links');
73 if (!empty($root_link)) {
74 $root_asset = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($root_link[
'minorid']);
76 if (!is_null($root_asset)) {
77 echo $root_asset->name.
' (Id: #'.$root_asset->id.
')';
79 echo translate(
'sch_no_root_node_selected');
82 asset_finder($prefix.
'_rootid', (!empty($root_link)) ? $root_link[
'minorid'] :
'');
102 if (!isset($_POST[$prefix.
'_rootid'][
'assetid'])) {
105 $new_root = $_POST[$prefix.
'_rootid'][
'assetid'];
108 $link_value =
'root';
109 $root_link = $GLOBALS[
'SQ_SYSTEM']->am->getLink($asset->id, SQ_LINK_NOTICE,
'', FALSE, $link_value);
112 if (!empty($root_link) && $root_link[
'minorid'] == $new_root) {
118 $GLOBALS[
'SQ_SYSTEM']->changeDatabaseConnection(
'db2');
119 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'BEGIN');
122 if (!empty($root_link) && !$GLOBALS[
'SQ_SYSTEM']->am->deleteAssetLink($root_link[
'linkid'])) {
124 }
else if ($new_root) {
125 $root = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($new_root);
126 if (!is_null($root)) {
127 if (!$asset->createLink($root, SQ_LINK_NOTICE, $link_value)) {
129 trigger_localised_error(
'SCH0012', E_USER_WARNING, $root->name, $root->id);
135 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'COMMIT');
137 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
140 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
158 $write_access = $asset->writeAccess(
'all');
159 $fields = $asset->attr(
'fields');
161 $query_types = Array(
162 'none' =>
'-- '.ucfirst(translate(
'sch_page_add_data_source').
' --'),
163 'include_all' => ucfirst(translate(
'include_all')),
164 'standard' => ucfirst(translate(
'sch_page_datatype_standard')),
165 'asset_attrib' => ucfirst(translate(
'sch_page_datatype_attribute')),
166 'metadata' => ucfirst(translate(
'sch_page_datatype_metadata')),
170 <table
class ="sq-backend-table" border=
"1" style=
"margin-bottom: 7px">
172 <th rowspan=
"2"><?php echo translate(
'name'); ?></th>
173 <th colspan=
"<?php echo $write_access ? 3 : 2; ?>"><?php echo translate(
'sch_page_data_sources'); ?></th>
174 <th rowspan=
"2"><?php echo translate(
'sch_page_word_logic'); ?></th>
178 <th rowspan=
"2"><?php echo translate(
'delete'); ?></th>
184 <th><?php echo translate(
'type');?></th>
185 <th <?php if (!$write_access) echo 'colspan=2';?>><?php echo translate(
'details');?> </th>
189 <th><?php echo translate(
'delete'); ?></th>
196 foreach ($fields as $field_name => $field_data) {
197 if ($field_data[
'exclude_field'])
continue;
199 $field_datasources = $field_data[
'data_sources'];
200 if ((!empty($field_datasources)) && ($field_datasources[0][
'type'] ==
'exclude')) {
203 if ($write_access) $field_datasources[] =
'new';
204 foreach ($field_datasources as $index => $field_datasource) {
210 <td rowspan=
"<?php echo count($field_datasources);?>"> <?php echo $field_data[
'name'] ?></td>
214 <td
class=
"sq-backend-data" style=
"padding: 4px;">
216 if ($field_datasource ==
'new') {
218 combo_box($prefix.
'_fields['.$field_name.
'][new_data_source_type]', $query_types, FALSE,
'none');
221 $type = array_get_index($field_datasource,
'type');
222 echo $query_types[$type];
228 if ($field_datasource !=
'new') {
232 if (!isset($field_datasource[
'params'])) {
233 $field_datasources[$index][
'params'] = Array();
235 $search_types = $asset->attr(
'types');
236 $search_type = array_get_index($field_datasources[$index][
'params'],
'asset_type',
'0');
237 $type_names = $GLOBALS[
'SQ_SYSTEM']->am->getTypeInfo(array_keys($search_types),
'name');
239 $options = Array(
'' =>
'-- '.translate(
'select_asset_type').
' --');
240 foreach (array_keys($search_types) as $this_type) {
241 $options[$this_type] = $type_names[$this_type];
243 combo_box($prefix.
'_fields['.$field_name.
'][data_sources]['.$index.
'][params][asset_type]', $options, FALSE, $search_type);
245 echo
'<strong>'.translate(
'asset_type').
':</strong> ';
249 if ($search_type !==
'0') {
250 echo sq_print_icon($GLOBALS[
'SQ_SYSTEM']->am->getAssetIconURL($search_type), 16, 16, $type_names[$search_type], $type_names[$search_type],
' align="absmiddle"');
251 echo $type_names[$search_type];
253 echo translate(
'no_asset_selected');
257 if (!isset($field_datasource[
'params'][
'attrid']) || empty($search_type)) {
260 $selected_attr = $field_datasource[
'params'][
'attrid'];
262 if (!empty($search_type)) {
263 $asset_type_attrs = $GLOBALS[
'SQ_SYSTEM']->am->getAssetTypeAttributes($search_type, Array(
'attrid',
'name'));
265 $type_attrs = Array(
'' =>
'-- '.translate(
'select_attribute').
' --');
266 foreach ($asset_type_attrs as $attr_id => $attr_name) {
267 $type_attrs[$attr_id] = $attr_name[
'name'];
269 combo_box($prefix.
'_fields['.$field_name.
'][data_sources]['.$index.
'][params][attrid]', $type_attrs, FALSE, $selected_attr);
270 }
else if ($selected_attr !=
'') {
271 echo
'<br /><strong>'.translate(
'attribute').
':</strong> '.$asset_type_attrs[$selected_attr][
'name'];
275 if (!empty($selected_attr)) {
277 $attr_info = $GLOBALS[
'SQ_SYSTEM']->am->getAttributeInfo(Array($selected_attr));
278 $attr_info = $attr_info[$selected_attr];
280 if (($attr_info[
'type'] ==
'int') || ($attr_info[
'type'] ==
'float')) {
281 $current_search = array_get_index($field_datasource[
'params'],
'numeric_search',
'exact');
284 radio_button($prefix.
'_fields['.$field_name.
'][data_sources]['.$index.
'][params][numeric_search]',
'exact', ($current_search ==
'exact'));
285 echo translate(
'sch_page_numeric_search_exact');
288 radio_button($prefix.
'_fields['.$field_name.
'][data_sources]['.$index.
'][params][numeric_search]',
'range', ($current_search ==
'range'));
289 echo translate(
'sch_page_numeric_search_range');
292 radio_button($prefix.
'_fields['.$field_name.
'][data_sources]['.$index.
'][params][numeric_search]',
'custom', ($current_search ==
'custom'));
293 echo translate(
'sch_page_numeric_search_custom');
296 ?><strong><?php echo translate(
'sch_page_numeric_search_style'); ?></strong> <?php
297 echo translate(
'sch_page_numeric_search_'.$current_search);
300 if ($current_search ==
'custom') {
301 $custom_ranges = array_get_index($field_datasource[
'params'],
'custom_num_search', Array());
302 $custom_ranges[] = Array();
303 ?><table
class=
"sq-backend-table" style=
"width:90%">
306 <th
class=
"sq-backend-table-header">Range Name</th>
307 <th
class=
"sq-backend-table-header">Minimum</th>
308 <th
class=
"sq-backend-table-header">Maximum</th>
313 foreach ($custom_ranges as $key => $custom_range) {
314 if ($key != max(array_keys($custom_ranges)) && (empty($custom_range) || (empty($custom_range[
'name']) && empty($custom_range[
'min']) && empty($custom_range[
'max'])))) {
318 ?><tr><td
class=
"sq-backend-table-cell"><?php
320 echo text_box($prefix.
'_fields['.$field_name.
'][data_sources]['.$index.
'][params][custom_num_search]['.$key.
'][name]', array_get_index($custom_range,
'name',
''), 20);
322 echo array_get_index($custom_range,
'name',
'');
324 ?></td><td
class=
"sq-backend-table-cell"><?php
326 echo text_box($prefix.
'_fields['.$field_name.
'][data_sources]['.$index.
'][params][custom_num_search]['.$key.
'][min]', array_get_index($custom_range,
'min',
''), 7);
328 echo array_get_index($custom_range,
'min',
'');
330 ?></td><td
class=
"sq-backend-table-cell"><?php
332 echo text_box($prefix.
'_fields['.$field_name.
'][data_sources]['.$index.
'][params][custom_num_search]['.$key.
'][max]', array_get_index($custom_range,
'max',
''), 7);
334 echo array_get_index($custom_range,
'max',
'');
338 ?></tbody></table><?php
348 if (!isset($field_datasource[
'params'])) {
349 $field_datasource[
'params'] = Array();
351 $metadata_field = array_get_index($field_datasource[
'params'],
'assetid',
'0');
353 asset_finder($prefix.
'_fields['.$field_name.
'][data_sources]['.$index.
'][params][metadata_field]', $metadata_field, Array(
'metadata_field' =>
'D'));
355 if ($metadata_field > 0) {
356 $field_asset = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($metadata_field);
357 if (!is_null($metadata_field)) {
358 echo get_asset_tag_line($field_asset->id);
360 echo translate(
'sch_page_no_metadata_field_specified');
363 echo translate(
'sch_page_no_metadata_field_specified');
369 if (!isset($field_datasource[
'params'])) {
370 $field_datasources[$index][
'params'] = Array();
372 if (isset($field_datasource[
'params'][
'field'])) {
373 $selected_attr_name = $field_datasource[
'params'][
'field'];
375 $selected_attr_name =
'';
378 $type_attrs = Array(
'' =>
'-- '.translate(
'select_attribute').
' --');
379 $sm = $GLOBALS[
'SQ_SYSTEM']->am->getSystemAsset(
'search_manager');
380 $attributes = $sm->standard_date_fields + $sm->standard_text_fields;
381 combo_box($prefix.
'_fields['.$field_name.
'][data_sources]['.$index.
'][params][field]', $attributes, FALSE, $selected_attr_name);
382 }
else if ($selected_attr_name !=
'') {
383 echo translate(
'sch_page_field').
': '.$selected_attr_name;
389 hidden_field($prefix.
'_fields['.$field_name.
'][data_sources]['.$index.
'][params]',
'');
400 <td
class=
"sq-backend-data">
402 if ($field_datasource !=
'new') {
403 check_box($prefix.
'_fields['.$field_name.
'][data_sources]['.$index.
'][delete]');
412 <td rowspan=
"<?php echo count($field_datasources);?>">
414 $word_logic_options = Array(
'AND' => translate(
'sch_page_all_words'),
'OR' => translate(
'sch_page_any_word'));
416 combo_box($prefix.
'_fields['.$field_name.
'][word_logic]', $word_logic_options, FALSE, array_get_index($field_data,
'word_logic',
'AND'), 0,
'title="'.translate(
'sch_page_word_logic_exp').
'"');
418 echo array_get_index($field_data,
'word_logic',
'AND');
425 if (($index == 0) && $write_access) {
428 <td rowspan=
"<?php echo count($field_datasources);?>">
430 check_box($prefix.
'_fields['.$field_name.
'][delete]');
445 label(translate(
'sch_page_new_search_field'), $prefix.
'_new_field_name');
447 text_box($prefix.
'_new_field_name',
'', 15);
466 $old_fields = $asset->attr(
'fields');
468 $new_fields = Array();
470 if (isset($_POST[$prefix.
'_fields'])) {
471 foreach ($_POST[$prefix.
'_fields'] as $field_name => $field) {
472 if (!isset($field[
'delete'])) {
473 $new_fields[$field_name][
'name'] = $old_fields[$field_name][
'name'];
474 $new_fields[$field_name][
'word_logic'] = $field[
'word_logic'];
475 $field_datasources = array_get_index($field,
'data_sources', Array());
476 $new_fields[$field_name][
'data_sources'] = Array();
477 $new_fields[$field_name][
'exclude_field'] = FALSE;
478 foreach ($field_datasources as $i => $field_datasource) {
479 if (!isset($field_datasource[
'delete'])) {
480 $new_datasource = Array();
481 $new_datasource[
'type'] = $old_fields[$field_name][
'data_sources'][$i][
'type'];
482 if ($new_datasource[
'type'] !=
'metadata') {
483 $new_datasource[
'params'] = $field_datasource[
'params'];
485 $new_datasource[
'params'][
'assetid'] = $field_datasource[
'params'][
'metadata_field'][
'assetid'];
487 $new_fields[$field_name][
'data_sources'][] = $new_datasource;
490 if (!empty($field[
'new_data_source_type']) && $field[
'new_data_source_type'] !=
'none') {
491 $new_datasource = Array();
492 $new_datasource[
'type'] = $field[
'new_data_source_type'];
493 $new_datasource[
'params'] = Array();
494 $new_fields[$field_name][
'data_sources'][] = $new_datasource;
500 if (!empty($_POST[$prefix.
'_new_field_name'])) {
501 $safe_name = strtolower(str_replace(
' ',
'_', $_POST[$prefix.
'_new_field_name']));
504 if (!isset($old_fields[$safe_name])) {
505 $new_fields[$safe_name][
'name'] = $_POST[$prefix.
'_new_field_name'];
506 $new_fields[$safe_name][
'data_sources'] = Array();
507 $new_fields[$safe_name][
'exclude_field'] = FALSE;
511 foreach ($old_fields as $field_name => $field) {
512 if ($field[
'exclude_field']) {
513 $new_fields[$field_name] = $field;
517 return $asset->setAttrValue(
'fields', $new_fields);
534 $write_access = $asset->writeAccess(
'all');
535 $fields = $asset->attr(
'fields');
536 $query_types = Array(
537 'none' =>
'-- '.ucfirst(translate(
'sch_page_add_data_source').
' --'),
538 'include_all' => ucfirst(translate(
'include_all')),
539 'standard' => ucfirst(translate(
'sch_page_datatype_standard')),
540 'asset_attrib' => ucfirst(translate(
'sch_page_datatype_attribute')),
541 'metadata' => ucfirst(translate(
'sch_page_datatype_metadata')),
545 <table
class ="sq-backend-table" border=
"1" style=
"margin-bottom: 7px">
547 <th rowspan=
"2"><?php echo translate(
'name'); ?></th>
548 <th colspan=
"<?php echo $write_access ? 3 : 2; ?>"><?php echo translate(
'sch_page_data_sources'); ?></th>
549 <th rowspan=
"2"><?php echo translate(
'sch_page_word_logic'); ?></th>
553 <th rowspan=
"2"><?php echo translate(
'delete'); ?></th>
559 <th><?php echo translate(
'type');?></th>
560 <th <?php if (!$write_access) echo 'colspan=2';?>><?php echo translate(
'details');?> </th>
564 <th><?php echo translate(
'delete'); ?></th>
570 foreach ($fields as $field_name => $field_data) {
571 if (!$field_data[
'exclude_field'])
continue;
572 $field_datasources = $field_data[
'data_sources'];
573 if ((!empty($field_datasources)) && ($field_datasources[0][
'type'] ==
'exclude')) {
576 if ($write_access) $field_datasources[] =
'new';
577 foreach ($field_datasources as $index => $field_datasource) {
583 <td rowspan=
"<?php echo count($field_datasources);?>"> <?php echo $field_data[
'name'] ?></td>
587 <td
class=
"sq-backend-data" style=
"padding: 4px;">
589 if ($field_datasource ==
'new') {
591 combo_box($prefix.
'_exclude_fields['.$field_name.
'][new_data_source_type]', $query_types, FALSE,
'none');
594 $type = array_get_index($field_datasource,
'type');
595 echo $query_types[$type];
601 if ($field_datasource !=
'new') {
605 if (!isset($field_datasource[
'params'])) {
606 $field_datasources[$index][
'params'] = Array();
608 $search_types = $asset->attr(
'types');
609 $search_type = array_get_index($field_datasources[$index][
'params'],
'asset_type',
'0');
610 $type_names = $GLOBALS[
'SQ_SYSTEM']->am->getTypeInfo(array_keys($search_types),
'name');
612 $options = Array(
'' =>
'-- '.translate(
'select_asset_type').
' --');
613 foreach (array_keys($search_types) as $this_type) {
614 $options[$this_type] = $type_names[$this_type];
616 combo_box($prefix.
'_exclude_fields['.$field_name.
'][data_sources]['.$index.
'][params][asset_type]', $options, FALSE, $search_type);
618 echo
'<strong>'.translate(
'asset_type').
':</strong> ';
619 echo sq_print_icon($GLOBALS[
'SQ_SYSTEM']->am->getAssetIconURL($search_type), 16, 16, $type_names[$search_type], $type_names[$search_type],
' align="absmiddle"');
620 echo $type_names[$search_type];
623 if (!isset($field_datasource[
'params'][
'attrid']) || empty($search_type)) {
626 $selected_attr = $field_datasource[
'params'][
'attrid'];
628 if (!empty($search_type)) {
629 $asset_type_attrs = $GLOBALS[
'SQ_SYSTEM']->am->getAssetTypeAttributes($search_type, Array(
'attrid',
'name'));
631 $type_attrs = Array(
'' =>
'-- '.translate(
'select_attribute').
' --');
632 foreach ($asset_type_attrs as $attr_id => $attr_name) {
633 $type_attrs[$attr_id] = $attr_name[
'name'];
635 combo_box($prefix.
'_exclude_fields['.$field_name.
'][data_sources]['.$index.
'][params][attrid]', $type_attrs, FALSE, $selected_attr);
636 }
else if ($selected_attr !=
'') {
637 echo
'<br /><strong>'.translate(
'attribute').
':</strong> '.$asset_type_attrs[$selected_attr][
'name'];
641 if (!empty($selected_attr)) {
643 $attr_info = $GLOBALS[
'SQ_SYSTEM']->am->getAttributeInfo(Array($selected_attr));
644 $attr_info = $attr_info[$selected_attr];
646 if (($attr_info[
'type'] ==
'int') || ($attr_info[
'type'] ==
'float')) {
647 $current_search = array_get_index($field_datasource[
'params'],
'numeric_search',
'exact');
650 radio_button($prefix.
'_exclude_fields['.$field_name.
'][data_sources]['.$index.
'][params][numeric_search]',
'exact', ($current_search ==
'exact'));
651 echo translate(
'sch_page_numeric_search_exact');
654 radio_button($prefix.
'_exclude_fields['.$field_name.
'][data_sources]['.$index.
'][params][numeric_search]',
'range', ($current_search ==
'range'));
655 echo translate(
'sch_page_numeric_search_range');
658 radio_button($prefix.
'_exclude_fields['.$field_name.
'][data_sources]['.$index.
'][params][numeric_search]',
'custom', ($current_search ==
'custom'));
659 echo translate(
'sch_page_numeric_search_custom');
662 ?><strong><?php echo translate(
'sch_page_numeric_search_style'); ?></strong> <?php
663 echo translate(
'sch_page_numeric_search_'.$current_search);
666 if ($current_search ==
'custom') {
667 $custom_ranges = array_get_index($field_datasource[
'params'],
'custom_num_search', Array());
668 $custom_ranges[] = Array();
669 ?><table
class=
"sq-backend-table" style=
"width:90%">
672 <th
class=
"sq-backend-table-header">Range Name</th>
673 <th
class=
"sq-backend-table-header">Minimum</th>
674 <th
class=
"sq-backend-table-header">Maximum</th>
679 foreach ($custom_ranges as $key => $custom_range) {
680 if ($key != max(array_keys($custom_ranges)) && (empty($custom_range) || (empty($custom_range[
'name']) && empty($custom_range[
'min']) && empty($custom_range[
'max'])))) {
684 ?><tr><td
class=
"sq-backend-table-cell"><?php
686 echo text_box($prefix.
'_exclude_fields['.$field_name.
'][data_sources]['.$index.
'][params][custom_num_search]['.$key.
'][name]', array_get_index($custom_range,
'name',
''), 20);
688 echo array_get_index($custom_range,
'name',
'');
690 ?></td><td
class=
"sq-backend-table-cell"><?php
692 echo text_box($prefix.
'_exclude_fields['.$field_name.
'][data_sources]['.$index.
'][params][custom_num_search]['.$key.
'][min]', array_get_index($custom_range,
'min',
''), 7);
694 echo array_get_index($custom_range,
'min',
'');
696 ?></td><td
class=
"sq-backend-table-cell"><?php
698 echo text_box($prefix.
'_exclude_fields['.$field_name.
'][data_sources]['.$index.
'][params][custom_num_search]['.$key.
'][max]', array_get_index($custom_range,
'max',
''), 7);
700 echo array_get_index($custom_range,
'max',
'');
704 ?></tbody></table><?php
714 if (!isset($field_datasource[
'params'])) {
715 $field_datasource[
'params'] = Array();
717 $metadata_field = array_get_index($field_datasource[
'params'],
'assetid',
'0');
719 asset_finder($prefix.
'_exclude_fields['.$field_name.
'][data_sources]['.$index.
'][params][metadata_field]', $metadata_field, Array(
'metadata_field' =>
'D'));
721 if ($metadata_field > 0) {
722 $field_asset = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($metadata_field);
723 if (!is_null($metadata_field)) {
724 echo get_asset_tag_line($field_asset->id);
726 echo translate(
'sch_page_no_metadata_field_specified');
729 echo translate(
'sch_page_no_metadata_field_specified');
735 if (!isset($field_datasource[
'params'])) {
736 $field_datasources[$index][
'params'] = Array();
738 if (isset($field_datasource[
'params'][
'field'])) {
739 $selected_attr_name = $field_datasource[
'params'][
'field'];
741 $selected_attr_name =
'';
744 $type_attrs = Array(
'' =>
'-- '.translate(
'select_attribute').
' --');
745 $sm = $GLOBALS[
'SQ_SYSTEM']->am->getSystemAsset(
'search_manager');
746 $attributes = $sm->standard_date_fields + $sm->standard_text_fields;
747 combo_box($prefix.
'_exclude_fields['.$field_name.
'][data_sources]['.$index.
'][params][field]', $attributes, FALSE, $selected_attr_name);
748 }
else if ($selected_attr_name !=
'') {
749 echo translate(
'sch_page_field').
': '.$selected_attr_name;
755 hidden_field($prefix.
'_exclude_fields['.$field_name.
'][data_sources]['.$index.
'][params]',
'');
766 <td
class=
"sq-backend-data">
768 if ($field_datasource !=
'new') {
769 check_box($prefix.
'_exclude_fields['.$field_name.
'][data_sources]['.$index.
'][delete]');
778 <td rowspan=
"<?php echo count($field_datasources);?>">
780 $word_logic_options = Array(
'AND' => translate(
'sch_page_all_words'),
'OR' => translate(
'sch_page_any_word'));
782 combo_box($prefix.
'_exclude_fields['.$field_name.
'][word_logic]', $word_logic_options, FALSE, array_get_index($field_data,
'word_logic',
'AND'), 0,
'title="'.translate(
'sch_page_word_logic_exp').
'"');
784 echo array_get_index($field_data,
'word_logic',
'AND');
791 if (($index == 0) && $write_access) {
794 <td rowspan=
"<?php echo count($field_datasources);?>">
796 check_box($prefix.
'_exclude_fields['.$field_name.
'][delete]');
811 label(translate(
'sch_page_new_exclude_field'), $prefix.
'_new_exclude_field_name');
813 text_box($prefix.
'_new_exclude_field_name',
'', 15);
834 $old_fields = $asset->attr(
'fields');
836 $new_fields = Array();
837 if (isset($_POST[$prefix.
'_exclude_fields'])) {
838 foreach ($_POST[$prefix.
'_exclude_fields'] as $field_name => $field) {
839 if (!isset($field[
'delete'])) {
840 $new_fields[$field_name][
'name'] = $old_fields[$field_name][
'name'];
841 $new_fields[$field_name][
'word_logic'] = $field[
'word_logic'];
842 $field_datasources = array_get_index($field,
'data_sources', Array());
843 $new_fields[$field_name][
'data_sources'] = Array();
844 $new_fields[$field_name][
'exclude_field'] = TRUE;
845 foreach ($field_datasources as $i => $field_datasource) {
846 if (!isset($field_datasource[
'delete'])) {
847 $new_datasource = Array();
848 $new_datasource[
'type'] = $old_fields[$field_name][
'data_sources'][$i][
'type'];
849 if ($new_datasource[
'type'] !=
'metadata') {
850 $new_datasource[
'params'] = $field_datasource[
'params'];
852 $new_datasource[
'params'][
'assetid'] = $field_datasource[
'params'][
'metadata_field'][
'assetid'];
854 $new_fields[$field_name][
'data_sources'][] = $new_datasource;
857 if (!empty($field[
'new_data_source_type']) && $field[
'new_data_source_type'] !=
'none') {
858 $new_datasource = Array();
859 $new_datasource[
'type'] = $field[
'new_data_source_type'];
860 $new_datasource[
'params'] = Array();
861 $new_fields[$field_name][
'data_sources'][] = $new_datasource;
869 if (!empty($_POST[$prefix.
'_new_exclude_field_name'])) {
870 $safe_name = strtolower(str_replace(
' ',
'_', $_POST[$prefix.
'_new_exclude_field_name']));
872 if (!isset($old_fields[$safe_name])) {
873 $new_fields[$safe_name][
'name'] = $_POST[$prefix.
'_new_exclude_field_name'];
874 $new_fields[$safe_name][
'data_sources'] = Array();
875 $new_fields[$safe_name][
'exclude_field'] = TRUE;
879 foreach ($old_fields as $field_name => $field) {
880 if (!$field[
'exclude_field']) {
881 $new_fields[$field_name] = $field;
885 return $asset->setAttrValue(
'fields', $new_fields);
903 $write_access = $asset->writeAccess(
'attributes');
904 $search_styles = $asset->attr(
'search_styles');
905 $fields = $asset->attr(
'fields');
906 foreach ($fields as $field) {
907 $field_datasources = $field[
'data_sources'];
909 foreach ($field_datasources as $field_datasource) {
910 if (isset($field_datasource[
'type'])) {
911 $type = $field_datasource[
'type'];
913 if ($type ==
'asset_attrib') {
915 if (!isset($field_datasource[
'params'][
'attrid'])) {
918 $attribute = $GLOBALS[
'SQ_SYSTEM']->am->getAttribute($field_datasource[
'params'][
'attrid']);
919 if (is_null($attribute))
continue;
922 if ($attribute->type() ==
'boolean' || $attribute->type() ==
'selection') {
923 $attribute->_params[
'allow_empty'] = TRUE;
926 if (!empty($search_styles) && isset($search_styles[$attribute->id])) {
927 $attribute->_edit_params = $search_styles[$attribute->id];
931 $attribute->paintEditParams($prefix.
'_'.$attribute->id, $write_access);
938 return $write_access;
956 if (!$asset->writeAccess(
'attributes'))
return FALSE;
958 $search_styles = Array();
960 $fields = $asset->attr(
'fields');
962 foreach ($fields as $fieldname => $field) {
963 $field_datasources = $field[
'data_sources'];
965 foreach ($field_datasources as $field_datasource) {
966 if (isset($field_datasource[
'type'])) {
967 $type = $field_datasource[
'type'];
969 if ($type ==
'asset_attrib') {
971 if (empty($field_datasource[
'params'][
'attrid'])) {
974 $attribute = $GLOBALS[
'SQ_SYSTEM']->am->getAttribute($field_datasource[
'params'][
'attrid']);
975 $search_styles[$attribute->id] = $attribute->processEditParams($prefix.
'_'.$attribute->id);
980 $asset->setAttrValue(
'search_styles', $search_styles);
1003 <style type=
"text/css">
1004 table.category-
set {
1005 margin-bottom: 10px;
1007 table.category-
set th.title {
1010 table.category-
set th.delete {
1011 vertical-align: middle;
1014 table.category-
set th.delete input {
1017 table.category-
set table.sq-backend-table {
1021 table.category-
set table.sq-backend-table th {
1022 font-weight: normal;
1024 table.category-
set table.sq-backend-table td {
1025 white-space: nowrap;
1028 <script type=
"text/javascript"><!--
1030 function handleDefaultStatusClick(elt)
1032 var td = elt.parentNode;
1033 while (td.tagName !=
'TD') {
1036 var selects = td.getElementsByTagName(
'SELECT');
1037 with (selects[0].style) {
1038 display = (display ==
'none') ?
'' :
'none';
1042 function handleDefaultRootClick(elt)
1044 var td = elt.parentNode;
1045 while (td.tagName !=
'TD') {
1048 var divs = td.getElementsByTagName(
'DIV');
1049 with (divs[0].style) {
1050 display = (display ==
'none') ?
'' :
'none';
1056 $sets = $asset->attr(
'categories');
1057 $wa = $asset->writeAccess(
'attributes');
1058 foreach ($sets as $name => $set_data) {
1060 <table
class=
"sq-backend-table category-set">
1062 <th
class=
"title"><?php echo $name; ?></th>
1066 $msg = translate(
'search_page_confirm_cat_delete');
1067 check_box($prefix.
'_category_sets_to_delete[]', $name, FALSE,
"return confirm('$msg')",
'id="'.$prefix.
'_category_sets_to_delete_'.$name.
'"');
1068 label(translate(
'delete'), $prefix.
'_category_sets_to_delete_'.$name);
1077 label(translate(
'search_cat_unselected_text').
': ', $prefix.
'_category_'.$name.
'_unselected_text');
1079 text_box($prefix.
'_category_'.$name.
'_unselected_text', $set_data[
'unselected_text']);
1081 echo translate(
'search_cat_unselected_text');
1082 echo $set_data[
'unselected_text'];
1090 echo translate(
'options').
':';
1091 $this->
_paintCategoryOptions($asset, $prefix.
'_category_'.$name.
'_options', $name, $set_data[
'options'], $wa);
1117 <table
class=
"sq-backend-table">
1119 <th><?php echo translate(
'name'); ?></th>
1120 <th style=
"width: 35ex"><?php echo translate(
'statuses'); ?></th>
1121 <th style=
"width: 60ex"><?php echo translate(
'root_node'); ?></th>
1125 <th style=
"width: 7ex"><?php echo translate(
'delete'); ?></th>
1131 foreach ($options as $code_name => $option) {
1137 text_box($prefix.
'_'.$code_name.
'_full_name', $option[
'full_name']);
1139 echo $option[
'full_name'];
1145 $customised = isset($option[
'statuses']);
1146 $current_stats = array_get_index($option,
'statuses', Array());
1148 check_box($prefix.
'_'.$code_name.
'_statuses_default',
'1', !$customised,
'handleDefaultStatusClick(this)');
1149 label(
'Use Default', $prefix.
'_'.$code_name.
'_statuses_default');
1151 echo
'<img src="'.sq_web_path(
'lib').
'/web/images/'.($customised ?
'cross' :
'tick').
'.gif" />';
1152 echo translate(
'use_default');
1154 $this->
_paintStatusChooser($prefix.
'_'.$code_name.
'_statuses', $current_stats, $wa, $customised);
1159 $customised = isset($option[
'root_assetid']);
1162 $link_value =
'root_'.$set_name.
'_'.$code_name;
1163 $root_link = $GLOBALS[
'SQ_SYSTEM']->am->getLink($asset->id, SQ_LINK_NOTICE,
'', FALSE, $link_value);
1164 $current_root = $root_link[
'minorid'];
1167 check_box($prefix.
'_'.$code_name.
'_root_default',
'1', !$customised,
'handleDefaultRootClick(this)');
1168 label(
'Use Default', $prefix.
'_'.$code_name.
'_root_default');
1170 echo
'<img src="'.sq_web_path(
'lib').
'/web/images/'.($customised ?
'cross' :
'tick').
'.gif" />';
1171 echo translate(
'use_default');
1173 $this->
_paintAssetChooser($prefix.
'_'.$code_name.
'_root', $current_root, $wa, $customised);
1181 check_box($prefix.
'_to_delete[]', $code_name, FALSE);
1194 <?php text_box($prefix.
'__new__full_name',
''); ?>
1198 check_box($prefix.
'__new__statuses_default',
'1', TRUE,
'handleDefaultStatusClick(this)');
1199 label(
'Use Default', $prefix.
'__new__statuses_default');
1205 check_box($prefix.
'__new__root_default',
'1', TRUE,
'handleDefaultRootClick(this)');
1206 label(
'Use Default', $prefix.
'__new__root_default');
1234 if (!$editable && !$visible) {
1237 $style = $visible ?
'' :
'display: none';
1240 require_once SQ_INCLUDE_PATH.
'/general_occasional.inc';
1242 require_once SQ_LIB_PATH.
'/html_form/html_form.inc';
1243 $statuses = get_constant_values(
'SQ_STATUS');
1245 foreach ($statuses as $constant => $value) {
1246 $options[$value] = get_status_description($value);
1248 combo_box($name, $options, TRUE, $current_values,
'',
'style="'.$style.
'"');
1250 if (empty($current_values)) {
1251 echo translate(
'sch_page_no_status_selected');
1253 ?><ul style=
"margin: 1px 15px;"><?php
1254 foreach ($current_values as $status) {
1255 $status_name = get_status_description($status);
1256 $status_colour = get_status_colour($status);
1258 echo
'<img src="'.sq_web_path(
'lib').
'/web/images/blank.gif" width="10" height="10" alt="'.$status_name.
'" title="'.$status_name.
'" align="absmiddle" style="margin: 2px; border: 1px solid #ccc; background-color: '.$status_colour.
'" /> ';
1282 if (!$editable && !$visible) {
1285 echo
'<div style="'.($visible ?
'' :
'display: none').
'">';
1287 asset_finder($name, $current_value);
1289 echo get_asset_tag_line($current_value);
1308 $cats = $asset->attr(
'categories');
1311 if (!empty($_POST[$prefix.
'_category_sets_to_delete'])) {
1312 foreach ($_POST[$prefix.
'_category_sets_to_delete'] as $delete_name) {
1314 if (isset($cats[$delete_name][
'options']) && !empty($cats[$delete_name][
'options'])) {
1315 foreach ($cats[$delete_name][
'options'] as $option_delete_name => $option_content) {
1316 $old_link_value =
'root_'.$delete_name.
'_'.$option_delete_name;
1317 $root_links = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($asset->id, SQ_LINK_NOTICE,
'', FALSE,
'major', $old_link_value);
1320 foreach ($root_links as $root_link) {
1321 if (!$GLOBALS[
'SQ_SYSTEM']->am->deleteAssetLink($root_link[
'linkid'])) {
1330 }
else if (isset($cats[$delete_name][
'options']) && empty($cats[$delete_name][
'options'])){
1333 if($ok) unset($cats[$delete_name]);
1338 foreach ($cats as $name => $cat_data) {
1339 $cat_data[
'unselected_text'] = $_POST[$prefix.
'_category_'.$name.
'_unselected_text'];
1340 $cat_data[
'options'] = $this->
_processCategoryOptions($asset, $prefix.
'_category_'.$name.
'_options', $name, $cat_data[
'options']);
1341 $cats[$name] = $cat_data;
1344 return $asset->setAttrValue(
'categories', $cats);
1364 $new_options = Array();
1366 if (isset($_POST[$prefix.
'_to_delete'])) {
1367 foreach ($_POST[$prefix.
'_to_delete'] as $delete_name) {
1368 $old_link_value =
'root_'.$set_name.
'_'.$delete_name;
1369 $root_links = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($asset->id, SQ_LINK_NOTICE,
'', FALSE,
'major', $old_link_value);
1372 foreach ($root_links as $root_link) {
1373 if (!$GLOBALS[
'SQ_SYSTEM']->am->deleteAssetLink($root_link[
'linkid'])) {
1377 if($ok) unset($old_options[$delete_name]);
1380 foreach ($old_options as $code_name => $old_option) {
1381 $new_option = Array();
1382 $new_option[
'full_name'] = $_POST[$prefix.
'_'.$code_name.
'_full_name'];
1383 if (empty($new_option[
'full_name'])) {
1385 $new_option[
'full_name'] = $old_option[
'full_name'];
1388 if (empty($_POST[$prefix.
'_'.$code_name.
'_statuses_default']) && !empty($_POST[$prefix.
'_'.$code_name.
'_statuses'])) {
1389 $new_option[
'statuses'] = $_POST[$prefix.
'_'.$code_name.
'_statuses'];
1392 $new_code_name = preg_replace(
'/[^a-zA-Z0-9 ]/',
'', $new_option[
'full_name']);
1393 $new_code_name = preg_replace(
'/( )+/',
'_', $new_code_name);
1394 $new_code_name = strtolower($new_code_name);
1396 if (empty($_POST[$prefix.
'_'.$code_name.
'_root_default'])) {
1397 $new_option[
'root_assetid'] =
'';
1398 $new_root = $_POST[$prefix.
'_'.$code_name.
'_root'][
'assetid'];
1400 $old_link_value =
'root_'.$set_name.
'_'.$code_name;
1401 $new_link_value =
'root_'.$set_name.
'_'.$new_code_name;
1402 $root_link = $GLOBALS[
'SQ_SYSTEM']->am->getLink($asset->id, SQ_LINK_NOTICE,
'', FALSE, $old_link_value);
1403 if (empty($root_link) || ($old_link_value != $new_link_value) || $root_link[
'minorid'] != $new_root) {
1406 $GLOBALS[
'SQ_SYSTEM']->changeDatabaseConnection(
'db2');
1407 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'BEGIN');
1409 if (!empty($root_link) && !$GLOBALS[
'SQ_SYSTEM']->am->deleteAssetLink($root_link[
'linkid'])) {
1411 }
else if ($new_root) {
1412 $root = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($new_root);
1413 if (!is_null($root)) {
1414 if (!$asset->createLink($root, SQ_LINK_NOTICE, $new_link_value)) {
1416 trigger_localised_error(
'SCH0012', E_USER_WARNING, $root->name, $root->id);
1421 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'COMMIT');
1423 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
1425 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
1428 $new_options[$new_code_name] = $new_option;
1432 if (!empty($_POST[$prefix.
'__new__full_name'])) {
1433 $new_option[
'full_name'] = $_POST[$prefix.
'__new__full_name'];
1434 if (empty($_POST[$prefix.
'__new__statuses_default'])) {
1435 $new_option[
'statuses'] = array_get_index($_POST, $prefix.
'__new__statuses', Array());
1437 $new_code_name = preg_replace(
'/[^a-zA-Z0-9 ]/',
'', $new_option[
'full_name']);
1438 $new_code_name = preg_replace(
'/( )+/',
'_', $new_code_name);
1439 $new_code_name = strtolower($new_code_name);
1440 $link_value =
'root_'.$set_name.
'_'.$new_code_name;
1441 if (empty($_POST[$prefix.
'__new__root_default']) && !empty($_POST[$prefix.
'__new__root'][
'assetid'])) {
1442 $GLOBALS[
'SQ_SYSTEM']->changeDatabaseConnection(
'db2');
1443 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'BEGIN');
1444 $new_root = $_POST[$prefix.
'__new__root'][
'assetid'];
1445 $root = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($new_root);
1446 if (!is_null($root)) {
1447 if (!$asset->createLink($root, SQ_LINK_NOTICE, $link_value)) {
1448 trigger_localised_error(
'SCH0012', E_USER_WARNING, $root->name, $root->id);
1449 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
1451 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'COMMIT');
1452 $new_option[
'root_assetid'] =
'';
1455 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
1457 $new_options[$new_code_name] = $new_option;
1459 return $new_options;
1476 if ($asset->writeAccess(
'attributes')) {
1477 label(translate(
'name').
': ', $prefix.
'_new_category');
1478 text_box($prefix.
'_new_category',
'');
1497 if ($asset->writeAccess(
'attributes')) {
1498 if (!empty($_POST[$prefix.
'_new_category'])) {
1499 $cats = $asset->attr(
'categories');
1500 $safe_name = preg_replace(
'/[^a-zA-Z0-9 ]/',
'', $_POST[$prefix.
'_new_category']);
1501 $safe_name = preg_replace(
'/( )+/',
'_', $safe_name);
1502 $safe_name = strtolower($safe_name);
1503 if (isset($cats[$safe_name])) {
1504 trigger_error(
'New Category Set could not be added: A category set called "'.$safe_name.
'" already exists. Try another name');
1507 $cats[$safe_name] = Array(
'unselected_text' =>
'',
'options' => Array());
1508 $asset->setAttrValue(
'categories', $cats);
1532 $write_access = $asset->writeAccess(
'links');
1534 $search_bodycopy_link = $asset->getFormatBodycopyLink(
'search_form');
1535 $sis_bodycopy_link = $asset->getFormatBodycopyLink(
'sis_form');
1536 $search_customised = !empty($search_bodycopy_link) && $search_bodycopy_link[
'link_type'] != SQ_LINK_TYPE_3;
1537 $sis_customised = !empty($sis_bodycopy_link) && $sis_bodycopy_link[
'link_type'] != SQ_LINK_TYPE_3;
1542 <td><?php echo translate(
'sch_page_customise_search_form') ?></td>
1545 if (!$write_access) {
1546 echo ($search_customised) ? translate(
'yes') : translate(
'no');
1548 check_box($prefix.
'_search_form', 1, $search_customised);
1554 <td><?php echo translate(
'sch_page_customise_sis_form') ?></td>
1557 if (!$write_access) {
1558 echo ($sis_customised) ? translate(
'yes') : translate(
'no');
1560 check_box($prefix.
'_sis_form', 1, $sis_customised);
1568 return $write_access;
1585 $format_folder =& $asset->getFormatFolder();
1588 translate(
'sch_page_default_search') =>
'search_form',
1589 translate(
'sch_page_sis') =>
'sis_form',
1592 $bodycopies_visible = FALSE;
1594 foreach ($forms as $form_name => $value) {
1595 if (isset($_POST[$prefix.
'_'.$value])) {
1597 if (is_null($format_folder)) {
1600 $GLOBALS[
'SQ_SYSTEM']->changeDatabaseConnection(
'db2');
1601 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'BEGIN');
1602 $GLOBALS[
'SQ_SYSTEM']->am->includeAsset(
'folder');
1603 $format_folder =
new Folder();
1604 $copy_link = Array(
'asset' => &$asset,
'value' =>
'format_folder',
'link_type' => SQ_LINK_TYPE_2,
'is_dependant' => 1,
'is_exclusive' => 1);
1606 $format_folder->setAttrValue(
'name',
'Search Forms');
1608 if (!$format_folder->create($copy_link)) {
1609 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
1610 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
1611 trigger_localised_error(
'SCH0013', E_USER_WARNING);
1614 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'COMMIT');
1615 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
1618 $bodycopy =& $asset->getFormatBodycopy($value);
1620 if (is_null($bodycopy)) {
1623 $GLOBALS[
'SQ_SYSTEM']->changeDatabaseConnection(
'db2');
1624 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'BEGIN');
1625 $GLOBALS[
'SQ_SYSTEM']->am->includeAsset(
'bodycopy');
1627 $copy_link = Array(
'asset' => &$format_folder,
'value' => $value,
'link_type' => SQ_LINK_TYPE_2,
'is_dependant' => 1,
'is_exclusive' => 1);
1629 $bodycopy->setAttrValue(
'name', $form_name);
1631 if (!$bodycopy->create($copy_link)) {
1632 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
1633 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
1634 trigger_localised_error(
'SCH0014', E_USER_WARNING, $form_name);
1637 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'COMMIT');
1638 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
1640 $bodycopy_link = $asset->getFormatBodycopyLink($value);
1641 if ($bodycopy_link[
'link_type'] != SQ_LINK_TYPE_2) {
1642 if (!$GLOBALS[
'SQ_SYSTEM']->am->updateLink($bodycopy_link[
'linkid'], SQ_LINK_TYPE_2)) {
1643 trigger_localised_error(
'SCH0014', E_USER_WARNING, $form_name);
1648 $bodycopies_visible = TRUE;
1651 $bodycopy_link = $asset->getFormatBodycopyLink($value);
1652 if (!empty($bodycopy_link[
'link_type']) && $bodycopy_link[
'link_type'] != SQ_LINK_TYPE_3) {
1653 if (!$GLOBALS[
'SQ_SYSTEM']->am->updateLink($bodycopy_link[
'linkid'], SQ_LINK_TYPE_3)) {
1654 trigger_localised_error(
'SCH0015', E_USER_WARNING, $form_name);
1663 $folder_link_type = SQ_LINK_TYPE_3;
1664 if ($bodycopies_visible) {
1665 $folder_link_type = SQ_LINK_TYPE_2;
1668 $folder_link = $asset->getFormatFolderLink();
1669 if (!empty($folder_link[
'link_type']) && $folder_link[
'link_type'] != $folder_link_type) {
1670 if (!$GLOBALS[
'SQ_SYSTEM']->am->updateLink($folder_link[
'linkid'], $folder_link_type)) {
1671 trigger_localised_error(
'SCH0016', E_USER_WARNING);
1693 $link_value =
'thesaurus';
1694 $root_link = $GLOBALS[
'SQ_SYSTEM']->am->getLink($asset->id, SQ_LINK_NOTICE,
'asset', FALSE, $link_value);
1696 $write_access = $asset->writeAccess(
'links');
1698 if (!$write_access) {
1700 if (!empty($root_link)) {
1701 echo get_asset_tag_line($root_link[
'minorid']);
1703 echo translate(
'sch_page_no_thesaurus_asset_selected');
1706 asset_finder($prefix.
'_thesaurusid', (!empty($root_link)) ? $root_link[
'minorid'] :
'', Array(
'thesaurus' =>
'D'));
1709 return $write_access;
1726 if (!isset($_POST[$prefix.
'_thesaurusid'][
'assetid'])) {
1729 $new_root = $_POST[$prefix.
'_thesaurusid'][
'assetid'];
1732 $link_value =
'thesaurus';
1733 $root_link = $GLOBALS[
'SQ_SYSTEM']->am->getLink($asset->id, SQ_LINK_NOTICE,
'', FALSE, $link_value);
1736 if (!empty($root_link) && $root_link[
'minorid'] == $new_root) {
1742 $GLOBALS[
'SQ_SYSTEM']->changeDatabaseConnection(
'db2');
1743 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'BEGIN');
1746 if (!empty($root_link) && !$GLOBALS[
'SQ_SYSTEM']->am->deleteAssetLink($root_link[
'linkid'])) {
1748 }
else if ($new_root) {
1749 $root = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($new_root);
1751 if (!is_null($root)) {
1752 if (!$asset->createLink($root, SQ_LINK_NOTICE, $link_value)) {
1754 trigger_localised_error(
'SCH0017', E_USER_WARNING, $root->name, $root->id);
1760 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'COMMIT');
1762 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
1765 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
1783 $search_fields = array_keys($asset->attr(
'fields'));
1784 $keyed_search_fields = Array();
1785 foreach ($search_fields as $field) {
1786 $keyed_search_fields[$field] = $field;
1789 $write_access = $asset->writeAccess(
'attributes');
1792 if (empty($search_fields)) {
1793 echo translate(
'sch_auto_syn_error_no_search_fields');
1799 echo translate(
'sch_auto_syn_error_thesaurus_not_installed');
1803 $link_value =
'thesaurus';
1804 $root_link = $GLOBALS[
'SQ_SYSTEM']->am->getLink($asset->id, SQ_LINK_NOTICE,
'asset', FALSE, $link_value);
1807 if (empty($root_link)) {
1808 echo translate(
'sch_auto_syn_error_no_thesaurus_set');
1812 $field = $asset->attr(
'auto_synonym_search_field');
1814 if ($write_access) {
1815 check_box($prefix.
'_auto_synonym_search_enabled', 1, !empty($field),
'form.elements["'.$prefix.
'_auto_synonym_search_field"].disabled = !this.checked; form.elements["'.$prefix.
'_enable_multi_word_synonym_lookups"].disabled = !this.checked; return TRUE;');
1816 echo translate(
'sch_auto_syn_enable');
1819 $o->openField(translate(
'sch_auto_syn_use_search_field'));
1820 combo_box($prefix.
'_auto_synonym_search_field', $keyed_search_fields, FALSE, $field, 0, empty($field) ?
'disabled="disabled"' :
'');
1822 if (empty($field)) {
1823 echo translate(
'sch_auto_syn_not_enabled');
1825 echo translate(
'sch_auto_syn_enabled_using_field', $field);
1847 if (empty($_POST[$prefix.
'_auto_synonym_search_enabled'])) {
1848 $asset->setAttrValue(
'auto_synonym_search_field',
'');
1853 if (!empty($_POST[$prefix.
'_auto_synonym_search_field'])) {
1854 $asset->setAttrValue(
'auto_synonym_search_field', $_POST[$prefix.
'_auto_synonym_search_field']);
1875 $search_fields = array_keys($asset->attr(
'fields'));
1876 $keyed_search_fields = Array();
1877 foreach ($search_fields as $field) {
1878 $keyed_search_fields[$field] = $field;
1881 $write_access = $asset->writeAccess(
'attributes');
1884 if (empty($search_fields)) {
1893 $link_value =
'thesaurus';
1894 $root_link = $GLOBALS[
'SQ_SYSTEM']->am->getLink($asset->id, SQ_LINK_NOTICE,
'asset', FALSE, $link_value);
1897 if (empty($root_link)) {
1901 $enable_multi_words = $asset->attr(
'enable_multi_word_synonym_lookups');
1903 $o->openField(translate(
'sch_enable_multi_word_synonym_lookups'));
1904 if ($write_access) {
1905 check_box($prefix.
'_enable_multi_word_synonym_lookups', 1, $enable_multi_words,
'');
1906 echo translate(
'sch_enable_multi_word_synonym_lookups');
1908 echo
'<img src="'.sq_web_path(
'lib').
'/web/images/'.(empty($enable_multi_words) ?
'cross' :
'tick').
'.gif" />';
1911 echo translate(
'sch_enable_multi_word_synonym_lookups_note');
1930 if (empty($_POST[$prefix.
'_enable_multi_word_synonym_lookups'])) {
1931 $asset->setAttrValue(
'enable_multi_word_synonym_lookups', FALSE);
1933 $asset->setAttrValue(
'enable_multi_word_synonym_lookups', TRUE);
1953 return $GLOBALS[
'SQ_SYSTEM']->am->installed(
'thesaurus');
1974 parent::_paintExtraSortOptions($asset, $o, $prefix);
1975 $wa = $asset->writeAccess(
'attributes');
1976 $o->openField(translate(
'sch_page_relevance'));
1977 $rel_enabled = FALSE;
1978 foreach ($asset->attr(
'sort_by') as $v) {
1979 if (array_get_index($v[
'params'],
'field') ==
'score') {
1980 $rel_enabled = TRUE;
1985 check_box($prefix.
'_enable_rel',
'1', $rel_enabled);
1986 label(translate(
'sch_page_enable_relevance'), $prefix.
'_enable_rel');
1988 $filename = $rel_enabled ?
'tick' :
'cross';
1989 echo
'<img src="'.sq_web_path(
'lib').
'/web/images/'.$filename.
'.gif" /> ';
1990 echo translate(
'sch_page_enable_relevance');
2009 $res = parent::_processExtraSortOptions($asset, $o, $prefix);
2010 $val = $asset->attr(
'sort_by');
2011 if (isset($_POST[$prefix.
'_submitted'])) {
2012 $want_rel = !empty($_POST[$prefix.
'_enable_rel']);
2014 foreach ($val as $i => $v) {
2015 if (array_get_index($v[
'params'],
'field') ==
'score') {
2020 if (($rel_index !== FALSE) && !$want_rel) {
2021 unset($val[$rel_index]);
2022 }
else if (($rel_index === FALSE) && $want_rel) {
2024 'name' => translate(
'sch_page_relevance'),
2026 'params' => Array(
'field' =>
'score'),
2029 $res = $asset->setAttrValue(
'sort_by', $val) || $res;
2053 $wa = $asset->writeAccess(
'attributes');
2054 $pmap = $asset->getAttribute(
'stored_query_session');
2055 $current_params = $pmap->_params;
2057 $fields = $asset->attr(
'fields');
2058 foreach ($fields as $fieldname => $fieldvalue) {
2059 $current_params[
'parameters'][$fieldname] =
'Search Field: '.$fieldname;
2061 $pmap->_params = $current_params;
2063 $pmap->paint($prefix);
2065 $pmap->paint($prefix, TRUE);
2083 $wa = $asset->writeAccess(
'attributes');
2084 $pmap = $asset->getAttribute(
'stored_query_session');
2086 $pmap->process($prefix);
2087 $asset->setAttrValue(
'stored_query_session', $pmap->value);
2088 $asset->saveAttributes();