Exemplo n.º 1
0
        private void DeleteBtn_Click(Object sender, EventArgs e)
        {
            if (itemId != -1)
            {
                Link link = new Link(itemId);

                if (link.ModuleId != moduleId)
                {
                    SiteUtils.RedirectToAccessDeniedPage(this);
                    return;
                }

                link.ContentChanged += new ContentChangedEventHandler(linkItem_ContentChanged);
                link.Delete();
                CurrentPage.UpdateLastModifiedTime();
                //CacheHelper.TouchCacheDependencyFile(cacheDependencyKey);
                CacheHelper.ClearModuleCache(moduleId);
                SiteUtils.QueueIndexing();
            }

            if (hdnReturnUrl.Value.Length > 0)
            {
                WebUtils.SetupRedirect(this, hdnReturnUrl.Value);
                return;
            }

            WebUtils.SetupRedirect(this, SiteUtils.GetCurrentPageUrl());
        }
Exemplo n.º 2
0
        void rptLinks_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            if ((e.CommandSource is Button) && (e.CommandName.Equals("delete")))
            {
                int itemId = Convert.ToInt32(e.CommandArgument);
                Link link = new Link(itemId);
                link.ContentChanged += new ContentChangedEventHandler(link_ContentChanged);
                link.Delete();

                //CacheHelper.TouchCacheDependencyFile(cacheDependencyKey);
                CacheHelper.ClearModuleCache(link.ModuleId);

                WebUtils.SetupRedirect(this, Page.Request.RawUrl);

            }
        }
        private static void IndexItem(Link link)
        {
            if (WebConfigSettings.DisableSearchIndex) { return; }

            SiteSettings siteSettings = CacheHelper.GetCurrentSiteSettings();
            if (siteSettings == null)
            {
                if (log.IsErrorEnabled)
                {
                    log.Error("Link object passed to Links.IndexItem was null");
                }

                return;
            }

            if (link == null) return;

            Guid linksFeatureGuid = new Guid("74bdbcc2-0e79-47ff-bcd4-a159270bf36e");
            ModuleDefinition linksFeature = new ModuleDefinition(linksFeatureGuid);
            Module module = new Module(link.ModuleId);

            // get list of pages where this module is published
            List<PageModule> pageModules
                = PageModule.GetPageModulesByModule(link.ModuleId);

            foreach (PageModule pageModule in pageModules)
            {
                PageSettings pageSettings
                    = new PageSettings(
                    siteSettings.SiteId,
                    pageModule.PageId);

                //don't index pending/unpublished pages
                if (pageSettings.IsPending) { continue; }

                mojoPortal.SearchIndex.IndexItem indexItem = new mojoPortal.SearchIndex.IndexItem();
                indexItem.SiteId = siteSettings.SiteId;
                indexItem.PageId = pageSettings.PageId;
                indexItem.PageName = pageSettings.PageName;
                indexItem.ViewRoles = pageSettings.AuthorizedRoles;
                indexItem.ModuleViewRoles = module.ViewRoles;
                indexItem.FeatureId = linksFeatureGuid.ToString();
                indexItem.FeatureName = linksFeature.FeatureName;
                indexItem.FeatureResourceFile = linksFeature.ResourceFile;

                indexItem.ItemId = link.ItemId;
                indexItem.ModuleId = link.ModuleId;
                indexItem.ModuleTitle = module.ModuleTitle;
                indexItem.Title = link.Title;
                indexItem.Content = link.Description;
                indexItem.CreatedUtc = link.CreatedDate;
                indexItem.LastModUtc = link.CreatedDate;
                indexItem.PublishBeginDate = pageModule.PublishBeginDate;
                indexItem.PublishEndDate = pageModule.PublishEndDate;

                mojoPortal.SearchIndex.IndexHelper.RebuildIndex(indexItem);
            }

            if (debugLog) log.Debug("Indexed " + link.Title);
        }
Exemplo n.º 4
0
        private void UpdateBtn_Click(Object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                Link linkItem = new Link(itemId);
                if ((linkItem.ItemId > -1) && (linkItem.ModuleId != moduleId))
                {
                    SiteUtils.RedirectToAccessDeniedPage(this);
                    return;
                }

                linkItem.ContentChanged += new ContentChangedEventHandler(linkItem_ContentChanged);

                Module module = new Module(moduleId);
                linkItem.ModuleGuid = module.ModuleGuid;
                linkItem.ModuleId = this.moduleId;
                linkItem.Title = this.txtTitle.Text;
                if (chkUseNewWindow.Checked)
                {
                    linkItem.Target = "_blank";
                }
                else
                {
                    linkItem.Target = String.Empty;
                }

                linkItem.Description = edDescription.Text;

                if ((!ddProtocol.Visible) || (txtUrl.Text.StartsWith("/")))
                {
                    linkItem.Url = txtUrl.Text;
                }
                else
                {
                    linkItem.Url = ddProtocol.SelectedValue + txtUrl.Text.Replace("https://", String.Empty).Replace("http://", String.Empty).Replace("~/", String.Empty);
                }

                linkItem.ViewOrder = int.Parse(this.txtViewOrder.Text);
                SiteUser linkUser = SiteUtils.GetCurrentSiteUser();
                if (linkUser != null)
                {
                    linkItem.CreatedByUser = linkUser.UserId;
                    linkItem.UserGuid = linkUser.UserGuid;
                }

                if(linkItem.Save())
                {
                    CurrentPage.UpdateLastModifiedTime();
                    //CacheHelper.TouchCacheDependencyFile(cacheDependencyKey);
                    CacheHelper.ClearModuleCache(linkItem.ModuleId);
                    SiteUtils.QueueIndexing();
                    if (hdnReturnUrl.Value.Length > 0)
                    {
                        WebUtils.SetupRedirect(this, hdnReturnUrl.Value);
                        return;
                    }

                    WebUtils.SetupRedirect(this, SiteUtils.GetCurrentPageUrl());
                }

            }
        }
Exemplo n.º 5
0
        private void PopulateControls()
        {
            if (itemId > -1)
            {
                Link linkItem = new Link(itemId);
                if (linkItem.ModuleId != moduleId)
                {
                    SiteUtils.RedirectToAccessDeniedPage(this);
                    return;
                }

                txtTitle.Text = linkItem.Title;

                edDescription.Text = linkItem.Description;

                //String linkProtocol = "http://";
                //if (linkItem.Url.StartsWith("https://"))
                //{
                //    linkProtocol = "https://";
                //}
                //if (linkItem.Url.StartsWith("~/"))
                //{
                //    linkProtocol = "~/";
                //}

                //ListItem listItem = ddProtocol.Items.FindByValue(linkProtocol);
                //if (listItem != null)
                //{
                //    ddProtocol.ClearSelection();
                //    listItem.Selected = true;
                //}

                //txtUrl.Text = linkItem.Url.Replace(linkProtocol, String.Empty);
                txtUrl.Text = linkItem.Url;
                txtViewOrder.Text = linkItem.ViewOrder.ToString();

                if (linkItem.Target == "_blank")
                {
                    chkUseNewWindow.Checked = true;
                }

                SiteUser linkUser = new SiteUser(siteSettings, linkItem.CreatedByUser);

            }
            else
            {
                deleteButton.Visible = false;
            }
        }