File: D:/HostingSpaces/TDijk1/erp-apps.eu/wwwroot/ERPApps/ERPWebParts/Documents/ReviewsRepeater.ascx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using CMS.PortalControls;
using CMS.GlobalHelper;
using CMS.CMSHelper;
using CMS.PortalEngine;
using CMS.TreeEngine;
using CMS.Controls;
using CMS.DocumentEngine;
using CMS.Helpers;
/// <summary>
/// Reviews repeater for displaying submitted reviews in Vendors zone
/// </summary>
public partial class ERPApps_ERPWebParts_Documents_ReviewsRepeater : CMSAbstractWebPart
{
#region "Properties"
/// <summary>
/// Doctype of review.
/// Default is ERPConfig.DOCTYPE_REVIEW
/// </summary>
public string DocumentType
{
get
{
return ValidationHelper.GetString(this.GetValue("DocumentType"), ERPConfig.DOCTYPE_REVIEW);
}
set
{
this.SetValue("DocumentType", value);
}
}
/// <summary>
/// Transformation used to render review`s preview.
/// Default is ERPConfig.DOCTYPE_REVIEW.Preview
/// </summary>
public string PreviewTransformationName
{
get
{
return ValidationHelper.GetString(this.GetValue("PreviewTransformationName"), ERPConfig.DOCTYPE_REVIEW + ".Preview");
}
set
{
this.SetValue("PreviewTransformationName", value);
}
}
/// <summary>
/// Transformation used to render detail of review.
/// Default is ERPConfig.DOCTYPE_REVIEW.Default
/// </summary>
public string DefaultTransformationName
{
get
{
return ValidationHelper.GetString(this.GetValue("DefaultTransformationName"), ERPConfig.DOCTYPE_REVIEW + ".Default");
}
set
{
this.SetValue("DefaultTransformationName", value);
}
}
/// <summary>
/// ORDER BY expression to sort reviews in the repeater.
/// Default is ReviewDate DESC
/// </summary>
public string OrderBy
{
get
{
return ValidationHelper.GetString(this.GetValue("OrderBy"), "ReviewDate DESC");
}
set
{
this.SetValue("OrderBy", value);
}
}
/// <summary>
/// Template displayed at the top of the repeater.
/// Macro $$appname$$ can be used to display application`s name.
/// </summary>
public string HeadingTemplate
{
get
{
return ValidationHelper.GetString(this.GetValue("HeadingTemplate"), "$$appname$$");
}
set
{
this.SetValue("HeadingTemplate", value);
}
}
/// <summary>
/// Content displayed if no reviews are found.
/// </summary>
public string NoReviewsText
{
get
{
return ValidationHelper.GetString(this.GetValue("NoReviewsText"), null);
}
set
{
this.SetValue("NoReviewsText", value);
}
}
/// <summary>
/// Application for which the reviews should be displayed.
/// </summary>
public int AppNodeID
{
get
{
return ValidationHelper.GetInteger(this.GetValue("AppNodeID"), 0);
}
set
{
this.SetValue("AppNodeID", value);
}
}
/// <summary>
/// Review ID in case of displaying review detail.
/// </summary>
public int ReviewNodeID
{
get
{
return ValidationHelper.GetInteger(this.GetValue("ReviewNodeID"), 0);
}
set
{
this.SetValue("ReviewNodeID", value);
}
}
TreeNode mAppNode;
public TreeNode AppNode
{
get
{
if ( mAppNode == null )
{
mAppNode = TreeHelper.SelectSingleNode(AppNodeID);
}
return mAppNode;
}
set
{
mAppNode = value;
}
}
#endregion
#region "Initialization"
public override void OnContentLoaded()
{
base.OnContentLoaded();
SetupControl();
}
private void SetupControl()
{
if ( StopProcessing || !IsVisible || AppNodeID == 0)
{
return;
}
// get path for folder with reviews
string path = ERPDataHelper.GetReviewsDirectoryPath(AppNodeID);
if ( path == null && PortalContext.ViewMode == ViewModeEnum.LiveSite )
{
ERPDataHelper.Redirect404(false);
}
// set heading
lblHeading.Text = HeadingTemplate.Replace("$$appname$$", ValidationHelper.GetString(AppNode.GetValue("AppName"), ""));
if ( ReviewNodeID > 0 )
{
// detail of a review
repeater.WhereCondition = "NodeID = " + ReviewNodeID;
repeater.TransformationName = DefaultTransformationName;
}
else if ( ReviewNodeID == 0 )
{
// list of reviews
repeater.TransformationName = PreviewTransformationName;
}
repeater.ClassNames = DocumentType;
repeater.Path = path;
repeater.OrderBy = OrderBy;
if ( !DataHelper.IsEmpty(NoReviewsText) )
{
repeater.HideControlForZeroRows = false;
repeater.ZeroRowsText = NoReviewsText;
}
}
#endregion
}