Compare commits

...

119 Commits

Author SHA1 Message Date
Sebastiaan Janssen 2bc33e0115 Merge 2013-03-27 08:58:34 -01:00
Sebastiaan Janssen 8576d9c67e Bump version to 4.11.6 2013-03-27 08:56:30 -01:00
Shannon Deminick 9452d5fd09 adds patch for #U4-1754 and updates 2013-03-27 03:08:37 +06:00
Shannon Deminick 1f40d726de adds patch for #U4-1754 2013-03-27 02:59:42 +06:00
Shannon Deminick 2699611ba3 adds patch for #U4-1754 2013-03-27 02:58:59 +06:00
Shannon Deminick b1fa06bfe8 Removes unused code. 2013-03-26 22:02:49 +06:00
Shannon Deminick 4dc22b6ce4 Applies patch for #U4-497 for getting exceptions for xslt 2013-03-26 22:02:08 +06:00
Sebastiaan Janssen 883277125a Can't use parameters here as the query gets butchered. 2013-03-26 13:27:46 -01:00
Sebastiaan Janssen ff961abaab Actual fix for U4-1987 Error when attempting to save document type 2013-03-26 09:50:48 -01:00
Sebastiaan Janssen b2414c1ab8 Fixes U4-1987 Error when attempting to save document type 2013-03-26 09:33:08 -01:00
Stephen Roberts 0e392b398c Fixed Property order for document types with Master document types. 2013-03-14 11:08:02 +00:00
Sebastiaan Janssen 5914690ad8 Allow leading sign in number field so that negative numbers are supported 2013-03-25 10:09:02 -01:00
Shannon Deminick dbbdd16bb9 Fixes: #U4-497 2013-03-23 02:34:34 +06:00
Shannon Deminick 762cca145f Fixes: #U4-1931 - allow empty string in dictionary item. 2013-03-22 21:59:21 +06:00
Morten Christensen 5cd2d568e3 Fixes U4-1938 by actually calling and checking the Before/AfterDelete events for DataTypeDefinitions.
Backported from 32fb51f603a3
2013-03-22 11:12:32 -01:00
Sebastiaan Janssen 259fbcb8f0 Fixed U4-1934 Error in comments of config files 2013-03-18 08:50:24 -01:00
Shannon Deminick db3f21429e Fixes infinite loop bug with string trimming. 2013-03-15 11:31:11 +06:00
Shannon Deminick 04b9607741 Fixes: #U4-1916 and another issue for vdirs, added unit tests, changed UI web project to always
launch in a VDIR.
2013-03-15 08:03:19 +04:00
Shannon Deminick 5bd2571395 Merge 2013-03-12 00:01:14 +04:00
Shannon Deminick c0cd157e60 applies patch for #U4-1890 2013-03-12 00:00:55 +04:00
Sebastiaan Janssen ac2f9b172c .transformed files are auto-generated and shouldn't be under source control 2013-03-11 17:15:30 -01:00
Sebastiaan Janssen b8e4a73c3b Revert Casey's mistakenly added files 2013-03-11 15:55:35 -01:00
Shannon Deminick 68c4255a51 updates proper error handling for razor script macros 2013-03-11 21:49:04 +06:00
Shannon Deminick d07212c89b Fixed changes with new MacroErrors config and how macros are rendered so it supports all macro types and also fixes up a bit of code
in the umbraco.macro class.
2013-03-11 21:06:02 +06:00
Shannon Deminick 28c55320a1 Updates the pull request for handling macro errors.
Backports fixes for partial view macros from 6.x - U4-1488, U4-1844, U4-1730, U4-1843
2013-03-11 20:11:11 +06:00
Shannon Deminick fd58017e97 imported patches for pull request spudstuff/u4497 2013-03-11 18:49:45 +06:00
Casey Neehouse 09408b898e Merge 2013-03-08 19:38:33 +05:00
Morten Christensen d1b05332c5 Manually adds fix for U4-1869 from 6.0.3 branch 2013-03-07 20:28:13 -01:00
Casey Neehouse caad0afed8 Corrects u4-1870 - Refactor Load Content SQL to check if ID is in published list
versus using a join that can cause duplicate entries.
2013-03-07 21:00:31 +05:00
Shannon Deminick 62d365573f Back ports fixes for: #U4-1614, #U4-793 - preview working properly in mvc 2013-03-06 03:17:18 +06:00
Shannon Deminick f3b7a8a581 Fixes: #U4-1471 - issue with having NewRelic installed and some sort of conflict with shutting down
our logger.
2013-03-05 23:49:45 +06:00
Shannon Deminick a765f36d24 Adds unit tests for DynamicNode and DynamicPublishedContent, fixes both when querying for recursive properties.
Fixes: #U4-1839
2013-03-05 21:00:16 +06:00
Shannon Deminick 046da1a8ce Fixes: #U4-1824 - issue with razor dynamic node property access performance enhancements. 2013-03-05 07:06:41 +06:00
Shannon Deminick ca7abd6c78 Merge 2013-03-05 06:08:59 +06:00
Shannon Deminick 7cc0f2a514 Fixes: #U4-1819 2013-03-05 05:56:53 +06:00
Shannon Deminick 4882df43bd Back merged from 6.1 the changes required for #U4-1822 and #U4-1797 2013-03-02 01:50:53 +06:00
Sebastiaan Janssen ee2943b9fb Created branch 4.11.6 2013-03-01 06:56:34 -01:00
Sebastiaan Janssen c250fa560e Restrict the NuGet .Core dependency to the same version. 2013-02-28 15:08:30 -01:00
Sebastiaan Janssen b017e8690a Fix errors in log caused by no prevalues beind selected. 2013-02-28 09:53:57 -01:00
Shannon Deminick 8a9680e75c updated unit test logic 2013-02-27 23:13:48 +06:00
Shannon Deminick 36c66e676a Fixed unit tests 2013-02-27 22:35:27 +06:00
Sebastiaan Janssen ba530061a0 Merge 2013-02-27 13:53:14 -01:00
Sebastiaan Janssen 89ae3bc143 Add RevertToCleanInstall.bat to 4.11.5 too, it's handy. 2013-02-27 13:51:58 -01:00
Shannon Deminick 3951f59d09 Merge 2013-02-27 20:46:06 +06:00
Shannon Deminick cd8c998ebf Fixes: U4-1788 - ensures internal reserved paths and urls (that cannot be modified) are stored staticly in code,
Also fixes that the _reservedPathsCache and _reservedUrlsCache actually works, before we were doing an
object.ReferenceEquals comparison which would never have worked and it was also not thread safe.
2013-02-27 20:42:11 +06:00
Sebastiaan Janssen 2cb544591b Pull in new translations 2013-02-27 12:43:21 -01:00
Stephan 1b1b5c047c U4-1779 - Web.BaseRest supports rest extensions over multiple classes 2013-02-26 16:52:06 -01:00
Sebastiaan Janssen fa5b9e5689 Typo: U4-512 "Memebertype saved" 2013-02-26 17:29:53 -01:00
Sebastiaan Janssen c26df8da6f U4-591 Access bug in dashboard 2013-02-26 15:48:22 -01:00
Shannon Deminick 1e02d85fca Fixes: #U4-1773 (backport fix from 6.0.1) 2013-02-26 21:35:09 +06:00
Shannon Deminick d1dc2331f8 Merge 2013-02-26 21:15:31 +06:00
Shannon Deminick d503deb8c5 reverted member index config, for pre 6.1 we will still need to manually set the member fields. 2013-02-26 21:07:59 +06:00
Morten Christensen 0859b92aaf Fixes U4-1781 so Saved is called when saving a DataTypeDefinition in the backoffice 2013-02-26 13:59:08 -01:00
Sebastiaan Janssen 695d26434c U4-600 Wrong membersearch.png path in MemberSearch.ascx 2013-02-26 09:48:14 -01:00
Shannon Deminick a19de645e4 Merge 2013-02-26 00:59:06 +06:00
Shannon Deminick de9a27db10 Updates to latest Examine lib (another bug fixed) 2013-02-26 00:45:42 +06:00
Sebastiaan Janssen b6d5b7d603 Fixes U4-1776 SafeAlias culture problem 2013-02-25 13:33:51 -01:00
Sebastiaan Janssen 93d7cf4dc3 Fixes U4-1776 SafeAlias culture problem 2013-02-25 13:28:54 -01:00
Tom Fulton 0c42596dc8 Fixed: U4-1678 Saving a Media should show a SpeechBubble 2013-02-25 08:39:18 -01:00
Sebastiaan Janssen 8cf9c1ba97 Fixes: U4-1769 Dictionary Item with "Illigal" character can not be deleted 2013-02-22 14:15:22 -01:00
Shannon Deminick 7a47d63b48 Fixed remaining tests 2013-02-22 19:55:22 +06:00
Sebastiaan Janssen 4648a8c103 Fixes U4-1746 Duplicate image source (src) when inserting resized image in tiny
mce (richtext editor)
2013-02-22 11:41:01 -01:00
Sebastiaan Janssen 87947871d1 Have to add new Examine version to Web.UI as well, else the build output from
build.bat file will not be able to find it.
2013-02-22 09:57:58 -01:00
Sebastiaan Janssen 87fee572ff Enable nuget package restore for teamcity, upgrade examine dll 2013-02-22 09:47:23 -01:00
Shannon Deminick 89f7a3ec63 Clearly these files shouldn't be deleted :P 2013-02-22 06:23:03 +06:00
Shannon Deminick 7092a9ccbb Reverted the macro engines and web proj's, it would seem as though 4.x on the build server hasn't
been configured for nuget package restor (or something like that)
2013-02-22 06:05:10 +06:00
Shannon Deminick e9ea9b5e1b Updates DynamicNode with some performance enhancements especially around things like HasProperty and GetProperty.
Also when it returned children, it was actually re-iterating over all children (going to the repo to find them even though
they were already resolved).
2013-02-22 05:44:17 +06:00
Shannon Deminick fd1efb29ec Fixes issue when saving settings to web.config, not sure how this error never came up before. Was missing a "\" between the path and "web.config".
Using Path.Combine is much safer than just string.Concat!
2013-02-22 04:45:20 +06:00
Shannon Deminick cf4781153e Fixes: #U4-873, #U4-888 - fixes media sorting in razor + MVC. Updates Nunit libs and Examine lib. Adds unit tests to
support new sorting fixes. Fixes up a few other issues with the legacy ExamineBackedMedia class, it will now handle all data
stored in Examine. Simplifies the Examine internal index sets to include all data.
2013-02-22 04:12:24 +06:00
Shannon Deminick ebed142cd5 Another fix for file sys test 2013-02-21 23:47:16 +06:00
Shannon Deminick d162aba14a Fix for file system test 2013-02-21 23:07:37 +06:00
Shannon Deminick ec075f5807 Merge 2013-02-21 22:38:38 +06:00
Sebastiaan Janssen dca90e6316 Merge 2013-02-21 15:09:20 -01:00
Sebastiaan Janssen df31fafec5 Update en_us umbracoembed file, had the wrong content 2013-02-21 15:06:37 -01:00
Shannon Deminick 828dc64035 Backports fix for FullpathToRoot in GlobalSettings... not sure how some unit tests have been working this whole time.
Changes UseLegacySchema default value to false... was set to true!?
un-ignores LookupByNiceUrl tests and still ensures it doesn't require a database to test by passing in an optional parameter
to LookupByNiceUrl to specify if we want to include domain lookups or not (default is true)
2013-02-21 22:02:56 +06:00
Shannon Deminick 0b74164a8e New base test class for anything relating to published content/media, un-ignores strongly typed tests. 2013-02-21 21:01:00 +06:00
Shannon Deminick 62be1b1267 un-ignores Can_Get_File_Dates in AbstractFileSystemTests... not sure why it was ignored seems to work properly. 2013-02-21 20:42:49 +06:00
Sebastiaan Janssen 85ae7e764f Merge 2013-02-21 08:52:48 -01:00
Sebastiaan Janssen 3daa624627 Fixes U4-1668 4.11.4 NiceUrl property on dynamicnode does not work until a
property has been requested from the dynamic node
2013-02-21 08:52:23 -01:00
Shannon Deminick d8af1aaf7b Changed logging in unit tests to filter out things we don't need to see 2013-02-21 03:13:16 +06:00
Shannon Deminick f2d105d8b9 Fixed #U4-814 and got all possible unit tests that were not working for DynamicNode but were working for
DynamicPublishedContent working. And fixed up the DynamicPublishedContent unit tests as these weren't working at all...
but seemed to say they did on the build server. strange.
2013-02-21 05:44:44 +06:00
Stephan 5b0a8c0668 Tests - fix build broken by back-porting 6.x code 2013-02-20 10:12:41 -01:00
Stephan c3ccf3a609 Tests - cleanup settings handling for more reliable tests 2013-02-19 18:01:52 -01:00
Stephan 60bbede408 U4-1441 - fix, fix and fix! 2013-02-19 17:49:49 -01:00
Stephan 1d0299af89 U4-1611 - bugfix 2013-02-19 13:58:16 -01:00
Shannon Deminick c2d0e255df Fixes: #U4-1537 2013-02-19 20:17:17 +06:00
Shannon Deminick 005d3e7d64 Removes area routing for local surface controllers and BeginUmbracoForm, adds strongly typed Html.Action<T>
method for rendering SurfaceController child actions regardless of area (so you don't have to specify).
All relates to #U4-1727
2013-02-19 06:19:26 +06:00
Shannon Deminick 12f8638223 Fixes: #U4-1727 2013-02-19 06:18:51 +06:00
Shannon Deminick e3f9e8c842 Fixes: #U4-552 2013-02-19 03:42:19 +06:00
Shannon Deminick a475f72d50 Fixes: #U4-1695 2013-02-19 02:25:57 +06:00
Shannon Deminick a559ef9f90 Fixes: #U4-1732 2013-02-19 00:59:21 +06:00
Sebastiaan Janssen be83302b14 Fixes U4-1451 2013-02-18 13:22:12 -01:00
Sebastiaan Janssen 83d7ea9ef1 Ignoring wrong unit test for now 2013-02-18 12:53:15 -01:00
Sebastiaan Janssen 95024442de Copy the umbracoSettings for PublishMediaStoreTests as well 2013-02-18 12:22:53 -01:00
Sebastiaan Janssen 69f54b5f22 Copy the umbracoSettings for LibraryTests as well 2013-02-18 11:57:58 -01:00
Sebastiaan Janssen 3404f95b2e Forgot one trailing slash in previous commit 2013-02-18 11:42:45 -01:00
Sebastiaan Janssen e56738481b Adding trailing slash to failing routing tests.
The issue with these tests might again be because of the UmbracoSettings file, which has the trailing slash setting. But with the settings being reset after teardown the tests were still failing, so made these minor corrections which shoudl correspond to the default setting.
2013-02-18 11:38:07 -01:00
Sebastiaan Janssen cb59dc353b Update version to 4.11.5 2013-02-18 10:31:43 -01:00
Sebastiaan Janssen d1b75eac08 Update wrong config path in unit tests 2013-02-18 10:31:17 -01:00
Sebastiaan Janssen 8fabd4e4ed Merge 2013-02-15 12:05:46 -01:00
Sebastiaan Janssen 564d92bed7 Possible fix for TeamCity 2013-02-15 12:05:25 -01:00
Shannon Deminick 95f103ccc2 Merge 2013-02-15 18:55:50 +06:00
Stephan 0ace2fdae7 U4-1611 - fix xpath special chars escaping issues in published content store 2013-02-14 16:31:45 -01:00
Stephan 5da3541584 U4-1441 - bugfix 2013-02-14 16:27:27 -01:00
Shannon Deminick ef86d2f1f1 Manually applies patch for #U4-1718 2013-02-14 23:26:29 +06:00
Sebastiaan Janssen a10a6d1af8 Need to wrap the login javascript in a placeholder for Concorde 2013-02-14 09:06:15 -01:00
Stephan 6d87174cc1 U4-1441 - improve logging 2013-02-08 07:54:16 -01:00
Stephan 9af9c3fe77 U4-1441 - change trySkipIisCustomError config key 2013-02-08 07:36:35 -01:00
Stephan 9cedf5da4c U4-1441 - make trySkipIisCustomError value a setting 2013-02-08 08:08:36 -01:00
Shannon Deminick 906d675dca Merge 2013-02-07 02:09:32 +06:00
Shannon Deminick f1b3105202 Patch for #U4-1653 - media library cache refresh issue 2013-02-06 20:56:47 +06:00
Shannon Deminick 3ebb213916 Patches installer issue. 2013-02-06 19:18:42 +06:00
Stephan a65ca205de U4-1441 - fix issue with IIS taking over custom errors 2013-02-05 16:29:10 -01:00
Stephan 3e1120612b Update version number 2013-02-04 12:00:58 -01:00
Stephan 8d06d39a62 Create branch for 4.11.5 2013-02-04 11:59:30 -01:00
Stephan da7fea47c6 U4-1441 - refactor (fix) legacy NotFoundHandler support 2013-02-03 14:34:04 -01:00
Shannon Deminick f2442b25f6 Close 4.11.4 branch 2013-02-01 19:25:12 +06:00
Sebastiaan Janssen 300d3ff09b Added tag Release-4.11.4 for changeset e02f5aebb87e 2013-02-01 08:41:26 -01:00
Max Rotvel 4321c8d24e Fix part of U4-1355 by making umbracoembed translatable and supply da lang files 2013-01-15 14:33:25 -01:00
175 changed files with 7555 additions and 15086 deletions
+1
View File
@@ -37,6 +37,7 @@ src\Umbraco.Web.UI\macroScripts\*
src\Umbraco.Web.UI\xslt\*
src\Umbraco.Web.UI\images\*
src\Umbraco.Web.UI\scripts\*
src\Umbraco.Web.UI\Web.*.config.transformed
umbraco\presentation\umbraco\plugins\uComponents\uComponentsInstaller.ascx
umbraco\presentation\packages\uComponents\MultiNodePicker\CustomTreeService.asmx
+1
View File
@@ -26,3 +26,4 @@ baa44b79cf90a60631e38e11f771c200b08a4583 Release-4.11.3
e4d0c7e740555d8707ba71f55a623a3f96da8e65 Release-4.11.3.1
e4d0c7e740555d8707ba71f55a623a3f96da8e65 Release-4.11.3.1
0000000000000000000000000000000000000000 Release-4.11.3.1
e02f5aebb87e3f07d27376647756caa9762931d8 Release-4.11.4
+1 -1
View File
@@ -1,5 +1,5 @@
@ECHO OFF
set version=4.11.4
set version=4.11.6
%windir%\Microsoft.NET\Framework\v4.0.30319\msbuild.exe "Build.proj" /p:BUILD_RELEASE=%version%
echo This file is only here so that the containing folder will be included in the NuGet package, it is safe to delete. > .\_BuildOutput\WebApp\App_Code\dummy.txt
+1 -1
View File
@@ -15,7 +15,7 @@
<language>en-US</language>
<tags>umbraco</tags>
<dependencies>
<dependency id="UmbracoCms.Core" version="$version$" />
<dependency id="UmbracoCms.Core" version="[$version$]" />
</dependencies>
</metadata>
<files>
+128
View File
@@ -0,0 +1,128 @@
@ECHO OFF
:choice
set /P c=WARNING! Are you sure you want to continue, this will remove all package files, view files, sqlce database, etc... Press 'Y' to auto-remove all files/folders, 'N' to cancel or 'C' to prompt for each folder removal?
if /I "%c%" EQU "C" goto :prompt
if /I "%c%" EQU "Y" goto :auto
if /I "%c%" EQU "N" goto :exit
goto :choice
:prompt
echo Current folder: %CD%
echo Removing sqlce database
del ..\src\Umbraco.Web.UI\App_Data\Umbraco.sdf
echo Resetting installedPackages.config
echo ^<?xml version="1.0" encoding="utf-8"?^>^<packages^>^</packages^> >..\src\Umbraco.Web.UI\App_Data\packages\installed\installedPackages.config
echo Removing plugin cache files
del ..\src\Umbraco.Web.UI\App_Data\TEMP\PluginCache\*.*
echo Removing cache files and examine index
del ..\src\Umbraco.Web.UI\App_Data\TEMP\*.*
echo Removing log files
del ..\src\Umbraco.Web.UI\App_Data\Logs\*.*
echo Removing packages
del ..\src\Umbraco.Web.UI\App_Data\packages\*.*
echo Removing previews
del ..\src\Umbraco.Web.UI\App_Data\preview\*.*
echo Removing app code files (typically added by starterkits)
del ..\src\Umbraco.Web.UI\App_Code\*.*
echo Removing xslt files
del ..\src\Umbraco.Web.UI\xslt\*.*
echo Removing user control files
del ..\src\Umbraco.Web.UI\UserControls\*.*
echo Removing masterpage files
del ..\src\Umbraco.Web.UI\masterpages\*.*
echo Removing view files
del ..\src\Umbraco.Web.UI\Views\*.*
echo Removing razor files
del ..\src\Umbraco.Web.UI\macroScripts\*.*
echo Removing media files
del ..\src\Umbraco.Web.UI\media\*.*
echo Removing script files
del ..\src\Umbraco.Web.UI\scripts\*.*
echo Removing css files
del ..\src\Umbraco.Web.UI\css\*.*
echo "Umbraco install reverted to clean install"
pause
exit
:auto
echo Current folder: %CD%
echo Removing sqlce database
del ..\src\Umbraco.Web.UI\App_Data\Umbraco.sdf
echo Resetting installedPackages.config
echo ^<?xml version="1.0" encoding="utf-8"?^>^<packages^>^</packages^> >..\src\Umbraco.Web.UI\App_Data\packages\installed\installedPackages.config
echo Removing plugin cache files
FOR %%A IN (..\src\Umbraco.Web.UI\App_Data\TEMP\PluginCache\*.*) DO DEL %%A
echo Removing cache files and examine index
FOR %%A IN (..\src\Umbraco.Web.UI\App_Data\TEMP\*.*) DO DEL %%A
echo Removing log files
FOR %%A IN (..\src\Umbraco.Web.UI\App_Data\Logs\*.*) DO DEL %%A
echo Removing packages
FOR %%A IN (..\src\Umbraco.Web.UI\App_Data\packages\*.*) DO DEL %%A
echo Removing previews
FOR %%A IN (..\src\Umbraco.Web.UI\App_Data\preview\*.*) DO DEL %%A
echo Removing app code files (typically added by starterkits)
FOR %%A IN (..\src\Umbraco.Web.UI\App_Code\*.*) DO DEL %%A
echo Removing xslt files
FOR %%A IN (..\src\Umbraco.Web.UI\xslt\*.*) DO DEL %%A
echo Removing masterpage files
FOR %%A IN (..\src\Umbraco.Web.UI\masterpages\*.*) DO DEL %%A
echo Removing user control files
FOR %%A IN (..\src\Umbraco.Web.UI\usercontrols\*.*) DO DEL %%A
echo Removing view files
FOR %%A IN (..\src\Umbraco.Web.UI\Views\*.*) DO DEL %%A
echo Removing razor files
FOR %%A IN (..\src\Umbraco.Web.UI\macroScripts\*.*) DO DEL %%A
echo Removing media files
FOR %%A IN (..\src\Umbraco.Web.UI\media\*.*) DO DEL %%A
echo Removing script files
FOR %%A IN (..\src\Umbraco.Web.UI\scripts\*.*) DO DEL %%A
echo Removing css files
FOR %%A IN (..\src\Umbraco.Web.UI\css\*.*) DO DEL %%A
echo "Umbraco install reverted to clean install"
pause
exit
:exit
exit
BIN
View File
Binary file not shown.
+6
View File
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<solution>
<add key="disableSourceControlIntegration" value="true" />
</solution>
</configuration>
Binary file not shown.
+152
View File
@@ -0,0 +1,152 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">$(MSBuildProjectDirectory)\..\</SolutionDir>
<!-- Enable the restore command to run before builds -->
<RestorePackages Condition=" '$(RestorePackages)' == '' ">false</RestorePackages>
<!-- Property that enables building a package from a project -->
<BuildPackage Condition=" '$(BuildPackage)' == '' ">false</BuildPackage>
<!-- Determines if package restore consent is required to restore packages -->
<RequireRestoreConsent Condition=" '$(RequireRestoreConsent)' != 'false' ">true</RequireRestoreConsent>
<!-- Download NuGet.exe if it does not already exist -->
<DownloadNuGetExe Condition=" '$(DownloadNuGetExe)' == '' ">false</DownloadNuGetExe>
</PropertyGroup>
<ItemGroup Condition=" '$(PackageSources)' == '' ">
<!-- Package sources used to restore packages. By default will used the registered sources under %APPDATA%\NuGet\NuGet.Config -->
<!--
<PackageSource Include="https://nuget.org/api/v2/" />
<PackageSource Include="https://my-nuget-source/nuget/" />
-->
<PackageSource Include="https://nuget.org/api/v2/" />
<PackageSource Include="http://www.myget.org/F/umbracocore/" />
</ItemGroup>
<PropertyGroup Condition=" '$(OS)' == 'Windows_NT'">
<!-- Windows specific commands -->
<NuGetToolsPath>$([System.IO.Path]::Combine($(SolutionDir), ".nuget"))</NuGetToolsPath>
<PackagesConfig>$([System.IO.Path]::Combine($(ProjectDir), "packages.config"))</PackagesConfig>
</PropertyGroup>
<PropertyGroup Condition=" '$(OS)' != 'Windows_NT'">
<!-- We need to launch nuget.exe with the mono command if we're not on windows -->
<NuGetToolsPath>$(SolutionDir).nuget</NuGetToolsPath>
<PackagesConfig>packages.config</PackagesConfig>
</PropertyGroup>
<PropertyGroup>
<!-- NuGet command -->
<NuGetExePath Condition=" '$(NuGetExePath)' == '' ">$(NuGetToolsPath)\nuget.exe</NuGetExePath>
<PackageSources Condition=" $(PackageSources) == '' ">@(PackageSource)</PackageSources>
<NuGetCommand Condition=" '$(OS)' == 'Windows_NT'">"$(NuGetExePath)"</NuGetCommand>
<NuGetCommand Condition=" '$(OS)' != 'Windows_NT' ">mono --runtime=v4.0.30319 $(NuGetExePath)</NuGetCommand>
<PackageOutputDir Condition="$(PackageOutputDir) == ''">$(TargetDir.Trim('\\'))</PackageOutputDir>
<RequireConsentSwitch Condition=" $(RequireRestoreConsent) == 'true' ">-RequireConsent</RequireConsentSwitch>
<!-- Commands -->
<RestoreCommand>$(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" $(RequireConsentSwitch) -solutionDir "$(SolutionDir) "</RestoreCommand>
<BuildCommand>$(NuGetCommand) pack "$(ProjectPath)" -p Configuration=$(Configuration) -o "$(PackageOutputDir)" -symbols</BuildCommand>
<!-- We need to ensure packages are restored prior to assembly resolve -->
<ResolveReferencesDependsOn Condition="$(RestorePackages) == 'true'">
RestorePackages;
$(ResolveReferencesDependsOn);
</ResolveReferencesDependsOn>
<!-- Make the build depend on restore packages -->
<BuildDependsOn Condition="$(BuildPackage) == 'true'">
$(BuildDependsOn);
BuildPackage;
</BuildDependsOn>
</PropertyGroup>
<Target Name="CheckPrerequisites">
<!-- Raise an error if we're unable to locate nuget.exe -->
<Error Condition="'$(DownloadNuGetExe)' != 'true' AND !Exists('$(NuGetExePath)')" Text="Unable to locate '$(NuGetExePath)'" />
<SetEnvironmentVariable EnvKey="VisualStudioVersion" EnvValue="$(VisualStudioVersion)" Condition=" '$(VisualStudioVersion)' != '' AND '$(OS)' == 'Windows_NT' " />
<!--
Take advantage of MsBuild's build dependency tracking to make sure that we only ever download nuget.exe once.
This effectively acts as a lock that makes sure that the download operation will only happen once and all
parallel builds will have to wait for it to complete.
-->
<MsBuild Targets="_DownloadNuGet" Projects="$(MSBuildThisFileFullPath)" Properties="Configuration=NOT_IMPORTANT" />
</Target>
<Target Name="_DownloadNuGet">
<DownloadNuGet OutputFilename="$(NuGetExePath)" Condition=" '$(DownloadNuGetExe)' == 'true' AND !Exists('$(NuGetExePath)')" />
</Target>
<Target Name="RestorePackages" DependsOnTargets="CheckPrerequisites">
<Exec Command="$(RestoreCommand)"
Condition="'$(OS)' != 'Windows_NT' And Exists('$(PackagesConfig)')" />
<Exec Command="$(RestoreCommand)"
LogStandardErrorAsError="true"
Condition="'$(OS)' == 'Windows_NT' And Exists('$(PackagesConfig)')" />
</Target>
<Target Name="BuildPackage" DependsOnTargets="CheckPrerequisites">
<Exec Command="$(BuildCommand)"
Condition=" '$(OS)' != 'Windows_NT' " />
<Exec Command="$(BuildCommand)"
LogStandardErrorAsError="true"
Condition=" '$(OS)' == 'Windows_NT' " />
</Target>
<UsingTask TaskName="DownloadNuGet" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
<ParameterGroup>
<OutputFilename ParameterType="System.String" Required="true" />
</ParameterGroup>
<Task>
<Reference Include="System.Core" />
<Using Namespace="System" />
<Using Namespace="System.IO" />
<Using Namespace="System.Net" />
<Using Namespace="Microsoft.Build.Framework" />
<Using Namespace="Microsoft.Build.Utilities" />
<Code Type="Fragment" Language="cs">
<![CDATA[
try {
OutputFilename = Path.GetFullPath(OutputFilename);
Log.LogMessage("Downloading latest version of NuGet.exe...");
WebClient webClient = new WebClient();
webClient.DownloadFile("https://nuget.org/nuget.exe", OutputFilename);
return true;
}
catch (Exception ex) {
Log.LogErrorFromException(ex);
return false;
}
]]>
</Code>
</Task>
</UsingTask>
<UsingTask TaskName="SetEnvironmentVariable" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
<ParameterGroup>
<EnvKey ParameterType="System.String" Required="true" />
<EnvValue ParameterType="System.String" Required="true" />
</ParameterGroup>
<Task>
<Using Namespace="System" />
<Code Type="Fragment" Language="cs">
<![CDATA[
try {
Environment.SetEnvironmentVariable(EnvKey, EnvValue, System.EnvironmentVariableTarget.Process);
}
catch {
}
]]>
</Code>
</Task>
</UsingTask>
</Project>
@@ -28,14 +28,31 @@ namespace Umbraco.Core.Configuration
#region Private static fields
// CURRENT UMBRACO VERSION ID
private const string CurrentUmbracoVersion = "4.11.4";
private const string CurrentUmbracoVersion = "4.11.6";
private static string _reservedUrlsCache;
private static readonly object Locker = new object();
//make this volatile so that we can ensure thread safety with a double check lock
private static volatile string _reservedUrlsCache;
private static string _reservedPathsCache;
private static StartsWithContainer _reservedList = new StartsWithContainer();
private static string _reservedPaths;
private static string _reservedUrls;
//ensure the built on (non-changeable) reserved paths are there at all times
private const string StaticReservedPaths = "~/app_plugins/,~/install/,";
private const string StaticReservedUrls = "~/config/splashes/booting.aspx,~/install/default.aspx,~/config/splashes/noNodes.aspx,~/VSEnterpriseHelper.axd,";
#endregion
/// <summary>
/// used for unit tests
/// </summary>
internal static void ResetCache()
{
_reservedUrlsCache = null;
_reservedPaths = null;
_reservedUrls = null;
}
/// <summary>
/// Gets the reserved urls from web.config.
/// </summary>
@@ -43,11 +60,19 @@ namespace Umbraco.Core.Configuration
public static string ReservedUrls
{
get
{
return ConfigurationManager.AppSettings.ContainsKey("umbracoReservedUrls")
? ConfigurationManager.AppSettings["umbracoReservedUrls"]
: string.Empty;
{
if (_reservedUrls == null)
{
var urls = ConfigurationManager.AppSettings.ContainsKey("umbracoReservedUrls")
? ConfigurationManager.AppSettings["umbracoReservedUrls"]
: string.Empty;
//ensure the built on (non-changeable) reserved paths are there at all times
_reservedUrls = StaticReservedUrls + urls;
}
return _reservedUrls;
}
internal set { _reservedUrls = value; }
}
/// <summary>
@@ -58,10 +83,25 @@ namespace Umbraco.Core.Configuration
{
get
{
return ConfigurationManager.AppSettings.ContainsKey("umbracoReservedPaths")
? ConfigurationManager.AppSettings["umbracoReservedPaths"]
: string.Empty;
if (_reservedPaths == null)
{
var reservedPaths = StaticReservedPaths;
//always add the umbraco path to the list
if (ConfigurationManager.AppSettings.ContainsKey("umbracoPath")
&& !ConfigurationManager.AppSettings["umbracoPath"].IsNullOrWhiteSpace())
{
reservedPaths += ConfigurationManager.AppSettings["umbracoPath"].EnsureEndsWith(',');
}
var allPaths = ConfigurationManager.AppSettings.ContainsKey("umbracoReservedPaths")
? ConfigurationManager.AppSettings["umbracoReservedPaths"]
: string.Empty;
_reservedPaths = reservedPaths + allPaths;
}
return _reservedPaths;
}
internal set { _reservedPaths = value; }
}
/// <summary>
@@ -116,6 +156,9 @@ namespace Umbraco.Core.Configuration
/// This will return the MVC area that we will route all custom routes through like surface controllers, etc...
/// We will use the 'Path' (default ~/umbraco) to create it but since it cannot contain '/' and people may specify a path of ~/asdf/asdf/admin
/// we will convert the '/' to '-' and use that as the path. its a bit lame but will work.
///
/// We also make sure that the virtual directory (SystemDirectories.Root) is stripped off first, otherwise we'd end up with something
/// like "MyVirtualDirectory-Umbraco" instead of just "Umbraco".
/// </remarks>
internal static string UmbracoMvcArea
{
@@ -125,7 +168,7 @@ namespace Umbraco.Core.Configuration
{
throw new InvalidOperationException("Cannot create an MVC Area path without the umbracoPath specified");
}
return Path.TrimStart('~').TrimStart('/').Replace('/', '-').Trim();
return Path.TrimStart(SystemDirectories.Root).TrimStart('~').TrimStart('/').Replace('/', '-').Trim().ToLower();
}
}
@@ -191,16 +234,16 @@ namespace Umbraco.Core.Configuration
{
var webConfig = new WebConfigurationFileMap();
var vDirs = webConfig.VirtualDirectories;
var vDir = FullpathToRoot;
var physicalPathToRoot = FullpathToRoot;
foreach (VirtualDirectoryMapping v in webConfig.VirtualDirectories)
{
if (v.IsAppRoot)
{
vDir = v.PhysicalDirectory;
physicalPathToRoot = v.PhysicalDirectory;
}
}
string fileName = String.Concat(vDir, "web.config");
string fileName = System.IO.Path.Combine(physicalPathToRoot, "web.config");
var xml = XDocument.Load(fileName);
var appSettings = xml.Root.Descendants("appSettings").Single();
@@ -221,7 +264,7 @@ namespace Umbraco.Core.Configuration
/// <value>The fullpath to root.</value>
public static string FullpathToRoot
{
get { return HttpRuntime.AppDomainAppPath; }
get { return IOHelper.GetRootDirectorySafe(); }
}
/// <summary>
@@ -581,38 +624,42 @@ namespace Umbraco.Core.Configuration
/// </returns>
public static bool IsReservedPathOrUrl(string url)
{
// check if GlobalSettings.ReservedPaths and GlobalSettings.ReservedUrls are unchanged
if (!object.ReferenceEquals(_reservedPathsCache, GlobalSettings.ReservedPaths)
|| !object.ReferenceEquals(_reservedUrlsCache, GlobalSettings.ReservedUrls))
if (_reservedUrlsCache == null)
{
// store references to strings to determine changes
_reservedPathsCache = GlobalSettings.ReservedPaths;
_reservedUrlsCache = GlobalSettings.ReservedUrls;
string _root = SystemDirectories.Root.Trim().ToLower();
// add URLs and paths to a new list
StartsWithContainer _newReservedList = new StartsWithContainer();
foreach (string reservedUrl in _reservedUrlsCache.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries))
lock (Locker)
{
//resolves the url to support tilde chars
string reservedUrlTrimmed = IOHelper.ResolveUrl(reservedUrl).Trim().ToLower();
if (reservedUrlTrimmed.Length > 0)
_newReservedList.Add(reservedUrlTrimmed);
if (_reservedUrlsCache == null)
{
// store references to strings to determine changes
_reservedPathsCache = GlobalSettings.ReservedPaths;
_reservedUrlsCache = GlobalSettings.ReservedUrls;
string _root = SystemDirectories.Root.Trim().ToLower();
// add URLs and paths to a new list
StartsWithContainer _newReservedList = new StartsWithContainer();
foreach (string reservedUrl in _reservedUrlsCache.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries))
{
//resolves the url to support tilde chars
string reservedUrlTrimmed = IOHelper.ResolveUrl(reservedUrl).Trim().ToLower();
if (reservedUrlTrimmed.Length > 0)
_newReservedList.Add(reservedUrlTrimmed);
}
foreach (string reservedPath in _reservedPathsCache.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries))
{
bool trimEnd = !reservedPath.EndsWith("/");
//resolves the url to support tilde chars
string reservedPathTrimmed = IOHelper.ResolveUrl(reservedPath).Trim().ToLower();
if (reservedPathTrimmed.Length > 0)
_newReservedList.Add(reservedPathTrimmed + (reservedPathTrimmed.EndsWith("/") ? "" : "/"));
}
// use the new list from now on
_reservedList = _newReservedList;
}
}
foreach (string reservedPath in _reservedPathsCache.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries))
{
bool trimEnd = !reservedPath.EndsWith("/");
//resolves the url to support tilde chars
string reservedPathTrimmed = IOHelper.ResolveUrl(reservedPath).Trim().ToLower();
if (reservedPathTrimmed.Length > 0)
_newReservedList.Add(reservedPathTrimmed + (reservedPathTrimmed.EndsWith("/") ? "" : "/"));
}
// use the new list from now on
_reservedList = _newReservedList;
}
//The url should be cleaned up before checking:
+126 -97
View File
@@ -25,7 +25,31 @@ namespace Umbraco.Core.Configuration
/// </summary>
internal class UmbracoSettings
{
/// <summary>
private static bool GetKeyValue(string key, bool defaultValue)
{
bool value;
string stringValue = GetKey(key);
if (string.IsNullOrWhiteSpace(stringValue))
return defaultValue;
if (bool.TryParse(stringValue, out value))
return value;
return defaultValue;
}
private static int GetKeyValue(string key, int defaultValue)
{
int value;
string stringValue = GetKey(key);
if (string.IsNullOrWhiteSpace(stringValue))
return defaultValue;
if (int.TryParse(stringValue, out value))
return value;
return defaultValue;
}
/// <summary>
/// Used in unit testing to reset all config items that were set with property setters (i.e. did not come from config)
/// </summary>
internal static void ResetSetters()
@@ -35,6 +59,7 @@ namespace Umbraco.Core.Configuration
_useLegacySchema = null;
_useDomainPrefixes = null;
_umbracoLibraryCacheDuration = null;
_trySkipIisCustomErrors = null;
}
internal const string TempFriendlyXmlChildContainerNodename = ""; // "children";
@@ -125,11 +150,32 @@ namespace Umbraco.Core.Configuration
{
EnsureSettingsDocument();
string attrName = null;
var pos = key.IndexOf('@');
if (pos > 0)
{
attrName = key.Substring(pos + 1);
key = key.Substring(0, pos - 1);
}
var node = UmbracoSettingsXmlDoc.DocumentElement.SelectSingleNode(key);
if (node == null || node.FirstChild == null || node.FirstChild.Value == null)
return string.Empty;
return node.FirstChild.Value;
}
if (node == null)
return string.Empty;
if (pos < 0)
{
if (node.FirstChild == null || node.FirstChild.Value == null)
return string.Empty;
return node.FirstChild.Value;
}
else
{
var attr = node.Attributes[attrName];
if (attr == null)
return string.Empty;
return attr.Value;
}
}
/// <summary>
/// Gets a value indicating whether the media library will create new directories in the /media directory.
@@ -202,6 +248,7 @@ namespace Umbraco.Core.Configuration
return value != null ? value.Attributes["assembly"].Value : "";
}
}
/// <summary>
/// Gets the type of an external logger that can be used to store log items in 3rd party systems
/// </summary>
@@ -350,24 +397,13 @@ namespace Umbraco.Core.Configuration
{
get
{
try
{
if (_useDomainPrefixes.HasValue)
return _useDomainPrefixes.Value;
bool result;
if (bool.TryParse(GetKey("/settings/requestHandler/useDomainPrefixes"), out result))
return result;
return false;
}
catch
{
return false;
}
// default: false
return _useDomainPrefixes ?? GetKeyValue("/settings/requestHandler/useDomainPrefixes", false);
}
// for unit tests only
internal set
{
_useDomainPrefixes = value;
// for unit tests only
_useDomainPrefixes = value;
}
}
@@ -381,31 +417,14 @@ namespace Umbraco.Core.Configuration
{
get
{
try
{
if (GlobalSettings.UseDirectoryUrls)
{
if (_addTrailingSlash.HasValue)
return _addTrailingSlash.Value;
bool result;
if (bool.TryParse(GetKey("/settings/requestHandler/addTrailingSlash"), out result))
return result;
return false;
}
else
{
return false;
}
}
catch
{
return false;
}
// default: false
return GlobalSettings.UseDirectoryUrls
&& (_addTrailingSlash ?? GetKeyValue("/settings/requestHandler/addTrailingSlash", false));
}
// for unit tests only
internal set
{
_addTrailingSlash = value;
// for unit tests only
_addTrailingSlash = value;
}
}
@@ -622,31 +641,34 @@ namespace Umbraco.Core.Configuration
{
get
{
if (_forceSafeAliases.HasValue)
return _forceSafeAliases.Value;
string forceSafeAlias = GetKey("/settings/content/ForceSafeAliases");
if (String.IsNullOrEmpty(forceSafeAlias))
return true;
else
{
try
{
return bool.Parse(forceSafeAlias);
}
catch
{
return true;
}
}
// default: true
return _forceSafeAliases ?? GetKeyValue("/settings/content/ForceSafeAliases", true);
}
internal set
{
//used for unit testing
// used for unit testing
_forceSafeAliases = value;
}
}
private static bool? _trySkipIisCustomErrors;
/// <summary>
/// Gets or sets a value indicating where to try to skip IIS custom errors.
/// </summary>
public static bool TrySkipIisCustomErrors
{
get
{
// default: false
return _trySkipIisCustomErrors ?? GetKeyValue("/settings/web.routing/@trySkipIisCustomErrors", false);
}
internal set
{
// used for unit testing
_trySkipIisCustomErrors = value;
}
}
/// <summary>
/// Gets the allowed image file types.
@@ -676,26 +698,14 @@ namespace Umbraco.Core.Configuration
{
get
{
if (_umbracoLibraryCacheDuration.HasValue)
return _umbracoLibraryCacheDuration.Value;
string libraryCacheDuration = GetKey("/settings/content/UmbracoLibraryCacheDuration");
if (String.IsNullOrEmpty(libraryCacheDuration))
return 1800;
else
{
try
{
return int.Parse(libraryCacheDuration);
}
catch
{
return 1800;
}
}
// default: 1800
return _umbracoLibraryCacheDuration ?? GetKeyValue("/settings/content/UmbracoLibraryCacheDuration", 1800);
}
internal set { _umbracoLibraryCacheDuration = value; }
internal set
{
// for unit tests only
_umbracoLibraryCacheDuration = value;
}
}
/// <summary>
@@ -1051,27 +1061,12 @@ namespace Umbraco.Core.Configuration
{
get
{
try
{
if (_useLegacySchema.HasValue)
return _useLegacySchema.Value;
string value = GetKey("/settings/content/UseLegacyXmlSchema");
bool result;
if (!string.IsNullOrEmpty(value) && bool.TryParse(value, out result))
return result;
return true;
}
catch (Exception)
{
//default. TODO: When we change this to a real config section we won't have to worry about parse errors
// and should handle defaults with unit tests properly.
return false;
}
// default: true
return _useLegacySchema ?? GetKeyValue("/settings/content/UseLegacyXmlSchema", false);
}
internal set
{
//used for unit testing
// used for unit testing
_useLegacySchema = value;
}
}
@@ -1220,6 +1215,40 @@ namespace Umbraco.Core.Configuration
}
}
private static MacroErrorBehaviour? _macroErrorBehaviour;
/// <summary>
/// This configuration setting defines how to handle macro errors:
/// - Inline - Show error within macro as text (default and current Umbraco 'normal' behavior)
/// - Silent - Suppress error and hide macro
/// - Throw - Throw an exception and invoke the global error handler (if one is defined, if not you'll get a YSOD)
/// </summary>
/// <value>MacroErrorBehaviour enum defining how to handle macro errors.</value>
public static MacroErrorBehaviour MacroErrorBehaviour
{
get
{
if (_macroErrorBehaviour == null)
{
try
{
var behaviour = MacroErrorBehaviour.Inline;
var value = GetKey("/settings/content/MacroErrors");
if (value != null)
{
Enum<MacroErrorBehaviour>.TryParse(value, true, out behaviour);
}
_macroErrorBehaviour = behaviour;
}
catch (Exception ex)
{
LogHelper.Error<UmbracoSettings>("Could not load /settings/content/MacroErrors from umbracosettings.config", ex);
_macroErrorBehaviour = MacroErrorBehaviour.Inline;
}
}
return _macroErrorBehaviour.Value;
}
}
/// <summary>
/// Configuration regarding webservices
+19 -4
View File
@@ -32,8 +32,7 @@ namespace Umbraco.Core
LogHelper.Info<CoreBootManager>("Umbraco application starting");
_timer = DisposableTimer.Start(x => LogHelper.Info<CoreBootManager>("Umbraco application startup complete" + " (took " + x + "ms)"));
//create the ApplicationContext
ApplicationContext = ApplicationContext.Current = new ApplicationContext();
CreateApplicationContext();
InitializeResolvers();
@@ -42,6 +41,15 @@ namespace Umbraco.Core
return this;
}
/// <summary>
/// Creates and assigns the application context singleton
/// </summary>
protected virtual void CreateApplicationContext()
{
//create the ApplicationContext
ApplicationContext = ApplicationContext.Current = new ApplicationContext();
}
/// <summary>
/// Fires after initialization and calls the callback to allow for customizations to occur
/// </summary>
@@ -72,8 +80,7 @@ namespace Umbraco.Core
if (_isComplete)
throw new InvalidOperationException("The boot manager has already been completed");
//freeze resolution to not allow Resolvers to be modified
Resolution.Freeze();
FreezeResolution();
//stop the timer and log the output
_timer.Dispose();
@@ -88,6 +95,14 @@ namespace Umbraco.Core
return this;
}
/// <summary>
/// Freeze resolution to not allow Resolvers to be modified
/// </summary>
protected virtual void FreezeResolution()
{
Resolution.Freeze();
}
/// <summary>
/// Create the resolvers
/// </summary>
+4 -2
View File
@@ -561,7 +561,8 @@ namespace Umbraco.Core.Dynamics
}
public IEnumerable<DynamicXml> Descendants(Func<XElement, bool> func)
{
var flattenedNodes = this.BaseElement.Elements().Map(func, (XElement n) => { return n.Elements(); });
//var flattenedNodes = this.BaseElement.Elements().Map(func, n => n.Elements());
var flattenedNodes = this.BaseElement.Elements().SelectMany(n => n.Elements()).Where(func);
return flattenedNodes.ToList().ConvertAll(n => new DynamicXml(n));
}
public IEnumerable<DynamicXml> DescendantsOrSelf()
@@ -570,7 +571,8 @@ namespace Umbraco.Core.Dynamics
}
public IEnumerable<DynamicXml> DescendantsOrSelf(Func<XElement, bool> func)
{
var flattenedNodes = this.BaseElement.Elements().Map(func, (XElement n) => { return n.Elements(); });
//var flattenedNodes = this.BaseElement.Elements().Map(func, n => n.Elements());
var flattenedNodes = this.BaseElement.Elements().SelectMany(n => n.Elements()).Where(func);
var list = new List<DynamicXml>();
list.Add(this);
list.AddRange(flattenedNodes.ToList().ConvertAll(n => new DynamicXml(n)));
+31 -28
View File
@@ -5,36 +5,35 @@ using Umbraco.Core.Models;
namespace Umbraco.Core.Dynamics
{
[Obsolete("This class should not be used, it is just referenced by already obsoleted code and will be removed in the future")]
internal static class ExtensionMethods
{
public static IEnumerable<TSource> Map<TSource>(
this IEnumerable<TSource> source,
Func<TSource, bool> selectorFunction,
Func<TSource, IEnumerable<TSource>> getChildrenFunction)
{
if (!source.Any())
{
return source;
}
// Add what we have to the stack
var flattenedList = source.Where(selectorFunction);
// Go through the input enumerable looking for children,
// and add those if we have them
foreach (TSource element in source)
{
var secondInner = getChildrenFunction(element);
if (secondInner.Any())
{
secondInner = secondInner.Map(selectorFunction, getChildrenFunction);
}
flattenedList = flattenedList.Concat(secondInner);
}
return flattenedList;
}
//public static IEnumerable<TSource> Map<TSource>(
// this IEnumerable<TSource> source,
// Func<TSource, bool> selectorFunction,
// Func<TSource, IEnumerable<TSource>> getChildrenFunction)
//{
// if (!source.Any())
// {
// return source;
// }
// // Add what we have to the stack
// var flattenedList = source.Where(selectorFunction);
// // Go through the input enumerable looking for children,
// // and add those if we have them
// foreach (TSource element in source)
// {
// var secondInner = getChildrenFunction(element);
// if (secondInner.Any())
// {
// secondInner = secondInner.Map(selectorFunction, getChildrenFunction);
// }
// flattenedList = flattenedList.Concat(secondInner);
// }
// return flattenedList;
//}
[Obsolete("This method should not be used and will be removed in the future")]
public static bool ContainsAny(this string haystack, IEnumerable<string> needles)
{
if (haystack == null) throw new ArgumentNullException("haystack");
@@ -44,6 +43,7 @@ namespace Umbraco.Core.Dynamics
}
return false;
}
[Obsolete("This method should not be used and will be removed in the future")]
public static bool ContainsAny(this string haystack, params string[] needles)
{
if (haystack == null) throw new ArgumentNullException("haystack");
@@ -53,6 +53,7 @@ namespace Umbraco.Core.Dynamics
}
return false;
}
[Obsolete("This method should not be used and will be removed in the future")]
public static bool ContainsAny(this string haystack, StringComparison comparison, IEnumerable<string> needles)
{
if (haystack == null) throw new ArgumentNullException("haystack");
@@ -62,6 +63,7 @@ namespace Umbraco.Core.Dynamics
}
return false;
}
[Obsolete("This method should not be used and will be removed in the future")]
public static bool ContainsAny(this string haystack, StringComparison comparison, params string[] needles)
{
if (haystack == null) throw new ArgumentNullException("haystack");
@@ -71,12 +73,13 @@ namespace Umbraco.Core.Dynamics
}
return false;
}
[Obsolete("This method should not be used and will be removed in the future")]
public static bool ContainsInsensitive(this string haystack, string needle)
{
if (haystack == null) throw new ArgumentNullException("haystack");
return haystack.IndexOf(needle, StringComparison.CurrentCultureIgnoreCase) >= 0;
}
[Obsolete("This method should not be used and will be removed in the future")]
public static bool HasValue(this string s)
{
return !string.IsNullOrWhiteSpace(s);
@@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Umbraco.Core.Events
{
// Provides information on the macro that caused an error
public class MacroErrorEventArgs : System.EventArgs
{
/// <summary>
/// Name of the faulting macro.
/// </summary>
public string Name { get; set; }
/// <summary>
/// Alias of the faulting macro.
/// </summary>
public string Alias { get; set; }
/// <summary>
/// Filename, file path, fully qualified class name, or other key used by the macro engine to do it's processing of the faulting macro.
/// </summary>
public string ItemKey { get; set; }
/// <summary>
/// Exception raised.
/// </summary>
public Exception Exception { get; set; }
/// <summary>
/// Gets or sets the desired behaviour when a matching macro causes an error. See
/// <see cref="MacroErrorBehaviour"/> for definitions. By setting this in your event
/// you can override the default behaviour defined in UmbracoSettings.config.
/// </summary>
/// <value>Macro error behaviour enum.</value>
public MacroErrorBehaviour Behaviour { get; set; }
}
}
+15
View File
@@ -8,6 +8,7 @@ using System.IO;
using System.Configuration;
using System.Web;
using System.Text.RegularExpressions;
using System.Xml;
using Umbraco.Core.Configuration;
using Umbraco.Core.Logging;
@@ -228,6 +229,20 @@ namespace Umbraco.Core.IO
filePath = String.Empty;
}
//Break up the file in name and extension before applying the UrlReplaceCharacters
var fileNamePart = filePath.Substring(0, filePath.LastIndexOf('.'));
var ext = filePath.Substring(filePath.LastIndexOf('.'));
//Because the file usually is downloadable as well we check characters against 'UmbracoSettings.UrlReplaceCharacters'
XmlNode replaceChars = UmbracoSettings.UrlReplaceCharacters;
foreach (XmlNode n in replaceChars.SelectNodes("char"))
{
if (n.Attributes.GetNamedItem("org") != null && n.Attributes.GetNamedItem("org").Value != "")
fileNamePart = fileNamePart.Replace(n.Attributes.GetNamedItem("org").Value, XmlHelper.GetNodeValue(n));
}
filePath = string.Concat(fileNamePart, ext);
// Adapted from: http://stackoverflow.com/a/4827510/5018
// Combined both Reserved Characters and Character Data
// from http://en.wikipedia.org/wiki/Percent-encoding
+14 -4
View File
@@ -183,16 +183,26 @@ namespace Umbraco.Core.IO
}
}
private static string _root;
/// <summary>
/// Gets the root path of the application
/// </summary>
public static string Root
{
get
{
string appPath = HttpRuntime.AppDomainAppVirtualPath ?? string.Empty;
if (appPath == "/")
appPath = string.Empty;
if (_root == null)
{
string appPath = HttpRuntime.AppDomainAppVirtualPath ?? string.Empty;
if (appPath == "/")
appPath = string.Empty;
return appPath;
_root = appPath;
}
return _root;
}
//Only required for unit tests
internal set { _root = value; }
}
}
@@ -64,23 +64,28 @@ namespace Umbraco.Core.Logging
{
_forceStop = true;
var windowsIdentity = WindowsIdentity.GetCurrent();
base.Append(new LoggingEvent(new LoggingEventData
{
Level = Level.Error,
Message =
"Unable to clear out the AsynchronousRollingFileAppender buffer in the allotted time, forcing a shutdown",
TimeStamp = DateTime.UtcNow,
Identity = "",
ExceptionString = "",
UserName = windowsIdentity != null ? windowsIdentity.Name : "",
Domain = AppDomain.CurrentDomain.FriendlyName,
ThreadName = Thread.CurrentThread.ManagedThreadId.ToString(),
LocationInfo =
new LocationInfo(this.GetType().Name, "OnClose", "AsynchronousRollingFileAppender.cs", "59"),
LoggerName = this.GetType().FullName,
Properties = new PropertiesDictionary(),
})
);
var logEvent = new LoggingEvent(new LoggingEventData
{
Level = global::log4net.Core.Level.Error,
Message =
"Unable to clear out the AsynchronousRollingFileAppender buffer in the allotted time, forcing a shutdown",
TimeStamp = DateTime.UtcNow,
Identity = "",
ExceptionString = "",
UserName = windowsIdentity != null ? windowsIdentity.Name : "",
Domain = AppDomain.CurrentDomain.FriendlyName,
ThreadName = Thread.CurrentThread.ManagedThreadId.ToString(),
LocationInfo =
new LocationInfo(this.GetType().Name, "OnClose", "AsynchronousRollingFileAppender.cs", "59"),
LoggerName = this.GetType().FullName,
Properties = new PropertiesDictionary(),
});
if (this.DateTimeStrategy != null)
{
base.Append(logEvent);
}
}
base.OnClose();
+23
View File
@@ -0,0 +1,23 @@
namespace Umbraco.Core
{
public enum MacroErrorBehaviour
{
/// <summary>
/// Default umbraco behavior - show an inline error within the
/// macro but allow the page to continue rendering.
/// </summary>
Inline,
/// <summary>
/// Silently eat the error and do not display the offending macro.
/// </summary>
Silent,
/// <summary>
/// Throw an exception which can be caught by the global error handler
/// defined in Application_OnError. If no such error handler is defined
/// then you'll see the Yellow Screen Of Death (YSOD) error page.
/// </summary>
Throw
}
}
+13 -9
View File
@@ -179,6 +179,8 @@ namespace Umbraco.Core
public static string TrimEnd(this string value, string forRemoving)
{
if (string.IsNullOrEmpty(value)) return value;
if (string.IsNullOrEmpty(forRemoving)) return value;
while (value.EndsWith(forRemoving, StringComparison.InvariantCultureIgnoreCase))
{
value = value.Remove(value.LastIndexOf(forRemoving, StringComparison.InvariantCultureIgnoreCase));
@@ -189,6 +191,8 @@ namespace Umbraco.Core
public static string TrimStart(this string value, string forRemoving)
{
if (string.IsNullOrEmpty(value)) return value;
if (string.IsNullOrEmpty(forRemoving)) return value;
while (value.StartsWith(forRemoving, StringComparison.InvariantCultureIgnoreCase))
{
value = value.Substring(forRemoving.Length);
@@ -204,22 +208,22 @@ namespace Umbraco.Core
public static string EnsureStartsWith(this string input, char value)
{
return input.StartsWith(value.ToString()) ? input : value + input;
return input.StartsWith(value.ToString(CultureInfo.InvariantCulture)) ? input : value + input;
}
public static string EnsureEndsWith(this string input, char value)
{
return input.EndsWith(value.ToString()) ? input : input + value;
return input.EndsWith(value.ToString(CultureInfo.InvariantCulture)) ? input : input + value;
}
public static bool IsLowerCase(this char ch)
{
return ch.ToString(CultureInfo.InvariantCulture) == ch.ToString(CultureInfo.InvariantCulture).ToLower();
return ch.ToString(CultureInfo.InvariantCulture) == ch.ToString(CultureInfo.InvariantCulture).ToLowerInvariant();
}
public static bool IsUpperCase(this char ch)
{
return ch.ToString(CultureInfo.InvariantCulture) == ch.ToString(CultureInfo.InvariantCulture).ToUpper();
return ch.ToString(CultureInfo.InvariantCulture) == ch.ToString(CultureInfo.InvariantCulture).ToUpperInvariant();
}
/// <summary>Is null or white space.</summary>
@@ -327,7 +331,7 @@ namespace Umbraco.Core
Enumerable.Range(97, 26));
var sb = new StringBuilder();
foreach (var c in value.Where(c => charReplacements.Values.Contains(c.ToString()) || validCodeRanges.Contains(c)))
foreach (var c in value.Where(c => charReplacements.Values.Contains(c.ToString(CultureInfo.InvariantCulture)) || validCodeRanges.Contains(c)))
{
sb.Append(c);
}
@@ -388,7 +392,7 @@ namespace Umbraco.Core
{
if (splittedPhraseChars.Length > 0)
{
splittedPhraseChars[0] = ((new String(splittedPhraseChars[0], 1)).ToUpper().ToCharArray())[0];
splittedPhraseChars[0] = ((new String(splittedPhraseChars[0], 1)).ToUpperInvariant().ToCharArray())[0];
}
sb.Append(new String(splittedPhraseChars));
}
@@ -403,15 +407,15 @@ namespace Umbraco.Core
var match = pattern.Match(result);
if (match.Success)
{
result = match.Groups[1].Value.ToLower() + match.Groups[2].Value;
result = match.Groups[1].Value.ToLowerInvariant() + match.Groups[2].Value;
return result.Substring(0, 1).ToLower() + result.Substring(1);
return result.Substring(0, 1).ToLowerInvariant() + result.Substring(1);
}
return result;
}
return result.ToLower();
return result.ToLowerInvariant();
}
return result;
+10
View File
@@ -12,6 +12,8 @@
<AssemblyName>Umbraco.Core</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
<RestorePackages>true</RestorePackages>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@@ -67,8 +69,10 @@
<Compile Include="Dictionary\ICultureDictionaryFactory.cs" />
<Compile Include="Dynamics\DynamicInstanceHelper.cs" />
<Compile Include="Enum.cs" />
<Compile Include="Events\MacroErrorEventArgs.cs" />
<Compile Include="HashCodeCombiner.cs" />
<Compile Include="IO\FileSystemWrapper.cs" />
<Compile Include="MacroErrorBehaviour.cs" />
<Compile Include="Media\IImageUrlProvider.cs" />
<Compile Include="ObjectResolution\LazyManyObjectsResolverbase.cs" />
<Compile Include="PublishedContentExtensions.cs" />
@@ -162,6 +166,11 @@
<Compile Include="WriteLock.cs" />
<Compile Include="XmlExtensions.cs" />
<Compile Include="XmlHelper.cs" />
<Compile Include="Xml\DynamicContext.cs" />
<Compile Include="Xml\XmlNamespaces.cs" />
<Compile Include="Xml\XmlNodeListFactory.cs" />
<Compile Include="Xml\XmlNodeExtensions.cs" />
<Compile Include="Xml\XPathVariable.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
@@ -174,6 +183,7 @@
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\nuget.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
+312
View File
@@ -0,0 +1,312 @@
using System;
using System.Collections.Generic;
using System.Xml;
using System.Xml.Xsl;
using System.Xml.XPath;
// source: mvpxml.codeplex.com
namespace Umbraco.Core.Xml
{
/// <summary>
/// Provides the evaluation context for fast execution and custom
/// variables resolution.
/// </summary>
/// <remarks>
/// This class is responsible for resolving variables during dynamic expression execution.
/// <para>Discussed in http://weblogs.asp.net/cazzu/archive/2003/10/07/30888.aspx</para>
/// <para>Author: Daniel Cazzulino, <a href="http://clariusconsulting.net/kzu">blog</a></para>
/// </remarks>
public class DynamicContext : XsltContext
{
#region Private vars
readonly IDictionary<string, IXsltContextVariable> _variables =
new Dictionary<string, IXsltContextVariable>();
#endregion Private
#region Constructors & Initialization
/// <summary>
/// Initializes a new instance of the <see cref="DynamicContext"/> class.
/// </summary>
public DynamicContext()
: base(new NameTable())
{
}
/// <summary>
/// Initializes a new instance of the <see cref="DynamicContext"/>
/// class with the specified <see cref="NameTable"/>.
/// </summary>
/// <param name="table">The NameTable to use.</param>
public DynamicContext(NameTable table)
: base(table)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="DynamicContext"/> class.
/// </summary>
/// <param name="context">A previously filled context with the namespaces to use.</param>
public DynamicContext(XmlNamespaceManager context)
: this(context, new NameTable())
{
}
/// <summary>
/// Initializes a new instance of the <see cref="DynamicContext"/> class.
/// </summary>
/// <param name="context">A previously filled context with the namespaces to use.</param>
/// <param name="table">The NameTable to use.</param>
public DynamicContext(XmlNamespaceManager context, NameTable table)
: base(table)
{
object xml = table.Add(XmlNamespaces.Xml);
object xmlns = table.Add(XmlNamespaces.XmlNs);
if (context == null) return;
foreach (string prefix in context)
{
var uri = context.LookupNamespace(prefix);
// Use fast object reference comparison to omit forbidden namespace declarations.
if (Equals(uri, xml) || Equals(uri, xmlns))
continue;
if (uri == null)
continue;
base.AddNamespace(prefix, uri);
}
}
#endregion Constructors & Initialization
#region Common Overrides
/// <summary>
/// Implementation equal to <see cref="XsltContext"/>.
/// </summary>
public override int CompareDocument(string baseUri, string nextbaseUri)
{
return String.Compare(baseUri, nextbaseUri, false, System.Globalization.CultureInfo.InvariantCulture);
}
/// <summary>
/// Same as <see cref="XmlNamespaceManager"/>.
/// </summary>
public override string LookupNamespace(string prefix)
{
var key = NameTable.Get(prefix);
return key == null ? null : base.LookupNamespace(key);
}
/// <summary>
/// Same as <see cref="XmlNamespaceManager"/>.
/// </summary>
public override string LookupPrefix(string uri)
{
var key = NameTable.Get(uri);
return key == null ? null : base.LookupPrefix(key);
}
/// <summary>
/// Same as <see cref="XsltContext"/>.
/// </summary>
public override bool PreserveWhitespace(XPathNavigator node)
{
return true;
}
/// <summary>
/// Same as <see cref="XsltContext"/>.
/// </summary>
public override bool Whitespace
{
get { return true; }
}
#endregion Common Overrides
#region Public Members
/// <summary>
/// Shortcut method that compiles an expression using an empty navigator.
/// </summary>
/// <param name="xpath">The expression to compile</param>
/// <returns>A compiled <see cref="XPathExpression"/>.</returns>
public static XPathExpression Compile(string xpath)
{
return new XmlDocument().CreateNavigator().Compile(xpath);
}
#endregion Public Members
#region Variable Handling Code
/// <summary>
/// Adds the variable to the dynamic evaluation context.
/// </summary>
/// <param name="name">The name of the variable to add to the context.</param>
/// <param name="value">The value of the variable to add to the context.</param>
/// <remarks>
/// Value type conversion for XPath evaluation is as follows:
/// <list type="table">
/// <listheader>
/// <term>CLR Type</term>
/// <description>XPath type</description>
/// </listheader>
/// <item>
/// <term>System.String</term>
/// <description>XPathResultType.String</description>
/// </item>
/// <item>
/// <term>System.Double (or types that can be converted to)</term>
/// <description>XPathResultType.Number</description>
/// </item>
/// <item>
/// <term>System.Boolean</term>
/// <description>XPathResultType.Boolean</description>
/// </item>
/// <item>
/// <term>System.Xml.XPath.XPathNavigator</term>
/// <description>XPathResultType.Navigator</description>
/// </item>
/// <item>
/// <term>System.Xml.XPath.XPathNodeIterator</term>
/// <description>XPathResultType.NodeSet</description>
/// </item>
/// <item>
/// <term>Others</term>
/// <description>XPathResultType.Any</description>
/// </item>
/// </list>
/// <note type="note">See the topic "Compile, Select, Evaluate, and Matches with
/// XPath and XPathExpressions" in MSDN documentation for additional information.</note>
/// </remarks>
/// <exception cref="ArgumentNullException">The <paramref name="value"/> is null.</exception>
public void AddVariable(string name, object value)
{
if (value == null) throw new ArgumentNullException("value");
_variables[name] = new DynamicVariable(name, value);
}
/// <summary>
/// See <see cref="XsltContext"/>. Not used in our implementation.
/// </summary>
public override IXsltContextFunction ResolveFunction(string prefix, string name, XPathResultType[] argTypes)
{
return null;
}
/// <summary>
/// Resolves the dynamic variables added to the context. See <see cref="XsltContext"/>.
/// </summary>
public override IXsltContextVariable ResolveVariable(string prefix, string name)
{
IXsltContextVariable var;
_variables.TryGetValue(name, out var);
return var;
}
#endregion Variable Handling Code
#region Internal DynamicVariable class
/// <summary>
/// Represents a variable during dynamic expression execution.
/// </summary>
internal class DynamicVariable : IXsltContextVariable
{
readonly string _name;
readonly object _value;
#region Public Members
public string Name { get { return _name; } }
/// <summary>
/// Initializes a new instance of the class.
/// </summary>
/// <param name="name">The name of the variable.</param>
/// <param name="value">The value of the variable.</param>
public DynamicVariable(string name, object value)
{
_name = name;
_value = value;
if (value is String)
_type = XPathResultType.String;
else if (value is bool)
_type = XPathResultType.Boolean;
else if (value is XPathNavigator)
_type = XPathResultType.Navigator;
else if (value is XPathNodeIterator)
_type = XPathResultType.NodeSet;
else
{
// Try to convert to double (native XPath numeric type)
if (value is double)
{
_type = XPathResultType.Number;
}
else
{
if (value is IConvertible)
{
try
{
_value = Convert.ToDouble(value);
// We suceeded, so it's a number.
_type = XPathResultType.Number;
}
catch (FormatException)
{
_type = XPathResultType.Any;
}
catch (OverflowException)
{
_type = XPathResultType.Any;
}
}
else
{
_type = XPathResultType.Any;
}
}
}
}
#endregion Public Members
#region IXsltContextVariable Implementation
XPathResultType IXsltContextVariable.VariableType
{
get { return _type; }
}
readonly XPathResultType _type;
object IXsltContextVariable.Evaluate(XsltContext context)
{
return _value;
}
bool IXsltContextVariable.IsLocal
{
get { return false; }
}
bool IXsltContextVariable.IsParam
{
get { return false; }
}
#endregion IXsltContextVariable Implementation
}
#endregion Internal DynamicVariable class
}
}
+16
View File
@@ -0,0 +1,16 @@
// source: mvpxml.codeplex.com
namespace Umbraco.Core.Xml
{
internal class XPathVariable
{
public string Name { get; set; }
public string Value { get; set; }
public XPathVariable(string name, string value)
{
Name = name;
Value = value;
}
}
}
+41
View File
@@ -0,0 +1,41 @@
// source: mvpxml.codeplex.com
namespace Umbraco.Core.Xml
{
/// <summary>
/// Provides public constants for wellknown XML namespaces.
/// </summary>
/// <remarks>Author: Daniel Cazzulino, <a href="http://clariusconsulting.net/kzu">blog</a></remarks>
public static class XmlNamespaces
{
/// <summary>
/// The public XML 1.0 namespace.
/// </summary>
/// <remarks>See http://www.w3.org/TR/2004/REC-xml-20040204/</remarks>
public const string Xml = "http://www.w3.org/XML/1998/namespace";
/// <summary>
/// Public Xml Namespaces specification namespace.
/// </summary>
/// <remarks>See http://www.w3.org/TR/REC-xml-names/</remarks>
public const string XmlNs = "http://www.w3.org/2000/xmlns/";
/// <summary>
/// Public Xml Namespaces prefix.
/// </summary>
/// <remarks>See http://www.w3.org/TR/REC-xml-names/</remarks>
public const string XmlNsPrefix = "xmlns";
/// <summary>
/// XML Schema instance namespace.
/// </summary>
/// <remarks>See http://www.w3.org/TR/xmlschema-1/</remarks>
public const string Xsi = "http://www.w3.org/2001/XMLSchema-instance";
/// <summary>
/// XML 1.0 Schema namespace.
/// </summary>
/// <remarks>See http://www.w3.org/TR/xmlschema-1/</remarks>
public const string Xsd = "http://www.w3.org/2001/XMLSchema";
}
}
+51
View File
@@ -0,0 +1,51 @@
using System.Collections.Generic;
using System.Linq;
using System.Xml;
using System.Xml.XPath;
// source: mvpxml.codeplex.com
namespace Umbraco.Core.Xml
{
internal static class XmlNodeExtensions
{
static XPathNodeIterator Select(string expression, XPathNavigator source, params XPathVariable[] variables)
{
var expr = source.Compile(expression);
var context = new DynamicContext();
foreach (var variable in variables)
context.AddVariable(variable.Name, variable.Value);
expr.SetContext(context);
return source.Select(expr);
}
public static XmlNodeList SelectNodes(this XmlNode source, string expression, IEnumerable<XPathVariable> variables)
{
var av = variables == null ? null : variables.ToArray();
return SelectNodes(source, expression, av);
}
public static XmlNodeList SelectNodes(this XmlNode source, string expression, params XPathVariable[] variables)
{
if (variables == null || variables.Length == 0 || variables[0] == null)
return source.SelectNodes(expression);
var iterator = Select(expression, source.CreateNavigator(), variables);
return XmlNodeListFactory.CreateNodeList(iterator);
}
public static XmlNode SelectSingleNode(this XmlNode source, string expression, IEnumerable<XPathVariable> variables)
{
var av = variables == null ? null : variables.ToArray();
return SelectSingleNode(source, expression, av);
}
public static XmlNode SelectSingleNode(this XmlNode source, string expression, params XPathVariable[] variables)
{
if (variables == null || variables.Length == 0 || variables[0] == null)
return source.SelectSingleNode(expression);
return SelectNodes(source, expression, variables).Cast<XmlNode>().FirstOrDefault();
}
}
}
+178
View File
@@ -0,0 +1,178 @@
using System;
using System.Collections.Generic;
using System.Xml;
using System.Xml.XPath;
// source: mvpxml.codeplex.com
namespace Umbraco.Core.Xml
{
class XmlNodeListFactory
{
private XmlNodeListFactory() { }
#region Public members
/// <summary>
/// Creates an instance of a <see cref="XmlNodeList"/> that allows
/// enumerating <see cref="XmlNode"/> elements in the iterator.
/// </summary>
/// <param name="iterator">The result of a previous node selection
/// through an <see cref="XPathNavigator"/> query.</param>
/// <returns>An initialized list ready to be enumerated.</returns>
/// <remarks>The underlying XML store used to issue the query must be
/// an object inheriting <see cref="XmlNode"/>, such as
/// <see cref="XmlDocument"/>.</remarks>
public static XmlNodeList CreateNodeList(XPathNodeIterator iterator)
{
return new XmlNodeListIterator(iterator);
}
#endregion Public members
#region XmlNodeListIterator
private class XmlNodeListIterator : XmlNodeList
{
readonly XPathNodeIterator _iterator;
readonly IList<XmlNode> _nodes = new List<XmlNode>();
public XmlNodeListIterator(XPathNodeIterator iterator)
{
_iterator = iterator.Clone();
}
public override System.Collections.IEnumerator GetEnumerator()
{
return new XmlNodeListEnumerator(this);
}
public override XmlNode Item(int index)
{
if (index >= _nodes.Count)
ReadTo(index);
// Compatible behavior with .NET
if (index >= _nodes.Count || index < 0)
return null;
return _nodes[index];
}
public override int Count
{
get
{
if (!_done) ReadToEnd();
return _nodes.Count;
}
}
/// <summary>
/// Reads the entire iterator.
/// </summary>
private void ReadToEnd()
{
while (_iterator.MoveNext())
{
var node = _iterator.Current as IHasXmlNode;
// Check IHasXmlNode interface.
if (node == null)
throw new ArgumentException("IHasXmlNode is missing.");
_nodes.Add(node.GetNode());
}
_done = true;
}
/// <summary>
/// Reads up to the specified index, or until the
/// iterator is consumed.
/// </summary>
private void ReadTo(int to)
{
while (_nodes.Count <= to)
{
if (_iterator.MoveNext())
{
var node = _iterator.Current as IHasXmlNode;
// Check IHasXmlNode interface.
if (node == null)
throw new ArgumentException("IHasXmlNode is missing.");
_nodes.Add(node.GetNode());
}
else
{
_done = true;
return;
}
}
}
/// <summary>
/// Flags that the iterator has been consumed.
/// </summary>
private bool Done
{
get { return _done; }
}
bool _done;
/// <summary>
/// Current count of nodes in the iterator (read so far).
/// </summary>
private int CurrentPosition
{
get { return _nodes.Count; }
}
#region XmlNodeListEnumerator
private class XmlNodeListEnumerator : System.Collections.IEnumerator
{
readonly XmlNodeListIterator _iterator;
int _position = -1;
public XmlNodeListEnumerator(XmlNodeListIterator iterator)
{
_iterator = iterator;
}
#region IEnumerator Members
void System.Collections.IEnumerator.Reset()
{
_position = -1;
}
bool System.Collections.IEnumerator.MoveNext()
{
_position++;
_iterator.ReadTo(_position);
// If we reached the end and our index is still
// bigger, there're no more items.
if (_iterator.Done && _position >= _iterator.CurrentPosition)
return false;
return true;
}
object System.Collections.IEnumerator.Current
{
get
{
return _iterator[_position];
}
}
#endregion
}
#endregion XmlNodeListEnumerator
}
#endregion XmlNodeListIterator
}
}
@@ -2,6 +2,7 @@ using System.Linq;
using System.Xml;
using NUnit.Framework;
using Umbraco.Core;
using Umbraco.Core.Configuration;
using Umbraco.Tests.TestHelpers;
using Umbraco.Web;
using Umbraco.Web.Routing;
@@ -54,6 +55,8 @@ namespace Umbraco.Tests.ContentStores
</Home>
<Home id=""1175"" parentID=""1046"" level=""2"" writerID=""0"" creatorID=""0"" nodeType=""1044"" template=""1045"" sortOrder=""2"" createDate=""2012-07-20T18:08:01"" updateDate=""2012-07-20T18:49:32"" nodeName=""Sub 2"" urlName=""sub-2"" writerName=""admin"" creatorName=""admin"" path=""-1,1046,1175"" isDoc=""""><content><![CDATA[]]></content>
</Home>
<Home id=""1177"" parentID=""1046"" level=""2"" writerID=""0"" creatorID=""0"" nodeType=""1044"" template=""1045"" sortOrder=""2"" createDate=""2012-07-20T18:08:01"" updateDate=""2012-07-20T18:49:32"" nodeName=""Sub'Apostrophe"" urlName=""sub'apostrophe"" writerName=""admin"" creatorName=""admin"" path=""-1,1046,1177"" isDoc=""""><content><![CDATA[]]></content>
</Home>
</Home>
<Home id=""1172"" parentID=""-1"" level=""1"" writerID=""0"" creatorID=""0"" nodeType=""1044"" template=""1045"" sortOrder=""3"" createDate=""2012-07-16T15:26:59"" updateDate=""2012-07-18T14:23:35"" nodeName=""Test"" urlName=""test"" writerName=""admin"" creatorName=""admin"" path=""-1,1172"" isDoc="""" />
</root>";
@@ -63,7 +66,7 @@ namespace Umbraco.Tests.ContentStores
public void SetUp()
{
TestHelper.SetupLog4NetForTests();
Umbraco.Core.Configuration.UmbracoSettings.UseLegacyXmlSchema = false;
_httpContextFactory = new FakeHttpContextFactory("~/Home");
//ensure the StateHelper is using our custom context
StateHelper.HttpContext = _httpContextFactory.HttpContext;
@@ -103,9 +106,7 @@ namespace Umbraco.Tests.ContentStores
[TearDown]
public void TearDown()
{
//TODO: need to reset everything!
Umbraco.Core.Configuration.UmbracoSettings.UseLegacyXmlSchema = false;
UmbracoSettings.ResetSetters();
}
[Test]
@@ -155,6 +156,7 @@ namespace Umbraco.Tests.ContentStores
[TestCase("/home/sub1", 1173)]
[TestCase("/Home/sub1", 1173)]
[TestCase("/home/Sub1", 1173)] //test different cases
[TestCase("/home/Sub'Apostrophe", 1177)]
public void Get_Node_By_Route(string route, int nodeId)
{
var result = _publishedContentStore.GetDocumentByRoute(_umbracoContext, route, false);
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Xml;
using Examine;
@@ -14,19 +15,26 @@ using umbraco.BusinessLogic;
namespace Umbraco.Tests.ContentStores
{
[TestFixture]
public class PublishMediaStoreTests : BaseWebTest
public class PublishMediaStoreTests : PublishedContentTestBase
{
public override void Initialize()
{
base.Initialize();
//we're going to use the same initialization as the PublishedMediaTests
PublishedMediaTests.DoInitialization(GetUmbracoContext("/test", 1234));
var currDir = new DirectoryInfo(TestHelper.CurrentAssemblyDirectory);
File.Copy(
currDir.Parent.Parent.Parent.GetDirectories("Umbraco.Web.UI")
.First()
.GetDirectories("config").First()
.GetFiles("umbracoSettings.Release.config").First().FullName,
Path.Combine(currDir.Parent.Parent.FullName, "config", "umbracoSettings.config"),
true);
}
public override void TearDown()
{
base.TearDown();
PublishedMediaTests.DoTearDown();
}
[Test]
@@ -10,6 +10,77 @@ namespace Umbraco.Tests
[TestFixture]
public class EnumerableExtensionsTests
{
[Test]
public void Flatten_List()
{
var hierarchy = new TestItem()
{
Children = new List<TestItem>()
{
new TestItem()
{
Children = new List<TestItem>()
{
new TestItem()
{
Children = new List<TestItem>()
{
new TestItem()
{
Children = new List<TestItem>()
{
new TestItem(),
new TestItem()
}
}
}
}
}
},
new TestItem()
{
Children = new List<TestItem>()
{
new TestItem()
{
Children = new List<TestItem>()
{
new TestItem()
{
Children = new List<TestItem>()
}
}
},
new TestItem()
{
Children = new List<TestItem>()
{
new TestItem()
{
Children = new List<TestItem>()
}
}
}
}
},
}
};
var flattened = hierarchy.Children.FlattenList(x => x.Children);
Assert.AreEqual(10, flattened.Count());
}
private class TestItem
{
public TestItem()
{
Children = Enumerable.Empty<TestItem>();
}
public IEnumerable<TestItem> Children { get; set; }
}
[Test]
public void InGroupsOf_ReturnsAllElements()
{
+23 -9
View File
@@ -1,6 +1,7 @@
using System.Configuration;
using System.Web.Routing;
using NUnit.Framework;
using Umbraco.Core.IO;
using Umbraco.Tests.TestHelpers;
using System.Web.Mvc;
@@ -15,21 +16,34 @@ namespace Umbraco.Tests
}
public override void Initialize()
{
{
base.Initialize();
ConfigurationManager.AppSettings.Set("umbracoReservedPaths", "~/umbraco,~/install/");
ConfigurationManager.AppSettings.Set("umbracoReservedUrls", "~/config/splashes/booting.aspx,~/install/default.aspx,~/config/splashes/noNodes.aspx,~/VSEnterpriseHelper.axd");
SettingsForTests.UmbracoPath = "~/umbraco";
}
public override void TearDown()
{
//ensure this is reset
SystemDirectories.Root = null;
SettingsForTests.UmbracoPath = "~/umbraco";
//reset the app config
base.TearDown();
//reset the app config
ConfigurationManager.AppSettings.Set("umbracoReservedPaths", "");
ConfigurationManager.AppSettings.Set("umbracoReservedUrls", "");
}
[TestCase("/umbraco/umbraco.aspx")]
[TestCase("~/umbraco", "/", "umbraco")]
[TestCase("~/umbraco", "/MyVirtualDir", "umbraco")]
[TestCase("~/customPath", "/MyVirtualDir/", "custompath")]
[TestCase("~/some-wacky/nestedPath", "/MyVirtualDir", "some-wacky-nestedpath")]
[TestCase("~/some-wacky/nestedPath", "/MyVirtualDir/NestedVDir/", "some-wacky-nestedpath")]
public void Umbraco_Mvc_Area(string path, string rootPath, string outcome)
{
SettingsForTests.UmbracoPath = path;
SystemDirectories.Root = rootPath;
Assert.AreEqual(outcome, Umbraco.Core.Configuration.GlobalSettings.UmbracoMvcArea);
}
[TestCase("/umbraco/umbraco.aspx")]
[TestCase("/umbraco/editContent.aspx")]
[TestCase("/install/default.aspx")]
[TestCase("/install/")]
@@ -70,8 +84,8 @@ namespace Umbraco.Tests
public void Is_Reserved_By_Route(string url, bool shouldMatch)
{
//reset the app config, we only want to test routes not the hard coded paths
ConfigurationManager.AppSettings.Set("umbracoReservedPaths", "");
ConfigurationManager.AppSettings.Set("umbracoReservedUrls", "");
Umbraco.Core.Configuration.GlobalSettings.ReservedPaths = "";
Umbraco.Core.Configuration.GlobalSettings.ReservedUrls = "";
var routes = new RouteCollection();
@@ -9,7 +9,7 @@ using Umbraco.Tests.BusinessLogic;
namespace Umbraco.Tests.IO
{
[TestFixture]
[TestFixture, RequiresSTA]
internal abstract class AbstractFileSystemTests
{
protected IFileSystem _fileSystem;
@@ -105,7 +105,6 @@ namespace Umbraco.Tests.IO
_fileSystem.DeleteDirectory("test", true);
}
[Ignore]
[Test]
public void Can_Get_File_Dates()
{
@@ -9,14 +9,32 @@ using Umbraco.Tests.BusinessLogic;
namespace Umbraco.Tests.IO
{
[TestFixture]
[TestFixture, RequiresSTA]
internal class PhysicalFileSystemTests : AbstractFileSystemTests
{
public PhysicalFileSystemTests()
: base(new PhysicalFileSystem(AppDomain.CurrentDomain.BaseDirectory,
: base(new PhysicalFileSystem(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "FileSysTests"),
"/Media/"))
{ }
[SetUp]
public void Setup()
{
}
[TearDown]
public void TearDown()
{
var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "FileSysTests");
var files = Directory.GetFiles(path);
foreach (var f in files)
{
File.Delete(f);
}
Directory.Delete(path, true);
}
protected override string ConstructUrl(string path)
{
return "/Media/" + path;
+12
View File
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using NUnit.Framework;
@@ -26,6 +27,17 @@ namespace Umbraco.Tests
var routingContext = GetRoutingContext("/test", 1234);
UmbracoContext.Current = routingContext.UmbracoContext;
var currDir = new DirectoryInfo(TestHelper.CurrentAssemblyDirectory);
File.Copy(
currDir.Parent.Parent.Parent.GetDirectories("Umbraco.Web.UI")
.First()
.GetDirectories("config").First()
.GetFiles("umbracoSettings.Release.config").First().FullName,
Path.Combine(currDir.Parent.Parent.FullName, "config", "umbracoSettings.config"),
true);
Core.Configuration.UmbracoSettings.SettingsFilePath = Core.IO.IOHelper.MapPath(Core.IO.SystemDirectories.Config + Path.DirectorySeparatorChar, false);
}
public override void TearDown()
File diff suppressed because it is too large Load Diff
@@ -12,66 +12,87 @@ using System.Linq;
namespace Umbraco.Tests.PublishedContent
{
[TestFixture]
public class DynamicNodeTests : DynamicDocumentTestsBase<DynamicNode, DynamicNodeList>
{
protected override bool RequiresDbSetup
{
get { return true; }
}
[TestFixture]
public class DynamicNodeTests : DynamicDocumentTestsBase<DynamicNode, DynamicNodeList>
{
protected override bool RequiresDbSetup
{
get { return true; }
}
public override void Initialize()
{
base.Initialize();
//copy the umbraco settings file over
var currDir = new DirectoryInfo(TestHelper.CurrentAssemblyDirectory);
File.Copy(
currDir.Parent.Parent.Parent.GetDirectories("Umbraco.Web.UI")
.First()
.GetDirectories("config").First()
.GetFiles("umbracoSettings.Release.config").First().FullName,
Path.Combine(currDir.Parent.Parent.FullName, "config", "umbracoSettings.config"),
true);
public override void Initialize()
{
base.Initialize();
//copy the umbraco settings file over
var currDir = new DirectoryInfo(TestHelper.CurrentAssemblyDirectory);
File.Copy(
currDir.Parent.Parent.Parent.GetDirectories("Umbraco.Web.UI")
.First()
.GetDirectories("config").First()
.GetFiles("umbracoSettings.Release.config").First().FullName,
Path.Combine(currDir.Parent.Parent.FullName, "config", "umbracoSettings.config"),
true);
UmbracoSettings.SettingsFilePath = IOHelper.MapPath(SystemDirectories.Config, false);
UmbracoSettings.SettingsFilePath = Core.IO.IOHelper.MapPath(Core.IO.SystemDirectories.Config + Path.DirectorySeparatorChar, false);
//for testing, we'll specify which assemblies are scanned for the PluginTypeResolver
PluginManager.Current.AssembliesToScan = new[]
//for testing, we'll specify which assemblies are scanned for the PluginTypeResolver
PluginManager.Current.AssembliesToScan = new[]
{
typeof(DynamicNode).Assembly
};
//need to specify a custom callback for unit tests
DynamicNode.GetDataTypeCallback = (docTypeAlias, propertyAlias) =>
{
if (propertyAlias == "content")
{
//return the rte type id
return Guid.Parse("5e9b75ae-face-41c8-b47e-5f4b0fd82f83");
}
return Guid.Empty;
};
//need to specify a custom callback for unit tests
DynamicNode.GetDataTypeCallback = (docTypeAlias, propertyAlias) =>
{
if (propertyAlias == "content")
{
//return the rte type id
return Guid.Parse("5e9b75ae-face-41c8-b47e-5f4b0fd82f83");
}
return Guid.Empty;
};
}
}
public override void TearDown()
{
base.TearDown();
[Test]
[Ignore("This test will never work unless DynamicNode is refactored a lot in order to get a list of root nodes since root nodes don't have a parent to look up")]
public override void Is_First_Root_Nodes()
{
base.Is_First_Root_Nodes();
}
PluginManager.Current.AssembliesToScan = null;
}
[Test]
[Ignore("This test will never work unless DynamicNode is refactored a lot in order to get a list of root nodes since root nodes don't have a parent to look up")]
public override void Is_Not_First_Root_Nodes()
{
base.Is_Not_First_Root_Nodes();
}
protected override dynamic GetDynamicNode(int id)
{
//var template = Template.MakeNew("test", new User(0));
//var ctx = GetUmbracoContext("/test", template.Id);
var ctx = GetUmbracoContext("/test", 1234);
var contentStore = new DefaultPublishedContentStore();
var node = new DynamicNode(
new DynamicBackingItem(
new Node(ctx.GetXml().SelectSingleNode("//*[@id='" + id + "' and @isDoc]"))));
Assert.IsNotNull(node);
return (dynamic) node;
}
}
[Test]
[Ignore("This test will never work unless DynamicNode is refactored a lot in order to get a list of root nodes since root nodes don't have a parent to look up")]
public override void Is_Position_Root_Nodes()
{
base.Is_Position_Root_Nodes();
}
public override void TearDown()
{
base.TearDown();
PluginManager.Current.AssembliesToScan = null;
}
protected override dynamic GetDynamicNode(int id)
{
//var template = Template.MakeNew("test", new User(0));
//var ctx = GetUmbracoContext("/test", template.Id);
var ctx = GetUmbracoContext("/test", 1234);
var contentStore = new DefaultPublishedContentStore();
var node = new DynamicNode(
new DynamicBackingItem(
new Node(ctx.GetXml().SelectSingleNode("//*[@id='" + id + "' and @isDoc]"))));
Assert.IsNotNull(node);
return (dynamic)node;
}
}
}
@@ -1,52 +1,22 @@
using System;
using System.Linq;
using NUnit.Framework;
using Umbraco.Core;
using Umbraco.Core.Models;
using Umbraco.Core.PropertyEditors;
using Umbraco.Web;
using Umbraco.Web.Models;
namespace Umbraco.Tests.PublishedContent
{
[TestFixture]
[TestFixture]
public class DynamicPublishedContentTests : DynamicDocumentTestsBase<DynamicPublishedContent, DynamicPublishedContentList>
{
public override void Initialize()
{
base.Initialize();
PropertyEditorValueConvertersResolver.Current = new PropertyEditorValueConvertersResolver(
new[]
{
typeof(DatePickerPropertyEditorValueConverter),
typeof(TinyMcePropertyEditorValueConverter),
typeof(YesNoPropertyEditorValueConverter)
});
//need to specify a custom callback for unit tests
PublishedContentHelper.GetDataTypeCallback = (docTypeAlias, propertyAlias) =>
{
if (propertyAlias == "content")
{
//return the rte type id
return Guid.Parse("5e9b75ae-face-41c8-b47e-5f4b0fd82f83");
}
return Guid.Empty;
};
var rCtx = GetRoutingContext("/test", 1234);
UmbracoContext.Current = rCtx.UmbracoContext;
PublishedContentStoreResolver.Current = new PublishedContentStoreResolver(new DefaultPublishedContentStore());
}
public override void TearDown()
{
base.TearDown();
PropertyEditorValueConvertersResolver.Reset();
PublishedContentStoreResolver.Reset();
UmbracoContext.Current = null;
}
internal DynamicPublishedContent GetNode(int id)
@@ -0,0 +1,82 @@
using System;
using System.IO;
using System.Linq;
using Lucene.Net.Documents;
using NUnit.Framework;
using Umbraco.Core.Configuration;
using Umbraco.Tests.TestHelpers.ExamineHelpers;
using umbraco.MacroEngines;
namespace Umbraco.Tests.PublishedContent
{
public class LegacyExamineBackedMediaTests : PublishedContentTestBase
{
public override void Initialize()
{
base.Initialize();
UmbracoSettings.ForceSafeAliases = true;
UmbracoSettings.UmbracoLibraryCacheDuration = 1800;
UmbracoSettings.ForceSafeAliases = true;
}
public override void TearDown()
{
base.TearDown();
}
[Test]
public void Ensure_Children_Are_Sorted()
{
var newIndexFolder = new DirectoryInfo(Path.Combine("App_Data\\CWSIndexSetTest", Guid.NewGuid().ToString()));
var indexInit = new IndexInitializer();
var indexer = indexInit.GetUmbracoIndexer(newIndexFolder);
indexer.RebuildIndex();
var searcher = indexInit.GetUmbracoSearcher(newIndexFolder);
var result = searcher.Search(searcher.CreateSearchCriteria().Id(1111).Compile());
Assert.IsNotNull(result);
Assert.AreEqual(1, result.TotalItemCount);
var searchItem = result.First();
var backedMedia = new ExamineBackedMedia(searchItem, indexer, searcher);
var children = backedMedia.ChildrenAsList.Value;
var currSort = 0;
for (var i = 0; i < children.Count(); i++)
{
Assert.GreaterOrEqual(children[i].SortOrder, currSort);
currSort = children[i].SortOrder;
}
}
[Test]
public void Ensure_Result_Has_All_Values()
{
var newIndexFolder = new DirectoryInfo(Path.Combine("App_Data\\CWSIndexSetTest", Guid.NewGuid().ToString()));
var indexInit = new IndexInitializer();
var indexer = indexInit.GetUmbracoIndexer(newIndexFolder);
indexer.RebuildIndex();
var searcher = indexInit.GetUmbracoSearcher(newIndexFolder);
var result = searcher.Search(searcher.CreateSearchCriteria().Id(1111).Compile());
Assert.IsNotNull(result);
Assert.AreEqual(1, result.TotalItemCount);
var searchItem = result.First();
var backedMedia = new ExamineBackedMedia(searchItem, indexer, searcher);
Assert.AreEqual(searchItem.Id, backedMedia.Id);
Assert.AreEqual(searchItem.Fields["sortOrder"], backedMedia.SortOrder.ToString());
Assert.AreEqual(searchItem.Fields["urlName"], backedMedia.UrlName);
Assert.AreEqual(DateTools.StringToDate(searchItem.Fields["createDate"]), backedMedia.CreateDate);
Assert.AreEqual(DateTools.StringToDate(searchItem.Fields["updateDate"]), backedMedia.UpdateDate);
Assert.AreEqual(Guid.Parse(searchItem.Fields["version"]), backedMedia.Version);
Assert.AreEqual(searchItem.Fields["level"], backedMedia.Level.ToString());
Assert.AreEqual(searchItem.Fields["writerID"], backedMedia.WriterID.ToString());
Assert.AreEqual(searchItem.Fields["writerID"], backedMedia.CreatorID.ToString()); //there's only writerId in the xml
Assert.AreEqual(searchItem.Fields["writerName"], backedMedia.CreatorName);
Assert.AreEqual(searchItem.Fields["writerName"], backedMedia.WriterName); //tehre's only writer name in the xml
}
}
}
@@ -0,0 +1,57 @@
using System;
using System.IO;
using Umbraco.Core;
using Umbraco.Core.Configuration;
using Umbraco.Core.PropertyEditors;
using Umbraco.Tests.TestHelpers;
using Umbraco.Web;
namespace Umbraco.Tests.PublishedContent
{
/// <summary>
/// Abstract base class for tests for published content and published media
/// </summary>
public abstract class PublishedContentTestBase : BaseRoutingTest
{
public override void Initialize()
{
base.Initialize();
UmbracoSettings.SettingsFilePath = Core.IO.IOHelper.MapPath(Core.IO.SystemDirectories.Config + Path.DirectorySeparatorChar, false);
PropertyEditorValueConvertersResolver.Current = new PropertyEditorValueConvertersResolver(
new[]
{
typeof(DatePickerPropertyEditorValueConverter),
typeof(TinyMcePropertyEditorValueConverter),
typeof(YesNoPropertyEditorValueConverter)
});
//need to specify a custom callback for unit tests
PublishedContentHelper.GetDataTypeCallback = (docTypeAlias, propertyAlias) =>
{
if (propertyAlias == "content")
{
//return the rte type id
return Guid.Parse("5e9b75ae-face-41c8-b47e-5f4b0fd82f83");
}
return Guid.Empty;
};
var rCtx = GetRoutingContext("/test", 1234);
UmbracoContext.Current = rCtx.UmbracoContext;
PublishedContentStoreResolver.Current = new PublishedContentStoreResolver(new DefaultPublishedContentStore());
PublishedMediaStoreResolver.Current = new PublishedMediaStoreResolver(new DefaultPublishedMediaStore());
}
public override void TearDown()
{
base.TearDown();
PropertyEditorValueConvertersResolver.Reset();
PublishedContentStoreResolver.Reset();
PublishedMediaStoreResolver.Reset();
UmbracoContext.Current = null;
}
}
}
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using NUnit.Framework;
@@ -14,7 +15,7 @@ namespace Umbraco.Tests.PublishedContent
/// Tests the methods on IPublishedContent using the DefaultPublishedContentStore
/// </summary>
[TestFixture]
public class PublishedContentTests : BaseWebTest
public class PublishedContentTests : PublishedContentTestBase
{
protected override bool RequiresDbSetup
{
@@ -35,23 +36,24 @@ namespace Umbraco.Tests.PublishedContent
<content><![CDATA[]]></content>
<umbracoUrlAlias><![CDATA[this/is/my/alias, anotheralias]]></umbracoUrlAlias>
<umbracoNaviHide>1</umbracoNaviHide>
<Home id=""1173"" parentID=""1046"" level=""2"" writerID=""0"" creatorID=""0"" nodeType=""1044"" template=""" + templateId + @""" sortOrder=""2"" createDate=""2012-07-20T18:06:45"" updateDate=""2012-07-20T19:07:31"" nodeName=""Sub1"" urlName=""sub1"" writerName=""admin"" creatorName=""admin"" path=""-1,1046,1173"" isDoc="""">
<Home id=""1173"" parentID=""1046"" level=""2"" writerID=""0"" creatorID=""0"" nodeType=""1044"" template=""" + templateId + @""" sortOrder=""1"" createDate=""2012-07-20T18:06:45"" updateDate=""2012-07-20T19:07:31"" nodeName=""Sub1"" urlName=""sub1"" writerName=""admin"" creatorName=""admin"" path=""-1,1046,1173"" isDoc="""">
<content><![CDATA[<div>This is some content</div>]]></content>
<umbracoUrlAlias><![CDATA[page2/alias, 2ndpagealias]]></umbracoUrlAlias>
<Home id=""1174"" parentID=""1173"" level=""3"" writerID=""0"" creatorID=""0"" nodeType=""1044"" template=""" + templateId + @""" sortOrder=""2"" createDate=""2012-07-20T18:07:54"" updateDate=""2012-07-20T19:10:27"" nodeName=""Sub2"" urlName=""sub2"" writerName=""admin"" creatorName=""admin"" path=""-1,1046,1173,1174"" isDoc="""">
<Home id=""1174"" parentID=""1173"" level=""3"" writerID=""0"" creatorID=""0"" nodeType=""1044"" template=""" + templateId + @""" sortOrder=""1"" createDate=""2012-07-20T18:07:54"" updateDate=""2012-07-20T19:10:27"" nodeName=""Sub2"" urlName=""sub2"" writerName=""admin"" creatorName=""admin"" path=""-1,1046,1173,1174"" isDoc="""">
<content><![CDATA[]]></content>
<umbracoUrlAlias><![CDATA[only/one/alias]]></umbracoUrlAlias>
<creatorName><![CDATA[Custom data with same property name as the member name]]></creatorName>
</Home>
<Home id=""1176"" parentID=""1173"" level=""3"" writerID=""0"" creatorID=""0"" nodeType=""1044"" template=""" + templateId + @""" sortOrder=""3"" createDate=""2012-07-20T18:08:08"" updateDate=""2012-07-20T19:10:52"" nodeName=""Sub 3"" urlName=""sub-3"" writerName=""admin"" creatorName=""admin"" path=""-1,1046,1173,1176"" isDoc="""">
</Home>
<CustomDocument id=""1177"" parentID=""1173"" level=""3"" writerID=""0"" creatorID=""0"" nodeType=""1234"" template=""" + templateId + @""" sortOrder=""2"" createDate=""2012-07-16T15:26:59"" updateDate=""2012-07-18T14:23:35"" nodeName=""custom sub 1"" urlName=""custom-sub-1"" writerName=""admin"" creatorName=""admin"" path=""-1,1046,1173,1177"" isDoc="""" />
<CustomDocument id=""1178"" parentID=""1173"" level=""3"" writerID=""0"" creatorID=""0"" nodeType=""1234"" template=""" + templateId + @""" sortOrder=""3"" createDate=""2012-07-16T15:26:59"" updateDate=""2012-07-16T14:23:35"" nodeName=""custom sub 2"" urlName=""custom-sub-2"" writerName=""admin"" creatorName=""admin"" path=""-1,1046,1173,1178"" isDoc="""" />
<Home id=""1176"" parentID=""1173"" level=""3"" writerID=""0"" creatorID=""0"" nodeType=""1044"" template=""" + templateId + @""" sortOrder=""4"" createDate=""2012-07-20T18:08:08"" updateDate=""2012-07-20T19:10:52"" nodeName=""Sub 3"" urlName=""sub-3"" writerName=""admin"" creatorName=""admin"" path=""-1,1046,1173,1176"" isDoc="""">
<content><![CDATA[]]></content>
<umbracoNaviHide>1</umbracoNaviHide>
</Home>
<CustomDocument id=""1177"" parentID=""1173"" level=""3"" writerID=""0"" creatorID=""0"" nodeType=""1234"" template=""" + templateId + @""" sortOrder=""4"" createDate=""2012-07-16T15:26:59"" updateDate=""2012-07-18T14:23:35"" nodeName=""custom sub 1"" urlName=""custom-sub-1"" writerName=""admin"" creatorName=""admin"" path=""-1,1046,1173,1177"" isDoc="""" />
<CustomDocument id=""1178"" parentID=""1173"" level=""3"" writerID=""0"" creatorID=""0"" nodeType=""1234"" template=""" + templateId + @""" sortOrder=""4"" createDate=""2012-07-16T15:26:59"" updateDate=""2012-07-16T14:23:35"" nodeName=""custom sub 2"" urlName=""custom-sub-2"" writerName=""admin"" creatorName=""admin"" path=""-1,1046,1173,1178"" isDoc="""" />
</Home>
<Home id=""1175"" parentID=""1046"" level=""2"" writerID=""0"" creatorID=""0"" nodeType=""1044"" template=""" + templateId + @""" sortOrder=""3"" createDate=""2012-07-20T18:08:01"" updateDate=""2012-07-20T18:49:32"" nodeName=""Sub 2"" urlName=""sub-2"" writerName=""admin"" creatorName=""admin"" path=""-1,1046,1175"" isDoc=""""><content><![CDATA[]]></content>
<Home id=""1175"" parentID=""1046"" level=""2"" writerID=""0"" creatorID=""0"" nodeType=""1044"" template=""" + templateId + @""" sortOrder=""2"" createDate=""2012-07-20T18:08:01"" updateDate=""2012-07-20T18:49:32"" nodeName=""Sub 2"" urlName=""sub-2"" writerName=""admin"" creatorName=""admin"" path=""-1,1046,1175"" isDoc=""""><content><![CDATA[]]></content>
</Home>
<CustomDocument id=""4444"" parentID=""1046"" level=""2"" writerID=""0"" creatorID=""0"" nodeType=""1234"" template=""" + templateId + @""" sortOrder=""4"" createDate=""2012-07-16T15:26:59"" updateDate=""2012-07-18T14:23:35"" nodeName=""Test"" urlName=""test-page"" writerName=""admin"" creatorName=""admin"" path=""-1,1046,4444"" isDoc="""">
<CustomDocument id=""4444"" parentID=""1046"" level=""2"" writerID=""0"" creatorID=""0"" nodeType=""1234"" template=""" + templateId + @""" sortOrder=""3"" createDate=""2012-07-16T15:26:59"" updateDate=""2012-07-18T14:23:35"" nodeName=""Test"" urlName=""test-page"" writerName=""admin"" creatorName=""admin"" path=""-1,1046,4444"" isDoc="""">
<selectedNodes><![CDATA[1172,1176,1173]]></selectedNodes>
</CustomDocument>
</Home>
@@ -62,38 +64,12 @@ namespace Umbraco.Tests.PublishedContent
public override void Initialize()
{
base.Initialize();
PropertyEditorValueConvertersResolver.Current = new PropertyEditorValueConvertersResolver(
new[]
{
typeof(DatePickerPropertyEditorValueConverter),
typeof(TinyMcePropertyEditorValueConverter),
typeof(YesNoPropertyEditorValueConverter)
});
//need to specify a custom callback for unit tests
PublishedContentHelper.GetDataTypeCallback = (docTypeAlias, propertyAlias) =>
{
if (propertyAlias == "content")
{
//return the rte type id
return Guid.Parse("5e9b75ae-face-41c8-b47e-5f4b0fd82f83");
}
return Guid.Empty;
};
var umbCtx = GetUmbracoContext("/test", 1234);
UmbracoContext.Current = umbCtx;
PublishedContentStoreResolver.Current = new PublishedContentStoreResolver(new DefaultPublishedContentStore());
}
public override void TearDown()
{
base.TearDown();
PropertyEditorValueConvertersResolver.Reset();
PublishedContentStoreResolver.Reset();
UmbracoContext.Current = null;
}
internal IPublishedContent GetNode(int id)
@@ -105,6 +81,122 @@ namespace Umbraco.Tests.PublishedContent
return doc;
}
[Test]
public void Is_Last_From_Where_Filter_Dynamic_Linq()
{
var doc = GetNode(1173);
foreach (var d in doc.Children.Where("Visible"))
{
if (d.Id != 1178)
{
Assert.IsFalse(d.IsLast());
}
else
{
Assert.IsTrue(d.IsLast());
}
}
}
[Test]
public void Is_Last_From_Where_Filter()
{
var doc = GetNode(1173);
foreach (var d in doc.Children.Where(x => x.IsVisible()))
{
if (d.Id != 1178)
{
Assert.IsFalse(d.IsLast());
}
else
{
Assert.IsTrue(d.IsLast());
}
}
}
[Test]
public void Is_Last_From_Take()
{
var doc = GetNode(1173);
foreach (var d in doc.Children.Take(3))
{
if (d.Id != 1178)
{
Assert.IsFalse(d.IsLast());
}
else
{
Assert.IsTrue(d.IsLast());
}
}
}
[Test]
public void Is_Last_From_Skip()
{
var doc = GetNode(1173);
foreach (var d in doc.Children.Skip(1))
{
if (d.Id != 1176)
{
Assert.IsFalse(d.IsLast());
}
else
{
Assert.IsTrue(d.IsLast());
}
}
}
[Test]
public void Is_Last_From_Concat()
{
var doc = GetNode(1173);
foreach (var d in doc.Children.Concat(new[] { GetNode(1175), GetNode(4444) }))
{
if (d.Id != 4444)
{
Assert.IsFalse(d.IsLast());
}
else
{
Assert.IsTrue(d.IsLast());
}
}
}
[Test]
public void Descendants_Ordered_Properly()
{
var doc = GetNode(1046);
var currentLevel = 0;
var lastSortOrder = 0;
var levelChangesAt = new[] { 1046, 1173, 1174 };
foreach (var d in doc.DescendantsOrSelf())
{
if (levelChangesAt.Contains(d.Id))
{
Assert.Greater(d.Level, currentLevel);
currentLevel = d.Level;
}
else
{
Assert.AreEqual(currentLevel, d.Level);
Assert.Greater(d.SortOrder, lastSortOrder);
}
lastSortOrder = d.SortOrder;
}
}
[Test]
public void Get_Property_Value_Uses_Converter()
{
@@ -138,11 +230,11 @@ namespace Umbraco.Tests.PublishedContent
var doc = GetNode(1173);
Assert.AreEqual(0, doc.Index());
doc = GetNode(1176);
Assert.AreEqual(1, doc.Index());
doc = GetNode(1177);
Assert.AreEqual(2, doc.Index());
doc = GetNode(1178);
Assert.AreEqual(3, doc.Index());
doc = GetNode(1177);
Assert.AreEqual(1, doc.Index());
doc = GetNode(1178);
Assert.AreEqual(2, doc.Index());
}
[Test]
@@ -373,7 +465,7 @@ namespace Umbraco.Tests.PublishedContent
[Test]
public void Next_Without_Sibling()
{
var doc = GetNode(1178);
var doc = GetNode(1176);
Assert.IsNull(doc.Next());
}
@@ -395,7 +487,7 @@ namespace Umbraco.Tests.PublishedContent
Assert.IsNotNull(result);
Assert.AreEqual((int)1174, (int)result.Id);
Assert.AreEqual((int)1178, (int)result.Id);
}
}
}
@@ -24,68 +24,24 @@ using System.Linq;
namespace Umbraco.Tests.PublishedContent
{
/// <summary>
/// <summary>
/// Tests the typed extension methods on IPublishedContent using the DefaultPublishedMediaStore
/// </summary>
[TestFixture]
public class PublishedMediaTests : BaseWebTest
[TestFixture, RequiresSTA]
public class PublishedMediaTests : PublishedContentTestBase
{
public override void Initialize()
{
base.Initialize();
DoInitialization(GetUmbracoContext("/test", 1234));
UmbracoSettings.ForceSafeAliases = true;
UmbracoSettings.UmbracoLibraryCacheDuration = 1800;
UmbracoSettings.ForceSafeAliases = true;
}
/// <summary>
/// Shared with PublishMediaStoreTests
/// </summary>
/// <param name="umbContext"></param>
internal static void DoInitialization(UmbracoContext umbContext)
{
PropertyEditorValueConvertersResolver.Current = new PropertyEditorValueConvertersResolver(
new[]
{
typeof(DatePickerPropertyEditorValueConverter),
typeof(TinyMcePropertyEditorValueConverter),
typeof(YesNoPropertyEditorValueConverter)
});
//need to specify a custom callback for unit tests
PublishedContentHelper.GetDataTypeCallback = (docTypeAlias, propertyAlias) =>
{
if (propertyAlias == "content")
{
//return the rte type id
return Guid.Parse("5e9b75ae-face-41c8-b47e-5f4b0fd82f83");
}
return Guid.Empty;
};
UmbracoSettings.ForceSafeAliases = true;
UmbracoSettings.UmbracoLibraryCacheDuration = 1800;
UmbracoContext.Current = umbContext;
PublishedMediaStoreResolver.Current = new PublishedMediaStoreResolver(new DefaultPublishedMediaStore());
UmbracoSettings.ForceSafeAliases = true;
}
public override void TearDown()
{
base.TearDown();
DoTearDown();
}
/// <summary>
/// Shared with PublishMediaStoreTests
/// </summary>
internal static void DoTearDown()
{
PropertyEditorValueConvertersResolver.Reset();
UmbracoContext.Current = null;
PublishedMediaStoreResolver.Reset();
}
/// <summary>
@@ -108,7 +64,33 @@ namespace Umbraco.Tests.PublishedContent
return GetNode(id, GetUmbracoContext("/test", 1234));
}
[Test]
[Test]
public void Ensure_Children_Sorted_With_Examine()
{
var newIndexFolder = new DirectoryInfo(Path.Combine("App_Data\\CWSIndexSetTest", Guid.NewGuid().ToString()));
var indexInit = new IndexInitializer();
var indexer = indexInit.GetUmbracoIndexer(newIndexFolder);
indexer.RebuildIndex();
var store = new DefaultPublishedMediaStore(
indexInit.GetUmbracoSearcher(newIndexFolder),
indexInit.GetUmbracoIndexer(newIndexFolder));
//we are using the media.xml media to test the examine results implementation, see the media.xml file in the ExamineHelpers namespace
var publishedMedia = store.GetDocumentById(GetUmbracoContext("/test", 1234), 1111);
var rootChildren = publishedMedia.Children().ToArray();
var currSort = 0;
for (var i = 0; i < rootChildren.Count(); i++)
{
Assert.GreaterOrEqual(rootChildren[i].SortOrder, currSort);
currSort = rootChildren[i].SortOrder;
}
}
[Test]
public void Children_With_Examine()
{
var newIndexFolder = new DirectoryInfo(Path.Combine("App_Data\\CWSIndexSetTest", Guid.NewGuid().ToString()));
@@ -116,7 +98,9 @@ namespace Umbraco.Tests.PublishedContent
var indexer = indexInit.GetUmbracoIndexer(newIndexFolder);
indexer.RebuildIndex();
var store = new DefaultPublishedMediaStore(indexInit.GetUmbracoSearcher(newIndexFolder));
var store = new DefaultPublishedMediaStore(
indexInit.GetUmbracoSearcher(newIndexFolder),
indexInit.GetUmbracoIndexer(newIndexFolder));
//we are using the media.xml media to test the examine results implementation, see the media.xml file in the ExamineHelpers namespace
var publishedMedia = store.GetDocumentById(GetUmbracoContext("/test", 1234), 1111);
@@ -136,7 +120,9 @@ namespace Umbraco.Tests.PublishedContent
var indexer = indexInit.GetUmbracoIndexer(newIndexFolder);
indexer.RebuildIndex();
var store = new DefaultPublishedMediaStore(indexInit.GetUmbracoSearcher(newIndexFolder));
var store = new DefaultPublishedMediaStore(
indexInit.GetUmbracoSearcher(newIndexFolder),
indexInit.GetUmbracoIndexer(newIndexFolder));
//we are using the media.xml media to test the examine results implementation, see the media.xml file in the ExamineHelpers namespace
var publishedMedia = store.GetDocumentById(GetUmbracoContext("/test", 1234), 1111);
@@ -156,7 +142,9 @@ namespace Umbraco.Tests.PublishedContent
var indexer = indexInit.GetUmbracoIndexer(newIndexFolder);
indexer.RebuildIndex();
var store = new DefaultPublishedMediaStore(indexInit.GetUmbracoSearcher(newIndexFolder));
var store = new DefaultPublishedMediaStore(
indexInit.GetUmbracoSearcher(newIndexFolder),
indexInit.GetUmbracoIndexer(newIndexFolder));
//we are using the media.xml media to test the examine results implementation, see the media.xml file in the ExamineHelpers namespace
var publishedMedia = store.GetDocumentById(GetUmbracoContext("/test", 1234), 1111);
@@ -176,7 +164,9 @@ namespace Umbraco.Tests.PublishedContent
var indexer = indexInit.GetUmbracoIndexer(newIndexFolder);
indexer.RebuildIndex();
var store = new DefaultPublishedMediaStore(indexInit.GetUmbracoSearcher(newIndexFolder));
var store = new DefaultPublishedMediaStore(
indexInit.GetUmbracoSearcher(newIndexFolder),
indexInit.GetUmbracoIndexer(newIndexFolder));
//we are using the media.xml media to test the examine results implementation, see the media.xml file in the ExamineHelpers namespace
var publishedMedia = store.GetDocumentById(GetUmbracoContext("/test", 1234), 3113);
@@ -192,7 +182,9 @@ namespace Umbraco.Tests.PublishedContent
var indexer = indexInit.GetUmbracoIndexer(newIndexFolder);
indexer.RebuildIndex();
var store = new DefaultPublishedMediaStore(indexInit.GetUmbracoSearcher(newIndexFolder));
var store = new DefaultPublishedMediaStore(
indexInit.GetUmbracoSearcher(newIndexFolder),
indexInit.GetUmbracoIndexer(newIndexFolder));
//we are using the media.xml media to test the examine results implementation, see the media.xml file in the ExamineHelpers namespace
var publishedMedia = store.GetDocumentById(GetUmbracoContext("/test", 1234), 3113);
@@ -4,15 +4,27 @@ using System.Collections.ObjectModel;
using System.Linq;
using NUnit.Framework;
using Umbraco.Core;
using Umbraco.Core.Configuration;
using Umbraco.Core.Models;
using Umbraco.Tests.TestHelpers;
using Umbraco.Web;
using Umbraco.Web.Models;
namespace Umbraco.Tests.PublishedContent
{
[TestFixture]
public class StronglyTypedQueryTests : BaseWebTest
public class StronglyTypedQueryTests : PublishedContentTestBase
{
public override void Initialize()
{
base.Initialize();
}
public override void TearDown()
{
base.TearDown();
}
protected override bool RequiresDbSetup
{
get { return false; }
@@ -69,7 +81,7 @@ namespace Umbraco.Tests.PublishedContent
return doc;
}
[Ignore]
[Test]
public void Type_Test()
{
@@ -79,7 +91,7 @@ namespace Umbraco.Tests.PublishedContent
Assert.AreEqual("John Smith", result[1].ArticleAuthor);
}
[Ignore]
[Test]
public void As_Test()
{
@@ -204,7 +216,7 @@ namespace Umbraco.Tests.PublishedContent
}
}
public class PublishedContentWrapper : IPublishedContent
public class PublishedContentWrapper : IPublishedContent, IOwnerCollectionAware<IPublishedContent>
{
protected IPublishedContent WrappedContent { get; private set; }
@@ -294,6 +306,46 @@ namespace Umbraco.Tests.PublishedContent
{
return WrappedContent.GetProperty(alias);
}
private IEnumerable<IPublishedContent> _ownersCollection;
/// <summary>
/// Need to get/set the owner collection when an item is returned from the result set of a query
/// </summary>
/// <remarks>
/// Based on this issue here: http://issues.umbraco.org/issue/U4-1797
/// </remarks>
IEnumerable<IPublishedContent> IOwnerCollectionAware<IPublishedContent>.OwnersCollection
{
get
{
var publishedContentBase = WrappedContent as IOwnerCollectionAware<IPublishedContent>;
if (publishedContentBase != null)
{
return publishedContentBase.OwnersCollection;
}
//if the owners collection is null, we'll default to it's siblings
if (_ownersCollection == null)
{
//get the root docs if parent is null
_ownersCollection = this.Siblings();
}
return _ownersCollection;
}
set
{
var publishedContentBase = WrappedContent as IOwnerCollectionAware<IPublishedContent>;
if (publishedContentBase != null)
{
publishedContentBase.OwnersCollection = value;
}
else
{
_ownersCollection = value;
}
}
}
}
public partial class HomeContentItem : ContentPageContentItem
@@ -9,12 +9,6 @@ namespace Umbraco.Tests.Routing
[TestFixture]
public class LookupByAliasTests : BaseRoutingTest
{
public override void Initialize()
{
base.Initialize();
Umbraco.Core.Configuration.UmbracoSettings.UseLegacyXmlSchema = false;
}
/// <summary>
/// We don't need a db for this test, will run faster without one
/// </summary>
@@ -9,12 +9,6 @@ namespace Umbraco.Tests.Routing
[TestFixture]
public class LookupByNiceUrlAndTemplateTests : BaseRoutingTest
{
public override void Initialize()
{
base.Initialize();
Umbraco.Core.Configuration.UmbracoSettings.UseLegacyXmlSchema = false;
}
[TestCase("/blah")]
[TestCase("/default.aspx/blah")] //this one is actually rather important since this is the path that comes through when we are running in pre-IIS 7 for the root document '/' !
[TestCase("/home/Sub1/blah")]
@@ -1,5 +1,6 @@
using System.Configuration;
using NUnit.Framework;
using Umbraco.Core.Configuration;
using Umbraco.Tests.TestHelpers;
using Umbraco.Web.Routing;
using umbraco.BusinessLogic;
@@ -10,11 +11,15 @@ namespace Umbraco.Tests.Routing
[TestFixture]
public class LookupByNiceUrlTests : BaseRoutingTest
{
public override void Initialize()
{
base.Initialize();
Umbraco.Core.Configuration.UmbracoSettings.UseLegacyXmlSchema = false;
}
public override void Initialize()
{
base.Initialize();
}
public override void TearDown()
{
base.TearDown();
}
/// <summary>
/// We don't need a db for this test, will run faster without one
@@ -24,7 +29,7 @@ namespace Umbraco.Tests.Routing
get { return false; }
}
[Ignore]
[TestCase("/", 1046)]
[TestCase("/default.aspx", 1046)] //this one is actually rather important since this is the path that comes through when we are running in pre-IIS 7 for the root document '/' !
[TestCase("/Sub1", 1173)]
@@ -41,8 +46,8 @@ namespace Umbraco.Tests.Routing
var routingContext = GetRoutingContext(urlString);
var url = routingContext.UmbracoContext.CleanedUmbracoUrl; //very important to use the cleaned up umbraco url
var docreq = new PublishedContentRequest(url, routingContext);
var lookup = new LookupByNiceUrl();
ConfigurationManager.AppSettings.Set("umbracoHideTopLevelNodeFromPath", "true");
var lookup = new LookupByNiceUrl(false);
SettingsForTests.HideTopLevelNodeFromPath = true;
var result = lookup.TrySetDocument(docreq);
@@ -57,7 +62,7 @@ namespace Umbraco.Tests.Routing
}
}
[Ignore]
[TestCase("/", 1046)]
[TestCase("/default.aspx", 1046)] //this one is actually rather important since this is the path that comes through when we are running in pre-IIS 7 for the root document '/' !
[TestCase("/home", 1046)]
@@ -69,8 +74,9 @@ namespace Umbraco.Tests.Routing
var routingContext = GetRoutingContext(urlString);
var url = routingContext.UmbracoContext.CleanedUmbracoUrl; //very important to use the cleaned up umbraco url
var docreq = new PublishedContentRequest(url, routingContext);
var lookup = new LookupByNiceUrl();
var lookup = new LookupByNiceUrl(false);
SettingsForTests.HideTopLevelNodeFromPath = false;
var result = lookup.TrySetDocument(docreq);
Assert.IsTrue(result);
@@ -18,16 +18,8 @@ namespace Umbraco.Tests.Routing
{
base.Initialize();
InitializeLanguagesAndDomains();
Umbraco.Core.Configuration.UmbracoSettings.UseLegacyXmlSchema = false;
}
public override void TearDown()
{
base.TearDown();
}
void InitializeLanguagesAndDomains()
{
var domains = Domain.GetDomains();
@@ -154,7 +146,7 @@ namespace Umbraco.Tests.Routing
{
SetDomains3();
ConfigurationManager.AppSettings.Set("umbracoHideTopLevelNodeFromPath", "true");
SettingsForTests.HideTopLevelNodeFromPath = true;
var routingContext = GetRoutingContext(url);
var uri = routingContext.UmbracoContext.CleanedUmbracoUrl; //very important to use the cleaned up umbraco url
@@ -193,7 +185,7 @@ namespace Umbraco.Tests.Routing
{
SetDomains4();
ConfigurationManager.AppSettings.Set("umbracoHideTopLevelNodeFromPath", "true");
SettingsForTests.HideTopLevelNodeFromPath = true;
var routingContext = GetRoutingContext(url);
var uri = routingContext.UmbracoContext.CleanedUmbracoUrl; //very important to use the cleaned up umbraco url
@@ -1,6 +1,8 @@
using System;
using System.Configuration;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using NUnit.Framework;
using Umbraco.Tests.TestHelpers;
using Umbraco.Web.Routing;
@@ -13,15 +15,17 @@ namespace Umbraco.Tests.Routing
public override void Initialize()
{
base.Initialize();
Umbraco.Core.Configuration.UmbracoSettings.UseLegacyXmlSchema = false;
}
public override void TearDown()
{
base.TearDown();
var currDir = new DirectoryInfo(TestHelper.CurrentAssemblyDirectory);
File.Copy(
currDir.Parent.Parent.Parent.GetDirectories("Umbraco.Web.UI")
.First()
.GetDirectories("config").First()
.GetFiles("umbracoSettings.Release.config").First().FullName,
Path.Combine(currDir.Parent.Parent.FullName, "config", "umbracoSettings.config"),
true);
ConfigurationManager.AppSettings.Set("umbracoUseDirectoryUrls", "");
ConfigurationManager.AppSettings.Set("umbracoHideTopLevelNodeFromPath", "");
SettingsForTests.SettingsFilePath = Core.IO.IOHelper.MapPath(Core.IO.SystemDirectories.Config + Path.DirectorySeparatorChar, false);
}
internal override IRoutesCache GetRoutesCache()
@@ -33,11 +37,14 @@ namespace Umbraco.Tests.Routing
/// This checks that when we retreive a NiceUrl for multiple items that there are no issues with cache overlap
/// and that they are all cached correctly.
/// </summary>
[Ignore]
[Test]
public void Ensure_Cache_Is_Correct()
{
var routingContext = GetRoutingContext("/test", 1111);
ConfigurationManager.AppSettings.Set("umbracoUseDirectoryUrls", "true");
SettingsForTests.UseDirectoryUrls = true;
SettingsForTests.HideTopLevelNodeFromPath = false;
SettingsForTests.AddTrailingSlash = false; // (cached routes have none)
var samples = new Dictionary<int, string> {
{ 1046, "/home" },
@@ -84,22 +91,22 @@ namespace Umbraco.Tests.Routing
}
// test hideTopLevelNodeFromPath false
[TestCase(1046, "/home")]
[TestCase(1173, "/home/sub1")]
[TestCase(1174, "/home/sub1/sub2")]
[TestCase(1176, "/home/sub1/sub-3")]
[TestCase(1177, "/home/sub1/custom-sub-1")]
[TestCase(1178, "/home/sub1/custom-sub-2")]
[TestCase(1175, "/home/sub-2")]
[TestCase(1172, "/test-page")]
[TestCase(1046, "/home/")]
[TestCase(1173, "/home/sub1/")]
[TestCase(1174, "/home/sub1/sub2/")]
[TestCase(1176, "/home/sub1/sub-3/")]
[TestCase(1177, "/home/sub1/custom-sub-1/")]
[TestCase(1178, "/home/sub1/custom-sub-2/")]
[TestCase(1175, "/home/sub-2/")]
[TestCase(1172, "/test-page/")]
public void Get_Nice_Url_Not_Hiding_Top_Level(int nodeId, string niceUrlMatch)
{
var routingContext = GetRoutingContext("/test", 1111);
ConfigurationManager.AppSettings.Set("umbracoUseDirectoryUrls", "true");
ConfigurationManager.AppSettings.Set("umbracoHideTopLevelNodeFromPath", "false");
Umbraco.Core.Configuration.UmbracoSettings.UseDomainPrefixes = false;
SettingsForTests.UseDirectoryUrls = true;
SettingsForTests.HideTopLevelNodeFromPath = false;
SettingsForTests.UseDomainPrefixes = false;
var result = routingContext.NiceUrlProvider.GetNiceUrl(nodeId);
Assert.AreEqual(niceUrlMatch, result);
@@ -109,21 +116,21 @@ namespace Umbraco.Tests.Routing
// test hideTopLevelNodeFromPath true
[TestCase(1046, "/")]
[TestCase(1173, "/sub1")]
[TestCase(1174, "/sub1/sub2")]
[TestCase(1176, "/sub1/sub-3")]
[TestCase(1177, "/sub1/custom-sub-1")]
[TestCase(1178, "/sub1/custom-sub-2")]
[TestCase(1175, "/sub-2")]
[TestCase(1172, "/test-page")] // not hidden because not first root
[TestCase(1173, "/sub1/")]
[TestCase(1174, "/sub1/sub2/")]
[TestCase(1176, "/sub1/sub-3/")]
[TestCase(1177, "/sub1/custom-sub-1/")]
[TestCase(1178, "/sub1/custom-sub-2/")]
[TestCase(1175, "/sub-2/")]
[TestCase(1172, "/test-page/")] // not hidden because not first root
public void Get_Nice_Url_Hiding_Top_Level(int nodeId, string niceUrlMatch)
{
var routingContext = GetRoutingContext("/test", 1111);
ConfigurationManager.AppSettings.Set("umbracoUseDirectoryUrls", "true");
ConfigurationManager.AppSettings.Set("umbracoHideTopLevelNodeFromPath", "true");
Umbraco.Core.Configuration.UmbracoSettings.UseDomainPrefixes = false;
SettingsForTests.UseDirectoryUrls = true;
SettingsForTests.HideTopLevelNodeFromPath = true;
SettingsForTests.UseDomainPrefixes = false;
var result = routingContext.NiceUrlProvider.GetNiceUrl(nodeId);
Assert.AreEqual(niceUrlMatch, result);
@@ -134,18 +141,18 @@ namespace Umbraco.Tests.Routing
{
var routingContext = GetRoutingContext("http://example.com/test", 1111);
ConfigurationManager.AppSettings.Set("umbracoUseDirectoryUrls", "true");
ConfigurationManager.AppSettings.Set("umbracoHideTopLevelNodeFromPath", "false");
SettingsForTests.UseDirectoryUrls = true;
SettingsForTests.HideTopLevelNodeFromPath = false;
Umbraco.Core.Configuration.UmbracoSettings.UseDomainPrefixes = false;
Assert.AreEqual("/home/sub1/custom-sub-1", routingContext.NiceUrlProvider.GetNiceUrl(1177));
SettingsForTests.UseDomainPrefixes = false;
Assert.AreEqual("/home/sub1/custom-sub-1/", routingContext.NiceUrlProvider.GetNiceUrl(1177));
Umbraco.Core.Configuration.UmbracoSettings.UseDomainPrefixes = true;
Assert.AreEqual("http://example.com/home/sub1/custom-sub-1", routingContext.NiceUrlProvider.GetNiceUrl(1177));
SettingsForTests.UseDomainPrefixes = true;
Assert.AreEqual("http://example.com/home/sub1/custom-sub-1/", routingContext.NiceUrlProvider.GetNiceUrl(1177));
Umbraco.Core.Configuration.UmbracoSettings.UseDomainPrefixes = false;
SettingsForTests.UseDomainPrefixes = false;
routingContext.NiceUrlProvider.EnforceAbsoluteUrls = true;
Assert.AreEqual("http://example.com/home/sub1/custom-sub-1", routingContext.NiceUrlProvider.GetNiceUrl(1177));
Assert.AreEqual("http://example.com/home/sub1/custom-sub-1/", routingContext.NiceUrlProvider.GetNiceUrl(1177));
}
[Test]
@@ -153,14 +160,14 @@ namespace Umbraco.Tests.Routing
{
var routingContext = GetRoutingContext("http://example.com/test", 1111);
ConfigurationManager.AppSettings.Set("umbracoUseDirectoryUrls", "true");
ConfigurationManager.AppSettings.Set("umbracoHideTopLevelNodeFromPath", "false");
SettingsForTests.UseDirectoryUrls = true;
SettingsForTests.HideTopLevelNodeFromPath = false;
Umbraco.Core.Configuration.UmbracoSettings.UseDomainPrefixes = false;
SettingsForTests.UseDomainPrefixes = false;
Assert.AreEqual("#", routingContext.NiceUrlProvider.GetNiceUrl(999999));
Umbraco.Core.Configuration.UmbracoSettings.UseDomainPrefixes = true;
SettingsForTests.UseDomainPrefixes = true;
Assert.AreEqual("#", routingContext.NiceUrlProvider.GetNiceUrl(999999));
Umbraco.Core.Configuration.UmbracoSettings.UseDomainPrefixes = false;
SettingsForTests.UseDomainPrefixes = false;
routingContext.NiceUrlProvider.EnforceAbsoluteUrls = true;
Assert.AreEqual("#", routingContext.NiceUrlProvider.GetNiceUrl(999999));
}
@@ -14,20 +14,11 @@ namespace Umbraco.Tests.Routing
[TestFixture]
public class NiceUrlsProviderWithDomainsTests : BaseRoutingTest
{
public override void TearDown()
{
base.TearDown();
ConfigurationManager.AppSettings.Set("umbracoUseDirectoryUrls", "");
ConfigurationManager.AppSettings.Set("umbracoHideTopLevelNodeFromPath", "");
}
internal override IRoutesCache GetRoutesCache()
{
return new DefaultRoutesCache(false);
}
void InitializeLanguagesAndDomains()
{
var domains = Domain.GetDomains();
@@ -181,24 +172,23 @@ namespace Umbraco.Tests.Routing
// with one simple domain "domain1.com"
// basic tests
[TestCase(1001, "http://domain1.com", false, "/")]
[TestCase(10011, "http://domain1.com", false, "/1001-1")]
[TestCase(1002, "http://domain1.com", false, "/1002")]
[TestCase(10011, "http://domain1.com", false, "/1001-1/")]
[TestCase(1002, "http://domain1.com", false, "/1002/")]
// absolute tests
[TestCase(1001, "http://domain1.com", true, "http://domain1.com/")]
[TestCase(10011, "http://domain1.com", true, "http://domain1.com/1001-1")]
[TestCase(10011, "http://domain1.com", true, "http://domain1.com/1001-1/")]
// different current tests
[TestCase(1001, "http://domain2.com", false, "http://domain1.com/")]
[TestCase(10011, "http://domain2.com", false, "http://domain1.com/1001-1")]
[TestCase(10011, "http://domain2.com", false, "http://domain1.com/1001-1/")]
[TestCase(1001, "https://domain1.com", false, "/")]
[TestCase(10011, "https://domain1.com", false, "/1001-1")]
[TestCase(10011, "https://domain1.com", false, "/1001-1/")]
public void Get_Nice_Url_SimpleDomain(int nodeId, string currentUrl, bool absolute, string expected)
{
var routingContext = GetRoutingContext("/test", 1111);
ConfigurationManager.AppSettings.Set("umbracoUseDirectoryUrls", "true");
ConfigurationManager.AppSettings.Set("umbracoHideTopLevelNodeFromPath", "false"); // ignored w/domains
Umbraco.Core.Configuration.UmbracoSettings.UseDomainPrefixes = false;
SettingsForTests.UseDirectoryUrls = true;
SettingsForTests.HideTopLevelNodeFromPath = false; // ignored w/domains
SettingsForTests.UseDomainPrefixes = false;
InitializeLanguagesAndDomains();
SetDomains1();
@@ -210,25 +200,24 @@ namespace Umbraco.Tests.Routing
// with one complete domain "http://domain1.com/foo"
// basic tests
[TestCase(1001, "http://domain1.com", false, "/foo")]
[TestCase(10011, "http://domain1.com", false, "/foo/1001-1")]
[TestCase(1002, "http://domain1.com", false, "/1002")]
[TestCase(1001, "http://domain1.com", false, "/foo/")]
[TestCase(10011, "http://domain1.com", false, "/foo/1001-1/")]
[TestCase(1002, "http://domain1.com", false, "/1002/")]
// absolute tests
[TestCase(1001, "http://domain1.com", true, "http://domain1.com/foo")]
[TestCase(10011, "http://domain1.com", true, "http://domain1.com/foo/1001-1")]
[TestCase(1001, "http://domain1.com", true, "http://domain1.com/foo/")]
[TestCase(10011, "http://domain1.com", true, "http://domain1.com/foo/1001-1/")]
// different current tests
[TestCase(1001, "http://domain2.com", false, "http://domain1.com/foo")]
[TestCase(10011, "http://domain2.com", false, "http://domain1.com/foo/1001-1")]
[TestCase(1001, "https://domain1.com", false, "http://domain1.com/foo")]
[TestCase(10011, "https://domain1.com", false, "http://domain1.com/foo/1001-1")]
[TestCase(1001, "http://domain2.com", false, "http://domain1.com/foo/")]
[TestCase(10011, "http://domain2.com", false, "http://domain1.com/foo/1001-1/")]
[TestCase(1001, "https://domain1.com", false, "http://domain1.com/foo/")]
[TestCase(10011, "https://domain1.com", false, "http://domain1.com/foo/1001-1/")]
public void Get_Nice_Url_SimpleWithSchemeAndPath(int nodeId, string currentUrl, bool absolute, string expected)
{
var routingContext = GetRoutingContext("/test", 1111);
ConfigurationManager.AppSettings.Set("umbracoUseDirectoryUrls", "true");
ConfigurationManager.AppSettings.Set("umbracoHideTopLevelNodeFromPath", "false"); // ignored w/domains
Umbraco.Core.Configuration.UmbracoSettings.UseDomainPrefixes = false;
SettingsForTests.UseDirectoryUrls = true;
SettingsForTests.HideTopLevelNodeFromPath = false; // ignored w/domains
SettingsForTests.UseDomainPrefixes = false;
InitializeLanguagesAndDomains();
SetDomains2();
@@ -239,18 +228,17 @@ namespace Umbraco.Tests.Routing
}
// with one domain, not at root
[TestCase(1001, "http://domain1.com", false, "/1001")]
[TestCase(1001, "http://domain1.com", false, "/1001/")]
[TestCase(10011, "http://domain1.com", false, "/")]
[TestCase(100111, "http://domain1.com", false, "/1001-1-1")]
[TestCase(1002, "http://domain1.com", false, "/1002")]
[TestCase(100111, "http://domain1.com", false, "/1001-1-1/")]
[TestCase(1002, "http://domain1.com", false, "/1002/")]
public void Get_Nice_Url_DeepDomain(int nodeId, string currentUrl, bool absolute, string expected)
{
var routingContext = GetRoutingContext("/test", 1111);
ConfigurationManager.AppSettings.Set("umbracoUseDirectoryUrls", "true");
ConfigurationManager.AppSettings.Set("umbracoHideTopLevelNodeFromPath", "false"); // ignored w/domains
Umbraco.Core.Configuration.UmbracoSettings.UseDomainPrefixes = false;
SettingsForTests.UseDirectoryUrls = true;
SettingsForTests.HideTopLevelNodeFromPath = false; // ignored w/domains
SettingsForTests.UseDomainPrefixes = false;
InitializeLanguagesAndDomains();
SetDomains3();
@@ -262,24 +250,23 @@ namespace Umbraco.Tests.Routing
// with nested domains
[TestCase(1001, "http://domain1.com", false, "/")]
[TestCase(10011, "http://domain1.com", false, "/en")]
[TestCase(100111, "http://domain1.com", false, "/en/1001-1-1")]
[TestCase(10012, "http://domain1.com", false, "/fr")]
[TestCase(100121, "http://domain1.com", false, "/fr/1001-2-1")]
[TestCase(10013, "http://domain1.com", false, "/1001-3")]
[TestCase(1002, "http://domain1.com", false, "/1002")]
[TestCase(10011, "http://domain1.com", false, "/en/")]
[TestCase(100111, "http://domain1.com", false, "/en/1001-1-1/")]
[TestCase(10012, "http://domain1.com", false, "/fr/")]
[TestCase(100121, "http://domain1.com", false, "/fr/1001-2-1/")]
[TestCase(10013, "http://domain1.com", false, "/1001-3/")]
[TestCase(1002, "http://domain1.com", false, "/1002/")]
[TestCase(1003, "http://domain3.com", false, "/")]
[TestCase(10031, "http://domain3.com", false, "/en")]
[TestCase(100321, "http://domain3.com", false, "/fr/1003-2-1")]
[TestCase(10031, "http://domain3.com", false, "/en/")]
[TestCase(100321, "http://domain3.com", false, "/fr/1003-2-1/")]
public void Get_Nice_Url_NestedDomains(int nodeId, string currentUrl, bool absolute, string expected)
{
var routingContext = GetRoutingContext("/test", 1111);
Umbraco.Core.Configuration.UmbracoSettings.UseDomainPrefixes = false;
ConfigurationManager.AppSettings.Set("umbracoUseDirectoryUrls", "true");
ConfigurationManager.AppSettings.Set("umbracoHideTopLevelNodeFromPath", "false"); // ignored w/domains
SettingsForTests.UseDirectoryUrls = true;
SettingsForTests.HideTopLevelNodeFromPath = false; // ignored w/domains
SettingsForTests.UseDomainPrefixes = false;
InitializeLanguagesAndDomains();
SetDomains4();
@@ -293,9 +280,9 @@ namespace Umbraco.Tests.Routing
{
var routingContext = GetRoutingContext("/test", 1111);
ConfigurationManager.AppSettings.Set("umbracoUseDirectoryUrls", "true");
ConfigurationManager.AppSettings.Set("umbracoHideTopLevelNodeFromPath", "false"); // ignored w/domains
Umbraco.Core.Configuration.UmbracoSettings.UseDomainPrefixes = false;
SettingsForTests.UseDirectoryUrls = true;
SettingsForTests.HideTopLevelNodeFromPath = false; // ignored w/domains
SettingsForTests.UseDomainPrefixes = false;
InitializeLanguagesAndDomains();
SetDomains4();
@@ -329,14 +316,14 @@ namespace Umbraco.Tests.Routing
// use the cache
Assert.AreEqual("/", routingContext.NiceUrlProvider.GetNiceUrl(1001, new Uri("http://domain1.com"), false));
Assert.AreEqual("/en", routingContext.NiceUrlProvider.GetNiceUrl(10011, new Uri("http://domain1.com"), false));
Assert.AreEqual("/en/1001-1-1", routingContext.NiceUrlProvider.GetNiceUrl(100111, new Uri("http://domain1.com"), false));
Assert.AreEqual("/fr", routingContext.NiceUrlProvider.GetNiceUrl(10012, new Uri("http://domain1.com"), false));
Assert.AreEqual("/fr/1001-2-1", routingContext.NiceUrlProvider.GetNiceUrl(100121, new Uri("http://domain1.com"), false));
Assert.AreEqual("/1001-3", routingContext.NiceUrlProvider.GetNiceUrl(10013, new Uri("http://domain1.com"), false));
Assert.AreEqual("/1002", routingContext.NiceUrlProvider.GetNiceUrl(1002, new Uri("http://domain1.com"), false));
Assert.AreEqual("/en/", routingContext.NiceUrlProvider.GetNiceUrl(10011, new Uri("http://domain1.com"), false));
Assert.AreEqual("/en/1001-1-1/", routingContext.NiceUrlProvider.GetNiceUrl(100111, new Uri("http://domain1.com"), false));
Assert.AreEqual("/fr/", routingContext.NiceUrlProvider.GetNiceUrl(10012, new Uri("http://domain1.com"), false));
Assert.AreEqual("/fr/1001-2-1/", routingContext.NiceUrlProvider.GetNiceUrl(100121, new Uri("http://domain1.com"), false));
Assert.AreEqual("/1001-3/", routingContext.NiceUrlProvider.GetNiceUrl(10013, new Uri("http://domain1.com"), false));
Assert.AreEqual("/1002/", routingContext.NiceUrlProvider.GetNiceUrl(1002, new Uri("http://domain1.com"), false));
Assert.AreEqual("http://domain1.com/fr/1001-2-1", routingContext.NiceUrlProvider.GetNiceUrl(100121, new Uri("http://domain2.com"), false));
Assert.AreEqual("http://domain1.com/fr/1001-2-1/", routingContext.NiceUrlProvider.GetNiceUrl(100121, new Uri("http://domain2.com"), false));
}
void CheckRoute(IDictionary<int, string> routes, IDictionary<string, int> ids, int id, string route)
@@ -352,24 +339,24 @@ namespace Umbraco.Tests.Routing
{
var routingContext = GetRoutingContext("http://domain1.com/test", 1111);
ConfigurationManager.AppSettings.Set("umbracoUseDirectoryUrls", "true");
ConfigurationManager.AppSettings.Set("umbracoHideTopLevelNodeFromPath", "false");
SettingsForTests.UseDirectoryUrls = true;
SettingsForTests.HideTopLevelNodeFromPath = false;
InitializeLanguagesAndDomains();
SetDomains4();
Umbraco.Core.Configuration.UmbracoSettings.UseDomainPrefixes = false;
Assert.AreEqual("/en/1001-1-1", routingContext.NiceUrlProvider.GetNiceUrl(100111));
Assert.AreEqual("http://domain3.com/en/1003-1-1", routingContext.NiceUrlProvider.GetNiceUrl(100311));
SettingsForTests.UseDomainPrefixes = false;
Assert.AreEqual("/en/1001-1-1/", routingContext.NiceUrlProvider.GetNiceUrl(100111));
Assert.AreEqual("http://domain3.com/en/1003-1-1/", routingContext.NiceUrlProvider.GetNiceUrl(100311));
Umbraco.Core.Configuration.UmbracoSettings.UseDomainPrefixes = true;
Assert.AreEqual("http://domain1.com/en/1001-1-1", routingContext.NiceUrlProvider.GetNiceUrl(100111));
Assert.AreEqual("http://domain3.com/en/1003-1-1", routingContext.NiceUrlProvider.GetNiceUrl(100311));
SettingsForTests.UseDomainPrefixes = true;
Assert.AreEqual("http://domain1.com/en/1001-1-1/", routingContext.NiceUrlProvider.GetNiceUrl(100111));
Assert.AreEqual("http://domain3.com/en/1003-1-1/", routingContext.NiceUrlProvider.GetNiceUrl(100311));
Umbraco.Core.Configuration.UmbracoSettings.UseDomainPrefixes = false;
routingContext.NiceUrlProvider.EnforceAbsoluteUrls = true;
Assert.AreEqual("http://domain1.com/en/1001-1-1", routingContext.NiceUrlProvider.GetNiceUrl(100111));
Assert.AreEqual("http://domain3.com/en/1003-1-1", routingContext.NiceUrlProvider.GetNiceUrl(100311));
SettingsForTests.UseDomainPrefixes = false;
routingContext.NiceUrlProvider.EnforceAbsoluteUrls = true;
Assert.AreEqual("http://domain1.com/en/1001-1-1/", routingContext.NiceUrlProvider.GetNiceUrl(100111));
Assert.AreEqual("http://domain3.com/en/1003-1-1/", routingContext.NiceUrlProvider.GetNiceUrl(100311));
}
[Test]
@@ -377,8 +364,8 @@ namespace Umbraco.Tests.Routing
{
var routingContext = GetRoutingContext("http://domain1.com/test", 1111);
ConfigurationManager.AppSettings.Set("umbracoUseDirectoryUrls", "true");
ConfigurationManager.AppSettings.Set("umbracoHideTopLevelNodeFromPath", "false");
SettingsForTests.UseDirectoryUrls = true;
SettingsForTests.HideTopLevelNodeFromPath = false;
InitializeLanguagesAndDomains();
SetDomains5();
@@ -389,9 +376,9 @@ namespace Umbraco.Tests.Routing
// all of them
// including the local one - duplicate?! - then must manually exclude?
Assert.AreEqual(3, result.Count());
Assert.IsTrue(result.Contains("http://domain1.com/en/1001-1-1"));
Assert.IsTrue(result.Contains("http://domain1a.com/en/1001-1-1"));
Assert.IsTrue(result.Contains("http://domain1b.com/en/1001-1-1"));
Assert.IsTrue(result.Contains("http://domain1.com/en/1001-1-1/"));
Assert.IsTrue(result.Contains("http://domain1a.com/en/1001-1-1/"));
Assert.IsTrue(result.Contains("http://domain1b.com/en/1001-1-1/"));
}
}
}
@@ -20,7 +20,7 @@ namespace Umbraco.Tests.Routing
public override void Initialize()
{
base.Initialize();
System.Configuration.ConfigurationManager.AppSettings.Set("umbracoPath", "~/umbraco");
SettingsForTests.UmbracoPath = "~/umbraco";
SurfaceControllerResolver.Current = new SurfaceControllerResolver(
PluginManager.Current.ResolveSurfaceControllers());
@@ -36,7 +36,6 @@ namespace Umbraco.Tests.Routing
{
base.TearDown();
RouteTable.Routes.Clear();
System.Configuration.ConfigurationManager.AppSettings.Set("umbracoPath", "");
SurfaceControllerResolver.Reset();
}
@@ -57,9 +57,9 @@ namespace Umbraco.Tests.Routing
//create the module
_module = new UmbracoModule();
ConfigurationManager.AppSettings.Set("umbracoConfigurationStatus", Umbraco.Core.Configuration.GlobalSettings.CurrentVersion);
ConfigurationManager.AppSettings.Set("umbracoReservedPaths", "~/umbraco,~/install/");
ConfigurationManager.AppSettings.Set("umbracoReservedUrls", "~/config/splashes/booting.aspx,~/install/default.aspx,~/config/splashes/noNodes.aspx,~/VSEnterpriseHelper.axd");
SettingsForTests.ConfigurationStatus = Core.Configuration.GlobalSettings.CurrentVersion;
SettingsForTests.ReservedPaths = "~/umbraco,~/install/";
SettingsForTests.ReservedUrls = "~/config/splashes/booting.aspx,~/install/default.aspx,~/config/splashes/noNodes.aspx,~/VSEnterpriseHelper.axd";
//create the not found handlers config
using (var sw = File.CreateText(Umbraco.Core.IO.IOHelper.MapPath(Umbraco.Core.IO.SystemFiles.NotFoundhandlersConfig, false)))
@@ -78,11 +78,6 @@ namespace Umbraco.Tests.Routing
base.TearDown();
_module.DisposeIfDisposable();
//reset the app config
ConfigurationManager.AppSettings.Set("umbracoConfigurationStatus", "");
ConfigurationManager.AppSettings.Set("umbracoReservedPaths", "");
ConfigurationManager.AppSettings.Set("umbracoReservedUrls", "");
}
// do not test for /base here as it's handled before EnsureUmbracoRoutablePage is called
@@ -22,9 +22,9 @@ namespace Umbraco.Tests.Routing
[Test]
public void DoNotPolluteCache()
{
ConfigurationManager.AppSettings.Set("umbracoUseDirectoryUrls", "true");
ConfigurationManager.AppSettings.Set("umbracoHideTopLevelNodeFromPath", "false"); // ignored w/domains
Umbraco.Core.Configuration.UmbracoSettings.UseDomainPrefixes = false;
SettingsForTests.UseDirectoryUrls = true;
SettingsForTests.HideTopLevelNodeFromPath = false; // ignored w/domains
SettingsForTests.UseDomainPrefixes = false;
InitializeLanguagesAndDomains();
SetDomains1();
@@ -34,7 +34,7 @@ namespace Umbraco.Tests.Routing
// get the nice url for 100111
routingContext = GetRoutingContext(url);
Assert.AreEqual("http://domain2.com/1001-1-1", routingContext.NiceUrlProvider.GetNiceUrl(100111, true));
Assert.AreEqual("http://domain2.com/1001-1-1/", routingContext.NiceUrlProvider.GetNiceUrl(100111, true));
// check that the proper route has been cached
var cachedRoutes = ((DefaultRoutesCache)routingContext.UmbracoContext.RoutesCache).GetCachedRoutes();
@@ -60,19 +60,10 @@ namespace Umbraco.Tests.Routing
//Assert.AreEqual("1001/1001-1/1001-1-1", cachedRoutes[100111]); // yes
// what's the nice url now?
Assert.AreEqual("http://domain2.com/1001-1-1", routingContext.NiceUrlProvider.GetNiceUrl(100111)); // good
Assert.AreEqual("http://domain2.com/1001-1-1/", routingContext.NiceUrlProvider.GetNiceUrl(100111)); // good
//Assert.AreEqual("http://domain1.com/1001-1/1001-1-1", routingContext.NiceUrlProvider.GetNiceUrl(100111, true)); // bad
}
public override void TearDown()
{
base.TearDown();
ConfigurationManager.AppSettings.Set("umbracoUseDirectoryUrls", "");
ConfigurationManager.AppSettings.Set("umbracoHideTopLevelNodeFromPath", "");
}
internal override IRoutesCache GetRoutesCache()
{
return new DefaultRoutesCache(false);
@@ -16,14 +16,6 @@ namespace Umbraco.Tests.Routing
[TestFixture]
public class uQueryGetNodeIdByUrlTests : BaseRoutingTest
{
public override void TearDown()
{
base.TearDown();
ConfigurationManager.AppSettings.Set("umbracoUseDirectoryUrls", "");
ConfigurationManager.AppSettings.Set("umbracoHideTopLevelNodeFromPath", "");
}
internal override IRoutesCache GetRoutesCache()
{
return new DefaultRoutesCache(false);
@@ -70,10 +62,9 @@ namespace Umbraco.Tests.Routing
public void GetNodeIdByUrl_Not_Hiding_Top_Level_Absolute(int nodeId, string url)
{
ConfigurationManager.AppSettings.Set("umbracoUseDirectoryUrls", "true");
ConfigurationManager.AppSettings.Set("umbracoHideTopLevelNodeFromPath", "false");
Umbraco.Core.Configuration.UmbracoSettings.UseDomainPrefixes = false;
SettingsForTests.UseDirectoryUrls = true;
SettingsForTests.HideTopLevelNodeFromPath = false;
SettingsForTests.UseDomainPrefixes = false;
Assert.AreEqual(nodeId, global::umbraco.uQuery.GetNodeIdByUrl("http://example.com" + url));
}
@@ -89,9 +80,9 @@ namespace Umbraco.Tests.Routing
public void GetNodeIdByUrl_Not_Hiding_Top_Level_Relative(int nodeId, string url)
{
ConfigurationManager.AppSettings.Set("umbracoUseDirectoryUrls", "true");
ConfigurationManager.AppSettings.Set("umbracoHideTopLevelNodeFromPath", "false");
Umbraco.Core.Configuration.UmbracoSettings.UseDomainPrefixes = false;
SettingsForTests.UseDirectoryUrls = true;
SettingsForTests.HideTopLevelNodeFromPath = false;
SettingsForTests.UseDomainPrefixes = false;
Assert.AreEqual(nodeId, global::umbraco.uQuery.GetNodeIdByUrl(url));
}
@@ -12,18 +12,6 @@ namespace Umbraco.Tests.TestHelpers
[TestFixture, RequiresSTA]
public abstract class BaseRoutingTest : BaseWebTest
{
public override void Initialize()
{
base.Initialize();
}
public override void TearDown()
{
base.TearDown();
ConfigurationManager.AppSettings.Set("umbracoHideTopLevelNodeFromPath", "");
}
/// <summary>
/// Return a new RoutingContext
/// </summary>
+4 -2
View File
@@ -23,7 +23,9 @@ namespace Umbraco.Tests.TestHelpers
[SetUp]
public virtual void Initialize()
{
TestHelper.SetupLog4NetForTests();
SettingsForTests.Reset();
TestHelper.SetupLog4NetForTests();
AppDomain.CurrentDomain.SetData("DataDirectory", TestHelper.CurrentAssemblyDirectory);
@@ -52,7 +54,7 @@ namespace Umbraco.Tests.TestHelpers
Cache.ClearAllCache();
UmbracoSettings.ResetSetters();
SettingsForTests.Reset();
}
/// <summary>
@@ -48,37 +48,35 @@ namespace Umbraco.Tests.TestHelpers.ExamineHelpers
new[]
{
new TestIndexField { Name = "id", EnableSorting = true, Type = "Number" },
new TestIndexField { Name = "nodeName", EnableSorting = true },
new TestIndexField { Name = "version" },
new TestIndexField { Name = "parentID" },
new TestIndexField { Name = "level" },
new TestIndexField { Name = "writerID" },
new TestIndexField { Name = "creatorID" },
new TestIndexField { Name = "nodeType" },
new TestIndexField { Name = "template" },
new TestIndexField { Name = "sortOrder", EnableSorting = true, Type = "Number"},
new TestIndexField { Name = "createDate", EnableSorting = true, Type = "DateTime" },
new TestIndexField { Name = "updateDate", EnableSorting = true, Type = "DateTime" },
new TestIndexField { Name = "nodeName", EnableSorting = true },
new TestIndexField { Name = "urlName" },
new TestIndexField { Name = "writerName" },
new TestIndexField { Name = "path" },
new TestIndexField { Name = "creatorName" },
new TestIndexField { Name = "nodeTypeAlias" },
new TestIndexField { Name = "parentID" }
new TestIndexField { Name = "path" }
},
Enumerable.Empty<IIndexField>(),
//new[]
// {
// new TestIndexField { Name = "headerText" },
// new TestIndexField { Name = "bodyText" },
// new TestIndexField { Name = "metaDescription" },
// new TestIndexField { Name = "metaKeywords" },
// new TestIndexField { Name = "bodyTextColOne" },
// new TestIndexField { Name = "bodyTextColTwo" },
// new TestIndexField { Name = "xmlStorageTest" }
// },
Enumerable.Empty<string>(),
//new[]
// {
// "CWS_Home",
// "CWS_Textpage",
// "CWS_TextpageTwoCol",
// "CWS_NewsEventsList",
// "CWS_NewsItem",
// "CWS_Gallery",
// "CWS_EventItem",
// "Image",
// },
new string[] { },
new[]
{
new TestIndexField { Name = "headerText" },
new TestIndexField { Name = "bodyText" },
new TestIndexField { Name = "metaDescription" },
new TestIndexField { Name = "metaKeywords" },
new TestIndexField { Name = "bodyTextColOne" },
new TestIndexField { Name = "bodyTextColTwo" },
new TestIndexField { Name = "xmlStorageTest" }
},
Enumerable.Empty<string>(),
Enumerable.Empty<string>(),
-1),
d,
new TestDataService(),
@@ -95,53 +93,12 @@ namespace Umbraco.Tests.TestHelpers.ExamineHelpers
{
return new UmbracoExamineSearcher(d, new StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_29));
}
//public SimpleDataIndexer GetSimpleIndexer(DirectoryInfo d)
//{
// var i = new SimpleDataIndexer(new IndexCriteria(
// new IIndexField[] { },
// new[]
// {
// new TestIndexField { Name = "Author" },
// new TestIndexField { Name = "DateCreated", EnableSorting = true, Type = "DateTime" },
// new TestIndexField { Name = "Title" },
// new TestIndexField { Name = "Photographer" },
// new TestIndexField { Name = "YearCreated", Type = "Date.Year" },
// new TestIndexField { Name = "MonthCreated", Type = "Date.Month" },
// new TestIndexField { Name = "DayCreated", Type = "Date.Day" },
// new TestIndexField { Name = "HourCreated", Type = "Date.Hour" },
// new TestIndexField { Name = "MinuteCreated", Type = "Date.Minute" },
// new TestIndexField { Name = "SomeNumber", Type = "Number" },
// new TestIndexField { Name = "SomeFloat", Type = "Float" },
// new TestIndexField { Name = "SomeDouble", Type = "Double" },
// new TestIndexField { Name = "SomeLong", Type = "Long" }
// },
// new string[] { },
// new string[] { },
// -1),
// d,
// new StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_29),
// new TestSimpleDataProvider(),
// new[] { "Documents", "Pictures" },
// false);
// i.IndexingError += IndexingError;
// return i;
//}
public LuceneSearcher GetLuceneSearcher(DirectoryInfo d)
{
return new LuceneSearcher(d, new StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_29));
}
//public PDFIndexer GetPdfIndexer(DirectoryInfo d)
//{
// var i = new PDFIndexer(d,
// new TestDataService(),
// new StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_29),
// false);
// i.IndexingError += IndexingError;
// return i;
//}
public MultiIndexSearcher GetMultiSearcher(DirectoryInfo pdfDir, DirectoryInfo simpleDir, DirectoryInfo conventionDir, DirectoryInfo cwsDir)
{
var i = new MultiIndexSearcher(new[] { pdfDir, simpleDir, conventionDir, cwsDir }, new StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_29));
@@ -2,15 +2,15 @@
<media>
<node id="1111" version="902e13f7-5793-482a-9e06-cd94eebd1de0" parentID="-1" level="1" writerID="0" nodeType="1031" template="0" sortOrder="2" createDate="2010-05-19T15:26:08" updateDate="2010-05-19T15:26:09" nodeName="Product Images" urlName="productimages" writerName="Administrator" nodeTypeAlias="Folder" path="-1,1111">
<data alias="contents"></data>
<node id="2222" version="902e13f7-5793-482a-9e06-cd94eebd1de0" parentID="1111" level="1" writerID="0" nodeType="1031" template="0" sortOrder="2" createDate="2010-05-19T15:26:08" updateDate="2010-05-19T15:26:09" nodeName="Product Images" urlName="productimages" writerName="Administrator" nodeTypeAlias="Folder" path="-1,1111,2222">
<node id="2222" version="902e13f7-5793-482a-9e06-cd94eebd1de0" parentID="1111" level="2" writerID="0" nodeType="1031" template="0" sortOrder="2" createDate="2010-05-19T15:26:08" updateDate="2010-05-19T15:26:09" nodeName="Product Images" urlName="productimages" writerName="Administrator" nodeTypeAlias="Folder" path="-1,1111,2222">
<data alias="contents"></data>
<node id="2112" version="5b3e46ab-3e37-4cfa-ab70-014234b5bd39" parentID="2222" level="2" writerID="0" nodeType="1032" template="0" sortOrder="1" createDate="2010-05-19T17:32:46" updateDate="2010-05-19T17:32:46" nodeName="Sam's Umbraco Image" urlName="acnestressscrub" writerName="Administrator" nodeTypeAlias="Image" path="-1,1111,2222,2112">
<node id="2112" version="5b3e46ab-3e37-4cfa-ab70-014234b5bd39" parentID="2222" level="3" writerID="0" nodeType="1032" template="0" sortOrder="1" createDate="2010-05-19T17:32:46" updateDate="2010-05-19T17:32:46" nodeName="Sam's Umbraco Image" urlName="acnestressscrub" writerName="Administrator" nodeTypeAlias="Image" path="-1,1111,2222,2112">
<data alias="umbracoFile"><![CDATA[/media/1234/blah.pdf]]></data>
<data alias="umbracoWidth">115</data>
<data alias="umbracoHeight">268</data>
<data alias="umbracoBytes">10726</data>
<data alias="umbracoExtension">jpg</data>
<node id="3113" version="5b3e46ab-3e37-4cfa-ab70-014234b5bd33" parentID="2112" level="3" writerID="0" nodeType="1032" template="0" sortOrder="2" createDate="2010-05-19T17:32:46" updateDate="2010-05-19T17:32:46" nodeName="Another Umbraco Image" urlName="acnestressscrub" writerName="Administrator" nodeTypeAlias="Image" path="-1,1111,2222,2112,3113">
<node id="3113" version="5b3e46ab-3e37-4cfa-ab70-014234b5bd33" parentID="2112" level="4" writerID="0" nodeType="1032" template="0" sortOrder="2" createDate="2010-05-19T17:32:46" updateDate="2010-05-19T17:32:46" nodeName="Another Umbraco Image" urlName="acnestressscrub" writerName="Administrator" nodeTypeAlias="Image" path="-1,1111,2222,2112,3113">
<data alias="umbracoFile"><![CDATA[/media/1234/blah.pdf]]></data>
<data alias="umbracoWidth">115</data>
<data alias="umbracoHeight">268</data>
@@ -26,21 +26,21 @@
<data alias="umbracoBytes">10726</data>
<data alias="umbracoExtension">jpg</data>
</node>
<node id="1114" version="5b3e46ab-3e37-4cfa-ab70-014234b5bd39" parentID="1111" level="2" writerID="0" nodeType="1032" template="0" sortOrder="1" createDate="2010-05-19T17:32:46" updateDate="2010-05-19T17:32:46" nodeName="String thoery" urlName="stringtheory" writerName="Administrator" nodeTypeAlias="File" path="-1,1111,1114">
<node id="1114" version="5b3e46ab-3e37-4cfa-ab70-014234b5bd39" parentID="1111" level="2" writerID="0" nodeType="1032" template="0" sortOrder="3" createDate="2010-05-19T17:32:46" updateDate="2010-05-19T17:32:46" nodeName="String thoery" urlName="stringtheory" writerName="Administrator" nodeTypeAlias="File" path="-1,1111,1114">
<data alias="umbracoFile"><![CDATA[/App_Data/StringTheory.pdf]]></data>
<data alias="umbracoWidth">115</data>
<data alias="umbracoHeight">268</data>
<data alias="umbracoBytes">10726</data>
<data alias="umbracoExtension">jpg</data>
</node>
<node id="1115" version="5b3e46ab-3e37-4cfa-ab70-014234b5bd39" parentID="1111" level="2" writerID="0" nodeType="1032" template="0" sortOrder="1" createDate="2010-05-19T17:32:46" updateDate="2010-05-19T17:32:46" nodeName="Umbraco Contour" urlName="umbracocontour" writerName="Administrator" nodeTypeAlias="File" path="-1,1111,1115">
<node id="1115" version="5b3e46ab-3e37-4cfa-ab70-014234b5bd39" parentID="1111" level="2" writerID="0" nodeType="1032" template="0" sortOrder="5" createDate="2010-05-19T17:32:46" updateDate="2010-05-19T17:32:46" nodeName="Umbraco Contour" urlName="umbracocontour" writerName="Administrator" nodeTypeAlias="File" path="-1,1111,1115">
<data alias="umbracoFile"><![CDATA[/App_Data/UmbracoContour.pdf]]></data>
<data alias="umbracoWidth">115</data>
<data alias="umbracoHeight">268</data>
<data alias="umbracoBytes">10726</data>
<data alias="umbracoExtension">jpg</data>
</node>
<node id="1116" version="5b3e46ab-3e37-4cfa-ab70-014234b5bd39" parentID="1111" level="2" writerID="0" nodeType="1032" template="0" sortOrder="1" createDate="2010-05-19T17:32:46" updateDate="2010-05-19T17:32:46" nodeName="PDF Standards" urlName="pdfstandards" writerName="Administrator" nodeTypeAlias="File" path="-1,1111,1116">
<node id="1116" version="5b3e46ab-3e37-4cfa-ab70-014234b5bd39" parentID="1111" level="2" writerID="0" nodeType="1032" template="0" sortOrder="4" createDate="2010-05-19T17:32:46" updateDate="2010-05-19T17:32:46" nodeName="PDF Standards" urlName="pdfstandards" writerName="Administrator" nodeTypeAlias="File" path="-1,1111,1116">
<data alias="umbracoFile"><![CDATA[/App_Data/PDFStandards.pdf]]></data>
<data alias="umbracoWidth">115</data>
<data alias="umbracoHeight">268</data>
@@ -0,0 +1,112 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using Umbraco.Core.Configuration;
namespace Umbraco.Tests.TestHelpers
{
class SettingsForTests
{
// umbracoSettings
public static bool UseLegacyXmlSchema
{
get { return UmbracoSettings.UseLegacyXmlSchema; }
set { UmbracoSettings.UseLegacyXmlSchema = value; }
}
public static bool AddTrailingSlash
{
get { return UmbracoSettings.AddTrailingSlash; }
set { UmbracoSettings.AddTrailingSlash = value; }
}
public static bool UseDomainPrefixes
{
get { return UmbracoSettings.UseDomainPrefixes; }
set { UmbracoSettings.UseDomainPrefixes = value; }
}
public static string SettingsFilePath
{
get { return UmbracoSettings.SettingsFilePath; }
set { UmbracoSettings.SettingsFilePath = value; }
}
// from appSettings
private static readonly IDictionary<string, string> SavedAppSettings = new Dictionary<string, string>();
static void SaveSetting(string key)
{
SavedAppSettings[key] = ConfigurationManager.AppSettings[key];
}
static void SaveSettings()
{
SaveSetting("umbracoHideTopLevelNodeFromPath");
SaveSetting("umbracoUseDirectoryUrls");
SaveSetting("umbracoPath");
SaveSetting("umbracoReservedPaths");
SaveSetting("umbracoReservedUrls");
SaveSetting("umbracoConfigurationStatus");
}
public static bool HideTopLevelNodeFromPath
{
get { return GlobalSettings.HideTopLevelNodeFromPath; }
set { ConfigurationManager.AppSettings.Set("umbracoHideTopLevelNodeFromPath", value ? "true" : "false"); }
}
public static bool UseDirectoryUrls
{
get { return GlobalSettings.UseDirectoryUrls; }
set { ConfigurationManager.AppSettings.Set("umbracoUseDirectoryUrls", value ? "true" : "false"); }
}
public static string UmbracoPath
{
get { return GlobalSettings.Path; }
set { ConfigurationManager.AppSettings.Set("umbracoPath", value); }
}
public static string ReservedPaths
{
get { return GlobalSettings.ReservedPaths; }
set { GlobalSettings.ReservedPaths = value; }
}
public static string ReservedUrls
{
get { return GlobalSettings.ReservedUrls; }
set { GlobalSettings.ReservedUrls = value; }
}
public static string ConfigurationStatus
{
get { return GlobalSettings.ConfigurationStatus; }
set { ConfigurationManager.AppSettings.Set("umbracoConfigurationStatus", value); }
}
// reset & defaults
static SettingsForTests()
{
SaveSettings();
}
public static void Reset()
{
UmbracoSettings.ResetSetters();
GlobalSettings.ResetCache();
foreach (var kvp in SavedAppSettings)
ConfigurationManager.AppSettings.Set(kvp.Key, kvp.Value);
// set some defaults that are wrong in the config file?!
// this is annoying, really
HideTopLevelNodeFromPath = false;
}
}
}
+20 -9
View File
@@ -12,6 +12,8 @@
<AssemblyName>Umbraco.Tests</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
<RestorePackages>true</RestorePackages>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@@ -31,16 +33,22 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Examine, Version=0.1.42.2941, Culture=neutral, processorArchitecture=MSIL" />
<Reference Include="Examine, Version=0.1.48.2941, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Examine.0.1.48.2941\lib\Examine.dll</HintPath>
</Reference>
<Reference Include="ICSharpCode.SharpZipLib">
<HintPath>..\packages\SharpZipLib.0.86.0\lib\20\ICSharpCode.SharpZipLib.dll</HintPath>
</Reference>
<Reference Include="log4net, Version=1.2.11.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\log4net.2.0.0\lib\net40-full\log4net.dll</HintPath>
</Reference>
<Reference Include="Lucene.Net, Version=2.9.4.1, Culture=neutral, PublicKeyToken=85089178b9ac3181, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\Umbraco.Web.UI\bin\Lucene.Net.dll</HintPath>
<Reference Include="Lucene.Net">
<HintPath>..\packages\Lucene.Net.2.9.4.1\lib\net40\Lucene.Net.dll</HintPath>
</Reference>
<Reference Include="nunit.framework">
<HintPath>..\packages\NUnit.2.6.0.12054\lib\nunit.framework.dll</HintPath>
<Reference Include="nunit.framework, Version=2.6.2.12296, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\NUnit.2.6.2\lib\nunit.framework.dll</HintPath>
</Reference>
<Reference Include="Rhino.Mocks">
<HintPath>..\packages\RhinoMocks.3.6.1\lib\net\Rhino.Mocks.dll</HintPath>
@@ -55,16 +63,17 @@
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="UmbracoExamine, Version=0.1.42.2941, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\Umbraco.Web.UI\bin\UmbracoExamine.dll</HintPath>
<Reference Include="UmbracoExamine">
<HintPath>..\packages\UmbracoExamine.0.1.42.2941\lib\UmbracoExamine.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="BusinessLogic\DictionaryTest.cs" />
<Compile Include="ContentStores\PublishMediaStoreTests.cs" />
<Compile Include="PublishedContent\DynamicXmlTests.cs" />
<Compile Include="PublishedContent\LegacyExamineBackedMediaTests.cs" />
<Compile Include="PublishedContent\PublishedContentDataTableTests.cs" />
<Compile Include="PublishedContent\PublishedContentTestBase.cs" />
<Compile Include="PublishedContent\PublishedContentTests.cs" />
<Compile Include="PublishedContent\PublishedMediaTests.cs" />
<Compile Include="PublishedContent\StronglyTypedQueryTests.cs" />
@@ -94,6 +103,7 @@
<Compile Include="Surface\PluginControllerAreaTests.cs" />
<Compile Include="Templates\MasterPageHelperTests.cs" />
<Compile Include="TestHelpers\BaseRoutingTest.cs" />
<Compile Include="TestHelpers\SettingsForTests.cs" />
<Compile Include="GlobalSettingsTests.cs" />
<Compile Include="Routing\LookupByAliasTests.cs" />
<Compile Include="Routing\LookupByIdTests.cs" />
@@ -209,6 +219,7 @@
<PostBuildEvent>xcopy "$(ProjectDir)"..\..\lib\SQLCE4\amd64\*.* "$(TargetDir)amd64\" /Y /F /E /D
xcopy "$(ProjectDir)"..\..\lib\SQLCE4\x86\*.* "$(TargetDir)x86\" /Y /F /E /D</PostBuildEvent>
</PropertyGroup>
<Import Project="$(SolutionDir)\.nuget\nuget.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
+5 -1
View File
@@ -1,6 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Examine" version="0.1.48.2941" targetFramework="net40" />
<package id="log4net" version="2.0.0" targetFramework="net40" />
<package id="NUnit" version="2.6.0.12054" targetFramework="net40" />
<package id="Lucene.Net" version="2.9.4.1" targetFramework="net40" />
<package id="NUnit" version="2.6.2" targetFramework="net40" />
<package id="RhinoMocks" version="3.6.1" targetFramework="net40" />
<package id="SharpZipLib" version="0.86.0" targetFramework="net40" />
<package id="UmbracoExamine" version="0.1.42.2941" targetFramework="net40" />
</packages>
@@ -5,6 +5,18 @@
<appender-ref ref="ConsoleAppender" />
</root>
<logger name="Umbraco.Core.PluginManager">
<level value="WARN" />
</logger>
<logger name="Umbraco.Core.Persistence.Database">
<level value="WARN" />
</logger>
<logger name="Umbraco.Core.Persistence.Migrations.Initial.BaseDataCreation">
<level value="WARN" />
</logger>
<appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender" >
<target value="Console.Out" />
<layout type="log4net.Layout.PatternLayout">
+10 -7
View File
@@ -44,6 +44,8 @@
<IISExpressAnonymousAuthentication />
<IISExpressWindowsAuthentication />
<IISExpressUseClassicPipelineMode />
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
<RestorePackages>true</RestorePackages>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<OutputPath>bin\</OutputPath>
@@ -101,24 +103,24 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\lib\CookComputing.XmlRpcV2.dll</HintPath>
</Reference>
<Reference Include="Examine, Version=0.9.0.0, Culture=en-AU, processorArchitecture=MSIL">
<Reference Include="Examine, Version=0.1.48.2941, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\lib\Examine.dll</HintPath>
<HintPath>..\packages\Examine.0.1.48.2941\lib\Examine.dll</HintPath>
</Reference>
<Reference Include="HtmlAgilityPack, Version=1.4.0.0, Culture=neutral, PublicKeyToken=bd319b19eaf3b43a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\lib\HtmlAgilityPack.dll</HintPath>
</Reference>
<Reference Include="ICSharpCode.SharpZipLib, Version=0.83.1.0, Culture=neutral, PublicKeyToken=1b03e6acf1164f73">
<Reference Include="ICSharpCode.SharpZipLib, Version=0.86.0.518, Culture=neutral, PublicKeyToken=1b03e6acf1164f73, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\lib\ICSharpCode.SharpZipLib.dll</HintPath>
<HintPath>..\packages\SharpZipLib.0.86.0\lib\20\ICSharpCode.SharpZipLib.dll</HintPath>
</Reference>
<Reference Include="log4net">
<HintPath>..\packages\log4net.2.0.0\lib\net40-full\log4net.dll</HintPath>
</Reference>
<Reference Include="Lucene.Net, Version=2.9.4.1, Culture=neutral, PublicKeyToken=85089178b9ac3181, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\lib\Lucene.Net.dll</HintPath>
<HintPath>..\packages\Lucene.Net.2.9.4.1\lib\net40\Lucene.Net.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Web.Helpers">
<HintPath>..\..\lib\WebPages\Microsoft.Web.Helpers.dll</HintPath>
@@ -256,7 +258,7 @@
</ProjectReference>
<ProjectReference Include="..\Umbraco.Web\Umbraco.Web.csproj">
<Project>{651E1350-91B6-44B7-BD60-7207006D7003}</Project>
<Name>umbraco.presentation</Name>
<Name>Umbraco.Web</Name>
</ProjectReference>
<ProjectReference Include="..\umbraco.providers\umbraco.providers.csproj">
<Project>{D7636876-0756-43CB-A192-138C6F0D5E42}</Project>
@@ -2389,7 +2391,7 @@ xcopy "$(ProjectDir)"..\..\lib\SQLCE4\x86\*.* "$(TargetDir)x86\" /Y /F /E /D</Po
<AutoAssignPort>True</AutoAssignPort>
<DevelopmentServerPort>61637</DevelopmentServerPort>
<DevelopmentServerVPath>/</DevelopmentServerVPath>
<IISUrl>http://localhost:61638/</IISUrl>
<IISUrl>http://localhost:61639/VirtualDir</IISUrl>
<NTLMAuthentication>False</NTLMAuthentication>
<UseCustomServer>False</UseCustomServer>
<CustomServerUrl>
@@ -2404,4 +2406,5 @@ xcopy "$(ProjectDir)"..\..\lib\SQLCE4\x86\*.* "$(TargetDir)x86\" /Y /F /E /D</Po
<PropertyGroup>
<!--<PostBuildEvent>xcopy "$(ProjectDir)..\..\lib\*.dll" "$(TargetDir)*.dll" /Y</PostBuildEvent>-->
</PropertyGroup>
<Import Project="$(SolutionDir)\.nuget\nuget.targets" />
</Project>
@@ -8,20 +8,7 @@ More information and documentation can be found on CodePlex: http://umbracoexami
-->
<ExamineLuceneIndexSets>
<!-- The internal index set used by Umbraco back-office - DO NOT REMOVE -->
<IndexSet SetName="InternalIndexSet" IndexPath="~/App_Data/TEMP/ExamineIndexes/Internal/">
<IndexAttributeFields>
<add Name="id" />
<add Name="nodeName" />
<add Name="updateDate" />
<add Name="writerName" />
<add Name="path" />
<add Name="nodeTypeAlias" />
<add Name="parentID" />
</IndexAttributeFields>
<IndexUserFields />
<IncludeNodeTypes/>
<ExcludeNodeTypes />
</IndexSet>
<IndexSet SetName="InternalIndexSet" IndexPath="~/App_Data/TEMP/ExamineIndexes/Internal/"/>
<!-- The internal index set used by Umbraco back-office for indexing members - DO NOT REMOVE -->
<IndexSet SetName="InternalMemberIndexSet" IndexPath="~/App_Data/TEMP/ExamineIndexes/InternalMember/">
@@ -34,9 +21,6 @@ More information and documentation can be found on CodePlex: http://umbracoexami
<add Name="email" />
<add Name="nodeTypeAlias" />
</IndexAttributeFields>
<IndexUserFields/>
<IncludeNodeTypes/>
<ExcludeNodeTypes />
</IndexSet>
<!-- Default Indexset for external searches, this indexes all fields on all types of nodes-->
+15 -32
View File
@@ -7,36 +7,19 @@ Index/Search providers can be defined in the UmbracoSettings.config
More information and documentation can be found on CodePlex: http://umbracoexamine.codeplex.com
-->
<ExamineLuceneIndexSets>
<!-- The internal index set used by Umbraco back-office - DO NOT REMOVE -->
<IndexSet SetName="InternalIndexSet" IndexPath="~/App_Data/TEMP/ExamineIndexes/Internal/">
<IndexAttributeFields>
<add Name="id" />
<add Name="nodeName" />
<add Name="updateDate" />
<add Name="writerName" />
<add Name="path" />
<add Name="nodeTypeAlias" />
<add Name="parentID" />
</IndexAttributeFields>
<IndexUserFields />
<IncludeNodeTypes/>
<ExcludeNodeTypes />
</IndexSet>
<!-- The internal index set used by Umbraco back-office for indexing members - DO NOT REMOVE -->
<IndexSet SetName="InternalMemberIndexSet" IndexPath="~/App_Data/TEMP/ExamineIndexes/InternalMember/">
<IndexAttributeFields>
<add Name="id" />
<add Name="nodeName"/>
<add Name="updateDate" />
<add Name="writerName" />
<add Name="loginName" />
<add Name="email" />
<add Name="nodeTypeAlias" />
</IndexAttributeFields>
<IndexUserFields/>
<IncludeNodeTypes/>
<ExcludeNodeTypes />
</IndexSet>
<!-- The internal index set used by Umbraco back-office - DO NOT REMOVE -->
<IndexSet SetName="InternalIndexSet" IndexPath="~/App_Data/TEMP/ExamineIndexes/Internal/" />
<!-- The internal index set used by Umbraco back-office for indexing members - DO NOT REMOVE -->
<IndexSet SetName="InternalMemberIndexSet" IndexPath="~/App_Data/TEMP/ExamineIndexes/InternalMember/">
<IndexAttributeFields>
<add Name="id" />
<add Name="nodeName"/>
<add Name="updateDate" />
<add Name="writerName" />
<add Name="loginName" />
<add Name="email" />
<add Name="nodeTypeAlias" />
</IndexAttributeFields>
</IndexSet>
</ExamineLuceneIndexSets>
@@ -21,7 +21,7 @@ More information and documentation can be found on CodePlex: http://umbracoexami
interval="10"
analyzer="Lucene.Net.Analysis.Standard.StandardAnalyzer, Lucene.Net"/>
<!-- default external indexer, which excludes protected and published pages-->
<!-- default external indexer, which excludes protected and unpublished pages-->
<add name="ExternalIndexer" type="UmbracoExamine.UmbracoContentIndexer, UmbracoExamine"
supportUnpublished="false"
supportProtected="false"
@@ -86,6 +86,14 @@
<!-- Setting this to true can increase render time for pages with a large number of links -->
<!-- If running Umbraco in virtual directory this *must* be set to true! -->
<ResolveUrlsFromTextString>false</ResolveUrlsFromTextString>
<!-- How Umbraco should handle errors during macro execution. Can be one of the following values:
- inline - show an inline error within the macro but allow the page to continue rendering. Historial Umbraco behaviour.
- silent - Silently suppress the error and do not render the offending macro.
- throw - Throw an exception which can be caught by the global error handler defined in Application_OnError. If no such
error handler is defined then you'll see the Yellow Screen Of Death (YSOD) error page.
Note the error can also be handled by the umbraco.macro.Error event, where you can log/alarm with your own code and change the behaviour per event. -->
<MacroErrors>inline</MacroErrors>
</content>
<security>
@@ -236,4 +244,17 @@
<!--<link application="content" applicationUrl="dashboard.aspx" language="en" userType="Administrators" helpUrl="http://www.xyz.no?{0}/{1}/{2}/{3}" /> -->
</help>
<!--
web.routing
@trySkipIisCustomErrors
Tries to skip IIS custom errors.
Starting with IIS 7.5, this must be set to true for Umbraco 404 pages to show. Else, IIS will take
over and render its build-in error page. See MS doc for HttpResponseBase.TrySkipIisCustomErrors.
The default value is false, for backward compatibility reasons, which means that IIS _will_ take
over, and _prevent_ Umbraco 404 pages to show.
-->
<web.routing
trySkipIisCustomErrors="false">
</web.routing>
</settings>
@@ -81,6 +81,13 @@
<!-- In seconds. 0 will disable cache -->
<UmbracoLibraryCacheDuration>1800</UmbracoLibraryCacheDuration>
<!-- How Umbraco should handle errors during macro execution. Can be one of the following values:
- inline - show an inline error within the macro but allow the page to continue rendering. Historial Umbraco behaviour.
- silent - Silently suppress the error and do not render the offending macro.
- throw - Throw an exception which can be caught by the global error handler defined in Application_OnError. If no such
error handler is defined then you'll see the Yellow Screen Of Death (YSOD) error page.
Note the error can also be handled by the umbraco.macro.Error event, where you can log/alarm with your own code and change the behaviour per event. -->
<MacroErrors>inline</MacroErrors>
</content>
<security>
@@ -192,4 +199,17 @@
<!--<link application="content" applicationUrl="dashboard.aspx" language="en" userType="Administrators" helpUrl="http://www.xyz.no?{0}/{1}/{2}/{3}" /> -->
</help>
<!--
web.routing
@trySkipIisCustomErrors
Tries to skip IIS custom errors.
Starting with IIS 7.5, this must be set to true for Umbraco 404 pages to show. Else, IIS will take
over and render its build-in error page. See MS doc for HttpResponseBase.TrySkipIisCustomErrors.
The default value is false, for backward compatibility reasons, which means that IIS _will_ take
over, and _prevent_ Umbraco 404 pages to show.
-->
<web.routing
trySkipIisCustomErrors="false">
</web.routing>
</settings>
+3
View File
@@ -1,9 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Examine" version="0.1.48.2941" targetFramework="net40" />
<package id="log4net" version="2.0.0" targetFramework="net40" />
<package id="Lucene.Net" version="2.9.4.1" targetFramework="net40" />
<package id="Microsoft.AspNet.Mvc" version="3.0.20105.1" targetFramework="net40" />
<package id="Microsoft.AspNet.Razor" version="1.0.20105.408" targetFramework="net40" />
<package id="Microsoft.AspNet.WebPages" version="1.0.20105.408" targetFramework="net40" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net40" />
<package id="SharpZipLib" version="0.86.0" targetFramework="net40" />
<package id="uGoLive" version="1.4.0" targetFramework="net40" />
</packages>
@@ -204,8 +204,8 @@
<area alias="editdatatype">
<key alias="addPrevalue">Add prevalue</key>
<key alias="dataBaseDatatype">Database datatype</key>
<key alias="guid">Data Editor GUID</key>
<key alias="renderControl">Render control</key>
<key alias="guid">Property editor GUID</key>
<key alias="renderControl">Property editor</key>
<key alias="rteButtons">Buttons</key>
<key alias="rteEnableAdvancedSettings">Enable advanced settings for</key>
<key alias="rteEnableContextMenu">Enable context menu</key>
@@ -735,7 +735,7 @@ To manage your website, simply open the umbraco back office and start adding con
<key alias="sortPleaseWait"><![CDATA[ Please wait. Items are being sorted, this can take a while.<br/> <br/> Do not close this window during sorting]]></key>
</area>
<area alias="speechBubbles">
<key alias="contentPublishedFailedByEvent">Publising was cancelled by a 3rd party add-in</key>
<key alias="contentPublishedFailedByEvent">Publishing was cancelled by a 3rd party add-in</key>
<key alias="contentTypeDublicatePropertyType">Property type already exists</key>
<key alias="contentTypePropertyTypeCreated">Property type created</key>
<key alias="contentTypePropertyTypeCreatedText"><![CDATA[Name: %0% <br /> DataType: %1%]]></key>
@@ -749,13 +749,15 @@ To manage your website, simply open the umbraco back office and start adding con
<key alias="cssSavedText">Stylesheet saved without any errors</key>
<key alias="dataTypeSaved">Datatype saved</key>
<key alias="dictionaryItemSaved">Dictionary item saved</key>
<key alias="editContentPublishedFailedByParent">Publising failed because the parent page isn't published</key>
<key alias="editContentPublishedFailedByParent">Publishing failed because the parent page isn't published</key>
<key alias="editContentPublishedHeader">Content published</key>
<key alias="editContentPublishedText">and visible at the website</key>
<key alias="editContentSavedHeader">Content saved</key>
<key alias="editContentSavedText">Remember to publish to make changes visible</key>
<key alias="editContentSendToPublish">Sent For Approval</key>
<key alias="editContentSendToPublishText">Changes have been sent for approval</key>
<key alias="editMediaSaved">Media saved</key>
<key alias="editMediaSavedText"></key>
<key alias="editMemberSaved">Member saved</key>
<key alias="editStylesheetPropertySaved">Stylesheet Property Saved</key>
<key alias="editStylesheetSaved">Stylesheet saved</key>
@@ -203,8 +203,8 @@
<area alias="editdatatype">
<key alias="addPrevalue">Add prevalue</key>
<key alias="dataBaseDatatype">Database datatype</key>
<key alias="guid">Data Editor GUID</key>
<key alias="renderControl">Render control</key>
<key alias="guid">Property editor GUID</key>
<key alias="renderControl">Property editor</key>
<key alias="rteButtons">Buttons</key>
<key alias="rteEnableAdvancedSettings">Enable advanced settings for</key>
<key alias="rteEnableContextMenu">Enable context menu</key>
@@ -734,7 +734,7 @@ To manage your website, simply open the umbraco back office and start adding con
<key alias="sortPleaseWait"><![CDATA[ Please wait. Items are being sorted, this can take a while.<br/> <br/> Do not close this window during sorting]]></key>
</area>
<area alias="speechBubbles">
<key alias="contentPublishedFailedByEvent">Publising was cancelled by a 3rd party add-in</key>
<key alias="contentPublishedFailedByEvent">Publishing was cancelled by a 3rd party add-in</key>
<key alias="contentTypeDublicatePropertyType">Property type already exists</key>
<key alias="contentTypePropertyTypeCreated">Property type created</key>
<key alias="contentTypePropertyTypeCreatedText"><![CDATA[Name: %0% <br /> DataType: %1%]]></key>
@@ -748,13 +748,15 @@ To manage your website, simply open the umbraco back office and start adding con
<key alias="cssSavedText">Stylesheet saved without any errors</key>
<key alias="dataTypeSaved">Datatype saved</key>
<key alias="dictionaryItemSaved">Dictionary item saved</key>
<key alias="editContentPublishedFailedByParent">Publising failed because the parent page isn't published</key>
<key alias="editContentPublishedFailedByParent">Publishing failed because the parent page isn't published</key>
<key alias="editContentPublishedHeader">Content published</key>
<key alias="editContentPublishedText">and visible at the website</key>
<key alias="editContentSavedHeader">Content saved</key>
<key alias="editContentSavedText">Remember to publish to make changes visible</key>
<key alias="editContentSendToPublish">Sent For Approval</key>
<key alias="editContentSendToPublishText">Changes have been sent for approval</key>
<key alias="editMediaSaved">Media saved</key>
<key alias="editMediaSavedText"></key>
<key alias="editMemberSaved">Member saved</key>
<key alias="editStylesheetPropertySaved">Stylesheet Property Saved</key>
<key alias="editStylesheetSaved">Stylesheet saved</key>
File diff suppressed because it is too large Load Diff
@@ -187,8 +187,8 @@
<area alias="editdatatype">
<key alias="addPrevalue">Adicionar valor prévio</key>
<key alias="dataBaseDatatype">Tipo de Dados do Banco de Dados</key>
<key alias="guid">GUID do Editor de Dados</key>
<key alias="renderControl">Mostrar controle</key>
<key alias="guid">GUID do Editor de Propriedades</key>
<key alias="renderControl">Editor de Propriedades</key>
<key alias="rteButtons">Botões</key>
<key alias="rteEnableAdvancedSettings">Habilitar configurações avançadas para</key>
<key alias="rteEnableContextMenu">Habilitar menu de contexto</key>
@@ -832,4 +832,4 @@ Para fechar a tarefa de tradução vá até os detalhes e clique no botão "Fech
<key alias="userTypes">Tipos de usuários</key>
<key alias="writer">Escrevente</key>
</area>
</language>
</language>
File diff suppressed because it is too large Load Diff
+7 -5
View File
@@ -109,11 +109,13 @@
<asp:HiddenField ID="hf_height" runat="server" />
<asp:HiddenField ID="hf_width" runat="server" />
</form>
<script type="text/javascript">
jQuery("#<%= lname.ClientID %>").focus();
jQuery('#<%= hf_height.ClientID %>').value = getViewportHeight();
jQuery('#<%= hf_width.ClientID %>').value = getViewportWidth();
</script>
<asp:PlaceHolder ID="loginJavascript" runat="server">
<script type="text/javascript">
jQuery("#<%= lname.ClientID %>").focus();
jQuery('#<%= hf_height.ClientID %>').value = getViewportHeight();
jQuery('#<%= hf_width.ClientID %>').value = getViewportWidth();
</script>
</asp:PlaceHolder>
<asp:PlaceHolder Visible="false" ID="loginError" runat="server">
<script type="text/javascript">
jQuery(document).ready(function () {
@@ -2,7 +2,7 @@
<%@ Register TagPrefix="cc1" Namespace="umbraco.uicontrols" Assembly="controls" %>
<div class="dashboardWrapper">
<h2>Member Search</h2>
<img src="./dashboard/images/membersearch.png" alt="Videos" class="dashboardIcon" />
<img src="<%= Umbraco.Core.IO.IOHelper.ResolveUrl(Umbraco.Core.IO.SystemDirectories.Umbraco) + "/dashboard/images/membersearch.png" %>" alt="Member Search" class="dashboardIcon" />
<p class="guiDialogNormal">
<asp:TextBox id="searchQuery" runat="server"></asp:TextBox>
<asp:Button id="ButtonSearch" runat="server" Text="Button" onclick="ButtonSearch_Click"></asp:Button></p>
@@ -19,14 +19,14 @@
</HeaderTemplate>
<ItemTemplate>
<tr>
<td><asp:HyperLink runat="server" NavigateUrl='<%# umbraco.IO.SystemDirectories.Umbraco + "/members/EditMember.aspx?id=" + Eval("Id") %>'><%# Eval("Name") %></asp:HyperLink></td>
<td><asp:HyperLink runat="server" NavigateUrl='<%# Umbraco.Core.IO.SystemDirectories.Umbraco + "/members/EditMember.aspx?id=" + Eval("Id") %>'><%# Eval("Name") %></asp:HyperLink></td>
<td><%# Eval("Email") %></td>
<td><%# Eval("LoginName") %></td>
</tr>
</ItemTemplate>
<AlternatingItemTemplate>
<tr class="alt">
<td><asp:HyperLink runat="server" NavigateUrl='<%# umbraco.IO.SystemDirectories.Umbraco + "/members/EditMember.aspx?id=" + Eval("Id") %>'><%# Eval("Name") %></asp:HyperLink></td>
<td><asp:HyperLink runat="server" NavigateUrl='<%# Umbraco.Core.IO.SystemDirectories.Umbraco + "/members/EditMember.aspx?id=" + Eval("Id") %>'><%# Eval("Name") %></asp:HyperLink></td>
<td><%# Eval("Email") %></td>
<td><%# Eval("LoginName") %></td>
</tr>
@@ -0,0 +1,3 @@
tinyMCE.addI18n('ja.example',{
desc : 'これはテンプレートボタンです'
});
@@ -0,0 +1,3 @@
tinyMCE.addI18n('ja.example_dlg',{
title : 'これは見出しの例です'
});
@@ -0,0 +1,3 @@
tinyMCE.addI18n('sv.example',{
desc : 'Detta är bara en mallknapp'
});
@@ -0,0 +1,3 @@
tinyMCE.addI18n('sv.example_dlg',{
title : 'Detta är bara ett exempel på en titel'
});
@@ -37,7 +37,7 @@
// Register example button
ed.addButton('umbracoembed', {
title : 'Embed third party media',
title : 'umbracoembed.desc',
cmd : 'mceUmbracoEmbed',
image : url + '/img/embed.gif'
});
@@ -0,0 +1,3 @@
tinyMCE.addI18n('da.umbracoembed', {
desc: 'Inds\u00E6t ekstern mediefil',
});
@@ -0,0 +1,9 @@
tinyMCE.addI18n('da.embed_dlg', {
title: 'Inds\u00E6t ekstern mediefil',
general: 'Generelt',
url: 'Url:',
size: 'Dimensioner:',
constrain_proportions: 'Bevar proportioner',
preview: 'Vis',
source: 'Vis kilde'
});
@@ -1,10 +1,3 @@
tinyMCE.addI18n('en.embed_dlg', {
title: 'Embed third party media',
general: 'General',
url: 'Url:',
size: 'Size:',
constrain_proportions: 'Constrain',
preview: 'Preview',
source: 'Source'
tinyMCE.addI18n('en.umbracoembed', {
desc: 'Embed third party media',
});
@@ -1,10 +1,3 @@
tinyMCE.addI18n('en_us.embed_dlg', {
title: 'Embed third party media',
general: 'General',
url: 'Url:',
size: 'Size:',
constrain_proportions: 'Constrain',
preview: 'Preview',
source: 'Source'
tinyMCE.addI18n('en_us.umbracoembed', {
desc: 'Embed third party media',
});
@@ -0,0 +1,10 @@
tinyMCE.addI18n('ja.embed_dlg', {
title: 'サードパーティメディアの埋め込み',
general: '一般',
url: 'Url:',
size: 'サイズ:',
constrain_proportions: '制約',
preview: 'プレビュー',
source: 'ソース'
});
@@ -0,0 +1,10 @@
tinyMCE.addI18n('ja.embed_dlg', {
title: サードパーティメディアの埋め込み',
general: '一般',
url: 'Url:',
size: 'サイズ:',
constrain_proportions: '制約',
preview: 'プレビュー',
source: 'ソース'
});
@@ -0,0 +1,10 @@
tinyMCE.addI18n('sv.embed_dlg', {
title: 'Bädda in tredjeparts media',
general: 'Generell',
url: 'Url:',
size: 'Storlek:',
constrain_proportions: 'Bibehåll proportioner',
preview: 'Förhandsgranska',
source: 'Källa'
});
@@ -0,0 +1,10 @@
tinyMCE.addI18n('sv.embed_dlg', {
title: 'Bädda in tredjeparts media',
general: 'Generell',
url: 'Url:',
size: 'Storlek:',
constrain_proportions: 'Bibehåll proportioner',
preview: 'Förhandsgranska',
source: 'Källa'
});
@@ -0,0 +1,43 @@
tinyMCE.addI18n('it.umbimage_dlg', {
tab_general: 'Generale',
tab_appearance: 'Aspetto',
tab_advanced: 'Avanzate',
general: 'Generale',
title: 'Titolo',
preview: 'Anteprima',
constrain_proportions: 'Vincola proporzioni',
langdir: 'Direzione lingua',
langcode: 'Codice lingua',
long_desc: 'Descrizione lunga del collegamento',
style: 'Stile',
classes: 'Classi',
ltr: 'Da sinistra a destra',
rtl: 'Da destra a sinistra',
id: 'Id',
map: 'Image map',
swap_image: 'Swap immagine',
alt_image: 'Testo alternativo',
mouseover: 'Mouse over',
mouseout: 'Mouse out',
misc: 'Varie',
example_img: 'Aspetto anteprima immagine',
missing_alt: 'Sei sicuro di voler continuare senza includere una Descrizione dell'immagine? Se non lo fai l'immagine potrebbe risultare non accessibile per gli utenti con disabilit\u00E0, o per chi utilizza un browser di testo, o per chi naviga senza immagini.',
dialog_title: 'Inserisci/Modifica immagine',
src: 'URL immagine',
alt: 'Descrizione immagine',
list: 'Immagine lista',
border: 'Bordo',
dimensions: 'Dimensioni',
vspace: 'Spaziatura verticale',
hspace: 'Spaziatura orizzontale',
align: 'Allineamento',
align_baseline: 'Baseline',
align_top: 'Top',
align_middle: 'Middle',
align_bottom: 'Bottom',
align_texttop: 'Testo superiore',
align_textbottom: 'Testo inferiore',
align_left: 'Sinistra',
align_right: 'Destra',
image_list: 'Immagine lista'
});
@@ -0,0 +1,43 @@
tinyMCE.addI18n('sv.umbimage_dlg', {
tab_general: 'Generellt',
tab_appearance: 'Utseende',
tab_advanced: 'Avancerat',
general: 'Generellt',
title: 'Titel',
preview: 'Förhandsgranska',
constrain_proportions: 'Bibehåll proportioner',
langdir: 'Språkdirektion',
langcode: 'Språkkod',
long_desc: 'Lång länkbeskrivning',
style: 'Stil',
classes: 'Klasser',
ltr: 'Vänster till höger',
rtl: 'höger till vänster',
id: 'Id',
map: 'Bildkarta',
swap_image: 'Byt bild',
alt_image: 'Alternativ bild',
mouseover: 'För musen över',
mouseout: 'för musen utanför',
misc: 'Blandat',
example_img: 'Visning av bildförhandsgranskning',
missing_alt: 'Are you sure you want to continue without including an Image Description? Without it the image may not be accessible to some users with disabilities, or to those using a text browser, or browsing the Web with images turned off.',
dialog_title: 'Infoga/redigera bild',
src: 'Bild URL',
alt: 'Bildbeskrivning',
list: 'Bildlista',
border: 'Ram',
dimensions: 'Dimensioner',
vspace: 'Vertikalt avstånd',
hspace: 'Horisontellt avstånd',
align: 'Position',
align_baseline: 'Baslinje',
align_top: 'Toppen',
align_middle: 'Mitten',
align_bottom: 'Botten',
align_texttop: 'Text topp',
align_textbottom: 'Text botten',
align_left: 'Vänster',
align_right: 'Höger',
image_list: 'Bildlista'
});
@@ -0,0 +1 @@
tinyMCE.addI18n('sv.advlink_dlg', { "target_name": "Målets namn", classes: "Klasser", style: "Stil", id: "ID", "popup_position": "Position (X/Y)", langdir: "Språkmål", "popup_size": "Storlek", "popup_dependent": "Dependent (Mozilla/Firefox Only)", "popup_resizable": "Make Window Resizable", "popup_location": "Show Location Bar", "popup_menubar": "Show Menu Bar", "popup_toolbar": "Show Toolbars", "popup_statusbar": "Show Status Bar", "popup_scrollbars": "Show Scrollbars", "popup_return": "Insert \'return false\'", "popup_name": "Window Name", "popup_url": "Popup URL", popup: "JavaScript Popup", "target_blank": "Öppna i ett nytt fönster", "target_top": "Öppna i toppramen", "target_parent": "Öppna i nuvarande fönster/ram", "target_same": "Öppna i detta fönster/ram", "anchor_names": "Ankare", "popup_opts": "Options", "advanced_props": "Advanced Properties", "event_props": "Events", "popup_props": "Popup Properties", "general_props": "General Properties", "advanced_tab": "Advanced", "events_tab": "Events", "popup_tab": "Popup", "general_tab": "General", list: "Link List", "is_external": "The URL you entered seems to be an external link. Do you want to add the required http:// prefix?", "is_email": "The URL you entered seems to be an email address. Do you want to add the required mailto: prefix?", titlefield: "Title", target: "Mål", url: "Länkens URL", title: "Infoga/redigera länk", "link_list": "Link List", rtl: "Right to Left", ltr: "Left to Right", accesskey: "AccessKey", tabindex: "TabIndex", rev: "Relationship Target to Page", rel: "Relationship Page to Target", mime: "Target MIME Type", encoding: "Target Character Encoding", langcode: "Språkkod", "target_langcode": "Målspråk", width: "Bredd", height: "Höjd" });
@@ -0,0 +1,3 @@
tinyMCE.addI18n('sv.umbracomacro',{
desc : 'Infoga makro'
});
@@ -0,0 +1,3 @@
tinyMCE.addI18n('sv.example_dlg',{
title : 'Detta är bar ett exempel på en titel'
});
@@ -17,9 +17,7 @@
<appSettings>
<add xdt:Transform="Replace" xdt:Locator="Match(key)" key="umbracoDbDSN"
value="server=.\sqlexpress;database=v4;user id=sa;password=test;Application Name=Umbraco41"/>
<add xdt:Transform="Replace" xdt:Locator="Match(key)" key="umbracoConfigurationStatus"
value="4.11.4"/>
value="server=.\sqlexpress;database=v4;user id=sa;password=test;Application Name=Umbraco41"/>
<add xdt:Transform="Replace" xdt:Locator="Match(key)" key="umbracoContentXML"
value="~/App_Data/umbraco.config"/>
<add xdt:Transform="Replace" xdt:Locator="Match(key)" key="umbracoStorageDirectory"
+70 -33
View File
@@ -1,49 +1,86 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Umbraco.Core;
using Umbraco.Core.ObjectResolution;
using umbraco.interfaces;
namespace Umbraco.Web
{
/// <summary>
/// A resolver to return all IApplicationEvents objects
/// </summary>
internal sealed class ApplicationEventsResolver : ManyObjectsResolverBase<ApplicationEventsResolver, IApplicationStartupHandler>
{
/// <summary>
/// A resolver to return all IApplicationEvents objects
/// </summary>
internal sealed class ApplicationEventsResolver : ManyObjectsResolverBase<ApplicationEventsResolver, IApplicationEventHandler>
{
/// <summary>
/// Constructor
/// </summary>
/// <param name="applicationEventHandlers"></param>
internal ApplicationEventsResolver(IEnumerable<Type> applicationEventHandlers)
: base(applicationEventHandlers)
{
private readonly LegacyStartupHandlerResolver _legacyResolver;
}
/// <summary>
/// Constructor
/// </summary>
/// <param name="applicationEventHandlers"></param>
internal ApplicationEventsResolver(IEnumerable<Type> applicationEventHandlers)
: base(applicationEventHandlers)
{
//create the legacy resolver and only include the legacy types
_legacyResolver = new LegacyStartupHandlerResolver(
applicationEventHandlers.Where(x => !TypeHelper.IsTypeAssignableFrom<IApplicationEventHandler>(x)));
}
/// <summary>
/// Gets the <see cref="IApplicationEventHandler"/> implementations.
/// </summary>
public IEnumerable<IApplicationEventHandler> ApplicationEventHandlers
{
get { return Values.OfType<IApplicationEventHandler>(); }
}
/// <summary>
/// Override in order to only return types of IApplicationEventHandler and above,
/// do not include the legacy types of IApplicationStartupHandler
/// </summary>
protected override IEnumerable<Type> InstanceTypes
{
get { return base.InstanceTypes.Where(TypeHelper.IsTypeAssignableFrom<IApplicationEventHandler>); }
}
protected override bool SupportsClear
{
get { return false; }
}
/// <summary>
/// Gets the <see cref="IApplicationEventHandler"/> implementations.
/// </summary>
public IEnumerable<IApplicationEventHandler> ApplicationEventHandlers
{
get { return Values; }
}
protected override bool SupportsInsert
{
get { return false; }
}
/// <summary>
/// Create instances of all of the legacy startup handlers
/// </summary>
public void InstantiateLegacyStartupHanlders()
{
//this will instantiate them all
var handlers = _legacyResolver.LegacyStartupHandlers;
}
protected override bool SupportsRemove
{
get { return false; }
}
protected override bool SupportsClear
{
get { return false; }
}
}
protected override bool SupportsInsert
{
get { return false; }
}
protected override bool SupportsRemove
{
get { return false; }
}
private class LegacyStartupHandlerResolver : ManyObjectsResolverBase<ApplicationEventsResolver, IApplicationStartupHandler>
{
internal LegacyStartupHandlerResolver(IEnumerable<Type> legacyStartupHandlers)
: base(legacyStartupHandlers)
{
}
public IEnumerable<IApplicationStartupHandler> LegacyStartupHandlers
{
get { return Values; }
}
}
}
}
@@ -199,33 +199,34 @@ namespace Umbraco.Web.BaseRest
// which has been properly marked with the attribute, and use the attribute
// properties to setup a RestExtensionMethodInfo
var extensions = PluginManager.Current.ResolveLegacyRestExtensions();
var extension = extensions
.SingleOrDefault(type => type.GetCustomAttribute<global::umbraco.presentation.umbracobase.RestExtension>(false).GetAlias() == extensionAlias);
var extensions = PluginManager.Current.ResolveLegacyRestExtensions()
.Where(type => type.GetCustomAttribute<global::umbraco.presentation.umbracobase.RestExtension>(false).GetAlias() == extensionAlias);
RestExtensionMethodInfo info = null;
if (extension != null)
foreach (var extension in extensions) // foreach classes with extension alias
{
var method = extension.GetMethod(methodName);
if (method != null)
{
var attribute = method.GetCustomAttributes(typeof(global::umbraco.presentation.umbracobase.RestExtensionMethod), false).Cast<global::umbraco.presentation.umbracobase.RestExtensionMethod>().SingleOrDefault();
if (attribute != null)
{
info = new RestExtensionMethodInfo(attribute.GetAllowAll(),
attribute.GetAllowGroup(), attribute.GetAllowType(), attribute.GetAllowMember(),
attribute.returnXml,
method);
if (method == null) continue; // not implementing the method = ignore
// looks good, cache
lock (_cache)
{
_cache[cacheKey] = info;
}
}
}
}
var attribute = method.GetCustomAttributes(typeof(global::umbraco.presentation.umbracobase.RestExtensionMethod), false).Cast<global::umbraco.presentation.umbracobase.RestExtensionMethod>().SingleOrDefault();
if (attribute == null) continue; // method has not attribute = ignore
// got it!
info = new RestExtensionMethodInfo(attribute.GetAllowAll(),
attribute.GetAllowGroup(), attribute.GetAllowType(), attribute.GetAllowMember(),
attribute.returnXml,
method);
// cache
lock (_cache)
{
_cache[cacheKey] = info;
}
// got it, no need to look any further
break;
}
return info;
}
@@ -249,34 +250,37 @@ namespace Umbraco.Web.BaseRest
// find an extension with that alias, then find a method with that name,
// which has been properly marked with the attribute, and use the attribute
// properties to setup a RestExtensionMethodInfo
//
// note: the extension may be implemented by more than one class
var extensions = PluginManager.Current.ResolveRestExtensions();
var extension = extensions
.SingleOrDefault(type => type.GetCustomAttribute<RestExtensionAttribute>(false).Alias == extensionAlias);
var extensions = PluginManager.Current.ResolveRestExtensions()
.Where(type => type.GetCustomAttribute<RestExtensionAttribute>(false).Alias == extensionAlias);
RestExtensionMethodInfo info = null;
if (extension != null)
{
var method = extension.GetMethod(methodName);
if (method != null)
{
var attribute = method.GetCustomAttributes(typeof(RestExtensionMethodAttribute), false).Cast<RestExtensionMethodAttribute>().SingleOrDefault();
if (attribute != null)
{
info = new RestExtensionMethodInfo(attribute.AllowAll,
attribute.AllowGroup, attribute.AllowType, attribute.AllowMember,
attribute.ReturnXml,
method);
foreach (var extension in extensions) // foreach classes with extension alias
{
var method = extension.GetMethod(methodName);
if (method == null) continue; // not implementing the method = ignore
// looks good, cache
lock (_cache)
{
_cache[cacheKey] = info;
}
}
}
}
var attribute = method.GetCustomAttributes(typeof(RestExtensionMethodAttribute), false).Cast<RestExtensionMethodAttribute>().SingleOrDefault();
if (attribute == null) continue; // method has not attribute = ignore
// got it!
info = new RestExtensionMethodInfo(attribute.AllowAll,
attribute.AllowGroup, attribute.AllowType, attribute.AllowMember,
attribute.ReturnXml,
method);
// cache
lock (_cache)
{
_cache[cacheKey] = info;
}
// got it, no need to look any further
break;
}
return info;
}
@@ -4,6 +4,7 @@ using System.Text;
using System.Xml;
using System.Xml.Linq;
using Umbraco.Core.Models;
using Umbraco.Core.Xml;
using Umbraco.Web.Routing;
using umbraco;
using umbraco.NodeFactory;
@@ -28,7 +29,8 @@ namespace Umbraco.Web
public string DescendantDocumentById { get; private set; }
public string DescendantDocumentByAlias { get; private set; }
public string ChildDocumentByUrlName { get; private set; }
public string RootDocumentWithLowestSortOrder { get; private set; }
public string ChildDocumentByUrlNameVar { get; private set; }
public string RootDocumentWithLowestSortOrder { get; private set; }
public XPathStringsDefinition(int version)
{
@@ -45,6 +47,7 @@ namespace Umbraco.Web
+ " or contains(concat(',',translate(data [@alias='umbracoUrlAlias'], ' ', ''),','),',/{0},')"
+ ")]";
ChildDocumentByUrlName = "/node [@urlName='{0}']";
ChildDocumentByUrlNameVar = "/node [@urlName=${0}]";
RootDocumentWithLowestSortOrder = "/root/node [not(@sortOrder > ../node/@sortOrder)][1]";
break;
@@ -57,6 +60,7 @@ namespace Umbraco.Web
+ " or contains(concat(',',translate(umbracoUrlAlias, ' ', ''),','),',/{0},')"
+ ")]";
ChildDocumentByUrlName = "/* [@isDoc and @urlName='{0}']";
ChildDocumentByUrlNameVar = "/* [@isDoc and @urlName=${0}]";
RootDocumentWithLowestSortOrder = "/root/* [@isDoc and not(@sortOrder > ../* [@isDoc]/@sortOrder)][1]";
break;
@@ -119,19 +123,20 @@ namespace Umbraco.Web
int pos = route.IndexOf('/');
string path = pos == 0 ? route : route.Substring(pos);
int startNodeId = pos == 0 ? 0 : int.Parse(route.Substring(0, pos));
IEnumerable<XPathVariable> vars;
var xpath = CreateXpathQuery(startNodeId, path, hideTopLevelNode.Value);
var xpath = CreateXpathQuery(startNodeId, path, hideTopLevelNode.Value, out vars);
//check if we can find the node in our xml cache
var found = GetXml(umbracoContext).SelectSingleNode(xpath);
var found = GetXml(umbracoContext).SelectSingleNode(xpath, vars);
// if hideTopLevelNodePath is true then for url /foo we looked for /*/foo
// but maybe that was the url of a non-default top-level node, so we also
// have to look for /foo (see note in NiceUrlProvider).
if (found == null && hideTopLevelNode.Value && path.Length > 1 && path.IndexOf('/', 1) < 0)
{
xpath = CreateXpathQuery(startNodeId, path, false);
found = GetXml(umbracoContext).SelectSingleNode(xpath);
xpath = CreateXpathQuery(startNodeId, path, false, out vars);
found = GetXml(umbracoContext).SelectSingleNode(xpath, vars);
}
return ConvertToDocument(found);
@@ -152,11 +157,17 @@ namespace Umbraco.Web
if (rootNodeId > 0)
xpathBuilder.AppendFormat(XPathStrings.DescendantDocumentById, rootNodeId);
XPathVariable var = null;
if (alias.Contains('\'') || alias.Contains('"'))
{
var = new XPathVariable("alias", alias);
alias = "$alias";
}
xpathBuilder.AppendFormat(XPathStrings.DescendantDocumentByAlias, alias);
var xpath = xpathBuilder.ToString();
return ConvertToDocument(GetXml(umbracoContext).SelectSingleNode(xpath));
return ConvertToDocument(GetXml(umbracoContext).SelectSingleNode(xpath, var));
}
public bool HasContent(UmbracoContext umbracoContext)
@@ -177,9 +188,10 @@ namespace Umbraco.Web
static readonly char[] SlashChar = new char[] { '/' };
protected string CreateXpathQuery(int startNodeId, string path, bool hideTopLevelNodeFromPath)
protected string CreateXpathQuery(int startNodeId, string path, bool hideTopLevelNodeFromPath, out IEnumerable<XPathVariable> vars)
{
string xpath;
vars = null;
if (path == string.Empty || path == "/")
{
@@ -213,6 +225,7 @@ namespace Umbraco.Web
var urlParts = path.Split(SlashChar, StringSplitOptions.RemoveEmptyEntries);
var xpathBuilder = new StringBuilder();
int partsIndex = 0;
List<XPathVariable> varsList = null;
if (startNodeId == 0)
{
@@ -229,10 +242,24 @@ namespace Umbraco.Web
while (partsIndex < urlParts.Length)
{
xpathBuilder.AppendFormat(XPathStrings.ChildDocumentByUrlName, urlParts[partsIndex++]);
var part = urlParts[partsIndex++];
if (part.Contains('\'') || part.Contains('"'))
{
varsList = varsList ?? new List<XPathVariable>();
var varName = string.Format("var{0}", partsIndex);
varsList.Add(new XPathVariable(varName, part));
xpathBuilder.AppendFormat(XPathStrings.ChildDocumentByUrlNameVar, varName);
}
else
{
xpathBuilder.AppendFormat(XPathStrings.ChildDocumentByUrlName, part);
}
}
xpath = xpathBuilder.ToString();
if (varsList != null)
vars = varsList.ToArray();
}
return xpath;
+56 -11
View File
@@ -9,9 +9,11 @@ using Examine.Providers;
using Lucene.Net.Documents;
using Umbraco.Core;
using Umbraco.Core.Dynamics;
using Umbraco.Core.Logging;
using Umbraco.Core.Models;
using umbraco;
using umbraco.cms.businesslogic;
using Examine.LuceneEngine.SearchCriteria;
namespace Umbraco.Web
{
@@ -28,16 +30,19 @@ namespace Umbraco.Web
{
}
/// <summary>
/// Generally used for unit testing to use an explicit examine searcher
/// </summary>
/// <param name="searchProvider"></param>
internal DefaultPublishedMediaStore(BaseSearchProvider searchProvider)
/// <summary>
/// Generally used for unit testing to use an explicit examine searcher
/// </summary>
/// <param name="searchProvider"></param>
/// <param name="indexProvider"></param>
internal DefaultPublishedMediaStore(BaseSearchProvider searchProvider, BaseIndexProvider indexProvider)
{
_searchProvider = searchProvider;
_searchProvider = searchProvider;
_indexProvider = indexProvider;
}
private readonly BaseSearchProvider _searchProvider;
private readonly BaseSearchProvider _searchProvider;
private readonly BaseIndexProvider _indexProvider;
public virtual IPublishedContent GetDocumentById(UmbracoContext umbracoContext, int nodeId)
{
@@ -71,7 +76,29 @@ namespace Umbraco.Web
}
}
private BaseSearchProvider GetSearchProviderSafe()
private BaseIndexProvider GetIndexProviderSafe()
{
if (_indexProvider != null)
return _indexProvider;
var eMgr = GetExamineManagerSafe();
if (eMgr != null)
{
try
{
//by default use the InternalSearcher
return eMgr.IndexProviderCollection["InternalIndexer"];
}
catch (Exception ex)
{
LogHelper.Error<DefaultPublishedMediaStore>("Could not retreive the InternalIndexer", ex);
//something didn't work, continue returning null.
}
}
return null;
}
private BaseSearchProvider GetSearchProviderSafe()
{
if (_searchProvider != null)
return _searchProvider;
@@ -306,11 +333,29 @@ namespace Umbraco.Web
{
//first check in Examine as this is WAY faster
var criteria = searchProvider.CreateSearchCriteria("media");
var filter = criteria.ParentId(parentId);
var results = searchProvider.Search(filter.Compile());
var filter = criteria.ParentId(parentId);
ISearchResults results;
//we want to check if the indexer for this searcher has "sortOrder" flagged as sortable.
//if so, we'll use Lucene to do the sorting, if not we'll have to manually sort it (slower).
var indexer = GetIndexProviderSafe();
var useLuceneSort = indexer != null && indexer.IndexerData.StandardFields.Any(x => x.Name.InvariantEquals("sortOrder") && x.EnableSorting);
if (useLuceneSort)
{
//we have a sortOrder field declared to be sorted, so we'll use Examine
results = searchProvider.Search(
filter.And().OrderBy(new SortableField("sortOrder", SortType.Int)).Compile());
}
else
{
results = searchProvider.Search(filter.Compile());
}
if (results.Any())
{
return results.Select(ConvertFromSearchResult);
return useLuceneSort
? results.Select(ConvertFromSearchResult) //will already be sorted by lucene
: results.Select(ConvertFromSearchResult).OrderBy(x => x.SortOrder);
}
}
catch (FileNotFoundException)
+1 -1
View File
@@ -11,7 +11,7 @@ namespace Umbraco.Web.Dynamics
internal class Grouping<K, T> : IGrouping<K, T> where T : DynamicObject
{
public K Key { get; set; }
public IEnumerable<T> Elements;
public IEnumerable<T> Elements { get; set; }
public IEnumerator<T> GetEnumerator()
{
+77 -9
View File
@@ -6,8 +6,10 @@ using System.Text;
using System.Web;
using System.Web.Mvc;
using System.Web.Mvc.Html;
using System.Web.Routing;
using Umbraco.Core;
using Umbraco.Core.Dynamics;
using Umbraco.Core.IO;
using Umbraco.Web.Mvc;
using umbraco;
using umbraco.cms.businesslogic.member;
@@ -19,6 +21,30 @@ namespace Umbraco.Web
/// </summary>
public static class HtmlHelperRenderExtensions
{
/// <summary>
/// Will render the preview badge when in preview mode which is not required ever unless the MVC page you are
/// using does not inherit from UmbracoTemplatePage
/// </summary>
/// <param name="helper"></param>
/// <returns></returns>
/// <remarks>
/// See: http://issues.umbraco.org/issue/U4-1614
/// </remarks>
public static MvcHtmlString PreviewBadge(this HtmlHelper helper)
{
if (UmbracoContext.Current.InPreviewMode)
{
var htmlBadge =
String.Format(UmbracoSettings.PreviewBadge,
IOHelper.ResolveUrl(SystemDirectories.Umbraco),
IOHelper.ResolveUrl(SystemDirectories.UmbracoClient),
UmbracoContext.Current.HttpContext.Server.UrlEncode(UmbracoContext.Current.HttpContext.Request.Path));
return new MvcHtmlString(htmlBadge);
}
return new MvcHtmlString("");
}
public static IHtmlString CachedPartial(
this HtmlHelper htmlHelper,
string partialViewName,
@@ -83,6 +109,48 @@ namespace Umbraco.Web
return filteredHtmlHelper.ValidationSummary(excludePropertyErrors, message, htmlAttributes);
}
/// <summary>
/// Returns the result of a child action of a strongly typed SurfaceController
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="htmlHelper"></param>
/// <param name="actionName"></param>
/// <returns></returns>
public static IHtmlString Action<T>(this HtmlHelper htmlHelper, string actionName)
where T : SurfaceController
{
return htmlHelper.Action(actionName, typeof(T));
}
/// <summary>
/// Returns the result of a child action of a SurfaceController
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="htmlHelper"></param>
/// <param name="actionName"></param>
/// <param name="surfaceType"></param>
/// <returns></returns>
public static IHtmlString Action(this HtmlHelper htmlHelper, string actionName, Type surfaceType)
{
Mandate.ParameterNotNull(surfaceType, "surfaceType");
Mandate.ParameterNotNullOrEmpty(actionName, "actionName");
var routeVals = new RouteValueDictionary(new {area = ""});
var surfaceController = SurfaceControllerResolver.Current.RegisteredSurfaceControllers
.SingleOrDefault(x => x == surfaceType);
if (surfaceController == null)
throw new InvalidOperationException("Could not find the surface controller of type " + surfaceType.FullName);
var metaData = PluginController.GetMetadata(surfaceController);
if (!metaData.AreaName.IsNullOrWhiteSpace())
{
//set the area to the plugin area
routeVals.Add("area", metaData.AreaName);
}
return htmlHelper.Action(actionName, metaData.ControllerName, routeVals);
}
#region BeginUmbracoForm
/// <summary>
@@ -201,8 +269,7 @@ namespace Umbraco.Web
Mandate.ParameterNotNullOrEmpty(action, "action");
Mandate.ParameterNotNullOrEmpty(controllerName, "controllerName");
var area = Umbraco.Core.Configuration.GlobalSettings.UmbracoMvcArea;
return html.BeginUmbracoForm(action, controllerName, area, additionalRouteVals, htmlAttributes);
return html.BeginUmbracoForm(action, controllerName, "", additionalRouteVals, htmlAttributes);
}
/// <summary>
@@ -307,17 +374,19 @@ namespace Umbraco.Web
Mandate.ParameterNotNullOrEmpty(action, "action");
Mandate.ParameterNotNull(surfaceType, "surfaceType");
var area = Umbraco.Core.Configuration.GlobalSettings.UmbracoMvcArea;
var surfaceController = SurfaceControllerResolver.Current.SurfaceControllers
.SingleOrDefault(x => x.Metadata.ControllerType == surfaceType);
var area = "";
var surfaceController = SurfaceControllerResolver.Current.RegisteredSurfaceControllers
.SingleOrDefault(x => x == surfaceType);
if (surfaceController == null)
throw new InvalidOperationException("Could not find the surface controller of type " + surfaceType.FullName);
if (!surfaceController.Metadata.AreaName.IsNullOrWhiteSpace())
var metaData = PluginController.GetMetadata(surfaceController);
if (!metaData.AreaName.IsNullOrWhiteSpace())
{
//set the area to the plugin area
area = surfaceController.Metadata.AreaName;
area = metaData.AreaName;
}
return html.BeginUmbracoForm(action, surfaceController.Metadata.ControllerName, area, additionalRouteVals, htmlAttributes);
return html.BeginUmbracoForm(action, metaData.ControllerName, area, additionalRouteVals, htmlAttributes);
}
/// <summary>
@@ -364,7 +433,6 @@ namespace Umbraco.Web
object additionalRouteVals,
IDictionary<string, object> htmlAttributes)
{
Mandate.ParameterNotNullOrEmpty(area, "area");
Mandate.ParameterNotNullOrEmpty(action, "action");
Mandate.ParameterNotNullOrEmpty(controllerName, "controllerName");
@@ -7,33 +7,37 @@ using System.Linq;
namespace Umbraco.Web.Macros
{
/// <summary>
/// Controller to render macro content for Parital View Macros
/// </summary>
internal class PartialViewMacroController : Controller
{
private readonly UmbracoContext _umbracoContext;
private readonly MacroModel _macro;
private readonly INode _currentPage;
public PartialViewMacroController(UmbracoContext umbracoContext, MacroModel macro, INode currentPage)
{
_umbracoContext = umbracoContext;
_macro = macro;
_currentPage = currentPage;
}
/// <summary>
/// Controller to render macro content for Parital View Macros
/// </summary>
internal class PartialViewMacroController : Controller
{
private readonly UmbracoContext _umbracoContext;
private readonly MacroModel _macro;
private readonly INode _currentPage;
/// <summary>
/// Child action to render a macro
/// </summary>
/// <returns></returns>
[ChildActionOnly]
public PartialViewResult Index()
{
var model = new PartialViewMacroModel(_currentPage.ConvertFromNode(),
_macro.Properties.ToDictionary(x => x.Key, x => (object)x.Value));
return PartialView(_macro.ScriptName, model);
}
public PartialViewMacroController(UmbracoContext umbracoContext, MacroModel macro, INode currentPage)
{
_umbracoContext = umbracoContext;
_macro = macro;
_currentPage = currentPage;
}
}
/// <summary>
/// Child action to render a macro
/// </summary>
/// <returns></returns>
[ChildActionOnly]
public PartialViewResult Index()
{
var model = new PartialViewMacroModel(
_currentPage.ConvertFromNode(),
_macro.Id,
_macro.Alias,
_macro.Name,
_macro.Properties.ToDictionary(x => x.Key, x => (object)x.Value));
return PartialView(_macro.ScriptName, model);
}
}
}
+123 -115
View File
@@ -12,51 +12,53 @@ using Umbraco.Core.IO;
using umbraco.cms.businesslogic.macro;
using umbraco.interfaces;
using Umbraco.Web.Mvc;
using Umbraco.Core;
using System.Web.Mvc.Html;
namespace Umbraco.Web.Macros
{
/// <summary>
/// A macro engine using MVC Partial Views to execute
/// </summary>
public class PartialViewMacroEngine : IMacroEngine
{
private readonly Func<HttpContextBase> _getHttpContext;
private readonly Func<UmbracoContext> _getUmbracoContext;
/// <summary>
/// A macro engine using MVC Partial Views to execute
/// </summary>
public class PartialViewMacroEngine : IMacroEngine
{
private readonly Func<HttpContextBase> _getHttpContext;
private readonly Func<UmbracoContext> _getUmbracoContext;
public const string EngineName = "Partial View Macro Engine";
public const string EngineName = "Partial View Macro Engine";
public PartialViewMacroEngine()
{
_getHttpContext = () =>
{
if (HttpContext.Current == null)
throw new InvalidOperationException("The " + this.GetType() + " cannot execute with a null HttpContext.Current reference");
return new HttpContextWrapper(HttpContext.Current);
};
public PartialViewMacroEngine()
{
_getHttpContext = () =>
{
if (HttpContext.Current == null)
throw new InvalidOperationException("The " + this.GetType() + " cannot execute with a null HttpContext.Current reference");
return new HttpContextWrapper(HttpContext.Current);
};
_getUmbracoContext = () =>
{
if (UmbracoContext.Current == null)
throw new InvalidOperationException("The " + this.GetType() + " cannot execute with a null UmbracoContext.Current reference");
return UmbracoContext.Current;
};
}
_getUmbracoContext = () =>
{
if (UmbracoContext.Current == null)
throw new InvalidOperationException("The " + this.GetType() + " cannot execute with a null UmbracoContext.Current reference");
return UmbracoContext.Current;
};
}
/// <summary>
/// Constructor generally used for unit testing
/// </summary>
/// <param name="httpContext"></param>
/// <param name="umbracoContext"> </param>
internal PartialViewMacroEngine(HttpContextBase httpContext, UmbracoContext umbracoContext)
{
_getHttpContext = () => httpContext;
_getUmbracoContext = () => umbracoContext;
}
/// <summary>
/// Constructor generally used for unit testing
/// </summary>
/// <param name="httpContext"></param>
/// <param name="umbracoContext"> </param>
internal PartialViewMacroEngine(HttpContextBase httpContext, UmbracoContext umbracoContext)
{
_getHttpContext = () => httpContext;
_getUmbracoContext = () => umbracoContext;
}
public string Name
{
get { return EngineName; }
}
public string Name
{
get { return EngineName; }
}
//NOTE: We do not return any supported extensions because we don't want the MacroEngineFactory to return this
// macro engine when searching for engines via extension. Those types of engines are reserved for files that are
@@ -65,7 +67,6 @@ namespace Umbraco.Web.Macros
public IEnumerable<string> SupportedExtensions
{
get { return Enumerable.Empty<string>(); }
//get { return new[] {"cshtml", "vbhtml"}; }
}
//NOTE: We do not return any supported extensions because we don't want the MacroEngineFactory to return this
@@ -75,92 +76,99 @@ namespace Umbraco.Web.Macros
public IEnumerable<string> SupportedUIExtensions
{
get { return Enumerable.Empty<string>(); }
//get { return new[] { "cshtml", "vbhtml" }; }
}
public Dictionary<string, IMacroGuiRendering> SupportedProperties
{
get { throw new NotSupportedException(); }
}
public Dictionary<string, IMacroGuiRendering> SupportedProperties
{
get { throw new NotSupportedException(); }
}
public bool Validate(string code, string tempFileName, INode currentPage, out string errorMessage)
{
var temp = GetVirtualPathFromPhysicalPath(tempFileName);
try
{
CompileAndInstantiate(temp);
}
catch (Exception exception)
{
errorMessage = exception.Message;
return false;
}
errorMessage = string.Empty;
return true;
}
public bool Validate(string code, string tempFileName, INode currentPage, out string errorMessage)
{
var temp = GetVirtualPathFromPhysicalPath(tempFileName);
try
{
CompileAndInstantiate(temp);
}
catch (Exception exception)
{
errorMessage = exception.Message;
return false;
}
errorMessage = string.Empty;
return true;
}
public string Execute(MacroModel macro, INode currentPage)
{
if (macro == null) throw new ArgumentNullException("macro");
if (currentPage == null) throw new ArgumentNullException("currentPage");
if (macro.ScriptName.IsNullOrWhiteSpace()) throw new ArgumentException("The ScriptName property of the macro object cannot be null or empty");
public string Execute(MacroModel macro, INode currentPage)
{
if (macro == null) throw new ArgumentNullException("macro");
if (currentPage == null) throw new ArgumentNullException("currentPage");
if (!macro.ScriptName.StartsWith(SystemDirectories.MvcViews + "/MacroPartials/")
&& (!Regex.IsMatch(macro.ScriptName, "~/App_Plugins/.+?/Views/MacroPartials", RegexOptions.Compiled)))
{
throw new InvalidOperationException("Cannot render the Partial View Macro with file: " + macro.ScriptName + ". All Partial View Macros must exist in the " + SystemDirectories.MvcViews + "/MacroPartials/ folder");
}
if (!macro.ScriptName.StartsWith(SystemDirectories.MvcViews + "/MacroPartials/")
&& (!Regex.IsMatch(macro.ScriptName, "~/App_Plugins/.+?/Views/MacroPartials", RegexOptions.Compiled)))
{
throw new InvalidOperationException("Cannot render the Partial View Macro with file: " + macro.ScriptName + ". All Partial View Macros must exist in the " + SystemDirectories.MvcViews + "/MacroPartials/ folder");
}
var http = _getHttpContext();
var umbCtx = _getUmbracoContext();
var routeVals = new RouteData();
routeVals.Values.Add("controller", "PartialViewMacro");
routeVals.Values.Add("action", "Index");
routeVals.DataTokens.Add("umbraco-context", umbCtx); //required for UmbracoViewPage
var http = _getHttpContext();
var umbCtx = _getUmbracoContext();
var routeVals = new RouteData();
routeVals.Values.Add("controller", "PartialViewMacro");
routeVals.Values.Add("action", "Index");
routeVals.DataTokens.Add("umbraco-context", umbCtx); //required for UmbracoViewPage
//lets render this controller as a child action if we are currently executing using MVC
//(otherwise don't do this since we're using webforms)
var mvcHandler = http.CurrentHandler as MvcHandler;
var viewContext = new ViewContext { ViewData = new ViewDataDictionary() }; ;
if (mvcHandler != null)
{
//try and extract the current view context from the route values, this would be set in the UmbracoViewPage.
if (mvcHandler.RequestContext.RouteData.DataTokens.ContainsKey(Constants.DataTokenCurrentViewContext))
{
viewContext = (ViewContext)mvcHandler.RequestContext.RouteData.DataTokens[Constants.DataTokenCurrentViewContext];
}
routeVals.DataTokens.Add("ParentActionViewContext", viewContext);
}
////lets render this controller as a child action if we are currently executing using MVC
////(otherwise don't do this since we're using webforms)
//var mvcHandler = http.CurrentHandler as MvcHandler;
//if (mvcHandler != null)
//{
// routeVals.DataTokens.Add("ParentActionViewContext",
// //If we could get access to the currently executing controller we could do this but this is nearly
// //impossible. The only way to do that would be to store the controller instance in the route values
// //in the base class of the UmbracoController.... but not sure the reprocussions of that, i think it could
// //work but is a bit nasty.
// new ViewContext());
//}
var request = new RequestContext(http, routeVals);
string output;
using (var controller = new PartialViewMacroController(umbCtx, macro, currentPage))
{
//bubble up the model state from the main view context to our custom controller.
//when merging we'll create a new dictionary, otherwise you might run into an enumeration error
// caused from ModelStateDictionary
controller.ModelState.Merge(new ModelStateDictionary(viewContext.ViewData.ModelState));
controller.ControllerContext = new ControllerContext(request, controller);
//call the action to render
var result = controller.Index();
output = controller.RenderViewResultAsString(result);
}
var request = new RequestContext(http, routeVals);
string output;
using (var controller = new PartialViewMacroController(umbCtx, macro, currentPage))
{
controller.ControllerContext = new ControllerContext(request, controller);
var result = controller.Index();
output = controller.RenderViewResultAsString(result);
}
return output;
}
return output;
}
private string GetVirtualPathFromPhysicalPath(string physicalPath)
{
string rootpath = _getHttpContext().Server.MapPath("~/");
physicalPath = physicalPath.Replace(rootpath, "");
physicalPath = physicalPath.Replace("\\", "/");
return "~/" + physicalPath;
}
private string GetVirtualPathFromPhysicalPath(string physicalPath)
{
string rootpath = _getHttpContext().Server.MapPath("~/");
physicalPath = physicalPath.Replace(rootpath, "");
physicalPath = physicalPath.Replace("\\", "/");
return "~/" + physicalPath;
}
private static PartialViewMacroPage CompileAndInstantiate(string virtualPath)
{
//Compile Razor - We Will Leave This To ASP.NET Compilation Engine & ASP.NET WebPages
//Security in medium trust is strict around here, so we can only pass a virtual file path
//ASP.NET Compilation Engine caches returned types
//Changed From BuildManager As Other Properties Are Attached Like Context Path/
var webPageBase = WebPageBase.CreateInstanceFromVirtualPath(virtualPath);
var webPage = webPageBase as PartialViewMacroPage;
if (webPage == null)
throw new InvalidCastException("All Partial View Macro views must inherit from " + typeof(PartialViewMacroPage).FullName);
return webPage;
}
}
private static PartialViewMacroPage CompileAndInstantiate(string virtualPath)
{
//Compile Razor - We Will Leave This To ASP.NET Compilation Engine & ASP.NET WebPages
//Security in medium trust is strict around here, so we can only pass a virtual file path
//ASP.NET Compilation Engine caches returned types
//Changed From BuildManager As Other Properties Are Attached Like Context Path/
var webPageBase = WebPageBase.CreateInstanceFromVirtualPath(virtualPath);
var webPage = webPageBase as PartialViewMacroPage;
if (webPage == null)
throw new InvalidCastException("All Partial View Macro views must inherit from " + typeof(PartialViewMacroPage).FullName);
return webPage;
}
}
}

Some files were not shown because too many files have changed in this diff Show More