本文整理汇总了C#中umbraco.cms.businesslogic.web.Document.ToPreviewXml方法的典型用法代码示例。如果您正苦于以下问题:C# Document.ToPreviewXml方法的具体用法?C# Document.ToPreviewXml怎么用?C# Document.ToPreviewXml使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类umbraco.cms.businesslogic.web.Document
的用法示例。
在下文中一共展示了Document.ToPreviewXml方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateTaskNode
private XmlElement CreateTaskNode(Task t, XmlDocument xd)
{
Document d = new Document(t.Node.Id);
XmlNode x = d.ToPreviewXml(xd);// xd.CreateNode(XmlNodeType.Element, "node", "");
XmlElement xTask = xd.CreateElement("task");
xTask.SetAttributeNode(xmlHelper.addAttribute(xd, "Id", t.Id.ToString()));
xTask.SetAttributeNode(xmlHelper.addAttribute(xd, "Date", t.Date.ToString("s")));
xTask.SetAttributeNode(xmlHelper.addAttribute(xd, "NodeId", t.Node.Id.ToString()));
xTask.SetAttributeNode(xmlHelper.addAttribute(xd, "TotalWords", cms.businesslogic.translation.Translation.CountWords(d.Id).ToString()));
xTask.AppendChild(xmlHelper.addCDataNode(xd, "Comment", t.Comment));
string protocol = GlobalSettings.UseSSL ? "https" : "http";
xTask.AppendChild(xmlHelper.addTextNode(xd, "PreviewUrl", protocol + "://" + Request.ServerVariables["SERVER_NAME"] + SystemDirectories.Umbraco + "/translation/preview.aspx?id=" + t.Id.ToString()));
// d.XmlPopulate(xd, ref x, false);
xTask.AppendChild(x);
return xTask;
}
示例2: PrepareDocument
public void PrepareDocument(User user, Document documentObject, bool includeSubs)
{
_userId = user.Id;
// clone xml
XmlContent = (XmlDocument)content.Instance.XmlContent.Clone();
// inject current document xml
int parentId = documentObject.Level == 1 ? -1 : documentObject.Parent.Id;
XmlContent = content.AppendDocumentXml(documentObject.Id, documentObject.Level, parentId, documentObject.ToPreviewXml(XmlContent), XmlContent);
if (includeSubs)
{
foreach (CMSPreviewNode prevNode in documentObject.GetNodesForPreview(true))
{
XmlContent = content.AppendDocumentXml(prevNode.NodeId, prevNode.Level, prevNode.ParentId, XmlContent.ReadNode(XmlReader.Create(new StringReader(prevNode.Xml))), XmlContent);
}
}
}
示例3: PrepareDocument
public void PrepareDocument(User user, Document documentObject, bool includeSubs)
{
_userId = user.Id;
// clone xml
XmlContent = (XmlDocument)content.Instance.XmlContent.Clone();
var previewNodes = new List<Document>();
var parentId = documentObject.Level == 1 ? -1 : documentObject.Parent.Id;
while (parentId > 0 && XmlContent.GetElementById(parentId.ToString(CultureInfo.InvariantCulture)) == null)
{
var document = new Document(parentId);
previewNodes.Insert(0, document);
parentId = document.ParentId;
}
previewNodes.Add(documentObject);
foreach (var document in previewNodes)
{
//Inject preview xml
parentId = document.Level == 1 ? -1 : document.Parent.Id;
var previewXml = document.ToPreviewXml(XmlContent);
content.AppendDocumentXml(document.Id, document.Level, parentId, previewXml, XmlContent);
}
if (includeSubs)
{
foreach (var prevNode in documentObject.GetNodesForPreview(true))
{
XmlContent = content.AppendDocumentXml(prevNode.NodeId, prevNode.Level, prevNode.ParentId, XmlContent.ReadNode(XmlReader.Create(new StringReader(prevNode.Xml))), XmlContent);
}
}
}
示例4: getPreviewOrPublishedNode
private static XmlNode getPreviewOrPublishedNode(Document d, XmlDocument xmlContentCopy, bool isPreview)
{
if (isPreview)
{
return d.ToPreviewXml(xmlContentCopy);
}
else
{
return d.ToXml(xmlContentCopy, false);
}
}
示例5: OnRenderNode
/// <summary>
/// Called when [render node].
/// </summary>
/// <param name="xNode">The x node.</param>
/// <param name="doc">The doc.</param>
protected override void OnRenderNode(ref XmlTreeNode xNode, Document doc)
{
base.OnRenderNode(ref xNode, doc);
var dataTypeId = this.GetDataTypeId();
var xpath = this.GetXPathFromCookie(dataTypeId);
var xPathType = this.GetXPathFilterTypeFromCookie(dataTypeId);
// resolves any Umbraco params in the XPath
xpath = uQuery.ResolveXPath(xpath);
var xDoc = new XmlDocument();
XmlNode xmlDoc;
if (!doc.Published)
{
xmlDoc = doc.ToPreviewXml(xDoc);
}
else
{
xmlDoc = doc.ToXml(xDoc, false);
}
var xmlString = "<root>" + xmlDoc.OuterXml + "</root>";
var xml = XElement.Parse(xmlString);
xNode.DetermineClickable(xpath, xPathType, xml);
//ensure that the NodeKey is passed through
xNode.Source = this.GetTreeServiceUrlWithParams(int.Parse(xNode.NodeID), dataTypeId);
}
示例6: GetContentXmlNode
private XmlNode GetContentXmlNode(string nodeId)
{
// try to get node from XML cache
XmlNode xmlNode = content.Instance.XmlContent.GetElementById(nodeId);
if (xmlNode == null)
{
// if unpublished, get from Document (database)
var doc = new Document(int.Parse(nodeId));
if (doc != null)
{
// get the preview XML
xmlNode = doc.ToPreviewXml(new XmlDocument());
}
}
return xmlNode;
}
示例7: PrepareDocument
public void PrepareDocument(User user, Document documentObject, bool includeSubs)
{
_userId = user.Id;
// clone xml
XmlContent = (XmlDocument)content.Instance.XmlContent.Clone();
var previewNodes = new List<Document>();
var parentId = documentObject.Level == 1 ? -1 : documentObject.Parent.Id;
while (parentId > 0 && XmlContent.GetElementById(parentId.ToString(CultureInfo.InvariantCulture)) == null)
{
var document = new Document(parentId);
previewNodes.Insert(0, document);
parentId = document.ParentId;
}
previewNodes.Add(documentObject);
foreach (var document in previewNodes)
{
//Inject preview xml
parentId = document.Level == 1 ? -1 : document.Parent.Id;
var previewXml = document.ToPreviewXml(XmlContent);
if (document.Content.Published == false
&& ApplicationContext.Current.Services.ContentService.HasPublishedVersion(document.Id))
previewXml.Attributes.Append(XmlContent.CreateAttribute("isDraft"));
content.AppendDocumentXml(document.Id, document.Level, parentId, previewXml, XmlContent);
}
if (includeSubs)
{
foreach (var prevNode in documentObject.GetNodesForPreview(true))
{
var previewXml = XmlContent.ReadNode(XmlReader.Create(new StringReader(prevNode.Xml)));
if (prevNode.IsDraft)
previewXml.Attributes.Append(XmlContent.CreateAttribute("isDraft"));
XmlContent = content.AppendDocumentXml(prevNode.NodeId, prevNode.Level, prevNode.ParentId, previewXml, XmlContent);
}
}
}