using System;
using System.Web.UI.WebControls;
using System.Data;
using CMS.CMSHelper;
using CMS.GlobalHelper;
using CMS.PortalEngine;
using CMS.SettingsProvider;
using CMS.UIControls;
public partial class CMSModules_PortalEngine_UI_PageTemplates_PageTemplate_List : SiteManagerPage
{
#region "Variables"
protected int categoryId = 0;
#endregion
#region "Page events"
///
/// Handles the Load event of the Page control.
///
protected void Page_Load(object sender, EventArgs e)
{
categoryId = QueryHelper.GetInteger("categoryid", 0);
// Register script for refresh tree after delete/destroy
string script =
@"
function RefreshAdditionalContent()
{
if (parent.parent.frames['pt_tree'])
{
parent.parent.frames['pt_tree'].location.href = '" + URLHelper.ResolveUrl("~/CMSModules/PortalEngine/UI/PageTemplates/PageTemplate_Tree.aspx?categoryid=" + categoryId) + @"';
}
}
";
ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "RefreshTree", ScriptHelper.GetScript(script));
// Configure the UniGrid
PageTemplateCategoryInfo categoryInfo = PageTemplateCategoryInfoProvider.GetPageTemplateCategoryInfo(categoryId);
if (categoryInfo != null)
{
string categoryPath = categoryInfo.CategoryPath;
// Add the slash character at the end of the categoryPath
if (!categoryPath.EndsWithCSafe("/"))
{
categoryPath += "/";
}
pageTemplatesGrid.WhereCondition = "ObjectPath LIKE '" + SqlHelperClass.GetSafeQueryString(categoryPath, false) + "%' AND ObjectType = 'pagetemplate'";
}
pageTemplatesGrid.OnAction += pageTemplatesGrid_OnAction;
pageTemplatesGrid.ZeroRowsText = GetString("general.nodatafound");
InitializeMasterPage();
}
#endregion
#region "UniGrid events"
///
/// Handles the UniGrid's OnAction event.
///
/// Name of item (button) that throws event
/// ID (value of Primary key) of corresponding data row
protected void pageTemplatesGrid_OnAction(string actionName, object actionArgument)
{
switch (actionName)
{
case "delete":
// Delete PageTemplateInfo object from database
PageTemplateInfoProvider.DeletePageTemplate(Convert.ToInt32(actionArgument));
ltlScript.Text += ScriptHelper.GetScript("RefreshAdditionalContent();");
break;
}
}
#endregion
#region "Other methods"
///
/// Initializes Master Page.
///
protected void InitializeMasterPage()
{
Title = "Page template list";
}
#endregion
}