is_array($v) || is_int_loose($v) || preg_match("~^\\-*\\d+[,\\-*\\d+]*$~", $v) ), false, fn ($v) => is_array($v) || is_int_loose($v) || preg_match("~^\\-*\\d+[,\\-*\\d+]*$~", $v) ); if ($archivechoices !== false) { $search_all_workflow_states = false; } else { $archivechoices = get_default_search_states(); } if (!is_array($archivechoices)) { $archivechoices = explode(",", $archivechoices); } foreach ($archivechoices as $archivechoice) { if (is_numeric($archivechoice)) { $selected_archive_states[] = $archivechoice; } } $archive = implode(",", $selected_archive_states); $archiveonly = count(array_diff($selected_archive_states, array(1,2))) == 0; # Selectedtypes is a list of (resource type) checkboxes which are checked # Selectedtypes can also contain FeaturedCollections if $search_includes_themes = true $selectedtypes = get_selectedtypes(); $access = getval("access", null, true); rs_setcookie("access", $access, 0, "{$baseurl_short}pages/", "", false, false); # Disable auto-save function, only applicable to edit form. Some fields pick up on this value when rendering then fail to work. $edit_autosave = false; if (getval("submitted", "") == "yes" && getval("resetform", "") == "") { $restypes = ""; reset($_POST); foreach ($_POST as $key => $value) { if (substr($key, 0, 12) == "resourcetype") { if ($restypes != "") { $restypes .= ","; } $restypes .= substr($key, 12); } if ($key == "hiddenfields") { $hiddenfields = $value; } } rs_setcookie('restypes', $restypes, 0, "", "", false, false); if ($hide_search_resource_types) { $restypes = ''; } # advanced search - build a search query and redirect $fields = array_merge(get_advanced_search_fields(false, $hiddenfields), get_advanced_search_collection_fields(false, $hiddenfields)); # Build a search query from the search form $search = search_form_to_search_query($fields); $search = refine_searchstring($search); if (getval("countonly", "") != "") { # Only show the results (this will appear in an iframe) if (substr($restypes, 0, 19) != "FeaturedCollections") { $result = do_search($search, $restypes, "relevance", $archive, [0,0], "", false, DEPRECATED_STARSEARCH, false, false, "", false, false, true, false, false, $access); } else { $order_by = $default_collection_sort; $sort = "DESC"; $result = do_collections_search($search, $restypes, $archive, $order_by, $sort); } if (is_array($result)) { $count = $result["total"] ?? count($result); } else { $count = 0; } ?> $search, "archive" => $archive, "restypes" => $restypes, "access" => $access, ) ) ); } } # Reconstruct a values array based on the search keyword, so we can pre-populate the form from the current search $search = isset($_COOKIE["search"]) ? $_COOKIE["search"] : ""; $keywords = split_keywords($search, false, false, false, false, true); $allwords = ""; $found_year = ""; $found_month = ""; $found_day = ""; $found_start_date = ""; $found_end_date = ""; $searched_nodes = array(); $full_text_search = ""; foreach ($advanced_search_properties as $advanced_search_property => $code) { $$advanced_search_property = ""; } $values = array(); if (getval("resetform", "") != "") { $found_year = ""; $found_month = ""; $found_day = ""; $found_start_date = ""; $found_end_date = ""; $allwords = ""; $full_text_search = ""; $restypes = get_search_default_restypes(); rs_setcookie('restypes', implode(",", $restypes), 0, "", "", false, false); $selected_archive_states = array(0); rs_setcookie("search", "", 0, "", "", false, false); rs_setcookie("saved_archive", "", 0, "", "", false, false); $access = null; rs_setcookie("access", "", 0, "{$baseurl_short}pages/", "", false, false); } else { if (getval("restypes", "") == "") { $restypes = get_search_default_restypes(); } else { $restypes = explode(",", getval("restypes", "")); } for ($n = 0; $n < count($keywords); $n++) { $keyword = trim($keywords[$n]); $quoted_string = (substr($keyword, 0, 1) == "\"" || substr($keyword, 0, 2) == "-\"" ) && substr($keyword, -1, 1) == "\""; if (strpos($keyword, ":") !== false && substr($keyword, 0, 1) != "!") { if ((substr($keyword, 0, 1) == "\"" || substr($keyword, 0, 2) == "-\"" ) && substr($keyword, -1, 1) == "\"") { $nk = explode(":", substr($keyword, 1, -1)); if ($nk[0] == FULLTEXT_SEARCH_PREFIX) { $name = trim($nk[0]); $full_text_search = str_replace(FULLTEXT_SEARCH_QUOTES_PLACEHOLDER, "\"", $nk[1]); } else { $name = trim($nk[0]); $keyword = "\"" . trim($nk[1]) . "\""; } } else { $nk = explode(":", $keyword); $name = trim($nk[0]); $keyword = trim($nk[1]); } if ($name == "basicday") { $found_day = $keyword; } if ($name == "basicmonth") { $found_month = $keyword; } if ($name == "basicyear") { $found_year = $keyword; } if ($name == "startdate") { $found_start_date = $keyword; } if ($name == "enddate") { $found_end_date = $keyword; } if (isset($values[$name])) { $values[$name] .= " " . $keyword; } else { $values[$name] = $keyword; } } elseif (substr($keyword, 0, 11) == "!properties") { $properties = explode(";", substr($keyword, 11)); $propertyfields = array_flip($advanced_search_properties); foreach ($properties as $property) { $propertycheck = explode(":", $property); $propertyname = isset($propertycheck[0]) ? $propertycheck[0] : ""; $propertyval = isset($propertycheck[1]) ? $propertycheck[1] : ""; if ($propertyval != "" && isset($propertyfields[$propertyname])) { $fieldname = $propertyfields[$propertyname]; $$fieldname = $propertyval; } } } elseif (strpos($keyword, NODE_TOKEN_PREFIX) !== false) { // Nodes search $nodes = resolve_nodes_from_string($keyword); foreach ($nodes as $node) { $searched_nodes[] = $node; } } else { if ($allwords == "") { $allwords = $keyword; } else { $allwords .= ", " . $keyword; } } } $allwords = str_replace(', ', ' ', $allwords); } include "../include/header.php"; ?>