using System;
using System.Data;
using System.Web.UI;
using System.Web.UI.WebControls;
using CMS.GlobalHelper;
using CMS.Notifications;
using CMS.SettingsProvider;
using CMS.UIControls;
using CMS.ExtendedControls;
public partial class CMSModules_Notifications_Development_Templates_Template_Edit_Text_Text : CMSNotificationsPage
{
#region "Variables"
private int templateId = 0;
private int gatewayId = 0;
private NotificationGatewayInfo gateway = null;
#endregion
#region "Page events"
protected void Page_Load(object sender, EventArgs e)
{
// Show info message if changes were saved
if (QueryHelper.GetInteger("saved", 0) == 1)
{
// Show message
ShowChangesSaved();
}
templateId = QueryHelper.GetInteger("templateid", 0);
gatewayId = QueryHelper.GetInteger("gatewayid", 0);
templateTextElem.TemplateID = templateId;
templateTextElem.GatewayID = gatewayId;
gateway = NotificationGatewayInfoProvider.GetNotificationGatewayInfo(gatewayId);
if (gateway != null)
{
// Header actions
string[,] actions = new string[1,11];
// Save button
actions[0, 0] = HeaderActions.TYPE_SAVEBUTTON;
actions[0, 1] = GetString("General.Save");
actions[0, 5] = GetImageUrl("CMSModules/CMS_Content/EditMenu/save.png");
actions[0, 6] = "save";
actions[0, 8] = "true";
CurrentMaster.HeaderActions.ActionPerformed += HeaderActions_ActionPerformed;
CurrentMaster.HeaderActions.Actions = actions;
// Initializes page breadcrumbs
string[,] breadcrumbs = new string[2,3];
breadcrumbs[0, 0] = GetString("notification.templatetexteditlist");
breadcrumbs[0, 1] = "~/CMSModules/Notifications/Development/Templates/Template_Edit_Text.aspx?templateId=" + templateId;
breadcrumbs[1, 0] = gateway.GatewayDisplayName;
CurrentMaster.Title.Breadcrumbs = breadcrumbs;
// Macros help
lnkMoreMacros.Text = GetString("notification.template.text.helplnk");
lblHelpHeader.Text = GetString("notification.template.text.helpheader");
DisplayHelperTable();
}
}
///
/// Actions handler.
///
protected void HeaderActions_ActionPerformed(object sender, CommandEventArgs e)
{
switch (e.CommandName.ToLowerCSafe())
{
case "save":
templateTextElem.SaveData();
URLHelper.Redirect("Template_Edit_Text_Text.aspx?gatewayId=" + gatewayId + "&templateid=" + templateId + "&saved=1");
break;
}
}
#endregion
#region "Private methods"
///
/// Fills table holding additional macros.
///
/// Data for table columns
private void FillHelperTable(string[,] tableColumns)
{
for (int i = 0; i <= tableColumns.GetUpperBound(0); i++)
{
TableRow tRow = new TableRow();
TableCell leftCell = new TableCell();
leftCell.Wrap = false;
TableCell rightCell = new TableCell();
Label lblExample = new Label();
Label lblExplanation = new Label();
// Init labels
lblExample.Text = tableColumns[i, 0];
lblExplanation.Text = tableColumns[i, 1];
// Add labels to the cells
leftCell.Controls.Add(lblExample);
rightCell.Controls.Add(lblExplanation);
leftCell.Width = new Unit(250);
// Add cells to the row
tRow.Cells.Add(leftCell);
tRow.Cells.Add(rightCell);
// Add row to the table
tblHelp.Rows.Add(tRow);
}
}
///
/// Displays helper table with makro examples.
///
private void DisplayHelperTable()
{
// 0 - left column (example), 1 - right column (explanation)
string[,] tableColumns = new string[5,2];
int i = 0;
//transformation expression examples
tableColumns[i, 0] = "{%notificationsubscription.SubscriptionID%}";
tableColumns[i++, 1] = GetString("notification.template.macrohelp.Subscription");
tableColumns[i, 0] = "{%notificationgateway.GatewayID%}";
tableColumns[i++, 1] = GetString("notification.template.macrohelp.Gateway");
tableColumns[i, 0] = "{%notificationuser.UserID%}";
tableColumns[i++, 1] = GetString("notification.template.macrohelp.User");
tableColumns[i, 0] = "{%notificationcustomdata.XXX%}";
tableColumns[i++, 1] = GetString("notification.template.macrohelp.CustomData");
tableColumns[i, 0] = "{%documentlink%}";
tableColumns[i, 1] = GetString("notification.template.macrohelp.DocumentLink");
FillHelperTable(tableColumns);
}
#endregion
}