GetFieldByMappedName("Title"); if ($Resource->UserCanViewField($G_User, $TitleField)) { $Title = strip_tags($Resource->Get($TitleField), ""); } $UrlField = $Schema->GetFieldByMappedName("Url"); if ($Resource->UserCanViewField($G_User, $UrlField)) { # maximum length of the URL $MaxLength = 60; $Url = $Resource->Get($UrlField); if (!strlen($Url)) { unset($Url); } else if (strlen($Url) > $MaxLength && strlen(strip_tags($Url))==strlen($Url)) { $Url = substr($Url, 0, $MaxLength)."..."; } } if ($DisplayDescription) { $DescriptionField = $Schema->GetFieldByMappedName("Description"); if ($DescriptionField instanceof MetadataField && $Resource->UserCanViewField($G_User, $DescriptionField)) { # maximum length of description (in characters) $MaxLength = 200; # get stripped and length-limited version of description $Description = strip_tags($Resource->Get($DescriptionField), ""); $Description = StdLib::NeatlyTruncateString($Description, $MaxLength); # if list of search terms was supplied if (is_array($TermsToHighlight) && count($TermsToHighlight)) { # highlight terms in description foreach ($TermsToHighlight as $Term) { $Patterns[] = "/([^a-z]{1})(".$Term.")([^a-z]{1})/i"; $Replacements[] = "\\1\\2\\3"; $Patterns[] = "/^(".$Term.")([^a-z]{1})/i"; $Replacements[] = "\\1\\2"; $Patterns[] = "/([^a-z]{1})(".$Term.")$/i"; $Replacements[] = "\\1\\2"; } $Description = preg_replace( $Patterns, $Replacements, $Description); } } } $ScreenshotField = $Schema->GetFieldByMappedName("Screenshot"); if ($Resource->UserCanViewField($G_User, $ScreenshotField)) { $Screenshot = $Resource->Get($ScreenshotField, TRUE); if (is_null($Screenshot) || !is_readable($Screenshot->ThumbnailUrl())) { unset($Screenshot); } } $RatingField = $Schema->GetFieldByName("Cumulative Rating"); if ($G_SysConfig->ResourceRatingsEnabled() && $Resource->UserCanViewField($G_User, $RatingField)) { if ($G_User->IsLoggedIn()) { $UserRating = $Resource->Rating(); } $BaseRatingGraphic = "StarRating--"; if (!is_null($Resource->ScaledCumulativeRating())) { switch ($Resource->ScaledCumulativeRating()) { case 0: $Rating["Graphic"] = $BaseRatingGraphic."1_0.gif"; $Rating["Alt"] = "This resource has a 1 star rating"; break; case 1: $Rating["Graphic"] = $BaseRatingGraphic."1_0.gif"; $Rating["Alt"] = "This resource has a 1 star rating"; break; case 2: $Rating["Graphic"] = $BaseRatingGraphic."1_0.gif"; $Rating["Alt"] = "This resource has a 1 star rating"; break; case 3: $Rating["Graphic"] = $BaseRatingGraphic."1_5.gif"; $Rating["Alt"] = "This resource has a 1.5 star rating"; break; case 4: $Rating["Graphic"] = $BaseRatingGraphic."2_0.gif"; $Rating["Alt"] = "This resource has a 2 star rating"; break; case 5: $Rating["Graphic"] = $BaseRatingGraphic."2_5.gif"; $Rating["Alt"] = "This resource has a 2.5 star rating"; break; case 6: $Rating["Graphic"] = $BaseRatingGraphic."3_0.gif"; $Rating["Alt"] = "This resource has a 3 star rating"; break; case 7: $Rating["Graphic"] = $BaseRatingGraphic."3_5.gif"; $Rating["Alt"] = "This resource has a 3.5 star rating"; break; case 8: $Rating["Graphic"] = $BaseRatingGraphic."4_0.gif"; $Rating["Alt"] = "This resource has a 4 star rating"; break; case 9: $Rating["Graphic"] = $BaseRatingGraphic."4_5.gif"; $Rating["Alt"] = "This resource has a 4.5 star rating"; break; case 10: $Rating["Graphic"] = $BaseRatingGraphic."5_0.gif"; $Rating["Alt"] = "This resource has a 5 star rating"; break; } } } ?>