void InitializeNewScript() { ViewState[Definition.XSLFolderName] = Definition.XSLFolderName; if (IsTrackingEmailMode) { txtTrackingEmailTemplate.Text = string.Concat("<style type=\"text/css\">", "\r\n", ".normal, .normalBold {font-family: Verdana, Tahoma, Arial, Helvetica;font-size: 11px;font-weight: normal;}", "\r\n", ".normalBold{font-weight: bold;}", "\r\n", "</style>", "\r\n", XslTemplatingUtilities.GenerateDetailViewTokenText (UdtController.GetSchemaDataset().Tables[ DataSetTableName.Fields], includeEditLink: false)); } else { txtListTemplate.Text = BuildContent(GetBasicElements()); txtListTemplateDelimiter.Enabled = false; txtListTemplateDelimiter.BackColor = Color.LightGray; txtDetailTemplate.Text = XslTemplatingUtilities.GenerateDetailViewTokenText( _schemaDataSet.Tables[DataSetTableName.Fields]); } txtFolderName.Text = Definition.XSLFolderName; txtFileName.MaxLength = Convert.ToInt32(200 - (ModuleContext.PortalSettings.HomeDirectoryMapPath + "/" + Definition.XSLFolderName + "/").Length); }
public static bool SaveTemplate(string name, string description, ModuleInstanceContext context, bool forceOverwrite, int maxNumberOfRecords) { var doc = new XmlDocument(); var moduleInfo = new ModuleController().GetModule(context.Configuration.ModuleID, context.Configuration.TabID); var node = ModuleSerializationController.SerializeModule(doc, moduleInfo, true, maxNumberOfRecords); // add PaneName as element "name" var paneNode = doc.CreateElement("name"); paneNode.InnerXml = context.Configuration.PaneName; node.AppendChild(paneNode); var template = new TemplateInfo { Name = name, Description = description, ExportContent = XslTemplatingUtilities.PrettyPrint(node.OuterXml) }; var fileName = string.Format("{0}.{1}.module.template", Globals.CleanFileName(name), moduleInfo.DesktopModule.ModuleName.ToLowerInvariant()); var portalSettings = context.PortalSettings; var folder = Utilities.GetFolder(portalSettings, Definition.TemplateFolderName); if (Utilities.SaveScript(template.GetXml(), fileName, folder, forceOverwrite)) { ClearCache(); return(true); } return(false); }
protected void cmdRebuildTrackingEmail_Click(object sender, EventArgs e) { txtTrackingEmailTemplate.Text = string.Concat("<style type=\"text/css\">", "\r\n", ".normal, .normalBold {font-family: Verdana, Tahoma, Arial, Helvetica;font-size: 11px;font-weight: normal;}", "\r\n", ".normalBold{font-weight: bold;}", "\r\n", "</style>", "\r\n", XslTemplatingUtilities.GenerateDetailViewTokenText( UdtController.GetSchemaDataset().Tables[ DataSetTableName.Fields], includeEditLink: false)); }
void cmdGenerateXslt_Click(object sender, EventArgs e) { lblTemplateError.Visible = false; lblXslScriptError.Visible = false; lblSaveXslError.Visible = false; var listTemplate = txtListTemplate.Text; var detailTemplate = txtDetailTemplate.Text; var headerTemplate = txtHeaderTemplate.Text; if (IsTrackingEmailMode) { if (isValid(txtTrackingEmailTemplate.Text, ErrorOutput.XslTranformation, addRoot: true)) { txtXslScript.Text = XslTemplatingUtilities.TransformTokenTextToXslScript(UdtController.GetSchemaDataset(), txtTrackingEmailTemplate.Text); txtXslScript.Enabled = true; ShowXslEditor(); } } else { if (isValid(listTemplate, ErrorOutput.XslTranformation, addRoot: true) && (!chkShowDetailView.Checked || isValid(detailTemplate, ErrorOutput.XslTranformation, addRoot: true))) { txtXslScript.Text = XslTemplatingUtilities.TransformTokenTextToXslScript(_schemaDataSet, listTemplate, detailTemplate, headerTemplate, chkEnablePaging.Checked, chkEnableSorting.Checked, chkEnableSearch.Checked, chkShowDetailView.Checked, CurrentListType); txtXslScript.Enabled = true; ShowXslEditor(); } } }
void cmdRebuildDetail_Click(object sender, EventArgs e) { txtDetailTemplate.Text = XslTemplatingUtilities.GenerateDetailViewTokenText(_schemaDataSet.Tables[DataSetTableName.Fields]); }
void EditExistingScriptAndTemplates(IFileInfo file) { ViewState[Definition.XSLFolderName] = file.Folder; txtFolderName.Text = file.Folder; txtFileName.Text = file.FileName; txtFileName.MaxLength = Convert.ToInt32(200 - (ModuleContext.PortalSettings.HomeDirectoryMapPath + "/" + file.Folder).Length); string fileContent; using (var stream = FileManager.Instance.GetFileContent(file)) { using (var x = new StreamReader(stream)) { fileContent = x.ReadToEnd(); } } fileContent = fileContent.Replace(XslTemplatingUtilities.HardSpace, XslTemplatingUtilities.SpacePlaceholder); var doc = new XmlDocument(); doc.LoadXml(fileContent); var nameSpaceManager = new XmlNamespaceManager(doc.NameTable); nameSpaceManager.AddNamespace("udt", "DotNetNuke/UserDefinedTable"); nameSpaceManager.AddNamespace("xsl", "http://www.w3.org/1999/XSL/Transform"); var scriptRoot = doc.SelectSingleNode("/xsl:stylesheet", nameSpaceManager); var templateDefinition = // ReSharper disable PossibleNullReferenceException (XmlElement)(scriptRoot.SelectSingleNode("udt:template", nameSpaceManager)); if (templateDefinition != null) { if (templateDefinition.HasAttribute("headerView")) { txtHeaderTemplate.Text = (HttpUtility.HtmlDecode(templateDefinition.Attributes["headerView"].Value).Replace( XslTemplatingUtilities.SpacePlaceholder, XslTemplatingUtilities.HardSpace)); } if (templateDefinition.HasAttribute("listView")) { txtListTemplate.Text = (HttpUtility.HtmlDecode(templateDefinition.Attributes["listView"].Value).Replace( XslTemplatingUtilities.SpacePlaceholder, XslTemplatingUtilities.HardSpace)); } if (templateDefinition.HasAttribute("detailView")) { txtDetailTemplate.Text = (HttpUtility.HtmlDecode(templateDefinition.Attributes["detailView"].Value).Replace( XslTemplatingUtilities.SpacePlaceholder, XslTemplatingUtilities.HardSpace)); } chkEnablePaging.Checked = templateDefinition.HasAttribute("paging"); chkEnableSorting.Checked = templateDefinition.HasAttribute("sorting"); chkEnableSearch.Checked = templateDefinition.HasAttribute("searching"); chkShowDetailView.Checked = templateDefinition.HasAttribute("showDetailView"); if (templateDefinition.HasAttribute("isTrackingMode")) { IsTrackingEmailMode = true; txtTrackingEmailTemplate.Text = (HttpUtility.HtmlDecode(templateDefinition.Attributes["trackingEmail"].Value).Replace( XslTemplatingUtilities.SpacePlaceholder, XslTemplatingUtilities.HardSpace)); } if (templateDefinition.HasAttribute("listType")) { ddlListTemplateType.SelectedValue = templateDefinition.Attributes["listType"].Value; setupDelimiter(); } if (templateDefinition.HasAttribute("delimiter")) { txtListTemplateDelimiter.Text = HttpUtility.HtmlDecode(templateDefinition.Attributes["delimiter"].Value); } scriptRoot.RemoveChild(templateDefinition); } txtXslScript.Text = (XslTemplatingUtilities.PrettyPrint(doc).Replace(XslTemplatingUtilities.SpacePlaceholder, XslTemplatingUtilities.HardSpace)); ShowXslEditor(); // ReSharper restore PossibleNullReferenceException }