diff --git a/src/Umbraco.Core/Models/ContentBase.cs b/src/Umbraco.Core/Models/ContentBase.cs
index cc5cfcdee5..738a896155 100644
--- a/src/Umbraco.Core/Models/ContentBase.cs
+++ b/src/Umbraco.Core/Models/ContentBase.cs
@@ -293,7 +293,10 @@ namespace Umbraco.Core.Models
/// Value as a
public virtual TPassType GetValue(string propertyTypeAlias)
{
- return (TPassType)Properties[propertyTypeAlias].Value;
+ if (Properties[propertyTypeAlias].Value is TPassType)
+ return (TPassType)Properties[propertyTypeAlias].Value;
+
+ return (TPassType)Convert.ChangeType(Properties[propertyTypeAlias].Value, typeof(TPassType));
}
///
diff --git a/src/Umbraco.Core/Models/ContentExtensions.cs b/src/Umbraco.Core/Models/ContentExtensions.cs
index 127f60e643..77f90d22a9 100644
--- a/src/Umbraco.Core/Models/ContentExtensions.cs
+++ b/src/Umbraco.Core/Models/ContentExtensions.cs
@@ -78,6 +78,53 @@ namespace Umbraco.Core.Models
return (propertyValueChanged && publishedState == PublishedState.Published) || contentDataChanged;
}
+ ///
+ /// Determines if the published db flag should be set to true for the current entity version and all other db
+ /// versions should have their flag set to false.
+ ///
+ ///
+ ///
+ ///
+ /// This is determined by:
+ /// * If a new version is being created and the entity is published
+ /// * If the published state has changed and the entity is published OR the entity has been un-published.
+ ///
+ internal static bool ShouldClearPublishedFlagForPreviousVersions(this IContent entity)
+ {
+ var publishedState = ((Content)entity).PublishedState;
+ return entity.ShouldClearPublishedFlagForPreviousVersions(publishedState, entity.ShouldCreateNewVersion(publishedState));
+ }
+
+ ///
+ /// Determines if the published db flag should be set to true for the current entity version and all other db
+ /// versions should have their flag set to false.
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// This is determined by:
+ /// * If a new version is being created and the entity is published
+ /// * If the published state has changed and the entity is published OR the entity has been un-published.
+ ///
+ internal static bool ShouldClearPublishedFlagForPreviousVersions(this IContent entity, PublishedState publishedState, bool isCreatingNewVersion)
+ {
+ if (isCreatingNewVersion && entity.Published)
+ {
+ return true;
+ }
+
+ //If Published state has changed then previous versions should have their publish state reset.
+ //If state has been changed to unpublished the previous versions publish state should also be reset.
+ if (((ICanBeDirty)entity).IsPropertyDirty("Published") && (entity.Published || publishedState == PublishedState.Unpublished))
+ {
+ return true;
+ }
+
+ return false;
+ }
+
///
/// Returns a list of the current contents ancestors, not including the content itself.
///
diff --git a/src/Umbraco.Core/Persistence/Migrations/Initial/BaseDataCreation.cs b/src/Umbraco.Core/Persistence/Migrations/Initial/BaseDataCreation.cs
index 7fc81b1db7..b50102396a 100644
--- a/src/Umbraco.Core/Persistence/Migrations/Initial/BaseDataCreation.cs
+++ b/src/Umbraco.Core/Persistence/Migrations/Initial/BaseDataCreation.cs
@@ -223,8 +223,6 @@ namespace Umbraco.Core.Persistence.Migrations.Initial
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 4, DataTypeId = -88, ControlId = new Guid(Constants.PropertyEditors.Textbox), DbType = "Nvarchar" });
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 5, DataTypeId = -89, ControlId = new Guid(Constants.PropertyEditors.TextboxMultiple), DbType = "Ntext" });
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 6, DataTypeId = -90, ControlId = new Guid(Constants.PropertyEditors.UploadField), DbType = "Nvarchar" });
- //Dropdown list
- //_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 12, DataTypeId = -91, ControlId = new Guid("a74ea9c9-8e18-4d2a-8cf6-73c6206c5da6"), DbType = "Nvarchar" });
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 7, DataTypeId = -92, ControlId = new Guid(Constants.PropertyEditors.NoEdit), DbType = "Nvarchar" });
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 8, DataTypeId = -36, ControlId = new Guid(Constants.PropertyEditors.DateTime), DbType = "Date" });
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 9, DataTypeId = -37, ControlId = new Guid(Constants.PropertyEditors.ColorPicker), DbType = "Nvarchar" });
@@ -234,24 +232,6 @@ namespace Umbraco.Core.Persistence.Migrations.Initial
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 13, DataTypeId = -41, ControlId = new Guid(Constants.PropertyEditors.Date), DbType = "Date" });
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 14, DataTypeId = -42, ControlId = new Guid(Constants.PropertyEditors.DropDownList), DbType = "Integer" });
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 15, DataTypeId = -43, ControlId = new Guid(Constants.PropertyEditors.CheckBoxList), DbType = "Nvarchar" });
- // Fix for rich text editor backwards compatibility -> 83722133-f80c-4273-bdb6-1befaa04a612 TinyMCE DataType
- //_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 22, DataTypeId = -44, ControlId = new Guid("a3776494-0574-4d93-b7de-efdfdec6f2d1"), DbType = "Ntext" });
- //Radiobutton list
- //_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 23, DataTypeId = -128, ControlId = new Guid("a52c7c1c-c330-476e-8605-d63d3b84b6a6"), DbType = "Nvarchar" });
- //Dropdown list multiple
- //_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 24, DataTypeId = -129, ControlId = new Guid("928639ed-9c73-4028-920c-1e55dbb68783"), DbType = "Nvarchar" });
- //Dropdown list
- //_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 25, DataTypeId = -130, ControlId = new Guid("a74ea9c9-8e18-4d2a-8cf6-73c6206c5da6"), DbType = "Nvarchar" });
- //Dropdown list
- //_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 26, DataTypeId = -131, ControlId = new Guid("a74ea9c9-8e18-4d2a-8cf6-73c6206c5da6"), DbType = "Nvarchar" });
- //Dropdown list
- //_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 27, DataTypeId = -132, ControlId = new Guid("a74ea9c9-8e18-4d2a-8cf6-73c6206c5da6"), DbType = "Nvarchar" });
- //No edit
- //_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 28, DataTypeId = -133, ControlId = new Guid("6c738306-4c17-4d88-b9bd-6546f3771597"), DbType = "Ntext" });
- //Dropdown list multiple
- //_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 29, DataTypeId = -134, ControlId = new Guid("928639ed-9c73-4028-920c-1e55dbb68783"), DbType = "Nvarchar" });
- //Not found - maybe a legacy thing?
- //_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 30, DataTypeId = -50, ControlId = new Guid("aaf99bb2-dbbe-444d-a296-185076bf0484"), DbType = "Date" });
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 16, DataTypeId = 1034, ControlId = new Guid(Constants.PropertyEditors.ContentPicker), DbType = "Integer" });
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 17, DataTypeId = 1035, ControlId = new Guid(Constants.PropertyEditors.MediaPicker), DbType = "Integer" });
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 18, DataTypeId = 1036, ControlId = new Guid(Constants.PropertyEditors.MemberPicker), DbType = "Integer" });
diff --git a/src/Umbraco.Core/Persistence/Repositories/ContentRepository.cs b/src/Umbraco.Core/Persistence/Repositories/ContentRepository.cs
index 4a2bb81eb8..7acd2cb7a0 100644
--- a/src/Umbraco.Core/Persistence/Repositories/ContentRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/ContentRepository.cs
@@ -332,7 +332,8 @@ namespace Umbraco.Core.Persistence.Repositories
//If Published state has changed then previous versions should have their publish state reset.
//If state has been changed to unpublished the previous versions publish state should also be reset.
- if (((ICanBeDirty)entity).IsPropertyDirty("Published") && (entity.Published || publishedState == PublishedState.Unpublished))
+ //if (((ICanBeDirty)entity).IsPropertyDirty("Published") && (entity.Published || publishedState == PublishedState.Unpublished))
+ if (entity.ShouldClearPublishedFlagForPreviousVersions(publishedState, shouldCreateNewVersion))
{
var publishedDocs = Database.Fetch("WHERE nodeId = @Id AND published = @IsPublished", new { Id = entity.Id, IsPublished = true });
foreach (var doc in publishedDocs)
diff --git a/src/Umbraco.Core/Persistence/Repositories/EntityRepository.cs b/src/Umbraco.Core/Persistence/Repositories/EntityRepository.cs
index a73c7c943a..8651068030 100644
--- a/src/Umbraco.Core/Persistence/Repositories/EntityRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/EntityRepository.cs
@@ -84,7 +84,7 @@ namespace Umbraco.Core.Persistence.Repositories
{
bool isContent = objectTypeId == new Guid(Constants.ObjectTypes.Document);
bool isMedia = objectTypeId == new Guid(Constants.ObjectTypes.Media);
- var sql = GetBaseWhere(GetBase, isContent, isMedia, objectTypeId).Append(GetGroupBy(isContent, isMedia));
+ var sql = GetBaseWhere(GetBase, isContent, isMedia, string.Empty, objectTypeId).Append(GetGroupBy(isContent, isMedia));
var dtos = isMedia
? _work.Database.Fetch(
new UmbracoEntityRelator().Map, sql)
@@ -101,7 +101,8 @@ namespace Umbraco.Core.Persistence.Repositories
public virtual IEnumerable GetByQuery(IQuery query)
{
- var sqlClause = GetBase(false, false);
+ var wheres = string.Concat(" AND ", string.Join(" AND ", ((Query) query).WhereClauses()));
+ var sqlClause = GetBase(false, false, wheres);
var translator = new SqlTranslator(sqlClause, query);
var sql = translator.Translate().Append(GetGroupBy(false, false));
@@ -117,7 +118,9 @@ namespace Umbraco.Core.Persistence.Repositories
{
bool isContent = objectTypeId == new Guid(Constants.ObjectTypes.Document);
bool isMedia = objectTypeId == new Guid(Constants.ObjectTypes.Media);
- var sqlClause = GetBaseWhere(GetBase, isContent, isMedia, objectTypeId);
+
+ var wheres = string.Concat(" AND ", string.Join(" AND ", ((Query)query).WhereClauses()));
+ var sqlClause = GetBaseWhere(GetBase, isContent, isMedia, wheres, objectTypeId);
var translator = new SqlTranslator(sqlClause, query);
var sql = translator.Translate().Append(GetGroupBy(isContent, isMedia));
@@ -136,7 +139,7 @@ namespace Umbraco.Core.Persistence.Repositories
#region Sql Statements
- protected virtual Sql GetBase(bool isContent, bool isMedia)
+ protected virtual Sql GetBase(bool isContent, bool isMedia, string additionWhereStatement = "")
{
var columns = new List
///
///
+ [SecuritySafeCritical]
public override void Initialize(string name, NameValueCollection config)
{
base.Initialize(name, config);
@@ -133,7 +135,7 @@ namespace UmbracoExamine.PDF
Action onError = (e) => OnIndexingError(new IndexingErrorEventArgs("Could not read PDF", -1, e));
- var txt = pdf.ParsePdfText(file.FullName, onError);
+ var txt = pdf.GetTextFromAllPages(file.FullName, onError);
return txt;
}
@@ -193,16 +195,21 @@ namespace UmbracoExamine.PDF
static PDFParser()
{
- lock (m_Locker)
+ lock (Locker)
{
- m_UnsupportedRange = new List();
- m_UnsupportedRange.AddRange(Enumerable.Range(0x0000, 0x001F));
- m_UnsupportedRange.Add(0x1F);
+ UnsupportedRange = new HashSet();
+ foreach (var c in Enumerable.Range(0x0000, 0x001F))
+ {
+ UnsupportedRange.Add((char) c);
+ }
+ UnsupportedRange.Add((char)0x1F);
+ //replace line breaks with space
+ ReplaceWithSpace = new HashSet {'\r', '\n'};
}
}
- private static readonly object m_Locker = new object();
+ private static readonly object Locker = new object();
///
/// Stores the unsupported range of character
@@ -214,61 +221,68 @@ namespace UmbracoExamine.PDF
/// http://en.wikipedia.org/wiki/Unicode
/// http://en.wikipedia.org/wiki/Basic_Multilingual_Plane
///
- private static List m_UnsupportedRange;
+ private static HashSet UnsupportedRange;
- ///
- /// Return only the valid string contents of the PDF
- ///
- ///
- ///
- ///
- [SecuritySafeCritical]
- public string ParsePdfText(string sourcePDF, Action onError)
+ private static HashSet ReplaceWithSpace;
+
+ [SecuritySafeCritical]
+ public string GetTextFromAllPages(string pdfPath, Action onError)
{
- var sb = new StringBuilder();
+ var output = new StringWriter();
- var reader = new PdfReader(sourcePDF);
- PRTokeniser token = null;
- var tknValue = String.Empty;
-
- for (var i = 1; (i <= reader.NumberOfPages); i++)
+ try
{
- var pageBytes = reader.GetPageContent(i);
- if (pageBytes != null)
- {
- token = new PRTokeniser(pageBytes);
- try
- {
- while (token.NextToken())
- {
- var tknType = token.TokenType;
- tknValue = token.StringValue;
- if ((tknType == PRTokeniser.TokType.STRING))
- {
- foreach (var s in tknValue)
- {
- //strip out unsupported characters, based on unicode tables.
- if (!m_UnsupportedRange.Contains(s))
- {
- sb.Append(s);
- }
- }
+ var reader = new PdfReader(pdfPath);
- }
- }
- }
- catch (InvalidPdfException ex)
- {
- onError(ex);
- }
+ for (int i = 1; i <= reader.NumberOfPages; i++)
+ {
+ var result =
+ ExceptChars(
+ PdfTextExtractor.GetTextFromPage(reader, i, new SimpleTextExtractionStrategy()),
+ UnsupportedRange,
+ ReplaceWithSpace);
+ output.Write(result);
}
}
+ catch (Exception ex)
+ {
+ onError(ex);
+ }
- return sb.ToString();
+ return output.ToString();
}
}
+
+ ///
+ /// remove all toExclude chars from string
+ ///
+ ///
+ ///
+ ///
+ ///
+ private static string ExceptChars(string str, HashSet toExclude, HashSet replaceWithSpace)
+ {
+ var sb = new StringBuilder(str.Length);
+ for (var i = 0; i < str.Length; i++)
+ {
+ var c = str[i];
+ if (toExclude.Contains(c) == false)
+ {
+ if (replaceWithSpace.Contains(c))
+ {
+ sb.Append(" ");
+ }
+ else
+ {
+ sb.Append(c);
+ }
+ }
+
+ }
+ return sb.ToString();
+ }
#endregion
}
diff --git a/src/UmbracoExamine.PDF/Properties/AssemblyInfo.cs b/src/UmbracoExamine.PDF/Properties/AssemblyInfo.cs
index 72fe9de54a..04b415b98d 100644
--- a/src/UmbracoExamine.PDF/Properties/AssemblyInfo.cs
+++ b/src/UmbracoExamine.PDF/Properties/AssemblyInfo.cs
@@ -28,4 +28,5 @@ using System.Security;
[assembly: AssemblyVersion("0.6.0.*")]
[assembly: AssemblyFileVersion("0.6.0.*")]
-[assembly: AllowPartiallyTrustedCallers]
\ No newline at end of file
+//Unfortunately itextsharp does not natively support full trust
+//[assembly: AllowPartiallyTrustedCallers]
\ No newline at end of file
diff --git a/src/UmbracoExamine.PDF/UmbracoExamine.PDF.csproj b/src/UmbracoExamine.PDF/UmbracoExamine.PDF.csproj
index b5a4cca007..6bdc3d3666 100644
--- a/src/UmbracoExamine.PDF/UmbracoExamine.PDF.csproj
+++ b/src/UmbracoExamine.PDF/UmbracoExamine.PDF.csproj
@@ -46,9 +46,9 @@
false
-
+
False
- ..\packages\Examine.0.1.51.2941\lib\Examine.dll
+ ..\packages\Examine.0.1.52.2941\lib\Examine.dll
..\packages\SharpZipLib.0.86.0\lib\20\ICSharpCode.SharpZipLib.dll
diff --git a/src/UmbracoExamine.PDF/packages.config b/src/UmbracoExamine.PDF/packages.config
index abf2bfc49c..1d29bc3cc6 100644
--- a/src/UmbracoExamine.PDF/packages.config
+++ b/src/UmbracoExamine.PDF/packages.config
@@ -1,6 +1,6 @@
-
+
diff --git a/src/UmbracoExamine/BaseUmbracoIndexer.cs b/src/UmbracoExamine/BaseUmbracoIndexer.cs
index 217eac73ec..8ccef8b22e 100644
--- a/src/UmbracoExamine/BaseUmbracoIndexer.cs
+++ b/src/UmbracoExamine/BaseUmbracoIndexer.cs
@@ -96,6 +96,7 @@ namespace UmbracoExamine
///
///
///
+ [SecuritySafeCritical]
public override void Initialize(string name, System.Collections.Specialized.NameValueCollection config)
{
if (config["dataService"] != null && !string.IsNullOrEmpty(config["dataService"]))
diff --git a/src/UmbracoExamine/UmbracoContentIndexer.cs b/src/UmbracoExamine/UmbracoContentIndexer.cs
index 81a9dbe41b..9da53a77f2 100644
--- a/src/UmbracoExamine/UmbracoContentIndexer.cs
+++ b/src/UmbracoExamine/UmbracoContentIndexer.cs
@@ -124,6 +124,7 @@ namespace UmbracoExamine
///
/// An attempt is made to call on a provider after the provider has already been initialized.
///
+ [SecuritySafeCritical]
public override void Initialize(string name, System.Collections.Specialized.NameValueCollection config)
{
diff --git a/src/UmbracoExamine/UmbracoExamine.csproj b/src/UmbracoExamine/UmbracoExamine.csproj
index aeb3a0ce05..5db7139a00 100644
--- a/src/UmbracoExamine/UmbracoExamine.csproj
+++ b/src/UmbracoExamine/UmbracoExamine.csproj
@@ -82,9 +82,9 @@
..\Solution Items\TheFARM-Public.snk
-
+
False
- ..\packages\Examine.0.1.51.2941\lib\Examine.dll
+ ..\packages\Examine.0.1.52.2941\lib\Examine.dll
False
diff --git a/src/UmbracoExamine/UmbracoExamineSearcher.cs b/src/UmbracoExamine/UmbracoExamineSearcher.cs
index 68f07f45e1..7406e98f8e 100644
--- a/src/UmbracoExamine/UmbracoExamineSearcher.cs
+++ b/src/UmbracoExamine/UmbracoExamineSearcher.cs
@@ -45,6 +45,7 @@ namespace UmbracoExamine
}
}
+ [SecuritySafeCritical]
public override void Initialize(string name, System.Collections.Specialized.NameValueCollection config)
{
if (name == null) throw new ArgumentNullException("name");
diff --git a/src/UmbracoExamine/packages.config b/src/UmbracoExamine/packages.config
index 0d7f689f95..31026832a5 100644
--- a/src/UmbracoExamine/packages.config
+++ b/src/UmbracoExamine/packages.config
@@ -1,6 +1,6 @@
-
+
\ No newline at end of file
diff --git a/src/umbraco.MacroEngines/packages.config b/src/umbraco.MacroEngines/packages.config
index 023ebfc6b9..404506a7aa 100644
--- a/src/umbraco.MacroEngines/packages.config
+++ b/src/umbraco.MacroEngines/packages.config
@@ -1,6 +1,6 @@
-
+
diff --git a/src/umbraco.MacroEngines/umbraco.MacroEngines.csproj b/src/umbraco.MacroEngines/umbraco.MacroEngines.csproj
index d6fecdbaca..1b028c6901 100644
--- a/src/umbraco.MacroEngines/umbraco.MacroEngines.csproj
+++ b/src/umbraco.MacroEngines/umbraco.MacroEngines.csproj
@@ -45,9 +45,9 @@
false
-
+
False
- ..\packages\Examine.0.1.51.2941\lib\Examine.dll
+ ..\packages\Examine.0.1.52.2941\lib\Examine.dll
False
diff --git a/src/umbraco.editorControls/BaseTreePickerEditor.cs b/src/umbraco.editorControls/BaseTreePickerEditor.cs
index 0984a2375b..9908d07e46 100644
--- a/src/umbraco.editorControls/BaseTreePickerEditor.cs
+++ b/src/umbraco.editorControls/BaseTreePickerEditor.cs
@@ -106,7 +106,7 @@ namespace umbraco.editorControls
public void Save()
{
if (ItemIdValue.Value.Trim() != "")
- _data.Value = ItemIdValue.Value.Trim();
+ _data.Value = int.Parse(ItemIdValue.Value.Trim());
else
_data.Value = null;
}