Exemplo n.º 1
0
        [EditArticles]  public static bool xmlDB_Save_Article(this TeamMentor_Article article, Guid libraryId, TM_Xml_Database tmDatabase)
        {
            UserRole.EditArticles.demand();
            if (libraryId == Guid.Empty)                                                // ensure we have a library to put the Article in
            {
                "[xmlDB_Save_GuidanceItem] no LibraryId was provided".error();
                return(false);
            }

            if (article.Content.DataType.lower() == "html")                             // tidy the html
            {
                var cdataContent = article.Content.Data.Value.replace("]]>", "]] >");   // xmlserialization below will break if there is a ]]>  in the text
                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).notValid())                                    // make sure the article can be serilialized  correctly
            {
                return(false);
            }

            article.update_Cache_GuidanceItems(tmDatabase);                             // add it to in Memory cache

            tmDatabase.Events.Article_Saved.raise(article);                             // TODO find way to identify save issues (like the return value of the save action)

            return(true);
        }
Exemplo n.º 2
0
        [EditArticles]  public static bool xmlDB_Save_Article(this TeamMentor_Article article, Guid libraryId, TM_Xml_Database tmDatabase)
        {
            if (libraryId == Guid.Empty)                                                // ensure we have a library to put the Article in
            {
                "[xmlDB_Save_GuidanceItem] no LibraryId was provided".error();
                return(false);
            }

            article.sanitize();

            article.Metadata.Library_Id = libraryId;                                    // ensure the LibraryID is correct

            if (article.serialize(false).notValid())                                    // make sure the article can be serilialized  correctly
            {
                return(false);
            }

            article.update_Cache_GuidanceItems(tmDatabase);                             // add it to in Memory cache

            if (tmDatabase.UsingFileStorage)                                            // save to disk
            {
                var guidanceXmlPath = tmDatabase.getXmlFilePathForGuidanceId(article.Metadata.Id, libraryId);
                if (guidanceXmlPath.valid())
                {
                    "Saving GuidanceItem {0} to {1}".info(article.Metadata.Id, guidanceXmlPath);
                    article.saveAs(guidanceXmlPath);
                    return(guidanceXmlPath.fileExists());
                }
            }
            return(true);
        }
Exemplo n.º 3
0
        public void handleAction_Create(string data)
        {
            var article = new TeamMentor_Article {
                Metadata = { Title = data.urlDecode() }
            };
            var xmlContent = article.serialize(false)
                             .add_Xslt("Article_Edit.xslt");

            context.Response.ContentType = "application/xml";
            context.Response.Write(xmlContent);
            endResponse();
        }
        [EditArticles]  public static bool xmlDB_Save_Article(this TeamMentor_Article article, Guid libraryId, TM_Xml_Database tmDatabase)
        {
            if (libraryId == Guid.Empty)                                                // ensure we have a library to put the Article in
            {
                "[xmlDB_Save_GuidanceItem] no LibraryId was provided".error();
                return(false);
            }

            if (article.Content.DataType.lower() == "html")                             // tidy the html
            {
                var cdataContent = article.Content.Data.Value.replace("]]>", "]] >");   // xmlserialization below will break if there is a ]]>  in the text
                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).notValid())                                    // make sure the article can be serilialized  correctly
            {
                return(false);
            }

            article.update_Cache_GuidanceItems(tmDatabase);                             // add it to in Memory cache

            if (tmDatabase.UsingFileStorage)                                            // save to disk
            {
                var guidanceXmlPath = tmDatabase.getXmlFilePathForGuidanceId(article.Metadata.Id, libraryId);
                if (guidanceXmlPath.valid())
                {
                    "Saving GuidanceItem {0} to {1}".info(article.Metadata.Id, guidanceXmlPath);
                    article.saveAs(guidanceXmlPath);
                    return(guidanceXmlPath.fileExists());
                }
            }
            return(true);
        }
Exemplo n.º 5
0
        public void handleAction_Create(string data)
        {
            var article = new TeamMentor_Article {
                Metadata = { Title = data.urlDecode() }
            };
            var xmlContent = article.serialize(false)
                             .add_Xslt("Article_Edit.xslt");

            context.Response.ContentType = "application/xml";
            context.Response.Write(xmlContent);

            tmWebServices.logUserActivity("Create Article (Notepad)", "{0} ({1})".info(article.Metadata.Title, data));

            endResponse();
        }
Exemplo n.º 6
0
        public static void sanitize(this TeamMentor_Article article)
        {
            if (article.Content.DataType.lower() == "html") // tidy the html
            {
                string cdataContent = article.Content.Data.Value.replace("]]>", "]] >");
                // xmlserialization below will break if there is a ]]>  in the text

                string 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;
                }
            }
        }
Exemplo n.º 7
0
        public void handleAction_Create(string data)
        {
            var article = new TeamMentor_Article {Metadata = {Title = data.urlDecode()}};
            var xmlContent = article.serialize(false)
                                    .add_Xslt("Article_Edit.xslt");
            context.Response.ContentType = "application/xml";
            context.Response.Write(xmlContent);

            tmWebServices.logUserActivity("Create Article (Notepad)", "{0} ({1})".info(article.Metadata.Title, data));

            endResponse();
        }
Exemplo n.º 8
0
 private bool handleAction_Create(string data)
 {
     var article = new TeamMentor_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;
 }