/// <summary> /// Removes a page from the list /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void DynamicEditPage_Delete(object sender, EventArgs e) { DynamicEditPage dep = (DynamicEditPage)sender; //open the appropriate language XML file XmlDocument doc = new XmlDocument(); string filename = Localization.ResourceManager.GetCurrentFilename(); doc.PreserveWhitespace = true; doc.Load(filename); //find the node with the matching key XmlElement page = (XmlElement)doc.SelectSingleNode("Resource/pages[@name='" + dep.Key + "']/page[@index='" + dep.EditingIndex.ToString() + "']"); //delete the row page.ParentNode.RemoveChild(page); doc.Save(filename); //remove the query string from the file Response.Redirect(Request.Path + "?ds=1", true); }
public void LanguageDropDown_Changed(object sender, EventArgs e) { BaseLocale locale = null; locale = Locales.FindLocaleByName(this.LanguageDropDown.SelectedValue); ((TBWebPage)this.Page).Locale = locale; //NOTE: this is not a good solution to the Singleton pattern DynamicEdit.ResetFirst(); DynamicEditPage.ResetFirst(); Response.Redirect(Request.Url.AbsoluteUri, true); }
public void CheckFlags() { //handle flag clicks //NOTE: this has been handled by GET to allow for Googlebots to search if (Request["lang"] != null) { switch (Request["lang"]) { case "en": ((TBWebPage)this.Page).Locale = Locales.America; break; case "pt": ((TBWebPage)this.Page).Locale = Locales.Brazil; break; case "ja": ((TBWebPage)this.Page).Locale = Locales.Japan; break; case "es": ((TBWebPage)this.Page).Locale = Locales.Peru; break; } string uri = Request.Url.AbsoluteUri; uri = System.Text.RegularExpressions.Regex.Replace(uri, "lang=..", ""); //NOTE: this is not a good solution to the Singleton pattern DynamicEdit.ResetFirst(); DynamicEditPage.ResetFirst(); //redirect with the new language Response.Redirect(uri, true); } }
//the data has been submitted for an edit public void DynamicEditPage_Submit(object sender, EventArgs e) { DynamicEditPage dep = ((DynamicEditPage)(((Button)sender).NamingContainer)); //open the appropriate language XML file XmlDocument doc = new XmlDocument(); string filename = Localization.ResourceManager.GetCurrentFilename(); doc.PreserveWhitespace = true; doc.Load(filename); if (dep.IsEdit) { //update xml //find the node with the matching key XmlElement page = (XmlElement)doc.SelectSingleNode("Resource/pages[@name='" + dep.Key + "']/page[@index='" + dep.EditingIndex.ToString() + "']"); page.SelectSingleNode("title").InnerXml = dep.EditTitle; page.SelectSingleNode("teaser").InnerXml = dep.EditTeaser; page.SelectSingleNode("text").InnerXml = dep.EditText; } else { //create page in xml XmlElement pages = (XmlElement)doc.SelectSingleNode("Resource/pages[@name='" + dep.Key + "']"); //add a new pages section if none found if (pages == null) { XmlElement root = (XmlElement)doc.SelectSingleNode("Resource"); pages = doc.CreateElement("pages"); XmlAttribute key = doc.CreateAttribute("name"); key.Value = dep.Key; pages.Attributes.Append(key); pages = (XmlElement)root.AppendChild(pages); } XmlElement page = doc.CreateElement("page"); page.SetAttribute("index", dep.NewIndex.ToString()); XmlElement title = doc.CreateElement("title"); title.InnerXml = dep.EditTitle; XmlElement teaser = doc.CreateElement("teaser"); teaser.InnerXml = dep.EditTeaser; XmlElement text = doc.CreateElement("text"); text.InnerXml = dep.EditText; page.AppendChild(title); pages.AppendChild(doc.CreateTextNode("\r\n\t")); page.AppendChild(teaser); pages.AppendChild(doc.CreateTextNode("\r\n\t")); page.AppendChild(text); pages.AppendChild(doc.CreateTextNode("\r\n\t")); pages.AppendChild(page); } doc.Save(filename); //remove the query string from the file Response.Redirect(Request.Path + "?s=1", true); }