Beispiel #1
0
		private void ApplyStateFlags(TreeNode node, ContentItem item)
		{
			StringBuilder className = new StringBuilder();

			if (!item.IsPublished())
				className.Append("unpublished ");
			else if (item.Published > N2.Utility.CurrentTime().AddDays(-1))
				className.Append("day ");
			else if (item.Published > N2.Utility.CurrentTime().AddDays(-7))
				className.Append("week ");
			else if (item.Published > N2.Utility.CurrentTime().AddMonths(-1))
				className.Append("month ");

			if (item.IsExpired())
			{
				className.Append("expired ");
			}

			if (!item.Visible)
			{
				className.Append("notvisible ");
			}

			if (item.AlteredPermissions != Permission.None && item.AuthorizedRoles != null && item.AuthorizedRoles.Count > 0)
			{
				className.Append("locked ");
			}

			node.CssClass = className.ToString();
		}
Beispiel #2
0
		/// <summary>Gets the node representation used to build the tree hierarchy in the management UI.</summary>
		/// <param name="item">The item to link to.</param>
		/// <returns>Tree node data.</returns>
		public virtual TreeNode GetTreeNode(ContentItem item, bool allowDraft = true)
		{
			var node = new TreeNode
			{
				ID = item.VersionOf.ID ?? item.ID,
				Path = item.Path,
				State = item.State,
				IconUrl = GetIconUrl(item),
				IconClass = GetIconClass(item),
				Title = Cleaner.Clean(item.Title),
				ToolTip = "#" + item.ID + ": " +  Definitions.GetDefinition(item).Title,
				PreviewUrl = GetPreviewUrl(item, allowDraft: allowDraft),
				MaximumPermission = GetMaximumPermission(item),
				SortOrder = item.SortOrder,
				VersionIndex = item.VersionIndex,
				ZoneName = item.ZoneName
			};
			
			node.MetaInformation = GetMetaInformation(item);
			ApplyStateFlags(node, item);
			return node;
		}