コード例 #1
0
ファイル: StaticPageOps.cs プロジェクト: JakeSaliga/TechBlog
 public void SaveStaticPage(StaticPage staticPage)
 {
     if (staticPage.DateOfPageCreation > new DateTime(01 / 01 / 2000))
     {
         _repo.SaveStaticPage(staticPage);
     }
 }
コード例 #2
0
        public ActionResult AdminEditStaticPage(StaticPageSearchVM vm)
        {
            if (ModelState.IsValid)
            {
                var manager = new StaticManger();
                var tagm    = new TagManager();
                var page    = new StaticPage();

                var pagetags = new List <Tag>();
                page.Name        = vm.Page.Name;
                page.Tag         = vm.Page.Tag;
                page.Category    = vm.Page.Category;
                page.Body        = vm.Page.Body;
                page.Name        = vm.Page.Name;
                page.Approved    = Approved.Yes;
                page.DateCreated = DateTime.Today;
                page.Id          = vm.Page.Id;
                foreach (var id in vm.SelectedTagIds)
                {
                    var tag = tagm.GetTagById(id);
                    pagetags.Add(tag);
                }
                page.Tag = pagetags;

                manager.EditStaticPage(page);
                return(RedirectToAction("ManageStaticPages"));
            }
            return(View("AdminEditStaticPage"));
        }
コード例 #3
0
        public ActionResult CreateStaticPages(StaticPageVM model)
        {
            var staticPage = new StaticPage();

            staticPage = model.NewPage;
            staticPage.StaticPageContent = model.HtmlContent;
            if (model.NewPage.Status == null)
            {
                staticPage.Status = new Status()
                {
                    StatusID = 1
                };
            }
            else
            {
                staticPage.Status.StatusID = model.NewPage.Status.StatusID;
            }
            var ops = OperationsFactory.CreateStaticPageOps();

            ops.SaveStaticPage(staticPage);



            return(RedirectToAction("Index", "Home"));
        }
コード例 #4
0
ファイル: RepositoryTests.cs プロジェクト: deanzel/Blog
        public void EditStaticPageTest()
        {
            StaticPage staticPage = new StaticPage()
            {
                StaticPageId = 2,
                User         = new ApplicationUser()
                {
                    Id = "74e60034-4ccf-4421-96cd-847d1aa2908a"
                },
                StaticPageTitle = "About 2SB&D!",
                StaticPageText  = "<p>\"Two Sweet Boys and Dean\" is a start-up dating service based in Akron, Ohio.</p>" +
                                  "<p> Dean is a struggling DJ with a hidden passion for Bootstrap.Tim is a sweet boy who dreams of one day moving to the big city...of Seattle.Patrick is also a sweet boy who can't resist the \"back-end\".</p>" +
                                  "<p> Together, we are here to help them find the \"coding partners\" of their dreams.</p>" +
                                  "<p> There you go... </p>",
                Status      = PageStatus.Approved,
                TimeCreated = DateTime.Parse("2015-12-07 21:20:10")
            };

            var actual = _repo.EditStaticPage(staticPage);

            Assert.AreEqual(staticPage.StaticPageId, actual.StaticPageId);
            Assert.AreEqual(staticPage.User.Id, actual.User.Id);
            Assert.AreEqual(staticPage.StaticPageTitle, actual.StaticPageTitle);
            Assert.AreEqual(staticPage.StaticPageText, actual.StaticPageText);
            Assert.AreEqual(staticPage.Status, actual.Status);
            Assert.AreEqual(staticPage.TimeCreated, actual.TimeCreated);
        }
コード例 #5
0
        //[ValidateAntiForgeryToken]
        public ActionResult Edit(int id, StaticPage collection)
        {
            try
            {
                StaticPage sp = db.StaticPages.Single(x => x.StaticPageId == id);
                sp.PageTitle   = collection.PageTitle;
                sp.PageContent = collection.PageContent;
                sp.CreatedDate = collection.CreatedDate;
                //sp.UpdatedDate = collection.UpdatedDate;
                db.SaveChanges();

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
            //if (ModelState.IsValid)
            //{
            //    db.Entry(staticPage).State = EntityState.Modified;
            //    db.SaveChanges();
            //    return RedirectToAction("Index");
            //}
            //return View(staticPage);
        }
コード例 #6
0
        public StaticPage UpdateStaticPageStatus(int staticPageId, PageStatus updateStaticPageStatus)
        {
            StaticPage staticPage = new StaticPage();

            using (SqlConnection cn = new SqlConnection(Settings.ConnectionString))
            {
                var cmd = new SqlCommand();
                cmd.CommandText = "UpdateStaticPageStatus";
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@StaticPageID", staticPageId);
                cmd.Parameters.AddWithValue("@Status", (int)updateStaticPageStatus);
                cmd.Connection = cn;
                cn.Open();

                using (SqlDataReader dr = cmd.ExecuteReader())
                {
                    while (dr.Read())
                    {
                        staticPage = PopulateStaticPageFromReader(dr);
                    }
                }
            }

            return(staticPage);
        }
コード例 #7
0
ファイル: Tests.cs プロジェクト: Derrek88/Toon-Saloon
        public void addStaticPageCheckTheDelete()
        {
            var repo = StaticFactory.CreateStaticPageRepository();

            StaticPage page = new StaticPage();

            page.Name        = "Anime";
            page.Body        = "Anime stuff";
            page.Category    = Category.Anime;
            page.Approved    = Approved.Yes;
            page.DateCreated = DateTime.Today;

            repo.AddStaticPage(page);
            List <StaticPage> pages = repo.GetAllPages();
            StaticPage        check = pages.Last();

            Assert.AreEqual("Anime", check.Name);
            Assert.AreEqual("Anime stuff", check.Body);
            //Assert.AreEqual(Anime, check.Category);
            //Assert.AreEqual("Yes", check.Approved);

            repo.RemoveStaticPage(page);

            Assert.IsNull(repo.GetPageByID(page.Id));
        }
コード例 #8
0
ファイル: Update.cs プロジェクト: anti0xidant/Fitlosophi
        public void EditPage(StaticPage staticPage)
        {
            using (SqlConnection cn = new SqlConnection(Settings.ConnectionString))
            {
                var p = new DynamicParameters();

                try
                {
                    p.Add("StaticPageID", staticPage.StaticPageID);
                    p.Add("ButtonName", staticPage.ButtonName);
                    p.Add("UserID", staticPage.UserID);
                    p.Add("Body", staticPage.Body);

                    cn.Execute("EditPage", p, commandType: CommandType.StoredProcedure);
                }
                //catch (Exception e)
                //{
                //    // Write failure to database
                //    var ep = new DynamicParameters();

                //    ep.Add("ExceptionType", e.GetType());
                //    ep.Add("ExceptionMessage", e.Message);
                //    cn.Execute("AddError", ep, commandType: CommandType.StoredProcedure);
                //}
                finally
                {
                    cn.Close();
                }
            }
        }
コード例 #9
0
        public EditStaticPageResponse UpdateStaticPage(StaticPage page)
        {
            var response = new EditStaticPageResponse();

            if (page == null)
            {
                response.Success = false;
                response.Message = $"{page} does not exist.";
            }
            else
            {
                response.Page = repo.UpdateStaticPage(page);

                if (response.Page == null)
                {
                    response.Success = false;
                    response.Message = $"{response.Page} does not exist.";
                }
                else
                {
                    response.Success = true;
                }
            }

            return(response);
        }
コード例 #10
0
        public ActionResult AdminDeleteStaticPage(StaticPage page)
        {
            var manager = new StaticManger();

            manager.RemoveStaticPage(page);
            return(RedirectToAction("ManageStaticPages"));
        }
コード例 #11
0
        public ActionResult EditSingleStaticPage(int id)
        {
            var        ops           = new BlogPostOperations();
            StaticPage newStaticPage = ops.GetStaticPageByID(id);

            return(View("EditSingleStaticPage", newStaticPage));
        }
コード例 #12
0
        public ActionResult DeleteStaticPage(StaticPage page)
        {
            var repo = RepositoryFactory.CreateRepository();

            repo.DeleteStaticPage(page.PageId);
            return(RedirectToAction("ManageStaticPages", "Admin"));
        }
コード例 #13
0
 public ActionResult AddStatic(StaticPage page)
 {
     var brepo = new BlogPostRepo();
     brepo.AddStaticPage(page);
     ViewBag.Message = "A new static page has been added.";
     return View("Success");
 }
コード例 #14
0
        public ActionResult AddStaticPage()
        {
            StaticPage model = new StaticPage();

            model.UserId = User.Identity.GetUserId();
            return(View(model));
        }
コード例 #15
0
ファイル: StaticPageController.cs プロジェクト: 09liweis/OSMH
        public ActionResult TogglePublish(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            StaticPage staticPage = db.StaticPages.Find(id);

            if (staticPage == null)
            {
                return(HttpNotFound());
            }
            if (staticPage.PageStatus == StaticPage.StaticPageStatus.published)
            {
                staticPage.PageStatus = StaticPage.StaticPageStatus.unpublished;
            }
            else if (staticPage.PageStatus == StaticPage.StaticPageStatus.unpublished)
            {
                staticPage.PageStatus = StaticPage.StaticPageStatus.published;
            }
            if (ModelState.IsValid)
            {
                db.Entry(staticPage).State = EntityState.Modified;
                db.SaveChanges();
            }
            return(RedirectToAction("Index"));
        }
コード例 #16
0
        public void RemoveStaticPage(StaticPage pageToRemove)
        {
            var repo = StaticFactory.CreateStaticPageRepository();

            repo.DeleteTagStaticBridgeTable(pageToRemove);
            repo.RemoveStaticPage(pageToRemove);
        }
コード例 #17
0
    protected void Page_Load(object sender, EventArgs e)
    {
        int pageId = Page.Request["staticpageid"].TryParseInt();

        page = StaticPageService.GetStaticPage(pageId);
        if (pageId == 0 || page == null || (page != null && !page.Enabled))
        {
            Error404();
            return;
        }
        SetMeta(page.Meta, page.PageName);


        sbShareButtons.Visible = AdvantShop.Configuration.SettingsDesign.EnableSocialShareButtons;

        ucBreadCrumbs.Items = StaticPageService.GetParentStaticPages(pageId).Select(StaticPageService.GetStaticPage).Select(stPage => new BreadCrumbs
        {
            Name = stPage.PageName,
            Url  = UrlService.GetLink(ParamType.StaticPage, stPage.UrlPath, stPage.StaticPageId)
        }).Reverse().ToList();

        ucBreadCrumbs.Items.Insert(0, new BreadCrumbs
        {
            Name = Resource.Client_MasterPage_MainPage,
            Url  = UrlService.GetAbsoluteLink("/")
        });
    }
コード例 #18
0
        public StaticPage GetPageByID(int staticPageID)
        {
            using (SqlConnection cn = new SqlConnection(Settings.ConnectionString))
            {
                var page = new StaticPage();

                try
                {
                    var p = new DynamicParameters();
                    p.Add("@StaticPageID", staticPageID);
                    page =
                        cn.Query <StaticPage>("GetPageByID", p, commandType: CommandType.StoredProcedure).FirstOrDefault();
                }
                //catch (Exception e)
                //{
                //    // Write failure to database
                //    var ep = new DynamicParameters();

                //    ep.Add("ExceptionType", e.GetType());
                //    ep.Add("ExceptionMessage", e.Message);
                //    cn.Execute("AddError", ep, commandType: CommandType.StoredProcedure);
                //}
                finally
                {
                    cn.Close();
                }

                return(page);
            }
        }
コード例 #19
0
ファイル: homeController.cs プロジェクト: Kingefosa/a-webshop
        public ActionResult terms_of_purchase()
        {
            // Get the current domain and the static page
            Domain currentDomain = Tools.GetCurrentDomain();
            StaticPage staticPage = StaticPage.GetOneByConnectionId(2, currentDomain.front_end_language);
            staticPage = staticPage != null ? staticPage : new StaticPage();

            // Get the translated texts
            KeyStringList tt = StaticText.GetAll(currentDomain.front_end_language, "id", "ASC");

            // Create the bread crumb list
            List<BreadCrumb> breadCrumbs = new List<BreadCrumb>(2);
            breadCrumbs.Add(new BreadCrumb(tt.Get("start_page"), "/"));
            breadCrumbs.Add(new BreadCrumb(staticPage.link_name, "/home/terms_of_purchase"));

            // Set form values
            ViewBag.BreadCrumbs = breadCrumbs;
            ViewBag.CurrentCategory = new Category();
            ViewBag.TranslatedTexts = tt;
            ViewBag.CurrentDomain = currentDomain;
            ViewBag.CurrentLanguage = Language.GetOneById(currentDomain.front_end_language);
            ViewBag.StaticPage = staticPage;
            ViewBag.PricesIncludesVat = Session["PricesIncludesVat"] != null ? Convert.ToBoolean(Session["PricesIncludesVat"]) : currentDomain.prices_includes_vat;
            ViewBag.CultureInfo = Tools.GetCultureInfo(ViewBag.CurrentLanguage);

            // Return the view
            return currentDomain.custom_theme_id == 0 ? View() : View("/Views/theme/terms_of_purchase.cshtml");

        } // End of the terms_of_purchase method
コード例 #20
0
        private static IQueryable <StaticPage> GenerateStaticPages()
        {
            List <StaticPage> pages = new List <StaticPage>();
            bool navToggle          = true;

            StaticPage h = new StaticPage
            {
                PageTitle = "Home"
            };

            pages.Add(h);

            for (int i = 1; i < 10; i++)
            {
                StaticPage sp = new StaticPage
                {
                    PageTitle       = $"Static Page No {i}",
                    FullContent     = $"Sample Content for sample page no {i}",
                    InMainNav       = navToggle,
                    MainNavPriority = 10 - i
                };
                navToggle = !navToggle;
                pages.Add(sp);
            }
            return(pages.AsQueryable());
        }
コード例 #21
0
ファイル: PageBuilder.cs プロジェクト: keyzf/IEManageSystem
        public void Build()
        {
            var permission = _context.Permissions.FirstOrDefault(e => e.Name == "Permission1");

            var contentPage = new ContentPage("ContentPage1Name")
            {
                DisplayName = "测试内容页",
                Description = "用于测试的数据",
                ContentPagePermissionCollection = new ContentPagePermissionCollection()
                {
                    IsEnableQueryPermission = true,
                    ContentPagePermissions  = new List <ContentPagePermission>()
                    {
                        new ContentPagePermission()
                        {
                            Permission = permission, IsManage = false
                        },
                        new ContentPagePermission()
                        {
                            Permission = permission, IsManage = true
                        }
                    },
                }
            };

            _context.Pages.Add(contentPage);

            _context.DefaultComponentDatas.AddRange(new List <DefaultComponentData>()
            {
                new DefaultComponentData()
                {
                    Sign        = "ContentPage1_Component1Sign",
                    SingleDatas = new List <SingleComponentData>()
                    {
                        new SingleComponentData()
                        {
                            Name = "PageData1_DefaultComponentData1_SingleComponentData1Name"
                        },
                        new SingleComponentData()
                        {
                            Name = "PageData1_DefaultComponentData1_SingleComponentData2Name"
                        }
                    },
                    Page = contentPage
                },
                new DefaultComponentData()
                {
                    Sign = "ContentPage1_Component2Sign", Page = contentPage
                }
            });

            var staticPage = new StaticPage("StaticPageName")
            {
                DisplayName = "测试内容页",
                Description = "用于测试的数据",
            };

            _context.Pages.Add(staticPage);
        }
コード例 #22
0
ファイル: StaticPageController.cs プロジェクト: 09liweis/OSMH
        public ActionResult DeleteConfirmed(int id)
        {
            StaticPage staticPage = db.StaticPages.Find(id);

            db.StaticPages.Remove(staticPage);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #23
0
 public void SaveNewStaticPage(StaticPage staticPage)
 {
     using (var repository = new ApplicationDbContext())
     {
         repository.StaticPages.Add(staticPage);
         repository.SaveChanges();
     }
 }
コード例 #24
0
 public StaticPage GetStaticPageById(int pageId)
 {
     using (var repository = new ApplicationDbContext())
     {
         StaticPage page = repository.StaticPages.FirstOrDefault(x => x.StaticPageId == pageId);
         return(page);
     }
 }
コード例 #25
0
        public ActionResult AddStaticPages(StaticPage newStaticPage)
        {
            var repo = new BlogPostRepository();

            repo.AddNewStaticPage(newStaticPage);

            return(RedirectToAction("Index", "Home"));
        }
コード例 #26
0
        public ActionResult EditStaticPage(StaticPage editedStaticPage)
        {
            var ops = new BlogPostOperations();

            ops.EditStaticPage(editedStaticPage);
            //what view should be returned?
            return(RedirectToAction("Index", "Home"));
        }
コード例 #27
0
        public void EditStaticPage(StaticPage pageToEdit)
        {
            var page = _pages.FirstOrDefault(p => p.Id == pageToEdit.Id);

            _pages.Remove(page);
            page = pageToEdit;
            _pages.Add(page);
        }
コード例 #28
0
        public ActionResult EditAbout(StaticPage page, string id)
        {
            page.StaticPageId = int.Parse(id);
            StaticPgManager manager = new StaticPgManager();

            manager.Edit(page);
            return(RedirectToAction("About", "Home"));
        }
コード例 #29
0
        public StaticPage get_by_id(Int32 id = 0, Int32 languageId = 0)
        {
            // Create the post to return
            StaticPage post = StaticPage.GetOneById(id, languageId);

            // Return the post
            return(post);
        } // End of the get_by_id method
コード例 #30
0
        public ActionResult EditDisclaimer(StaticPage page, string disclaimerId)
        {
            page.StaticPageId = int.Parse(disclaimerId);
            StaticPgManager manager = new StaticPgManager();

            manager.Edit(page);
            return(RedirectToAction("Disclaimer", "Home"));
        }
コード例 #31
0
        public List <StaticPage> get_all_active(Int32 languageId = 0, string sortField = "", string sortOrder = "")
        {
            // Create the list to return
            List <StaticPage> posts = StaticPage.GetAllActive(languageId, sortField, sortOrder);

            // Return the list
            return(posts);
        } // End of the get_all_active method
コード例 #32
0
 public ActionResult Edit(StaticPage page)
 {
     var brepo = new BlogPostRepo();
     brepo.UpdatePage(page);
     ViewBag.Message = "The static page has been edited successfully.";
     return View("Success");
     //return RedirectToAction("ManagePages", "Admin");
 }
コード例 #33
0
        public void Update(int id, StaticPage entity)
        {
            var existing = GetById(id);

            existing.Title = entity.Title;
            existing.Content = entity.Content;
            existing.Key = entity.Key;
            existing.Section = entity.Section;
            existing.Account = entity.Account;
            existing.IsManual = entity.IsManual;
            existing.IsSystem = entity.IsSystem;
        }
コード例 #34
0
        public HttpResponseMessage update(StaticPage post, Int32 languageId = 0)
        {
            // Check for errors
            if (post == null)
            {
                return Request.CreateResponse<string>(HttpStatusCode.BadRequest, "The post is null");
            }
            else if (Language.MasterPostExists(languageId) == false)
            {
                return Request.CreateResponse<string>(HttpStatusCode.BadRequest, "The language does not exist");
            }

            // Make sure that the data is valid
            post.link_name = AnnytabDataValidation.TruncateString(post.link_name, 100);
            post.title = AnnytabDataValidation.TruncateString(post.title, 200);
            post.meta_description = AnnytabDataValidation.TruncateString(post.meta_description, 200);
            post.meta_keywords = AnnytabDataValidation.TruncateString(post.meta_keywords, 200);
            post.meta_robots = AnnytabDataValidation.TruncateString(post.meta_robots, 20);
            post.page_name = AnnytabDataValidation.TruncateString(post.page_name, 100);

            // Get the saved post
            StaticPage savedPost = StaticPage.GetOneById(post.id, languageId);

            // Check if the post exists
            if (savedPost == null)
            {
                return Request.CreateResponse<string>(HttpStatusCode.BadRequest, "The record does not exist");
            }

            // Get a static page on page name
            StaticPage staticPageOnPageName = StaticPage.GetOneByPageName(post.page_name, languageId);

            // Check if the page name exists
            if (staticPageOnPageName != null && post.id != staticPageOnPageName.id)
            {
                return Request.CreateResponse<string>(HttpStatusCode.BadRequest, "The page name is not unique for the language");
            }

            // Update the post
            StaticPage.UpdateMasterPost(post);
            StaticPage.UpdateLanguagePost(post, languageId);

            // Return the success response
            return Request.CreateResponse<string>(HttpStatusCode.OK, "The update was successful");

        } // End of the update method
コード例 #35
0
ファイル: BlogPostRepo.cs プロジェクト: alanhoo/BlogCMS_B
        public void AddStaticPage(StaticPage p)
        {
            var pr = new DynamicParameters();
            pr.Add("Content", p.Content);
            pr.Add("LinkText", p.LinkText);
            pr.Add("Title", p.Title);
            pr.Add("ImageURL", p.ImageURL);

            var sqlQuery = "Insert Into Static (TheContent, Title, LinkText, ImageURL, Active) " +
                        "VALUES (@Content, @Title, @LinkText, @ImageURL,'1');";

            using (SqlConnection cn = new SqlConnection(Connection.ConnectionString))
            {
                cn.Execute(sqlQuery, pr);
                //cn.Query<int>(sqlQuery, pr);
            }
        }
コード例 #36
0
ファイル: StaticPage.cs プロジェクト: raphaelivo/a-webshop
    } // End of the constructor

    #endregion

    #region Insert methods

    /// <summary>
    /// Add one master page post
    /// </summary>
    /// <param name="post">A reference to a static page post</param>
    public static long AddMasterPost(StaticPage post)
    {
        // Create the long to return
        long idOfInsert = 0;

        // Create the connection and the sql statement
        string connection = Tools.GetConnectionString();
        string sql = "INSERT INTO dbo.static_pages (connected_to_page, meta_robots) "
            + "VALUES (@connected_to_page, @meta_robots);SELECT SCOPE_IDENTITY();";

        // The using block is used to call dispose automatically even if there are an exception.
        using (SqlConnection cn = new SqlConnection(connection))
        {
            // The using block is used to call dispose automatically even if there are an exception.
            using (SqlCommand cmd = new SqlCommand(sql, cn))
            {
                // Add parameters
                cmd.Parameters.AddWithValue("@connected_to_page", post.connected_to_page);
                cmd.Parameters.AddWithValue("@meta_robots", post.meta_robots);

                // The Try/Catch/Finally statement is used to handle unusual exceptions in the code to
                // avoid having our application crash in such cases
                try
                {
                    // Open the connection
                    cn.Open();

                    // Execute the insert
                    idOfInsert = Convert.ToInt64(cmd.ExecuteScalar());

                }
                catch (Exception e)
                {
                    throw e;
                }
            }
        }

        // Return the id of the inserted item
        return idOfInsert;

    } // End of the AddMasterPost method
コード例 #37
0
    protected void Page_Load(object sender, EventArgs e)
    {
        var sp1 = new StaticPage();
        var cache = new CacheManager<StaticPage>("PigeonCms.StaticPage", this.CacheDuration);
        if (cache.IsEmpty(this.PageName))
        {
            if (!StaticPagesManager.ExistPage(this.PageName))
                this.PageName = StaticPagesManager.DEFAULT_PAGE_NAME;
            sp1 = new StaticPagesManager().GetStaticPageByName(this.PageName);
            cache.Insert(this.PageName, sp1);
        }
        else
        {
            sp1 = cache.GetValue(this.PageName);
        }

        if (sp1.ShowPageTitle) LitPageTitle.Text = sp1.PageTitle + "<br />";
        LitPageContent.Text = "";
        if (!sp1.IsPageContentTranslated)
        {
            //LitPageContent.Text += "<span class='textNote'>" + Resources.PublicLabels.LblTextNotTranslated + "</span><br />";
        }
        LitPageContent.Text += sp1.PageContentParsed;
    }
コード例 #38
0
ファイル: StaticPage.cs プロジェクト: raphaelivo/a-webshop
    } // End of the GetOneByConnectionId method

    /// <summary>
    /// Get one static page based on page name
    /// </summary>
    /// <param name="pageName">A page name</param>
    /// <param name="languageId">A language id</param>
    /// <returns>A reference to a static page post</returns>
    public static StaticPage GetOneByPageName(string pageName, Int32 languageId)
    {
        // Create the post to return
        StaticPage post = null;

        // Create the connection and the sql statement
        string connection = Tools.GetConnectionString();
        string sql = "SELECT * FROM dbo.static_pages_detail AS D INNER JOIN dbo.static_pages AS P ON D.static_page_id = P.id " 
            + "WHERE D.page_name = @page_name AND D.language_id = @language_id;";

        // The using block is used to call dispose automatically even if there is a exception
        using (SqlConnection cn = new SqlConnection(connection))
        {
            // The using block is used to call dispose automatically even if there is a exception
            using (SqlCommand cmd = new SqlCommand(sql, cn))
            {
                // Add a parameters
                cmd.Parameters.AddWithValue("@page_name", pageName);
                cmd.Parameters.AddWithValue("@language_id", languageId);

                // Create a reader
                SqlDataReader reader = null;

                // The Try/Catch/Finally statement is used to handle unusual exceptions in the code to
                // avoid having our application crash in such cases.
                try
                {
                    // Open the connection.
                    cn.Open();

                    // Fill the reader with one row of data.
                    reader = cmd.ExecuteReader();

                    // Loop through the reader as long as there is something to read and add values
                    while (reader.Read())
                    {
                        post = new StaticPage(reader);
                    }
                }
                catch (Exception e)
                {
                    throw e;
                }
                finally
                {
                    // Call Close when done reading to avoid memory leakage.
                    if (reader != null)
                        reader.Close();
                }
            }
        }

        // Return the post
        return post;

    } // End of the GetOneByPageName method
コード例 #39
0
ファイル: StaticPage.cs プロジェクト: raphaelivo/a-webshop
    } // End of the UpdateMasterPost method

    /// <summary>
    /// Update a language static page post
    /// </summary>
    /// <param name="post">A reference to a static page post</param>
    /// <param name="languageId">A language id</param>
    public static void UpdateLanguagePost(StaticPage post, int languageId)
    {
        // Create the connection and the sql statement
        string connection = Tools.GetConnectionString();
        string sql = "UPDATE dbo.static_pages_detail SET link_name = @link_name, title = @title, main_content = @main_content, "
            + "meta_description = @meta_description, meta_keywords = @meta_keywords, page_name = @page_name, "
            + "inactive = @inactive WHERE static_page_id = @static_page_id AND language_id = @language_id;";

        // The using block is used to call dispose automatically even if there are an exception.
        using (SqlConnection cn = new SqlConnection(connection))
        {
            // The using block is used to call dispose automatically even if there are an exception.
            using (SqlCommand cmd = new SqlCommand(sql, cn))
            {
                // Add parameters
                cmd.Parameters.AddWithValue("@static_page_id", post.id);
                cmd.Parameters.AddWithValue("@language_id", languageId);
                cmd.Parameters.AddWithValue("@link_name", post.link_name);
                cmd.Parameters.AddWithValue("@title", post.title);
                cmd.Parameters.AddWithValue("@main_content", post.main_content);
                cmd.Parameters.AddWithValue("@meta_description", post.meta_description);
                cmd.Parameters.AddWithValue("@meta_keywords", post.meta_keywords);
                cmd.Parameters.AddWithValue("@page_name", post.page_name);
                cmd.Parameters.AddWithValue("@inactive", post.inactive);

                // The Try/Catch/Finally statement is used to handle unusual exceptions in the code to
                // avoid having our application crash in such cases.
                try
                {
                    // Open the connection.
                    cn.Open();

                    // Execute the update
                    cmd.ExecuteNonQuery();

                }
                catch (Exception e)
                {
                    throw e;
                }
            }
        }

    } // End of the UpdateLanguagePost method
コード例 #40
0
ファイル: StaticPage.cs プロジェクト: raphaelivo/a-webshop
    } // End of the AddLanguagePost method

    #endregion

    #region Update methods

    /// <summary>
    /// Update a master static page post
    /// </summary>
    /// <param name="post">A reference to a static page post</param>
    public static void UpdateMasterPost(StaticPage post)
    {
        // Create the connection and the sql statement
        string connection = Tools.GetConnectionString();
        string sql = "UPDATE dbo.static_pages SET connected_to_page = @connected_to_page, meta_robots = @meta_robots " 
            + "WHERE id = @id;";

        // The using block is used to call dispose automatically even if there are an exception.
        using (SqlConnection cn = new SqlConnection(connection))
        {
            // The using block is used to call dispose automatically even if there are an exception.
            using (SqlCommand cmd = new SqlCommand(sql, cn))
            {
                // Add parameters
                cmd.Parameters.AddWithValue("@id", post.id);
                cmd.Parameters.AddWithValue("@connected_to_page", post.connected_to_page);
                cmd.Parameters.AddWithValue("@meta_robots", post.meta_robots);

                // The Try/Catch/Finally statement is used to handle unusual exceptions in the code to
                // avoid having our application crash in such cases.
                try
                {
                    // Open the connection.
                    cn.Open();

                    // Execute the update
                    cmd.ExecuteNonQuery();

                }
                catch (Exception e)
                {
                    throw e;
                }
            }
        }

    } // End of the UpdateMasterPost method
コード例 #41
0
ファイル: StaticPage.cs プロジェクト: raphaelivo/a-webshop
    } // End of the AddMasterPost method

    /// <summary>
    /// Add one language static page post
    /// </summary>
    /// <param name="post">A reference to a static page post</param>
    /// <param name="languageId">A language id</param>
    public static void AddLanguagePost(StaticPage post, Int32 languageId)
    {

        // Create the connection and the sql statement
        string connection = Tools.GetConnectionString();
        string sql = "INSERT INTO dbo.static_pages_detail (static_page_id, language_id, link_name, title, main_content, " 
            + "meta_description, meta_keywords, page_name, inactive) "
            + "VALUES (@static_page_id, @language_id, @link_name, @title, @main_content, @meta_description, " 
            + "@meta_keywords, @page_name, @inactive);";

        // The using block is used to call dispose automatically even if there are an exception.
        using (SqlConnection cn = new SqlConnection(connection))
        {
            // The using block is used to call dispose automatically even if there are an exception.
            using (SqlCommand cmd = new SqlCommand(sql, cn))
            {
                // Add parameters
                cmd.Parameters.AddWithValue("@static_page_id", post.id);
                cmd.Parameters.AddWithValue("@language_id", languageId);
                cmd.Parameters.AddWithValue("@link_name", post.link_name);
                cmd.Parameters.AddWithValue("@title", post.title);
                cmd.Parameters.AddWithValue("@main_content", post.main_content);
                cmd.Parameters.AddWithValue("@meta_description", post.meta_description);
                cmd.Parameters.AddWithValue("@meta_keywords", post.meta_keywords);
                cmd.Parameters.AddWithValue("@page_name", post.page_name);
                cmd.Parameters.AddWithValue("@inactive", post.inactive);

                // The Try/Catch/Finally statement is used to handle unusual exceptions in the code to
                // avoid having our application crash in such cases
                try
                {
                    // Open the connection
                    cn.Open();

                    // Execute the insert
                    cmd.ExecuteNonQuery();

                }
                catch (Exception e)
                {
                    throw e;
                }
            }
        }

    } // End of the AddLanguagePost method
コード例 #42
0
ファイル: Default.ascx.cs プロジェクト: liqueflies/pigeoncms
    private bool saveForm()
    {
        bool res = false;
        LblErr.Text = "";
        LblOk.Text = "";

        try
        {
            StaticPage p1 = new StaticPage();
            if (TxtId.Text == string.Empty)
            {
                form2obj(p1);
                p1 = new StaticPagesManager().Insert(p1);
            }
            else
            {
                p1 = new StaticPagesManager().GetStaticPageByName(TxtPageName.Text);//precarico i campi esistenti e nn gestiti dal form
                form2obj(p1);
                new StaticPagesManager().Update(p1);
            }
            new CacheManager<StaticPage>("PigeonCms.StaticPage").Remove(p1.PageName);

            Grid1.DataBind();
            LblOk.Text = RenderSuccess(Utility.GetLabel("RECORD_SAVED_MSG"));
            res = true;
        }
        catch (Exception e1)
        {
            LblErr.Text = RenderError(Utility.GetLabel("RECORD_ERR_MSG") + "<br />" + e1.ToString());
        }
        finally
        {
        }
        return res;
    }
コード例 #43
0
ファイル: Default.ascx.cs プロジェクト: liqueflies/pigeoncms
    private void obj2form(StaticPage page1)
    {
        TxtPageName.Text = page1.PageName;
        ChkVisibile.Checked = page1.Visible;
        ChkShowPageTitle.Checked = page1.ShowPageTitle;
        foreach (KeyValuePair<string, string> item in Config.CultureList)
        {
            string sTitleTranslation = "";
            TextBox t1 = new TextBox();
            t1 = (TextBox)PanelPageTitle.FindControl("TxtPageTitle" + item.Value);
            page1.PageTitleTranslations.TryGetValue(item.Key, out sTitleTranslation);
            t1.Text = sTitleTranslation;

            string sPageContentTraslation = "";
            var html1 = new Controls_ContentEditorControl();
            html1 = Utility.FindControlRecursive<Controls_ContentEditorControl>(this, "HtmlText" + item.Value);
            page1.PageContentTranslations.TryGetValue(item.Key, out sPageContentTraslation);
            html1.Text = sPageContentTraslation;
        }
    }
コード例 #44
0
ファイル: Default.ascx.cs プロジェクト: liqueflies/pigeoncms
    private void form2obj(StaticPage page1)
    {
        page1.PageName = TxtPageName.Text;
        page1.Visible = ChkVisibile.Checked;
        page1.ShowPageTitle = ChkShowPageTitle.Checked;
        page1.PageTitleTranslations.Clear();
        page1.PageContentTranslations.Clear();
        foreach (KeyValuePair<string, string> item in Config.CultureList)
        {
            TextBox t1 = new TextBox();
            t1 = (TextBox)PanelPageTitle.FindControl("TxtPageTitle" + item.Value);
            page1.PageTitleTranslations.Add(item.Key, t1.Text);

            var html1 = new Controls_ContentEditorControl();
            html1 = Utility.FindControlRecursive<Controls_ContentEditorControl>(this, "HtmlText"+item.Value);
            page1.PageContentTranslations.Add(item.Key, html1.Text);
        }
    }
コード例 #45
0
 public void Add(StaticPage entity)
 {
     Context.StaticPageSet.AddObject(entity);
 }
コード例 #46
0
ファイル: BlogPostRepo.cs プロジェクト: alanhoo/BlogCMS_B
        public void UpdatePage(StaticPage p)
        {
            var pr = new DynamicParameters();
            pr.Add("StaticPageID", p.StaticPageID);
            pr.Add("Content", p.Content);
            pr.Add("LinkText", p.LinkText);
            pr.Add("Title", p.Title);
            pr.Add("ImageURL", p.ImageURL);
            pr.Add("Active", p.Active);

            var sqlQuery = "Update Static " +
                     "Set TheContent = @Content, Title = @Title, LinkText = @LinkText, ImageURL = @ImageURL, Active = @Active " +
                     "WHERE StaticPageID = @StaticPageID; ";

            using (SqlConnection cn = new SqlConnection(Connection.ConnectionString))
            {
                cn.Execute(sqlQuery, pr);
                //cn.Query<int>(sqlQuery, pr);
            }
        }
コード例 #47
0
ファイル: BlogPostRepo.cs プロジェクト: alanhoo/BlogCMS_B
        public StaticPage GetPageById(int id)
        {
            var page = new StaticPage();

            StringBuilder query = new StringBuilder();

            var pr = new DynamicParameters();
            pr.Add("StaticPageID", id);

            query.Append("select StaticPageID, TheContent as Content, Title, LinkText, ImageURL, Active ");
            query.Append("from Static ");
            query.Append("WHERE StaticPageID = @StaticPageID; ");

            using (SqlConnection cn = new SqlConnection(Connection.ConnectionString))
            {
                page = cn.Query<StaticPage>(query.ToString(), pr).
                    First();
            }

            return page;
        }
コード例 #48
0
    private void sendNotificationEmail(string username, string pwd, string toEmail, string userEmail)
    {
        var emailPage = new StaticPage();

        if (string.IsNullOrEmpty(base.NotificationEmailPageName))
            return;

        try
        {
            emailPage = new StaticPagesManager().GetStaticPageByName(base.NotificationEmailPageName);
            if (string.IsNullOrEmpty(emailPage.PageName))
                throw new ArgumentException("invalid NotificationEmailPageName");

            var smtp = new SmtpClient(AppSettingsManager.GetValue("SmtpServer"));
            using (smtp as IDisposable)
            {
                smtp.EnableSsl = false;
                if (!string.IsNullOrEmpty(AppSettingsManager.GetValue("SmtpUseSSL")))
                {
                    bool useSsl = false;
                    bool.TryParse(AppSettingsManager.GetValue("SmtpUseSSL"), out useSsl);
                    smtp.EnableSsl = useSsl;
                }
                if (!string.IsNullOrEmpty(AppSettingsManager.GetValue("SmtpPort")))
                {
                    int port = 25;
                    int.TryParse(AppSettingsManager.GetValue("SmtpPort"), out port);
                    smtp.Port = port;
                }
                if (!string.IsNullOrEmpty(AppSettingsManager.GetValue("SmtpUser")))
                {
                    smtp.Credentials = new NetworkCredential(
                        AppSettingsManager.GetValue("SmtpUser"),
                        AppSettingsManager.GetValue("SmtpPassword"));
                }

                MailMessage mail1 = new MailMessage();
                mail1.From = new MailAddress(AppSettingsManager.GetValue("EmailSender"));
                mail1.To.Add(toEmail);
                //mail1.Bcc = this.EmailAddressBcc;   //debug controllo formato email
                mail1.Subject = emailPage.PageTitle;
                mail1.IsBodyHtml = true;
                //available placeholders [[NewUsername]],[[NewUserPassword]],[[NewUserEmail]]
                mail1.Body = emailPage.PageContent
                    .Replace("[[NewUsername]]", username)
                    .Replace("[[NewUserPassword]]", pwd)
                    .Replace("[[NewUserEmail]]", userEmail);

                smtp.Send(mail1);
            }
        }
        catch (Exception e1)
        {
            LogProvider.Write(this.BaseModule, "sendNotificationEmail("+ username +",,"+ toEmail +","+ userEmail +") failed: " +e1.ToString(), TracerItemType.Error);
            Tracer.Log("sendNotificationEmail() failed " + e1.ToString(), TracerItemType.Error);
        }
    }
コード例 #49
0
        public ActionResult translate(FormCollection collection)
        {
            // Get the current domain
            Domain currentDomain = Tools.GetCurrentDomain();
            ViewBag.CurrentDomain = currentDomain;

            // Get all the form values
            Int32 translationLanguageId = Convert.ToInt32(collection["selectLanguage"]);
            Int32 id = Convert.ToInt32(collection["hiddenStaticPageId"]);
            string title = collection["txtTranslatedTitle"];
            string linkname = collection["txtTranslatedLinkname"];
            string description = collection["txtTranslatedDescription"];
            string metadescription = collection["txtTranslatedMetadescription"];
            string metakeywords = collection["txtTranslatedMetakeywords"];
            string pagename = collection["txtTranslatedPagename"];
            bool inactive = Convert.ToBoolean(collection["cbInactive"]);
            string returnUrl = collection["returnUrl"];
            string keywords = collection["txtSearch"];
            Int32 currentPage = Convert.ToInt32(collection["hiddenPage"]);

            // Get query parameters
            ViewBag.QueryParams = new QueryParams(returnUrl);

            // Check if the administrator is authorized
            if (Administrator.IsAuthorized(new string[] { "Administrator", "Editor", "Translator" }) == true)
            {
                ViewBag.AdminSession = true;
            }
            else if (Administrator.IsAuthorized(Administrator.GetAllAdminRoles()) == true)
            {
                ViewBag.AdminSession = true;
                ViewBag.AdminErrorCode = 1;
                ViewBag.TranslatedTexts = StaticText.GetAll(currentDomain.back_end_language, "id", "ASC");
                return View("index");
            }
            else
            {
                // Redirect the user to the start page
                return RedirectToAction("index", "admin_login");
            }

            // Get the standard static page
            StaticPage standardStaticPage = StaticPage.GetOneById(id, currentDomain.back_end_language);

            // Get translated texts
            KeyStringList tt = StaticText.GetAll(currentDomain.back_end_language, "id", "ASC");

            // Create the translated static page
            StaticPage translatedStaticPage = new StaticPage();
            translatedStaticPage.id = id;
            translatedStaticPage.title = title;
            translatedStaticPage.link_name = linkname;
            translatedStaticPage.main_content = description;
            translatedStaticPage.meta_description = metadescription;
            translatedStaticPage.meta_keywords = metakeywords;
            translatedStaticPage.page_name = pagename;
            translatedStaticPage.inactive = inactive;

            // Check if the user wants to do a search
            if (collection["btnSearch"] != null)
            {
                // Set form values
                ViewBag.Keywords = keywords;
                ViewBag.CurrentPage = 1;
                ViewBag.LanguageId = translationLanguageId;
                ViewBag.Languages = Language.GetAll(currentDomain.back_end_language, "name", "ASC");
                ViewBag.StandardStaticPage = standardStaticPage;
                ViewBag.TranslatedStaticPage = translatedStaticPage;
                ViewBag.TranslatedTexts = tt;
                ViewBag.ReturnUrl = returnUrl;

                // Return the translate view
                return View("translate");
            }

            // Check if the user wants to do a search
            if (collection["btnPreviousPage"] != null)
            {
                // Set form values
                ViewBag.Keywords = keywords;
                ViewBag.CurrentPage = currentPage - 1;
                ViewBag.LanguageId = translationLanguageId;
                ViewBag.Languages = Language.GetAll(currentDomain.back_end_language, "name", "ASC");
                ViewBag.StandardStaticPage = standardStaticPage;
                ViewBag.TranslatedStaticPage = translatedStaticPage;
                ViewBag.TranslatedTexts = tt;
                ViewBag.ReturnUrl = returnUrl;

                // Return the translate view
                return View("translate");
            }

            // Check if the user wants to do a search
            if (collection["btnNextPage"] != null)
            {
                // Set form values
                ViewBag.Keywords = keywords;
                ViewBag.CurrentPage = currentPage + 1;
                ViewBag.LanguageId = translationLanguageId;
                ViewBag.Languages = Language.GetAll(currentDomain.back_end_language, "name", "ASC");
                ViewBag.StandardStaticPage = standardStaticPage;
                ViewBag.TranslatedStaticPage = translatedStaticPage;
                ViewBag.TranslatedTexts = tt;
                ViewBag.ReturnUrl = returnUrl;

                // Return the translate view
                return View("translate");
            }

            // Create a error message
            string errorMessage = string.Empty;

            // Get a static page on page name
            StaticPage pageOnPageName = StaticPage.GetOneByPageName(translatedStaticPage.page_name, currentDomain.back_end_language);

            // Check the page name
            if (pageOnPageName != null && translatedStaticPage.id != pageOnPageName.id)
            {
                errorMessage += "&#149; " + String.Format(tt.Get("error_field_language_unique"), tt.Get("page_name")) + "<br/>";
            }
            if (translatedStaticPage.page_name == string.Empty)
            {
                errorMessage += "&#149; " + String.Format(tt.Get("error_field_required"), tt.Get("page_name")) + "<br/>";
            }
            if (AnnytabDataValidation.CheckPageNameCharacters(translatedStaticPage.page_name) == false)
            {
                errorMessage += "&#149; " + String.Format(tt.Get("error_field_bad_chars"), tt.Get("page_name")) + "<br/>";
            }
            if (translatedStaticPage.page_name.Length > 100)
            {
                errorMessage += "&#149; " + String.Format(tt.Get("error_field_length"), tt.Get("page_name"), "100") + "<br/>";
            }
            if (translatedStaticPage.title.Length > 200)
            {
                errorMessage += "&#149; " + String.Format(tt.Get("error_field_length"), tt.Get("title"), "200") + "<br/>";
            }
            if (translatedStaticPage.link_name.Length > 100)
            {
                errorMessage += "&#149; " + String.Format(tt.Get("error_field_length"), tt.Get("link_name"), "100") + "<br/>";
            }
            if (translatedStaticPage.meta_description.Length > 200)
            {
                errorMessage += "&#149; " + String.Format(tt.Get("error_field_length"), tt.Get("meta_description"), "200") + "<br/>";
            }
            if (translatedStaticPage.meta_keywords.Length > 200)
            {
                errorMessage += "&#149; " + String.Format(tt.Get("error_field_length"), tt.Get("keywords"), "200") + "<br/>";
            }

            // Check if there is errors
            if (errorMessage == string.Empty)
            {
                // Get the saved static page
                StaticPage staticPage = StaticPage.GetOneById(id, translationLanguageId);

                if (staticPage == null)
                {
                    // Add a new translated static page
                    StaticPage.AddLanguagePost(translatedStaticPage, translationLanguageId);
                }
                else
                {
                    // Update values for the saved static page
                    staticPage.title = translatedStaticPage.title;
                    staticPage.link_name = translatedStaticPage.link_name;
                    staticPage.main_content = translatedStaticPage.main_content;
                    staticPage.meta_description = translatedStaticPage.meta_description;
                    staticPage.meta_keywords = translatedStaticPage.meta_keywords;
                    staticPage.page_name = translatedStaticPage.page_name;
                    staticPage.inactive = translatedStaticPage.inactive;

                    // Update the static page translation
                    StaticPage.UpdateLanguagePost(staticPage, translationLanguageId);
                }

                // Redirect the user to the list
                return Redirect(returnUrl);
            }
            else
            {
                // Set form values
                ViewBag.Keywords = keywords;
                ViewBag.CurrentPage = currentPage;
                ViewBag.LanguageId = translationLanguageId;
                ViewBag.Languages = Language.GetAll(currentDomain.back_end_language, "name", "ASC");
                ViewBag.StandardStaticPage = standardStaticPage;
                ViewBag.TranslatedStaticPage = translatedStaticPage;
                ViewBag.ErrorMessage = errorMessage;
                ViewBag.TranslatedTexts = tt;
                ViewBag.ReturnUrl = returnUrl;

                // Return the translate view
                return View("translate");
            }

        } // End of the translate method
コード例 #50
0
        public ActionResult edit(FormCollection collection)
        {
            // Get the current domain
            Domain currentDomain = Tools.GetCurrentDomain();
            ViewBag.CurrentDomain = currentDomain;

            // Get query parameters
            string returnUrl = collection["returnUrl"];
            ViewBag.QueryParams = new QueryParams(returnUrl);

            // Check if the administrator is authorized
            if (Administrator.IsAuthorized(new string[] { "Administrator", "Editor" }) == true)
            {
                ViewBag.AdminSession = true;
            }
            else if (Administrator.IsAuthorized(Administrator.GetAllAdminRoles()) == true)
            {
                ViewBag.AdminSession = true;
                ViewBag.AdminErrorCode = 1;
                ViewBag.TranslatedTexts = StaticText.GetAll(currentDomain.back_end_language, "id", "ASC");
                return View("index");
            }
            else
            {
                // Redirect the user to the start page
                return RedirectToAction("index", "admin_login");
            }

            // Get all the form values
            Int32 id = Convert.ToInt32(collection["txtId"]);
            string title = collection["txtTitle"];
            string linkname = collection["txtLinkname"];
            string description = collection["txtDescription"];
            string metaDescription = collection["txtMetaDescription"];
            string metaKeywords = collection["txtMetaKeywords"];
            string pageName = collection["txtPageName"];
            string metaRobots = collection["selectMetaRobots"];
            byte connectionId = Convert.ToByte(collection["selectConnectionId"]);
            bool inactive = Convert.ToBoolean(collection["cbInactive"]);

            // Get the default admin language id
            Int32 adminLanguageId = currentDomain.back_end_language;

            // Get translated texts
            KeyStringList tt = StaticText.GetAll(adminLanguageId, "id", "ASC");

            // Get the static page
            StaticPage staticPage = StaticPage.GetOneById(id, adminLanguageId);

            // Check if the static page exists
            if (staticPage == null)
            {
                // Create an empty static page
                staticPage = new StaticPage();
            }

            // Update values
            staticPage.title = title;
            staticPage.link_name = linkname;
            staticPage.main_content = description;
            staticPage.meta_description = metaDescription;
            staticPage.meta_keywords = metaKeywords;
            staticPage.page_name = pageName;
            staticPage.meta_robots = metaRobots;
            staticPage.connected_to_page = connectionId;
            staticPage.inactive = inactive;

            // Create a error message
            string errorMessage = string.Empty;

            // Get a static page on page name
            StaticPage pageOnPageName = StaticPage.GetOneByPageName(staticPage.page_name, adminLanguageId);

            // Check for errors
            if (pageOnPageName != null && staticPage.id != pageOnPageName.id)
            {
                errorMessage += "&#149; " + String.Format(tt.Get("error_field_language_unique"), tt.Get("page_name")) + "<br/>";
            }
            if (staticPage.page_name == string.Empty)
            {
                errorMessage += "&#149; " + String.Format(tt.Get("error_field_required"), tt.Get("page_name")) + "<br/>";
            }
            if (AnnytabDataValidation.CheckPageNameCharacters(staticPage.page_name) == false)
            {
                errorMessage += "&#149; " + String.Format(tt.Get("error_field_bad_chars"), tt.Get("page_name")) + "<br/>";
            }
            if (staticPage.page_name.Length > 100)
            {
                errorMessage += "&#149; " + String.Format(tt.Get("error_field_length"), tt.Get("page_name"), "100") + "<br/>";
            }
            if (staticPage.title.Length > 200)
            {
                errorMessage += "&#149; " + String.Format(tt.Get("error_field_length"), tt.Get("title"), "200") + "<br/>";
            }
            if (staticPage.link_name.Length > 100)
            {
                errorMessage += "&#149; " + String.Format(tt.Get("error_field_length"), tt.Get("link_name"), "100") + "<br/>";
            }
            if (staticPage.meta_description.Length > 200)
            {
                errorMessage += "&#149; " + String.Format(tt.Get("error_field_length"), tt.Get("meta_description"), "200") + "<br/>";
            }
            if (staticPage.meta_keywords.Length > 200)
            {
                errorMessage += "&#149; " + String.Format(tt.Get("error_field_length"), tt.Get("keywords"), "200") + "<br/>";
            }

            // Check if there is errors
            if (errorMessage == string.Empty)
            {
                // Check if we should add or update the static page
                if (staticPage.id == 0)
                {
                    // Add the static page
                    Int64 insertId = StaticPage.AddMasterPost(staticPage);
                    staticPage.id = Convert.ToInt32(insertId);
                    StaticPage.AddLanguagePost(staticPage, adminLanguageId);
                }
                else
                {
                    // Update the static page
                    StaticPage.UpdateMasterPost(staticPage);
                    StaticPage.UpdateLanguagePost(staticPage, adminLanguageId);
                }

                // Redirect the user to the list
                return Redirect("/admin_static_pages" + returnUrl);
            }
            else
            {
                // Set form values
                ViewBag.ErrorMessage = errorMessage;
                ViewBag.StaticPage = staticPage;
                ViewBag.TranslatedTexts = tt;
                ViewBag.ReturnUrl = returnUrl;

                // Return the edit view
                return View("edit");
            }

        } // End of the edit method
コード例 #51
0
ファイル: Default.ascx.cs プロジェクト: liqueflies/pigeoncms
    private void editPage(string pageName)
    {
        LblOk.Text = "";
        LblErr.Text = "";

        TxtPageName.Text = pageName;
        TxtPageName.Enabled = true;
        TxtId.Text = "";
        ChkShowPageTitle.Checked = true;
        foreach (KeyValuePair<string, string> item in Config.CultureList)
        {
            TextBox t1 = new TextBox();
            t1 = (TextBox)PanelPageTitle.FindControl("TxtPageTitle" + item.Value);
            t1.Text = "";

            var html1 = new Controls_ContentEditorControl();
            html1 = Utility.FindControlRecursive<Controls_ContentEditorControl>(this, "HtmlText" + item.Value);
            html1.Text = "";
        }
        if (pageName != "")
        {
            TxtId.Text = "1";
            TxtPageName.Enabled = false;
            StaticPage currPage = new StaticPage();
            currPage = new StaticPagesManager().GetStaticPageByName(pageName);
            obj2form(currPage);
        }
        MultiView1.ActiveViewIndex = 1;
    }
コード例 #52
0
        public ActionResult AddStatic()
        {
            var model = new StaticPage();

            return View(model);
        }