using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using CMS.GlobalHelper;
using CMS.PortalControls;
using CMS.PortalEngine;
public partial class CMSWebParts_Viewers_Effects_ScrollingText : CMSAbstractWebPart
{
#region "Variables"
protected string mStyleOptions = null;
protected int totalItems = 0;
#endregion
#region "Document properties"
///
/// Gets or sets the cache item name.
///
public override string CacheItemName
{
get
{
return base.CacheItemName;
}
set
{
base.CacheItemName = value;
repItems.CacheItemName = value;
}
}
///
/// Cache dependencies, each cache dependency on a new line.
///
public override string CacheDependencies
{
get
{
return ValidationHelper.GetString(base.CacheDependencies, repItems.CacheDependencies);
}
set
{
base.CacheDependencies = value;
repItems.CacheDependencies = value;
}
}
///
/// Gets or sets the cache minutes.
///
public override int CacheMinutes
{
get
{
return base.CacheMinutes;
}
set
{
base.CacheMinutes = value;
repItems.CacheMinutes = value;
}
}
///
/// Gets or sets the value that indicates whether permissions should be checked.
///
public bool CheckPermissions
{
get
{
return ValidationHelper.GetBoolean(GetValue("CheckPermissions"), repItems.CheckPermissions);
}
set
{
SetValue("CheckPermissions", value);
}
}
///
/// Gets or sets the class names which should be displayed.
///
public string ClassNames
{
get
{
return DataHelper.GetNotEmpty(ValidationHelper.GetString(GetValue("Classnames"), repItems.ClassNames), repItems.ClassNames);
}
set
{
SetValue("ClassNames", value);
repItems.ClassNames = value;
}
}
///
/// Gets or sets the value that indicates whether documents are combined with default culture version.
///
public bool CombineWithDefaultCulture
{
get
{
return ValidationHelper.GetBoolean(GetValue("CombineWithDefaultCulture"), repItems.CombineWithDefaultCulture);
}
set
{
SetValue("CombineWithDefaultCulture", value);
repItems.CombineWithDefaultCulture = value;
}
}
///
/// Gets or sets the value that indicates whether filter out duplicate documents.
///
public bool FilterOutDuplicates
{
get
{
return ValidationHelper.GetBoolean(GetValue("FilterOutDuplicates"), repItems.FilterOutDuplicates);
}
set
{
SetValue("FilterOutDuplicates", value);
repItems.FilterOutDuplicates = value;
}
}
///
/// Gets or sets the culture code of the documents.
///
public string CultureCode
{
get
{
return DataHelper.GetNotEmpty(ValidationHelper.GetString(GetValue("CultureCode"), repItems.CultureCode), repItems.CultureCode);
}
set
{
SetValue("CultureCode", value);
repItems.CultureCode = value;
}
}
///
/// Gets or sets the maximal relative level of the documents to be shown.
///
public int MaxRelativeLevel
{
get
{
return ValidationHelper.GetInteger(GetValue("MaxRelativeLevel"), repItems.MaxRelativeLevel);
}
set
{
SetValue("MaxRelativeLevel", value);
repItems.MaxRelativeLevel = value;
}
}
///
/// Gets or sets the order by clause.
///
public string OrderBy
{
get
{
return DataHelper.GetNotEmpty(ValidationHelper.GetString(GetValue("OrderBy"), repItems.OrderBy), repItems.OrderBy);
}
set
{
SetValue("OrderBy", value);
repItems.OrderBy = value;
}
}
///
/// Gets or sets the path of the documents.
///
public string Path
{
get
{
return DataHelper.GetNotEmpty(ValidationHelper.GetString(GetValue("Path"), repItems.Path), repItems.Path);
}
set
{
SetValue("Path", value);
repItems.Path = value;
}
}
///
/// Gets or sets the value that indicates whether only published documents are selected.
///
public bool SelectOnlyPublished
{
get
{
return ValidationHelper.GetBoolean(GetValue("SelectOnlyPublished"), repItems.SelectOnlyPublished);
}
set
{
SetValue("SelectOnlyPublished", value);
repItems.SelectOnlyPublished = value;
}
}
///
/// Gets or sets the site name.
///
public string SiteName
{
get
{
return DataHelper.GetNotEmpty(ValidationHelper.GetString(GetValue("SiteName"), repItems.SiteName), repItems.SiteName);
}
set
{
SetValue("SiteName", value);
repItems.SiteName = value;
}
}
///
/// Gets or sets the where condition.
///
public string WhereCondition
{
get
{
return DataHelper.GetNotEmpty(GetValue("WhereCondition"), repItems.WhereCondition);
}
set
{
SetValue("WhereCondition", value);
repItems.WhereCondition = value;
}
}
///
/// Gets or sets the number which indicates how many documents should be displayed.
///
public int SelectTopN
{
get
{
return ValidationHelper.GetInteger(GetValue("SelectTopN"), repItems.SelectTopN);
}
set
{
SetValue("SelectTopN", value);
repItems.SelectTopN = value;
}
}
///
/// Gets or sets the columns to get.
///
public string Columns
{
get
{
return DataHelper.GetNotEmpty(GetValue("Columns"), repItems.Columns);
}
set
{
SetValue("Columns", value);
repItems.Columns = value;
}
}
#endregion
#region "Relationships properties"
///
/// Gets or sets the value that indicates whether related node is on the left side.
///
public bool RelatedNodeIsOnTheLeftSide
{
get
{
return ValidationHelper.GetBoolean(GetValue("RelatedNodeIsOnTheLeftSide"), repItems.RelatedNodeIsOnTheLeftSide);
}
set
{
SetValue("RelatedNodeIsOnTheLeftSide", value);
repItems.RelatedNodeIsOnTheLeftSide = value;
}
}
///
/// Gets or sets the relationship name.
///
public string RelationshipName
{
get
{
return DataHelper.GetNotEmpty(ValidationHelper.GetString(GetValue("RelationshipName"), repItems.RelationshipName), repItems.RelationshipName);
}
set
{
SetValue("RelationshipName", value);
repItems.RelationshipName = value;
}
}
///
/// Gets or sets the relationship with node GUID.
///
public Guid RelationshipWithNodeGUID
{
get
{
return ValidationHelper.GetGuid(GetValue("RelationshipWithNodeGuid"), repItems.RelationshipWithNodeGuid);
}
set
{
SetValue("RelationshipWithNodeGuid", value);
repItems.RelationshipWithNodeGuid = value;
}
}
#endregion
#region "Transformation properties"
///
/// Gets or sets the name of the transforamtion which is used for displaying the results.
///
public string TransformationName
{
get
{
return DataHelper.GetNotEmpty(ValidationHelper.GetString(GetValue("TransformationName"), repItems.TransformationName), repItems.TransformationName);
}
set
{
SetValue("TransformationName", value);
repItems.TransformationName = value;
}
}
///
/// Gets or sets the name of the transforamtion which is used for displaying the alternate results.
///
public string AlternatingTransformationName
{
get
{
return DataHelper.GetNotEmpty(ValidationHelper.GetString(GetValue("AlternatingTransformationName"), repItems.AlternatingTransformationName), repItems.AlternatingTransformationName);
}
set
{
SetValue("AlternatingTransformationName", value);
repItems.AlternatingTransformationName = value;
}
}
#endregion
#region "Public properties"
///
/// Gets or sets the nested controls IDs. Use ';' like separator.
///
public string NestedControlsID
{
get
{
return ValidationHelper.GetString(GetValue("NestedControlsID"), repItems.NestedControlsID);
}
set
{
SetValue("NestedControlsID", value);
repItems.NestedControlsID = value;
}
}
///
/// Gets or sets the value that indicates whether control should be hidden if no data found.
///
public bool HideControlForZeroRows
{
get
{
return ValidationHelper.GetBoolean(GetValue("HideControlForZeroRows"), repItems.HideControlForZeroRows);
}
set
{
SetValue("HideControlForZeroRows", value);
repItems.HideControlForZeroRows = value;
}
}
///
/// Gets or sets the text which is displayed for zero rows results.
///
public string ZeroRowsText
{
get
{
return DataHelper.GetNotEmpty(ValidationHelper.GetString(GetValue("ZeroRowsText"), repItems.ZeroRowsText), repItems.ZeroRowsText);
}
set
{
SetValue("ZeroRowsText", value);
repItems.ZeroRowsText = value;
}
}
///
/// Gets or sets the separator (tetx, html code) which is displayed between displayed items.
///
public string ItemSeparator
{
get
{
return DataHelper.GetNotEmpty(GetValue("ItemSeparator"), repItems.ItemSeparator);
}
set
{
SetValue("ItemSeparator", value);
repItems.ItemSeparator = value;
}
}
#endregion
#region "Div properties"
///
/// Gets or sets the DIV element width.
///
public int DivWidth
{
get
{
return ValidationHelper.GetInteger(GetValue("DivWidth"), 400);
}
set
{
SetValue("DivWidth", value);
}
}
///
/// Gets or sets the DIV element height.
///
public int DivHeight
{
get
{
return ValidationHelper.GetInteger(GetValue("DivHeight"), 300);
}
set
{
SetValue("DivHeight", value);
}
}
///
/// Gets or sets the DIV element style.
///
public string DivStyle
{
get
{
return ValidationHelper.GetString(GetValue("DivStyle"), "");
}
set
{
SetValue("DivStyle", value);
}
}
///
/// Style options.
///
private string StyleOptions
{
get
{
return mStyleOptions ?? (mStyleOptions = "width: " + DivWidth + "px; height: " + DivHeight + "px; overflow: hidden; position: absolute; left: 0px;");
}
}
#endregion
#region "Javascript properties"
///
/// Gets or sets the text moving interval (higher value = slower scrolling ).
///
public int JsMoveTime
{
get
{
return ValidationHelper.GetInteger(GetValue("JsMoveTime"), 1000);
}
set
{
SetValue("JsMoveTime", value);
}
}
///
/// Gets or sets the value that indicates how long should be item stopped.
///
public int JsStopTime
{
get
{
return ValidationHelper.GetInteger(GetValue("JsStopTime"), 3000);
}
set
{
SetValue("JsStopTime", value);
}
}
///
/// Gets or sets the value that indicates moving direction.
///
public int JsDirection
{
get
{
return ValidationHelper.GetInteger(GetValue("JsDirection"), 0);
}
set
{
SetValue("JsDirection", value);
}
}
///
/// Gets or sets the value that indicates moving direction.
///
public bool JsOnMouseStop
{
get
{
return ValidationHelper.GetBoolean(GetValue("JsOnMouseStop"), true);
}
set
{
SetValue("JsOnMouseStop", value);
}
}
#endregion
#region "Stop processing"
///
/// Returns true if the control processing should be stopped.
///
public override bool StopProcessing
{
get
{
return base.StopProcessing;
}
set
{
base.StopProcessing = value;
repItems.StopProcessing = value;
}
}
#endregion
#region "Methods"
///
/// Content loaded event handler.
///
public override void OnContentLoaded()
{
base.OnContentLoaded();
SetupControl();
}
///
/// Initializes the control properties.
///
protected void SetupControl()
{
if (StopProcessing)
{
repItems.StopProcessing = true;
}
else
{
// Set repeater
repItems.ControlContext = ControlContext;
// Document properties
repItems.CacheItemName = CacheItemName;
repItems.CacheDependencies = CacheDependencies;
repItems.CacheMinutes = CacheMinutes;
repItems.CheckPermissions = CheckPermissions;
repItems.ClassNames = ClassNames;
repItems.CombineWithDefaultCulture = CombineWithDefaultCulture;
repItems.CultureCode = CultureCode;
repItems.MaxRelativeLevel = MaxRelativeLevel;
repItems.OrderBy = OrderBy;
repItems.SelectTopN = SelectTopN;
repItems.Columns = Columns;
repItems.SelectOnlyPublished = SelectOnlyPublished;
repItems.FilterOutDuplicates = FilterOutDuplicates;
repItems.Path = Path;
repItems.SiteName = SiteName;
repItems.WhereCondition = WhereCondition;
// Relationships
repItems.RelatedNodeIsOnTheLeftSide = RelatedNodeIsOnTheLeftSide;
repItems.RelationshipName = RelationshipName;
repItems.RelationshipWithNodeGuid = RelationshipWithNodeGUID;
// Transformation properties
repItems.TransformationName = TransformationName;
repItems.AlternatingTransformationName = AlternatingTransformationName;
// Public properties
repItems.HideControlForZeroRows = HideControlForZeroRows;
repItems.ZeroRowsText = ZeroRowsText;
repItems.ItemSeparator = ItemSeparator;
repItems.NestedControlsID = NestedControlsID;
// Register MooTools javascript framework
ScriptHelper.RegisterMooTools(Page);
}
}
public override void ReloadData()
{
base.ReloadData();
SetupControl();
repItems.ReloadData(true);
}
protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);
bool checkCollision = false;
if (ParentZone != null)
{
checkCollision = ParentZone.RequiresWebPartManagement();
}
else
{
checkCollision = (ViewMode == ViewModeEnum.Design);
}
if (ScriptHelper.IsPrototypeBoxRegistered() && checkCollision)
{
Label lblError = new Label();
lblError.EnableViewState = false;
lblError.CssClass = "ErrorLabel";
lblError.Text = GetString("javascript.mootoolsprototype");
Controls.Add(lblError);
}
else
{
if (StopProcessing)
{
Visible = false;
}
else
{
string divScript = "
" +
"
";
ltlBefore.Text = divScript;
ltlAfter.Text = "
";
// Register Slider javascript
ScriptHelper.RegisterScriptFile(Page, "~/CMSWebParts/Viewers/Effects/ScrollingText_files/ScrollingText.js");
// Build Javascript
string jScript =
@"window.addEvent('load', function(){
try {
var scroller_" + ClientID + " = new Sroller('" + ClientID + "'," + JsDirection + "," + JsMoveTime + "," + JsStopTime + ",'" + JsOnMouseStop + "'," + DivWidth + "," + DivHeight + @");
if (scrollernodes['" + ClientID + @"'].length != 0)
{
startScroller(scroller_" + ClientID + "," + (JsMoveTime + JsStopTime) + @", false);
}
} catch (ex) {}
});";
ScriptHelper.RegisterClientScriptBlock(this, typeof(string), ("scrollingScript" + ClientID), ScriptHelper.GetScript(jScript));
// Hide control based on repeater datasource and HideControlForZeroRows property
if (!repItems.HasData())
{
if (!HideControlForZeroRows)
{
lblNoData.Text = ZeroRowsText;
lblNoData.Visible = true;
}
else
{
Visible = false;
}
}
else
{
Visible = repItems.Visible;
}
}
}
}
///
/// Handle item data bound.
///
protected void repItems_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
// Add the envelope
if ((e.Item.Controls.Count > 0) && !(e.Item.Controls[0] is LiteralControl))
{
e.Item.Controls[0].Controls.AddAt(0, new LiteralControl(""));
e.Item.Controls[0].Controls.Add(new LiteralControl("
"));
}
}
///
/// Clears cache.
///
public override void ClearCache()
{
repItems.ClearCache();
}
#endregion
}