261049 false false /Component Project 261046 32 Project 4 261055 false false /Component Project/Component Library 261049 8192 Folder 4 261102 261107 /Component Project/Models/Component Definition Folder/ false false /Component Project/Component Library/Component Definitions 261055 0 Folder 4 261180 261107 /Component Project/Models/Component Definition Folder/ false false /Component Project/Component Library/Component Definitions/core 261102 0 Folder 4 261344 261485 /Component Project/Templates/Component Framework/Enhanced/Component Definition/ 1 261191 false false 0 /Component Project/Component Library/Component Definitions/core/Date 261180 0 512 ContentAsset 2 class_name Date content_block_hide yes json_component yes markup read_only sanitized_class_name Date upload#snapshot upload_name#snapshot 263532 261485 /Component Project/Templates/Component Framework/Enhanced/Component Definition/ 1 261191 false false 0 /Component Project/Component Library/Component Definitions/core/Document 261180 0 512 ContentAsset 2 class_name Document content_block_hide yes json_component yes markup read_only sanitized_class_name Document upload#snapshot upload_name#snapshot 261201 261485 /Component Project/Templates/Component Framework/Enhanced/Component Definition/ 1 0 false false 0 /Component Project/Component Library/Component Definitions/core/Image 261180 0 512 ContentAsset 2 class_name Image component_category component component_component_form_override_type component_component_hardcoded_snippet component_component_input_label component_component_label my_image component_component_message_content component_component_message_type basic component_component_required component_component_required_message component_component_type Src component_component_type_in_markup true component_panel 0 content_block_hide yes json_component yes markup <img src="{my_image : Src}" /> read_only sanitized_class_name Image upload#preview_my_image upload#snapshot upload_name#preview_my_image upload_name#snapshot 261197 261485 /Component Project/Templates/Component Framework/Enhanced/Component Definition/ 1 0 false false 0 /Component Project/Component Library/Component Definitions/core/Src 261180 0 512 ContentAsset 2 class_name Src content_block_hide yes json_component yes markup read_only sanitized_class_name Src 261196 261485 /Component Project/Templates/Component Framework/Enhanced/Component Definition/ 1 0 false false 0 /Component Project/Component Library/Component Definitions/core/Text 261180 0 512 ContentAsset 2 class_name Text content_block_hide yes json_component yes markup read_only sanitized_class_name Text 261195 261485 /Component Project/Templates/Component Framework/Enhanced/Component Definition/ 1 0 false false 0 /Component Project/Component Library/Component Definitions/core/Widget 261180 0 512 ContentAsset 2 class_name Widget content_block_hide yes json_component yes markup read_only sanitized_class_name Widget 261194 261485 /Component Project/Templates/Component Framework/Enhanced/Component Definition/ 1 0 false false 0 /Component Project/Component Library/Component Definitions/core/Wysiwyg 261180 0 512 ContentAsset 2 class_name Wysiwyg content_block_hide yes json_component yes markup read_only sanitized_class_name Wysiwyg 261059 false false /Component Project/Library 261049 64 LibraryFolder 4 261475 1792 /System/Templates/Basis/DeveloperCS/ 1 0 false false 0 0 /Component Project/Library/ComponentBase.cs 261059 17 LibraryClass 2 body using System; using System.Collections.Generic; using System.Linq; using System.Text; using CrownPeak.CMSAPI; using CrownPeak.CMSAPI.Experimental; using CrownPeak.CMSAPI.Services; using System.Text.RegularExpressions; /* Some Namespaces are not allowed. */ namespace Component_Library.Component_Project.Components { public abstract class ComponentBase : CrownPeak.CMSAPI.ComponentBase { private String contentNodeName = "cp-content"; private String repeatableNodeName = "cp-list"; //neccessary evil for now Dictionary<String, String> componentMarkupDictionary = new Dictionary<string, string>(); public String ComponentMarkup { get; set; } public String componentLabel { get; set; } public bool isRequired { get; set; } public String validationError { get; set; } public ComponentBase() { } public ComponentBase(Asset componentAsset, String componentMarkup, String componentLabel, bool isRequired = false, String validationError = "") { this.ComponentMarkup = componentMarkup; this.componentLabel = componentLabel; this.isRequired = isRequired; this.validationError = validationError; } public override void ComponentInput(Asset asset, InputContext context, string label, string name) { //generateInput_old(label, name); } public override void ComponentPostInput(Asset asset, PostInputContext context, string name, string index = "") { //code } public override String ComponentOutput(Asset asset, OutputContext context, string name, string index = "", bool isDrag = false) { return "<p>Output does not exist</p>"; //return generateOutput(asset, name, index); } /*********************HELPER FUNCITONS*********************/ protected String getComponentMarkup(String componentPath) { componentPath = componentPath.ToLower(); //if the dictionary does not contain the component add the component markup to the dictionary and return it. if (!componentMarkupDictionary.ContainsKey(componentPath)) { Asset component = Asset.Load(componentPath); if (component.IsLoaded) { String componentMarkup = component.Raw["markup"]; componentMarkupDictionary.Add(componentPath, componentMarkup); return componentMarkup; } else { return ""; } } else { return componentMarkupDictionary[componentPath]; } } public void PanelInput(Asset asset, InputContext context, String label, String name, Dictionary<List<String>, Action<Asset, InputContext, string, string>> fields, int? minPanels = null, int? maxPanels = null) { while (Input.NextPanel(name, ListPanelType.Regular, minPanels, maxPanels, displayName: label)) { foreach (KeyValuePair<List<string>, Action<Asset, InputContext, string, string>> entry in fields) { var fieldName = entry.Key[0]; var fieldLabel = (entry.Key.Count > 1 ? entry.Key[1] : String.Empty); var isInControlPanel = (entry.Key.Count > 2 ? entry.Key[2] : String.Empty); var method = entry.Value; String messageContent = (entry.Key.Count > 3 ? entry.Key[3] : String.Empty); String messageType = (entry.Key.Count > 4 ? entry.Key[4] : String.Empty); ; Out.DebugWriteLine("messageType: " + messageType); if (isInControlPanel == "control_group") { Input.StartControlPanel(fieldLabel); if (!String.IsNullOrWhiteSpace(messageContent)) { Input.ShowMessage(messageContent, messageType == "basic" ? MessageType.Basic : MessageType.Warning); } method(asset, context, "", name + fieldName); Input.EndControlPanel(); } else { if (!String.IsNullOrWhiteSpace(messageContent)) { Input.ShowMessage(messageContent, messageType == "basic" ? MessageType.Basic : MessageType.Warning); } method(asset, context, fieldLabel, name + fieldName); } } } } public void PanelPostInput(Asset asset, PostInputContext context, String name, Dictionary<List<String>, Action<Asset, PostInputContext, string, string>> fields, String index = "") { Int32 i = 1; //while (!String.IsNullOrEmpty(context.InputForm[name + Index(i) + index])) //{ // foreach (KeyValuePair<List<string>, Action<PostInputContext, string, string>> entry in fields) // { // var fieldParams = entry.Key; // var method = entry.Value; // method(context, name + fieldParams[0], Index(i) + index); // } // i++; //} if (!String.IsNullOrEmpty(context.InputForm[name + Index(i) + index])) { while (!String.IsNullOrEmpty(context.InputForm[name + Index(i) + index])) { Out.DebugWriteLine("context.InputForm[" + name + Index(i) + index + "] = " + context.InputForm[name + Index(i) + index]); foreach (KeyValuePair<List<string>, Action<Asset, PostInputContext, string, string>> entry in fields) { var fieldParams = entry.Key; var contentName = fieldParams.Count > 0 ? fieldParams[0] : ""; var contentType = fieldParams.Count > 1 ? fieldParams[1] : ""; var contentValidationMessage = fieldParams.Count > 1 ? fieldParams[2] : ""; var method = entry.Value; if (contentType != "") { if (contentType == "Href") { if (context.InputForm[name + contentName + "_link_type" + Index(i) + index] == "Internal") { if (String.IsNullOrWhiteSpace(context.InputForm[name + contentName + "_link_internal" + Index(i) + index])) { context.ValidationErrorFields.Add(name + contentName + "_link_internal" + Index(i) + index, contentValidationMessage); } } else if (context.InputForm[name + contentName + "_link_type" + Index(i) + index] == "External") { if (String.IsNullOrWhiteSpace(context.InputForm[name + contentName + "_link_external" + Index(i) + index])) { context.ValidationErrorFields.Add(name + contentName + "_link_external" + Index(i) + index, contentValidationMessage); } } } else if (contentType == "Src") { if (String.IsNullOrWhiteSpace(context.InputForm[name + contentName + "_image" + Index(i) + index])) { context.ValidationErrorFields.Add(name + contentName + "_image" + Index(i) + index, contentValidationMessage); } } else { if (String.IsNullOrWhiteSpace(context.InputForm[name + contentName + Index(i) + index])) { context.ValidationErrorFields.Add(name + contentName + Index(i) + index, contentValidationMessage); } } } else { method(asset, context, name + fieldParams[0], Index(i) + index); //pattern = pattern.Replace(fieldParams[0], method(asset, context, name + fieldParams[1], Index(i) + index)); } } i++; //output += pattern; } } else if (!String.IsNullOrEmpty(context.InputForm[name + index])) { ////String pattern = markup; //Out.DebugWriteLine("context.InputForm[" + name + index + "] = " + context.InputForm[name + index]); //foreach (KeyValuePair<List<string>, Action<PostInputContext, string, string>> entry in fields) //{ // var fieldParams = entry.Key; // var method = entry.Value; // method(context, name + fieldParams[0], index); // //pattern = pattern.Replace(fieldParams[0], method(asset, context, name + fieldParams[1], index)); //} //i++; //while (!String.IsNullOrEmpty(context.InputForm[name + index])) //{ Out.DebugWriteLine("context.InputForm[" + name + index + "] = " + context.InputForm[name + index]); foreach (KeyValuePair<List<string>, Action<Asset, PostInputContext, string, string>> entry in fields) { var fieldParams = entry.Key; var contentName = fieldParams.Count > 0 ? fieldParams[0] : ""; var contentType = fieldParams.Count > 1 ? fieldParams[1] : ""; var contentValidationMessage = fieldParams.Count > 1 ? fieldParams[2] : ""; var method = entry.Value; if (contentType != "") { if (contentType == "Href") { if (context.InputForm[name + contentName + "_link_type" + index] == "Internal") { if (String.IsNullOrWhiteSpace(context.InputForm[name + contentName + "_link_internal" + index])) { context.ValidationErrorFields.Add(name + contentName + "_link_internal" + index, contentValidationMessage); } } else if (context.InputForm[name + contentName + "_link_type" + index] == "External") { if (String.IsNullOrWhiteSpace(context.InputForm[name + contentName + "_link_external" + index])) { context.ValidationErrorFields.Add(name + contentName + "_link_external" + index, contentValidationMessage); } } } else if (contentType == "Src") { if (String.IsNullOrWhiteSpace(context.InputForm[name + contentName + "_image" + index])) { context.ValidationErrorFields.Add(name + contentName + "_image" + index, contentValidationMessage); } } else { if (String.IsNullOrWhiteSpace(context.InputForm[name + contentName + index])) { context.ValidationErrorFields.Add(name + contentName + index, contentValidationMessage); } } } else { method(asset, context, name + fieldParams[0], index); //pattern = pattern.Replace(fieldParams[0], method(asset, context, name + fieldParams[1], Index(i) + index)); } } i++; //output += pattern; //} } else if (!String.IsNullOrEmpty(context.InputForm[name + Index(i) + ":1"])) { while (!String.IsNullOrEmpty(context.InputForm[name + Index(i) + ":1"])) { Out.DebugWriteLine("context.InputForm[" + name + Index(i) + ":1" + "] = " + context.InputForm[name + Index(i) + ":1"]); foreach (KeyValuePair<List<string>, Action<Asset, PostInputContext, string, string>> entry in fields) { var fieldParams = entry.Key; var method = entry.Value; method(asset, context, name + fieldParams[0], Index(i) + ":1"); //pattern = pattern.Replace(fieldParams[0], method(asset, context, name + fieldParams[1], Index(i) + ":1")); } i++; } } } public String PanelOutput(Asset asset, OutputContext context, String name, String markup, String listName, Dictionary<List<String>, Func<Asset, OutputContext, String, String, bool, String>> fields, String index = "") { Out.DebugWriteLine("Entered panel_output with name: {0}, markup: {1}, listName: {2}", name, Util.HtmlEncode(markup), listName); //Regex rx = new Regex(@"\[" + listName + @":.*\]", RegexOptions.Compiled | RegexOptions.IgnoreCase); // MatchCollection matches = rx.Matches(markup); //foreach (Match match in matches) //{ //String pattern = markup; String output = ""; Int32 i = 1; Out.DebugWriteLine("checking asset[" + name + Index(i) + index + "]..."); if (!String.IsNullOrEmpty(asset[name + Index(i) + index])) { while (!String.IsNullOrEmpty(asset[name + Index(i) + index])) { String pattern = markup; //Out.DebugWriteLine("asset[" + name + Index(i) + index + "] = " + asset[name + Index(i) + index]); foreach (KeyValuePair<List<string>, Func<Asset, OutputContext, String, String, bool, String>> entry in fields) { var fieldParams = entry.Key; var method = entry.Value; Out.DebugWriteLine(fieldParams[0] + " = " + method(asset, context, name + fieldParams[1], Index(i) + index, false)); pattern = pattern.Replace(fieldParams[0], method(asset, context, name + fieldParams[1], Index(i) + index, false)); } i++; output += pattern; } } else if (!String.IsNullOrEmpty(asset[name + index])) { String pattern = markup; Out.DebugWriteLine("asset[" + name + index + "] = " + asset[name + index]); foreach (KeyValuePair<List<string>, Func<Asset, OutputContext, String, String, bool, String>> entry in fields) { var fieldParams = entry.Key; var method = entry.Value; pattern = pattern.Replace(fieldParams[0], method(asset, context, name + fieldParams[1], index, false)); } i++; output += pattern; } else if (!String.IsNullOrEmpty(asset[name + Index(i) + ":1"])) { while (!String.IsNullOrEmpty(asset[name + Index(i) + ":1"])) { String pattern = markup; Out.DebugWriteLine("asset[" + name + Index(i) + ":1" + "] = " + asset[name + Index(i) + ":1"]); foreach (KeyValuePair<List<string>, Func<Asset, OutputContext, String, String, bool, String>> entry in fields) { var fieldParams = entry.Key; var method = entry.Value; pattern = pattern.Replace(fieldParams[0], method(asset, context, name + fieldParams[1], Index(i) + ":1", false)); } i++; output += pattern; } } return output; //markup = markup.Replace(match.Value, output); //return markup; } public String PanelOutput(Asset asset, OutputContext context, String markup, Dictionary<List<String>, Func<Asset, OutputContext, String, String, bool, String>> fields, String index = "", List<Asset> overrideAssetList = null) { String contentToReplace = fields.First().Key[0]; Func<Asset, OutputContext, String, String, bool, String> method = fields.First().Value; return PanelOutput(asset, context, markup, contentToReplace, method, overrideAssetList: overrideAssetList); } public String PanelOutput(Asset asset, OutputContext context, String markup, String contentToReplace, Func<Asset, OutputContext, String, String, bool, String> method, String index = "", List<Asset> overrideAssetList = null) { String output = ""; Int32 i = 1; if (overrideAssetList != null) { foreach (Asset overrideAsset in overrideAssetList) { String pattern = markup; pattern = pattern.Replace(contentToReplace, method(overrideAsset, context, "", Index(i), false)); i++; output += pattern; } } return output; } public static String Index(Int32 i) { return ":" + i.ToString(); } public static int Index(String i) { Regex rx = new Regex("^(:)*[0-9]+"); Match m = rx.Match(i); Out.DebugWriteLine("i: " + i); Out.DebugWriteLine("index match value: " + m.Value); if (m != null && !String.IsNullOrWhiteSpace(m.Value)) { return Convert.ToInt32(m.Value.Substring(1)); } else { return -1; } } } } 261476 1792 /System/Templates/Basis/DeveloperCS/ 1 0 false false 0 0 /Component Project/Library/ComponentBuilderHelper.cs 261059 17 LibraryClass 2 body using System; using System.Collections.Generic; using System.Linq; using System.Text; using CrownPeak.CMSAPI; using CrownPeak.CMSAPI.Services; /* Some Namespaces are not allowed. */ namespace Component_Library.Component_Project.Components { public class ComponentBuilderHelper { public static void InputHelper(Asset asset, InputContext context) { Dictionary<String, String> labelOverrideTypeOptions = new Dictionary<string, string>() { { "Control Group", "control_group" }, { "Prepend to Label", "prepend" } }; Dictionary<String, String> messageTypeOptions = new Dictionary<string, string>() { { "Basic", "basic" }, { "Warning", "warning" } }; Input.StartTabbedPanel("Pattern", "Preview Content", "Governance", "Advanced"); //Input.ShowCheckBox("Update pattern content?", "save_pattern", "yes", "Yes", helpMessage: "Check this box to save the pattern content", defaultChecked: false); Input.StartControlPanel("Pattern"); if (!String.IsNullOrWhiteSpace(asset["post_save_error"])) { Input.ShowMessage(asset["post_save_error"], MessageType.Warning); } if (asset["read_only"] == "yes") { Input.ShowTextBox("Markup", "markup", width: 800, height: 30, readOnly: true, helpMessage: "This component is marked as \"read only\""); } else { Input.ShowTextBox("Markup", "markup", width: 800, height: 30); } Dictionary<String, String> componentTypeOptions = ComponentLibraryHelper.getAllComponentTypesForDropdown(asset); ComponentBuilderHelper.ComponentDetailsHelper(asset, context, "component_panel", 1); Input.EndControlPanel(); Input.NextTabbedPanel(); { //Input.ShowCheckBox("Update Preview Content?", "save_preview_content", "yes", "Yes", defaultChecked: false, helpMessage: "Check this box to update the preview content."); ComponentLibraryHelper.generateComponentPreviewContentInput(asset); } Input.NextTabbedPanel(); { Input.ShowTextBox("Governance Tags", "component_zones", helpMessage: "Comma separated zone tags for drag and drop governance."); } Input.NextTabbedPanel(); { string className = System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(asset.Label.ToLower()).Replace(" ", ""); Input.ShowTextBox("Class Name", "class_name", className, width: className.Length + 3, readOnly: true); Input.ShowAcquireImage("Component Snapshot", "snapshot", "If specified, this image will be used instead of a real time rendering of the component"); Input.ShowCheckBox("Hide From Content Block Panel?", "content_block_hide", "yes", "Yes"); Input.ShowCheckBox("Regenerate Component?", "regenerate", "yes", "Yes", helpMessage: "Checking this and saving the asset will regenerate the component's library files."); Input.ShowCheckBox("Read Only Component?", "read_only", "yes", "Yes", helpMessage: "When checked it will prevent the user from changing the markup of the component. Must save before changes take effect."); Input.ShowCheckBox("Delete AssetContent", "delete_asset_content", "yes", "Yes", helpMessage: "When checked all content fields except for the markup, class name and read only fields will be deleted." ); Input.ShowCheckBox("JSON Component?", "json_component", "yes", "Yes", helpMessage: "When checked, the generated component will include JSON output."); Asset baseCodeFileAsset = ComponentLibraryHelper.getComponentCodeFileAsset(asset["class_name"], asset, ComponentLibraryHelper.ComponentClassNameType.Base); if (baseCodeFileAsset != null && baseCodeFileAsset.IsLoaded) { Input.ShowLink(baseCodeFileAsset, null, InputLinkType.EditForm); } Asset overrideCodeFileAsset = ComponentLibraryHelper.getComponentCodeFileAsset(asset["class_name"], asset, ComponentLibraryHelper.ComponentClassNameType.Override); if (overrideCodeFileAsset != null && overrideCodeFileAsset.IsLoaded) { Input.ShowLink(overrideCodeFileAsset, null, InputLinkType.EditForm); } } Input.EndTabbedPanel(); } public static void CopyHelper(Asset asset, CopyContext context) { //asset.SaveContentField("class_name", System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(asset.Label.ToLower() + asset.Id).Replace(" ", "")); //if (asset["read_only"] != "yes") //{ // //if (asset["save_pattern"] == "yes") // //{ // /***Functions should be unneccessary when cloning / branching***/ // //ComponentLibraryHelper.deleteExistingContentFieldsForComponents(ref asset); // //int count = ComponentLibraryHelper.consolidateCurrentContentFields(ref asset); // //ComponentLibraryHelper.updateExistingContentFields(ref asset); // /***************************************************************/ // List<ComponentContentPlaceholder> markupContentPlaceholders = ComponentLibraryHelper.buildComponentContentPlaceholderFromMarkup(asset["markup"]); // List<PanelEntry> componentPanels = asset.GetPanels("component_panel"); // List<ComponentContentPlaceholder> assetContentPlaceholders = ComponentContentPlaceholder.ConvertPanelEntryList(componentPanels, "component_panel"); // List<ComponentContentPlaceholder> flattenedAssetcontentPlaceholders = ComponentLibraryHelper.flattenComponentContentPlaceholderList(assetContentPlaceholders); // ComponentLibraryHelper.createContentFieldsForComponents(ref assetContentPlaceholders, markupContentPlaceholders, flattenedAssetcontentPlaceholders); // Dictionary<String, String> content = ComponentContentPlaceholder.ConvertToContentDictionary(assetContentPlaceholders); // ComponentLibraryHelper.deleteComponentContent(asset); // asset.SaveContent(content); // //ComponentLibraryHelper.deleteCodeFile(asset); // bool recompileSuccessful = false; // Asset codeFile = ComponentLibraryHelper.createCodeFile(asset, ref recompileSuccessful); // Asset wysiwygTemplateFile = ComponentLibraryHelper.createWysiwygTemplate(asset, "/System/CMS Snippets/Default"); // if (wysiwygTemplateFile == null || !wysiwygTemplateFile.IsLoaded) // { // Util.Email(String.Format("wysiwygTemplateFile {0} creation unsuccessful.", asset["class_name"]), // String.Format("Creation failed for they wysiwyg template file {0}", asset["class_name"]), // "corey.casado@crownpeak.com"); // } //} } public static void DeleteHelper(Asset asset, DeleteContext context) { Asset codeFile = ComponentLibraryHelper.getComponentCodeFileAsset(asset["class_name"], asset, ComponentLibraryHelper.ComponentClassNameType.Base); if (codeFile != null && codeFile.IsLoaded && codeFile["componentAsset"] == asset.GetLink(LinkType.Internal)) { codeFile.DeleteContentField("componentAsset"); } } public static OutputContext FilenameHelper(Asset asset, OutputContext context) { context.PublishPath = string.Empty; return context; } public static void OutputHelper(Asset asset, OutputContext context) { Out.WriteLine(ComponentLibraryHelper.generateComponentPreview(asset, context)); } public static void PostInputHelper(Asset asset, PostInputContext context) { context.InputForm.Remove("regenerate"); if (asset["read_only"] != "yes") { //if (context.InputForm["save_pattern"] == "yes") //{ context = ComponentLibraryHelper.validateComponentPlaceholderNames(asset, context); //} //else //{ // List<String> componentContentFields = new List<string>(); // componentContentFields.Add("markup"); // componentContentFields.Add("class_name"); // componentContentFields.AddRange(context.InputForm.Where(x => x.Key.StartsWith("component_")).ToDictionary(x => x.Key, x => x.Value).Keys.ToList()); // context.InputForm.Remove(componentContentFields); //} //if (context.InputForm["save_preview_content"] == "yes") //{ if (String.IsNullOrWhiteSpace(context.Error) && String.IsNullOrWhiteSpace(context.ValidationError) && (context.ValidationErrorFields == null || context.ValidationErrorFields.Count < 1)) { context = ComponentLibraryHelper.generateComponentPreviewPostInput(asset, context); } //} //else //{ // List<String> previewContentFields = context.InputForm.Where(x => x.Key.StartsWith("preview_")).ToDictionary(x => x.Key, x => x.Value).Keys.ToList(); // context.InputForm.Remove(previewContentFields); //} String className = (!String.IsNullOrWhiteSpace(context.InputForm["class_name"]) ? context.InputForm["class_name"] : asset.Raw["class_name"]); //if the class name has changed if (context.InputForm["class_name"] != asset["class_name"]) { Asset baseCodeFile = ComponentLibraryHelper.getComponentCodeFileAsset(asset["class_name"], asset, ComponentLibraryHelper.ComponentClassNameType.Base); //if the codeFile exists and is actually associated with this asset. Prevents issue where we're chaing the name to one that already exists. if (baseCodeFile != null && baseCodeFile["componentAsset"] == asset.GetLink(LinkType.Internal)) { baseCodeFile.Rename(ComponentLibraryHelper.createComponentClassFileName(context.InputForm["class_name"], ComponentLibraryHelper.ComponentClassNameType.Base)); } Asset overrideCodeFile = ComponentLibraryHelper.getComponentCodeFileAsset(asset["class_name"], asset, ComponentLibraryHelper.ComponentClassNameType.Override); //if the codeFile exists and is actually associated with this asset. Prevents issue where we're chaing the name to one that already exists. if (overrideCodeFile != null && overrideCodeFile["componentAsset"] == asset.GetLink(LinkType.Internal)) { overrideCodeFile.Rename(ComponentLibraryHelper.createComponentClassFileName(context.InputForm["class_name"], ComponentLibraryHelper.ComponentClassNameType.Override)); } } Asset existingCodeFile = ComponentLibraryHelper.getComponentCodeFileAsset(className, asset, ComponentLibraryHelper.ComponentClassNameType.Base); if (existingCodeFile != null && existingCodeFile.IsLoaded) { String componentAsset = existingCodeFile["componentAsset"]; if (!String.IsNullOrWhiteSpace(componentAsset) && componentAsset.Substring(componentAsset.LastIndexOf("/") + 1) != asset.Id.ToString()) { // Try again with a path mapped to this branch var branchVersion = ComponentLibraryHelper.getAssetForBranch(Asset.Load(componentAsset), asset); if (branchVersion.Id != asset.Id) context.ValidationError = "A component with this name already exists."; } } } context.InputForm.Remove("save_preview_content"); } public static void PostSaveHelper(Asset asset, PostSaveContext context) { var deferCompilation = asset["defer_compilation"] == "yes"; if (asset["delete_asset_content"] == "yes") { List<String> keys = asset.GetContent().Keys.ToList(); keys.Remove("markup"); keys.Remove("delete_asset_content"); keys.Remove("class_name"); keys.Remove("read_only"); keys.Remove("json_component"); keys.Remove("component_zones"); keys.Remove("content_block_hide"); asset.DeleteContentFields(keys); Out.DebugWriteLine("asset content deleted"); } else { asset.DeleteContentField("defer_compilation"); } Out.DebugWriteLine("Were in the post-save"); if (asset["read_only"] != "yes" && asset["delete_asset_content"] != "yes") { List<ComponentContentPlaceholder> markupContentPlaceholders = ComponentLibraryHelper.buildComponentContentPlaceholderFromMarkup(asset["markup"]); List<PanelEntry> componentPanels = asset.GetPanels("component_panel"); List<ComponentContentPlaceholder> assetContentPlaceholders = ComponentContentPlaceholder.ConvertPanelEntryList(componentPanels, "component_panel"); List<ComponentContentPlaceholder> flattenedAssetcontentPlaceholders = ComponentLibraryHelper.flattenComponentContentPlaceholderList(assetContentPlaceholders); ComponentLibraryHelper.deleteExistingContentFieldsForComponents(ref assetContentPlaceholders, markupContentPlaceholders); ComponentLibraryHelper.updateExistingContentFields(ref assetContentPlaceholders, markupContentPlaceholders); ComponentLibraryHelper.createContentFieldsForComponents(ref assetContentPlaceholders, markupContentPlaceholders, flattenedAssetcontentPlaceholders); Dictionary<String, String> content = ComponentContentPlaceholder.ConvertToContentDictionary(assetContentPlaceholders); ComponentLibraryHelper.deleteComponentContent(asset); asset.SaveContent(content); //foreach (KeyValuePair<String, String> kvp in content) //{ // Out.DebugWriteLine(kvp.Key + " = " + kvp.Value); //} bool recompileSuccessful = false; Asset codeFile = ComponentLibraryHelper.createCodeFile(asset, deferCompilation, ref recompileSuccessful); //Asset wysiwygTemplateFile = ComponentLibraryHelper.createWysiwygTemplate(asset, "/System/CMS Snippets/Default"); if (!recompileSuccessful) { asset.SaveContentField("post_save_error", "The following errors occured when attempting to compile the generated code file:\r\n" + context.Error); } else { asset.DeleteContentField("post_save_error"); } //if (wysiwygTemplateFile == null || !wysiwygTemplateFile.IsLoaded) //{ // Util.Email(String.Format("wysiwygTemplateFile {0} creation unsuccessful.", asset["class_name"]), // String.Format("Creation failed for they wysiwyg template file {0}", asset["class_name"]), // "corey.casado@crownpeak.com"); //} } } public static void UrlHelper(Asset asset, OutputContext context) { context.PublishUrl = string.Empty; } public static void ComponentDetailsHelper(Asset asset, InputContext context, String panelName, int panelDepth, String index = "", List<PanelEntry> currentPanelEntries = null, string listName = "") { int currentComponentCount = 2; //List<PanelEntry> currentPanelsEntries = null; if (currentPanelEntries == null) { currentPanelEntries = asset.GetPanels(panelName); } Out.DebugWriteLine("# of panels for\"" + panelName + "\" is: " + (currentPanelEntries == null ? "null" : currentPanelEntries.Count.ToString())); if (currentPanelEntries != null) { currentComponentCount = currentPanelEntries != null ? currentPanelEntries.Count : 2; } Out.DebugWriteLine("Current Panel entries count: " + currentComponentCount); Dictionary<String, String> labelOverrideTypeOptions = new Dictionary<string, string>() { { "Control Group", "control_group" }, { "Prepend to Label", "prepend" } }; Dictionary<String, String> messageTypeOptions = new Dictionary<string, string>() { { "Basic", "basic" }, { "Warning", "warning" } }; Dictionary<String, String> componentTypeOptions = ComponentLibraryHelper.getAllComponentTypesForDropdown(asset); int i = 1; if (currentComponentCount > 0) { String panelLabel = (panelName == "component_panel" ? "Component Details List" : listName + " sub components"); bool isOnlyPanel = currentPanelEntries.Count <= 1 && panelName == "component_panel"; //while (Input.NextPanel(panelName)) while (Input.NextPanel(panelName, min: currentComponentCount, max: currentComponentCount, displayName: panelLabel)) { #region old code for single item situations //if (currentComponentCount == 1) //{ // if (asset["component_category"] == "component") // { // #region Component Logic // Input.AddHiddenField("component_category", "component"); // Input.ShowMessage("Is Component"); // Input.ShowTextBox("Component Name: ", "component_component_label", readOnly: true); // if (asset["component_component_type_in_markup"] == "true") // { // Input.ShowTextBox("Component Type: ", "component_component_type", readOnly: true); // } // else // { // Input.ShowDropDown("Component Type", "component_component_type", componentTypeOptions); // } // if (ComponentLibraryHelper.getCoreComponentTypes(asset).Contains(asset["component_component_type"])) // { // Input.ShowCheckBox("Is this component required?", "component_component_required", "yes", "Yes"); // Input.ShowTextBox("Validation error message", "component_component_required_message", helpMessage: "This message will show if the field is required but not populated"); // } // Input.StartHorizontalWrapContainer(); // Input.ShowTextBox("Label Override", "component_component_input_label"); // if (!ComponentLibraryHelper.getCoreComponentTypes(asset).Contains(asset["component_component_type"])) // { // Input.ShowDropDown("Label Override Type", "component_component_form_override_type", labelOverrideTypeOptions, Util.MakeList("prepend")); // } // Input.EndHorizontalWrapContainer(); // Input.StartHorizontalWrapContainer(); // Input.ShowTextBox("Message Field", "component_component_message_content", helpMessage: "The message will be placed above the associated component"); // Input.ShowDropDown("Message Type", "component_component_message_type", messageTypeOptions, defaultValue: Util.MakeList("basic")); // Input.EndHorizontalWrapContainer(); // #endregion // } // else // { // #region List Logic // Input.AddHiddenField("component_category", "list"); // Input.ShowMessage("Is List"); // Input.ShowTextBox("List Name: ", "component_list_label", readOnly: true); // Input.ShowTextBox("List Content: ", "component_list_content", readOnly: true); // Input.ShowTextBox("List Components: ", "component_list_components", readOnly: true); // Input.StartHorizontalWrapContainer(); // Input.ShowTextBox("Minimum Number of Panels:", "min_panels", width: 5); // //Input.ShowTextBox("(Copy Here) Minimum Number of Panels:", "component_list_min_panels", width: 5); // Input.ShowTextBox("Maximum Number of Panels:", "max_panels", width: 5); // //Input.ShowTextBox("(Copy Here) Maximum Number of Panels:", "component_list_max_panels", width: 5); // Input.EndHorizontalWrapContainer(); // Input.StartHorizontalWrapContainer(); // Input.ShowTextBox("Message Field", "component_list_message_content", helpMessage: "The message will be placed above the associated component"); // Input.ShowDropDown("Message Type", "component_list_message_type", messageTypeOptions, defaultValue: Util.MakeList("basic")); // Input.EndHorizontalWrapContainer(); // String nextPanelName = ComponentLibraryHelper.getNextComponentPanelDepth(panelName); // List<PanelEntry> nextPanelEntries = currentPanelEntries[(i - 1)].GetPanels(nextPanelName); // ComponentDetailsHelper(asset, context, nextPanelName, ++panelDepth, ComponentBase.Index(i) + index, nextPanelEntries); // #endregion //} //} //else //{ #endregion String myIndex = isOnlyPanel ? "" : ComponentBase.Index(i); if (asset["component_category" + myIndex + index] == "component") { #region Component Logic Input.StartControlPanel(asset["component_component_label" + myIndex + index] + " " + asset["component_component_type" + myIndex + index] + " Component"); Input.AddHiddenField("component_category", "component"); Input.ShowMessage("Is Component"); //Input.ShowMessage(String.Format("Panel's name & index: {0} , {1}. Panel's content field name: {2}", panelName, (i - 1), currentPanelEntries[(i - 1)]["component_component_name"], panelName)); Input.ShowTextBox("Component Name: ", "component_component_label", readOnly: true); if (asset["component_component_type_in_markup" + myIndex + index] == "true") { Input.ShowTextBox("Component Type: ", "component_component_type", readOnly: true); } else { Input.ShowDropDown("Component Type", "component_component_type", componentTypeOptions); } if (ComponentLibraryHelper.getCoreComponentTypes(asset).Contains(asset["component_component_type" + myIndex + index])) { if (asset["component_component_type" + myIndex + index] == "Code") { Input.ShowTextBox("Code snippet", "component_component_hardcoded_snippet", helpMessage: "This snippet will be baked into the component code, must evaluate to a string and not end with a \";\""); } else { Input.ShowCheckBox("Is this component required?", "component_component_required", "yes", "Yes"); Input.ShowTextBox("Validation error message", "component_component_required_message", helpMessage: "This message will show if the field is required but not populated"); } } Input.StartHorizontalWrapContainer(); if (asset["component_component_type" + myIndex + index] != "Code") { Input.ShowTextBox("Label Override", "component_component_input_label"); } if (!ComponentLibraryHelper.getCoreComponentTypes(asset).Contains(asset["component_component_type" + myIndex + index])) { Input.ShowDropDown("Label Override Type", "component_component_form_override_type", labelOverrideTypeOptions, Util.MakeList("prepend")); } Input.EndHorizontalWrapContainer(); if (asset["component_component_type" + myIndex + index] != "Code") { Input.StartHorizontalWrapContainer(); Input.ShowTextBox("Message Field", "component_component_message_content", helpMessage: "The message will be placed above the associated component"); Input.ShowDropDown("Message Type", "component_component_message_type", messageTypeOptions, defaultValue: Util.MakeList("basic")); Input.EndHorizontalWrapContainer(); } Input.EndControlPanel(); #endregion } else { #region List Logic Input.StartControlPanel(asset["component_list_label" + myIndex + index] + " List"); Input.AddHiddenField("component_category", "list"); Input.ShowMessage("Is List"); //Input.ShowMessage(String.Format("Panel's name & index: {0} , {1}. Panel's content field name: {2}", panelName, (i - 1), currentPanelEntries[(i - 1)]["component_list_name"], panelName)); Input.ShowTextBox("List Name: ", "component_list_label", readOnly: true); Input.ShowTextBox("List Content: ", "component_list_content", readOnly: true); Input.ShowTextBox("List Components: ", "component_list_components", readOnly: true); Input.StartHorizontalWrapContainer(); Input.ShowTextBox("Minimum Number of Panels:", "min_panels", width: 5); //Input.ShowTextBox("(Copy here) Minimum Number of Panels:", "component_list_min_panels", width: 5); Input.ShowTextBox("Maximum Number of Panels:", "max_panels", width: 5); //Input.ShowTextBox("(Copy Here) Maximum Number of Panels:", "component_list_max_panels", width: 5); Input.EndHorizontalWrapContainer(); Input.StartHorizontalWrapContainer(); Input.ShowTextBox("Message Field", "component_list_message_content", helpMessage: "The message will be placed above the associated component"); Input.ShowDropDown("Message Type", "component_list_message_type", messageTypeOptions, defaultValue: Util.MakeList("basic")); Input.EndHorizontalWrapContainer(); String nextPanelName = ComponentLibraryHelper.getNextComponentPanelDepth(panelName); List<PanelEntry> nextPanelEntries = currentPanelEntries[(i - 1)].GetPanels(nextPanelName); ComponentDetailsHelper(asset, context, nextPanelName, ++panelDepth, ComponentBase.Index(i) + index, nextPanelEntries, asset["component_list_label" + ComponentBase.Index(i) + index]); Input.EndControlPanel(); #endregion } i++; } } } } } 261477 1792 /System/Templates/Basis/DeveloperCS/ 1 0 false false 0 0 /Component Project/Library/ComponentContentPlaceholder.cs 261059 17 LibraryClass 2 body using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Text.RegularExpressions; using CrownPeak.CMSAPI; using CrownPeak.CMSAPI.Services; /* Some Namespaces are not allowed. */ namespace Component_Library.Component_Project.Components { public class ComponentContentPlaceholder { /***BOTH***/ public String name { get; set; } public ComponentLibraryHelper.ContentPlaceholderCategory category { get; set; } public String message { get; set; } public String messageType { get; set; } /***COMPONENTS & CORE***/ public String type { get; set; } public bool typeInMarkup { get; set; } public String inputLabel { get; set; } public String inputLabelType { get; set; } public String isRequired { get; set; } public String isRequiredMessage { get; set; } public String fieldIndexed { get; set; } public String hardcodedSnippet { get; set; } /****LIST***/ public String content { get; set; } public String minPanels { get; set; } public String maxPanels { get; set; } public String components { get; set; } public List<ComponentContentPlaceholder> subComponents { get; set; } public ComponentContentPlaceholder(PanelEntry contentPlaceholderPanel, String panelName) { category = contentPlaceholderPanel["component_category"] == "list" ? ComponentLibraryHelper.ContentPlaceholderCategory.List : ComponentLibraryHelper.ContentPlaceholderCategory.Component; if (contentPlaceholderPanel["component_category"] == "list") { name = contentPlaceholderPanel["component_list_label"]; category = ComponentLibraryHelper.ContentPlaceholderCategory.List; message = contentPlaceholderPanel["component_list_message_content"]; messageType = contentPlaceholderPanel["component_list_message_type"]; content = contentPlaceholderPanel["component_list_content"]; minPanels = contentPlaceholderPanel["min_panels"]; maxPanels = contentPlaceholderPanel["max_panels"]; components = contentPlaceholderPanel["component_list_components"]; String nextPanelDepthName = ComponentLibraryHelper.getNextComponentPanelDepth(panelName); if (!nextPanelDepthName.StartsWith("ERROR:")) { subComponents = ConvertPanelEntryList(contentPlaceholderPanel.GetPanels(nextPanelDepthName), nextPanelDepthName); } } else if (contentPlaceholderPanel["component_category"] == "component") { name = contentPlaceholderPanel["component_component_label"]; category = ComponentLibraryHelper.ContentPlaceholderCategory.Component; message = contentPlaceholderPanel["component_component_message_content"]; messageType = contentPlaceholderPanel["component_component_message_type"]; type = contentPlaceholderPanel["component_component_type"]; inputLabel = contentPlaceholderPanel["component_component_input_label"]; inputLabelType = contentPlaceholderPanel["component_component_form_override_type"]; typeInMarkup = contentPlaceholderPanel["component_component_type_in_markup"].Trim().ToLower() == "true"; isRequired = contentPlaceholderPanel["component_component_required"]; isRequiredMessage = contentPlaceholderPanel["component_component_required_message"]; fieldIndexed = contentPlaceholderPanel["component_component_indexed"]; hardcodedSnippet = contentPlaceholderPanel["component_component_hardcoded_snippet"]; } Out.DebugWriteLine("CCP \"" + name + "\" created"); } public ComponentContentPlaceholder(Match contentPlaceholderMatch, String category) { if (category == "list") { name = ComponentLibraryHelper.getAttribValueFromComponentMarkup(contentPlaceholderMatch.Value, "name"); this.category = ComponentLibraryHelper.ContentPlaceholderCategory.List; content = ComponentLibraryHelper.getListNodeContent(contentPlaceholderMatch.Value); components = ComponentLibraryHelper.getListNodeComponents(contentPlaceholderMatch.Value); } else if (category == "component") { name = ComponentLibraryHelper.getContentPlaceholderName(contentPlaceholderMatch.Value); this.category = ComponentLibraryHelper.ContentPlaceholderCategory.Component; type = ComponentLibraryHelper.getContentPlaceholderTypeFromMarkup(contentPlaceholderMatch.Value); typeInMarkup = true; if (type == String.Empty) { type = ComponentLibraryHelper.getDefaultContentPlaceholderType(); typeInMarkup = false; } fieldIndexed = ComponentLibraryHelper.getContentPlaceholderIndexedFieldFromMarkup(contentPlaceholderMatch.Value); } else if (category == "template") { name = ComponentLibraryHelper.getContentPlaceholderName(contentPlaceholderMatch.Value); this.category = ComponentLibraryHelper.ContentPlaceholderCategory.Component; type = ComponentLibraryHelper.getContentPlaceholderTypeFromMarkup(contentPlaceholderMatch.Value); typeInMarkup = true; if (type == String.Empty) { type = name; } } } public ComponentContentPlaceholder() { } public static List<ComponentContentPlaceholder> ConvertPanelEntryList(List<PanelEntry> panelEntryList, String panelName) { List<ComponentContentPlaceholder> contentPlaceholderList = new List<ComponentContentPlaceholder>(); foreach (PanelEntry pe in panelEntryList) { contentPlaceholderList.Add(new ComponentContentPlaceholder(pe, panelName)); } return contentPlaceholderList; } public static List<ComponentContentPlaceholder> ConvertMatchCollection(MatchCollection contentPlaceholderMatches, String category) { List<ComponentContentPlaceholder> contentPlaceholderList = new List<ComponentContentPlaceholder>(); foreach (Match m in contentPlaceholderMatches) { contentPlaceholderList.Add(new ComponentContentPlaceholder(m, category)); } return contentPlaceholderList; } public static Dictionary<String, String> ConvertToContentDictionary(List<ComponentContentPlaceholder> componentContentPlaceholderList, String currentPanel = "", String index = "") { if (currentPanel == "") currentPanel = "component_panel"; Dictionary<String, String> contentDictionary = new Dictionary<string, string>(); bool isOnlyPanel = componentContentPlaceholderList.Count <= 1 && currentPanel == "component_panel"; int i = 1; foreach (ComponentContentPlaceholder componentContentPlaceholder in componentContentPlaceholderList) { String myIndex = isOnlyPanel ? "" : ComponentBase.Index(i); contentDictionary.Add(currentPanel + myIndex + index, (i - 1).ToString()); if (componentContentPlaceholder.category == ComponentLibraryHelper.ContentPlaceholderCategory.Component) { contentDictionary.Add("component_component_label" + myIndex + index, componentContentPlaceholder.name); contentDictionary.Add("component_category" + myIndex + index, "component"); contentDictionary.Add("component_component_message_content" + myIndex + index, componentContentPlaceholder.message); contentDictionary.Add("component_component_message_type" + myIndex + index, componentContentPlaceholder.messageType); contentDictionary.Add("component_component_type" + myIndex + index, componentContentPlaceholder.type); contentDictionary.Add("component_component_type_in_markup" + myIndex + index, componentContentPlaceholder.typeInMarkup ? "true" : "false"); contentDictionary.Add("component_component_input_label" + myIndex + index, componentContentPlaceholder.inputLabel); contentDictionary.Add("component_component_form_override_type" + myIndex + index, componentContentPlaceholder.inputLabelType); contentDictionary.Add("component_component_required" + myIndex + index, componentContentPlaceholder.isRequired); contentDictionary.Add("component_component_required_message" + myIndex + index, componentContentPlaceholder.isRequiredMessage); contentDictionary.Add("component_component_indexed" + myIndex + index, componentContentPlaceholder.fieldIndexed); contentDictionary.Add("component_component_hardcoded_snippet" + myIndex + index, componentContentPlaceholder.hardcodedSnippet); } else if (componentContentPlaceholder.category == ComponentLibraryHelper.ContentPlaceholderCategory.List) { contentDictionary.Add("component_list_label" + myIndex + index, componentContentPlaceholder.name); contentDictionary.Add("component_category" + myIndex + index, "list"); contentDictionary.Add("component_list_message_content" + myIndex + index, componentContentPlaceholder.message); contentDictionary.Add("component_list_message_type" + myIndex + index, componentContentPlaceholder.messageType); contentDictionary.Add("component_list_content" + myIndex + index, componentContentPlaceholder.content); contentDictionary.Add("min_panels" + myIndex + index, componentContentPlaceholder.minPanels); contentDictionary.Add("max_panels" + myIndex + index, componentContentPlaceholder.maxPanels); contentDictionary.Add("component_list_components" + myIndex + index, componentContentPlaceholder.components); String nextPanel = ComponentLibraryHelper.getNextComponentPanelDepth(currentPanel); //contentDictionary.Add(nextPanel + (isOnlyPanel ? "" : ComponentBase.Index(i)) + index, (--i).ToString()); Dictionary<String, String> subComponents = ConvertToContentDictionary(componentContentPlaceholder.subComponents, nextPanel, ComponentBase.Index(i) + index); contentDictionary = contentDictionary.Concat(subComponents).ToDictionary(x => x.Key, x => x.Value); } i++; } return contentDictionary; } } } 261478 1792 /System/Templates/Basis/DeveloperCS/ 1 0 false false 0 0 /Component Project/Library/ComponentLibraryConfigHelper.cs 261059 17 LibraryClass 2 body using System; using System.Collections.Generic; using System.Linq; using System.Text; using CrownPeak.CMSAPI; using CrownPeak.CMSAPI.Services; /* Some Namespaces are not allowed. */ namespace Component_Library.Component_Project.Components { public class ComponentLibraryConfigHelper { public static void FilenameHelper(Asset asset, OutputContext context) { context.PublishPath = string.Empty; } public static void InputHelper(Asset asset, InputContext context) { Input.StartTabbedPanel(/*"Version Config",*/ "Component Class Config"); //{ // Dictionary<String, String> versionOptions = new Dictionary<string, string>(); // FilterParams fParams = new FilterParams(); // fParams.Add(AssetPropertyNames.Label, Comparison.StartsWith, "ComponentLibrary_"); // fParams.ExcludeProjectTypes = false; // List<Asset> versionList = Asset.Load("/System/Library").GetFilterList(fParams); // Out.DebugWriteLine("Number of ComponentLibrary_ files: " + versionList.Count); // foreach (Asset version in versionList) // { // versionOptions.Add(version.Label.Replace(".cs", ""), version.Label.Replace(".cs", "")); // } // Input.ShowDropDown("Live State", "live_version", versionOptions); // Input.ShowDropDown("Stage State", "stage_version", versionOptions); // Input.ShowDropDown("Draft State", "draft_version", versionOptions); //} //Input.NextTabbedPanel(); Input.ShowSelectFolder("Component Library Root Folder", "component_library_root_folder", defaultFolder: asset.Parent.AssetPath, helpMessage: "this is the root folder for the component library framework"); Input.ShowSelectFolder("Component Library Project Folder", "component_library_project_folder", defaultFolder: asset.Parent.AssetPath + "/Component_Project", helpMessage: "this is the project folder"); Input.ShowSelectFolder("Component Library Code File Folder", "component_class_folder", defaultFolder: asset.Parent.AssetPath + "/Component_Project/Components", helpMessage: "this is the folder where all the component classes will be created"); Input.ShowSelectFolder("Component Library Component Assets Folder", "component_library_components_folder", defaultFolder: asset.Parent.AssetPath + "/_Components", helpMessage: "this is the folder where all the component assets are kept"); Input.ShowSelectFolder("Component Library Models Folder", "component_library_models_folder", helpMessage: "this is the folder where all the component library models are kept"); Input.ShowSelectFolder("Site Root Folder", "site_root", helpMessage: "this is the root of the site the component library is being used in"); Input.ShowAcquireDocument("Site Config", "site_config", helpMessage: "this is the site configuration file"); Input.ShowTextBox("Component Library Namespace", "component_library_namespace"); Input.EndTabbedPanel(); } public static void OutputHelper(Asset asset, OutputContext context) { } } } 261548 1792 /System/Templates/Basis/DeveloperCS/ 1 0 false false 0 0 /Component Project/Library/ComponentLibraryEnhancedTemplateBuilderHelper.cs 261059 17 LibraryClass 2 body using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Text.RegularExpressions; using CrownPeak.CMSAPI; using CrownPeak.CMSAPI.Services; /* Some Namespaces are not allowed. */ namespace Component_Library.Component_Project.Components { public class ComponentLibraryEnhancedTemplateBuilderHelper { public static void InputHelper(Asset asset, InputContext context) { Asset componentLibraryProjectTemplatesFolder = InitializeTemplateFolder(asset); String SiteRootFolderPath = ComponentLibraryHelper.getcomponentLibraryRootFolder(asset).AssetPath.ToString(); String ComponentsFolderPath = ComponentLibraryHelper.getComponentLibraryComponentsFolder(asset).ToString(); string libraryPath = ComponentLibraryHelper.getComponentLibraryComponentsFolder(asset).AssetPath.ToString(); if (String.IsNullOrEmpty(asset["inputBody"])) { Input.StartTabbedPanel("Pattern", "Wrapper", "Settings"); } else { Input.StartTabbedPanel("Pattern", "Wrapper", "Settings", "Code"); } Input.StartControlPanel("Pattern"); Input.ShowTextBox("Markup", "markup", width: 800, height: 30); Dictionary<String, String> componentTypeOptions = ComponentLibraryHelper.getAllComponentTypesForDropdown(asset); ComponentBuilderHelper.ComponentDetailsHelper(asset, context, "component_panel", 1); Input.EndControlPanel(); Input.NextTabbedPanel(); //Dictionary<String, String> wrapperOptions = new Dictionary<string, string>() { { "Default", "default" }, { "Landing Page", "landing" }, { "None", "none" } }; //Input.ShowRadioButton("Content Wrapper", "wrapper", wrapperOptions); ShowAcquireParams wrapperAcquireParams = new ShowAcquireParams { DefaultFolder = asset.Parent.AssetPath.ToString() + "/Site Wrappers" }; Dictionary<String, String> wrapperTypeOptions = new Dictionary<string, string>(); wrapperTypeOptions.Add("Built With Wrapper Builder", "template_builder"); wrapperTypeOptions.Add("Custom Built Wrapper", "custom"); Input.StartDropDownContainer("Wrapper Selection Type", "wrapper_type", wrapperTypeOptions, defaultValue: "template_builder"); Input.ShowMessage("This options lets you select a wrapper built via a wrapper builder asset"); Input.ShowAcquireDocument("Wrapper", "wrapper", wrapperAcquireParams); Input.NextDropDownContainer(); Input.ShowMessage("This option lets you select a custom built wrapper"); Input.ShowSelectFolder("Wrapper Template", "custom_wrapper"); Input.EndDropDownContainer(); Input.NextTabbedPanel(); Input.ShowCheckBox("Create", "create", "yes", "yes"); Input.ShowTextBox("Template Name", "template_name", asset.Label.Replace(" Template", "") + " Template"); Input.StartExpandPanel("Template File Settings"); Input.ShowCheckBox("", "do_not_overwrite_post_save", "do_not_overwrite", "Do not overwrite the post_save.aspx template file"); Input.EndExpandPanel(); Input.ShowSelectFolder("Template Folder", "template_folder", componentLibraryProjectTemplatesFolder.AssetPath); Input.ShowAcquireDocument("Select preview asset", "previewAsset", SiteRootFolderPath + "/_templates"); Input.ShowCheckBox("JSON Template?", "json_template", "yes", "Yes", helpMessage: "When checked, the generated template will include JSON output and Search G2."); Input.ShowCheckBox("Enable Page Metadata", "meta", "yes", "yes"); Input.ShowCheckBox("Enable Page specific JavaScript and CSS", "custom_js_css", "yes", "yes"); Input.ShowCheckBox("Enable Advanced Capabilities", "advanced", "yes", "yes", helpMessage: "This option adds an \"Advanced\" tab to the input form which contains a link to directly edit this template builder template."); Input.ShowCheckBox("Enable TMF", "enable_tmf", "yes", "Yes"); Input.StartExpandPanel("TMF Settings"); Input.ShowCheckBox("Create a output_translate_xml.aspx file?", "create_output_translate_xml", "yes", "Yes", helpMessage: "When custom code is required to package the content being translated you will need to enter the custom function in the text box below"); Input.ShowTextBox("TMF output_translate_xml.aspx code", "output_translate_xml_body", width: 100, height: 5); Input.EndExpandPanel(); if (!String.IsNullOrEmpty(asset["inputBody"])) { Input.NextTabbedPanel(); Input.ShowTextBox("Input", "inputBody", width: 100, readOnly: true); Input.ShowTextBox("Post Input", "postinputBody", width: 100, readOnly: true); Input.ShowTextBox("Output", "outputBody", width: 100, readOnly: true); if (asset["json_template"] == "yes") { Input.ShowTextBox("Output JSON", "outputJsonBody", width: 100, readOnly: true); Input.ShowTextBox("Search G2 Delete", "searchG2DeleteBody", width: 100, readOnly: true); Input.ShowTextBox("Search G2 Insert", "searchG2InsertBody", width: 100, readOnly: true); Input.ShowTextBox("Search G2 Update", "searchG2UpdateBody", width: 100, readOnly: true); } if (asset["enable_tmf"] == "yes") { Input.ShowTextBox("Output Post Save (TMF)", "postSaveBody", width: 100, readOnly: true); Input.ShowTextBox("Output Changes (TMF)", "outputChangesBody", width: 100, readOnly: true); if (asset["create_output_translate_xml"] == "yes") { Input.ShowTextBox("Output Translate Xml (TMF)", "outputTranslateXmlBody", width: 100, readOnly: true); } } } Input.EndTabbedPanel(); } private static Asset InitializeTemplateFolder(Asset asset) { Asset componentLibraryProjectTemplatesFolder = Asset.Load(ComponentLibraryHelper.getComponentLibraryProjectFolder(asset).AssetPath + "/Templates"); if (string.IsNullOrEmpty(asset["template_folder"]) && componentLibraryProjectTemplatesFolder != null && componentLibraryProjectTemplatesFolder.IsLoaded) { asset["template_folder"] = componentLibraryProjectTemplatesFolder.GetLink(LinkType.Internal); } return componentLibraryProjectTemplatesFolder; } public static void OutputHelper(Asset asset, OutputContext context) { Component_Layout layout = new Component_Layout(); context.IsGeneratingDependencies = false; String componentColumn = ""; String componentOutput = ""; String wrapperType = asset["wrapper_type"]; String SiteRootFolderPath = ComponentLibraryHelper.getcomponentLibraryRootFolder(asset).AssetPath.ToString(); Asset globalConfig = Asset.Load(SiteRootFolderPath + "/_Global/Global Config"); //dictionary to allow for multiple columns based on ComponentLibrary Config Dictionary<int, StringBuilder> columnDictionary = new Dictionary<int, StringBuilder>(); Dictionary<String, StringBuilder> rowContent = new Dictionary<string, StringBuilder>(); StringBuilder sbCol1 = new StringBuilder(); StringBuilder sbCol2 = new StringBuilder(); if (String.IsNullOrWhiteSpace(wrapperType)) { wrapperType = asset["wrapper_type"]; } if (wrapperType == "custom") { Asset wrapperAsset = Asset.Load(asset["custom_wrapper"]); if (wrapperAsset.IsLoaded) { ComponentLibraryHelper.startWrap(asset, context, wrapperAsset.AssetPath.ToString(), wrapperType); } } else { Asset wrapperAsset = Asset.Load(asset["wrapper"]); if (!string.IsNullOrEmpty(wrapperAsset.Raw["template_name"])) { ComponentLibraryHelper.startWrap(asset, context, wrapperAsset.Raw["template_name"]); } } foreach (PanelEntry entry in asset.GetPanels("layouts")) { sbCol1.Clear(); sbCol2.Clear(); foreach (PanelEntry subEntry in entry.GetPanels("components")) { componentOutput = ""; componentColumn = ""; if (String.IsNullOrEmpty(subEntry.Raw["custom_code"])) { Asset aComponent = ComponentLibraryHelper.getComponentAsset(asset, subEntry["component"]); if (aComponent != null && aComponent.IsLoaded) { componentOutput = ComponentLibraryHelper.generateComponentPreview(aComponent, context); } componentColumn = subEntry["column"]; } else { componentOutput = subEntry["custom_code"]; componentColumn = subEntry["custom_column"]; } switch (componentColumn) { case "col1": sbCol1.Append(componentOutput); break; case "col2": sbCol2.Append(componentOutput); break; } } rowContent.Add("{col1}", sbCol1); rowContent.Add("{col2}", sbCol2); Out.Write(layout.output(asset, entry.GetFieldName("layout"), rowContent, entry["layout"])); rowContent.Clear(); } if (asset["wrapper"] == "yes") { ComponentLibraryHelper.endWrap(asset, context); } } public static void OutputCodeHelper(Asset asset, OutputContext context) { context.IsGeneratingDependencies = false; string SiteRootFolderPath = ComponentLibraryHelper.getcomponentLibraryRootFolder(asset).AssetPath.ToString(); //Root Assets folders string cssFolder = SiteRootFolderPath + "/_Assets/css/"; string jsFolder = SiteRootFolderPath + "/_Assets/js/"; Out.DebugWriteLine("<!DOCTYPE html>"); Out.WriteLine("<html lang=\"en\">"); Out.WriteLine("<head>"); Out.WriteLine(" <link rel=\"stylesheet\" href=\"" + Asset.Load(cssFolder + "/bootstrap.css").GetLink(LinkType.Include) + "\" media=\"all\" />"); Out.WriteLine(" <script type=\"text/javascript\" src=\"http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.js\"></script>"); Out.WriteLine("</head>"); Out.WriteLine("<body>"); Out.WriteLine(" <div class=\"container\">"); Out.WriteLine(" <div id=\"content\">"); Out.WriteLine(" <ul id=\"tabs\" class=\"nav nav-tabs\" data-tabs=\"tabs\">"); Out.WriteLine(" <li class=\"active\"><a href=\"#input\" data-toggle=\"tab\">Input</a></li>"); Out.WriteLine(" <li><a href=\"#postinput\" data-toggle=\"tab\">PostInput</a></li>"); Out.WriteLine(" <li><a href=\"#output\" data-toggle=\"tab\">Output</a></li>"); Out.WriteLine(" </ul>"); Out.WriteLine(" <div id=\"my-tab-content\" class=\"tab-content\">"); Out.WriteLine(" <div class=\"tab-pane active\" id=\"input\">"); Out.WriteLine(" <h1>Input</h1>"); Out.WriteLine(" " + Util.ConvertTextToHtml(asset["inputBody"]).Replace("<dd>", "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;")); Out.WriteLine(" </div>"); Out.WriteLine(" <div class=\"tab-pane\" id=\"postinput\">"); Out.WriteLine(" <h1>PostInput</h1>"); Out.WriteLine(" " + Util.ConvertTextToHtml(asset["postinputBody"]).Replace("<dd>", "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;")); Out.WriteLine(" </div>"); Out.WriteLine(" <div class=\"tab-pane\" id=\"output\">"); Out.WriteLine(" <h1>Output</h1>"); Out.WriteLine(" " + Util.ConvertTextToHtml(asset["outputBody"]).Replace("<dd>", "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;")); Out.WriteLine(" </div>"); Out.WriteLine(" </div>"); Out.WriteLine(" </div>"); Out.WriteLine(" <script type=\"text/javascript\">"); Out.WriteLine(" jQuery(document).ready(function ($) {"); Out.WriteLine(" $('#tabs').tab();"); Out.WriteLine(" });"); Out.WriteLine(" </script>"); Out.WriteLine(" </div>"); Out.WriteLine(" <!-- container -->"); Out.WriteLine(" <script type=\"text/javascript\" src=\"" + Asset.Load(jsFolder + "/bootstrap.js").GetLink(LinkType.Include) + "\"></script>"); Out.WriteLine("</body>"); Out.WriteLine("</html>"); } public static void OutputComponentsHelper(Asset asset, OutputContext context) { Component_Layout layout = new Component_Layout(); Dictionary<String, StringBuilder> rowContent = new Dictionary<string, StringBuilder>(); context.IsGeneratingDependencies = false; String SiteRootFolderPath = ComponentLibraryHelper.getcomponentLibraryRootFolder(asset).AssetPath.ToString(); //Out.WriteLine(SiteRootFolderPath); Asset globalConfig = Asset.Load(SiteRootFolderPath + "/_Global/Global Config"); //Root Assets folders string imageFolder = SiteRootFolderPath + "/_Assets/images/"; string cssFolder = SiteRootFolderPath + "/_Assets/css/"; string jsFolder = SiteRootFolderPath + "/_Assets/js/"; string componentName = ""; string componentThumbnail = ""; string componentType = ""; string componentPath = ""; string componentId = ""; string componentColumn = ""; // Asset aComponent; string componentOutput = ""; StringBuilder sbCol1 = new StringBuilder(); StringBuilder sbCol2 = new StringBuilder(); String wrapperType = asset["wrapper_type"]; if (String.IsNullOrWhiteSpace(wrapperType)) { wrapperType = asset["wrapper_type"]; } if (wrapperType == "custom") { Asset wrapperAsset = Asset.Load(asset["custom_wrapper"]); if (wrapperAsset.IsLoaded) { ComponentLibraryHelper.startWrap(asset, context, wrapperAsset.AssetPath.ToString(), wrapperType); } } else { Asset wrapperAsset = Asset.Load(asset["wrapper"]); if (!string.IsNullOrEmpty(wrapperAsset.Raw["template_name"])) { ComponentLibraryHelper.startWrap(asset, context, wrapperAsset.Raw["template_name"]); } } foreach (PanelEntry entry in asset.GetPanels("layouts")) { sbCol1.Clear(); sbCol2.Clear(); foreach (PanelEntry subEntry in entry.GetPanels("components")) { componentOutput = ""; componentThumbnail = ""; componentColumn = ""; if (String.IsNullOrEmpty(subEntry.Raw["custom_code"])) { Asset aComponent = ComponentLibraryHelper.getComponentAsset(asset, subEntry["component"]); if (aComponent != null && aComponent.IsLoaded) { componentOutput = "<span " + Util.Editable("component", subEntry) + "> " + makeRaw(ComponentLibraryHelper.generateComponentPreview(aComponent, context)) + "</span>"; } componentColumn = subEntry["column"]; } else { componentOutput = subEntry["custom_code"]; componentColumn = subEntry["custom_column"]; } switch (componentColumn) { case "col1": sbCol1.Append(componentOutput); break; case "col2": sbCol2.Append(componentOutput); break; } } rowContent.Add("{col1}", sbCol1); rowContent.Add("{col2}", sbCol2); Out.Write(layout.output(asset, entry.GetFieldName("layout"), rowContent, entry["layout"])); rowContent.Clear(); } if (asset["wrapper"] == "yes") { ComponentLibraryHelper.endWrap(asset, context); } } public static void OutputContentHelper(Asset asset, OutputContext context) { /***Commented out because no longer serves a purpose***/ //Component_Layout layout = new Component_Layout(); //Dictionary<String, StringBuilder> rowContent = new Dictionary<string, StringBuilder>(); //context.IsGeneratingDependencies = false; //string SiteRootFolderPath = "/" + asset.AssetPath[0]; //"/Utility.GetSiteRootPathReg(asset); ////Out.WriteLine(SiteRootFolderPath); //Asset globalConfig = Asset.Load(SiteRootFolderPath + "/_Global/Global Config"); ////Root Assets folders //string imageFolder = SiteRootFolderPath + "/_Assets/images/"; //string cssFolder = SiteRootFolderPath + "/_Assets/css/"; //string jsFolder = SiteRootFolderPath + "/_Assets/js/"; //string componentName = ""; //string componentThumbnail = ""; //string componentType = ""; //string componentPath = ""; //string componentId = ""; //string componentColumn = ""; //// Asset aComponent; //string componentOutput = ""; //StringBuilder sbCol1 = new StringBuilder(); //StringBuilder sbCol2 = new StringBuilder(); //if (!string.IsNullOrEmpty(Asset.Load(asset["wrapper"]).Raw["template_name"])) ComponentLibraryHelper.startWrap(asset, context, Asset.Load(asset["wrapper"]).Raw["template_name"]); //foreach (PanelEntry entry in asset.GetPanels("layouts")) //{ // sbCol1.Clear(); // sbCol2.Clear(); // foreach (PanelEntry subEntry in entry.GetPanels("components")) // { // componentOutput = ""; // componentThumbnail = ""; // componentColumn = ""; // if (String.IsNullOrEmpty(subEntry.Raw["custom_code"])) // { // componentPath = subEntry["component"]; // //componentPath = subEntry["component"]; // Asset aComponent = Asset.Load(componentPath); // if (aComponent.IsLoaded) // { // componentOutput = ComponentLibraryHelper.generateComponentPreview(aComponent, context); // } // componentColumn = subEntry["column"]; // } // else // { // componentOutput = subEntry["custom_code"]; // componentColumn = subEntry["custom_column"]; // } // switch (componentColumn) // { // case "col1": // sbCol1.Append(componentOutput); // break; // case "col2": // sbCol2.Append(componentOutput); // Console.WriteLine("Case 2"); // break; // } // } // rowContent.Add("{col1}", sbCol1); // rowContent.Add("{col2}", sbCol2); // Out.Write(layout.output(asset, entry.GetFieldName("layout"), rowContent, entry["layout"])); // rowContent.Clear(); //} //if (asset["wrapper"] == "yes") //{ // ComponentLibraryHelper.endWrap(asset, context); //} } public static void PostInputHelper(Asset asset, PostInputContext context) { context = ComponentLibraryHelper.validateComponentPlaceholderNames(asset, context); List<ComponentContentPlaceholder> markupContentPlaceholders = ComponentLibraryHelper.buildComponentContentPlaceholderForTemplateFromMarkup(context.InputForm["markup"]); List<PanelEntry> componentPanels = context.InputForm.GetPanels("component_panel"); List<ComponentContentPlaceholder> assetContentPlaceholders = ComponentContentPlaceholder.ConvertPanelEntryList(componentPanels, "component_panel"); List<ComponentContentPlaceholder> flattenedAssetcontentPlaceholders = ComponentLibraryHelper.flattenComponentContentPlaceholderList(assetContentPlaceholders); ComponentLibraryHelper.deleteExistingContentFieldsForComponents(ref assetContentPlaceholders, markupContentPlaceholders); ComponentLibraryHelper.updateExistingContentFields(ref assetContentPlaceholders, markupContentPlaceholders); ComponentLibraryHelper.createContentFieldsForComponents(ref assetContentPlaceholders, markupContentPlaceholders, flattenedAssetcontentPlaceholders); Dictionary<String, String> content = ComponentContentPlaceholder.ConvertToContentDictionary(assetContentPlaceholders); ComponentLibraryHelper.deleteTemplateContent(context); foreach (var kvp in content) { context.InputForm[kvp.Key] = kvp.Value; } // Truly delete unused panels foreach (PanelEntry entry in context.InputForm.GetPanels("component_panel")) { if (entry["component_component_type"].Length == 0 && entry["component_component_label"].Length == 0) { var fields = new List<string> { entry.GetFieldName("component_category"), entry.GetFieldName("component_component_form_override_type"), entry.GetFieldName("component_component_hardcoded_snippet"), entry.GetFieldName("component_component_input_label"), entry.GetFieldName("component_component_label"), entry.GetFieldName("component_component_message_content"), entry.GetFieldName("component_component_message_type"), entry.GetFieldName("component_component_required"), entry.GetFieldName("component_component_required_message"), entry.GetFieldName("component_component_type"), entry.GetFieldName("component_component_type_in_markup"), entry.GetFieldName("component_list_components"), entry.GetFieldName("component_list_content"), entry.GetFieldName("component_list_label"), entry.GetFieldName("component_list_message_content"), entry.GetFieldName("component_list_message_type"), entry.GetFieldName("component_panel"), }; context.InputForm.Remove(fields); } } string ComponentLibraryComponentFolder = ComponentLibraryHelper.getComponentLibraryComponentsFolder(asset).AssetPath.ToString(); string nameSpace = ""; //"CrownPeak.CMSAPI.CustomLibrary.Components."; string componentLibraryClassName = "ComponentLibraryHelper"; string layoutClassName = "layout"; string openTag = "<" + "%"; string closeTag = "%" + ">"; string tab = "\t"; string componentClassName = ""; string componentName = ""; string componentLabel = ""; string componentMessage = ""; string componentFieldName = ""; string componentThumbnail = ""; string componentType = ""; Asset aComponent; StringBuilder sbDeclare = new StringBuilder(); StringBuilder sbImportNamespaces = new StringBuilder(); StringBuilder sbInput = new StringBuilder(); StringBuilder sbInputContent = new StringBuilder(); StringBuilder sbPostInput = new StringBuilder(); StringBuilder sbPostInputContent = new StringBuilder(); StringBuilder sbOutput = new StringBuilder(); StringBuilder sbOutputContent = new StringBuilder(); StringBuilder sbOutputChanges = new StringBuilder(); StringBuilder sbOutputChangesContent = new StringBuilder(); StringBuilder sbOutputTranslateXml = new StringBuilder(); StringBuilder sbOutputTranslateXmlContent = new StringBuilder(); StringBuilder sbOutputJson = new StringBuilder(); StringBuilder sbOutputJsonContent = new StringBuilder(); StringBuilder sbPostSave = new StringBuilder(); StringBuilder sbPostSaveContent = new StringBuilder(); StringBuilder sbSearchG2Delete = new StringBuilder(); StringBuilder sbSearchG2DeleteContent = new StringBuilder(); StringBuilder sbSearchG2Insert = new StringBuilder(); StringBuilder sbSearchG2InsertContent = new StringBuilder(); StringBuilder sbSearchG2Update = new StringBuilder(); StringBuilder sbSearchG2UpdateContent = new StringBuilder(); StringBuilder sbSearchG2IndexedFieldsContent = new StringBuilder(); PanelEntry firstPe = context.InputForm.GetPanels("layouts").FirstOrDefault(); Dictionary<string, int> components = new Dictionary<string, int>(); sbDeclare.Append(openTag + "@ Import Namespace=\"CrownPeak.CMSAPI\" " + closeTag).AppendLine(); sbImportNamespaces.Append(openTag + "@ Import Namespace=\"CrownPeak.CMSAPI\" " + closeTag).AppendLine(); sbDeclare.Append(openTag + "@ Import Namespace=\"CrownPeak.CMSAPI.Services\" " + closeTag).AppendLine(); sbImportNamespaces.Append(openTag + "@ Import Namespace=\"CrownPeak.CMSAPI.Services\" " + closeTag).AppendLine(); sbDeclare.Append(openTag + "@ Import Namespace=\"CrownPeak.CMSAPI.CustomLibrary\" " + closeTag).AppendLine(); sbImportNamespaces.Append(openTag + "@ Import Namespace=\"CrownPeak.CMSAPI.CustomLibrary\" " + closeTag).AppendLine(); sbDeclare.Append(openTag + "@ Import Namespace=\"" + ComponentLibraryHelper.getComponentLibraryNamespace(asset) + "\"" + closeTag).AppendLine(); sbImportNamespaces.Append(openTag + "@ Import Namespace=\"" + ComponentLibraryHelper.getComponentLibraryNamespace(asset) + "\"" + closeTag).AppendLine(); MatchCollection dropZoneMatches = new Regex("<DropZone([^>]*\\s+)name=(['\"])([^'\"]+)\\2([^>]*?)((/>)|(>(?:.|\\s)*?</DropZone>))").Matches(context.InputForm["markup"]); sbDeclare.Append("<!--DO NOT MODIFY CODE ABOVE THIS LINE-->").AppendLine(); sbImportNamespaces.Append("<!--DO NOT MODIFY CODE ABOVE THIS LINE-->").AppendLine(); sbDeclare.Append(openTag).AppendLine(); if (context.InputForm["meta"] == "yes") { sbDeclare.Append(tab + nameSpace + "MetaData metaData = new " + nameSpace + "MetaData();").AppendLine(); } if (context.InputForm["custom_js_css"] == "yes") { sbDeclare.Append(tab + nameSpace + "HeaderJavascriptAndCss headerAndJavascriptCSS = new " + nameSpace + "HeaderJavascriptAndCss();").AppendLine(); } sbInputContent.Append(tab + "Input.StartTabbedPanel("); String dlm = ""; foreach (PanelEntry entry in context.InputForm.GetPanels("component_panel")) { //if (entry["consolidate_section_tab"] != "yes") { sbInputContent.Append(dlm + "\"" + entry["component_component_label"] + "\""); dlm = ", "; } } foreach (Match match in dropZoneMatches) { sbInputContent.Append(dlm + "\"" + match.Groups[3] + "\""); } if (context.InputForm["meta"] == "yes") sbInputContent.Append(", \"Metadata & Header Content\""); if (context.InputForm["advanced"] == "yes") sbInputContent.Append(", \"Advanced\""); if (context.InputForm["enable_tmf"] == "yes") sbInputContent.Append(", \"TMF\""); sbInputContent.Append(");").AppendLine(); String wrapperType = context.InputForm["wrapper_type"]; if (String.IsNullOrWhiteSpace(wrapperType)) { wrapperType = asset["wrapper_type"]; } if (wrapperType == "custom") { Asset wrapperAsset = Asset.Load(context.InputForm["custom_wrapper"]); if (!wrapperAsset.IsLoaded) { wrapperAsset = Asset.Load(asset["custom_wrapper"]); } if (wrapperAsset.IsLoaded) { sbOutputContent.AppendLine(openTag); sbOutputContent.Append(tab + "//Begin Wrapper").AppendLine(); sbOutputContent.Append(tab + componentLibraryClassName + ".startWrap(asset,context,\"" + wrapperAsset.AssetPath + "\", \"" + wrapperType + "\");").AppendLine(); sbOutputContent.AppendLine(closeTag); } } else { Asset wrapperAsset = Asset.Load(context.InputForm["wrapper"]); if (!wrapperAsset.IsLoaded) { wrapperAsset = Asset.Load(asset["wrapper"]); } if (!string.IsNullOrEmpty(wrapperAsset.Raw["template_name"]) && !string.IsNullOrEmpty(wrapperAsset.Raw["template_folder"])) { String wrapperAssetPath = Asset.Load(wrapperAsset["template_folder"]).AssetPath + "/" + wrapperAsset.Raw["template_name"]; sbOutputContent.AppendLine(openTag); sbOutputContent.Append(tab + "//Begin Wrapper").AppendLine(); sbOutputContent.Append(tab + componentLibraryClassName + ".startWrap(asset,context,\"" + wrapperAssetPath + "\", \"" + wrapperType + "\");").AppendLine(); sbOutputContent.AppendLine(closeTag); } } sbOutputContent.AppendLine(); String nextTab = ""; Int32 unique = 0; bool isFirstPe = true; /************BEGIN BUILDING INPUT & POST-INPUT************/ foreach (PanelEntry entry in context.InputForm.GetPanels("component_panel")) { if (!(isFirstPe && entry["consolidate_section_tab"] == "yes")) { if (entry["consolidate_section_tab"] != "yes") { sbInputContent.Append(nextTab).AppendLine(); } if (!(isFirstPe && entry["consolidate_section_tab"] == "yes")) { sbInputContent.Append(tab + tab + "// Capture content").AppendLine(); } componentClassName = entry["component_component_type"].Trim(); componentLabel = entry["component_component_label"].Trim(); componentName = componentClassName[0].ToString().ToLowerInvariant() + componentClassName.Substring(1); if (!components.ContainsKey(componentName)) { components.Add(componentName, 0); sbDeclare.Append(tab + nameSpace + componentClassName + " " + componentName + " = new " + nameSpace + componentClassName + "();").AppendLine(); } else components[componentName]++; componentFieldName = entry["component_component_label"]; //if (!(isFirstPe && entry["consolidate_section_tab"] == "yes")) { sbInputContent.Append(tab + tab + componentName + ".ComponentInput(asset, context, \"" + componentLabel + "\", \"" + componentFieldName + "\");").AppendLine(); sbPostInputContent.Append(tab + componentName + ".ComponentPostInput(asset, context, \"" + componentFieldName + "\");").AppendLine(); sbSearchG2IndexedFieldsContent.Append(tab + "indexedFields.AddRange(" + componentName + ".ComponentIndexedFields(asset, context, \"" + componentFieldName + "\"));").AppendLine(); } if (!(isFirstPe && entry["consolidate_section_tab"] == "yes")) { sbInputContent.AppendLine(); } nextTab = tab + "Input.NextTabbedPanel();"; } isFirstPe = false; } foreach (Match match in dropZoneMatches) { if (!isFirstPe) { sbInputContent.Append(nextTab).AppendLine(); } var zone = match.Groups[3]; sbInputContent.Append(tab + tab + "// DropZone " + zone).AppendLine(); sbInputContent.Append(tab + tab + "Input.ShowDragDrop(\"" + zone + "\", \"" + zone + "\");").AppendLine(); sbInputContent.AppendLine(); nextTab = tab + "Input.NextTabbedPanel();"; isFirstPe = false; } /************END BUILDING INPUT & POST-INPUT************/ /*****************BEGIN BUILDING OUTPUT & OUTPUT-JSON***/ sbOutputJsonContent.AppendLine(tab + "var sbJson = new StringBuilder(1024);"); sbOutputJsonContent.AppendLine(tab + "sbJson.Append(\"{\");"); var markup = context.InputForm["markup"]; var first = true; foreach (PanelEntry entry in context.InputForm.GetPanels("component_panel")) { var name = entry["component_component_label"]; var type = entry["component_component_type"]; var variableName = type[0].ToString().ToLowerInvariant() + type.Substring(1); var lookfor = "{" + (name == type ? name : (name + ":" + type)) + "}"; var replacement = openTag + "= " + variableName + ".ComponentOutput(asset, context, \"" + name + "\") " + closeTag; markup = markup.Replace(lookfor, replacement); if (entry["component_processed"] == "yes") continue; if (!first) sbOutputJsonContent.AppendLine(tab + "sbJson.Append(\",\");"); var otherFields = context.InputForm.GetPanels("component_panel") .Where(p => p["component_component_type"] == type && p["component_component_label"] != name && p["component_processed"] != "yes").ToArray(); if (otherFields.Any()) { sbOutputJsonContent.AppendLine(tab + "sbJson.AppendFormat(\"\\\"{0}\\\":[\", JsonHelper.StringToJson(\"" + name + "\"));"); sbOutputJsonContent.AppendLine(tab + tab + "sbJson.Append(" + variableName + ".ComponentJson(asset, context, \"" + name + "\"));"); foreach (PanelEntry subEntry in otherFields) { sbOutputJsonContent.AppendLine(tab + tab + "sbJson.Append(\",\");"); var arrayName = subEntry["component_component_label"]; sbOutputJsonContent.AppendLine(tab + tab + "sbJson.Append(" + variableName + ".ComponentJson(asset, context, \"" + arrayName + "\"));"); subEntry["component_processed"] = "yes"; } sbOutputJsonContent.AppendLine(tab + "sbJson.Append(\"]\");"); } else { sbOutputJsonContent.AppendLine(tab + "sbJson.AppendFormat(\"\\\"{0}\\\":{1}\", JsonHelper.StringToJson(\"" + name + "\"), " + variableName + ".ComponentJson(asset, context, \"" + name + "\"));"); } entry["component_processed"] = "yes"; first = false; } if (dropZoneMatches.Count > 0) { if (!first) sbOutputJsonContent.AppendLine(tab + "sbJson.Append(\",\");"); sbOutputJsonContent.AppendLine(tab + "sbJson.Append(\"\\\"DropZones\\\":{\");"); var firstZone = true; foreach (Match match in dropZoneMatches) { if (!firstZone) sbOutputJsonContent.AppendLine(tab + "sbJson.Append(\",\");"); sbOutputJsonContent.AppendLine(tab + "sbJson.Append(JsonHelper.DragAndDropZoneToJson(asset, context, \"" + match.Groups[3] + "\"));"); markup = markup.Replace(match.Groups[0].Value, "<% Out.ShowDragDropIncludeList(\"" + match.Groups[3] + "\", new [] { \"All\", \"" + match.Groups[3] + "\" }); %>"); firstZone = false; } sbOutputJsonContent.AppendLine(tab + "sbJson.Append(\"}\");"); first = false; } if (context.InputForm["meta"] == "yes") { if (!first) sbOutputJsonContent.AppendLine(tab + "sbJson.Append(\",\");"); sbOutputJsonContent.AppendLine(tab + "sbJson.AppendFormat(\"\\\"{0}\\\":{1}\", JsonHelper.StringToJson(\"MetaData\"), metaData.ComponentJson(asset, context, \"meta\"));"); sbSearchG2IndexedFieldsContent.Append(tab + "indexedFields.AddRange(metaData.ComponentIndexedFields(asset, context, \"meta\"));").AppendLine(); } // Tidy up foreach (PanelEntry entry in context.InputForm.GetPanels("component_panel")) { context.InputForm.Remove(entry.GetFieldName("component_processed")); } sbOutputContent.AppendLine(markup); sbOutputJsonContent.AppendLine(tab + "sbJson.Append(\"}\");"); sbOutputJsonContent.AppendLine(tab + "Out.Write(sbJson.ToString());"); /*****************END BUILDING OUTPUT & OUTPUT-JSON*****/ /*****************BEGIN BUILDING SEARCH G2**************/ sbSearchG2DeleteContent.AppendLine(tab + "var doc = new SearchG2JsonParams"); sbSearchG2DeleteContent.AppendLine(tab + "{"); sbSearchG2DeleteContent.AppendLine(tab + tab + "Id = asset.BranchId.ToString(),"); sbSearchG2DeleteContent.AppendLine(tab + tab + "Operation = SearchG2JsonParams.OperationType.Delete,"); sbSearchG2DeleteContent.AppendLine(tab + tab + "Overwrite = true"); sbSearchG2DeleteContent.AppendLine(tab + "};"); sbSearchG2DeleteContent.AppendLine(tab + "context.JsonParams.Add(doc);"); sbSearchG2InsertContent.AppendLine(tab + "var doc = new SearchG2JsonParams"); sbSearchG2InsertContent.AppendLine(tab + "{"); sbSearchG2InsertContent.AppendLine(tab + tab + "Id = asset.BranchId.ToString(),"); sbSearchG2InsertContent.AppendLine(tab + tab + "Operation = SearchG2JsonParams.OperationType.Create,"); sbSearchG2InsertContent.AppendLine(tab + tab + "Overwrite = true"); sbSearchG2InsertContent.AppendLine(tab + "};"); sbSearchG2UpdateContent.AppendLine(tab + "var doc = new SearchG2JsonParams"); sbSearchG2UpdateContent.AppendLine(tab + "{"); sbSearchG2UpdateContent.AppendLine(tab + tab + "Id = asset.BranchId.ToString(),"); sbSearchG2UpdateContent.AppendLine(tab + tab + "Operation = SearchG2JsonParams.OperationType.Update,"); sbSearchG2UpdateContent.AppendLine(tab + tab + "Overwrite = true"); sbSearchG2UpdateContent.AppendLine(tab + "};"); // Insert and Update are the same content StringBuilder sbInsertAndUpdateContent = new StringBuilder(1024); sbInsertAndUpdateContent.AppendLine(tab + "doc.Add(\"custom_i_asset_id\", AssetPropertyNames.Id);"); sbInsertAndUpdateContent.AppendLine(tab + "doc.Add(\"custom_i_template_id\", AssetPropertyNames.TemplateId);"); sbInsertAndUpdateContent.AppendLine(tab + "doc.Add(\"custom_s_template_label\", AssetPropertyNames.TemplateLabel);"); sbInsertAndUpdateContent.AppendLine(tab + "doc.Add(\"custom_dt_created\", AssetPropertyNames.CreateDate);"); sbInsertAndUpdateContent.AppendLine(tab + "doc.Add(\"custom_dt_modified\", AssetPropertyNames.ModifiedDate);"); sbInsertAndUpdateContent.AppendLine(tab + "doc.AddFixed(\"custom_dt_published\", DateTime.UtcNow.ToString(\"o\"));"); sbInsertAndUpdateContent.AppendLine(tab + "doc.Add(\"title\", AssetPropertyNames.Label);"); sbInsertAndUpdateContent.AppendLine(tab + "doc.AddFixed(\"content\", Utils.StripHtml(asset.Show()));"); sbInsertAndUpdateContent.AppendLine(tab + "doc.AddFixed(\"custom_s_slug\", asset.GetLink());"); sbInsertAndUpdateContent.AppendLine(tab + "var siteRoot = Asset.GetSiteRoot(asset);"); sbInsertAndUpdateContent.AppendLine(tab + "var siteRootId = siteRoot.IsLoaded ? siteRoot.Id : 0;"); sbInsertAndUpdateContent.AppendLine(tab + "var parents = new List<Asset>();"); sbInsertAndUpdateContent.AppendLine(tab + "var a = asset.Parent;"); sbInsertAndUpdateContent.AppendLine(tab + "while (true)"); sbInsertAndUpdateContent.AppendLine(tab + "{"); sbInsertAndUpdateContent.AppendLine(tab + tab + "parents.Add(a);"); sbInsertAndUpdateContent.AppendLine(tab + tab + "if (a.Id == siteRootId || a.FolderId == siteRootId && a.FolderId == 0) break;"); sbInsertAndUpdateContent.AppendLine(tab + tab + "a = a.Parent;"); sbInsertAndUpdateContent.AppendLine(tab + "}"); sbInsertAndUpdateContent.AppendLine(tab + "if (parents.Any())"); sbInsertAndUpdateContent.AppendLine(tab + "{"); sbInsertAndUpdateContent.AppendLine(tab + tab + "doc.AddFixed(\"custom_i_parent_cms_folder_id\", parents.First().Id.ToString());"); sbInsertAndUpdateContent.AppendLine(tab + tab + "doc.AddFixed(\"custom_is_cms_folder_id\", parents.Select(p => p.Id.ToString()));"); sbInsertAndUpdateContent.AppendLine(tab + "}"); sbInsertAndUpdateContent.AppendLine(); sbInsertAndUpdateContent.AppendLine(tab + "doc.AddFixed(\"custom_s_type\", \"" + asset.Label.Replace(" Template", "") + "\");"); sbInsertAndUpdateContent.AppendLine(tab + "doc.AddFixed(\"custom_t_json\", asset.Show(\"output_json\"));"); sbInsertAndUpdateContent.AppendLine(); sbInsertAndUpdateContent.AppendLine(tab + "var indexedFields = new List<IndexedField>();"); sbInsertAndUpdateContent.AppendLine(sbSearchG2IndexedFieldsContent.ToString()); sbInsertAndUpdateContent.AppendLine(tab + "indexedFields.ForEach(f => doc.AddFixed(f.Name, Util.ReplaceAttachments(Util.ReplaceCptInternals(asset.Raw[f.FieldName.ToLowerInvariant()]))));"); sbInsertAndUpdateContent.AppendLine(); sbInsertAndUpdateContent.AppendLine(tab + "context.JsonParams.Add(doc);"); /*****************END BUILDING SEARCH G2****************/ sbDeclare.Append(closeTag).AppendLine(); //sbImportNamespaces.Append(closeTag).AppendLine(); if (context.InputForm["meta"] == "yes" || context.InputForm["custom_js_css"] == "yes") { sbInputContent.Append(tab + "Input.NextTabbedPanel();").AppendLine(); if (context.InputForm["meta"] == "yes") { sbInputContent.Append(tab + tab + "Input.StartExpandPanel(\"Metadata\");").AppendLine(); sbInputContent.Append(tab + tab + "metaData.ComponentInput(asset, context, \"Metadata\", \"meta\");").AppendLine(); sbInputContent.Append(tab + tab + "Input.EndExpandPanel();").AppendLine(); sbPostInputContent.Append(tab + "metaData.ComponentPostInput(asset, context, \"meta\");").AppendLine(); sbOutputContent.AppendLine(); } if (context.InputForm["custom_js_css"] == "yes") { sbInputContent.Append(tab + tab + "Input.StartExpandPanel(\"Javascript and CSS references\");").AppendLine(); sbInputContent.Append(tab + tab + "headerAndJavascriptCSS.ComponentInput(asset, context, \"Metadata\", \"meta\");").AppendLine(); sbInputContent.Append(tab + tab + "Input.EndExpandPanel();").AppendLine(); sbOutputContent.AppendLine(); } } if (context.InputForm["advanced"] == "yes") { sbInputContent.Append(tab + "Input.NextTabbedPanel();").AppendLine(); //site root not configurable via the site config yet. //sbInputContent.Append(tab + tab + "Input.ShowLink(Asset.Load(\"" + siteConfig.AssetPath.ToString() + "\"), \"Edit Theme\", InputLinkType.EditTab);").AppendLine(); sbInputContent.Append(tab + tab + "Input.ShowLink(Asset.Load(\"" + asset.AssetPath.ToString() + "\"), \"Edit Template\", InputLinkType.EditTab);").AppendLine(); } if (context.InputForm["enable_tmf"] == "yes") { sbInputContent.Append(tab + "Input.NextTabbedPanel();").AppendLine(); sbInputContent.AppendLine().Append(tab + "try { ServicesTMF.Input.LoadInput(asset, context); } catch (Exception ex){}").AppendLine().AppendLine(); sbOutputContent.Append(openTag).AppendLine(); sbOutputContent.Append(tab + "try { ServicesTMF.Output.LoadOutput(asset, context); } catch (Exception ex){}").AppendLine(); sbOutputContent.Append(closeTag).AppendLine(); sbOutputChangesContent.Append(tab + "try { ServicesTMF.Output.LoadMasterAssetChanges(asset); } catch (Exception ex){}").AppendLine(); sbOutputTranslateXmlContent.Append(tab + "try { " + context.InputForm["output_translate_xml_body"] + " } catch (Exception ex){}").AppendLine(); sbPostSaveContent.Append(tab + "try { ServicesTMF.PostSave.LoadPostSave(asset, context); } catch (Exception ex){}").AppendLine(); } sbInputContent.Append(tab + "Input.EndTabbedPanel();").AppendLine(); sbInput.Append(openTag + "@ Page Language=\"C#\" Inherits=\"CrownPeak.Internal.Debug.InputInit\" " + closeTag).AppendLine(); sbInput.Append(sbDeclare.ToString()).AppendLine(); sbInput.Append(openTag).AppendLine(); sbInput.Append(sbInputContent.ToString()); sbInput.Append(closeTag).AppendLine(); sbPostInput.Append(openTag + "@ Page Language=\"C#\" Inherits=\"CrownPeak.Internal.Debug.PostInputInit\" " + closeTag).AppendLine(); sbPostInput.Append(sbDeclare.ToString()).AppendLine(); sbPostInput.Append(openTag).AppendLine(); sbPostInput.Append(sbPostInputContent.ToString()); sbPostInput.Append(closeTag).AppendLine(); sbOutput.Append(openTag + "@ Page Language=\"C#\" Inherits=\"CrownPeak.Internal.Debug.OutputInit\" " + closeTag).AppendLine(); sbOutput.Append(sbDeclare.ToString()).AppendLine(); sbOutput.Append(sbOutputContent.ToString()); if (context.InputForm["json_template"] == "yes") { sbOutputJson.Append(openTag + "@ Page Language=\"C#\" Inherits=\"CrownPeak.Internal.Debug.OutputInit\" " + closeTag).AppendLine(); sbOutputJson.Append(sbDeclare.ToString()).AppendLine(); sbOutputJson.Append(openTag).AppendLine(); sbOutputJson.Append(sbOutputJsonContent.ToString()); sbOutputJson.Append(closeTag).AppendLine(); sbSearchG2Delete.Append(openTag + "@ Page Language=\"C#\" Inherits=\"CrownPeak.Internal.Debug.SearchG2Init\" " + closeTag).AppendLine(); sbSearchG2Delete.Append(sbDeclare.ToString()).AppendLine(); sbSearchG2Delete.Append(openTag).AppendLine(); sbSearchG2Delete.Append(sbSearchG2DeleteContent.ToString()); sbSearchG2Delete.Append(closeTag).AppendLine(); sbSearchG2Insert.Append(openTag + "@ Page Language=\"C#\" Inherits=\"CrownPeak.Internal.Debug.SearchG2Init\" " + closeTag).AppendLine(); sbSearchG2Insert.Append(sbDeclare.ToString()).AppendLine(); sbSearchG2Insert.Append(openTag).AppendLine(); sbSearchG2Insert.Append(sbSearchG2InsertContent.ToString()); sbSearchG2Insert.Append(sbInsertAndUpdateContent.ToString()); sbSearchG2Insert.Append(closeTag).AppendLine(); sbSearchG2Update.Append(openTag + "@ Page Language=\"C#\" Inherits=\"CrownPeak.Internal.Debug.SearchG2Init\" " + closeTag).AppendLine(); sbSearchG2Update.Append(sbDeclare.ToString()).AppendLine(); sbSearchG2Update.Append(openTag).AppendLine(); sbSearchG2Update.Append(sbSearchG2UpdateContent.ToString()); sbSearchG2Update.Append(sbInsertAndUpdateContent.ToString()); sbSearchG2Update.Append(closeTag).AppendLine(); } else { sbOutputJson.Clear(); sbSearchG2Delete.Clear(); sbSearchG2Insert.Clear(); sbSearchG2Update.Clear(); } if (context.InputForm["enable_tmf"] == "yes") { sbOutputChanges.Append(openTag + "@ Page Language=\"C#\" Inherits=\"CrownPeak.Internal.Debug.OutputInit\" " + closeTag).AppendLine(); sbOutputChanges.Append(sbImportNamespaces.ToString()).AppendLine(); sbOutputChanges.Append(openTag).AppendLine(); sbOutputChanges.Append(sbOutputChangesContent.ToString()); sbOutputChanges.Append(closeTag).AppendLine(); sbOutputTranslateXml.Append(openTag + "@ Page Language=\"C#\" Inherits=\"CrownPeak.Internal.Debug.OutputInit\" " + closeTag).AppendLine(); sbOutputTranslateXml.Append(sbImportNamespaces.ToString()).AppendLine(); sbOutputTranslateXml.Append(openTag).AppendLine(); sbOutputTranslateXml.Append(sbOutputTranslateXmlContent.ToString()); sbOutputTranslateXml.Append(closeTag).AppendLine(); sbPostSave.Append(openTag + "@ Page Language=\"C#\" Inherits=\"CrownPeak.Internal.Debug.PostSaveInit\" " + closeTag).AppendLine(); sbPostSave.Append(sbDeclare.ToString()).AppendLine(); sbPostSave.Append(openTag).AppendLine(); sbPostSave.Append(sbPostSaveContent.ToString()); sbPostSave.Append(closeTag).AppendLine(); } else { sbOutputChanges.Clear(); sbOutputTranslateXml.Clear(); sbPostSave.Clear(); } context.InputForm["inputBody"] = sbInput.ToString(); context.InputForm["postinputBody"] = sbPostInput.ToString(); context.InputForm["outputBody"] = sbOutput.ToString(); context.InputForm["outputChangesBody"] = sbOutputChanges.ToString(); context.InputForm["outputTranslateXmlBody"] = sbOutputTranslateXml.ToString(); context.InputForm["postSaveBody"] = sbPostSave.ToString(); context.InputForm["outputJsonBody"] = sbOutputJson.ToString(); context.InputForm["searchG2DeleteBody"] = sbSearchG2Delete.ToString(); context.InputForm["searchG2InsertBody"] = sbSearchG2Insert.ToString(); context.InputForm["searchG2UpdateBody"] = sbSearchG2Update.ToString(); if (context.InputForm["create"] == "yes") { Asset folderAsset = Asset.Load(context.InputForm["template_folder"]); Asset templateAsset = Asset.Load(folderAsset.AssetPath + "/" + context.InputForm["template_name"]); // if(templateAsset.IsLoaded && String.IsNullOrEmpty(context.InputForm["override"])) // { // context.ValidationErrorFields.Add("override", "Please check this box to override existing template"); // } if (!folderAsset.IsLoaded) { context.ValidationErrorFields.Add("template_folder", "Please specify a folder to generate the template in"); } } } public static void PostSaveHelper(Asset asset, PostSaveContext context) { if (asset["create"] == "yes") { Asset folderAsset = Asset.Load(asset["template_folder"]); Asset templateAsset = Asset.Load(folderAsset.AssetPath + "/" + asset.Raw["template_name"]); Asset modelAsset = Asset.LoadDirect("/System/Templates/Basis/Template/Template C#"); Dictionary<string, string> contentFields = new Dictionary<string, string> { { "Auto created by", asset.Id.ToString() } }; if (!templateAsset.IsLoaded) { templateAsset = Asset.CreateNewAsset(asset.Raw["template_name"], folderAsset, modelAsset, contentFields); asset["templateId"] = templateAsset.Id.ToString(); asset.SaveContentField("templateId", templateAsset.Id.ToString()); var defaultTemplateFolder = Asset.Load(ComponentLibraryHelper.getComponentLibraryProjectFolder(asset).AssetPath + "/Templates/Component Framework/Template Builder Default"); if (defaultTemplateFolder.IsLoaded) { var ap = new AssetParams { ExcludeProjectTypes = false }; var defaultTemplateFiles = defaultTemplateFolder.GetFileList(ap); defaultTemplateFiles.ForEach(f => Asset.CopyAsset(f.Label, templateAsset, f)); } } if (templateAsset.IsLoaded) { folderAsset = templateAsset; modelAsset = Asset.LoadDirect("/System/Templates/Basis/ComponentsCS/input.aspx"); contentFields = new Dictionary<string, string> { { "body", asset.Raw["inputBody"] } }; Asset inputAsset = Asset.Load(folderAsset.AssetPath + "/input.aspx"); if (inputAsset.IsLoaded) { //inputAsset.Delete(); inputAsset.SaveContent(contentFields); } else { inputAsset = Asset.CreateNewAsset("input.aspx", folderAsset, modelAsset, contentFields); } modelAsset = Asset.LoadDirect("/System/Templates/Basis/ComponentsCS/post_input.aspx"); contentFields = new Dictionary<string, string> { { "body", asset.Raw["postinputBody"] } }; Asset postinputAsset = Asset.Load(folderAsset.AssetPath + "/post_input.aspx"); if (postinputAsset.IsLoaded) { postinputAsset.SaveContent(contentFields); //postinputAsset.Delete(); } else { postinputAsset = Asset.CreateNewAsset("post_input.aspx", folderAsset, modelAsset, contentFields); } modelAsset = Asset.LoadDirect("/System/Templates/Basis/ComponentsCS/output.aspx"); contentFields = new Dictionary<string, string> { { "body", asset.Raw["outputBody"] } }; Asset outputAsset = Asset.Load(folderAsset.AssetPath + "/output.aspx"); if (outputAsset.IsLoaded) { outputAsset.SaveContent(contentFields); outputAsset.SaveSource(asset.Raw["outputBody"]); //outputAsset.Delete(); } else { outputAsset = Asset.CreateNewAsset("output.aspx", folderAsset, modelAsset, contentFields); } modelAsset = Asset.LoadDirect("/System/Templates/Basis/ComponentsCS/output.aspx"); contentFields = new Dictionary<string, string> { { "body", asset.Raw["outputJsonBody"] } }; Asset outputJsonAsset = Asset.Load(folderAsset.AssetPath + "/output_json.aspx"); if (outputJsonAsset.IsLoaded) outputJsonAsset.Delete(); if (asset["json_template"] == "yes") { outputJsonAsset = Asset.CreateNewAsset("output_json.aspx", folderAsset, modelAsset, contentFields); } modelAsset = Asset.LoadDirect("/System/Templates/Basis/ComponentsCS/search_g2_delete.aspx"); if (!modelAsset.IsLoaded) modelAsset = Asset.LoadDirect("/System/Templates/Basis/ComponentsCS/output.aspx"); // DEBUG contentFields = new Dictionary<string, string> { { "body", asset.Raw["searchG2DeleteBody"] } }; Asset searchG2DeleteAsset = Asset.Load(folderAsset.AssetPath + "/search_g2_delete.aspx"); if (searchG2DeleteAsset.IsLoaded) searchG2DeleteAsset.Delete(); if (asset["json_template"] == "yes") { searchG2DeleteAsset = Asset.CreateNewAsset("search_g2_delete.aspx", folderAsset, modelAsset, contentFields); } modelAsset = Asset.LoadDirect("/System/Templates/Basis/ComponentsCS/search_g2_insert.aspx"); if (!modelAsset.IsLoaded) modelAsset = Asset.LoadDirect("/System/Templates/Basis/ComponentsCS/output.aspx"); // DEBUG contentFields = new Dictionary<string, string> { { "body", asset.Raw["searchG2InsertBody"] } }; Asset searchG2InsertAsset = Asset.Load(folderAsset.AssetPath + "/search_g2_insert.aspx"); if (searchG2InsertAsset.IsLoaded) searchG2InsertAsset.Delete(); if (asset["json_template"] == "yes") { searchG2InsertAsset = Asset.CreateNewAsset("search_g2_insert.aspx", folderAsset, modelAsset, contentFields); } modelAsset = Asset.LoadDirect("/System/Templates/Basis/ComponentsCS/search_g2_update.aspx"); if (!modelAsset.IsLoaded) modelAsset = Asset.LoadDirect("/System/Templates/Basis/ComponentsCS/output.aspx"); // DEBUG contentFields = new Dictionary<string, string> { { "body", asset.Raw["searchG2UpdateBody"] } }; Asset searchG2UpdateAsset = Asset.Load(folderAsset.AssetPath + "/search_g2_update.aspx"); if (searchG2UpdateAsset.IsLoaded) searchG2UpdateAsset.Delete(); if (asset["json_template"] == "yes") { searchG2UpdateAsset = Asset.CreateNewAsset("search_g2_update.aspx", folderAsset, modelAsset, contentFields); } if (asset["do_not_overwrite_post_save"] != "do_not_overwrite") { //Post save currently in "enable_tmf" because only used for TMF currently, should be moved out eventually modelAsset = Asset.LoadDirect("/System/Templates/Basis/ComponentsCS/post_save.aspx"); contentFields = new Dictionary<string, string> { { "body", asset.Raw["postSaveBody"] } }; Asset postSaveAsset = Asset.Load(folderAsset.AssetPath + "/post_save.aspx"); if (postSaveAsset.IsLoaded) postSaveAsset.Delete(); if (asset["enable_tmf"] == "yes") { postSaveAsset = Asset.CreateNewAsset("post_save.aspx", folderAsset, modelAsset, contentFields); } } modelAsset = Asset.LoadDirect("/System/Templates/Basis/ComponentsCS/output.aspx"); contentFields = new Dictionary<string, string> { { "body", asset.Raw["outputChangesBody"] } }; Asset outputChangesAsset = Asset.Load(folderAsset.AssetPath + "/output_changes.aspx"); if (outputChangesAsset.IsLoaded) outputChangesAsset.Delete(); if (asset["enable_tmf"] == "yes") { outputChangesAsset = Asset.CreateNewAsset("output_changes.aspx", folderAsset, modelAsset, contentFields); } modelAsset = Asset.LoadDirect("/System/Templates/Basis/ComponentsCS/output.aspx"); contentFields = new Dictionary<string, string> { { "body", asset.Raw["outputTranslateXmlBody"] } }; Asset outputTranslateXmlAsset = Asset.Load(folderAsset.AssetPath + "/output_translate_xml.aspx"); if (outputTranslateXmlAsset.IsLoaded) outputTranslateXmlAsset.Delete(); if (asset["enable_tmf"] == "yes" && asset["create_output_translate_xml"] == "yes") { outputTranslateXmlAsset = Asset.CreateNewAsset("output_translate_xml.aspx", folderAsset, modelAsset, contentFields); } } if (!String.IsNullOrEmpty(asset[asset["previewAsset"]])) { Asset previewAsset = Asset.Load(asset["previewAsset"]); previewAsset.SetTemplate(templateAsset.Id); foreach (PanelEntry entry in asset.GetPanels("layouts")) { previewAsset[entry.GetFieldName("layout")] = entry["layout"]; } previewAsset.SaveContent(); } } asset.SaveContentField("override", ""); asset.Rename(asset["template_name"]); //asset.SaveContent(); } private static string makeRaw(string content) { foreach (Match mc in Regex.Matches(content, @"~\$CPIL\$\d+\$[\w:]+\$\w+\$")) { content = content.Replace(mc.Value, "").Replace("$/CPIL$~", ""); } foreach (Match mc in Regex.Matches(content, @"%\$CPIL\$\d+\$[\w:]+\$\w+\$")) { content = content.Replace(mc.Value, "").Replace("$/CPIL$%", ""); } return content; } } } 261479 1792 /System/Templates/Basis/DeveloperCS/ 1 0 false false 0 0 /Component Project/Library/ComponentLibraryHelper.cs 261059 17 LibraryClass 2 body using System; using System.Collections.Generic; using System.Linq; using System.Text; using CrownPeak.CMSAPI; using CrownPeak.CMSAPI.Experimental; using CrownPeak.CMSAPI.Services; using System.Text.RegularExpressions; /* Some Namespaces are not allowed. */ namespace Component_Library.Component_Project.Components { public class ComponentLibraryHelper { /// <summary> /// Class variable contains the namespace for components. Is also used to specify the prefix of the .cs library file name /// </summary> public static readonly String xComponentNamespace = "Components"; /// <summary> /// Class variable contains the name of html element which encompases repeatable content. /// </summary> private static String repeatableNodeName = "cp-list"; /// <summary> /// Class variable contains the name of html element which encompases content which is only rendered in preview in the CMS. /// </summary> private static String previewOnlyNodeName = "cp-preview"; /// <summary> /// Class variable contains the name of html element which encompases content which is only rendered for output / publish purposes. /// </summary> private static String publishOnlyNodeName = "cp-publish"; /// <summary> /// Private class variable contains the newLineChars used when creating a .cs library file /// </summary> private static String newLineChar = "\r\n"; /// <summary> /// Private class variable contains the tab character used when creating a .cs library file /// </summary> private static String tabChar = "\t"; private static String defaultContentPlaceholderType = "Text"; public static String getDefaultContentPlaceholderType() { return defaultContentPlaceholderType; } private static Asset GlobalLibraryConfig; private static String[] depthList = new string[] { "component_panel", "component_panel_depth_a", "component_panel_depth_b", "component_panel_depth_c", "component_panel_depth_d" }; /// <summary> /// Private class variable which contains a list of all base component types which do not have physical assets in the CMS. /// </summary> //Now is built by retrieving the components in the base componnet folder //private static List<String> CoreComponentTypes = new List<String>() { "Wysiwyg", "Text", "Href", "Src", "Image", "Color", "Widget" }; /// <summary> /// Accessor function for the list of base component types /// </summary> /// <returns>the list of base components</returns> public static List<String> getCoreComponentTypes(Asset asset) { List<String> componentAssetTypes = new List<string>(); FilterParams fParams = new FilterParams(); fParams.ExcludeProjectTypes = false; fParams.Add(AssetPropertyNames.TemplateLabel, Comparison.IsInSet, new List<string> { "Component Definition", "Enhanced Component Definition" }); List<Asset> coreComponents = Asset.Load(componentsPath(asset) + "/core/").GetFilterList(fParams); foreach (Asset componentAsset in coreComponents) { if (!String.IsNullOrWhiteSpace(componentAsset["class_name"])) { //Out.DebugWriteLine("adding " + componentAsset["class_name"] + " to base types"); componentAssetTypes.Add(componentAsset["class_name"]); } } return componentAssetTypes; } /// <summary> /// Function returns all components in the corresponding asset's _Components folder /// </summary> /// <param name="asset">the asset for which you want to get all the available components for</param> /// <returns>a list of components available for the current asset</returns> public static List<String> getAllComponentTypes(Asset asset) { FilterParams fParams = new FilterParams(); fParams.ExcludeProjectTypes = false; fParams.Add(AssetPropertyNames.TemplateLabel, Comparison.IsInSet, new List<string> { "Component Definition", "Enhanced Component Definition" }); List<Asset> componentAssetList = Asset.Load(componentsPath(asset)).GetFilterList(fParams); List<String> componentAssetTypes = new List<string>(); foreach (Asset componentAsset in componentAssetList) { if (!String.IsNullOrWhiteSpace(componentAsset["class_name"]) /*&& !componentAssetTypes.Contains(componentAsset["class_name"])*/) { componentAssetTypes.Add(componentAsset["class_name"]); } } return componentAssetTypes; } public static Dictionary<String, String> getAllComponentTypesForDropdown(Asset asset) { FilterParams fParams = new FilterParams(); fParams.ExcludeProjectTypes = false; fParams.Add(AssetPropertyNames.TemplateLabel, Comparison.IsInSet, new List<string> { "Component Definition", "Enhanced Component Definition" }); List<Asset> componentAssetList = Asset.Load(componentsPath(asset)).GetFilterList(fParams); Dictionary<String, String> componentAssetTypes = new Dictionary<String, String>(); foreach (Asset componentAsset in componentAssetList) { if (!String.IsNullOrWhiteSpace(componentAsset["class_name"]) /*&& !componentAssetTypes.Contains(componentAsset["class_name"])*/) { componentAssetTypes.Add(componentAsset.Parent.Label + ": " + componentAsset["class_name"], componentAsset["class_name"]); } } componentAssetTypes = componentAssetTypes.OrderBy(x => x.Key).ToDictionary(x => x.Key, x => x.Value); return componentAssetTypes; } /// <summary> /// Validates the components types for a given component asset /// </summary> /// <param name="asset">the component asset to validate</param> /// <param name="context">the context of the asset to validate</param> /// <returns>an updated version of the context parameter with any applicable errors</returns> public static PostInputContext validateComponentPlaceholderNames(Asset asset, PostInputContext context) { String componentMarkup = ""; if (!String.IsNullOrWhiteSpace(context.InputForm["markup"]) && context.InputForm["markup"] != asset["markup"]) { componentMarkup = context.InputForm["markup"]; //should only be used for debugging //componentMarkup = asset["markup"]; //List<String> names = new List<string>(); List<String> validTypes = getAllComponentTypes(asset); Regex contentPlaceholderRx = getContentFieldRegex(ContentNodeType.Content); //new Regex(@"{[^=|>|<|\n|""]*}", RegexOptions.Compiled | RegexOptions.IgnoreCase); Regex listPlaceholderRx = getContentFieldRegex(ContentNodeType.ListNode); MatchCollection contentPlaceholderMatches = contentPlaceholderRx.Matches(componentMarkup); MatchCollection listPlaceholderMatches = listPlaceholderRx.Matches(componentMarkup); foreach (Match match in contentPlaceholderMatches) { //verify that content field names are not the same as list names if (listPlaceholderMatches.Cast<Match>().Any(x => getAttribValueFromComponentMarkup(x.Value, "name") == getContentPlaceholderName(match.Value))) { context.ValidationError = "The content field \"" + match.Value + "\" has the same name as a repeatable node placeholder"; } //verify that if a content type is specified it is a valid content type else if (getContentPlaceholderTypeFromMarkup(match.Value) != String.Empty && !validTypes.Contains(getContentPlaceholderTypeFromMarkup(match.Value))) { context.ValidationError = match.Value + " is of an unrecognized type. Types are case sensitive and must match the component class name exactly"; } //Verify that if a content placeholder has the same name as another content placeholder that it also has the same type //might be tricky for content placesholder without a type specified in the markup because I might not have the type at the time of this execution { } } } return context; } public static String getNextComponentPanelDepth(String currentPanel) { for (int i = 0; i < depthList.Length; i++) { if (depthList[i] == currentPanel && i < depthList.Length) { return depthList[++i]; } else if (i >= depthList.Length) { return "ERROR: Depth exceeds maximum allowable depth"; } } return "ERROR: Depth not found"; } public static void deleteExistingContentFieldsForComponents(ref List<ComponentContentPlaceholder> assetContentPlaceholdersList, List<ComponentContentPlaceholder> markupContentPlaceholdersList) { List<ComponentContentPlaceholder> updatedAssetContentPlaceholderList = new List<ComponentContentPlaceholder>(); //GO THROUGH ASSET AND IF A COMPONENT WITH THAT LABEL AND CATEGORY DOES NOT EXIST IN MARKUP DELETE IT foreach (ComponentContentPlaceholder assetContentPlaceholder in assetContentPlaceholdersList) { String name = assetContentPlaceholder.name; ContentPlaceholderCategory category = assetContentPlaceholder.category; //if (existsInComponentContentPlaceholderList(name, category, markupContentPlaceholdersList)) ComponentContentPlaceholder markupMatch = markupContentPlaceholdersList.FirstOrDefault(x => x.name == name && x.category == category); if (markupMatch != null) { ComponentContentPlaceholder tempNewComponentContentPlaceholder = assetContentPlaceholder; if (tempNewComponentContentPlaceholder.category == ContentPlaceholderCategory.List) { tempNewComponentContentPlaceholder.subComponents = deleteExistingContentFieldsForComponentsHelper(assetContentPlaceholder.subComponents, markupMatch.subComponents); } updatedAssetContentPlaceholderList.Add(tempNewComponentContentPlaceholder); } } assetContentPlaceholdersList = updatedAssetContentPlaceholderList; } public static List<ComponentContentPlaceholder> deleteExistingContentFieldsForComponentsHelper(List<ComponentContentPlaceholder> assetContentPlaceholdersList, List<ComponentContentPlaceholder> markupContentPlaceholdersList) { List<ComponentContentPlaceholder> updatedAssetContentPlaceholderList = new List<ComponentContentPlaceholder>(); //GO THROUGH ASSET AND IF A COMPONENT WITH THAT LABEL AND CATEGORY DOES NOT EXIST IN MARKUP DELETE IT foreach (ComponentContentPlaceholder assetContentPlaceholder in assetContentPlaceholdersList) { String name = assetContentPlaceholder.name; ContentPlaceholderCategory category = assetContentPlaceholder.category; //if (existsInComponentContentPlaceholderList(name, category, markupContentPlaceholdersList)) ComponentContentPlaceholder markupMatch = markupContentPlaceholdersList.FirstOrDefault(x => x.name == assetContentPlaceholder.name && x.category == assetContentPlaceholder.category); if (markupMatch != null) { ComponentContentPlaceholder tempNewComponentContentPlaceholder = assetContentPlaceholder; if (tempNewComponentContentPlaceholder.category == ContentPlaceholderCategory.List) { tempNewComponentContentPlaceholder.subComponents = deleteExistingContentFieldsForComponentsHelper(assetContentPlaceholder.subComponents, markupMatch.subComponents); } updatedAssetContentPlaceholderList.Add(tempNewComponentContentPlaceholder); } } return updatedAssetContentPlaceholderList; } public static bool existsInComponentContentPlaceholderList(String name, ContentPlaceholderCategory category, List<ComponentContentPlaceholder> componentContentPlaceholderList) { return findInComponentContentPlaceholderList(name, category, componentContentPlaceholderList) != null; } public static ComponentContentPlaceholder findInComponentContentPlaceholderList(String name, ContentPlaceholderCategory category, List<ComponentContentPlaceholder> componentContentPlaceholderList) { ComponentContentPlaceholder match = null; List<ComponentContentPlaceholder> flattenedList = flattenComponentContentPlaceholderList(componentContentPlaceholderList); return flattenedList.FirstOrDefault(x => x.name == name && x.category == category); //if (componentContentPlaceholderList != null) //{ // foreach (ComponentContentPlaceholder ccp in componentContentPlaceholderList) // { // if (ccp.name == name && category == ccp.category) // { // return ccp; // } // else if(ccp.category == ContentPlaceholderCategory.List) // { // match = findInComponentContentPlaceholderList(name, category, ccp.subComponents); // } // } //} //return match; } public static List<ComponentContentPlaceholder> flattenComponentContentPlaceholderList(List<ComponentContentPlaceholder> componentContentPlaceholderList) { List<ComponentContentPlaceholder> newList = new List<ComponentContentPlaceholder>(); foreach (ComponentContentPlaceholder ccp in componentContentPlaceholderList) { newList.Add(ccp); if (ccp.category == ContentPlaceholderCategory.List) { newList.AddRange(flattenComponentContentPlaceholderList(ccp.subComponents)); } } return newList; } public static void updateExistingContentFields(ref List<ComponentContentPlaceholder> assetContentPlaceholdersList, List<ComponentContentPlaceholder> markupContentPlaceholdersList) { foreach (ComponentContentPlaceholder assetContentPlaceholder in assetContentPlaceholdersList) { String name = assetContentPlaceholder.name; ContentPlaceholderCategory category = assetContentPlaceholder.category; ComponentContentPlaceholder markupMatch = findInComponentContentPlaceholderList(name, category, markupContentPlaceholdersList); if (markupMatch != null) { if (markupMatch.category == ContentPlaceholderCategory.Component) { if (markupMatch.typeInMarkup) { assetContentPlaceholder.typeInMarkup = markupMatch.typeInMarkup; assetContentPlaceholder.type = markupMatch.type; } else { assetContentPlaceholder.typeInMarkup = false; //if there is no type currently specified in the asset's content then set as default type if (String.IsNullOrWhiteSpace(assetContentPlaceholder.type)) { assetContentPlaceholder.type = getDefaultContentPlaceholderType(); } } assetContentPlaceholder.fieldIndexed = markupMatch.fieldIndexed; } else if (markupMatch.category == ContentPlaceholderCategory.List) { assetContentPlaceholder.content = markupMatch.content; assetContentPlaceholder.components = markupMatch.components; assetContentPlaceholder.subComponents = updateExistingContentFieldsHelper(assetContentPlaceholder.subComponents, markupContentPlaceholdersList); } } } } public static List<ComponentContentPlaceholder> updateExistingContentFieldsHelper(List<ComponentContentPlaceholder> assetContentPlaceholdersList, List<ComponentContentPlaceholder> markupContentPlaceholdersList) { foreach (ComponentContentPlaceholder assetContentPlaceholder in assetContentPlaceholdersList) { String name = assetContentPlaceholder.name; ContentPlaceholderCategory category = assetContentPlaceholder.category; ComponentContentPlaceholder markupMatch = findInComponentContentPlaceholderList(name, category, markupContentPlaceholdersList); if (markupMatch != null) { if (markupMatch.category == ContentPlaceholderCategory.Component) { if (markupMatch.typeInMarkup) { assetContentPlaceholder.typeInMarkup = markupMatch.typeInMarkup; assetContentPlaceholder.type = markupMatch.type; } else { assetContentPlaceholder.typeInMarkup = false; //if there is no type currently specified in the asset's content then set as default type if (String.IsNullOrWhiteSpace(assetContentPlaceholder.type)) { assetContentPlaceholder.type = getDefaultContentPlaceholderType(); } } } else if (markupMatch.category == ContentPlaceholderCategory.List) { assetContentPlaceholder.content = markupMatch.content; assetContentPlaceholder.components = markupMatch.components; assetContentPlaceholder.subComponents = updateExistingContentFieldsHelper(assetContentPlaceholder.subComponents, markupContentPlaceholdersList); } } } return assetContentPlaceholdersList; } public static void createContentFieldsForComponents(ref List<ComponentContentPlaceholder> assetContentPlaceholdersList, List<ComponentContentPlaceholder> markupContentPlaceholdersList, List<ComponentContentPlaceholder> flattenedAssetcontentPlaceholders) { foreach (ComponentContentPlaceholder markupPlaceholder in markupContentPlaceholdersList) { if (!assetContentPlaceholdersList.Any(x => x.name == markupPlaceholder.name && x.category == markupPlaceholder.category)) { ComponentContentPlaceholder contentPlaceholderToAdd = markupPlaceholder; ComponentContentPlaceholder flattenedAssetContentPlaceholderMatch = flattenedAssetcontentPlaceholders.FirstOrDefault(x => x.name == contentPlaceholderToAdd.name && x.category == contentPlaceholderToAdd.category); if (flattenedAssetContentPlaceholderMatch != null) { contentPlaceholderToAdd.message = flattenedAssetContentPlaceholderMatch.message; contentPlaceholderToAdd.messageType = flattenedAssetContentPlaceholderMatch.messageType; contentPlaceholderToAdd.inputLabel = flattenedAssetContentPlaceholderMatch.inputLabel; contentPlaceholderToAdd.inputLabelType = flattenedAssetContentPlaceholderMatch.inputLabelType; if (contentPlaceholderToAdd.category == ContentPlaceholderCategory.List) { contentPlaceholderToAdd.maxPanels = flattenedAssetContentPlaceholderMatch.maxPanels; contentPlaceholderToAdd.minPanels = flattenedAssetContentPlaceholderMatch.minPanels; contentPlaceholderToAdd.subComponents = createContentFieldsForComponentsSubListHelper(contentPlaceholderToAdd.subComponents, flattenedAssetcontentPlaceholders); } else { contentPlaceholderToAdd.isRequired = flattenedAssetContentPlaceholderMatch.isRequired; contentPlaceholderToAdd.isRequiredMessage = flattenedAssetContentPlaceholderMatch.isRequiredMessage; contentPlaceholderToAdd.hardcodedSnippet = flattenedAssetContentPlaceholderMatch.hardcodedSnippet; contentPlaceholderToAdd.fieldIndexed = flattenedAssetContentPlaceholderMatch.fieldIndexed; } } assetContentPlaceholdersList.Add(markupPlaceholder); } else { if (markupPlaceholder.category == ContentPlaceholderCategory.List) { for (int x = 0; x < assetContentPlaceholdersList.Count; x++) { if (assetContentPlaceholdersList[x].name == markupPlaceholder.name && assetContentPlaceholdersList[x].category == markupPlaceholder.category) { assetContentPlaceholdersList[x].subComponents = createContentFieldsForComponentsHelper(assetContentPlaceholdersList[x].subComponents, markupPlaceholder.subComponents, flattenedAssetcontentPlaceholders); } } } } } } public static List<ComponentContentPlaceholder> createContentFieldsForComponentsSubListHelper(List<ComponentContentPlaceholder> contentPlaceholderSubList, List<ComponentContentPlaceholder> flattenedAssetcontentPlaceholders) { foreach (ComponentContentPlaceholder subItem in contentPlaceholderSubList) { ComponentContentPlaceholder flattenedAssetContentPlaceholderMatch = flattenedAssetcontentPlaceholders.FirstOrDefault(x => x.name == subItem.name && x.category == subItem.category); if (flattenedAssetContentPlaceholderMatch != null) { subItem.message = flattenedAssetContentPlaceholderMatch.message; subItem.messageType = flattenedAssetContentPlaceholderMatch.messageType; subItem.inputLabel = flattenedAssetContentPlaceholderMatch.inputLabel; subItem.inputLabelType = flattenedAssetContentPlaceholderMatch.inputLabelType; if (subItem.category == ContentPlaceholderCategory.List) { subItem.maxPanels = flattenedAssetContentPlaceholderMatch.maxPanels; subItem.minPanels = flattenedAssetContentPlaceholderMatch.minPanels; subItem.subComponents = createContentFieldsForComponentsSubListHelper(subItem.subComponents, flattenedAssetcontentPlaceholders); } else { subItem.isRequired = flattenedAssetContentPlaceholderMatch.isRequired; subItem.isRequiredMessage = flattenedAssetContentPlaceholderMatch.isRequiredMessage; subItem.fieldIndexed = flattenedAssetContentPlaceholderMatch.fieldIndexed; } } } return contentPlaceholderSubList; } public static List<ComponentContentPlaceholder> createContentFieldsForComponentsHelper(List<ComponentContentPlaceholder> assetContentPlaceholdersList, List<ComponentContentPlaceholder> markupContentPlaceholdersList, List<ComponentContentPlaceholder> flattenedAssetcontentPlaceholders) { foreach (ComponentContentPlaceholder markupPlaceholder in markupContentPlaceholdersList) { if (!assetContentPlaceholdersList.Any(x => x.name == markupPlaceholder.name && x.category == markupPlaceholder.category)) { ComponentContentPlaceholder contentPlaceholderToAdd = markupPlaceholder; ComponentContentPlaceholder flattenedAssetContentPlaceholderMatch = flattenedAssetcontentPlaceholders.FirstOrDefault(x => x.name == contentPlaceholderToAdd.name && x.category == contentPlaceholderToAdd.category); if (flattenedAssetContentPlaceholderMatch != null) { contentPlaceholderToAdd.message = flattenedAssetContentPlaceholderMatch.message; contentPlaceholderToAdd.messageType = flattenedAssetContentPlaceholderMatch.messageType; contentPlaceholderToAdd.inputLabel = flattenedAssetContentPlaceholderMatch.inputLabel; contentPlaceholderToAdd.inputLabelType = flattenedAssetContentPlaceholderMatch.inputLabelType; if (contentPlaceholderToAdd.category == ContentPlaceholderCategory.List) { contentPlaceholderToAdd.maxPanels = flattenedAssetContentPlaceholderMatch.maxPanels; contentPlaceholderToAdd.minPanels = flattenedAssetContentPlaceholderMatch.minPanels; contentPlaceholderToAdd.subComponents = createContentFieldsForComponentsSubListHelper(contentPlaceholderToAdd.subComponents, flattenedAssetcontentPlaceholders); } else { contentPlaceholderToAdd.isRequired = flattenedAssetContentPlaceholderMatch.isRequired; contentPlaceholderToAdd.isRequiredMessage = flattenedAssetContentPlaceholderMatch.isRequiredMessage; contentPlaceholderToAdd.hardcodedSnippet = flattenedAssetContentPlaceholderMatch.hardcodedSnippet; contentPlaceholderToAdd.fieldIndexed = flattenedAssetContentPlaceholderMatch.fieldIndexed; } } assetContentPlaceholdersList.Add(markupPlaceholder); } else { if (markupPlaceholder.category == ContentPlaceholderCategory.List) { for (int x = 0; x < assetContentPlaceholdersList.Count; x++) { if (assetContentPlaceholdersList[x].name == markupPlaceholder.name && assetContentPlaceholdersList[x].category == markupPlaceholder.category) { assetContentPlaceholdersList[x].subComponents = createContentFieldsForComponentsHelper(assetContentPlaceholdersList[x].subComponents, markupPlaceholder.subComponents, flattenedAssetcontentPlaceholders); } } } } } return assetContentPlaceholdersList; } /// <summary> /// Delets any content fields that no longer exist in the markup of the component asset. /// </summary> /// <param name="asset">The component asset</param> public static void old_deleteExistingContentFieldsForComponents(ref Asset asset) { Out.DebugWriteLine("Begin deleteExistingContentFieldsForComponents()..."); Dictionary<String, String> currentContentFieldLabels = asset.GetContent().Where(x => x.Key.StartsWith("component_component_label") || x.Key.StartsWith("component_list_label")).ToDictionary(x => x.Key, x => x.Value); List<String> contentFieldsToDelete = new List<string>(); Regex rxContent = getContentFieldRegex(ContentNodeType.Content); Regex rxList = getContentFieldRegex(ContentNodeType.ListNode); MatchCollection contentMatches = rxContent.Matches(asset["markup"]); List<String> matches = new List<string>(); foreach (Match cm in contentMatches) { matches.Add(getContentPlaceholderName(cm.Value)); } MatchCollection listMatches = rxList.Matches(asset["markup"]); foreach (Match lm in listMatches) { matches.Add(getAttribValueFromComponentMarkup(lm.Value, "name")); } Out.DebugWriteLine("{0} matches found....", matches.Count); //FOR EACH CONTENT FIELD... foreach (String fieldLabelKey in currentContentFieldLabels.Keys) { //IF NO CONENT FIELD IN THE MARKUP MATCHES THE CURRENT CONTENT FIELD VALUE... if (!matches.Any(x => x == currentContentFieldLabels[fieldLabelKey])) { //Out.DebugWriteLine(fieldLabelKey); if (fieldLabelKey.Contains(":")) { int componentIndex = getContentFieldIndex(fieldLabelKey); //Out.DebugWriteLine("componentIndex: " + componentIndex); List<String> temp = asset.GetContent().Where(x => x.Key.StartsWith("component_") && getContentFieldIndex(x.Key) == componentIndex).Select(x => x.Key).ToList(); Out.DebugWriteLine("Deleting Content Fields..."); foreach (String s in temp) { Out.DebugWriteLine(s); } Out.DebugWriteLine("End deleted content fields"); asset.DeleteContentFields(temp); } else { //case for where it is the only content field. List<String> temp = asset.GetContent().Where(x => x.Key.StartsWith("component_")).Select(x => x.Key).ToList(); asset.DeleteContentFields(temp); } } } Out.DebugWriteLine("deleteExistingContentFieldsForComponents()... COMPLETED!"); } /// <summary> /// Consildates the remaining content fields after the deleteExistingContentFieldsForComponents function is called. /// </summary> /// <param name="asset">The component asset</param> /// <returns>returns the index of the panel that was last created during consolidation</returns> public static int old_consolidateCurrentContentFields(ref Asset asset) { Out.DebugWriteLine("Begin consolidateCurrentContentFields()..."); int count = 1; Dictionary<String, String> currentContentFieldLabels = asset.GetContent().Where(x => x.Key.StartsWith("component_panel")).ToDictionary(x => x.Key, x => x.Value); if (currentContentFieldLabels.Keys.Count == 1) { String panelKey = currentContentFieldLabels.Keys.First(); Out.DebugWriteLine("Only one existing content field found= " + panelKey + " : " + currentContentFieldLabels[panelKey]); bool moreThenOneComponentInMarkup = (getTotalComponentCount(asset["markup"]) > 1); if (panelKey.Contains(":")) { if (moreThenOneComponentInMarkup) { Dictionary<String, String> fieldsToRemove = asset.GetContent().Where(x => x.Key.StartsWith("component_")).ToDictionary(x => x.Key, x => x.Value); Dictionary<String, String> fieldsToCreate = new Dictionary<string, string>(); foreach (String fieldToRemoveKey in fieldsToRemove.Keys) { if (fieldToRemoveKey.StartsWith("component_panel")) { //special case where we need to set the value to 0 as it is the only panel fieldsToCreate.Add(fieldToRemoveKey.Substring(0, fieldToRemoveKey.LastIndexOf(":") + 1) + "1", "0"); } else { //creates a new field with the same value but with the index set to 1 fieldsToCreate.Add(fieldToRemoveKey.Substring(0, fieldToRemoveKey.LastIndexOf(":") + 1) + "1", fieldsToRemove[fieldToRemoveKey]); } } displayContent(fieldsToRemove); asset.DeleteContentFields(fieldsToRemove.Keys.ToList()); asset.SaveContent(fieldsToCreate); count++; } else { int contentFieldIndex = getContentFieldIndex(panelKey); Dictionary<String, String> fieldsToRemove = asset.GetContent().Where(x => x.Key.StartsWith("component_") && getContentFieldIndex(x.Key) == contentFieldIndex).ToDictionary(x => x.Key, x => x.Value); Dictionary<String, String> fieldsToCreate = new Dictionary<string, string>(); foreach (String fieldToRemoveKey in fieldsToRemove.Keys) { if (fieldToRemoveKey.StartsWith("component_panel")) { //special case where we need to set the value to 0 as it is the only panel fieldsToCreate.Add(fieldToRemoveKey.Substring(0, fieldToRemoveKey.LastIndexOf(":")), "0"); } else { //creates a new field with the same value but with the :# removed from the key fieldsToCreate.Add(fieldToRemoveKey.Substring(0, fieldToRemoveKey.LastIndexOf(":")), fieldsToRemove[fieldToRemoveKey]); } } displayContent(fieldsToRemove); asset.DeleteContentFields(fieldsToRemove.Keys.ToList()); asset.SaveContent(fieldsToCreate); count++; } } else if (moreThenOneComponentInMarkup) { Dictionary<String, String> fieldsToRemove = asset.GetContent().Where(x => x.Key.StartsWith("component_")).ToDictionary(x => x.Key, x => x.Value); Dictionary<String, String> fieldsToCreate = new Dictionary<string, string>(); foreach (String fieldToRemoveKey in fieldsToRemove.Keys) { if (fieldToRemoveKey.StartsWith("component_panel")) { //special case where we need to set the value to 0 as it is the only panel fieldsToCreate.Add(fieldToRemoveKey + ":" + "1", "0"); } else { //creates a new field with the same value but with the :# removed from the key fieldsToCreate.Add(fieldToRemoveKey + ":" + "1", fieldsToRemove[fieldToRemoveKey]); } } displayContent(fieldsToRemove); asset.DeleteContentFields(fieldsToRemove.Keys.ToList()); asset.SaveContent(fieldsToCreate); count++; } } else { foreach (String panelKey in currentContentFieldLabels.Keys) { Out.DebugWriteLine("Current conent field: " + panelKey); if (getContentFieldIndex(panelKey) == count) { count++; } else { if (panelKey.Contains(":")) { int contentFieldIndex = getContentFieldIndex(panelKey); Dictionary<String, String> fieldsToRemove = asset.GetContent().Where(x => x.Key.StartsWith("component_") && getContentFieldIndex(x.Key) == contentFieldIndex).ToDictionary(x => x.Key, x => x.Value); Dictionary<String, String> fieldsToCreate = new Dictionary<string, string>(); foreach (String fieldToRemoveKey in fieldsToRemove.Keys) { if (fieldToRemoveKey.StartsWith("component_panel")) { //special case where we need to set the value to 0 as it is the only panel fieldsToCreate.Add(fieldToRemoveKey.Substring(0, fieldToRemoveKey.LastIndexOf(":") + 1) + count.ToString(), (count - 1).ToString()); } else { //creates a new field with the same value but with the :# removed from the key fieldsToCreate.Add(fieldToRemoveKey.Substring(0, fieldToRemoveKey.LastIndexOf(":") + 1) + count.ToString(), fieldsToRemove[fieldToRemoveKey]); } } displayContent(fieldsToRemove); asset.DeleteContentFields(fieldsToRemove.Keys.ToList()); asset.SaveContent(fieldsToCreate); count++; } else { Dictionary<String, String> fieldsToRemove = asset.GetContent().Where(x => x.Key.StartsWith("component_")).ToDictionary(x => x.Key, x => x.Value); Dictionary<String, String> fieldsToCreate = new Dictionary<string, string>(); foreach (String fieldToRemoveKey in fieldsToRemove.Keys) { if (fieldToRemoveKey.StartsWith("component_panel")) { //special case where we need to set the value to 0 as it is the only panel fieldsToCreate.Add(fieldToRemoveKey + ":" + count.ToString(), (count - 1).ToString()); } else { //creates a new field with the same value but with the :# removed from the key fieldsToCreate.Add(fieldToRemoveKey + ":" + count.ToString(), fieldsToRemove[fieldToRemoveKey]); } } displayContent(fieldsToRemove); asset.DeleteContentFields(fieldsToRemove.Keys.ToList()); asset.SaveContent(fieldsToCreate); count++; } } } } Out.DebugWriteLine("consolidateCurrentContentFields()... COMPLETED!"); return count; } /// <summary> /// Constructs the component's class file name using the parameters /// </summary> /// <param name="type">Specifies if you want the base class file or the override class file name</param> /// <param name="componentClassName">The component's name in class case</param> /// <returns>the component's class file name</returns> public static String createComponentClassFileName(String componentClassName, ComponentClassNameType type) { return xComponentNamespace + "_" + componentClassName + (type == ComponentClassNameType.Base ? "Base" : "") + ".cs"; } /// <summary> /// Function delets the code file of the corresponding component asset. /// </summary> /// <param name="asset">The component asset for which the corresponding code file should be deleted</param> public static void deleteCodeFile(Asset asset) { Asset componentLibraryClassFolder = getComponentLibraryClassFolder(asset); String codeFileName = createComponentClassFileName(asset["class_name"], ComponentClassNameType.Base); FilterParams fParams = new FilterParams(); fParams.ExcludeProjectTypes = false; fParams.Add(AssetPropertyNames.Label, Comparison.Equals, codeFileName); List<Asset> matchingCodeFiles = componentLibraryClassFolder.GetFilterList(fParams); if (matchingCodeFiles.Count < 1) { Out.DebugWriteLine("No matching class files found for component \"" + codeFileName + "\""); } else if (matchingCodeFiles.Count > 1) { Out.DebugWriteLine("Multiple matching code files found..."); foreach (Asset mcf in matchingCodeFiles) { Out.DebugWriteLine(mcf.AssetPath.ToString()); } } else { Asset libraryFile = matchingCodeFiles[0]; //Regex rx = new Regex(@"_v[0-9]*\.cs$"); //MatchCollection matches = rx.Matches(libraryFile.Label); //if (matches.Count != 1) //{ //Out.DebugWriteLine("Should delete but just renaming for testing purposes..."); //Out.DebugWriteLine("no version number detected... starting from _v1"); //libraryFile.Rename(libraryFile.Label.Substring(0, libraryFile.Label.LastIndexOf(".")) + "_v1.cs"); libraryFile.Delete(); //} //else //{ //String versionString = matches[0].Value; //int versionNumber = Convert.ToInt32(versionString.Substring(2, versionString.Length - 2)); //Out.DebugWriteLine("Should delete but just renaming for testing purposes..."); //libraryFile.Rename(libraryFile.Label.Substring(0, libraryFile.Label.LastIndexOf(".")) + "_v" + (++versionNumber).ToString() + ".cs"); //libraryFile.Delete(); //} } } /// <summary> /// Creates a library code file using the provided component asset /// </summary> /// <param name="asset">The component asset for which a corresponding code file should be created</param> /// /// <param name="recompileSuccessful">Used to verify if the library code file is compiled </param> /// <returns></returns> public static Asset createCodeFile(Asset asset, bool deferCompilation, ref bool recompileSuccessful, String currentPanelName = "") { #region initializations Asset componentLibraryConfig = getComponentLibraryConfig(asset); Asset componentLibraryClassFolder = getComponentLibraryClassFolder(asset); String componentLibraryNamespace = getComponentLibraryNamespace(asset); String className = asset["class_name"]; currentPanelName = currentPanelName == "" ? "component_panel" : currentPanelName; StringBuilder childComponentInitialization = new StringBuilder(); StringBuilder childComponents = new StringBuilder(); StringBuilder inputFunctionCode = new StringBuilder(); StringBuilder inputHelperFunctionCode = new StringBuilder(); StringBuilder postInputFunctionCode = new StringBuilder(); StringBuilder postInputHelperFunctionCode = new StringBuilder(); StringBuilder outputFunctionCode = new StringBuilder(); StringBuilder outputHelperFunctionCode = new StringBuilder(); StringBuilder jsonFunctionCode = new StringBuilder(); StringBuilder jsonHelperFunctionCode = new StringBuilder(); StringBuilder indexedFieldsFunctionCode = new StringBuilder(); List<PanelEntry> componentPanels = asset.GetPanels("component_panel"); int listCount = 0; #endregion var createJsonComponent = asset.Raw["json_component"] == "yes"; // Changed 2020-10-08 issue #57, specify field names in all JSON output var isSingleList = false; // componentPanels.Count == 1 && componentPanels[0]["component_category"] != "component"; if (!isSingleList) { jsonFunctionCode.AppendFormat(moarTabs(3) + "sbJson.Append(\"{{\");{0}", newLineChar); } for (int index = 0; index < componentPanels.Count; index++) { PanelEntry pe = componentPanels[index]; if (index > 0) jsonFunctionCode.AppendFormat(moarTabs(3) + "sbJson.Append(\",\");{0}", newLineChar); if (pe["component_category"] == "component") { #region component logic String fieldName = pe["component_component_label"]; String fieldLabelOverride = pe["component_component_input_label"]; String requiredMessage = pe["component_component_required_message"]; String fieldType = pe["component_component_type"]; String fieldIndexed = pe["component_component_indexed"]; String wrapInControlGroup = pe["component_component_form_override_type"]; String messageContent = pe["component_component_message_content"]; String messageType = pe["component_component_message_type"]; if (string.IsNullOrWhiteSpace(messageType)) messageType = "basic"; String codeSnippet = String.IsNullOrWhiteSpace(pe["component_component_hardcoded_snippet"]) ? "\"\"" : pe["component_component_hardcoded_snippet"]; String componentHtml = getContentPlaceholderMarkup(fieldName, ContentNodeType.Content, asset["markup"]); if (fieldType != "Code") { //DECLARATION CODE childComponents.AppendFormat(moarTabs(2) + "public {0} {1} {{ get; set; }}{2}", fieldType, fieldName, newLineChar); //INITIALIZATION CODE childComponentInitialization.AppendFormat(moarTabs(3) + "{0} = new {1}();{2}", fieldName, fieldType, newLineChar); //INPUT CODE if (getCoreComponentTypes(asset).Contains(fieldType)) { if (!String.IsNullOrWhiteSpace(messageContent)) { inputFunctionCode.AppendFormat(moarTabs(3) + "Input.ShowMessage(\"{0}\", MessageType.{1});{2}", messageContent, labelize(messageType), newLineChar); } if (fieldType != "Code") { inputFunctionCode.AppendFormat( moarTabs(3) + "this.{0}.ComponentInput(asset, context, label + \" {1}\", name + \"_{2}\");{3}", fieldName, String.IsNullOrWhiteSpace(fieldLabelOverride) ? labelize(fieldName) : fieldLabelOverride, fieldName.ToLower(), newLineChar); } } else { if (wrapInControlGroup == "control_group") { inputFunctionCode.AppendFormat(moarTabs(3) + "Input.StartControlPanel(\"{0}\");{1}", fieldLabelOverride, newLineChar); if (!String.IsNullOrWhiteSpace(messageContent)) { inputFunctionCode.AppendFormat(moarTabs(3) + "Input.ShowMessage(\"{0}\", MessageType.{1});{2}", messageContent, labelize(messageType), newLineChar); } inputFunctionCode.AppendFormat(moarTabs(3) + "this.{0}.ComponentInput(asset, context, label, name + \"_{1}\");{2}", fieldName, fieldName.ToLower(), newLineChar); inputFunctionCode.AppendFormat(moarTabs(3) + "Input.EndControlPanel();"); } else { if (!String.IsNullOrWhiteSpace(messageContent)) { inputFunctionCode.AppendFormat(moarTabs(3) + "Input.ShowMessage(\"{0}\", MessageType.{1});{2}", messageContent, labelize(messageType), newLineChar); } inputFunctionCode.AppendFormat(moarTabs(3) + "this.{0}.ComponentInput(asset, context, label + \" {1}\", name + \"_{2}\");{3}", fieldName, fieldLabelOverride.Trim(), fieldName.ToLower(), newLineChar); } } //POST_INPUT CODE #region post_input code if (fieldType != "Code") { if (pe["component_component_required"] == "yes") { //special case for image because Image class has a _image sufix. Should fix but will need to update all current content because it will break. if (fieldType == "Src") { postInputFunctionCode.AppendFormat(moarTabs(3) + "if (String.IsNullOrWhiteSpace(context.InputForm[name + \"_{0}_image\" + index])) {{ context.ValidationErrorFields.Add(name + \"_{0}_image\" + index, \"{1}\"); }} {2}", fieldName.ToLower(), requiredMessage, newLineChar); } else if (fieldType == "Href") { postInputFunctionCode.AppendFormat(moarTabs(3) + "if (context.InputForm[name + \"_{0}_link_type\" + index] == \"Internal\"){1}", fieldName.ToLower(), newLineChar); postInputFunctionCode.AppendFormat(moarTabs(3) + "{{ {0}", newLineChar); postInputFunctionCode.AppendFormat(moarTabs(4) + "if (String.IsNullOrWhiteSpace(context.InputForm[name + \"_{0}_link_internal\" + index])) {{ context.ValidationErrorFields.Add(name + \"_{0}_link_internal\" + index, \"{1}\"); }} {2}", fieldName.ToLower(), requiredMessage, newLineChar); postInputFunctionCode.AppendFormat(moarTabs(3) + "}} {0}", newLineChar); postInputFunctionCode.AppendFormat(moarTabs(3) + "if (context.InputForm[name + \"_{0}_link_type\" + index] == \"External\"){1}", fieldName.ToLower(), newLineChar); postInputFunctionCode.AppendFormat(moarTabs(3) + "{{ {0}", newLineChar); postInputFunctionCode.AppendFormat(moarTabs(4) + "if (String.IsNullOrWhiteSpace(context.InputForm[name + \"_{0}_link_external\" + index])) {{ context.ValidationErrorFields.Add(name + \"_{0}_link_external\" + index, \"{1}\"); }} {2}", fieldName.ToLower(), requiredMessage, newLineChar); postInputFunctionCode.AppendFormat(moarTabs(3) + "}} {0}", newLineChar); } else { postInputFunctionCode.AppendFormat(moarTabs(3) + "if (String.IsNullOrWhiteSpace(context.InputForm[name + \"_{0}\" + index])) {{ context.ValidationErrorFields.Add(name + \"_{0}\" + index, \"{1}\"); }} {2}", fieldName.ToLower(), requiredMessage, newLineChar); } } if (!ComponentLibraryHelper.getCoreComponentTypes(asset).Contains(fieldType)) { postInputFunctionCode.AppendFormat(moarTabs(3) + "this.{0}.ComponentPostInput(asset, context, name + \"_{0}\" + index);{1}", fieldName, newLineChar); } } #endregion //OUTPUT CODE outputFunctionCode.AppendFormat(moarTabs(3) + "sbContent.Replace(@\"{3}\", this.{0}.ComponentOutput(asset, context, name + \"_{1}\", index, isDrag));{2}", fieldName, fieldName.ToLower(), newLineChar, componentHtml.Replace("\"", "\"\"")); //JSON CODE jsonFunctionCode.AppendFormat(moarTabs(3) + "sbJson.AppendFormat(\"\\\"{{0}}\\\":{{1}}\", JsonHelper.StringToJson(\"{0}\"), this.{0}.ComponentJson(asset, context, name + \"_{1}\", index));{2}", fieldName, fieldName.ToLower(), newLineChar); //INDEXED FIELDS CODE indexedFieldsFunctionCode.AppendFormat(moarTabs(3) + "fields.AddRange(this.{0}.ComponentIndexedFields(asset, context, name + \"_{1}\", index));{2}", fieldName, fieldName.ToLower(), newLineChar); if (!string.IsNullOrWhiteSpace(fieldIndexed)) { indexedFieldsFunctionCode.AppendFormat(moarTabs(3) + "fields.Add(new IndexedField(SearchG2FieldType.{0}, name + \"_{1}\" + index));{2}", fieldIndexed, fieldName.ToLower(), newLineChar); } } else { outputFunctionCode.AppendFormat("{0}sbContent.Replace(@\"{1}\", {2});{3}", moarTabs(3), componentHtml.Replace("\"", "\"\""), codeSnippet, newLineChar); jsonFunctionCode.AppendFormat(moarTabs(3) + "sbJson.AppendFormat(\"\\\"{{0}}\\\":{{1}}\", JsonHelper.StringToJson(\"{0}\"), JsonHelper.StringToJson({1}, includeQuotes: true));{2}", fieldName, codeSnippet, newLineChar); } #endregion } else /*is list*/ { #region list logic String listLabel = pe["component_list_label"]; String minPanels = String.IsNullOrWhiteSpace(pe["min_panels"]) ? "null" : pe["min_panels"]; String maxPanels = String.IsNullOrWhiteSpace(pe["max_panels"]) ? "null" : pe["max_panels"]; String listMessageContent = pe["component_list_message_content"]; String listMessageType = pe["component_list_message_type"]; if (string.IsNullOrWhiteSpace(listMessageType)) listMessageType = "basic"; String subPanelEntryName = getNextComponentPanelDepth(currentPanelName); List<PanelEntry> subPanelEntryList = pe.GetPanels(subPanelEntryName); StringBuilder sbComponentHardcodedCode = new StringBuilder(); //INPUT CODE inputFunctionCode.AppendFormat(moarTabs(3) + "Dictionary<List<String>, Action<Asset, InputContext, string, string>> {0}_fields = new Dictionary<List<String>, Action<Asset, InputContext, string, string>>();{1}", listLabel, newLineChar); //POST_INPUT CODE postInputFunctionCode.AppendFormat(moarTabs(3) + "Dictionary<List<String>, Action<Asset, PostInputContext, string, string>> {0}_fields = new Dictionary<List<String>, Action<Asset, PostInputContext, string, string>>();{1}", listLabel, newLineChar); //OUTPUT CODE outputFunctionCode.AppendFormat(moarTabs(3) + "Dictionary<List<String>, Func<Asset, OutputContext, String, String, bool, String>> {0}_fields = new Dictionary<List<String>, Func<Asset, OutputContext, String, String, bool, String>>();{1}", listLabel, newLineChar); //JSON CODE jsonFunctionCode.AppendFormat(moarTabs(3) + "Dictionary<List<String>, Func<Asset, OutputContext, String, String, String>> {0}_fields = new Dictionary<List<String>, Func<Asset, OutputContext, String, String, String>>();{1}", listLabel, newLineChar); String subItemLabel = "sub"; List<String> subComponents = pe["component_list_components"].Split(Util.MakeList(", ").ToArray(), StringSplitOptions.RemoveEmptyEntries).ToList(); int subComponentCount = 0; Queue<SubListDetails> subListQueue = new Queue<SubListDetails>(); #endregion foreach (PanelEntry subPanelEntry in subPanelEntryList) { /*IF SUBCOMPONENT IS LIST*/ if (subPanelEntry["component_category"] == "list") { #region sub list logic //index++; //PanelEntry subComponentPanel = componentPanels[index]; String subListLabel = subPanelEntry["component_list_label"]; subItemLabel = subListLabel; String subListMessageContent = subPanelEntry["component_list_message_content"]; String subListMessageType = subPanelEntry["component_list_message_type"]; if (string.IsNullOrWhiteSpace(subListMessageType)) subListMessageType = "basic"; String subListMinPanels = String.IsNullOrWhiteSpace(subPanelEntry["min_panels"]) ? "null" : subPanelEntry["min_panels"]; String subListMaxPanels = String.IsNullOrWhiteSpace(subPanelEntry["max_panels"]) ? "null" : subPanelEntry["max_panels"]; //INPUT CODE inputFunctionCode.AppendFormat(moarTabs(3) + "List<String> {0}_fieldParams = new List<String>();{1}", subListLabel, newLineChar); inputFunctionCode.AppendFormat(moarTabs(3) + "{0}_fieldParams.Add(\"_{0}\");{1}", subListLabel, newLineChar); inputFunctionCode.AppendFormat(moarTabs(3) + "{0}_fieldParams.Add(\"\");{1}", subListLabel, newLineChar); inputFunctionCode.AppendFormat(moarTabs(3) + "{0}_fieldParams.Add(\"\");{1}", subListLabel, newLineChar); inputFunctionCode.AppendFormat(moarTabs(3) + "{0}_fieldParams.Add(\"\");{1}", subListLabel, newLineChar); inputFunctionCode.AppendFormat(moarTabs(3) + "{0}_fieldParams.Add(\"\");{1}", subListLabel, newLineChar); inputFunctionCode.AppendFormat(moarTabs(3) + "{0}_fields.Add({1}_fieldParams, this.{1}ListInputHelper);{2}", listLabel, subListLabel, newLineChar); //POST-INPUT //TODO: add post input code //OUTPUT String subComponentHtml = getContentPlaceholderMarkup(subListLabel, ContentNodeType.ListNodeAndContentV2, asset["markup"], true); outputFunctionCode.AppendFormat(moarTabs(3) + "List<String> {0}_fieldParams = new List<String>();{1}", subListLabel, newLineChar); outputFunctionCode.AppendFormat(moarTabs(3) + "{0}_fieldParams.Add(@\"{1}\");{2}", subListLabel, subComponentHtml.Replace("\"", "\"\"").Replace("\r", "").Replace("\n", ""), newLineChar); outputFunctionCode.AppendFormat(moarTabs(3) + "{0}_fieldParams.Add(\"_{0}\");{1}", subListLabel, newLineChar); outputFunctionCode.AppendFormat(moarTabs(3) + "{0}_fields.Add({1}_fieldParams, this.{1}ListOutputHelper);{2}", listLabel, subListLabel, newLineChar); //append lists "componentmarkup" to class vars childComponents.AppendFormat(moarTabs(2) + "public String {0}_ContentMarkup = @\"{1}\";{2}", subListLabel, subComponentHtml.Replace("\"", "\"\"").Replace("\r", "").Replace("\n", ""), newLineChar); //JSON jsonFunctionCode.AppendFormat(moarTabs(3) + "List<String> {0}_fieldParams = new List<String>();{1}", subListLabel, newLineChar); jsonFunctionCode.AppendFormat(moarTabs(3) + "{0}_fieldParams.Add(@\"{1}\");{2}", subListLabel, subComponentHtml.Replace("\"", "\"\"").Replace("\r", "").Replace("\n", ""), newLineChar); jsonFunctionCode.AppendFormat(moarTabs(3) + "{0}_fieldParams.Add(\"_{0}\");{1}", subListLabel, newLineChar); jsonFunctionCode.AppendFormat(moarTabs(3) + "{0}_fields.Add({1}_fieldParams, this.{1}ListJsonHelper);{2}", listLabel, subListLabel, newLineChar); //LIST HELPER //will recursively create inputs for each list //createCodeFileHelper(asset, subPanelEntry, subPanelEntryName, ref inputHelperFunctionCode, ref postInputHelperFunctionCode, ref outputHelperFunctionCode, ref childComponents, ref childComponentInitialization, ref listCount); subListQueue.Enqueue(new SubListDetails(subPanelEntry, subPanelEntryName)); #endregion } /*IF SUBCOMPONENT IS COMPONENT*/ else { #region sub component logic //index++; //PanelEntry subComponentPanel = componentPanels[index]; String subComponentType = subPanelEntry["component_component_type"]; String subComponentLabel = subPanelEntry["component_component_label"]; subItemLabel = subComponentLabel; String subComponentLabelOverride = subPanelEntry["component_component_input_label"]; String subComponentIsValidated = subPanelEntry["component_component_required"]; String subComponentValidationMessage = subPanelEntry["component_component_required_message"]; String subComponentWrapInControlGroup = subPanelEntry["component_component_form_override_type"]; String subComponentMessageContent = subPanelEntry["component_component_message_content"]; String subComponentMessageType = subPanelEntry["component_component_message_type"]; if (string.IsNullOrWhiteSpace(subComponentMessageType)) subComponentMessageType = "basic"; String subComponentHardcodedSnippet = String.IsNullOrWhiteSpace(subPanelEntry["component_component_hardcoded_snippet"]) ? "\"\"" : subPanelEntry["component_component_hardcoded_snippet"]; String subComponentHtml = getContentPlaceholderMarkup(subComponentLabel, ContentNodeType.Content, asset["markup"]); if (subComponentType == "Code") { sbComponentHardcodedCode.AppendFormat("{0}sbContent.Replace(@\"{1}\", {2});{3}", moarTabs(3), subComponentHtml, subComponentHardcodedSnippet, newLineChar); } else { //DECLARATION childComponents.AppendFormat(moarTabs(2) + "public {0} {1} {{get; set;}}{2}", subComponentType, subComponentLabel, newLineChar); //INITIALIZATION childComponentInitialization.AppendFormat(moarTabs(3) + "{0} = new {1}();{2}", subComponentLabel, subComponentType, newLineChar); //INPUT CODE inputFunctionCode.AppendFormat(moarTabs(3) + "List<String> {0}_fieldParams = new List<String>();{1}", (subComponentCount > 0 ? listLabel + "_" + subComponentLabel : listLabel), newLineChar); inputFunctionCode.AppendFormat(moarTabs(3) + "{0}_fieldParams.Add(\"_{0}\");{1}", (subComponentCount > 0 ? listLabel + "_" + subComponentLabel : listLabel), newLineChar); if (getCoreComponentTypes(asset).Contains(subComponentType)) { inputFunctionCode.AppendFormat(moarTabs(3) + "{0}_fieldParams.Add(\"{1}\");{2}", (subComponentCount > 0 ? listLabel + "_" + subComponentLabel : listLabel), String.IsNullOrWhiteSpace(subComponentLabelOverride) ? labelize(subComponentLabel) : subComponentLabelOverride, newLineChar); inputFunctionCode.AppendFormat(moarTabs(3) + "{0}_fieldParams.Add(\"{1}\");{2}", (subComponentCount > 0 ? listLabel + "_" + subComponentLabel : listLabel), "", newLineChar); } else { inputFunctionCode.AppendFormat(moarTabs(3) + "{0}_fieldParams.Add(\"{1}\");{2}", (subComponentCount > 0 ? listLabel + "_" + subComponentLabel : listLabel), subComponentLabelOverride.Trim(), newLineChar); inputFunctionCode.AppendFormat(moarTabs(3) + "{0}_fieldParams.Add(\"{1}\");{2}", (subComponentCount > 0 ? listLabel + "_" + subComponentLabel : listLabel), subComponentWrapInControlGroup, newLineChar); } inputFunctionCode.AppendFormat(moarTabs(3) + "{0}_fieldParams.Add(\"{1}\");{2}", (subComponentCount > 0 ? listLabel + "_" + subComponentLabel : listLabel), subComponentMessageContent, newLineChar); inputFunctionCode.AppendFormat(moarTabs(3) + "{0}_fieldParams.Add(\"{1}\");{2}", (subComponentCount > 0 ? listLabel + "_" + subComponentLabel : listLabel), subComponentMessageType, newLineChar); inputFunctionCode.AppendFormat(moarTabs(3) + "{0}_fields.Add({1}_fieldParams, this.{2}.ComponentInput);{3}", listLabel, (subComponentCount > 0 ? listLabel + "_" + subComponentLabel : listLabel), subComponentLabel, newLineChar); //POST_INPUT CODE postInputFunctionCode.AppendFormat(moarTabs(3) + "List<String> {0}_fieldParams = new List<String>();{1}", (subComponentCount > 0 ? listLabel + "_" + subComponentLabel : listLabel), newLineChar); postInputFunctionCode.AppendFormat(moarTabs(3) + "{0}_fieldParams.Add(\"_{0}\");{1}", (subComponentCount > 0 ? listLabel + "_" + subComponentLabel : listLabel), newLineChar); if (getCoreComponentTypes(asset).Contains(subComponentType) && subComponentIsValidated == "yes") { postInputFunctionCode.AppendFormat(moarTabs(3) + "{0}_fieldParams.Add(\"{1}\");{2}", (subComponentCount > 0 ? listLabel + "_" + subComponentLabel : listLabel), subComponentType, newLineChar); postInputFunctionCode.AppendFormat(moarTabs(3) + "{0}_fieldParams.Add(\"{1}\");{2}", (subComponentCount > 0 ? listLabel + "_" + subComponentLabel : listLabel), subComponentValidationMessage, newLineChar); } postInputFunctionCode.AppendFormat(moarTabs(3) + "{0}_fields.Add({1}_fieldParams, this.{2}.ComponentPostInput);{3}", listLabel, (subComponentCount > 0 ? listLabel + "_" + subComponentLabel : listLabel), subComponentLabel, newLineChar); //OUTPUT CODE outputFunctionCode.AppendFormat(moarTabs(3) + "List<String> {0}_fieldParams = new List<String>();{1}", (subComponentCount > 0 ? listLabel + "_" + subComponentLabel : listLabel), newLineChar); outputFunctionCode.AppendFormat(moarTabs(3) + "{0}_fieldParams.Add(@\"{1}\");{2}", (subComponentCount > 0 ? listLabel + "_" + subComponentLabel : listLabel), subComponentHtml.Replace("\"", "\"\""), newLineChar); outputFunctionCode.AppendFormat(moarTabs(3) + "{0}_fieldParams.Add(\"_{1}\");{2}", (subComponentCount > 0 ? listLabel + "_" + subComponentLabel : listLabel), (subComponentCount > 0 ? listLabel + "_" + subComponentLabel : listLabel), newLineChar); outputFunctionCode.AppendFormat(moarTabs(3) + "{0}_fields.Add({1}_fieldParams, this.{2}.ComponentOutput);{3}", listLabel, (subComponentCount > 0 ? listLabel + "_" + subComponentLabel : listLabel), subComponentLabel, newLineChar); //JSON CODE jsonFunctionCode.AppendFormat(moarTabs(3) + "List<String> {0}_fieldParams = new List<String>();{1}", (subComponentCount > 0 ? listLabel + "_" + subComponentLabel : listLabel), newLineChar); jsonFunctionCode.AppendFormat(moarTabs(3) + "{0}_fieldParams.Add(@\"{1}\");{2}", (subComponentCount > 0 ? listLabel + "_" + subComponentLabel : listLabel), subComponentHtml.Replace("\"", "\"\""), newLineChar); jsonFunctionCode.AppendFormat(moarTabs(3) + "{0}_fieldParams.Add(\"_{1}\");{2}", (subComponentCount > 0 ? listLabel + "_" + subComponentLabel : listLabel), (subComponentCount > 0 ? listLabel + "_" + subComponentLabel : listLabel), newLineChar); jsonFunctionCode.AppendFormat(moarTabs(3) + "{0}_fields.Add({1}_fieldParams, this.{2}.ComponentJson);{3}", listLabel, (subComponentCount > 0 ? listLabel + "_" + subComponentLabel : listLabel), subComponentLabel, newLineChar); //INDEXED FIELDS indexedFieldsFunctionCode.AppendFormat(moarTabs(3) + "fields.AddRange(IndexedField.ToArray(this.{0}.ComponentIndexedFields(asset, context, name + \"_panel_{1}\", index)));{2}", subComponentLabel, (subComponentCount > 0 ? listLabel + "_" + subComponentLabel : listLabel).ToLowerInvariant(), newLineChar); } subComponentCount++; #endregion } } #region more list logic //INPUT CODE inputFunctionCode.AppendFormat(""); if (!String.IsNullOrWhiteSpace(listMessageContent)) { inputFunctionCode.AppendFormat(moarTabs(3) + "Input.ShowMessage(\"{0}\", MessageType.{1});{2}", listMessageContent, labelize(listMessageType), newLineChar); } inputFunctionCode.AppendFormat(moarTabs(3) + "PanelInput(asset, context, \"{0}\", name + {1}\"_panel\", {2}_fields, {3}, {4});{5}", labelize(listLabel), (listCount > 0 ? "\"_" + listLabel + "\" + " : ""), listLabel, minPanels, maxPanels, newLineChar); inputFunctionCode.Append(newLineChar); //POST_INPUT CODE postInputFunctionCode.AppendFormat(moarTabs(3) + "PanelPostInput(asset, context, name + {0}\"_panel\", {1}_fields, index);{2}", (listCount > 0 ? "\"_" + listLabel + "\" + " : ""), listLabel, newLineChar); //OUTPUT CODE String listContent = getContentPlaceholderMarkup(listLabel, ContentNodeType.ListNodeAndContentV2, asset["markup"]); listContent = listContent.Replace("\r", "").Replace("\n", "").Replace("\"", "\"\""); outputFunctionCode.AppendFormat(moarTabs(3) + "sbContent.Replace(@\"{0}\", PanelOutput(asset, context, name + {1}\"_panel\", @\"{2}\", \"{3}\", {4}_fields, index));{5}", listContent, (listCount > 0 ? "\"_" + listLabel + "\" + " : ""), pe["component_list_content"].Replace("\r", "").Replace("\n", "").Replace("\"", "\"\""), listLabel, listLabel, newLineChar); outputFunctionCode.Append(sbComponentHardcodedCode.ToString()); outputFunctionCode.Append(newLineChar); //JSON CODE // Strip any HTML from the list markup var jsonPanelMarkup = pe["component_list_content"].Replace("\r", "").Replace("\n", "").Replace("\"", "\"\""); jsonPanelMarkup = string.Join(",", new Regex("\\{[^}]+\\}").Matches(jsonPanelMarkup).OfType<Match>().Select(m => m.Value)); if (isSingleList) jsonFunctionCode.AppendFormat(moarTabs(3) + "sbJson.AppendFormat(\"[{{0}}]\", PanelJson(asset, context, name + {1}\"_panel\", @\"{2}\", \"{3}\", \"{5}\", {4}_fields, index));{6}", listLabel, (listCount > 0 ? "\"_" + listLabel + "\" + " : ""), jsonPanelMarkup, listLabel, listLabel, subItemLabel, newLineChar); else jsonFunctionCode.AppendFormat(moarTabs(3) + "sbJson.AppendFormat(\"\\\"{{0}}\\\":[{{1}}]\", JsonHelper.StringToJson(\"{3}\"), PanelJson(asset, context, name + {1}\"_panel\", @\"{2}\", \"{3}\", \"{5}\", {4}_fields, index));{6}", listLabel, (listCount > 0 ? "\"_" + listLabel + "\" + " : ""), jsonPanelMarkup, listLabel, listLabel, subItemLabel, newLineChar); listCount++; while (subListQueue.Count > 0) { SubListDetails sld = subListQueue.Dequeue(); if (sld != null) { createCodeFileHelper(asset, sld.pe, sld.panelEntryName, ref inputHelperFunctionCode, ref postInputHelperFunctionCode, ref outputHelperFunctionCode, ref jsonHelperFunctionCode, ref childComponents, ref childComponentInitialization); } } #endregion } } if (!isSingleList) { jsonFunctionCode.AppendFormat(moarTabs(3) + "sbJson.Append(\"}}\");{0}", newLineChar); } #region add to code file frame and save String code = "using System;" + newLineChar + "using System.Collections.Generic;" + newLineChar + "using System.Linq;" + newLineChar + "using System.Text;" + newLineChar + "using CrownPeak.CMSAPI;" + newLineChar + "using CrownPeak.CMSAPI.Services;" + newLineChar + "using " + componentLibraryNamespace + ";" + newLineChar + "/* Some Namespaces are not allowed. */" + newLineChar + "namespace " + componentLibraryNamespace + newLineChar + "{" + newLineChar + tabChar + "[Serializable]" + newLineChar + tabChar + "public partial class " + className + " : " + (createJsonComponent ? "Json" : "") + "ComponentBase" + newLineChar + tabChar + "{" + newLineChar + childComponents.ToString() + newLineChar + tabChar + tabChar + "public " + className + "()" + newLineChar + tabChar + tabChar + "{" + newLineChar + childComponentInitialization.ToString() + tabChar + tabChar + tabChar + "ComponentMarkup = @\"" + asset["markup"].Replace("\"", "\"\"").Replace("\r", "").Replace("\n", "").Replace("\\{", "{").Replace("\\}", "}") + "\";" + newLineChar + tabChar + tabChar + "}" + newLineChar + newLineChar + tabChar + tabChar + "public void InputBase(Asset asset, InputContext context, string label, string name)" + newLineChar + tabChar + tabChar + "{" + newLineChar + inputFunctionCode.ToString() + tabChar + tabChar + "}" + newLineChar + newLineChar + inputHelperFunctionCode.ToString() + tabChar + tabChar + "public void PostInputBase(Asset asset, PostInputContext context, string name, string index = \"\")" + newLineChar + tabChar + tabChar + "{" + newLineChar + postInputFunctionCode.ToString() + tabChar + tabChar + "}" + newLineChar + newLineChar + postInputHelperFunctionCode.ToString() + tabChar + tabChar + "public string OutputBase(Asset asset, OutputContext context, string name, string index = \"\", bool isDrag = false)" + newLineChar + tabChar + tabChar + "{" + newLineChar + tabChar + tabChar + tabChar + "if (isDrag)" + newLineChar + tabChar + tabChar + tabChar + "{" + newLineChar + tabChar + tabChar + tabChar + tabChar + "StringBuilder ddContent = new StringBuilder();" + newLineChar + tabChar + tabChar + tabChar + tabChar + "ddContent.Append(ComponentMarkup);" + newLineChar + newLineChar + tabChar + tabChar + tabChar + tabChar + "return ComponentFramework.ParseDragAndDropMarkupForPreviewAndPublish(context, ddContent.ToString());" + newLineChar + tabChar + tabChar + tabChar + "}" + newLineChar + newLineChar + tabChar + tabChar + tabChar + "StringBuilder sbContent = new StringBuilder();" + newLineChar + tabChar + tabChar + tabChar + "sbContent.Append(ComponentMarkup);" + newLineChar + outputFunctionCode.ToString() + tabChar + tabChar + tabChar + "String markup = ComponentFramework.UpdateMarkupForPreviewPublish(context, sbContent.ToString());" + newLineChar + tabChar + tabChar + tabChar + "return markup;" + newLineChar + tabChar + tabChar + "}" + newLineChar + newLineChar + outputHelperFunctionCode.ToString() + (!createJsonComponent ? "" : ( tabChar + tabChar + "public string JsonBase(Asset asset, OutputContext context, string name, string index = \"\")" + newLineChar + tabChar + tabChar + "{" + newLineChar + tabChar + tabChar + tabChar + "StringBuilder sbJson = new StringBuilder(1024);" + newLineChar + jsonFunctionCode.ToString() + tabChar + tabChar + tabChar + "return sbJson.ToString();" + newLineChar + tabChar + tabChar + "}" + newLineChar + newLineChar + jsonHelperFunctionCode.ToString() + newLineChar + tabChar + tabChar + "public IEnumerable<IndexedField> IndexedFieldsBase(Asset asset, SearchG2Context context, string name, string index = \"\")" + newLineChar + tabChar + tabChar + "{" + newLineChar + tabChar + tabChar + tabChar + "var fields = new List<IndexedField>();" + newLineChar + indexedFieldsFunctionCode + tabChar + tabChar + tabChar + "return fields;" + newLineChar + tabChar + tabChar + "}" + newLineChar )) + tabChar + "}" + newLineChar + "}"; Dictionary<String, String> codeContent = new Dictionary<string, string>(); codeContent.Add("body", Util.DecodeEntities(code)); codeContent.Add("componentAsset", asset.GetLink(LinkType.Internal)); String componentClassFileName = createComponentClassFileName(className, ComponentClassNameType.Base); String componentClassOverrideFileName = createComponentClassFileName(className, ComponentClassNameType.Override); String overrideCode = "using System;" + newLineChar + "using System.Collections.Generic;" + newLineChar + "using System.Linq;" + newLineChar + "using System.Text;" + newLineChar + "using CrownPeak.CMSAPI;" + newLineChar + "using CrownPeak.CMSAPI.Services;" + newLineChar + "using " + componentLibraryNamespace + ";" + newLineChar + "/* Some Namespaces are not allowed. */" + newLineChar + "namespace " + componentLibraryNamespace + newLineChar + "{" + newLineChar + tabChar + "public partial class " + className + " : " + (createJsonComponent ? "Json" : "") + "ComponentBase" + newLineChar + tabChar + "{" + newLineChar + tabChar + tabChar + "/*comment out \"InputBase(asset, context, label, name);\" & modify this function if you want to overwrite the input functionality of the component.*/" + newLineChar + tabChar + tabChar + "public override void ComponentInput(Asset asset, InputContext context, String label, string name)" + newLineChar + tabChar + tabChar + "{" + newLineChar + tabChar + tabChar + tabChar + "InputBase(asset, context, label, name);" + newLineChar + tabChar + tabChar + "}" + newLineChar + newLineChar + tabChar + tabChar + "/*comment out \"PostInputBase(asset, context, name, index);\" & modify this function if you want to overwrite the post_input functionality of the component.*/" + newLineChar + tabChar + tabChar + "public override void ComponentPostInput(Asset asset, PostInputContext context, string name, string index = \"\")" + newLineChar + tabChar + tabChar + "{" + newLineChar + tabChar + tabChar + tabChar + "PostInputBase(asset, context, name, index);" + newLineChar + tabChar + tabChar + "}" + newLineChar + newLineChar + tabChar + tabChar + "/*comment out \"OutputBase(asset, context, name, index, isDrag);\" & modify this function if you want to overwrite the output functionality of the component.*/" + newLineChar + tabChar + tabChar + "public override string ComponentOutput(Asset asset, OutputContext context, string name, string index = \"\", bool isDrag = false)" + newLineChar + tabChar + tabChar + "{" + newLineChar + tabChar + tabChar + tabChar + "return OutputBase(asset, context, name, index, isDrag);" + newLineChar + tabChar + tabChar + "}" + newLineChar + (!createJsonComponent ? "" : ( newLineChar + tabChar + tabChar + "/*comment out \"JsonBase(asset, context, name, index);\" & modify this function if you want to overwrite the JSON functionality of the component.*/" + newLineChar + tabChar + tabChar + "public override string ComponentJson(Asset asset, OutputContext context, string name, string index = \"\")" + newLineChar + tabChar + tabChar + "{" + newLineChar + tabChar + tabChar + tabChar + "return JsonBase(asset, context, name, index);" + newLineChar + tabChar + tabChar + "}" + newLineChar + newLineChar + tabChar + tabChar + "/*comment out \"IndexedFieldsBase(asset, context, name, index);\" & modify this function if you want to overwrite the indexed fields of the component.*/" + newLineChar + tabChar + tabChar + "public override IEnumerable<IndexedField> ComponentIndexedFields(Asset asset, SearchG2Context context, string name, string index = \"\")" + newLineChar + tabChar + tabChar + "{" + newLineChar + tabChar + tabChar + tabChar + "return IndexedFieldsBase(asset, context, name, index);" + newLineChar + tabChar + tabChar + "}" + newLineChar )) + tabChar + "}" + newLineChar + "}"; Dictionary<String, String> overrideCodeContent = new Dictionary<string, string> { { "body", overrideCode } }; Asset existingCodeFile = getComponentCodeFileAsset(asset["class_name"], asset, ComponentClassNameType.Base); Asset codeFile = null; Asset overrideCodeFile = null; if (existingCodeFile != null && existingCodeFile.IsLoaded) { String componentAsset = existingCodeFile["componentAsset"]; var branchVersion = getAssetForBranch(Asset.Load(componentAsset), asset); if (String.IsNullOrWhiteSpace(componentAsset) || componentAsset.Substring(componentAsset.LastIndexOf("/") + 1) == asset.Id.ToString() || branchVersion.Id == asset.Id) { //String contentBackup = existingCodeFile["body"]; existingCodeFile.SaveContent(codeContent); if (deferCompilation) recompileSuccessful = true; else recompileSuccessful = existingCodeFile.SaveSource(Util.DecodeEntities(code)); #region rollback code (COMMENTED OUT) //if (!recompileSuccessful) //{ // existingCodeFile.SaveContentField("body", contentBackup); //} //codeFile = existingCodeFile; #endregion } } else { String codeFileModelPath = getComponentLibraryModelFolder(asset).AssetPath + "/Code File"; Asset codeFileModel = Asset.Load(codeFileModelPath); codeFile = Asset.CreateNewAsset(componentClassFileName, componentLibraryClassFolder, codeFileModel, codeContent); overrideCodeFile = Asset.CreateNewAsset(componentClassOverrideFileName, componentLibraryClassFolder, codeFileModel, overrideCodeContent); if (deferCompilation) recompileSuccessful = true; else recompileSuccessful = overrideCodeFile.SaveSource(Util.DecodeEntities(overrideCode)); #region rollback code (COMMENTED OUT) // if (!recompileSuccessful) // { // codeFile.Delete(); // } #endregion } if (!recompileSuccessful) { //Util.Email(String.Format("xCodefile {0} recompilation unsuccessful.", componentClassFileName), // String.Format("Recompilation failed when recompiling after codefile {0} \r\n\r\n {1}", componentClassFileName, Util.DecodeEntities(code)), // "corey.casado@crownpeak.com"); } #endregion return codeFile; #region rollback code (COMMENTED OUT) //if (existingCodeFile != null && existingCodeFile.IsLoaded) //{ // if (existingCodeFile["componentAsset"] == asset.GetLink(LinkType.Internal)) // { // existingCodeFile.SaveContent(codeContent); // codeFile = existingCodeFile; // } // else // { // throw new Exception("Error updating existing code file. The code file loaded is not associated with this asset."); // } //} //else //{ // String codeFileModelPath = "/" + asset.AssetPath[0] + "/Component_Project/Models/Code File"; // Asset codeFileModel = Asset.Load(codeFileModelPath); // codeFile = Asset.CreateNewAsset(componentClassFileName, componentLibraryClassFolder, Asset.Load("/" + asset.AssetPath[0] + "/Component_Project/Models/Code File"), codeContent); //} //return codeFile; #endregion } private static void createCodeFileHelper(Asset asset, PanelEntry pe, String currentPanelName, ref StringBuilder inputFunctionCode, ref StringBuilder postInputFunctionCode, ref StringBuilder outputFunctionCode, ref StringBuilder jsonFunctionCode, ref StringBuilder childComponents, ref StringBuilder childComponentInitialization) { StringBuilder newInputFunctionCode = new StringBuilder(); StringBuilder newPostInputFunctionCode = new StringBuilder(); StringBuilder newOutputFunctionCode = new StringBuilder(); StringBuilder newJsonFunctionCode = new StringBuilder(); #region list logic String listLabel = pe["component_list_label"]; String minPanels = String.IsNullOrWhiteSpace(pe["min_panels"]) ? "null" : pe["min_panels"]; String maxPanels = String.IsNullOrWhiteSpace(pe["max_panels"]) ? "null" : pe["max_panels"]; String listMessageContent = pe["component_list_message_content"]; String listMessageType = pe["component_list_message_type"]; if (string.IsNullOrWhiteSpace(listMessageType)) listMessageType = "basic"; String subPanelEntryName = getNextComponentPanelDepth(currentPanelName); List<PanelEntry> subPanelEntryList = pe.GetPanels(subPanelEntryName); StringBuilder sbComponentHardcodedCode = new StringBuilder(); //INPUT CODE newInputFunctionCode.AppendFormat(moarTabs(3) + "Dictionary<List<String>, Action<Asset, InputContext, string, string>> {0}_fields = new Dictionary<List<String>, Action<Asset, InputContext, string, string>>();{1}", listLabel, newLineChar); //POST_INPUT CODE newPostInputFunctionCode.AppendFormat(moarTabs(3) + "Dictionary<List<String>, Action<Asset, PostInputContext, string, string>> {0}_fields = new Dictionary<List<String>, Action<Asset, PostInputContext, string, string>>();{1}", listLabel, newLineChar); //OUTPUT CODE newOutputFunctionCode.AppendFormat(moarTabs(3) + "Dictionary<List<String>, Func<Asset, OutputContext, String, String, String>> {0}_fields = new Dictionary<List<String>, Func<Asset, OutputContext, String, String, bool, String>>();{1}", listLabel, newLineChar); // JSON CODE newJsonFunctionCode.AppendFormat(moarTabs(3) + "Dictionary<List<String>, Func<Asset, OutputContext, String, String, String>> {0}_fields = new Dictionary<List<String>, Func<Asset, OutputContext, String, String, String>>();{1}", listLabel, newLineChar); int subComponentCount = 0; Queue<SubListDetails> subListQueue = new Queue<SubListDetails>(); #endregion foreach (PanelEntry subPanelEntry in subPanelEntryList) { /*IF SUBCOMPONENT IS LIST*/ if (subPanelEntry["component_category"] == "list") { #region sub list logic //index++; //PanelEntry subComponentPanel = componentPanels[index]; String subListLabel = subPanelEntry["component_list_label"]; String subListMessageContent = subPanelEntry["component_list_message_content"]; String subListMessageType = subPanelEntry["component_list_message_type"]; if (string.IsNullOrWhiteSpace(subListMessageType)) subListMessageType = "basic"; String subListMinPanels = String.IsNullOrWhiteSpace(subPanelEntry["min_panels"]) ? "null" : subPanelEntry["min_panels"]; String subListMaxPanels = String.IsNullOrWhiteSpace(subPanelEntry["max_panels"]) ? "null" : subPanelEntry["max_panels"]; //INPUT CODE newInputFunctionCode.AppendFormat(moarTabs(3) + "List<String> {0}_fieldParams = new List<String>();{1}", subListLabel, newLineChar); newInputFunctionCode.AppendFormat(moarTabs(3) + "{0}_fieldParams.Add(\"_{0}\");{1}", subListLabel, newLineChar); newInputFunctionCode.AppendFormat(moarTabs(3) + "{0}_fieldParams.Add(\"\");{1}", subListLabel, newLineChar); newInputFunctionCode.AppendFormat(moarTabs(3) + "{0}_fieldParams.Add(\"\");{1}", subListLabel, newLineChar); newInputFunctionCode.AppendFormat(moarTabs(3) + "{0}_fieldParams.Add(\"\");{1}", subListLabel, newLineChar); newInputFunctionCode.AppendFormat(moarTabs(3) + "{0}_fieldParams.Add(\"\");{1}", subListLabel, newLineChar); newInputFunctionCode.AppendFormat(moarTabs(3) + "{0}_fields.Add({1}_fieldParams, this.{1}ListInputHelper);{2}", listLabel, subListLabel, newLineChar); //POST-INPUT //TODO: add post input code //OUTPUT String subComponentHtml = getContentPlaceholderMarkup(subListLabel, ContentNodeType.ListNodeAndContentV2, asset["markup"], true); newOutputFunctionCode.AppendFormat(moarTabs(3) + "List<String> {0}_fieldParams = new List<String>();{1}", subListLabel, newLineChar); newOutputFunctionCode.AppendFormat(moarTabs(3) + "{0}_fieldParams.Add(@\"{1}\");{2}", subListLabel, subComponentHtml.Replace("\"", "\"\""), newLineChar); newOutputFunctionCode.AppendFormat(moarTabs(3) + "{0}_fieldParams.Add(\"_{0}\");{1}", subListLabel, newLineChar); newOutputFunctionCode.AppendFormat(moarTabs(3) + "{0}_fields.Add({1}_fieldParams, this.{1}ListOutputHelper);{2}", listLabel, subListLabel, newLineChar); //append lists "componentmarkup" to class vars childComponents.AppendFormat(moarTabs(2) + "public String {0}_ContentMarkup = @\"{1}\";{2}", subListLabel, subComponentHtml.Replace("\"", "\"\"").Replace("\r", "").Replace("\n", ""), newLineChar); //LIST HELPER //will recursively create inputs for each list subListQueue.Enqueue(new SubListDetails(subPanelEntry, subPanelEntryName)); #endregion } /*IF SUBCOMPONENT IS COMPONENT*/ else { #region sub component logic //index++; //PanelEntry subComponentPanel = componentPanels[index]; String subComponentType = subPanelEntry["component_component_type"]; String subComponentLabel = subPanelEntry["component_component_label"]; String subComponentLabelOverride = subPanelEntry["component_component_input_label"]; String subComponentWrapInControlGroup = subPanelEntry["component_component_form_override_type"]; String subComponentMessageContent = subPanelEntry["component_component_message_content"]; String subComponentMessageType = subPanelEntry["component_component_message_type"]; if (string.IsNullOrWhiteSpace(subComponentMessageType)) subComponentMessageType = "basic"; String subComponentHardcodedSnippet = String.IsNullOrWhiteSpace(subPanelEntry["component_component_hardcoded_snippet"]) ? "\"\"" : subPanelEntry["component_component_hardcoded_snippet"]; String subComponentHtml = getContentPlaceholderMarkup(subComponentLabel, ContentNodeType.Content, asset["markup"]); if (subComponentType == "Code") { sbComponentHardcodedCode.AppendFormat("{0}sbContent.Replace(@\"{1}\", {2});{3}", moarTabs(3), subComponentHtml, subComponentHardcodedSnippet, newLineChar); } else { //DECLARATION childComponents.AppendFormat(moarTabs(2) + "public {0} {1} {{get; set;}}{2}", subComponentType, subComponentLabel, newLineChar); //INITIALIZATION childComponentInitialization.AppendFormat(moarTabs(3) + "{0} = new {1}();{2}", subComponentLabel, subComponentType, newLineChar); //INPUT CODE newInputFunctionCode.AppendFormat(moarTabs(3) + "List<String> {0}_fieldParams = new List<String>();{1}", (subComponentCount > 0 ? listLabel + "_" + subComponentLabel : listLabel), newLineChar); newInputFunctionCode.AppendFormat(moarTabs(3) + "{0}_fieldParams.Add(\"_{0}\");{1}", (subComponentCount > 0 ? listLabel + "_" + subComponentLabel : listLabel), newLineChar); if (getCoreComponentTypes(asset).Contains(subComponentType)) { newInputFunctionCode.AppendFormat(moarTabs(3) + "{0}_fieldParams.Add(\"{1}\");{2}", (subComponentCount > 0 ? listLabel + "_" + subComponentLabel : listLabel), String.IsNullOrWhiteSpace(subComponentLabelOverride) ? labelize(subComponentLabel) : subComponentLabelOverride, newLineChar); newInputFunctionCode.AppendFormat(moarTabs(3) + "{0}_fieldParams.Add(\"{1}\");{2}", (subComponentCount > 0 ? listLabel + "_" + subComponentLabel : listLabel), "", newLineChar); } else { newInputFunctionCode.AppendFormat(moarTabs(3) + "{0}_fieldParams.Add(\"{1}\");{2}", (subComponentCount > 0 ? listLabel + "_" + subComponentLabel : listLabel), subComponentLabelOverride.Trim(), newLineChar); newInputFunctionCode.AppendFormat(moarTabs(3) + "{0}_fieldParams.Add(\"{1}\");{2}", (subComponentCount > 0 ? listLabel + "_" + subComponentLabel : listLabel), subComponentWrapInControlGroup, newLineChar); } newInputFunctionCode.AppendFormat(moarTabs(3) + "{0}_fieldParams.Add(\"{1}\");{2}", (subComponentCount > 0 ? listLabel + "_" + subComponentLabel : listLabel), subComponentMessageContent, newLineChar); newInputFunctionCode.AppendFormat(moarTabs(3) + "{0}_fieldParams.Add(\"{1}\");{2}", (subComponentCount > 0 ? listLabel + "_" + subComponentLabel : listLabel), subComponentMessageType, newLineChar); newInputFunctionCode.AppendFormat(moarTabs(3) + "{0}_fields.Add({1}_fieldParams, this.{2}.ComponentInput);{3}", listLabel, (subComponentCount > 0 ? listLabel + "_" + subComponentLabel : listLabel), subComponentLabel, newLineChar); //POST_INPUT CODE newPostInputFunctionCode.AppendFormat(moarTabs(3) + "List<String> {0}_fieldParams = new List<String>();{1}", (subComponentCount > 0 ? listLabel + "_" + subComponentLabel : listLabel), newLineChar); newPostInputFunctionCode.AppendFormat(moarTabs(3) + "{0}_fieldParams.Add(\"_{0}\");{1}", (subComponentCount > 0 ? listLabel + "_" + subComponentLabel : listLabel), newLineChar); newPostInputFunctionCode.AppendFormat(moarTabs(3) + "{0}_fields.Add({1}_fieldParams, this.{2}.ComponentPostInput);{3}", listLabel, (subComponentCount > 0 ? listLabel + "_" + subComponentLabel : listLabel), subComponentLabel, newLineChar); //OUTPUT CODE newOutputFunctionCode.AppendFormat(moarTabs(3) + "List<String> {0}_fieldParams = new List<String>();{1}", (subComponentCount > 0 ? listLabel + "_" + subComponentLabel : listLabel), newLineChar); newOutputFunctionCode.AppendFormat(moarTabs(3) + "{0}_fieldParams.Add(@\"{1}\");{2}", (subComponentCount > 0 ? listLabel + "_" + subComponentLabel : listLabel), subComponentHtml.Replace("\"", "\"\""), newLineChar); newOutputFunctionCode.AppendFormat(moarTabs(3) + "{0}_fieldParams.Add(\"_{1}\");{2}", (subComponentCount > 0 ? listLabel + "_" + subComponentLabel : listLabel), (subComponentCount > 0 ? listLabel + "_" + subComponentLabel : listLabel), newLineChar); newOutputFunctionCode.AppendFormat(moarTabs(3) + "{0}_fields.Add({1}_fieldParams, this.{2}.ComponentOutput);{3}", listLabel, (subComponentCount > 0 ? listLabel + "_" + subComponentLabel : listLabel), subComponentLabel, newLineChar); //JSON CODE newJsonFunctionCode.AppendFormat(moarTabs(3) + "List<String> {0}_fieldParams = new List<String>();{1}", (subComponentCount > 0 ? listLabel + "_" + subComponentLabel : listLabel), newLineChar); newJsonFunctionCode.AppendFormat(moarTabs(3) + "{0}_fieldParams.Add(@\"{1}\");{2}", (subComponentCount > 0 ? listLabel + "_" + subComponentLabel : listLabel), subComponentHtml.Replace("\"", "\"\""), newLineChar); newJsonFunctionCode.AppendFormat(moarTabs(3) + "{0}_fieldParams.Add(\"_{1}\");{2}", (subComponentCount > 0 ? listLabel + "_" + subComponentLabel : listLabel), (subComponentCount > 0 ? listLabel + "_" + subComponentLabel : listLabel), newLineChar); newJsonFunctionCode.AppendFormat(moarTabs(3) + "{0}_fields.Add({1}_fieldParams, this.{2}.ComponentJson);{3}", listLabel, (subComponentCount > 0 ? listLabel + "_" + subComponentLabel : listLabel), subComponentLabel, newLineChar); } subComponentCount++; #endregion } } #region more list logic //INPUT CODE newInputFunctionCode.AppendFormat(""); if (!String.IsNullOrWhiteSpace(listMessageContent)) { newInputFunctionCode.AppendFormat(moarTabs(3) + "Input.ShowMessage(\"{0}\", MessageType.{1});{2}", listMessageContent, labelize(listMessageType), newLineChar); } newInputFunctionCode.AppendFormat(moarTabs(3) + "PanelInput(asset, context, \"{0}\", name + {1}\"_panel\", {2}_fields, {3}, {4});{5}", labelize(listLabel), "\"_" + listLabel + "\" + ", listLabel, minPanels, maxPanels, newLineChar); newInputFunctionCode.Append(newLineChar); //POST_INPUT CODE newPostInputFunctionCode.AppendFormat(moarTabs(3) + "PanelPostInput(asset, context, name + {0}\"_panel\", {1}_fields, index);{2}", "\"_" + listLabel + "\" + ", listLabel, newLineChar); //OUTPUT CODE String listContent = getContentPlaceholderMarkup(listLabel, ContentNodeType.ListNodeAndContentV2, asset["markup"], true); listContent = listContent.Replace("\r", "").Replace("\n", "").Replace("\"", "\"\""); newOutputFunctionCode.AppendFormat(moarTabs(3) + "sbContent.Replace(@\"{0}\", PanelOutput(asset, context, name + {1}\"_panel\", @\"{2}\", \"{3}\", {4}_fields, index));{5}", listContent, "\"_" + listLabel + "\" + ", pe["component_list_content"].Replace("\"", "\"\""), listLabel, listLabel, newLineChar); newOutputFunctionCode.Append(sbComponentHardcodedCode.ToString()); newOutputFunctionCode.Append(newLineChar); //JSON CODE listContent = getContentPlaceholderMarkup(listLabel, ContentNodeType.ListNodeAndContentV2, asset["markup"], true); listContent = listContent.Replace("\r", "").Replace("\n", "").Replace("\"", "\"\""); newJsonFunctionCode.AppendFormat(moarTabs(3) + "sbJson.AppendFormat(\"\\\"{{0}}\\\":{{1}}\", JsonHelper.StringToJson(\"{4}\"), PanelJson(asset, context, name + {1}\"_panel\", @\"{2}\", \"{3}\", {4}_fields, index));{5}", listContent, "\"_" + listLabel + "\" + ", pe["component_list_content"].Replace("\"", "\"\""), listLabel, listLabel, newLineChar); newJsonFunctionCode.Append(newLineChar); #region append to existing input, postInput, output & json helper stringbuilders //INPUT inputFunctionCode.AppendFormat("{0}public void {1}ListInputHelper(Asset asset, String label, String name){2}", moarTabs(2), listLabel, newLineChar); inputFunctionCode.AppendFormat("{0}{{{1}", moarTabs(2), newLineChar); inputFunctionCode.Append(newInputFunctionCode.ToString()); inputFunctionCode.AppendFormat("{0}}}{1}", moarTabs(2), newLineChar + newLineChar); //POSTINPUT postInputFunctionCode.AppendFormat("{0}public void {1}ListPostInputHelper(PostInputContext context, string name, string index = \"\"){2}", moarTabs(2), listLabel, newLineChar); postInputFunctionCode.AppendFormat("{0}{{{1}", moarTabs(2), newLineChar); postInputFunctionCode.Append(newPostInputFunctionCode.ToString()); postInputFunctionCode.AppendFormat("{0}}}{1}", moarTabs(2), newLineChar + newLineChar); //OUTPUT outputFunctionCode.AppendFormat("{0}public String {1}ListOutputHelper(Asset asset, OutputContext context, string name, string index = \"\"){2}", moarTabs(2), listLabel, newLineChar); outputFunctionCode.AppendFormat("{0}{{{1}", moarTabs(2), newLineChar); outputFunctionCode.AppendFormat("{0}StringBuilder sbContent = new StringBuilder();{1}", moarTabs(3), newLineChar); outputFunctionCode.AppendFormat("{0}sbContent.Append({1}_ContentMarkup);{2}", moarTabs(3), listLabel, newLineChar); outputFunctionCode.Append(newOutputFunctionCode.ToString()); outputFunctionCode.AppendFormat("{0}return sbContent.ToString();{1}", moarTabs(3), newLineChar); outputFunctionCode.AppendFormat("{0}}}{1}", moarTabs(2), newLineChar + newLineChar); //JSON jsonFunctionCode.AppendFormat("{0}public String {1}ListJsonHelper(Asset asset, OutputContext context, string name, string index = \"\"){2}", moarTabs(2), listLabel, newLineChar); jsonFunctionCode.AppendFormat("{0}{{{1}", moarTabs(2), newLineChar); jsonFunctionCode.AppendFormat("{0}StringBuilder sbJson = new StringBuilder();{1}", moarTabs(3), newLineChar); jsonFunctionCode.Append(newJsonFunctionCode.ToString()); jsonFunctionCode.AppendFormat("{0}return sbJson.ToString();{1}", moarTabs(3), newLineChar); jsonFunctionCode.AppendFormat("{0}}}{1}", moarTabs(2), newLineChar + newLineChar); #endregion while (subListQueue.Count > 0) { SubListDetails sld = subListQueue.Dequeue(); if (sld != null) { createCodeFileHelper(asset, sld.pe, sld.panelEntryName, ref inputFunctionCode, ref postInputFunctionCode, ref outputFunctionCode, ref jsonFunctionCode, ref childComponents, ref childComponentInitialization); } } #endregion } private static Asset getProject(Asset asset) { SiteRootProperties srp = Asset.GetSiteRootProperties(asset.Id); var project = Asset.Load(srp.ProjectId); var projectPath = project.AssetPath; var assetPath = asset.AssetPath; if (assetPath.Count >= projectPath.Count && !assetPath.ToString().StartsWith(projectPath.ToString())) { var path = "/" + string.Join("/", assetPath.Take(projectPath.Count)); if (Asset.Load(path + "/Component Library/Component Library Config").IsLoaded) return Asset.Load(path); } return project; } public static Asset getAssetForBranch(Asset asset, Asset branchAsset) { var project = getProject(branchAsset); var projectPath = project.AssetPath; var assetPath = asset.AssetPath; if (assetPath.Count >= projectPath.Count && !assetPath.ToString().StartsWith(projectPath.ToString())) { return Asset.Load(projectPath + "/" + string.Join("/", assetPath.Skip(projectPath.Count).Take(999))); } return asset; } public static Asset getComponentLibraryConfig(Asset asset) { if (GlobalLibraryConfig != null && GlobalLibraryConfig.IsLoaded) { return GlobalLibraryConfig; } //String currentFolder = asset.Parent.AssetPath.ToString(); Asset frameworkFolder = getProject(asset); FilterParams fParams = new FilterParams(); fParams.ExcludeProjectTypes = false; fParams.Add(AssetPropertyNames.TemplateLabel, Comparison.Equals, "Component Library Configuration"); Asset componentLibraryConfig = frameworkFolder.GetFilterList(fParams).FirstOrDefault(); //componentLibraryConfig = Asset.Load(currentFolder).GetFilterList(fParams).FirstOrDefault(); //while (currentFolder.Length > 0 && (componentLibraryConfig == null || !componentLibraryConfig.IsLoaded)) //{ // currentFolder = currentFolder.Substring(0, currentFolder.LastIndexOf("/")); // //check if the component library config is at the current level // if (Asset.Load(currentFolder).GetFilterList(fParams).Count > 0) // { // componentLibraryConfig = Asset.Load(currentFolder).GetFilterList(fParams).FirstOrDefault(); // } //} if (componentLibraryConfig == null || !componentLibraryConfig.IsLoaded) { throw new Exception("Unable to find CL Config asset"); } // Populate if anything is empty componentLibraryConfig.GetContent(); if (string.IsNullOrWhiteSpace(componentLibraryConfig["component_class_folder"]) || string.IsNullOrWhiteSpace(componentLibraryConfig["component_library_components_folder"]) || string.IsNullOrWhiteSpace(componentLibraryConfig["component_library_models_folder"]) || string.IsNullOrWhiteSpace(componentLibraryConfig["component_library_namespace"]) || string.IsNullOrWhiteSpace(componentLibraryConfig["component_library_project_folder"]) || string.IsNullOrWhiteSpace(componentLibraryConfig["component_library_root_folder"]) || string.IsNullOrWhiteSpace(componentLibraryConfig["site_root"])) { var siteRoot = Asset.GetSiteRoot(asset); var project = getProject(asset); var projectPath = project.AssetPath.ToString(); if (string.IsNullOrWhiteSpace(componentLibraryConfig["site_root"])) componentLibraryConfig["site_root"] = siteRoot.GetCmsUtilityLink(UtilityLinkType.Internal); if (string.IsNullOrWhiteSpace(componentLibraryConfig["component_library_namespace"])) componentLibraryConfig["component_library_namespace"] = "Component_Library.Component_Project.Components"; if (string.IsNullOrWhiteSpace(componentLibraryConfig["component_library_project_folder"])) componentLibraryConfig["component_library_project_folder"] = project.GetCmsUtilityLink(UtilityLinkType.Internal); if (string.IsNullOrWhiteSpace(componentLibraryConfig["component_class_folder"])) componentLibraryConfig["component_class_folder"] = Asset.Load(projectPath + "/Library").GetCmsUtilityLink(UtilityLinkType.Internal); if (string.IsNullOrWhiteSpace(componentLibraryConfig["component_library_root_folder"])) componentLibraryConfig["component_library_root_folder"] = Asset.Load(projectPath + "/Component Library").GetCmsUtilityLink(UtilityLinkType.Internal); if (string.IsNullOrWhiteSpace(componentLibraryConfig["component_library_components_folder"])) componentLibraryConfig["component_library_components_folder"] = Asset.Load(projectPath + "/Component Library/Component Definitions").GetCmsUtilityLink(UtilityLinkType.Internal); if (string.IsNullOrWhiteSpace(componentLibraryConfig["component_library_models_folder"])) componentLibraryConfig["component_library_models_folder"] = Asset.Load(projectPath + "/Models").GetCmsUtilityLink(UtilityLinkType.Internal); } GlobalLibraryConfig = componentLibraryConfig; return GlobalLibraryConfig; } public static String componentsPath(Asset asset) { Asset componentLibraryConfig = getComponentLibraryConfig(asset); return Asset.Load(componentLibraryConfig["component_library_components_folder"]).AssetPath.ToString(); } public static Asset getComponentLibraryModelFolder(Asset asset) { Asset componentLibraryConfig = getComponentLibraryConfig(asset); return Asset.Load(componentLibraryConfig["component_library_models_folder"]); //Asset componentLibraryFolder = Asset.Load(getComponentLibraryConfig(asset)["component_class_folder"]); //if (!componentLibraryFolder.IsLoaded) //{ // componentLibraryFolder = Asset.Load("/" + asset.AssetPath[0] + "/Component Project/Components"); // if (!componentLibraryFolder.IsLoaded) // { // throw new Exception("Error Loading the Components library folder in the Components Project"); // } //} //return Asset.Load(componentLibraryFolder.Parent.AssetPath.ToString() + "/Models"); } public static Asset getComponentLibraryProjectFolder(Asset asset) { Asset componentLibraryConfig = getComponentLibraryConfig(asset); return Asset.Load(componentLibraryConfig["component_library_project_folder"]); } public static Asset getComponentLibraryComponentsFolder(Asset asset) { Asset componentLibraryConfig = getComponentLibraryConfig(asset); return Asset.Load(componentLibraryConfig["component_library_components_folder"]); } public static Asset getcomponentLibraryRootFolder(Asset asset) { Asset componentLibraryConfig = getComponentLibraryConfig(asset); return Asset.Load(componentLibraryConfig["component_library_root_folder"]); } public static Asset getComponentLibraryClassFolder(Asset asset) { Asset componentLibraryConfig = getComponentLibraryConfig(asset); return Asset.Load(componentLibraryConfig["component_class_folder"]); //return Asset.Load(getComponentLibraryConfig(asset)["component_class_folder"]); } public static Asset getComponentLibrarySiteRootFolder(Asset asset) { Asset componentLibraryConfig = getComponentLibraryConfig(asset); return Asset.Load(componentLibraryConfig["site_root"]); } public static String getComponentLibraryNamespace(Asset asset) { // DEBUG return "Component_Library.Component_Project.Components"; Asset componentLibraryConfig = getComponentLibraryConfig(asset); if (!String.IsNullOrWhiteSpace(componentLibraryConfig.Raw["component_library_namespace"])) { return componentLibraryConfig.Raw["component_library_namespace"]; } else { Asset componentLibraryFolder = Asset.Load(componentLibraryConfig["component_class_folder"]); String componentNamespace = componentLibraryFolder.AssetPath.ToString().Replace(" ", "_").Replace("/", "."); if (componentNamespace[0] == '.') { componentNamespace = componentNamespace.Substring(1); } return componentNamespace; } } public static Asset getComponentAsset(Asset asset, String componentName) { Asset componentsFolder = getComponentLibraryComponentsFolder(asset); FilterParams fParams = new FilterParams(); fParams.Add(AssetPropertyNames.Label, Comparison.Equals, componentName); return componentsFolder.GetFilterList(fParams).FirstOrDefault(); } /// <summary> /// Creates a wysiwyg template for the specified component asset. /// </summary> /// <param name="asset">The component asset for which a wysiwyg template should be created</param> /// <param name="templateFolderPath">The folder path where the wysiwyg template should be created</param> /// <returns></returns> public static Asset createWysiwygTemplate(Asset asset, String templateFolderPath) { Asset wysiwygTemplatesFolder = Asset.Load(templateFolderPath); Asset wysiwygTemplate = null; String body = @"<%@ Page Language=""C#"" Inherits=""CrownPeak.Internal.Debug.OutputInit"" %> <%@ Import Namespace=""CrownPeak.CMSAPI"" %> <%@ Import Namespace=""CrownPeak.CMSAPI.Services"" %> <%@ Import Namespace=""CrownPeak.CMSAPI.CustomLibrary"" %> <!--DO NOT MODIFY CODE ABOVE THIS LINE--> <%//This plugin uses OutputContext as its context class type%> <% // output.aspx: template file to specify the published content in site HTML // if no preview.aspx exists, then this is used by default for preview Out.WriteLine(ComponentLibraryHelper.generateComponentPreview(Asset.Load(" + asset.AssetPath + @"))); %>"; Dictionary<String, String> contentDict = new Dictionary<String, String>() { { "body", body } }; FilterParams fParams = new FilterParams(); fParams.Add(AssetPropertyNames.Label, Comparison.Equals, asset.Label); List<Asset> existingAssetList = wysiwygTemplatesFolder.GetFilterList(fParams); if (existingAssetList != null && existingAssetList.Count == 1) { wysiwygTemplate = Asset.Load(existingAssetList[0].Id); wysiwygTemplate.SaveContentField("body", body); } else { Asset saveLocation = Asset.Load("/System/CMS Snippets/Default"); String codeFileModelPath = getComponentLibraryModelFolder(asset).AssetPath + "/Code File"; Asset codeFileModel = Asset.Load(codeFileModelPath); if (saveLocation.IsLoaded && codeFileModel.IsLoaded) { wysiwygTemplate = Asset.CreateNewAsset(asset.Label, saveLocation, codeFileModel, contentDict); } else { if (!saveLocation.IsLoaded) { Out.DebugWriteLine( "Unable to load the save location for the Wysiwyg Template: /System/CMS Snippets/Default"); } if (!codeFileModel.IsLoaded) { Out.DebugWriteLine("Unable to load the code file model for the Wysiwyg Template: " + codeFileModelPath); } } } return wysiwygTemplate; } /// <summary> /// Recompiles all the code files in the /System/Library folder /// </summary> public static bool recompileLibrary(Asset asset) { return Asset.RecompileLibrary(getComponentLibraryClassFolder(asset).Id); } /// <summary> /// Returns the regular expression used to locate the specified content node type. /// </summary> /// <param name="type">The name of the markup field for which you want the corresponding regular expression returned</param> /// <returns></returns> public static Regex getContentFieldRegex(ContentNodeType type, String name = "") { if (type == ContentNodeType.ListNodeAndContent) { return new Regex(@"<" + repeatableNodeName + @"(\w|\s|\=|""|-)*>(.|\n)*?</" + repeatableNodeName + ">", RegexOptions.Compiled | RegexOptions.IgnoreCase); } else if (type == ContentNodeType.ListNode) { if (name != "") { return new Regex(@"\<" + repeatableNodeName + @"(\w|\s|-)*\=""" + name + @""">", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace); } else { return new Regex(@"\<" + repeatableNodeName + @"(\w|\s|\=|""|-)*>", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace); } } else if (type == ContentNodeType.PreviewNodeOpen) { return new Regex(@"\<" + previewOnlyNodeName + @">", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace); } else if (type == ContentNodeType.PreviewNodeClose) { return new Regex(@"</" + previewOnlyNodeName + ">", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace); } else if (type == ContentNodeType.PreviewNodeAndContent) { return new Regex(@"\<" + previewOnlyNodeName + @">(.|\n)*?</" + previewOnlyNodeName + ">", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace); } else if (type == ContentNodeType.PublishNodeOpen) { return new Regex(@"\<" + publishOnlyNodeName + @">", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace); } else if (type == ContentNodeType.PublishNodeClose) { return new Regex(@"</" + publishOnlyNodeName + ">", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace); } else if (type == ContentNodeType.PublishNodeAndContent) { return new Regex(@"\<" + publishOnlyNodeName + @">(.|\n)*?</" + publishOnlyNodeName + ">", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace); } else if (type == ContentNodeType.ListNodeAndContentV2) { if (name != "") { return new Regex(@"<" + repeatableNodeName + @"(\w|\s|)*\=""" + name + @"""> (?><" + repeatableNodeName + @" (?<DEPTH>) | </" + repeatableNodeName + @"> (?<-DEPTH>) | .? )* (?(DEPTH)(?!))</" + repeatableNodeName + @">", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace | RegexOptions.Singleline); } else { return new Regex(@"<" + repeatableNodeName + @"(\w|\s|\=|""|-)*> (?><" + repeatableNodeName + @" (?<DEPTH>) | </" + repeatableNodeName + @"> (?<-DEPTH>) | .? )* (?(DEPTH)(?!))</" + repeatableNodeName + @">", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace | RegexOptions.Singleline); } } else { //return new Regex(@"\<" + contentNodeName + @"(\w|\s|\=|""|-)*/>", RegexOptions.Compiled | RegexOptions.IgnoreCase); return new Regex(@"(?<!\{)\{\s*[^0-9][a-zA-Z0-9\s\w|:]*\}(?!\})", RegexOptions.Compiled | RegexOptions.IgnoreCase); } } /// <summary> /// Gets the content placeholder markup in the specified content markup /// </summary> /// <param name="fieldName">the content placeholder name to retrieve</param> /// <param name="type">the type of content placeholder</param> /// <param name="componentMarkup">the markup that should be searched through</param> /// <returns></returns> public static String getContentPlaceholderMarkup(String fieldName, ContentNodeType type, String componentMarkup, bool isNestedList = false) { Regex rx = getContentFieldRegex(type); MatchCollection matches = rx.Matches(componentMarkup); if (type == ContentNodeType.Content) { foreach (Match m in matches) { String currentFieldName = getContentPlaceholderName(m.Value); if (currentFieldName == fieldName) { Out.DebugWriteLine(Util.HtmlEncode(m.Value) + " tag found! for fieldName: " + fieldName); return m.Value; } } } else { foreach (Match m in matches) { if (m.Value.Contains("name=\"" + fieldName + "\"")) { if (isNestedList && !m.Value.Trim().StartsWith("<cp-list name=\"" + fieldName + "\"")) { Regex startNodeRegex = getContentFieldRegex(ContentNodeType.ListNode); Match startNodeMatch = startNodeRegex.Match(componentMarkup); String subContent = m.Value.Trim().Replace(startNodeMatch.Value, ""); subContent = subContent.Substring(0, subContent.LastIndexOf("</" + repeatableNodeName + ">")).Trim(); return getContentPlaceholderMarkup(fieldName, type, subContent, true); } else { Out.DebugWriteLine(Util.HtmlEncode(m.Value) + " tag found! for fieldName: " + fieldName); return m.Value; } } } } Out.DebugWriteLine("No matching tags found for fieldName: " + fieldName); return ""; } /// <summary> /// Function used to start the navigation wrapper /// </summary> /// <param name="asset">the asset to be wrapped</param> /// <param name="context">the context of the specified asset</param> /// <param name="wrapper">the name of the wrapper template</param> public static void startWrap(Asset asset, OutputContext context, String wrapper = "Content Wrapper", String wrapperType = null) { if (wrapperType != null && wrapperType == "custom") { Out.Wrap(wrapper); } else { Asset wrapperAsset = Asset.Load(Asset.Load(asset.TemplateId).Parent.AssetPath + "/" + wrapper); if (wrapperAsset.IsLoaded) { Out.Wrap(Asset.Load(asset.TemplateId).Parent.AssetPath + "/" + wrapper); } else { Out.Wrap(wrapper); } } } /// <summary> /// Function used to end the navigation wrapper. IS CURRENTLY EMPTY and will need to be updated when content actually needs to be published. /// </summary> /// <param name="asset">the asset to be wrapped</param> /// <param name="context">the context of the specified asset</param> public static void endWrap(Asset asset, OutputContext context) { } /// <summary> /// Calls the input function for the specified component asset class file /// </summary> /// <param name="componentAsset">the asset corresponding to the class whos input function is called</param> public static void generateComponentPreviewContentInput(Asset componentAsset, String label = "", String name = "preview") { String className = componentAsset.Raw["class_name"].ToString(); String componentNamespace = getComponentLibraryNamespace(componentAsset); string objectNamespaceString = String.Format(componentNamespace + "." + componentAsset.Raw["class_name"]); ComponentBase componentInstance = (ComponentBase)XUtils.CreateInstance(objectNamespaceString); if (!String.IsNullOrWhiteSpace(componentAsset["class_name"]) && componentInstance != null) { componentInstance.ComponentInput(componentAsset, null, label, name); } else { Input.ShowMessage("This area allows you to customize the component preview once you save the markup in the pattern tab"); } } public static Asset getComponentCodeFileAsset(String className, Asset componentAsset, ComponentClassNameType type) { String classFileLabel = createComponentClassFileName(className, type); Asset componentLibraryClassFolder = getComponentLibraryClassFolder(componentAsset); if (!String.IsNullOrWhiteSpace(classFileLabel) && componentLibraryClassFolder.IsLoaded) { Asset codeFile = Asset.Load(componentLibraryClassFolder.AssetPath.ToString() + "/" + classFileLabel); if (codeFile.IsLoaded) { return codeFile; } } return null; } /// <summary> /// Calls the post_input function for the specified component asset class file /// </summary> /// <param name="componentAsset">the asset corresponding to the class whos post_input function is called</param> /// <param name="context">the current context</param> /// <returns>returns the context with any errors that were caught during post_input validation</returns> public static PostInputContext generateComponentPreviewPostInput(Asset componentAsset, PostInputContext context) { try { String className = componentAsset.Raw["class_name"].ToString(); String componentNamespace = getComponentLibraryNamespace(componentAsset); string objectNamespaceString = String.Format(componentNamespace + "." + componentAsset.Raw["class_name"]); Out.DebugWriteLine(objectNamespaceString); ComponentBase componentInstance = (ComponentBase)XUtils.CreateInstance(objectNamespaceString); //CrownPeak.CMSAPI.CustomLibrary.MediaBlockSection componentInstance = new CrownPeak.CMSAPI.CustomLibrary.MediaBlockSection(); componentInstance.ComponentPostInput(componentAsset, context, "preview"); } catch (Exception ex) { } return context; } /// <summary> /// Calls the output function for the specified component asset class file /// </summary> /// <param name="componentAsset">the asset corresponding to the class whos output function is called</param> /// <returns>returns the outputed content via a string</returns> public static string generateComponentPreview(Asset componentAsset, OutputContext context, string name = "preview", Asset renderAsset = null) { StringBuilder sbContent = new StringBuilder(); try { String className = componentAsset.Raw["class_name"].ToString(); String componentNamespace = getComponentLibraryNamespace(componentAsset); string objectNamespaceString = String.Format(componentNamespace + "." + componentAsset.Raw["class_name"]); Out.DebugWriteLine("objectNamespaceString: " + objectNamespaceString); ComponentBase componentInstance = (ComponentBase)XUtils.CreateInstance(objectNamespaceString); //Hero componentInstance = new Hero(); if (renderAsset == null) { sbContent.Append(componentInstance.ComponentOutput(componentAsset, context, name)); } else { sbContent.Append(componentInstance.ComponentOutput(renderAsset, context, name)); } } catch (Exception ex) { Out.DebugWriteLine("exception caught: " + ex.Message + " :: " + ex.InnerException); } return sbContent.ToString(); } /// <summary> /// adds a list node to the content dictionary /// </summary> /// <param name="currentContent">the current content dictionary where the list node should be added to</param> /// <param name="nodeString">the string representation of the list node</param> /// <param name="currentPanel">the current panel index which will be incremented accordingly</param> /// <returns>Returns the updated content dictionary with the list node added</returns> private static Dictionary<String, String> addListNodeContent(Dictionary<String, String> currentContent, String nodeString, ref int currentPanel) { Regex listNodeRegex = getContentFieldRegex(ContentNodeType.ListNode); Match listNodeMatch = listNodeRegex.Match(nodeString); if (listNodeMatch != null && !String.IsNullOrEmpty(listNodeMatch.Value)) { String fieldName = getAttribValueFromComponentMarkup(listNodeMatch.Value, "name"); if (!currentContent.Any(x => x.Key.Contains("component_list_label") && x.Value == fieldName)) { String nodeContent = nodeString.Replace("</" + repeatableNodeName + ">", "").Replace(listNodeMatch.Value, "").Trim(); Out.DebugWriteLine("repeatableNodeName found with field name: {0}", fieldName ?? "N/S"); //Need to parse remaining content in the list node //get the types for each content field specified in the remaining content //get the field names //Dictionary<String, String> fieldNamesAndTypes = new Dictionary<string, string>(); currentContent.Add("component_panel:" + currentPanel, (currentPanel - 1).ToString()); currentContent.Add("component_category:" + currentPanel, "list"); currentContent.Add("component_list_label:" + currentPanel, fieldName); currentContent.Add("component_list_content:" + currentPanel, nodeContent); currentPanel++; } } return currentContent; } /// <summary> /// adds a component node to the content dictionary /// </summary> /// <param name="currentContent">the current content dictionary where the list node should be added to</param> /// <param name="contentString">the string representation of the component node</param> /// <param name="currentPanel">the current panel index which will be incremented accordingly</param> /// <param name="isOnlyOneComponent">identifies if the compoentnt being added is the only component in the markup</param> /// <param name="containedComponents">field used specifically if the component is apart of a list. keeps a comma seperated list of components contained in the list</param> /// <returns>Returns the updated content dictionary with the list node added</returns> private static Dictionary<String, String> addContentPlaceholderContent(Dictionary<String, String> currentContent, String contentString, ref int currentPanel, bool isOnlyOneComponent, ref StringBuilder containedComponents) { String fieldName = getContentPlaceholderName(contentString); String typeName = getContentPlaceholderTypeFromMarkup(contentString); bool typeInMarkup = true; if (typeName == string.Empty) { typeName = defaultContentPlaceholderType; typeInMarkup = false; } String fieldLabel = cap(fieldName); if (fieldName != String.Empty) { fieldLabel = cap(fieldName); } if (!currentContent.Any(x => x.Key.Contains("component_component_label") && x.Value == fieldName)) { Out.DebugWriteLine("contentNode found with field name: {0}, type: {1}, panelCount: {2}", fieldName ?? "N/S", typeName ?? "N/S", currentPanel.ToString()); if (isOnlyOneComponent) { currentContent.Add("component_panel", (currentPanel - 1).ToString()); currentContent.Add("component_category", "component"); currentContent.Add("component_component_label", fieldName); currentContent.Add("component_component_type", typeName); currentContent.Add("component_component_type_in_markup", typeInMarkup.ToString()); } else { currentContent.Add("component_panel:" + currentPanel, (currentPanel - 1).ToString()); currentContent.Add("component_category:" + currentPanel, "component"); currentContent.Add("component_component_label:" + currentPanel, fieldName); currentContent.Add("component_component_type:" + currentPanel, typeName); currentContent.Add("component_component_type_in_markup:" + currentPanel, typeInMarkup.ToString()); } currentPanel++; if (containedComponents != null) { containedComponents.Append(fieldName + ", "); } } else { Out.DebugWriteLine("Unable to add component: {0} because it already exists", fieldName); } return currentContent; } /// <summary> /// Parses the content field markup to get the content field name /// </summary> /// <param name="contentPlaceholderMarkup">the content field markup for which the field name is to be returned.</param> /// <returns>the content field name from the provided content</returns> public static String getContentPlaceholderName(String contentPlaceholderMarkup) { int delimeterIndex = contentPlaceholderMarkup.IndexOf(":"); String contentPlaceholderName = ""; if (delimeterIndex == -1) { contentPlaceholderName = contentPlaceholderMarkup.Replace("{", "").Replace("}", "").Trim(); } else { contentPlaceholderName = contentPlaceholderMarkup.Substring(0, contentPlaceholderMarkup.IndexOf(":")).Replace("{", "").Replace("}", "").Trim(); } return contentPlaceholderName; } /// <summary> /// Parses the content field markup to get the content field type /// </summary> /// <param name="contentPlaceholderMarkup">the content field markup for which the field name is to be returned.</param> /// <returns>the content field name from the provided content</returns> public static String getContentPlaceholderTypeFromMarkup(String contentPlaceholderMarkup) { if (!contentPlaceholderMarkup.Contains(":")) { return string.Empty; } var result = contentPlaceholderMarkup.Substring(contentPlaceholderMarkup.IndexOf(":") + 1).Replace("{", "").Replace("}", "").Trim(); if (result.Contains(":")) { result = result.Substring(0, result.IndexOf(":")); } return result; } /// <summary> /// Parses the content field markup to get the indexed field details /// </summary> /// <param name="contentPlaceholderMarkup">the content field markup for which the indexed field is to be returned.</param> /// <returns>the content indexed field details from the provided content</returns> public static String getContentPlaceholderIndexedFieldFromMarkup(String contentPlaceholderMarkup) { if (!contentPlaceholderMarkup.Contains(":")) { return string.Empty; } var segments = contentPlaceholderMarkup.Replace("{", "").Replace("}", "").Trim().Split(":".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); if (segments.Length > 2) { var thirdSegment = segments[2].Trim(); if (thirdSegment.StartsWith("Indexed")) return thirdSegment.Substring(7); } return string.Empty; } /// <summary> /// Retrieves the index of the content field of the provided content field key. Only expects non-nested componnets with no more then 1 semi-colon /// </summary> /// <param name="contentFieldKey">The content field key for which the index is to be returned</param> /// <returns>The index of the content field key</returns> private static int getContentFieldIndex(String contentFieldKey) { int index = -1; if (contentFieldKey.Contains(":")) { index = Convert.ToInt32(contentFieldKey.Substring(contentFieldKey.LastIndexOf(":") + 1, contentFieldKey.Length - (contentFieldKey.LastIndexOf(":") + 1))); Out.DebugWriteLine("returning index \"" + index.ToString() + "\" for " + contentFieldKey); } return index; } /// <summary> /// Displays the content of the dictioary provided for testing purposes /// </summary> /// <param name="content">the content to be displayed</param> private static void displayContent(Dictionary<string, string> content) { Out.DebugWriteLine("Content Fields Being Deleted..."); foreach (String key in content.Keys) { Out.DebugWriteLine(key + " : " + content[key]); } Out.DebugWriteLine("End Content Fields Being Deleted"); } /// <summary> /// Retrives the attribute value for the specified attribName in the specified markup /// </summary> /// <param name="markup">The markup to be parsed</param> /// <param name="attribName">the attribute for which the value is to be returned</param> /// <returns>the attribute value</returns> public static String getAttribValueFromComponentMarkup(String markup, String attribName) { if (String.IsNullOrWhiteSpace(markup) || String.IsNullOrWhiteSpace(attribName)) { return string.Empty; } Regex rx = new Regex(attribName + "\\s*=\\s*\"[a-zA-Z0-9\\w|-]*\"", RegexOptions.Compiled | RegexOptions.IgnoreCase); Match attribMatch = rx.Match(markup); Out.DebugWriteLine(attribMatch.Success ? "attribMatch.value: " + attribMatch.Value : "no match found"); if (String.IsNullOrWhiteSpace(attribMatch.Value)) { return string.Empty; } String attribMatchValue = attribMatch.Value.Replace(" ", ""); String value = attribMatchValue.Substring(attribName.Length + 2, attribMatchValue.Length - (attribName.Length + 3)); if (attribName == "label") { return cap(value); // char.ToUpper(value[0]) + value.Substring(1); } else { return value; } } public static String getListNodeContent(String markup) { Regex listNodeRegex = getContentFieldRegex(ContentNodeType.ListNode); Match listNodeMatch = listNodeRegex.Match(markup); return markup.Replace("</" + repeatableNodeName + ">", "").Replace(listNodeMatch.Value, "").Trim(); } public static String getListNodeComponents(String markup) { StringBuilder containedComponents = new StringBuilder(); Regex contentPlaceholderRegex = getContentFieldRegex(ContentNodeType.Content); MatchCollection matches = contentPlaceholderRegex.Matches(markup); foreach (Match match in matches) { containedComponents.Append(getContentPlaceholderName(match.Value) + ", "); } if (!String.IsNullOrWhiteSpace(containedComponents.ToString())) { if (containedComponents.ToString().EndsWith(", ")) { containedComponents.Remove(containedComponents.Length - 2, 2); } } return containedComponents.ToString(); } /// <summary> /// Returns the specifed number of tab characters /// </summary> /// <param name="n">The number of tab characters to be returned</param> /// <returns>The specifed number of tab characters</returns> private static String moarTabs(int n) { StringBuilder sb = new StringBuilder(); for (int x = 0; x < n; x++) { sb.Append(tabChar); } return sb.ToString(); } /// <summary> /// Capitalizes the first letter of the provided string /// </summary> /// <param name="s">The string where the first letter is to be capitalized</param> /// <returns>The provided string with the first letter capitalized</returns> public static String cap(String s) { if (s.Length < 2) { return s; } else { return char.ToUpper(s[0]) + s.Substring(1); } } /// <summary> /// Changes the provided string by capitalizing the first letter and then capitalizing every subsaquent character that appears after an underscore /// </summary> /// <param name="s">The string to be changed</param> /// <returns>the updated string</returns> public static String labelize(String s) { String label = ""; for (int index = 0; index < s.Length; index++) { if (index == 0) { label = label + Char.ToUpper(s[index]); } else if (s[index] == '_') { label = label + " " + Char.ToUpper(s[index + 1]); index++; } else { label = label + s[index]; } } return label; } /// <summary> /// Counts all components (list and content) in the markup /// </summary> /// <param name="markup">The markup for which components are counted</param> /// <returns>The total number of components</returns> private static int getTotalComponentCount(String markup) { Regex compRegex = getContentFieldRegex(ContentNodeType.Content); Regex listRegex = getContentFieldRegex(ContentNodeType.ListNode); MatchCollection compMatches = compRegex.Matches(markup); MatchCollection Listmatches = listRegex.Matches(markup); if (compMatches != null && Listmatches != null) { return compMatches.Count + Listmatches.Count; } else { Out.DebugWriteLine("0 content fields or or " + repeatableNodeName + " elements found in markup."); return 0; } } /// <summary> /// parses the provided markup, removes either the preview or publish content depending on the context and then returns the updated markup /// </summary> /// <param name="asset">The current asset</param> /// <param name="context">The current asset's context</param> /// <param name="markup">The current markup being constructed</param> /// <returns>an updated markup with the preview or publish content removed depending on the context</returns> public static String updateMarkupForPreviewPublish(OutputContext context, String markup) { if (context.IsPublishing) { //removes all preview content from the markup Regex previewNodeAndContentRegex = getContentFieldRegex(ContentNodeType.PreviewNodeAndContent); MatchCollection previewContentMatches = previewNodeAndContentRegex.Matches(markup); foreach (Match match in previewContentMatches) { markup = markup.Replace(match.Value, ""); } //removes all the publish node open tags from the markup Regex publishNodeOpenRegex = getContentFieldRegex(ContentNodeType.PublishNodeOpen); MatchCollection publishNodeOpenMatches = publishNodeOpenRegex.Matches(markup); foreach (Match match in publishNodeOpenMatches) { markup = markup.Replace(match.Value, ""); } //removes all the publish node close tags from the markup Regex publishNodeCloseRegex = getContentFieldRegex(ContentNodeType.PublishNodeClose); MatchCollection publishNodeCloseMatches = publishNodeCloseRegex.Matches(markup); foreach (Match match in publishNodeCloseMatches) { markup = markup.Replace(match.Value, ""); } } else { //removes all publish content from the markup Regex publishNodeAndContentRegex = getContentFieldRegex(ContentNodeType.PublishNodeAndContent); MatchCollection publishContentMatches = publishNodeAndContentRegex.Matches(markup); foreach (Match match in publishContentMatches) { markup = markup.Replace(match.Value, ""); } //removes all the preview node open tags from the markup Regex previewNodeOpenRegex = getContentFieldRegex(ContentNodeType.PreviewNodeOpen); MatchCollection previewNodeOpenMatches = previewNodeOpenRegex.Matches(markup); foreach (Match match in previewNodeOpenMatches) { markup = markup.Replace(match.Value, ""); } //removes all the preview node close tags from the markup Regex previewNodeCloseRegex = getContentFieldRegex(ContentNodeType.PreviewNodeClose); MatchCollection previewNodeCloseMatches = previewNodeCloseRegex.Matches(markup); foreach (Match match in previewNodeCloseMatches) { markup = markup.Replace(match.Value, ""); } } return markup; } /// <summary> /// Values used to identify content node types /// </summary> public enum ContentNodeType { Content, ListNode, ListNodeAndContent, ListNodeAndContentV2, PreviewNodeOpen, PreviewNodeClose, PreviewNodeAndContent, PublishNodeOpen, PublishNodeClose, PublishNodeAndContent } public enum ComponentClassNameType { Base, Override } public enum ContentPlaceholderCategory { List, Component } public static List<ComponentContentPlaceholder> buildComponentContentPlaceholderFromMarkup(String componentMarkup) { List<ComponentContentPlaceholder> componentContentPlaceholdersList = new List<ComponentContentPlaceholder>(); ContentParser(ref componentContentPlaceholdersList, componentMarkup); return componentContentPlaceholdersList; } public static List<ComponentContentPlaceholder> buildComponentContentPlaceholderForTemplateFromMarkup(String componentMarkup) { List<ComponentContentPlaceholder> componentContentPlaceholdersList = new List<ComponentContentPlaceholder>(); ContentParserForTemplate(ref componentContentPlaceholdersList, componentMarkup); return componentContentPlaceholdersList; } // public static String parserTest(String ComponentMarkup) // { // //Regex rx = new Regex(@"<" + repeatableNodeName + @"(\w|\s|\=|""|-)*>(.|\n)*?</" + repeatableNodeName + ">", RegexOptions.Compiled | RegexOptions.IgnoreCase); // StringBuilder sb = new StringBuilder(); // string input = @"<h1>{title}</h1> // //<div class=""intro""> // // {intro_content : Wysiwyg} // //</div> // //<cp-list name=""primary_accordion_list""> // // {accordion_title : AccordionTitle} // // <cp-list name=""a_panel_list""> // // {panel_content : Wysiwyg} // // </cp-list> // // <cp-list name=""b_panel_list""> // // {panel_content : Wysiwyg} // // </cp-list> // //</cp-list> // //<cp-list name=""secondary_accordion_list_b""> // // {accordion_title : AccordionTitle} // // <cp-list name=""c_panel_list""> // // {panel_content : Wysiwyg} // // </cp-list> // //</cp-list>"; // //string input = "username,TB_PEOPLE.fields(FirstName,LastName,TB_PHONE.fields(num_phone1, num_phone2)),password"; // string pattern = @"(?>\w+\.)?\w+\((?>\((?<DEPTH>)|\)(?<-DEPTH>)|[^()]+)*\)(?(DEPTH)(?!))|\w+"; // //@"<" + repeatableNodeName + @"(\w|\s|\=|""|-)*>(.|\n)*?</" + repeatableNodeName + ">" // // @"(<control\sid=.+?>.+?(?:</control>){2,})",(RegexOptions) 0); // //Regex regex = new Regex(@"(<cp-list\sname=.+?>.+?(?:</cp-list>){2,})",(RegexOptions) 0); // Regex regex = new Regex(@"<" + repeatableNodeName + @"(\w|\s|\=|""|-)*> (?><" + repeatableNodeName + @" (?<DEPTH>) | </" + repeatableNodeName + @"> (?<-DEPTH>) | .? )* (?(DEPTH)(?!))</" + repeatableNodeName + @">", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace | RegexOptions.Singleline); // sb.AppendLine(@"<" + repeatableNodeName + @"(\w|\s|\=|""|-)*> (?><" + repeatableNodeName + @" (?<DEPTH>) | </" + repeatableNodeName + @"> (?<-DEPTH>) | .? )* (?(DEPTH)(?!))</" + repeatableNodeName + @">"); // MatchCollection matches = regex.Matches(input); // sb.AppendLine(input).AppendLine(); // sb.AppendLine("# of Matches: " + matches.Count).AppendLine(); // foreach (Match match in matches) // { // sb.AppendLine("Match:: " + match.Groups[0].Value); // } // return sb.ToString(); // } //private static List<XmlNode> getXmlNodeListFromMarkup(String componentMarkup) //{ // List<XmlNode> nodeList = null; // if (String.IsNullOrWhiteSpace(componentMarkup)) // { // Input.ShowMessage("The component markup is not available"); // return nodeList; // } // Out.DebugWriteLine("componentMarkup: " + Util.HtmlEncode(componentMarkup)); // Regex rootNodeRx = new Regex(@"^\s*<\s*([a-zA-Z0-9]|-)*\s*", RegexOptions.Compiled | RegexOptions.IgnoreCase); // Match rootNodeMatch = rootNodeRx.Match(componentMarkup); // String rootNodeName = ""; // if (!rootNodeMatch.Success) // { // Out.DebugWriteLine("No match for ar root node found."); // } // rootNodeName = rootNodeMatch.Value.Substring(rootNodeMatch.Value.IndexOf("<") + 1).Trim(); // Out.DebugWriteLine("Root Node Match value: {0}", rootNodeName); // try // { // nodeList = Util.LoadXml(componentMarkup, rootNodeName); // } // catch (Exception ex) // { // if (ex.Message.Contains("There are multiple root elements") || ex.Message.Contains("We're sorry - but the system was unable to complete your request due to an internal error.")) // { // Out.DebugWriteLine("multiple root elements found. creating temporary root element..."); // String tempComponentMarkup = "<root>" + componentMarkup + "</root>"; // nodeList = Util.LoadXml(tempComponentMarkup, "root"); // nodeList = nodeList[0].XmlNodes; // } // else // { // throw ex; // } // } // return nodeList; //} public static void ContentParser(ref List<ComponentContentPlaceholder> componentContentPlaceholdersList, String myComponentMarkup) { //Pull out Lists Regex listAndContentRegex = getContentFieldRegex(ContentNodeType.ListNodeAndContentV2); MatchCollection listMAtchesList = listAndContentRegex.Matches(myComponentMarkup); //goes through and replaces all of the list matches found with empty strings so that we can focus on any remaining placeholders myComponentMarkup = listMAtchesList.Cast<Match>().Aggregate(myComponentMarkup, (current, listMatch) => current.Replace(listMatch.Value, String.Empty)); //for each list recursion foreach (Match listMatch in listMAtchesList) { ComponentContentPlaceholder listCcp = getComponentContentPlaceholderFromMatch(listMatch); componentContentPlaceholdersList.Add(listCcp); } //add remaining content fields Regex contentPlaceholderRegex = getContentFieldRegex(ContentNodeType.Content); MatchCollection contenPlaceholdertMatchesList = contentPlaceholderRegex.Matches(myComponentMarkup); foreach (Match contentPlaceholderMatch in contenPlaceholdertMatchesList) { componentContentPlaceholdersList.Add(new ComponentContentPlaceholder(contentPlaceholderMatch, "component")); } //return } public static void ContentParserForTemplate(ref List<ComponentContentPlaceholder> componentContentPlaceholdersList, String myTemplateMarkup) { //Pull out Lists Regex listAndContentRegex = getContentFieldRegex(ContentNodeType.ListNodeAndContentV2); MatchCollection listMatchesList = listAndContentRegex.Matches(myTemplateMarkup); //goes through and replaces all of the list matches found with empty strings so that we can focus on any remaining placeholders myTemplateMarkup = listMatchesList.Cast<Match>().Aggregate(myTemplateMarkup, (current, listMatch) => current.Replace(listMatch.Value, String.Empty)); //for each list recursion foreach (Match listMatch in listMatchesList) { ComponentContentPlaceholder listCcp = getComponentContentPlaceholderFromMatch(listMatch); componentContentPlaceholdersList.Add(listCcp); } //add remaining content fields Regex contentPlaceholderRegex = getContentFieldRegex(ContentNodeType.Content); MatchCollection contentPlaceholderMatchesList = contentPlaceholderRegex.Matches(myTemplateMarkup); foreach (Match contentPlaceholderMatch in contentPlaceholderMatchesList) { componentContentPlaceholdersList.Add(new ComponentContentPlaceholder(contentPlaceholderMatch, "template")); } //return } private static ComponentContentPlaceholder getComponentContentPlaceholderFromMatch(Match listMatch) { String listMatchValue = listMatch.Value; String listNodeString = getListNodeString(listMatchValue); String content = listMatchValue.Substring(listNodeString.Length + 2, listMatchValue.Length - listNodeString.Length - ("</" + repeatableNodeName + ">").Length - 2).Trim(); ComponentContentPlaceholder listPlaceholder = new ComponentContentPlaceholder(); listPlaceholder.name = getAttribValueFromComponentMarkup(listNodeString, "name"); listPlaceholder.category = ContentPlaceholderCategory.List; listPlaceholder.content = content; listPlaceholder.subComponents = ContentParserHelper(content); return listPlaceholder; } private static List<ComponentContentPlaceholder> ContentParserHelper(String myComponentMarkup) { List<ComponentContentPlaceholder> myComponentContentPlaceholderList = new List<ComponentContentPlaceholder>(); //Pull out Lists Regex listAndContentRegex = getContentFieldRegex(ContentNodeType.ListNodeAndContentV2); MatchCollection listMAtchesList = listAndContentRegex.Matches(myComponentMarkup); //goes through and replaces all of the list matches found with empty strings so that we can focus on any remaining placeholders myComponentMarkup = listMAtchesList.Cast<Match>().Aggregate(myComponentMarkup, (current, listMatch) => current.Replace(listMatch.Value, String.Empty)); //for each list recursion foreach (Match listMatch in listMAtchesList) { ComponentContentPlaceholder listCcp = getComponentContentPlaceholderFromMatch(listMatch); myComponentContentPlaceholderList.Add(listCcp); } //add remaining content fields Regex contentPlaceholderRegex = getContentFieldRegex(ContentNodeType.Content); MatchCollection contenPlaceholdertMatchesList = contentPlaceholderRegex.Matches(myComponentMarkup); foreach (Match contentPlaceholderMatch in contenPlaceholdertMatchesList) { ComponentContentPlaceholder contentPlaceholderToAdd = new ComponentContentPlaceholder(contentPlaceholderMatch, "component"); if (!myComponentContentPlaceholderList.Any(x => x.name == contentPlaceholderToAdd.name && x.category == contentPlaceholderToAdd.category)) { myComponentContentPlaceholderList.Add(contentPlaceholderToAdd); } } //return return myComponentContentPlaceholderList; } private static String getListNodeString(String markup) { return markup.Substring(markup.IndexOf("<"), markup.IndexOf(">") + 1); } public static void deleteComponentContent(Asset asset) { List<String> keysToRemove = asset.GetContentFields().Keys.ToList(); keysToRemove.Remove("markup"); keysToRemove.Remove("class_name"); keysToRemove.Remove("read_only"); keysToRemove.Remove("json_component"); keysToRemove.Remove("component_zones"); keysToRemove.Remove("content_block_hide"); keysToRemove.RemoveAll(x => x.StartsWith("preview_") || x.StartsWith("upload#") || x.StartsWith("upload_name#") || x.StartsWith("ommsnippetid#") || x.StartsWith("ommvariantid#")); asset.DeleteContentFields(keysToRemove); } public static void deleteTemplateContent(PostInputContext context) { List<String> keysToRemove = context.InputForm.Select(f => f.Key).ToList(); keysToRemove.Remove("markup"); keysToRemove.Remove("json_template"); keysToRemove.Remove("wrapper_type"); keysToRemove.Remove("wrapper"); keysToRemove.Remove("custom_wrapper"); keysToRemove.Remove("create"); keysToRemove.Remove("template_name"); keysToRemove.Remove("template_folder"); keysToRemove.Remove("previewAsset"); keysToRemove.Remove("meta"); keysToRemove.Remove("custom_js_css"); keysToRemove.Remove("advanced"); keysToRemove.Remove("enable_tmf"); keysToRemove.Remove("create_output_translate_xml"); keysToRemove.Remove("output_translate_xml_body"); keysToRemove.RemoveAll(x => x.StartsWith("upload#") || x.StartsWith("upload_name#") || x.StartsWith("ommsnippetid#") || x.StartsWith("ommvariantid#")); // Don't do a Remove here else it kills the ability to update and save the fields later //context.InputForm.Remove(keysToRemove); keysToRemove.ForEach(k => context.InputForm[k] = ""); } public static String generateCssHeaderDeclarations(Asset configAsset) { string openTag = "<" + "%"; string closeTag = "%" + ">"; StringBuilder sb = new StringBuilder(); sb.Append("<link rel=\"stylesheet\" href=\"" + Asset.Load(configAsset["css_to_use"]).GetLink(LinkType.Include) + "\" media=\"all\" />").AppendLine(); return sb.ToString(); } //public static String outputComponentPlaceholderListContent(List<ComponentContentPlaceholder> componentContentPlaceholderList) //{ // StringBuilder sb = new StringBuilder(); // foreach (ComponentContentPlaceholder ccp in componentContentPlaceholderList) // { // if (ccp.type == "list") // { // sb.AppendFormat("<p>{0} : {1}</p>", "type", ccp.type); // sb.AppendFormat("<p>{0} : {1}</p>", "type", ccp.type); // } // else if(ccp.type == "content") // { // } // else // { // } // } // return sb.ToString(); //} //private static void ContentParserListHelper(List<XmlNode> nodeList, ref Dictionary<String, String> currentContent, ref StringBuilder containedComponents, ref int panelCount) //{ // foreach (XmlNode currentNode in nodeList) // { // Out.DebugWriteLine("Entered ContentParserListHelper for Node: {0}...", currentNode.Name); // /***IF THE CURRENT NODE IS A CONTENT NODE***/ // if (currentNode.Name == contentNodeName) // { // String fieldName = currentNode.Attributes["name"] ?? String.Empty; // String typeName = currentNode.Attributes["type"] ?? String.Empty; // if (fieldName != String.Empty) // { // String fieldLabel = cap(fieldName); // char.ToUpper(fieldName[0]) + fieldName.Substring(1); // } // if (typeName != String.Empty) // { // typeName = typeName.ToLower(); // } // Out.DebugWriteLine("contentNode found with field name: {0}, type: {1}", fieldName ?? "N/S", typeName ?? "N/S"); // currentContent.Add("component_panel:" + panelCount, (panelCount - 1).ToString()); // currentContent.Add("component_category:" + panelCount, "component"); // currentContent.Add("component_component_label:" + panelCount, fieldName); // currentContent.Add("component_component_type:" + panelCount, typeName); // containedComponents.Append(fieldName + ", "); // panelCount++; // } // /***IF THE CURRENT NODE IS A LIST NODE***/ // else if (currentNode.Name == repeatableNodeName) // { // String fieldName = currentNode.Attributes["name"] ?? String.Empty; // /*if the current node is a list node but we are already in a list throw an error*/ // Input.ShowMessage("Error Parsing componnet Nested List: {0} found", fieldName); // } // //IF THE CURRENT NODE IS NOT A LIST OR CONTENT NODE // else // { // ContentParserListHelper(currentNode.XmlNodes, ref currentContent, ref containedComponents, ref panelCount); // } // } //} } } 261252 1792 /System/Templates/Basis/DeveloperCS/ 1 0 false false 0 0 /Component Project/Library/ComponentLibraryHelperUpdates.cs 261059 17 LibraryClass 2 body using System; using System.CodeDom; using System.Collections.Generic; using System.Linq; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; using CrownPeak.CMSAPI; using CrownPeak.CMSAPI.Experimental; using CrownPeak.CMSAPI.Services; /* Some Namespaces are not allowed. */ namespace Component_Library.Component_Project.Components { public abstract class JsonComponentBase : ComponentBase { // // Summary: // The JSON function which is meant to be overridden by the child class // // Parameters: // asset: // The current asset // // context: // The current OutputContext context // // name: // The content field name for the current field or component // // index: // If this is in a list panel then the current panel index // // Returns: // The JSON for the current component with all the content placeholders names // and their specified content public abstract string ComponentJson(Asset asset, OutputContext context, string name, string index = ""); // // Summary: // The indexed fields function which is meant to be overridden by the child class // // Parameters: // asset: // The current asset // // context: // The current OutputContext context // // name: // The content field name for the current field or component // // index: // If this is in a list panel then the current panel index // // Returns: // A collection of the sortable fields for the component public abstract IEnumerable<IndexedField> ComponentIndexedFields(Asset asset, SearchG2Context context, string name, string index = ""); // // Summary: // The default helper function used to iterate through each panel during the JSON output // process when list panels are used. // // Parameters: // asset: // The current asset // // context: // The current OutputContext context // // name: // The current content field name for the current content field or component // // markup: // The markup that should be repeated within the panel // // listName: // the cp-list name attribute value // // fields: // A Dictionary where each key value pair consist of a list of string parameters // and the corresponding content field's output function // // index: // If this is in a list panel then the current panel index // // Returns: // The markup for the current list panel with all the content placeholders replaced // with their specified content for each panel public string PanelJson(Asset asset, OutputContext context, string name, string markup, string listName, string itemName, Dictionary<List<string>, Func<Asset, OutputContext, string, string, string>> fields, string index = "") { Out.DebugWriteLine("Entered panel_json with name: {0}, markup: {1}, listName: {2}", name, Util.HtmlEncode(markup), listName); var output = new StringBuilder(1024); var i = 1; Out.DebugWriteLine("checking asset[" + name + Index(i) + index + "]..."); if (!string.IsNullOrEmpty(asset[name + Index(i) + index])) { while (!string.IsNullOrEmpty(asset[name + Index(i) + index])) { var pattern = itemName.StartsWith("_") ? markup : string.Format("{{\"{0}\":{1}}}", JsonHelper.StringToJson(itemName), markup); Out.DebugWriteLine("asset[" + name + Index(i) + index + "] = " + asset[name + Index(i) + index]); foreach (var entry in fields) { var fieldParams = entry.Key; var method = entry.Value; pattern = pattern.Replace(fieldParams[0], method(asset, context, name + fieldParams[1], Index(i) + index)); } if (i++ > 1) output.Append(","); output.Append(pattern); } } else if (!string.IsNullOrEmpty(asset[name + index])) { var pattern = itemName.StartsWith("_") ? markup : string.Format("{{\"{0}\":{1}}}", JsonHelper.StringToJson(itemName), markup); Out.DebugWriteLine("asset[" + name + index + "] = " + asset[name + index]); foreach (var entry in fields) { var fieldParams = entry.Key; var method = entry.Value; pattern = pattern.Replace(fieldParams[0], method(asset, context, name + fieldParams[1], index)); } if (i++ > 1) output.Append(","); output.Append(pattern); } else if (!string.IsNullOrEmpty(asset[name + Index(i) + ":1"])) { while (!string.IsNullOrEmpty(asset[name + Index(i) + ":1"])) { var pattern = itemName.StartsWith("_") ? markup : string.Format("{{\"{0}\":{1}}}", JsonHelper.StringToJson(itemName), markup); Out.DebugWriteLine("asset[" + name + Index(i) + ":1" + "] = " + asset[name + Index(i) + ":1"]); foreach (var entry in fields) { var fieldParams = entry.Key; var method = entry.Value; pattern = pattern.Replace(fieldParams[0], method(asset, context, name + fieldParams[1], Index(i) + ":1")); } if (i++ > 1) output.Append(","); output.Append(pattern); } } return output.ToString(); } // // Summary: // A different helper function used to iterate through a list of assets to provide // content for each panel. Use this option to generate the JSON output if your panels // correspond to a list of external assets rather then content within the current // asset // // Parameters: // asset: // The current asset // // context: // The current OutputContext context // // markup: // The markup that should be repeated within the panel // // fields: // A Dictionary where each key value pair consist of a list of string parameters // and the corresponding content field's output function. Note that in this case // it will only take the first kvp within the dictionary // // index: // If this is in a list panel then the current panel index // // overrideAssetList: // The list of assets from which the content will be pulled from instead of the // current asset // // Returns: // The markup for the current list panel with all the content placeholders replaced // with their specified content for each panel public string PanelJson(Asset asset, OutputContext context, string markup, Dictionary<List<string>, Func<Asset, OutputContext, string, string, bool, string>> fields, string index = "", List<Asset> overrideAssetList = null) { throw new NotImplementedException(); } // // Summary: // A different helper function used to iterate through a list of assets to provide // JSON content for each panel. Use this option to generate the output if your panels // correspond to a list of external assets rather then content within the current // asset // // Parameters: // asset: // The current asset // // context: // The current OutputContext context // // markup: // The markup that should be repeated within the panel // // contentToReplace: // The markup within the <cp-list> tags that should be updated with the content // from the external assets // // method: // The method of the output function that should be used to replace the content // placeholders within the <cp-list> tags // // index: // If this is in a list panel then the current panel index // // overrideAssetList: // The list of assets from which the content will be pulled from instead of the // current asset // // Returns: // The markup for the current list panel with all the content placeholders replaced // with their specified content for each panel public string PanelJson(Asset asset, OutputContext context, string markup, string contentToReplace, Func<Asset, OutputContext, string, string, bool, string> method, string index = "", List<Asset> overrideAssetList = null) { throw new NotImplementedException(); } } public class IndexedField { public SearchG2FieldType Type { get; set; } public string FieldName { get; set; } public string Name { get { var fieldType = "s"; switch (Type) { case SearchG2FieldType.Boolean: fieldType = "b"; break; case SearchG2FieldType.BooleanArray: fieldType = "bs"; break; case SearchG2FieldType.Currency: fieldType = "c"; break; case SearchG2FieldType.DateTime: fieldType = "dt"; break; case SearchG2FieldType.DateTimeArray: fieldType = "dts"; break; case SearchG2FieldType.Double: fieldType = "d"; break; case SearchG2FieldType.DoubleArray: fieldType = "ds"; break; case SearchG2FieldType.Float: fieldType = "f"; break; case SearchG2FieldType.FloatArray: fieldType = "fs"; break; case SearchG2FieldType.Integer: fieldType = "i"; break; case SearchG2FieldType.IntegerArray: fieldType = "is"; break; case SearchG2FieldType.Location: fieldType = "p"; break; case SearchG2FieldType.Long: fieldType = "l"; break; case SearchG2FieldType.LongArray: fieldType = "ls"; break; case SearchG2FieldType.String: fieldType = "s"; break; case SearchG2FieldType.StringArray: fieldType = "ss"; break; case SearchG2FieldType.Text: fieldType = "t"; break; case SearchG2FieldType.TextArray: fieldType = "txt"; break; } return "custom_" + fieldType + "_" + FieldName.ToLowerInvariant().Replace(" ", "_").Split(":".ToCharArray()).First(); } } public IndexedField(SearchG2FieldType type, string fieldName) { Type = type; FieldName = fieldName; } public static IndexedField ToArray(IndexedField field) { switch (field.Type) { case SearchG2FieldType.Boolean: case SearchG2FieldType.BooleanArray: return new IndexedField(SearchG2FieldType.BooleanArray, field.FieldName); case SearchG2FieldType.DateTime: case SearchG2FieldType.DateTimeArray: return new IndexedField(SearchG2FieldType.DateTimeArray, field.FieldName); case SearchG2FieldType.Double: case SearchG2FieldType.DoubleArray: return new IndexedField(SearchG2FieldType.DoubleArray, field.FieldName); case SearchG2FieldType.Float: case SearchG2FieldType.FloatArray: return new IndexedField(SearchG2FieldType.FloatArray, field.FieldName); case SearchG2FieldType.Integer: case SearchG2FieldType.IntegerArray: return new IndexedField(SearchG2FieldType.IntegerArray, field.FieldName); case SearchG2FieldType.Long: case SearchG2FieldType.LongArray: return new IndexedField(SearchG2FieldType.LongArray, field.FieldName); case SearchG2FieldType.String: case SearchG2FieldType.StringArray: return new IndexedField(SearchG2FieldType.StringArray, field.FieldName); case SearchG2FieldType.Text: case SearchG2FieldType.TextArray: return new IndexedField(SearchG2FieldType.TextArray, field.FieldName); case SearchG2FieldType.Currency: case SearchG2FieldType.Location: throw new NotSupportedException(); default: throw new NotImplementedException(); } } public static IEnumerable<IndexedField> ToArray(IEnumerable<IndexedField> fields) { return fields.Select(ToArray); } } public enum SearchG2FieldType { Boolean = 0, BooleanArray, Currency, DateTime, DateTimeArray, Double, DoubleArray, Float, FloatArray, Integer, IntegerArray, Location, Long, LongArray, String, StringArray, Text, TextArray } public static class Utils { public static string StripHtml(string value) { if (value == null) return null; var result = new Regex("<script(.|\\n)*?</script>", RegexOptions.IgnoreCase).Replace(value, ""); result = new Regex("<style(.|\\n)*?</style>", RegexOptions.IgnoreCase).Replace(result, ""); result = CrownPeak.CMSAPI.Util.StripHtml(result); result = new Regex("\\s+").Replace(result, " "); return result.Trim(); } } public static class JsonHelper { public static string DragAndDropZoneToJson(Asset asset, OutputContext context, string zone) { var result = new StringBuilder(1024); result.AppendFormat("\"{0}\":[", StringToJson(zone)); var componentNamespace = ComponentLibraryHelper.getComponentLibraryNamespace(asset); asset.GetContent(); var first = true; foreach (var component in asset.GetPanels(zone + "_0")) { var componentType = component.Raw[zone + "_component_type"]; if (string.IsNullOrWhiteSpace(componentType) || componentType == "Zone" || componentType == "DragDropZone") continue; if (first) first = false; else result.Append(","); var index = component.GetFieldName(zone + "_0"); index = index.Substring(index.IndexOf(":")); result.Append("{"); result.AppendFormat("\"{0}\":", StringToJson(componentType)); var comp = XUtils.CreateInstance(componentNamespace + "." + componentType) as JsonComponentBase; if (comp != null) { result.Append(comp.ComponentJson(asset, context, zone, index)); } else { result.Append("null"); } result.Append("}"); } result.Append("]"); return result.ToString(); } public static string StringToJson(string value, bool includeQuotes = false, bool escapeSlashes = true) { if (value == null) return null; var result = new JsonString(value).ToString(); if (!escapeSlashes) result = result.Replace("\\/", "/"); if (!includeQuotes) result = result.Substring(1, result.Length - 2); return result; } [DataContract] private class JsonString { [DataMember] public string Value { get; set; } public JsonString(string value) { Value = value; } public override string ToString() { var value = Util.SerializeDataContractJson(this); value = value.Substring(value.IndexOf(':') + 1); value = value.Replace("\\u000d", "\\r").Replace("\\u000a", "\\n").Replace("\\u0009", "\\t"); return value.Substring(0, value.Length - 1); } } } } 261480 1792 /System/Templates/Basis/DeveloperCS/ 1 0 false false 0 0 /Component Project/Library/ComponentLibraryLayoutHelper.cs 261059 17 LibraryClass 2 body using System; using System.Collections.Generic; using System.Linq; using System.Text; using CrownPeak.CMSAPI; using CrownPeak.CMSAPI.Services; /* Some Namespaces are not allowed. */ namespace Component_Library.Component_Project.Components { public class ComponentLibraryLayoutHelper { public static void FilenameHelper(Asset asset, OutputContext context) { context.PublishPath = string.Empty; } public static void InputHelper(Asset asset, InputContext context) { Input.StartControlPanel("Pattern"); //Input.ShowTextBox("Class Name","class_name", helpMessage: "Must only consist of alphanumeric characters and an underscores"); Input.ShowTextBox("Markup", "markup", width: 400, height: 30); Input.EndControlPanel(); } public static void OutputHelper(Asset asset, OutputContext context) { // Asset siteConfig = Asset.Load(asset.Parent.AssetPath + "/_Config/Site Config"); // //Root Assets folders // string imageFolder = asset.Parent.Parent.Parent.AssetPath + "/_Assets/images/"; // string cssFolder = asset.Parent.Parent.Parent.AssetPath + "/_Assets/css/"; // string jsFolder = asset.Parent.Parent.Parent.AssetPath + "/_Assets/js/"; //%> //<!DOCTYPE html> //<html class="pl"> // <head> // <meta charset="UTF-8"> // <meta name="viewport" content="width=device-width" /> // <link rel="stylesheet" href="<%= Asset.Load(cssFolder + "/style.css").GetLink(LinkType.Include) %>" media="all" /> // <!-- Begin Pattern Lab (Required for Pattern Lab to run properly) --> // <!-- never cache patterns --> // <meta http-equiv="cache-control" content="max-age=0" /> // <meta http-equiv="cache-control" content="no-cache" /> // <meta http-equiv="expires" content="0" /> // <meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" /> // <meta http-equiv="pragma" content="no-cache" /> // <!-- // <link rel="stylesheet" href="../../styleguide/css/styleguide.css?1413476785" media="all"> // <link rel="stylesheet" href="../../styleguide/css/styleguide-specific.css?1413476785" media="all" /> // --> // <!-- End Pattern Lab --> // </head> // <body> // <%=asset["markup"]%> %> // </body> //</html> } public static void PostInputHelper(Asset asset, PostInputContext context) { } public static void PostSaveHelper(Asset asset, PostSaveContext context) { } public static void UrlHelper(Asset asset, OutputContext context) { context.PublishUrl = string.Empty; } } } 261481 1792 /System/Templates/Basis/DeveloperCS/ 1 0 false false 0 0 /Component Project/Library/ComponentLibraryTemplateBuilderHelper.cs 261059 17 LibraryClass 2 body using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Text.RegularExpressions; using CrownPeak.CMSAPI; using CrownPeak.CMSAPI.Services; /* Some Namespaces are not allowed. */ namespace Component_Library.Component_Project.Components { public class ComponentLibraryTemplateBuilderHelper { public static void InputHelper(Asset asset, InputContext context) { Asset componentLibraryProjectTemplatesFolder = InitializeTemplateFolder(asset); String SiteRootFolderPath = ComponentLibraryHelper.getcomponentLibraryRootFolder(asset).AssetPath.ToString(); String ComponentsFolderPath = ComponentLibraryHelper.getComponentLibraryComponentsFolder(asset).ToString(); string libraryPath = ComponentLibraryHelper.getComponentLibraryComponentsFolder(asset).AssetPath.ToString(); // setup dictionary of available layouts FilterParams fpLayoutFilter = new FilterParams(); fpLayoutFilter.Add(AssetPropertyNames.TemplateLabel, Comparison.Equals, "Layout"); fpLayoutFilter.SortOrder = SortOrder.OrderBy(AssetPropertyNames.FolderId).ThenBy(AssetPropertyNames.Label); Dictionary<string, string> layouts = new Dictionary<string, string>(); foreach (Asset aLayout in Asset.Load(libraryPath).GetFilterList(fpLayoutFilter)) { if (aLayout.IsLoaded) layouts.Add(aLayout.Label, aLayout.Label); } // setup dictionary of available components FilterParams fpComponentFilter = new FilterParams(); fpComponentFilter.Add(AssetPropertyNames.TemplateLabel, Comparison.Equals, "Component"); fpComponentFilter.SortOrder = SortOrder.OrderBy(AssetPropertyNames.FolderId).ThenBy(AssetPropertyNames.Label); Dictionary<string, string> components = new Dictionary<string, string>(); foreach (Asset aComponent in Asset.Load(libraryPath).GetFilterList(fpComponentFilter)) { if (aComponent.IsLoaded) components.Add(Asset.Load(aComponent.FolderId).Label + ": " + aComponent.Label + " (" + aComponent.Id + ")", aComponent.Label/*aComponent.GetLink(LinkType.Internal)*//*aComponent.AssetPath.ToString()*/); } components = components.OrderBy(x => x.Key).ToDictionary(x => x.Key, y => y.Value); // available columns Dictionary<string, string> columns = new Dictionary<string, string>() { {"Column One","col1"}, {"Column Two","col2"}//, {"Column Three","col3"} }; if (String.IsNullOrEmpty(asset["inputBody"])) { Input.StartTabbedPanel("Components", "Wrapper", "Settings"); } else { Input.StartTabbedPanel("Components", "Wrapper", "Settings", "Code"); } while (Input.NextPanel("Layouts")) { Input.ShowTextBox("Section Name", "section"); // Layouts ShowAcquireParams sapLayouts = new ShowAcquireParams(); sapLayouts.DefaultFolder = ComponentsFolderPath + "/_thumbnails/layouts"; sapLayouts.ShowUpload = false; Input.ShowAcquireImage("Layout", "layout_thumbnail", sapLayouts); Input.ShowDropDown("Select a Layout", "layout", layouts); Input.StartExpandPanel("Customize"); //Input.ShowCheckBox("Editable", "editable", "yes", "yes"); Input.ShowCheckBox("Consolidate section into the above section's input tab?", "consolidate_section_tab", "yes", "Yes"); Input.EndExpandPanel(); while (Input.NextPanel("Components")) { //Dictionary<string, string> dropDownRows = new Dictionary<string, string>() {{"Component", "component" }, { "Custom", "custom" }}; ShowAcquireParams sapComponents = new ShowAcquireParams(); sapComponents.DefaultFolder = ComponentsFolderPath + "/_thumbnails/components"; sapComponents.ShowUpload = false; // Input.StartDropDownContainer("Content Type", "content_type", dropDownRows, firstRowLabel: "Content Type"); // Components Input.StartHorizontalWrapContainer(); Input.ShowAcquireImage("Component", "component_thumbnail", sapComponents); Input.ShowDropDown("Column", "column", columns, Util.MakeList("col1")); // Input.ShowRadioButton("Column", "column", columns); Input.EndHorizontalWrapContainer(); /* ShowAcquireParams aParams = new ShowAcquireParams(); aParams.ShowBrowse = true; aParams.DefaultFolder = SiteRootFolderPath + "/_components/organisms"; Input.ShowAcquireDocument("Component", "component_id", aParams); */ Input.ShowDropDown("Selected Component", "component", components); Input.StartExpandPanel("Customize"); Input.ShowTextBox("Component Message", "message", width: 100); Input.ShowTextBox("Component Label", "label", width: 100); Input.ShowTextBox("Component Name", "name", width: 100); Input.ShowTextBox("Custom Code", "custom_code", width: 500, helpMessage: "if custom code is specified then it will be rendered instead of the component selected."); Input.EndExpandPanel(); } } Input.NextTabbedPanel(); //Dictionary<String, String> wrapperOptions = new Dictionary<string, string>() { { "Default", "default" }, { "Landing Page", "landing" }, { "None", "none" } }; //Input.ShowRadioButton("Content Wrapper", "wrapper", wrapperOptions); ShowAcquireParams wrapperAcquireParams = new ShowAcquireParams { DefaultFolder = asset.Parent.AssetPath.ToString() + "/Site Wrappers" }; Dictionary<String, String> wrapperTypeOptions = new Dictionary<string, string>(); wrapperTypeOptions.Add("Built With Wrapper Builder", "template_builder"); wrapperTypeOptions.Add("Custom Built Wrapper", "custom"); Input.StartDropDownContainer("Wrapper Selection Type", "wrapper_type", wrapperTypeOptions, defaultValue: "template_builder"); Input.ShowMessage("This options lets you select a wrapper built via a wrapper builder asset"); Input.ShowAcquireDocument("Wrapper", "wrapper", wrapperAcquireParams); Input.NextDropDownContainer(); Input.ShowMessage("This option lets you select a custom built wrapper"); Input.ShowSelectFolder("Wrapper Template", "custom_wrapper"); Input.EndDropDownContainer(); Input.NextTabbedPanel(); Input.ShowCheckBox("Create", "create", "yes", "yes"); Input.ShowTextBox("Template Name", "template_name", asset.Label.Replace(" Template", "") + " Template"); Input.StartExpandPanel("Template File Settings"); Input.ShowCheckBox("", "do_not_overwrite_post_save", "do_not_overwrite", "Do not overwrite the post_save.aspx template file"); Input.EndExpandPanel(); Input.ShowSelectFolder("Template Folder", "template_folder", componentLibraryProjectTemplatesFolder.AssetPath); Input.ShowAcquireDocument("Select preview asset", "previewAsset", SiteRootFolderPath + "/_templates"); Input.ShowCheckBox("Enable Page Metadata", "meta", "yes", "yes"); Input.ShowCheckBox("Enable Page specific JavaScript and CSS", "custom_js_css", "yes", "yes"); Input.ShowCheckBox("Enable Advanced Capabilities", "advanced", "yes", "yes", helpMessage: "This option adds an \"Advanced\" tab to the input form which contains a link to directly edit this template builder template."); Input.ShowCheckBox("Enable TMF", "enable_tmf", "yes", "Yes"); Input.StartExpandPanel("TMF Settings"); Input.ShowCheckBox("Create a output_translate_xml.aspx file?", "create_output_translate_xml", "yes", "Yes", helpMessage: "When custom code is required to package the content being translated you will need to enter the custom function in the text box below"); Input.ShowTextBox("TMF output_translate_xml.aspx code", "output_translate_xml_body", width: 100, height: 5); Input.EndExpandPanel(); if (!String.IsNullOrEmpty(asset["inputBody"])) { Input.NextTabbedPanel(); Input.ShowTextBox("Input", "inputBody", width: 100, readOnly: true); Input.ShowTextBox("Post Input", "postinputBody", width: 100, readOnly: true); Input.ShowTextBox("Output", "outputBody", width: 100, readOnly: true); if (asset["enable_tmf"] == "yes") { Input.ShowTextBox("Output Post Save (TMF)", "postSaveBody", width: 100, readOnly: true); Input.ShowTextBox("Output Changes (TMF)", "outputChangesBody", width: 100, readOnly: true); if (asset["create_output_translate_xml"] == "yes") { Input.ShowTextBox("Output Translate Xml (TMF)", "outputTranslateXmlBody", width: 100, readOnly: true); } } } Input.EndTabbedPanel(); } private static Asset InitializeTemplateFolder(Asset asset) { Asset componentLibraryProjectTemplatesFolder = Asset.Load(ComponentLibraryHelper.getComponentLibraryProjectFolder(asset).AssetPath + "/Templates"); if (string.IsNullOrEmpty(asset["template_folder"]) && componentLibraryProjectTemplatesFolder != null && componentLibraryProjectTemplatesFolder.IsLoaded) { asset["template_folder"] = componentLibraryProjectTemplatesFolder.GetLink(LinkType.Internal); } return componentLibraryProjectTemplatesFolder; } public static void OutputHelper(Asset asset, OutputContext context) { Component_Layout layout = new Component_Layout(); context.IsGeneratingDependencies = false; String componentColumn = ""; String componentOutput = ""; String wrapperType = asset["wrapper_type"]; String SiteRootFolderPath = ComponentLibraryHelper.getcomponentLibraryRootFolder(asset).AssetPath.ToString(); Asset globalConfig = Asset.Load(SiteRootFolderPath + "/_Global/Global Config"); //dictionary to allow for multiple columns based on ComponentLibrary Config Dictionary<int, StringBuilder> columnDictionary = new Dictionary<int, StringBuilder>(); Dictionary<String, StringBuilder> rowContent = new Dictionary<string, StringBuilder>(); StringBuilder sbCol1 = new StringBuilder(); StringBuilder sbCol2 = new StringBuilder(); if (String.IsNullOrWhiteSpace(wrapperType)) { wrapperType = asset["wrapper_type"]; } if (wrapperType == "custom") { Asset wrapperAsset = Asset.Load(asset["custom_wrapper"]); if (wrapperAsset.IsLoaded) { ComponentLibraryHelper.startWrap(asset, context, wrapperAsset.AssetPath.ToString(), wrapperType); } } else { Asset wrapperAsset = Asset.Load(asset["wrapper"]); if (!string.IsNullOrEmpty(wrapperAsset.Raw["template_name"])) { ComponentLibraryHelper.startWrap(asset, context, wrapperAsset.Raw["template_name"]); } } foreach (PanelEntry entry in asset.GetPanels("layouts")) { sbCol1.Clear(); sbCol2.Clear(); foreach (PanelEntry subEntry in entry.GetPanels("components")) { componentOutput = ""; componentColumn = ""; if (String.IsNullOrEmpty(subEntry.Raw["custom_code"])) { Asset aComponent = ComponentLibraryHelper.getComponentAsset(asset, subEntry["component"]); if (aComponent != null && aComponent.IsLoaded) { componentOutput = ComponentLibraryHelper.generateComponentPreview(aComponent, context); } componentColumn = subEntry["column"]; } else { componentOutput = subEntry["custom_code"]; componentColumn = subEntry["custom_column"]; } switch (componentColumn) { case "col1": sbCol1.Append(componentOutput); break; case "col2": sbCol2.Append(componentOutput); break; } } rowContent.Add("{col1}", sbCol1); rowContent.Add("{col2}", sbCol2); Out.Write(layout.output(asset, entry.GetFieldName("layout"), rowContent, entry["layout"])); rowContent.Clear(); } if (asset["wrapper"] == "yes") { ComponentLibraryHelper.endWrap(asset, context); } } public static void OutputCodeHelper(Asset asset, OutputContext context) { context.IsGeneratingDependencies = false; string SiteRootFolderPath = ComponentLibraryHelper.getcomponentLibraryRootFolder(asset).AssetPath.ToString(); //Root Assets folders string cssFolder = SiteRootFolderPath + "/_Assets/css/"; string jsFolder = SiteRootFolderPath + "/_Assets/js/"; Out.DebugWriteLine("<!DOCTYPE html>"); Out.WriteLine("<html lang=\"en\">"); Out.WriteLine("<head>"); Out.WriteLine(" <link rel=\"stylesheet\" href=\"" + Asset.Load(cssFolder + "/bootstrap.css").GetLink(LinkType.Include) + "\" media=\"all\" />"); Out.WriteLine(" <script type=\"text/javascript\" src=\"http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.js\"></script>"); Out.WriteLine("</head>"); Out.WriteLine("<body>"); Out.WriteLine(" <div class=\"container\">"); Out.WriteLine(" <div id=\"content\">"); Out.WriteLine(" <ul id=\"tabs\" class=\"nav nav-tabs\" data-tabs=\"tabs\">"); Out.WriteLine(" <li class=\"active\"><a href=\"#input\" data-toggle=\"tab\">Input</a></li>"); Out.WriteLine(" <li><a href=\"#postinput\" data-toggle=\"tab\">PostInput</a></li>"); Out.WriteLine(" <li><a href=\"#output\" data-toggle=\"tab\">Output</a></li>"); Out.WriteLine(" </ul>"); Out.WriteLine(" <div id=\"my-tab-content\" class=\"tab-content\">"); Out.WriteLine(" <div class=\"tab-pane active\" id=\"input\">"); Out.WriteLine(" <h1>Input</h1>"); Out.WriteLine(" " + Util.ConvertTextToHtml(asset["inputBody"]).Replace("<dd>", "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;")); Out.WriteLine(" </div>"); Out.WriteLine(" <div class=\"tab-pane\" id=\"postinput\">"); Out.WriteLine(" <h1>PostInput</h1>"); Out.WriteLine(" " + Util.ConvertTextToHtml(asset["postinputBody"]).Replace("<dd>", "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;")); Out.WriteLine(" </div>"); Out.WriteLine(" <div class=\"tab-pane\" id=\"output\">"); Out.WriteLine(" <h1>Output</h1>"); Out.WriteLine(" " + Util.ConvertTextToHtml(asset["outputBody"]).Replace("<dd>", "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;")); Out.WriteLine(" </div>"); Out.WriteLine(" </div>"); Out.WriteLine(" </div>"); Out.WriteLine(" <script type=\"text/javascript\">"); Out.WriteLine(" jQuery(document).ready(function ($) {"); Out.WriteLine(" $('#tabs').tab();"); Out.WriteLine(" });"); Out.WriteLine(" </script>"); Out.WriteLine(" </div>"); Out.WriteLine(" <!-- container -->"); Out.WriteLine(" <script type=\"text/javascript\" src=\"" + Asset.Load(jsFolder + "/bootstrap.js").GetLink(LinkType.Include) + "\"></script>"); Out.WriteLine("</body>"); Out.WriteLine("</html>"); } public static void OutputComponentsHelper(Asset asset, OutputContext context) { Component_Layout layout = new Component_Layout(); Dictionary<String, StringBuilder> rowContent = new Dictionary<string, StringBuilder>(); context.IsGeneratingDependencies = false; String SiteRootFolderPath = ComponentLibraryHelper.getcomponentLibraryRootFolder(asset).AssetPath.ToString(); //Out.WriteLine(SiteRootFolderPath); Asset globalConfig = Asset.Load(SiteRootFolderPath + "/_Global/Global Config"); //Root Assets folders string imageFolder = SiteRootFolderPath + "/_Assets/images/"; string cssFolder = SiteRootFolderPath + "/_Assets/css/"; string jsFolder = SiteRootFolderPath + "/_Assets/js/"; string componentName = ""; string componentThumbnail = ""; string componentType = ""; string componentPath = ""; string componentId = ""; string componentColumn = ""; // Asset aComponent; string componentOutput = ""; StringBuilder sbCol1 = new StringBuilder(); StringBuilder sbCol2 = new StringBuilder(); String wrapperType = asset["wrapper_type"]; if (String.IsNullOrWhiteSpace(wrapperType)) { wrapperType = asset["wrapper_type"]; } if (wrapperType == "custom") { Asset wrapperAsset = Asset.Load(asset["custom_wrapper"]); if (wrapperAsset.IsLoaded) { ComponentLibraryHelper.startWrap(asset, context, wrapperAsset.AssetPath.ToString(), wrapperType); } } else { Asset wrapperAsset = Asset.Load(asset["wrapper"]); if (!string.IsNullOrEmpty(wrapperAsset.Raw["template_name"])) { ComponentLibraryHelper.startWrap(asset, context, wrapperAsset.Raw["template_name"]); } } foreach (PanelEntry entry in asset.GetPanels("layouts")) { sbCol1.Clear(); sbCol2.Clear(); foreach (PanelEntry subEntry in entry.GetPanels("components")) { componentOutput = ""; componentThumbnail = ""; componentColumn = ""; if (String.IsNullOrEmpty(subEntry.Raw["custom_code"])) { Asset aComponent = ComponentLibraryHelper.getComponentAsset(asset, subEntry["component"]); if (aComponent != null && aComponent.IsLoaded) { componentOutput = "<span " + Util.Editable("component", subEntry) + "> " + makeRaw(ComponentLibraryHelper.generateComponentPreview(aComponent, context)) + "</span>"; } componentColumn = subEntry["column"]; } else { componentOutput = subEntry["custom_code"]; componentColumn = subEntry["custom_column"]; } switch (componentColumn) { case "col1": sbCol1.Append(componentOutput); break; case "col2": sbCol2.Append(componentOutput); break; } } rowContent.Add("{col1}", sbCol1); rowContent.Add("{col2}", sbCol2); Out.Write(layout.output(asset, entry.GetFieldName("layout"), rowContent, entry["layout"])); rowContent.Clear(); } if (asset["wrapper"] == "yes") { ComponentLibraryHelper.endWrap(asset, context); } } public static void OutputContentHelper(Asset asset, OutputContext context) { /***Commented out because no longer serves a purpose***/ //Component_Layout layout = new Component_Layout(); //Dictionary<String, StringBuilder> rowContent = new Dictionary<string, StringBuilder>(); //context.IsGeneratingDependencies = false; //string SiteRootFolderPath = "/" + asset.AssetPath[0]; //"/Utility.GetSiteRootPathReg(asset); ////Out.WriteLine(SiteRootFolderPath); //Asset globalConfig = Asset.Load(SiteRootFolderPath + "/_Global/Global Config"); ////Root Assets folders //string imageFolder = SiteRootFolderPath + "/_Assets/images/"; //string cssFolder = SiteRootFolderPath + "/_Assets/css/"; //string jsFolder = SiteRootFolderPath + "/_Assets/js/"; //string componentName = ""; //string componentThumbnail = ""; //string componentType = ""; //string componentPath = ""; //string componentId = ""; //string componentColumn = ""; //// Asset aComponent; //string componentOutput = ""; //StringBuilder sbCol1 = new StringBuilder(); //StringBuilder sbCol2 = new StringBuilder(); //if (!string.IsNullOrEmpty(Asset.Load(asset["wrapper"]).Raw["template_name"])) ComponentLibraryHelper.startWrap(asset, context, Asset.Load(asset["wrapper"]).Raw["template_name"]); //foreach (PanelEntry entry in asset.GetPanels("layouts")) //{ // sbCol1.Clear(); // sbCol2.Clear(); // foreach (PanelEntry subEntry in entry.GetPanels("components")) // { // componentOutput = ""; // componentThumbnail = ""; // componentColumn = ""; // if (String.IsNullOrEmpty(subEntry.Raw["custom_code"])) // { // componentPath = subEntry["component"]; // //componentPath = subEntry["component"]; // Asset aComponent = Asset.Load(componentPath); // if (aComponent.IsLoaded) // { // componentOutput = ComponentLibraryHelper.generateComponentPreview(aComponent, context); // } // componentColumn = subEntry["column"]; // } // else // { // componentOutput = subEntry["custom_code"]; // componentColumn = subEntry["custom_column"]; // } // switch (componentColumn) // { // case "col1": // sbCol1.Append(componentOutput); // break; // case "col2": // sbCol2.Append(componentOutput); // Console.WriteLine("Case 2"); // break; // } // } // rowContent.Add("{col1}", sbCol1); // rowContent.Add("{col2}", sbCol2); // Out.Write(layout.output(asset, entry.GetFieldName("layout"), rowContent, entry["layout"])); // rowContent.Clear(); //} //if (asset["wrapper"] == "yes") //{ // ComponentLibraryHelper.endWrap(asset, context); //} } public static void PostInputHelper(Asset asset, PostInputContext context) { string ComponentLibraryComponentFolder = ComponentLibraryHelper.getComponentLibraryComponentsFolder(asset).AssetPath.ToString(); //string ComponentLibraryRootFolderPath = ComponentLibraryHelper.getcomponentLibraryRootFolder(asset).AssetPath.ToString(); //"/Utility.GetSiteRootPathReg(asset); //Asset siteConfig = Asset.Load(SiteRootFolderPath + "/_Config/Site Config"); //Root Assets folders //string imageFolder = SiteRootFolderPath + "/_Assets/images/"; //string cssFolder = SiteRootFolderPath + "/_Assets/css/"; //string jsFolder = SiteRootFolderPath + "/_Assets/js/"; //string componentColumn = ""; string nameSpace = ""; //"CrownPeak.CMSAPI.CustomLibrary.Components."; string componentLibraryClassName = "ComponentLibraryHelper"; string layoutClassName = "layout"; string openTag = "<" + "%"; string closeTag = "%" + ">"; string tab = "\t"; string componentClassName = ""; string componentName = ""; string componentLabel = ""; string componentMessage = ""; string componentFieldName = ""; string componentThumbnail = ""; string componentType = ""; Asset aComponent; //StringBuilder sbOutputLayouts = new StringBuilder(); //StringBuilder sbCol1 = new StringBuilder(); //StringBuilder sbCol2 = new StringBuilder(); //StringBuilder sbInputDeclare = new StringBuilder(); //StringBuilder sbPostInputDeclare = new StringBuilder(); //StringBuilder sbOutputDeclare = new StringBuilder(); StringBuilder sbDeclare = new StringBuilder(); StringBuilder sbImportNamespaces = new StringBuilder(); StringBuilder sbInput = new StringBuilder(); StringBuilder sbInputContent = new StringBuilder(); StringBuilder sbPostInput = new StringBuilder(); StringBuilder sbPostInputContent = new StringBuilder(); StringBuilder sbOutput = new StringBuilder(); StringBuilder sbOutputContent = new StringBuilder(); StringBuilder sbOutputChanges = new StringBuilder(); StringBuilder sbOutputChangesContent = new StringBuilder(); StringBuilder sbOutputTranslateXml = new StringBuilder(); StringBuilder sbOutputTranslateXmlContent = new StringBuilder(); StringBuilder sbPostSave = new StringBuilder(); StringBuilder sbPostSaveContent = new StringBuilder(); PanelEntry firstPe = context.InputForm.GetPanels("layouts").FirstOrDefault(); //if (firstPe != null && firstPe["consolidate_section_tab"] == "yes") //{ // context.ValidationError = "Please uncheck the \"Consolidate section into the above sections input tab\" checkbox on the first section."; //} //else //{ Dictionary<string, int> components = new Dictionary<string, int>(); sbDeclare.Append(openTag + "@ Import Namespace=\"CrownPeak.CMSAPI\" " + closeTag).AppendLine(); sbImportNamespaces.Append(openTag + "@ Import Namespace=\"CrownPeak.CMSAPI\" " + closeTag).AppendLine(); sbDeclare.Append(openTag + "@ Import Namespace=\"CrownPeak.CMSAPI.Services\" " + closeTag).AppendLine(); sbImportNamespaces.Append(openTag + "@ Import Namespace=\"CrownPeak.CMSAPI.Services\" " + closeTag).AppendLine(); sbDeclare.Append(openTag + "@ Import Namespace=\"CrownPeak.CMSAPI.CustomLibrary\" " + closeTag).AppendLine(); sbImportNamespaces.Append(openTag + "@ Import Namespace=\"CrownPeak.CMSAPI.CustomLibrary\" " + closeTag).AppendLine(); sbDeclare.Append(openTag + "@ Import Namespace=\"" + ComponentLibraryHelper.getComponentLibraryNamespace(asset) + "\"" + closeTag).AppendLine(); sbImportNamespaces.Append(openTag + "@ Import Namespace=\"" + ComponentLibraryHelper.getComponentLibraryNamespace(asset) + "\"" + closeTag).AppendLine(); sbDeclare.Append("<!--DO NOT MODIFY CODE ABOVE THIS LINE-->").AppendLine(); sbImportNamespaces.Append("<!--DO NOT MODIFY CODE ABOVE THIS LINE-->").AppendLine(); sbDeclare.Append(openTag).AppendLine(); //sbImportNamespaces.Append(openTag).AppendLine(); sbDeclare.Append(tab + nameSpace + "Component_Layout layout = new " + nameSpace + "Component_Layout();").AppendLine(); if (context.InputForm["meta"] == "yes") { sbDeclare.Append(tab + nameSpace + "MetaData metaData = new " + nameSpace + "MetaData();").AppendLine(); } if (context.InputForm["custom_js_css"] == "yes") { sbDeclare.Append(tab + nameSpace + "HeaderJavascriptAndCss headerAndJavascriptCSS = new " + nameSpace + "HeaderJavascriptAndCss();").AppendLine(); } sbInputContent.Append(tab + "Input.StartTabbedPanel("); String dlm = ""; foreach (PanelEntry entry in context.InputForm.GetPanels("layouts")) { if (entry["consolidate_section_tab"] != "yes") { sbInputContent.Append(dlm + "\"" + entry["section"] + "\""); dlm = ", "; } } if (context.InputForm["meta"] == "yes") sbInputContent.Append(", \"Metadata & Header Content\""); if (context.InputForm["advanced"] == "yes") sbInputContent.Append(", \"Advanced\""); if (context.InputForm["enable_tmf"] == "yes") sbInputContent.Append(", \"TMF\""); sbInputContent.Append(");").AppendLine(); //if(asset.Raw["editable"]=="yes") sbInput.Append(", \"Layout\""); String wrapperType = context.InputForm["wrapper_type"]; if (String.IsNullOrWhiteSpace(wrapperType)) { wrapperType = asset["wrapper_type"]; } if (wrapperType == "custom") { Asset wrapperAsset = Asset.Load(context.InputForm["custom_wrapper"]); if (!wrapperAsset.IsLoaded) { wrapperAsset = Asset.Load(asset["custom_wrapper"]); } if (wrapperAsset.IsLoaded) { sbOutputContent.Append(tab + "//Begin Wrapper").AppendLine(); sbOutputContent.Append(tab + componentLibraryClassName + ".startWrap(asset,context,\"" + wrapperAsset.AssetPath + "\", \"" + wrapperType + "\");").AppendLine(); } } else { Asset wrapperAsset = Asset.Load(context.InputForm["wrapper"]); if (!wrapperAsset.IsLoaded) { wrapperAsset = Asset.Load(asset["wrapper"]); } if (!string.IsNullOrEmpty(wrapperAsset.Raw["template_name"]) && !string.IsNullOrEmpty(wrapperAsset.Raw["template_folder"])) { String wrapperAssetPath = Asset.Load(wrapperAsset["template_folder"]).AssetPath + "/" + wrapperAsset.Raw["template_name"]; sbOutputContent.Append(tab + "//Begin Wrapper").AppendLine(); sbOutputContent.Append(tab + componentLibraryClassName + ".startWrap(asset,context,\"" + wrapperAssetPath + "\", \"" + wrapperType + "\");").AppendLine(); } } sbOutputContent.Append(tab + "StringBuilder sbCol1 = new StringBuilder();").AppendLine(); sbOutputContent.Append(tab + "StringBuilder sbCol2 = new StringBuilder();").AppendLine(); sbOutputContent.Append(tab + "StringBuilder sbCol3 = new StringBuilder();").AppendLine(); sbOutputContent.Append(tab + "StringBuilder sbCol4 = new StringBuilder();").AppendLine(); sbOutputContent.Append(tab + "Dictionary<String, StringBuilder> rowContent = new Dictionary<string, StringBuilder>();").AppendLine(); sbOutputContent.AppendLine(); String nextTab = ""; Int32 unique = 0; bool isFirstPe = true; /************BEGIN BUILDING INPUT & POST-INPUT************/ foreach (PanelEntry entry in context.InputForm.GetPanels("layouts")) { if (!(isFirstPe && entry["consolidate_section_tab"] == "yes")) { if (!String.IsNullOrEmpty(entry["layout_thumbnail"])) { Asset aLayoutThumbnail = Asset.Load(entry["layout_thumbnail"]); if (aLayoutThumbnail.IsLoaded) { Asset aLayout = Asset.Load(ComponentLibraryComponentFolder + "/layouts/" + aLayoutThumbnail.Label.ToLower().Replace(".png", "")); if (aLayout.IsLoaded) entry["layout"] = aLayout.Label; } } if (entry["consolidate_section_tab"] != "yes") { sbInputContent.Append(nextTab).AppendLine(); } Int32 col = 1; while (col < 3) { if (!(isFirstPe && entry["consolidate_section_tab"] == "yes")) { sbInputContent.Append(tab + tab + "// Capture content for Column " + col.ToString()).AppendLine(); } foreach (PanelEntry subEntry in entry.GetPanels("components")) { if (subEntry["column"] == "col" + col.ToString()) { /* // Commented out 2016-10-05 by RL - adding no value! if (!String.IsNullOrEmpty(subEntry["component_thumbnail"])) { componentThumbnail = Asset.Load(subEntry["component_thumbnail"]).Label; if (!String.IsNullOrEmpty(componentThumbnail)) { componentType = componentThumbnail.Substring(0, componentThumbnail.IndexOf(" - ")).Trim(); componentName = componentThumbnail.Substring(componentThumbnail.IndexOf(" - ") + 3).Replace(".png", "").Trim(); //sbDeclare.AppendLine("//" + ComponentLibraryRootFolderPath + componentType + "s/" + componentName); aComponent = Asset.Load(ComponentLibraryComponentFolder + "/" + componentType + "s/" + componentName); if (aComponent.IsLoaded) subEntry["component"] = aComponent.Label; //aComponent.AssetPath.ToString(); //aComponent.Id.ToString(); } } //sbInputContent.Append("component:" + componentThumbnail + " |" + componentType + " |" + componentName); */ aComponent = ComponentLibraryHelper.getComponentAsset(asset, subEntry["component"]); if (aComponent != null && aComponent.IsLoaded) { componentClassName = aComponent.Raw["class_name"]; componentLabel = subEntry["label"].Trim(); componentName = char.ToLower(componentClassName[0]) + componentClassName.Substring(1); componentMessage = subEntry["message"]; if (!string.IsNullOrWhiteSpace(componentMessage)) sbInputContent.AppendFormat(tab + tab + "Input.ShowMessage(\"{0}\");", componentMessage.Replace("\"", "\\\"")).AppendLine(); if (!components.ContainsKey(componentName)) { components.Add(componentName, 0); sbDeclare.Append(tab + nameSpace + componentClassName + " " + componentName + " = new " + nameSpace + componentClassName + "();").AppendLine(); } else components[componentName]++; componentFieldName = !String.IsNullOrEmpty(subEntry["name"]) ? subEntry["name"] : aComponent.Label.ToLower().Replace(" ", "_") + (components[componentName] > 0 ? "_" + (components[componentName] + 1).ToString() : ""); subEntry["name"] = componentFieldName; //subEntry["label"] = componentLabel; // sbInputContent.Append(tab + tab + componentName + ".input(\"" + subEntry["label"] + "\",\"" + subEntry.Raw["name"]+"\");").AppendLine(); if (!(isFirstPe && entry["consolidate_section_tab"] == "yes")) { sbInputContent.Append(tab + tab + componentName + ".ComponentInput(asset, context, \"" + componentLabel + "\",\"" + componentFieldName + "\");").AppendLine(); // sbPostInputContent.Append(tab + componentName + ".postinput(context,\"" + subEntry.Raw["name"]+"\");").AppendLine(); sbPostInputContent.Append(tab + componentName + ".ComponentPostInput(asset, context, \"" + componentFieldName + "\");").AppendLine(); } } } unique++; } if (!(isFirstPe && entry["consolidate_section_tab"] == "yes")) { sbInputContent.AppendLine(); } col++; } //if (entry["editable"] == "yes") //{ // sbInputContent.Append(tab + tab + "//Layout").AppendLine(); // sbInputContent.Append(tab + tab + layoutClassName + ".input(asset,\"" + entry["section"] + " layout\",\"" + entry.GetFieldName("layout") + "\",\"" + entry["layout"] + "\");").AppendLine(); // sbInputContent.AppendLine(); //} nextTab = "Input.NextTabbedPanel();"; } isFirstPe = false; } /************END BUILDING INPUT & POST-INPUT************/ /*****************BEGIN BUILDING OUTPUT*****************/ foreach (PanelEntry entry in context.InputForm.GetPanels("layouts")) { if (!String.IsNullOrEmpty(entry["layout_thumbnail"])) { Asset aLayoutThumbnail = Asset.Load(entry["layout_thumbnail"]); if (aLayoutThumbnail.IsLoaded) { Asset aLayout = Asset.Load(ComponentLibraryComponentFolder + "/layouts/" + aLayoutThumbnail.Label.ToLower().Replace(".png", "")); if (aLayout.IsLoaded) entry["layout"] = aLayout.Label; } } sbOutputContent.Append(tab + "// " + entry["section"]).AppendLine(); sbOutputContent.AppendLine(); Int32 col = 1; while (col < 5) { sbOutputContent.Append(tab + "// Assemble content for Column " + col.ToString()).AppendLine(); sbOutputContent.Append(tab + "sbCol" + col.ToString() + ".Clear();").AppendLine(); foreach (PanelEntry subEntry in entry.GetPanels("components")) { if (subEntry["column"] == "col" + col.ToString()) { /* // Commented out 2016-10-05 by RL - adding no value! if (!String.IsNullOrEmpty(subEntry["component_thumbnail"])) { componentThumbnail = Asset.Load(subEntry["component_thumbnail"]).Label; if (!String.IsNullOrEmpty(componentThumbnail)) { componentType = componentThumbnail.Substring(0, componentThumbnail.IndexOf(" - ")).Trim(); componentName = componentThumbnail.Substring(componentThumbnail.IndexOf(" - ") + 3).Replace(".png", "").Trim(); aComponent = Asset.Load(ComponentLibraryComponentFolder + "/" + componentType + "s/" + componentName); if (aComponent.IsLoaded) subEntry["component"] = aComponent.Label; //aComponent.AssetPath.ToString(); //aComponent.Id.ToString(); } } */ aComponent = ComponentLibraryHelper.getComponentAsset(asset, subEntry["component"]); if (aComponent != null && aComponent.IsLoaded) { componentClassName = aComponent.Raw["class_name"]; componentLabel = subEntry["label"].Trim(); componentName = char.ToLower(componentClassName[0]) + componentClassName.Substring(1); if (!components.ContainsKey(componentName)) { components.Add(componentName, 0); sbDeclare.Append(tab + nameSpace + componentClassName + " " + componentName + " = new " + nameSpace + componentClassName + "();").AppendLine(); } else components[componentName]++; componentFieldName = !String.IsNullOrEmpty(subEntry["name"]) ? subEntry["name"] : aComponent.Label.ToLower().Replace(" ", "_") + (components[componentName] > 0 ? "_" + (components[componentName] + 1).ToString() : ""); subEntry["name"] = componentFieldName; // subEntry["label"] = componentLabel; // sbOutputContent.Append(tab + "sbCol"+ col.ToString()+".Append(" + componentName + ".output(asset,\"" + subEntry.Raw["name"]+"\"));").AppendLine(); sbOutputContent.Append(tab + "sbCol" + col.ToString() + ".Append(" + componentName + ".output(asset, context,\"" + componentFieldName + "\"));").AppendLine(); } } else if (!String.IsNullOrEmpty(subEntry["custom_code"]) && subEntry["custom_column"] == "col" + col.ToString()) { sbOutputContent.Append(tab + "Out.StartCapture();").AppendLine(); sbOutputContent.Append(closeTag).AppendLine(); sbOutputContent.Append(subEntry.Raw["custom_code"]).AppendLine(); sbOutputContent.Append(openTag).AppendLine(); sbOutputContent.Append(tab + "sbCol" + col.ToString() + ".Append(Out.StopCapture());").AppendLine(); } unique++; } sbOutputContent.Append(tab + "rowContent.Add(\"{col" + col.ToString() + "}\", sbCol" + col.ToString() + ");").AppendLine(); sbOutputContent.AppendLine(); col++; } sbOutputContent.Append(tab + "// Output Content for Page using a specific layout").AppendLine(); sbOutputContent.Append(tab + "Out.Write(layout.output(asset, \"" + entry.GetFieldName("layout") + "\", rowContent,\"" + entry["layout"] + "\"));").AppendLine(); sbOutputContent.Append(tab + "rowContent.Clear();").AppendLine(); sbOutputContent.AppendLine(); nextTab = "Input.NextTabbedPanel();"; isFirstPe = false; } /*****************END BUILDING OUTPUT*****************/ sbDeclare.Append(closeTag).AppendLine(); //sbImportNamespaces.Append(closeTag).AppendLine(); if (context.InputForm["meta"] == "yes" || context.InputForm["custom_js_css"] == "yes") { sbInputContent.Append(tab + "Input.NextTabbedPanel();").AppendLine(); if (context.InputForm["meta"] == "yes") { sbInputContent.Append(tab + tab + "Input.StartExpandPanel(\"Metadata\");").AppendLine(); sbInputContent.Append(tab + tab + "metaData.ComponentInput(asset, context, \"Metadata\", \"meta\");").AppendLine(); sbInputContent.Append(tab + tab + "Input.EndExpandPanel();").AppendLine(); sbPostInputContent.Append(tab + "metaData.ComponentPostInput(asset, context, \"meta\");").AppendLine(); //sbOutputContent.Append(tab + "// Metadata Output").AppendLine(); //sbOutputContent.Append(tab + "metaData.output(asset, context, \"meta\");").AppendLine(); sbOutputContent.AppendLine(); } if (context.InputForm["custom_js_css"] == "yes") { sbInputContent.Append(tab + tab + "Input.StartExpandPanel(\"Javascript and CSS references\");").AppendLine(); sbInputContent.Append(tab + tab + "headerAndJavascriptCSS.ComponentInput(asset, context, \"Metadata\", \"meta\");").AppendLine(); sbInputContent.Append(tab + tab + "Input.EndExpandPanel();").AppendLine(); //sbOutputContent.Append(tab + "// Page specific CSS & JavaScript Output").AppendLine(); //sbOutputContent.Append(tab + "headerAndJavascriptCSS.output(asset, context, \"meta\");").AppendLine(); sbOutputContent.AppendLine(); } } if (context.InputForm["advanced"] == "yes") { sbInputContent.Append(tab + "Input.NextTabbedPanel();").AppendLine(); //site root not configurable via the site config yet. //sbInputContent.Append(tab + tab + "Input.ShowLink(Asset.Load(\"" + siteConfig.AssetPath.ToString() + "\"), \"Edit Theme\", InputLinkType.EditTab);").AppendLine(); sbInputContent.Append(tab + tab + "Input.ShowLink(Asset.Load(\"" + asset.AssetPath.ToString() + "\"), \"Edit Template\", InputLinkType.EditTab);").AppendLine(); } if (context.InputForm["enable_tmf"] == "yes") { sbInputContent.Append(tab + "Input.NextTabbedPanel();").AppendLine(); // Replacing with TMF from the Service Library //sbInputContent.AppendLine().Append(tab + "try { TMFInput.LoadInput(asset, context); } catch (Exception ex){}").AppendLine().AppendLine(); //sbPostInputContent.AppendLine().Append(tab + "try { TMFPostInput.LoadPostInput(asset, context); } catch (Exception ex){}").AppendLine(); //sbOutputContent.Append(tab + "try { TMFOutput.LoadOutput(asset, context); } catch (Exception ex){}").AppendLine(); //sbOutputChangesContent.Append(tab + "try { TMFOutput.LoadMasterAssetChanges(asset); } catch (Exception ex){}").AppendLine(); //sbOutputTranslateXmlContent.Append(tab + "try { " + context.InputForm["output_translate_xml_body"] + " } catch (Exception ex){}").AppendLine(); //sbPostSaveContent.Append(tab + "try { TMFPostSave.LoadPostSave(asset, context); } catch (Exception ex){}").AppendLine(); sbInputContent.AppendLine().Append(tab + "try { ServicesTMF.Input.LoadInput(asset, context); } catch (Exception ex){}").AppendLine().AppendLine(); //sbPostInputContent.AppendLine().Append(tab + "try { ServicesTMF.PostInput.LoadPostInput(asset, context); } catch (Exception ex){}").AppendLine(); sbOutputContent.Append(tab + "try { ServicesTMF.Output.LoadOutput(asset, context); } catch (Exception ex){}").AppendLine(); sbOutputChangesContent.Append(tab + "try { ServicesTMF.Output.LoadMasterAssetChanges(asset); } catch (Exception ex){}").AppendLine(); sbOutputTranslateXmlContent.Append(tab + "try { " + context.InputForm["output_translate_xml_body"] + " } catch (Exception ex){}").AppendLine(); sbPostSaveContent.Append(tab + "try { ServicesTMF.PostSave.LoadPostSave(asset, context); } catch (Exception ex){}").AppendLine(); } sbInputContent.Append(tab + "Input.EndTabbedPanel();").AppendLine(); /* if(context.InputForm["wrapper"]=="yes") { sbOutputContent.Append(tab + "//End Wrapper").AppendLine(); sbOutputContent.Append(tab + componentLibraryClassName + ".endWrap(asset,context);").AppendLine(); } */ sbInput.Append(openTag + "@ Page Language=\"C#\" Inherits=\"CrownPeak.Internal.Debug.InputInit\" " + closeTag).AppendLine(); sbInput.Append(sbDeclare.ToString()).AppendLine(); sbInput.Append(openTag).AppendLine(); sbInput.Append(sbInputContent.ToString()); sbInput.Append(closeTag).AppendLine(); sbPostInput.Append(openTag + "@ Page Language=\"C#\" Inherits=\"CrownPeak.Internal.Debug.PostInputInit\" " + closeTag).AppendLine(); sbPostInput.Append(sbDeclare.ToString()).AppendLine(); sbPostInput.Append(openTag).AppendLine(); sbPostInput.Append(sbPostInputContent.ToString()); sbPostInput.Append(closeTag).AppendLine(); sbOutput.Append(openTag + "@ Page Language=\"C#\" Inherits=\"CrownPeak.Internal.Debug.OutputInit\" " + closeTag).AppendLine(); sbOutput.Append(sbDeclare.ToString()).AppendLine(); sbOutput.Append(openTag).AppendLine(); sbOutput.Append(sbOutputContent.ToString()); sbOutput.Append(closeTag).AppendLine(); if (context.InputForm["enable_tmf"] == "yes") { sbOutputChanges.Append(openTag + "@ Page Language=\"C#\" Inherits=\"CrownPeak.Internal.Debug.OutputInit\" " + closeTag).AppendLine(); sbOutputChanges.Append(sbImportNamespaces.ToString()).AppendLine(); sbOutputChanges.Append(openTag).AppendLine(); sbOutputChanges.Append(sbOutputChangesContent.ToString()); sbOutputChanges.Append(closeTag).AppendLine(); sbOutputTranslateXml.Append(openTag + "@ Page Language=\"C#\" Inherits=\"CrownPeak.Internal.Debug.OutputInit\" " + closeTag).AppendLine(); sbOutputTranslateXml.Append(sbImportNamespaces.ToString()).AppendLine(); sbOutputTranslateXml.Append(openTag).AppendLine(); sbOutputTranslateXml.Append(sbOutputTranslateXmlContent.ToString()); sbOutputTranslateXml.Append(closeTag).AppendLine(); sbPostSave.Append(openTag + "@ Page Language=\"C#\" Inherits=\"CrownPeak.Internal.Debug.PostSaveInit\" " + closeTag).AppendLine(); sbPostSave.Append(sbDeclare.ToString()).AppendLine(); sbPostSave.Append(openTag).AppendLine(); sbPostSave.Append(sbPostSaveContent.ToString()); sbPostSave.Append(closeTag).AppendLine(); } else { sbOutputChanges.Clear(); sbOutputTranslateXml.Clear(); sbPostSave.Clear(); } context.InputForm["inputBody"] = sbInput.ToString(); context.InputForm["postinputBody"] = sbPostInput.ToString(); context.InputForm["outputBody"] = sbOutput.ToString(); context.InputForm["outputChangesBody"] = sbOutputChanges.ToString(); context.InputForm["outputTranslateXmlBody"] = sbOutputTranslateXml.ToString(); context.InputForm["postSaveBody"] = sbPostSave.ToString(); if (context.InputForm["create"] == "yes") { Asset folderAsset = Asset.Load(context.InputForm["template_folder"]); Asset templateAsset = Asset.Load(folderAsset.AssetPath + "/" + context.InputForm["template_name"]); // if(templateAsset.IsLoaded && String.IsNullOrEmpty(context.InputForm["override"])) // { // context.ValidationErrorFields.Add("override", "Please check this box to override existing template"); // } if (!folderAsset.IsLoaded) { context.ValidationErrorFields.Add("template_folder", "Please specify a folder to generate the template in"); } } } public static void PostSaveHelper(Asset asset, PostSaveContext context) { if (asset["create"] == "yes") { Asset folderAsset = Asset.Load(asset["template_folder"]); Asset templateAsset = Asset.Load(folderAsset.AssetPath + "/" + asset.Raw["template_name"]); Asset modelAsset = Asset.LoadDirect("/System/Templates/Basis/Template/Template C#"); Dictionary<string, string> contentFields = new Dictionary<string, string> { { "Auto created by", asset.Id.ToString() } }; if (!templateAsset.IsLoaded) { templateAsset = Asset.CreateNewAsset(asset.Raw["template_name"], folderAsset, modelAsset, contentFields); asset["templateId"] = templateAsset.Id.ToString(); asset.SaveContentField("templateId", templateAsset.Id.ToString()); var defaultTemplateFolder = Asset.Load(ComponentLibraryHelper.getComponentLibraryProjectFolder(asset).AssetPath + "/Templates/Component Framework/Template Builder Default"); if (defaultTemplateFolder.IsLoaded) { var ap = new AssetParams { ExcludeProjectTypes = false }; var defaultTemplateFiles = defaultTemplateFolder.GetFileList(ap); defaultTemplateFiles.ForEach(f => Asset.CopyAsset(f.Label, templateAsset, f)); } } if (templateAsset.IsLoaded) { folderAsset = templateAsset; modelAsset = Asset.LoadDirect("/System/Templates/Basis/ComponentsCS/input.aspx"); contentFields = new Dictionary<string, string> { { "body", asset.Raw["inputBody"] } }; Asset inputAsset = Asset.Load(folderAsset.AssetPath + "/input.aspx"); if (inputAsset.IsLoaded) { //inputAsset.Delete(); inputAsset.SaveContent(contentFields); } else { inputAsset = Asset.CreateNewAsset("input.aspx", folderAsset, modelAsset, contentFields); } modelAsset = Asset.LoadDirect("/System/Templates/Basis/ComponentsCS/post_input.aspx"); contentFields = new Dictionary<string, string> { { "body", asset.Raw["postinputBody"] } }; Asset postinputAsset = Asset.Load(folderAsset.AssetPath + "/post_input.aspx"); if (postinputAsset.IsLoaded) { postinputAsset.SaveContent(contentFields); //postinputAsset.Delete(); } else { postinputAsset = Asset.CreateNewAsset("post_input.aspx", folderAsset, modelAsset, contentFields); } modelAsset = Asset.LoadDirect("/System/Templates/Basis/ComponentsCS/output.aspx"); contentFields = new Dictionary<string, string> { { "body", asset.Raw["outputBody"] } }; Asset outputAsset = Asset.Load(folderAsset.AssetPath + "/output.aspx"); if (outputAsset.IsLoaded) { outputAsset.SaveContent(contentFields); outputAsset.SaveSource(asset.Raw["outputBody"]); //outputAsset.Delete(); } else { outputAsset = Asset.CreateNewAsset("output.aspx", folderAsset, modelAsset, contentFields); } if (asset["do_not_overwrite_post_save"] != "do_not_overwrite") { //Post save currently in "enable_tmf" because only used for TMF currently, should be moved out eventually modelAsset = Asset.LoadDirect("/System/Templates/Basis/ComponentsCS/post_save.aspx"); contentFields = new Dictionary<string, string> { { "body", asset.Raw["postSaveBody"] } }; Asset postSaveAsset = Asset.Load(folderAsset.AssetPath + "/post_save.aspx"); if (postSaveAsset.IsLoaded) postSaveAsset.Delete(); if (asset["enable_tmf"] == "yes") { postSaveAsset = Asset.CreateNewAsset("post_save.aspx", folderAsset, modelAsset, contentFields); } } modelAsset = Asset.LoadDirect("/System/Templates/Basis/ComponentsCS/output.aspx"); contentFields = new Dictionary<string, string> { { "body", asset.Raw["outputChangesBody"] } }; Asset outputChangesAsset = Asset.Load(folderAsset.AssetPath + "/output_changes.aspx"); if (outputChangesAsset.IsLoaded) outputChangesAsset.Delete(); if (asset["enable_tmf"] == "yes") { outputChangesAsset = Asset.CreateNewAsset("output_changes.aspx", folderAsset, modelAsset, contentFields); } modelAsset = Asset.LoadDirect("/System/Templates/Basis/ComponentsCS/output.aspx"); contentFields = new Dictionary<string, string> { { "body", asset.Raw["outputTranslateXmlBody"] } }; Asset outputTranslateXmlAsset = Asset.Load(folderAsset.AssetPath + "/output_translate_xml.aspx"); if (outputTranslateXmlAsset.IsLoaded) outputTranslateXmlAsset.Delete(); if (asset["enable_tmf"] == "yes" && asset["create_output_translate_xml"] == "yes") { outputTranslateXmlAsset = Asset.CreateNewAsset("output_translate_xml.aspx", folderAsset, modelAsset, contentFields); } } if (!String.IsNullOrEmpty(asset[asset["previewAsset"]])) { Asset previewAsset = Asset.Load(asset["previewAsset"]); previewAsset.SetTemplate(templateAsset.Id); foreach (PanelEntry entry in asset.GetPanels("layouts")) { previewAsset[entry.GetFieldName("layout")] = entry["layout"]; } previewAsset.SaveContent(); } } asset.SaveContentField("override", ""); asset.Rename(asset["template_name"]); //asset.SaveContent(); } private static string makeRaw(string content) { foreach (Match mc in Regex.Matches(content, @"~\$CPIL\$\d+\$[\w:]+\$\w+\$")) { content = content.Replace(mc.Value, "").Replace("$/CPIL$~", ""); } foreach (Match mc in Regex.Matches(content, @"%\$CPIL\$\d+\$[\w:]+\$\w+\$")) { content = content.Replace(mc.Value, "").Replace("$/CPIL$%", ""); } return content; } } } 261482 1792 /System/Templates/Basis/DeveloperCS/ 1 0 false false 0 0 /Component Project/Library/ComponentLibraryTemplateUtils.cs 261059 17 LibraryClass 2 body using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Text.RegularExpressions; using CrownPeak.CMSAPI; using CrownPeak.CMSAPI.Services; /* Some Namespaces are not allowed. */ namespace Component_Library.Component_Project.Components { public class ComponentLibraryTemplateUtils { #region Cleanup Component Library Files public static void CleanupComponentLibraryFilesInput(Asset asset, InputContext context) { Input.ShowCheckBox("Cleanup Library Files?", "cleanup", "yes", "Yes"); } public static void CleanupComponentLibraryFilesOutput(Asset asset, OutputContext context) { Out.Write(asset["output_content"]); } public static void CleanupComponentLibraryFilesPostSave(Asset asset, PostSaveContext context) { FilterParams fParams = new FilterParams(); fParams.ExcludeProjectTypes = false; List<Asset> componentLibraryFiles = ComponentLibraryHelper.getComponentLibraryClassFolder(asset).GetFilterList(fParams); StringBuilder outputSb = new StringBuilder(); foreach (Asset clf in componentLibraryFiles) { int n; Regex rx = new Regex("[0-9]{3,}"); if (rx.IsMatch(clf.Label)) { outputSb.AppendFormat("<p>{0}</p>", clf.Label).AppendLine(); clf.Delete(); } } asset.SaveContentField("output_content", outputSb.ToString()); //StringBuilder outputSb = new StringBuilder(); //FilterParams fParams = new FilterParams(); //fParams.ExcludeProjectTypes = false; //List<Asset> componentLibraryFiles = ComponentLibraryHelper.getComponentLibraryClassFolder(asset).GetFilterList(fParams); //foreach (Asset clf in componentLibraryFiles) //{ // if (clf.Label.StartsWith("Components_") && !clf.Label.EndsWith("Base.cs") ) // { // String body = clf["body"]; // if (body.Contains("public override string output(Asset asset, OutputContext context, string name, string index = \"\")") || // body.Contains("return outputBase(asset, context, name, index);")) // { // outputSb.AppendFormat("<p>{0}</p>", clf.Label); // body = body.Replace("public override string output(Asset asset, OutputContext context, string name, string index = \"\")", "public override string output(Asset asset, OutputContext context, string name, string index = \"\", bool isDrag = false)"); // body = body.Replace("return outputBase(asset, context, name, index);", "return outputBase(asset, context, name, index, isDrag);"); // clf.SaveContentField("body", body); // } // } // asset.SaveContentField("output_content", outputSb.ToString()); //} } #endregion #region Delete DuplicateFiles public static void DeleteDuplicateFilesInput(Asset asset, InputContext context) { Input.ShowSelectFolder("Folder in which to delete duplicate files", "folder"); } public static void DeleteDuplicateFilesOutput(Asset asset, OutputContext context) { Out.Write(asset["output"]); } public static void DeleteDuplicateFilesPostSave(Asset asset, PostSaveContext context) { FilterParams fParams = new FilterParams(); fParams.ExcludeProjectTypes = false; StringBuilder outputSb = new StringBuilder(); List<Asset> assets = Asset.Load(asset["folder"]).GetFilterList(fParams); List<Asset> alreadyExists = new List<Asset>(); assets.Sort((x, y) => { int result = x.Label.CompareTo(y.Label); return result != 0 ? result : DateTime.Compare(x.CreateDate ?? DateTime.MinValue, y.CreateDate ?? DateTime.MinValue); }); foreach (Asset a in assets) { if (alreadyExists.Any(x => x.Label == a.Label)) { outputSb.AppendLine(String.Format("<p>{0} : {1} will be Deleted!</p>", a.Label, a.CreateDate)); //a.Delete(); } else { alreadyExists.Add(a); outputSb.AppendLine(String.Format("<p>{0} : {1}</p>", a.Label, a.CreateDate)); } } asset.SaveContentField("output", outputSb.ToString()); } #endregion #region Post Migration Cleanup public static void PostMigrationCleanupInput(Asset asset, InputContext context) { Input.ShowSelectFolder("Component Library Migration Root folder", "root_folder"); Input.ShowCheckBox("Run post migration script?", "run_script", "yes", "Yes"); } public static void PostMigrationCleanupOutput(Asset asset, OutputContext context) { } public static void PostMigrationCleanupPostSave(Asset asset, PostSaveContext context) { StringBuilder outputSb = new StringBuilder(); Asset rootFolder = Asset.Load(asset["root_folder"]); String rootFolderAssetPath = rootFolder.AssetPath.ToString(); if (asset["run_script"] == "yes") { Asset componentLibraryConfig = Asset.Load(rootFolderAssetPath + "/_Framework/Component Library Config"); componentLibraryConfig["component_class_folder"] = Asset.Load(rootFolderAssetPath + "/_Framework/Component_Project/Components").GetLink(LinkType.Internal); componentLibraryConfig["component_class_folder"] = componentLibraryConfig["component_class_folder"].Substring(0, componentLibraryConfig["component_class_folder"].Length - 1); componentLibraryConfig["component_library_components_folder"] = Asset.Load(rootFolderAssetPath + "/_Framework/_Components").GetLink(LinkType.Internal); componentLibraryConfig["component_library_components_folder"] = componentLibraryConfig["component_library_components_folder"].Substring(0, componentLibraryConfig["component_library_components_folder"].Length - 1); componentLibraryConfig["component_library_models_folder"] = Asset.Load(rootFolderAssetPath + "/_Framework/Component_Project/Models").GetLink(LinkType.Internal); componentLibraryConfig["component_library_models_folder"] = componentLibraryConfig["component_library_models_folder"].Substring(0, componentLibraryConfig["component_library_models_folder"].Length - 1); componentLibraryConfig["component_library_project_folder"] = Asset.Load(rootFolderAssetPath + "/_Framework/Component_Project").GetLink(LinkType.Internal); componentLibraryConfig["component_library_project_folder"] = componentLibraryConfig["component_library_project_folder"].Substring(0, componentLibraryConfig["component_library_project_folder"].Length - 1); rootFolder.SaveContentField("_cmsprojectid", Asset.Load(rootFolderAssetPath + "/_Framework/Component_Project").Id.ToString()); componentLibraryConfig["component_library_root_folder"] = Asset.Load(rootFolderAssetPath + "/_Framework").GetLink(LinkType.Internal); componentLibraryConfig["component_library_root_folder"] = componentLibraryConfig["component_library_root_folder"].Substring(0, componentLibraryConfig["component_library_root_folder"].Length - 1); componentLibraryConfig["site_root"] = Asset.Load(rootFolderAssetPath).GetLink(LinkType.Internal); componentLibraryConfig["site_root"] = componentLibraryConfig["site_root"].Substring(0, componentLibraryConfig["site_root"].Length - 1); componentLibraryConfig["upload#site_config"] = Asset.Load(rootFolderAssetPath + "/_Site Config/site config").GetLink(LinkType.Internal); componentLibraryConfig["upload#site_config"] = componentLibraryConfig["upload#site_config"].Substring(0, componentLibraryConfig["upload#site_config"].Length - 1); componentLibraryConfig["upload_name#site_config"] = Asset.Load(rootFolderAssetPath + "/_Site Config/site config").AssetPath.ToString(); componentLibraryConfig.SaveContent(); rootFolder.SaveContentField("_cmsprojectid", Asset.Load(rootFolderAssetPath + "/_Framework/Component_Project").Id.ToString()); List<Asset> assignWorkflowAssets = new List<Asset>(); FilterParams awfaParams = new FilterParams(); awfaParams.Add(AssetPropertyNames.TemplateLabel, Comparison.Equals, "DeveloperCS"); awfaParams.Add(Comparison.Equals, AssetType.File); FilterParams awfaPicturesParams = new FilterParams(); awfaPicturesParams.Add(Comparison.Equals, AssetType.File); //everything in the root /_Assets/ folder assignWorkflowAssets = Asset.Load(rootFolderAssetPath + "/_Assets").GetFilterList(awfaParams); assignWorkflowAssets.AddRange(Asset.Load(rootFolderAssetPath + "/_Assets/images").GetFilterList(awfaPicturesParams)); //everything in the /_Framework/_Assets/ folder assignWorkflowAssets.AddRange(Asset.Load(rootFolderAssetPath + "/_Framework/_Assets").GetFilterList(awfaParams)); assignWorkflowAssets.AddRange(Asset.Load(rootFolderAssetPath + "/_Framework/_Assets/images").GetFilterList(awfaPicturesParams)); //the site map assignWorkflowAssets.Add(Asset.Load(rootFolderAssetPath + "/Site Map")); //foreach (Asset wa in assignWorkflowAssets) //{ // wa.SetWorkflow("Basic Workflow"); //} Asset.Load(rootFolderAssetPath + "/_Assets/css/developer").Delete(); Asset.Load(rootFolderAssetPath + "/_Assets/js/developer").Delete(); Asset.Load(rootFolderAssetPath + "/_Assets/images/developer").Delete(); Asset.Load(rootFolderAssetPath + "/_Framework/_Components/developer").Delete(); Asset.Load(rootFolderAssetPath + "/_Framework/_Templates/Visual Template Builder Templates").Delete(); Asset.Load(rootFolderAssetPath + "/_Framework/_Templates/Site Wrappers/Developer Site Wrapper").Delete(); Asset componentFolderModel = Asset.Load(rootFolderAssetPath + "/_Framework/Component_Project/Models/Component Folder"); Asset.Load(rootFolderAssetPath + "/_Framework/_Components").SetModel(componentFolderModel.Id); Asset.Load(rootFolderAssetPath + "/_Framework/_Components/atoms").SetModel(componentFolderModel.Id); Asset.Load(rootFolderAssetPath + "/_Framework/_Components/core").SetModel(componentFolderModel.Id); Asset.Load(rootFolderAssetPath + "/_Framework/_Components/molecules").SetModel(componentFolderModel.Id); Asset.Load(rootFolderAssetPath + "/_Framework/_Components/organisms").SetModel(componentFolderModel.Id); Asset layoutsFolderModel = Asset.Load(rootFolderAssetPath + "/_Framework/Component_Project/Models/Layouts"); Asset.Load(rootFolderAssetPath + "/_Framework/_Components/layouts").SetModel(layoutsFolderModel.Id); Asset templateBuilderFolderModel = Asset.Load(rootFolderAssetPath + "/_Framework/Component_Project/Models/Templates"); Asset.Load(rootFolderAssetPath + "/_Framework/_Templates").SetModel(templateBuilderFolderModel.Id); Asset wrapperBuilderFolderModel = Asset.Load(rootFolderAssetPath + "/_Framework/Component_Project/Models/Wrapper Builder Folder Model"); Asset.Load(rootFolderAssetPath + "/_Framework/_Templates/Site Wrappers").SetModel(wrapperBuilderFolderModel.Id); Asset articlesFolderModel = Asset.Load(rootFolderAssetPath + "/_Framework/Component_Project/Models/Articles"); Asset.Load(rootFolderAssetPath + "/Articles").SetModel(articlesFolderModel.Id); Asset blogFolderModel = Asset.Load(rootFolderAssetPath + "/_Framework/Component_Project/Models/Blog"); Asset.Load(rootFolderAssetPath + "/Blog").SetModel(blogFolderModel.Id); Asset campaignsFolderModel = Asset.Load(rootFolderAssetPath + "/_Framework/Component_Project/Models/Campaigns"); Asset.Load(rootFolderAssetPath + "/Campaigns").SetModel(campaignsFolderModel.Id); Asset contentFolderModel = Asset.Load(rootFolderAssetPath + "/_Framework/Component_Project/Models/Content Pages"); Asset.Load(rootFolderAssetPath + "/Content").SetModel(contentFolderModel.Id); Asset newsFolderModel = Asset.Load(rootFolderAssetPath + "/_Framework/Component_Project/Models/News Room"); Asset.Load(rootFolderAssetPath + "/News Room").SetModel(newsFolderModel.Id); Asset widgetFolderModel = Asset.Load(rootFolderAssetPath + "/_Framework/Component_Project/Models/Widgets Folder Model"); Asset.Load(rootFolderAssetPath + "/Widgets").SetModel(widgetFolderModel.Id); Asset rootFolderModel = Asset.Load(rootFolderAssetPath + "/_Framework/Component_Project/Models/Site Root Pages"); Asset.Load(rootFolderAssetPath).SetModel(rootFolderModel.Id); /*Update all template builder template_folder paths*/ FilterParams templateBuilderFilterParams = new FilterParams(); templateBuilderFilterParams.Add(AssetPropertyNames.TemplateLabel, Comparison.Equals, "Template Builder"); FilterParams wrapperBuilderFilterParams = new FilterParams(); wrapperBuilderFilterParams.Add(AssetPropertyNames.TemplateLabel, Comparison.Equals, "Wrapper Builder"); List<Asset> templateBuilderAssets = Asset.Load(rootFolderAssetPath + "/_Framework/_Templates").GetFilterList(templateBuilderFilterParams); templateBuilderAssets.AddRange(Asset.Load(rootFolderAssetPath + "/_Framework/_Templates").GetFilterList(wrapperBuilderFilterParams)); String templateBuilderTemplatePath = Asset.Load(rootFolderAssetPath + "/_Framework/Component_Project/Templates").GetLink(LinkType.Internal); templateBuilderTemplatePath = templateBuilderTemplatePath.Substring(0, templateBuilderTemplatePath.Length - 1); foreach (Asset tba in templateBuilderAssets) { tba.SaveContentField("template_folder", templateBuilderTemplatePath); } asset.DeleteContentField("run_script"); } } #endregion #region Update Template Builder Component Content Fields public static void UpdateTemplateBuilderComponentContentFieldsInput(Asset asset, InputContext context) { Input.ShowAcquireDocument("Update This Template Builder Template ONLY", "single"); Input.ShowCheckBox("Update ALL Template Builder Templates", "all", "yes", "Yes"); } public static void UpdateTemplateBuilderComponentContentFieldsOutput(Asset asset, OutputContext context) { Out.Write(asset["debug_output"]); } public static void UpdateTemplateBuilderComponentContentFieldsPostSave(Asset asset, PostSaveContext context) { StringBuilder outputSb = new StringBuilder(); if (!String.IsNullOrWhiteSpace(asset["single"])) { Asset templateBuilder = Asset.Load(asset["single"]); foreach (PanelEntry layout in templateBuilder.GetPanels("layouts")) { foreach (PanelEntry component in layout.GetPanels("Components")) { if (component["component"].Contains("/")) { String currentComponent = component["component"]; currentComponent = currentComponent.Substring(currentComponent.LastIndexOf("/") + 1); outputSb.AppendFormat("<p>{0} ==> {1}</p>", component["component"], currentComponent).AppendLine(); //component["component"] = currentComponent; } } } templateBuilder.SaveContent(); } else if (asset["all"] == "yes") { FilterParams fParams1 = new FilterParams(); fParams1.Add(AssetPropertyNames.TemplateLabel, Comparison.Equals, "Template Builder"); List<Asset> builderAssets = Asset.Load(ComponentLibraryHelper.getcomponentLibraryRootFolder(asset).AssetPath + "/_Templates").GetFilterList(fParams1); FilterParams fParams2 = new FilterParams(); fParams2.Add(AssetPropertyNames.TemplateLabel, Comparison.Equals, "Wrapper Builder"); builderAssets.AddRange(Asset.Load(ComponentLibraryHelper.getcomponentLibraryRootFolder(asset).AssetPath + "/_Templates").GetFilterList(fParams2)); foreach (Asset builderAsset in builderAssets) { foreach (PanelEntry layout in builderAsset.GetPanels("layouts")) { foreach (PanelEntry component in layout.GetPanels("Components")) { if (component["component"].Contains("/")) { String currentComponent = component["component"]; currentComponent = currentComponent.Substring(currentComponent.LastIndexOf("/") + 1); outputSb.AppendFormat("<p>workflow state: {0} template: {1} {2} ==> {3}</p>", builderAsset.WorkflowStatus.Name, builderAsset.TemplateLabel, component["component"], currentComponent).AppendLine(); component["component"] = currentComponent; } } } builderAsset.SaveContent(); } } asset.SaveContentField("debug_output", outputSb.ToString()); asset.DeleteContentField("all"); asset.DeleteContentField("single"); } #endregion #region Component Library Code Refresh public static void ComponentLibraryCodeRefreshInput(Asset asset, InputContext context) { Input.ShowTextBox("Asset Id", "asset_id"); FilterParams fparams = new FilterParams(); fparams.Add(AssetPropertyNames.TemplateLabel, Comparison.Equals, "Component"); Asset componentsFolder = ComponentLibraryHelper.getComponentLibraryComponentsFolder(asset); List<Asset> componentAssets = componentsFolder.GetFilterList(fparams); Dictionary<String, String> componentOptions = componentAssets.ToDictionary(x => x.Label, y => y.GetLink(LinkType.Internal)); Input.ShowSelectList("Components To exclude", "compoents_to_exclude", componentOptions); Dictionary<String, String> options = new Dictionary<string, string>() { { "Yes", "Yes" }, { "No", "No" } }; Input.ShowDropDown("Rebuild component classes?", "rebuild", options, Util.MakeList("No")); } public static void ComponentLibraryCodeRefreshOutput(Asset asset, OutputContext context) { Out.Write(asset["output_content"]); } public static void ComponentLibraryCodeRefreshPostInput(Asset asset, PostInputContext context) { //if (context.InputForm["rebuild"] == "Yes") //{ Asset currentAsset = null; FilterParams fParams = new FilterParams(); fParams.Add(AssetPropertyNames.TemplateLabel, Comparison.Equals, "Component"); if (!String.IsNullOrWhiteSpace(context.InputForm["asset_id"])) { fParams.Add(AssetPropertyNames.Id, Comparison.Equals, context.InputForm["asset_id"]); } else if (!String.IsNullOrWhiteSpace(asset["asset_id"])) { fParams.Add(AssetPropertyNames.Id, Comparison.Equals, asset["asset_id"]); } List<Asset> assetsToExclude = asset.GetPanels("compoents_to_exclude").Select(panel => Asset.Load(panel["compoents_to_exclude"])).ToList(); StringBuilder sbOutput = new StringBuilder(); List<Asset> componentAssetList = Asset.Load(ComponentLibraryHelper.componentsPath(asset)).GetFilterList(fParams); for (int index = 0; index < componentAssetList.Count; index++) { try { currentAsset = componentAssetList[index]; if (currentAsset["read_only"] != "yes" && assetsToExclude.All(x => x.Id != currentAsset.Id)) { sbOutput.AppendLine("<p>Recompiled: " + currentAsset.AssetPath.ToString() + "</p>"); List<ComponentContentPlaceholder> markupContentPlaceholders = ComponentLibraryHelper.buildComponentContentPlaceholderFromMarkup(currentAsset["markup"]); List<PanelEntry> componentPanels = currentAsset.GetPanels("component_panel"); List<ComponentContentPlaceholder> assetContentPlaceholders = ComponentContentPlaceholder.ConvertPanelEntryList(componentPanels, "component_panel"); List<ComponentContentPlaceholder> flattenedAssetcontentPlaceholders = ComponentLibraryHelper.flattenComponentContentPlaceholderList(assetContentPlaceholders); ComponentLibraryHelper.deleteExistingContentFieldsForComponents(ref assetContentPlaceholders, markupContentPlaceholders); ComponentLibraryHelper.updateExistingContentFields(ref assetContentPlaceholders, markupContentPlaceholders); ComponentLibraryHelper.createContentFieldsForComponents(ref assetContentPlaceholders, markupContentPlaceholders, flattenedAssetcontentPlaceholders); Dictionary<String, String> content = ComponentContentPlaceholder.ConvertToContentDictionary(assetContentPlaceholders); ComponentLibraryHelper.deleteComponentContent(currentAsset); currentAsset.SaveContent(content); bool recompileSuccessful = false; Asset codeFile = ComponentLibraryHelper.createCodeFile(currentAsset, false, ref recompileSuccessful); Asset wysiwygTemplateFile = ComponentLibraryHelper.createWysiwygTemplate(currentAsset, "/System/CMS Snippets/Default"); } else { if (assetsToExclude.Any(x => x.Id == currentAsset.Id)) { sbOutput.AppendLine("<p>Manually Excluded: " + currentAsset.AssetPath.ToString() + "</p>"); } else { sbOutput.AppendLine("<p>Excluded: " + currentAsset.AssetPath.ToString() + "</p>"); } } } catch (Exception ex) { Util.Email(String.Format("Component Refresh Script exception AssetId: {0} {1}", currentAsset.Id, currentAsset.Label), String.Format("The following exception was thrown when running the script on asset id {0} \"{1}\" \r\n {2} \r\n {3}", currentAsset.Id, currentAsset.Label, ex.Message, ex.InnerException), "corey.casado@crownpeak.com"); } } asset.SaveContentField("output_content", sbOutput.ToString()); //bool libraryRecompileSuccessful = ComponentLibraryHelper.recompileLibrary(asset); //if (!libraryRecompileSuccessful) //{ // Util.Email("CL class refresh script recompilation unsuccessful.", "Recompilation failed when recompiling after the CL class refresh script was executed.", "corey.casado@crownpeak.com"); //} //} context.InputForm.Remove("rebuild"); } #endregion #region Component Library Template Refresh public static void ComponentLibraryTemplateRefreshInput(Asset asset, InputContext context) { Input.ShowTextBox("Asset Id", "asset_id"); FilterParams fparams = new FilterParams(); fparams.Add(AssetPropertyNames.TemplateLabel, Comparison.Equals, "Template Builder"); Asset templatesFolder = Asset.Load(ComponentLibraryHelper.getcomponentLibraryRootFolder(asset).AssetPath + "/_Templates"); List<Asset> templateBuilderAssets = templatesFolder.GetFilterList(fparams); Dictionary<String, String> templateOptions = templateBuilderAssets.ToDictionary(x => x.Label, y => y.GetLink(LinkType.Internal)); Input.ShowSelectList("Templates To exclude", "templates_to_exclude", templateOptions); Dictionary<String, String> options = new Dictionary<string, string>() { { "Yes", "Yes" }, { "No", "No" } }; Input.ShowDropDown("Rebuild templates?", "rebuild", options, Util.MakeList("No")); } public static void ComponentLibraryTemplateRefreshOutput(Asset asset, OutputContext context) { Out.Write(asset["output_content"]); } public static void ComponentLibraryTemplateRefreshPostInput(Asset asset, PostInputContext context) { //if (context.InputForm["rebuild"] == "Yes") //{ Asset currentAsset = null; FilterParams fParams = new FilterParams(); fParams.Add(AssetPropertyNames.TemplateLabel, Comparison.Equals, "Template Builder"); if (!String.IsNullOrWhiteSpace(context.InputForm["asset_id"])) { fParams.Add(AssetPropertyNames.Id, Comparison.Equals, context.InputForm["asset_id"]); } else if (!String.IsNullOrWhiteSpace(asset["asset_id"])) { fParams.Add(AssetPropertyNames.Id, Comparison.Equals, asset["asset_id"]); } List<Asset> assetsToExclude = asset.GetPanels("templates_to_exclude").Select(panel => Asset.Load(panel["templates_to_exclude"])).ToList(); StringBuilder sbOutput = new StringBuilder(); List<Asset> templateAssetList = Asset.Load(ComponentLibraryHelper.getcomponentLibraryRootFolder(asset).AssetPath + "/_Templates").GetFilterList(fParams); for (int index = 0; index < templateAssetList.Count; index++) { try { currentAsset = templateAssetList[index]; if (assetsToExclude.All(x => x.Id != currentAsset.Id)) { sbOutput.AppendLine("<p>Recompiled: " + currentAsset.AssetPath.ToString() + "</p>"); asset.SaveContentField("create", "yes"); } else { if (assetsToExclude.Any(x => x.Id == currentAsset.Id)) { sbOutput.AppendLine("<p>Manually Excluded: " + currentAsset.AssetPath.ToString() + "</p>"); } else { sbOutput.AppendLine("<p>Excluded: " + currentAsset.AssetPath.ToString() + "</p>"); } } } catch (Exception ex) { Util.Email(String.Format("Component Refresh Script exception AssetId: {0} {1}", (currentAsset != null ? currentAsset.Id.ToString() : "NULL"), (currentAsset != null ? currentAsset.Label : "NULL")), String.Format("The following exception was thrown when running the script on asset id {0} \"{1}\" \r\n {2} \r\n {3}", currentAsset.Id, currentAsset.Label, ex.Message, ex.InnerException), "corey.casado@crownpeak.com"); } } asset.SaveContentField("output_content", sbOutput.ToString()); //bool libraryRecompileSuccessful = ComponentLibraryHelper.recompileLibrary(asset); //if (!libraryRecompileSuccessful) //{ // Util.Email("CL class refresh script recompilation unsuccessful.", "Recompilation failed when recompiling after the CL class refresh script was executed.", "corey.casado@crownpeak.com"); //} //} context.InputForm.Remove("rebuild"); } #endregion } } 261483 1792 /System/Templates/Basis/DeveloperCS/ 1 0 false false 0 0 /Component Project/Library/ComponentLibraryUtils.cs 261059 17 LibraryClass 2 body using System; using System.Collections.Generic; using System.Linq; using System.Text; using CrownPeak.CMSAPI; using CrownPeak.CMSAPI.Services; /* Some Namespaces are not allowed. */ namespace Component_Library.Component_Project.Components { public class ComponentLibraryUtils { } public class SubListDetails { public PanelEntry pe { get; set; } public String panelEntryName { get; set; } public SubListDetails(PanelEntry pe, String panelEntryName) { this.pe = pe; this.panelEntryName = panelEntryName; } } public class Component_Layout { public void input(Asset asset, String label, String name, String initial) { FilterParams fpFilter = new FilterParams(); fpFilter.Add(AssetPropertyNames.TemplateLabel, Comparison.Equals, "Layout"); Dictionary<string, string> layouts = new Dictionary<string, string>(); foreach (Asset aLayout in Asset.Load(ComponentLibraryHelper.componentsPath(asset) + "layouts").GetFilterList(fpFilter)) { if (aLayout.IsLoaded) layouts.Add(aLayout.Label, aLayout.Label); } Input.ShowDropDown(label + " layout", name, layouts, Util.MakeList(initial)); } public String output(Asset asset, String name, Dictionary<String, StringBuilder> content, String layout = null) { StringBuilder sbContent = new StringBuilder(); //Out.DebugWriteLine("temp " + Asset.Load(ComponentLibraryHelper.getcomponentLibraryRootFolder(asset) + "/Layout Definitions/" + (string.IsNullOrEmpty(layout) ? asset[name] : layout)).Id); sbContent.Append(Asset.Load(ComponentLibraryHelper.getcomponentLibraryRootFolder(asset) + "/Layout Definitions/" + (string.IsNullOrEmpty(layout) ? asset[name] : layout)).Raw["markup"]); //Out.DebugWriteLine("Layout: {0} loaded...", ComponentLibraryHelper.getcomponentLibraryRootFolder(asset) + "/Layout Definitions/" + asset[name]); foreach (KeyValuePair<String, StringBuilder> kvp in content) { sbContent.Replace(kvp.Key, kvp.Value.ToString()); } return sbContent.ToString(); } } } 261484 1792 /System/Templates/Basis/DeveloperCS/ 1 0 false false 0 0 /Component Project/Library/ComponentLibraryWrapperBuilderHelper.cs 261059 17 LibraryClass 2 body using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Text.RegularExpressions; using CrownPeak.CMSAPI; using CrownPeak.CMSAPI.Services; /* Some Namespaces are not allowed. */ namespace Component_Library.Component_Project.Components { public class ComponentLibraryWrapperBuilderHelper { public static void InputHelper(Asset asset, InputContext context) { String componentLibraryProjectTemplateFolderPath = ComponentLibraryHelper.getComponentLibraryProjectFolder(asset).AssetPath + "/Templates"; String SiteRootFolderPath = ComponentLibraryHelper.getcomponentLibraryRootFolder(asset).AssetPath.ToString(); String ComponentsFolderPath = ComponentLibraryHelper.getComponentLibraryComponentsFolder(asset).ToString(); string libraryPath = ComponentLibraryHelper.getComponentLibraryComponentsFolder(asset).AssetPath.ToString(); Out.DebugWriteLine("Library Path: " + libraryPath); WysiwygParams wParams = ServicesInput.FullWYSIWYG(); ShowAcquireParams sapComponents = new ShowAcquireParams(); sapComponents.DefaultFolder = SiteRootFolderPath + "/_components/_thumbnails/components"; sapComponents.ShowUpload = false; Dictionary<string, string> wrapperLocations = new Dictionary<string, string>() { { "Header", "header" }, { "Footer", "footer" } }; // setup dictionary of available layouts FilterParams fpLayoutFilter = new FilterParams(); fpLayoutFilter.Add(AssetPropertyNames.TemplateLabel, Comparison.Equals, "Layout"); fpLayoutFilter.SortOrder = SortOrder.OrderBy(AssetPropertyNames.FolderId).ThenBy(AssetPropertyNames.Label); Dictionary<string, string> layouts = new Dictionary<string, string>(); foreach (Asset aLayout in Asset.Load(libraryPath).GetFilterList(fpLayoutFilter)) { if (aLayout.IsLoaded) layouts.Add(aLayout.Label, aLayout.Label); } // setup dictionary of available components FilterParams fpComponentFilter = new FilterParams(); fpComponentFilter.Add(AssetPropertyNames.TemplateLabel, Comparison.Equals, "Component"); fpComponentFilter.SortOrder = SortOrder.OrderBy(AssetPropertyNames.FolderId).ThenBy(AssetPropertyNames.Label); Dictionary<string, string> components = new Dictionary<string, string>(); components.Add("- - None - -", "none"); foreach (Asset aComponent in Asset.Load(libraryPath).GetFilterList(fpComponentFilter)) { if (aComponent.IsLoaded) components.Add(Asset.Load(aComponent.FolderId).Label + ": " + aComponent.Label + " (" + aComponent.Id + ")", aComponent.Label /*aComponent.AssetPath.ToString()*/); } components = components.OrderBy(x => x.Key).ToDictionary(x => x.Key, y => y.Value); // available columns Dictionary<string, string> columns = new Dictionary<string, string>() { {"Column One","col1"}, {"Column Two","col2"}//, {"Column Three","col3"} }; if (String.IsNullOrEmpty(asset["inputBody"])) { Input.StartTabbedPanel("Components", "Wrapper", "Settings"); } else { Input.StartTabbedPanel("Components", "Wrapper", "Settings", "Code"); } while (Input.NextPanel("Layouts")) { // Layouts Input.ShowTextBox("Section Name", "section"); ShowAcquireParams sapLayouts = new ShowAcquireParams(); sapLayouts.DefaultFolder = SiteRootFolderPath + "/_components/_thumbnails/layouts"; sapLayouts.ShowUpload = false; Input.ShowAcquireImage("Layout", "layout_thumbnail", sapLayouts); Input.ShowRadioButton("Wrapper Option", "wrapper_option", wrapperLocations); Input.ShowDropDown("Seleced Layout", "layout", layouts); //Input.StartExpandPanel("Customize"); //Input.ShowCheckBox("Editable", "editable", "yes", "yes"); //Input.EndExpandPanel(); while (Input.NextPanel("Components")) { // Components Input.StartHorizontalWrapContainer(); Input.ShowAcquireImage("Component", "component_thumbnail", sapComponents); Input.ShowDropDown("Column", "column", columns, Util.MakeList("col1")); Input.EndHorizontalWrapContainer(); Input.StartExpandPanel("Customize"); Input.ShowDropDown("Selected Component", "component", components); Input.ShowTextBox("Component Label", "label", width: 100); Input.ShowTextBox("Component Name", "name", width: 100); Input.ShowTextBox("Custom Code", "custom_code", width: 500); Input.EndExpandPanel(); } } Input.NextTabbedPanel(); Input.StartExpandPanel("Header"); Input.ShowMessage("Use {css} {css_configurable} {javascript} {page_specific_js_css} and {metadata} to specify where the css, javascript and metaData sections are located in the markup."); Input.ShowTextBox("Header Markup", "header_markup", width: 500, height: 10); while (Input.NextPanel("Header CSS")) { Input.ShowAcquireDocument("Select CSS File", "header_css"); } while (Input.NextPanel("Header Javascript")) { Input.ShowAcquireDocument("Select JS File", "header_javascript"); } Input.EndExpandPanel(); Input.StartExpandPanel("Before Content"); Input.ShowTextBox("Before Markup", "before_markup", width: 500, height: 10); Input.EndExpandPanel(); Input.StartExpandPanel("After Content"); Input.ShowTextBox("After Markup", "after_markup", width: 500, height: 10); Input.EndExpandPanel(); Input.StartExpandPanel("Footer"); Input.ShowMessage("Use {css} and {javascript} to specify where css and javascript sections are located in the markup."); Input.ShowTextBox("Footer Markup", "footer_markup", width: 500, height: 10); while (Input.NextPanel("Footer CSS")) { Input.ShowAcquireDocument("Select CSS File", "footer_css"); } while (Input.NextPanel("Footer Javascript")) { Input.ShowAcquireDocument("Select JS File", "footer_javascript"); } Input.EndExpandPanel(); Input.NextTabbedPanel(); Input.ShowCheckBox("Create", "create", "yes", "yes"); Input.ShowTextBox("Wrapper Name", "template_name", asset.Label.Replace(" Wrapper", "") + " Wrapper"); Input.ShowSelectFolder("Wrapper Folder", "template_folder", "/System/Templates"); Dictionary<String, String> configAssetOptions = new Dictionary<string, string>() { { "Coupled", "coupled" }, { "Decoupled", "decoupled" } }; Input.StartDropDownContainer("Config Asset Options", "config_asset_type", configAssetOptions, "coupled"); { Input.ShowMessage("In this option the wrapper itself is its own config file."); Input.ShowAcquireDocument("Config Asset", "config_asset", helpMessage: "The asset where the wrapper configuration settings are kept"); } Input.NextDropDownContainer(); { Input.ShowMessage("In this option a seperate configuration asset is created from the template. The config template is saved in the same template folder as the wrapper"); Input.ShowTextBox("Wrapper Config Name", "wrapper_config_template_name", asset.Label.Replace(" Wrapper", "") + " Wrapper Config"); Dictionary<String, String> wrapperConfigReferenceOptions = new Dictionary<string, string>() { { "Relative", "relative" }, { "Custom", "custom" } }; Input.ShowMessage("Since the config is now decoupled from the wrapper the below options determine how the wrapper knows where to find its config asset"); Input.StartDropDownContainer("Wrapper Config Reference Options", "wrapper_config_reference_type", wrapperConfigReferenceOptions); { Input.ShowMessage("This options allows you to specify a folder path. The wrapper will look for a config asset of this type within the specified folder"); Input.ShowSelectFolder("Config Folder", "wrapper_config_folder"); } Input.NextDropDownContainer(); { Input.ShowMessage("This option allows you to specify custom code (a function is reccomended) on how to find the config asset"); Input.ShowTextBox("Custom Code", "wrapper_config_custom_code", width: 500, height: 3, helpMessage: "Asset wrapperConfig = [Custom Code]"); } Input.EndDropDownContainer(); } Input.EndDropDownContainer(); if (!String.IsNullOrEmpty(asset["inputBody"])) { Input.NextTabbedPanel(); Input.ShowTextBox("Input / Config", "inputBody", width: 100, readOnly: true); Input.ShowTextBox("Post Input", "postinputBody", width: 100, readOnly: true); Input.ShowTextBox("Output", "outputBody", width: 100, readOnly: true); } Input.EndTabbedPanel(); } public static void OutputHelper(Asset asset, OutputContext context) { String wrapperAssetPath = Asset.Load(asset.Raw["template_folder"]).AssetPath + "/" + asset.Raw["template_name"]; ComponentLibraryHelper.startWrap(asset, context, wrapperAssetPath); Out.WriteLine("<p>ASSET CONTENT</p>"); } public static void OutputCodeHelper(Asset asset, OutputContext context) { context.IsGeneratingDependencies = false; string SiteRootFolderPath = "/" + asset.AssetPath[0]; //"/Utility.GetSiteRootPathReg(asset); Asset siteConfig = Asset.Load(SiteRootFolderPath + "/_Config/site config"); //Root Assets folders string cssFolder = SiteRootFolderPath + "/_Assets/css/"; string jsFolder = SiteRootFolderPath + "/_Assets/js/"; Out.DebugWriteLine("<!DOCTYPE html>"); Out.WriteLine("<html lang=\"en\">"); Out.WriteLine("<head>"); Out.WriteLine(" <link rel=\"stylesheet\" href=\"" + Asset.Load(cssFolder + "/original.css").GetLink(LinkType.Include) + "\" media=\"all\" />"); Out.WriteLine(" <link rel=\"stylesheet\" href=\"" + Asset.Load(cssFolder + "/PatternLabIO.css").GetLink(LinkType.Include) + "\" media=\"all\" />"); Out.WriteLine(" <script type=\"text/javascript\" src=\"http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.js\"></script>"); Out.WriteLine("</head>"); Out.WriteLine("<body>"); Out.WriteLine(" <div class=\"container\">"); Out.WriteLine(" <div id=\"content\">"); Out.WriteLine(" <ul id=\"tabs\" class=\"nav nav-tabs\" data-tabs=\"tabs\">"); Out.WriteLine(" <li class=\"active\"><a href=\"#input\" data-toggle=\"tab\">Input</a></li>"); Out.WriteLine(" <li><a href=\"#postinput\" data-toggle=\"tab\">PostInput</a></li>"); Out.WriteLine(" <li><a href=\"#output\" data-toggle=\"tab\">Output</a></li>"); Out.WriteLine(" </ul>"); Out.WriteLine(" <div id=\"my-tab-content\" class=\"tab-content\">"); Out.WriteLine(" <div class=\"tab-pane active\" id=\"input\">"); Out.WriteLine(" <h1>Input</h1>"); Out.WriteLine(" " + Util.ConvertTextToHtml(asset["inputBody"]).Replace("<dd>", "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;")); Out.WriteLine(" </div>"); Out.WriteLine(" <div class=\"tab-pane\" id=\"postinput\">"); Out.WriteLine(" <h1>PostInput</h1>"); Out.WriteLine(" " + Util.ConvertTextToHtml(asset["postinputBody"]).Replace("<dd>", "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;")); Out.WriteLine(" </div>"); Out.WriteLine(" <div class=\"tab-pane\" id=\"output\">"); Out.WriteLine(" <h1>Output</h1>"); Out.WriteLine(" " + Util.ConvertTextToHtml(asset["outputBody"]).Replace("<dd>", "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;")); Out.WriteLine(" </div>"); Out.WriteLine(" </div>"); Out.WriteLine(" </div>"); Out.WriteLine(" <script type=\"text/javascript\">"); Out.WriteLine(" jQuery(document).ready(function ($) {"); Out.WriteLine(" $('#tabs').tab();"); Out.WriteLine(" });"); Out.WriteLine(" </script>"); Out.WriteLine(" </div>"); Out.WriteLine(" <!-- container -->"); Out.WriteLine(" <script type=\"text/javascript\" src=\"" + Asset.Load(jsFolder + "/bootstrap.js").GetLink(LinkType.Include) + "\"></script>"); Out.WriteLine("</body>"); Out.WriteLine("</html>"); } public static void OutputComponentsHelper(Asset asset, OutputContext context) { Component_Layout layout = new Component_Layout(); Dictionary<String, StringBuilder> rowContent = new Dictionary<string, StringBuilder>(); context.IsGeneratingDependencies = false; string SiteRootFolderPath = "/" + asset.AssetPath[0]; //"/Utility.GetSiteRootPathReg(asset); //Out.WriteLine(SiteRootFolderPath); Asset siteConfig = Asset.Load(SiteRootFolderPath + "/_Config/Site Config"); //Root Assets folders string imageFolder = SiteRootFolderPath + "/_Assets/images/"; string cssFolder = SiteRootFolderPath + "/_Assets/css/"; string jsFolder = SiteRootFolderPath + "/_Assets/js/"; string componentName = ""; string componentThumbnail = ""; string componentType = ""; string componentPath = ""; string componentId = ""; string componentColumn = ""; // Asset aComponent; bool startFooter = false; string componentOutput = ""; StringBuilder sbCol1 = new StringBuilder(); StringBuilder sbCol2 = new StringBuilder(); StringBuilder sbCol3 = new StringBuilder(); String header = ""; String footer = ""; String css = ""; String javascript = ""; foreach (PanelEntry entry in asset.GetPanels("Header CSS")) css += "<link rel=\"stylesheet\" href=\"" + Asset.Load(entry["header_css"]).GetLink(LinkType.Include) + "\" media=\"all\" />"; foreach (PanelEntry entry in asset.GetPanels("Header Javascript")) javascript += "<link rel=\"stylesheet\" href=\"" + Asset.Load(entry["header_javascript"]).GetLink(LinkType.Include) + "\" media=\"all\" />"; header = asset.Raw["header_markup"].Replace("{css}", css).Replace("{javascript}", javascript); css = ""; javascript = ""; foreach (PanelEntry entry in asset.GetPanels("Footer CSS")) css += "<link rel=\"stylesheet\" href=\"" + Asset.Load(entry["footer_css"]).GetLink(LinkType.Include) + "\" media=\"all\" />"; foreach (PanelEntry entry in asset.GetPanels("Footer Javascript")) javascript += "<link rel=\"stylesheet\" href=\"" + Asset.Load(entry["header_javascript"]).GetLink(LinkType.Include) + "\" media=\"all\" />"; footer = asset.Raw["footer_markup"].Replace("{css}", css).Replace("{javascript}", javascript); Out.WriteLine(header); foreach (PanelEntry entry in asset.GetPanels("layouts")) { sbCol1.Clear(); sbCol2.Clear(); sbCol3.Clear(); if (entry["wrapper_option"] == "footer") startFooter = true; if (startFooter) Out.WriteLine(asset.Raw["before_markup"] + "ASSET CONTENT" + asset.Raw["after_markup"]); foreach (PanelEntry subEntry in entry.GetPanels("components")) { componentOutput = ""; componentThumbnail = ""; componentColumn = ""; if (String.IsNullOrEmpty(subEntry.Raw["custom_code"])) { componentPath = subEntry["component"]; //componentPath = subEntry["component"]; Asset aComponent = Asset.Load(componentPath); if (aComponent.IsLoaded) { componentOutput = "<span " + Util.Editable("component", subEntry) + ">" + makeRaw(ComponentLibraryHelper.generateComponentPreview(aComponent, context)) + "</span>"; } componentColumn = subEntry["column"]; } else { componentOutput = subEntry["custom_code"]; componentColumn = subEntry["custom_column"]; } switch (componentColumn) { case "col1": sbCol1.Append(componentOutput); break; case "col2": sbCol2.Append(componentOutput); break; case "col3": sbCol3.Append(componentOutput); break; } } rowContent.Add("{col1}", sbCol1); rowContent.Add("{col2}", sbCol2); Out.Write(layout.output(asset, entry.GetFieldName("layout"), rowContent, entry["layout"])); rowContent.Clear(); } Out.WriteLine(footer); } public static void PostInputHelper(Asset asset, PostInputContext context) { PanelEntry firstPe = context.InputForm.GetPanels("layouts").FirstOrDefault(); if (firstPe != null && firstPe["consolidate_section_tab"] == "yes") { context.ValidationError = "Please uncheck the \"Consolidate section into the above sections input tab\" checkbox on the first section."; } else { Asset siteConfig = Asset.Load(!String.IsNullOrWhiteSpace(context.InputForm["config_asset"]) ? context.InputForm["config_asset"] : asset["config_asset"]); if (context.InputForm["config_asset_type"] == "decoupled") { if (context.InputForm["wrapper_config_reference_type"] == "relative") { if (String.IsNullOrWhiteSpace(context.InputForm["wrapper_config_template_name"])) { context.ValidationErrorFields.Add("wrapper_config_template_name", "Please specify a wrapper config name"); } else if (String.IsNullOrWhiteSpace(context.InputForm["wrapper_config_folder"])) { context.ValidationErrorFields.Add("wrapper_config_folder", "Please specify the folder the wrapper will exist in"); } FilterParams wrapperConfigFilterParams = new FilterParams(); wrapperConfigFilterParams.Add(AssetPropertyNames.TemplateLabel, Comparison.Equals, context.InputForm["wrapper_config_template_name"]); siteConfig = Asset.Load(Asset.Load(context.InputForm["wrapper_config_folder"]).AssetPath).GetFilterList(wrapperConfigFilterParams).FirstOrDefault(); } else if (context.InputForm["wrapper_config_reference_type"] != "custom") { context.ValidationErrorFields.Add("wrapper_config_reference_type", "Please select a wrapper config reference option"); } } Asset componentLibraryComponentsFolder = ComponentLibraryHelper.getComponentLibraryComponentsFolder(asset); string nameSpace = ""; string componentLibraryClassName = "ComponentLibraryHelper"; string layoutClassName = "layout"; string openTag = "<" + "%"; string closeTag = "%" + ">"; string tab = "\t"; string componentClassName = ""; string componentName = ""; string componentLabel = ""; string componentFieldName = ""; string componentThumbnail = ""; string componentType = ""; string componentColumn = ""; Asset aComponent; bool startFooter = false; bool GetWrapContentPlaceholderInserted = false; StringBuilder sbDeclare = new StringBuilder(); StringBuilder sbInput = new StringBuilder(); StringBuilder sbPostInput = new StringBuilder(); StringBuilder sbOutput = new StringBuilder(); StringBuilder sbInputContent = new StringBuilder(); StringBuilder sbPostInputContent = new StringBuilder(); StringBuilder sbOutputContent = new StringBuilder(); Dictionary<string, int> components = new Dictionary<string, int>(); String header = context.InputForm["header_markup"]; bool enableThemingOnConfig = header.Contains("{css_configurable}"); String footer = context.InputForm["footer_markup"]; String css = ""; String javascript = ""; String metaData = openTag + " Out.Write(metaData.output(asset, context, \"meta\")); " + closeTag; String customJavascriptAndCss = openTag + " Out.Write(customJavascriptAndCss.output(asset, context, \"meta\")); " + closeTag; List<PanelEntry> cssHeaderPanels = context.InputForm.GetPanels("Header CSS"); for (int cssIndex = 0; cssIndex < cssHeaderPanels.Count; cssIndex++) { PanelEntry entry = cssHeaderPanels[cssIndex]; String cssString = "<link rel=\"stylesheet\" href=\"" + openTag + "=Asset.Load(\"" + Asset.Load(entry["header_css"]).AssetPath.ToString() + "\").GetLink(LinkType.Include)" + closeTag + "\" media=\"all\" />"; css += cssString + "\r\n\t\t"; Regex cssPlaceholderRegex = new Regex(@"{\s*css\s*:\s*" + (cssIndex + 1) + @"\s*}"); MatchCollection matches = cssPlaceholderRegex.Matches(header); foreach (Match match in matches) { header = header.Replace(match.Value, cssString); } } List<PanelEntry> jsHeaderPanels = context.InputForm.GetPanels("Header Javascript"); for (int jsIndex = 0; jsIndex < jsHeaderPanels.Count; jsIndex++) { PanelEntry entry = jsHeaderPanels[jsIndex]; String jsString = "<script src=\"" + openTag + "=Asset.Load(\"" + Asset.Load(entry["header_javascript"]).AssetPath.ToString() + "\").GetLink(LinkType.Include)" + closeTag + "\"></script>"; javascript += jsString + "\r\n\t\t"; Regex jsPlaceholderRegex = new Regex(@"{\s*javascript\s*:\s*" + (jsIndex + 1) + @"\s*}"); MatchCollection matches = jsPlaceholderRegex.Matches(header); foreach (Match match in matches) { header = header.Replace(match.Value, jsString); } } header = header.Replace("{css}", css).Replace("{javascript}", javascript).Replace("{metadata}", metaData).Replace("{page_specific_js_css}", customJavascriptAndCss).Replace("{css_configurable}", openTag + "Out.Write(ComponentLibraryHelper.generateCssHeaderDeclarations(siteConfig)); " + closeTag); css = ""; javascript = ""; List<PanelEntry> cssFooterPanels = context.InputForm.GetPanels("Footer CSS"); for (int cssIndex = 0; cssIndex < cssFooterPanels.Count; cssIndex++) { PanelEntry entry = cssFooterPanels[cssIndex]; String cssString = "<link rel=\"stylesheet\" href=\"" + openTag + "=Asset.Load(\"" + Asset.Load(entry["footer_css"]).AssetPath.ToString() + "\").GetLink(LinkType.Include)" + closeTag + "\" media=\"all\" />"; ; css += cssString + "\r\n\t\t"; Regex cssPlaceholderRegex = new Regex(@"{\s*css\s*:\s*" + (cssIndex + 1) + @"\s*}"); MatchCollection matches = cssPlaceholderRegex.Matches(footer); foreach (Match match in matches) { footer = footer.Replace(match.Value, cssString); } } List<PanelEntry> jsFooterPanels = context.InputForm.GetPanels("Footer Javascript"); for (int jsIndex = 0; jsIndex < jsFooterPanels.Count; jsIndex++) { PanelEntry entry = jsFooterPanels[jsIndex]; String jsString = "<script src=\"" + openTag + "=Asset.Load(\"" + Asset.Load(entry["footer_javascript"]).AssetPath.ToString() + "\").GetLink(LinkType.Include)" + closeTag + "\"></script>"; javascript += jsString + "\r\n\t\t"; Regex jsPlaceholderRegex = new Regex(@"{\s*javascript\s*:\s*" + (jsIndex + 1) + @"\s*}"); MatchCollection matches = jsPlaceholderRegex.Matches(footer); foreach (Match match in matches) { footer = footer.Replace(match.Value, jsString); } } footer = footer.Replace("{css}", css).Replace("{javascript}", javascript); String componentLibraryNamespace = ComponentLibraryHelper.getComponentLibraryNamespace(asset); sbDeclare.Append(openTag + "@ Import Namespace=\"CrownPeak.CMSAPI\" " + closeTag).AppendLine(); sbDeclare.Append(openTag + "@ Import Namespace=\"CrownPeak.CMSAPI.Services\" " + closeTag).AppendLine(); sbDeclare.Append(openTag + "@ Import Namespace=\"CrownPeak.CMSAPI.CustomLibrary\" " + closeTag).AppendLine(); sbDeclare.Append(openTag + "@ Import Namespace=\"" + componentLibraryNamespace + "\" " + closeTag).AppendLine(); sbDeclare.Append("<!--DO NOT MODIFY CODE ABOVE THIS LINE-->").AppendLine(); sbDeclare.Append(openTag).AppendLine(); sbDeclare.Append(tab + nameSpace + "Component_Layout layout = new " + nameSpace + "Component_Layout();").AppendLine(); sbDeclare.Append(tab + nameSpace + "MetaData metaData = new " + nameSpace + "MetaData();").AppendLine(); sbDeclare.Append(tab + nameSpace + "HeaderJavascriptAndCss customJavascriptAndCss = new " + nameSpace + "HeaderJavascriptAndCss();").AppendLine(); if (enableThemingOnConfig) { sbInputContent.Append(tab + "String SiteRootFolderPath = ComponentLibraryHelper.getComponentLibrarySiteRootFolder(asset).AssetPath.ToString();").AppendLine(); } sbInputContent.Append(tab + "Input.StartTabbedPanel("); if (context.InputForm["config_asset_type"] == "decoupled") { if (context.InputForm["wrapper_config_reference_type"] == "relative") { sbOutputContent.Append(tab + "FilterParams wrapperConfigFilterParams = new FilterParams();").AppendLine(); sbOutputContent.Append(tab + "wrapperConfigFilterParams.Add(AssetPropertyNames.TemplateLabel, Comparison.Equals, \"" + context.InputForm["wrapper_config_template_name"] + "\");").AppendLine(); sbOutputContent.Append(tab + "Asset siteConfig = Asset.Load(\"" + Asset.Load(context.InputForm["wrapper_config_folder"]).AssetPath + "\").GetFilterList(wrapperConfigFilterParams).FirstOrDefault();").AppendLine(); } else { sbOutputContent.Append(tab + "Asset siteConfig = " + context.InputForm["wrapper_config_custom_code"]).AppendLine(); } } else { sbOutputContent.Append(tab + "Asset siteConfig = Asset.Load(\"" + siteConfig.AssetPath + "\");").AppendLine(); } String dlm = ""; foreach (PanelEntry entry in context.InputForm.GetPanels("layouts")) { if (entry["consolidate_section_tab"] != "yes") { sbInputContent.Append(dlm + "\"" + entry["section"] + "\""); dlm = ", "; } } if (context.InputForm["meta"] == "yes") sbInputContent.Append(", \"Meta Data\""); if (enableThemingOnConfig) sbInputContent.Append(", \"Theme / CSS\""); if (context.InputForm["advanced"] == "yes") sbInputContent.Append(", \"Advanced\""); sbInputContent.Append(");").AppendLine(); // add header content sbOutputContent.Append(closeTag).AppendLine(); sbOutputContent.Append(header).AppendLine(); sbOutputContent.Append(openTag).AppendLine(); sbOutputContent.Append(tab + "StringBuilder sbCol1 = new StringBuilder();").AppendLine(); sbOutputContent.Append(tab + "StringBuilder sbCol2 = new StringBuilder();").AppendLine(); sbOutputContent.Append(tab + "StringBuilder sbCol3 = new StringBuilder();").AppendLine(); sbOutputContent.Append(tab + "Dictionary<String, StringBuilder> rowContent = new Dictionary<string, StringBuilder>();").AppendLine(); sbOutputContent.AppendLine(); String nextTab = ""; Int32 unique = 0; foreach (PanelEntry entry in context.InputForm.GetPanels("layouts")) { if (entry["wrapper_option"] == "footer") startFooter = true; if (startFooter && !GetWrapContentPlaceholderInserted) { // add main content sbOutputContent.Append(closeTag).AppendLine(); sbOutputContent.Append(context.InputForm["before_markup"]).AppendLine(); sbOutputContent.Append(tab + openTag + "= Out.GetWrapContentPlaceholder()" + closeTag).AppendLine(); sbOutputContent.Append(context.InputForm["after_markup"]).AppendLine(); sbOutputContent.Append(openTag).AppendLine(); GetWrapContentPlaceholderInserted = true; } if (!String.IsNullOrEmpty(entry["layout_thumbnail"])) { Asset aLayoutThumbnail = Asset.Load(entry["layout_thumbnail"]); if (aLayoutThumbnail.IsLoaded) { Asset aLayout = Asset.Load(componentLibraryComponentsFolder + "/layouts/" + aLayoutThumbnail.Label.ToLower().Replace(".png", "")); if (aLayout.IsLoaded) entry["layout"] = aLayout.Label; } } if (entry["consolidate_section_tab"] != "yes") { sbInputContent.Append(nextTab).AppendLine(); } sbOutputContent.Append(tab + "// " + entry["section"]).AppendLine(); sbOutputContent.AppendLine(); Int32 col = 1; while (col < 3) { sbInputContent.Append(tab + tab + "// Capture content for Column " + col.ToString()).AppendLine(); sbOutputContent.Append(tab + "// Assemble content for Column " + col.ToString()).AppendLine(); sbOutputContent.Append(tab + "sbCol" + col.ToString() + ".Clear();").AppendLine(); foreach (PanelEntry subEntry in entry.GetPanels("components")) { if (subEntry["column"] == "col" + col.ToString()) { if (!String.IsNullOrEmpty(subEntry["component_thumbnail"])) { componentThumbnail = Asset.Load(subEntry["component_thumbnail"]).Label; if (!String.IsNullOrEmpty(componentThumbnail)) { componentType = componentThumbnail.Substring(0, componentThumbnail.IndexOf(" - ")).Trim(); componentName = componentThumbnail.Substring(componentThumbnail.IndexOf(" - ") + 3).Replace(".png", "").Trim(); aComponent = Asset.Load(componentLibraryComponentsFolder + "/" + componentType + "s/" + componentName); if (aComponent.IsLoaded) subEntry["component"] = aComponent.Label; //aComponent.AssetPath.ToString(); } } aComponent = ComponentLibraryHelper.getComponentAsset(asset, subEntry["component"]); if (aComponent != null && aComponent.IsLoaded) { componentClassName = aComponent.Raw["class_name"]; //componentLabel = String.IsNullOrEmpty(subEntry["label"])?aComponent.Label:subEntry["label"]; componentName = char.ToLower(componentClassName[0]) + componentClassName.Substring(1); if (!components.ContainsKey(componentName)) { components.Add(componentName, 0); sbDeclare.Append(tab + nameSpace + componentClassName + " " + componentName + " = new " + nameSpace + componentClassName + "();").AppendLine(); } else components[componentName]++; componentFieldName = !String.IsNullOrEmpty(subEntry["name"]) ? subEntry["name"] : aComponent.Label.ToLower().Replace(" ", "_") + (components[componentName] > 0 ? "_" + (components[componentName] + 1).ToString() : ""); subEntry["name"] = componentFieldName; //subEntry["label"] = componentLabel; sbInputContent.Append(tab + tab + componentName + ".input(asset, \"" + componentLabel + "\",\"" + componentFieldName + "\");").AppendLine(); sbPostInputContent.Append(tab + componentName + ".postinput(context,\"" + componentFieldName + "\");").AppendLine(); sbOutputContent.Append(tab + "sbCol" + col.ToString() + ".Append(" + componentName + ".output(siteConfig, context,\"" + componentFieldName + "\"));").AppendLine(); } } else if (subEntry["content_type"] == "custom" && !String.IsNullOrEmpty(subEntry["custom_code"]) && subEntry["custom_column"] == "col" + col.ToString()) { sbOutputContent.Append(tab + "Out.StartCapture();").AppendLine(); sbOutputContent.Append(closeTag).AppendLine(); sbOutputContent.Append(subEntry.Raw["custom_code"]).AppendLine(); sbOutputContent.Append(openTag).AppendLine(); sbOutputContent.Append(tab + "sbCol" + col.ToString() + ".Append(Out.StopCapture());").AppendLine(); } unique++; } sbInputContent.AppendLine(); sbOutputContent.Append(tab + "rowContent.Add(\"{col" + col.ToString() + "}\", sbCol" + col.ToString() + ");").AppendLine(); sbOutputContent.AppendLine(); col++; } if (entry["editable"] == "yes") { sbInputContent.Append(tab + tab + "//Layout").AppendLine(); sbInputContent.Append(tab + tab + layoutClassName + ".input(asset,\"" + entry["section"] + " layout\",\"" + entry.GetFieldName("layout") + "\",\"" + entry["layout"] + "\");").AppendLine(); sbInputContent.AppendLine(); } sbOutputContent.Append(tab + "// Output Content for Page using a specific layout").AppendLine(); sbOutputContent.Append(tab + "Out.Write(layout.output(asset, \"" + entry.GetFieldName("layout") + "\", rowContent,\"" + entry["layout"] + "\"));").AppendLine(); sbOutputContent.Append(tab + "rowContent.Clear();").AppendLine(); sbOutputContent.AppendLine(); nextTab = "Input.NextTabbedPanel();"; } if (!startFooter) { //append Out.writeline even if footer is not present sbOutputContent.Append(closeTag).AppendLine(); sbOutputContent.Append(context.InputForm["before_markup"]).AppendLine(); sbOutputContent.Append(tab + openTag + "=Out.GetWrapContentPlaceholder();" + closeTag).AppendLine(); sbOutputContent.Append(context.InputForm["after_markup"]).AppendLine(); sbOutputContent.Append(openTag).AppendLine(); GetWrapContentPlaceholderInserted = true; } sbDeclare.Append(closeTag).AppendLine(); if (enableThemingOnConfig) { sbInputContent.Append(tab + "Input.NextTabbedPanel();").AppendLine(); sbInputContent.Append(tab + tab + "ShowAcquireParams parameters = new ShowAcquireParams();").AppendLine(); sbInputContent.Append(tab + tab + "parameters.DefaultFolder = SiteRootFolderPath + \"/_themes\";").AppendLine(); sbInputContent.Append(tab + tab + "parameters.ShowUpload = false;").AppendLine(); sbInputContent.Append(tab + tab + "Input.ShowAcquireImage(\"Theme\", \"theme\", parameters);").AppendLine(); sbInputContent.Append(tab + tab + "ShowAcquireParams aParams = new ShowAcquireParams();").AppendLine(); sbInputContent.Append(tab + tab + "aParams.DefaultFolder = SiteRootFolderPath + \"/_Assets/css\";").AppendLine(); sbInputContent.Append(tab + tab + "Input.ShowAcquireDocument(\"Custom Theme\", \"theme_id\", aParams);").AppendLine(); sbPostInputContent.Append("*/").AppendLine(); sbPostInputContent.Append(tab + "string cssFolder = \"/\" + asset.AssetPath[0] + \"/_Assets/css/\";").AppendLine(); sbPostInputContent.Append(tab + "string cssFileId = Asset.Load(cssFolder + \"original.css\").Id.ToString();").AppendLine(); sbPostInputContent.Append(tab + "if (!String.IsNullOrEmpty(context.InputForm[\"theme_id\"]))").AppendLine(); sbPostInputContent.Append(tab + "{").AppendLine(); sbPostInputContent.Append(tab + " Asset aCSSFile = Asset.Load(context.InputForm[\"theme_id\"]);").AppendLine(); sbPostInputContent.Append(tab + " if (aCSSFile.IsLoaded)").AppendLine(); sbPostInputContent.Append(tab + " {").AppendLine(); sbPostInputContent.Append(tab + " cssFileId = aCSSFile.Id.ToString();").AppendLine(); sbPostInputContent.Append(tab + " //context.InputForm.Remove(\"theme\");").AppendLine(); sbPostInputContent.Append(tab + " context.InputForm[\"theme\"] = \"\";").AppendLine(); sbPostInputContent.Append(tab + " context.InputForm[\"upload#theme\"] = \"\";").AppendLine(); sbPostInputContent.Append(tab + " context.InputForm[\"upload_name#theme\"] = \"\";").AppendLine(); sbPostInputContent.Append(tab + " }").AppendLine(); sbPostInputContent.Append(tab + "}").AppendLine(); sbPostInputContent.Append(tab + "else if (!String.IsNullOrEmpty(context.InputForm[\"theme\"]))").AppendLine(); sbPostInputContent.Append(tab + "{").AppendLine(); sbPostInputContent.Append(tab + " Asset aCSSTheme = Asset.Load(context.InputForm[\"theme\"]);").AppendLine(); sbPostInputContent.Append(tab + " if (aCSSTheme.IsLoaded)").AppendLine(); sbPostInputContent.Append(tab + " {").AppendLine(); sbPostInputContent.Append(tab + " Asset aCSSFile = Asset.Load(cssFolder + aCSSTheme.Label.ToLower().Replace(\"png\", \"css\"));").AppendLine(); sbPostInputContent.Append(tab + " if (aCSSFile.IsLoaded) cssFileId = aCSSFile.Id.ToString();").AppendLine(); sbPostInputContent.Append(tab + " }").AppendLine(); sbPostInputContent.Append(tab + "}").AppendLine(); sbPostInputContent.Append(tab + "context.InputForm[\"css_to_use\"] = cssFileId;").AppendLine(); sbPostInputContent.Append("/*").AppendLine(); } if (context.InputForm["advanced"] == "yes") { sbInputContent.Append(tab + "Input.NextTabbedPanel();").AppendLine(); if (context.InputForm["config_asset_type"] != "decoupled" && context.InputForm["wrapper_config_reference_type"] != "custom") { sbInputContent.Append(tab + tab + "Input.ShowLink(Asset.Load(\"" + siteConfig.AssetPath.ToString() + "\"), \"Edit Theme\", InputLinkType.EditTab);").AppendLine(); } sbInputContent.Append(tab + tab + "Input.ShowLink(Asset.Load(\"" + asset.AssetPath.ToString() + "\"), \"Edit Template\", InputLinkType.EditTab);").AppendLine(); } sbInputContent.Append(tab + "Input.EndTabbedPanel();").AppendLine(); // add footer content sbOutputContent.Append(closeTag).AppendLine(); sbOutputContent.Append(footer).AppendLine(); sbOutputContent.Append(openTag).AppendLine(); sbInput.Append(openTag + "@ Page Language=\"C#\" Inherits=\"CrownPeak.Internal.Debug.InputInit\" " + closeTag).AppendLine(); sbInput.Append(sbDeclare.ToString()).AppendLine(); sbInput.Append(openTag).AppendLine(); sbInput.Append(sbInputContent.ToString()); sbInput.Append(closeTag).AppendLine(); sbPostInput.Append(openTag + "@ Page Language=\"C#\" Inherits=\"CrownPeak.Internal.Debug.PostInputInit\" " + closeTag).AppendLine(); sbPostInput.Append(sbDeclare.ToString()).AppendLine(); sbPostInput.Append(openTag + "/*").AppendLine(); sbPostInput.Append(sbPostInputContent.ToString()); sbPostInput.Append("*/" + closeTag).AppendLine(); sbOutput.Append(openTag + "@ Page Language=\"C#\" Inherits=\"CrownPeak.Internal.Debug.OutputInit\" " + closeTag).AppendLine(); sbOutput.Append(sbDeclare.ToString()).AppendLine(); sbOutput.Append(openTag).AppendLine(); sbOutput.Append(sbOutputContent.ToString()); sbOutput.Append(closeTag).AppendLine(); context.InputForm["inputBody"] = sbInput.ToString(); context.InputForm["postinputBody"] = sbPostInput.ToString(); context.InputForm["outputBody"] = sbOutput.ToString(); if (context.InputForm["create"] == "yes") { Asset folderAsset = Asset.Load(context.InputForm["template_folder"]); Asset templateAsset = Asset.Load(folderAsset.AssetPath + "/" + context.InputForm["template_name"]); } } } public static void PostSaveHelper(Asset asset, PostSaveContext context) { if (asset["create"] == "yes") { Asset folderAsset = Asset.Load(asset["template_folder"]); Asset wrapperTemplateAsset = Asset.Load(folderAsset.AssetPath + "/" + asset.Raw["template_name"]); Asset configTemplateAsset = asset["config_asset_type"] == "decoupled" ? Asset.Load(folderAsset.AssetPath + "/" + asset.Raw["wrapper_config_template_name"]) : null; Asset modelAsset = Asset.LoadDirect("/System/Templates/Basis/Template/Template Folder"); Dictionary<string, string> contentFields = new Dictionary<string, string> { { "Auto created by", asset.Id.ToString() } }; if (!wrapperTemplateAsset.IsLoaded) { wrapperTemplateAsset = Asset.CreateNewAsset(asset.Raw["template_name"], folderAsset, modelAsset, contentFields); asset.SaveContentField("templateId", wrapperTemplateAsset.Id.ToString()); asset["templateId"] = wrapperTemplateAsset.Id.ToString(); } if (asset["config_asset_type"] == "decoupled" && !configTemplateAsset.IsLoaded) { configTemplateAsset = Asset.CreateNewAsset(asset.Raw["wrapper_config_template_name"], folderAsset, modelAsset, contentFields); asset.SaveContentField("configTemplateId", configTemplateAsset.Id.ToString()); asset["configTemplateId"] = configTemplateAsset.Id.ToString(); } if (wrapperTemplateAsset.IsLoaded) { folderAsset = wrapperTemplateAsset; if (asset["config_asset_type"] == "decoupled" && configTemplateAsset.IsLoaded) { modelAsset = Asset.LoadDirect("/System/Templates/Basis/ComponentsCS/input.aspx"); contentFields = new Dictionary<string, string> { { "body", asset.Raw["inputBody"] } }; Asset inputAsset = Asset.Load(configTemplateAsset.AssetPath + "/input.aspx"); if (inputAsset.IsLoaded) inputAsset.Delete(); inputAsset = Asset.CreateNewAsset("input.aspx", configTemplateAsset, modelAsset, contentFields); modelAsset = Asset.LoadDirect("/System/Templates/Basis/ComponentsCS/post_input.aspx"); contentFields = new Dictionary<string, string> { { "body", asset.Raw["postinputBody"] } }; Asset postinputAsset = Asset.Load(configTemplateAsset.AssetPath + "/post_input.aspx"); if (postinputAsset.IsLoaded) postinputAsset.Delete(); postinputAsset = Asset.CreateNewAsset("post_input.aspx", configTemplateAsset, modelAsset, contentFields); } else { modelAsset = Asset.LoadDirect("/System/Templates/Basis/ComponentsCS/input.aspx"); contentFields = new Dictionary<string, string> { { "body", asset.Raw["inputBody"] } }; Asset inputAsset = Asset.Load(folderAsset.AssetPath + "/input.aspx"); if (inputAsset.IsLoaded) inputAsset.Delete(); inputAsset = Asset.CreateNewAsset("input.aspx", folderAsset, modelAsset, contentFields); modelAsset = Asset.LoadDirect("/System/Templates/Basis/ComponentsCS/post_input.aspx"); contentFields = new Dictionary<string, string> { { "body", asset.Raw["postinputBody"] } }; Asset postinputAsset = Asset.Load(folderAsset.AssetPath + "/post_input.aspx"); if (postinputAsset.IsLoaded) postinputAsset.Delete(); postinputAsset = Asset.CreateNewAsset("post_input.aspx", folderAsset, modelAsset, contentFields); } modelAsset = Asset.LoadDirect("/System/Templates/Basis/ComponentsCS/output.aspx"); contentFields = new Dictionary<string, string> { { "body", asset.Raw["outputBody"] } }; Asset outputAsset = Asset.Load(folderAsset.AssetPath + "/output.aspx"); if (outputAsset.IsLoaded) outputAsset.Delete(); outputAsset = Asset.CreateNewAsset("output.aspx", folderAsset, modelAsset, contentFields); } if (!String.IsNullOrEmpty(asset[asset["previewAsset"]])) { Asset previewAsset = Asset.Load(asset["previewAsset"]); previewAsset.SetTemplate(wrapperTemplateAsset.Id); foreach (PanelEntry entry in asset.GetPanels("layouts")) { previewAsset[entry.GetFieldName("layout")] = entry["layout"]; } previewAsset.SaveContent(); } } asset.SaveContentField("override", ""); asset.Rename(asset["template_name"]); //asset.SaveContent(); } private static string makeRaw(string content) { foreach (Match mc in Regex.Matches(content, @"~\$CPIL\$\d+\$[\w:]+\$\w+\$")) { content = content.Replace(mc.Value, "").Replace("$/CPIL$~", ""); } foreach (Match mc in Regex.Matches(content, @"%\$CPIL\$\d+\$[\w:]+\$\w+\$")) { content = content.Replace(mc.Value, "").Replace("$/CPIL$%", ""); } return content; } } } 172437 1792 /System/Templates/Basis/DeveloperCS/ 1 0 false false 0 /Component Project/Library/Components_Code.cs 261059 17 LibraryClass 2 body using System; using System.Collections.Generic; using System.Linq; using System.Text; using CrownPeak.CMSAPI; using CrownPeak.CMSAPI.Services; using Component_Library.Component_Project.Components; /* Some Namespaces are not allowed. */ namespace Component_Library.Component_Project.Components { public partial class Code : JsonComponentBase { /*comment out "inputBase(label, name);" & modify this function if you want to overwrite the input functionality of the component.*/ public override void ComponentInput(Asset asset, InputContext context, String label, string name) { //inputBase(asset, label, name); Input.ShowTextBox(label, name); } /*comment out "postInputBase(context, name, index);" & modify this function if you want to overwrite the post_input functionality of the component.*/ public override void ComponentPostInput(Asset asset, PostInputContext context, string name, string index = "") { PostInputBase(asset, context, name, index); } /*comment out "outputBase(asset, context, name, index, isDrag);" & modify this function if you want to overwrite the output functionality of the component.*/ public override string ComponentOutput(Asset asset, OutputContext context, string name, string index = "", bool isDrag = false) { //return outputBase(asset, context, name, index, ); return asset[name + index]; } public override string ComponentJson(Asset asset, OutputContext context, string name, string index = "") { //The below function refers the automatically generated output functionality for this component. //If you wish to alter the the output functionality write your own output code here. //NOTE: It is important to handle cases where the asset AND OR the context will be null in your custom code var content = asset.Raw[name + index]; return string.IsNullOrEmpty(content) ? "null" : JsonHelper.StringToJson(content, includeQuotes: true); } /*comment out "IndexedFieldsBase(asset, context, name, index);" & modify this function if you want to overwrite the indexed fields of the component.*/ public override IEnumerable<IndexedField> ComponentIndexedFields(Asset asset, SearchG2Context context, string name, string index = "") { return IndexedFieldsBase(asset, context, name, index); } } } 172436 1792 /System/Templates/Basis/DeveloperCS/ 1 0 false false 0 /Component Project/Library/Components_CodeBase.cs 261059 17 LibraryClass 2 body using System; using System.Collections.Generic; using System.Linq; using System.Text; using CrownPeak.CMSAPI; using CrownPeak.CMSAPI.Services; using Component_Library.Component_Project.Components; /* Some Namespaces are not allowed. */ namespace Component_Library.Component_Project.Components { [Serializable] public partial class Code : JsonComponentBase { public Code() { ComponentMarkup = @""; } public void InputBase(Asset asset, InputContext context, string label, string name) { } public void PostInputBase(Asset asset, PostInputContext context, string name, string index = "") { } public string OutputBase(Asset asset, OutputContext context, string name, string index = "", bool isDrag = false) { if (isDrag) { StringBuilder ddContent = new StringBuilder(); ddContent.Append(ComponentMarkup); return ComponentFramework.ParseDragAndDropMarkupForPreviewAndPublish(context, ddContent.ToString()); } StringBuilder sbContent = new StringBuilder(); sbContent.Append(ComponentMarkup); string markup = ComponentFramework.UpdateMarkupForPreviewPublish(context, sbContent.ToString()); return markup; } public string JsonBase(Asset asset, OutputContext context, string name, string index = "") { return ""; } public IEnumerable<IndexedField> IndexedFieldsBase(Asset asset, SearchG2Context context, string name, string index = "") { return new IndexedField[0]; } } } 172435 1792 /System/Templates/Basis/DeveloperCS/ 1 0 false false 0 /Component Project/Library/Components_Color.cs 261059 17 LibraryClass 2 body using System; using System.Collections.Generic; using System.Linq; using System.Text; using CrownPeak.CMSAPI; using CrownPeak.CMSAPI.Services; using Component_Library.Component_Project.Components; /* Some Namespaces are not allowed. */ namespace Component_Library.Component_Project.Components { public partial class Color : JsonComponentBase { /*comment out "inputBase(label, name);" & modify this function if you want to overwrite the input functionality of the component.*/ public override void ComponentInput(Asset asset, InputContext context, String label, string name) { //inputBase(asset, label, name); Input.ShowSelectColor(label, name); } /*comment out "postInputBase(context, name, index);" & modify this function if you want to overwrite the post_input functionality of the component.*/ public override void ComponentPostInput(Asset asset, PostInputContext context, string name, string index = "") { PostInputBase(asset, context, name, index); } /*comment out "outputBase(asset, context, name, index, isDrag);" & modify this function if you want to overwrite the output functionality of the component.*/ public override string ComponentOutput(Asset asset, OutputContext context, string name, string index = "", bool isDrag = false) { //return outputBase(asset, context, name, index, isDrag); return asset[name + index]; } public override string ComponentJson(Asset asset, OutputContext context, string name, string index = "") { //The below function refers the automatically generated output functionality for this component. //If you wish to alter the the output functionality write your own output code here. //NOTE: It is important to handle cases where the asset AND OR the context will be null in your custom code var content = asset.Raw[name + index]; return string.IsNullOrEmpty(content) ? "null" : JsonHelper.StringToJson(content, includeQuotes: true); } /*comment out "IndexedFieldsBase(asset, context, name, index);" & modify this function if you want to overwrite the indexed fields of the component.*/ public override IEnumerable<IndexedField> ComponentIndexedFields(Asset asset, SearchG2Context context, string name, string index = "") { return IndexedFieldsBase(asset, context, name, index); } } } 172434 1792 /System/Templates/Basis/DeveloperCS/ 1 0 false false 0 /Component Project/Library/Components_ColorBase.cs 261059 17 LibraryClass 2 body using System; using System.Collections.Generic; using System.Linq; using System.Text; using CrownPeak.CMSAPI; using CrownPeak.CMSAPI.Services; using Component_Library.Component_Project.Components; /* Some Namespaces are not allowed. */ namespace Component_Library.Component_Project.Components { [Serializable] public partial class Color : JsonComponentBase { public Color() { ComponentMarkup = @""; } public void InputBase(Asset asset, InputContext context, string label, string name) { } public void PostInputBase(Asset asset, PostInputContext context, string name, string index = "") { } public string OutputBase(Asset asset, OutputContext context, string name, string index = "", bool isDrag = false) { if (isDrag) { StringBuilder ddContent = new StringBuilder(); ddContent.Append(ComponentMarkup); return ComponentFramework.ParseDragAndDropMarkupForPreviewAndPublish(context, ddContent.ToString()); } StringBuilder sbContent = new StringBuilder(); sbContent.Append(ComponentMarkup); string markup = ComponentFramework.UpdateMarkupForPreviewPublish(context, sbContent.ToString()); return markup; } public string JsonBase(Asset asset, OutputContext context, string name, string index = "") { return ""; } public IEnumerable<IndexedField> IndexedFieldsBase(Asset asset, SearchG2Context context, string name, string index = "") { return new IndexedField[0]; } } } 261346 1792 /System/Templates/Basis/DeveloperCS/ 1 0 false false 0 0 /Component Project/Library/Components_Date.cs 261059 17 LibraryClass 2 body using System; using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Text; using CrownPeak.CMSAPI; using CrownPeak.CMSAPI.Services; using Component_Library.Component_Project.Components; /* Some Namespaces are not allowed. */ namespace Component_Library.Component_Project.Components { public partial class Date : JsonComponentBase { public override void ComponentInput(Asset asset, InputContext context, string label, string name) { Input.ShowSelectDate(label, name); } public override void ComponentPostInput(Asset asset, PostInputContext context, string name, string index = "") { //The below function refers the automatically generated post_input functionality for this component. //If you wish to alter the the post_input functionality write your own post_input code here. //NOTE: It is important to handle cases where the asset AND OR the context will be null in your custom code PostInputBase(asset, context, name, index); } public override string ComponentOutput(Asset asset, OutputContext context, string name, string index = "", bool isDrag = false) { //The below function refers the automatically generated output functionality for this component. //If you wish to alter the the output functionality write your own output code here. //NOTE: It is important to handle cases where the asset AND OR the context will be null in your custom code if (isDrag && !context.IsPublishing) { return "~$cpfield$" + name + index + "$/cpfield$~"; } return asset[name + index]; } public override string ComponentJson(Asset asset, OutputContext context, string name, string index = "") { //The below function refers the automatically generated output functionality for this component. //If you wish to alter the the output functionality write your own output code here. //NOTE: It is important to handle cases where the asset AND OR the context will be null in your custom code var value = asset.Raw[name + index]; DateTime dt; if (DateTime.TryParseExact(value, "M/d/yyyy", null, DateTimeStyles.None, out dt)) return JsonHelper.StringToJson(dt.ToString("yyyy-MM-dd"), includeQuotes: true); return "null"; } /*comment out "IndexedFieldsBase(asset, context, name, index);" & modify this function if you want to overwrite the indexed fields of the component.*/ public override IEnumerable<IndexedField> ComponentIndexedFields(Asset asset, SearchG2Context context, string name, string index = "") { return IndexedFieldsBase(asset, context, name, index); } } } 261345 1792 /System/Templates/Basis/DeveloperCS/ 1 0 false false 0 0 /Component Project/Library/Components_DateBase.cs 261059 17 LibraryClass 2 body using System; using System.Collections.Generic; using System.Linq; using System.Text; using CrownPeak.CMSAPI; using CrownPeak.CMSAPI.Services; using Component_Library.Component_Project.Components; /* Some Namespaces are not allowed. */ namespace Component_Library.Component_Project.Components { [Serializable] public partial class Date : JsonComponentBase { public Date() { ComponentMarkup = @""; } public void InputBase(Asset asset, InputContext context, string label, string name) { } public void PostInputBase(Asset asset, PostInputContext context, string name, string index = "") { } public string OutputBase(Asset asset, OutputContext context, string name, string index = "", bool isDrag = false) { if (isDrag) { StringBuilder ddContent = new StringBuilder(); ddContent.Append(ComponentMarkup); return ComponentFramework.ParseDragAndDropMarkupForPreviewAndPublish(context, ddContent.ToString()); } StringBuilder sbContent = new StringBuilder(); sbContent.Append(ComponentMarkup); string markup = ComponentFramework.UpdateMarkupForPreviewPublish(context, sbContent.ToString()); return markup; } public string JsonBase(Asset asset, OutputContext context, string name, string index = "") { return "null"; } public IEnumerable<IndexedField> IndexedFieldsBase(Asset asset, SearchG2Context context, string name, string index = "") { return new IndexedField[0]; } } } 263534 1792 /System/Templates/Basis/DeveloperCS/ 1 0 false false 0 0 /Component Project/Library/Components_Document.cs 261059 17 LibraryClass 2 body using System; using System.Collections.Generic; using System.Linq; using System.Text; using CrownPeak.CMSAPI; using CrownPeak.CMSAPI.Services; using Component_Library.Component_Project.Components; /* Some Namespaces are not allowed. */ namespace Component_Library.Component_Project.Components { public partial class Document : JsonComponentBase { public override void ComponentInput(Asset asset, InputContext context, string label, string name) { //The below function refers the automatically generated input functionality for this component. //If you wish to alter the the input functionality write your own input code here. //NOTE: It is important to handle cases where the asset AND OR the context will be null in your custom code var sap = new ShowAcquireParams { DefaultFolder = Asset.GetSiteRoot(asset).AssetPath.ToString(), PickerType = PickerViewType.FileView, ShowBrowse = true, ShowUpload = false, }; Input.ShowAcquireDocument(label, name, sap); } public override void ComponentPostInput(Asset asset, PostInputContext context, string name, string index = "") { //The below function refers the automatically generated post_input functionality for this component. //If you wish to alter the the post_input functionality write your own post_input code here. //NOTE: It is important to handle cases where the asset AND OR the context will be null in your custom code PostInputBase(asset, context, name, index); } public override string ComponentOutput(Asset asset, OutputContext context, string name, string index = "", bool isDrag = false) { //The below function refers the automatically generated output functionality for this component. //If you wish to alter the the output functionality write your own output code here. //NOTE: It is important to handle cases where the asset AND OR the context will be null in your custom code if (isDrag && !context.IsPublishing) { return "~$cpfield$" + name + index + "$/cpfield$~"; } return asset[name + index]; } public override string ComponentJson(Asset asset, OutputContext context, string name, string index = "") { //The below function refers the automatically generated output functionality for this component. //If you wish to alter the the output functionality write your own output code here. //NOTE: It is important to handle cases where the asset AND OR the context will be null in your custom code if (asset == null) return "null"; var linkedAsset = Asset.Load(asset.Raw[name + index]); if (linkedAsset == null || !linkedAsset.IsLoaded) return "null"; return string.Format("{{\"AssetId\":{0},\"Label\":\"{1}\",\"Url\":\"{2}\"}}", linkedAsset.Id, JsonHelper.StringToJson(linkedAsset.Label), JsonHelper.StringToJson(linkedAsset.GetLink(true, ProtocolType.Https)) ?? ""); } /*comment out "IndexedFieldsBase(asset, context, name, index);" & modify this function if you want to overwrite the indexed fields of the component.*/ public override IEnumerable<IndexedField> ComponentIndexedFields(Asset asset, SearchG2Context context, string name, string index = "") { return IndexedFieldsBase(asset, context, name, index); } } } 263533 1792 /System/Templates/Basis/DeveloperCS/ 1 0 false false 0 0 /Component Project/Library/Components_DocumentBase.cs 261059 17 LibraryClass 2 body using System; using System.Collections.Generic; using System.Linq; using System.Text; using CrownPeak.CMSAPI; using CrownPeak.CMSAPI.Services; using Component_Library.Component_Project.Components; /* Some Namespaces are not allowed. */ namespace Component_Library.Component_Project.Components { [Serializable] public partial class Document : JsonComponentBase { public Document() { ComponentMarkup = @""; } public void InputBase(Asset asset, InputContext context, string label, string name) { } public void PostInputBase(Asset asset, PostInputContext context, string name, string index = "") { } public string OutputBase(Asset asset, OutputContext context, string name, string index = "", bool isDrag = false) { if (isDrag) { StringBuilder ddContent = new StringBuilder(); ddContent.Append(ComponentMarkup); return ComponentFramework.ParseDragAndDropMarkupForPreviewAndPublish(context, ddContent.ToString()); } StringBuilder sbContent = new StringBuilder(); sbContent.Append(ComponentMarkup); string markup = ComponentFramework.UpdateMarkupForPreviewPublish(context, sbContent.ToString()); return markup; } public string JsonBase(Asset asset, OutputContext context, string name, string index = "") { return "null"; } public IEnumerable<IndexedField> IndexedFieldsBase(Asset asset, SearchG2Context context, string name, string index = "") { return new IndexedField[0]; } } } 261148 1792 /System/Templates/Basis/DeveloperCS/ 1 0 false false 0 /Component Project/Library/Components_Href.cs 261059 17 LibraryClass 2 body using System; using System.Collections.Generic; using System.Linq; using System.Text; using CrownPeak.CMSAPI; using CrownPeak.CMSAPI.Services; using Component_Library.Component_Project.Components; /* Some Namespaces are not allowed. */ namespace Component_Library.Component_Project.Components { public partial class Href : JsonComponentBase { /*comment out "inputBase(label, name);" & modify this function if you want to overwrite the input functionality of the component.*/ public override void ComponentInput(Asset asset, InputContext context, String label, string name) { //inputBase(asset, label, name); Dictionary<String, String> linkTypeOptions = new Dictionary<string, string> { { "Internal", "Internal" }, { "External", "External" } }; Input.StartDropDownContainer(label + " Type", name + "_link_type", linkTypeOptions, defaultValue: "External"); //Internal Input.ShowAcquireDocument(label, name + "_link_internal"); Input.NextDropDownContainer(); Input.ShowTextBox(label, name + "_link_external", defaultValue: "#"); Input.EndDropDownContainer(); } /*comment out "postInputBase(context, name, index);" & modify this function if you want to overwrite the post_input functionality of the component.*/ public override void ComponentPostInput(Asset asset, PostInputContext context, string name, string index = "") { PostInputBase(asset, context, name, index); } /*comment out "outputBase(asset, context, name, index, isDrag);" & modify this function if you want to overwrite the output functionality of the component.*/ public override string ComponentOutput(Asset asset, OutputContext context, string name, string index = "", bool isDrag = false) { //return outputBase(asset, context, name, index, isDrag); if (asset[name + "_link_type" + index] == "Internal") { if (String.IsNullOrWhiteSpace(asset[name + "_link_internal" + index])) { return "#"; } else { return asset[name + "_link_internal" + index]; } } else { if (String.IsNullOrWhiteSpace(asset[name + "_link_external" + index])) { return "#"; } else { return asset[name + "_link_external" + index]; } } } public override string ComponentJson(Asset asset, OutputContext context, string name, string index = "") { //The below function refers the automatically generated output functionality for this component. //If you wish to alter the the output functionality write your own output code here. //NOTE: It is important to handle cases where the asset AND OR the context will be null in your custom code //return JsonBase(asset, context, name, index); if (asset[name + "_link_type" + index] == "Internal") { if (!string.IsNullOrWhiteSpace(asset[name + "_link_internal" + index])) { return JsonHelper.StringToJson(asset.Raw[name + "_link_internal" + index], includeQuotes: true, escapeSlashes: false); } } else { if (!string.IsNullOrWhiteSpace(asset[name + "_link_external" + index])) { return JsonHelper.StringToJson(asset.Raw[name + "_link_external" + index], includeQuotes: true); } } return JsonHelper.StringToJson("#", includeQuotes: true); } /*comment out "IndexedFieldsBase(asset, context, name, index);" & modify this function if you want to overwrite the indexed fields of the component.*/ public override IEnumerable<IndexedField> ComponentIndexedFields(Asset asset, SearchG2Context context, string name, string index = "") { return IndexedFieldsBase(asset, context, name, index); } } } 261146 1792 /System/Templates/Basis/DeveloperCS/ 1 0 false false 0 /Component Project/Library/Components_HrefBase.cs 261059 17 LibraryClass 2 body using System; using System.Collections.Generic; using System.Linq; using System.Text; using CrownPeak.CMSAPI; using CrownPeak.CMSAPI.Services; using Component_Library.Component_Project.Components; /* Some Namespaces are not allowed. */ namespace Component_Library.Component_Project.Components { [Serializable] public partial class Href : JsonComponentBase { public Href() { ComponentMarkup = @""; } public void InputBase(Asset asset, InputContext context, string label, string name) { } public void PostInputBase(Asset asset, PostInputContext context, string name, string index = "") { } public string OutputBase(Asset asset, OutputContext context, string name, string index = "", bool isDrag = false) { if (isDrag) { StringBuilder ddContent = new StringBuilder(); ddContent.Append(ComponentMarkup); return ComponentFramework.ParseDragAndDropMarkupForPreviewAndPublish(context, ddContent.ToString()); } StringBuilder sbContent = new StringBuilder(); sbContent.Append(ComponentMarkup); string markup = ComponentFramework.UpdateMarkupForPreviewPublish(context, sbContent.ToString()); return markup; } public string JsonBase(Asset asset, OutputContext context, string name, string index = "") { return "null"; } public IEnumerable<IndexedField> IndexedFieldsBase(Asset asset, SearchG2Context context, string name, string index = "") { return new IndexedField[0]; } } } 261145 1792 /System/Templates/Basis/DeveloperCS/ 1 0 false false 0 /Component Project/Library/Components_Image.cs 261059 17 LibraryClass 2 body using System; using System.Collections.Generic; using System.Linq; using System.Text; using CrownPeak.CMSAPI; using CrownPeak.CMSAPI.Services; using Component_Library.Component_Project.Components; /* Some Namespaces are not allowed. */ namespace Component_Library.Component_Project.Components { public partial class Image : JsonComponentBase { /*comment out "inputBase(label, name);" & modify this function if you want to overwrite the input functionality of the component.*/ public override void ComponentInput(Asset asset, InputContext context, String label, string name) { InputBase(asset, context, label, name); } /*comment out "postInputBase(context, name, index);" & modify this function if you want to overwrite the post_input functionality of the component.*/ public override void ComponentPostInput(Asset asset, PostInputContext context, string name, string index = "") { PostInputBase(asset, context, name, index); } /*comment out "outputBase(asset, context, name, index, isDrag);" & modify this function if you want to overwrite the output functionality of the component.*/ public override string ComponentOutput(Asset asset, OutputContext context, string name, string index = "", bool isDrag = false) { return OutputBase(asset, context, name, index, isDrag); } public override string ComponentJson(Asset asset, OutputContext context, string name, string index = "") { //The below function refers the automatically generated output functionality for this component. //If you wish to alter the the output functionality write your own output code here. //NOTE: It is important to handle cases where the asset AND OR the context will be null in your custom code return JsonBase(asset, context, name, index); } /*comment out "IndexedFieldsBase(asset, context, name, index);" & modify this function if you want to overwrite the indexed fields of the component.*/ public override IEnumerable<IndexedField> ComponentIndexedFields(Asset asset, SearchG2Context context, string name, string index = "") { return IndexedFieldsBase(asset, context, name, index); } } } 261144 1792 /System/Templates/Basis/DeveloperCS/ 1 0 false false 0 /Component Project/Library/Components_ImageBase.cs 261059 17 LibraryClass 2 body using System; using System.Collections.Generic; using System.Linq; using System.Text; using CrownPeak.CMSAPI; using CrownPeak.CMSAPI.Services; using Component_Library.Component_Project.Components; /* Some Namespaces are not allowed. */ namespace Component_Library.Component_Project.Components { [Serializable] public partial class Image : JsonComponentBase { public Src my_image { get; set; } public Image() { my_image = new Src(); ComponentMarkup = @"<img src=""{my_image : Src}"" />"; } public void InputBase(Asset asset, InputContext context, string label, string name) { this.my_image.ComponentInput(asset, context, label + " My Image", name + "_my_image"); } public void PostInputBase(Asset asset, PostInputContext context, string name, string index = "") { } public string OutputBase(Asset asset, OutputContext context, string name, string index = "", bool isDrag = false) { if (isDrag) { StringBuilder ddContent = new StringBuilder(); ddContent.Append(ComponentMarkup); return ComponentFramework.ParseDragAndDropMarkupForPreviewAndPublish(context, ddContent.ToString()); } StringBuilder sbContent = new StringBuilder(); sbContent.Append(ComponentMarkup); sbContent.Replace(@"{my_image : Src}", this.my_image.ComponentOutput(asset, context, name + "_my_image", index)); string markup = ComponentFramework.UpdateMarkupForPreviewPublish(context, sbContent.ToString()); return markup; } public string JsonBase(Asset asset, OutputContext context, string name, string index = "") { var sbJson = new StringBuilder(1024); sbJson.Append("{"); sbJson.AppendFormat("\"{0}\":{1}", JsonHelper.StringToJson("my_image"), this.my_image.ComponentJson(asset, context, name + "_my_image", index)); sbJson.Append("}"); return sbJson.ToString(); } public IEnumerable<IndexedField> IndexedFieldsBase(Asset asset, SearchG2Context context, string name, string index = "") { return new IndexedField[0]; } } } 261143 1792 /System/Templates/Basis/DeveloperCS/ 1 0 false false 0 /Component Project/Library/Components_Layout.cs 261059 17 LibraryClass 2 body using System; using System.Collections.Generic; using System.Linq; using System.Text; using CrownPeak.CMSAPI; using CrownPeak.CMSAPI.ComponentFrameworkTemplates; using CrownPeak.CMSAPI.Services; /* Some Namespaces are not allowed. */ namespace Component_Library.Component_Project.Components { /* public class Component_Layout { public void input(Asset asset, String label, String name, String initial) { //FilterParams fpFilter = new FilterParams(); //fpFilter.Add(AssetPropertyNames.TemplateLabel, Comparison.Equals, "Layout"); //Dictionary<string, string> layouts = new Dictionary<string, string>(); //foreach (Asset aLayout in Asset.Load(ComponentLibraryHelper.componentsPath(asset) + "layouts").GetFilterList(fpFilter)) //{ // if (aLayout.IsLoaded) layouts.Add(aLayout.Label, aLayout.Label); //} //Input.ShowDropDown(label + " layout", name, layouts, Util.MakeList(initial)); } public String output(Asset asset, String name, Dictionary<String, StringBuilder> content, String layout = null, Asset CLConfig = null) { StringBuilder sbContent = new StringBuilder(); string id = ComponentLibraryConfig.GetCLConfig(asset).ComponentLibraryRootFolder; Asset ClFolder = Asset.Load(id); string layoutName = ClFolder.AssetPath.ToString() + "/layout definitions/" + (string.IsNullOrEmpty(layout) ? asset[name] : layout); sbContent.Append(Asset.Load(layoutName).Raw["markup"]); //Out.DebugWriteLine("Layout: {0} loaded...", ComponentBase.componentsPath(asset) + "layouts/" + asset[name]); foreach (KeyValuePair<String, StringBuilder> kvp in content) { sbContent.Replace(kvp.Key, kvp.Value.ToString()); } return sbContent.ToString(); // return new CrownPeak.CMSAPI.ComponentFrameworkComponents.Component_Layout().Output(asset, name, content, layout); } } */ } 172405 1792 /System/Templates/Basis/DeveloperCS/ 1 0 false false 0 /Component Project/Library/Components_MetaData.cs 261059 17 LibraryClass 2 body using System; using System.Collections.Generic; using System.Linq; using System.Text; using CrownPeak.CMSAPI; using CrownPeak.CMSAPI.Services; using Component_Library.Component_Project.Components; /* Some Namespaces are not allowed. */ namespace Component_Library.Component_Project.Components { public partial class MetaData : JsonComponentBase { /*comment out "InputBase(asset, context, label, name);" & modify this function if you want to overwrite the input functionality of the component.*/ public override void ComponentInput(Asset asset, InputContext context, String label, string name) { CrownPeak.CMSAPI.Services.ServicesInput.ShowMetaInput(); while (Input.NextPanel("custom_metadata_tags")) { Input.StartHorizontalWrapContainer(); Input.ShowTextBox("Meta Name", "meta_name"); Input.ShowTextBox("Meta Content", "meta_content"); Input.EndHorizontalWrapContainer(); } Input.ShowTextBox("Canonical Link", "canonical_link"); } /*comment out "PostInputBase(asset, context, name, index);" & modify this function if you want to overwrite the post_input functionality of the component.*/ public override void ComponentPostInput(Asset asset, PostInputContext context, string name, string index = "") { PostInputBase(asset, context, name, index); } /*comment out "OutputBase(asset, context, name, index, isDrag);" & modify this function if you want to overwrite the output functionality of the component.*/ public override string ComponentOutput(Asset asset, OutputContext context, string name, string index = "", bool isDrag = false) { StringBuilder sb = new StringBuilder(); sb.AppendLine("<title>" + asset["html_title"] + "</title>").AppendLine(); sb.AppendLine(CrownPeak.CMSAPI.Services.ServicesOutput.MetaOutputBuilder(asset, asset, false, false)); foreach (PanelEntry pe in asset.GetPanels("custom_metadata_tags")) { if (!String.IsNullOrWhiteSpace(pe["meta_name"]) || !String.IsNullOrWhiteSpace(pe["meta_content"])) { sb.AppendFormat("<meta name=\"{0}\" content=\"{1}\" >", pe["meta_name"], pe["meta_content"]).AppendLine(); } } if (!String.IsNullOrWhiteSpace(asset["canonical_link"])) { sb.AppendLine("<link rel=\"canonical\" href=\"" + asset["canonical_link"] + "\" />"); } return sb.ToString(); } /*comment out "JsonBase(asset, context, name, index);" & modify this function if you want to overwrite the JSON functionality of the component.*/ public override string ComponentJson(Asset asset, OutputContext context, string name, string index = "") { StringBuilder sbJson = new StringBuilder(1024); sbJson.Append("{"); sbJson.AppendFormat("\"{0}\":{1}", JsonHelper.StringToJson("html_title"), JsonHelper.StringToJson(asset.Raw["html_title"], true)); sbJson.Append(","); sbJson.AppendFormat("\"{0}\":{1}", JsonHelper.StringToJson("meta_author"), JsonHelper.StringToJson(asset.Raw["meta_author"], true)); sbJson.Append(","); sbJson.AppendFormat("\"{0}\":{1}", JsonHelper.StringToJson("meta_title"), JsonHelper.StringToJson(asset.Raw["meta_title"], true)); sbJson.Append(","); sbJson.AppendFormat("\"{0}\":{1}", JsonHelper.StringToJson("meta_desc"), JsonHelper.StringToJson(asset.Raw["meta_desc"], true)); sbJson.Append(","); sbJson.AppendFormat("\"{0}\":{1}", JsonHelper.StringToJson("meta_keywords"), JsonHelper.StringToJson(asset.Raw["meta_keywords"], true)); sbJson.Append(","); sbJson.AppendFormat("\"{0}\":[", JsonHelper.StringToJson("custom_metadata")); var first = true; foreach (PanelEntry pe in asset.GetPanels("custom_metadata_tags")) { if (!string.IsNullOrWhiteSpace(pe.Raw["meta_name"])) { if (!first) sbJson.Append(","); sbJson.AppendFormat("{{\"{0}\":{1}", "name", JsonHelper.StringToJson(pe.Raw["meta_name"], true)); sbJson.AppendFormat(",\"{0}\":{1}}}", "content", JsonHelper.StringToJson(pe.Raw["meta_content"], true)); first = false; } } sbJson.Append("],"); sbJson.AppendFormat("\"{0}\":{1}", JsonHelper.StringToJson("canonical_link"), JsonHelper.StringToJson(asset.Raw["canonical_link"], true)); sbJson.Append("}"); return sbJson.ToString(); } /*comment out "IndexedFieldsBase(asset, context, name, index);" & modify this function if you want to overwrite the indexed fields of the component.*/ public override IEnumerable<IndexedField> ComponentIndexedFields(Asset asset, SearchG2Context context, string name, string index = "") { return IndexedFieldsBase(asset, context, name, index); } } } 172406 1792 /System/Templates/Basis/DeveloperCS/ 1 0 false false 0 /Component Project/Library/Components_MetaDataBase.cs 261059 17 LibraryClass 2 body using System; using System.Collections.Generic; using System.Linq; using System.Text; using CrownPeak.CMSAPI; using CrownPeak.CMSAPI.Services; using Component_Library.Component_Project.Components; /* Some Namespaces are not allowed. */ namespace Component_Library.Component_Project.Components { [Serializable] public partial class MetaData : JsonComponentBase { public MetaData() { ComponentMarkup = @""; } public void InputBase(Asset asset, InputContext context, string label, string name) { } public void PostInputBase(Asset asset, PostInputContext context, string name, string index = "") { } public string OutputBase(Asset asset, OutputContext context, string name, string index = "", bool isDrag = false) { if (isDrag) { StringBuilder ddContent = new StringBuilder(); ddContent.Append(ComponentMarkup); return ComponentFramework.ParseDragAndDropMarkupForPreviewAndPublish(context, ddContent.ToString()); } StringBuilder sbContent = new StringBuilder(); sbContent.Append(ComponentMarkup); string markup = ComponentFramework.UpdateMarkupForPreviewPublish(context, sbContent.ToString()); return markup; } public string JsonBase(Asset asset, OutputContext context, string name, string index = "") { return ""; } public IEnumerable<IndexedField> IndexedFieldsBase(Asset asset, SearchG2Context context, string name, string index = "") { return new IndexedField[0]; } } } 261122 1792 /System/Templates/Basis/DeveloperCS/ 1 0 false false 0 /Component Project/Library/Components_Src.cs 261059 17 LibraryClass 2 body using System; using System.Collections.Generic; using System.Linq; using System.Text; using CrownPeak.CMSAPI; using CrownPeak.CMSAPI.Services; using Component_Library.Component_Project.Components; /* Some Namespaces are not allowed. */ namespace Component_Library.Component_Project.Components { public partial class Src : JsonComponentBase { /*comment out "inputBase(label, name);" & modify this function if you want to overwrite the input functionality of the component.*/ public override void ComponentInput(Asset asset, InputContext context, String label, string name) { //inputBase(asset, label, name); ShowAcquireParams img = new ShowAcquireParams(); img.ShowBrowse = true; img.ShowUpload = true; //img.DefaultFolder = "/Component Library Auto POC/_Assets/images"; //will need to think of a way to get Asset.getSiteRoot(asset); in here img.Extensions = Util.MakeList("jpg", "jpeg", "gif", "png"); //img.DefaultFolder = "...../Assets/images/"; Input.ShowAcquireImage(label, name, img); } /*comment out "postInputBase(context, name, index);" & modify this function if you want to overwrite the post_input functionality of the component.*/ public override void ComponentPostInput(Asset asset, PostInputContext context, string name, string index = "") { PostInputBase(asset, context, name, index); } /*comment out "outputBase(asset, context, name, index, isDrag);" & modify this function if you want to overwrite the output functionality of the component.*/ public override string ComponentOutput(Asset asset, OutputContext context, string name, string index = "", bool isDrag = false) { //return outputBase(asset, context, name, index, isDrag); return asset[name + index]; } public override string ComponentJson(Asset asset, OutputContext context, string name, string index = "") { //The below function refers the automatically generated output functionality for this component. //If you wish to alter the the output functionality write your own output code here. //NOTE: It is important to handle cases where the asset AND OR the context will be null in your custom code var url = Asset.Load(asset.Raw[name + index]).GetLink(true, ProtocolType.Https); return string.IsNullOrEmpty(url) ? "null" : JsonHelper.StringToJson(url, includeQuotes: true); } /*comment out "IndexedFieldsBase(asset, context, name, index);" & modify this function if you want to overwrite the indexed fields of the component.*/ public override IEnumerable<IndexedField> ComponentIndexedFields(Asset asset, SearchG2Context context, string name, string index = "") { return IndexedFieldsBase(asset, context, name, index); } } } 261121 1792 /System/Templates/Basis/DeveloperCS/ 1 0 false false 0 /Component Project/Library/Components_SrcBase.cs 261059 17 LibraryClass 2 body using System; using System.Collections.Generic; using System.Linq; using System.Text; using CrownPeak.CMSAPI; using CrownPeak.CMSAPI.Services; using Component_Library.Component_Project.Components; /* Some Namespaces are not allowed. */ namespace Component_Library.Component_Project.Components { [Serializable] public partial class Src : JsonComponentBase { public Src() { ComponentMarkup = @""; } public void InputBase(Asset asset, InputContext context, string label, string name) { } public void PostInputBase(Asset asset, PostInputContext context, string name, string index = "") { } public string OutputBase(Asset asset, OutputContext context, string name, string index = "", bool isDrag = false) { if (isDrag) { StringBuilder ddContent = new StringBuilder(); ddContent.Append(ComponentMarkup); return ComponentFramework.ParseDragAndDropMarkupForPreviewAndPublish(context, ddContent.ToString()); } StringBuilder sbContent = new StringBuilder(); sbContent.Append(ComponentMarkup); string markup = ComponentFramework.UpdateMarkupForPreviewPublish(context, sbContent.ToString()); return markup; } public string JsonBase(Asset asset, OutputContext context, string name, string index = "") { return ""; } public IEnumerable<IndexedField> IndexedFieldsBase(Asset asset, SearchG2Context context, string name, string index = "") { return new IndexedField[0]; } } } 261115 1792 /System/Templates/Basis/DeveloperCS/ 1 0 false false 0 /Component Project/Library/Components_Text.cs 261059 17 LibraryClass 2 body using System; using System.Collections.Generic; using System.Linq; using System.Text; using CrownPeak.CMSAPI; using CrownPeak.CMSAPI.Services; using Component_Library.Component_Project.Components; /* Some Namespaces are not allowed. */ namespace Component_Library.Component_Project.Components { public partial class Text : JsonComponentBase { /*comment out "inputBase(label, name);" & modify this function if you want to overwrite the input functionality of the component.*/ public override void ComponentInput(Asset asset, InputContext context, String label, string name) { //inputBase(asset, label, name); Input.ShowTextBox(label, name); } /*comment out "postInputBase(context, name, index);" & modify this function if you want to overwrite the post_input functionality of the component.*/ public override void ComponentPostInput(Asset asset, PostInputContext context, string name, string index = "") { PostInputBase(asset, context, name, index); } /*comment out "outputBase(asset, context, name, index, isDrag);" & modify this function if you want to overwrite the output functionality of the component.*/ public override string ComponentOutput(Asset asset, OutputContext context, string name, string index = "", bool isDrag = false) { //return outputBase(asset, context, name, index, isDrag); if (isDrag && !context.IsPublishing) { return "~$cpfield$" + name + index + "$/cpfield$~"; } return asset[name + index]; } public override string ComponentJson(Asset asset, OutputContext context, string name, string index = "") { //The below function refers the automatically generated output functionality for this component. //If you wish to alter the the output functionality write your own output code here. //NOTE: It is important to handle cases where the asset AND OR the context will be null in your custom code return JsonHelper.StringToJson(asset.Raw[name + index], includeQuotes: true); } public override IEnumerable<IndexedField> ComponentIndexedFields(Asset asset, SearchG2Context context, string name, string index = "") { //The below function refers to the automatically generated functionality for this component. //If you wish to alter the the output functionality write your own output code here. //NOTE: It is important to handle cases where the asset AND OR the context will be null in your custom code return IndexedFieldsBase(asset, context, name, index); } } } 261116 1792 /System/Templates/Basis/DeveloperCS/ 1 0 false false 0 /Component Project/Library/Components_TextBase.cs 261059 17 LibraryClass 2 body using System; using System.Collections.Generic; using System.Linq; using System.Text; using CrownPeak.CMSAPI; using CrownPeak.CMSAPI.Services; using Component_Library.Component_Project.Components; /* Some Namespaces are not allowed. */ namespace Component_Library.Component_Project.Components { [Serializable] public partial class Text : JsonComponentBase { public Text() { ComponentMarkup = @""; } public void InputBase(Asset asset, InputContext context, string label, string name) { } public void PostInputBase(Asset asset, PostInputContext context, string name, string index = "") { } public string OutputBase(Asset asset, OutputContext context, string name, string index = "", bool isDrag = false) { if (isDrag) { StringBuilder ddContent = new StringBuilder(); ddContent.Append(ComponentMarkup); return ComponentFramework.ParseDragAndDropMarkupForPreviewAndPublish(context, ddContent.ToString()); } StringBuilder sbContent = new StringBuilder(); sbContent.Append(ComponentMarkup); string markup = ComponentFramework.UpdateMarkupForPreviewPublish(context, sbContent.ToString()); return markup; } public string JsonBase(Asset asset, OutputContext context, string name, string index = "") { return ""; } public IEnumerable<IndexedField> IndexedFieldsBase(Asset asset, SearchG2Context context, string name, string index = "") { return new IndexedField[0]; } } } 172378 1792 /System/Templates/Basis/DeveloperCS/ 1 0 false false 0 /Component Project/Library/Components_Video.cs 261059 17 LibraryClass 2 body using System; using System.Collections.Generic; using System.Linq; using System.Text; using CrownPeak.CMSAPI; using CrownPeak.CMSAPI.Services; using Component_Library.Component_Project.Components; /* Some Namespaces are not allowed. */ namespace Component_Library.Component_Project.Components { public partial class Video : JsonComponentBase { /*comment out "inputBase(label, name);" & modify this function if you want to overwrite the input functionality of the component.*/ public override void ComponentInput(Asset asset, InputContext context, String label, string name) { InputBase(asset, context, label, name); } /*comment out "postInputBase(context, name, index);" & modify this function if you want to overwrite the post_input functionality of the component.*/ public override void ComponentPostInput(Asset asset, PostInputContext context, string name, string index = "") { PostInputBase(asset, context, name, index); } /*comment out "outputBase(asset, context, name, index, isDrag);" & modify this function if you want to overwrite the output functionality of the component.*/ public override string ComponentOutput(Asset asset, OutputContext context, string name, string index = "", bool isDrag = false) { return OutputBase(asset, context, name, index, isDrag); } public override string ComponentJson(Asset asset, OutputContext context, string name, string index = "") { //The below function refers the automatically generated output functionality for this component. //If you wish to alter the the output functionality write your own output code here. //NOTE: It is important to handle cases where the asset AND OR the context will be null in your custom code var url = Asset.Load(asset.Raw[name + "_video_src" + index]).GetLink(true, ProtocolType.Https); return string.IsNullOrEmpty(url) ? "null" : JsonHelper.StringToJson(url, includeQuotes: true); } /*comment out "IndexedFieldsBase(asset, context, name, index);" & modify this function if you want to overwrite the indexed fields of the component.*/ public override IEnumerable<IndexedField> ComponentIndexedFields(Asset asset, SearchG2Context context, string name, string index = "") { return IndexedFieldsBase(asset, context, name, index); } } } 172377 1792 /System/Templates/Basis/DeveloperCS/ 1 0 false false 0 /Component Project/Library/Components_VideoBase.cs 261059 17 LibraryClass 2 body using System; using System.Collections.Generic; using System.Linq; using System.Text; using CrownPeak.CMSAPI; using CrownPeak.CMSAPI.Services; using Component_Library.Component_Project.Components; /* Some Namespaces are not allowed. */ namespace Component_Library.Component_Project.Components { [Serializable] public partial class Video : JsonComponentBase { public Src video_src { get; set; } public Video() { video_src = new Src(); ComponentMarkup = @"<video width controls=""""> <source src=""{video_src : Src}"" type=""{type : Code}""> Your browser does not support HTML5 video.</video>"; } public void InputBase(Asset asset, InputContext context, string label, string name) { this.video_src.ComponentInput(asset, context, label + " Video Src", name + "_video_src"); } public void PostInputBase(Asset asset, PostInputContext context, string name, string index = "") { } public string OutputBase(Asset asset, OutputContext context, string name, string index = "", bool isDrag = false) { if (isDrag) { StringBuilder ddContent = new StringBuilder(); ddContent.Append(ComponentMarkup); return ComponentFramework.ParseDragAndDropMarkupForPreviewAndPublish(context, ddContent.ToString()); } StringBuilder sbContent = new StringBuilder(); sbContent.Append(ComponentMarkup); sbContent.Replace(@"{video_src : Src}", this.video_src.ComponentOutput(asset, context, name + "_video_src", index)); sbContent.Replace(@"{type : Code}", ""); string markup = ComponentFramework.UpdateMarkupForPreviewPublish(context, sbContent.ToString()); return markup; } public string JsonBase(Asset asset, OutputContext context, string name, string index = "") { return ""; } public IEnumerable<IndexedField> IndexedFieldsBase(Asset asset, SearchG2Context context, string name, string index = "") { return new IndexedField[0]; } } } 261110 1792 /System/Templates/Basis/DeveloperCS/ 1 0 false false 0 /Component Project/Library/Components_Widget.cs 261059 17 LibraryClass 2 body using System; using System.Collections.Generic; using System.Linq; using System.Text; using CrownPeak.CMSAPI; using CrownPeak.CMSAPI.Services; using Component_Library.Component_Project.Components; /* Some Namespaces are not allowed. */ namespace Component_Library.Component_Project.Components { public partial class Widget : JsonComponentBase { /*comment out "inputBase(label, name);" & modify this function if you want to overwrite the input functionality of the component.*/ public override void ComponentInput(Asset asset, InputContext context, String label, string name) { //inputBase(asset, label, name); Input.ShowAcquireDocument(label, name); } /*comment out "postInputBase(context, name, index);" & modify this function if you want to overwrite the post_input functionality of the component.*/ public override void ComponentPostInput(Asset asset, PostInputContext context, string name, string index = "") { PostInputBase(asset, context, name, index); } /*comment out "outputBase(asset, context, name, index, isDrag);" & modify this function if you want to overwrite the output functionality of the component.*/ public override string ComponentOutput(Asset asset, OutputContext context, string name, string index = "", bool isDrag = false) { //return outputBase(asset, context, name, index, isDrag); Asset widget = Asset.Load(asset[name + index]); return widget.Show(); } public override string ComponentJson(Asset asset, OutputContext context, string name, string index = "") { //The below function refers the automatically generated output functionality for this component. //If you wish to alter the the output functionality write your own output code here. //NOTE: It is important to handle cases where the asset AND OR the context will be null in your custom code var widget = Asset.Load(asset[name + index]); if (widget != null && widget.IsLoaded) { return widget.Show("output_json"); } return "null"; } /*comment out "IndexedFieldsBase(asset, context, name, index);" & modify this function if you want to overwrite the indexed fields of the component.*/ public override IEnumerable<IndexedField> ComponentIndexedFields(Asset asset, SearchG2Context context, string name, string index = "") { return IndexedFieldsBase(asset, context, name, index); } } } 261109 1792 /System/Templates/Basis/DeveloperCS/ 1 0 false false 0 /Component Project/Library/Components_WidgetBase.cs 261059 17 LibraryClass 2 body using System; using System.Collections.Generic; using System.Linq; using System.Text; using CrownPeak.CMSAPI; using CrownPeak.CMSAPI.Services; using Component_Library.Component_Project.Components; /* Some Namespaces are not allowed. */ namespace Component_Library.Component_Project.Components { [Serializable] public partial class Widget : JsonComponentBase { public Widget() { ComponentMarkup = @""; } public void InputBase(Asset asset, InputContext context, string label, string name) { } public void PostInputBase(Asset asset, PostInputContext context, string name, string index = "") { } public string OutputBase(Asset asset, OutputContext context, string name, string index = "", bool isDrag = false) { if (isDrag) { StringBuilder ddContent = new StringBuilder(); ddContent.Append(ComponentMarkup); return ComponentFramework.ParseDragAndDropMarkupForPreviewAndPublish(context, ddContent.ToString()); } StringBuilder sbContent = new StringBuilder(); sbContent.Append(ComponentMarkup); string markup = ComponentFramework.UpdateMarkupForPreviewPublish(context, sbContent.ToString()); return markup; } public string JsonBase(Asset asset, OutputContext context, string name, string index = "") { return null; } public IEnumerable<IndexedField> IndexedFieldsBase(Asset asset, SearchG2Context context, string name, string index = "") { return new IndexedField[0]; } } } 261108 1792 /System/Templates/Basis/DeveloperCS/ 1 0 false false 0 /Component Project/Library/Components_Wysiwyg.cs 261059 17 LibraryClass 2 body using System; using System.Collections.Generic; using System.Linq; using System.Text; using CrownPeak.CMSAPI; using CrownPeak.CMSAPI.Services; using CrownPeak.CMSAPI.CustomLibrary; using Component_Library.Component_Project.Components; /* Some Namespaces are not allowed. */ namespace Component_Library.Component_Project.Components { public partial class Wysiwyg : JsonComponentBase { /*comment out "inputBase(label, name);" & modify this function if you want to overwrite the input functionality of the component.*/ public override void ComponentInput(Asset asset, InputContext context, String label, string name) { //inputBase(asset, label, name); WysiwygParams wParams = ServicesInput.FullWYSIWYG(); Input.ShowWcoControls(name); Input.ShowWysiwyg(label, name, wParams, width: 950, height: 200); } /*comment out "postInputBase(context, name, index);" & modify this function if you want to overwrite the post_input functionality of the component.*/ public override void ComponentPostInput(Asset asset, PostInputContext context, string name, string index = "") { PostInputBase(asset, context, name, index); } /*comment out "outputBase(asset, context, name, index, isDrag);" & modify this function if you want to overwrite the output functionality of the component.*/ public override string ComponentOutput(Asset asset, OutputContext context, string name, string index = "", bool isDrag = false) { //return outputBase(asset, context, name, index, isDrag); if (isDrag && !context.IsPublishing) { return "~$cpfield$" + name + index + "$/cpfield$~"; } return asset[name + index]; } public override string ComponentJson(Asset asset, OutputContext context, string name, string index = "") { //The below function refers the automatically generated output functionality for this component. //If you wish to alter the the output functionality write your own output code here. //NOTE: It is important to handle cases where the asset AND OR the context will be null in your custom code return JsonHelper.StringToJson(Util.ReplaceAttachments(Util.ReplaceCptInternals(asset.Raw[name + index])), includeQuotes:true); } /*comment out "IndexedFieldsBase(asset, context, name, index);" & modify this function if you want to overwrite the indexed fields of the component.*/ public override IEnumerable<IndexedField> ComponentIndexedFields(Asset asset, SearchG2Context context, string name, string index = "") { return IndexedFieldsBase(asset, context, name, index); } } } 261106 1792 /System/Templates/Basis/DeveloperCS/ 1 0 false false 0 /Component Project/Library/Components_WysiwygBase.cs 261059 17 LibraryClass 2 body using System; using System.Collections.Generic; using System.Linq; using System.Text; using CrownPeak.CMSAPI; using CrownPeak.CMSAPI.Services; using Component_Library.Component_Project.Components; /* Some Namespaces are not allowed. */ namespace Component_Library.Component_Project.Components { [Serializable] public partial class Wysiwyg : JsonComponentBase { public Wysiwyg() { ComponentMarkup = @""; } public void InputBase(Asset asset, InputContext context, string label, string name) { } public void PostInputBase(Asset asset, PostInputContext context, string name, string index = "") { } public string OutputBase(Asset asset, OutputContext context, string name, string index = "", bool isDrag = false) { if (isDrag) { StringBuilder ddContent = new StringBuilder(); ddContent.Append(ComponentMarkup); return ComponentFramework.ParseDragAndDropMarkupForPreviewAndPublish(context, ddContent.ToString()); } StringBuilder sbContent = new StringBuilder(); sbContent.Append(ComponentMarkup); string markup = ComponentFramework.UpdateMarkupForPreviewPublish(context, sbContent.ToString()); return markup; } public string JsonBase(Asset asset, OutputContext context, string name, string index = "") { return ""; } public IEnumerable<IndexedField> IndexedFieldsBase(Asset asset, SearchG2Context context, string name, string index = "") { return new IndexedField[0]; } } } 261054 false false /Component Project/Models 261049 4096 Model, Folder 4 261107 802 /System/Models/Basis/Asset/Asset Folder/ false false /Component Project/Models/Component Definition Folder 261054 0 Model, Folder 4 261521 261485 /Component Project/Templates/Component Framework/Enhanced/Component Definition/ 1 0 false false 0 0 /Component Project/Models/Component Definition Folder/Enhanced Component 261107 0 512 Model, ContentAsset 2 261100 802 /System/Models/Basis/Asset/Asset Folder/ false false /Component Project/Models/Template Definition Folder 261054 0 Model, Folder 4 261547 261538 /Component Project/Templates/Component Framework/Enhanced Template Definition/ 1 0 false false 0 0 /Component Project/Models/Template Definition Folder/Enhanced Template 261100 0 512 Model, ContentAsset 2 261056 false false /Component Project/Templates 261049 256 TemplatesFolder 4 261105 false false /Component Project/Templates/Component Framework 261056 256 TemplateFolder 4 267063 false false /Component Project/Templates/Component Framework/Enhanced 261105 256 TemplateFolder 4 261485 false false /Component Project/Templates/Component Framework/Enhanced/Component Definition 267063 512 TemplateFolder 4 261486 1792 /System/Templates/Basis/DeveloperCS/ 1 0 false false 0 /Component Project/Templates/Component Framework/Enhanced/Component Definition/copy.aspx 261485 17 Template 2 body <%@ Page Language="C#" Inherits="CrownPeak.Internal.Debug.CopyInit" %> <%@ Import Namespace="CrownPeak.CMSAPI" %> <%@ Import Namespace="CrownPeak.CMSAPI.Services" %> <!--DO NOT MODIFY CODE ABOVE THIS LINE--> <%@ Import Namespace="CrownPeak.CMSAPI.CustomLibrary" %> <%@ Import Namespace="Component_Library.Component_Project.Components" %> <% //MODIFY or ADD Import Statements to Define Namespaces Used by the Template %> <%//This plugin uses CopyContext as its context class type%> <% CrownPeak.CMSAPI.ComponentFrameworkTemplates.ComponentBuilder.CopyHelper(asset, context); %> 261487 1792 /System/Templates/Basis/DeveloperCS/ 1 0 false false 0 /Component Project/Templates/Component Framework/Enhanced/Component Definition/delete.aspx 261485 17 Template 2 body <%@ Page Language="C#" Inherits="CrownPeak.Internal.Debug.DeleteInit" %> <%@ Import Namespace="CrownPeak.CMSAPI" %> <%@ Import Namespace="CrownPeak.CMSAPI.Services" %> <!--DO NOT MODIFY CODE ABOVE THIS LINE--> <%@ Import Namespace="CrownPeak.CMSAPI.CustomLibrary" %> <%@ Import Namespace="Component_Library.Component_Project.Components" %> <% //MODIFY or ADD Import Statements to Define Namespaces Used by the Template %> <%//This plugin uses DeleteContext as its context class type%> <% CrownPeak.CMSAPI.ComponentFrameworkTemplates.ComponentBuilder.DeleteHelper(asset, context); %> 261488 1792 /System/Templates/Basis/DeveloperCS/ 1 0 false false 0 /Component Project/Templates/Component Framework/Enhanced/Component Definition/filename.aspx 261485 17 Template 2 body <%@ Page Language="C#" Inherits="CrownPeak.Internal.Debug.FilenameInit" %> <%@ Import Namespace="CrownPeak.CMSAPI" %> <%@ Import Namespace="CrownPeak.CMSAPI.Services" %> <!--DO NOT MODIFY CODE ABOVE THIS LINE--> <%@ Import Namespace="CrownPeak.CMSAPI.CustomLibrary" %> <%@ Import Namespace="Component_Library.Component_Project.Components" %> <% //MODIFY or ADD Import Statements to Define Namespaces Used by the Template %> <%//This plugin uses OutputContext as its context class type%> <% CrownPeak.CMSAPI.ComponentFrameworkTemplates.ComponentBuilder.FilenameHelper(asset, context); %> 261489 1792 /System/Templates/Basis/DeveloperCS/ 1 0 false false 0 /Component Project/Templates/Component Framework/Enhanced/Component Definition/input.aspx 261485 17 Template 2 body <%@ Page Language="C#" Inherits="CrownPeak.Internal.Debug.InputInit" %> <%@ Import Namespace="CrownPeak.CMSAPI" %> <%@ Import Namespace="CrownPeak.CMSAPI.Services" %> <!--DO NOT MODIFY CODE ABOVE THIS LINE--> <%@ Import Namespace="CrownPeak.CMSAPI.CustomLibrary" %> <%@ Import Namespace="Component_Library.Component_Project.Components" %> <% //MODIFY or ADD Import Statements to Define Namespaces Used by the Template %> <%//This plugin uses InputContext as its context class type%> <% //CrownPeak.CMSAPI.ComponentFrameworkTemplates.ComponentBuilder.InputHelper(asset, context); ComponentBuilderHelper.InputHelper(asset, context); %> 261490 1792 /System/Templates/Basis/DeveloperCS/ 1 0 false false 0 /Component Project/Templates/Component Framework/Enhanced/Component Definition/output.aspx 261485 17 Template 2 body <%@ Page Language="C#" Inherits="CrownPeak.Internal.Debug.OutputInit" %> <%@ Import Namespace="CrownPeak.CMSAPI" %> <%@ Import Namespace="CrownPeak.CMSAPI.Services" %> <!--DO NOT MODIFY CODE ABOVE THIS LINE--> <%@ Import Namespace="CrownPeak.CMSAPI.CustomLibrary" %> <%@ Import Namespace="Component_Library.Component_Project.Components" %> <% //MODIFY or ADD Import Statements to Define Namespaces Used by the Template %> <%//This plugin uses OutputContext as its context class type%> <% Component_Layout layout = new Component_Layout(); MetaData metaData = new MetaData(); HeaderJavascriptAndCss customJavascriptAndCss = new HeaderJavascriptAndCss(); NavFooterContent navFooterContent = new NavFooterContent(); %> <% context.DisablePreviewCache = true; Asset siteConfig = Asset.Load("/Site-Summer-of-Fun/_Site Config/site config"); %> <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>Demo</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="stylesheet" href="<%=Asset.Load("/Site-Summer-of-Fun/_Assets/css/bootstrap.css").GetLink(LinkType.Include)%>" media="all" /> <link rel="stylesheet" href="<%=Asset.Load("/Site-Summer-of-Fun/_Assets/css/custom.css").GetLink(LinkType.Include)%>" media="all" /> <link rel="stylesheet" href="<%=Asset.Load("/Site-Summer-of-Fun/_Assets/css/flexslider.css").GetLink(LinkType.Include)%>" media="all" /> <link rel="stylesheet" href="<%=Asset.Load("/Site-Summer-of-Fun/_Assets/css/lightbox.min.css").GetLink(LinkType.Include)%>" media="all" /> <link rel="stylesheet" href="<%=Asset.Load("/Site-Summer-of-Fun/_Assets/css/lightbox.min.css").GetLink(LinkType.Include)%>" media="all" /> <link rel="stylesheet" href="<%=Asset.Load("/Site-Summer-of-Fun/_Assets/css/theme.css").GetLink(LinkType.Include)%>" media="all" /> <link rel="stylesheet" href="<%=Asset.Load("/Site-Summer-of-Fun/_Assets/css/themify-icons.css").GetLink(LinkType.Include)%>" media="all" /> <link href='//fonts.googleapis.com/css?family=Lato:300,400%7CRaleway:100,400,300,500,600,700%7COpen+Sans:400,500,600' rel='stylesheet' type='text/css'> </head> <body> <% StringBuilder sbCol1 = new StringBuilder(); StringBuilder sbCol2 = new StringBuilder(); StringBuilder sbCol3 = new StringBuilder(); Dictionary<String, StringBuilder> rowContent = new Dictionary<string, StringBuilder>(); %> </div> <div class="main-container"> <% CrownPeak.CMSAPI.ComponentFrameworkTemplates.ComponentBuilder.OutputHelper(asset, context); %> <script src="<%=Asset.Load("/Site-Summer-of-Fun/_Assets/js/jquery.min.js").GetLink(LinkType.Include)%>"></script> <script src="<%=Asset.Load("/Site-Summer-of-Fun/_Assets/js/bootstrap.min.js").GetLink(LinkType.Include)%>"></script> <script src="<%=Asset.Load("/Site-Summer-of-Fun/_Assets/js/flexslider.min.js").GetLink(LinkType.Include)%>"></script> <script src="<%=Asset.Load("/Site-Summer-of-Fun/_Assets/js/lightbox.min.js").GetLink(LinkType.Include)%>"></script> <script src="<%=Asset.Load("/Site-Summer-of-Fun/_Assets/js/scripts.js").GetLink(LinkType.Include)%>"></script> <script src="<%=Asset.Load("/Site-Summer-of-Fun/_Assets/js/parallax.js").GetLink(LinkType.Include)%>"></script> </div> </body> 261491 1792 /System/Templates/Basis/DeveloperCS/ 1 0 false false 0 /Component Project/Templates/Component Framework/Enhanced/Component Definition/post_input.aspx 261485 17 Template 2 body <%@ Page Language="C#" Inherits="CrownPeak.Internal.Debug.PostInputInit" %> <%@ Import Namespace="CrownPeak.CMSAPI" %> <%@ Import Namespace="CrownPeak.CMSAPI.Services" %> <!--DO NOT MODIFY CODE ABOVE THIS LINE--> <%@ Import Namespace="CrownPeak.CMSAPI.CustomLibrary" %> <%@ Import Namespace="Component_Library.Component_Project.Components" %> <% //MODIFY or ADD Import Statements to Define Namespaces Used by the Template %> <%//This plugin uses PostInputContext as its context class type%> <% //CrownPeak.CMSAPI.ComponentFrameworkTemplates.ComponentBuilder.PostInputHelper(asset, context); ComponentBuilderHelper.PostInputHelper(asset, context); %> 261492 1792 /System/Templates/Basis/DeveloperCS/ 1 0 false false 0 /Component Project/Templates/Component Framework/Enhanced/Component Definition/post_save.aspx 261485 17 Template 2 body <%@ Page Language="C#" Inherits="CrownPeak.Internal.Debug.PostSaveInit" %> <%@ Import Namespace="CrownPeak.CMSAPI" %> <%@ Import Namespace="CrownPeak.CMSAPI.Services" %> <!--DO NOT MODIFY CODE ABOVE THIS LINE--> <%@ Import Namespace="CrownPeak.CMSAPI.CustomLibrary" %> <%@ Import Namespace="Component_Library.Component_Project.Components" %> <% //MODIFY or ADD Import Statements to Define Namespaces Used by the Template %> <%//This plugin uses PostSaveContext as its context class type%> <% //CrownPeak.CMSAPI.ComponentFrameworkTemplates.ComponentBuilder.PostSaveHelper(asset, context); ComponentBuilderHelper.PostSaveHelper(asset, context); %> 261493 1792 /System/Templates/Basis/DeveloperCS/ 1 0 false false 0 /Component Project/Templates/Component Framework/Enhanced/Component Definition/url.aspx 261485 17 Template 2 body <%@ Page Language="C#" Inherits="CrownPeak.Internal.Debug.UrlInit" %> <%@ Import Namespace="CrownPeak.CMSAPI" %> <%@ Import Namespace="CrownPeak.CMSAPI.Services" %> <!--DO NOT MODIFY CODE ABOVE THIS LINE--> <%@ Import Namespace="CrownPeak.CMSAPI.CustomLibrary" %> <%@ Import Namespace="Component_Library.Component_Project.Components" %> <% //MODIFY or ADD Import Statements to Define Namespaces Used by the Template %> <%//This plugin uses OutputContext as its context class type%> <% CrownPeak.CMSAPI.ComponentFrameworkTemplates.ComponentBuilder.UrlHelper(asset, context); %> 261538 false false /Component Project/Templates/Component Framework/Enhanced Template Definition 261105 512 TemplateFolder 4 261539 1792 /System/Templates/Basis/DeveloperCS/ 1 0 false false 0 /Component Project/Templates/Component Framework/Enhanced Template Definition/filename.aspx 261538 17 Template 2 body <%@ Page Language="C#" Inherits="CrownPeak.Internal.Debug.FilenameInit" %> <%@ Import Namespace="CrownPeak.CMSAPI" %> <%@ Import Namespace="CrownPeak.CMSAPI.Services" %> <!--DO NOT MODIFY CODE ABOVE THIS LINE--> <%@ Import Namespace="CrownPeak.CMSAPI.CustomLibrary" %> <%@ Import Namespace="Component_Library.Component_Project.Components" %> <% //MODIFY or ADD Import Statements to Define Namespaces Used by the Template %> <%//This plugin uses OutputContext as its context class type%> <% CrownPeak.CMSAPI.ComponentFrameworkTemplates.TemplateBuilder.FilenameHelper(asset, context); %> 261540 1792 /System/Templates/Basis/DeveloperCS/ 1 0 false false 0 /Component Project/Templates/Component Framework/Enhanced Template Definition/input.aspx 261538 17 Template 2 body <%@ Page Language="C#" Inherits="CrownPeak.Internal.Debug.InputInit" %> <%@ Import Namespace="CrownPeak.CMSAPI" %> <%@ Import Namespace="CrownPeak.CMSAPI.Services" %> <!--DO NOT MODIFY CODE ABOVE THIS LINE--> <%@ Import Namespace="CrownPeak.CMSAPI.CustomLibrary" %> <%@ Import Namespace="Component_Library.Component_Project.Components" %> <% //MODIFY or ADD Import Statements to Define Namespaces Used by the Template %> <%//This plugin uses InputContext as its context class type%> <% //CrownPeak.CMSAPI.ComponentFrameworkTemplates.TemplateBuilder.InputHelper(asset, context); ComponentLibraryEnhancedTemplateBuilderHelper.InputHelper(asset, context); %> 261541 1792 /System/Templates/Basis/DeveloperCS/ 1 0 false false 0 /Component Project/Templates/Component Framework/Enhanced Template Definition/output.aspx 261538 17 Template 2 body <%@ Page Language="C#" Inherits="CrownPeak.Internal.Debug.OutputInit" %> <%@ Import Namespace="CrownPeak.CMSAPI" %> <%@ Import Namespace="CrownPeak.CMSAPI.Services" %> <!--DO NOT MODIFY CODE ABOVE THIS LINE--> <%@ Import Namespace="CrownPeak.CMSAPI.CustomLibrary" %> <%@ Import Namespace="Component_Library.Component_Project.Components" %> <% //MODIFY or ADD Import Statements to Define Namespaces Used by the Template %> <%//This plugin uses OutputContext as its context class type%> <% //CrownPeak.CMSAPI.ComponentFrameworkTemplates.TemplateBuilder.OutputHelper(asset, context); ComponentLibraryEnhancedTemplateBuilderHelper.OutputHelper(asset, context); %> 261542 1792 /System/Templates/Basis/DeveloperCS/ 1 0 false false 0 /Component Project/Templates/Component Framework/Enhanced Template Definition/output_code.aspx 261538 17 Template 2 body <%@ Page Language="C#" Inherits="CrownPeak.Internal.Debug.OutputInit" %> <%@ Import Namespace="CrownPeak.CMSAPI" %> <%@ Import Namespace="CrownPeak.CMSAPI.Services" %> <!--DO NOT MODIFY CODE ABOVE THIS LINE--> <%@ Import Namespace="CrownPeak.CMSAPI.CustomLibrary" %> <%@ Import Namespace="Component_Library.Component_Project.Components" %> <% //MODIFY or ADD Import Statements to Define Namespaces Used by the Template %> <%//This plugin uses OutputContext as its context class type%> <% //CrownPeak.CMSAPI.ComponentFrameworkTemplates.TemplateBuilder.OutputCodeHelper(asset, context); ComponentLibraryEnhancedTemplateBuilderHelper.OutputCodeHelper(asset, context); %> 261543 1792 /System/Templates/Basis/DeveloperCS/ 1 0 false false 0 /Component Project/Templates/Component Framework/Enhanced Template Definition/output_components.aspx 261538 17 Template 2 body <%@ Page Language="C#" Inherits="CrownPeak.Internal.Debug.OutputInit" %> <%@ Import Namespace="CrownPeak.CMSAPI" %> <%@ Import Namespace="CrownPeak.CMSAPI.Services" %> <!--DO NOT MODIFY CODE ABOVE THIS LINE--> <%@ Import Namespace="CrownPeak.CMSAPI.CustomLibrary" %> <%@ Import Namespace="Component_Library.Component_Project.Components" %> <% //MODIFY or ADD Import Statements to Define Namespaces Used by the Template %> <%//This plugin uses OutputContext as its context class type%> <% //CrownPeak.CMSAPI.ComponentFrameworkTemplates.TemplateBuilder.OutputComponentsHelper(asset, context); ComponentLibraryEnhancedTemplateBuilderHelper.OutputComponentsHelper(asset, context); %> 261544 1792 /System/Templates/Basis/DeveloperCS/ 1 0 false false 0 /Component Project/Templates/Component Framework/Enhanced Template Definition/post_input.aspx 261538 17 Template 2 body <%@ Page Language="C#" Inherits="CrownPeak.Internal.Debug.PostInputInit" %> <%@ Import Namespace="CrownPeak.CMSAPI" %> <%@ Import Namespace="CrownPeak.CMSAPI.Services" %> <!--DO NOT MODIFY CODE ABOVE THIS LINE--> <%@ Import Namespace="CrownPeak.CMSAPI.CustomLibrary" %> <%@ Import Namespace="Component_Library.Component_Project.Components" %> <% //MODIFY or ADD Import Statements to Define Namespaces Used by the Template %> <%//This plugin uses PostInputContext as its context class type%> <% //CrownPeak.CMSAPI.ComponentFrameworkTemplates.TemplateBuilder.PostInputHelper(asset, context); ComponentLibraryEnhancedTemplateBuilderHelper.PostInputHelper(asset, context); %> 261545 1792 /System/Templates/Basis/DeveloperCS/ 1 0 false false 0 /Component Project/Templates/Component Framework/Enhanced Template Definition/post_save.aspx 261538 17 Template 2 body <%@ Page Language="C#" Inherits="CrownPeak.Internal.Debug.PostSaveInit" %> <%@ Import Namespace="CrownPeak.CMSAPI" %> <%@ Import Namespace="CrownPeak.CMSAPI.Services" %> <!--DO NOT MODIFY CODE ABOVE THIS LINE--> <%@ Import Namespace="CrownPeak.CMSAPI.CustomLibrary" %> <%@ Import Namespace="Component_Library.Component_Project.Components" %> <% //MODIFY or ADD Import Statements to Define Namespaces Used by the Template %> <%//This plugin uses PostSaveContext as its context class type%> <% //CrownPeak.CMSAPI.ComponentFrameworkTemplates.TemplateBuilder.PostSaveHelper(asset, context); ComponentLibraryEnhancedTemplateBuilderHelper.PostSaveHelper(asset, context); %> 261546 1792 /System/Templates/Basis/DeveloperCS/ 1 0 false false 0 /Component Project/Templates/Component Framework/Enhanced Template Definition/url.aspx 261538 17 Template 2 body <%@ Page Language="C#" Inherits="CrownPeak.Internal.Debug.UrlInit" %> <%@ Import Namespace="CrownPeak.CMSAPI" %> <%@ Import Namespace="CrownPeak.CMSAPI.Services" %> <!--DO NOT MODIFY CODE ABOVE THIS LINE--> <%@ Import Namespace="CrownPeak.CMSAPI.CustomLibrary" %> <%@ Import Namespace="Component_Library.Component_Project.Components" %> <% //MODIFY or ADD Import Statements to Define Namespaces Used by the Template %> <%//This plugin uses OutputContext as its context class type%> <% CrownPeak.CMSAPI.ComponentFrameworkTemplates.TemplateBuilder.UrlHelper(asset, context); %>