This commit is contained in:
perploug
2013-11-04 08:45:03 +01:00
17 changed files with 1056 additions and 1052 deletions
@@ -179,7 +179,10 @@ namespace Umbraco.Core.Configuration
{
throw new InvalidOperationException("Cannot create an MVC Area path without the umbracoPath specified");
}
return Path.TrimStart(SystemDirectories.Root).TrimStart('~').TrimStart('/').Replace('/', '-').Trim().ToLower();
var path = Path;
if (path.StartsWith(SystemDirectories.Root)) // beware of TrimStart, see U4-2518
path = path.Substring(SystemDirectories.Root.Length);
return path.TrimStart('~').TrimStart('/').Replace('/', '-').Trim().ToLower();
}
}
+70 -61
View File
@@ -97,8 +97,17 @@ namespace Umbraco.Core
// if we've got a nullable of something, we try to convert directly to that thing.
if (destinationType.IsGenericType && destinationType.GetGenericTypeDefinition() == typeof(Nullable<>))
{
var underlyingType = Nullable.GetUnderlyingType(destinationType);
//special case for empty strings for bools/dates which should return null if an empty string
var asString = input as string;
if (asString != null && string.IsNullOrEmpty(asString) && (underlyingType == typeof(DateTime) || underlyingType == typeof(bool)))
{
return Attempt<object>.Succeed(null);
}
// recursively call into myself with the inner (not-nullable) type and handle the outcome
var nonNullable = input.TryConvertTo(Nullable.GetUnderlyingType(destinationType));
var nonNullable = input.TryConvertTo(underlyingType);
// and if sucessful, fall on through to rewrap in a nullable; if failed, pass on the exception
if (nonNullable.Success)
@@ -202,78 +211,78 @@ namespace Umbraco.Core
if (destinationType == typeof(string))
return Attempt<object>.Succeed(input);
if (input == null || input.Length == 0)
if (string.IsNullOrEmpty(input))
{
if (destinationType == typeof(Boolean))
return Attempt<object>.Succeed(false); // special case for booleans, null/empty == false
else if (destinationType == typeof(DateTime))
return Attempt<object>.Succeed(false);
if (destinationType == typeof(DateTime))
return Attempt<object>.Succeed(DateTime.MinValue);
}
// we have a non-empty string, look for type conversions in the expected order of frequency of use...
if (destinationType.IsPrimitive)
{
if (destinationType == typeof(Int32))
if (destinationType == typeof(Int32))
{
Int32 value;
return Int32.TryParse(input, out value) ? Attempt<object>.Succeed(value) : Attempt<object>.Fail();
}
else if (destinationType == typeof(Int64))
{
Int64 value;
return Int64.TryParse(input, out value) ? Attempt<object>.Succeed(value) : Attempt<object>.Fail();
}
else if (destinationType == typeof(Boolean))
{
Boolean value;
if (Boolean.TryParse(input, out value))
return Attempt<object>.Succeed(value); // don't declare failure so the CustomBooleanTypeConverter can try
}
else if (destinationType == typeof(Int16))
{
Int16 value;
return Int16.TryParse(input, out value) ? Attempt<object>.Succeed(value) : Attempt<object>.Fail();
}
else if (destinationType == typeof(Double))
{
Double value;
return Double.TryParse(input, out value) ? Attempt<object>.Succeed(value) : Attempt<object>.Fail();
}
else if (destinationType == typeof(Single))
{
Single value;
return Single.TryParse(input, out value) ? Attempt<object>.Succeed(value) : Attempt<object>.Fail();
}
else if (destinationType == typeof(Char))
{
Char value;
return Char.TryParse(input, out value) ? Attempt<object>.Succeed(value) : Attempt<object>.Fail();
}
else if (destinationType == typeof(Byte))
{
Byte value;
return Byte.TryParse(input, out value) ? Attempt<object>.Succeed(value) : Attempt<object>.Fail();
}
else if (destinationType == typeof(SByte))
{
SByte value;
return SByte.TryParse(input, out value) ? Attempt<object>.Succeed(value) : Attempt<object>.Fail();
}
else if (destinationType == typeof(UInt32))
{
UInt32 value;
return UInt32.TryParse(input, out value) ? Attempt<object>.Succeed(value) : Attempt<object>.Fail();
}
else if (destinationType == typeof(UInt16))
{
UInt16 value;
return UInt16.TryParse(input, out value) ? Attempt<object>.Succeed(value) : Attempt<object>.Fail();
}
else if (destinationType == typeof(UInt64))
{
UInt64 value;
return UInt64.TryParse(input, out value) ? Attempt<object>.Succeed(value) : Attempt<object>.Fail();
}
if (destinationType == typeof(Int64))
{
Int64 value;
return Int64.TryParse(input, out value) ? Attempt<object>.Succeed(value) : Attempt<object>.Fail();
}
if (destinationType == typeof(Boolean))
{
Boolean value;
if (Boolean.TryParse(input, out value))
return Attempt<object>.Succeed(value); // don't declare failure so the CustomBooleanTypeConverter can try
}
else if (destinationType == typeof(Int16))
{
Int16 value;
return Int16.TryParse(input, out value) ? Attempt<object>.Succeed(value) : Attempt<object>.Fail();
}
else if (destinationType == typeof(Double))
{
Double value;
return Double.TryParse(input, out value) ? Attempt<object>.Succeed(value) : Attempt<object>.Fail();
}
else if (destinationType == typeof(Single))
{
Single value;
return Single.TryParse(input, out value) ? Attempt<object>.Succeed(value) : Attempt<object>.Fail();
}
else if (destinationType == typeof(Char))
{
Char value;
return Char.TryParse(input, out value) ? Attempt<object>.Succeed(value) : Attempt<object>.Fail();
}
else if (destinationType == typeof(Byte))
{
Byte value;
return Byte.TryParse(input, out value) ? Attempt<object>.Succeed(value) : Attempt<object>.Fail();
}
else if (destinationType == typeof(SByte))
{
SByte value;
return SByte.TryParse(input, out value) ? Attempt<object>.Succeed(value) : Attempt<object>.Fail();
}
else if (destinationType == typeof(UInt32))
{
UInt32 value;
return UInt32.TryParse(input, out value) ? Attempt<object>.Succeed(value) : Attempt<object>.Fail();
}
else if (destinationType == typeof(UInt16))
{
UInt16 value;
return UInt16.TryParse(input, out value) ? Attempt<object>.Succeed(value) : Attempt<object>.Fail();
}
else if (destinationType == typeof(UInt64))
{
UInt64 value;
return UInt64.TryParse(input, out value) ? Attempt<object>.Succeed(value) : Attempt<object>.Fail();
}
}
else if (destinationType == typeof(Guid))
{
+49 -42
View File
@@ -1,4 +1,5 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
@@ -32,15 +33,15 @@ namespace Umbraco.Core.Services
private readonly RepositoryFactory _repositoryFactory;
private readonly IDatabaseUnitOfWorkProvider _uowProvider;
private Dictionary<string, IContentType> _importedContentTypes;
public PackagingService(IContentService contentService,
IContentTypeService contentTypeService,
IMediaService mediaService,
IDataTypeService dataTypeService,
IFileService fileService,
public PackagingService(IContentService contentService,
IContentTypeService contentTypeService,
IMediaService mediaService,
IDataTypeService dataTypeService,
IFileService fileService,
ILocalizationService localizationService,
RepositoryFactory repositoryFactory,
RepositoryFactory repositoryFactory,
IDatabaseUnitOfWorkProvider uowProvider)
{
_contentService = contentService;
@@ -56,7 +57,7 @@ namespace Umbraco.Core.Services
}
#region Generic export methods
internal void ExportToFile(string absoluteFilePath, string nodeType, int id)
{
XElement xml = null;
@@ -91,7 +92,7 @@ namespace Umbraco.Core.Services
xml = Export(dataType);
}
if(xml != null)
if (xml != null)
xml.Save(absoluteFilePath);
}
@@ -293,7 +294,7 @@ namespace Umbraco.Core.Services
var properties = from property in element.Elements()
where property.Attribute("isDoc") == null
select property;
IContent content = parent == null
? new Content(nodeName, parentId, contentType)
{
@@ -324,7 +325,7 @@ namespace Umbraco.Core.Services
{
propertyValueList.Add(dtos.Single(x => x.Value == preValue).Id.ToString(CultureInfo.InvariantCulture));
}
propertyValue = string.Join(",", propertyValueList.ToArray());
}
@@ -355,7 +356,7 @@ namespace Umbraco.Core.Services
new XElement("AllowAtRoot", contentType.AllowedAsRoot.ToString()));
var masterContentType = contentType.CompositionAliases().FirstOrDefault();
if(masterContentType != null)
if (masterContentType != null)
info.Add(new XElement("Master", masterContentType));
var allowedTemplates = new XElement("AllowedTemplates");
@@ -364,7 +365,7 @@ namespace Umbraco.Core.Services
allowedTemplates.Add(new XElement("Template", template.Alias));
}
info.Add(allowedTemplates);
if(contentType.DefaultTemplate != null && contentType.DefaultTemplate.Id != 0)
if (contentType.DefaultTemplate != null && contentType.DefaultTemplate.Id != 0)
info.Add(new XElement("DefaultTemplate", contentType.DefaultTemplate.Alias));
else
info.Add(new XElement("DefaultTemplate", ""));
@@ -391,7 +392,7 @@ namespace Umbraco.Core.Services
new XElement("Description", new XCData(propertyType.Description)));
genericProperties.Add(genericProperty);
}
var tabs = new XElement("Tabs");
foreach (var propertyGroup in contentType.PropertyGroups)
{
@@ -541,7 +542,7 @@ namespace Umbraco.Core.Services
var template = _fileService.GetTemplate(alias.ToSafeAlias());
if (template != null)
{
if(allowedTemplates.Any(x => x.Id == template.Id)) continue;
if (allowedTemplates.Any(x => x.Id == template.Id)) continue;
allowedTemplates.Add(template);
}
else
@@ -598,40 +599,46 @@ namespace Umbraco.Core.Services
var dataTypeDefinitionId = new Guid(property.Element("Definition").Value);//Unique Id for a DataTypeDefinition
var dataTypeDefinition = _dataTypeService.GetDataTypeDefinitionById(dataTypeDefinitionId);
//If no DataTypeDefinition with the guid from the xml wasn't found OR the ControlId on the DataTypeDefinition didn't match the DataType Id
//We look up a DataTypeDefinition that matches
//we'll check if it is a GUID (legacy id for a property editor)
var legacyPropertyEditorId = Guid.Empty;
Guid.TryParse(property.Element("Type").Value, out legacyPropertyEditorId);
//get the alias as a string for use below
var propertyEditorAlias = property.Element("Type").Value.Trim();
//If no DataTypeDefinition with the guid from the xml wasn't found OR the ControlId on the DataTypeDefinition didn't match the DataType Id
//We look up a DataTypeDefinition that matches
if (dataTypeDefinition == null)
{
//we'll check if it is a GUID (legacy id for a property editor)
Guid legacyPropertyEditorId;
if (Guid.TryParse(property.Element("Type").Value, out legacyPropertyEditorId))
var dataTypeDefinitions = legacyPropertyEditorId != Guid.Empty
? _dataTypeService.GetDataTypeDefinitionByControlId(legacyPropertyEditorId)
: _dataTypeService.GetDataTypeDefinitionByPropertyEditorAlias(propertyEditorAlias);
if (dataTypeDefinitions != null && dataTypeDefinitions.Any())
{
if (dataTypeDefinition.ControlId != legacyPropertyEditorId)
{
var dataTypeDefinitions = _dataTypeService.GetDataTypeDefinitionByControlId(legacyPropertyEditorId);
if (dataTypeDefinitions != null && dataTypeDefinitions.Any())
{
dataTypeDefinition = dataTypeDefinitions.First();
}
}
dataTypeDefinition = dataTypeDefinitions.First();
}
else
}
else if (legacyPropertyEditorId != Guid.Empty && dataTypeDefinition.ControlId != legacyPropertyEditorId)
{
var dataTypeDefinitions = _dataTypeService.GetDataTypeDefinitionByControlId(legacyPropertyEditorId);
if (dataTypeDefinitions != null && dataTypeDefinitions.Any())
{
//check against the property editor string alias
var propertyEditorAlias = property.Element("Type").Value.Trim();
if (dataTypeDefinition.PropertyEditorAlias != propertyEditorAlias)
{
var dataTypeDefinitions = _dataTypeService.GetDataTypeDefinitionByPropertyEditorAlias(propertyEditorAlias);
if (dataTypeDefinitions != null && dataTypeDefinitions.Any())
{
dataTypeDefinition = dataTypeDefinitions.First();
}
}
dataTypeDefinition = dataTypeDefinitions.First();
}
}
else if (dataTypeDefinition.PropertyEditorAlias != propertyEditorAlias)
{
var dataTypeDefinitions = _dataTypeService.GetDataTypeDefinitionByPropertyEditorAlias(propertyEditorAlias);
if (dataTypeDefinitions != null && dataTypeDefinitions.Any())
{
dataTypeDefinition = dataTypeDefinitions.First();
}
}
// For backwards compatibility, if no datatype with that ID can be found, we're letting this fail silently.
// This means that the property will not be created.
if (dataTypeDefinition == null)
@@ -790,7 +797,7 @@ namespace Umbraco.Core.Services
var databaseType = databaseTypeAttribute != null
? databaseTypeAttribute.Value.EnumParse<DataTypeDatabaseType>(true)
: DataTypeDatabaseType.Ntext;
//check if the Id was a GUID, that means it is referenced using the legacy property editor GUID id
if (legacyPropertyEditorId != Guid.Empty)
{
@@ -813,7 +820,7 @@ namespace Umbraco.Core.Services
};
dataTypes.Add(dataTypeDefinitionName, dataTypeDefinition);
}
}
}
@@ -96,20 +96,6 @@
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>
<!-- How Umbraco should show icons in the document type editor. Historically, the list has included all the files in
/Umbraco/Images/Umbraco plus a CSS sprite defined in Umbraco_Client/Tree/treeIcons.css, unfortunately these
contain many duplicates. The DocumentTypeIconList setting allows you to favor one list over the other.
Can be one of the following values:
- ShowDuplicates - Show duplicates in files and sprites. Historial Umbraco behaviour.
- HideSpriteDuplicates - If a file exists on disk with the same name as one in the sprite
then the file on disk overrules the one in the sprite, the
sprite icon will not be shown
- HideFileDuplicates - If a file exists on disk with the same name as one in the sprite
then the file in the sprite overrules the one on disk, the file
on disk will be shown (recommended) -->
<DocumentTypeIconList>HideFileDuplicates</DocumentTypeIconList>
<!-- These file types will not be allowed to be uploaded via the upload control for media and content -->
<disallowedUploadFiles>ashx,aspx,ascx,config,cshtml,vbhtml,asmx,air,axd</disallowedUploadFiles>
@@ -114,6 +114,23 @@ namespace Umbraco.Tests
Assert.AreEqual(DateTime.Equals(dateTime.Date, result.Result.Date), testCase.Value, testCase.Key);
}
}
[Test]
public virtual void CanConvertBlankStringToNullDateTime()
{
var result = "".TryConvertTo<DateTime?>();
Assert.IsTrue(result.Success);
Assert.IsNull(result.Result);
}
[Test]
public virtual void CanConvertBlankStringToNullBool()
{
var result = "".TryConvertTo<bool?>();
Assert.IsTrue(result.Success);
Assert.IsNull(result.Result);
}
[Test]
public virtual void CanConvertBlankStringToDateTime()
{
+6 -2
View File
@@ -183,7 +183,9 @@
</Reference>
<Reference Include="System.Drawing" />
<Reference Include="System.EnterpriseServices" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Net.Http">
<Private>True</Private>
</Reference>
<Reference Include="System.Net.Http.Extensions">
<HintPath>..\packages\Microsoft.Net.Http.2.2.15\lib\net45\System.Net.Http.Extensions.dll</HintPath>
</Reference>
@@ -193,7 +195,9 @@
<Reference Include="System.Net.Http.Primitives">
<HintPath>..\packages\Microsoft.Net.Http.2.2.15\lib\net45\System.Net.Http.Primitives.dll</HintPath>
</Reference>
<Reference Include="System.Net.Http.WebRequest" />
<Reference Include="System.Net.Http.WebRequest">
<Private>True</Private>
</Reference>
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.ServiceModel" />
<Reference Include="System.Web">
@@ -13,12 +13,12 @@ namespace Umbraco.Web
/// <summary>
/// A class used to query for published content, media items
/// </summary>
public class PublishedQueryContext
public class PublishedContentQuery
{
private readonly ContextualPublishedContentCache _contentCache;
private readonly ContextualPublishedMediaCache _mediaCache;
public PublishedQueryContext(ContextualPublishedContentCache contentCache, ContextualPublishedMediaCache mediaCache)
public PublishedContentQuery(ContextualPublishedContentCache contentCache, ContextualPublishedMediaCache mediaCache)
{
_contentCache = contentCache;
_mediaCache = mediaCache;
@@ -9,11 +9,11 @@ namespace Umbraco.Web
/// <summary>
/// A class that exposes methods used to query tag data in views
/// </summary>
public class TagQueryContext
public class TagQuery
{
private readonly ITagService _tagService;
public TagQueryContext(ITagService tagService)
public TagQuery(ITagService tagService)
{
if (tagService == null) throw new ArgumentNullException("tagService");
_tagService = tagService;
+1
View File
@@ -22,6 +22,7 @@ namespace Umbraco.Web.UI
/// specific app, they'd still be able to execute code to create/delete for any ITask regardless of what app
/// they have access to.
/// </remarks>
[Obsolete("ITask is used for legacy webforms back office editors, change to using the v7 angular approach")]
public abstract class LegacyDialogTask : ITaskReturnUrl, IAssignedApp
{
public virtual int ParentID { get; set; }
+2 -2
View File
@@ -401,9 +401,9 @@
<Compile Include="PropertyEditors\LabelPropertyEditor.cs" />
<Compile Include="PropertyEditors\LabelPropertyValueEditor.cs" />
<Compile Include="PropertyEditors\PropertyValueEditorWrapper.cs" />
<Compile Include="PublishedQueryContext.cs" />
<Compile Include="PublishedContentQuery.cs" />
<Compile Include="Routing\UrlProviderExtensions.cs" />
<Compile Include="TagQueryContext.cs" />
<Compile Include="TagQuery.cs" />
<Compile Include="Trees\CoreTreeAttribute.cs" />
<Compile Include="Trees\DataTypeTreeController.cs" />
<Compile Include="Trees\LegacyBaseTreeAttribute.cs" />
+63 -63
View File
@@ -32,23 +32,23 @@ namespace Umbraco.Web
{
private readonly UmbracoContext _umbracoContext;
private readonly IPublishedContent _currentPage;
private PublishedQueryContext _queryContext;
private TagQueryContext _tagContext;
private PublishedContentQuery _query;
private TagQuery _tag;
/// <summary>
/// Lazy instantiates the tag context
/// </summary>
public TagQueryContext Tags
public TagQuery TagQuery
{
get { return _tagContext ?? (_tagContext = new TagQueryContext(UmbracoContext.Application.Services.TagService)); }
get { return _tag ?? (_tag = new TagQuery(UmbracoContext.Application.Services.TagService)); }
}
/// <summary>
/// Lazy instantiates the query context
/// </summary>
public PublishedQueryContext QueryContext
public PublishedContentQuery ContentQuery
{
get { return _queryContext ?? (_queryContext = new PublishedQueryContext(UmbracoContext.ContentCache, UmbracoContext.MediaCache)); }
get { return _query ?? (_query = new PublishedContentQuery(UmbracoContext.ContentCache, UmbracoContext.MediaCache)); }
}
/// <summary>
@@ -73,13 +73,13 @@ namespace Umbraco.Web
{
}
public UmbracoHelper(UmbracoContext umbracoContext, IPublishedContent content, PublishedQueryContext queryContext)
public UmbracoHelper(UmbracoContext umbracoContext, IPublishedContent content, PublishedContentQuery query)
: this(umbracoContext)
{
if (content == null) throw new ArgumentNullException("content");
if (queryContext == null) throw new ArgumentNullException("queryContext");
if (query == null) throw new ArgumentNullException("query");
_currentPage = content;
_queryContext = queryContext;
_query = query;
}
/// <summary>
@@ -109,11 +109,11 @@ namespace Umbraco.Web
}
}
public UmbracoHelper(UmbracoContext umbracoContext, PublishedQueryContext queryContext)
public UmbracoHelper(UmbracoContext umbracoContext, PublishedContentQuery query)
: this(umbracoContext)
{
if (queryContext == null) throw new ArgumentNullException("queryContext");
_queryContext = queryContext;
if (query == null) throw new ArgumentNullException("query");
_query = query;
}
/// <summary>
@@ -576,140 +576,140 @@ namespace Umbraco.Web
public IPublishedContent TypedContent(object id)
{
int intId;
return ConvertIdObjectToInt(id, out intId) ? QueryContext.TypedContent(intId) : null;
return ConvertIdObjectToInt(id, out intId) ? ContentQuery.TypedContent(intId) : null;
}
public IPublishedContent TypedContent(int id)
{
return QueryContext.TypedContent(id);
return ContentQuery.TypedContent(id);
}
public IPublishedContent TypedContent(string id)
{
int intId;
return ConvertIdObjectToInt(id, out intId) ? QueryContext.TypedContent(intId) : null;
return ConvertIdObjectToInt(id, out intId) ? ContentQuery.TypedContent(intId) : null;
}
public IPublishedContent TypedContentSingleAtXPath(string xpath, params XPathVariable[] vars)
{
return QueryContext.TypedContentSingleAtXPath(xpath, vars);
return ContentQuery.TypedContentSingleAtXPath(xpath, vars);
}
public IEnumerable<IPublishedContent> TypedContent(params object[] ids)
{
return QueryContext.TypedContent(ConvertIdsObjectToInts(ids));
return ContentQuery.TypedContent(ConvertIdsObjectToInts(ids));
}
public IEnumerable<IPublishedContent> TypedContent(params int[] ids)
{
return QueryContext.TypedContent(ids);
return ContentQuery.TypedContent(ids);
}
public IEnumerable<IPublishedContent> TypedContent(params string[] ids)
{
return QueryContext.TypedContent(ConvertIdsObjectToInts(ids));
return ContentQuery.TypedContent(ConvertIdsObjectToInts(ids));
}
public IEnumerable<IPublishedContent> TypedContent(IEnumerable<object> ids)
{
return QueryContext.TypedContent(ConvertIdsObjectToInts(ids));
return ContentQuery.TypedContent(ConvertIdsObjectToInts(ids));
}
public IEnumerable<IPublishedContent> TypedContent(IEnumerable<string> ids)
{
return QueryContext.TypedContent(ConvertIdsObjectToInts(ids));
return ContentQuery.TypedContent(ConvertIdsObjectToInts(ids));
}
public IEnumerable<IPublishedContent> TypedContent(IEnumerable<int> ids)
{
return QueryContext.TypedContent(ids);
return ContentQuery.TypedContent(ids);
}
public IEnumerable<IPublishedContent> TypedContentAtXPath(string xpath, params XPathVariable[] vars)
{
return QueryContext.TypedContentAtXPath(xpath, vars);
return ContentQuery.TypedContentAtXPath(xpath, vars);
}
public IEnumerable<IPublishedContent> TypedContentAtXPath(XPathExpression xpath, params XPathVariable[] vars)
{
return QueryContext.TypedContentAtXPath(xpath, vars);
return ContentQuery.TypedContentAtXPath(xpath, vars);
}
public IEnumerable<IPublishedContent> TypedContentAtRoot()
{
return QueryContext.TypedContentAtRoot();
return ContentQuery.TypedContentAtRoot();
}
public dynamic Content(object id)
{
int intId;
return ConvertIdObjectToInt(id, out intId) ? QueryContext.Content(intId) : DynamicNull.Null;
return ConvertIdObjectToInt(id, out intId) ? ContentQuery.Content(intId) : DynamicNull.Null;
}
public dynamic Content(int id)
{
return QueryContext.Content(id);
return ContentQuery.Content(id);
}
public dynamic Content(string id)
{
int intId;
return ConvertIdObjectToInt(id, out intId) ? QueryContext.Content(intId) : DynamicNull.Null;
return ConvertIdObjectToInt(id, out intId) ? ContentQuery.Content(intId) : DynamicNull.Null;
}
public dynamic ContentSingleAtXPath(string xpath, params XPathVariable[] vars)
{
return QueryContext.ContentSingleAtXPath(xpath, vars);
return ContentQuery.ContentSingleAtXPath(xpath, vars);
}
public dynamic ContentSingleAtXPath(XPathExpression xpath, params XPathVariable[] vars)
{
return QueryContext.ContentSingleAtXPath(xpath, vars);
return ContentQuery.ContentSingleAtXPath(xpath, vars);
}
public dynamic Content(params object[] ids)
{
return QueryContext.Content(ConvertIdsObjectToInts(ids));
return ContentQuery.Content(ConvertIdsObjectToInts(ids));
}
public dynamic Content(params int[] ids)
{
return QueryContext.Content(ids);
return ContentQuery.Content(ids);
}
public dynamic Content(params string[] ids)
{
return QueryContext.Content(ConvertIdsObjectToInts(ids));
return ContentQuery.Content(ConvertIdsObjectToInts(ids));
}
public dynamic Content(IEnumerable<object> ids)
{
return QueryContext.Content(ConvertIdsObjectToInts(ids));
return ContentQuery.Content(ConvertIdsObjectToInts(ids));
}
public dynamic Content(IEnumerable<int> ids)
{
return QueryContext.Content(ids);
return ContentQuery.Content(ids);
}
public dynamic Content(IEnumerable<string> ids)
{
return QueryContext.Content(ConvertIdsObjectToInts(ids));
return ContentQuery.Content(ConvertIdsObjectToInts(ids));
}
public dynamic ContentAtXPath(string xpath, params XPathVariable[] vars)
{
return QueryContext.ContentAtXPath(xpath, vars);
return ContentQuery.ContentAtXPath(xpath, vars);
}
public dynamic ContentAtXPath(XPathExpression xpath, params XPathVariable[] vars)
{
return QueryContext.ContentAtXPath(xpath, vars);
return ContentQuery.ContentAtXPath(xpath, vars);
}
public dynamic ContentAtRoot()
{
return QueryContext.ContentAtRoot();
return ContentQuery.ContentAtRoot();
}
private bool ConvertIdObjectToInt(object id, out int intId)
@@ -760,105 +760,105 @@ namespace Umbraco.Web
public IPublishedContent TypedMedia(object id)
{
int intId;
return ConvertIdObjectToInt(id, out intId) ? QueryContext.TypedMedia(intId) : null;
return ConvertIdObjectToInt(id, out intId) ? ContentQuery.TypedMedia(intId) : null;
}
public IPublishedContent TypedMedia(int id)
{
return QueryContext.TypedMedia(id);
return ContentQuery.TypedMedia(id);
}
public IPublishedContent TypedMedia(string id)
{
int intId;
return ConvertIdObjectToInt(id, out intId) ? QueryContext.TypedMedia(intId) : null;
return ConvertIdObjectToInt(id, out intId) ? ContentQuery.TypedMedia(intId) : null;
}
public IEnumerable<IPublishedContent> TypedMedia(params object[] ids)
{
return QueryContext.TypedMedia(ConvertIdsObjectToInts(ids));
return ContentQuery.TypedMedia(ConvertIdsObjectToInts(ids));
}
public IEnumerable<IPublishedContent> TypedMedia(params int[] ids)
{
return QueryContext.TypedMedia(ids);
return ContentQuery.TypedMedia(ids);
}
public IEnumerable<IPublishedContent> TypedMedia(params string[] ids)
{
return QueryContext.TypedMedia(ConvertIdsObjectToInts(ids));
return ContentQuery.TypedMedia(ConvertIdsObjectToInts(ids));
}
public IEnumerable<IPublishedContent> TypedMedia(IEnumerable<object> ids)
{
return QueryContext.TypedMedia(ConvertIdsObjectToInts(ids));
return ContentQuery.TypedMedia(ConvertIdsObjectToInts(ids));
}
public IEnumerable<IPublishedContent> TypedMedia(IEnumerable<int> ids)
{
return QueryContext.TypedMedia(ids);
return ContentQuery.TypedMedia(ids);
}
public IEnumerable<IPublishedContent> TypedMedia(IEnumerable<string> ids)
{
return QueryContext.TypedMedia(ConvertIdsObjectToInts(ids));
return ContentQuery.TypedMedia(ConvertIdsObjectToInts(ids));
}
public IEnumerable<IPublishedContent> TypedMediaAtRoot()
{
return QueryContext.TypedMediaAtRoot();
return ContentQuery.TypedMediaAtRoot();
}
public dynamic Media(object id)
{
int intId;
return ConvertIdObjectToInt(id, out intId) ? QueryContext.Media(intId) : DynamicNull.Null;
return ConvertIdObjectToInt(id, out intId) ? ContentQuery.Media(intId) : DynamicNull.Null;
}
public dynamic Media(int id)
{
return QueryContext.Media(id);
return ContentQuery.Media(id);
}
public dynamic Media(string id)
{
int intId;
return ConvertIdObjectToInt(id, out intId) ? QueryContext.Media(intId) : DynamicNull.Null;
return ConvertIdObjectToInt(id, out intId) ? ContentQuery.Media(intId) : DynamicNull.Null;
}
public dynamic Media(params object[] ids)
{
return QueryContext.Media(ConvertIdsObjectToInts(ids));
return ContentQuery.Media(ConvertIdsObjectToInts(ids));
}
public dynamic Media(params int[] ids)
{
return QueryContext.Media(ids);
return ContentQuery.Media(ids);
}
public dynamic Media(params string[] ids)
{
return QueryContext.Media(ConvertIdsObjectToInts(ids));
return ContentQuery.Media(ConvertIdsObjectToInts(ids));
}
public dynamic Media(IEnumerable<object> ids)
{
return QueryContext.Media(ConvertIdsObjectToInts(ids));
return ContentQuery.Media(ConvertIdsObjectToInts(ids));
}
public dynamic Media(IEnumerable<int> ids)
{
return QueryContext.Media(ids);
return ContentQuery.Media(ids);
}
public dynamic Media(IEnumerable<string> ids)
{
return QueryContext.Media(ConvertIdsObjectToInts(ids));
return ContentQuery.Media(ConvertIdsObjectToInts(ids));
}
public dynamic MediaAtRoot()
{
return QueryContext.MediaAtRoot();
return ContentQuery.MediaAtRoot();
}
#endregion
@@ -874,7 +874,7 @@ namespace Umbraco.Web
/// <returns></returns>
public dynamic Search(string term, bool useWildCards = true, string searchProvider = null)
{
return QueryContext.Search(term, useWildCards, searchProvider);
return ContentQuery.Search(term, useWildCards, searchProvider);
}
/// <summary>
@@ -885,7 +885,7 @@ namespace Umbraco.Web
/// <returns></returns>
public dynamic Search(Examine.SearchCriteria.ISearchCriteria criteria, Examine.Providers.BaseSearchProvider searchProvider = null)
{
return QueryContext.Search(criteria, searchProvider);
return ContentQuery.Search(criteria, searchProvider);
}
/// <summary>
@@ -897,7 +897,7 @@ namespace Umbraco.Web
/// <returns></returns>
public IEnumerable<IPublishedContent> TypedSearch(string term, bool useWildCards = true, string searchProvider = null)
{
return QueryContext.Search(term, useWildCards, searchProvider);
return ContentQuery.Search(term, useWildCards, searchProvider);
}
/// <summary>
@@ -908,7 +908,7 @@ namespace Umbraco.Web
/// <returns></returns>
public IEnumerable<IPublishedContent> TypedSearch(Examine.SearchCriteria.ISearchCriteria criteria, Examine.Providers.BaseSearchProvider searchProvider = null)
{
return QueryContext.Search(criteria, searchProvider);
return ContentQuery.Search(criteria, searchProvider);
}
#endregion
@@ -23,7 +23,7 @@ namespace Umbraco.Web.WebServices
/// </summary>
public IEnumerable<TagModel> GetAllTags(string group = null)
{
return Umbraco.Tags.GetAllTags(group);
return Umbraco.TagQuery.GetAllTags(group);
}
/// <summary>
@@ -33,7 +33,7 @@ namespace Umbraco.Web.WebServices
/// <returns></returns>
public IEnumerable<TagModel> GetAllContentTags(string group = null)
{
return Umbraco.Tags.GetAllContentTags(group);
return Umbraco.TagQuery.GetAllContentTags(group);
}
/// <summary>
@@ -43,7 +43,7 @@ namespace Umbraco.Web.WebServices
/// <returns></returns>
public IEnumerable<TagModel> GetAllMediaTags(string group = null)
{
return Umbraco.Tags.GetAllMediaTags(group);
return Umbraco.TagQuery.GetAllMediaTags(group);
}
/// <summary>
@@ -53,7 +53,7 @@ namespace Umbraco.Web.WebServices
/// <returns></returns>
public IEnumerable<TagModel> GetAllMemberTags(string group = null)
{
return Umbraco.Tags.GetAllMemberTags(group);
return Umbraco.TagQuery.GetAllMemberTags(group);
}
/// <summary>
@@ -65,7 +65,7 @@ namespace Umbraco.Web.WebServices
/// <returns></returns>
public IEnumerable<TagModel> GetTagsForProperty(int contentId, string propertyTypeAlias, string tagGroup = null)
{
return Umbraco.Tags.GetTagsForProperty(contentId, propertyTypeAlias, tagGroup);
return Umbraco.TagQuery.GetTagsForProperty(contentId, propertyTypeAlias, tagGroup);
}
/// <summary>
@@ -76,7 +76,7 @@ namespace Umbraco.Web.WebServices
/// <returns></returns>
public IEnumerable<TagModel> GetTagsForEntity(int contentId, string tagGroup = null)
{
return Umbraco.Tags.GetTagsForEntity(contentId, tagGroup);
return Umbraco.TagQuery.GetTagsForEntity(contentId, tagGroup);
}
}
@@ -4,8 +4,10 @@ using Umbraco.Core.CodeAnnotations;
using Umbraco.Core.IO;
using Umbraco.Core.Logging;
using Umbraco.Web.Mvc;
using Umbraco.Web.UI;
using umbraco.BasePages;
using Umbraco.Core;
using umbraco.BusinessLogic;
namespace umbraco
{
@@ -13,13 +15,10 @@ namespace umbraco
/// The UI 'tasks' for the create dialog and delete processes
/// </summary>
[UmbracoWillObsolete("http://issues.umbraco.org/issue/U4-1373", "This will one day be removed when we overhaul the create process")]
public class PartialViewMacroTasks : interfaces.ITaskReturnUrl
public class PartialViewMacroTasks : LegacyDialogTask
{
private string _alias;
private int _parentId;
private int _typeId;
private int _userId;
private string _returnUrl = "";
protected virtual string EditViewFile
{
get { return "Settings/Views/EditView.aspx"; }
@@ -35,34 +34,11 @@ namespace umbraco
get { return "MacroPartials"; }
}
public int UserId
public override bool PerformSave()
{
set { _userId = value; }
}
public int TypeID
{
set { _typeId = value; }
get { return _typeId; }
}
public string Alias
{
set { _alias = value; }
get { return _alias; }
}
public int ParentID
{
set { _parentId = value; }
get { return _parentId; }
}
public bool Save()
{
var pipesIndex = _alias.IndexOf("|||", System.StringComparison.Ordinal);
var template = _alias.Substring(0, pipesIndex).Trim();
var fileName = _alias.Substring(pipesIndex + 3, _alias.Length - pipesIndex - 3) + ".cshtml";
var pipesIndex = Alias.IndexOf("|||", System.StringComparison.Ordinal);
var template = Alias.Substring(0, pipesIndex).Trim();
var fileName = Alias.Substring(pipesIndex + 3, Alias.Length - pipesIndex - 3) + ".cshtml";
var fullFilePath = IOHelper.MapPath(BasePath + fileName);
@@ -97,27 +73,29 @@ namespace umbraco
return true;
}
public bool Delete()
public override string ReturnUrl
{
var path = IOHelper.MapPath(BasePath + _alias.TrimStart('/'));
get { return _returnUrl; }
}
public override string AssignedApp
{
get { return DefaultApps.developer.ToString(); }
}
public override bool PerformDelete()
{
var path = IOHelper.MapPath(BasePath + Alias.TrimStart('/'));
if (File.Exists(path))
File.Delete(path);
else if (Directory.Exists(path))
Directory.Delete(path, true);
LogHelper.Info<PartialViewTasks>(string.Format("{0} Deleted by user {1}", _alias, UmbracoEnsuredPage.CurrentUser.Id));
LogHelper.Info<PartialViewTasks>(string.Format("{0} Deleted by user {1}", Alias, User.Id));
return true;
}
#region ITaskReturnUrl Members
private string _returnUrl = "";
public string ReturnUrl
{
get { return _returnUrl; }
}
#endregion
}
}
@@ -107,4 +107,4 @@ namespace umbraco
}
}
}
}
File diff suppressed because it is too large Load Diff
+1
View File
@@ -5,6 +5,7 @@ namespace umbraco.interfaces
/// <summary>
/// Summary description for ITask.
/// </summary>
[Obsolete("ITask is used for legacy webforms back office editors, change to using the v7 angular approach")]
public interface ITask
{
int ParentID {set; get;}
+3
View File
@@ -1,5 +1,8 @@
using System;
namespace umbraco.interfaces
{
[Obsolete("ITask is used for legacy webforms back office editors, change to using the v7 angular approach")]
public interface ITaskReturnUrl : ITask
{
string ReturnUrl {get;}