本文整理汇总了C#中ContentItem.IsPublished方法的典型用法代码示例。如果您正苦于以下问题:C# ContentItem.IsPublished方法的具体用法?C# ContentItem.IsPublished怎么用?C# ContentItem.IsPublished使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ContentItem
的用法示例。
在下文中一共展示了ContentItem.IsPublished方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Match
/// <summary>Matches an item against the current filter.</summary>
/// <param name="item"></param>
/// <returns></returns>
public override bool Match(ContentItem item)
{
var isMatch = item.IsPage;
if (isMatch && RequirePublished)
isMatch &= item.IsPublished() && !item.IsExpired();
if (isMatch && RequireVisible)
isMatch &= item.Visible;
if (isMatch && RequireAuthorized)
isMatch &= new AccessFilter().Match(item);
return isMatch;
}
示例2: Fixit
private void Fixit(ref int updatedItems, ContentItem item)
{
if (item.IsExpired())
item.State = ContentState.Unpublished;
else if (item.IsPublished())
item.State = ContentState.Published;
else
item.State = ContentState.Waiting;
repository.SaveOrUpdate(item);
updatedItems++;
}
示例3: PerformMove
private void PerformMove(ContentItem toMove)
{
EnsureAuthorization(Permission.Write);
EnsureAuthorization(toMove, toMove.IsPublished() ? Permission.Publish : Permission.Write);
var previousParent = toMove.Parent;
Engine.AddActivity(new ManagementActivity { Operation = "Move", PerformedBy = User.Identity.Name, Path = toMove.Path, ID = toMove.ID });
Engine.Persister.Move(toMove, Selection.SelectedItem);
if (toMove.IsPage && !(toMove.Parent is IActiveContent))
Response.Redirect(Selection.SelectedUrl("{ManagementUrl}/Content/LinkTracker/UpdateReferences.aspx", toMove).ToUrl().AppendQuery("previousParent", previousParent != null ? previousParent.Path : null).AppendQuery("previousName", toMove.Name));
else
Refresh(toMove);
}
示例4: IsPublished
/// <summary>Check whether an item is published, i.e. it's published and isn't expired.</summary>
/// <param name="item">The item to check.</param>
/// <returns>A boolean indicating whether the item is published.</returns>
public virtual bool IsPublished(ContentItem item)
{
return item.IsPublished();
}
示例5: GetNodeFlags
public virtual IEnumerable<string> GetNodeFlags(ContentItem item)
{
var type = item.GetContentType();
var tags = new List<string>();
tags.Add(item.State.ToString());
foreach (var possibleState in Enum.GetValues(typeof(CollectionState)).Cast<CollectionState>())
if (possibleState != CollectionState.Unknown && item.ChildState.HasFlag(possibleState))
tags.Add(possibleState.ToString());
if (!item.IsPublished())
tags.Add("NotPublished");
if (item.IsExpired())
tags.Add("Expired");
if (!item.Visible)
tags.Add("Invisible");
if (item.AlteredPermissions != Permission.None && item.AuthorizedRoles != null && item.AuthorizedRoles.Count > 0)
tags.Add("Locked");
if (Drafts.HasDraft(item))
tags.Add("HasDraft");
if (item.Created.AddDays(3) > Utility.CurrentTime())
tags.Add("Recent");
tags.Add(type.Assembly.GetName().Name);
tags.AddRange(Utility.GetBaseTypesAndSelf(type).Where(t => t != typeof(object)).Select(t => t.Name));
tags.AddRange(type.GetInterfaces().Where(t => t.Namespace.Contains("Definition")).Select(t => t.Name));
var d = Definitions.GetDefinition(item);
tags.AddRange(d.AdditionalFlags);
if (d.RemovedFlags.Any())
tags.RemoveAll(f => d.RemovedFlags.Contains(f));
return tags;
}
示例6: ApplyStateFlags
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();
}
示例7: PerformMove
private void PerformMove(ContentItem toMove)
{
EnsureAuthorization(Permission.Write);
EnsureAuthorization(toMove, toMove.IsPublished() ? Permission.Publish : Permission.Write);
Engine.Persister.Move(toMove, Selection.SelectedItem);
Refresh(toMove, ToolbarArea.Both);
}
示例8: GetClassName
private string GetClassName(ContentItem item)
{
StringBuilder className = new StringBuilder();
if (!item.IsPublished())
className.Append("unpublished ");
else if (item.Published > DateTime.Now.AddDays(-1))
className.Append("day ");
else if (item.Published > DateTime.Now.AddDays(-7))
className.Append("week ");
else if (item.Published > DateTime.Now.AddMonths(-1))
className.Append("month ");
if (item.IsExpired())
className.Append("expired ");
if (!item.Visible)
className.Append("invisible ");
if (item.AlteredPermissions != Permission.None && item.AuthorizedRoles != null && item.AuthorizedRoles.Count > 0)
className.Append("locked ");
return className.ToString();
}
示例9: IsPublished
/// <summary>Tells whether the item is published, i.e. now is between it's published and expires dates.</summary>
/// <param name="item">The item to check.</param>
/// <returns>True if the item is published</returns>
public static bool IsPublished(ContentItem item)
{
return item.IsPublished() && !item.IsExpired();
}
示例10: IsAuthorized
/// <summary>Find out if a principal is allowed to access an item.</summary>
/// <param name="item">The item to check against.</param>
/// <param name="user">The principal to check for allowance.</param>
/// <returns>True if the item has public access or the principal is allowed to access it.</returns>
public virtual bool IsAuthorized(ContentItem item, IPrincipal user)
{
if (!Enabled || !ScopeEnabled || IsAdmin(user))
{
// Disabled security manager or Editor means full access
return true;
}
else if (!IsEditor(user) && !item.IsPublished())
{
// Non-editors cannot load unpublished items
return false;
}
return item.IsAuthorized(user);
}
示例11: WriteDefaultAttributes
protected virtual void WriteDefaultAttributes(ElementWriter itemElement, ContentItem item)
{
if (itemElement == null)
throw new ArgumentNullException("itemElement");
if (item == null)
throw new ArgumentNullException("item");
itemElement.WriteAttribute("id", item.ID);
itemElement.WriteAttribute("name", item.ID.ToString() == item.Name ? "" : item.Name, true);
if (item.Parent != null)
{
if (item.Parent.ID != 0)
itemElement.WriteAttribute("parent", item.Parent.ID.ToString());
else
{
itemElement.WriteAttribute("parent", item.Parent.VersionOf.ID.ToString());
if (item.Parent.GetVersionKey() != null)
itemElement.WriteAttribute("parentVersionKey", item.Parent.GetVersionKey());
}
}
itemElement.WriteAttribute("title", item.Title, true);
itemElement.WriteAttribute("zoneName", item.ZoneName, true);
itemElement.WriteAttribute("templateKey", item.TemplateKey, true);
if (item.TranslationKey.HasValue)
itemElement.WriteAttribute("translationKey", item.TranslationKey.Value);
itemElement.WriteAttribute("state", Enum.GetName(typeof(ContentState), item.State)); // use textual state to avoid future import trouble
itemElement.WriteAttribute("created", item.Created);
itemElement.WriteAttribute("updated", item.Updated);
itemElement.WriteAttribute("published", item.Published);
itemElement.WriteAttribute("expires", item.Expires); // TODO expired items could be excluded
itemElement.WriteAttribute("sortOrder", item.SortOrder);
if (item.IsPage && item.IsPublished())
itemElement.WriteAttribute("url", (parser != null) ? (string) parser.BuildUrl(item) : item.Url); // generated
itemElement.WriteAttribute("visible", item.Visible);
itemElement.WriteAttribute("savedBy", item.SavedBy);
itemElement.WriteAttribute("typeName", SerializationUtility.GetTypeAndAssemblyName(item.GetContentType()));
itemElement.WriteAttribute("discriminator", definitions.GetDefinition(item).Discriminator);
itemElement.WriteAttribute("ancestralTrail", item.AncestralTrail); // generated
if (item.AlteredPermissions != 0)
itemElement.WriteAttribute("alteredPermissions", (int)item.AlteredPermissions);
itemElement.WriteAttribute("childState", (int)item.ChildState);
if (item.VersionOf.HasValue && item.VersionOf.ID != null)
{
itemElement.WriteAttribute("versionIndex", item.VersionIndex); // write only if versioned
itemElement.WriteAttribute("versionOf", item.VersionOf.ID.Value);
}
}
示例12: IsPubliclyAvailableOrEmpty
private bool IsPubliclyAvailableOrEmpty(ContentItem item)
{
return (item == null) || (item.IsPublished() && (item.AlteredPermissions & Security.Permission.Read) == Security.Permission.None);
}
示例13: PerformMove
private void PerformMove(ContentItem toMove)
{
EnsureAuthorization(Permission.Write);
EnsureAuthorization(toMove, toMove.IsPublished() ? Permission.Publish : Permission.Write);
Engine.Persister.Move(toMove, Selection.SelectedItem);
Response.Redirect(Selection.SelectedUrl("{ManagementUrl}/Content/LinkTracker/UpdateReferences.aspx", toMove));
}