protected void OnDeleteClick(object sender, EventArgs e)
        {
            var failure          = false;
            var strSkinPath      = Globals.ApplicationMapPath.ToLower() + cboSkins.SelectedItem.Value;
            var strContainerPath = Globals.ApplicationMapPath.ToLower() + cboContainers.SelectedItem.Value;

            string strMessage;

            if (UserInfo.IsSuperUser == false && cboSkins.SelectedItem.Value.IndexOf("\\portals\\_default\\", 0) != -1)
            {
                strMessage = Localization.GetString("SkinDeleteFailure", LocalResourceFile);
                UI.Skins.Skin.AddModuleMessage(this, strMessage, ModuleMessage.ModuleMessageType.RedError);
                failure = true;
            }
            else
            {
                if (cboSkins.SelectedIndex > 0)
                {
                    SkinPackageInfo skinPackage = SkinController.GetSkinPackage(PortalId, cboSkins.SelectedItem.Text, "Skin");
                    if (skinPackage != null)
                    {
                        strMessage = Localization.GetString("UsePackageUnInstall", LocalResourceFile);
                        UI.Skins.Skin.AddModuleMessage(this, strMessage, ModuleMessage.ModuleMessageType.RedError);
                        return;
                    }
                    if (Directory.Exists(strSkinPath))
                    {
                        Globals.DeleteFolderRecursive(strSkinPath);
                    }
                    if (Directory.Exists(strSkinPath.Replace("\\" + SkinController.RootSkin.ToLower() + "\\", "\\" + SkinController.RootContainer + "\\")))
                    {
                        Globals.DeleteFolderRecursive(strSkinPath.Replace("\\" + SkinController.RootSkin.ToLower() + "\\", "\\" + SkinController.RootContainer + "\\"));
                    }
                }
                else if (cboContainers.SelectedIndex > 0)
                {
                    var skinPackage = SkinController.GetSkinPackage(PortalId, cboContainers.SelectedItem.Text, "Container");
                    if (skinPackage != null)
                    {
                        strMessage = Localization.GetString("UsePackageUnInstall", LocalResourceFile);
                        UI.Skins.Skin.AddModuleMessage(this, strMessage, ModuleMessage.ModuleMessageType.RedError);
                        return;
                    }
                    if (Directory.Exists(strContainerPath))
                    {
                        Globals.DeleteFolderRecursive(strContainerPath);
                    }
                }
            }
            if (!failure)
            {
                LoadCombos();
                ShowSkins();
                ShowContainers();
            }
        }
Exemple #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="portalSettings"></param>
        /// <param name="theme"></param>
        public void DeleteThemePackage(PortalSettings portalSettings, ThemeInfo theme)
        {
            var themePath = Path.Combine(Globals.ApplicationMapPath, theme.Path);
            var user      = UserController.Instance.GetCurrentUserInfo();

            if (!user.IsSuperUser && themePath.IndexOf("\\portals\\_default\\", StringComparison.InvariantCultureIgnoreCase) != Null.NullInteger)
            {
                throw new SecurityException("NoPermission");
            }

            if (theme.Type == ThemeType.Skin)
            {
                var skinPackage = SkinController.GetSkinPackage(portalSettings.PortalId, theme.PackageName, "Skin");
                if (skinPackage != null)
                {
                    throw new InvalidOperationException("UsePackageUninstall");
                }

                if (Directory.Exists(themePath))
                {
                    Globals.DeleteFolderRecursive(themePath);
                }
                if (Directory.Exists(themePath.Replace("\\" + SkinController.RootSkin.ToLower() + "\\", "\\" + SkinController.RootContainer + "\\")))
                {
                    Globals.DeleteFolderRecursive(themePath.Replace("\\" + SkinController.RootSkin.ToLower() + "\\", "\\" + SkinController.RootContainer + "\\"));
                }
            }
            else if (theme.Type == ThemeType.Container)
            {
                var skinPackage = SkinController.GetSkinPackage(portalSettings.PortalId, theme.PackageName, "Container");
                if (skinPackage != null)
                {
                    throw new InvalidOperationException("UsePackageUninstall");
                }

                if (Directory.Exists(themePath))
                {
                    Globals.DeleteFolderRecursive(themePath);
                }
            }
        }
        private void ShowSkins()
        {
            tblSkins.Rows.Clear();
            var intPortalId = PortalId;

            var strSkinPath = Globals.ApplicationMapPath.ToLower() + cboSkins.SelectedItem.Value;

            if (strSkinPath.ToLowerInvariant().Contains(Globals.HostMapPath.ToLowerInvariant()))
            {
                intPortalId = Null.NullInteger;
            }
            var skinPackage = SkinController.GetSkinPackage(intPortalId, cboSkins.SelectedItem.Text, "Skin");

            if (skinPackage == null)
            {
                lblLegacy.Visible = (cboSkins.SelectedIndex > 0);
            }
            if (cboSkins.SelectedIndex > 0)
            {
                ProcessSkins(strSkinPath, "Skin");
                pnlSkin.Visible = true;
                if (UserInfo.IsSuperUser || strSkinPath.IndexOf(Globals.HostMapPath.ToLower()) == -1)
                {
                    cmdParse.Visible = true;
                    pnlParse.Visible = true;
                }
                else
                {
                    cmdParse.Visible = false;
                    pnlParse.Visible = false;
                }
            }
            else
            {
                pnlSkin.Visible  = false;
                pnlParse.Visible = false;
            }
        }
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// The Install method installs the skin component
        /// </summary>
        public override void Install()
        {
            bool bAdd = Null.NullBoolean;

            try
            {
                //Attempt to get the Skin Package
                TempSkinPackage = SkinController.GetSkinPackage(SkinPackage.PortalID, SkinPackage.SkinName, SkinType);
                if (TempSkinPackage == null)
                {
                    bAdd = true;
                    SkinPackage.PackageID = Package.PackageID;
                }
                else
                {
                    SkinPackage.SkinPackageID = TempSkinPackage.SkinPackageID;
                    if (TempSkinPackage.PackageID != Package.PackageID)
                    {
                        Completed = false;
                        Log.AddFailure(Util.SKIN_Installed);
                        return;
                    }
                    else
                    {
                        SkinPackage.PackageID = TempSkinPackage.PackageID;
                    }
                }
                SkinPackage.SkinType = SkinType;
                if (bAdd)
                {
                    //Add new skin package
                    SkinPackage.SkinPackageID = SkinController.AddSkinPackage(SkinPackage);
                }
                else
                {
                    //Update skin package
                    SkinController.UpdateSkinPackage(SkinPackage);
                }
                Log.AddInfo(string.Format(Util.SKIN_Registered, SkinPackage.SkinName));

                //install (copy the files) by calling the base class
                base.Install();

                //process the list of skin files
                if (SkinFiles.Count > 0)
                {
                    Log.StartJob(Util.SKIN_BeginProcessing);
                    string strMessage = Null.NullString;
                    var    NewSkin    = new SkinFileProcessor(RootPath, SkinRoot, SkinPackage.SkinName);
                    foreach (string skinFile in SkinFiles)
                    {
                        strMessage += NewSkin.ProcessFile(skinFile, SkinParser.Portable);
                        skinFile.Replace(Globals.HostMapPath + "\\", "[G]");
                        switch (Path.GetExtension(skinFile))
                        {
                        case ".htm":
                            SkinController.AddSkin(SkinPackage.SkinPackageID, skinFile.Replace("htm", "ascx"));
                            break;

                        case ".html":
                            SkinController.AddSkin(SkinPackage.SkinPackageID, skinFile.Replace("html", "ascx"));
                            break;

                        case ".ascx":
                            SkinController.AddSkin(SkinPackage.SkinPackageID, skinFile);
                            break;
                        }
                    }
                    Array arrMessage = strMessage.Split(new[] { "<br />" }, StringSplitOptions.None);
                    foreach (string strRow in arrMessage)
                    {
                        Log.AddInfo(HtmlUtils.StripTags(strRow, true));
                    }
                    Log.EndJob(Util.SKIN_EndProcessing);
                }
                Completed = true;
            }
            catch (Exception ex)
            {
                Log.AddFailure(ex);
            }
        }