@@ -379,7 +379,7 @@ namespace umbraco.cms.businesslogic.packager
|
||||
if (saveNeeded) { insPack.Save(); saveNeeded = false; }
|
||||
|
||||
// Documents
|
||||
foreach (XmlElement n in _packageConfig.DocumentElement.SelectNodes("Documents/DocumentSet [@importMode = 'root']/node")) {
|
||||
foreach (XmlElement n in _packageConfig.DocumentElement.SelectNodes("Documents/DocumentSet [@importMode = 'root']/*")) {
|
||||
insPack.Data.ContentNodeId = cms.businesslogic.web.Document.Import(-1, u, n).ToString();
|
||||
}
|
||||
|
||||
@@ -572,7 +572,7 @@ namespace umbraco.cms.businesslogic.packager
|
||||
}
|
||||
|
||||
// Documents
|
||||
foreach (XmlElement n in _packageConfig.DocumentElement.SelectNodes("Documents/DocumentSet [@importMode = 'root']/node")) {
|
||||
foreach (XmlElement n in _packageConfig.DocumentElement.SelectNodes("Documents/DocumentSet [@importMode = 'root']/*")) {
|
||||
cms.businesslogic.web.Document.Import(-1, u, n);
|
||||
|
||||
//PPH todo log document install...
|
||||
|
||||
@@ -243,63 +243,103 @@ namespace umbraco.cms.businesslogic.web
|
||||
/// <param name="Source">Xmlsource</param>
|
||||
public static int Import(int ParentId, User Creator, XmlElement Source)
|
||||
{
|
||||
Document d = MakeNew(
|
||||
Source.GetAttribute("nodeName"),
|
||||
DocumentType.GetByAlias(Source.GetAttribute("nodeTypeAlias")),
|
||||
Creator,
|
||||
ParentId);
|
||||
// check what schema is used for the xml
|
||||
bool sourceIsLegacySchema = Source.Name.ToLower() == "node" ? true : false;
|
||||
|
||||
// check whether or not to create a new document
|
||||
int id = int.Parse(Source.GetAttribute("id"));
|
||||
Document d = null;
|
||||
if (Document.IsDocument(id))
|
||||
{
|
||||
try
|
||||
{
|
||||
// if the parent is the same, we'll update the existing document. Else we'll create a new document below
|
||||
d = new Document(id);
|
||||
if (d.ParentId != ParentId)
|
||||
d = null;
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
// document either didn't exist or had another parent so we'll create a new one
|
||||
if (d == null)
|
||||
{
|
||||
string nodeTypeAlias = sourceIsLegacySchema ? Source.GetAttribute("nodeTypeAlias") : Source.Name;
|
||||
d = MakeNew(
|
||||
Source.GetAttribute("nodeName"),
|
||||
DocumentType.GetByAlias(nodeTypeAlias),
|
||||
Creator,
|
||||
ParentId);
|
||||
}
|
||||
else
|
||||
{
|
||||
// update name of the document
|
||||
d.Text = Source.GetAttribute("nodeName");
|
||||
}
|
||||
|
||||
d.CreateDateTime = DateTime.Parse(Source.GetAttribute("createDate"));
|
||||
|
||||
// Properties
|
||||
foreach (XmlElement n in Source.SelectNodes("data"))
|
||||
string propertyXPath = sourceIsLegacySchema ? "data" : "* [not(@isDoc)]";
|
||||
foreach (XmlElement n in Source.SelectNodes(propertyXPath))
|
||||
{
|
||||
Property prop = d.getProperty(n.GetAttribute("alias"));
|
||||
string propertyAlias = sourceIsLegacySchema ? n.GetAttribute("alias") : n.Name;
|
||||
Property prop = d.getProperty(propertyAlias);
|
||||
string propValue = xmlHelper.GetNodeValue(n);
|
||||
|
||||
// only update real values
|
||||
if (!String.IsNullOrEmpty(propValue))
|
||||
if (prop != null)
|
||||
{
|
||||
//test if the property has prevalues, of so, try to convert the imported values so they match the new ones
|
||||
SortedList prevals = cms.businesslogic.datatype.PreValues.GetPreValues(prop.PropertyType.DataTypeDefinition.Id);
|
||||
|
||||
//Okey we found some prevalue, let's replace the vals with some ids
|
||||
if (prevals.Count > 0)
|
||||
// only update real values
|
||||
if (!String.IsNullOrEmpty(propValue))
|
||||
{
|
||||
System.Collections.Generic.List<string> list = new System.Collections.Generic.List<string>(propValue.Split(','));
|
||||
//test if the property has prevalues, of so, try to convert the imported values so they match the new ones
|
||||
SortedList prevals = cms.businesslogic.datatype.PreValues.GetPreValues(prop.PropertyType.DataTypeDefinition.Id);
|
||||
|
||||
foreach (DictionaryEntry item in prevals)
|
||||
//Okey we found some prevalue, let's replace the vals with some ids
|
||||
if (prevals.Count > 0)
|
||||
{
|
||||
string pval = ((umbraco.cms.businesslogic.datatype.PreValue)item.Value).Value;
|
||||
string pid = ((umbraco.cms.businesslogic.datatype.PreValue)item.Value).Id.ToString();
|
||||
System.Collections.Generic.List<string> list = new System.Collections.Generic.List<string>(propValue.Split(','));
|
||||
|
||||
if (list.Contains(pval))
|
||||
list[list.IndexOf(pval)] = pid;
|
||||
foreach (DictionaryEntry item in prevals)
|
||||
{
|
||||
string pval = ((umbraco.cms.businesslogic.datatype.PreValue)item.Value).Value;
|
||||
string pid = ((umbraco.cms.businesslogic.datatype.PreValue)item.Value).Id.ToString();
|
||||
|
||||
if (list.Contains(pval))
|
||||
list[list.IndexOf(pval)] = pid;
|
||||
|
||||
}
|
||||
|
||||
//join the list of new values and return it as the new property value
|
||||
System.Text.StringBuilder builder = new System.Text.StringBuilder();
|
||||
bool isFirst = true;
|
||||
|
||||
foreach (string str in list)
|
||||
{
|
||||
if (!isFirst)
|
||||
builder.Append(",");
|
||||
|
||||
builder.Append(str);
|
||||
isFirst = false;
|
||||
}
|
||||
prop.Value = builder.ToString();
|
||||
|
||||
}
|
||||
|
||||
//join the list of new values and return it as the new property value
|
||||
System.Text.StringBuilder builder = new System.Text.StringBuilder();
|
||||
bool isFirst = true;
|
||||
|
||||
foreach (string str in list)
|
||||
{
|
||||
if (!isFirst)
|
||||
builder.Append(",");
|
||||
|
||||
builder.Append(str);
|
||||
isFirst = false;
|
||||
}
|
||||
prop.Value = builder.ToString();
|
||||
|
||||
else
|
||||
prop.Value = propValue;
|
||||
}
|
||||
else
|
||||
prop.Value = propValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Add(LogTypes.Error, d.Id, String.Format("Couldn't import property '{0}' as the property type doesn't exist on this document type", propertyAlias));
|
||||
}
|
||||
}
|
||||
|
||||
d.Save();
|
||||
|
||||
// Subpages
|
||||
foreach (XmlElement n in Source.SelectNodes("node"))
|
||||
string subXPath = sourceIsLegacySchema ? "node" : "* [@isDoc]";
|
||||
foreach (XmlElement n in Source.SelectNodes(subXPath))
|
||||
Import(d.Id, Creator, n);
|
||||
|
||||
return d.Id;
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace umbraco.presentation.umbraco.dialogs
|
||||
public partial class ExportCode : BasePages.UmbracoEnsuredPage
|
||||
{
|
||||
private Dictionary<Guid, Type> dataTypeMapping = new Dictionary<Guid, Type>();
|
||||
private const string EXPORT_FOLDER = "exported-doctypes/";
|
||||
private const string EXPORT_FOLDER = "/exported-doctypes/";
|
||||
|
||||
private List<DocumentType> _docTypes;
|
||||
public List<DocumentType> DocTypes
|
||||
|
||||
@@ -176,7 +176,8 @@ namespace umbraco.presentation.translation
|
||||
XmlNodeList tasks = tf.SelectNodes("//task");
|
||||
|
||||
foreach (XmlNode taskXml in tasks) {
|
||||
XmlNode taskNode = taskXml.SelectSingleNode("node");
|
||||
string xpath = UmbracoSettings.UseLegacyXmlSchema ? "node" : "* [@isDoc]";
|
||||
XmlNode taskNode = taskXml.SelectSingleNode(xpath);
|
||||
|
||||
// validate file
|
||||
Task t = new Task(int.Parse(taskXml.Attributes.GetNamedItem("Id").Value));
|
||||
@@ -186,7 +187,8 @@ namespace umbraco.presentation.translation
|
||||
|
||||
// update node contents
|
||||
Document d = new Document(t.Node.Id);
|
||||
d.Text = taskNode.Attributes.GetNamedItem("nodeName").Value.Trim();
|
||||
Document.Import(d.ParentId, getUser(), (XmlElement)taskNode);
|
||||
/* d.Text = taskNode.Attributes.GetNamedItem("nodeName").Value.Trim();
|
||||
|
||||
// update data elements
|
||||
foreach (XmlNode data in taskNode.SelectNodes("data"))
|
||||
@@ -194,7 +196,7 @@ namespace umbraco.presentation.translation
|
||||
d.getProperty(data.Attributes.GetNamedItem("alias").Value).Value = data.FirstChild.Value;
|
||||
else
|
||||
d.getProperty(data.Attributes.GetNamedItem("alias").Value).Value = "";
|
||||
|
||||
*/
|
||||
|
||||
t.Closed = true;
|
||||
t.Save();
|
||||
|
||||
@@ -27,13 +27,13 @@ namespace umbraco.presentation.translation
|
||||
|
||||
Task t = new Task(taskId);
|
||||
Document translated = new Document(t.Node.Id);
|
||||
|
||||
translatedUrl = String.Format("/{0}.aspx?umbVersion={1}", translated.Id.ToString(), translated.Version.ToString());
|
||||
|
||||
translatedUrl = String.Format("../dialogs/preview.aspx?id={0}", translated.Id.ToString(), translated.Version.ToString());
|
||||
|
||||
Relation[] orgRel = Relation.GetRelations(t.Node.Id, RelationType.GetByAlias("relateDocumentOnCopy"));
|
||||
if (orgRel.Length > 0) {
|
||||
Document original = new Document(orgRel[0].Parent.Id);
|
||||
originalUrl = String.Format("/{0}.aspx?umbVersion={1}", original.Id.ToString(), original.Version.ToString());
|
||||
originalUrl = String.Format("../dialogs/preview.aspx?id={0}", original.Id.ToString(), original.Version.ToString());
|
||||
} else {
|
||||
Response.Redirect(translatedUrl);
|
||||
}
|
||||
|
||||
@@ -20,23 +20,25 @@ namespace umbraco.presentation.translation
|
||||
public partial class xml : BasePages.UmbracoEnsuredPage
|
||||
{
|
||||
private XmlDocument xd = new XmlDocument();
|
||||
|
||||
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
Response.ContentType = "text/xml";
|
||||
int pageId;
|
||||
|
||||
XmlNode root = xd.CreateElement("tasks");
|
||||
|
||||
|
||||
if (int.TryParse(Request["id"], out pageId))
|
||||
{
|
||||
Task t = new Task(pageId);
|
||||
if (t.User.Id == base.getUser().Id || t.ParentUser.Id == base.getUser().Id) {
|
||||
if (t.User.Id == base.getUser().Id || t.ParentUser.Id == base.getUser().Id)
|
||||
{
|
||||
XmlNode x = CreateTaskNode(t, xd);
|
||||
root.AppendChild(x);
|
||||
|
||||
xmlContents.Text = root.OuterXml;
|
||||
Response.AddHeader("Content-Disposition", "attachment; filename=" + x.SelectSingleNode("//node").Attributes.GetNamedItem("nodeName").Value.Replace(" ", "_") + ".xml");
|
||||
xmlContents.Text = root.OuterXml;
|
||||
|
||||
Response.AddHeader("Content-Disposition", "attachment; filename=" + t.Node.Text.Replace(" ", "_") + ".xml");
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -46,7 +48,8 @@ namespace umbraco.presentation.translation
|
||||
|
||||
foreach (Task t in Task.GetTasks(base.getUser(), false))
|
||||
{
|
||||
if (!nodes.ContainsKey(t.Node.Path)) {
|
||||
if (!nodes.ContainsKey(t.Node.Path))
|
||||
{
|
||||
XmlElement xTask = CreateTaskNode(t, xd);
|
||||
totalWords += int.Parse(xTask.Attributes.GetNamedItem("TotalWords").Value);
|
||||
nodes.Add(t.Node.Path, xTask);
|
||||
@@ -58,17 +61,19 @@ namespace umbraco.presentation.translation
|
||||
while (ide.MoveNext())
|
||||
{
|
||||
XmlElement x = (XmlElement)ide.Value;
|
||||
XmlNode parent = xd.SelectSingleNode("//node [@id = '" + x.SelectSingleNode("//node").Attributes.GetNamedItem("parentID").Value + "']");
|
||||
string parentXpath = UmbracoSettings.UseLegacyXmlSchema ? "//node [@id = '" + x.SelectSingleNode("//node").Attributes.GetNamedItem("parentID").Value + "']" :
|
||||
"//* [@isDoc and @id = '" + x.SelectSingleNode("//* [@isDoc]").Attributes.GetNamedItem("parentID").Value + "']";
|
||||
XmlNode parent = xd.SelectSingleNode(parentXpath);
|
||||
|
||||
if (parent == null)
|
||||
parent = root;
|
||||
else
|
||||
parent = parent.ParentNode;
|
||||
|
||||
parent.AppendChild((XmlElement) ide.Value);
|
||||
parent.AppendChild((XmlElement)ide.Value);
|
||||
}
|
||||
|
||||
root.Attributes.Append(global::umbraco.xmlHelper.addAttribute(xd, "TotalWords" , totalWords.ToString() ) );
|
||||
root.Attributes.Append(global::umbraco.xmlHelper.addAttribute(xd, "TotalWords", totalWords.ToString()));
|
||||
xmlContents.Text = root.OuterXml;
|
||||
Response.AddHeader("Content-Disposition", "attachment; filename=all.xml");
|
||||
|
||||
@@ -78,7 +83,7 @@ namespace umbraco.presentation.translation
|
||||
private XmlElement CreateTaskNode(Task t, XmlDocument xd)
|
||||
{
|
||||
Document d = new Document(t.Node.Id);
|
||||
XmlNode x = xd.CreateNode(XmlNodeType.Element, "node", "");
|
||||
XmlNode x = d.ToPreviewXml(xd);// xd.CreateNode(XmlNodeType.Element, "node", "");
|
||||
|
||||
XmlElement xTask = xd.CreateElement("task");
|
||||
xTask.SetAttributeNode(xmlHelper.addAttribute(xd, "Id", t.Id.ToString()));
|
||||
@@ -87,7 +92,7 @@ namespace umbraco.presentation.translation
|
||||
xTask.SetAttributeNode(xmlHelper.addAttribute(xd, "TotalWords", cms.businesslogic.translation.Translation.CountWords(d.Id).ToString()));
|
||||
xTask.AppendChild(xmlHelper.addCDataNode(xd, "Comment", t.Comment));
|
||||
xTask.AppendChild(xmlHelper.addTextNode(xd, "PreviewUrl", "http://" + Request.ServerVariables["SERVER_NAME"] + SystemDirectories.Umbraco + "/translation/preview.aspx?id=" + t.Id.ToString()));
|
||||
d.XmlPopulate(xd, ref x, false);
|
||||
// d.XmlPopulate(xd, ref x, false);
|
||||
xTask.AppendChild(x);
|
||||
|
||||
return xTask;
|
||||
|
||||
Reference in New Issue
Block a user