Please do not spider search results in an automated fashion. " ."It can generate significant system load. "; if ($GLOBALS["G_PluginManager"]->PluginEnabled("XmlSitemap")) { print "Instead, please use the " ."XML Sitemap " ."that we provide."; } print ""; return; } # set page title PageTitle("Search Results - ".StdLib::NeatlyTruncateString( $H_SearchParams->TextDescription(FALSE), 120)); # ----- LOCAL FUNCTIONS ------------------------------------------------------ /** * Process an array of search facets, generating the necessary HTML for * each. * @param array $Facets Search facets to display. This is keyed by * FieldId. If there are no sub-selections, then the value is an * array of hrefs for URLs that will modify the search. If there * are subselection, then the value is an array that contains a * single array where the last element is a link to remove the * current selection and the other elements are suggestions. * @param array $FieldsOpenByDefault List of fields to be initially open. * @param bool $DisplayCounts If TRUE, resource counts will be added * to the list item if available. */ function PrintSearchFacets($Facets, $FieldsOpenByDefault, $DisplayCounts) { # ShrinkCounter counts the number of shrinkable facet spans so # that each can have a unique class name static $ShrinkCounter = 0; # if we have any facets if (count($Facets) > 0) { # iterate over each foreach ($Facets as $Key => $Values) { # if this facet should be open, display it as such, otherwise # display a closed facet (the HTML below differs in which # elements get the "display: none" initially applied) $ToggleClass = "DD_Toggle".$ShrinkCounter; if (isset($FieldsOpenByDefault[$Key])) { print "
" ."[" ."+" ."–" ."] ".$Key."" ."
\n" ."

\n"; } else { print "
" ."[" ."+" ."–" ."] ".$Key."" ."
\n" ."

\n"; } # foreach value in this facet, generate a list item foreach ($Values as $Value) { # check if this facet is a tree, which encodes # suggestions arrays if (!isset($Value["Name"])) { # current selection in the tree is always the last element $TopLevel = array_pop($Value); # display current selection $ListItem = GenerateFacetListItem($TopLevel, $DisplayCounts); print $ListItem."

\n"; # then list the children of the current selection in a sublist foreach ($Value as $ValueChild) { print GenerateFacetListItem($ValueChild, $DisplayCounts); } print "

\n"; } else { print GenerateFacetListItem($Value, $DisplayCounts); } } print "

\n"; $ShrinkCounter++; } } } /** * Generate list item HTML for facet. * @param array $Info List item info, with "Name" and either "AddLink" * or "RemoveLink" entries, and optionally a "Count" entry. * @param bool $DisplayCounts If TRUE, resource counts will be added * to the list item if available. * @return string Generated item string. */ function GenerateFacetListItem($Info, $DisplayCounts) { # if this is a removal item if (isset($Info["RemoveLink"])) { $Item = '
- '.$Info["Name"].' '."[X]
\n"; } # else this must be an addition item else { $Item = '
- '.$Info["Name"]; if ($DisplayCounts && isset($Info["Count"])) { $Item .= ' ('.$Info["Count"].')'; } $Item .= "
\n"; } # return generated item to caller return $Item; } /** * Get the controls for sorting and ordering. * @param int $ItemType Type of item handled by sort controls. * @param mixed $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 Returns the sort controls HTML as a string. */ function GetSortControls($ItemType, $SortField, $SortDescending, $SortableFields, $UrlParameterString, $SearchParams, $NumSearchResults) { # 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) { # 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 not sort field or starting index parameter for this item type if ((($Param != TransportControlsUI::PNAME_SORTFIELD) && ($Param != TransportControlsUI::PNAME_STARTINGINDEX)) || ($Index != $ItemType)) { # add tag to sort field tags $SortFieldHiddenTags .= $Tag; } # if not reverse sort parameter for this item type if (($Param != TransportControlsUI::PNAME_REVERSESORT) || ($Index != $ItemType)) { # add tag to sort direction tags $SortDirectionHiddenTags .= $Tag; } } } else { # build hidden tag $Tag = "\n"; # add tag to sort field and sort direction tags $SortFieldHiddenTags .= $Tag; $SortDirectionHiddenTags .= $Tag; } } # retrieve specifications for sort direction button list($AscOrderInfo, $DescOrderInfo) = GetSortOrderButton($SortField); # grab unique ID for use in the JavaScript below $SafeUniqId = defaulthtmlentities(uniqid()); $SafeSortFieldId = NULL; ob_start(); ?>
Sort by:
Order: ]" value="0" id="_RS_0" /> ↓ Ascending (*) ]" value="1" id="_RS_1" /> ↓ Descending (*)
SignalEvent("EVENT_HTML_INSERTION_POINT", array($GLOBALS["AF"]->GetPageName(), "Search Results Buttons", array( "ItemType" => $ItemType, "SearchParameters" => $SearchParams, "SortParamsForUrl" => $UrlParameterString, "NumberSearchResults" => $NumSearchResults, "ReturnToString" => $OurLink))); ?>
"Display the results in ascending order", "Text" => array("", ""), "Width" => 25); $Descending = array( "Message" => "Display the results in descending order", "Text" => array("", ""), "Width" => 25); # relevance or rating if (is_null($Field) || $Field->Name() == "Cumulative Rating") { $Ascending["Text"] = array("Lo", "Hi"); $Descending["Text"] = array("Hi", "Lo"); $Ascending["Width"] = 30; $Descending["Width"] = 30; } # based on field type else { switch ($Field->Type()) { case MetadataSchema::MDFTYPE_NUMBER: $Ascending["Text"] = array("1", "10"); $Descending["Text"] = array("10", "1"); break; case MetadataSchema::MDFTYPE_DATE: case MetadataSchema::MDFTYPE_TIMESTAMP: $Ascending["Text"] = array("JAN", "DEC"); $Descending["Text"] = array("DEC", "JAN"); $Ascending["Width"] = 35; $Descending["Width"] = 35; break; default: $Ascending["Text"] = array("A", "Z"); $Descending["Text"] = array("Z", "A"); break; } } return array($Ascending, $Descending); } /** * Print the search results display for specified item type. * @param int $ItemType Type of item. * @param object $SearchParams Search parameters. * @param array $SearchResults Array of search results, with item IDs for the * index and relevance scores for the values. * @param int $StartingIndex Starting index into search results for current page. * @param int $ResultsPerPage Number of results to display per page. * @param int $SortFieldId ID of field currently used for sorting results. * @param bool $SortDescending TRUE if results are currently sorted in descending * order, otherwise FALSE. * @param float $SearchTime Time it took to conduct search, in seconds. * @param bool $UseTabs TRUE to indicate that a tabbed interface should be * displayed, otherwise FALSE. * @param object $TransportUI Transport controls user interface object. */ function PrintSearchResults($ItemType, $SearchParams, $SearchResults, $StartingIndex, $ResultsPerPage, $SortFieldId, $SortDescending, $SearchTime, $UseTabs, $TransportUI) { # ----- SETUP (STRING BUILDING) ---------------------------------------------- # get text description of search parameters $SearchDescription = $SearchParams->TextDescription(); # tell transport UI to use our tab (if tabs in use) for any links if ($UseTabs) { $SaveActiveTab = $TransportUI->ActiveTab(); $TransportUI->ActiveTab($ItemType); } # build description of where we are in search results $ResultCount = count($SearchResults); $ResultPositionDescription = "Results " .number_format(min(($StartingIndex + 1), $ResultCount)) ." - " .number_format(min(($StartingIndex + $ResultsPerPage), $ResultCount)) ." of " .number_format($ResultCount) .""; # build blurb for footer if ((rand(0, 100) > 50) || !$GLOBALS["G_PluginManager"]->PluginEnabled("RSSExport") || !$GLOBALS["G_PluginManager"]->GetPlugin( "RSSExport")->ConfigSetting("SearchFeed")) { $RefineLink = "index.php?P=AdvancedSearch&RF=1&" .$SearchParams->UrlParameterString(); $FooterBlurb = "Too many (or not the right) results?" ." Refine your search!"; } else { $FooterBlurb = "This search is also available as an" ." UrlParameterString()."\">RSS feed."; } # ----- SETUP (DATA LOADING) ------------------------------------------------- # load sort controls HTML $Schema = new MetadataSchema($ItemType); $SortField = (($SortFieldId != "R") && $Schema->ItemExists($SortFieldId)) ? new MetadataField($SortFieldId) : NULL; $SortableFields = GetPossibleSortFields($ItemType); $FullUrlParameterString = "P=SearchResults&" .$SearchParams->UrlParameterString() .$TransportUI->UrlParameterString(FALSE); $SortControlsTop = GetSortControls( $ItemType, $SortField, $SortDescending, $SortableFields, $FullUrlParameterString, $SearchParams, count($SearchResults)); $SortControlsBottom = GetSortControls( $ItemType, $SortField, $SortDescending, $SortableFields, $FullUrlParameterString, $SearchParams, count($SearchResults)); # get data for faceted search $BaseLink = "index.php?P=SearchResults"; # if a sort field was set, preserve it if ($SortField !== NULL) { $BaseLink .= "&" .TransportControlsUI::PNAME_SORTFIELD ."[".$Schema->Id()."]=".$SortField->Id(); } $FacetUI = new SearchFacetUI($BaseLink, $SearchParams, $SearchResults, $GLOBALS["G_User"], $GLOBALS["G_SysConfig"]->MaxFacetsPerField(), $ItemType); $SuggestionsByFieldName = $FacetUI->GetSuggestionsByFieldName(); $TreeSuggestionsByFieldName = $FacetUI->GetTreeSuggestionsByFieldName(); $FieldsOpenByDefault = $FacetUI->GetFieldsOpenByDefault(); # determine whether faceted search should be displayed $ShowFacetedSearch = (count($SuggestionsByFieldName) || count($TreeSuggestionsByFieldName)) ? TRUE : FALSE; # determine whether counts should be displayed $DisplayCounts = (count($SearchResults) <= $GLOBALS["G_SysConfig"]->NumResourcesForSearchFacets()) ? TRUE : FALSE; # load resources to be displayed $ResultsToDisplay = array(); $ResultSliceIds = array_keys(array_slice( $SearchResults, $StartingIndex, $ResultsPerPage, TRUE)); foreach ($ResultSliceIds as $Id) { $ResultsToDisplay[] = new Resource($Id); } # ----- TAB CONTAINER (if any) BEGIN ------------------------------------ if ($UseTabs) { ?>
UrlParameters(), "&"); $TransportUI->PrintControls( $ItemType, $BaseLinkWithSearchParams, $SortControlsTop); $RefineLink = "index.php?P=AdvancedSearch&RF=1&" .$SearchParams->UrlParameterString(); ?>

Searched for: |

Narrow Your Search \n"; PrintSearchFacets($TreeSuggestionsByFieldName, $FieldsOpenByDefault, $DisplayCounts); ?> | ParameterCount()) { ?> No matching results were found. No search parameters were specified.

Search time: seconds |

PrintControls( $ItemType, $BaseLinkWithSearchParams, $SortControlsBottom); # ----- TAB CONTAINER (if any) END -------------------------------------- if ($UseTabs) { ?>
ActiveTab($SaveActiveTab); } # report to caller whether faceted search interface was displayed return $ShowFacetedSearch; } # ----- PAGE CONTENT --------------------------------------------------------- ?>

# Search Results

UrlParameterString(); ?> Refine Search
1); if ($UseTabs) { $GLOBALS["AF"]->RequireUIFile('jquery-ui.css', ApplicationFramework::ORDER_FIRST); ?>
StartingIndex(); $SortFields = $H_TransportUI->SortField(); foreach ($H_SearchResults as $ItemType => $TypeResults) { if ($ItemType != MetadataSchema::SCHEMAID_USER) { $ShowFacetedSearch |= PrintSearchResults( $ItemType, $H_SearchParams, $TypeResults, $StartingIndexes[$ItemType], $H_ResultsPerPage, $SortFields[$ItemType], $H_SortDescending[$ItemType], $H_SearchTime, $UseTabs, $H_TransportUI); } } # ----- TAB FOOTER ---------------------------------------------------------- if ($UseTabs) { ?>
ActiveTab()]."}"; ?>