manage.aspx.cs 4.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*******************************************************************************
  2. * iNethinkCMS - 网站内容管理系统
  3. * Copyright (C) 2012-2013 inethink.com
  4. *
  5. * @author jackyang <69991000@qq.com>
  6. * @website http://cms.inethink.com
  7. * @version 1.3.6.0 (2013-08-14)
  8. *
  9. * This is licensed under the GNU LGPL, version 3.0 or later.
  10. * For details, see: http://www.gnu.org/licenses/gpl-3.0.html
  11. *******************************************************************************/
  12. using System;
  13. using System.Collections.Generic;
  14. using System.Web;
  15. using System.Web.UI;
  16. using System.Web.UI.WebControls;
  17. using iNethinkCMS.Helper;
  18. using iNethinkCMS.Command;
  19. using iNethinkCMS.Web.UI;
  20. namespace iNethinkCMS.Web.plugs.search
  21. {
  22. public partial class manage : Admin_BasePage
  23. {
  24. private string vXmlPath = @"/plugs/search/setting.xml";
  25. private string vState;
  26. private string vTemplatepath;
  27. private string vKeywordlengthMin;
  28. private string vKeywordlengthMax;
  29. private string vSearchMode;
  30. protected void Page_Load(object sender, EventArgs e)
  31. {
  32. CheckUserPower("c");
  33. if (!IsPostBack)
  34. {
  35. if (Request.UrlReferrer != null)
  36. {
  37. ViewState["reJumpUrl"] = Request.UrlReferrer.AbsoluteUri;
  38. }
  39. else
  40. {
  41. ViewState["reJumpUrl"] = Request.Url.AbsoluteUri;
  42. }
  43. vState = XMLHelper.GetXmlAttribute(Server.MapPath(vXmlPath), "//plugs//config//key[@name=\"state\"]", "value").Value.Trim();
  44. vTemplatepath = XMLHelper.GetXmlAttribute(Server.MapPath(vXmlPath), "//plugs//config//key[@name=\"templatepath\"]", "value").Value.Trim();
  45. vKeywordlengthMin = XMLHelper.GetXmlAttribute(Server.MapPath(vXmlPath), "//plugs//config//key[@name=\"keywordlengthmin\"]", "value").Value.Trim();
  46. vKeywordlengthMax = XMLHelper.GetXmlAttribute(Server.MapPath(vXmlPath), "//plugs//config//key[@name=\"keywordlengthmax\"]", "value").Value.Trim();
  47. vSearchMode = XMLHelper.GetXmlAttribute(Server.MapPath(vXmlPath), "//plugs//config//key[@name=\"searchmode\"]", "value").Value.Trim();
  48. this.txtState.SelectedValue = vState;
  49. this.txtTemplatepath.Text = vTemplatepath;
  50. this.txtKeywordlengthMin.Text = vKeywordlengthMin;
  51. this.txtKeywordlengthMax.Text = vKeywordlengthMax;
  52. this.txtSearchMode.SelectedValue = vSearchMode;
  53. }
  54. }
  55. protected void Button_Submit_Click(object sender, EventArgs e)
  56. {
  57. vState = this.txtState.SelectedValue;
  58. vTemplatepath = this.txtTemplatepath.Text.Trim();
  59. vKeywordlengthMin = this.txtKeywordlengthMin.Text.Trim();
  60. vKeywordlengthMax = this.txtKeywordlengthMax.Text.Trim();
  61. vSearchMode = this.txtSearchMode.SelectedValue;
  62. if (this.vTemplatepath.Length == 0)
  63. {
  64. MessageBox.Show(this, "请输入模板路径!");
  65. return;
  66. }
  67. if (!Command_Validate.IsNumber(vKeywordlengthMin))
  68. {
  69. MessageBox.Show(this, "关键字长度(最小)只能为数字!");
  70. return;
  71. }
  72. if (!Command_Validate.IsNumber(vKeywordlengthMax))
  73. {
  74. MessageBox.Show(this, "关键字长度(最大)只能为数字!");
  75. return;
  76. }
  77. XMLHelper.CreateOrUpdateXmlAttributeByXPath(Server.MapPath(vXmlPath), "//plugs//config//key[@name=\"state\"]", "value", vState);
  78. XMLHelper.CreateOrUpdateXmlAttributeByXPath(Server.MapPath(vXmlPath), "//plugs//config//key[@name=\"templatepath\"]", "value", vTemplatepath);
  79. XMLHelper.CreateOrUpdateXmlAttributeByXPath(Server.MapPath(vXmlPath), "//plugs//config//key[@name=\"keywordlengthmin\"]", "value", vKeywordlengthMin);
  80. XMLHelper.CreateOrUpdateXmlAttributeByXPath(Server.MapPath(vXmlPath), "//plugs//config//key[@name=\"keywordlengthmax\"]", "value", vKeywordlengthMax);
  81. XMLHelper.CreateOrUpdateXmlAttributeByXPath(Server.MapPath(vXmlPath), "//plugs//config//key[@name=\"searchmode\"]", "value", vSearchMode);
  82. Response.Redirect(ViewState["reJumpUrl"].ToString());
  83. }
  84. }
  85. }