Skip to content

Commit

Permalink
Merge pull request #83 from KalikoCMS/1.1.1-dev
Browse files Browse the repository at this point in the history
Merge 1.1.1 to master
  • Loading branch information
fschultz committed Jan 20, 2016
2 parents a6d94f2 + c95da89 commit a006252
Show file tree
Hide file tree
Showing 13 changed files with 182 additions and 144 deletions.
8 changes: 5 additions & 3 deletions KalikoCMS.Admin/Admin/Content/EditPage.aspx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ private void SaveButtonEventHandler(object sender, EventArgs e) {
var page = SaveData();

if (_pageTypeId > 0) {
Feedback.Text = string.Format("<script>parent.$('.notifications.top-right').notify({{ type: 'info', message: \"<i class=\\\"icon-flag\\\"></i> Page <b>{0}</b> has been created!!\", fadeOut: {{ enabled: true, delay: 5000 }}}}).show();parent.refreshTreeNode('{1}','{2}');document.location = '{3}?id={2}';</script>", _pageName, _parentId, _pageId, Request.Path);
Feedback.Text = string.Format("<script>parent.$('.notifications.top-right').notify({{ type: 'info', message: \"<i class=\\\"icon-flag\\\"></i> Page <b>{0}</b> has been created!!\", fadeOut: {{ enabled: true, delay: 5000 }}}}).show();parent.refreshTreeNode('{1}','{2}');document.location = '{3}?id={2}';</script>", _pageName.Replace("\"", "\\\""), _parentId, _pageId, Request.Path);
Feedback.Visible = true;
}
else {
Expand All @@ -223,11 +223,11 @@ private void PublishButtonEventHandler(object sender, EventArgs e) {
ScriptArea.Text = "top.refreshNode('" + CurrentPageId + "');";

if (_pageTypeId > 0) {
Feedback.Text = string.Format("<script>parent.$('.notifications.top-right').notify({{ type: 'info', message: \"<i class=\\\"icon-flag\\\"></i> Page <b>{0}</b> has been created and published!!\", fadeOut: {{ enabled: true, delay: 5000 }}}}).show();parent.refreshTreeNode('{1}','{2}');document.location = '{3}?id={2}';</script>", _pageName, _parentId, _pageId, Request.Path);
Feedback.Text = string.Format("<script>parent.$('.notifications.top-right').notify({{ type: 'info', message: \"<i class=\\\"icon-flag\\\"></i> Page <b>{0}</b> has been created and published!!\", fadeOut: {{ enabled: true, delay: 5000 }}}}).show();parent.refreshTreeNode('{1}','{2}');document.location = '{3}?id={2}';</script>", _pageName.Replace("\"", "\\\""), _parentId, _pageId, Request.Path);
Feedback.Visible = true;
}
else {
Feedback.Text = string.Format("<script>parent.$('.notifications.top-right').notify({{ type: 'info', message: \"<i class=\\\"icon-flag\\\"></i> Page <b>{0}</b> has been published!!\", fadeOut: {{ enabled: true, delay: 5000 }}}}).show();</script>", _pageName);
Feedback.Text = string.Format("<script>parent.$('.notifications.top-right').notify({{ type: 'info', message: \"<i class=\\\"icon-flag\\\"></i> Page <b>{0}</b> has been published!!\", fadeOut: {{ enabled: true, delay: 5000 }}}}).show();</script>", _pageName.Replace("\"", "\\\""));
Feedback.Visible = true;
}
}
Expand Down Expand Up @@ -272,6 +272,7 @@ private EditablePage SaveDataForNewPage() {
var editablePage = parent.CreateChildPage(_pageTypeId);
SavePropertiesForPage(editablePage);
_pageId = editablePage.PageId;
_pageName = editablePage.PageName;
OldPageUrlSegment.Value = editablePage.UrlSegment;

return editablePage;
Expand All @@ -283,6 +284,7 @@ private EditablePage SaveDataForExistingPage() {
var editablePage = cmsPage.MakeEditable();
SavePropertiesForPage(editablePage);
OldPageUrlSegment.Value = editablePage.UrlSegment;
_pageName = editablePage.PageName;

return editablePage;
}
Expand Down
50 changes: 31 additions & 19 deletions KalikoCMS.Admin/Admin/Content/PageTree/JQueryTreeContent.ashx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,43 +19,55 @@

namespace KalikoCMS.Admin.Content.PageTree {
using System;
using System.Text;
using System.Collections.Generic;
using System.Web;
using fastJSON;
using KalikoCMS.Core;
using KalikoCMS.Data;
using KalikoCMS.Caching;

public class JQueryTreeContent : IHttpHandler {
private class JQueryTreeItem {
// ReSharper disable InconsistentNaming
public string text { get; set; }
public bool children { get; set; }
public string id { get; set; }
public string parent { get; set; }
public string icon { get; set; }
public object a_attr { get; set; }
// ReSharper restore InconsistentNaming
}

private class JQueryTreeLink {
public string href { get; set; }
}

private void GetChildren(HttpContext context) {
context.Response.ContentType = "application/json";

var items = new List<dynamic>();

var id = context.Request.Form["id"];
if (id == "#") {
context.Response.Write("[{\"text\":\"Root\",\"children\":true,\"id\":\"" + Guid.Empty + "\",\"parent\":\"#\",\"icon\":\"jstree-rooticon\"}]");
items.Add(new JQueryTreeItem {text = "Root", children = true, id = Guid.Empty.ToString(), parent = "#", icon = "jstree-rooticon"});
context.Response.Write(Serialization.JsonSerialization.SerializeJson(items, new JSONParameters { UseExtensions = false, SerializeNullValues = false }));
context.Response.End();
}

var pageId = new Guid(id);
var separator = string.Empty;

var children = PageFactory.GetChildrenForPage(pageId, PublishState.All);
var stringBuilder = new StringBuilder();
stringBuilder.Append("[");


foreach (Guid childId in children.PageIds) {
foreach (var childId in children.PageIds) {
var page = PageFactory.GetPage(childId);
var icon = page.Status == PageInstanceStatus.Published ? "" : "jstree-newpage";
var text = page.Status == PageInstanceStatus.Published ? page.PageName : "<i>" + page.PageName + "</i>";
stringBuilder.AppendFormat("{0}{{\"text\": \"{1}\", \"id\": \"{2}\", \"children\": {3}, \"a_attr\": {{ \"href\": \"{4}\" }},\"icon\":\"{5}\"}}", separator, text, childId, (page.HasChildren ? "true" : "false"), page.PageUrl, icon);
separator = ",";
items.Add(new JQueryTreeItem { text = text, children = page.HasChildren, id = childId.ToString(), icon = icon, a_attr = new JQueryTreeLink { href = page.PageUrl.ToString() } });
}

stringBuilder.Append("]");

context.Response.Write(stringBuilder.ToString());
context.Response.Write(Serialization.JsonSerialization.SerializeJson(items, new JSONParameters { UseExtensions = false, SerializeNullValues = false }));
}

private void MoveNode(HttpContext context) {
var pageId = new Guid(context.Request.Form["id"]);
var targetId = new Guid(context.Request.Form["ref"]);
Expand All @@ -81,9 +93,10 @@ private void MoveNode(HttpContext context) {
}

private static void WriteResponse(HttpContext context, bool status, string message) {
var statusString = status ? "true" : "false";
var success = status ? "true" : "false";
context.Response.ContentType = "application/json";
context.Response.Write(string.Format("{{ \"success\": {0}, \"message\": \"{1}\" }}", statusString, message));
var json = Serialization.JsonSerialization.SerializeJson(new {success, message});
context.Response.Write(json);
}

private void RemoveNode(HttpContext context) {
Expand All @@ -95,15 +108,13 @@ private void RemoveNode(HttpContext context) {
#region IHttpHandler Members

public bool IsReusable {
get {
return false;
}
get { return false; }
}

public void ProcessRequest(HttpContext context) {
string operation = context.Request.Form["operation"];

if(operation== "get_children") {
if (operation == "get_children") {
GetChildren(context);
}
else if (operation == "move_node") {
Expand All @@ -115,5 +126,6 @@ public void ProcessRequest(HttpContext context) {
}

#endregion

}
}
4 changes: 4 additions & 0 deletions KalikoCMS.Admin/KalikoCMS.Admin.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="fastjson, Version=2.1.0.0, Culture=neutral, PublicKeyToken=6b75a806b86095cd, processorArchitecture=MSIL">
<HintPath>..\packages\fastJSON.2.1.14.0\lib\net40\fastjson.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Kaliko.ImageLibrary, Version=2.0.4.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\ImageLibrary.2.0.5\lib\net40\Kaliko.ImageLibrary.dll</HintPath>
Expand Down
1 change: 1 addition & 0 deletions KalikoCMS.Admin/packages.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="fastJSON" version="2.1.14.0" targetFramework="net40" />
<package id="ImageLibrary" version="2.0.5" targetFramework="net40" />
<package id="Kaliko.Logger" version="1.1.1" targetFramework="net40" />
<package id="Telerik.DataAccess.Core" version="2015.3.926.1" targetFramework="net40" />
Expand Down
2 changes: 1 addition & 1 deletion KalikoCMS.Engine/Data/DataContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace KalikoCMS.Data {

public class DataContext : OpenAccessContext {
private const string ConnectionStringName = "KalikoCMS";
private const int DatabaseVersion = 5;
private const int DatabaseVersion = 7;
private static readonly MetadataContainer MetadataContainer;
private static readonly BackendConfiguration BackendConfiguration;

Expand Down
2 changes: 1 addition & 1 deletion KalikoCMS.Engine/Data/PropertyData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ from m in merge.DefaultIfEmpty()
orderby p.SortOrder
select new PropertyItem {
PagePropertyId = m.PagePropertyId,
PropertyName = p.Name.ToLower(),
PropertyName = p.Name.ToLowerInvariant(),
PropertyData = CreatePropertyData(p.PropertyTypeId, m.PageData),
PropertyId = p.PropertyId,
PropertyTypeId = p.PropertyTypeId
Expand Down
2 changes: 1 addition & 1 deletion KalikoCMS.Engine/PageFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public static bool FindPage(string pageUrl, IRequestManager requestManager) {
if (TryAsPageExtender(i + 1, segments, lastPage)) {
return true;
}
if (requestManager.TryMvcSupport(i, segments, lastPage)) {
if (requestManager.TryMvcSupport(i + 1, segments, lastPage)) {
return true;
}
if (TryAsRedirect(pageUrl)) {
Expand Down
Loading

0 comments on commit a006252

Please sign in to comment.