HEX
Server: Microsoft-IIS/10.0
System: Windows NT ITPWINWEBSVR22 10.0 build 20348 (Windows Server 2022) AMD64
User: www.conferencesearch.co.uk (0)
PHP: 8.3.30
Disabled: NONE
Upload Files
File: D:/web/castironradiatorcentre/changes prev/2024-02-29 (copies)/inc-template-reviews - Copy.asp
<%
' (SS,15/02/12) New for recent reviews and reviews page, product reviews are held in inc-template-other.asp
' (SS,23/05/12) Minor change to ShowReviewsPageItem
' (SS,28/08/14) Bootstrap version, version 2 of ShowRecentReviewsItem has more parameters, Recent Reviews link more to fotter and named More Reviews
' (SS,17/02/16) Changes to Sub ShowRecentReviewsItem to add Rich Snippets /  Microdata
' (SS,15/09/17) Added Sub ShowProductReviewsInDescHeader, ShowProductReviewsInDescItem, ShowProductReviewsInDescFooter
' (SS,22/10/19) Changes to fix errors shown in Google Search Console due to it thinking values missing from reviews on the home page
' Added Class RecentReviews and Sub ShowRecentReviewsStructuredData
' Snippets removed from ShowRecentReviewsItem

' (SS,21/10/19) added Class RecentReviews for new improved data/rich snippets for Google
' NB. const not allowed in Class
Const RR_AUTHOR = 0, RR_DATE_PUBLISHED = 1, RR_REVIEW_BODY = 2, RR_RATING = 3
Const RR_MAX_FIRST_ELEMENT = 3, RR_MAX_REVIEWS = 20 ' allow for up to 20 reviews

Class RecentReviews
  Private FReviewCount, FRatingSum
  Private FArray, FIndex
  ' NB. const not allowed in Class
  
  Private Sub Class_Initialize()   
    FReviewCount = 0
    FRatingSum = 0
    Redim FArray(RR_MAX_FIRST_ELEMENT, RR_MAX_REVIEWS)
  End Sub
  
  Private Sub Class_Terminate()
  End Sub
    
  Public Sub AddReview(AAuthor, ADatePublished, AReviewBody, ARating)
    Dim i
    i = FReviewCount
    FReviewCount = FReviewCount + 1
    FRatingSum = FRatingSum + ARating
    
    FArray(RR_AUTHOR, i) = AAuthor
    FArray(RR_DATE_PUBLISHED, i) = ADatePublished
    FArray(RR_REVIEW_BODY, i) = AReviewBody
    FArray(RR_RATING, i) = ARating
  End Sub

  Public Property Let ReviewIndex(AIndex)
    FIndex = AIndex
  End Property  

  Public Property Get ReviewCount()
    ReviewCount = FReviewCount
  End Property
  
  Public Property Get Author()
    Author = FArray(RR_AUTHOR, FIndex)
  End Property
  
  Public Property Get DatePublished()
    DatePublished = FArray(RR_DATE_PUBLISHED, FIndex)
  End Property

  Public Property Get ReviewBody()
    ReviewBody = FArray(RR_REVIEW_BODY, FIndex)
  End Property

  Public Property Get Rating()
    Rating = FArray(RR_RATING, FIndex)
  End Property
  
  Public Property Get AggregateRating()
    AggregateRating = Round2dp(FRatingSum / FReviewCount)
  End Property
  
End Class

Dim oRecentReviews

' --- START OF RECENT REVIEWS TEMPLATES --- '
Sub ShowRecentReviewsEmpty
' html to show if no recent reviews to go here '
%>
<%
End Sub

Sub ShowRecentReviewsHeader
  ' (SS,21/10/19) create the recent reviews object to show in structured data later
  Set oRecentReviews = New RecentReviews
%>
<div id="recent-reviews">
  <div id="recent-reviews-header">

  </div>
<%
End Sub

' (SS,26/8/14) new parameters AReviewTitle, AProductRating, AReviewerName, AReviewText 
' (SS,15/2/16) added rich snippets for reviews
' (SS,16/4/17) replaced <i> tag with <span> for review stars due to <i> being deprecated
' (SS,22/10/19) old version with rich snippets
Sub ShowRecentReviewsItemOld(ANumber, AReviewID, AProductCode, AProductName, ADateInfo, AReviewTitle, AProductRating, AReviewerName, AReviewText)
  ' (SS,22/10/19) added following to use later in JSON data snippet
  oRecentReviews.AddReview AReviewerName, ADateInfo, AReviewText, AProductRating
  
  Dim i
%>
<!-- START OF RECENT REVIEWS ITEM -->
  <div itemscope itemtype="http://schema.org/Review" class="recent-reviews-item">
    <div itemprop="itemReviewed" itemscope itemtype="http://schema.org/Product" class="recent-reviews-name"><a href="<%=GetScriptName%>?page=reviews#reviewid<%=AReviewID%>"><small><span itemprop="name"><%=AProductName%></span></small></a></div>
    <div>
<%For i = 1 To AProductRating%>    
    <span class="glyphicon glyphicon-star" style="color: #FFB500"></span>
<%Next%>
    &nbsp;<strong><%=AReviewTitle%></strong>
    </div>
    <div itemprop="reviewRating" itemscope itemtype="http://schema.org/Rating">
      <meta itemprop="ratingValue" content="<%=AProductRating%>">
    </div>
    <div class="recent-reviews-text">
      &quot;
      <span itemprop="reviewBody"><%=Mid(AReviewText, 1, 200) & "..."%></span>
      &quot;  
    </div>
    <div class="recent-reviews-date"><small><span itemprop="datePublished"><%=ADateInfo%></span>,</small> 
      <span itemprop="author" itemscope itemtype="http://schema.org/Person"><small><span itemprop="name"><%=AReviewerName%></span></small></span>
    </div>
  <br />
<!-- END OF RECENT REVIEWS ITEM -->
  </div>
<%
End Sub

' (SS,26/8/14) new parameters AReviewTitle, AProductRating, AReviewerName, AReviewText 
' (SS,15/2/16) added rich snippets for reviews
' (SS,16/4/17) replaced <i> tag with <span> for review stars due to <i> being deprecated
' (SS,22/10/19) new version with snippets removed due to Google now complaining about missing values (added to separate localbusiness snippet)
' removed itemscope itemtype="http://schema.org/Review" 
' itemprop="itemReviewed" itemscope itemtype="http://schema.org/Product" 
' itemprop="reviewRating" itemscope itemtype="http://schema.org/Rating"
'<span itemprop="name">
' meta itemprop="ratingValue"
' <span itemprop="reviewBody" 
' <span itemprop="datePublished">
' <span itemprop="author" itemscope itemtype="http://schema.org/Person"
' <span itemprop="name">
Sub ShowRecentReviewsItem(ANumber, AReviewID, AProductCode, AProductName, ADateInfo, AReviewTitle, AProductRating, AReviewerName, AReviewText)
  ' (SS,22/10/19) added following to use later in JSON data snippet
  oRecentReviews.AddReview AReviewerName, ADateInfo, AReviewText, AProductRating
  
  Dim i
%>
<!-- START OF RECENT REVIEWS ITEM -->
  <div class="recent-reviews-item">
    <div class="recent-reviews-name"><a href="<%=GetScriptName%>?page=reviews#reviewid<%=AReviewID%>"><small><%=AProductName%></small></a></div>
    <div>
<%For i = 1 To AProductRating%>    
    <span class="glyphicon glyphicon-star" style="color: #FFB500"></span>
<%Next%>
    &nbsp;<strong><%=AReviewTitle%></strong>
    </div>
    <div class="recent-reviews-text">
      &quot;
      <%=Mid(AReviewText, 1, 200) & "..."%>
      &quot;  
    </div>
    <div class="recent-reviews-date"><small><%=ADateInfo%>,</small> 
      <small><%=AReviewerName%></small>
    </div>
  <br />
<!-- END OF RECENT REVIEWS ITEM -->
  </div>
<%
End Sub

Sub ShowRecentReviewsFooter
%>
  <div id="recent-reviews-footer">
    <a href="<%=GetPageLink("reviews")%>">More Reviews</a>
  </div>
  <div class="clear"></div>
</div>
<%
End Sub

' (SS,21/10/19) renders the data in JSON format
Sub ShowRecentReviewsStructuredData
  ' exist if object oRecentReviews not defined, it's only set on home page currently
  If IsEmpty(oRecentReviews) Then
    Exit Sub
  End If
  Dim i, LReviewCount
  LReviewCount = oRecentReviews.ReviewCount

%>,
    "aggregateRating": {
      "@type": "AggregateRating",
      "ratingValue": "<%=oRecentReviews.AggregateRating%>",
      "ratingCount": "<%=LReviewCount%>"
     },
    "review": [<%
  For i = 0 To LReviewCount - 1
    oRecentReviews.ReviewIndex = i
%>
    {
    "@type": "Review",
    "author": "<%=JavaScriptStrEscape(oRecentReviews.Author)%>",
    "datePublished": "<%=oRecentReviews.DatePublished%>",
    "reviewBody": "<%=JavaScriptStrEscape(oRecentReviews.ReviewBody)%>",
    "reviewRating": {
      "@type": "Rating",
      "bestRating": "5",
      "ratingValue": "<%=oRecentReviews.Rating%>",
      "worstRating": "1"
    }
    }<%
    If i < (LReviewCount - 1) Then Response.Write(",")
  Next
%>
    ]
<%
End Sub

' (SS,24/10/19) to show count and average of all reviews in structured data, only run on home page
Sub ShowReviewAggregateRatingStructuredData
  ' exist if not home page or GetReviewAggregateRating returns false
  If Not IsHomePage Then
    Exit Sub
  End If
  Dim LReviewCount, LAverageRating
  If Not GetReviewAggregateRating(LReviewCount, LAverageRating) Then
    Exit Sub
  End If
%>,
    "aggregateRating": {
      "@type": "AggregateRating",
      "ratingValue": "<%=LAverageRating%>",
      "ratingCount": "<%=LReviewCount%>",
      "bestRating": "5",
      "worstRating": "1"
     }
<%
End Sub

' --- END OF RECENT REVIEWS TEMPLATES --- '

' --- START OF REVIEWS PAGE TEMPLATES --- '

Sub ShowReviewsPageHeader
  ' (SS,5/12/19) modified to add "" as 2nd and 3rd parameters
  ShowPageTitle "Reviews", "", ""
%>
<div id="other-pages2" style="padding: 0">
<%
End Sub

Sub ShowReviewsPageEmpty
%>
  No reviews yet.
<%
End Sub

' (SS,23/5/12) removed bold tags from product name which was resulting in extra bold via different font in IE and FireFox
' (SS,12/9/14) replaced ShowReviewRatingImage with ShowReviewRatingStars for Bootstrap, also further <i> with <em>
Sub ShowReviewsPageItem(ANumber, AReviewID, AProductCode, AProductName, AProductDisabled, ADate, ATitle, ARating, AText, AReviewedBy)
  Dim LProductLinkStart, LProductLinkEnd, i
  If AProductDisabled Then
    LProductLinkStart = ""
    LProductLinkEnd = ""
  Else
    LProductLinkStart = "<a href=""" + GetProductLink(AProductCode) + """>"
    LProductLinkEnd = "</a>"
  End If
%>
<!-- START OF REVIEWS PAGE ITEM -->
  <div class="reviews-page-item">
      <div class="reviews-page-item-header">        
        <div class="reviews-page-item-name"><a name="reviewid<%=AReviewID%>"></a>
          <h4><%=LProductLinkStart%><%=AProductName%><%=Iif(AProductDisabled, " (discontinued)", "")%><%=LProductLinkEnd%><h4>
        </div>
      </div>
    <div class="row">
      <div class="col-lg-3 col-md-3 col-sm-4 col-xs-12">    
        <div class="reviews-page-item-left">
          <%=LProductLinkStart%><img class="reviews-page-image" src="<%=GetProductImageLink(AProductCode, "s")%>" alt="<%=AProductName%>" /><%=LProductLinkEnd%>      
        </div>
      </div>
      <div class="col-lg-9 col-md-9 col-sm-8 col-xs-12">
        <div class="reviews-page-item-right">
          <div class="reviews-page-item-right-header">
            <div class="reviews-page-item-rating">
            <%ShowReviewRatingStars ARating%>
              <!--<div class="reviews-page-item-title"-->&nbsp;<big><b><%=ATitle%></b></big><!--</div>-->
            </div>            
            <!--<div class="reviews-page-item-date"><%=ADate%></div>-->
            <div class="reviews-page-item-review-by">Review by&nbsp;<%=AReviewedBy%> on <%=ADate%></div>        
          </div>
          <div class="reviews-page-item-body">        
            <p><em><%=AText%></em></p>
          </div>
        </div>
      </div>
    </div><!--row-->
  </div>
  <hr>
<!-- END OF REVIEWS PAGE ITEM -->  
<%
End Sub

Sub ShowReviewsPageFooter
%>
</div> <!-- end #other-pages2 -->
<%
End Sub

' (SS,15/9/17) added following for recent reviews to show in description, called from ShowProductReviewsInDesc in AppUtils.asp
Sub ShowProductReviewsInDescHeader
%>
  <hr>
  <div><h4>Most recent customer reviews</h4></div>
<%
End Sub

' (SS,15/9/17)
Sub ShowProductReviewsInDescItem(ADate, ATitle, ARating, AText, AReviewedBy)
  ShowReviewRatingStars ARating
  Response.Write "<span class=""small""> by " & AReviewedBy & " on " & ADate & "</span>"
  Response.Write AText
End Sub

' (SS,15/9/17)
Sub ShowProductReviewsInDescFooter
End Sub

' --- END OF REVIEWS PAGE TEMPLATE --- '


%>