public string SaveCss(string fileName, string oldName, string fileContents, int fileID)
        {
            if (AuthorizeRequest(DefaultApps.settings.ToString()))
            {
                string returnValue;
                var stylesheet = new StyleSheet(fileID)
                    {
                        Content = fileContents, Text = fileName
                    };

                try
                {
                    stylesheet.saveCssToFile();
                    stylesheet.Save();
                    returnValue = "true";


                    //deletes the old css file if the name was changed... 
                    if (fileName.ToLowerInvariant() != oldName.ToLowerInvariant())
                    {
                        var p = IOHelper.MapPath(SystemDirectories.Css + "/" + oldName + ".css");
                        if (File.Exists(p))
                            File.Delete(p);
                    }

                }
                catch (Exception ex)
                {
                    return ex.ToString();
                }

                return returnValue;
            }
            return "false";
        }
        public bool Delete()
        {
            cms.businesslogic.web.StylesheetProperty sp = new cms.businesslogic.web.StylesheetProperty(ParentID);
            cms.businesslogic.web.StyleSheet         s  = sp.StyleSheet();
            s.saveCssToFile();
            sp.delete();

            return(true);
        }
示例#3
0
        public string SaveCss(string fileName, string oldName, string fileContents, int fileID)
        {
            if (BasePage.ValidateUserContextID(BasePage.umbracoUserContextID))
            {
                string returnValue = "false";
                StyleSheet stylesheet = new StyleSheet(fileID);

                if (stylesheet != null)
                {
                    stylesheet.Content = fileContents;
                    stylesheet.Text = fileName;
                    try
                    {
                        stylesheet.saveCssToFile();
                        stylesheet.Save();
                        returnValue = "true";


                        //deletes the old css file if the name was changed... 
                        if (fileName != oldName)
                        {
                            string p = IOHelper.MapPath(SystemDirectories.Css + "/" + oldName + ".css");
                            if (System.IO.File.Exists(p))
                                System.IO.File.Delete(p);
                        }

                    }
                    catch (Exception ex)
                    {
                        return ex.ToString();
                    }

                    //this.speechBubble(speechBubbleIcon.save, ui.Text("speechBubbles", "editStylesheetSaved", base.getUser()), "");
                }
                return returnValue;
            }
            return "false";
        }
示例#4
0
        public static StyleSheet Import(XmlNode n, umbraco.BusinessLogic.User u)
        {
            string     stylesheetName = xmlHelper.GetNodeValue(n.SelectSingleNode("Name"));
            StyleSheet s = GetByName(stylesheetName);

            if (s == null)
            {
                s = StyleSheet.MakeNew(
                    u,
                    stylesheetName,
                    xmlHelper.GetNodeValue(n.SelectSingleNode("FileName")),
                    xmlHelper.GetNodeValue(n.SelectSingleNode("Content")));
            }

            foreach (XmlNode prop in n.SelectNodes("Properties/Property"))
            {
                string alias = xmlHelper.GetNodeValue(prop.SelectSingleNode("Alias"));
                var    sp    = s.Properties.SingleOrDefault(p => p != null && p.Alias == alias);
                string name  = xmlHelper.GetNodeValue(prop.SelectSingleNode("Name"));
                if (sp == default(StylesheetProperty))
                {
                    sp = StylesheetProperty.MakeNew(
                        name,
                        s,
                        u);
                }
                else
                {
                    sp.Text = name;
                }
                sp.Alias = alias;
                sp.value = xmlHelper.GetNodeValue(prop.SelectSingleNode("Value"));
            }
            s.saveCssToFile();

            return(s);
        }
        private static string SaveCss(string fileName, string fileContents, int fileID)
        {
            string returnValue;
            var stylesheet = new StyleSheet(fileID) {Content = fileContents, Text = fileName};

	        try
	        {
		        stylesheet.saveCssToFile();
		        returnValue = "true";
	        }
	        catch (Exception ee)
	        {
		        throw new Exception("Couldn't save file", ee);
	        }

	        //this.speechBubble(speechBubbleIcon.save, ui.Text("speechBubbles", "editStylesheetSaved", base.getUser()), "");
	        return returnValue;
        }
示例#6
0
        public void update(stylesheetCarrier carrier, string username, string password)
        {
            Authenticate(username, password);

            StyleSheet stylesheet = null;
            try
            {
                stylesheet = new StyleSheet(carrier.Id);
            }
            catch
            { }

            if (stylesheet == null)
                throw new Exception("Could not load stylesheet with id: " + carrier.Id);

            stylesheet.Content = carrier.Content;
            stylesheet.saveCssToFile();
        }
        private static string SaveCss(string fileName, string fileContents, int fileId)
        {
            string returnValue;
            var stylesheet = new StyleSheet(fileId)
                {
                    Content = fileContents,
                    Text = fileName
                };

            try
            {
                stylesheet.saveCssToFile();
                returnValue = "true";
            }
            catch (Exception ee)
            {
                throw new Exception("Couldn't save file", ee);
            }

	        return returnValue;
        }