public static void TemplateDataBind(string Module, DropDownList ddlTemplate, int PortalId, string LocalResourceFile, HttpServerUtility Server)
 {
     ddlTemplate.Items.Clear();
     ddlTemplate.Items.Add(new ListItem(Localization.GetString("selectTemplate", LocalResourceFile), ""));
     for (int type = 1; type < 4; type++)
     {
         string path = TemplateEditorUtils.GenerateDirectory(Module, type, "", PortalId, Server);
         if (!string.IsNullOrEmpty(path) && Directory.Exists(Server.MapPath(path)))
         {
             var dryLst = Directory.GetDirectories(Server.MapPath(path));
             if (dryLst.Count() > 0 && (Directory.GetFiles(Server.MapPath(path)).Count() == 0 || Module == "Blog"))
             {
                 foreach (string item in dryLst)
                 {
                     int nb = item.LastIndexOf('\\');
                     ddlTemplate.Items.Add(new ListItem(GetTypes()[type] + " - " + item.Substring(nb + 1), ReverseMapPath(item)));
                 }
             }
             else
             {
                 ddlTemplate.Items.Add(new ListItem(GetTypes()[type], path));
             }
         }
     }
     if (ddlTemplate.Items.Count == 2)
     {
         ddlTemplate.Items.RemoveAt(0);
         ddlTemplate.SelectedIndex = 0;
     }
 }
 protected void ddlTypeCopy_SelectedIndexChanged(object sender, EventArgs e)
 {
     TemplateEditorUtils.TemplateDataBind(ddlModule, ddlTypeCopy, ddlTemplate, PortalId, LocalResourceFile, Server);
     if (rblMode.SelectedValue == "1")
     {
         //lblMode.Text = Localization.GetString("lblModeCopy", LocalResourceFile);
         //lblMode.HelpText = Localization.GetString("lblModeCopy.Help", LocalResourceFile);
     }
 }
        protected void lbCKEditor_Click(object sender, EventArgs e)
        {
            string      FileName = Path.Combine(PortalSettings.HomeDirectoryMapPath, "CKToolbarButtons.xml");
            XmlDocument doc      = new XmlDocument();

            doc.Load(FileName);
            if (doc.SelectNodes("/ArrayOfToolbarButton//ToolbarButton[contains(ToolbarName,'dnntokens')]").Count == 0)
            {
                var        ArrayOfToolbarButton = doc.GetElementsByTagName("ArrayOfToolbarButton").Item(0);
                XmlElement ToolbarButton        = doc.CreateElement("ToolbarButton");
                ArrayOfToolbarButton.AppendChild(ToolbarButton);
                XmlElement ToolbarName = doc.CreateElement("ToolbarName");
                ToolbarName.InnerText = "dnntokens";
                ToolbarButton.AppendChild(ToolbarName);
                XmlElement ToolbarIcon = doc.CreateElement("ToolbarIcon");
                ToolbarIcon.InnerText = "../plugins/dnntokens/icon.gif";
                ToolbarButton.AppendChild(ToolbarIcon);
                doc.Save(FileName);
            }

            FileName = Path.Combine(PortalSettings.HomeDirectoryMapPath, "CKEditorSettings.xml");
            doc      = new XmlDocument();
            doc.Load(FileName);
            var nodes = doc.SelectNodes("/EditorProviderSettings//Config");

            if (nodes.Count > 0)
            {
                var      extraPlugins = nodes.Item(0).Attributes["extraPlugins"].Value;
                string[] plugins      = extraPlugins.Split(',');
                if (!plugins.Contains("dnntokens"))
                {
                    nodes.Item(0).Attributes["extraPlugins"].Value = extraPlugins + ",dnntokens";
                    doc.Save(FileName);
                }
            }
            // Add ...
            FileName = Path.Combine(PortalSettings.HomeDirectoryMapPath, "CKToolbarSets.xml");
            doc      = new XmlDocument();
            doc.Load(FileName);
            nodes = doc.SelectNodes("/ArrayOfToolbarSet//ToolbarSet[contains(Name,'Full')]//ToolbarGroups//ToolbarGroup[contains(name,'insert')]//items");
            if (nodes.Count > 0 && !nodes.Item(0).InnerXml.Contains("<string>dnntokens</string>"))
            {
                //nodes = doc.SelectNodes("/ArrayOfToolbarSet//ToolbarSet[contains(Name,'Full')]//ToolbarGroups//ToolbarGroup[contains(name,'insert')]//items");
                if (nodes.Count > 0)
                {
                    var elem = doc.CreateElement("string");
                    elem.InnerXml = "dnntokens";
                    nodes.Item(0).AppendChild(elem);
                    doc.Save(FileName);
                }
            }
            // Install plugin
            TemplateEditorUtils.DirectoryCopy(Server.MapPath("~/DesktopModules/OpenBlocks/Providers/HtmlEditorProviders"), Server.MapPath("~/Providers/HtmlEditorProviders"), true, true);
        }
Esempio n. 4
0
 public override void LoadSettings(Hashtable settings)
 {
     try
     {
         ddlDataSource.SelectedValue = (string)settings["Widget_DataSourceProvider"];
         SelectProvider(ddlDataSource.SelectedValue, settings);
         TemplateEditorUtils.TemplateDataBind("Widgets", ddlTemplate, PortalId, LocalResourceFile, Server);
         ddlTemplate.SelectedValue = (string)settings["Widget_Template"];
         TemplateEditorUtils.FileDataBind("Widgets", ddlTemplate, ddlFile, PortalId, LocalResourceFile, Server);
         ddlFile.SelectedValue = (string)settings["Widget_File"];
     }
     catch (Exception exc) // Module failed to load
     {
         Exceptions.ProcessModuleLoadException(this, exc);
     }
 }
        private void UnzipFile(HttpPostedFile objFileUpload)
        {
            ZipInputStream s = new ZipInputStream(objFileUpload.InputStream);
            ZipEntry       theEntry;
            string         virtualPath   = "~" + TemplateEditorUtils.GenerateDirectory(ddlModule, ddlType, tbxNewTemplate, PortalId, Server) + "/";
            string         fileName      = string.Empty;
            string         folderName    = string.Empty;
            string         fileExtension = string.Empty;
            string         fileSize      = string.Empty;

            while ((theEntry = s.GetNextEntry()) != null)
            {
                folderName    = Path.GetDirectoryName(theEntry.Name);
                fileName      = Path.GetFileName(theEntry.Name);
                fileExtension = Path.GetExtension(fileName);

                if (!string.IsNullOrEmpty(fileName))
                {
                    try
                    {
                        if (!string.IsNullOrEmpty(folderName))
                        {
                            Directory.CreateDirectory(Server.MapPath(virtualPath + folderName));
                        }

                        FileStream streamWriter = File.Create(Server.MapPath(virtualPath + folderName + "/" + fileName));
                        int        size         = 2048;
                        byte[]     data         = new byte[2048];

                        do
                        {
                            size = s.Read(data, 0, data.Length);
                            streamWriter.Write(data, 0, size);
                        } while (size > 0);

                        fileSize = Convert.ToDecimal(streamWriter.Length / 1024).ToString() + " KB";

                        streamWriter.Close();
                    }
                    catch (Exception ex)
                    {
                        Response.Write(ex.ToString());
                    }
                }
            }
            s.Close();
        }
 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;
             }
         }
     }
 }
Esempio n. 7
0
        protected void lkbDelete_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(tbxEdit.Text))
            {
                tbxEdit.Text = "";
            }

            tbxEdit.Visible = true;
            //string path = Server.MapPath(TemplateEditorUtils.GenerateDirectory(ddlModule, ddlType, ddlTemplate, PortalId, Server));
            string path = ddlTemplate.SelectedValue;

            TemplateEditorUtils.DeleteDirectory(Server.MapPath(path));
            lblMsg.Visible = true;
            lblMsg.Text    = Localization.GetString("msgSuccessDelete", LocalResourceFile);
            ddlTemplate.Items.Clear();
            ddlTemplate.Items.Add(new ListItem(Localization.GetString("selectTemplate", LocalResourceFile), ""));
            TemplateEditorUtils.TemplateDataBind(ddlModule.SelectedValue, ddlTemplate, PortalId, LocalResourceFile, Server);
            ClearTreeView();
            RefreshControls();
        }
        protected void btnValid_Click(object sender, EventArgs e)
        {
            if (Request.Cookies["lkbRefresh"] != null)
            {
                HttpCookie myCookie = new HttpCookie("lkbRefresh");
                myCookie.Expires = DateTime.Now.AddDays(-1d);
                Response.Cookies.Add(myCookie);
            }
            Response.Cookies["ddlModule"].Value = ddlModule.SelectedValue;
            //Response.Cookies["ddlType"].Value = ddlType.SelectedValue;
            //Response.Cookies["ddlTemplate"].Value = tbxNewTemplate.Text;
            string newpath = TemplateEditorUtils.GenerateDirectory(ddlModule.SelectedValue, int.Parse(ddlType.SelectedValue), tbxNewTemplate.Text, PortalId, Server, false);

            Response.Cookies["ddlTemplate"].Value = newpath;
            newpath = Server.MapPath(newpath);
            Directory.CreateDirectory(newpath);

            if (rblMode.SelectedValue == "0")
            {
                Response.Redirect(Globals.NavigateURL(), true);
            }
            else if (rblMode.SelectedValue == "1")
            {
                string copypath = Server.MapPath(TemplateEditorUtils.GenerateDirectory(ddlModule, ddlTypeCopy, ddlTemplate, PortalId, Server));
                CopyDirectoriesAndFiles(copypath, newpath);
                Response.Redirect(Globals.NavigateURL(), true);
            }
            else if (rblMode.SelectedValue == "2" && updZip.HasFile)
            {
                UnzipFile(updZip.PostedFile);
                Response.Redirect(Globals.NavigateURL(), true);
            }
            else
            {
                //lblMode.Text = Localization.GetString("lblModeZip", LocalResourceFile);
                //lblMode.HelpText = Localization.GetString("lblModeZip.Help", LocalResourceFile);

                lblemptyFile.Visible = true;
                lblemptyFile.Text    = Localization.GetString("emptyFile", LocalResourceFile);
            }
        }
Esempio n. 9
0
        protected void btnZip_Click(object sender, EventArgs e)
        {
            //string path = Server.MapPath(TemplateEditorUtils.GenerateDirectory(ddlModule, ddlType, ddlTemplate, PortalId, Server) + "\\");
            string path         = Server.MapPath(ddlTemplate.SelectedValue);
            string TemplateName = ddlTemplate.SelectedValue.TrimEnd('/');

            TemplateName = TemplateName.Substring(TemplateName.LastIndexOf("/") + 1);
            string          filename = PortalSettings.HomeDirectoryMapPath + "Templates\\" + TemplateName + ".zip";
            ZipOutputStream zip      = new ZipOutputStream(File.Create(filename));

            zip.SetLevel(9);
            TemplateEditorUtils.ZipFolder(path, path, zip);
            zip.Finish();
            zip.Close();
            Response.ContentType = "application/zip";
            Response.AppendHeader("content-disposition", "attachment; filename=\"" + TemplateName + ".zip\"");
            Response.CacheControl = "Private";
            Response.Cache.SetExpires(DateTime.Now.AddMinutes(3));
            Response.TransmitFile(filename);
            Response.Flush();
            Response.End();
        }
Esempio n. 10
0
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         if (!Page.IsPostBack)
         {
             foreach (var item in DataSourceProvider.GetProviderList())
             {
                 ddlDataSource.Items.Add(new ListItem(item.FriendlyName));
             }
             foreach (DataSourceConfigurator conf in phConfigurator.Controls)
             {
                 conf.Visible = ddlDataSource.SelectedValue == conf.ID;
             }
             TemplateEditorUtils.TemplateDataBind("Widgets", ddlTemplate, PortalId, LocalResourceFile, Server);
             TemplateEditorUtils.FileDataBind("Widgets", ddlTemplate, ddlFile, PortalId, LocalResourceFile, Server);
         }
     }
     catch (Exception exc) // Module failed to load
     {
         Exceptions.ProcessModuleLoadException(this, exc);
     }
 }
    public static void TemplateDataBind(string Module, int Type, DropDownList ddlTemplate, int PortalId, string LocalResourceFile, HttpServerUtility Server)
    {
        if (Type > 0)
        {
            ddlTemplate.Items.Clear();
            ddlTemplate.Items.Add(new ListItem(Localization.GetString("selectTemplate", LocalResourceFile), ""));
            string path = TemplateEditorUtils.GenerateDirectory(Module, Type, ddlTemplate.SelectedValue, PortalId, Server);
            if (!string.IsNullOrEmpty(path) && Directory.Exists(Server.MapPath(path)))
            {
                var dryLst = Directory.GetDirectories(Server.MapPath(path));

                foreach (string item in dryLst)
                {
                    int nb = item.LastIndexOf('\\');
                    ddlTemplate.Items.Add(item.Substring(nb + 1));
                }
            }
        }
        else
        {
            ddlTemplate.Items.Clear();
            ddlTemplate.Items.Add(new ListItem(Localization.GetString("selectTemplate", LocalResourceFile), ""));
        }
    }
Esempio n. 12
0
 protected void ddlTemplate_SelectedIndexChanged(object sender, EventArgs e)
 {
     TemplateEditorUtils.FileDataBind("Widgets", ddlTemplate, ddlFile, PortalId, LocalResourceFile, Server);
 }
Esempio n. 13
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");
        }