本文整理汇总了C#中ContentItem.GetVersionKey方法的典型用法代码示例。如果您正苦于以下问题:C# ContentItem.GetVersionKey方法的具体用法?C# ContentItem.GetVersionKey怎么用?C# ContentItem.GetVersionKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ContentItem
的用法示例。
在下文中一共展示了ContentItem.GetVersionKey方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteChild
protected virtual void WriteChild(XmlTextWriter writer, ContentItem child)
{
using (ElementWriter childElement = new ElementWriter("child", writer))
{
childElement.WriteAttribute("id", child.ID);
childElement.WriteAttribute("name", child.Name);
childElement.WriteAttribute("versionIndex", child.VersionIndex);
if (child.VersionOf.HasValue)
childElement.WriteAttribute("versionOf", child.VersionOf.Value.ID);
if (child.GetVersionKey() != null)
childElement.WriteAttribute("versionKey", child.GetVersionKey());
}
}
示例2: BuildUrl
/// <summary>Calculates an item url by walking it's parent path.</summary>
/// <param name="item">The item whose url to compute.</param>
/// <returns>A friendly url to the supplied item.</returns>
public override Url BuildUrl(ContentItem item)
{
if (item == null) throw new ArgumentNullException("item");
if (item.VersionOf.HasValue && item.VersionOf.Value != null)
{
return BuildUrl(item.VersionOf.Value)
.SetQueryParameter(PathData.VersionIndexQueryKey, item.VersionIndex);
}
else if (item.ID == 0)
{
var page = Find.ClosestPage(item);
if (page != null && page != item)
{
return BuildUrl(page)
.SetQueryParameter(PathData.VersionIndexQueryKey, page.VersionIndex)
.SetQueryParameter("versionKey", item.GetVersionKey());
}
}
// move up until first real page
var current = Find.ClosestPage(item);
// no page found, throw
if (current == null) throw new N2Exception("Cannot build url to data item '{0}' with no containing page item.", item);
Url url = BuildPageUrl(current, ref current);
var startPage = FindStartPage(current);
// no start page found, use rewritten url
if (startPage == null)
return item.FindPath(PathData.DefaultAction).GetRewrittenUrl();
if (!item.IsPage)
// the item was not a page, add this information as a query string
url = url.AppendQuery(PathData.ItemQueryKey, item.ID);
if (startPage.ID == host.CurrentSite.StartPageID)
{
// the start page belongs to the current site, use relative url
return Url.ToAbsolute("~" + url.PathAndQuery);
}
var site = host.GetSite(startPage.ID) ?? host.DefaultSite;
return GetHostedUrl(item, url, site);
}
示例3: FindPartVersion
public static ContentItem FindPartVersion(this ContentItem parent, ContentItem part)
{
if (part.ID == parent.VersionOf.ID)
return parent;
if (part.VersionOf.HasValue && part.VersionOf.ID == parent.VersionOf.ID)
return parent;
if (parent.ID == 0 && parent.GetVersionKey() == part.GetVersionKey())
return parent;
foreach (var child in parent.Children)
{
var grandChild = child.FindPartVersion(part);
if (grandChild != null)
return grandChild;
}
return null;
}
示例4: RefreshPreviewFrame
public static void RefreshPreviewFrame(this Page page, ContentItem item, string previewUrl)
{
var engine = page.GetEngine();
string script = string.Format(RefreshBothFormat,
engine.ManagementPaths.GetEditInterfaceUrl(), // 0
engine.ManagementPaths.GetNavigationUrl(item), // 1
Url.ToAbsolute(previewUrl), // 2
item.ID, // 3
item.Path, // 4
engine.ResolveAdapter<NodeAdapter>(item).GetMaximumPermission(item), // permission:'{5}',
"true", // force:{6}
item.VersionIndex,
item.GetVersionKey()
);
page.ClientScript.RegisterClientScriptBlock(
typeof(EditExtensions),
"RefreshFramesScript",
script, true);
}
示例5: AddChildItem
protected override void AddChildItem(Control container, ContentItem item)
{
if (State.IsFlagSet(ControlPanelState.DragDrop) && IsMovableOnThisPage(item))
{
string preview = Page.Request.QueryString["preview"];
if (!string.IsNullOrEmpty(preview))
{
int previewIndex;
int publishedItemID;
if (int.TryParse(preview, out previewIndex) && int.TryParse(Page.Request.QueryString["item"], out publishedItemID))
if (publishedItemID == item.ID)
item = Engine.Resolve<IVersionManager>().GetVersion(item, previewIndex);
}
ItemDefinition definition = GetDefinition(item);
Panel itemContainer = AddPanel(container, "zoneItem " + definition.Discriminator);
if (CurrentItem.ID != 0 && !CurrentItem.VersionOf.HasValue)
itemContainer.Attributes[PartUtilities.PathAttribute] = item.Path;
else
{
itemContainer.Attributes[PartUtilities.PathAttribute] = Find.ClosestPage(item).Path;
itemContainer.Attributes["data-versionKey"] = item.GetVersionKey();
itemContainer.Attributes["data-versionIndex"] = item.VersionIndex.ToString();
}
itemContainer.Attributes[PartUtilities.TypeAttribute] = definition.Discriminator;
itemContainer.Attributes["data-sortOrder"] = item.SortOrder.ToString();
Control toolbar = AddToolbar(itemContainer, item, definition);
base.AddChildItem(itemContainer, item);
}
else if (State.IsFlagSet(ControlPanelState.Previewing) && item.ID.ToString() == Page.Request["original"])
{
item = Engine.Persister.Get(int.Parse(Page.Request["preview"]));
base.AddChildItem(this, item);
}
else
{
base.AddChildItem(this, item);
}
}
示例6: GetEditExistingItemUrl
/// <summary>Gets the url to the edit page where to edit an existing item.</summary>
/// <param name="item">The item to edit.</param>
/// <returns>The url to the edit page</returns>
public virtual string GetEditExistingItemUrl(ContentItem item)
{
if (item == null)
return null;
var editUrl = EditItemUrl.ToUrl()
.ResolveTokens()
.SetQueryParameter(SelectionUtility.SelectedQueryKey, item.Path);
if (item.VersionOf.HasValue)
{
if (item.IsPage)
editUrl = editUrl
.SetQueryParameter(PathData.VersionIndexQueryKey, item.VersionIndex)
.SetQueryParameter("versionKey", item.GetVersionKey());
else
editUrl = editUrl
.SetQueryParameter(PathData.VersionIndexQueryKey, Find.ClosestPage(item).VersionIndex)
.SetQueryParameter("versionKey", item.GetVersionKey());
}
else if (item.ID == 0)
{
var page = Find.ClosestPage(item);
if (page != null && page.VersionOf.HasValue)
editUrl = editUrl
.SetQueryParameter(SelectionUtility.SelectedQueryKey, page.VersionOf.Path)
.SetQueryParameter(PathData.VersionIndexQueryKey, page.VersionIndex)
.SetQueryParameter("versionKey", item.GetVersionKey());
}
return editUrl;
}
示例7: GetEditNewPageUrl
/// <summary>Gets the url to edit page creating new items.</summary>
/// <param name="selected">The selected item.</param>
/// <param name="definition">The type of item to edit.</param>
/// <param name="zoneName">The zone to add the item to.</param>
/// <param name="position">The position relative to the selected item to add the item.</param>
/// <returns>The url to the edit page.</returns>
public virtual string GetEditNewPageUrl(ContentItem selected, ItemDefinition definition, string zoneName,
CreationPosition position)
{
if (selected == null) throw new ArgumentNullException("selected");
if (definition == null) throw new ArgumentNullException("definition");
ContentItem parent = (position != CreationPosition.Below)
? selected.Parent
: selected;
if (selected == null)
throw new N2Exception("Cannot insert item before or after the root page.");
Url url = Url.ResolveTokens(EditItemUrl);
url = url.AppendQuery(SelectionUtility.SelectedQueryKey, parent.Path);
url = url.AppendQuery("discriminator", definition.Discriminator);
if (!string.IsNullOrEmpty(zoneName))
url = url.AppendQuery("zoneName", zoneName);
if (!string.IsNullOrEmpty(definition.TemplateKey))
url = url.AppendQuery("template", definition.TemplateKey);
if (position == CreationPosition.Before)
url = url.AppendQuery("before", selected.Path);
else if (position == CreationPosition.After)
url = url.AppendQuery("after", selected.Path);
if (selected.VersionOf.HasValue)
{
url = url.AppendQuery(PathData.VersionIndexQueryKey, selected.VersionIndex)
.AppendQuery("VersionKey", selected.GetVersionKey());
}
return url;
}
示例8: EnsureDraft
private PathData EnsureDraft(ContentItem item)
{
var page = Find.ClosestPage(item);
if (page.ID == 0)
return new PathData(page, item);
var cvr = Engine.Resolve<ContentVersionRepository>();
var vm = Engine.Resolve<IVersionManager>();
var path = PartsExtensions.EnsureDraft(vm, cvr, "", item.GetVersionKey(), item);
return path;
}
示例9: ResolvePartActionUrl
private VirtualPathData ResolvePartActionUrl(RequestContext requestContext, RouteValueDictionary values, ContentItem page, ContentItem item)
{
if (page.ID == 0)
{
if (page.VersionOf.Value == null)
return null;
values[ContentPageKey] = page.VersionOf.ID;
values[PathData.VersionIndexQueryKey] = page.VersionIndex;
}
else
values[ContentPageKey] = page.ID;
values[ContentPartKey] = item.ID;
if (item.ID == 0)
{
if (item.VersionOf.Value != null)
values[ContentPartKey] = item.VersionOf.ID;
values[PathData.VersionKeyQueryKey] = item.GetVersionKey();
}
var vpd = innerRoute.GetVirtualPath(requestContext, values);
if (vpd == null)
return null;
vpd.Route = this;
vpd.DataTokens[PathData.PathKey] = new PathData(page, item);
return vpd;
}
示例10: RenderTemplate
protected override void RenderTemplate(TextWriter writer, ContentItem model)
{
if (state.IsFlagSet(ControlPanelState.DragDrop) && model.Parent == CurrentItem)
{
ItemDefinition definition = Html.ResolveService<IDefinitionManager>().GetDefinition(model);
writer.Write("<div class='" + definition.Discriminator + " zoneItem'");
if (model.ID != 0 && !model.VersionOf.HasValue)
writer.WriteAttribute(PartUtilities.PathAttribute, model.Path);
else
{
writer.WriteAttribute(PartUtilities.PathAttribute, Find.ClosestPage(model).Path);
writer.WriteAttribute("data-versionKey", model.GetVersionKey())
.WriteAttribute("data-versionIndex", model.VersionIndex.ToString());
}
writer.WriteAttribute("data-sortOrder", model.SortOrder.ToString())
.WriteAttribute(PartUtilities.TypeAttribute, definition.Discriminator);
writer.Write(">");
Html.ResolveService<PartUtilities>().WriteTitleBar(writer, model, Html.ViewContext.HttpContext.Request.RawUrl);
base.RenderTemplate(writer, model);
writer.Write("</div>");
}
else
base.RenderTemplate(writer, model);
}
示例11: BuildUrl
/// <summary>Calculates an item url by walking it's parent path.</summary>
/// <param name="item">The item whose url to compute.</param>
/// <returns>A friendly url to the supplied item.</returns>
public virtual Url BuildUrl(ContentItem item)
{
if (item == null) throw new ArgumentNullException("item");
if (item.VersionOf.HasValue)
{
ContentItem version = item.VersionOf;
if (version != null)
return BuildUrl(version).SetQueryParameter(PathData.VersionIndexQueryKey, item.VersionIndex);
}
else if (item.ID == 0)
{
var page = Find.ClosestPage(item);
if (page != null && page != item)
{
return BuildUrl(page)
.SetQueryParameter(PathData.VersionIndexQueryKey, page.VersionIndex)
.SetQueryParameter("versionKey", item.GetVersionKey());
}
}
var current = Find.ClosestPage(item);
// no page found, throw
if (current == null) throw new N2Exception("Cannot build url to data item '{0}' with no containing page item.", item);
Url url = BuildPageUrl(current, ref current);
if (current == null)
// no start page found, use rewritten url
return item.FindPath(PathData.DefaultAction).GetRewrittenUrl();
if (!item.IsPage)
// the item was not a page, add this information as a query string
url = url.AppendQuery(PathData.ItemQueryKey, item.ID);
var absoluteUrl = Url.ToAbsolute("~" + url);
if (BuiltUrl != null)
{
var args = new UrlEventArgs(item) { Url = absoluteUrl };
BuiltUrl(this, args);
return args.Url;
}
else
return absoluteUrl;
}
示例12: ApplyCommonValuesRecursive
private void ApplyCommonValuesRecursive(ContentItem parent)
{
if (string.IsNullOrEmpty(parent.GetVersionKey()))
parent.SetVersionKey(Guid.NewGuid().ToString());
foreach (var child in parent.Children)
{
child.State = parent.State;
child.VersionIndex = parent.VersionIndex;
ApplyCommonValuesRecursive(child);
}
}
示例13: ApplyCommonValuesRecursive
private void ApplyCommonValuesRecursive(ContentItem parent)
{
if (string.IsNullOrEmpty(parent.GetVersionKey()))
parent.SetVersionKey(Guid.NewGuid().ToString());
foreach (var child in parent.Children)
{
// copy state-related properties
child.State = parent.State;
child.Published = parent.Published;
child.Expires = parent.Expires;
child.VersionIndex = parent.VersionIndex;
ApplyCommonValuesRecursive(child);
}
}
示例14: GetEditExistingItemUrl
/// <summary>Gets the url to the edit page where to edit an existing item.</summary>
/// <param name="item">The item to edit.</param>
/// <returns>The url to the edit page</returns>
public virtual string GetEditExistingItemUrl(ContentItem item, string returnUrl = null, string alternativeEditorPath = null)
{
if (item == null)
return null;
var editUrl = (alternativeEditorPath ?? EditItemUrl).ToUrl()
.ResolveTokens()
.SetQueryParameter(SelectionUtility.SelectedQueryKey, item.Path);
if (item.VersionOf.HasValue)
{
editUrl = editUrl.SetQueryParameter(PathData.ItemQueryKey, item.VersionOf.ID.Value);
if (item.IsPage)
editUrl = editUrl
.SetQueryParameter(PathData.VersionIndexQueryKey, item.VersionIndex)
.SetQueryParameter(PathData.VersionKeyQueryKey, item.GetVersionKey());
else
editUrl = editUrl
.SetQueryParameter(PathData.VersionIndexQueryKey, Find.ClosestPage(item).VersionIndex)
.SetQueryParameter(PathData.VersionKeyQueryKey, item.GetVersionKey());
}
else if (item.ID == 0)
{
var page = Find.ClosestPage(item);
editUrl = editUrl.SetQueryParameter(PathData.ItemQueryKey, page.ID);
if (page != null)
editUrl = editUrl
.SetQueryParameter(SelectionUtility.SelectedQueryKey, (page.VersionOf.Value ?? page).Path)
.SetQueryParameter(PathData.VersionIndexQueryKey, page.VersionIndex)
.SetQueryParameter(PathData.VersionKeyQueryKey, item.GetVersionKey());
}
if (returnUrl != null)
editUrl = editUrl.SetQueryParameter("returnUrl", returnUrl);
return editUrl;
}
示例15: FormatSelectedUrl
private static string FormatSelectedUrl(ContentItem selectedItem, string path)
{
Url url = Url.ResolveTokens(path);
if (selectedItem != null)
{
if (selectedItem.ID == 0 && !selectedItem.VersionOf.HasValue && !selectedItem.IsPage)
{
var page = Find.ClosestPage(selectedItem);
return url.AppendQuery(SelectionUtility.SelectedQueryKey + "=" + page.Path)
.AppendQuery(PathData.VersionIndexQueryKey + "=" + page.VersionIndex)
.AppendQuery("versionKey", selectedItem.GetVersionKey());
}
url = url.AppendQuery(SelectionUtility.SelectedQueryKey + "=" + selectedItem.Path);
if (selectedItem.VersionOf.HasValue)
url = url.AppendQuery(PathData.VersionIndexQueryKey + "=" + selectedItem.VersionIndex)
.AppendQuery("versionKey", selectedItem.GetVersionKey());
}
return url;
}