Merge
This commit is contained in:
@@ -26,7 +26,13 @@ namespace Umbraco.Tests.IO
|
||||
[TearDown]
|
||||
public void TearDown()
|
||||
{
|
||||
Directory.Delete(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "FileSysTests"));
|
||||
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)
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -24,10 +24,10 @@ using System.Linq;
|
||||
|
||||
namespace Umbraco.Tests.PublishedContent
|
||||
{
|
||||
/// <summary>
|
||||
/// <summary>
|
||||
/// Tests the typed extension methods on IPublishedContent using the DefaultPublishedMediaStore
|
||||
/// </summary>
|
||||
[TestFixture]
|
||||
[TestFixture, RequiresSTA]
|
||||
public class PublishedMediaTests : PublishedContentTestBase
|
||||
{
|
||||
|
||||
@@ -63,7 +63,34 @@ namespace Umbraco.Tests.PublishedContent
|
||||
{
|
||||
return GetNode(id, GetUmbracoContext("/test", 1234));
|
||||
}
|
||||
|
||||
[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 Do_Not_Find_In_Recycle_Bin()
|
||||
{
|
||||
@@ -72,7 +99,7 @@ namespace Umbraco.Tests.PublishedContent
|
||||
var indexer = indexInit.GetUmbracoIndexer(newIndexFolder);
|
||||
indexer.RebuildIndex();
|
||||
var searcher = indexInit.GetUmbracoSearcher(newIndexFolder);
|
||||
var store = new DefaultPublishedMediaStore(searcher);
|
||||
var store = new DefaultPublishedMediaStore(searcher, indexer);
|
||||
var ctx = GetUmbracoContext("/test", 1234);
|
||||
|
||||
//ensure it is found
|
||||
@@ -109,7 +136,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);
|
||||
@@ -129,7 +158,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);
|
||||
@@ -149,7 +180,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);
|
||||
@@ -169,7 +202,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);
|
||||
@@ -185,7 +220,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);
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -48,9 +48,9 @@
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Examine, Version=0.1.42.2941, Culture=neutral, processorArchitecture=MSIL">
|
||||
<Reference Include="Examine, Version=0.1.47.2941, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\Examine.0.1.42.2941\lib\Examine.dll</HintPath>
|
||||
<HintPath>..\packages\Examine.0.1.47.2941\lib\Examine.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="ICSharpCode.SharpZipLib, Version=0.86.0.518, Culture=neutral, PublicKeyToken=1b03e6acf1164f73, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
@@ -68,8 +68,9 @@
|
||||
<Private>True</Private>
|
||||
<HintPath>..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.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>
|
||||
@@ -189,6 +190,7 @@
|
||||
<Compile Include="Persistence\SyntaxProvider\SqlSyntaxProviderTests.cs" />
|
||||
<Compile Include="PublishedContent\DynamicXmlConverterTests.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" />
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Examine" version="0.1.42.2941" targetFramework="net40" />
|
||||
<package id="Examine" version="0.1.47.2941" targetFramework="net40" />
|
||||
<package id="log4net-mediumtrust" version="2.0.0" targetFramework="net40" />
|
||||
<package id="Lucene.Net" version="2.9.4.1" targetFramework="net40" />
|
||||
<package id="Microsoft.AspNet.Mvc" version="4.0.20710.0" targetFramework="net40" />
|
||||
<package id="Microsoft.AspNet.Razor" version="2.0.20715.0" targetFramework="net40" />
|
||||
<package id="Microsoft.AspNet.WebPages" version="2.0.20710.0" targetFramework="net40" />
|
||||
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net40" />
|
||||
<package id="NUnit" version="2.6.0.12054" 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="SqlServerCE" version="4.0.0.0" targetFramework="net40" />
|
||||
|
||||
@@ -10,6 +10,7 @@ using Examine.Providers;
|
||||
using Lucene.Net.Documents;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Dynamics;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Web.Models;
|
||||
using UmbracoExamine;
|
||||
@@ -32,16 +33,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)
|
||||
{
|
||||
@@ -75,7 +79,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;
|
||||
@@ -314,11 +340,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)
|
||||
|
||||
@@ -96,9 +96,9 @@
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\xmlrpcnet.2.5.0\lib\net20\CookComputing.XmlRpcV2.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Examine, Version=0.1.42.2941, Culture=neutral, processorArchitecture=MSIL">
|
||||
<Reference Include="Examine, Version=0.1.47.2941, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\Examine.0.1.42.2941\lib\Examine.dll</HintPath>
|
||||
<HintPath>..\packages\Examine.0.1.47.2941\lib\Examine.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="HtmlAgilityPack, Version=1.4.5.0, Culture=neutral, PublicKeyToken=bd319b19eaf3b43a, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
@@ -124,7 +124,7 @@
|
||||
<Private>True</Private>
|
||||
<HintPath>..\packages\CodeSharp.Package.AspNetWebPage.1.0\lib\net40\NuGet.Core.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Our.Umbraco.uGoLive">
|
||||
<Reference Include="Our.Umbraco.uGoLive">
|
||||
<HintPath>..\packages\uGoLive.1.4.0\lib\Our.Umbraco.uGoLive.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Our.Umbraco.uGoLive.47x">
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<packages>
|
||||
<package id="ClientDependency" version="1.5.1.0" targetFramework="net40" />
|
||||
<package id="CodeSharp.Package.AspNetWebPage" version="1.0" targetFramework="net40" />
|
||||
<package id="Examine" version="0.1.42.2941" targetFramework="net40" />
|
||||
<package id="Examine" version="0.1.47.2941" targetFramework="net40" />
|
||||
<package id="HtmlAgilityPack" version="1.4.5" targetFramework="net40" />
|
||||
<package id="Lucene.Net" version="2.9.4.1" targetFramework="net40" />
|
||||
<package id="Microsoft.AspNet.Mvc" version="4.0.20710.0" targetFramework="net40" />
|
||||
|
||||
@@ -88,7 +88,7 @@ namespace umbraco.MacroEngines
|
||||
var children = media.ChildrenAsList.Value;
|
||||
if (children != null)
|
||||
{
|
||||
return children.ToList().ConvertAll(m => new DynamicBackingItem(m));
|
||||
return children.ConvertAll(m => new DynamicBackingItem(m));
|
||||
}
|
||||
}
|
||||
return new List<DynamicBackingItem>();
|
||||
|
||||
@@ -168,7 +168,7 @@ namespace umbraco.MacroEngines
|
||||
}
|
||||
else
|
||||
{
|
||||
_cachedChildren = new DynamicNodeList(n.ChildrenAsList);
|
||||
_cachedChildren = new DynamicNodeList(children);
|
||||
}
|
||||
}
|
||||
return _cachedChildren;
|
||||
@@ -294,34 +294,17 @@ namespace umbraco.MacroEngines
|
||||
var results = s.Search(criteria);
|
||||
return ExamineSearchUtill.ConvertSearchResultToDynamicNode(results);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public bool HasProperty(string name)
|
||||
{
|
||||
if (n != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
IProperty prop = n.GetProperty(name);
|
||||
if (prop == null)
|
||||
{
|
||||
// check for nicer support of Pascal Casing EVEN if alias is camelCasing:
|
||||
if (prop == null && name.Substring(0, 1).ToUpper() == name.Substring(0, 1))
|
||||
{
|
||||
prop = n.GetProperty(name.Substring(0, 1).ToLower() + name.Substring((1)));
|
||||
}
|
||||
}
|
||||
return (prop != null);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return GetProperty(name) != null;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public override bool TryInvokeMember(InvokeMemberBinder binder, object[] args, out object result)
|
||||
{
|
||||
try
|
||||
@@ -1347,7 +1330,43 @@ namespace umbraco.MacroEngines
|
||||
public IProperty GetProperty(string alias)
|
||||
{
|
||||
if (n == null) return null;
|
||||
return n.GetProperty(alias);
|
||||
|
||||
object result;
|
||||
IProperty prop;
|
||||
//check the cache first!
|
||||
if (_cachedMemberOutput.TryGetValue(alias, out result))
|
||||
{
|
||||
prop = result as IProperty;
|
||||
if (prop != null)
|
||||
return prop;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
prop = n.GetProperty(alias);
|
||||
if (prop == null)
|
||||
{
|
||||
// check for nicer support of Pascal Casing EVEN if alias is camelCasing:
|
||||
if (alias.Substring(0, 1).ToUpper() == alias.Substring(0, 1))
|
||||
{
|
||||
//change the alias to the other case to check
|
||||
alias = alias.Substring(0, 1).ToLower() + alias.Substring((1));
|
||||
prop = n.GetProperty(alias);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (prop == null)
|
||||
return null;
|
||||
|
||||
//cache it!
|
||||
_cachedMemberOutput.TryAdd(alias, prop);
|
||||
|
||||
return prop;
|
||||
}
|
||||
public IProperty GetProperty(string alias, bool recursive)
|
||||
{
|
||||
|
||||
@@ -4,6 +4,9 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Xml.XPath;
|
||||
using Examine;
|
||||
using Examine.LuceneEngine.SearchCriteria;
|
||||
using Examine.Providers;
|
||||
using Umbraco.Core;
|
||||
using UmbracoExamine;
|
||||
using Lucene.Net.Documents;
|
||||
using umbraco.interfaces;
|
||||
@@ -15,6 +18,8 @@ namespace umbraco.MacroEngines
|
||||
|
||||
public class ExamineBackedMedia
|
||||
{
|
||||
private readonly BaseIndexProvider _indexer;
|
||||
private readonly BaseSearchProvider _searcher;
|
||||
//Custom properties won't be available
|
||||
public bool WasLoadedFromExamine;
|
||||
|
||||
@@ -99,6 +104,20 @@ namespace umbraco.MacroEngines
|
||||
Values = result.Fields;
|
||||
WasLoadedFromExamine = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Internal constructor used for unit tests
|
||||
/// </summary>
|
||||
/// <param name="result"></param>
|
||||
/// <param name="indexer"></param>
|
||||
/// <param name="searcher"></param>
|
||||
internal ExamineBackedMedia(SearchResult result, BaseIndexProvider indexer, BaseSearchProvider searcher)
|
||||
: this(result)
|
||||
{
|
||||
_indexer = indexer;
|
||||
_searcher = searcher;
|
||||
}
|
||||
|
||||
public IProperty LoadCustomPropertyNotFoundInExamine(string alias, out bool propertyExists)
|
||||
{
|
||||
//custom property, not loaded from examine
|
||||
@@ -137,44 +156,26 @@ namespace umbraco.MacroEngines
|
||||
{
|
||||
get
|
||||
{
|
||||
int parentId = 0;
|
||||
string value = null;
|
||||
if (Values.TryGetValue("parentID", out value))
|
||||
{
|
||||
if (int.TryParse(value, out parentId))
|
||||
{
|
||||
return new Lazy<ExamineBackedMedia>(() => { return ExamineBackedMedia.GetUmbracoMedia(parentId); });
|
||||
}
|
||||
}
|
||||
return null;
|
||||
var parentId = GetValueAsInt("parentID");
|
||||
return parentId != 0
|
||||
? new Lazy<ExamineBackedMedia>(() => GetUmbracoMedia(parentId))
|
||||
: null;
|
||||
}
|
||||
}
|
||||
|
||||
public int ParentId
|
||||
{
|
||||
get
|
||||
{
|
||||
int parentId = 0;
|
||||
if (int.TryParse(Values["parentID"], out parentId))
|
||||
{
|
||||
return parentId;
|
||||
}
|
||||
return 0;
|
||||
return GetValueAsInt("parentID");
|
||||
}
|
||||
}
|
||||
|
||||
public int Id
|
||||
{
|
||||
get
|
||||
{
|
||||
int id = 0;
|
||||
string value = null;
|
||||
if (Values.TryGetValue("id", out value))
|
||||
{
|
||||
if (int.TryParse(value, out id))
|
||||
{
|
||||
return id;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
return GetValueAsInt("id");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -182,7 +183,7 @@ namespace umbraco.MacroEngines
|
||||
{
|
||||
get
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
return GetValueAsInt("sortOrder");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -190,30 +191,23 @@ namespace umbraco.MacroEngines
|
||||
{
|
||||
get
|
||||
{
|
||||
string value = null;
|
||||
if (Values.TryGetValue("umbracoFile", out value))
|
||||
{
|
||||
return value;
|
||||
}
|
||||
return null;
|
||||
return GetValueAsString("umbracoFile");
|
||||
}
|
||||
}
|
||||
|
||||
public string UrlName
|
||||
{
|
||||
get { throw new NotImplementedException(); }
|
||||
get
|
||||
{
|
||||
return GetValueAsString("urlName");
|
||||
}
|
||||
}
|
||||
|
||||
public string NodeTypeAlias
|
||||
{
|
||||
get
|
||||
{
|
||||
string value = null;
|
||||
if (Values.TryGetValue("nodeTypeAlias", out value))
|
||||
{
|
||||
return value;
|
||||
}
|
||||
return null;
|
||||
return GetValueAsString("nodeTypeAlias");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -221,62 +215,56 @@ namespace umbraco.MacroEngines
|
||||
{
|
||||
get
|
||||
{
|
||||
string value = null;
|
||||
if (Values.TryGetValue("writerName", out value))
|
||||
{
|
||||
return value;
|
||||
}
|
||||
return null;
|
||||
return GetValueAsString("writerName");
|
||||
}
|
||||
}
|
||||
|
||||
public string CreatorName
|
||||
{
|
||||
get { throw new NotImplementedException(); }
|
||||
get
|
||||
{
|
||||
return GetValueAsString("writerName");
|
||||
}
|
||||
}
|
||||
|
||||
public int WriterID
|
||||
{
|
||||
get { throw new NotImplementedException(); }
|
||||
get
|
||||
{
|
||||
return GetValueAsInt("writerID");
|
||||
}
|
||||
}
|
||||
|
||||
public int CreatorID
|
||||
{
|
||||
get { throw new NotImplementedException(); }
|
||||
get
|
||||
{
|
||||
//there is no creator id in xml, so will have to be the same as writer id :(
|
||||
return GetValueAsInt("writerID");
|
||||
}
|
||||
}
|
||||
|
||||
public string Path
|
||||
{
|
||||
get
|
||||
{
|
||||
string value = null;
|
||||
if (Values.TryGetValue("__Path", out value))
|
||||
{
|
||||
return value;
|
||||
}
|
||||
return null;
|
||||
return GetValueAsString("__Path");
|
||||
}
|
||||
}
|
||||
|
||||
public DateTime CreateDate
|
||||
{
|
||||
get { throw new NotImplementedException(); }
|
||||
get
|
||||
{
|
||||
return GetvalueAsDateTime("createDate");
|
||||
}
|
||||
}
|
||||
|
||||
public DateTime UpdateDate
|
||||
{
|
||||
get
|
||||
{
|
||||
DateTime dt = DateTime.MinValue;
|
||||
string value = null;
|
||||
if (Values.TryGetValue("UpdateDate", out value))
|
||||
{
|
||||
if (DateTime.TryParse(value, out dt))
|
||||
{
|
||||
return dt;
|
||||
}
|
||||
}
|
||||
return DateTime.Now;
|
||||
return GetvalueAsDateTime("updateDate");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -284,7 +272,7 @@ namespace umbraco.MacroEngines
|
||||
{
|
||||
get
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
return GetValueAsGuid("version");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -292,12 +280,7 @@ namespace umbraco.MacroEngines
|
||||
{
|
||||
get
|
||||
{
|
||||
string value = null;
|
||||
if (Values.TryGetValue("umbracoFile", out value))
|
||||
{
|
||||
return value;
|
||||
}
|
||||
return null;
|
||||
return GetValueAsString("umbracoFile");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -305,20 +288,87 @@ namespace umbraco.MacroEngines
|
||||
{
|
||||
get
|
||||
{
|
||||
string value = null;
|
||||
if (Values.TryGetValue("__Path", out value))
|
||||
{
|
||||
return value.Split(',').Length;
|
||||
}
|
||||
return 0;
|
||||
var level = GetValueAsInt("level");
|
||||
if (level != 0) return level;
|
||||
|
||||
//return it based on the path if level is not there
|
||||
string value;
|
||||
return Values.TryGetValue("__Path", out value) ? value.Split(',').Length : 0;
|
||||
}
|
||||
}
|
||||
|
||||
private BaseIndexProvider GetIndexer()
|
||||
{
|
||||
return _indexer ?? ExamineManager.Instance.IndexProviderCollection["InternalIndexer"];
|
||||
}
|
||||
|
||||
private BaseSearchProvider GetSearcher()
|
||||
{
|
||||
return _searcher ?? ExamineManager.Instance.SearchProviderCollection["InternalSearcher"];
|
||||
}
|
||||
|
||||
private DateTime GetvalueAsDateTime(string key)
|
||||
{
|
||||
var dt = DateTime.MinValue;
|
||||
string value = null;
|
||||
if (Values.TryGetValue(key, out value))
|
||||
{
|
||||
if (DateTime.TryParse(value, out dt))
|
||||
{
|
||||
return dt;
|
||||
}
|
||||
//normally dates in lucene are stored with a specific lucnene date format so we'll try to parse that.
|
||||
try
|
||||
{
|
||||
return DateTools.StringToDate(value);
|
||||
}
|
||||
catch (FormatException)
|
||||
{
|
||||
//it could not be formatted :(
|
||||
}
|
||||
}
|
||||
return dt;
|
||||
}
|
||||
|
||||
private Guid GetValueAsGuid(string key)
|
||||
{
|
||||
string value;
|
||||
if (Values.TryGetValue(key, out value))
|
||||
{
|
||||
Guid gId;
|
||||
if (Guid.TryParse(value, out gId))
|
||||
{
|
||||
return gId;
|
||||
}
|
||||
}
|
||||
return Guid.Empty;
|
||||
}
|
||||
|
||||
private string GetValueAsString(string key)
|
||||
{
|
||||
string value;
|
||||
return Values.TryGetValue(key, out value) ? value : null;
|
||||
}
|
||||
|
||||
private int GetValueAsInt(string key)
|
||||
{
|
||||
var val = 0;
|
||||
string value;
|
||||
if (Values.TryGetValue(key, out value))
|
||||
{
|
||||
if (int.TryParse(value, out val))
|
||||
{
|
||||
return val;
|
||||
}
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
public List<IProperty> PropertiesAsList
|
||||
{
|
||||
get
|
||||
{
|
||||
string[] internalProperties = new string[] {
|
||||
var internalProperties = new[] {
|
||||
"id", "nodeName", "updateDate", "writerName", "path", "nodeTypeAlias",
|
||||
"parentID", "__NodeId", "__IndexType", "__Path", "__NodeTypeAlias",
|
||||
"__nodeName"
|
||||
@@ -336,27 +386,37 @@ namespace umbraco.MacroEngines
|
||||
{
|
||||
get
|
||||
{
|
||||
return new Lazy<List<ExamineBackedMedia>>(() =>
|
||||
{
|
||||
return GetChildrenMedia(this.Id);
|
||||
});
|
||||
return new Lazy<List<ExamineBackedMedia>>(() => GetChildrenMedia(this.Id));
|
||||
}
|
||||
}
|
||||
private static List<ExamineBackedMedia> GetChildrenMedia(int ParentId)
|
||||
|
||||
private List<ExamineBackedMedia> GetChildrenMedia(int parentId)
|
||||
{
|
||||
try
|
||||
{
|
||||
//first check in Examine as this is WAY faster
|
||||
var criteria = ExamineManager.Instance
|
||||
.SearchProviderCollection["InternalSearcher"]
|
||||
.CreateSearchCriteria("media");
|
||||
var filter = criteria.ParentId(ParentId);
|
||||
var results = ExamineManager
|
||||
.Instance.SearchProviderCollection["InternalSearcher"]
|
||||
.Search(filter.Compile());
|
||||
var searcher = GetSearcher();
|
||||
var indexer = GetIndexer();
|
||||
var criteria = searcher.CreateSearchCriteria("media");
|
||||
var filter = criteria.ParentId(parentId);
|
||||
ISearchResults results;
|
||||
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 = searcher.Search(
|
||||
filter.And().OrderBy(new SortableField("sortOrder", SortType.Int)).Compile());
|
||||
}
|
||||
else
|
||||
{
|
||||
results = searcher.Search(filter.Compile());
|
||||
}
|
||||
|
||||
if (results.Any())
|
||||
{
|
||||
return results.ToList().ConvertAll(result => new ExamineBackedMedia(result));
|
||||
return useLuceneSort
|
||||
? results.Select(result => new ExamineBackedMedia(result)).ToList() //will already be sorted by lucene
|
||||
: results.Select(result => new ExamineBackedMedia(result)).OrderBy(x => x.SortOrder).ToList();
|
||||
}
|
||||
}
|
||||
catch (FileNotFoundException)
|
||||
@@ -366,12 +426,12 @@ namespace umbraco.MacroEngines
|
||||
//Catch the exception here for the time being, and just fallback to GetMedia
|
||||
}
|
||||
|
||||
var media = umbraco.library.GetMedia(ParentId, true);
|
||||
var media = umbraco.library.GetMedia(parentId, true);
|
||||
if (media != null && media.Current != null)
|
||||
{
|
||||
media.MoveNext();
|
||||
var children = media.Current.SelectChildren(XPathNodeType.Element);
|
||||
List<ExamineBackedMedia> mediaList = new List<ExamineBackedMedia>();
|
||||
var mediaList = new List<ExamineBackedMedia>();
|
||||
while (children != null && children.Current != null)
|
||||
{
|
||||
if (children.MoveNext())
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Examine" version="0.1.42.2941" targetFramework="net40" />
|
||||
<package id="Examine" version="0.1.47.2941" targetFramework="net40" />
|
||||
<package id="HtmlAgilityPack" version="1.4.5" targetFramework="net40" />
|
||||
<package id="Lucene.Net" version="2.9.4.1" targetFramework="net40" />
|
||||
<package id="Microsoft.AspNet.Mvc" version="4.0.20710.0" targetFramework="net40" />
|
||||
|
||||
@@ -42,9 +42,9 @@
|
||||
<DocumentationFile>bin\Release\umbraco.MacroEngines.xml</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Examine, Version=0.1.42.2941, Culture=neutral, processorArchitecture=MSIL">
|
||||
<Reference Include="Examine, Version=0.1.47.2941, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\Examine.0.1.42.2941\lib\Examine.dll</HintPath>
|
||||
<HintPath>..\packages\Examine.0.1.47.2941\lib\Examine.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="HtmlAgilityPack, Version=1.4.5.0, Culture=neutral, PublicKeyToken=bd319b19eaf3b43a, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Web;
|
||||
using Umbraco.Core.IO;
|
||||
@@ -14,7 +15,12 @@ namespace umbraco.editorControls.tinymce
|
||||
{
|
||||
public static string cleanImages(string html)
|
||||
{
|
||||
var allowedAttributes = UmbracoSettings.ImageAllowedAttributes.ToLower().Split(',');
|
||||
var allowedAttributes = UmbracoSettings.ImageAllowedAttributes.ToLower().Split(',').ToList();
|
||||
|
||||
//Always add src as it's essential to output any image at all
|
||||
if (allowedAttributes.Contains("src") == false)
|
||||
allowedAttributes.Add("src");
|
||||
|
||||
const string pattern = @"<img [^>]*>";
|
||||
var tags = Regex.Matches(html + " ", pattern, RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace);
|
||||
foreach (Match tag in tags)
|
||||
@@ -43,7 +49,11 @@ namespace umbraco.editorControls.tinymce
|
||||
{
|
||||
int newWidth;
|
||||
int newHeight;
|
||||
cleanTag += DoResize(ht, out newWidth, out newHeight);
|
||||
string newSrc;
|
||||
|
||||
cleanTag += DoResize(ht, out newWidth, out newHeight, out newSrc);
|
||||
|
||||
ht["src"] = newSrc;
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
@@ -96,7 +106,7 @@ namespace umbraco.editorControls.tinymce
|
||||
return html;
|
||||
}
|
||||
|
||||
private static string DoResize(IDictionary attributes, out int finalWidth, out int finalHeight)
|
||||
private static string DoResize(IDictionary attributes, out int finalWidth, out int finalHeight, out string newSrc)
|
||||
{
|
||||
var fs = FileSystemProviderManager.Current.GetFileSystemProvider<MediaFileSystem>();
|
||||
var orgSrc = HttpContext.Current.Server.HtmlDecode(helper.FindAttribute(attributes, "src").Replace("%20", " "));
|
||||
@@ -106,7 +116,7 @@ namespace umbraco.editorControls.tinymce
|
||||
var newWidth = int.Parse(helper.FindAttribute(attributes, "width"));
|
||||
var newHeight = int.Parse(helper.FindAttribute(attributes, "height"));
|
||||
|
||||
var newSrc = "";
|
||||
newSrc = "";
|
||||
|
||||
if (orgHeight > 0 && orgWidth > 0 && orgSrc != "")
|
||||
{
|
||||
@@ -131,7 +141,7 @@ namespace umbraco.editorControls.tinymce
|
||||
finalWidth = newWidth;
|
||||
finalHeight = newHeight;
|
||||
|
||||
return " src=\"" + newSrc + "\" width=\"" + newWidth + "\" height=\"" + newHeight + "\"";
|
||||
return " width=\"" + newWidth + "\" height=\"" + newHeight + "\"";
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user