Example #1
0
 public PageItem(PagesBrowseModule module, PageDefinition page, ModuleDefinition pageSettings)
 {
     Module         = module;
     PageEditModule = pageSettings;
     ObjectSupport.CopyData(page, this);
     Anonymous      = page.IsAuthorized_View_Anonymous();
     Users          = page.IsAuthorized_View_AnyUser();
     Editors        = page.IsAuthorized_View_Editor();
     Administrators = page.IsAuthorized_View_Administrator();
 }
Example #2
0
 public bool WantPage(PageDefinition page)
 {
     if (!page.WantSearch)
     {
         Logging.AddLog("No search keywords wanted for page {0}", page.Url);
         return(false);
     }
     if (!string.IsNullOrWhiteSpace(page.RedirectToPageUrl))   // only search pages that aren't redirected
     {
         Logging.AddLog("No search keywords for page {0} as it is redirected", page.Url);
         return(false);
     }
     if (!page.IsAuthorized_View_Anonymous() && !page.IsAuthorized_View_AnyUser())
     {
         Logging.AddLog("No search keywords for page {0} - neither Anonymous nor User role has access to the page", page.Url);
         return(false);
     }
     return(true);
 }
Example #3
0
 private void AddPage(List <PageBarInfo.PanelEntry> list, PageDefinition pageDef, bool popup)
 {
     if (pageDef != null && pageDef.IsAuthorized_View())
     {
         // If a page is authorized for anonymous but not users, we suppress it if we're Editor, Admin, Superuser, etc. to avoid cases where we
         // have 2 of the same pages, one for anonymous users, the other for logged on users.
         if (Manager.HaveUser && pageDef.IsAuthorized_View_Anonymous() && !pageDef.IsAuthorized_View_AnyUser())
         {
             return;
         }
         list.Add(new PageBarInfo.PanelEntry {
             Url      = pageDef.EvaluatedCanonicalUrl,
             Caption  = pageDef.Title,
             ToolTip  = pageDef.Description,
             ImageUrl = GetImage(pageDef),
             Popup    = popup
         });
     }
 }
Example #4
0
 private async Task SearchPageAsync(SearchWords searchWords, PageDefinition page)
 {
     if (!searchWords.WantPage(page))
     {
         return;
     }
     if (await searchWords.SetUrlAsync(page.Url, page.PageSecurity, page.Title, page.Description, page.Created, page.Updated, page.IsAuthorized_View_Anonymous(), page.IsAuthorized_View_AnyUser()))
     {
         searchWords.AddKeywords(page.Keywords);
         foreach (var m in page.ModuleDefinitions)
         {
             Guid             modGuid = m.ModuleGuid;
             ModuleDefinition mod     = null;
             try {
                 mod = await ModuleDefinition.LoadAsync(m.ModuleGuid);
             } catch (Exception ex) {
                 Logging.AddErrorLog("An error occurred retrieving module {0} in page {1}", m.ModuleGuid, page.Url, ex);
             }
             if (mod != null)
             {
                 SearchModule(searchWords, mod);
             }
         }
         await searchWords.SaveAsync();
     }
 }
Example #5
0
        // ISEARCHDYNAMICURLS
        // ISEARCHDYNAMICURLS
        // ISEARCHDYNAMICURLS

        public async Task KeywordsForDynamicUrlsAsync(ISearchWords searchWords)
        {
            using (this) {
                BlogConfigData config = await BlogConfigDataProvider.GetConfigAsync();

                List <DataProviderFilterInfo> filters = DataProviderFilterInfo.Join(null, new DataProviderFilterInfo {
                    Field = nameof(BlogEntry.Published), Operator = "==", Value = true
                });
                DataProviderGetRecords <BlogEntry> entries = await GetItemsAsync(0, 0, null, filters);

                foreach (BlogEntry entry in entries.Data)
                {
                    string url = await BlogConfigData.GetEntryCanonicalNameAsync(entry.Identity);

                    PageDefinition page = await PageDefinition.LoadFromUrlAsync(url);

                    if (page == null)
                    {
                        return;               // there is no such root page
                    }
                    if (!searchWords.WantPage(page))
                    {
                        return;
                    }

                    if (await searchWords.SetUrlAsync(url, page.PageSecurity, entry.Title, entry.DisplayableSummaryText, entry.DateCreated, entry.DateUpdated, page.IsAuthorized_View_Anonymous(), page.IsAuthorized_View_AnyUser()))
                    {
                        searchWords.AddObjectContents(entry);
                        using (BlogCommentDataProvider commentDP = new BlogCommentDataProvider(entry.Identity)) {
                            DataProviderGetRecords <BlogComment> comments = await commentDP.GetItemsAsync(0, 0, null, null);

                            foreach (BlogComment comment in comments.Data)
                            {
                                searchWords.AddObjectContents(comment);
                            }
                        }
                        await searchWords.SaveAsync();
                    }
                }
            }
        }