Ejemplo n.º 1
0
        protected void btnCreateNewContent_Click(object sender, EventArgs e)
        {
            Page.Validate("contentcatalog");
            if (!Page.IsValid) { return; }

            int moduleDefID = int.Parse(ddModuleType.SelectedItem.Value, CultureInfo.InvariantCulture);
            ModuleDefinition moduleDefinition = new ModuleDefinition(moduleDefID);

            Module module = new Module();
            module.ModuleTitle = this.txtModuleTitle.Text;
            module.ModuleDefId = moduleDefID;
            module.FeatureGuid = moduleDefinition.FeatureGuid;
            module.Icon = moduleDefinition.Icon;
            module.SiteId = siteSettings.SiteId;
            module.SiteGuid = siteSettings.SiteGuid;
            module.CreatedByUserId = SiteUtils.GetCurrentSiteUser().UserId;
            module.CacheTime = moduleDefinition.DefaultCacheTime;
            module.ShowTitle = WebConfigSettings.ShowModuleTitlesByDefault;
            module.HeadElement = WebConfigSettings.ModuleTitleTag;
            module.Save();
            WebUtils.SetupRedirect(this, SiteRoot
                + "/Admin/ContentManagerPreview.aspx?mid="
                + module.ModuleId.ToInvariantString()
                );
        }
Ejemplo n.º 2
0
        private void btnCreateNewContent_Click(Object sender, EventArgs e)
        {
            Page.Validate("pagelayout");
            if (!Page.IsValid) { return; }

            int moduleDefID = int.Parse(moduleType.SelectedItem.Value);
            ModuleDefinition moduleDefinition = new ModuleDefinition(moduleDefID);

            Module m = new Module();
            m.SiteId = siteSettings.SiteId;
            m.SiteGuid = siteSettings.SiteGuid;
            m.ModuleDefId = moduleDefID;
            m.FeatureGuid = moduleDefinition.FeatureGuid;
            m.Icon = moduleDefinition.Icon;
            m.CacheTime = moduleDefinition.DefaultCacheTime;
            m.PageId = pageID;
            m.ModuleTitle = moduleTitle.Text;
            m.PaneName = ddPaneNames.SelectedValue;
            //m.AuthorizedEditRoles = "Admins";
            SiteUser currentUser = SiteUtils.GetCurrentSiteUser();
            if (currentUser != null)
            {
                m.CreatedByUserId = currentUser.UserId;
            }
            m.ShowTitle = WebConfigSettings.ShowModuleTitlesByDefault;
            m.HeadElement = WebConfigSettings.ModuleTitleTag;
            m.Save();

            CurrentPage.RefreshModules();

            ArrayList modules = GetPaneModules(m.PaneName);
            OrderModules(modules);

            foreach (Module item in modules)
            {
                Module.UpdateModuleOrder(pageID, item.ModuleId, item.ModuleOrder, m.PaneName);
            }

            //WebUtils.SetupRedirect(this, Request.RawUrl);
            //return;

            CurrentPage.RefreshModules();
            BindPanes();
            upLayout.Update();
        }
Ejemplo n.º 3
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            Page.Validate("webstore");
            if ((Page.IsValid)&&(store != null))
            {

                SiteUser siteUser = SiteUtils.GetCurrentSiteUser();

                if (store.SiteGuid == Guid.Empty)
                {
                    store.SiteGuid = siteSettings.SiteGuid;
                }
                if (store.ModuleId == -1)
                {
                    store.ModuleId = moduleId;
                }

                Module module = new Module(moduleId);
                module.ModuleTitle = txtName.Text;
                module.Save();

                store.Name = txtName.Text;
                store.Description = edDescription.Text;
                store.OwnerName = txtOwnerName.Text;
                store.OwnerEmail = txtOwnerEmail.Text;
                store.SalesEmail = txtSalesEmail.Text;
                store.SupportEmail = txtSupportEmail.Text;
                store.EmailFrom = txtEmailFrom.Text;
                store.OrderBccEmail = txtOrderBCCEmail.Text;
                store.Phone = txtPhone.Text;
                store.Fax = txtFax.Text;
                store.Address = txtAddress.Text;
                store.City = txtCity.Text;

                if (!String.IsNullOrEmpty(ddZoneGuid.SelectedValue))
                {
                    store.ZoneGuid = new Guid(ddZoneGuid.SelectedValue);
                }

                store.PostalCode = txtPostalCode.Text;

                if (!String.IsNullOrEmpty(ddCountryGuid.SelectedValue))
                {
                    store.CountryGuid = new Guid(ddCountryGuid.SelectedValue);
                }

                store.IsClosed = chkIsClosed.Checked;
                store.ClosedMessage = edClosedMessage.Text;

                if (store.Guid == Guid.Empty)
                {
                    store.Created = DateTime.UtcNow;
                    store.CreatedBy = siteUser.UserGuid;

                }

                store.Save();

                List<TaxClass> taxClasses = TaxClass.GetList(siteSettings.SiteGuid);

                if (taxClasses.Count == 0)
                {
                    TaxClass taxClass = new TaxClass();
                    taxClass.SiteGuid = siteSettings.SiteGuid;
                    taxClass.Title = WebStoreResources.TaxClassTaxable;
                    taxClass.Description = WebStoreResources.TaxClassTaxable;
                    taxClass.Save();

                    taxClass = new TaxClass();
                    taxClass.SiteGuid = siteSettings.SiteGuid;
                    taxClass.Title = WebStoreResources.TaxClassNotTaxable;
                    taxClass.Description = WebStoreResources.TaxClassNotTaxable;
                    taxClass.Save();

                }

                List<FullfillDownloadTerms> downloadTerms = FullfillDownloadTerms.GetList(store.Guid);
                if (downloadTerms.Count == 0)
                {
                    if(currentUser == null)currentUser = SiteUtils.GetCurrentSiteUser();
                    if (currentUser != null)
                    {
                        FullfillDownloadTerms term = new FullfillDownloadTerms();
                        term.Name = WebStoreResources.DownloadUnlimited;
                        term.Description = WebStoreResources.DownloadUnlimited;
                        term.CreatedBy = currentUser.UserGuid;
                        term.CreatedFromIP = SiteUtils.GetIP4Address();
                        term.StoreGuid = store.Guid;
                        term.Save();

                    }

                }

                WebUtils.SetupRedirect(this, Request.RawUrl);

            }
        }
        void btnCreateNewContent_Click(object sender, EventArgs e)
        {
            Page.Validate("contentwizard");
            if (!Page.IsValid) { return; }

            int moduleDefID = int.Parse(moduleType.SelectedItem.Value);
            ModuleDefinition moduleDefinition = new ModuleDefinition(moduleDefID);
            PageSettings CurrentPage = CacheHelper.GetCurrentPage();

            Module m = new Module();
            m.SiteId = siteSettings.SiteId;
            m.SiteGuid = siteSettings.SiteGuid;
            m.ModuleDefId = moduleDefID;
            m.FeatureGuid = moduleDefinition.FeatureGuid;
            m.Icon = moduleDefinition.Icon;
            m.CacheTime = moduleDefinition.DefaultCacheTime;
            m.PageId = CurrentPage.PageId;
            m.ModuleTitle = moduleTitle.Text;
            m.PaneName = "contentpane";
            //m.AuthorizedEditRoles = "Admins";
            SiteUser currentUser = SiteUtils.GetCurrentSiteUser();
            if (currentUser != null)
            {
                m.CreatedByUserId = currentUser.UserId;
            }
            m.ShowTitle = WebConfigSettings.ShowModuleTitlesByDefault;
            m.HeadElement = WebConfigSettings.ModuleTitleTag;
            m.Save();

            WebUtils.SetupRedirect(this, Request.RawUrl);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// wp.newPage method
        /// </summary>
        /// <param name="blogId">blogID in string format</param>
        /// <param name="userName">login username</param>
        /// <param name="password">login password</param>
        /// <param name="mwaPage">The mwa page.</param>
        /// <param name="publish">if set to <c>true</c> [publish].</param>
        /// <returns>The new page.</returns>
        internal string NewPage(string blogId, string userName, string password, MWAPage mwaPage, bool publish)
        {
            PageSettings page = new PageSettings();
            PageSettings parentPage = null;

            Guid parentGuid = Guid.Empty;
            if ((mwaPage.pageParentID != null)&&(mwaPage.pageParentID.Length == 36))
            {
                parentGuid = new Guid(mwaPage.pageParentID);
            }

            if (parentGuid == Guid.Empty) //root level page
            {
                if (!UserCanCreateRootLevelPages())
                {
                    throw new MetaWeblogException("11", MetaweblogResources.NotAllowedToCreateRootPages);
                }

                // TODO: promote these to site settings?
                //page.AuthorizedRoles = WebConfigSettings.DefaultPageRoles;
                //page.EditRoles = WebConfigSettings.DefaultRootPageEditRoles;
                //page.CreateChildPageRoles = WebConfigSettings.DefaultRootPageCreateChildPageRoles;

                page.AuthorizedRoles = siteSettings.DefaultRootPageViewRoles;
                page.EditRoles = siteSettings.DefaultRootPageEditRoles;
                page.CreateChildPageRoles = siteSettings.DefaultRootPageCreateChildPageRoles;
            }
            else
            {
                parentPage = new PageSettings(parentGuid);

                if (parentPage.PageId == -1)
                {
                    throw new MetaWeblogException("11", MetaweblogResources.ParentPageNotFound);
                }

                if (parentPage.SiteId != siteSettings.SiteId)
                {
                    throw new MetaWeblogException("11", MetaweblogResources.ParentPageNotFound);
                }

                if (!UserCanCreateChildPages(parentPage))
                {
                    throw new MetaWeblogException("11", MetaweblogResources.NotAllowedParentPage);
                }
            }

            if (parentPage != null)
            {
                page.ParentId = parentPage.PageId;
                page.ParentGuid = parentPage.PageGuid;
                page.PageOrder = PageSettings.GetNextPageOrder(siteSettings.SiteId, parentPage.PageId);

                // by default inherit settings from parent
                page.AuthorizedRoles = parentPage.AuthorizedRoles;
                page.EditRoles = parentPage.EditRoles;
                page.DraftEditOnlyRoles = parentPage.DraftEditOnlyRoles;
                page.CreateChildPageRoles = parentPage.CreateChildPageRoles;
                page.CreateChildDraftRoles = parentPage.CreateChildDraftRoles;
            }

            if ((mwaPage.pageOrder != null) && (mwaPage.pageOrder.Length > 0))
            {
                 page.PageOrder = Convert.ToInt32(mwaPage.pageOrder);
            }

            page.SiteId = siteSettings.SiteId;
            page.SiteGuid = siteSettings.SiteGuid;
            page.IsPending = !publish;

            page.PageName = mwaPage.title;
            //page.PageTitle = mwaPage.title; // this was the override page title it should not be set here
            if ((mwaPage.mt_keywords != null) && (mwaPage.mt_keywords.Length > 0))
            {
                page.PageMetaKeyWords = mwaPage.mt_keywords;
            }

            if (WebConfigSettings.AutoGeneratePageMetaDescriptionForMetaweblogNewPages)
            {
                page.PageMetaDescription = UIHelper.CreateExcerpt(mwaPage.description, WebConfigSettings.MetaweblogGeneratedMetaDescriptionMaxLength);
            }

            //if (WebConfigSettings.ShowUseUrlSettingInPageSettings)
            //{

            //}

            string friendlyUrlString = SiteUtils.SuggestFriendlyUrl(page.PageName, siteSettings);
            page.Url = "~/" + friendlyUrlString;
            page.UseUrl = true;

            switch (mwaPage.commentPolicy)
            {
                // open
                case "1":
                    // if the post was previously closed to comments
                    // re-open it using the default allowed days
                    page.EnableComments = true;

                    break;

                //closed
                case "0":
                case "2":
                default:
                    page.EnableComments = false;
                    break;

            }

            // I'm not sure we should support the page created event handler here, people may do redirects there
            // that would interupt our next steps
            // maybe need a config setting to decide

            // page.PageCreated += new PageCreatedEventHandler(PageCreated);

            page.Save();

            FriendlyUrl newFriendlyUrl = new FriendlyUrl();
            newFriendlyUrl.SiteId = siteSettings.SiteId;
            newFriendlyUrl.SiteGuid = siteSettings.SiteGuid;
            newFriendlyUrl.PageGuid = page.PageGuid;
            newFriendlyUrl.Url = friendlyUrlString;
            newFriendlyUrl.RealUrl = "~/Default.aspx?pageid=" + page.PageId.ToInvariantString();
            newFriendlyUrl.Save();

            // create html module in center pane
            ModuleDefinition moduleDefinition = new ModuleDefinition(HtmlContent.FeatureGuid);
            Module m = new Module();
            m.SiteId = siteSettings.SiteId;
            m.SiteGuid = siteSettings.SiteGuid;
            m.ModuleDefId = moduleDefinition.ModuleDefId;
            m.FeatureGuid = moduleDefinition.FeatureGuid;
            m.Icon = moduleDefinition.Icon;
            m.CacheTime = moduleDefinition.DefaultCacheTime;
            m.PageId = page.PageId;
            m.ModuleTitle = page.PageTitle;
            m.PaneName = "contentpane";
            m.CreatedByUserId = siteUser.UserId;
            m.ShowTitle = WebConfigSettings.ShowModuleTitlesByDefault;
            m.HeadElement = WebConfigSettings.ModuleTitleTag;
            m.ModuleOrder = 1;
            m.Save();

            HtmlRepository repository = new HtmlRepository();
            HtmlContent html = new HtmlContent();
            html.ModuleId = m.ModuleId;
            html.ModuleGuid = m.ModuleGuid;
            html.Body = mwaPage.description;
            //html.CreatedBy = siteUser.UserId;
            html.UserGuid = siteUser.UserGuid;
            html.CreatedDate = DateTime.UtcNow;
            html.LastModUserGuid = siteUser.UserGuid;
            html.LastModUtc = DateTime.UtcNow;

            html.ContentChanged += new ContentChangedEventHandler(html_ContentChanged);

            repository.Save(html);

            mojoPortal.SearchIndex.IndexHelper.RebuildPageIndexAsync(page);
            SiteUtils.QueueIndexing();

            CacheHelper.ResetSiteMapCache(siteSettings.SiteId);

            return page.PageGuid.ToString();
        }