diff --git a/src/Umbraco.Web.UI/umbraco/dialogs/sort.aspx b/src/Umbraco.Web.UI/umbraco/dialogs/sort.aspx
index a2792d1b50..36f8271741 100644
--- a/src/Umbraco.Web.UI/umbraco/dialogs/sort.aspx
+++ b/src/Umbraco.Web.UI/umbraco/dialogs/sort.aspx
@@ -48,7 +48,7 @@
| Name |
- Creation date |
+ ">Creation date |
Sort order |
diff --git a/src/Umbraco.Web.UI/umbraco_client/Dialogs/SortDialog.js b/src/Umbraco.Web.UI/umbraco_client/Dialogs/SortDialog.js
index a7bb1d9f29..eb62afd805 100644
--- a/src/Umbraco.Web.UI/umbraco_client/Dialogs/SortDialog.js
+++ b/src/Umbraco.Web.UI/umbraco_client/Dialogs/SortDialog.js
@@ -59,7 +59,7 @@
$.ajax({
type: "POST",
url: self._opts.serviceUrl,
- data: '{ "ParentId": ' + parseInt(self._opts.currentId) + ', "SortOrder": "' + sortOrder + '"}',
+ data: '{ "ParentId": "' + self._opts.currentId + '", "SortOrder": "' + sortOrder + '"}',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(msg) {
diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/sort.aspx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/sort.aspx.cs
index 2b104404b4..547d2c2ac7 100644
--- a/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/sort.aspx.cs
+++ b/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/sort.aspx.cs
@@ -23,6 +23,12 @@ namespace umbraco.cms.presentation
{
private readonly List _nodes = new List();
+ protected bool HideDateColumn
+ {
+ set { ViewState["HideDateColumn"] = value; }
+ get { return ViewState["HideDateColumn"] == null ? false : (bool) ViewState["HideDateColumn"]; }
+ }
+
protected override void OnInit(EventArgs e)
{
CurrentApp = helper.Request("app");
@@ -56,13 +62,13 @@ namespace umbraco.cms.presentation
if (parentId == -1)
{
foreach (var child in mediaService.GetRootMedia().ToList().OrderBy(x => x.SortOrder))
- _nodes.Add(CreateNode(child.Id, child.SortOrder, child.Name, child.CreateDate, icon));
+ _nodes.Add(CreateNode(child.Id.ToInvariantString(), child.SortOrder, child.Name, child.CreateDate, icon));
}
else
{
var children = mediaService.GetChildren(parentId);
foreach (var child in children.OrderBy(x => x.SortOrder))
- _nodes.Add(CreateNode(child.Id, child.SortOrder, child.Name, child.CreateDate, icon));
+ _nodes.Add(CreateNode(child.Id.ToInvariantString(), child.SortOrder, child.Name, child.CreateDate, icon));
}
}
@@ -73,29 +79,41 @@ namespace umbraco.cms.presentation
if (parentId == -1)
{
foreach (var child in contentService.GetRootContent().ToList().OrderBy(x => x.SortOrder))
- _nodes.Add(CreateNode(child.Id, child.SortOrder, child.Name, child.CreateDate, icon));
+ _nodes.Add(CreateNode(child.Id.ToInvariantString(), child.SortOrder, child.Name, child.CreateDate, icon));
}
else
{
var children = contentService.GetChildren(parentId);
foreach (var child in children)
- _nodes.Add(CreateNode(child.Id, child.SortOrder, child.Name, child.CreateDate, icon));
+ _nodes.Add(CreateNode(child.Id.ToInvariantString(), child.SortOrder, child.Name, child.CreateDate, icon));
}
}
-
+
+ bindNodesToList(string.Empty);
+ }
+ else
+ {
// hack for stylesheet, used to sort stylesheet properties
if (app == Constants.Applications.Settings)
{
icon = "../images/umbraco/settingCss.gif";
- var ss = new StyleSheet(parentId);
- foreach (var child in ss.Properties)
- {
- var node = new CMSNode(child.Id);
- _nodes.Add(CreateNode(child.Id, node.sortOrder, child.Text, child.CreateDateTime, icon));
- }
- }
- bindNodesToList(string.Empty);
+ HideDateColumn = true;
+
+ var stylesheetName = Request.GetItemAsString("ID");
+ if (stylesheetName.IsNullOrWhiteSpace())throw new NullReferenceException("No Id passed in to editor");
+ var stylesheet = Services.FileService.GetStylesheetByName(stylesheetName.EnsureEndsWith(".css"));
+ if (stylesheet == null) throw new InvalidOperationException("No stylesheet found by name " + stylesheetName);
+
+ var sort = 0;
+ foreach (var child in stylesheet.Properties)
+ {
+ _nodes.Add(CreateNode(child.Name, sort, child.Name, DateTime.Now, icon));
+ sort++;
+ }
+
+ bindNodesToList(string.Empty);
+ }
}
}
@@ -115,10 +133,12 @@ namespace umbraco.cms.presentation
}
foreach (var n in _nodes)
- lt_nodes.Text += string.Format("| {1} | {2} {3} | {4} |
", n.id, n.Name, n.createDate.ToShortDateString(), n.createDate.ToShortTimeString(), n.sortOder);
+ lt_nodes.Text += string.Format(
+ "| {1} | {2} {3} | {4} |
",
+ n.id, n.Name, n.createDate.ToShortDateString(), n.createDate.ToShortTimeString(), n.sortOder, HideDateColumn ? "none" : "block");
}
- private static SortableNode CreateNode(int id, int sortOrder, string name, DateTime createDateTime, string icon)
+ private static SortableNode CreateNode(string id, int sortOrder, string name, DateTime createDateTime, string icon)
{
var node = new SortableNode
{
@@ -133,7 +153,7 @@ namespace umbraco.cms.presentation
public struct SortableNode
{
- public int id;
+ public string id;
public int sortOder;
public string Name;
public string icon;
diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/webservices/nodeSorter.asmx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/webservices/nodeSorter.asmx.cs
index 2177fedeb1..a0aed7ccdb 100644
--- a/src/Umbraco.Web/umbraco.presentation/umbraco/webservices/nodeSorter.asmx.cs
+++ b/src/Umbraco.Web/umbraco.presentation/umbraco/webservices/nodeSorter.asmx.cs
@@ -31,54 +31,70 @@ namespace umbraco.presentation.webservices
public class nodeSorter : UmbracoAuthorizedWebService
{
[WebMethod]
- public SortNode GetNodes(int ParentId, string App)
+ public SortNode GetNodes(string ParentId, string App)
{
if (BasePage.ValidateUserContextID(BasePage.umbracoUserContextID))
{
- var parent = new SortNode { Id = ParentId };
var nodes = new List();
- var entityService = base.ApplicationContext.Services.EntityService;
- // Root nodes?
- if (ParentId == -1)
+ // "hack for stylesheet"
+ if (App == "settings")
{
- if (App == "media")
+ var stylesheet = Services.FileService.GetStylesheetByName(ParentId.EnsureEndsWith(".css"));
+ if (stylesheet == null) throw new InvalidOperationException("No stylesheet found by name " + ParentId);
+
+ var sort = 0;
+ foreach (var child in stylesheet.Properties)
{
- var rootMedia = entityService.GetRootEntities(UmbracoObjectTypes.Media);
- nodes.AddRange(rootMedia.Select(media => new SortNode(media.Id, media.SortOrder, media.Name, media.CreateDate)));
+ nodes.Add(new SortNode(child.Name.GetHashCode(), sort, child.Name, DateTime.Now));
+ sort++;
}
- else
+
+ return new SortNode()
{
- var rootContent = entityService.GetRootEntities(UmbracoObjectTypes.Document);
- nodes.AddRange(rootContent.Select(content => new SortNode(content.Id, content.SortOrder, content.Name, content.CreateDate)));
- }
+ SortNodes = nodes.ToArray()
+ };
}
else
{
- // "hack for stylesheet"
- if (App == "settings")
+ var asInt = int.Parse(ParentId);
+
+ var parent = new SortNode { Id = asInt };
+
+ var entityService = base.ApplicationContext.Services.EntityService;
+
+ // Root nodes?
+ if (asInt == -1)
{
- var cmsNode = new cms.businesslogic.CMSNode(ParentId);
- var styleSheet = new StyleSheet(cmsNode.Id);
- nodes.AddRange(styleSheet.Properties.Select(child => new SortNode(child.Id, child.sortOrder, child.Text, child.CreateDateTime)));
+ if (App == "media")
+ {
+ var rootMedia = entityService.GetRootEntities(UmbracoObjectTypes.Media);
+ nodes.AddRange(rootMedia.Select(media => new SortNode(media.Id, media.SortOrder, media.Name, media.CreateDate)));
+ }
+ else
+ {
+ var rootContent = entityService.GetRootEntities(UmbracoObjectTypes.Document);
+ nodes.AddRange(rootContent.Select(content => new SortNode(content.Id, content.SortOrder, content.Name, content.CreateDate)));
+ }
}
else
{
- var children = entityService.GetChildren(ParentId);
+ var children = entityService.GetChildren(asInt);
nodes.AddRange(children.Select(child => new SortNode(child.Id, child.SortOrder, child.Name, child.CreateDate)));
}
+
+
+ parent.SortNodes = nodes.ToArray();
+
+ return parent;
}
-
- parent.SortNodes = nodes.ToArray();
-
- return parent;
}
throw new ArgumentException("User not logged in");
}
[WebMethod]
- public void UpdateSortOrder(int ParentId, string SortOrder)
+ public void UpdateSortOrder(string ParentId, string SortOrder)
{
if (AuthorizeRequest() == false) return;
if (SortOrder.Trim().Length <= 0) return;
@@ -92,13 +108,17 @@ namespace umbraco.presentation.webservices
var ids = SortOrder.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries);
if (isContent)
- SortContent(ids, ParentId);
-
- if (isMedia)
+ {
+ SortContent(ids, int.Parse(ParentId));
+ }
+ else if (isMedia)
+ {
SortMedia(ids);
-
- if (isContent == false && isMedia == false)
- SortStylesheetProperties(ids);
+ }
+ else
+ {
+ SortStylesheetProperties(ParentId, ids);
+ }
}
private void SortMedia(string[] ids)
@@ -123,20 +143,27 @@ namespace umbraco.presentation.webservices
}
}
- private void SortStylesheetProperties(string[] ids)
+
+ private void SortStylesheetProperties(string stylesheetName, string[] names)
{
- try
+ var stylesheet = Services.FileService.GetStylesheetByName(stylesheetName.EnsureEndsWith(".css"));
+ if (stylesheet == null) throw new InvalidOperationException("No stylesheet found by name " + stylesheetName);
+
+ var currProps = stylesheet.Properties.ToArray();
+ //remove them all first
+ foreach (var prop in currProps)
{
- for (var i = 0; i < ids.Length; i++)
- {
- var id = int.Parse(ids[i]);
- new cms.businesslogic.CMSNode(id).sortOrder = i;
- }
+ stylesheet.RemoveProperty(prop.Name);
}
- catch (Exception ex)
+
+ //re-add them in the right order
+ for (var i = 0; i < names.Length; i++)
{
- LogHelper.Error("Could not update stylesheet property sort order", ex);
+ var found = currProps.Single(x => x.Name == names[i]);
+ stylesheet.AddProperty(found);
}
+
+ Services.FileService.SaveStylesheet(stylesheet);
}
private void SortContent(string[] ids, int parentId)
@@ -168,7 +195,7 @@ namespace umbraco.presentation.webservices
LogHelper.Error("Could not update content sort order", ex);
}
}
-
+
}
[Serializable]