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"; }
protected void Page_Load(object sender, EventArgs e) { Panel1.Text = ui.Text("stylesheet", "editstylesheet", UmbracoUser); pp_name.Text = ui.Text("name", UmbracoUser); pp_path.Text = ui.Text("path", UmbracoUser); stylesheet = new StyleSheet(int.Parse(Request.QueryString["id"])); var appPath = Request.ApplicationPath; if (appPath == "/") appPath = ""; lttPath.Text = "<a target='_blank' href='" + appPath + "/css/" + stylesheet.Text + ".css'>" + appPath + SystemDirectories.Css + "/" + stylesheet.Text + ".css</a>"; if (IsPostBack == false) { NameTxt.Text = stylesheet.Text; editorSource.Text = stylesheet.Content; ClientTools .SetActiveTreeType(TreeDefinitionCollection.Instance.FindTree<loadStylesheets>().Tree.Alias) .SyncTree("-1,init," + Request.GetItemAsString("id"), false); } }
public IEnumerable<StylesheetRule> GetRules(int id) { var css = new StyleSheet(id); if (css == null) throw new HttpResponseException(System.Net.HttpStatusCode.NotFound); return css.Properties.Select(x => new StylesheetRule() { Id = x.Id, Name = x.Text, Selector = x.Alias }); }
public static StylesheetProperty MakeNew(string Text, StyleSheet sheet, BusinessLogic.User user) { CMSNode newNode = CMSNode.MakeNew(sheet.Id, moduleObjectType, user.Id, 2, Text, Guid.NewGuid()); SqlHelper.ExecuteNonQuery(String.Format("Insert into cmsStylesheetProperty (nodeId,stylesheetPropertyAlias,stylesheetPropertyValue) values ('{0}','{1}','')", newNode.Id, Text)); StylesheetProperty ssp = new StylesheetProperty(newNode.Id); NewEventArgs e = new NewEventArgs(); ssp.OnNew(e); return ssp; }
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); }
public bool Save() { try { cms.businesslogic.web.StyleSheet s = new cms.businesslogic.web.StyleSheet(ParentID); int id = s.AddProperty(Alias, BusinessLogic.User.GetUser(_userID)).Id; m_returnUrl = string.Format("settings/stylesheet/property/EditStyleSheetProperty.aspx?id={0}", id); } catch { throw new ArgumentException("DER ER SKET EN FEJL MED AT OPRETTE NOGET MED ET PARENT ID : " + ParentID); } return true; }
public override bool PerformSave() { try { var s = new cms.businesslogic.web.StyleSheet(ParentID); var id = s.AddProperty(Alias, User).Id; _returnUrl = string.Format("settings/stylesheet/property/EditStyleSheetProperty.aspx?id={0}", id); } catch { throw new ArgumentException("DER ER SKET EN FEJL MED AT OPRETTE NOGET MED ET PARENT ID : " + ParentID); } return true; }
public SortNode GetNodes(int ParentId, string App) { if (BasePage.ValidateUserContextID(BasePage.umbracoUserContextID)) { SortNode parent = new SortNode(); parent.Id = ParentId; ArrayList _nodes = new ArrayList(); cms.businesslogic.CMSNode n = new cms.businesslogic.CMSNode(ParentId); // Root nodes? if (ParentId == -1) { if (App == "media") { foreach (cms.businesslogic.media.Media child in cms.businesslogic.media.Media.GetRootMedias()) _nodes.Add(new SortNode(child.Id, child.sortOrder, child.Text, child.CreateDateTime)); } else foreach (cms.businesslogic.web.Document child in cms.businesslogic.web.Document.GetRootDocuments()) _nodes.Add(new SortNode(child.Id, child.sortOrder, child.Text, child.CreateDateTime)); } else { // "hack for stylesheet" if (App == "settings") { StyleSheet ss = new StyleSheet(n.Id); foreach (cms.businesslogic.web.StylesheetProperty child in ss.Properties) _nodes.Add(new SortNode(child.Id, child.sortOrder, child.Text, child.CreateDateTime)); } else { //store children array here because iterating over an Array property object is very inneficient. var children = n.Children; foreach (cms.businesslogic.CMSNode child in children) { _nodes.Add(new SortNode(child.Id, child.sortOrder, child.Text, child.CreateDateTime)); } } } parent.SortNodes = (SortNode[])_nodes.ToArray(typeof(SortNode)); return parent; } throw new ArgumentException("User not logged in"); }
public bool Save() { try { cms.businesslogic.web.StyleSheet s = new cms.businesslogic.web.StyleSheet(ParentID); int id = s.AddProperty(Alias, BusinessLogic.User.GetUser(_userID)).Id; m_returnUrl = string.Format("settings/stylesheet/property/EditStyleSheetProperty.aspx?id={0}", id); } catch { throw new ArgumentException("DER ER SKET EN FEJL MED AT OPRETTE NOGET MED ET PARENT ID : " + ParentID); } return(true); }
public static void SaveToDisk(StyleSheet item) { if (item != null) { try { XmlDocument xmlDoc = helpers.XmlDoc.CreateDoc(); xmlDoc.AppendChild(item.ToXml(xmlDoc)); helpers.XmlDoc.SaveXmlDoc(item.GetType().ToString(), item.Text, xmlDoc); } catch (Exception ex) { Log.Add(LogTypes.Error, 0, String.Format("uSync: Error Reading Stylesheet {0} - {1}", item.Text, ex.ToString())); throw new SystemException(string.Format("error saving stylesheet {0}", item.Text), ex); } } }
public SortNode GetNodes(int ParentId, string App) { if (BasePage.ValidateUserContextID(BasePage.umbracoUserContextID)) { var parent = new SortNode { Id = ParentId }; var nodes = new List<SortNode>(); var entityService = base.ApplicationContext.Services.EntityService; // Root nodes? if (ParentId == -1) { if (App == "media") { var rootMedia = entityService.GetRootEntities(UmbracoObjectTypes.Media); nodes.AddRange(rootMedia.Select(media => new SortNode(media.Id, media.SortOrder, media.Name, media.CreateDate))); } else { var rootContent = entityService.GetRootEntities(UmbracoObjectTypes.Document); nodes.AddRange(rootContent.Select(content => new SortNode(content.Id, content.SortOrder, content.Name, content.CreateDate))); } } else { // "hack for stylesheet" if (App == "settings") { var cmsNode = new cms.businesslogic.CMSNode(ParentId); var styleSheet = new StyleSheet(cmsNode.Id); nodes.AddRange(styleSheet.Properties.Select(child => new SortNode(child.Id, child.sortOrder, child.Text, child.CreateDateTime))); } else { var children = entityService.GetChildren(ParentId); nodes.AddRange(children.Select(child => new SortNode(child.Id, child.SortOrder, child.Name, child.CreateDate))); } } parent.SortNodes = nodes.ToArray(); return parent; } throw new ArgumentException("User not logged in"); }
public stylesheetCarrier read(int id, string username, string password) { Authenticate(username, password); StyleSheet stylesheet; try { stylesheet = new StyleSheet(id); } catch (Exception) { throw new Exception("Could not load stylesheet with id: " + id + ", not found"); } if (stylesheet == null) throw new Exception("Could not load stylesheet with id: " + id + ", not found"); return createCarrier(stylesheet); }
public override void Render(ref XmlTree tree) { StyleSheet sn = new StyleSheet(m_id); foreach (StylesheetProperty n in sn.Properties) { XmlTreeNode xNode = XmlTreeNode.Create(this); xNode.NodeID = n.Id.ToString(); xNode.Text = n.Text; xNode.Action = "javascript:openStylesheetProperty(" + n.Id + ");"; xNode.Icon = "icon-brackets"; xNode.OpenIcon = "icon-brackets"; OnBeforeNodeRender(ref tree, ref xNode, EventArgs.Empty); if (xNode != null) { tree.Add(xNode); OnAfterNodeRender(ref tree, ref xNode, EventArgs.Empty); } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { // editor source if (!UmbracoSettings.ScriptDisableEditor) { // TODO: Register the some script editor js file if you can find a good one. } ClientTools .SetActiveTreeType(TreeDefinitionCollection.Instance.FindTree<loadStylesheets>().Tree.Alias) .SyncTree("-1,init," + helper.Request("id"), false); } MenuIconI save = Panel1.Menu.NewIcon(); save.ImageURL = SystemDirectories.Umbraco + "/images/editor/save.gif"; save.OnClickCommand = "doSubmit()"; save.AltText = "Save stylesheet"; save.ID = "save"; Panel1.Text = ui.Text("stylesheet", "editstylesheet", base.getUser()); pp_name.Text = ui.Text("name", base.getUser()); pp_path.Text = ui.Text("path", base.getUser()); stylesheet = new StyleSheet(int.Parse(Request.QueryString["id"])); string appPath = Request.ApplicationPath; if (appPath == "/") appPath = ""; lttPath.Text = "<a target='_blank' href='" + appPath + "/css/" + stylesheet.Text + ".css'>" + appPath + IO.SystemDirectories.Css + "/" + stylesheet.Text + ".css</a>"; if (!IsPostBack) { NameTxt.Text = stylesheet.Text; editorSource.Text = stylesheet.Content; } }
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"; }
protected void Page_Load(object sender, EventArgs e) { if (Request.QueryString["id"] != null) { pack = cms.businesslogic.packager.InstalledPackage.GetById(int.Parse(Request.QueryString["id"])); lt_packagename.Text = pack.Data.Name; lt_packageVersion.Text = pack.Data.Version; lt_packageAuthor.Text = pack.Data.Author; lt_readme.Text = library.ReplaceLineBreaks( pack.Data.Readme ); bt_confirmUninstall.Attributes.Add("onClick", "jQuery('#buttons').hide(); jQuery('#loadingbar').show();; return true;"); if (!Page.IsPostBack) { //temp list to contain failing items... List<string> tempList = new List<string>(); foreach (string str in pack.Data.Documenttypes) { int tId = 0; if (int.TryParse(str, out tId)) { try { DocumentType dc = new DocumentType(tId); if (dc != null) { ListItem li = new ListItem(dc.Text, dc.Id.ToString()); li.Selected = true; documentTypes.Items.Add(li); } else { tempList.Add(str); } } catch { tempList.Add(str); } } } //removing failing documentTypes items from the uninstall manifest syncLists(pack.Data.Documenttypes, tempList); foreach (string str in pack.Data.Templates) { int tId = 0; if (int.TryParse(str, out tId)) { try { Template t = new Template(tId); if (t != null) { ListItem li = new ListItem(t.Text, t.Id.ToString()); li.Selected = true; templates.Items.Add(li); } else { tempList.Add(str); } } catch { tempList.Add(str); } } } //removing failing template items from the uninstall manifest syncLists(pack.Data.Templates, tempList); foreach (string str in pack.Data.Stylesheets) { int tId = 0; if (int.TryParse(str, out tId)) { try { StyleSheet s = new StyleSheet(tId); if (s != null) { ListItem li = new ListItem(s.Text, s.Id.ToString()); li.Selected = true; stylesheets.Items.Add(li); } else { tempList.Add(str); } } catch { tempList.Add(str); } } } //removing failing stylesheet items from the uninstall manifest syncLists(pack.Data.Stylesheets, tempList); foreach (string str in pack.Data.Macros) { int tId = 0; if (int.TryParse(str, out tId)) { try { Macro m = new Macro(tId); if (m != null && !string.IsNullOrEmpty(m.Name)) { //Macros need an extra check to see if they actually exists. For some reason the macro does not return null, if the id is not found... ListItem li = new ListItem(m.Name, m.Id.ToString()); li.Selected = true; macros.Items.Add(li); } else { tempList.Add(str); } } catch { tempList.Add(str); } } } //removing failing macros items from the uninstall manifest syncLists(pack.Data.Macros, tempList); foreach (string str in pack.Data.Files) { try { if (!String.IsNullOrEmpty(str) && System.IO.File.Exists( IOHelper.MapPath(str) )) { ListItem li = new ListItem(str, str); li.Selected = true; files.Items.Add(li); } else { tempList.Add(str); } } catch { tempList.Add(str); } } //removing failing files from the uninstall manifest syncLists(pack.Data.Files, tempList); foreach (string str in pack.Data.DictionaryItems) { int tId = 0; if (int.TryParse(str, out tId)) { try { cms.businesslogic.Dictionary.DictionaryItem di = new global::umbraco.cms.businesslogic.Dictionary.DictionaryItem(tId); if (di != null) { ListItem li = new ListItem(di.key, di.id.ToString()); li.Selected = true; dictionaryItems.Items.Add(li); } else { tempList.Add(str); } } catch { tempList.Add(str); } } } //removing failing files from the uninstall manifest syncLists(pack.Data.DictionaryItems, tempList); foreach (string str in pack.Data.DataTypes) { int tId = 0; if (int.TryParse(str, out tId)) { try { cms.businesslogic.datatype.DataTypeDefinition dtd = new global::umbraco.cms.businesslogic.datatype.DataTypeDefinition(tId); if (dtd != null) { ListItem li = new ListItem(dtd.Text, dtd.Id.ToString()); li.Selected = true; dataTypes.Items.Add(li); } else { tempList.Add(str); } } catch { tempList.Add(str); } } } //removing failing files from the uninstall manifest syncLists(pack.Data.DataTypes, tempList); //save the install manifest, so even tho the user doesn't uninstall, it stays uptodate. pack.Save(); //Look for updates on packages. if (!String.IsNullOrEmpty(pack.Data.RepositoryGuid) && !String.IsNullOrEmpty(pack.Data.PackageGuid)) { try { repo = cms.businesslogic.packager.repositories.Repository.getByGuid(pack.Data.RepositoryGuid); if (repo != null) { hl_packageRepo.Text = repo.Name; hl_packageRepo.NavigateUrl = "BrowseRepository.aspx?repoGuid=" + repo.Guid; pp_repository.Visible = true; } cms.businesslogic.packager.repositories.Package repoPackage = repo.Webservice.PackageByGuid(pack.Data.PackageGuid); if (repoPackage != null) { if (repoPackage.HasUpgrade && repoPackage.UpgradeVersion != pack.Data.Version) { bt_update.Visible = true; bt_update.Text = "Update available: version: " + repoPackage.UpgradeVersion; lt_upgradeReadme.Text = repoPackage.UpgradeReadMe; bt_gotoUpgrade.OnClientClick = "window.location.href = 'browseRepository.aspx?url=" + repoPackage.Url + "'; return true;"; lt_noUpdate.Visible = false; } else { bt_update.Visible = false; lt_noUpdate.Visible = true; } if (!string.IsNullOrEmpty(repoPackage.Demo)) { lb_demoLink.OnClientClick = "openDemo(this, '" + pack.Data.PackageGuid + "'); return false;"; pp_documentation.Visible = true; } if(!string.IsNullOrEmpty(repoPackage.Documentation)) { hl_docLink.NavigateUrl = repoPackage.Documentation; hl_docLink.Target = "_blank"; pp_documentation.Visible = true; } } } catch { bt_update.Visible = false; lt_noUpdate.Visible = true; } } bool deletePackage = true; //sync the UI to match what is in the package if (macros.Items.Count == 0) pp_macros.Visible = false; else deletePackage = false; if (documentTypes.Items.Count == 0) pp_docTypes.Visible = false; else deletePackage = false; if (files.Items.Count == 0) pp_files.Visible = false; else deletePackage = false; if (templates.Items.Count == 0) pp_templates.Visible = false; else deletePackage = false; if (stylesheets.Items.Count == 0) pp_css.Visible = false; else deletePackage = false; if (dictionaryItems.Items.Count == 0) pp_di.Visible = false; else deletePackage = false; if (dataTypes.Items.Count == 0) pp_dt.Visible = false; else deletePackage = false; if (deletePackage) { pane_noItems.Visible = true; bt_uninstall.Visible = false; pane_uninstall.Visible = false; } } } }
public void RefreshFromFile() { // ping the stylesheet web.StyleSheet ss = new StyleSheet(this.Parent.Id); initProperty(); }
protected void confirmUnInstall(object sender, EventArgs e) { bool refreshCache = false; //Uninstall Stylesheets foreach (ListItem li in stylesheets.Items) { if (li.Selected) { int nId; if (int.TryParse(li.Value, out nId)) { StyleSheet s = new StyleSheet(nId); if (s != null) { s.delete(); pack.Data.Stylesheets.Remove(nId.ToString()); } } } } //Uninstall templates foreach (ListItem li in templates.Items) { if (li.Selected) { int nId; if (int.TryParse(li.Value, out nId)) { Template s = new Template(nId); if (s != null) { s.RemoveAllReferences(); s.delete(); pack.Data.Templates.Remove(nId.ToString()); } } } } //Uninstall macros foreach (ListItem li in macros.Items) { if (li.Selected) { int nId; if (int.TryParse(li.Value, out nId)) { Macro s = new Macro(nId); if (s != null && !String.IsNullOrEmpty(s.Name)) { // remove from cache runtimeMacro.GetMacro(s.Id).removeFromCache(); s.Delete(); } pack.Data.Macros.Remove(nId.ToString()); } } } //Remove Document types foreach (ListItem li in documentTypes.Items) { if (li.Selected) { int nId; if (int.TryParse(li.Value, out nId)) { DocumentType s = new DocumentType(nId); if (s != null) { s.delete(); pack.Data.Documenttypes.Remove(nId.ToString()); // refresh content cache when document types are removed refreshCache = true; } } } } //Remove Dictionary items foreach (ListItem li in dictionaryItems.Items) { if (li.Selected) { int nId; if (int.TryParse(li.Value, out nId)) { cms.businesslogic.Dictionary.DictionaryItem di = new global::umbraco.cms.businesslogic.Dictionary.DictionaryItem(nId); if (di != null) { di.delete(); pack.Data.DictionaryItems.Remove(nId.ToString()); } } } } //Remove Data types foreach (ListItem li in dataTypes.Items) { if (li.Selected) { int nId; if (int.TryParse(li.Value, out nId)) { cms.businesslogic.datatype.DataTypeDefinition dtd = new global::umbraco.cms.businesslogic.datatype.DataTypeDefinition(nId); if (dtd != null) { dtd.delete(); pack.Data.DataTypes.Remove(nId.ToString()); } } } } pack.Save(); if (!isManifestEmpty()) { Response.Redirect(Request.RawUrl); } else { BusinessLogic.Log.Add(global::umbraco.BusinessLogic.LogTypes.Debug, -1, "executing undo actions"); // uninstall actions try { System.Xml.XmlDocument actionsXml = new System.Xml.XmlDocument(); actionsXml.LoadXml("<Actions>" + pack.Data.Actions + "</Actions>"); BusinessLogic.Log.Add(global::umbraco.BusinessLogic.LogTypes.Debug, -1, actionsXml.OuterXml); foreach (XmlNode n in actionsXml.DocumentElement.SelectNodes("//Action")) { try { cms.businesslogic.packager.PackageAction.UndoPackageAction(pack.Data.Name, n.Attributes["alias"].Value, n); } catch (Exception ex) { BusinessLogic.Log.Add(global::umbraco.BusinessLogic.LogTypes.Debug, -1, ex.ToString()); } } } catch (Exception ex) { BusinessLogic.Log.Add(global::umbraco.BusinessLogic.LogTypes.Debug, -1, ex.ToString()); } //moved remove of files here so custom package actions can still undo //Remove files foreach (ListItem li in files.Items) { if (li.Selected) { //here we need to try to find the file in question as most packages does not support the tilde char string file = IOHelper.FindFile(li.Value); string filePath = IOHelper.MapPath(file); if (System.IO.File.Exists(filePath)) { System.IO.File.Delete(filePath); pack.Data.Files.Remove(li.Value); } } } pack.Save(); pack.Delete(); packageUninstalled.Visible = true; installedPackagePanel.Visible = false; } // refresh cache if (refreshCache) { library.RefreshContent(); } //ensure that all tree's are refreshed after uninstall ClientTools.ClearClientTreeCache() .RefreshTree(); TreeDefinitionCollection.Instance.ReRegisterTrees(); BizLogicAction.ReRegisterActionsAndHandlers(); }
public override bool PerformDelete() { var s = new cms.businesslogic.web.StyleSheet(ParentID); s.delete(); return true; }
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; }
void StyleSheet_AfterSave(StyleSheet sender, umbraco.cms.businesslogic.SaveEventArgs e) { ItemIdentifier itemId = new ItemIdentifier(sender.Text, ItemProviders.ProviderIDCollection.stylesheetItemProviderGuid); sendToCache(itemId); }
public void Publish() { CreatedPackage package = this; PackageInstance pack = package.Data; try { PublishEventArgs e = new PublishEventArgs(); package.FireBeforePublish(e); if (!e.Cancel) { int outInt = 0; //Path checking... string localPath = IOHelper.MapPath(SystemDirectories.Media + "/" + pack.Folder); if (!System.IO.Directory.Exists(localPath)) System.IO.Directory.CreateDirectory(localPath); //Init package file... createPackageManifest(); //Info section.. appendElement(utill.PackageInfo(pack, _packageManifest)); //Documents... int _contentNodeID = 0; if (!String.IsNullOrEmpty(pack.ContentNodeId) && int.TryParse(pack.ContentNodeId, out _contentNodeID)) { XmlNode documents = _packageManifest.CreateElement("Documents"); XmlNode documentSet = _packageManifest.CreateElement("DocumentSet"); XmlAttribute importMode = _packageManifest.CreateAttribute("importMode", ""); importMode.Value = "root"; documentSet.Attributes.Append(importMode); documents.AppendChild(documentSet); //load content from umbraco. cms.businesslogic.web.Document umbDocument = new Document(_contentNodeID); documentSet.AppendChild(umbDocument.ToXml(_packageManifest, pack.ContentLoadChildNodes)); appendElement(documents); } //Document types.. List<DocumentType> dtl = new List<DocumentType>(); XmlNode docTypes = _packageManifest.CreateElement("DocumentTypes"); foreach (string dtId in pack.Documenttypes) { if (int.TryParse(dtId, out outInt)) { DocumentType docT = new DocumentType(outInt); AddDocumentType(docT, ref dtl); } } foreach (DocumentType d in dtl) { docTypes.AppendChild(d.ToXml(_packageManifest)); } appendElement(docTypes); //Templates XmlNode templates = _packageManifest.CreateElement("Templates"); foreach (string templateId in pack.Templates) { if (int.TryParse(templateId, out outInt)) { Template t = new Template(outInt); templates.AppendChild(t.ToXml(_packageManifest)); } } appendElement(templates); //Stylesheets XmlNode stylesheets = _packageManifest.CreateElement("Stylesheets"); foreach (string ssId in pack.Stylesheets) { if (int.TryParse(ssId, out outInt)) { StyleSheet s = new StyleSheet(outInt); stylesheets.AppendChild(s.ToXml(_packageManifest)); } } appendElement(stylesheets); //Macros XmlNode macros = _packageManifest.CreateElement("Macros"); foreach (string macroId in pack.Macros) { if (int.TryParse(macroId, out outInt)) { macros.AppendChild(utill.Macro(int.Parse(macroId), true, localPath, _packageManifest)); } } appendElement(macros); //Dictionary Items XmlNode dictionaryItems = _packageManifest.CreateElement("DictionaryItems"); foreach (string dictionaryId in pack.DictionaryItems) { if (int.TryParse(dictionaryId, out outInt)) { Dictionary.DictionaryItem di = new Dictionary.DictionaryItem(outInt); dictionaryItems.AppendChild(di.ToXml(_packageManifest)); } } appendElement(dictionaryItems); //Languages XmlNode languages = _packageManifest.CreateElement("Languages"); foreach (string langId in pack.Languages) { if (int.TryParse(langId, out outInt)) { language.Language lang = new umbraco.cms.businesslogic.language.Language(outInt); languages.AppendChild(lang.ToXml(_packageManifest)); } } appendElement(languages); //Datatypes XmlNode dataTypes = _packageManifest.CreateElement("DataTypes"); foreach (string dtId in pack.DataTypes) { if (int.TryParse(dtId, out outInt)) { cms.businesslogic.datatype.DataTypeDefinition dtd = new umbraco.cms.businesslogic.datatype.DataTypeDefinition(outInt); dataTypes.AppendChild(dtd.ToXml(_packageManifest)); } } appendElement(dataTypes); //Files foreach (string fileName in pack.Files) { utill.AppendFileToManifest(fileName, localPath, _packageManifest); } //Load control on install... if (!string.IsNullOrEmpty(pack.LoadControl)) { XmlNode control = _packageManifest.CreateElement("control"); control.InnerText = pack.LoadControl; utill.AppendFileToManifest(pack.LoadControl, localPath, _packageManifest); appendElement(control); } //Actions if (!string.IsNullOrEmpty(pack.Actions)) { try { XmlDocument xd_actions = new XmlDocument(); xd_actions.LoadXml("<Actions>" + pack.Actions + "</Actions>"); XmlNode actions = xd_actions.DocumentElement.SelectSingleNode("."); if (actions != null) { actions = _packageManifest.ImportNode(actions, true).Clone(); appendElement(actions); } } catch { } } string manifestFileName = localPath + "/package.xml"; if (System.IO.File.Exists(manifestFileName)) System.IO.File.Delete(manifestFileName); _packageManifest.Save(manifestFileName); _packageManifest = null; //string packPath = Settings.PackagerRoot.Replace(System.IO.Path.DirectorySeparatorChar.ToString(), "/") + "/" + pack.Name.Replace(' ', '_') + "_" + pack.Version.Replace(' ', '_') + "." + Settings.PackageFileExtension; // check if there's a packages directory below media string packagesDirectory = SystemDirectories.Media + "/created-packages"; if (!System.IO.Directory.Exists(IOHelper.MapPath(packagesDirectory))) System.IO.Directory.CreateDirectory(IOHelper.MapPath(packagesDirectory)); string packPath = packagesDirectory + "/" + (pack.Name + "_" + pack.Version).Replace(' ', '_') + "." + Settings.PackageFileExtension; utill.ZipPackage(localPath, IOHelper.MapPath(packPath)); pack.PackagePath = packPath; if (pack.PackageGuid.Trim() == "") pack.PackageGuid = Guid.NewGuid().ToString(); package.Save(); //Clean up.. System.IO.File.Delete(localPath + "/package.xml"); System.IO.Directory.Delete(localPath, true); package.FireAfterPublish(e); } } catch (Exception ex) { LogHelper.Error<CreatedPackage>("An error occurred", ex); } }
static void StyleSheet_AfterSave(StyleSheet sender, SaveEventArgs e) { SaveToDisk(sender); }
public static StyleSheet[] GetAll() { var dbStylesheets = new ArrayList(); var topNodeIds = CMSNode.TopMostNodeIds(ModuleObjectType); //StyleSheet[] retval = new StyleSheet[topNodeIds.Length]; for (int i = 0; i < topNodeIds.Length; i++) { //retval[i] = new StyleSheet(topNodeIds[i]); dbStylesheets.Add(new StyleSheet(topNodeIds[i]).Text.ToLower()); } var fileStylesheets = new ArrayList(); var fileListing = new DirectoryInfo(IOHelper.MapPath(SystemDirectories.Css + "/")); foreach (var file in fileListing.GetFiles("*.css")) { if (!dbStylesheets.Contains(file.Name.Replace(file.Extension, "").ToLower())) { fileStylesheets.Add(file.Name.Replace(file.Extension, "")); } } var retval = new StyleSheet[dbStylesheets.Count + fileStylesheets.Count]; for (int i = 0; i < topNodeIds.Length; i++) { retval[i] = new StyleSheet(topNodeIds[i]); } for (int i = 0; i < fileStylesheets.Count; i++) { string content = string.Empty; using (StreamReader re = File.OpenText(IOHelper.MapPath(string.Format("{0}/{1}.css", SystemDirectories.Css, fileStylesheets[i])))) { content = re.ReadToEnd(); } retval[dbStylesheets.Count + i] = StyleSheet.MakeNew(new umbraco.BusinessLogic.User(0), fileStylesheets[i].ToString(), fileStylesheets[i].ToString(), content); } Array.Sort(retval, 0, retval.Length, new StyleSheetComparer()); return retval; }
public static StyleSheet MakeNew(BusinessLogic.User user, string Text, string FileName, string Content) { // Create the umbraco node var newNode = CMSNode.MakeNew(-1, ModuleObjectType, user.Id, 1, Text, Guid.NewGuid()); // Create the stylesheet data SqlHelper.ExecuteNonQuery(string.Format("insert into cmsStylesheet (nodeId, filename, content) values ('{0}','{1}',@content)", newNode.Id, FileName), SqlHelper.CreateParameter("@content", Content)); // save to file to avoid file coherency issues var newCss = new StyleSheet(newNode.Id, false, false); var e = new NewEventArgs(); newCss.OnNew(e); return newCss; }
static void StyleSheetAfterDelete(StyleSheet sender, DeleteEventArgs e) { DistributedCache.Instance.RemoveStylesheetCache(sender); }
private stylesheetCarrier createCarrier(StyleSheet stylesheet) { stylesheetCarrier carrier = new stylesheetCarrier(); carrier.Id = stylesheet.Id; carrier.Name = stylesheet.Text; carrier.Content = stylesheet.Content; return carrier; }
public static void RemoveStylesheetCache(this DistributedCache dc, StyleSheet styleSheet) { if (styleSheet != null) { dc.Remove(new Guid(DistributedCache.StylesheetCacheRefresherId), styleSheet.Id); } }
static void StyleSheet_BeforeDelete(StyleSheet sender, DeleteEventArgs e) { helpers.XmlDoc.ArchiveFile(sender.GetType().ToString(), sender.Text); e.Cancel = false; }
static void StyleSheetAfterSave(StyleSheet sender, SaveEventArgs e) { DistributedCache.Instance.RefreshStylesheetCache(sender); }
/// <summary> /// Converts a umbraco stylesheet to a package xml node /// </summary> /// <param name="ssId">The ss id.</param> /// <param name="incluceProperties">if set to <c>true</c> [incluce properties].</param> /// <param name="doc">The doc.</param> /// <returns></returns> public static XmlNode Stylesheet(int ssId, bool incluceProperties, XmlDocument doc) { StyleSheet sts = new StyleSheet(ssId); XmlNode stylesheet = doc.CreateElement("Stylesheet"); stylesheet.AppendChild(_node("Name", sts.Text, doc)); stylesheet.AppendChild(_node("FileName", sts.Filename, doc)); stylesheet.AppendChild(_node("Content", "<![CDATA[" + sts.Content + "]]>", doc)); if (incluceProperties) { XmlNode properties = doc.CreateElement("Properties"); foreach (StylesheetProperty ssP in sts.Properties) { XmlNode property = doc.CreateElement("Property"); property.AppendChild(_node("Name", ssP.Text, doc)); property.AppendChild(_node("Alias", ssP.Alias, doc)); property.AppendChild(_node("Value", ssP.value, doc)); //xnode += "<Property><Name>" + ssP.Text + "</Name><Alias>" + ssP.Alias + "</Alias><Value>" + ssP.value + "</Value></Property>\n"; } stylesheet.AppendChild(properties); } return stylesheet; }
public bool Delete() { cms.businesslogic.web.StyleSheet s = new cms.businesslogic.web.StyleSheet(ParentID); s.delete(); return(true); }
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(); }