protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { string baseUrl = string.Format("{0}", (Request.ApplicationPath.Equals("/")) ? string.Empty : Request.ApplicationPath); Node currentPage = new Node(CurrentPageId); List<Contact> contactList = new List<Contact>(); foreach (Node node in currentPage.Children) { if (node.NodeTypeAlias == "Contact") { Contact contact = new Contact(); contact.Name = node.Name; contact.Position = node.GetProperty("position").Value ?? ""; contact.Email = node.GetProperty("email").Value ?? ""; contact.Phone = node.GetProperty("phone").Value ?? ""; int imageId = 0; if (int.TryParse(node.GetProperty("image").Value ?? "", out imageId)) { var mediaService = ServiceLocator.Instance.Locate<IMediaService>(); var media = mediaService.GetById(imageId); contact.ImageUrl = media.GetValue<string>("umbracoFile").Replace("~", baseUrl); } contactList.Add(contact); } } contacts.DataSource = contactList; contacts.DataBind(); } }
void Document_BeforeMove(object sender, MoveEventArgs e) { #if !DEBUG try #endif { Document doc = sender as Document; #if !DEBUG try #endif { if (doc != null) { Node node = new Node(doc.Id); if (node != null && !string.IsNullOrEmpty(node.NiceUrl) && !doc.Path.StartsWith("-1,-20")) // -1,-20 == Recycle bin | Not moved to recycle bin UrlTrackerRepository.AddUrlMapping(doc, node.GetDomainRootNode().Id, node.NiceUrl, AutoTrackingTypes.Moved); } } #if !DEBUG catch (Exception ex) { ex.LogException(doc.Id); } #endif } #if !DEBUG catch (Exception ex) { ex.LogException(); } #endif }
private Case GetCaseFromUmbracoNode(INode customerCase) { //laver cropUp imageUrl var imageId = customerCase.GetProperty("images").Value.Split(',').Where(x => string.IsNullOrEmpty(x) == false).Select(x => int.Parse(x)).FirstOrDefault(); var imageUrl = imageId > 0 ? Umbraco.Media(imageId).Url : ""; if (string.IsNullOrEmpty(imageUrl) == false) { var cropUpSizeDesktop = new ImageSizeArguments { Width = 300, Height = 225, CropMode = CropUpMode.BestFit, Zoom = true }; imageUrl = CropUp.GetUrl("~" + imageUrl, cropUpSizeDesktop); } //henter kategori var catNode = new Node(Convert.ToInt32(customerCase.GetProperty("kategorier").Value)); //laver return objekt var p = new Case { Id = 0, Headline = customerCase.Name, Customer = customerCase.Parent.Name, ImageUrl = imageUrl, Url = customerCase.NiceUrl, Created = customerCase.CreateDate, Modified = customerCase.UpdateDate, CategoryId = catNode.Id, CategoryName = catNode.Name, SortOrder = customerCase.Parent.SortOrder }; return p; }
public static string node(int nodeId) { var node = new umbraco.NodeFactory.Node(nodeId); // I think getting template name requires a database hit /*var template = new umbraco.cms.businesslogic.template.Template(node.template); */ return Json.Encode( new { node.Name, node.UrlName, node.NodeTypeAlias, node.CreatorName, node.template, /*Template = template.Alias,*/ Properties = node.PropertiesAsList.Select(p => new { p.Alias, Value=replacemedia(p.Value) }).ToDictionary(k => k.Alias, k => k.Value), node.CreateDate, node.UpdateDate, node.SortOrder, node.Url, ParentId = (node.Parent != null) ? node.Parent.Id : -1, ChildIds = node.ChildrenAsList.Select(n => n.Id) }); }
protected NavigationMenu Navigation() { Node node = new Node(1080); var mainMenu = ModelFactory.CreateModel<NavigationMenu>(node); DetermineCurrentItem(mainMenu); return mainMenu; }
protected void Page_Load(object sender, EventArgs e) { Node node = new Node(1080); var mainMenu = ModelFactory.CreateModel<NavigationMenu>(node); DetermineCurrentItem(mainMenu); topNavigationContent.Text = MustacheHelper.RenderMustacheTemplate(this, "topNavigation", mainMenu); }
public void LoadView() { UrlTrackerDomain domain = null; Node redirectRootNode = new Node(UrlTrackerModel.RedirectRootNodeId); List<UrlTrackerDomain> domains = UmbracoHelper.GetDomains(); domain = domains.FirstOrDefault(x => x.NodeId == redirectRootNode.Id); if (domain == null) domain = new UrlTrackerDomain(-1, redirectRootNode.Id, HttpContext.Current.Request.Url.Host); if (!domains.Any()) pnlRootNode.Visible = false; else { lnkRootNode.Text = string.Format("{0} ({1})", domain.Node.Name, domain.Name); lnkRootNode.ToolTip = UrlTrackerResources.SyncTree; lnkRootNode.NavigateUrl = string.Format("javascript:parent.UmbClientMgr.mainTree().syncTree('{1}', false);", redirectRootNode.Id, redirectRootNode.Path); } lnkOldUrl.Text = string.Format("{0} <i class=\"icon-share\"></i>", UrlTrackerModel.CalculatedOldUrl); lnkOldUrl.NavigateUrl = UrlTrackerModel.CalculatedOldUrlWithDomain; Node redirectNode = new Node(UrlTrackerModel.RedirectNodeId.Value); lnkRedirectNode.Text = redirectNode.Name; lnkRedirectNode.ToolTip = UrlTrackerResources.SyncTree; lnkRedirectNode.NavigateUrl = string.Format("javascript:parent.UmbClientMgr.mainTree().syncTree('{1}', false);", redirectNode.Id, redirectNode.Path); if (UrlTrackerModel.RedirectHttpCode == 301) rbPermanent.Checked = true; else if (UrlTrackerModel.RedirectHttpCode == 302) rbTemporary.Checked = true; cbRedirectPassthroughQueryString.Checked = UrlTrackerModel.RedirectPassThroughQueryString; lblNotes.Text = UrlTrackerModel.Notes; lblInserted.Text = UrlTrackerModel.Inserted.ToString(); }
internal static Settings CreateSettingsFromNode(Node node) { if (node == null) throw new Exception("Trying to load data from null node"); var product = new Settings(); LoadDataFromNode(product, node); return product; }
private Node GetParentDocument(Node node) { if (node == null || node.Parent == null || node.NodeTypeAlias != DateDocumentType) return node; var parent = new Node(node.Parent.Id); return GetParentDocument(parent); }
protected void Page_Load(object sender, EventArgs e) { CurrentNode = Node.GetCurrent(); List<ArticleListItem> articlePages = articleBo.FindFullArticle(CurrentNode); ArticleMenuRepeater.DataSource = articlePages; ArticleMenuRepeater.DataBind(); }
private string GetPropertyValue(umbraco.NodeFactory.Node umbracoNode, string propertyAlias) { if (umbracoNode.GetProperty(propertyAlias) == null && string.IsNullOrWhiteSpace(umbracoNode.GetProperty(propertyAlias).Value)) { return(string.Empty); } return(umbracoNode.GetProperty(propertyAlias).Value); }
private void GetMovieImages(Cinema model) { foreach (var program in model.MoviePrograms) { Node movieNode = new Node(program.MovieLink.NodeId); program.MovieInfo = new MovieProgramInfo(); ModelFactory.FillModel(program.MovieInfo, movieNode); } }
public static void ImportPageContent(int importPageId) { Node importPage = new Node(importPageId); var rawData = APIHelper.GetPageRaw(importPage.GetProperty("gatherContentId").ToString()); var structure = GetPageContentStructure(rawData); var pageContent = DecodeFrom64(structure.page.config); var pageStructure = GetPageStructure(pageContent); AddPageContent(pageStructure, importPageId); }
/// <summary> /// Gets an umbraco node, based on its node id. /// </summary> /// <param name="nodeId">The node id.</param> /// <returns></returns> /// <remarks></remarks> public virtual UmbracoNode GetByNodeId(int nodeId) { var nativeNode = new Node(nodeId); var node = new UmbracoNode() { Name = nativeNode.Name.Replace(" ", "-").Replace(".", "_"), Url = GetUrlPath(nodeId), UpdateDate = nativeNode.UpdateDate}; LoadChildrenIds(nativeNode, node); LoadParentId(nativeNode, node); LoadProperties(nativeNode, node); LoadDocumentTypeId(nativeNode, node); return node; }
/// <summary> /// Gets the umbraco node by id /// </summary> public HttpResponseMessage GetNodeData(int id) { var node = new Node(id); if (node.Id == 0) return NodeNotFound(); var viewNode = ViewNode.Create(node); return JsonResponse(viewNode); }
/// <summary> /// Method for getting a file url /// </summary> /// <param name="node">Node with file property</param> /// <param name="filePropertyAlias">Property alias</param> /// <returns>string</returns> public static string GetFileUrl(Node node, string filePropertyAlias) { if (!string.IsNullOrEmpty(node.GetProperty<string>(filePropertyAlias))) { var file = ApplicationContext.Current.Services.MediaService.GetById(node.GetProperty<int>(filePropertyAlias)); return file.GetValue<string>("umbracoFile"); } return string.Empty; }
internal static void LoadUwebshopEntityPropertiesFromNode(uWebshopEntity entity, Node node) { if (entity.Id == 0) entity.Id = node.Id; entity.ParentId = node.Parent != null ? node.Parent.Id : -1; entity.SortOrder = node.SortOrder; entity.NodeTypeAlias = node.NodeTypeAlias; entity.Name = node.Name; entity.Path = node.Path; entity.CreateDate = node.CreateDate; entity.UpdateDate = node.UpdateDate; entity.UrlName = node.UrlName; }
/// <summary> /// Gets an umbraco node by its NiceUrl. /// </summary> /// <param name="niceUrl">The NiceUrl path.</param> /// <returns>Node.</returns> public virtual Node GetByNiceUrl(string niceUrl) { var xmlNode = umbraco.library.GetXmlNodeByXPath(umbraco.requestHandler.CreateXPathQuery(niceUrl, false).Replace("[ ", "[@urlName ").Replace("/root/*", "/root//*")); xmlNode.MoveNext(); var idStr = xmlNode.Current.GetAttribute("id", string.Empty); var id = 0; Node node = null; if (int.TryParse(idStr, out id)) { node = new Node(id); } return node; }
public static object NodeNavigation(Node node) { return new { node.NiceUrl, node.Name, Visible = NodeVisible(node), node.Id, node.UrlName, Children = node.ChildrenAsList.Select(n => NodeNavigation(n as Node)) }; }
private static Node GetParentNode(int nodeId, string typeName) { var node = new Node(nodeId); Node parentNode = (Node)node.Parent; if (parentNode.NodeTypeAlias == typeName) { return parentNode; } else { return GetParentNode(parentNode.Id, typeName); } }
private void GetMembers() { if (ShowNewest) { this.header.InnerHtml = "Nieuwe leden"; //var group = MemberGroup.GetByName(MembershipHelper.ForumUserRoleName); var members = Member.GetAll.OrderByDescending(x => x.CreateDateTime).Take(5);//group.GetMembers().OrderByDescending(x => x.CreateDateTime).Take(5); if (members.Any()) { rprMembers.DataSource = members; rprMembers.DataBind(); } } else { this.header.InnerHtml = "Groepsleden"; ForumCategory currentCategory = null; switch (CurrentNode.NodeTypeAlias) { case global.GlobalConstants.MembergroupAlias: case global.GlobalConstants.ProjectAlias: currentCategory = Mapper.MapForumCategory(CurrentNode); break; case global.GlobalConstants.DiscussionAlias: ForumTopic currentTopic = Mapper.MapForumTopic(CurrentNode); Node categoryNode = new Node(currentTopic.CategoryId); currentCategory = Mapper.MapForumCategory(categoryNode); break; default: break; } if(currentCategory != null) { MemberGroup group = MemberGroup.GetByName(currentCategory.Name); if(group != null) { rprMembers.DataSource = group.GetMembers(); rprMembers.DataBind(); } } } }
public static bool AddUrlMapping(IContent content, int rootNodeId, string url, AutoTrackingTypes type, bool isChild = false) { if (url != "#" && content.Template != null && content.Template.Id > 0) { string notes = isChild ? "An ancestor" : "This page"; switch (type) { case AutoTrackingTypes.Moved: notes += " was moved"; break; case AutoTrackingTypes.Renamed: notes += " was renamed"; break; case AutoTrackingTypes.UrlOverwritten: notes += "'s property 'umbracoUrlName' changed"; break; } url = UrlTrackerHelper.ResolveShortestUrl(url); if (!string.IsNullOrEmpty(url)) { string query = "SELECT 1 FROM icUrlTracker WHERE RedirectNodeId = @nodeId AND OldUrl = @url"; int exists = _sqlHelper.ExecuteScalar<int>(query, _sqlHelper.CreateParameter("nodeId", content.Id), _sqlHelper.CreateStringParameter("url", url)); if (exists != 1) { LoggingHelper.LogInformation("UrlTracker Repository | Adding mapping for node id: {0} and url: {1}", new string[] { content.Id.ToString(), url }); query = "INSERT INTO icUrlTracker (RedirectRootNodeId, RedirectNodeId, OldUrl, Notes) VALUES (@rootNodeId, @nodeId, @url, @notes)"; _sqlHelper.ExecuteNonQuery(query, _sqlHelper.CreateParameter("rootNodeId", rootNodeId), _sqlHelper.CreateParameter("nodeId", content.Id), _sqlHelper.CreateStringParameter("url", url), _sqlHelper.CreateStringParameter("notes", notes)); if (content.Children().Any()) { foreach (IContent child in content.Children()) { Node node = new Node(child.Id); AddUrlMapping(child, rootNodeId, node.NiceUrl, type, true); } } return true; } } } return false; }
private static void GetNodeList(int nodeId, string[] typeNames, ref List<Node> result) { var node = new Node(nodeId); foreach (Node childNode in node.Children) { var child = childNode; if (typeNames.Contains(child.NodeTypeAlias)) { result.Add(child); } if (child.Children.Count > 0) { GetNodeList(child.Id, typeNames, ref result); } } }
/// <summary> /// Executes the specified URL. /// </summary> /// <param name="url">The URL.</param> /// <returns>Returns whether the NotFoundHandler has a match.</returns> public bool Execute(string url) { HttpContext.Current.Response.StatusCode = (int)HttpStatusCode.NotFound; var success = false; // get the current domain name var domainName = HttpContext.Current.Request.ServerVariables["SERVER_NAME"]; // if there is a port number, append it var port = HttpContext.Current.Request.ServerVariables["SERVER_PORT"]; if (!string.IsNullOrEmpty(port) && port != "80") { domainName = string.Concat(domainName, ":", port); } // get the root node id of the domain var rootNodeId = Domain.GetRootFromDomain(domainName); try { if (rootNodeId > 0) { // get the node var node = new Node(rootNodeId); // get the property that holds the node id for the 404 page var property = node.GetProperty("umbracoPageNotFound"); if (property != null) { var errorId = property.Value; if (!string.IsNullOrEmpty(errorId)) { // if the node id is numeric, then set the redirectId success = int.TryParse(errorId, out this._redirectId); } } } } catch { success = false; } return success; }
public static ViewNode Create(Node node) { var viewNode = new ViewNode { NiceUrl = node.NiceUrl, TemplateId = node.template, Name = node.Name, Level = node.Level, Id = node.Id, Properties = node.PropertiesAsList, StatusMessage = new StatusMessage { Success = true }, HostName = GetHostname() }; GetChildrenRecursive(node, viewNode); return viewNode; }
public virtual void addContent(Document document, List<Content> contentList, string path) { Content content = new Content(); content.nodeID = document.Id; content.name = document.Text; content.updateDate = document.UpdateDate.ToString(); content.createDate = document.CreateDateTime.ToString(); content.icon = "/umbraco/images/umbraco/" + document.ContentTypeIcon; content.creator = document.Creator.Name; content.docType = document.ContentType.Alias; content.image = "/umbraco/images/thumbnails/" + document.ContentType.Thumbnail; content.docTypeID = document.ContentType.Id; content.path = path; Node thisNode = new Node(document.Id); content.publisher = thisNode.WriterName; contentList.Add(content); }
/// <summary> /// Gets the pre values. /// TODO: [OA] Document on Codeplex /// </summary> /// <param name="nodeId">The node id.</param> /// <param name="propertyAlias">The property alias.</param> /// <returns></returns> public static PreValue[] GetPreValues(int nodeId, string propertyAlias) { var node = new Node(nodeId); var xml = node.ToXml(); if (xml != null && xml.Attributes != null) { int nodeType; int.TryParse(xml.Attributes["nodeType"].Value, out nodeType); foreach (var property in PropertyType.GetAll().Where(x => x.ContentTypeId.Equals(nodeType) && x.Alias.Equals(propertyAlias))) { var dtd = property.DataTypeDefinition; return GetPreValues(dtd.Id); } } return new List<PreValue>().ToArray(); }
/// <summary> /// Wrapper for Node constructor /// </summary> /// <param name="id">id of Node to get</param> /// <returns>Node or null</returns> public static Node GetNode(int id) { Node node; try { node = new Node(id); if (node.Id == 0) { node = null; } } catch { node = null; } return node; }
public void RenderBlockContextMenu() { int blockSourceNodeId = PreValueAccessor.BlockSourceNodeId; IconProvider iconProvider = new IconProvider(); try { var blocksSourceNode = new Node(blockSourceNodeId); var sb = new StringBuilder(); // Loop through each children and output accordingly. foreach (Node child in blocksSourceNode.Children) { RenderBlockSubList(child, sb, iconProvider); } plcBlocksContextMenu.Controls.Add(new LiteralControl(sb.ToString())); plcBlocksContextMenu2.Controls.Add(new LiteralControl(sb.ToString())); } catch { } }
protected bool IsMember(string loginName) { bool result = false; Member member = Member.GetMemberByName(loginName, false)[0]; Node selectedNode = new Node(this.SelectedNodeID); //return member.Groups.ContainsValue(selectedNode.Name); foreach (var group in member.Groups.Values) { if (((umbraco.cms.businesslogic.CMSNode)group).Text == selectedNode.Name) { result = true; break; } } return result; }
void ContentService_Publishing(IPublishingStrategy sender, PublishEventArgs<IContent> e) { // When content is renamed or 'umbracoUrlName' property value is added/updated foreach (IContent content in e.PublishedEntities) { #if !DEBUG try #endif { Node node = new Node(content.Id); if (node.Name != content.Name && !string.IsNullOrEmpty(node.Name)) // If name is null, it's a new document { // Rename occurred UrlTrackerRepository.AddUrlMapping(content, node.GetDomainRootNode().Id, node.NiceUrl, AutoTrackingTypes.Renamed); if (ClientTools != null) ClientTools.ChangeContentFrameUrl(string.Concat("/umbraco/editContent.aspx?id=", content.Id)); } if (content.HasProperty("umbracoUrlName")) { string contentUmbracoUrlNameValue = content.GetValue("umbracoUrlName") != null ? content.GetValue("umbracoUrlName").ToString() : string.Empty; string nodeUmbracoUrlNameValue = node.GetProperty("umbracoUrlName") != null ? node.GetProperty("umbracoUrlName").Value : string.Empty; if (contentUmbracoUrlNameValue != nodeUmbracoUrlNameValue) { // 'umbracoUrlName' property value added/changed UrlTrackerRepository.AddUrlMapping(content, node.GetDomainRootNode().Id, node.NiceUrl, AutoTrackingTypes.UrlOverwritten); if (ClientTools != null) ClientTools.ChangeContentFrameUrl(string.Concat("/umbraco/editContent.aspx?id=", content.Id)); } } } #if !DEBUG catch (Exception ex) { ex.LogException(); } #endif } }
private IEnumerable <umbraco.NodeFactory.Node> GetUmbracoNodes(XPathNodeIterator starterKitsIterator) { var nodes = new List <umbraco.NodeFactory.Node>(); while (starterKitsIterator.MoveNext()) { var current = starterKitsIterator.Current as IHasXmlNode; if (current == null) { continue; } var node = current.GetNode(); var umbracoNode = new umbraco.NodeFactory.Node(node); if (node != null) { nodes.Add(umbracoNode); } } return(nodes); }