Skip to content

Commit

Permalink
Merge pull request #760 from Orckestra/dev
Browse files Browse the repository at this point in the history
C1 CMS v6.10
  • Loading branch information
napernik authored Oct 5, 2020
2 parents 63b179b + 8ca9f26 commit b918360
Show file tree
Hide file tree
Showing 43 changed files with 873 additions and 621 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ private void saveTypeCodeActivity_Save_ExecuteCode(object sender, EventArgs e)
helper.SetLocalizedControlled(hasLocalization);
}

helper.SetCachable(hasCaching);
helper.SetCacheable(hasCaching);
helper.SetNewTypeFullName(typeName, typeNamespace);
helper.SetNewTypeTitle(typeTitle);
helper.SetNewFieldDescriptors(dataFieldDescriptors, null, labelFieldName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ private void codeActivity1_ExecuteCode(object sender, EventArgs e)

if (helper.IsEditProcessControlledAllowed)
{
helper.SetCachable(hasCaching);
helper.SetCacheable(hasCaching);
helper.SetPublishControlled(hasPublishing);
helper.SetLocalizedControlled(hasLocalization);
helper.SetSearchable(isSearchable);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ private void initializeStateCodeActivity_Initialize_ExecuteCode(object sender, E
{"TypeNamespace", dataTypeDescriptor.Namespace},
{"TypeTitle", dataTypeDescriptor.Title},
{"LabelFieldName", dataTypeDescriptor.LabelFieldName},
{"HasCaching", helper.IsCachable},
{"HasCaching", helper.IsCacheable},
{"HasPublishing", helper.IsPublishControlled},
{"DataFieldDescriptors", fieldDescriptors},
{"OldTypeName", dataTypeDescriptor.Name},
Expand Down Expand Up @@ -135,7 +135,7 @@ private void saveTypeCodeActivity_Save_ExecuteCode(object sender, EventArgs e)
helper.SetNewTypeTitle(typeTitle);
// TODO: fix
helper.SetNewFieldDescriptors(dataFieldDescriptors, null, labelFieldName);
helper.SetCachable(hasCaching);
helper.SetCacheable(hasCaching);

if (helper.IsEditProcessControlledAllowed)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ private void initialStateCodeActivity_ExecuteCode(object sender, EventArgs e)
{BindingNames.KeyFieldName, dataTypeDescriptor.KeyPropertyNames.Single() },
{BindingNames.LabelFieldName, dataTypeDescriptor.LabelFieldName},
{BindingNames.InternalUrlPrefix, dataTypeDescriptor.InternalUrlPrefix},
{BindingNames.HasCaching, helper.IsCachable},
{BindingNames.HasCaching, helper.IsCacheable},
{BindingNames.HasPublishing, helper.IsPublishControlled},
{BindingNames.IsSearchable, helper.IsSearchable},
{BindingNames.DataFieldDescriptors, fieldDescriptors},
Expand Down Expand Up @@ -164,7 +164,7 @@ private void finalizeStateCodeActivity_ExecuteCode(object sender, EventArgs e)

if (helper.IsEditProcessControlledAllowed)
{
helper.SetCachable(hasCaching);
helper.SetCacheable(hasCaching);
helper.SetSearchable(isSearchable);
helper.SetPublishControlled(hasPublishing);
helper.SetLocalizedControlled(hasLocalization);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ private void finalizeCodeActivity_Finalize_ExecuteCode(object sender, EventArgs
DataFacade.AddNew(reference);
}

function.SetFunctinoCode(code);
function.SetFunctionCode(code);

function = DataFacade.AddNew(function);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ private void saveCodeActivity_Save_ExecuteCode(object sender, EventArgs e)
ManagedParameterManager.Save(function.Id, parameters);

DataFacade.Update(function);
InlineFunctionHelper.SetFunctinoCode(function, code);
function.SetFunctionCode(code);

transactionScope.Complete();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,8 @@ private Guid GetParentId()
return Guid.Empty;
}

if (this.EntityToken is DataEntityToken)
if (this.EntityToken is DataEntityToken dataEntityToken)
{
DataEntityToken dataEntityToken = (DataEntityToken)this.EntityToken;
IPage selectedPage = (IPage)dataEntityToken.Data;

return selectedPage.Id;
Expand Down Expand Up @@ -244,9 +243,8 @@ private void stepInitialize_codeActivity_ExecuteCode(object sender, EventArgs e)
{
templateId = PageTemplateFacade.GetPageTemplates().Select(t => t.Id).FirstOrDefault();
}
else if (this.EntityToken is DataEntityToken)
else if (this.EntityToken is DataEntityToken dataEntityToken)
{
DataEntityToken dataEntityToken = (DataEntityToken)this.EntityToken;
IPage selectedPage = (IPage)dataEntityToken.Data;

templateId = selectedPage.TemplateId;
Expand Down Expand Up @@ -420,7 +418,10 @@ private void PrepareStep2_ExecuteCode(object sender, EventArgs e)

if (this.GetBinding<string>("SelectedSortOrder") == SortOrder.Relative)
{
Dictionary<Guid, string> existingPages = PageServices.GetChildren(GetParentId()).ToDictionary(page => page.Id, page => page.Title);
Dictionary<Guid, string> existingPages = PageServices.GetChildren(GetParentId())
.GroupBy(page => page.Id)
.Select(group => group.First())
.ToDictionary(page => page.Id, page => page.Title);

this.Bindings["ExistingPages"] = existingPages;
this.Bindings["RelativeSelectedPageId"] = existingPages.First().Key;
Expand Down Expand Up @@ -476,7 +477,7 @@ private void stepFinalize_codeActivity_ExecuteCode(object sender, EventArgs e)
}
else
{
throw new InvalidOperationException($"Not handled page instert position '{sortOrder}'");
throw new InvalidOperationException($"Not handled page insert position '{sortOrder}'");
}

newPage = newPage.Add(parentId, position);
Expand Down
13 changes: 6 additions & 7 deletions Composite/AspNet/CmsPageHttpHandler.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Web;
using System.Xml.Linq;
using Composite.AspNet.Caching;
using Composite.Core;
using Composite.Core.Configuration;
using Composite.Core.Instrumentation;
using Composite.Core.PageTemplates;
Expand Down Expand Up @@ -133,15 +134,13 @@ public void ProcessRequest(HttpContext context)

var response = context.Response;

if (preventResponseCaching)
{
context.Response.Cache.SetNoServerCaching();
}

// Disabling ASP.NET cache if there's a logged-in user
if (consoleUserLoggedIn)
if (consoleUserLoggedIn || preventResponseCaching)
{
context.Response.Cache.SetCacheability(HttpCacheability.NoCache);
using (preventResponseCaching ? Profiler.Measure("CmsPageHttpHandler: Disabling HTTP caching as at least one of the functions is not cacheable") : EmptyDisposable.Instance)
{
context.Response.Cache.SetCacheability(HttpCacheability.NoCache);
}
}

// Inserting performance profiling information
Expand Down
2 changes: 1 addition & 1 deletion Composite/AspNet/CmsPageSiteMapNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class CmsPageSiteMapNode : SiteMapNode, ICmsSiteMapNode, ISchemaOrgSiteMa
private int? _depth;

/// <inheritdoc />
public CultureInfo Culture { get; }
public CultureInfo Culture { get; protected set; }

/// <inheritdoc />
public int? Priority { get; protected set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Web;
using Composite.C1Console.Actions;
using Composite.C1Console.Elements.Foundation.PluginFacades;
using Composite.C1Console.Elements.Plugins.ElementActionProvider;
using Composite.C1Console.Events;
using Composite.C1Console.Security;
using Composite.Core;
Expand Down Expand Up @@ -326,6 +327,22 @@ public static void AddActions(IEnumerable<Element> elements, string providerName
Log.LogCritical("ElementActionProviderFacade", ex);
}
}

foreach (var elementActionProvider in ServiceLocator.GetServices<IElementActionProvider>())
{
try
{
var actions = elementActionProvider.GetActions(element.ElementHandle.EntityToken);

element.AddAction(actions);
}
catch (Exception ex)
{
Log.LogCritical(nameof(ElementActionProviderFacade),
$"Failed to add actions from the element action provider '{elementActionProvider.GetType()}'");
Log.LogCritical(nameof(ElementActionProviderFacade), ex);
}
}
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion Composite/C1Console/Security/UserGroupFacade.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using Composite.Core.Linq;
using Composite.Data;
using Composite.Data.Types;

Expand Down Expand Up @@ -36,7 +37,8 @@ public static IReadOnlyCollection<Guid> GetUserGroupIds(string username)
return _cache.GetOrAdd(username, name =>
{
IUser user = DataFacade.GetData<IUser>()
.SingleOrDefault(f => string.Compare(f.Username, name, StringComparison.InvariantCultureIgnoreCase) == 0);
.Where(f => string.Compare(f.Username, name, StringComparison.InvariantCultureIgnoreCase) == 0)
.SingleOrDefaultOrException("Multiple data records for the same user name '{0}'", name);

Verify.IsNotNull(user, "Failed to find user by name '{0}'", name);

Expand Down
5 changes: 5 additions & 0 deletions Composite/Composite.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@
<Compile Include="AspNet\CmsPageHttpHandler.cs" />
<Compile Include="Core\Serialization\CompositeJsonSerializer.cs" />
<Compile Include="Core\Serialization\CompositeSerializationBinder.cs" />
<Compile Include="Core\Types\CSharpCodeProviderFactory.cs" />
<Compile Include="Core\WebClient\PageStructureRpc.cs" />
<Compile Include="Core\WebClient\Renderings\Page\PagePreviewContext.cs" />
<Compile Include="Core\WebClient\Renderings\Page\IPageContentFilter.cs" />
Expand All @@ -271,6 +272,10 @@
<Compile Include="Plugins\Forms\WebChannel\UiControlFactories\TemplatedTreelSelectorUiControlFactory.cs">
<SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="Plugins\Functions\FunctionProviders\CodeBasedFunctionProvider\CodeBasedFunctionEntityToken.cs" />
<Compile Include="Plugins\Functions\FunctionProviders\CodeBasedFunctionProvider\CodeBasedFunctionProvider.cs" />
<Compile Include="Plugins\Functions\FunctionProviders\CodeBasedFunctionProvider\CodeBasedFunctionRegistry.cs" />
<Compile Include="Plugins\Functions\FunctionProviders\CodeBasedFunctionProvider\CodeBasedFunction.cs" />
<Compile Include="Plugins\Functions\WidgetFunctionProviders\StandardWidgetFunctionProvider\DataReference\HomePageSelectorWidgetFunction.cs" />
<Compile Include="Plugins\Functions\WidgetFunctionProviders\StandardWidgetFunctionProvider\DataReference\PageReferenceSelectorWidgetFunctionBase.cs" />
<Compile Include="Plugins\Functions\WidgetFunctionProviders\StandardWidgetFunctionProvider\String\TreeSelectorWidgetFunction.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public override System.Configuration.ConfigurationSection GetSection(string sect
{
configurationSection = configuration.GetSection(sectionName) as System.Configuration.ConfigurationSection;
}
catch (System.Configuration.ConfigurationException ex)
catch
{
// retry once
UpdateCache();
Expand Down
10 changes: 9 additions & 1 deletion Composite/Core/Routing/Pages/C1PageRouteHander.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@

namespace Composite.Core.Routing.Pages
{
internal class C1PageRouteHandler : IRouteHandler
/// <summary>
/// A route handler for the "C1 page" route.
/// </summary>
public class C1PageRouteHandler : IRouteHandler
{
private const string PageHandlerPath = "Renderers/Page.aspx";
private const string PageHandlerVirtualPath = "~/" + PageHandlerPath;
Expand Down Expand Up @@ -65,12 +68,17 @@ static C1PageRouteHandler()

}

/// <summary>
/// Creates a new instance of <see cref="C1PageRouteHandler"/>.
/// </summary>
/// <param name="pageUrlData"></param>
public C1PageRouteHandler(PageUrlData pageUrlData)
{
_pageUrlData = pageUrlData;
}


/// <inheritdoc/>
public IHttpHandler GetHttpHandler(RequestContext requestContext)
{
var context = requestContext.HttpContext;
Expand Down
12 changes: 10 additions & 2 deletions Composite/Core/Routing/Pages/SeoFriendlyRedirectRouteHandler.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
using System.Web;
using System.Web;
using System.Web.Routing;

namespace Composite.Core.Routing.Pages
{
internal class SeoFriendlyRedirectRouteHandler: IRouteHandler
/// <summary>
/// A route handler that performs an HTTP redirect with response code 301 (Permanently moved).
/// </summary>
public class SeoFriendlyRedirectRouteHandler: IRouteHandler
{
private readonly string _redirectUrl;

/// <summary>
/// Creates a new instance of <see cref="SeoFriendlyRedirectRouteHandler"/>
/// </summary>
/// <param name="redirectUrl">The URL to redirect to.</param>
public SeoFriendlyRedirectRouteHandler(string redirectUrl)
{
_redirectUrl = redirectUrl;
}

/// <inheritdoc />
public IHttpHandler GetHttpHandler(RequestContext requestContext)
{
return new SeoFriendlyRedirectHttpHandler(_redirectUrl);
Expand Down
Loading

0 comments on commit b918360

Please sign in to comment.