예제 #1
0
        public Inject ComponentProperties(string id, string section)
        {
            if (R.isSessionLost() == true)
            {
                return(lostInject());
            }
            Inject response = new Inject();

            response.element = ".winProperties .props-content";

            //check security
            if (R.User.Website(R.Page.websiteId).getWebsiteSecurityItem("dashboard/pages", 0) == false)
            {
                return(response);
            }

            //load properties window
            ComponentView comp      = R.Page.GetComponentViewById(id);
            string        cid       = comp.ComponentName.Replace(" ", ".");
            string        className = "Rennder.Components.Properties." + cid;
            Type          type      = Type.GetType(className, false, true);

            if (type == null)
            {
                return(response);
            }
            ComponentProperties properties = (ComponentProperties)Activator.CreateInstance(type, new object[] { R, comp });

            if (comp == null)
            {
                return(response);
            }

            //load properties.js
            string js = "";

            if (R.Server.Cache.ContainsKey("props-" + cid) == true & R.isLocal == false)
            {
                //load from cache
                js = (string)R.Server.Cache["props-" + cid];
            }
            else
            {
                //load from file
                string jsp = File.ReadAllText(R.Server.MapPath("/app/components/" + cid + "/properties.js"));
                js = jsp;
                if (R.isLocal == false)
                {
                    //save to cache
                    R.Server.Cache.Add("props-" + cid, jsp);
                }
            }
            R.Page.RegisterJS("props", "R.editor.components.properties.loaded('" + comp.ComponentName +
                              "'," + properties.Width + ");" + js);

            //finally, render properties window
            response.html = properties.Render();
            response.js   = CompileJs();

            return(response);
        }