private void loadNodes(string parentId, SiteMapNode parentNode) { lock (this) { NodeFactory.Node n = new NodeFactory.Node(int.Parse(parentId)); foreach (NodeFactory.Node child in n.Children) { string roles = findRoles(child.Id, child.Path); SiteMapNode childNode = createNode( child.Id.ToString(), child.Name, child.GetProperty(m_defaultDescriptionAlias) != null ? child.GetProperty(m_defaultDescriptionAlias).Value : "", child.Url, roles); try { AddNode(childNode, parentNode); } catch (Exception ex) { BusinessLogic.Log.Add( LogTypes.Error, child.Id, String.Format("Error adding to SiteMapProvider in loadNodes(): {0}", ex)); } loadNodes(child.Id.ToString(), childNode); } } }
protected void Page_Load(object sender, EventArgs e) { if (User.GetCurrent().GetApplications().Find(t => string.Equals(t.alias, Constants.Applications.Settings, StringComparison.OrdinalIgnoreCase)) == null) { throw new Exception("The current user can't edit skins as the user doesn't have access to the Settings section!"); } NodeFactory.Node n = NodeFactory.Node.GetCurrent(); ActiveSkin = Skin.CreateFromAlias(Skinning.GetCurrentSkinAlias(n.template)); pnl_connectionerror.Visible = false; //load dependencies if (ActiveSkin != null && ActiveSkin.Dependencies.Count > 0) { LoadDependencies(); } else { //show skin selection pCustomizeSkin.Visible = false; ltCustomizeSkinStyle.Text = ltChangeSkinStyle.Text; ltChangeSkinStyle.Text = string.Empty; } LoadSkins(); }
public void UpdateNode(NodeFactory.Node node) { lock (this) { // validate sitemap BuildSiteMap(); SiteMapNode n; if (!m_nodes.ContainsKey(node.Id.ToString())) { n = createNode(node.Id.ToString(), node.Name, node.GetProperty(m_defaultDescriptionAlias) != null ? node.GetProperty(m_defaultDescriptionAlias).Value : "", node.Url, findRoles(node.Id, node.Path)); string parentNode = node.Parent == null ? "-1" : node.Parent.Id.ToString(); try { AddNode(n, m_nodes[parentNode]); } catch (Exception ex) { LogHelper.Error <UmbracoSiteMapProvider>(String.Format("Error adding node with url '{0}' and Id {1} to SiteMapProvider", node.Name, node.Id), ex); } } else { n = m_nodes[node.Id.ToString()]; n.Url = node.Url; n.Description = node.GetProperty(m_defaultDescriptionAlias) != null?node.GetProperty(m_defaultDescriptionAlias).Value : ""; n.Title = node.Name; n.Roles = findRoles(node.Id, node.Path).Split(",".ToCharArray()); } } }
private void LoadNodes(string parentId, SiteMapNode parentNode) { lock (this) { NodeFactory.Node n = new NodeFactory.Node(int.Parse(parentId)); foreach (NodeFactory.Node child in n.Children) { string roles = FindRoles(child.Id, child.Path); SiteMapNode childNode = CreateNode( child.Id.ToString(), child.Name, child.GetProperty(_defaultDescriptionAlias) != null ? child.GetProperty(_defaultDescriptionAlias).Value : "", child.Url, roles); try { AddNode(childNode, parentNode); } catch (Exception ex) { LogHelper.Error <UmbracoSiteMapProvider>(string.Format("Error adding node {0} to SiteMapProvider in loadNodes()", child.Id), ex); } LoadNodes(child.Id.ToString(), childNode); } } }
protected void SelectStarterKitDesign(object sender, EventArgs e) { if (((Button)sender).CommandName == "apply") { Skin s = Skin.CreateFromName(((Button)sender).CommandArgument); Skinning.ActivateAsCurrentSkin(s); Page.Response.Redirect(library.NiceUrl(int.Parse(UmbracoContext.Current.PageId.ToString()))); } else if (((Button)sender).CommandName == "remove") { NodeFactory.Node n = NodeFactory.Node.GetCurrent(); Template t = new Template(n.template); Skinning.RollbackSkin(t.Id); Page.Response.Redirect(library.NiceUrl(int.Parse(UmbracoContext.Current.PageId.ToString()))); } else { Guid kitGuid = new Guid(((Button)sender).CommandArgument); cms.businesslogic.packager.Installer installer = new cms.businesslogic.packager.Installer(); if (repo.HasConnection()) { cms.businesslogic.packager.Installer p = new cms.businesslogic.packager.Installer(); string tempFile = p.Import(repo.fetch(kitGuid.ToString())); p.LoadConfig(tempFile); int pID = p.CreateManifest(tempFile, kitGuid.ToString(), repoGuid); p.InstallFiles(pID, tempFile); p.InstallBusinessLogic(pID, tempFile); p.InstallCleanUp(pID, tempFile); library.RefreshContent(); if (cms.businesslogic.skinning.Skinning.GetAllSkins().Count > 0) { cms.businesslogic.skinning.Skinning.ActivateAsCurrentSkin(cms.businesslogic.skinning.Skinning.GetAllSkins()[0]); } Page.Response.Redirect(library.NiceUrl(int.Parse(UmbracoContext.Current.PageId.ToString()))); } else { //ShowConnectionError(); } } }
public DynamicBackingItem(int Id, DynamicBackingItemType Type) { NodeFactory.Node baseNode = new NodeFactory.Node(Id); if (Type == DynamicBackingItemType.Media) { this.media = ExamineBackedMedia.GetUmbracoMedia(Id); this.Type = Type; } else { this.content = baseNode; this.Type = Type; } }
protected virtual void AddSkinningModules() { // SKINNING // verify access to settings area if (User.GetCurrent().GetApplications().Find(t => string.Equals(t.alias, Umbraco.Core.Constants.Applications.Settings, StringComparison.OrdinalIgnoreCase)) != null) { //only add if there is a skin NodeFactory.Node n = NodeFactory.Node.GetCurrent(); if (!string.IsNullOrEmpty(Skinning.GetCurrentSkinAlias(n.template)) || Skinning.HasAvailableSkins(n.template)) { m_Manager.LiveEditingContext.Menu.Add(new Separator()); m_Manager.LiveEditingContext.Menu.Add(new SkinModule(m_Manager)); } } }
protected virtual void AddSkinningModules() { // SKINNING // verify access to settings area if (User.GetCurrent().GetApplications().Find(t => t.alias.ToLower() == "settings") != null) { //only add if there is a skin NodeFactory.Node n = NodeFactory.Node.GetCurrent(); if (!string.IsNullOrEmpty(Skinning.GetCurrentSkinAlias(n.template)) || Skinning.HasAvailableSkins(n.template)) { m_Manager.LiveEditingContext.Menu.Add(new Separator()); m_Manager.LiveEditingContext.Menu.Add(new SkinModule(m_Manager)); } } }
public DynamicBackingItem(int Id) { NodeFactory.Node baseNode = new NodeFactory.Node(Id); this.content = baseNode; this.Type = DynamicBackingItemType.Content; if (baseNode.Id == 0 && Id != 0) { this.media = ExamineBackedMedia.GetUmbracoMedia(Id); this.Type = DynamicBackingItemType.Media; if (this.media == null) { this.Type = DynamicBackingItemType.Content; } return; } }
protected override void OnInit(EventArgs e) { base.OnInit(e); ClientDependencyLoader.Instance.RegisterDependency("Application/JQuery/jquery.autocomplete.js", "UmbracoClient", ClientDependencyType.Javascript); ClientDependencyLoader.Instance.RegisterDependency("css/umbracoGui.css", "UmbracoRoot", ClientDependencyType.Css); string _alias = ((umbraco.cms.businesslogic.datatype.DefaultData)_data).PropertyId.ToString(); //making sure that we have a ID for context string pageId = UmbracoContext.Current.Request["id"]; if (pageId != null) { pageId = pageId.Trim(); } if (string.IsNullOrEmpty(pageId)) { // we need an empty try/catch as Node.GetCurrent() will throw an exception if we're outside of Umbraco Context try { NodeFactory.Node currentNode = NodeFactory.Node.GetCurrent(); if (currentNode != null) { pageId = currentNode.Id.ToString(); } } catch { } } tagBox.ID = "tagBox_" + _alias; tagBox.AutoPostBack = true; tagBox.AutoCompleteType = AutoCompleteType.Disabled; tagBox.TextChanged += new System.EventHandler(this.tagBoxTextChange); tagBox.CssClass = "umbEditorTextField"; Button tagButton = new Button(); tagButton.Click += new System.EventHandler(this.tagBoxTextChange); tagButton.Text = "tag"; tagCheckList.ID = "tagCheckList_" + _alias; if (!String.IsNullOrEmpty(pageId)) { var tags = umbraco.cms.businesslogic.Tags.Tag.GetTags(int.Parse(pageId), _group); foreach (var t in tags) { ListItem li = new ListItem(t.TagCaption, t.Id.ToString()); li.Selected = true; tagCheckList.Items.Add(li); } } this.ContentTemplateContainer.Controls.Add(tagBox); this.ContentTemplateContainer.Controls.Add(tagButton); this.ContentTemplateContainer.Controls.Add(tagCheckList); string tagsAutoCompleteScript = "jQuery(\"#" + tagBox.ClientID + "\").autocomplete(\"" + umbraco.IO.IOHelper.ResolveUrl(umbraco.IO.SystemDirectories.Umbraco) + "/webservices/TagsAutoCompleteHandler.ashx\",{minChars: 2,max: 100, extraParams:{group:\"" + _group + "\",id:\"" + pageId + "\",rnd:\"" + DateTime.Now.Ticks + "\"}}).result(function(e, data){jQuery(\"#" + tagButton.ClientID + "\").trigger('click');});"; string tagsAutoCompleteInitScript = "jQuery(document).ready(function(){" + tagsAutoCompleteScript + "});"; Page.ClientScript.RegisterStartupScript(GetType(), ClientID + "_tagsinit", tagsAutoCompleteInitScript, true); if (Page.IsPostBack) { ScriptManager.RegisterClientScriptBlock(this, GetType(), ClientID + "_tags", tagsAutoCompleteScript, true); } }
protected override void OnInit(EventArgs e) { base.OnInit(e); //ClientDependencyLoader.Instance.RegisterDependency("Application/JQuery/jquery.autocomplete.js", "UmbracoClient", ClientDependencyType.Javascript); ClientDependencyLoader.Instance.RegisterDependency("ui/ui-lightness/jquery-ui.custom.css", "UmbracoClient", ClientDependencyType.Css); ClientDependencyLoader.Instance.RegisterDependency("css/umbracoGui.css", "UmbracoRoot", ClientDependencyType.Css); ClientDependencyLoader.Instance.RegisterDependency("tags/css/jquery.tagsinput.css", "UmbracoClient", ClientDependencyType.Css); ClientDependencyLoader.Instance.RegisterDependency("tags/js/jquery.tagsinput.min.js", "UmbracoClient", ClientDependencyType.Javascript); string _alias = ((umbraco.cms.businesslogic.datatype.DefaultData)_data).PropertyId.ToString(); //making sure that we have a ID for context string pageId = UmbracoContext.Current.Request["id"]; if (pageId != null) { pageId = pageId.Trim(); } if (string.IsNullOrEmpty(pageId)) { // we need an empty try/catch as Node.GetCurrent() will throw an exception if we're outside of Umbraco Context try { NodeFactory.Node currentNode = NodeFactory.Node.GetCurrent(); if (currentNode != null) { pageId = currentNode.Id.ToString(); } } catch { } } tagBox.ID = "tagBox2_" + _alias; tagBox.CssClass = "umbEditorTextField umbTagBox"; if (!String.IsNullOrEmpty(pageId)) { var tags = umbraco.cms.businesslogic.Tags.Tag.GetTags(int.Parse(pageId), _group); tagBox.Text = string.Join(",", tags.Select(x => x.TagCaption)); } this.ContentTemplateContainer.Controls.Add(tagBox); string tagsAutoCompleteScript = "jQuery('#" + tagBox.ClientID + "').tagsInput({ width: '400px', defaultText: 'Add a tag', minChars: 2, autocomplete_url: '" + umbraco.IO.IOHelper.ResolveUrl(umbraco.IO.SystemDirectories.Umbraco) + "/webservices/TagsAutoCompleteHandler.ashx?group=" + _group + "&id=" + pageId + "&rnd=" + DateTime.Now.Ticks + "&format=json' });"; string tagsAutoCompleteInitScript = "jQuery(document).ready(function(){" + tagsAutoCompleteScript + "});"; Page.ClientScript.RegisterStartupScript(GetType(), ClientID + "_tagsinit", tagsAutoCompleteInitScript, true); if (Page.IsPostBack) { ScriptManager.RegisterClientScriptBlock(this, GetType(), ClientID + "_tags", tagsAutoCompleteScript, true); } }