Exemplo n.º 1
0
        private void GetWebpageAreas(SqlConnection connection, Webpage webpage)
        {
            string sql = @"
SELECT 
	* 
FROM 
	purple_WebpageAreas
WHERE
	RevisionID = @RevisionID;"    ;

            SqlCommand command = new SqlCommand(sql, connection);

            command.Parameters.Add("@RevisionID", SqlDbType.UniqueIdentifier).Value = webpage.RevisionID;

            SqlDataReader reader = command.ExecuteReader();

            while (reader.Read())
            {
                WebpageArea area = new WebpageArea();

                area.AreaID               = new Guid(reader["AreaID"].ToString());
                area.WebpageID            = webpage.WebpageID;
                area.RevisionID           = webpage.RevisionID;
                area.SortOrder            = (int)reader["SortOrder"];
                area.ContentPlaceHolderID = (string)reader["ContentPlaceHolderID"];
                area.ContentHtml          = (string)reader["ContentHtml"];
                area.ControlName          = (string)reader["ControlName"];

                webpage.Areas.Add(area);
            }
        }
Exemplo n.º 2
0
        void PurplePageAddButton_Click(object sender, EventArgs e)
        {
            // What to do now?
            Webpage newpage = new Webpage();

            FindAdminControls();

            newpage.ParentID           = this.Webpage.WebpageID;
            newpage.Filename           = webpageFilename.Text;
            newpage.Title              = webpagePageTitle.Text;
            newpage.MenuTitle          = webpageMenuTitle.Text;
            newpage.Url                = ((this.Webpage.IsSiteRoot) ? "" : this.Webpage.Url + "/") + newpage.Filename;
            newpage.FullUrl            = newpage.Url;
            newpage.ForceSsl           = false;
            newpage.ShowInMenu         = true;
            newpage.MasterPageFilename = webpageMasterPageFilename.SelectedValue + ".master"; // this.Webpage.MasterPageFilename; //  PurpleSettings.DefaultMasterPageFilename;
            newpage.MenuType           = (MenuType)Enum.Parse(typeof(MenuType), webpageMenuType.SelectedValue);

            WebpageArea area = new WebpageArea();

            area.ContentPlaceHolderID = ContentPlaceHolders[0].ID;
            area.ContentHtml          = "New Page";
            newpage.Areas.Add(area);

            // save
            Webpages.AddWebpage(newpage);

            // see the finished page
            Response.Redirect("/" + newpage.Url + "?pagemode=edit");
        }
Exemplo n.º 3
0
        private void ProcessRevisionXml(XmlNode node, Webpage webpage)
        {
            webpage.RevisionID        = GetAttributeGuid(node, "revisionid", Guid.Empty);
            webpage.IsPublished       = GetAttributeBool(node, "ispublished", false);
            webpage.RevisedDate       = GetAttributeDateTime(node, "reviseddate", DateTime.MinValue);
            webpage.RevisedByUsername = GetAttributeString(node, "revisedbyusername", "");

            webpage.Title              = GetSubNodeString(node, "meta/title", "");
            webpage.MenuTitle          = GetSubNodeString(node, "meta/menutitle", "");
            webpage.MetaDescription    = GetSubNodeString(node, "meta/metadescription", "");
            webpage.MetaKeywords       = GetSubNodeString(node, "meta/metakeywords", "");
            webpage.Filename           = GetSubNodeString(node, "meta/filename", "");
            webpage.MasterPageFilename = GetSubNodeString(node, "meta/masterpagefilename", "");
            webpage.ForceSsl           = GetSubNodeBoolean(node, "meta/forcessl", false);
            webpage.ShowInMenu         = GetSubNodeBoolean(node, "meta/showinmenu", true);
            webpage.SortOrder          = GetSubNodeInt(node, "meta/sortorder", 0);
            webpage.MenuType           = (MenuType)GetSubNodeInt(node, "meta/menutype", 0);
            webpage.FullUrl            = GetSubNodeString(node, "meta/fullurl", "");
            webpage.Editors            = GetSubNodeString(node, "meta/editors", "");

            webpage.ContentExpirationDate = GetSubNodeDateTime(node, "meta/contentexpirationdate", DateTime.MinValue);
            webpage.CommonAreaHeader      = GetSubNodeString(node, "meta/commonareaheader", "");
            webpage.IgnoreParentHeader    = GetSubNodeBoolean(node, "meta/IgnoreParentHeader", false);


            // process areas
            XmlNodeList areaNodes = node.SelectNodes("areas/area");

            foreach (XmlNode areaNode in areaNodes)
            {
                WebpageArea area = new WebpageArea();
                area.WebpageID = webpage.WebpageID;

                area.ContentPlaceHolderID = GetAttributeString(areaNode, "contentplaceholderid", "");
                area.ControlName          = GetAttributeString(areaNode, "controlname", "");
                area.SortOrder            = GetAttributeInt(areaNode, "sortoder", 9999);
                area.ContentHtml          = areaNode.InnerText;

                webpage.Areas.Add(area);
            }
        }
Exemplo n.º 4
0
        private void GetWebpageAreas(SqlConnection connection, Webpage webpage)
        {
            string sql = @"
            SELECT
            *
            FROM
            purple_WebpageAreas
            WHERE
            RevisionID = @RevisionID;";

            SqlCommand command = new SqlCommand(sql, connection);
            command.Parameters.Add("@RevisionID", SqlDbType.UniqueIdentifier).Value = webpage.RevisionID;

            SqlDataReader reader = command.ExecuteReader();

            while (reader.Read())
            {
                WebpageArea area = new WebpageArea();

                area.AreaID = new Guid(reader["AreaID"].ToString());
                area.WebpageID = webpage.WebpageID;
                area.RevisionID = webpage.RevisionID;
                area.SortOrder = (int)reader["SortOrder"];
                area.ContentPlaceHolderID = (string)reader["ContentPlaceHolderID"];
                area.ContentHtml = (string)reader["ContentHtml"];
                area.ControlName = (string)reader["ControlName"];

                webpage.Areas.Add(area);
            }
        }
Exemplo n.º 5
0
        private void ProcessRevisionXml(XmlNode node, Webpage webpage)
        {
            webpage.RevisionID = GetAttributeGuid(node, "revisionid", Guid.Empty);
            webpage.IsPublished = GetAttributeBool(node, "ispublished", false);
            webpage.RevisedDate = GetAttributeDateTime(node, "reviseddate", DateTime.MinValue);
            webpage.RevisedByUsername = GetAttributeString(node, "revisedbyusername", "");

            webpage.Title = GetSubNodeString(node, "meta/title", "");
            webpage.MenuTitle = GetSubNodeString(node, "meta/menutitle", "");
            webpage.MetaDescription = GetSubNodeString(node, "meta/metadescription", "");
            webpage.MetaKeywords = GetSubNodeString(node, "meta/metakeywords", "");
            webpage.Filename = GetSubNodeString(node, "meta/filename", "");
            webpage.MasterPageFilename = GetSubNodeString(node, "meta/masterpagefilename", "");
            webpage.ForceSsl = GetSubNodeBoolean(node, "meta/forcessl", false);
            webpage.ShowInMenu = GetSubNodeBoolean(node, "meta/showinmenu", true);
            webpage.SortOrder = GetSubNodeInt(node, "meta/sortorder", 0);
            webpage.MenuType = (MenuType) GetSubNodeInt(node, "meta/menutype", 0);
            webpage.FullUrl = GetSubNodeString(node, "meta/fullurl", "");
            webpage.Editors = GetSubNodeString(node, "meta/editors", "");

            webpage.ContentExpirationDate = GetSubNodeDateTime(node, "meta/contentexpirationdate", DateTime.MinValue);
            webpage.CommonAreaHeader = GetSubNodeString(node, "meta/commonareaheader", "");
            webpage.IgnoreParentHeader = GetSubNodeBoolean(node, "meta/IgnoreParentHeader", false);

            // process areas
            XmlNodeList areaNodes = node.SelectNodes("areas/area");
            foreach (XmlNode areaNode in areaNodes)
            {
                WebpageArea area = new WebpageArea();
                area.WebpageID = webpage.WebpageID;

                area.ContentPlaceHolderID = GetAttributeString(areaNode, "contentplaceholderid", "");
                area.ControlName = GetAttributeString(areaNode, "controlname", "");
                area.SortOrder = GetAttributeInt(areaNode, "sortoder", 9999);
                area.ContentHtml = areaNode.InnerText;

                webpage.Areas.Add(area);
            }
        }
Exemplo n.º 6
0
        void PurplePageSaveButton_Click(object sender, EventArgs e)
        {
            // What to do now?
            Webpage webpage = this.Webpage;

            FindAdminControls();

            // update main values
            webpage.Filename = webpageFilename.Text;
            webpage.FullUrl  = ((!webpage.Parent.IsSiteRoot) ? webpage.Parent.Url + "/" : "") + webpage.Filename;

            string url = webpageUrl.Text;

            // TODO: seriously need some better checking here
            webpage.Url = (!String.IsNullOrWhiteSpace(url)) ? url : webpage.FullUrl;

            webpage.Title              = webpagePageTitle.Text;
            webpage.MenuTitle          = webpageMenuTitle.Text;
            webpage.MetaDescription    = webpageMetaDescription.Text;
            webpage.MetaKeywords       = webpageMetaKeywords.Text;
            webpage.MasterPageFilename = webpageMasterPageFilename.SelectedValue + ".master";

            webpage.ForceSsl   = webpageForceSsl.Checked;
            webpage.ShowInMenu = webpageShowInMenu.Checked;


            webpage.CommonAreaHeader   = webpageCommonAreaHeader.Text;
            webpage.IgnoreParentHeader = webpageIgnoreParentHeader.Checked;
            DateTime expiresDate = DateTime.MinValue;

            if (DateTime.TryParse(webpageContentExpirationDate.Text, out expiresDate))
            {
                webpage.ContentExpirationDate = expiresDate;
            }
            else
            {
                webpage.ContentExpirationDate = DateTime.MinValue;
            }


            webpage.MenuType = (MenuType)Enum.Parse(typeof(MenuType), webpageMenuType.SelectedValue);

            int menuSortOrder = 0;

            if (Int32.TryParse(webpageSortOrder.Text, out menuSortOrder))
            {
                webpage.SortOrder = menuSortOrder;
            }

            // permissions
            List <string> pageEditors = new List <string>();

            foreach (ListItem li in webpageEditors.Items)
            {
                if (li.Selected)
                {
                    pageEditors.Add(li.Value);
                }
            }
            webpage.Editors = String.Join(",", pageEditors.ToArray());


            // update modules
            webpage.Areas.Clear();
            foreach (ContentPlaceHolder placeholder in ContentPlaceHolders)
            {
                int sortOrder = 1;
                // each sub control should be a editarea.ascx control
                foreach (Control control in placeholder.Controls)
                {
                    WebpageArea area = new WebpageArea();

                    string html = (control.FindControl("HtmlContent") as TextBox).Text;

                    area.ContentPlaceHolderID = placeholder.ID;
                    area.ContentHtml          = html;
                    DropDownList controlList = control.FindControl("ControlName") as DropDownList;
                    area.ControlName = (!String.IsNullOrWhiteSpace(controlList.SelectedValue)) ? controlList.SelectedValue + ".ascx" : "";
                    area.SortOrder   = sortOrder;

                    webpage.Areas.Add(area);
                    sortOrder++;
                }
            }

            // save
            webpage.IsPublished = true;
            Webpages.UpdateWebpage(webpage);

            // see the finished page
            Response.Redirect("/" + webpage.Url);
        }