Please try your search" ." again later, or log in before searching, if you have an account."; $MaintFile = is_readable("local/interface/default/MaintenanceMode.html") ? "local/interface/default/MaintenanceMode.html" : "interface/default/MaintenanceMode.html"; include($MaintFile); $AF->suppressStandardPageStartAndEnd(); return; } # bail out if this access came from an unwanted bot if (!isset($H_IsBot)) { throw new Exception("Required variable \$H_IsBot was not initialized"); } if ($H_IsBot) { print "
Please do not spider search results in an automated fashion. " ."It can generate significant system load. "; if (PluginManager::getInstance()->pluginEnabled("XmlSitemap")) { print "Instead, please use the " ."XML Sitemap " ."that we provide."; } print "
"; return; } if (!isset($H_SearchParams)) { throw new Exception("Required variable \$H_SearchParams was not initialized"); } # set page title PageTitle("Search Results - ".StdLib::NeatlyTruncateString( $H_SearchParams->TextDescription(false), 120 )); # ----- LOCAL FUNCTIONS ------------------------------------------------------ /** * Get hidden tags needed by the sort controls for sorting and ordering. * @param int $ItemType Type of item handled by sort controls. * @param ?MetadataField $SortField The field to sort by. * @param string $UrlParameterString String with all URL parameters. * @return array Two-element array of strings where the first gives the hidden * tags for sort fields and the second gives the hidden tags for the sort * direction. */ function getSortFieldHiddenTags( int $ItemType, ?MetadataField $SortField, string $UrlParameterString ) : array { # split out URL parameters to build hidden tags for sort field and direction parse_str($UrlParameterString, $UrlParameters); $SortFieldHiddenTags = ""; $SortDirectionHiddenTags = ""; # for each URL parameter foreach ($UrlParameters as $Param => $Values) { $VarNameSuffix = $ItemType ? $ItemType : ""; # if multiple values were (or may be) provided if (is_array($Values)) { # for each value foreach ($Values as $Index => $Value) { # build hidden tag $Tag = "\n"; if ((($Param != TransportControlsUI::PNAME_SORTFIELD.$VarNameSuffix) && ($Param != TransportControlsUI::PNAME_STARTINGINDEX.$VarNameSuffix)) || ($Index != $ItemType)) { # add tag to sort field tags $SortFieldHiddenTags .= $Tag; } # if not reverse sort parameter for this item type if (($Param != TransportControlsUI::PNAME_REVERSESORT.$VarNameSuffix) || ($Index != $ItemType)) { # add tag to sort direction tags $SortDirectionHiddenTags .= $Tag; } } } else { # build hidden tag $Tag = "\n"; # if param isn't reverse sort tag if ($Param != TransportControlsUI::PNAME_REVERSESORT.$VarNameSuffix) { # add to direction tags $SortDirectionHiddenTags .= $Tag; # and if param also isn't sort field tag or start index tag if ($Param != TransportControlsUI::PNAME_SORTFIELD.$VarNameSuffix || $Param != TransportControlsUI::PNAME_STARTINGINDEX.$VarNameSuffix) { # add to sort field tags $SortFieldHiddenTags .= $Tag; } } } } return [$SortFieldHiddenTags, $SortDirectionHiddenTags]; } /** * Get the controls for sorting and ordering. * @param int $ItemType Type of item handled by sort controls. * @param MetadataField|null $SortField The field to sort by. * @param bool $SortDescending Set to TRUE to indicate that sorting is in * descending order. * @param array $SortableFields Array of sortable fields. * @param string $UrlParameterString String with all URL parameters. * @param SearchParameterSet $SearchParams Search parameters for this search * @param int $NumSearchResults Number of search results * @return string Returns the sort controls HTML as a string. */ function GetSortControls( int $ItemType, ?MetadataField $SortField, bool $SortDescending, array $SortableFields, string $UrlParameterString, SearchParameterSet $SearchParams, int $NumSearchResults ) : string { # get hidden tags list($SortFieldHiddenTags, $SortDirectionHiddenTags) = getSortFieldHiddenTags( $ItemType, $SortField, $UrlParameterString ); # retrieve specifications for sort direction button list($AscOrderInfo, $DescOrderInfo) = GetSortOrderButton($SortField); # grab unique ID for use in the JavaScript below $SafeUniqId = defaulthtmlentities(uniqid()); $ForwardSortValue = (is_null($SortField) || $SortField->Type() == MetadataSchema::MDFTYPE_DATE || $SortField->Type() == MetadataSchema::MDFTYPE_TIMESTAMP) ? 1 : 0; $VarNameSuffix = $ItemType ? $ItemType : ""; $SortFieldVarName = TransportControlsUI::PNAME_SORTFIELD.$VarNameSuffix; $ReverseSortVarName = TransportControlsUI::PNAME_REVERSESORT.$VarNameSuffix; $SortButton = new HtmlButton("Sort"); $SortButton->setSize(HtmlButton::SIZE_SMALL); $SortButton->addClass("mv-search-sort-submit-button"); $SortOptions = []; $SortFieldId = is_object($SortField) ? $SortField->Id() : "R"; foreach ($SortableFields as $FieldId => $FieldName) { $SortOptions[$FieldId] = $FieldName; } $SortOptionList = new HtmlOptionList($SortFieldVarName, $SortOptions, $SortFieldId); ob_start(); ?>