using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using CMS.GlobalHelper;
using CMS.PortalEngine;
using CMS.UIControls;
public partial class CMSModules_PortalEngine_Controls_Layout_LayoutFlatSelector : CMSAdminControl
{
#region "Flat selector properties"
///
/// Retruns inner instance of UniFlatSelector control.
///
public UniFlatSelector UniFlatSelector
{
get
{
return flatElem;
}
}
///
/// Gets or sets selected item in flat selector.
///
public string SelectedItem
{
get
{
return flatElem.SelectedItem;
}
set
{
flatElem.SelectedItem = value;
}
}
///
/// Indicates if the control should perform the operations.
///
public override bool StopProcessing
{
get
{
return base.StopProcessing;
}
set
{
base.StopProcessing = value;
flatElem.StopProcessing = value;
EnableViewState = !value;
}
}
#endregion
#region "Page events"
protected void Page_Load(object sender, EventArgs e)
{
if (StopProcessing)
{
return;
}
// Register jquery
ScriptHelper.RegisterJQuery(Page);
// Setup flat selector
flatElem.QueryName = "cms.layout.selectall";
flatElem.ValueColumn = "LayoutID";
flatElem.SearchLabelResourceString = "layouts.layoutname";
flatElem.SearchColumn = "LayoutDisplayName";
flatElem.SelectedColumns = "LayoutID, LayoutCodeName, LayoutDisplayName, LayoutThumbnailGUID";
flatElem.PageSize = 15;
flatElem.OrderBy = "LayoutDisplayName";
flatElem.NotAvailableImageUrl = GetImageUrl("Objects/CMS_Layout/notavailable.png");
flatElem.NoRecordsMessage = "layouts.norecordsincategory";
flatElem.NoRecordsSearchMessage = "layouts.norecords";
flatElem.OnItemSelected += new UniFlatSelector.ItemSelectedEventHandler(flatElem_OnItemSelected);
}
///
/// On PreRender.
///
protected override void OnPreRender(EventArgs e)
{
if (StopProcessing)
{
return;
}
// Description area
litCategory.Text = ShowInDescriptionArea(SelectedItem);
}
#endregion
#region "Event handling"
///
/// Updates description after item is selected in flat selector.
///
protected string flatElem_OnItemSelected(string selectedValue)
{
return ShowInDescriptionArea(selectedValue);
}
#endregion
#region "Methods"
///
/// Reloads data.
///
public override void ReloadData()
{
flatElem.ReloadData();
pnlUpdate.Update();
}
///
/// Add a reload script to the page which will update the page size (items count) according to the window size.
///
/// Indicates whether to invoke resizing of the page before calculating the items count
public void RegisterRefreshPageSizeScript(bool forceResize)
{
flatElem.RegisterRefreshPageSizeScript(forceResize);
}
///
/// Generates HTML text to be used in description area.
///
///Selected item for which generate description
private string ShowInDescriptionArea(string selectedValue)
{
string name = String.Empty;
string description = String.Empty;
if (!String.IsNullOrEmpty(selectedValue))
{
int layoutId = ValidationHelper.GetInteger(selectedValue, 0);
DataSet ds = LayoutInfoProvider.GetLayouts("LayoutID = " + layoutId, null, 0, "LayoutDisplayName, LayoutDescription");
if (!DataHelper.DataSourceIsEmpty(ds))
{
name = ResHelper.LocalizeString(ValidationHelper.GetString(ds.Tables[0].Rows[0]["LayoutDisplayName"], ""));
description = ResHelper.LocalizeString(ValidationHelper.GetString(ds.Tables[0].Rows[0]["LayoutDescription"], ""));
}
}
else
{
name = GetString("layouts.selectlayout");
}
string text = "
" + HTMLHelper.HTMLEncode(name) + "
";
if (description != null)
{
text += "" + HTMLHelper.HTMLEncode(description) + "
";
}
return text;
}
#endregion
}