Exemple #1
0
        public HttpResponseMessage UpdateTheme(UpdateThemeInfo updateTheme)
        {
            try
            {
                var token = SkinControlController.GetSkinControls().Values.FirstOrDefault(t => t.ControlSrc == updateTheme.Token);
                if (token == null)
                {
                    return(this.Request.CreateErrorResponse(HttpStatusCode.BadRequest, "InvalidParameter"));
                }

                var themeFilePath = updateTheme.Path.ToLowerInvariant();
                if ((!themeFilePath.StartsWith("[g]") && !themeFilePath.StartsWith("[l]") && !themeFilePath.StartsWith("[s]")) ||
                    (themeFilePath.StartsWith("[g]") && !this.UserInfo.IsSuperUser))
                {
                    return(this.Request.CreateErrorResponse(HttpStatusCode.BadRequest, "InvalidPermission"));
                }

                updateTheme.Token = token.ControlKey;
                this._controller.UpdateTheme(this.PortalSettings, updateTheme);
                return(this.Request.CreateResponse(HttpStatusCode.OK, new { }));
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                return(this.Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message));
            }
        }
        private void LoadTokens()
        {
            cboTokens.DataSource = SkinControlController.GetSkinControls().Values;
            cboTokens.DataBind();

            cboTokens.InsertItem(0, "<" + Localization.GetString("Not_Specified") + ">", "");
        }
Exemple #3
0
 public static void ProcessLegacySkinControls()
 {
     foreach (SkinControlInfo skinControl in SkinControlController.GetSkinControls().Values)
     {
         if (skinControl.PackageID == Null.NullInteger)
         {
             try
             {
                 PackageInfo package = new PackageInfo(new InstallerInfo());
                 package.Name         = skinControl.ControlKey;
                 package.FriendlyName = skinControl.ControlKey;
                 package.Description  = Null.NullString;
                 package.Version      = new Version(1, 0, 0);
                 package.PackageType  = "SkinObject";
                 ParsePackageName(package);
                 SkinControlPackageWriter skinControlWriter = new SkinControlPackageWriter(skinControl, package);
                 package.Manifest = skinControlWriter.WriteManifest(true);
                 PackageController.SavePackage(package);
                 skinControl.PackageID = package.PackageID;
                 SkinControlController.SaveSkinControl(skinControl);
             }
             catch (Exception ex)
             {
                 ex.ToString();
             }
         }
     }
 }
Exemple #4
0
        public HttpResponseMessage GetEditableTokens()
        {
            try
            {
                var tokens = SkinControlController.GetSkinControls().Values
                             .Where(c => !string.IsNullOrEmpty(c.ControlKey) && !string.IsNullOrEmpty(c.ControlSrc))
                             .Select(c => new ListItemInfo {
                    Text = c.ControlKey, Value = c.ControlSrc
                });

                return(this.Request.CreateResponse(HttpStatusCode.OK, tokens));
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                return(this.Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message));
            }
        }
        /// <summary>
        /// Process legacy skinobject version 3 .dnn install package
        /// </summary>
        public static void ProcessLegacySkinControls()
        {
            foreach (SkinControlInfo skinControl in SkinControlController.GetSkinControls().Values)
            {
                if (skinControl.PackageID == Null.NullInteger)
                {
                    try
                    {
                        //SkinControl is not affiliated with a Package
                        var package = new PackageInfo(new InstallerInfo());
                        package.Name = skinControl.ControlKey;

                        package.FriendlyName = skinControl.ControlKey;
                        package.Description  = Null.NullString;
                        package.Version      = new Version(1, 0, 0);
                        package.PackageType  = "SkinObject";

                        //See if the SkinControl is using a "Namespace" for its name
                        ParsePackageName(package);

                        var skinControlWriter = new SkinControlPackageWriter(skinControl, package);
                        package.Manifest = skinControlWriter.WriteManifest(true);

                        //Save Package
                        PackageController.Instance.SaveExtensionPackage(package);

                        //Update SkinControl with new PackageID
                        skinControl.PackageID = package.PackageID;

                        //Save SkinControl
                        SkinControlController.SaveSkinControl(skinControl);
                    }
                    catch (Exception exc)
                    {
                        Logger.Error(exc);
                    }
                }
            }
        }
Exemple #6
0
        public SkinFileProcessor(string SkinPath, string SkinRoot, string SkinName)
        {
            this.Message += SkinController.FormatMessage(INITIALIZE_PROCESSOR, SkinRoot + " :: " + SkinName, 0, false);
            m_SkinRoot    = SkinRoot;
            m_SkinPath    = SkinPath;
            m_SkinName    = SkinName;
            string FileName = this.SkinPath + this.SkinRoot + "\\" + this.SkinName + "\\" + SkinRoot.Substring(0, SkinRoot.Length - 1) + ".xml";

            if (File.Exists(FileName))
            {
                try
                {
                    this.SkinAttributes.Load(FileName);
                    this.Message += SkinController.FormatMessage(PACKAGE_LOAD, Path.GetFileName(FileName), 2, false);
                }
                catch (Exception ex)
                {
                    this.Message += SkinController.FormatMessage(string.Format(PACKAGE_LOAD_ERROR, ex.Message), Path.GetFileName(FileName), 2, true);
                }
            }
            string Token;

            foreach (SkinControlInfo objSkinControl in SkinControlController.GetSkinControls().Values)
            {
                Token = objSkinControl.ControlKey.ToUpper();
                if (m_ControlList.ContainsKey(Token))
                {
                    this.Message += SkinController.FormatMessage(string.Format(DUPLICATE_ERROR, objSkinControl.ControlKey.ToString().ToUpper()), string.Format(DUPLICATE_DETAIL, (string)m_ControlList[Token], objSkinControl.ControlSrc.ToString()), 2, true);
                }
                else
                {
                    this.Message += SkinController.FormatMessage(string.Format(LOAD_SKIN_TOKEN, objSkinControl.ControlKey.ToString().ToUpper()), objSkinControl.ControlSrc.ToString(), 2, false);
                    m_ControlList.Add(Token, objSkinControl.ControlSrc);
                }
            }
            m_ControlFactory = new ControlParser(m_ControlList);
            m_ObjectFactory  = new ObjectParser(m_ControlList);
        }