protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         TemplateEditorUtils.ModuleDataBind(ddlModule, PortalId, LocalResourceFile, Server);
         ddlModule.SelectedValue = "widgets";
         if (Request.Cookies["ddlModule"] != null)
         {
             string module_value = Request.Cookies["ddlModule"].Value.ToString();
             var    module_item  = ddlModule.Items.FindByValue(module_value);
             if (module_item != null)
             {
                 ddlModule.SelectedValue = module_value;
             }
         }
     }
 }
Exemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            ServicesFramework.Instance.RequestAjaxAntiForgerySupport();
            lkbDelete.Attributes.Add("onClick", " return confirm('" + Localization.GetString("msgConfirm", LocalResourceFile) + "')");
            lbCreate.NavigateUrl   = EditUrl();
            PreviewUrl             = ModuleContext.NavigateUrl(TabId, "Preview", true, "mid=" + ModuleId);
            DataSourceUrl          = ModuleContext.NavigateUrl(TabId, "DataSource", true, "mid=" + ModuleId);
            hlSettings.NavigateUrl = EditUrl("Config");
            hlHome.NavigateUrl     = Globals.NavigateURL(PortalSettings.HomeTabId);

            /*
             * string SaveDataSource = Page.ClientScript.GetPostBackEventReference(Page, "SaveDataSource");
             * Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "SaveDataSource", string.Format("function SaveDataSource(){{ {0} }}\n", SaveDataSource), true);
             * string LoadDataSource = Page.ClientScript.GetPostBackEventReference(Page, "SaveDataSource");
             * Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "LoadDataSource", string.Format("function LoadDataSource(){{ {0} }}\n", LoadDataSource), true);
             * if (Page.IsPostBack)
             * {
             *  string eventArg = Request["__EVENTARGUMENT"];
             *  if (eventArg == "SaveDataSource")
             *  {
             *      string ds = "";
             *      foreach (DataSourceConfigurator conf in phConfigurator.Controls)
             *      {
             *          if (conf.Visible)
             *          {
             *              ds += conf.getToken();
             *          }
             *      }
             *      File.WriteAllText(Server.MapPath(dfeTree.TreeView.SelectedValue), ds);
             *  }
             *  else if (eventArg == "LoadDataSource")
             *  {
             *      string ds = File.ReadAllText(Server.MapPath(dfeTree.TreeView.SelectedValue));
             *      var dic = DataSourceConfigurator.ParseToken(ds);
             *      foreach (DataSourceConfigurator conf in phConfigurator.Controls)
             *      {
             *          conf.Visible = conf.ID == dic["dataprovider"];
             *          if (conf.Visible)
             *          {
             *              conf.setToken(ds);
             *          }
             *      }
             *  }
             * }
             */
            if (!Page.IsPostBack)
            {
                //hlNoSkin.NavigateUrl = Request.RawUrl + "?SkinSrc=%5BG%5DSkins/_default/No%20Skin";
                TemplateEditorUtils.ModuleDataBind(ddlModule, PortalId, LocalResourceFile, Server);
                if (Request.Cookies["ddlModule"] != null)
                {
                    string module_value = Request.Cookies["ddlModule"].Value.ToString();
                    var    module_item  = ddlModule.Items.FindByValue(module_value);
                    if (module_item != null)
                    {
                        ddlModule.SelectedValue = module_value;
                        if (ddlModule.SelectedIndex > 0)
                        {
                            TemplateEditorUtils.TemplateDataBind(ddlModule.SelectedValue, ddlTemplate, PortalId, LocalResourceFile, Server);
                            if (!string.IsNullOrEmpty(ddlTemplate.SelectedValue))
                            {
                                //ddlTemplate_SelectedIndexChanged(null, null);
                            }
                            else if (Request.Cookies["ddlTemplate"] != null)
                            {
                                string template_value = Request.Cookies["ddlTemplate"].Value.ToString();
                                var    template_item  = ddlTemplate.Items.FindByValue(template_value);
                                if (template_item != null)
                                {
                                    ddlTemplate.SelectedValue = Request.Cookies["ddlTemplate"].Value.ToString();
                                }
                            }
                            if (!string.IsNullOrEmpty(ddlTemplate.SelectedValue))
                            {
                                if (Request.Cookies["lkbRefresh"] != null)
                                {
                                    showFile(Request.Cookies["lkbRefresh"].Value.ToString());
                                }
                            }
                        }
                    }
                }
                if (Request.Cookies["cbFullScreen"] != null)
                {
                    cbFullScreen.Checked = Boolean.Parse(Request.Cookies["cbFullScreen"].Value.ToString());
                    //cbFullScreen_CheckedChanged(null, null);
                    ScopeWrapper.CssClass = cbFullScreen.Checked ? "overlay" : "";
                }
            }
            else
            {
                string ctrlname = Page.Request.Params["__EVENTTARGET"];
                if (!string.IsNullOrEmpty(ctrlname))
                {
                    var targetControl = this.Page.FindControl(ctrlname);
                    if (targetControl == ddlModule)
                    {
                        TemplateEditorUtils.TemplateDataBind(ddlModule.SelectedValue, ddlTemplate, PortalId, LocalResourceFile, Server);
                    }
                }
            }
            if (!string.IsNullOrEmpty(ddlTemplate.SelectedValue))
            {
                //string path = TemplateEditorUtils.GenerateDirectory(ddlModule, ddlType, ddlTemplate, PortalId, Server);
                string path = ddlTemplate.SelectedValue;
                if (dfeTree.Configuration.ViewPaths.Length == 0 || path != dfeTree.Configuration.ViewPaths[0])
                {
                    dfeTree.TreeView.Nodes.Clear();
                    dfeTree.Configuration.ViewPaths   = new string[] { path };
                    dfeTree.Configuration.DeletePaths = dfeTree.Configuration.ViewPaths;
                    dfeTree.Configuration.UploadPaths = dfeTree.Configuration.ViewPaths;
                }
            }
            else
            {
                ClearTreeView();
            }
            customMenuOption.Value = "newfile";
            dfeTree.TreeView.ContextMenus[0].Items.Add(customMenuOption);
            dfeTree.TreeView.OnClientContextMenuItemClicked = "OnTreeContextMenuItemClicked";
            RefreshControls();
            DotNetNuke.Framework.AJAX.RegisterPostBackControl(ddlModule);
            //DotNetNuke.Framework.AJAX.RegisterPostBackControl(ddlType);
            DotNetNuke.Framework.AJAX.RegisterPostBackControl(ddlTemplate);
            //DotNetNuke.Framework.AJAX.RegisterPostBackControl(lkbRefresh);
            //DotNetNuke.Framework.AJAX.RegisterPostBackControl(btnValid);
            DotNetNuke.Framework.AJAX.RegisterPostBackControl(lkbDelete);
            //DotNetNuke.Framework.AJAX.RegisterPostBackControl(lkbRun);
            lkbData.Visible = hlDataSource.Visible = hlPreview.Visible = hlWidget.Visible = (ddlModule.SelectedValue == "widgets" || ddlModule.SelectedValue == "RazorModules/RazorHost");
        }