17 require_once SQ_PACKAGES_PATH.
'/cms/listing_engine/listing_engine_edit_fns.inc';
18 require_once SQ_LIB_PATH.
'/html_form/html_form.inc';
40 parent::__construct();
41 $this->static_screens[
'details'][
'lock_type'] =
'content';
42 $this->static_screens[
'details'][
'force_unlock'] = FALSE;
58 return ($owner->attr(
'search_type') ==
'integrated');
76 <table
class=
"sq-backend-table">
78 <th><?php echo translate(
'edit_format') ?></th>
79 <th><?php echo translate(
'note') ?></th>
86 $folder = $asset->getFolder(
'type_format');
111 <table
class=
"sq-backend-table">
113 <th><?php echo translate(
'edit_format') ?></th>
114 <th><?php echo translate(
'note') ?></th>
117 $folder = $asset->getFolder(
'fluster_format');
120 $this->
_paintDefaultFormatLink($folder->id,
'navigation_format', translate(
'funnelback_navigation_format_desc'));
143 <table
class=
"sq-backend-table">
145 <th><?php echo translate(
'edit_format') ?></th>
146 <th><?php echo translate(
'note') ?></th>
149 $folder = $asset->getFolder(
'spell_format');
174 function _paintDefaultFormatLink($root_assetid, $bodycopy_name, $bodycopy_description, $delete_control=FALSE, $prefix=
'', $type_code=
'bodycopy', $screen=
'contents')
176 $link = $GLOBALS[
'SQ_SYSTEM']->am->getLink($root_assetid, SQ_LINK_TYPE_2, $type_code, TRUE, $bodycopy_name);
178 $info = Array($link[
'minorid'] =>
'contents');
179 $href = $GLOBALS[
'SQ_SYSTEM']->am->getAssetBackendHref($info);
183 <?php echo get_asset_tag_line($link[
'minorid'], $screen); ?>
186 <?php echo $bodycopy_description; ?>
189 if ($delete_control) {
191 check_box($prefix.
'_delete['.$bodycopy_name.
']');
214 $write_access = $asset->writeAccess(
'links');
215 $folder = $asset->getFolder(
'type_format');
216 $formats = $asset->getFormats(
'type_format');
218 if (count($formats) > 2) {
220 <table
class=
"sq-backend-table">
222 <th><?php echo translate(
'edit_format') ?></th>
223 <th><?php echo translate(
'note') ?></th>
227 <th><?php echo translate(
'delete_question') ?></th>
233 foreach ($formats as $minorid => $value) {
234 if ($value ==
'default_format')
continue;
235 if ($value ==
'featured_format')
continue;
237 $this->
_paintDefaultFormatLink($folder->id, $value, translate(
'funnelback_custom_format_desc', strtoupper($value)), $write_access, $prefix);
243 echo translate(
'funnelback_no_type_formats');
247 echo
'<p><b>'.translate(
'funnelback_new_type_format').
'</b> ';
248 text_box($prefix.
'_new_type',
'');
251 $o->note(translate(
'funnelback_custom_format_note'));
269 $folder = $asset->getFolder(
'type_format');
271 $new_type = array_get_index($_POST, $prefix.
'_new_type',
'');
272 $deleted_formats = array_get_index($_POST, $prefix.
'_delete', Array());
275 if (isset($deleted_formats[$new_type])) {
276 unset($deleted_formats[$new_type]);
280 foreach ($deleted_formats as $type => $on) {
281 $current_link = $GLOBALS[
'SQ_SYSTEM']->am->getLink($folder->id, SQ_LINK_TYPE_2,
'bodycopy', TRUE, $type);
282 if (!empty($current_link)) {
283 if (!$GLOBALS[
'SQ_SYSTEM']->am->deleteAssetLink($current_link[
'linkid'])) {
284 trigger_localised_error(
'FNB0006', E_USER_WARNING, $type);
289 if (!empty($new_type)) {
291 $current_link = $GLOBALS[
'SQ_SYSTEM']->am->getLink($folder->id, SQ_LINK_TYPE_2,
'bodycopy', TRUE, $new_type);
292 if (empty($current_link)) {
294 $GLOBALS[
'SQ_SYSTEM']->changeDatabaseConnection(
'db2');
295 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'BEGIN');
296 $GLOBALS[
'SQ_SYSTEM']->am->includeAsset(
'bodycopy');
298 $copy_link = Array(
'asset' => &$folder,
'value' => $new_type,
'link_type' => SQ_LINK_TYPE_2,
'is_dependant' => 1,
'is_exclusive' => 1);
301 $bodycopy->setAttrValue(
'name', strtoupper($new_type).
' Format');
302 $copy_args = Array(
'content' => $asset->_getDefaultBodycopyContent(
'custom_format'));
304 if (!$bodycopy->create($copy_link, $copy_args)) {
305 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
306 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
309 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'COMMIT');
310 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
312 trigger_localised_error(
'FNB0005', E_USER_WARNING, $new_type);
333 $wa = $asset->writeAccess(
'attributes');
334 $search_type = $asset->attr(
'search_type');
335 $web_url = $asset->attr(
'funnelback_url');
336 $collection = $asset->attr(
'collection');
337 $fm = $GLOBALS[
'SQ_SYSTEM']->am->getSystemAsset(
'funnelback_manager');
338 $all_collections = $fm->getCollections();
339 $local_collections = Array(
''=>translate(
'funnelback_no_collection'));
340 $squiz_search_options = $this->_getSquizSearchSystems();
341 $suiteid = $asset->attr(
'systemid');
342 $systemname = array_get_index($squiz_search_options, $suiteid,
'');
343 $squiz_collections = $this->_getSquizSearchCollections($suiteid);
344 foreach ($all_collections as $all_col_id => $all_col_info) {
345 $local_collections[$all_col_id] = array_get_index($all_col_info,
'name',
'');
347 if ($search_type ==
'integrated') {
348 $hidden_web =
'style="display:none;"';
350 $hidden_squiz =
'style="display:none;"';
351 }
else if ($search_type ==
'squiz') {
352 $hidden_web =
'style="display:none;"';
353 $hidden_local =
'style="display:none;"';
357 $hidden_local =
'style="display:none;"';
358 $hidden_squiz =
'style="display:none;"';
360 $object_type =
'this.form.'.$prefix.
'_search_type.value';
361 $object_url1 =
'this.form.'.$prefix.
'_search_url_web';
362 $object_url2 =
'document.getElementById(\''.$prefix.
'_search_url_local\')';
363 $object_url3 =
'this.form.'.$prefix.
'_search_url_squiz';
364 $object_url4 =
'document.getElementById(\''.$prefix.
'_search_mode_hosted\')';
365 $object_coll1 =
'this.form.'.$prefix.
'_search_collection_web';
366 $object_coll2 =
'this.form.'.$prefix.
'_search_collection_local';
367 $object_coll3 =
'this.form.'.$prefix.
'_search_collection_squiz';
368 $object_coll4 =
'this.form.'.$prefix.
'_search_mode';
369 $js =
'onChange="chooseFunnelbackSearchType('.$object_type.
', '.$object_url1.
', '.$object_url2.
', '.$object_url3.
', '.$object_url4.
', '.$object_coll1.
', '.$object_coll2.
', '.$object_coll3.
', '.$object_coll4.
');"';
371 $o->openField(
'Search Type');
373 <script type=
"text/javascript">
374 function chooseFunnelbackSearchType(type, url1, url2, url3, url4, coll1, coll2, coll3, coll4) {
375 if (type ==
'web' || type ==
'hosted') {
376 url1.style.display=
'block';
378 url2.style.display=
'none';
380 url3.style.display=
'none';
382 coll1.style.display=
'block';
383 coll1.disabled=
false;
384 coll2.style.display=
'none';
386 coll3.style.display=
'none';
388 if (type ==
'hosted') {
389 url4.style.display=
'none';
391 coll4.style.display=
'block';
392 coll4.disabled=
false;
394 url4.style.display=
'block';
396 coll4.style.display=
'none';
399 }
else if (type ==
'squiz') {
400 url1.style.display=
'none';
402 url2.style.display=
'none';
404 url3.style.display=
'block';
406 url4.style.display=
'block';
408 coll1.style.display=
'none';
410 coll2.style.display=
'none';
412 coll3.style.display=
'block';
413 coll3.disabled=
false;
414 coll4.style.display=
'none';
417 url1.style.display=
'none';
419 url2.style.display=
'block';
421 url3.style.display=
'none';
423 url4.style.display=
'block';
425 coll1.style.display=
'none';
427 coll2.style.display=
'block';
428 coll2.disabled=
false;
429 coll3.style.display=
'none';
431 coll4.style.display=
'none';
437 $type_attribute = $asset->getAttribute(
'search_type');
438 $type_options = $type_attribute->getOptions();
440 echo combo_box($prefix.
'_search_type', $type_options, FALSE, $search_type, 0, $js);
442 echo $type_options[$search_type];
444 $o->note(translate(
'funnelback_search_type_note'));
446 $o->openField(
'Mode to use');
447 $mode = $asset->attr(
'hosted_mode');
448 $modes = Array(
'0' =>
'Classic',
'1' =>
'Advanced');
450 echo combo_box($prefix.
'_search_mode', $modes, FALSE, $mode, 0, $hidden_web);
451 echo
'<span id="'.$prefix.
'_search_mode_hosted" '.$hidden_local.
'>';
452 echo
'Not Available';
458 $o->openField(
'Search URL');
460 echo text_box($prefix.
'_search_url_web', $web_url,
'',
'', FALSE, $hidden_web);
461 echo
'<span id="'.$prefix.
'_search_url_local" '.$hidden_local.
'>';
462 echo
'Integrated Search';
464 echo combo_box($prefix.
'_search_url_squiz', $squiz_search_options, FALSE, $suiteid, 0, $hidden_squiz);
466 if ($search_type ==
'integrated') {
467 echo
'Integrated Search';
468 }
else if ($search_type ==
'squiz') {
475 $o->openField(
'Collection');
477 echo text_box($prefix.
'_search_collection_web', $collection,
'',
'', FALSE, $hidden_web);
478 echo combo_box($prefix.
'_search_collection_local', $local_collections, FALSE, $collection, 0, $hidden_local);
479 echo combo_box($prefix.
'_search_collection_squiz', $squiz_collections, FALSE, $collection, 0, $hidden_squiz);
481 if ($search_type ==
'integrated') {
482 if (empty($collection) || !isset($local_collections[$collection])) {
483 echo translate(
'funnelback_no_collection');
485 echo $local_collections[$collection];
487 }
else if ($search_type ==
'squiz') {
488 if (empty($collection) || !isset($squiz_collections[$collection])) {
489 echo translate(
'funnelback_no_collection');
491 echo $squiz_collections[$collection];
517 $wa = $asset->writeAccess(
'attributes');
519 $type = array_get_index($_POST, $prefix.
'_search_type',
'integrated');
521 if ($type ==
'integrated') {
522 $collection = array_get_index($_POST, $prefix.
'_search_collection_local',
'');
523 $fm = $GLOBALS[
'SQ_SYSTEM']->am->getSystemAsset(
'funnelback_manager');
524 $all_collections = $fm->getCollections();
526 if (!array_key_exists($collection, $all_collections)) {
531 }
else if ($type ==
'squiz') {
532 $collection = array_get_index($_POST, $prefix.
'_search_collection_squiz',
'');
533 $suiteid = array_get_index($_POST, $prefix.
'_search_url_squiz',
'');
535 $systems = $this->_getSquizSearchSystems();
536 $collections = $this->_getSquizSearchCollections($suiteid);
537 if (!array_key_exists($suiteid, $systems)) {
541 if (!array_key_exists($collection, $collections)) {
544 }
else if ($type ==
'hosted') {
545 $collection = array_get_index($_POST, $prefix.
'_search_collection_web',
'');
546 $url = array_get_index($_POST, $prefix.
'_search_url_web',
'');
549 $collection = array_get_index($_POST, $prefix.
'_search_collection_web',
'');
550 $url = array_get_index($_POST, $prefix.
'_search_url_web',
'');
555 $mode = array_get_index($_POST, $prefix.
'_search_mode', 0);
556 $asset->setAttrValue(
'search_type', $type);
557 $asset->setAttrValue(
'funnelback_url', $url);
558 $asset->setAttrValue(
'systemid', $suiteid);
559 $asset->setAttrValue(
'collection', $collection);
560 $asset->setAttrValue(
'hosted_mode', $mode);
561 $status = $asset->saveAttributes();
575 private function _getSquizSearchSystems()
578 $suitem = $GLOBALS[
'SQ_SYSTEM']->am->getSystemAsset(
'suite_manager', TRUE);
579 if ($suitem !== NULL) {
580 $products = $suitem->getProducts(FALSE, FALSE);
581 foreach ($products as $product) {
582 if ($product[
'type'] ==
'Squiz Search' && $product[
'status'] ==
'live') {
583 $productname = array_get_index($product[
'connection'],
'name',
'');
584 $systems[$product[
'suiteid']] = $productname;
602 private function _getSquizSearchCollections($suiteid=
'')
604 $collections = array();
605 $suitem = $GLOBALS[
'SQ_SYSTEM']->am->getSystemAsset(
'suite_manager', TRUE);
606 if ($suitem !== NULL) {
607 $system = $suitem->getProduct($suiteid);
608 if (empty($system) === FALSE) {
609 $productUrl = array_get_index($system,
'url',
'');
611 $response = $suitem->sendRequest($suiteid,
'json',
'SquizSearch',
'getAvailableCollections', $request);
612 if (isset($response[
'curlInfo'][
'http_code']) === TRUE && $response[
'curlInfo'][
'http_code'] == 200) {
613 $resultData = $response[
'result'];
614 $resultData = (array) $suitem->decodeJson($resultData);
615 $results = (array) $resultData[
'result'];
616 if (empty($results) === FALSE) {
617 foreach ($results as $k => $v) {
618 $collections[$k] = $v;
642 $sort = $asset->attr(
'sort_order');
643 $sort_options = $asset->getSortOptions();
645 if ($asset->writeAccess(
'attributes')) {
646 combo_box($prefix.
'_sort_order', $sort_options, FALSE, $sort);
648 if (!isset($sort_options[$sort])) {
651 echo $sort_options[$sort];
672 if ($asset->writeAccess(
'attributes')) {
673 $processed_value = array_get_index($_POST, $prefix.
'_sort_order',
'rank');
674 $current_value = $asset->attr(
'sort_order');
675 if ($processed_value != $current_value) {
676 $asset->setAttrValue(
'sort_order', $processed_value);
677 $asset->saveAttributes();
698 $scope = $asset->attr(
'scope');
699 $default = $asset->attr(
'default_scope');
701 if ($asset->writeAccess(
'attributes')) {
702 echo combo_box($prefix.
'_default_scope', $scope, FALSE, $default);
704 echo (isset($scope[$default])) ? $scope[$default] : translate(
'funnelback_no_default_scope');
725 $processed_value = array_get_index($_POST, $prefix.
'_default_scope',
'');
726 if (!empty($processed_value) && $asset->writeAccess(
'attributes')) {
727 $asset->setAttrValue(
'default_scope', $processed_value);
728 $asset->saveAttributes();
748 $scope = $asset->attr(
'scope');
770 if (!isset($_REQUEST[$prefix.
'_options']))
return;
771 $value = $_REQUEST[$prefix.
'_options'];
772 foreach ($value as $i => $v) {
773 $value[$i] = htmlentities($v);
774 if ($v ==
'') unset($value[$i]);
778 if (!isset($_REQUEST[$prefix.
'_options_keys']))
return;
779 $key_value = $_REQUEST[$prefix.
'_options_keys'];
780 foreach ($key_value as $j => $k) {
781 $key_value[$j] = htmlentities($k);
782 if (empty($key_value[$j])) {
783 unset($key_value[$j]);
788 foreach ($key_value as $index => $key) {
789 $values[$key] = (isset($value[$index])) ? $value[$index] :
'';
792 $processed_value = $values;
793 if ($asset->writeAccess(
'attributes')) {
794 $asset->setAttrValue(
'scope', $processed_value);
795 $asset->saveAttributes();
817 if ($asset->writeAccess(
'attributes')) {
825 <div
id=
"option-list-<?php echo $prefix; ?>">
828 if (count($values) > 0) {
829 foreach ($values as $k => $v) {
830 $k = html_entity_decode($k);
831 $v = html_entity_decode($v);
832 $printup = ($order < 1) ? FALSE : TRUE;
837 for ($i = 0; $i < 2; $i++) {
840 $printdown = ($i < 1) ? TRUE : FALSE;
846 <script type=
"text/javascript">
851 if (!SQ_IN_BACKEND && !SQ_IN_LIMBO) {
853 buttons = document.getElementsByTagName(
'BUTTON');
854 for (i = 0; i < buttons.length; i++) {
855 if (buttons[i].className ==
'delete-button') {
856 with (buttons[i].style) {
857 backgroundImage =
'url(<?php echo sq_web_path('lib
') ?>/web/images/icons/delete.png)';
858 backgroundPosition =
'50% 50%';
859 backgroundRepeat =
'no-repeat';
862 backgroundColor =
'transparent';
872 var optionItemPrefix =
'<?php echo $prefix; ?>';
875 var doExpandList =
new Function(
'doExpandOptionList(this)');
876 var doDeleteRow =
new Function(
'doDeleteOptionListRow(this); return false;');
878 function doExpandOptionList(input)
881 var nextInput = input.nextSibling;
882 while (nextInput !== null) {
883 if (nextInput.tagName ==
'INPUT') {
886 nextInput = nextInput.nextSibling;
890 var lastInput = input.previousSibling;
891 var last2Input = lastInput.previousSibling;
892 if (input.value ==
'') {
893 while (lastInput !== null) {
894 if (lastInput.tagName ==
'INPUT') {
895 last2Input = lastInput.previousSibling;
896 while (last2Input !== null) {
897 if (last2Input.tagName ==
'INPUT') {
898 if (last2Input.value ==
'') {
903 last2Input = last2Input.previousSibling;
907 lastInput = lastInput.previousSibling;
911 var optionList = document.getElementById(
'option-list-<?php echo $prefix; ?>');
912 var inputs = optionList.getElementsByTagName(
'INPUT');
914 var brElements = lastInput.parentNode.getElementsByTagName(
'BR');
915 input.parentNode.removeChild(brElements[brElements.length-1]);
916 input.parentNode.appendChild(document.createTextNode(
' '));
917 input.parentNode.appendChild(document.createElement(
'BR'));
920 var newInput = input.cloneNode(
true);
921 var newKeyInput = lastInput.cloneNode(
true);
922 var newId = (inputs.length/2);
923 var newKeyId = (inputs.length/2);
924 newKeyInput.onfocus = doExpandList;
925 newKeyInput.value =
'';
926 newKeyInput.id = optionItemPrefix+
'_options_keys['+newId+
']';
927 input.parentNode.appendChild(newKeyInput);
928 input.parentNode.appendChild(document.createTextNode(
' '));
929 newInput.onfocus = doExpandList;
931 newInput.id = optionItemPrefix+
'_options['+newId+
']';
932 input.parentNode.appendChild(newInput);
933 input.parentNode.appendChild(document.createTextNode(
' '));
934 var delButton = input.nextSibling;
935 while (delButton.tagName !=
'BUTTON') {
936 delButton = delButton.nextSibling;
938 delButton = delButton.cloneNode(
true);
939 delButton.onclick = doDeleteRow;
940 input.parentNode.appendChild(delButton);
941 input.parentNode.appendChild(document.createTextNode(
' '));
943 input.parentNode.appendChild(document.createTextNode(
' '));
944 input.parentNode.appendChild(document.createElement(
'BR'));
948 function doDeleteOptionListRow(button)
950 var input = button.previousSibling;
951 while (input.tagName !=
'INPUT') {
952 input = input.previousSibling;
955 var input2 = input.previousSibling;
956 while (input2.tagName !=
'INPUT') {
957 input2 = input2.previousSibling;
960 if (input.value ==
'')
return;
963 if (input.disabled)
return;
967 var inputs = input.parentNode.getElementsByTagName(
'INPUT');
968 if (inputs.length <= 2) {
974 var brTag = button.nextSibling;
975 while (brTag.tagName !=
'BR') {
976 brTag = brTag.nextSibling;
978 button.parentNode.removeChild(input2);
979 button.parentNode.removeChild(input);
980 button.parentNode.removeChild(brTag);
981 button.parentNode.removeChild(button);
985 var optionList = document.getElementById(
'option-list-<?php echo $prefix; ?>');
986 var inputs = optionList.getElementsByTagName(
'INPUT');
987 for (var j=0; j < inputs.length; j++) {
988 inputs[j].onfocus = doExpandList;
990 var buttons = optionList.getElementsByTagName(
'BUTTON');
991 for (var j=0; j < buttons.length; j++) {
992 buttons[j].onclick = doDeleteRow;
995 lastOrder = <?php echo $order; ?>;
1000 if (count($values) > 0) {
1002 foreach ($values as $value) {
1003 if (!empty($value)) {
1004 echo
'<li>'.html_entity_decode($value).
'</li>';
1029 $current_button = ($order * 2) + 1;
1032 $key_size = $size / 2;
1036 <input type=
"text" name=
"<?php echo $prefix; ?>_options_keys[]" value=
"<?php echo $key; ?>" id=
"<?php echo $prefix; ?>_options_keys[<?php echo $order; ?>]" size=
"<?=$key_size; ?>" />
1037 <input type=
"text" name=
"<?php echo $prefix; ?>_options[]" value=
"<?php echo $value; ?>" id=
"<?php echo $prefix; ?>_options[<?php echo $order; ?>]" size=
"<?=$size; ?>" />
1038 <button type=
"button" tabindex=
"99999" class=
"delete-button"> </button>