示例#1
0
        protected void ButtonAdd_OnClick(object sender, EventArgs e)
        {
            if (Page.IsValid) {

                Guid parentID = new Guid(DropDownListDirectories.SelectedValue);
                Guid templateID = new Guid(DropDownListTemplates.SelectedValue);

                string filePath = Path.GetTempFileName();
                InputFileUpload.PostedFile.SaveAs(filePath);
                try {
                    DataTable data = getDataFromXLS(filePath);
                    int count = 0;
                    foreach (DataRow dr in data.Rows) {
                        string filename = Clean(dr["Filename"]);
                        if (filename != null && filename.Length > 0) {

                            CmsPage page = new CmsPage();
                            page.FileName = filename;
                            page.Title = Clean(dr["Title"]);
                            page.ParentID = parentID;
                            page.TemplateID = templateID;
                            page.Insert();
                            count++;

                            AddAttribute(page, "website", Clean(dr["Website"]));
                            AddAttribute(page, "phone", Clean(dr["Phone"]));
                            AddAttribute(page, "street", Clean(dr["Street"]));
                            AddAttribute(page, "addressHint", Clean(dr["AddressHint"]));
                            AddAttribute(page, "city", Clean(dr["City"]));
                            AddAttribute(page, "subcategory", Clean(dr["Subcategory"]));

                             //string description = Clean(dr["Description"]);
                             //if (description != null && description.Length > 0) {
                             //    LiteralContent content = (LiteralContent)page.ContentBlocks["Body"];
                             //    content.Text = description;
                             //    page
                             //}

                            //Website	Phone	Street	AddressHint	Subcategory	City	Featured	City	State	Description

                        }
                    }

                    MessageBox1.ShowMessage(MessageBox.MessageBoxMode.Info, count + " pages have been created.");

                } finally {
                    try {
                        File.Delete(filePath);
                    } catch (Exception ex) {
                    }
                }
            }
        }
示例#2
0
        protected void ButtonAddPage_OnClick(object sender, EventArgs e)
        {
            if(Page.IsValid){
                CmsPage p = new CmsPage();
                DataBindingManagerPage.DataSource = p;
                DataBindingManagerPage.PullData();

                p.ParentID = DirectoryID;

                if(p.TemplateID == Guid.Empty){
                    p.IsStatic = true;
                }

                CmsWebDirectory d = CmsWebDirectory.FindByID(DirectoryID);
                p.SortOrder = d.Files.Count;  //TODO: Pull this out into page!
                p.Insert();

                Response.Redirect(p.FileType.EditUrl + "?FileID=" + p.ID);
            }
        }
示例#3
0
 public void AddAttribute(CmsPage page, string name, string value)
 {
     if (value != null && value.Length > 0) {
         page.Attributes.Add(name, value);
     }
 }
示例#4
0
        private void CreateUrlElement(CmsPage p, XmlElement urlsetElement)
        {
            XmlElement urlElement = urlsetElement.OwnerDocument.CreateElement("url");
            urlsetElement.AppendChild(urlElement);

            XmlElement locElement = urlsetElement.OwnerDocument.CreateElement("loc");
            urlElement.AppendChild(locElement);
            locElement.InnerText = "http://" + host.HostHeaderName + p.FullPath.Substring(rootDirectory.FullPath.Length);

            XmlElement lastModElement = urlsetElement.OwnerDocument.CreateElement("lastmod");
            urlElement.AppendChild(lastModElement);
            lastModElement.InnerText = p.DateModified.ToString("yyyy-MM-dd");
        }
示例#5
0
 /// <summary>
 /// This method supports the Xenosynth CMS Module and is not intended to be used directly from your code. 
 /// </summary>
 /// <param name="page">
 /// A <see cref="CmsPage"/>
 /// </param>
 public CmsContentBlockCollection(CmsPage page)
 {
     this.page = page;
 }