Exemplo n.º 1
0
        //
        // ====================================================================================================
        /// <summary>
        /// create the colleciton zip file and return the pathFilename in the Cdn
        /// </summary>
        /// <param name="cp"></param>
        /// <param name="collectionId"></param>
        /// <returns></returns>
        public static string createCollectionZip_returnCdnPathFilename(CPBaseClass cp, AddonCollectionModel collection)
        {
            string cdnExportZip_Filename = "";

            try {
                if ((collection == null))
                {
                    //
                    // -- exit with error
                    cp.UserError.Add("The collection you selected could not be found");
                    return(string.Empty);
                }
                using (CPCSBaseClass CS = cp.CSNew()) {
                    CS.OpenRecord("Add-on Collections", collection.id);
                    if (!CS.OK())
                    {
                        //
                        // -- exit with error
                        cp.UserError.Add("The collection you selected could not be found");
                        return(string.Empty);
                    }
                    string collectionXml  = "<?xml version=\"1.0\" encoding=\"windows-1252\"?>";
                    string CollectionGuid = CS.GetText("ccGuid");
                    if (CollectionGuid == "")
                    {
                        CollectionGuid = cp.Utils.CreateGuid();
                        CS.SetField("ccGuid", CollectionGuid);
                    }
                    string onInstallAddonGuid = "";
                    if ((CS.FieldOK("onInstallAddonId")))
                    {
                        int onInstallAddonId = CS.GetInteger("onInstallAddonId");
                        if ((onInstallAddonId > 0))
                        {
                            AddonModel addon = AddonModel.create <AddonModel>(cp, onInstallAddonId);
                            if ((addon != null))
                            {
                                onInstallAddonGuid = addon.ccguid;
                            }
                        }
                    }
                    string CollectionName = CS.GetText("name");
                    collectionXml        += System.Environment.NewLine + "<Collection";
                    collectionXml        += " name=\"" + CollectionName + "\"";
                    collectionXml        += " guid=\"" + CollectionGuid + "\"";
                    collectionXml        += " system=\"" + GenericController.getYesNo(CS.GetBoolean("system")) + "\"";
                    collectionXml        += " updatable=\"" + GenericController.getYesNo(CS.GetBoolean("updatable")) + "\"";
                    collectionXml        += " blockNavigatorNode=\"" + GenericController.getYesNo(CS.GetBoolean("blockNavigatorNode")) + "\"";
                    collectionXml        += " onInstallAddonGuid=\"" + onInstallAddonGuid + "\"";
                    collectionXml        += ">";
                    cdnExportZip_Filename = encodeFilename(cp, CollectionName + ".zip");
                    List <string> tempPathFileList = new List <string>();
                    string        tempExportPath   = "CollectionExport" + Guid.NewGuid().ToString() + @"\";
                    //
                    // --resource executable files
                    string        wwwFileList          = CS.GetText("wwwFileList");
                    string        ContentFileList      = CS.GetText("ContentFileList");
                    List <string> execFileList         = ExportResourceListController.getResourceFileList(cp, CS.GetText("execFileList"), CollectionGuid);
                    string        execResourceNodeList = ExportResourceListController.getResourceNodeList(cp, execFileList, CollectionGuid, tempPathFileList, tempExportPath);
                    //
                    // helpLink
                    //
                    if (CS.FieldOK("HelpLink"))
                    {
                        collectionXml += System.Environment.NewLine + "\t" + "<HelpLink>" + System.Net.WebUtility.HtmlEncode(CS.GetText("HelpLink")) + "</HelpLink>";
                    }
                    //
                    // Help
                    //
                    collectionXml += System.Environment.NewLine + "\t" + "<Help>" + System.Net.WebUtility.HtmlEncode(CS.GetText("Help")) + "</Help>";
                    //
                    // Addons
                    //
                    string IncludeSharedStyleGuidList = "";
                    string IncludeModuleGuidList      = "";
                    foreach (var addon in DbBaseModel.createList <AddonModel>(cp, "collectionid=" + collection.id))
                    {
                        //
                        // -- style sheet is in the wwwroot
                        if (!string.IsNullOrEmpty(addon.stylesLinkHref))
                        {
                            string filename = addon.stylesLinkHref.Replace("/", "\\");
                            if (filename.Substring(0, 1).Equals(@"\"))
                            {
                                filename = filename.Substring(1);
                            }
                            if (!cp.WwwFiles.FileExists(filename))
                            {
                                cp.WwwFiles.Save(filename, @"/* css file created as exported for addon [" + addon.name + "], collection [" + collection.name + "] in site [" + cp.Site.Name + "] */");
                            }
                            wwwFileList += System.Environment.NewLine + addon.stylesLinkHref;
                        }
                        //
                        // -- js is in the wwwroot
                        if (!string.IsNullOrEmpty(addon.jsHeadScriptSrc))
                        {
                            string filename = addon.jsHeadScriptSrc.Replace("/", "\\");
                            if (filename.Substring(0, 1).Equals(@"\"))
                            {
                                filename = filename.Substring(1);
                            }
                            if (!cp.WwwFiles.FileExists(filename))
                            {
                                cp.WwwFiles.Save(filename, @"// javascript file created as exported for addon [" + addon.name + "], collection [" + collection.name + "] in site [" + cp.Site.Name + "]");
                            }
                            wwwFileList += System.Environment.NewLine + addon.jsHeadScriptSrc;
                        }
                        collectionXml += ExportAddonController.getAddonNode(cp, addon.id, ref IncludeModuleGuidList, ref IncludeSharedStyleGuidList);
                    }
                    //
                    // Layouts
                    foreach (var layout in DbBaseModel.createList <LayoutModel>(cp, "(installedByCollectionId=" + collection.id + ")"))
                    {
                        collectionXml += ExportLayoutController.get(cp, layout);
                    }
                    //
                    // Templates
                    foreach (var template in DbBaseModel.createList <PageTemplateModel>(cp, "(collectionId=" + collection.id + ")"))
                    {
                        collectionXml += ExportTemplateController.get(cp, template);
                    }
                    //
                    // Data Records
                    string DataRecordList = CS.GetText("DataRecordList");
                    collectionXml += ExportDataRecordController.getNodeList(cp, DataRecordList, tempPathFileList, tempExportPath);
                    //
                    // CDef
                    foreach (Contensive.Models.Db.ContentModel content in createListFromCollection(cp, collection.id))
                    {
                        if ((string.IsNullOrEmpty(content.ccguid)))
                        {
                            content.ccguid = cp.Utils.CreateGuid();
                            content.save(cp);
                        }
                        XmlController xmlTool = new XmlController(cp);
                        string        Node    = xmlTool.GetXMLContentDefinition3(content.name);
                        //
                        // remove the <collection> top node
                        //
                        int Pos = Strings.InStr(1, Node, "<cdef", CompareMethod.Text);
                        if (Pos > 0)
                        {
                            Node = Strings.Mid(Node, Pos);
                            Pos  = Strings.InStr(1, Node, "</cdef>", CompareMethod.Text);
                            if (Pos > 0)
                            {
                                Node           = Strings.Mid(Node, 1, Pos + 6);
                                collectionXml += System.Environment.NewLine + "\t" + Node;
                            }
                        }
                    }
                    //
                    // Scripting Modules
                    if (IncludeModuleGuidList != "")
                    {
                        string[] Modules = Strings.Split(IncludeModuleGuidList, System.Environment.NewLine);
                        for (var Ptr = 0; Ptr <= Information.UBound(Modules); Ptr++)
                        {
                            string ModuleGuid = Modules[Ptr];
                            if (ModuleGuid != "")
                            {
                                using (CPCSBaseClass CS2 = cp.CSNew()) {
                                    CS2.Open("Scripting Modules", "ccguid=" + cp.Db.EncodeSQLText(ModuleGuid));
                                    if (CS2.OK())
                                    {
                                        string Code = CS2.GetText("code").Trim();
                                        Code           = EncodeCData(Code);
                                        collectionXml += System.Environment.NewLine + "\t" + "<ScriptingModule Name=\"" + System.Net.WebUtility.HtmlEncode(CS2.GetText("name")) + "\" guid=\"" + ModuleGuid + "\">" + Code + "</ScriptingModule>";
                                    }
                                    CS2.Close();
                                }
                            }
                        }
                    }
                    //
                    // shared styles
                    string[] recordGuids;
                    string   recordGuid;
                    if ((IncludeSharedStyleGuidList != ""))
                    {
                        recordGuids = Strings.Split(IncludeSharedStyleGuidList, System.Environment.NewLine);
                        for (var Ptr = 0; Ptr <= Information.UBound(recordGuids); Ptr++)
                        {
                            recordGuid = recordGuids[Ptr];
                            if (recordGuid != "")
                            {
                                using (CPCSBaseClass CS2 = cp.CSNew()) {
                                    CS2.Open("Shared Styles", "ccguid=" + cp.Db.EncodeSQLText(recordGuid));
                                    if (CS2.OK())
                                    {
                                        collectionXml += System.Environment.NewLine + "\t" + "<SharedStyle"
                                                         + " Name=\"" + System.Net.WebUtility.HtmlEncode(CS2.GetText("name")) + "\""
                                                         + " guid=\"" + recordGuid + "\""
                                                         + " alwaysInclude=\"" + CS2.GetBoolean("alwaysInclude") + "\""
                                                         + " prefix=\"" + System.Net.WebUtility.HtmlEncode(CS2.GetText("prefix")) + "\""
                                                         + " suffix=\"" + System.Net.WebUtility.HtmlEncode(CS2.GetText("suffix")) + "\""
                                                         + " sortOrder=\"" + System.Net.WebUtility.HtmlEncode(CS2.GetText("sortOrder")) + "\""
                                                         + ">"
                                                         + EncodeCData(CS2.GetText("styleFilename").Trim())
                                                         + "</SharedStyle>";
                                    }
                                    CS2.Close();
                                }
                            }
                        }
                    }
                    //
                    // Import Collections
                    {
                        string Node = "";
                        using (CPCSBaseClass CS3 = cp.CSNew()) {
                            if (CS3.Open("Add-on Collection Parent Rules", "parentid=" + collection.id))
                            {
                                do
                                {
                                    using (CPCSBaseClass CS2 = cp.CSNew()) {
                                        if (CS2.OpenRecord("Add-on Collections", CS3.GetInteger("childid")))
                                        {
                                            string Guid = CS2.GetText("ccGuid");
                                            if (Guid == "")
                                            {
                                                Guid = cp.Utils.CreateGuid();
                                                CS2.SetField("ccGuid", Guid);
                                            }

                                            Node = Node + System.Environment.NewLine + "\t" + "<ImportCollection name=\"" + System.Net.WebUtility.HtmlEncode(CS2.GetText("name")) + "\">" + Guid + "</ImportCollection>";
                                        }

                                        CS2.Close();
                                    }

                                    CS3.GoNext();
                                }while (CS3.OK());
                            }
                            CS3.Close();
                        }
                        collectionXml += Node;
                    }
                    //
                    // wwwFileList
                    if (wwwFileList != "")
                    {
                        string[] Files = Strings.Split(wwwFileList, System.Environment.NewLine);
                        for (int Ptr = 0; Ptr <= Information.UBound(Files); Ptr++)
                        {
                            string pathFilename = Files[Ptr];
                            if (pathFilename != "")
                            {
                                pathFilename = Strings.Replace(pathFilename, @"\", "/");
                                string path     = "";
                                string filename = pathFilename;
                                int    Pos      = Strings.InStrRev(pathFilename, "/");
                                if (Pos > 0)
                                {
                                    filename = Strings.Mid(pathFilename, Pos + 1);
                                    path     = Strings.Mid(pathFilename, 1, Pos - 1);
                                }
                                string fileExtension = System.IO.Path.GetExtension(filename);
                                pathFilename = Strings.Replace(pathFilename, "/", @"\");
                                if (tempPathFileList.Contains(tempExportPath + filename))
                                {
                                    //
                                    // -- the path already has a file with this name
                                    cp.UserError.Add("There was an error exporting this collection because there were multiple files with the same filename [" + filename + "]");
                                }
                                else if (fileExtension.ToUpperInvariant().Equals(".ZIP"))
                                {
                                    //
                                    // -- zip files come from the collection folder
                                    CoreController core           = ((CPClass)cp).core;
                                    string         addonPath      = AddonController.getPrivateFilesAddonPath();
                                    string         collectionPath = CollectionFolderController.getCollectionConfigFolderPath(core, collection.ccguid);
                                    if (!cp.PrivateFiles.FileExists(addonPath + collectionPath + filename))
                                    {
                                        //
                                        // - not there
                                        cp.UserError.Add("There was an error exporting this collection because the zip file [" + pathFilename + "] was not found in the collection path [" + collectionPath + "].");
                                    }
                                    else
                                    {
                                        //
                                        // -- copy file from here
                                        cp.PrivateFiles.Copy(addonPath + collectionPath + filename, tempExportPath + filename, cp.TempFiles);
                                        tempPathFileList.Add(tempExportPath + filename);
                                        collectionXml += System.Environment.NewLine + "\t" + "<Resource name=\"" + System.Net.WebUtility.HtmlEncode(filename) + "\" type=\"www\" path=\"" + System.Net.WebUtility.HtmlEncode(path) + "\" />";
                                    }
                                }
                                else if ((!cp.WwwFiles.FileExists(pathFilename)))
                                {
                                    cp.UserError.Add("There was an error exporting this collection because the www file [" + pathFilename + "] was not found.");
                                }
                                else
                                {
                                    cp.WwwFiles.Copy(pathFilename, tempExportPath + filename, cp.TempFiles);
                                    tempPathFileList.Add(tempExportPath + filename);
                                    collectionXml += System.Environment.NewLine + "\t" + "<Resource name=\"" + System.Net.WebUtility.HtmlEncode(filename) + "\" type=\"www\" path=\"" + System.Net.WebUtility.HtmlEncode(path) + "\" />";
                                }
                            }
                        }
                    }
                    //
                    // ContentFileList
                    //
                    if (true)
                    {
                        if (ContentFileList != "")
                        {
                            string[] Files = Strings.Split(ContentFileList, System.Environment.NewLine);
                            for (var Ptr = 0; Ptr <= Information.UBound(Files); Ptr++)
                            {
                                string PathFilename = Files[Ptr];
                                if (PathFilename != "")
                                {
                                    PathFilename = Strings.Replace(PathFilename, @"\", "/");
                                    string Path     = "";
                                    string Filename = PathFilename;
                                    int    Pos      = Strings.InStrRev(PathFilename, "/");
                                    if (Pos > 0)
                                    {
                                        Filename = Strings.Mid(PathFilename, Pos + 1);
                                        Path     = Strings.Mid(PathFilename, 1, Pos - 1);
                                    }
                                    if (tempPathFileList.Contains(tempExportPath + Filename))
                                    {
                                        cp.UserError.Add("There was an error exporting this collection because there were multiple files with the same filename [" + Filename + "]");
                                    }
                                    else if ((!cp.CdnFiles.FileExists(PathFilename)))
                                    {
                                        cp.UserError.Add("There was an error exporting this collection because the cdn file [" + PathFilename + "] was not found.");
                                    }
                                    else
                                    {
                                        cp.CdnFiles.Copy(PathFilename, tempExportPath + Filename, cp.TempFiles);
                                        tempPathFileList.Add(tempExportPath + Filename);
                                        collectionXml += System.Environment.NewLine + "\t" + "<Resource name=\"" + System.Net.WebUtility.HtmlEncode(Filename) + "\" type=\"content\" path=\"" + System.Net.WebUtility.HtmlEncode(Path) + "\" />";
                                    }
                                }
                            }
                        }
                    }
                    //
                    // ExecFileListNode
                    //
                    collectionXml += execResourceNodeList;
                    //
                    // Other XML
                    //
                    string OtherXML;
                    OtherXML = CS.GetText("otherxml");
                    if (Strings.Trim(OtherXML) != "")
                    {
                        collectionXml += System.Environment.NewLine + OtherXML;
                    }
                    collectionXml += System.Environment.NewLine + "</Collection>";
                    CS.Close();
                    string tempExportXml_Filename = encodeFilename(cp, CollectionName + ".xml");
                    //
                    // Save the installation file and add it to the archive
                    //
                    cp.TempFiles.Save(tempExportPath + tempExportXml_Filename, collectionXml);
                    if (!tempPathFileList.Contains(tempExportPath + tempExportXml_Filename))
                    {
                        tempPathFileList.Add(tempExportPath + tempExportXml_Filename);
                    }
                    string tempExportZip_Filename = encodeFilename(cp, CollectionName + ".zip");
                    //
                    // -- zip up the folder to make the collection zip file in temp filesystem
                    zipTempCdnFile(cp, tempExportPath + tempExportZip_Filename, tempPathFileList);
                    //
                    // -- copy the collection zip file to the cdn filesystem as the download link
                    cp.TempFiles.Copy(tempExportPath + tempExportZip_Filename, cdnExportZip_Filename, cp.CdnFiles);
                    //
                    // -- delete the temp folder
                    cp.TempFiles.DeleteFolder(tempExportPath);
                }
            } catch (Exception ex) {
                cp.Site.ErrorReport(ex);
            }
            return(cdnExportZip_Filename);
        }
Exemplo n.º 2
0
        //
        // ====================================================================================================

        public static string getAddonNode(CPBaseClass cp, int addonid, ref string Return_IncludeModuleGuidList, ref string Return_IncludeSharedStyleGuidList)
        {
            string result = "";

            try {
                using (CPCSBaseClass CS = cp.CSNew()) {
                    if (CS.OpenRecord("Add-ons", addonid))
                    {
                        string addonName      = CS.GetText("name");
                        bool   processRunOnce = CS.GetBoolean("ProcessRunOnce");
                        if (((Strings.LCase(addonName) == "oninstall") | (Strings.LCase(addonName) == "_oninstall")))
                        {
                            processRunOnce = true;
                        }
                        //
                        // content
                        result += ExportController.getNode("Copy", CS.GetText("Copy"));
                        result += ExportController.getNode("CopyText", CS.GetText("CopyText"));
                        //
                        // DLL
                        result += ExportController.getNode("ActiveXProgramID", CS.GetText("objectprogramid"), true);
                        result += ExportController.getNode("DotNetClass", CS.GetText("DotNetClass"));
                        //
                        // Features
                        result += ExportController.getNode("ArgumentList", CS.GetText("ArgumentList"));
                        result += ExportController.getNodeLookupContentName(cp, "instanceSettingPrimaryContentId", CS.GetInteger("instanceSettingPrimaryContentId"), "content");
                        result += ExportController.getNode("AsAjax", CS.GetBoolean("AsAjax"));
                        result += ExportController.getNode("Filter", CS.GetBoolean("Filter"));
                        result += ExportController.getNode("Help", CS.GetText("Help"));
                        result += ExportController.getNode("HelpLink", CS.GetText("HelpLink"));
                        result += System.Environment.NewLine + "\t" + "<Icon Link=\"" + CS.GetText("iconfilename") + "\" width=\"" + CS.GetInteger("iconWidth") + "\" height=\"" + CS.GetInteger("iconHeight") + "\" sprites=\"" + CS.GetInteger("iconSprites") + "\" />";
                        result += ExportController.getNode("InIframe", CS.GetBoolean("InFrame"));
                        result += ExportController.getNode("BlockEditTools", CS.GetBoolean("BlockEditTools"));
                        result += ExportController.getNode("AliasList", CS.GetText("aliasList"));
                        //
                        // -- Form XML
                        result += ExportController.getNode("FormXML", CS.GetText("FormXML"));
                        //
                        // -- addon dependencies
                        using (CPCSBaseClass CS2 = cp.CSNew()) {
                            CS2.Open("Add-on Include Rules", "addonid=" + addonid);
                            while (CS2.OK())
                            {
                                int IncludedAddonID = CS2.GetInteger("IncludedAddonID");
                                using (CPCSBaseClass CS3 = cp.CSNew()) {
                                    CS3.Open("Add-ons", "ID=" + IncludedAddonID);
                                    if (CS3.OK())
                                    {
                                        string Guid = CS3.GetText("ccGuid");
                                        if (Guid == "")
                                        {
                                            Guid = cp.Utils.CreateGuid();
                                            CS3.SetField("ccGuid", Guid);
                                        }
                                        result += System.Environment.NewLine + "\t" + "<IncludeAddon name=\"" + System.Net.WebUtility.HtmlEncode(CS3.GetText("name")) + "\" guid=\"" + Guid + "\"/>";
                                    }
                                    CS3.Close();
                                }
                                CS2.GoNext();
                            }
                            CS2.Close();
                        }
                        //
                        // -- is inline/block
                        result += ExportController.getNode("IsInline", CS.GetBoolean("IsInline"));
                        //
                        // -- javascript (xmlnode may not match Db filename)
                        result += ExportController.getNode("JavascriptInHead", CS.GetText("JSFilename"));
                        result += ExportController.getNode("javascriptForceHead", CS.GetBoolean("javascriptForceHead"));
                        result += ExportController.getNode("JSHeadScriptSrc", CS.GetText("JSHeadScriptSrc"));
                        //
                        // -- javascript deprecated
                        result += ExportController.getNode("JSBodyScriptSrc", CS.GetText("JSBodyScriptSrc"), true);
                        result += ExportController.getNode("JavascriptBodyEnd", CS.GetText("JavascriptBodyEnd"), true);
                        result += ExportController.getNode("JavascriptOnLoad", CS.GetText("JavascriptOnLoad"), true);
                        //
                        // -- Placements
                        result += ExportController.getNode("Content", CS.GetBoolean("Content"));
                        result += ExportController.getNode("Template", CS.GetBoolean("Template"));
                        result += ExportController.getNode("Email", CS.GetBoolean("Email"));
                        result += ExportController.getNode("Admin", CS.GetBoolean("Admin"));
                        result += ExportController.getNode("OnPageEndEvent", CS.GetBoolean("OnPageEndEvent"));
                        result += ExportController.getNode("OnPageStartEvent", CS.GetBoolean("OnPageStartEvent"));
                        result += ExportController.getNode("OnBodyStart", CS.GetBoolean("OnBodyStart"));
                        result += ExportController.getNode("OnBodyEnd", CS.GetBoolean("OnBodyEnd"));
                        result += ExportController.getNode("RemoteMethod", CS.GetBoolean("RemoteMethod"));
                        result += CS.FieldOK("Diagnostic") ? ExportController.getNode("Diagnostic", CS.GetBoolean("Diagnostic")) : "";
                        //
                        // -- Presentation
                        result += ExportController.getNode("category", CS.GetText("addoncategoryid"));
                        //
                        // -- Process
                        result += ExportController.getNode("ProcessRunOnce", processRunOnce);
                        result += ExportController.getNode("ProcessInterval", CS.GetInteger("ProcessInterval"));
                        //
                        // Meta
                        //
                        result += ExportController.getNode("MetaDescription", CS.GetText("MetaDescription"));
                        result += ExportController.getNode("OtherHeadTags", CS.GetText("OtherHeadTags"));
                        result += ExportController.getNode("PageTitle", CS.GetText("PageTitle"));
                        result += ExportController.getNode("RemoteAssetLink", CS.GetText("RemoteAssetLink"));
                        //
                        // Styles
                        string Styles = "";
                        if (!CS.GetBoolean("BlockDefaultStyles"))
                        {
                            Styles = CS.GetText("StylesFilename").Trim();
                        }
                        string StylesTest = CS.GetText("CustomStylesFilename").Trim();
                        if (StylesTest != "")
                        {
                            if (Styles != "")
                            {
                                Styles = Styles + System.Environment.NewLine + StylesTest;
                            }
                            else
                            {
                                Styles = StylesTest;
                            }
                        }
                        result += ExportController.getNode("Styles", Styles);
                        result += ExportController.getNode("styleslinkhref", CS.GetText("styleslinkhref"));
                        //
                        //
                        // Scripting
                        //
                        string NodeInnerText = CS.GetText("ScriptingCode").Trim();
                        if (NodeInnerText != "")
                        {
                            NodeInnerText = System.Environment.NewLine + "\t" + "\t" + "<Code>" + ExportController.EncodeCData(NodeInnerText) + "</Code>";
                        }
                        using (CPCSBaseClass CS2 = cp.CSNew()) {
                            CS2.Open("Add-on Scripting Module Rules", "addonid=" + addonid);
                            while (CS2.OK())
                            {
                                int ScriptingModuleID = CS2.GetInteger("ScriptingModuleID");
                                using (CPCSBaseClass CS3 = cp.CSNew()) {
                                    CS3.Open("Scripting Modules", "ID=" + ScriptingModuleID);
                                    if (CS3.OK())
                                    {
                                        string Guid = CS3.GetText("ccGuid");
                                        if (Guid == "")
                                        {
                                            Guid = cp.Utils.CreateGuid();
                                            CS3.SetField("ccGuid", Guid);
                                        }
                                        Return_IncludeModuleGuidList = Return_IncludeModuleGuidList + System.Environment.NewLine + Guid;
                                        NodeInnerText = NodeInnerText + System.Environment.NewLine + "\t" + "\t" + "<IncludeModule name=\"" + System.Net.WebUtility.HtmlEncode(CS3.GetText("name")) + "\" guid=\"" + Guid + "\"/>";
                                    }
                                    CS3.Close();
                                }
                                CS2.GoNext();
                            }
                            CS2.Close();
                        }
                        if (NodeInnerText == "")
                        {
                            result += System.Environment.NewLine + "\t" + "<Scripting Language=\"" + CS.GetText("ScriptingLanguageID") + "\" EntryPoint=\"" + CS.GetText("ScriptingEntryPoint") + "\" Timeout=\"" + CS.GetText("ScriptingTimeout") + "\"/>";
                        }
                        else
                        {
                            result += System.Environment.NewLine + "\t" + "<Scripting Language=\"" + CS.GetText("ScriptingLanguageID") + "\" EntryPoint=\"" + CS.GetText("ScriptingEntryPoint") + "\" Timeout=\"" + CS.GetText("ScriptingTimeout") + "\">" + NodeInnerText + System.Environment.NewLine + "\t" + "</Scripting>";
                        }
                        //
                        // Shared Styles
                        //
                        using (CPCSBaseClass CS2 = cp.CSNew()) {
                            CS2.Open("Shared Styles Add-on Rules", "addonid=" + addonid);
                            while (CS2.OK())
                            {
                                int styleId = CS2.GetInteger("styleId");
                                using (CPCSBaseClass CS3 = cp.CSNew()) {
                                    CS3.Open("shared styles", "ID=" + styleId);
                                    if (CS3.OK())
                                    {
                                        string Guid = CS3.GetText("ccGuid");
                                        if (Guid == "")
                                        {
                                            Guid = cp.Utils.CreateGuid();
                                            CS3.SetField("ccGuid", Guid);
                                        }
                                        Return_IncludeSharedStyleGuidList = Return_IncludeSharedStyleGuidList + System.Environment.NewLine + Guid;
                                        result += System.Environment.NewLine + "\t" + "<IncludeSharedStyle name=\"" + System.Net.WebUtility.HtmlEncode(CS3.GetText("name")) + "\" guid=\"" + Guid + "\"/>";
                                    }
                                    CS3.Close();
                                }
                                CS2.GoNext();
                            }
                            CS2.Close();
                        }
                        //
                        // Process Triggers
                        //
                        NodeInnerText = "";
                        using (CPCSBaseClass CS2 = cp.CSNew()) {
                            CS2.Open("Add-on Content Trigger Rules", "addonid=" + addonid);
                            while (CS2.OK())
                            {
                                int TriggerContentID = CS2.GetInteger("ContentID");
                                using (CPCSBaseClass CS3 = cp.CSNew()) {
                                    CS3.Open("content", "ID=" + TriggerContentID);
                                    if (CS3.OK())
                                    {
                                        string Guid = CS3.GetText("ccGuid");
                                        if (Guid == "")
                                        {
                                            Guid = cp.Utils.CreateGuid();
                                            CS3.SetField("ccGuid", Guid);
                                        }
                                        NodeInnerText = NodeInnerText + System.Environment.NewLine + "\t" + "\t" + "<ContentChange name=\"" + System.Net.WebUtility.HtmlEncode(CS3.GetText("name")) + "\" guid=\"" + Guid + "\"/>";
                                    }
                                    CS3.Close();
                                }
                                CS2.GoNext();
                            }
                            CS2.Close();
                        }
                        if (NodeInnerText != "")
                        {
                            result += System.Environment.NewLine + "\t" + "<ProcessTriggers>" + NodeInnerText + System.Environment.NewLine + "\t" + "</ProcessTriggers>";
                        }
                        //
                        // Editors
                        //
                        if (cp.Content.IsField("Add-on Content Field Type Rules", "id"))
                        {
                            NodeInnerText = "";
                            using (CPCSBaseClass CS2 = cp.CSNew()) {
                                CS2.Open("Add-on Content Field Type Rules", "addonid=" + addonid);
                                while (CS2.OK())
                                {
                                    int    fieldTypeID = CS2.GetInteger("contentFieldTypeID");
                                    string fieldType   = cp.Content.GetRecordName("Content Field Types", fieldTypeID);
                                    if (fieldType != "")
                                    {
                                        NodeInnerText = NodeInnerText + System.Environment.NewLine + "\t" + "\t" + "<type>" + fieldType + "</type>";
                                    }
                                    CS2.GoNext();
                                }
                                CS2.Close();
                            }
                            if (NodeInnerText != "")
                            {
                                result += System.Environment.NewLine + "\t" + "<Editors>" + NodeInnerText + System.Environment.NewLine + "\t" + "</Editors>";
                            }
                        }
                        //
                        string addonGuid = CS.GetText("ccGuid");
                        if ((string.IsNullOrWhiteSpace(addonGuid)))
                        {
                            addonGuid = cp.Utils.CreateGuid();
                            CS.SetField("ccGuid", addonGuid);
                        }
                        string NavType = CS.GetText("NavTypeID");
                        if ((NavType == ""))
                        {
                            NavType = "Add-on";
                        }
                        result = ""
                                 + System.Environment.NewLine + "\t" + "<Addon name=\"" + System.Net.WebUtility.HtmlEncode(addonName) + "\" guid=\"" + addonGuid + "\" type=\"" + NavType + "\">"
                                 + ExportController.tabIndent(cp, result)
                                 + System.Environment.NewLine + "\t" + "</Addon>";
                    }
                    CS.Close();
                }
            } catch (Exception ex) {
                cp.Site.ErrorReport(ex, "GetAddonNode");
            }
            return(result);
        }