$MaxDescriptionLength) { $Description = NeatlyTruncateString($Description, $MaxDescriptionLength); } # build rating graphic image tag (if any) $RatingGraphicImageTag = ""; if (($SearchResult["Cumulative Rating"] !== NULL) && ($SearchResult["Cumulative Rating Scale"] > 0)) { $RatingIndex = ($SearchResult["Cumulative Rating"] * 10) / $SearchResult["Cumulative Rating Scale"]; $RatingGraphicFileSuffixes = array( 0 => "1_0.gif", 1 => "1_0.gif", 2 => "1_0.gif", 3 => "1_5.gif", 4 => "2_0.gif", 5 => "2_5.gif", 6 => "3_0.gif", 7 => "3_5.gif", 8 => "4_0.gif", 9 => "4_5.gif", 10 => "5_0.gif", ); $RatingGraphicAltText = array( 0 => "This resource has a 1 star rating", 1 => "This resource has a 1 star rating", 2 => "This resource has a 1 star rating", 3 => "This resource has a 1.5 star rating", 4 => "This resource has a 2 star rating", 5 => "This resource has a 2.5 star rating", 6 => "This resource has a 3 star rating", 7 => "This resource has a 3.5 star rating", 8 => "This resource has a 4 star rating", 9 => "This resource has a 4.5 star rating", 10 => "This resource has a 5 star rating", ); $RatingGraphicImageTag = "
"; } ?>

" border="0" width="21" height="22" alt="View Resource" /> |  | " target="_blank">
"> | " target="_blank">More Info

0) { foreach ($Facets as $Key => $Values) { if ( isset($FieldsOpenByDefault[$Key]) ) print( "
" ."[" ."+" ."–" ."] ".$Key."" ."
" ."

"); else print( "
" ."[" ."+" ."–" ."] ".$Key."" ."
" ."

"); foreach ($Values as $FieldKey => $Value) { # Tree field suggestions are encoded as arrays: if (is_array($Value)) { $TopLevel = array_pop($Value); print("
- ".$TopLevel."
\n

"); foreach ($Value as $ValueChild) print("
- ".$ValueChild."
"); print("

"); } else { print("
- ".$Value."
"); } } print("

"); $G_ShrinkCounter++; } } } function AddTermToSearchURL($Field, $Term) { # Generate a search URL that just nukes this field: $UrlFiltered = preg_replace( array("/\\&[FHG]".$Field->Id()."=[^&]+/","/\\&SI=[0-9]+/"), '', $_SERVER["REQUEST_URI"]); if ($Field->Type() == MetadataSchema::MDFTYPE_TREE) { $UrlFiltered .= "&F".$Field->Id()."=".urlencode($Term); } else { if (isset($_GET["G".$Field->Id()])) $OldSetting = $_GET["G".$Field->Id()]; elseif (isset($_GET["H".$Field->Id()])) $OldSetting = $_GET["H".$Field->Id()]; $UrlFiltered .= "&H".$Field->Id()."=". (isset($OldSetting) ? $OldSetting."-": "" ). $Term; } return $UrlFiltered; } function RemoveTermFromSearchURL($Field, $Term) { # Generate a search URL that just nukes this field: $UrlFiltered = preg_replace( array("/\\&[FGH]".$Field->Id()."=[^&]+/","/\\&SI=[0-9]+/"), '', $_SERVER["REQUEST_URI"]); # For tree fields, offer to remove the last selected tree element. # Currently, this doesn't allow multiple-select searches for trees if ($Field->Type() == MetadataSchema::MDFTYPE_TREE) { if (isset($_GET["F".$Field->Id()])) { $TreeTerms = explode(' -- ', $_GET["F".$Field->Id()] ); array_pop($TreeTerms); if ( count($TreeTerms)>0 ) { $UrlFiltered .= '&F'.$Field->Id() .'='.urlencode(implode(' -- ',$TreeTerms)); } } } else { # Figure out if we used the AND or the OR prefix: $Prefix = (isset($_GET["G".$Field->Id()])) ? "G" : "H" ; # Extract the current selections: $CurrentSettings = explode("-", $_GET[$Prefix.$Field->Id()]); # Construct a new set of selections that filters out the desired term: $NewSettings = array(); foreach ($CurrentSettings as $Setting) { if ($Setting != $Term) $NewSettings []= $Setting; } # If there's only one suggestion left, offer it as an OR. # Otherwise, keep the selection using the previous logic. if (count($NewSettings)==1) { $UrlFiltered .= "&G".$Field->Id()."=".implode("-",$NewSettings); } elseif (count($NewSettings)>=2) { $UrlFiltered .= "&".$Prefix.$Field->Id()."=".implode("-",$NewSettings); } } return $UrlFiltered; } function cmp_plaintext($a, $b){ return strcmp( strip_tags($a), strip_tags($b)); } # ----- MAIN ----------------------------------------------------------------- $FoldersEnabled = $G_PluginManager->PluginEnabled("Folders"); $IsLoggedIn = $G_User->IsLoggedIn(); $ReturnToString = urlencode("index.php?".http_build_query($_GET)); $SafeReturnToString = defaulthtmlentities($ReturnToString); if ($FoldersEnabled) { $TooManyResources = $G_SearchResultTotal > Folders_Common::MAX_RESOURCES_PER_ADD; } # get the HTML for the sort controls to use when printing the transport controls # use two because the form elements need to have separate IDs for the labels to # work $SortControlsTop = GetResourceSortControls( $G_SortField, $G_SortDescending, $G_SearchGroupsArrayForUrl, $G_SortFields); $SortControlsBottom = GetResourceSortControls( $G_SortField, $G_SortDescending, $G_SearchGroupsArrayForUrl, $G_SortFields); $FieldsOpenByDefault = array(); $SuggestionsByFieldName = array(); $TreeSuggestionsByFieldName = array(); $DisplayCounts = $G_SearchResultTotal <= $SysConfig->NumResourcesForSearchFacets() ; foreach (SPTSearchEngine::GetResultFacets($G_SearchResultsAll) as $FieldName => $Suggestions) { $ThisField = $Schema->GetFieldByName($FieldName); $FieldId = $ThisField->Id(); # For tree fields... if ($ThisField->Type() == MetadataSchema::MDFTYPE_TREE) { # If we already have selections for this field, dig out the children of that # selection and present those as options: if (isset($_GET["F".$FieldId])) { $FieldsOpenByDefault[ $FieldName ] = "1"; $ParentValue = $_GET["F".$FieldId ]; $ParentSegments = explode(" -- ", $ParentValue); $DisplayedSegments = array(); # Keep track of what has been shown $FacetsForThisTree = array(); # Pull out those classifications which were explicitly assigned to something. # those are the ones we can get counts for: foreach ($Suggestions as $ValueId => $ValueData ) { $ValueName = $ValueData["Name"]; $ValueCount = $ValueData["Count"]; $FieldSegments = explode(" -- ", $ValueName); # Print any children of the current field value: if (preg_match("/^".preg_quote($ParentValue." -- ","/")."/", $ValueName) && count($FieldSegments) == count($ParentSegments)+1) { $DisplayedSegments[$ValueName]=TRUE; $LeafValue = array_pop($FieldSegments); $FacetsForThisTree []= '' .$LeafValue.($DisplayCounts ? ' ('.$ValueCount.')' : '' ).''; } } # Now, we'll need to iterate over the suggestions again and make sure that we've # displayed proper suggestions even for fields where only the lowest level # elements are displayed: foreach ($Suggestions as $ValueId => $ValueData ) { $ValueName = $ValueData["Name"]; $ValueCount = $ValueData["Count"]; $FieldSegments = explode(" -- ", $ValueName); # Skip segments that are along some other branch of this tree: if (!preg_match("/^".preg_quote($ParentValue." -- ","/")."/", $ValueName) ) continue; # Skip segments that aren't (grand)* children of the current parent. if (count($FieldSegments) < count($ParentSegments)) continue; $TargetSegments = array_slice( $FieldSegments, 0, count($ParentSegments)+1); $TargetName = implode(" -- ", $TargetSegments); if (!isset($DisplayedSegments[$TargetName])) { $DisplayedSegments[ $TargetName ] = TRUE; $LeafValue = array_pop( $TargetSegments ); $FacetsForThisTree []= '' .$LeafValue. ''; } } if (count($FacetsForThisTree) > 0 && count($FacetsForThisTree) <= $G_SysConfig->MaxFacetsPerField() ) { $TreeSuggestionsByFieldName[$FieldName][$ParentValue] = $FacetsForThisTree; $TreeSuggestionsByFieldName[ $FieldName ] [$ParentValue] []= ''.$ParentValue.' ' ."[X]" ; } } else { $FacetsForThisTree = array(); # Otherwise, list the toplevel options for this field: $DisplayedSegments = array(); # Keep track of what has been already shown # First, pull out those which are assigned to some reasources and for which # we can compute counts: foreach ($Suggestions as $ValueId => $ValueData ) { $ValueName = $ValueData["Name"]; $ValueCount = $ValueData["Count"]; $FieldSegments = explode(" -- ",$ValueName ); if (count($FieldSegments) == 1) { $DisplayedSegments[ $ValueName ] = TRUE; $FacetsForThisTree []= '' .$ValueName.($DisplayCounts ? ' ('.$ValueCount.')' : '' ).''; } } # Scan through the suggestions again, and verify that we've at least offered the top-level # option for each entry. foreach ($Suggestions as $ValueId => $ValueData) { $ValueName = $ValueData["Name"]; $ValueCount = $ValueData["Count"]; $FieldSegments = explode(" -- ",$ValueName ); if (!isset($DisplayedSegments[ $FieldSegments[0] ] )) { $DisplayedSegments[ $FieldSegments[0] ] = TRUE; $FacetsForThisTree []= '' .$FieldSegments[0].''; } } if (count($FacetsForThisTree) > 0 && count($FacetsForThisTree) <= $G_SysConfig->MaxFacetsPerField()) $TreeSuggestionsByFieldName[ $FieldName ] = $FacetsForThisTree; } } else { # For option fields, bail when there are too many suggestions for this option: if (count($Suggestions) > $G_SysConfig->MaxFacetsPerField()) continue; # If we have a non-optional field, with only one suggestion, and # And that field wasn't already selected as a facet, then don't display it. # So, want to actually display all the *other* fields. if (isset($_GET["G".$FieldId])) { # If it was OR logic, and there's more than one suggestion, then # we can't facet this field, so bail. $CurrentValue = $_GET["G".$FieldId]; if (count(explode("-", $CurrentValue))>1) continue; } elseif (isset($_GET["H".$FieldId])) { $CurrentValue = $_GET["H".$FieldId]; } if ( !($ThisField->Optional() == FALSE && count($Suggestions)==1 && !isset($CurrentValue))) { foreach ($Suggestions as $ValueId => $ValueData) { $ValueName = $ValueData["Name"]; $ValueCount = $ValueData["Count"]; if ( isset($CurrentValue) && in_array($ValueId, explode("-", $CurrentValue) ) ) { $FieldsOpenByDefault[ $FieldName ] = "1"; $SuggestionsByFieldName[ $FieldName ] []= ''.$ValueName.' ' ."[X]" ; } else { # If we have a selection for this field, then we will not be able to generate accurate # search counts, so do not display them. $SuggestionsByFieldName[ $FieldName ] []= '' .$ValueName.($DisplayCounts ? ' ('.$ValueCount.')' : '' )."" ; } } } } } ## # Make sure that we've got a facet displayed for each selected search option foreach ($_GET as $Key => $Value) { if ($Key[0] == "G" || $Key[0] == "F" || $Key[0] == "H") { $FieldId = str_replace( array("F","G","H"), '', $Key); $ThisField = $Schema->GetField( $FieldId ); if ( !is_object($ThisField) || $ThisField->Status() !== MetadataSchema::MDFSTAT_OK || !$ThisField->IncludeInFacetedSearch() ) continue; if ($ThisField->Type() == MetadataSchema::MDFTYPE_TREE) { if ( !isset($TreeSuggestionsByFieldName[$ThisField->Name()]) ) { $FieldsOpenByDefault[ $ThisField->Name() ] = "1"; $TreeSuggestionsByFieldName[ $ThisField->Name() ] [$Value] []= ''.$Value.' ' ."[X]" ; } } else if ($ThisField->Type() == MetadataSchema::MDFTYPE_OPTION || $ThisField->Type() == MetadataSchema::MDFTYPE_CONTROLLEDNAME) { if ( !isset($SuggestionsByFieldName[$ThisField->Name()]) ) { # If this was a "Contains" search run against a controlled name, # Then don't try to display it as if it were a facet that can be removed. if ($Key[0] == "F") continue; $FieldsOpenByDefault[ $ThisField->Name() ] = "1"; if (isset($_GET["G".$FieldId])) $CurrentValues = explode("-", $_GET["G".$FieldId]); else $CurrentValues = explode("-", $_GET["H".$FieldId]); foreach ($CurrentValues as $Value) { $CName = new ControlledName($Value); $SuggestionsByFieldName[ $ThisField->Name() ] []= ''.$CName->Name().' ' ."[X]" ; } } } } } foreach ($TreeSuggestionsByFieldName as &$Suggestion) { uasort($Suggestion, "cmp_plaintext"); } # Within each field, sort the suggestions alphabetically. foreach ($SuggestionsByFieldName as &$Suggestion) { uasort($Suggestion, "cmp_plaintext"); } ?>

# CWISnet Search Results

# Search Results

&ReturnTo=" title="Add the results of this search to your current folder."> " alt="" /> Add to Folder " alt="" /> Add to Folder ">Refine Search
Search Locally
Search CWISnet
" .number_format(min(($G_StartingResult + 1), $G_SearchResultTotal)) ." - " .number_format(min(($G_StartingResult + $G_RecordsPerPage), $G_SearchResultTotal)) ." of " .number_format($G_SearchResultTotal) .""; ?>

Searched for: |  | HasPriv(PRIV_COLLECTIONADMIN, PRIV_SYSADMIN) && !IsGlobalSearch()) { ?> 0) { ?> ( currently flagged) |

Narrow Your Search \n"); PrintSearchFacets($TreeSuggestionsByFieldName, $FieldsOpenByDefault); ?> | No matching results were found.

Search time: seconds | 50) { ?> Too many (or not the right) results? Refine your search! This search is also available as an RSS feed.