Compare commits

...

15 Commits

Author SHA1 Message Date
Benedek Farkas
28f0bd52ed #8830: Fixing that fields attached to a Menu Item are not updated (#8844)
Some checks failed
Compile / Compile .NET solution (push) Has been cancelled
Compile / Compile Client-side Assets (push) Has been cancelled
SpecFlow Tests / Define Strategy Matrix (push) Has been cancelled
SpecFlow Tests / SpecFlow Tests (push) Has been cancelled
* Navigation: Fixing that saving a menu item should not force creating a draft version

* Navigation: Adding support to the AdminController for the Delete button rendered by the Contents feature

* Navigation: Fixing that fields attached to a Menu Item should also be updated when creating the item

* MainMenuService: Fixing that unpublished menu items could not be deleted

* Adding notification when deleting a menu items
2025-10-05 16:26:36 +02:00
Benedek Farkas
971a97874c Preventing Indexing AdminController and Commands from operating with unsafe index names (#8845)
Some checks failed
Compile / Compile .NET solution (push) Has been cancelled
Compile / Compile Client-side Assets (push) Has been cancelled
SpecFlow Tests / Define Strategy Matrix (push) Has been cancelled
SpecFlow Tests / SpecFlow Tests (push) Has been cancelled
2025-10-02 19:18:19 +02:00
Benedek Farkas
8851f622a3 Adding release package workflow (#8846)
Some checks failed
Compile / Compile .NET solution (push) Has been cancelled
Compile / Compile Client-side Assets (push) Has been cancelled
SpecFlow Tests / Define Strategy Matrix (push) Has been cancelled
SpecFlow Tests / SpecFlow Tests (push) Has been cancelled
(cherry picked from commit 4268b28d95)
2025-09-29 21:10:53 +02:00
Benedek Farkas
0063c18f7f Testing windows-2025 runners on 1.10.x (#8843)
* Testing compile workflow on windows-2025 runners

* Wording [skip ci]

* Compile workflow: Switch shell to cmd where pwsh is not needed
2025-09-19 09:57:27 +02:00
Benedek Farkas
0de919d36f Fix gulp pipeline installation and error detection (#8841)
Some checks failed
Compile / Compile .NET solution (push) Has been cancelled
Compile / Compile Client-side Assets (push) Has been cancelled
* Fine-tuning the compile-node job in the compile workflow

* Temporarily disabling the compile job

* Splitting up steps in the compile-node job of the compile workflow

* Revert "Temporarily disabling the compile job"

This reverts commit c130566943.
2025-09-18 23:48:02 +02:00
Andrea Piovanelli
b14c29503b #8565: Delete and Unpublish buttons in backoffice content edit (#8566)
Some checks failed
Compile / Compile .NET solution (push) Has been cancelled
Compile / Compile Client-side Assets (push) Has been cancelled
* Added publish and delete buttons to backoffice content edit.

* Corrected condition for content unpublishing.
Managed unpublish and delete button for blogs and widgets.

* Some little code refactoring

* Added css classes for unpublish-button.
Condition for delete button visibility now checks for contentItem.Id > 0 instead of IsNew() function

* Removed UnpublishButton from Widget Editor.

* Removed Widget_DeleteButton to use the generic Content_DeleteButton shape and avoid its duplication or confusing management via Placement.info.

* Removed Widget_UnpublishButton shape

* Removed unpublish button show/hide logic from driver.
Added comments to clarify how new Unpublish and Delete actions work.

* EOL fix to Orchard.Widgets.csproj.

* Added unpublish button to edit widget (shown if widget is draftable only)

* Hide Content edit delete button at frontend

* ContentsDriver: removed AdminFilter check to display delete button and checked the content is published before showing the unpublish button.

* Applied some of the proposed formatting changes

* Several refactoring operations

* Autoformatting.

* Stylesheet refactoring and reorganization to properly position backoffice buttons

* Autoformatting

---------

Co-authored-by: Alessandro Agostini <alessandro.agostini@laser-group.com>
Co-authored-by: Matteo Piovanelli <matteo.piovanelli@laser-group.com>
2025-06-13 16:17:11 +02:00
Marek Dzikiewicz
d310fb56e1 #8832: Add LazyLoadConvention (#8833)
Some checks failed
Compile / Compile .NET solution (push) Has been cancelled
Compile / Compile Client-side Assets (push) Has been cancelled
2025-04-17 10:03:42 -07:00
Marek Dzikiewicz
4c463287ca #8828: Expose Redis API to clear multiple keys using wildcard syntax (#8829)
* #8828: Expose Redis API to clear multiple keys using wildcard syntax

* #8828: Rename IRedisCacheStorageProvider to ICacheStorageProviderWithKeyPrefix

* Moving ICacheStorageProviderWithKeyPrefix to Orchard.Caching

---------

Co-authored-by: Benedek Farkas <benedek.farkas@lombiq.com>
2025-04-16 14:28:43 +02:00
Andrea Piovanelli
3561be6e37 Moved embed video import to a dedicated service. (#8827)
Some checks failed
Compile / Compile .NET solution (push) Has been cancelled
Compile / Compile Client-side Assets (push) Has been cancelled
2025-02-04 12:55:39 +01:00
Benedek Farkas
5c3d045aa1 #8800: Reverting breaking changes to Enumeration Fields caused by #8789 (#8824)
Some checks failed
Compile / Compile .NET solution (push) Has been cancelled
Compile / Compile Client-side Assets (push) Has been cancelled
* Revert "#8640: Fixing consistency between different Enumeration Field flavors' data storage (#8789)"

This reverts commit fdbb06ba8d.

* Re-adding change to fix that changing the ListMode of an EnumerationField from a multi-select to a single-select flavor shouldn't break the editor

* Code styling in Fields/Enumeration.Edit.cshtml
2025-01-23 11:59:24 +01:00
Benedek Farkas
32c5f1e821 #8822: Upgrading MailKit to 4.9.0 and consolidating all NuGet packages (#8823)
Some checks failed
Compile / Compile .NET solution (push) Has been cancelled
Compile / Compile Client-side Assets (push) Has been cancelled
* Upgrading MailKit to 4.8.0 and consolidating all NuGet packages

* Upgrading MailKit to 4.9.0 and consolidating dependency package versions
2025-01-17 19:22:19 +01:00
Benedek Farkas
d26e8e47f1 #8232: Adding warnings when a Projection Query has an empty Filter Group (#8813)
Some checks failed
Compile / Compile .NET solution (push) Has been cancelled
Compile / Compile Client-side Assets (push) Has been cancelled
* Projections: Returning empty list of content items instead of every content item when the query has no filters

* Better solution to skip processing empty filter groups, instead of returning nothing when there's an empty filter group

* Code styling and comments

* Code styling in ProjectionPartDriver, QueryPartDriver and ProjectionManager

* Reverting functional change to ignore empty filter groups

* Code styling in AdminController, ProjectionPartDriver and QueryPartDriver

* Adding notification when saving a Query or a ProjectionPart to warn about the effect of an empty filter group

* Fixing that upgrading Newtonsoft.Json 13.x broke the SpecFlow test execution app
2025-01-14 17:22:02 +01:00
Benedek Farkas
1c40b8ba93 #8808: Fixing Container admin navigation (#8809)
* Fixing that Core.Containers "Show on admin menu" functionality shouldn't depend on the Orchard.Lists feature

* Moving menu.list.png admin menu icon from Orchard.Lists to Core.Containers as menu.container.png

to fix that Containers should have a default admin menu icon

* Fixing conflict between lists and container admin navicon by applying the unused menu.list-definition.png to lists

* Code styling and removing duplicate code
2024-12-10 09:30:58 +01:00
Benedek Farkas
c3b98ba3c4 #8819: Compile workflow should run at least one of the SpecFlow tests (#8820)
* Using Title Casing in the Compile workflow's step names

* Adding step to run the Setup with SpecFlow

* Fixing typo

* Fixing that upgrading Newtonsoft.Json to 13.x broke the SpecFlow test execution app
2024-12-07 20:48:21 +01:00
Benedek Farkas
ebae790f15 #8276: Updating Npgsql to 4.0.17 and fixing setup with PostgreSQL (#8810)
* Updating Npgsql to version 4.0.17 (the latest minor version of the closest major version that isn't vulnerable)

https://github.com/OrchardCMS/Orchard/security/dependabot/54

* Fixing that Projection Migrations created indexes with the same name in different tables, which is not supported by PostgreSQL
2024-12-06 14:14:57 +01:00
74 changed files with 2286 additions and 1314 deletions

View File

@@ -0,0 +1,27 @@
name: Build Crowdin Translation Packages
on:
workflow_dispatch:
schedule:
- cron: '0 6 * * *'
jobs:
build-crowdin-translation-packages:
runs-on: ubuntu-24.04
steps:
- name: Orchard CMS
uses: andrii-bodnar/crowdin-request-action@ee7a2af9564d8934b5b4a8427185aaaffee0165e # v0.3.0
with:
route: POST /projects/{projectId}/translations/builds
projectId: 46524
env:
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_API_TOKEN }}
- name: Orchard CMS Gallery
uses: andrii-bodnar/crowdin-request-action@ee7a2af9564d8934b5b4a8427185aaaffee0165e # v0.3.0
with:
route: POST /projects/{projectId}/translations/builds
projectId: 63766
env:
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_API_TOKEN }}

View File

@@ -13,17 +13,17 @@ jobs:
name: Compile .NET solution
defaults:
run:
shell: pwsh
runs-on: windows-latest
shell: cmd
runs-on: windows-2025
steps:
- name: Clone repository
uses: actions/checkout@v4.1.1
- name: Clone Repository
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- name: Restore NuGet packages
- name: Restore NuGet Packages
run: nuget restore src/Orchard.sln
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v2
- name: Add MSBuild to PATH
uses: microsoft/setup-msbuild@6fb02220983dee41ce7ae257b6f4d8f9bf5ed4ce # v2.0.0
- name: Compile
run: msbuild Orchard.proj /m /v:minimal /t:Compile /p:TreatWarningsAsErrors=true -WarnAsError /p:MvcBuildViews=true
@@ -31,14 +31,22 @@ jobs:
- name: Test
run: msbuild Orchard.proj /m /v:minimal /t:Test
- name: Run Orchard setup
- name: Test Setup with SpecFlow
shell: pwsh
run: |
$nunitConsole = (Get-ChildItem -Path 'src/packages' -Recurse -Filter 'nunit-console.exe' | Select-Object -Last 1).FullName
& $nunitConsole 'build/Compile/Orchard.Specs.dll' /xml='build/Orchard.Specs.xml' /run=Orchard.Specs.SetupFeature.RootAndSetupFolderShowsSetupScreenAndFormValuesAreValidated
- name: Run Orchard Setup with Orchard.exe
shell: pwsh
run: |
$commandFile = 'src/Orchard.Web/bin/setup-commands.txt'
New-Item -Path $commandFile -ItemType File -Force
Set-Content -Path $commandFile -Value 'setup /SiteName:Orchard /AdminUsername:admin /AdminPassword:Password1! /DatabaseProvider:SqlCe /Recipe:Default'
& 'src/Orchard.Web/bin/Orchard.exe' @$commandFile
- name: Run code generation
- name: Run Code Generation
shell: pwsh
run: |
$commandFile = 'src/Orchard.Web/bin/codegen-commands.txt'
New-Item -Path $commandFile -ItemType File -Force
@@ -50,38 +58,44 @@ jobs:
'@
& 'src/Orchard.Web/bin/Orchard.exe' @$commandFile
- name: Compile with generated projects
- name: Compile Again with Generated Projects
run: msbuild Orchard.proj /m /v:minimal /t:Compile /p:TreatWarningsAsErrors=true -WarnAsError /NoWarn:CS2008
compile-node:
name: Compile client-side assets
name: Compile Client-side Assets
defaults:
run:
shell: pwsh
runs-on: windows-latest
shell: cmd
runs-on: windows-2025
steps:
- name: Clone repository
uses: actions/checkout@v4.1.1
- name: Clone Repository
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- name: Setup NodeJS
uses: actions/setup-node@v4.0.2
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
with:
node-version: '7'
node-version: 7
- name: Setup NPM packages
- name: Install Gulp Globally
working-directory: ./src
shell: pwsh
run: |
npm install --loglevel warn
# Install gulp globally to be able to run the rebuild task, using the same version as in the project.
$gulpVersion = (Get-Content Package.json -Raw | ConvertFrom-Json).devDependencies.gulp
Start-Process npm -NoNewWindow -Wait -ArgumentList "install gulp@$gulpVersion -g --loglevel warn"
- name: Rebuild client-side assets
- name: Install NPM Packages
working-directory: ./src
run: |
gulp rebuild
run: npm install --loglevel warn
- name: Rebuild Client-side Assets
working-directory: ./src
run: gulp rebuild
- name: Check Client-side Assets
working-directory: ./src
shell: pwsh
run: |
git add . # To make line ending changes "disappear".
$gitStatus = (git status --porcelain)
if ($gitStatus)

39
.github/workflows/release-package.yml vendored Normal file
View File

@@ -0,0 +1,39 @@
name: Release Package
# Builds the release package and uploads it as an artifact.
on:
workflow_dispatch:
jobs:
release-package:
name: Release Package
runs-on: Windows-2025
defaults:
run:
shell: cmd
steps:
- name: Clone Repository
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- name: Restore NuGet Packages
run: nuget restore src/Orchard.sln
- name: Add MSBuild to PATH
uses: microsoft/setup-msbuild@6fb02220983dee41ce7ae257b6f4d8f9bf5ed4ce # v2.0.0
- name: Build Precompiled Application
run: msbuild Orchard.proj /m /v:minimal /t:Precompiled
- name: Generate Release Package Name
id: package-name
shell: pwsh
run: |
$packageName = "Orchard-$('${{ github.ref_name }}'.Replace('/', '_'))-${{ github.sha }}"
"package-name=$packageName" >> $Env:GITHUB_OUTPUT
- name: Upload Release Package
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: ${{ steps.package-name.outputs.package-name }}
path: .\build\Precompiled
if-no-files-found: error

59
.github/workflows/specflow.yml vendored Normal file
View File

@@ -0,0 +1,59 @@
name: SpecFlow Tests
# Compiles the solution and runs unit tests, as well the SpecFlow tests on the main development branches.
on:
workflow_dispatch:
push:
branches:
- 1.10.x
- dev
schedule:
- cron: '0 0 * * 1' # Every Monday midnight.
jobs:
define-matrix:
name: Define Strategy Matrix
runs-on: ubuntu-24.04
outputs:
branches: ${{ steps.branches.outputs.branches }}
steps:
- name: Define Branches
id: branches
run: |
if [ "${{ github.event_name }}" = "schedule" ]; then
echo 'branches=["1.10.x", "dev"]' >> "$GITHUB_OUTPUT"
else
echo 'branches=["${{ github.ref_name }}"]' >> "$GITHUB_OUTPUT"
fi
compile:
name: SpecFlow Tests
needs: define-matrix
runs-on: windows-2025
strategy:
matrix:
branch: ${{ fromJSON(needs.define-matrix.outputs.branches) }}
fail-fast: false
defaults:
run:
shell: cmd
steps:
- name: Clone Repository
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
ref: ${{ matrix.branch }}
- name: Restore NuGet Packages
run: nuget restore src/Orchard.sln
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@6fb02220983dee41ce7ae257b6f4d8f9bf5ed4ce # v2.0.0
- name: Compile
run: msbuild Orchard.proj /m /v:minimal /t:Compile /p:MvcBuildViews=true /p:TreatWarningsAsErrors=true -WarnAsError
- name: Test
run: msbuild Orchard.proj /m /v:minimal /t:Test
- name: Spec
run: msbuild Orchard.proj /m /v:minimal /t:Spec

View File

@@ -26,6 +26,22 @@
<assemblyIdentity name="System.Net.Http.Formatting" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.2.7.0" newVersion="5.2.7.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.4.0" newVersion="4.0.4.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Numerics.Vectors" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.5.0" newVersion="4.1.5.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

View File

@@ -38,6 +38,26 @@
<assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.2.2.0" newVersion="4.2.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.4.0" newVersion="4.0.4.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Threading.Tasks.Extensions" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.2.1.0" newVersion="4.2.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.1.0" newVersion="6.0.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Numerics.Vectors" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.5.0" newVersion="4.1.5.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<specFlow>

View File

@@ -151,7 +151,7 @@
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0" />
<bindingRedirect oldVersion="0.0.0.0-13.0.0.0" newVersion="13.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="NHibernate" publicKeyToken="aa95f207798dfdb4" culture="neutral" />

View File

@@ -42,6 +42,22 @@
<assemblyIdentity name="System.Net.Http.Formatting" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.2.7.0" newVersion="5.2.7.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.4.0" newVersion="4.0.4.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Numerics.Vectors" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.5.0" newVersion="4.1.5.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

View File

@@ -30,6 +30,26 @@
<assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.2.2.0" newVersion="4.2.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.4.0" newVersion="4.0.4.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Threading.Tasks.Extensions" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.2.1.0" newVersion="4.2.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.1.0" newVersion="6.0.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Numerics.Vectors" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.5.0" newVersion="4.1.5.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

View File

@@ -0,0 +1,93 @@
using System.Linq;
using Orchard.ContentManagement;
using Orchard.Core.Containers.Models;
using Orchard.Core.Containers.Services;
using Orchard.Localization;
using Orchard.Security;
using Orchard.UI.Navigation;
using Orchard.Utility.Extensions;
namespace Orchard.Core.Containers {
public class AdminMenu : INavigationProvider {
private readonly IContainerService _containerService;
private readonly IContentManager _contentManager;
private readonly IAuthorizationService _authorizationService;
private readonly IWorkContextAccessor _workContextAccessor;
public AdminMenu(
IContainerService containerService,
IContentManager contentManager,
IAuthorizationService authorizationService,
IWorkContextAccessor workContextAccessor) {
_containerService = containerService;
_contentManager = contentManager;
_authorizationService = authorizationService;
_workContextAccessor = workContextAccessor;
}
public Localizer T { get; set; }
public string MenuName { get { return "admin"; } }
public void GetNavigation(NavigationBuilder builder) {
builder.AddImageSet("container");
var containers = _containerService
.GetContainersQuery(VersionOptions.Latest)
.Where<ContainerPartRecord>(x => x.ShowOnAdminMenu)
.List()
.Where(content => _authorizationService.TryCheckAccess(
Contents.Permissions.EditContent,
_workContextAccessor.GetContext().CurrentUser,
content))
.ToList();
foreach (var container in containers) {
var closureContainer = container;
if (!string.IsNullOrWhiteSpace(container.AdminMenuImageSet)) {
builder.AddImageSet(container.AdminMenuImageSet.Trim());
}
builder.Add(T(container.AdminMenuText), container.AdminMenuPosition, item => {
var containedItems = _containerService.GetContentItems(closureContainer.Id, VersionOptions.Latest).ToList();
var actualContainer = closureContainer;
var position = 0;
// If the list has just a single item that happens to be a container itself,
// we will treat that one as the actual container to provide a nice & quick way to manage that list.
if (containedItems.Count == 1) {
var containedItem = containedItems.First().As<ContainerPart>();
if (containedItem != null) {
actualContainer = containedItem;
foreach (var itemContentType in containedItem.ItemContentTypes) {
var closureItemContentType = itemContentType;
item.Add(T("New {0}", itemContentType.DisplayName), string.Format("1.{0}", position++), subItem => subItem
.Action("Create", "Admin", new {
id = closureItemContentType.Name,
containerid = containedItem.Id,
area = "Contents"
}));
}
}
}
item.Action(_contentManager.GetItemMetadata(actualContainer).AdminRouteValues)
.AddClass("section-container")
.AddClass(closureContainer.AdminMenuText.HtmlClassify())
.LinkToFirstChild(false);
foreach (var itemContentType in closureContainer.ItemContentTypes) {
var closureItemContentType = itemContentType;
item.Add(T("New {0}", itemContentType.DisplayName), string.Format("1.{0}", position++), subItem => subItem
.Action("Create", "Admin", new {
id = closureItemContentType.Name,
containerid = container.Id,
area = "Contents"
}));
}
});
}
}
}
}

View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<staticContent>
<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="7.00:00:00" />
</staticContent>
<handlers accessPolicy="Script,Read">
<!-- For any request to a file exists on disk, return it via native http module. AccessPolicy="Script" above is to allow for a managed 404 page. -->
<add name="StaticFile" path="*" verb="*" modules="StaticFileModule" preCondition="integratedMode" resourceType="File" requireAccess="Read" />
</handlers>
</system.webServer>
</configuration>

View File

Before

Width:  |  Height:  |  Size: 998 B

After

Width:  |  Height:  |  Size: 998 B

View File

@@ -0,0 +1,7 @@
.menu-admin > .section-container > h3 > a {
background-image: url(images/menu.container.png) !important;
}
.menu-admin > .section-container > h3 > a:hover {
background-position: 0 -30px !important;
}

View File

@@ -352,6 +352,32 @@ namespace Orchard.Core.Contents.Controllers {
return EditPOST(id, returnUrl, contentItem => _contentManager.Publish(contentItem));
}
/// <summary>
/// This action is specific to the submit button of the edit form.
/// Unpublish logic is the same of the Unpublish action, which is called by the content list.
/// </summary>
/// <param name="id"></param>
/// <param name="returnUrl"></param>
/// <returns></returns>
[HttpPost, ActionName("Edit")]
[Mvc.FormValueRequired("submit.Unpublish")]
public ActionResult EditUnpublishPOST(int id, string returnUrl) {
return Unpublish(id, returnUrl);
}
/// <summary>
/// This action is specific to the submit button of the edit form.
/// Delete logic is the same of the Remove action, which is called by the content list.
/// </summary>
/// <param name="id"></param>
/// <param name="returnUrl"></param>
/// <returns></returns>
[HttpPost, ActionName("Edit")]
[Mvc.FormValueRequired("submit.Delete")]
public ActionResult EditDeletePOST(int id, string returnUrl) {
return Remove(id, returnUrl);
}
private ActionResult EditPOST(int id, string returnUrl, Action<ContentItem> conditionallyPublish) {
var contentItem = _contentManager.Get(id, VersionOptions.DraftRequired);

View File

@@ -21,8 +21,14 @@ namespace Orchard.Core.Contents.Drivers {
protected override DriverResult Editor(ContentPart part, dynamic shapeHelper) {
var results = new List<DriverResult> { ContentShape("Content_SaveButton", saveButton => saveButton) };
if (part.TypeDefinition.Settings.GetModel<ContentTypeSettings>().Draftable)
if (part.TypeDefinition.Settings.GetModel<ContentTypeSettings>().Draftable) {
results.Add(ContentShape("Content_PublishButton", publishButton => publishButton));
results.Add(ContentShape("Content_UnpublishButton", unpublishButton => unpublishButton));
}
if (part.Id > 0) {
results.Add(ContentShape("Content_DeleteButton", deleteButton => deleteButton));
}
return Combined(results.ToArray());
}

View File

@@ -6,8 +6,10 @@
Parts_Contents_Publish_SummaryAdmin
-->
<!-- edit "shape" -->
<Place Content_PublishButton="Sidebar:24"/>
<Place Content_SaveButton="Sidebar:23"/>
<Place Content_PublishButton="Sidebar:24"/>
<Place Content_UnpublishButton="Sidebar:25"/>
<Place Content_DeleteButton="Sidebar:26"/>
<Match DisplayType="Detail">
<Place Parts_Contents_Publish="Content:5"/>
</Match>

View File

@@ -0,0 +1,8 @@
@using Orchard.ContentManagement;
@using Orchard.Core.Contents;
@if (Authorizer.Authorize(Permissions.DeleteContent, (IContent)Model.ContentItem)) {
<fieldset class="delete-button">
<button type="submit" name="submit.Delete" value="submit.Delete" itemprop="RemoveUrl">@T("Delete")</button>
</fieldset>
}

View File

@@ -0,0 +1,12 @@
@using Orchard.ContentManagement;
@using Orchard.Core.Contents;
@{
var contentItem = Model.ContentItem as IContent;
}
@if (Authorizer.Authorize(Permissions.PublishContent, contentItem) && contentItem.IsPublished()) {
<fieldset class="unpublish-button">
<button type="submit" name="submit.Unpublish" value="submit.Unpublish">@T("Unpublish")</button>
</fieldset>
}

View File

@@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using System.Web.Routing;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Aspects;
using Orchard.ContentManagement.Handlers;
@@ -14,6 +13,7 @@ using Orchard.Data;
using Orchard.Exceptions;
using Orchard.Localization;
using Orchard.Logging;
using Orchard.Mvc;
using Orchard.Mvc.Extensions;
using Orchard.Mvc.Html;
using Orchard.Security;
@@ -131,11 +131,15 @@ namespace Orchard.Core.Navigation.Controllers {
return RedirectToAction("Index", new { menuId });
}
[HttpPost, ActionName("Edit")]
[FormValueRequired("submit.Delete")]
public ActionResult EditDeletePOST(int id) => Delete(id);
[HttpPost]
public ActionResult Delete(int id) {
MenuPart menuPart = _menuService.Get(id);
int? menuId = null;
if (!_authorizer.Authorize(
Permissions.ManageMenus,
menuPart == null ? null : _menuService.GetMenu(menuPart.Menu.Id),
@@ -152,7 +156,7 @@ namespace Orchard.Core.Navigation.Controllers {
.ToList();
foreach (var menuItem in menuItems.Concat(new[] { menuPart })) {
// if the menu item is a concrete content item, don't delete it, just unreference the menu
// if the menu item is a concrete content item, don't delete it, just remove the menu reference
if (!menuPart.ContentItem.TypeDefinition.Settings.ContainsKey("Stereotype")
|| menuPart.ContentItem.TypeDefinition.Settings["Stereotype"] != "MenuItem") {
menuPart.Menu = null;
@@ -162,6 +166,11 @@ namespace Orchard.Core.Navigation.Controllers {
}
}
_notifier.Information(T.Plural(
"The menu item '{1}' has been deleted.",
"The menu item '{1}' and its children have been deleted.",
menuItems.Count() + 1,
menuPart.MenuText));
}
return RedirectToAction("Index", new { menuId });
@@ -172,7 +181,8 @@ namespace Orchard.Core.Navigation.Controllers {
return new HttpUnauthorizedResult();
// create a new temporary menu item
var menuPart = _contentManager.New<MenuPart>(id);
var contentItem = _contentManager.New(id);
var menuPart = contentItem.As<MenuPart>();
if (menuPart == null)
return HttpNotFound();
@@ -187,7 +197,7 @@ namespace Orchard.Core.Navigation.Controllers {
// filter the content items for this specific menu
menuPart.MenuPosition = Position.GetNext(_navigationManager.BuildMenu(menu));
menuPart.Menu = menu;
var model = _contentManager.BuildEditor(menuPart);
var model = _contentManager.BuildEditor(contentItem);
return View(model);
}
@@ -206,23 +216,32 @@ namespace Orchard.Core.Navigation.Controllers {
public ActionResult CreateMenuItemPost(string id, int menuId, string returnUrl) {
if (!_authorizer.Authorize(Permissions.ManageMenus, _menuService.GetMenu(menuId), T("Couldn't manage the menu")))
return new HttpUnauthorizedResult();
var menuPart = _contentManager.New<MenuPart>(id);
var contentItem = _contentManager.New(id);
var menuPart = contentItem.As<MenuPart>();
if (menuPart == null)
return HttpNotFound();
// load the menu
var menu = _contentManager.Get(menuId);
if (menu == null)
return HttpNotFound();
_contentManager.Create(contentItem);
menuPart.Menu = menu;
var model = _contentManager.UpdateEditor(menuPart, this);
menuPart.MenuPosition = Position.GetNext(_navigationManager.BuildMenu(menu));
_contentManager.Create(menuPart);
var model = _contentManager.UpdateEditor(contentItem, this);
if (!ModelState.IsValid) {
_transactionManager.Cancel();
return View(model);
}
_notifier.Information(T("Your {0} has been added.", menuPart.TypeDefinition.DisplayName));
_notifier.Information(T("Your {0} has been added.", contentItem.TypeDefinition.DisplayName));
return this.RedirectLocal(returnUrl, () => RedirectToAction("Index"));
}
@@ -308,7 +327,8 @@ namespace Orchard.Core.Navigation.Controllers {
}
private ActionResult EditPOST(int id, string returnUrl, Action<ContentItem> conditionallyPublish) {
var menuPart = _contentManager.GetDraftRequired<MenuPart>(id);
var contentItem = _contentManager.GetLatest(id);
var menuPart = contentItem.As<MenuPart>();
if (menuPart == null)
return HttpNotFound();
@@ -316,8 +336,6 @@ namespace Orchard.Core.Navigation.Controllers {
if (!_authorizer.Authorize(Permissions.ManageMenus, menuPart.Menu, T("Couldn't manage the menu")))
return new HttpUnauthorizedResult();
var contentItem = menuPart.ContentItem;
string previousRoute = null;
if (contentItem.Has<IAliasAspect>()
&& !string.IsNullOrWhiteSpace(returnUrl)

View File

@@ -25,7 +25,7 @@ namespace Orchard.Core.Navigation.Services {
}
public IContent GetMenu(string menuName) {
if(string.IsNullOrWhiteSpace(menuName)) {
if (string.IsNullOrWhiteSpace(menuName)) {
return null;
}
@@ -37,19 +37,19 @@ namespace Orchard.Core.Navigation.Services {
}
public IContent GetMenu(int menuId) {
return _contentManager.Get(menuId, VersionOptions.Published);
return _contentManager.Get(menuId, VersionOptions.Published);
}
public MenuPart Get(int menuPartId) {
return _contentManager.Get<MenuPart>(menuPartId);
return _contentManager.Get<MenuPart>(menuPartId, VersionOptions.Latest);
}
public IContent Create(string name) {
if(string.IsNullOrWhiteSpace(name)) {
if (string.IsNullOrWhiteSpace(name)) {
throw new ArgumentNullException(name);
}
var menu = _contentManager.Create("Menu");
menu.As<TitlePart>().Title = name;

View File

@@ -119,6 +119,7 @@
<Compile Include="Common\ViewModels\DateTimeEditor.cs" />
<Compile Include="Common\ViewModels\TextFieldDriverViewModel.cs" />
<Compile Include="Common\ViewModels\TextFieldSettingsEventsViewModel.cs" />
<Compile Include="Containers\AdminMenu.cs" />
<Compile Include="Containers\Controllers\ItemController.cs" />
<Compile Include="Containers\Drivers\ContainablePartDriver.cs" />
<Compile Include="Containers\Drivers\ContainerPartDriver.cs" />
@@ -318,6 +319,8 @@
<Content Include="Common\Views\Parts.Common.Metadata.cshtml" />
<Content Include="Common\Views\CommonMetadataLastModified.cshtml" />
<Content Include="Containers\Module.txt" />
<Content Include="Containers\Styles\images\menu.container.png" />
<Content Include="Containers\Styles\menu.container-admin.css" />
<Content Include="Shapes\Scripts\admin-localnavigation.js" />
<Content Include="Contents\Styles\images\menu.content.png" />
<Content Include="Contents\Styles\menu.content-admin.css" />
@@ -610,9 +613,16 @@
<Content Include="Navigation\Views\Admin\Edit.cshtml" />
</ItemGroup>
<ItemGroup>
<Content Include="Contents\Views\Content.UnpublishButton.cshtml" />
<Content Include="Contents\Views\Content.DeleteButton.cshtml" />
<None Include="packages.config" />
<Content Include="Title\Views\DefinitionTemplates\TitlePartSettings.cshtml" />
</ItemGroup>
<ItemGroup>
<Content Include="Containers\Styles\Web.config">
<SubType>Designer</SubType>
</Content>
</ItemGroup>
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>

View File

@@ -62,20 +62,20 @@
<HintPath>..\..\..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
<Reference Include="System.Buffers, Version=4.0.4.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\System.Buffers.4.6.0\lib\net462\System.Buffers.dll</HintPath>
</Reference>
<Reference Include="System.Configuration" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\System.Memory.4.5.4\lib\net461\System.Memory.dll</HintPath>
<Reference Include="System.Memory, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\System.Memory.4.6.0\lib\net462\System.Memory.dll</HintPath>
</Reference>
<Reference Include="System.Numerics" />
<Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
<Reference Include="System.Numerics.Vectors, Version=4.1.5.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\System.Numerics.Vectors.4.6.0\lib\net462\System.Numerics.Vectors.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\System.Runtime.CompilerServices.Unsafe.4.5.3\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=6.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\System.Runtime.CompilerServices.Unsafe.6.1.0\lib\net462\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
<Reference Include="System.Web" />
<Reference Include="System.Web.ApplicationServices" />
@@ -231,4 +231,4 @@
</FlavorProperties>
</VisualStudio>
</ProjectExtensions>
</Project>
</Project>

View File

@@ -68,6 +68,22 @@
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-5.2.7.0" newVersion="5.2.7.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Numerics.Vectors" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.5.0" newVersion="4.1.5.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.4.0" newVersion="4.0.4.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<system.codedom>

View File

@@ -6,8 +6,8 @@
<package id="Microsoft.AspNet.WebPages" version="3.2.7" targetFramework="net48" />
<package id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="4.1.0" targetFramework="net48" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net48" />
<package id="System.Buffers" version="4.5.1" targetFramework="net48" />
<package id="System.Memory" version="4.5.4" targetFramework="net48" />
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net48" />
<package id="System.Runtime.CompilerServices.Unsafe" version="4.5.3" targetFramework="net48" />
</packages>
<package id="System.Buffers" version="4.6.0" targetFramework="net48" />
<package id="System.Memory" version="4.6.0" targetFramework="net48" />
<package id="System.Numerics.Vectors" version="4.6.0" targetFramework="net48" />
<package id="System.Runtime.CompilerServices.Unsafe" version="6.1.0" targetFramework="net48" />
</packages>

View File

@@ -1,6 +1,5 @@
using System;
using System.Linq;
using System.Reflection;
using System.Web.Mvc;
using Orchard.Blogs.Extensions;
using Orchard.Blogs.Models;
@@ -138,6 +137,12 @@ namespace Orchard.Blogs.Controllers {
});
}
[HttpPost, ActionName("Edit")]
[Mvc.FormValueRequired("submit.Delete")]
public ActionResult EditDeletePOST(int blogId, int postId, string returnUrl) {
return Delete(blogId, postId);
}
[HttpPost, ActionName("Edit")]
[FormValueRequired("submit.Publish")]
public ActionResult EditAndPublishPOST(int blogId, int postId, string returnUrl) {
@@ -156,6 +161,12 @@ namespace Orchard.Blogs.Controllers {
return EditPOST(blogId, postId, returnUrl, contentItem => Services.ContentManager.Publish(contentItem));
}
[HttpPost, ActionName("Edit")]
[Mvc.FormValueRequired("submit.Unpublish")]
public ActionResult EditUnpublishPOST(int blogId, int postId, string returnUrl) {
return Unpublish(blogId, postId);
}
public ActionResult EditPOST(int blogId, int postId, string returnUrl, Action<ContentItem> conditionallyPublish) {
var blog = _blogService.Get(blogId, VersionOptions.Latest);
if (blog == null)

View File

@@ -68,6 +68,22 @@
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-5.2.7.0" newVersion="5.2.7.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Numerics.Vectors" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.5.0" newVersion="4.1.5.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.4.0" newVersion="4.0.4.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<system.codedom>

View File

@@ -8,4 +8,8 @@ namespace Orchard.Caching.Services {
void Remove(string key);
void Clear();
}
public interface ICacheStorageProviderWithKeyPrefix : ICacheStorageProvider {
void Clear(string key);
}
}

View File

@@ -69,6 +69,22 @@
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-5.2.7.0" newVersion="5.2.7.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Numerics.Vectors" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.5.0" newVersion="4.1.5.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.4.0" newVersion="4.0.4.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<system.codedom>

View File

@@ -69,6 +69,22 @@
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-5.2.7.0" newVersion="5.2.7.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Numerics.Vectors" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.5.0" newVersion="4.1.5.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.4.0" newVersion="4.0.4.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<system.codedom>

View File

@@ -71,6 +71,22 @@
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-5.2.7.0" newVersion="5.2.7.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Numerics.Vectors" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.5.0" newVersion="4.1.5.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.4.0" newVersion="4.0.4.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<system.codedom>

View File

@@ -55,8 +55,11 @@
<Reference Include="BouncyCastle.Crypto, Version=1.9.0.0, Culture=neutral, PublicKeyToken=0e99375e54769942, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Portable.BouncyCastle.1.9.0\lib\net40\BouncyCastle.Crypto.dll</HintPath>
</Reference>
<Reference Include="MailKit, Version=3.1.0.0, Culture=neutral, PublicKeyToken=4e064fe7c44a8f1b, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\MailKit.3.1.1\lib\net48\MailKit.dll</HintPath>
<Reference Include="BouncyCastle.Cryptography, Version=2.0.0.0, Culture=neutral, PublicKeyToken=072edcf4a5328938, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\BouncyCastle.Cryptography.2.5.0\lib\net461\BouncyCastle.Cryptography.dll</HintPath>
</Reference>
<Reference Include="MailKit, Version=4.9.0.0, Culture=neutral, PublicKeyToken=4e064fe7c44a8f1b, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\MailKit.4.9.0\lib\net48\MailKit.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.4.1.0\lib\net472\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll</HintPath>
@@ -65,23 +68,42 @@
<Reference Include="Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll</HintPath>
</Reference>
<Reference Include="MimeKit, Version=3.1.0.0, Culture=neutral, PublicKeyToken=bede1c8a46c66814, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\MimeKit.3.1.1\lib\net48\MimeKit.dll</HintPath>
<Reference Include="MimeKit, Version=4.9.0.0, Culture=neutral, PublicKeyToken=bede1c8a46c66814, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\MimeKit.4.9.0\lib\net48\MimeKit.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
<Reference Include="System.Buffers, Version=4.0.4.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\System.Buffers.4.6.0\lib\net462\System.Buffers.dll</HintPath>
</Reference>
<Reference Include="System.Configuration">
<Private>False</Private>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Formats.Asn1, Version=8.0.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\System.Formats.Asn1.8.0.1\lib\net462\System.Formats.Asn1.dll</HintPath>
</Reference>
<Reference Include="System.Memory, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\System.Memory.4.6.0\lib\net462\System.Memory.dll</HintPath>
</Reference>
<Reference Include="System.Net.Http, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="System.Numerics" />
<Reference Include="System.Numerics.Vectors, Version=4.1.5.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\System.Numerics.Vectors.4.6.0\lib\net462\System.Numerics.Vectors.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=6.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\System.Runtime.CompilerServices.Unsafe.6.1.0\lib\net462\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
<Reference Include="System.Security" />
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\System.Threading.Tasks.Extensions.4.6.0\lib\net462\System.Threading.Tasks.Extensions.dll</HintPath>
</Reference>
<Reference Include="System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll</HintPath>
</Reference>
<Reference Include="System.Web.ApplicationServices" />
<Reference Include="System.Web.DynamicData" />
<Reference Include="System.Web.Entity" />

View File

@@ -69,6 +69,18 @@
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-5.2.7.0" newVersion="5.2.7.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.4.0" newVersion="4.0.4.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<system.codedom>

View File

@@ -1,13 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="MailKit" version="3.1.1" targetFramework="net48" />
<package id="BouncyCastle.Cryptography" version="2.5.0" targetFramework="net48" />
<package id="MailKit" version="4.9.0" targetFramework="net48" />
<package id="Microsoft.AspNet.Mvc" version="5.2.7" targetFramework="net48" />
<package id="Microsoft.AspNet.Razor" version="3.2.7" targetFramework="net48" />
<package id="Microsoft.AspNet.WebPages" version="3.2.7" targetFramework="net48" />
<package id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="4.1.0" targetFramework="net48" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net48" />
<package id="MimeKit" version="3.1.1" targetFramework="net48" />
<package id="MimeKit" version="4.9.0" targetFramework="net48" />
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net48" />
<package id="Portable.BouncyCastle" version="1.9.0" targetFramework="net48" />
<package id="System.Buffers" version="4.5.1" targetFramework="net48" />
<package id="System.Buffers" version="4.6.0" targetFramework="net48" />
<package id="System.Formats.Asn1" version="8.0.1" targetFramework="net48" />
<package id="System.Memory" version="4.6.0" targetFramework="net48" />
<package id="System.Numerics.Vectors" version="4.6.0" targetFramework="net48" />
<package id="System.Runtime.CompilerServices.Unsafe" version="6.1.0" targetFramework="net48" />
<package id="System.Threading.Tasks.Extensions" version="4.6.0" targetFramework="net48" />
<package id="System.ValueTuple" version="4.5.0" targetFramework="net48" />
</packages>

View File

@@ -4,41 +4,46 @@ using Orchard.ContentManagement.Handlers;
using Orchard.Fields.Fields;
using Orchard.Fields.Settings;
using Orchard.Localization;
using System;
using System.Collections.Generic;
using System.Linq;
namespace Orchard.Fields.Drivers {
public class EnumerationFieldDriver : ContentFieldDriver<EnumerationField> {
public IOrchardServices Services { get; set; }
private const string TemplateName = "Fields/Enumeration.Edit";
public EnumerationFieldDriver(IOrchardServices services) {
Services = services;
T = NullLocalizer.Instance;
}
public Localizer T { get; set; }
private static string GetPrefix(ContentField field, ContentPart part) =>
part.PartDefinition.Name + "." + field.Name;
private static string GetPrefix(ContentField field, ContentPart part) {
return part.PartDefinition.Name + "." + field.Name;
}
private static string GetDifferentiator(EnumerationField field) => field.Name;
private static string GetDifferentiator(EnumerationField field, ContentPart part) {
return field.Name;
}
protected override DriverResult Display(ContentPart part, EnumerationField field, string displayType, dynamic shapeHelper) {
return ContentShape("Fields_Enumeration", GetDifferentiator(field), () => shapeHelper.Fields_Enumeration());
return ContentShape("Fields_Enumeration", GetDifferentiator(field, part),
() => shapeHelper.Fields_Enumeration());
}
protected override DriverResult Editor(ContentPart part, EnumerationField field, dynamic shapeHelper) {
return ContentShape("Fields_Enumeration_Edit", GetDifferentiator(field), () => {
if (part.IsNew() && string.IsNullOrEmpty(field.Value)) {
var settings = field.PartFieldDefinition.Settings.GetModel<EnumerationFieldSettings>();
if (!string.IsNullOrWhiteSpace(settings.DefaultValue)) {
field.SelectedValues = new string[] { settings.DefaultValue };
return ContentShape("Fields_Enumeration_Edit", GetDifferentiator(field, part),
() => {
if (part.IsNew() && String.IsNullOrEmpty(field.Value)) {
var settings = field.PartFieldDefinition.Settings.GetModel<EnumerationFieldSettings>();
if (!String.IsNullOrWhiteSpace(settings.DefaultValue)) {
field.Value = settings.DefaultValue;
}
}
}
return shapeHelper.EditorTemplate(TemplateName: TemplateName, Model: field, Prefix: GetPrefix(field, part));
});
return shapeHelper.EditorTemplate(TemplateName: TemplateName, Model: field, Prefix: GetPrefix(field, part));
});
}
protected override DriverResult Editor(ContentPart part, EnumerationField field, IUpdateModel updater, dynamic shapeHelper) {

View File

@@ -7,16 +7,28 @@ namespace Orchard.Fields.Fields {
private const char Separator = ';';
public string Value {
get => Storage.Get<string>()?.Trim(Separator) ?? "";
set => Storage.Set(string.IsNullOrWhiteSpace(value)
? string.Empty
// It is now the responsibility of this field to (re-)add the separators.
: Separator + value.Trim(Separator) + Separator);
get { return Storage.Get<string>(); }
set { Storage.Set(value ?? String.Empty); }
}
public string[] SelectedValues {
get => Value?.Split(new[] { Separator }, StringSplitOptions.RemoveEmptyEntries) ?? new string[0];
set => Value = value?.Length > 0 ? string.Join(Separator.ToString(), value) : "";
get {
var value = Value;
if(string.IsNullOrWhiteSpace(value)) {
return new string[0];
}
return value.Split(new [] { Separator }, StringSplitOptions.RemoveEmptyEntries);
}
set {
if (value == null || value.Length == 0) {
Value = String.Empty;
}
else {
Value = Separator + string.Join(Separator.ToString(), value) + Separator;
}
}
}
}
}

View File

@@ -169,10 +169,6 @@
<Compile Include="ViewModels\NumericFieldViewModel.cs" />
<Compile Include="ViewModels\DateTimeFieldViewModel.cs" />
</ItemGroup>
<ItemGroup>
<Folder Include="Controllers\" />
<Folder Include="Models\" />
</ItemGroup>
<ItemGroup>
<Content Include="Views\Fields\Input.cshtml" />
</ItemGroup>
@@ -223,4 +219,4 @@
</FlavorProperties>
</VisualStudio>
</ProjectExtensions>
</Project>
</Project>

View File

@@ -4,30 +4,48 @@
@{
var settings = Model.PartFieldDefinition.Settings.GetModel<EnumerationFieldSettings>();
string[] options = (!String.IsNullOrWhiteSpace(settings.Options)) ? settings.Options.Split(new string[] { System.Environment.NewLine }, StringSplitOptions.None) : new string[] { T("Select an option").ToString() };
string[] options = (!String.IsNullOrWhiteSpace(settings.Options)) ?
settings.Options.Split(new string[] { System.Environment.NewLine }, StringSplitOptions.None)
: new string[] { T("Select an option").ToString() };
}
<fieldset>
<label for="@Html.FieldIdFor(m => m.Value)" @if (settings.Required) { <text> class="required" </text> }>@Model.DisplayName</label>
@switch (settings.ListMode) {
case ListMode.Dropdown:
@Html.DropDownListFor(m => m.Value, new SelectList(options, Model.SelectedValues.FirstOrDefault()), settings.Required ? new { required = "required" } : null)
@Html.DropDownListFor(
m => m.Value,
new SelectList(options, Model.SelectedValues.FirstOrDefault()),
settings.Required ? new { required = "required" } : null)
break;
case ListMode.Radiobutton:
foreach (var option in options) {
if (string.IsNullOrWhiteSpace(option)) {
<label>@Html.RadioButton("Value", "", string.IsNullOrWhiteSpace(Model.SelectedValues.FirstOrDefault()), settings.Required ? new { required = "required" } : null)<i>@T("unset")</i></label>
<label>@Html.RadioButton(
"Value",
"",
string.IsNullOrWhiteSpace(Model.SelectedValues.FirstOrDefault()),
settings.Required ? new { required = "required" } : null)<i>@T("unset")</i>
</label>
}
else {
<label>@Html.RadioButton("Value", option, (option == Model.SelectedValues.FirstOrDefault()), settings.Required ? new { required = "required" } : null)@option</label>
<label>@Html.RadioButton(
"Value",
option,
option == Model.SelectedValues.FirstOrDefault(),
settings.Required ? new { required = "required" } : null)@option
</label>
}
}
break;
case ListMode.Listbox:
<input name="@Html.FieldNameFor(m => m.SelectedValues)" type="hidden" />
@Html.ListBoxFor(m => m.SelectedValues, new MultiSelectList(options, Model.SelectedValues), settings.Required ? new { required = "required" } : null)
@Html.ListBoxFor(
m => m.SelectedValues,
new MultiSelectList(options, Model.SelectedValues),
settings.Required ? new { required = "required" } : null)
break;
case ListMode.Checkbox:
@@ -37,7 +55,9 @@
index++;
if (!string.IsNullOrWhiteSpace(option)) {
<div>
<input type="checkbox" name="@Html.FieldNameFor(m => m.SelectedValues)" value="@option" @((Model.SelectedValues != null && Model.SelectedValues.Contains(option)) ? "checked=\"checked\"" : "") class="check-box" id="@Html.FieldIdFor(m => m.SelectedValues)-@index" />
<input type="checkbox" name="@Html.FieldNameFor(m => m.SelectedValues)" value="@option"
@((Model.SelectedValues != null && Model.SelectedValues.Contains(option)) ? "checked=\"checked\"" : "")
class="check-box" id="@Html.FieldIdFor(m => m.SelectedValues)-@index" />
<label class="forcheckbox" for="@Html.FieldIdFor(m => m.SelectedValues)-@index">@option</label>
</div>
}

View File

@@ -4,7 +4,7 @@ using Orchard.Commands;
using Orchard.ContentManagement;
using Orchard.Indexing.Services;
using Orchard.Tasks.Indexing;
using Orchard.Utility.Extensions;
using static Orchard.Indexing.Helpers.IndexingHelpers;
namespace Orchard.Indexing.Commands {
public class IndexingCommands : DefaultOrchardCommandHandler {
@@ -38,27 +38,22 @@ namespace Orchard.Indexing.Commands {
return;
}
if (string.IsNullOrWhiteSpace(index)) {
if (!IsValidIndexName(index)) {
Context.Output.WriteLine(T("Invalid index name."));
return;
}
if (index.ToSafeName() != index) {
Context.Output.WriteLine(T("Invalid index name."));
var indexProvider = _indexManager.GetSearchIndexProvider();
if (indexProvider == null) {
Context.Output.WriteLine(T("No indexing service was found. Please enable a module like Lucene."));
}
else {
var indexProvider = _indexManager.GetSearchIndexProvider();
if(indexProvider == null) {
Context.Output.WriteLine(T("No indexing service was found. Please enable a module like Lucene."));
if (indexProvider.Exists(index)) {
Context.Output.WriteLine(T("The specified index already exists."));
}
else {
if (indexProvider.Exists(index)) {
Context.Output.WriteLine(T("The specified index already exists."));
}
else {
_indexManager.GetSearchIndexProvider().CreateIndex(index);
Context.Output.WriteLine(T("New index has been created successfully."));
}
_indexManager.GetSearchIndexProvider().CreateIndex(index);
Context.Output.WriteLine(T("New index has been created successfully."));
}
}
}
@@ -66,7 +61,7 @@ namespace Orchard.Indexing.Commands {
[CommandName("index update")]
[CommandHelp("index update <index>\r\n\t" + "Updates the specified index")]
public void Update(string index) {
if (string.IsNullOrWhiteSpace(index)) {
if (!IsValidIndexName(index)) {
Context.Output.WriteLine(T("Invalid index name."));
return;
}
@@ -78,7 +73,7 @@ namespace Orchard.Indexing.Commands {
[CommandName("index rebuild")]
[CommandHelp("index rebuild <index> \r\n\t" + "Rebuilds the specified index")]
public void Rebuild(string index) {
if (string.IsNullOrWhiteSpace(index)) {
if (!IsValidIndexName(index)) {
Context.Output.WriteLine(T("Invalid index name."));
return;
}
@@ -91,24 +86,24 @@ namespace Orchard.Indexing.Commands {
[CommandHelp("index query <index> /Query:<query>\r\n\t" + "Searches the specified <query> terms in the specified index")]
[OrchardSwitches("Query")]
public void Search(string index) {
if (string.IsNullOrWhiteSpace(index)) {
if (!IsValidIndexName(index)) {
Context.Output.WriteLine(T("Invalid index name."));
return;
}
if ( !_indexManager.HasIndexProvider() ) {
if (!_indexManager.HasIndexProvider()) {
Context.Output.WriteLine(T("No index available"));
return;
}
var searchBuilder = _indexManager.GetSearchIndexProvider().CreateSearchBuilder(index);
var results = searchBuilder.Parse( new [] {"body", "title"}, Query).Search();
var results = searchBuilder.Parse(new[] { "body", "title" }, Query).Search();
Context.Output.WriteLine("{0} result{1}\r\n-----------------\r\n", results.Count(), results.Count() > 0 ? "s" : "");
Context.Output.WriteLine("┌──────────────────────────────────────────────────────────────┬────────┐");
Context.Output.WriteLine("│ {0} │ {1,6} │", "Title" + new string(' ', 60 - "Title".Length), "Score");
Context.Output.WriteLine("├──────────────────────────────────────────────────────────────┼────────┤");
foreach ( var searchHit in results ) {
foreach (var searchHit in results) {
var contentItem = _contentManager.Get(searchHit.ContentItemId);
var metadata = _contentManager.GetItemMetadata(contentItem);
var title = String.IsNullOrWhiteSpace(metadata.DisplayText) ? "- no title -" : metadata.DisplayText;
@@ -126,12 +121,12 @@ namespace Orchard.Indexing.Commands {
[CommandHelp("index stats <index>\r\n\t" + "Displays some statistics about the search index")]
[OrchardSwitches("IndexName")]
public void Stats(string index) {
if (string.IsNullOrWhiteSpace(index)) {
if (!IsValidIndexName(index)) {
Context.Output.WriteLine(T("Invalid index name."));
return;
}
if ( !_indexManager.HasIndexProvider() ) {
if (!_indexManager.HasIndexProvider()) {
Context.Output.WriteLine(T("No index available"));
return;
}
@@ -140,11 +135,10 @@ namespace Orchard.Indexing.Commands {
}
[CommandName("index refresh")]
[CommandHelp("index refresh /ContentItem:<content item id> \r\n\t" + "Refreshes the index for the specifed <content item id>")]
[CommandHelp("index refresh /ContentItem:<content item id> \r\n\t" + "Refreshes the index for the specified <content item id>")]
[OrchardSwitches("ContentItem")]
public void Refresh() {
int contentItemId;
if ( !int.TryParse(ContentItem, out contentItemId) ) {
if (!int.TryParse(ContentItem, out int contentItemId)) {
Context.Output.WriteLine(T("Invalid content item id. Not an integer."));
return;
}
@@ -152,19 +146,18 @@ namespace Orchard.Indexing.Commands {
var contentItem = _contentManager.Get(contentItemId);
_indexingTaskManager.CreateUpdateIndexTask(contentItem);
Context.Output.WriteLine(T("Content Item marked for reindexing"));
Context.Output.WriteLine(T("Content Item marked for re-indexing"));
}
[CommandName("index delete")]
[CommandHelp("index delete /ContentItem:<content item id>\r\n\t" + "Deletes the specifed <content item id> from the index")]
[CommandHelp("index delete /ContentItem:<content item id>\r\n\t" + "Deletes the specified <content item id> from the index")]
[OrchardSwitches("ContentItem")]
public void Delete() {
int contentItemId;
if(!int.TryParse(ContentItem, out contentItemId)) {
if (!int.TryParse(ContentItem, out int contentItemId)) {
Context.Output.WriteLine(T("Invalid content item id. Not an integer."));
return;
}
var contentItem = _contentManager.Get(contentItemId);
_indexingTaskManager.CreateDeleteIndexTask(contentItem);

View File

@@ -2,12 +2,12 @@
using System.Linq;
using System.Web.Mvc;
using Orchard.Indexing.Services;
using Orchard.Indexing.ViewModels;
using Orchard.Localization;
using Orchard.Logging;
using Orchard.Security;
using Orchard.Indexing.ViewModels;
using Orchard.UI.Notify;
using Orchard.Utility.Extensions;
using static Orchard.Indexing.Helpers.IndexingHelpers;
namespace Orchard.Indexing.Controllers {
public class AdminController : Controller {
@@ -15,7 +15,7 @@ namespace Orchard.Indexing.Controllers {
private readonly IIndexManager _indexManager;
public AdminController(
IIndexingService indexingService,
IIndexingService indexingService,
IOrchardServices services,
IIndexManager indexManager) {
_indexingService = indexingService;
@@ -34,23 +34,21 @@ namespace Orchard.Indexing.Controllers {
IndexEntries = Enumerable.Empty<IndexEntry>(),
IndexProvider = _indexManager.GetSearchIndexProvider()
};
if (_indexManager.HasIndexProvider()) {
viewModel.IndexEntries = _indexManager.GetSearchIndexProvider().List().Select(x => {
try {
return _indexingService.GetIndexEntry(x);
}
catch(Exception e) {
catch (Exception e) {
Logger.Error(e, "Index couldn't be read: " + x);
return new IndexEntry {
return new IndexEntry {
IndexName = x,
IndexingStatus = IndexingStatus.Unavailable
};
}
});
}
// Services.Notifier.Information(T("The index might be corrupted. If you can't recover click on Rebuild."));
return View(viewModel);
}
@@ -59,7 +57,7 @@ namespace Orchard.Indexing.Controllers {
if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not allowed to manage the search index.")))
return new HttpUnauthorizedResult();
return View("Create", String.Empty);
return View("Create");
}
[HttpPost, ActionName("Create")]
@@ -68,7 +66,7 @@ namespace Orchard.Indexing.Controllers {
return new HttpUnauthorizedResult();
var provider = _indexManager.GetSearchIndexProvider();
if (String.IsNullOrWhiteSpace(id) || id.ToSafeName() != id) {
if (!IsValidIndexName(id)) {
Services.Notifier.Error(T("Invalid index name."));
return View("Create", id);
}
@@ -82,9 +80,9 @@ namespace Orchard.Indexing.Controllers {
provider.CreateIndex(id);
Services.Notifier.Information(T("Index named {0} created successfully", id));
}
catch(Exception e) {
catch (Exception e) {
Services.Notifier.Error(T("An error occurred while creating the index: {0}", id));
Logger.Error("An error occurred while creatign the index " + id, e);
Logger.Error("An error occurred while creating the index " + id, e);
return View("Create", id);
}
@@ -96,7 +94,12 @@ namespace Orchard.Indexing.Controllers {
if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not allowed to manage the search index.")))
return new HttpUnauthorizedResult();
_indexingService.UpdateIndex(id);
if (IsValidIndexName(id)) {
_indexingService.UpdateIndex(id);
}
else {
Services.Notifier.Error(T("Invalid index name."));
}
return RedirectToAction("Index");
}
@@ -106,7 +109,12 @@ namespace Orchard.Indexing.Controllers {
if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not allowed to manage the search index.")))
return new HttpUnauthorizedResult();
_indexingService.RebuildIndex(id);
if (IsValidIndexName(id)) {
_indexingService.RebuildIndex(id);
}
else {
Services.Notifier.Error(T("Invalid index name."));
}
return RedirectToAction("Index");
}
@@ -116,7 +124,12 @@ namespace Orchard.Indexing.Controllers {
if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not allowed to manage the search index.")))
return new HttpUnauthorizedResult();
_indexingService.DeleteIndex(id);
if (IsValidIndexName(id)) {
_indexingService.DeleteIndex(id);
}
else {
Services.Notifier.Error(T("Invalid index name."));
}
return RedirectToAction("Index");
}

View File

@@ -0,0 +1,8 @@
using Orchard.Utility.Extensions;
namespace Orchard.Indexing.Helpers {
public static class IndexingHelpers {
public static bool IsValidIndexName(string name) =>
!string.IsNullOrWhiteSpace(name) && name.ToSafeName() == name;
}
}

View File

@@ -95,6 +95,7 @@
<Compile Include="AdminMenu.cs" />
<Compile Include="Commands\IndexingCommands.cs" />
<Compile Include="Controllers\AdminController.cs" />
<Compile Include="Helpers\IndexingHelpers.cs" />
<Compile Include="Migrations.cs" />
<Compile Include="Handlers\CreateIndexingTaskHandler.cs" />
<Compile Include="Handlers\InfosetFieldIndexingHandler.cs" />
@@ -180,4 +181,4 @@
</FlavorProperties>
</VisualStudio>
</ProjectExtensions>
</Project>
</Project>

View File

@@ -1101,17 +1101,17 @@ html.dyn #submit-pager, html.dyn .apply-bulk-actions-auto { display:none; }
padding:0;
}
fieldset.publish-button, fieldset.delete-button, fieldset.save-button {
fieldset.publish-button, fieldset.delete-button, fieldset.save-button, fieldset.unpublish-button {
clear:none;
float:left;
}
fieldset.save-button {
clear:left;
}
fieldset.publish-button {
fieldset.publish-button, fieldset.unpublish-button {
margin: 0 12px 0 0;
padding: 0 12px;
border-right:1px solid #ccc;
border-right: 1px solid #ccc;
}
fieldset.delete-button {
margin: 0 0 0 12px;

View File

@@ -69,6 +69,22 @@
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-5.2.7.0" newVersion="5.2.7.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Numerics.Vectors" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.5.0" newVersion="4.1.5.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.4.0" newVersion="4.0.4.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<system.codedom>

View File

@@ -1,98 +1,15 @@
using System;
using System.Linq;
using Orchard.ContentManagement;
using Orchard.Core.Containers.Models;
using Orchard.Core.Containers.Services;
using Orchard.Localization;
using Orchard.Security;
using Orchard.Localization;
using Orchard.UI.Navigation;
using Orchard.Utility.Extensions;
namespace Orchard.Lists {
public class AdminMenu : INavigationProvider {
private readonly IContainerService _containerService;
private readonly IContentManager _contentManager;
private readonly IAuthorizationService _authorizationService;
private readonly IWorkContextAccessor _workContextAccessor;
public AdminMenu(
IContainerService containerService,
IContentManager contentManager,
IAuthorizationService authorizationService,
IWorkContextAccessor workContextAccessor
) {
_containerService = containerService;
_contentManager = contentManager;
_authorizationService = authorizationService;
_workContextAccessor = workContextAccessor;
}
public Localizer T { get; set; }
public string MenuName { get { return "admin"; } }
public void GetNavigation(NavigationBuilder builder) {
builder.AddImageSet("list");
CreateListManagementMenuItem(builder);
CreateListMenuItems(builder);
}
private void CreateListManagementMenuItem(NavigationBuilder builder) {
builder.Add(T("Lists"), "11", item => item
.Action("Index", "Admin", new {area = "Orchard.Lists"}).Permission(Permissions.ManageLists)
);
}
private void CreateListMenuItems(NavigationBuilder builder) {
var containers = _containerService
.GetContainersQuery(VersionOptions.Latest)
.Where<ContainerPartRecord>(x => x.ShowOnAdminMenu)
.List()
.Where(x => _authorizationService.TryCheckAccess(Orchard.Core.Contents.Permissions.EditContent, _workContextAccessor.GetContext().CurrentUser, x))
.ToList();
foreach (var container in containers) {
var closureContainer = container;
if (!String.IsNullOrWhiteSpace(container.AdminMenuImageSet)) {
builder.AddImageSet(container.AdminMenuImageSet.Trim());
}
builder.Add(T(container.AdminMenuText), container.AdminMenuPosition, item => {
var containedItems = _containerService.GetContentItems(closureContainer.Id, VersionOptions.Latest).ToList();
var actualContainer = closureContainer;
var position = 0;
// If the list has just a single item that happens to be a container itself,
// we will treat that one as the actual container to provide a nice & quick way to manage that list.
if (containedItems.Count == 1) {
var containedItem = containedItems.First().As<ContainerPart>();
if (containedItem != null) {
actualContainer = containedItem;
foreach (var itemContentType in containedItem.ItemContentTypes) {
var closureItemContentType = itemContentType;
item.Add(T("New {0}", itemContentType.DisplayName), String.Format("1.{0}", position++), subItem => subItem
.Action("Create", "Admin", new { id = closureItemContentType.Name, containerid = containedItem.Id, area = "Contents" }));
}
}
}
var containerMetadata = _contentManager.GetItemMetadata(actualContainer);
item.Action(containerMetadata.AdminRouteValues);
item.Action(containerMetadata.AdminRouteValues);
item.AddClass("nav-list");
item.AddClass(closureContainer.AdminMenuText.HtmlClassify());
item.LinkToFirstChild(false);
foreach (var itemContentType in closureContainer.ItemContentTypes) {
var closureItemContentType = itemContentType;
item.Add(T("New {0}", itemContentType.DisplayName), String.Format("1.{0}", position++), subItem => subItem
.Action("Create", "Admin", new { id = closureItemContentType.Name, containerid = container.Id, area = "Contents" }));
}
});
}
}
public void GetNavigation(NavigationBuilder builder) =>
builder
.AddImageSet("lists")
.Add(T("Lists"), "11", item => item
.Action("Index", "Admin", new { area = "Orchard.Lists" }).Permission(Permissions.ManageLists));
}
}
}

View File

@@ -115,6 +115,7 @@
<Content Include="Styles\images\icons.png" />
<Content Include="Styles\images\view.default.png" />
<Content Include="Styles\images\view.condensed.png" />
<Content Include="Styles\menu.lists-admin.css" />
<Content Include="Styles\nprogress.css" />
<Content Include="Scripts\nprogress.js" />
<Content Include="Scripts\orchard-lists-admin.js" />
@@ -143,16 +144,14 @@
<Content Include="Scripts\orchard-lists-admin.min.js">
<DependentUpon>orchard-lists-admin.js</DependentUpon>
</Content>
<Content Include="Styles\images\menu.list-definition.png" />
<Content Include="Styles\images\menu.lists.png" />
<Content Include="Styles\images\move.gif" />
<Content Include="Styles\images\offline.gif" />
<Content Include="Styles\images\online.gif" />
<Content Include="Styles\list-admin.css" />
<Content Include="Styles\images\menu.list.png" />
<Content Include="Styles\list-admin.min.css">
<DependentUpon>list-admin.css</DependentUpon>
</Content>
<Content Include="Styles\menu.list-admin.css" />
</ItemGroup>
<ItemGroup>
<Content Include="Web.config">
@@ -272,4 +271,4 @@
</FlavorProperties>
</VisualStudio>
</ProjectExtensions>
</Project>
</Project>

View File

@@ -1,22 +0,0 @@
.navicon-list,
.navicon-lists,
.section-new .subnavicon-list,
.nav-list > h3 > a,
.nav-list-definition > h3 > a {
background-image:url(images/menu.list.png) !important;
}
.navicon-list:hover,
.navicon-lists:hover,
.nav-list > h3 > a:hover,
.nav-list-definition > h3 > a:hover {
background-position:0 -30px !important;
}
.navicon-lists {
background-image:url(images/menu.list.png) !important;
}
.navicon-lists:hover {
background-position:0 -30px !important;
}

View File

@@ -0,0 +1,7 @@
.navicon-lists {
background-image: url(images/menu.lists.png) !important;
}
.navicon-lists:hover {
background-position: 0 -30px !important;
}

View File

@@ -17,12 +17,16 @@ namespace Orchard.MediaLibrary.Controllers {
[Admin, Themed(false)]
public class OEmbedController : Controller {
private readonly IMediaLibraryService _mediaLibraryService;
private readonly IOEmbedService _oEmbedService;
public OEmbedController(
IOrchardServices services,
IMediaLibraryService mediaManagerService) {
_mediaLibraryService = mediaManagerService;
IMediaLibraryService mediaManagerService,
IOEmbedService oEmbedService) {
Services = services;
_mediaLibraryService = mediaManagerService;
_oEmbedService = oEmbedService;
T = NullLocalizer.Instance;
}
@@ -78,39 +82,9 @@ namespace Orchard.MediaLibrary.Controllers {
}
}
var webClient = new WebClient { Encoding = Encoding.UTF8 };
try {
// <link rel="alternate" href="http://vimeo.com/api/oembed.xml?url=http%3A%2F%2Fvimeo.com%2F23608259" type="text/xml+oembed">
viewModel.Content = _oEmbedService.DownloadMediaData(url);
var source = webClient.DownloadString(url);
// seek type="text/xml+oembed" or application/xml+oembed
var oembedSignature = source.IndexOf("type=\"text/xml+oembed\"", StringComparison.OrdinalIgnoreCase);
if (oembedSignature == -1) {
oembedSignature = source.IndexOf("type=\"application/xml+oembed\"", StringComparison.OrdinalIgnoreCase);
}
if (oembedSignature != -1) {
var tagStart = source.Substring(0, oembedSignature).LastIndexOf('<');
var tagEnd = source.IndexOf('>', oembedSignature);
var tag = source.Substring(tagStart, tagEnd - tagStart);
var matches = new Regex("href=\"([^\"]+)\"").Matches(tag);
if (matches.Count > 0) {
var href = matches[0].Groups[1].Value;
try {
var content = webClient.DownloadString(Server.HtmlDecode(href));
viewModel.Content = XDocument.Parse(content);
}
catch {
// bubble exception
}
}
}
if (viewModel.Content == null) {
viewModel.Content = new XDocument(
new XDeclaration("1.0", "utf-8", "yes"),
new XElement("oembed")
);
}
var root = viewModel.Content.Root;
if (!String.IsNullOrWhiteSpace(url)) {
root.El("url", url);

View File

@@ -200,7 +200,9 @@
<Compile Include="Security\MediaAuthorizationEventHandler.cs" />
<Compile Include="Services\IMediaLibraryService.cs" />
<Compile Include="Providers\IMediaFolderProvider.cs" />
<Compile Include="Services\IOEmbedService.cs" />
<Compile Include="Services\MediaLibraryService.cs" />
<Compile Include="Services\OEmbedService.cs" />
<Compile Include="Services\Shapes.cs" />
<Compile Include="Services\XmlRpcHandler.cs" />
<Compile Include="Settings\MediaLibraryPickerFieldEditorEvents.cs" />

View File

@@ -0,0 +1,7 @@
using System.Xml.Linq;
namespace Orchard.MediaLibrary.Services {
public interface IOEmbedService : IDependency {
XDocument DownloadMediaData(string url);
}
}

View File

@@ -0,0 +1,51 @@
using System;
using System.Net;
using System.Text;
using System.Text.RegularExpressions;
using System.Web;
using System.Xml.Linq;
namespace Orchard.MediaLibrary.Services {
public class OEmbedService : IOEmbedService {
public XDocument DownloadMediaData(string url) {
var webClient = new WebClient { Encoding = Encoding.UTF8 };
XDocument doc = null;
try {
// <link rel="alternate" href="http://vimeo.com/api/oembed.xml?url=http%3A%2F%2Fvimeo.com%2F23608259" type="text/xml+oembed">
var source = webClient.DownloadString(url);
// seek type="text/xml+oembed" or application/xml+oembed
var oembedSignature = source.IndexOf("type=\"text/xml+oembed\"", StringComparison.OrdinalIgnoreCase);
if (oembedSignature == -1) {
oembedSignature = source.IndexOf("type=\"application/xml+oembed\"", StringComparison.OrdinalIgnoreCase);
}
if (oembedSignature != -1) {
var tagStart = source.Substring(0, oembedSignature).LastIndexOf('<');
var tagEnd = source.IndexOf('>', oembedSignature);
var tag = source.Substring(tagStart, tagEnd - tagStart);
var matches = new Regex("href=\"([^\"]+)\"").Matches(tag);
if (matches.Count > 0) {
var href = matches[0].Groups[1].Value;
try {
var content = webClient.DownloadString(HttpUtility.HtmlDecode(href));
doc = XDocument.Parse(content);
} catch {
// bubble exception
}
}
}
} catch {
doc = null;
}
if (doc == null) {
doc = new XDocument(
new XDeclaration("1.0", "utf-8", "yes"),
new XElement("oembed")
);
}
return doc;
}
}
}

View File

@@ -1,9 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using System.Web.Routing;
using Orchard.ContentManagement;
using Orchard.Core.Title.Models;
using Orchard.DisplayManagement;
using Orchard.Forms.Services;
using Orchard.Localization;
using Orchard.Mvc;
using Orchard.Projections.Descriptors.Filter;
using Orchard.Projections.Descriptors.Layout;
@@ -11,13 +15,9 @@ using Orchard.Projections.Descriptors.SortCriterion;
using Orchard.Projections.Models;
using Orchard.Projections.Services;
using Orchard.Projections.ViewModels;
using Orchard.ContentManagement;
using Orchard.DisplayManagement;
using Orchard.Localization;
using Orchard.UI.Notify;
using System;
using Orchard.Settings;
using Orchard.UI.Navigation;
using Orchard.UI.Notify;
namespace Orchard.Projections.Controllers {
[ValidateInput(false)]
@@ -84,7 +84,7 @@ namespace Orchard.Projections.Controllers {
var model = new AdminIndexViewModel {
Queries = results.Select(x => new QueryEntry {
Query = x.As<QueryPart>().Record,
Query = x.As<QueryPart>().Record,
QueryId = x.Id,
Name = x.As<QueryPart>().Name
}).ToList(),
@@ -158,16 +158,21 @@ namespace Orchard.Projections.Controllers {
Category = f.Category,
Type = f.Type,
FilterRecordId = filter.Id,
DisplayText = String.IsNullOrWhiteSpace(filter.Description) ? f.Display(new FilterContext {State = FormParametersHelper.ToDynamic(filter.State)}).Text : filter.Description
DisplayText = String.IsNullOrWhiteSpace(filter.Description) ? f.Display(new FilterContext { State = FormParametersHelper.ToDynamic(filter.State) }).Text : filter.Description
});
}
}
filterGroupEntries.Add( new FilterGroupEntry { Id = group.Id, Filters = filterEntries } );
filterGroupEntries.Add(new FilterGroupEntry { Id = group.Id, Filters = filterEntries });
}
viewModel.FilterGroups = filterGroupEntries;
if (viewModel.FilterGroups.Any(group => group.Filters.Count() == 0)) {
_services.Notifier.Warning(
T("This Query has at least one empty filter group, which will cause all content items to be returned, unless the Projection using this Query limits the number of content items displayed."));
}
#endregion
#region Load Sort criterias
@@ -185,7 +190,7 @@ namespace Orchard.Projections.Controllers {
Category = f.Category,
Type = f.Type,
SortCriterionRecordId = sortCriterion.Id,
DisplayText = String.IsNullOrWhiteSpace(sortCriterion.Description) ? f.Display(new SortCriterionContext { State = FormParametersHelper.ToDynamic(sortCriterion.State) }).Text : sortCriterion.Description
DisplayText = String.IsNullOrWhiteSpace(sortCriterion.Description) ? f.Display(new SortCriterionContext { State = FormParametersHelper.ToDynamic(sortCriterion.State) }).Text : sortCriterion.Description
});
}
}

View File

@@ -20,10 +20,12 @@ using Orchard.Projections.Settings;
using Orchard.Projections.ViewModels;
using Orchard.Tokens;
using Orchard.UI.Navigation;
using Orchard.UI.Notify;
using Orchard.Utility.Extensions;
namespace Orchard.Projections.Drivers {
public class ProjectionPartDriver : ContentPartDriver<ProjectionPart> {
private readonly IOrchardServices _orchardServices;
private readonly IRepository<QueryPartRecord> _queryRepository;
private readonly IProjectionManagerExtension _projectionManager;
private readonly IFeedManager _feedManager;
@@ -33,25 +35,25 @@ namespace Orchard.Projections.Drivers {
private const string TemplateName = "Parts/ProjectionPart";
public ProjectionPartDriver(
IOrchardServices services,
IOrchardServices orchardServices,
IRepository<QueryPartRecord> queryRepository,
IProjectionManagerExtension projectionManager,
IFeedManager feedManager,
ITokenizer tokenizer,
IDisplayHelperFactory displayHelperFactory,
IWorkContextAccessor workContextAccessor) {
_orchardServices = orchardServices;
_queryRepository = queryRepository;
_projectionManager = projectionManager;
_feedManager = feedManager;
_tokenizer = tokenizer;
_displayHelperFactory = displayHelperFactory;
_workContextAccessor = workContextAccessor;
T = NullLocalizer.Instance;
Services = services;
}
public Localizer T { get; set; }
public IOrchardServices Services { get; set; }
protected override string Prefix { get { return "ProjectionPart"; } }
@@ -59,7 +61,7 @@ namespace Orchard.Projections.Drivers {
var query = part.Record.QueryPartRecord;
// retrieving paging parameters
var queryString = Services.WorkContext.HttpContext.Request.QueryString;
var queryString = _orchardServices.WorkContext.HttpContext.Request.QueryString;
var pageKey = String.IsNullOrWhiteSpace(part.Record.PagerSuffix) ? "page" : "page-" + part.Record.PagerSuffix;
var page = 0;
@@ -81,16 +83,14 @@ namespace Orchard.Projections.Drivers {
var pageSizeKey = "pageSize" + part.Record.PagerSuffix;
if (queryString.AllKeys.Contains(pageSizeKey)) {
int qsPageSize;
if (Int32.TryParse(queryString[pageSizeKey], out qsPageSize)) {
if (Int32.TryParse(queryString[pageSizeKey], out int qsPageSize)) {
if (part.Record.MaxItems == 0 || qsPageSize <= part.Record.MaxItems) {
pageSize = qsPageSize;
}
}
}
var pager = new Pager(Services.WorkContext.CurrentSite, page, pageSize);
var pager = new Pager(_orchardServices.WorkContext.CurrentSite, page, pageSize);
var pagerShape = shapeHelper.Pager(pager)
.ContentPart(part)
@@ -107,7 +107,7 @@ namespace Orchard.Projections.Drivers {
ContentShape("Parts_ProjectionPart_List", shape => {
// generates a link to the RSS feed for this term
var metaData = Services.ContentManager.GetItemMetadata(part.ContentItem);
var metaData = _orchardServices.ContentManager.GetItemMetadata(part.ContentItem);
_feedManager.Register(metaData.DisplayText, "rss", new RouteValueDictionary { { "projection", part.Id } });
// execute the query
@@ -130,8 +130,8 @@ namespace Orchard.Projections.Drivers {
// renders in a standard List shape if no specific layout could be found
if (layoutDescriptor == null) {
var list = Services.New.List();
var contentShapes = contentItems.Select(item => Services.ContentManager.BuildDisplay(item, "Summary"));
var list = _orchardServices.New.List();
var contentShapes = contentItems.Select(item => _orchardServices.ContentManager.BuildDisplay(item, "Summary"));
list.AddRange(contentShapes);
return list;
@@ -143,7 +143,7 @@ namespace Orchard.Projections.Drivers {
var layoutComponents = contentItems.Select(
contentItem => {
var contentItemMetadata = Services.ContentManager.GetItemMetadata(contentItem);
var contentItemMetadata = _orchardServices.ContentManager.GetItemMetadata(contentItem);
var propertyDescriptors = fieldDescriptors.Select(
d => {
@@ -156,9 +156,9 @@ namespace Orchard.Projections.Drivers {
});
// apply all settings to the field content, wrapping it in a FieldWrapper shape
var properties = Services.New.Properties(
var properties = _orchardServices.New.Properties(
Items: propertyDescriptors.Select(
pd => Services.New.PropertyWrapper(
pd => _orchardServices.New.PropertyWrapper(
Item: pd.Shape,
Property: pd.Property,
ContentItem: contentItem,
@@ -199,14 +199,14 @@ namespace Orchard.Projections.Drivers {
return key;
}).Select(x => new { Key = x.Key, Components = x });
var list = Services.New.List();
var list = _orchardServices.New.List();
foreach (var group in groups) {
var localResult = layoutDescriptor.Render(renderLayoutContext, group.Components);
// add the Context to the shape
localResult.Context(renderLayoutContext);
list.Add(Services.New.LayoutGroup(Key: new MvcHtmlString(group.Key), List: localResult));
list.Add(_orchardServices.New.LayoutGroup(Key: new MvcHtmlString(group.Key), List: localResult));
}
return list;
@@ -223,81 +223,80 @@ namespace Orchard.Projections.Drivers {
}
protected override DriverResult Editor(ProjectionPart part, dynamic shapeHelper) {
return ContentShape("Parts_ProjectionPart_Edit",
() => {
var model = new ProjectionPartEditViewModel();
return ContentShape("Parts_ProjectionPart_Edit", () => {
var model = new ProjectionPartEditViewModel();
// for create read the setting values
var settings = part.TypePartDefinition.Settings.GetModel<ProjectionPartSettings>();
if (part.Id == 0) {
model = new ProjectionPartEditViewModel {
DisplayPager = settings.DisplayPager,
Items = settings.Items,
Skip = settings.Skip,
PagerSuffix = settings.PagerSuffix,
MaxItems = settings.MaxItems,
QueryLayoutRecordId = settings.QueryLayoutRecordId
};
}
else {
model = new ProjectionPartEditViewModel {
DisplayPager = part.Record.DisplayPager,
Items = part.Record.Items,
ItemsPerPage = part.Record.ItemsPerPage,
Skip = part.Record.Skip,
PagerSuffix = part.Record.PagerSuffix,
MaxItems = part.Record.MaxItems,
QueryLayoutRecordId = "-1"
};
// concatenated Query and Layout ids for the view
if (part.Record.QueryPartRecord != null) {
model.QueryLayoutRecordId = part.Record.QueryPartRecord.Id + ";";
}
// for create read the setting values
var settings = part.TypePartDefinition.Settings.GetModel<ProjectionPartSettings>();
if (part.Id == 0) {
model = new ProjectionPartEditViewModel {
DisplayPager = settings.DisplayPager,
Items = settings.Items,
Skip = settings.Skip,
PagerSuffix = settings.PagerSuffix,
MaxItems = settings.MaxItems,
QueryLayoutRecordId = settings.QueryLayoutRecordId
};
}
else {
model = new ProjectionPartEditViewModel {
DisplayPager = part.Record.DisplayPager,
Items = part.Record.Items,
ItemsPerPage = part.Record.ItemsPerPage,
Skip = part.Record.Skip,
PagerSuffix = part.Record.PagerSuffix,
MaxItems = part.Record.MaxItems,
QueryLayoutRecordId = "-1"
};
// concatenated Query and Layout ids for the view
if (part.Record.QueryPartRecord != null) {
model.QueryLayoutRecordId = part.Record.QueryPartRecord.Id + ";";
}
if (part.Record.LayoutRecord != null) {
model.QueryLayoutRecordId += part.Record.LayoutRecord.Id.ToString();
}
else {
model.QueryLayoutRecordId += "-1";
}
}
if (part.Record.LayoutRecord != null) {
model.QueryLayoutRecordId += part.Record.LayoutRecord.Id.ToString();
}
else {
model.QueryLayoutRecordId += "-1";
}
}
model.PartId = part.Id;
model.PartId = part.Id;
// lock fields
model.LockEditingItems = settings.LockEditingItems;
model.LockEditingSkip = settings.LockEditingSkip;
model.LockEditingMaxItems = settings.LockEditingMaxItems;
model.LockEditingPagerSuffix = settings.LockEditingPagerSuffix;
model.LockEditingDisplayPager = settings.LockEditingDisplayPager;
// lock fields
model.LockEditingItems = settings.LockEditingItems;
model.LockEditingSkip = settings.LockEditingSkip;
model.LockEditingMaxItems = settings.LockEditingMaxItems;
model.LockEditingPagerSuffix = settings.LockEditingPagerSuffix;
model.LockEditingDisplayPager = settings.LockEditingDisplayPager;
// populating the list of queries and layouts
var layouts = _projectionManager.DescribeLayouts().SelectMany(x => x.Descriptors).ToList();
model.QueryRecordEntries = Services.ContentManager.Query<QueryPart, QueryPartRecord>().Join<TitlePartRecord>().OrderBy(x => x.Title).List()
.Select(x => new QueryRecordEntry {
Id = x.Id,
Name = x.Name,
LayoutRecordEntries = x.Layouts.Select(l => new LayoutRecordEntry {
Id = l.Id,
Description = GetLayoutDescription(layouts, l)
})
});
// populating the list of queries and layouts
var layouts = _projectionManager.DescribeLayouts().SelectMany(x => x.Descriptors).ToList();
model.QueryRecordEntries = _orchardServices.ContentManager.Query<QueryPart, QueryPartRecord>().Join<TitlePartRecord>().OrderBy(x => x.Title).List()
.Select(x => new QueryRecordEntry {
Id = x.Id,
Name = x.Name,
LayoutRecordEntries = x.Layouts.Select(l => new LayoutRecordEntry {
Id = l.Id,
Description = GetLayoutDescription(layouts, l)
})
});
// if any values, use default list of the settings
if (!string.IsNullOrWhiteSpace(settings.FilterQueryRecordId)) {
var filterQueryRecordId = settings.FilterQueryRecordId.Split('&');
model.QueryRecordIdFilterEntries = filterQueryRecordId
.Select(x => new QueryRecordFilterEntry {
Id = x.Split(';')[0],
LayoutId = x.Split(';')[1]
});
}
else {
model.QueryRecordIdFilterEntries = new List<QueryRecordFilterEntry>();
}
// if any values, use default list of the settings
if (!string.IsNullOrWhiteSpace(settings.FilterQueryRecordId)) {
var filterQueryRecordId = settings.FilterQueryRecordId.Split('&');
model.QueryRecordIdFilterEntries = filterQueryRecordId
.Select(x => new QueryRecordFilterEntry {
Id = x.Split(';')[0],
LayoutId = x.Split(';')[1]
});
}
else {
model.QueryRecordIdFilterEntries = new List<QueryRecordFilterEntry>();
}
return shapeHelper.EditorTemplate(TemplateName: TemplateName, Model: model, Prefix: Prefix);
});
return shapeHelper.EditorTemplate(TemplateName: TemplateName, Model: model, Prefix: Prefix);
});
}
private static string GetLayoutDescription(IEnumerable<LayoutDescriptor> layouts, LayoutRecord l) {
@@ -313,7 +312,7 @@ namespace Orchard.Projections.Drivers {
updater.TryUpdateModel(model, Prefix, null, null);
model.PartId = part.Id;
// check the setting, if it is unlocked, assign the setting value
if (settings.LockEditingDisplayPager) {
part.Record.DisplayPager = settings.DisplayPager;
@@ -356,6 +355,12 @@ namespace Orchard.Projections.Drivers {
updater.AddModelError("PagerSuffix", T("Suffix should not contain special characters."));
}
if (model.Items == 0
&& (part.Record.QueryPartRecord?.FilterGroups.Any(group => group.Filters.Count == 0) ?? false)) {
_orchardServices.Notifier.Warning(
T("The selected Query has at least one empty filter group, which causes all content items to be returned. It is recommended to limit the number of content items queried by setting the 'Items to display' field to a non-zero value."));
}
return Editor(part, shapeHelper);
}
@@ -376,12 +381,11 @@ namespace Orchard.Projections.Drivers {
protected override void ImportCompleted(ProjectionPart part, ImportContentContext context) {
// Assign the query only when everything is imported.
var query = context.Attribute(part.PartDefinition.Name, "Query");
if (query != null && context.GetItemFromSession(query).As<QueryPart>()!=null) {
if (query != null && context.GetItemFromSession(query).As<QueryPart>() != null) {
part.Record.QueryPartRecord = context.GetItemFromSession(query).As<QueryPart>().Record;
var layoutIndex = context.Attribute(part.PartDefinition.Name, "LayoutIndex");
int layoutIndexValue;
if (layoutIndex != null
&& Int32.TryParse(layoutIndex, out layoutIndexValue)
&& Int32.TryParse(layoutIndex, out int layoutIndexValue)
&& layoutIndexValue >= 0
&& part.Record.QueryPartRecord.Layouts.Count > layoutIndexValue) {
part.Record.LayoutRecord = part.Record.QueryPartRecord.Layouts[Int32.Parse(layoutIndex)];
@@ -398,9 +402,9 @@ namespace Orchard.Projections.Drivers {
context.Element(part.PartDefinition.Name).SetAttributeValue("DisplayPager", part.Record.DisplayPager);
if (part.Record.QueryPartRecord != null) {
var queryPart = Services.ContentManager.Query<QueryPart, QueryPartRecord>("Query").Where(x => x.Id == part.Record.QueryPartRecord.Id).List().FirstOrDefault();
var queryPart = _orchardServices.ContentManager.Query<QueryPart, QueryPartRecord>("Query").Where(x => x.Id == part.Record.QueryPartRecord.Id).List().FirstOrDefault();
if (queryPart != null) {
var queryIdentity = Services.ContentManager.GetItemMetadata(queryPart).Identity;
var queryIdentity = _orchardServices.ContentManager.GetItemMetadata(queryPart).Identity;
context.Element(part.PartDefinition.Name).SetAttributeValue("Query", queryIdentity.ToString());
context.Element(part.PartDefinition.Name).SetAttributeValue("LayoutIndex", part.Record.QueryPartRecord.Layouts.IndexOf(part.Record.LayoutRecord));
}

View File

@@ -19,14 +19,16 @@ namespace Orchard.Projections.Drivers {
_projectionManager = projectionManager;
_formManager = formManager;
}
protected override string Prefix {
get {
return "Query_Part";
}
}
protected override DriverResult Editor(QueryPart part, dynamic shapeHelper) {
return Editor(part, null, shapeHelper);
}
protected override DriverResult Editor(QueryPart part, dynamic shapeHelper) =>
Editor(part, null, shapeHelper);
protected override DriverResult Editor(QueryPart part, IUpdateModel updater, dynamic shapeHelper) {
var model = new QueryViewModel { VersionScope = part.VersionScope };
if (updater != null) {
@@ -34,10 +36,10 @@ namespace Orchard.Projections.Drivers {
part.VersionScope = model.VersionScope;
}
}
return ContentShape("Parts_QueryPart_Edit",
() => {
return shapeHelper.EditorTemplate(TemplateName: "Parts/QueryPart_Edit", Model: model, Prefix: Prefix);
});
return ContentShape("Parts_QueryPart_Edit", () => {
return shapeHelper.EditorTemplate(TemplateName: "Parts/QueryPart_Edit", Model: model, Prefix: Prefix);
});
}
protected override void Exporting(QueryPart part, ExportContentContext context) {
@@ -60,12 +62,12 @@ namespace Orchard.Projections.Drivers {
}
return new XElement("Filter",
new XAttribute("Category", filter.Category ?? ""),
new XAttribute("Description", filter.Description ?? ""),
new XAttribute("Position", filter.Position),
new XAttribute("State", state ?? ""),
new XAttribute("Type", filter.Type ?? "")
);
new XAttribute("Category", filter.Category ?? ""),
new XAttribute("Description", filter.Description ?? ""),
new XAttribute("Position", filter.Position),
new XAttribute("State", state ?? ""),
new XAttribute("Type", filter.Type ?? "")
);
})
)
)

View File

@@ -72,17 +72,7 @@ namespace Orchard.Projections {
SchemaBuilder.CreateTable("FieldIndexPartRecord", table => table.ContentPartRecord());
//Adds indexes for better performances in queries
SchemaBuilder.AlterTable("StringFieldIndexRecord", table => table.CreateIndex("IX_PropertyName", new string[] { "PropertyName" }));
SchemaBuilder.AlterTable("StringFieldIndexRecord", table => table.CreateIndex("IX_FieldIndexPartRecord_Id", new string[] { "FieldIndexPartRecord_Id" }));
SchemaBuilder.AlterTable("IntegerFieldIndexRecord", table => table.CreateIndex("IX_PropertyName", new string[] { "PropertyName" }));
SchemaBuilder.AlterTable("IntegerFieldIndexRecord", table => table.CreateIndex("IX_FieldIndexPartRecord_Id", new string[] { "FieldIndexPartRecord_Id" }));
SchemaBuilder.AlterTable("DoubleFieldIndexRecord", table => table.CreateIndex("IX_PropertyName", new string[] { "PropertyName" }));
SchemaBuilder.AlterTable("DoubleFieldIndexRecord", table => table.CreateIndex("IX_FieldIndexPartRecord_Id", new string[] { "FieldIndexPartRecord_Id" }));
SchemaBuilder.AlterTable("DecimalFieldIndexRecord", table => table.CreateIndex("IX_PropertyName", new string[] { "PropertyName" }));
SchemaBuilder.AlterTable("DecimalFieldIndexRecord", table => table.CreateIndex("IX_FieldIndexPartRecord_Id", new string[] { "FieldIndexPartRecord_Id" }));
AddPropertyNameAndFieldIndexPartRecordIdIndexes();
// Query
@@ -287,7 +277,7 @@ namespace Orchard.Projections {
Description = T("The text from the Body part").Text
});
return 6;
return 8;
}
public int UpdateFrom1() {
@@ -343,17 +333,7 @@ namespace Orchard.Projections {
.AddColumn<decimal>("LatestValue"));
//Adds indexes for better performances in queries
SchemaBuilder.AlterTable("StringFieldIndexRecord", table => table.CreateIndex("IX_PropertyName", new string[] { "PropertyName" }));
SchemaBuilder.AlterTable("StringFieldIndexRecord", table => table.CreateIndex("IX_FieldIndexPartRecord_Id", new string[] { "FieldIndexPartRecord_Id" }));
SchemaBuilder.AlterTable("IntegerFieldIndexRecord", table => table.CreateIndex("IX_PropertyName", new string[] { "PropertyName" }));
SchemaBuilder.AlterTable("IntegerFieldIndexRecord", table => table.CreateIndex("IX_FieldIndexPartRecord_Id", new string[] { "FieldIndexPartRecord_Id" }));
SchemaBuilder.AlterTable("DoubleFieldIndexRecord", table => table.CreateIndex("IX_PropertyName", new string[] { "PropertyName" }));
SchemaBuilder.AlterTable("DoubleFieldIndexRecord", table => table.CreateIndex("IX_FieldIndexPartRecord_Id", new string[] { "FieldIndexPartRecord_Id" }));
SchemaBuilder.AlterTable("DecimalFieldIndexRecord", table => table.CreateIndex("IX_PropertyName", new string[] { "PropertyName" }));
SchemaBuilder.AlterTable("DecimalFieldIndexRecord", table => table.CreateIndex("IX_FieldIndexPartRecord_Id", new string[] { "FieldIndexPartRecord_Id" }));
AddPropertyNameAndFieldIndexPartRecordIdIndexes();
SchemaBuilder.AlterTable("QueryPartRecord", table => table
.AddColumn<string>("VersionScope", c => c.WithLength(15)));
@@ -386,5 +366,47 @@ namespace Orchard.Projections {
return 7;
}
public int UpdateFrom7() {
SchemaBuilder.AlterTable("StringFieldIndexRecord", table => {
table.DropIndex("IX_PropertyName");
table.DropIndex("IX_FieldIndexPartRecord_Id");
});
SchemaBuilder.AlterTable("IntegerFieldIndexRecord", table => {
table.DropIndex("IX_PropertyName");
table.DropIndex("IX_FieldIndexPartRecord_Id");
});
SchemaBuilder.AlterTable("DoubleFieldIndexRecord", table => {
table.DropIndex("IX_PropertyName");
table.DropIndex("IX_FieldIndexPartRecord_Id");
});
SchemaBuilder.AlterTable("DecimalFieldIndexRecord", table => {
table.DropIndex("IX_PropertyName");
table.DropIndex("IX_FieldIndexPartRecord_Id");
});
AddPropertyNameAndFieldIndexPartRecordIdIndexes();
return 8;
}
private void AddPropertyNameAndFieldIndexPartRecordIdIndexes() {
SchemaBuilder.AlterTable("StringFieldIndexRecord", table => {
table.CreateIndex("IDX_StringFieldIndexRecord_PropertyName", "PropertyName");
table.CreateIndex("IDX_StringFieldIndexRecord_FieldIndexPartRecord_Id", "FieldIndexPartRecord_Id");
});
SchemaBuilder.AlterTable("IntegerFieldIndexRecord", table => {
table.CreateIndex("IDX_IntegerFieldIndexRecord_PropertyName", "PropertyName");
table.CreateIndex("IDX_IntegerFieldIndexRecord_FieldIndexPartRecord_Id", "FieldIndexPartRecord_Id");
});
SchemaBuilder.AlterTable("DoubleFieldIndexRecord", table => {
table.CreateIndex("IDX_DoubleFieldIndexRecord_PropertyName", "PropertyName");
table.CreateIndex("IDX_DoubleFieldIndexRecord_FieldIndexPartRecord_Id", "FieldIndexPartRecord_Id");
});
SchemaBuilder.AlterTable("DecimalFieldIndexRecord", table => {
table.CreateIndex("IDX_DecimalFieldIndexRecord_PropertyName", "PropertyName");
table.CreateIndex("IDX_DecimalFieldIndexRecord_FieldIndexPartRecord_Id", "FieldIndexPartRecord_Id");
});
}
}
}
}

View File

@@ -108,19 +108,15 @@ namespace Orchard.Projections.Services {
}
public int GetCount(int queryId, ContentPart part) {
var queryRecord = _queryRepository.Get(queryId);
var queryRecord = _queryRepository.Get(queryId) ?? throw new ArgumentException("queryId");
if (queryRecord == null) {
throw new ArgumentException("queryId");
}
// prepares tokens
// Prepare tokens.
Dictionary<string, object> tokens = new Dictionary<string, object>();
if (part != null) {
tokens.Add("Content", part.ContentItem);
}
// aggregate the result for each group query
// Aggregate the result of each filter group.
return GetContentQueries(queryRecord, Enumerable.Empty<SortCriterionRecord>(), tokens)
.Sum(contentQuery => contentQuery.Count());
}
@@ -140,13 +136,13 @@ namespace Orchard.Projections.Services {
var contentItems = new List<ContentItem>();
// prepares tokens
// Prepare tokens.
Dictionary<string, object> tokens = new Dictionary<string, object>();
if (part != null) {
tokens.Add("Content", part.ContentItem);
}
// aggregate the result for each group query
// Aggregate the result of each filter group.
foreach (var contentQuery in GetContentQueries(queryRecord, queryRecord.SortCriteria.OrderBy(sc => sc.Position), tokens)) {
contentItems.AddRange(contentQuery.Slice(skip, count));
}
@@ -155,7 +151,7 @@ namespace Orchard.Projections.Services {
return contentItems;
}
// re-executing the sorting with the cumulated groups
// Re-executing the sorting on the aggregated results.
var ids = contentItems.Select(c => c.Id).ToArray();
if (ids.Length == 0) {
@@ -164,7 +160,7 @@ namespace Orchard.Projections.Services {
var groupQuery = _contentManager.HqlQuery().Where(alias => alias.Named("ci"), x => x.InG("Id", ids));
// iterate over each sort criteria to apply the alterations to the query object
// Iterate over each sort criteria to apply the alterations to the query object.
foreach (var sortCriterion in queryRecord.SortCriteria.OrderBy(s => s.Position)) {
var tokenizedState = _tokenizer.Replace(sortCriterion.State, tokens);
var sortCriterionContext = new SortCriterionContext {
@@ -177,15 +173,17 @@ namespace Orchard.Projections.Services {
string category = sortCriterion.Category;
string type = sortCriterion.Type;
// look for the specific filter component
var descriptor = availableSortCriteria.SelectMany(x => x.Descriptors).FirstOrDefault(x => x.Category == category && x.Type == type);
// Find specific sort criterion.
var descriptor = availableSortCriteria
.SelectMany(x => x.Descriptors)
.FirstOrDefault(x => x.Category == category && x.Type == type);
// ignore unfound descriptors
// Skip if not found.
if (descriptor == null) {
continue;
}
// apply alteration
// Apply alteration.
descriptor.Sort(sortCriterionContext);
groupQuery = sortCriterionContext.Query;
@@ -194,7 +192,10 @@ namespace Orchard.Projections.Services {
return groupQuery.Slice(skip, count);
}
public IEnumerable<IHqlQuery> GetContentQueries(QueryPartRecord queryRecord, IEnumerable<SortCriterionRecord> sortCriteria, Dictionary<string, object> tokens) {
public IEnumerable<IHqlQuery> GetContentQueries(
QueryPartRecord queryRecord,
IEnumerable<SortCriterionRecord> sortCriteria,
Dictionary<string, object> tokens) {
var availableFilters = DescribeFilters().ToList();
var availableSortCriteria = DescribeSortCriteria().ToList();
@@ -204,11 +205,11 @@ namespace Orchard.Projections.Services {
var version = queryRecord.VersionScope.ToVersionOptions();
// pre-executing all groups
// Iterate over each filter group and evaluate the filters.
foreach (var group in queryRecord.FilterGroups) {
var contentQuery = _contentManager.HqlQuery().ForVersion(version);
// iterate over each filter to apply the alterations to the query object
// Iterate over each filter to apply the alterations to the query object.
foreach (var filter in group.Filters) {
var tokenizedState = _tokenizer.Replace(filter.State, tokens);
var filterContext = new FilterContext {
@@ -221,23 +222,23 @@ namespace Orchard.Projections.Services {
string category = filter.Category;
string type = filter.Type;
// look for the specific filter component
// Find specific filter.
var descriptor = availableFilters
.SelectMany(x => x.Descriptors)
.FirstOrDefault(x => x.Category == category && x.Type == type);
// ignore unfound descriptors
// Skip if not found.
if (descriptor == null) {
continue;
}
// apply alteration
// Apply alteration.
descriptor.Filter(filterContext);
contentQuery = filterContext.Query;
}
// iterate over each sort criteria to apply the alterations to the query object
// Iterate over each sort criteria to apply the alterations to the query object.
foreach (var sortCriterion in sortCriteria.OrderBy(s => s.Position)) {
var tokenizedState = _tokenizer.Replace(sortCriterion.State, tokens);
var sortCriterionContext = new SortCriterionContext {
@@ -250,23 +251,22 @@ namespace Orchard.Projections.Services {
string category = sortCriterion.Category;
string type = sortCriterion.Type;
// look for the specific filter component
// Find specific sort criterion.
var descriptor = availableSortCriteria
.SelectMany(x => x.Descriptors)
.FirstOrDefault(x => x.Category == category && x.Type == type);
// ignore unfound descriptors
// Skip if not found.
if (descriptor == null) {
continue;
}
// apply alteration
// Apply alteration.
descriptor.Sort(sortCriterionContext);
contentQuery = sortCriterionContext.Query;
}
yield return contentQuery;
}
}

View File

@@ -9,10 +9,9 @@ using StackExchange.Redis;
using System;
namespace Orchard.Redis.Caching {
[OrchardFeature("Orchard.Redis.Caching")]
[OrchardSuppressDependency("Orchard.Caching.Services.DefaultCacheStorageProvider")]
public class RedisCacheStorageProvider : Component, ICacheStorageProvider {
public class RedisCacheStorageProvider : Component, ICacheStorageProviderWithKeyPrefix {
public const string ConnectionStringKey = "Orchard.Redis.Cache";
private readonly ShellSettings _shellSettings;
@@ -61,6 +60,10 @@ namespace Orchard.Redis.Caching {
_connectionMultiplexer.KeyDeleteWithPrefix(GetLocalizedKey("*"));
}
public void Clear(string key) {
_connectionMultiplexer.KeyDeleteWithPrefix(GetLocalizedKey($"{_shellSettings.Name}:{key}"));
}
private string GetLocalizedKey(string key) {
return _shellSettings.Name + ":Cache:" + key;
}

View File

@@ -68,6 +68,22 @@
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-5.2.7.0" newVersion="5.2.7.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Numerics.Vectors" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.5.0" newVersion="4.1.5.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.4.0" newVersion="4.0.4.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<system.codedom>

View File

@@ -68,6 +68,22 @@
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-5.2.7.0" newVersion="5.2.7.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Numerics.Vectors" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.5.0" newVersion="4.1.5.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.4.0" newVersion="4.0.4.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<system.codedom>

View File

@@ -33,30 +33,25 @@ namespace Orchard.Widgets.Drivers {
() => shapeHelper.EditorTemplate(TemplateName: "Parts.Widgets.LayerPart", Model: layerPart, Prefix: Prefix))
};
if (layerPart.Id > 0)
results.Add(ContentShape("Widget_DeleteButton",
deleteButton => deleteButton));
return Combined(results.ToArray());
}
protected override DriverResult Editor(LayerPart layerPart, IUpdateModel updater, dynamic shapeHelper) {
if(updater.TryUpdateModel(layerPart, Prefix, null, null)) {
if (updater.TryUpdateModel(layerPart, Prefix, null, null)) {
if (String.IsNullOrWhiteSpace(layerPart.LayerRule)) {
layerPart.LayerRule = "true";
}
if (_widgetsService.GetLayers()
.Any(l =>
.Any(l =>
l.Id != layerPart.Id
&& String.Equals(l.Name, layerPart.Name, StringComparison.InvariantCultureIgnoreCase))) {
&& String.Equals(l.Name, layerPart.Name, StringComparison.InvariantCultureIgnoreCase))) {
updater.AddModelError("Name", T("A Layer with the same name already exists"));
}
try {
_conditionManager.Matches(layerPart.LayerRule);
}
catch (Exception e) {
} catch (Exception e) {
updater.AddModelError("Description", T("The rule is not valid: {0}", e.Message));
}
}
@@ -82,7 +77,7 @@ namespace Orchard.Widgets.Drivers {
var rule = context.Attribute(part.PartDefinition.Name, "LayerRule");
if (rule != null) {
part.LayerRule = rule;
part.LayerRule = rule;
}
}

View File

@@ -35,26 +35,22 @@ namespace Orchard.Widgets.Drivers {
() => shapeHelper.EditorTemplate(TemplateName: "Parts.Widgets.WidgetPart", Model: widgetPart, Prefix: Prefix))
};
if (widgetPart.Id > 0)
results.Add(ContentShape("Widget_DeleteButton",
deleteButton => deleteButton));
return Combined(results.ToArray());
}
protected override DriverResult Editor(WidgetPart widgetPart, IUpdateModel updater, dynamic shapeHelper) {
updater.TryUpdateModel(widgetPart, Prefix, null, null);
if(string.IsNullOrWhiteSpace(widgetPart.Title)) {
if (string.IsNullOrWhiteSpace(widgetPart.Title)) {
updater.AddModelError("Title", T("Title can't be empty."));
}
// if there is a name, ensure it's unique
if(!string.IsNullOrWhiteSpace(widgetPart.Name)) {
if (!string.IsNullOrWhiteSpace(widgetPart.Name)) {
widgetPart.Name = widgetPart.Name.ToHtmlName();
var widgets = _contentManager.Query<WidgetPart, WidgetPartRecord>().Where(x => x.Name == widgetPart.Name && x.Id != widgetPart.Id).Count();
if(widgets > 0) {
if (widgets > 0) {
updater.AddModelError("Name", T("A Widget with the same Name already exists."));
}
}

View File

@@ -207,9 +207,6 @@
<Content Include="Views\EditorTemplates\Parts.Widgets.LayerPart.cshtml" />
<Content Include="Views\EditorTemplates\Parts.Widgets.WidgetPart.cshtml" />
</ItemGroup>
<ItemGroup>
<Content Include="Views\Widget.DeleteButton.cshtml" />
</ItemGroup>
<ItemGroup>
<Content Include="Web.config" />
</ItemGroup>

View File

@@ -1,5 +1,4 @@
<Placement>
<Place Widget_DeleteButton="Sidebar:25"/>
<Place Parts_Widgets_LayerPart="Content:1"/>
<Place Parts_Widgets_WidgetPart="Content:1"/>
<Place Parts_Widgets_WidegetBagPart="Content:5"/>

View File

@@ -1,3 +0,0 @@
<fieldset class="delete-button">
<button type="submit" name="submit.Delete" value="@T("Delete")" itemprop="RemoveUrl">@T("Delete")</button>
</fieldset>

View File

@@ -68,6 +68,22 @@
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-5.2.7.0" newVersion="5.2.7.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Numerics.Vectors" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.5.0" newVersion="4.1.5.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.4.0" newVersion="4.0.4.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<system.codedom>

View File

@@ -70,6 +70,18 @@
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-5.2.7.0" newVersion="5.2.7.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.4.0" newVersion="4.0.4.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<system.codedom>

View File

@@ -72,17 +72,14 @@
<Reference Include="Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll</HintPath>
</Reference>
<Reference Include="Mono.Security, Version=4.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL">
<HintPath>..\packages\Npgsql.2.2.3\lib\net45\Mono.Security.dll</HintPath>
</Reference>
<Reference Include="MySql.Data, Version=6.7.9.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d, processorArchitecture=MSIL">
<HintPath>..\packages\MySql.Data.6.7.9\lib\net45\MySql.Data.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="Npgsql, Version=2.2.3.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7, processorArchitecture=MSIL">
<HintPath>..\packages\Npgsql.2.2.3\lib\net45\Npgsql.dll</HintPath>
<Reference Include="Npgsql, Version=4.0.17.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7, processorArchitecture=MSIL">
<HintPath>..\packages\Npgsql.4.0.17\lib\net451\Npgsql.dll</HintPath>
</Reference>
<Reference Include="NuGet.Core, Version=1.1.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Orchard.NuGet.Core.1.1.0.0\lib\NuGet.Core.dll</HintPath>
@@ -91,6 +88,9 @@
<HintPath>..\packages\Owin.1.0\lib\net40\Owin.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Buffers, Version=4.0.4.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Buffers.4.6.0\lib\net462\System.Buffers.dll</HintPath>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.ComponentModel.DataAnnotations">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
@@ -100,7 +100,23 @@
<HintPath>..\..\lib\sqlce\System.Data.SqlServerCe.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Memory, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Memory.4.6.0\lib\net462\System.Memory.dll</HintPath>
</Reference>
<Reference Include="System.Numerics" />
<Reference Include="System.Numerics.Vectors, Version=4.1.5.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Numerics.Vectors.4.6.0\lib\net462\System.Numerics.Vectors.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=6.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.6.1.0\lib\net462\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
<Reference Include="System.ServiceModel" />
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.6.0\lib\net462\System.Threading.Tasks.Extensions.dll</HintPath>
</Reference>
<Reference Include="System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll</HintPath>
</Reference>
<Reference Include="System.Web.ApplicationServices" />
<Reference Include="System.Web.DynamicData" />
<Reference Include="System.Web.Entity" />

File diff suppressed because it is too large Load Diff

View File

@@ -91,6 +91,22 @@
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-5.2.7.0" newVersion="5.2.7.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Numerics.Vectors" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.5.0" newVersion="4.1.5.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.4.0" newVersion="4.0.4.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<system.codedom>

View File

@@ -227,6 +227,26 @@
<assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.2.2.0" newVersion="4.2.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.4.0" newVersion="4.0.4.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Threading.Tasks.Extensions" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.2.1.0" newVersion="4.2.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.1.0" newVersion="6.0.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Numerics.Vectors" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.5.0" newVersion="4.1.5.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<!-- Registering Roslyn as a compiler for Dynamic Compilation. -->

View File

@@ -11,7 +11,13 @@
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net48" />
<package id="MySql.Data" version="6.7.9" targetFramework="net48" />
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net48" />
<package id="Npgsql" version="2.2.3" targetFramework="net48" />
<package id="Npgsql" version="4.0.17" targetFramework="net48" />
<package id="Orchard.NuGet.Core" version="1.1.0.0" targetFramework="net48" />
<package id="Owin" version="1.0" targetFramework="net48" />
<package id="System.Buffers" version="4.6.0" targetFramework="net48" />
<package id="System.Memory" version="4.6.0" targetFramework="net48" />
<package id="System.Numerics.Vectors" version="4.6.0" targetFramework="net48" />
<package id="System.Runtime.CompilerServices.Unsafe" version="6.1.0" targetFramework="net48" />
<package id="System.Threading.Tasks.Extensions" version="4.6.0" targetFramework="net48" />
<package id="System.ValueTuple" version="4.5.0" targetFramework="net48" />
</packages>

View File

@@ -0,0 +1,16 @@
using System;
using FluentNHibernate.Conventions;
using FluentNHibernate.Conventions.Instances;
namespace Orchard.Data.Conventions
{
[AttributeUsage(AttributeTargets.Property)]
public class LazyLoadAttribute : Attribute {
}
public class LazyLoadConvention : AttributePropertyConvention<LazyLoadAttribute> {
protected override void Apply(LazyLoadAttribute attribute, IPropertyInstance instance) {
instance.LazyLoad();
}
}
}

View File

@@ -147,6 +147,7 @@
<ItemGroup>
<Compile Include="ContentManagement\Extensions\DriverResultExtensions.cs" />
<Compile Include="ContentManagement\Handlers\CloneContentContext.cs" />
<Compile Include="Data\Conventions\LazyLoadConvention.cs" />
<Compile Include="Data\MapAsRecordAttribute.cs" />
<Compile Include="Data\Migration\Interpreters\PostgreSqlCommandInterpreter.cs" />
<Compile Include="DisplayManagement\Descriptors\ShapePlacementStrategy\DefaultPlacementParseMatchProviders.cs" />