private void OnUpdateClick(object sender, EventArgs e)
 {
     try
     {
         if (cboFile.SelectedValue == "None")
         {
             //No file type selected
             UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("NoFileTypeSelected", LocalResourceFile), ModuleMessage.ModuleMessageType.RedError);
         }
         else
         {
             var objModuleControl = ModuleControlController.GetModuleControl(ModuleControlId);
             if (objModuleControl != null)
             {
                 var srcVirtualPath  = objModuleControl.ControlSrc;
                 var srcPhysicalPath = GetSourceFileName(srcVirtualPath);
                 if (File.Exists(srcPhysicalPath))
                 {
                     File.SetAttributes(srcPhysicalPath, FileAttributes.Normal);
                     var objStream = File.CreateText(srcPhysicalPath);
                     objStream.WriteLine(txtSource.Text);
                     objStream.Close();
                 }
             }
             Response.Redirect(ReturnURL, true);
         }
     }
     catch (Exception exc) //Module failed to load
     {
         Exceptions.ProcessModuleLoadException(this, exc);
     }
 }
示例#2
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            this.cboFile.SelectedIndexChanged += this.OnFileIndexChanged;
            this.cmdUpdate.Click += this.OnUpdateClick;

            if (this.Page.IsPostBack == false)
            {
                this.cmdCancel.NavigateUrl = this.ReturnURL;

                var objModuleControl = ModuleControlController.GetModuleControl(this.ModuleControlId);
                if (objModuleControl != null)
                {
                    this.BindFiles(objModuleControl.ControlSrc);
                }

                if (this.Request.UrlReferrer != null)
                {
                    this.ViewState["UrlReferrer"] = Convert.ToString(this.Request.UrlReferrer);
                }
                else
                {
                    this.ViewState["UrlReferrer"] = string.Empty;
                }
            }

            this.cmdUpdate.Visible = this.CanEditSource;
            this.txtSource.Enabled = this.CanEditSource;
        }
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            cboFile.SelectedIndexChanged += OnFileIndexChanged;
            cmdUpdate.Click += OnUpdateClick;

            if (Page.IsPostBack == false)
            {
                cmdCancel.NavigateUrl = ReturnURL;

                var objModuleControl = ModuleControlController.GetModuleControl(ModuleControlId);
                if (objModuleControl != null)
                {
                    BindFiles(objModuleControl.ControlSrc);
                }
                if (Request.UrlReferrer != null)
                {
                    ViewState["UrlReferrer"] = Convert.ToString(Request.UrlReferrer);
                }
                else
                {
                    ViewState["UrlReferrer"] = "";
                }
            }
            cmdUpdate.Visible = CanEditSource;
            txtSource.Enabled = CanEditSource;
        }
        private void OnConfigureClick(object sender, EventArgs e)
        {
            var        objModuleControl    = ModuleControlController.GetModuleControl(ModuleControlId);
            var        objModuleDefinition = ModuleDefinitionController.GetModuleDefinitionByID(objModuleControl.ModuleDefID);
            var        objDesktopModule    = DesktopModuleController.GetDesktopModule(objModuleDefinition.DesktopModuleID, PortalId);
            ModuleInfo objModule           = ModuleController.Instance.GetModuleByDefinition(-1, "Extensions");

            Response.Redirect(Globals.NavigateURL(objModule.TabID, "Edit", "mid=" + objModule.ModuleID.ToString(), "PackageID=" + objDesktopModule.PackageID.ToString()) + "?popUp=true", true);
        }
示例#5
0
        private void OnPackageClick(object sender, EventArgs e)
        {
            var        objModuleControl    = ModuleControlController.GetModuleControl(this.ModuleControlId);
            var        objModuleDefinition = ModuleDefinitionController.GetModuleDefinitionByID(objModuleControl.ModuleDefID);
            var        objDesktopModule    = DesktopModuleController.GetDesktopModule(objModuleDefinition.DesktopModuleID, this.PortalId);
            ModuleInfo objModule           = ModuleController.Instance.GetModuleByDefinition(-1, "Extensions");

            this.Response.Redirect(this._navigationManager.NavigateURL(objModule.TabID, "PackageWriter", "rtab=" + this.TabId.ToString(), "packageId=" + objDesktopModule.PackageID.ToString(), "mid=" + objModule.ModuleID.ToString()) + "?popUp=true", true);
        }
示例#6
0
        /// <Summary>Page_Load runs when the control is loaded.</Summary>
        protected void Page_Load(object sender, EventArgs e)
        {
            string FriendlyName = "";

            ModuleController objModules = new ModuleController();
            ModuleInfo       objModule  = objModules.GetModule(ModuleId, TabId, false);

            if (objModule != null)
            {
                FriendlyName = objModule.FriendlyName;
            }

            int ModuleControlId = Null.NullInteger;

            if (!(Request.QueryString["ctlid"] == null))
            {
                ModuleControlId = int.Parse(Request.QueryString["ctlid"]);
            }

            ModuleControlController objModuleControls = new ModuleControlController();
            ModuleControlInfo       objModuleControl  = objModuleControls.GetModuleControl(ModuleControlId);

            if (objModuleControl != null)
            {
                string FileName          = Path.GetFileName(objModuleControl.ControlSrc);
                string localResourceFile = objModuleControl.ControlSrc.Replace(FileName, Localization.LocalResourceDirectory + "/" + FileName);
                if (Localization.GetString(ModuleActionType.HelpText, localResourceFile) != "")
                {
                    lblHelp.Text = Localization.GetString(ModuleActionType.HelpText, localResourceFile);
                }
                _key = objModuleControl.ControlKey;

                string helpUrl = Globals.GetOnLineHelp(objModuleControl.HelpURL, ModuleConfiguration);
                if (!Null.IsNull(helpUrl))
                {
                    cmdHelp.NavigateUrl = Globals.FormatHelpUrl(helpUrl, PortalSettings, FriendlyName);
                    cmdHelp.Visible     = true;
                }
                else
                {
                    cmdHelp.Visible = false;
                }
            }

            if (Page.IsPostBack == false)
            {
                if (Request.UrlReferrer != null)
                {
                    ViewState["UrlReferrer"] = Convert.ToString(Request.UrlReferrer);
                }
                else
                {
                    ViewState["UrlReferrer"] = "";
                }
            }
        }
示例#7
0
        private void OnPackageClick(object sender, EventArgs e)
        {
            var objModuleControl        = ModuleControlController.GetModuleControl(ModuleControlId);
            var objModuleDefinition     = ModuleDefinitionController.GetModuleDefinitionByID(objModuleControl.ModuleDefID);
            var objDesktopModule        = DesktopModuleController.GetDesktopModule(objModuleDefinition.DesktopModuleID, PortalId);
            ModuleController objModules = new ModuleController();
            ModuleInfo       objModule  = objModules.GetModuleByDefinition(-1, "Extensions");

            Response.Redirect(Globals.NavigateURL(objModule.TabID, "PackageWriter", "rtab=" + TabId.ToString(), "packageId=" + objDesktopModule.PackageID.ToString(), "mid=" + objModule.ModuleID.ToString()) + "?popUp=true", true);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!CurrentUser.IsSuperAdmin)
            {
                Response.Redirect(AppEnv.ADMIN_CMD);
            }

            controlId = ConvertUtility.ToInt32(Request.QueryString["cid"]);
            moduleId  = ConvertUtility.ToInt32(Request.QueryString["mid"]);
            ModuleInfo        module        = ModuleController.GetModule(moduleId);
            ModuleControlInfo moduleControl = ModuleControlController.GetModuleControl(controlId);

            if (moduleControl == null)
            {
                this.btnDelete.Visible = false;
            }

            if (module == null)
            {
                module = ModuleController.GetModule(moduleControl.ModuleID);
            }
            if (module != null)
            {
                lblModuleName.Text         = module.ModuleName;
                txtControlIcon.fpUploadDir = CheckPath(module);
            }

            if (!Page.IsPostBack)
            {
                if (module != null && module.ModuleFolder.Length > 0)
                {
                    GetFiles(Server.MapPath("/"), Server.MapPath(module.ModuleFolder));
                    dropPath.DataSource = lstFile;
                    dropPath.DataBind();
                }
                MiscUtility.FillIndex(dropControlOrder, 30, 1);
                chkControlType.DataSource = RoleController.GetRoles();
                chkControlType.DataBind();
                if (moduleControl == null)
                {
                    return;
                }
                lblModuleName.Text         = ModuleController.GetModule(moduleControl.ModuleID).ModuleName;
                txtControlName.Text        = moduleControl.ControlName;
                txtControlDescription.Text = moduleControl.ControlDescription;
                txtControlKey.Text         = moduleControl.ControlKey;
                MiscUtility.SelectItemFromList(dropPath, moduleControl.ControlPath);
                txtControlIcon.Text        = moduleControl.ControlIcon;
                txtControlDescription.Text = moduleControl.ControlDescription;
                chkControlHeader.Checked   = moduleControl.ControlHeader;
                MiscUtility.SelectItemFromList(dropControlOrder, moduleControl.ControlOrder.ToString());
                string[] roleList = (moduleControl.ControlRole != null)?moduleControl.ControlRole.Split("|".ToCharArray()):null;
                MiscUtility.SelectItemFromList(chkControlType, roleList);
            }
        }
示例#9
0
        private void LoadReadMe()
        {
            var templatePath = this.Server.MapPath(this.ControlPath) + "Templates\\" + this.optLanguage.SelectedValue + "\\" + this.cboTemplate.SelectedItem.Value;

            if (File.Exists(templatePath + "\\readme.txt"))
            {
                var readMe = Null.NullString;
                using (TextReader tr = new StreamReader(templatePath + "\\readme.txt"))
                {
                    readMe = tr.ReadToEnd();
                    tr.Close();
                }

                this.lblDescription.Text = readMe.Replace("\n", "<br/>");
            }
            else
            {
                this.lblDescription.Text = string.Empty;
            }

            // Determine if Control Name is required
            var controlNameRequired = false;
            var controlName         = "<Not Required>";

            string[] fileList = Directory.GetFiles(templatePath);
            foreach (string filePath in fileList)
            {
                if (Path.GetFileName(filePath).ToLowerInvariant().IndexOf("template") > -1)
                {
                    controlNameRequired = true;
                    controlName         = "Edit";
                }
                else
                {
                    if (Path.GetFileName(filePath).EndsWith(".ascx"))
                    {
                        controlName = Path.GetFileNameWithoutExtension(filePath);
                    }
                }
            }

            this.txtControl.Text    = controlName;
            this.txtControl.Enabled = controlNameRequired;
            if (this.txtControl.Enabled)
            {
                if (!this.cboTemplate.SelectedItem.Value.ToLowerInvariant().StartsWith("module"))
                {
                    var objModuleControl    = ModuleControlController.GetModuleControl(this.ModuleControlId);
                    var objModuleDefinition = ModuleDefinitionController.GetModuleDefinitionByID(objModuleControl.ModuleDefID);
                    var objDesktopModule    = DesktopModuleController.GetDesktopModule(objModuleDefinition.DesktopModuleID, this.PortalId);
                    this.txtControl.Text = objDesktopModule.FriendlyName;
                }
            }
        }
示例#10
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            ServicesFramework.Instance.RequestAjaxAntiForgerySupport();

            this.cboFile.SelectedIndexChanged     += this.OnFileIndexChanged;
            this.optLanguage.SelectedIndexChanged += this.OnLanguageSelectedIndexChanged;
            this.cboTemplate.SelectedIndexChanged += this.cboTemplate_SelectedIndexChanged;
            this.cmdUpdate.Click    += this.OnUpdateClick;
            this.cmdPackage.Click   += this.OnPackageClick;
            this.cmdConfigure.Click += this.OnConfigureClick;
            this.cmdCreate.Click    += this.OnCreateClick;

            if (this.Page.IsPostBack == false)
            {
                this.cmdCancel1.NavigateUrl = this.ReturnURL;
                this.cmdCancel2.NavigateUrl = this.ReturnURL;

                var objModuleControl = ModuleControlController.GetModuleControl(this.ModuleControlId);
                if (objModuleControl != null)
                {
                    this.BindFiles(objModuleControl.ControlSrc);
                    this.LoadFile();
                }

                if (this.Request.UrlReferrer != null)
                {
                    this.ViewState["UrlReferrer"] = Convert.ToString(this.Request.UrlReferrer);
                }
                else
                {
                    this.ViewState["UrlReferrer"] = string.Empty;
                }

                this.LoadLanguages();
                this.LoadModuleTemplates();
                if (this.cboTemplate.Items.FindByText("Module - User Control") != null)
                {
                    this.cboTemplate.Items.FindByText("Module - User Control").Selected = true;
                }

                this.LoadReadMe();
            }
        }
示例#11
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            ServicesFramework.Instance.RequestAjaxAntiForgerySupport();

            cboFile.SelectedIndexChanged     += OnFileIndexChanged;
            optLanguage.SelectedIndexChanged += OnLanguageSelectedIndexChanged;
            cboTemplate.SelectedIndexChanged += cboTemplate_SelectedIndexChanged;
            cmdUpdate.Click    += OnUpdateClick;
            cmdPackage.Click   += OnPackageClick;
            cmdConfigure.Click += OnConfigureClick;
            cmdCreate.Click    += OnCreateClick;

            if (Page.IsPostBack == false)
            {
                cmdCancel1.NavigateUrl = Globals.NavigateURL();
                cmdCancel2.NavigateUrl = Globals.NavigateURL();

                var objModuleControl = ModuleControlController.GetModuleControl(ModuleControlId);
                if (objModuleControl != null)
                {
                    BindFiles(objModuleControl.ControlSrc);
                    LoadFile();
                }

                if (Request.UrlReferrer != null)
                {
                    ViewState["UrlReferrer"] = Convert.ToString(Request.UrlReferrer);
                }
                else
                {
                    ViewState["UrlReferrer"] = "";
                }

                LoadLanguages();
                LoadModuleTemplates();
                if (cboTemplate.Items.FindByText("Module - User Control") != null)
                {
                    cboTemplate.Items.FindByText("Module - User Control").Selected = true;
                }
                LoadReadMe();
            }
        }
示例#12
0
        protected ModuleControlBase LoadAdminControl(string controlKey)
        {
            ModuleControlInfo moduleControl = ModuleControlController.GetModuleControl(controlKey);

            if (moduleControl != null)
            {
                if (File.Exists(Server.MapPath(moduleControl.ControlPath)))
                {
                    try
                    {
                        ModuleControlBase controlToLoad = (ModuleControlBase)LoadControl(moduleControl.ControlPath);
                        controlToLoad.ControlID = moduleControl.ControlID;
                        return(controlToLoad);
                    }
                    catch (Exception ex)
                    {
                        Response.Write(ex.Message);
                    }
                }
            }
            return(null);
        }
        private void DisplayFile()
        {
            var objModuleControl = ModuleControlController.GetModuleControl(ModuleControlId);

            if (objModuleControl != null)
            {
                var srcVirtualPath = objModuleControl.ControlSrc;
                var srcFile        = Null.NullString;
                var displaySource  = cboFile.SelectedValue != "None";

                if (displaySource)
                {
                    srcFile            = GetSourceFileName(srcVirtualPath);
                    lblSourceFile.Text = string.Format(Localization.GetString("SourceFile", LocalResourceFile), srcFile);

                    var objStreamReader = File.OpenText(srcFile);
                    txtSource.Text = objStreamReader.ReadToEnd();
                    objStreamReader.Close();
                }
                lblSourceFile.Visible = displaySource;
                trSource.Visible      = displaySource;
            }
        }
示例#14
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            cboSource.SelectedIndexChanged += cboSource_SelectedIndexChanged;
            cmdCancel.Click += cmdCancel_Click;
            cmdDelete.Click += cmdDelete_Click;
            cmdUpdate.Click += cmdUpdate_Click;

            try
            {
                ModuleDefId     = (Request.QueryString["moduledefid"] != null) ? Int32.Parse(Request.QueryString["moduledefid"]) : Null.NullInteger;
                ModuleControlId = (Request.QueryString["modulecontrolid"] != null) ? Int32.Parse(Request.QueryString["modulecontrolid"]) : Null.NullInteger;
                if (Page.IsPostBack == false)
                {
                    lblModule.Text = DesktopModule.FriendlyName;
                    var objModuleDefinition = ModuleDefinitionController.GetModuleDefinitionByID(ModuleDefId);
                    if (objModuleDefinition != null)
                    {
                        lblDefinition.Text = objModuleDefinition.FriendlyName;
                    }
                    ClientAPI.AddButtonConfirm(cmdDelete, Localization.GetString("DeleteItem"));
                    var moduleControl = ModuleControlController.GetModuleControl(ModuleControlId);
                    BindControlList("DesktopModules", true);
                    BindControlList("Admin/Skins", false);
                    //cboSource.Items.Insert(0, new ListItem("<" + Localization.GetString("None_Specified") + ">", ""));
                    cboSource.InsertItem(0, "<" + Localization.GetString("None_Specified") + ">", "");
                    if (!Null.IsNull(ModuleControlId))
                    {
                        if (moduleControl != null)
                        {
                            txtKey.Text   = moduleControl.ControlKey;
                            txtTitle.Text = moduleControl.ControlTitle;
                            if (cboSource.FindItemByValue(moduleControl.ControlSrc.ToLower()) != null)
                            {
                                cboSource.FindItemByValue(moduleControl.ControlSrc.ToLower()).Selected = true;
                                LoadIcons();
                            }
                            else
                            {
                                txtSource.Text = moduleControl.ControlSrc;
                            }
                            if (cboType.FindItemByValue(Convert.ToInt32(moduleControl.ControlType).ToString()) != null)
                            {
                                cboType.FindItemByValue(Convert.ToInt32(moduleControl.ControlType).ToString()).Selected = true;
                            }
                            if (!Null.IsNull(moduleControl.ViewOrder))
                            {
                                txtViewOrder.Text = moduleControl.ViewOrder.ToString();
                            }
                            if (cboIcon.FindItemByValue(moduleControl.IconFile.ToLower()) != null)
                            {
                                cboIcon.FindItemByValue(moduleControl.IconFile.ToLower()).Selected = true;
                            }
                            if (!Null.IsNull(moduleControl.HelpURL))
                            {
                                txtHelpURL.Text = moduleControl.HelpURL;
                            }
                            if (moduleControl.SupportsPartialRendering)
                            {
                                chkSupportsPartialRendering.Checked = true;
                            }
                            supportsModalPopUpsCheckBox.Checked = moduleControl.SupportsPopUps;
                        }
                    }
                    else
                    {
                        if (cboType.Enabled)
                        {
                            cboType.FindItemByValue("0").Selected = true;
                        }
                        else
                        {
                            cboType.FindItemByValue("-2").Selected = true;
                        }
                    }
                }
            }
            catch (Exception exc)
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
示例#15
0
        /// <summary>
        /// Page_Load runs when the control is loaded.
        /// </summary>
        /// <returns></returns>
        /// <remarks>
        /// </remarks>
        /// <history>
        ///     [cnurse]	9/28/2004	Updated to reflect design changes for Help, 508 support
        ///                       and localisation
        /// </history>
        protected void Page_Load(Object sender, EventArgs e)
        {
            try
            {
                if ((Request.QueryString["desktopmoduleid"] != null))
                {
                    DesktopModuleId = int.Parse(Request.QueryString["desktopmoduleid"]);
                    if (DesktopModuleId == -2)
                    {
                        DesktopModuleId = Null.NullInteger;
                    }
                }
                else
                {
                    DesktopModuleId = Null.NullInteger;
                }

                if ((Request.QueryString["moduledefid"] != null))
                {
                    ModuleDefId = int.Parse(Request.QueryString["moduledefid"]);
                }
                else
                {
                    ModuleDefId = Null.NullInteger;
                }

                if ((Request.QueryString["modulecontrolid"] != null))
                {
                    ModuleControlId = int.Parse(Request.QueryString["modulecontrolid"]);
                }
                else
                {
                    ModuleControlId = Null.NullInteger;
                }

                if (Page.IsPostBack == false)
                {
                    DesktopModuleController objDesktopModules = new DesktopModuleController();
                    DesktopModuleInfo       objDesktopModule;

                    objDesktopModule = objDesktopModules.GetDesktopModule(DesktopModuleId);
                    if (objDesktopModule != null)
                    {
                        txtModule.Text = objDesktopModule.FriendlyName;
                    }
                    else
                    {
                        txtModule.Text       = Localization.GetString("SkinObjects");
                        txtTitle.Enabled     = false;
                        cboType.Enabled      = false;
                        txtViewOrder.Enabled = false;
                        cboIcon.Enabled      = false;
                    }

                    ModuleDefinitionController objModuleDefinitions = new ModuleDefinitionController();
                    ModuleDefinitionInfo       objModuleDefinition;

                    objModuleDefinition = objModuleDefinitions.GetModuleDefinition(ModuleDefId);
                    if (objModuleDefinition != null)
                    {
                        txtDefinition.Text = objModuleDefinition.FriendlyName;
                    }

                    ClientAPI.AddButtonConfirm(cmdDelete, Localization.GetString("DeleteItem"));

                    ModuleControlController objModuleControls = new ModuleControlController();
                    ModuleControlInfo       objModuleControl;

                    objModuleControl = objModuleControls.GetModuleControl(ModuleControlId);

                    // Added to populate cboSource with desktop module or skin controls
                    // Issue #586
                    BindControlList("DesktopModules", true);
                    BindControlList("Admin/Skins", false);
                    if (objDesktopModule == null)  // Add Container Controls
                    {
                        BindControlList("Admin/Containers", false);
                    }

                    if (!Null.IsNull(ModuleControlId))
                    {
                        if (objModuleControl != null)
                        {
                            txtKey.Text   = objModuleControl.ControlKey;
                            txtTitle.Text = objModuleControl.ControlTitle;
                            if (cboSource.Items.FindByValue(objModuleControl.ControlSrc.ToString().ToLower()) != null)
                            {
                                cboSource.Items.FindByValue(objModuleControl.ControlSrc.ToString().ToLower()).Selected = true;
                                LoadIcons();
                            }
                            if (cboType.Items.FindByValue(Convert.ToInt32(objModuleControl.ControlType).ToString()) != null)
                            {
                                cboType.Items.FindByValue(Convert.ToInt32(objModuleControl.ControlType).ToString()).Selected = true;
                            }
                            if (!Null.IsNull(objModuleControl.ViewOrder))
                            {
                                txtViewOrder.Text = objModuleControl.ViewOrder.ToString();
                            }
                            if (cboIcon.Items.FindByValue(objModuleControl.IconFile.ToLower()) != null)
                            {
                                cboIcon.Items.FindByValue(objModuleControl.IconFile.ToLower()).Selected = true;
                            }
                            if (!Null.IsNull(objModuleControl.HelpURL))
                            {
                                txtHelpURL.Text = objModuleControl.HelpURL;
                            }
                        }
                    }
                }
            }
            catch (Exception exc)  //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
示例#16
0
        private void BindFiles(string controlSrc)
        {
            string[] fileList;
            cboFile.Items.Clear();

            var objModuleControl    = ModuleControlController.GetModuleControl(ModuleControlId);
            var objModuleDefinition = ModuleDefinitionController.GetModuleDefinitionByID(objModuleControl.ModuleDefID);
            var objDesktopModule    = DesktopModuleController.GetDesktopModule(objModuleDefinition.DesktopModuleID, PortalId);

            var relativePath = $"DesktopModules/{(objModuleControl.ControlSrc.EndsWith(".mvc") ? "MVC/" : string.Empty)}{objDesktopModule.FolderName}/";
            var modulePath   = Server.MapPath(relativePath);

            if (Directory.Exists(modulePath))
            {
                //iterate through files in desktopmodules folder
                fileList = Directory.GetFiles(modulePath, "*", SearchOption.AllDirectories);
                foreach (string filePath in fileList)
                {
                    switch (Path.GetExtension(filePath).ToLower())
                    {
                    case ".ascx":
                        cboFile.Items.Add(new ListItem(filePath.Substring(modulePath.Length), filePath));
                        var resxPath = filePath.Replace(Path.GetFileName(filePath), "App_LocalResources\\" + Path.GetFileName(filePath)) + ".resx";
                        if (File.Exists(resxPath))
                        {
                            cboFile.Items.Add(new ListItem(filePath.Substring(modulePath.Length), resxPath));
                        }
                        break;

                    case ".vb":
                    case ".cs":
                    case ".vbhtml":
                    case ".cshtml":
                    case ".css":
                    case ".js":
                    case ".txt":
                    case ".html":
                    case ".xml":
                    case ".xslt":
                    case ".sql":
                    case ".sqldataprovider":
                        cboFile.Items.Add(new ListItem(filePath.Substring(modulePath.Length), filePath));
                        break;
                    }
                }
            }
            else
            {
                DotNetNuke.UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("FolderNameInvalid", LocalResourceFile), ModuleMessage.ModuleMessageType.RedError);
            }


            //iterate through files in app_code folder
            modulePath = Globals.ApplicationMapPath + "\\App_Code\\" + objDesktopModule.FolderName.Replace("/", "\\") + "\\";
            if (Directory.Exists(modulePath))
            {
                fileList = Directory.GetFiles(modulePath);
                foreach (string filePath in fileList)
                {
                    switch (Path.GetExtension(filePath).ToLower())
                    {
                    case ".vb":
                        cboFile.Items.Add(new ListItem(Path.GetFileName(filePath), filePath));
                        break;

                    case ".cs":
                        cboFile.Items.Add(new ListItem(Path.GetFileName(filePath), filePath));
                        break;
                    }
                }
            }

            // select file
            if (cboFile.Items.FindByValue(Globals.ApplicationMapPath + "\\" + controlSrc.Replace("/", "\\")) != null)
            {
                cboFile.Items.FindByValue(Globals.ApplicationMapPath + "\\" + controlSrc.Replace("/", "\\")).Selected = true;
            }
        }
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                if (controlId == 0)                 // add control
                {
                    if (txtControlKey.Text != string.Empty && ModuleControlController.CheckExistsControlKey(txtControlKey.Text))
                    {
                        this.lblUpdateStatus.Text = MiscUtility.MSG_CONTROKEY_EXISTS;
                        return;
                    }
                    ModuleInfo module = ModuleController.GetModule(moduleId);
                    if (module == null)
                    {
                        return;
                    }
                    ModuleControlInfo moduleControl = new ModuleControlInfo();
                    moduleControl.ModuleID      = module.ModuleID;
                    moduleControl.ControlName   = txtControlName.Text.Trim();
                    moduleControl.ControlKey    = txtControlKey.Text.Trim();
                    moduleControl.ControlPath   = dropPath.SelectedValue;
                    moduleControl.ControlIcon   = txtControlIcon.Text.Trim();
                    moduleControl.ControlOrder  = ConvertUtility.ToInt32(dropControlOrder.SelectedValue);
                    moduleControl.ControlHeader = chkControlHeader.Checked;
                    string roleList = "|";
                    foreach (ListItem item in chkControlType.Items)
                    {
                        if (item.Selected)
                        {
                            roleList += item.Value + "|";
                        }
                    }
                    if (roleList.Length < 2)
                    {
                        roleList = string.Empty;
                    }
                    moduleControl.ControlTitle       = txtControlTitle.Text;
                    moduleControl.ControlRole        = roleList;
                    moduleControl.ControlDescription = txtControlDescription.Text.Trim();

                    ModuleControlController.AddModuleControl(moduleControl);
                }
                else                 // update control
                {
                    ModuleControlInfo moduleControl = ModuleControlController.GetModuleControl(controlId);
                    moduleControl.ControlName        = txtControlName.Text.Trim();
                    moduleControl.ControlDescription = txtControlDescription.Text;
                    moduleControl.ControlKey         = txtControlKey.Text.Trim();
                    moduleControl.ControlPath        = dropPath.SelectedValue;
                    moduleControl.ControlIcon        = txtControlIcon.Text.Trim();
                    moduleControl.ControlOrder       = ConvertUtility.ToInt32(dropControlOrder.SelectedValue);
                    string roleList = "|";
                    foreach (ListItem item in chkControlType.Items)
                    {
                        if (item.Selected)
                        {
                            roleList += item.Value + "|";
                        }
                    }
                    //if (roleList.Length < 2) roleList = string.Empty;
                    moduleControl.ControlRole        = roleList;
                    moduleControl.ControlDescription = txtControlDescription.Text.Trim();
                    moduleControl.ControlHeader      = chkControlHeader.Checked;
                    ModuleControlController.UpdateModuleControl(moduleControl);
                }
                this.lblUpdateStatus.Text = MiscUtility.MSG_UPDATE_SUCCESS;
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }
        }
示例#18
0
        private string CreateModuleControl()
        {
            var objModuleControl    = ModuleControlController.GetModuleControl(ModuleControlId);
            var objModuleDefinition = ModuleDefinitionController.GetModuleDefinitionByID(objModuleControl.ModuleDefID);
            var objDesktopModule    = DesktopModuleController.GetDesktopModule(objModuleDefinition.DesktopModuleID, PortalId);
            var objPackage          = PackageController.Instance.GetExtensionPackage(Null.NullInteger, p => p.PackageID == objDesktopModule.PackageID);

            var moduleTemplatePath = Server.MapPath(ControlPath) + "Templates\\" + optLanguage.SelectedValue + "\\" + cboTemplate.SelectedValue + "\\";


            EventLogController.Instance.AddLog("Processing Template Folder", moduleTemplatePath, PortalSettings, -1, EventLogController.EventLogType.HOST_ALERT);


            var controlName = Null.NullString;
            var fileName    = Null.NullString;
            var modulePath  = Null.NullString;
            var sourceCode  = Null.NullString;

            //iterate through files in template folder
            string[] fileList = Directory.GetFiles(moduleTemplatePath);
            foreach (string filePath in fileList)
            {
                modulePath = Server.MapPath("DesktopModules/" + objDesktopModule.FolderName + "/");

                //open file
                using (TextReader tr = new StreamReader(filePath))
                {
                    sourceCode = tr.ReadToEnd();
                    tr.Close();
                }

                //replace tokens
                var owner = objPackage.Owner.Replace(" ", "");
                if (string.IsNullOrEmpty(owner))
                {
                    owner = "DNN";
                }
                sourceCode = sourceCode.Replace("_OWNER_", owner);
                sourceCode = sourceCode.Replace("_MODULE_", objDesktopModule.FriendlyName.Replace(" ", ""));
                sourceCode = sourceCode.Replace("_CONTROL_", GetControl());
                sourceCode = sourceCode.Replace("_YEAR_", DateTime.Now.Year.ToString());

                //get filename
                fileName = Path.GetFileName(filePath);
                fileName = fileName.Replace("template", GetControl());
                fileName = fileName.Replace("_OWNER_", objPackage.Owner.Replace(" ", ""));
                fileName = fileName.Replace("_MODULE_", objDesktopModule.FriendlyName.Replace(" ", ""));
                fileName = fileName.Replace("_CONTROL_", GetControl());

                switch (Path.GetExtension(filePath).ToLower())
                {
                case ".ascx":
                    controlName = fileName;
                    break;

                case ".vbhtml":
                    controlName = fileName;
                    break;

                case ".cshtml":
                    controlName = fileName;
                    break;

                case ".resx":
                    modulePath = modulePath + "\\App_LocalResources\\";
                    break;

                case ".vb":
                    if (filePath.ToLower().IndexOf(".ascx") == -1)
                    {
                        modulePath = modulePath.Replace("DesktopModules", "App_Code");
                    }
                    break;

                case ".cs":
                    if (filePath.ToLower().IndexOf(".ascx") == -1)
                    {
                        modulePath = modulePath.Replace("DesktopModules", "App_Code");
                    }
                    break;

                case ".js":
                    modulePath = modulePath + "\\js\\";
                    break;
                }

                //check if folder exists
                if (!Directory.Exists(modulePath))
                {
                    Directory.CreateDirectory(modulePath);
                }

                //check if file already exists
                if (!File.Exists(modulePath + fileName))
                {
                    //create file
                    using (TextWriter tw = new StreamWriter(modulePath + fileName))
                    {
                        tw.WriteLine(sourceCode);
                        tw.Close();
                    }

                    EventLogController.Instance.AddLog("Created File", modulePath + fileName, PortalSettings, -1, EventLogController.EventLogType.HOST_ALERT);
                }
            }

            //Create module control
            if (controlName != Null.NullString)
            {
                try
                {
                    objModuleControl = new ModuleControlInfo();
                    objModuleControl.ModuleControlID          = Null.NullInteger;
                    objModuleControl.ModuleDefID              = objModuleDefinition.ModuleDefID;
                    objModuleControl.ControlKey               = GetControl();
                    objModuleControl.ControlSrc               = "DesktopModules/" + objDesktopModule.FolderName + "/" + controlName;
                    objModuleControl.ControlTitle             = txtControl.Text;
                    objModuleControl.ControlType              = (SecurityAccessLevel)Enum.Parse(typeof(SecurityAccessLevel), cboType.SelectedItem.Value);
                    objModuleControl.HelpURL                  = "";
                    objModuleControl.IconFile                 = "";
                    objModuleControl.ViewOrder                = 0;
                    objModuleControl.SupportsPartialRendering = true;
                    objModuleControl.SupportsPopUps           = true;
                    ModuleControlController.AddModuleControl(objModuleControl);
                    controlName = objModuleControl.ControlSrc;
                }
                catch
                {
                    //Suppress error
                }
            }

            DotNetNuke.UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("ControlCreated", LocalResourceFile), ModuleMessage.ModuleMessageType.GreenSuccess);

            return(controlName);
        }
示例#19
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Page_Load runs when the control is loaded.
        /// </summary>
        /// <remarks>
        /// </remarks>
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            cmdCancel.Click += cmdCancel_Click;
            int moduleControlId = Null.NullInteger;

            if (Request.QueryString["ctlid"] != null)
            {
                moduleControlId = Int32.Parse(Request.QueryString["ctlid"]);
            }
            else if (Host.EnableModuleOnLineHelp)
            {
                helpFrame.Text = string.Format("<iframe src='{0}' id='helpFrame' width='100%' height='500' />", Host.HelpURL);
            }

            ModuleControlInfo objModuleControl = ModuleControlController.GetModuleControl(moduleControlId);

            if (objModuleControl != null)
            {
                if (!string.IsNullOrEmpty(objModuleControl.HelpURL) && Host.EnableModuleOnLineHelp)
                {
                    helpFrame.Text = string.Format("<iframe src='{0}' id='helpFrame' width='100%' height='500' />", objModuleControl.HelpURL);;
                }
                else
                {
                    string fileName          = Path.GetFileName(objModuleControl.ControlSrc);
                    string localResourceFile = objModuleControl.ControlSrc.Replace(fileName, Localization.LocalResourceDirectory + "/" + fileName);
                    if (!String.IsNullOrEmpty(Localization.GetString(ModuleActionType.HelpText, localResourceFile)))
                    {
                        lblHelp.Text = Localization.GetString(ModuleActionType.HelpText, localResourceFile);
                    }
                    else
                    {
                        lblHelp.Text = Localization.GetString("lblHelp.Text", Localization.GetResourceFile(this, MyFileName));
                    }
                }

                _key = objModuleControl.ControlKey;
                //display module info to Host users
                if (UserInfo.IsSuperUser)
                {
                    string strInfo = Localization.GetString("lblInfo.Text", Localization.GetResourceFile(this, MyFileName));
                    strInfo = strInfo.Replace("[CONTROL]", objModuleControl.ControlKey);
                    strInfo = strInfo.Replace("[SRC]", objModuleControl.ControlSrc);
                    ModuleDefinitionInfo objModuleDefinition = ModuleDefinitionController.GetModuleDefinitionByID(objModuleControl.ModuleDefID);
                    if (objModuleDefinition != null)
                    {
                        strInfo = strInfo.Replace("[DEFINITION]", objModuleDefinition.FriendlyName);
                        DesktopModuleInfo objDesktopModule = DesktopModuleController.GetDesktopModule(objModuleDefinition.DesktopModuleID, PortalId);
                        if (objDesktopModule != null)
                        {
                            PackageInfo objPackage = PackageController.Instance.GetExtensionPackage(Null.NullInteger, p => p.PackageID == objDesktopModule.PackageID);
                            if (objPackage != null)
                            {
                                strInfo = strInfo.Replace("[ORGANIZATION]", objPackage.Organization);
                                strInfo = strInfo.Replace("[OWNER]", objPackage.Owner);
                                strInfo = strInfo.Replace("[EMAIL]", objPackage.Email);
                                strInfo = strInfo.Replace("[URL]", objPackage.Url);
                                strInfo = strInfo.Replace("[MODULE]", objPackage.Name);
                                strInfo = strInfo.Replace("[VERSION]", objPackage.Version.ToString());
                            }
                        }
                    }
                    lblInfo.Text = Server.HtmlDecode(strInfo);
                }

                cmdHelp.Visible = !string.IsNullOrEmpty(objModuleControl.HelpURL);
            }
            if (Page.IsPostBack == false)
            {
                if (Request.UrlReferrer != null)
                {
                    ViewState["UrlReferrer"] = Convert.ToString(Request.UrlReferrer);
                }
                else
                {
                    ViewState["UrlReferrer"] = "";
                }
            }
        }
示例#20
0
文件: Help.cs 项目: misterPaul0/Curt
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Page_Load runs when the control is loaded.
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <history>
        /// </history>
        /// -----------------------------------------------------------------------------
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            cmdCancel.Click += cmdCancel_Click;

            string     FriendlyName = "";
            var        objModules   = new ModuleController();
            ModuleInfo objModule    = objModules.GetModule(ModuleId, TabId, false);

            if (objModule != null)
            {
                FriendlyName = objModule.DesktopModule.FriendlyName;
            }
            int ModuleControlId = Null.NullInteger;

            if (Request.QueryString["ctlid"] != null)
            {
                ModuleControlId = Int32.Parse(Request.QueryString["ctlid"]);
            }
            ModuleControlInfo objModuleControl = ModuleControlController.GetModuleControl(ModuleControlId);

            if (objModuleControl != null)
            {
                string FileName          = Path.GetFileName(objModuleControl.ControlSrc);
                string LocalResourceFile = objModuleControl.ControlSrc.Replace(FileName, Localization.LocalResourceDirectory + "/" + FileName);
                if (!String.IsNullOrEmpty(Localization.GetString(ModuleActionType.HelpText, LocalResourceFile)))
                {
                    lblHelp.Text = Localization.GetString(ModuleActionType.HelpText, LocalResourceFile);
                }
                else
                {
                    lblHelp.Text = Localization.GetString("lblHelp.Text", Localization.GetResourceFile(this, MyFileName));
                }
                _key = objModuleControl.ControlKey;

                string helpUrl = Globals.GetOnLineHelp(objModuleControl.HelpURL, ModuleConfiguration);
                if (!string.IsNullOrEmpty(helpUrl))
                {
                    var version = Globals.FormatVersion(DotNetNukeContext.Current.Application.Version, false);
                    cmdHelp.NavigateUrl = Globals.FormatHelpUrl(helpUrl, PortalSettings, FriendlyName, version);
                    cmdHelp.Visible     = true;
                }
                else
                {
                    cmdHelp.Visible = false;
                }

                //display module info to Host users
                if (UserInfo.IsSuperUser)
                {
                    string strInfo = Localization.GetString("lblInfo.Text", Localization.GetResourceFile(this, MyFileName));
                    strInfo = strInfo.Replace("[CONTROL]", objModuleControl.ControlKey);
                    strInfo = strInfo.Replace("[SRC]", objModuleControl.ControlSrc);
                    ModuleDefinitionInfo objModuleDefinition = ModuleDefinitionController.GetModuleDefinitionByID(objModuleControl.ModuleDefID);
                    if (objModuleDefinition != null)
                    {
                        strInfo = strInfo.Replace("[DEFINITION]", objModuleDefinition.FriendlyName);
                        DesktopModuleInfo objDesktopModule = DesktopModuleController.GetDesktopModule(objModuleDefinition.DesktopModuleID, PortalId);
                        if (objDesktopModule != null)
                        {
                            PackageInfo objPackage = PackageController.GetPackage(objDesktopModule.PackageID);
                            if (objPackage != null)
                            {
                                strInfo = strInfo.Replace("[ORGANIZATION]", objPackage.Organization);
                                strInfo = strInfo.Replace("[OWNER]", objPackage.Owner);
                                strInfo = strInfo.Replace("[EMAIL]", objPackage.Email);
                                strInfo = strInfo.Replace("[URL]", objPackage.Url);
                                strInfo = strInfo.Replace("[MODULE]", objPackage.Name);
                                strInfo = strInfo.Replace("[VERSION]", objPackage.Version.ToString());
                            }
                        }
                    }
                    lblInfo.Text = Server.HtmlDecode(strInfo);
                }
            }
            if (Page.IsPostBack == false)
            {
                if (Request.UrlReferrer != null)
                {
                    ViewState["UrlReferrer"] = Convert.ToString(Request.UrlReferrer);
                }
                else
                {
                    ViewState["UrlReferrer"] = "";
                }
            }
        }