Esempio n. 1
0
        private bool handleAction_Create(string data)
        {
            var article = new TeamMentor_Article();

            article.Metadata.Title = data.urlDecode();
            var xmlContent = article.serialize(false)
                             .add_Xslt("Article_Edit.xslt");

            context.Response.ContentType = "application/xml";
            context.Response.Write(xmlContent);
            return(true);
        }
Esempio n. 2
0
        public static bool xmlDB_Save_Article(this TeamMentor_Article article, Guid libraryId, TM_Xml_Database tmDatabase)
        {
            if (libraryId == Guid.Empty)
            {
                "[xmlDB_Save_GuidanceItem] no LibraryId was provided".error();
                return(false);
            }
            var xmlLibraries    = TM_Xml_Database.Path_XmlLibraries;
            var guidanceXmlPath = tmDatabase.getXmlFilePathForGuidanceId(article.Metadata.Id, libraryId);

            "Saving GuidanceItem {0} to {1}".info(article.Metadata.Id, guidanceXmlPath);

            //tidy the html
            if (article.Content.DataType.lower() == "html")
            {
                var cdataContent = article.Content.Data.Value.replace("]]>", "]] >"); // xmlserialization below will break if there is a ]]>  in the text
                //cdataContent = cdataContent.fixXmlDoubleEncodingIssue();
                var tidiedHtml = cdataContent.tidyHtml();

                article.Content.Data.Value = tidiedHtml;
                if (article.serialize(false).inValid())        //see if the tidied content can be serialized  and if not use the original data
                {
                    article.Content.Data.Value = cdataContent;
                }
            }
            article.Metadata.Library_Id = libraryId;        //ensure the LibraryID is correct

            if (article.serialize(false).valid())           // make sure the article can be serilialized  correctly
            {
                article.saveAs(guidanceXmlPath);
                //add it to in Memory cache
                article.update_Cache_GuidanceItems(tmDatabase);
                return(guidanceXmlPath.fileExists());
            }
            return(false);
        }
 private bool handleAction_Create(string data)
 {
     var article = new TeamMentor_Article();
     article.Metadata.Title = data.urlDecode();
     var xmlContent = article.serialize(false)
                             .add_Xslt("Article_Edit.xslt");
     context.Response.ContentType = "application/xml";
     context.Response.Write(xmlContent);
     return true;
 }