public void AddMessageTest() { IPagesStorageProviderV40 pagesStorageProvider = mocks.DynamicMock <IPagesStorageProviderV40>(); Expect.Call(pagesStorageProvider.CurrentWiki).Return("wiki1").Repeat.Any(); mocks.ReplayAll(); Collectors.InitCollectors(); Collectors.AddProvider(typeof(AzureIndexDirectoryProvider), System.Reflection.Assembly.GetAssembly(typeof(AzureIndexDirectoryProvider)), ConfigurationManager.AppSettings["AzureConnString"], typeof(IIndexDirectoryProviderV40)); Host.Instance = new Host(); Host.Instance.OverridePublicDirectory(testDir); ProviderLoader.SetUp <IIndexDirectoryProviderV40>(typeof(AzureIndexDirectoryProvider), ConfigurationManager.AppSettings["AzureConnString"]); string messageSubject = "This is the subject of the message"; string messageBody = "This is the body of the message"; DateTime dt = DateTime.Now; PageContent page = new PageContent("pagefullname", pagesStorageProvider, dt, "title", "user-test", dt, "", "content", new string[0], ""); Message message = new Message(1, "user-test", messageSubject, dt, messageBody); Assert.IsTrue(SearchClass.IndexMessage(message, page)); List <SearchResult> results = SearchClass.Search("wiki1", new SearchField[] { SearchField.Content }, "message", SearchOptions.AtLeastOneWord); Assert.AreEqual(1, results.Count, "Wrong result length"); Assert.AreEqual(DocumentType.Message, results[0].DocumentType, "Wrong document type"); MessageDocument documentMessage = results[0].Document as MessageDocument; Assert.AreEqual("This is the subject of the message", documentMessage.Subject, "Wrong title"); Assert.AreEqual("This is the body of the <b class=\"searchkeyword\">message</b>", documentMessage.HighlightedBody, "Wrong content"); }
public void AddPageTest() { IPagesStorageProviderV40 pagesStorageProvider = mocks.DynamicMock <IPagesStorageProviderV40>(); Expect.Call(pagesStorageProvider.CurrentWiki).Return("wiki1").Repeat.Any(); mocks.ReplayAll(); Collectors.InitCollectors(); Collectors.AddProvider(typeof(AzureIndexDirectoryProvider), System.Reflection.Assembly.GetAssembly(typeof(AzureIndexDirectoryProvider)), ConfigurationManager.AppSettings["AzureConnString"], typeof(IIndexDirectoryProviderV40)); Host.Instance = new Host(); Host.Instance.OverridePublicDirectory(testDir); ProviderLoader.SetUp <IIndexDirectoryProviderV40>(typeof(AzureIndexDirectoryProvider), ConfigurationManager.AppSettings["AzureConnString"]); string pageTitle = "This is the title of the page"; string pageContent = "This is the content of the page"; PageContent page = new PageContent("pagefullname", pagesStorageProvider, DateTime.Now, pageTitle, "user-test", DateTime.Now, "comment to last editing", pageContent, null, "Description of the page"); Assert.IsTrue(SearchClass.IndexPage(page)); List <SearchResult> results = SearchClass.Search("wiki1", new SearchField[] { SearchField.Title }, "page", SearchOptions.AtLeastOneWord); Assert.AreEqual(1, results.Count, "Wrong result length"); Assert.AreEqual(DocumentType.Page, results[0].DocumentType, "Wrong document type"); PageDocument documentPage = results[0].Document as PageDocument; Assert.AreEqual("This is the title of the <b class=\"searchkeyword\">page</b>", documentPage.HighlightedTitle, "Wrong title"); Assert.AreEqual("This is the content of the <b class=\"searchkeyword\">page</b>", documentPage.HighlightedContent, "Wrong content"); }
/// <summary> /// Creates a new Snippet. /// </summary> /// <param name="wiki">The wiki.</param> /// <param name="name">The name of the Snippet.</param> /// <param name="content">The content of the Snippet.</param> /// <param name="provider">The Provider to use to store the Snippet (<c>null</c> for the default provider).</param> /// <returns>True if the Snippets has been addedd successfully.</returns> public static bool AddSnippet(string wiki, string name, string content, IPagesStorageProviderV40 provider) { if (Find(wiki, name) != null) { return(false); } if (provider == null) { provider = Collectors.CollectorsBox.PagesProviderCollector.GetProvider(GlobalSettings.DefaultPagesProvider, wiki); } Snippet newSnippet = provider.AddSnippet(name, content); if (newSnippet != null) { Log.LogEntry("Snippet " + name + " created", EntryType.General, Log.SystemUsername, wiki); } else { Log.LogEntry("Creation failed for Snippet " + name, EntryType.Error, Log.SystemUsername, wiki); } return(newSnippet != null); }
public void Init() { IPagesStorageProviderV40 prov = GetProvider(); prov.Init(MockHost(), ConnString + InitialCatalog, null); Assert.IsNotNull(prov.Information, "Information should not be null"); }
public void UnindexPageTest() { IPagesStorageProviderV40 pagesStorageProvider = mocks.DynamicMock <IPagesStorageProviderV40>(); Expect.Call(pagesStorageProvider.CurrentWiki).Return("wiki1").Repeat.Any(); mocks.ReplayAll(); Collectors.InitCollectors(); Collectors.AddProvider(typeof(SqlServerIndexDirectoryProvider), System.Reflection.Assembly.GetAssembly(typeof(SqlServerIndexDirectoryProvider)), ConnString + InitialCatalog, typeof(IIndexDirectoryProviderV40)); Host.Instance = new Host(); Host.Instance.OverridePublicDirectory(testDir); ProviderLoader.SetUp <IIndexDirectoryProviderV40>(typeof(SqlServerIndexDirectoryProvider), ConnString + InitialCatalog); string pageTitle1 = "This is the title"; string pageContent1 = "This is the content of the page"; PageContent page1 = new PageContent("pagefullname1", pagesStorageProvider, DateTime.Now, pageTitle1, "user-test", DateTime.Now, "comment to last editing", pageContent1, null, "Description of the page"); string pageTitle2 = "This is the title of the second page"; string pageContent2 = "This is the content of the second page"; PageContent page2 = new PageContent("pagefullname2", pagesStorageProvider, DateTime.Now, pageTitle2, "user-test", DateTime.Now, "comment to last editing", pageContent2, null, "Description of the page"); Lucene.Net.Store.Directory directory = new RAMDirectory(); Assert.IsTrue(SearchClass.IndexPage(page1)); Assert.IsTrue(SearchClass.IndexPage(page2)); List <SearchResult> results = SearchClass.Search("wiki1", new SearchField[] { SearchField.Title, SearchField.Content }, "page", SearchOptions.AtLeastOneWord); Assert.AreEqual(2, results.Count, "Wrong result length"); Assert.AreEqual(DocumentType.Page, results[1].DocumentType, "Wrong document type"); PageDocument doc1 = results[1].Document as PageDocument; Assert.AreEqual(string.Empty, doc1.HighlightedTitle, "Wrong title"); Assert.AreEqual("This is the content of the <b class=\"searchkeyword\">page</b>", doc1.HighlightedContent, "Wrong content"); Assert.AreEqual(DocumentType.Page, results[0].DocumentType, "Wrong document type"); PageDocument doc2 = results[0].Document as PageDocument; Assert.AreEqual("This is the title of the second <b class=\"searchkeyword\">page</b>", doc2.HighlightedTitle, "Wrong title"); Assert.AreEqual("This is the content of the second <b class=\"searchkeyword\">page</b>", doc2.HighlightedContent, "Wrong content"); Assert.IsTrue(SearchClass.UnindexPage(page1)); results = SearchClass.Search("wiki1", new SearchField[] { SearchField.Title, SearchField.Content }, "page", SearchOptions.AtLeastOneWord); Assert.AreEqual(1, results.Count, "Wrong result length"); Assert.AreEqual(DocumentType.Page, results[0].DocumentType, "Wrong document type"); PageDocument doc3 = results[0].Document as PageDocument; Assert.AreEqual("This is the title of the second <b class=\"searchkeyword\">page</b>", doc3.HighlightedTitle, "Wrong title"); Assert.AreEqual("This is the content of the second <b class=\"searchkeyword\">page</b>", doc3.HighlightedContent, "Wrong content"); }
public void RenamePageAttachmentTest() { IPagesStorageProviderV40 pagesStorageProvider = mocks.DynamicMock <IPagesStorageProviderV40>(); Expect.Call(pagesStorageProvider.CurrentWiki).Return("wiki1").Repeat.Any(); mocks.ReplayAll(); Collectors.InitCollectors(); Collectors.AddProvider(typeof(AzureIndexDirectoryProvider), System.Reflection.Assembly.GetAssembly(typeof(AzureIndexDirectoryProvider)), ConfigurationManager.AppSettings["AzureConnString"], typeof(IIndexDirectoryProviderV40)); Host.Instance = new Host(); Host.Instance.OverridePublicDirectory(testDir); ProviderLoader.SetUp <IIndexDirectoryProviderV40>(typeof(AzureIndexDirectoryProvider), ConfigurationManager.AppSettings["AzureConnString"]); DateTime dt = DateTime.Now; PageContent page = new PageContent("pagefullname", pagesStorageProvider, dt, "title", "user-test", dt, "", "content", new string[0], ""); string fileName = "file name_1"; string filePath = Path.Combine(testDir, "test.txt"); using (StreamWriter writer = File.CreateText(filePath)) { writer.Write("This is the content of a file"); } Assert.IsTrue(SearchClass.IndexPageAttachment(fileName, filePath, page)); List <SearchResult> results = SearchClass.Search("wiki1", new SearchField[] { SearchField.FileName, SearchField.FileContent }, "file", SearchOptions.AtLeastOneWord); Assert.AreEqual(1, results.Count, "Wrong result length"); Assert.AreEqual(DocumentType.Attachment, results[0].DocumentType, "Wrong document type"); PageAttachmentDocument pageAttachmentDocument = results[0].Document as PageAttachmentDocument; Assert.AreEqual(fileName, pageAttachmentDocument.FileName, "Wrong file name"); Assert.AreEqual("This is the content of a <b class=\"searchkeyword\">file</b>", pageAttachmentDocument.HighlightedFileContent, "Wrong file content"); Assert.IsTrue(SearchClass.RenamePageAttachment(page, fileName, "file name_2")); results = SearchClass.Search("wiki1", new SearchField[] { SearchField.FileName, SearchField.FileContent }, "file", SearchOptions.AtLeastOneWord); Assert.AreEqual(1, results.Count, "Wrong result length"); Assert.AreEqual(DocumentType.Attachment, results[0].DocumentType, "Wrong document type"); pageAttachmentDocument = results[0].Document as PageAttachmentDocument; Assert.AreEqual("file name_2", pageAttachmentDocument.FileName, "Wrong file name"); Assert.AreEqual("This is the content of a <b class=\"searchkeyword\">file</b>", pageAttachmentDocument.HighlightedFileContent, "Wrong file content"); }
/// <summary> /// Initializes a new instance of the <see cref="T:PageContent"/> class. /// </summary> /// <param name="pageFullName">The PageInfo object.</param> /// <param name="provider">The Pages Storage Provider that manages this Page.</param> /// <param name="creationDateTime">The Page creation Date/Time.</param> /// <param name="title">The Title.</param> /// <param name="user">The User that last modified the Page.</param> /// <param name="lastModified">The last modification Date and Time.</param> /// <param name="comment">The Comment of the editor, about this revision.</param> /// <param name="content">The <b>unparsed</b> Content.</param> /// <param name="keywords">The keywords, usually used for SEO, or <c>null</c>.</param> /// <param name="description">The description, usually used for SEO, or <c>null</c>.</param> public PageContent(string pageFullName, IPagesStorageProviderV40 provider, DateTime creationDateTime, string title, string user, DateTime lastModified, string comment, string content, string[] keywords, string description) { this.nspace = NameTools.GetNamespace(pageFullName); this.name = NameTools.GetLocalName(pageFullName); this.provider = provider; this.creationDateTime = creationDateTime; this.title = title; this.user = user; this.lastModified = lastModified; this.content = content; this.comment = comment; this.keywords = keywords != null ? keywords : new string[0]; this.description = description; }
/// <summary> /// Finds the appropriate provider to use for operations. /// </summary> /// <returns>The provider.</returns> private IPagesStorageProviderV40 FindAppropriateProvider() { IPagesStorageProviderV40 provider = null; if (currentPage != null) { provider = currentPage.Provider; } else { NamespaceInfo currentNamespace = DetectNamespaceInfo(); provider = currentNamespace == null? Collectors.CollectorsBox.PagesProviderCollector.GetProvider(GlobalSettings.DefaultPagesProvider, currentWiki) : currentNamespace.Provider; } return(provider); }
/// <summary> /// Populates the categories for the current namespace and provider, selecting the ones specified. /// </summary> /// <param name="toSelect">The categories to select.</param> private void PopulateCategories(CategoryInfo[] toSelect) { IPagesStorageProviderV40 provider = FindAppropriateProvider(); List <CategoryInfo> cats = Pages.GetCategories(currentWiki, DetectNamespaceInfo()); lstCategories.Items.Clear(); foreach (CategoryInfo c in cats) { if (c.Provider == provider) { ListItem itm = new ListItem(NameTools.GetLocalName(c.FullName), c.FullName); if (Array.Find <CategoryInfo>(toSelect, delegate(CategoryInfo s) { return(s.FullName == c.FullName); }) != null) { itm.Selected = true; } lstCategories.Items.Add(itm); } } }
/// <summary> /// Gets an empty instance of <see cref="T:PageContent" />. /// </summary> /// <param name="pageFullName">The page full name.</param> /// <param name="provider">The Pages Storage Provider that manages this Page.</param> /// <param name="creationDateTime">The Page creation Date/Time.</param> /// <returns>The instance.</returns> public static PageContent GetEmpty(string pageFullName, IPagesStorageProviderV40 provider, DateTime creationDateTime) { return(new EmptyPageContent(pageFullName, provider, creationDateTime)); }
/// <summary> /// Initializes a new instance of the <see cref="T:NamespaceInfo" /> class. /// </summary> /// <param name="name">The namespace name.</param> /// <param name="provider">The provider.</param> /// <param name="defaultPageFullName">The full name of the default page, or <c>null</c>.</param> public NamespaceInfo(string name, IPagesStorageProviderV40 provider, string defaultPageFullName) { this.name = name; this.provider = provider; this.defaultPageFullName = defaultPageFullName; }
protected void rptIndex_ItemCommand(object sender, CommandEventArgs e) { Log.LogEntry("Index rebuild requested for " + e.CommandArgument as string, EntryType.General, SessionFacade.GetCurrentUsername(), currentWiki); if (e.CommandName == "PagesRebuild") { // Clear the pages search index for the current wiki SearchClass.ClearIndex(currentWiki); IPagesStorageProviderV40 pagesProvider = Collectors.CollectorsBox.PagesProviderCollector.GetProvider(e.CommandArgument as string, currentWiki); // Index all pages of the wiki List <NamespaceInfo> namespaces = new List <NamespaceInfo>(pagesProvider.GetNamespaces()); namespaces.Add(null); foreach (NamespaceInfo nspace in namespaces) { // Index pages of the namespace PageContent[] pages = pagesProvider.GetPages(nspace); foreach (PageContent page in pages) { // Index page SearchClass.IndexPage(page); // Index page messages Message[] messages = pagesProvider.GetMessages(page.FullName); foreach (Message message in messages) { SearchClass.IndexMessage(message, page); // Search for replies Message[] replies = message.Replies; foreach (Message reply in replies) { // Index reply SearchClass.IndexMessage(reply, page); } } } } } else if (e.CommandName == "FilesRebuild") { // Clear the files search index for the current wiki SearchClass.ClearFilesIndex(currentWiki); IFilesStorageProviderV40 filesProvider = Collectors.CollectorsBox.FilesProviderCollector.GetProvider(e.CommandArgument as string, currentWiki); // Index all files of the wiki // 1. List all directories (add the root directory: null) // 2. List all files in each directory // 3. Index each file List <string> directories = new List <string>(filesProvider.ListDirectories(null)); directories.Add(null); foreach (string directory in directories) { string[] files = filesProvider.ListFiles(directory); foreach (string file in files) { byte[] fileContent; using (MemoryStream stream = new MemoryStream()) { filesProvider.RetrieveFile(file, stream); fileContent = new byte[stream.Length]; stream.Seek(0, SeekOrigin.Begin); stream.Read(fileContent, 0, (int)stream.Length); } // Index the file string tempDir = Path.Combine(Environment.GetEnvironmentVariable("TEMP"), Guid.NewGuid().ToString()); if (!Directory.Exists(tempDir)) { Directory.CreateDirectory(tempDir); } string tempFile = Path.Combine(tempDir, file.Substring(file.LastIndexOf('/') + 1)); using (FileStream writer = File.Create(tempFile)) { writer.Write(fileContent, 0, fileContent.Length); } SearchClass.IndexFile(filesProvider.GetType().FullName + "|" + file, tempFile, currentWiki); Directory.Delete(tempDir, true); } } // Index all attachment of the wiki string[] pagesWithAttachments = filesProvider.GetPagesWithAttachments(); foreach (string page in pagesWithAttachments) { string[] attachments = filesProvider.ListPageAttachments(page); foreach (string attachment in attachments) { byte[] fileContent; using (MemoryStream stream = new MemoryStream()) { filesProvider.RetrievePageAttachment(page, attachment, stream); fileContent = new byte[stream.Length]; stream.Seek(0, SeekOrigin.Begin); stream.Read(fileContent, 0, (int)stream.Length); } // Index the attached file string tempDir = Path.Combine(Environment.GetEnvironmentVariable("TEMP"), Guid.NewGuid().ToString()); if (!Directory.Exists(tempDir)) { Directory.CreateDirectory(tempDir); } string tempFile = Path.Combine(tempDir, attachment); using (FileStream writer = File.Create(tempFile)) { writer.Write(fileContent, 0, fileContent.Length); } SearchClass.IndexPageAttachment(attachment, tempFile, Pages.FindPage(currentWiki, page)); Directory.Delete(tempDir, true); } } } Log.LogEntry("Index rebuild completed for " + e.CommandArgument as string, EntryType.General, SessionFacade.GetCurrentUsername(), currentWiki); }
/// <summary> /// Initializes a new instance of the <b>NavigationPath</b> class. /// </summary> /// <param name="fullName">The Full Name of the Navigation Path.</param> /// <param name="provider">The Provider</param> public NavigationPath(string fullName, IPagesStorageProviderV40 provider) { NameTools.ExpandFullName(fullName, out nspace, out name); this.provider = provider; pages = new string[0]; }
protected void btnSave_Click(object sender, EventArgs e) { bool wasVisible = pnlPageName.Visible; pnlPageName.Visible = true; if (!wasVisible && Settings.GetAutoGeneratePageNames(currentWiki) && txtName.Enabled) { txtName.Text = GenerateAutoName(txtTitle.Text); } txtName.Text = txtName.Text.Trim(); Page.Validate("nametitle"); Page.Validate("captcha"); if (!Page.IsValid) { if (!rfvTitle.IsValid || !rfvName.IsValid || !cvName1.IsValid || !cvName2.IsValid) { pnlPageName.Visible = true; pnlManualName.Visible = false; } return; } pnlPageName.Visible = wasVisible; // Check permissions if (currentPage == null) { // Check permissions for creating new pages if (!canCreateNewPages) { UrlTools.Redirect("AccessDenied.aspx"); } } else { // Check permissions for editing current page if (!canEdit && !canEditWithApproval) { UrlTools.Redirect("AccessDenied.aspx"); } } chkMinorChange.Visible = true; chkSaveAsDraft.Visible = true; // Verify edit with approval if (!canEdit && canEditWithApproval) { chkSaveAsDraft.Checked = true; } // Check for scripts (Administrators can always add SCRIPT tags) if (!SessionFacade.GetCurrentGroupNames(currentWiki).Contains(Settings.GetAdministratorsGroup(currentWiki)) && !Settings.GetScriptTagsAllowed(currentWiki)) { Regex r = new Regex(@"\<script.*?\>", RegexOptions.Compiled | RegexOptions.IgnoreCase); if (r.Match(editor.GetContent()).Success) { lblResult.Text = @"<span style=""color: #FF0000;"">" + Properties.Messages.ScriptDetected + "</span>"; return; } } bool redirect = true; if (sender == btnSaveAndContinue) { redirect = false; } lblResult.Text = ""; lblResult.CssClass = ""; string username = ""; if (SessionFacade.LoginKey == null) { username = Request.UserHostAddress; } else { username = SessionFacade.CurrentUsername; } IPagesStorageProviderV40 provider = FindAppropriateProvider(); // Create list of selected categories List <CategoryInfo> categories = new List <CategoryInfo>(); for (int i = 0; i < lstCategories.Items.Count; i++) { if (lstCategories.Items[i].Selected) { CategoryInfo cat = Pages.FindCategory(currentWiki, lstCategories.Items[i].Value); // Sanity check if (cat.Provider == provider) { categories.Add(cat); } } } txtComment.Text = txtComment.Text.Trim(); txtDescription.Text = txtDescription.Text.Trim(); SaveMode saveMode = SaveMode.Backup; if (chkSaveAsDraft.Checked) { saveMode = SaveMode.Draft; } if (chkMinorChange.Checked) { saveMode = SaveMode.Normal; } if (txtName.Enabled) { // Find page, if inexistent create it Log.LogEntry("Page update requested for " + txtName.Text, EntryType.General, username, currentWiki); string nspace = DetectNamespaceInfo() != null?DetectNamespaceInfo().Name : null; PageContent pg = Pages.FindPage(NameTools.GetFullName(DetectNamespace(), txtName.Text), provider); if (pg == null) { saveMode = SaveMode.Normal; pg = Pages.SetPageContent(currentWiki, nspace, txtName.Text, provider, txtTitle.Text, username, DateTime.UtcNow, txtComment.Text, editor.GetContent(), GetKeywords(), txtDescription.Text, saveMode); attachmentManager.CurrentPage = pg; } else { Pages.SetPageContent(currentWiki, nspace, txtName.Text, provider, txtTitle.Text, username, DateTime.UtcNow, txtComment.Text, editor.GetContent(), GetKeywords(), txtDescription.Text, saveMode); } // Save categories binding Pages.Rebind(pg, categories.ToArray()); // If not a draft, remove page draft if (saveMode != SaveMode.Draft) { Pages.DeleteDraft(pg.FullName, pg.Provider); isDraft = false; } else { isDraft = true; } ManageDraft(); lblResult.CssClass = "resultok"; lblResult.Text = Properties.Messages.PageSaved; // This is a new page, so only who has page management permissions can execute this code // No notification must be sent for drafts awaiting approval if (redirect) { Collisions.CancelEditingSession(pg, username); string target = UrlTools.BuildUrl(currentWiki, Tools.UrlEncode(txtName.Text), GlobalSettings.PageExtension, "?NoRedirect=1"); UrlTools.Redirect(target); } else { // Disable PageName, because the name cannot be changed anymore txtName.Enabled = false; pnlManualName.Visible = false; } } else { // Used for redirecting to a specific section after editing it string anchor = ""; if (currentPage == null) { currentPage = Pages.FindPage(currentWiki, NameTools.GetFullName(DetectNamespace(), txtName.Text)); } // Save data Log.LogEntry("Page update requested for " + currentPage.FullName, EntryType.General, username, currentWiki); if (!isDraft && currentSection != -1) { StringBuilder sb = new StringBuilder(currentPage.Content.Length); int start, len; ExtractSection(currentPage.Content, currentSection, out start, out len, out anchor); if (start > 0) { sb.Append(currentPage.Content.Substring(0, start)); } sb.Append(editor.GetContent()); if (start + len < currentPage.Content.Length - 1) { sb.Append(currentPage.Content.Substring(start + len)); } Pages.SetPageContent(currentPage.Provider.CurrentWiki, NameTools.GetNamespace(currentPage.FullName), NameTools.GetLocalName(currentPage.FullName), txtTitle.Text, username, DateTime.UtcNow, txtComment.Text, sb.ToString(), GetKeywords(), txtDescription.Text, saveMode); } else { Pages.SetPageContent(currentPage.Provider.CurrentWiki, NameTools.GetNamespace(currentPage.FullName), NameTools.GetLocalName(currentPage.FullName), txtTitle.Text, username, DateTime.UtcNow, txtComment.Text, editor.GetContent(), GetKeywords(), txtDescription.Text, saveMode); } // Save Categories binding Pages.Rebind(currentPage, categories.ToArray()); // If not a draft, remove page draft if (saveMode != SaveMode.Draft) { Pages.DeleteDraft(currentPage.FullName, currentPage.Provider); isDraft = false; } else { isDraft = true; } ManageDraft(); lblResult.CssClass = "resultok"; lblResult.Text = Properties.Messages.PageSaved; // This code is executed every time the page is saved, even when "Save & Continue" is clicked // This causes a draft approval notification to be sent multiple times for the same page, // but this is the only solution because the user might navigate away from the page after // clicking "Save & Continue" but not "Save" or "Cancel" - in other words, it is necessary // to take every chance to send a notification because no more chances might be available if (!canEdit && canEditWithApproval) { Pages.SendEmailNotificationForDraft(currentPage.Provider.CurrentWiki, currentPage.FullName, txtTitle.Text, txtComment.Text, username); } if (redirect) { Collisions.CancelEditingSession(currentPage, username); string target = UrlTools.BuildUrl(currentWiki, Tools.UrlEncode(currentPage.FullName), GlobalSettings.PageExtension, "?NoRedirect=1", (!string.IsNullOrEmpty(anchor) ? ("#" + anchor + "_" + currentSection.ToString()) : "")); UrlTools.Redirect(target); } } }
/// <summary> /// Initializes a new instance of the <see cref="T:ContentTemplate" /> class. /// </summary> /// <param name="name">The name of the template.</param> /// <param name="content">The content of the template.</param> /// <param name="provider">The provider handling the template.</param> public ContentTemplate(string name, string content, IPagesStorageProviderV40 provider) { this.name = name; this.content = content; this.provider = provider; }
/// <summary> /// Initializes a new instance of the <see cref="T:EmptyPageContent"/> class. /// </summary> /// <param name="pageFullName">The page the content refers to.</param> /// <param name="provider">The Pages Storage Provider that manages this Page.</param> /// <param name="creationDateTime">The Page creation Date/Time.</param> public EmptyPageContent(string pageFullName, IPagesStorageProviderV40 provider, DateTime creationDateTime) : base(pageFullName, provider, creationDateTime, "", "", DateTime.MinValue, "", "", null, "") { }
/// <summary> /// Adds a new Navigation Path. /// </summary> /// <param name="wiki">The wiki.</param> /// <param name="nspace">The target namespace (<c>null</c> for the root).</param> /// <param name="name">The Name.</param> /// <param name="pages">The full name of the pages.</param> /// <param name="provider">The Provider to use for the new Navigation Path, or <c>null</c> for the default provider.</param> /// <returns>True if the Path is added successfully.</returns> public static bool AddNavigationPath(string wiki, NamespaceInfo nspace, string name, List <string> pages, IPagesStorageProviderV40 provider) { string namespaceName = nspace != null ? nspace.Name : null; string fullName = NameTools.GetFullName(namespaceName, name); if (Exists(wiki, fullName)) { return(false); } if (provider == null) { provider = Collectors.CollectorsBox.PagesProviderCollector.GetProvider(GlobalSettings.DefaultPagesProvider, wiki); } NavigationPath newPath = provider.AddNavigationPath(namespaceName, name, pages.ToArray()); if (newPath != null) { Log.LogEntry("Navigation Path " + fullName + " added", EntryType.General, Log.SystemUsername, wiki); } else { Log.LogEntry("Creation failed for Navigation Path " + fullName, EntryType.Error, Log.SystemUsername, wiki); } return(newPath != null); }
public void Init() { IPagesStorageProviderV40 prov = GetProvider(); Assert.IsNotNull(prov.Information, "Information should not be null"); }
/// <summary> /// Initializes a new instance of the <see cref="T:CategoryInfo" /> class. /// </summary> /// <param name="fullName">The Full Name of the Category.</param> /// <param name="provider">The Storage that manages the category.</param> public CategoryInfo(string fullName, IPagesStorageProviderV40 provider) { NameTools.ExpandFullName(fullName, out nspace, out name); this.provider = provider; }
/// <summary> /// Initializes a new instance of the <b>Snippet</b> class. /// </summary> /// <param name="name">The Name of the Snippet.</param> /// <param name="content">The Content of the Snippet.</param> /// <param name="provider">The Provider of the Snippet.</param> public Snippet(string name, string content, IPagesStorageProviderV40 provider) { this.name = name; this.content = content; this.provider = provider; }