Updating DefaultData and ContentControl to better support saving through the new api.
DataTypes doesn't save directly to the db, but keeps the value in-memory so the save can be handled by the new api. Correcting the usage of versioning in the ContentRepository.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Models.Membership;
|
||||
using Umbraco.Core.Persistence;
|
||||
using Umbraco.Core.Persistence.Repositories;
|
||||
@@ -116,7 +117,8 @@ namespace Umbraco.Core.Models
|
||||
new XAttribute("urlName", niceUrl),//Format Url ?
|
||||
new XAttribute("writerName", content.GetWriterProfile().Name),
|
||||
new XAttribute("creatorName", content.GetCreatorProfile().Name),
|
||||
new XAttribute("path", content.Path));
|
||||
new XAttribute("path", content.Path),
|
||||
new XAttribute("isDoc", ""));
|
||||
|
||||
foreach (var property in content.Properties)
|
||||
{
|
||||
|
||||
@@ -126,7 +126,7 @@ namespace Umbraco.Core.Persistence.Factories
|
||||
{
|
||||
//TODO: Change this once the Language property is public on IContent
|
||||
var content = entity as Content;
|
||||
var nodeName = content == null ? entity.Name : content.NodeName;
|
||||
var nodeName = content != null && string.IsNullOrEmpty(content.NodeName) == false ? content.NodeName : entity.Name;
|
||||
|
||||
var nodeDto = new NodeDto
|
||||
{
|
||||
|
||||
@@ -45,18 +45,15 @@ namespace Umbraco.Core.Persistence.Factories
|
||||
public IEnumerable<PropertyDataDto> BuildDto(IEnumerable<Property> properties)
|
||||
{
|
||||
var propertyDataDtos = new List<PropertyDataDto>();
|
||||
/*var serviceStackSerializer = new ServiceStackXmlSerializer();
|
||||
var service = new SerializationService(serviceStackSerializer);*/
|
||||
|
||||
foreach (var property in properties)
|
||||
{
|
||||
var dto = new PropertyDataDto { NodeId = _id, PropertyTypeId = property.PropertyTypeId, VersionId = _version };
|
||||
//TODO Add complex (PropertyEditor) ValueModels to the Ntext/Nvarchar column as a serialized 'Object' (DataTypeDatabaseType.Object)
|
||||
/*if (property.Value is IEditorModel)
|
||||
{
|
||||
var result = service.ToStream(property.Value);
|
||||
dto.Text = result.ResultStream.ToJsonString();
|
||||
}*/
|
||||
|
||||
//Check if property has an Id and set it, so that it can be updated if it already exists
|
||||
if (property.HasIdentity)
|
||||
dto.Id = property.Id;
|
||||
|
||||
if (property.DataTypeDatabaseType == DataTypeDatabaseType.Integer && property.Value != null)
|
||||
{
|
||||
dto.Integer = int.Parse(property.Value.ToString());
|
||||
|
||||
@@ -226,8 +226,17 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
|
||||
protected override void PersistUpdatedItem(IContent entity)
|
||||
{
|
||||
//Updates Modified date and Version Guid
|
||||
((Content)entity).UpdatingEntity();
|
||||
//A new version should only be created if published state has changed
|
||||
bool hasPublishedStateChanged = ((ICanBeDirty) entity).IsPropertyDirty("Published");
|
||||
if (hasPublishedStateChanged)
|
||||
{
|
||||
//Updates Modified date and Version Guid
|
||||
((Content)entity).UpdatingEntity();
|
||||
}
|
||||
else
|
||||
{
|
||||
entity.UpdateDate = DateTime.UtcNow;
|
||||
}
|
||||
|
||||
//Look up parent to get and set the correct Path if ParentId has changed
|
||||
if (((ICanBeDirty) entity).IsPropertyDirty("ParentId"))
|
||||
@@ -254,17 +263,8 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
Database.Update(newContentDto);
|
||||
}
|
||||
|
||||
//Look up (newest) entries by id in cmsDocument table to set newest = false
|
||||
var documentDtos = Database.Fetch<DocumentDto>("WHERE nodeId = @Id AND newest = @IsNewest", new { Id = entity.Id, IsNewest = true });
|
||||
foreach (var documentDto in documentDtos)
|
||||
{
|
||||
var docDto = documentDto;
|
||||
docDto.Newest = false;
|
||||
Database.Update(docDto);
|
||||
}
|
||||
|
||||
//If Published state has changed previous versions should have their publish state reset
|
||||
if (((ICanBeDirty) entity).IsPropertyDirty("Published") && entity.Published)
|
||||
//If Published state has changed then previous versions should have their publish state reset
|
||||
if (hasPublishedStateChanged && entity.Published)
|
||||
{
|
||||
var publishedDocs = Database.Fetch<DocumentDto>("WHERE nodeId = @Id AND published = @IsPublished", new { Id = entity.Id, IsPublished = true });
|
||||
foreach (var doc in publishedDocs)
|
||||
@@ -275,14 +275,35 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
}
|
||||
}
|
||||
|
||||
//Create a new version - cmsContentVersion
|
||||
//Assumes a new Version guid and Version date (modified date) has been set
|
||||
var contentVersionDto = dto.ContentVersionDto;
|
||||
Database.Insert(contentVersionDto);
|
||||
if (hasPublishedStateChanged)
|
||||
{
|
||||
//Look up (newest) entries by id in cmsDocument table to set newest = false
|
||||
//NOTE: This is only relevant when a new version is created, which is why its done inside this if-statement.
|
||||
var documentDtos = Database.Fetch<DocumentDto>("WHERE nodeId = @Id AND newest = @IsNewest", new { Id = entity.Id, IsNewest = true });
|
||||
foreach (var documentDto in documentDtos)
|
||||
{
|
||||
var docDto = documentDto;
|
||||
docDto.Newest = false;
|
||||
Database.Update(docDto);
|
||||
}
|
||||
|
||||
//Create the Document specific data for this version - cmsDocument
|
||||
//Assumes a new Version guid has been generated
|
||||
Database.Insert(dto);
|
||||
//Create a new version - cmsContentVersion
|
||||
//Assumes a new Version guid and Version date (modified date) has been set
|
||||
Database.Insert(contentVersionDto);
|
||||
//Create the Document specific data for this version - cmsDocument
|
||||
//Assumes a new Version guid has been generated
|
||||
Database.Insert(dto);
|
||||
}
|
||||
else
|
||||
{
|
||||
//In order to update the ContentVersion we need to retreive its primary key id
|
||||
var contentVerDto = Database.SingleOrDefault<ContentVersionDto>("WHERE VersionId = @Version", new { Version = entity.Version });
|
||||
contentVersionDto.Id = contentVerDto.Id;
|
||||
|
||||
Database.Update(contentVersionDto);
|
||||
Database.Update(dto);
|
||||
}
|
||||
|
||||
//Create the PropertyData for this version - cmsPropertyData
|
||||
var propertyFactory = new PropertyFactory(((Content)entity).ContentType, entity.Version, entity.Id);
|
||||
@@ -290,7 +311,14 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
//Add Properties
|
||||
foreach (var propertyDataDto in propertyDataDtos)
|
||||
{
|
||||
Database.Insert(propertyDataDto);
|
||||
if (hasPublishedStateChanged == false && propertyDataDto.Id > 0)
|
||||
{
|
||||
Database.Update(propertyDataDto);
|
||||
}
|
||||
else
|
||||
{
|
||||
Database.Insert(propertyDataDto);
|
||||
}
|
||||
}
|
||||
|
||||
((ICanBeDirty)entity).ResetDirtyProperties();
|
||||
|
||||
@@ -62,18 +62,6 @@ namespace Umbraco.Core.Publishing
|
||||
string.Format("Content '{0}' with Id '{1}' has been published.",
|
||||
content.Name, content.Id));
|
||||
|
||||
//Fire Published event
|
||||
//OnPublished(content, e);
|
||||
|
||||
//NOTE: Ideally the xml cache should be refreshed here - as part of the publishing
|
||||
//but the updated content hasn't been saved yet
|
||||
//Consider creating a method in the PublishingStrategy that is called when updating a content-being-publishing item is final
|
||||
//and thus more legit to fire the OnPublished event
|
||||
//PublishingFinalized(IContent content) { OnPublished(content, new PublishingEventArgs()); }
|
||||
//PublishingFinalized(IEnumerable<IContent> content) { OnPublished(content, new PublishingEventArgs()); }
|
||||
//UnPublishingFinalized(IContent content) { OnUnPublished(content, new PublishingEventArgs()); }
|
||||
//UnPublishingFinalized(IEnumerable<IContent> content) { OnUnPublished(content, new PublishingEventArgs()); }
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -132,16 +120,8 @@ namespace Umbraco.Core.Publishing
|
||||
LogHelper.Info<PublishingStrategy>(
|
||||
string.Format("Content '{0}' with Id '{1}' has been published.",
|
||||
item.Name, item.Id));
|
||||
|
||||
//Fire Published event
|
||||
//OnPublished(item, e);
|
||||
}
|
||||
|
||||
//OnPublished(content, e);
|
||||
|
||||
//NOTE: Ideally the xml cache should be refreshed here - as part of the publishing
|
||||
//OnCacheContentAfterPublish(content, e)
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -176,13 +156,6 @@ namespace Umbraco.Core.Publishing
|
||||
LogHelper.Info<PublishingStrategy>(
|
||||
string.Format("Content '{0}' with Id '{1}' has been unpublished.",
|
||||
content.Name, content.Id));
|
||||
|
||||
//Fire UnPublishing event
|
||||
//OnUnPublished(content, e);
|
||||
|
||||
//NOTE: Ideally the xml cache should be refreshed here - as part of the unpublishing
|
||||
//OnRemoveCacheContentAfterPublish(content, e)
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -223,15 +196,8 @@ namespace Umbraco.Core.Publishing
|
||||
LogHelper.Info<PublishingStrategy>(
|
||||
string.Format("Content '{0}' with Id '{1}' has been unpublished.",
|
||||
item.Name, item.Id));
|
||||
|
||||
//Fire AfterUnPublish event
|
||||
//OnUnPublished(item, e);
|
||||
}
|
||||
|
||||
//OnUnPublished(content, e);
|
||||
|
||||
//NOTE: Ideally the xml cache should be refreshed here - as part of the publishing
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -517,7 +517,7 @@ namespace Umbraco.Core.Services
|
||||
if(omitCacheRefresh == false)
|
||||
_publishingStrategy.UnPublishingFinalized(content);
|
||||
|
||||
Audit.Add(AuditTypes.Publish, "UnPublish performed by user", userId == -1 ? 0 : userId, content.Id);
|
||||
Audit.Add(AuditTypes.UnPublish, "UnPublish performed by user", userId == -1 ? 0 : userId, content.Id);
|
||||
}
|
||||
|
||||
return unpublished;
|
||||
@@ -588,12 +588,14 @@ namespace Umbraco.Core.Services
|
||||
|
||||
//Publish and then update the database with new status
|
||||
bool published = _publishingStrategy.Publish(content, userId);
|
||||
|
||||
//Since this is the Save and Publish method, the content should be saved even though the publish fails or isn't allowed
|
||||
SetWriter(content, userId);
|
||||
repository.AddOrUpdate(content);
|
||||
_unitOfWork.Commit();
|
||||
|
||||
if (published)
|
||||
{
|
||||
SetWriter(content, userId);
|
||||
repository.AddOrUpdate(content);
|
||||
_unitOfWork.Commit();
|
||||
|
||||
var xml = content.ToXml();
|
||||
var poco = new ContentXmlDto{NodeId = content.Id, Xml = xml.ToString(SaveOptions.None)};
|
||||
var exists = DatabaseContext.Current.Database.FirstOrDefault<ContentXmlDto>("WHERE nodeId = @Id", new {Id = content.Id}) != null;
|
||||
@@ -633,7 +635,11 @@ namespace Umbraco.Core.Services
|
||||
var repository = _contentRepository;
|
||||
|
||||
SetWriter(content, userId);
|
||||
content.ChangePublishedState(false);
|
||||
|
||||
//Only change the publish state if the "previous" version was actually published
|
||||
if(content.Published)
|
||||
content.ChangePublishedState(false);
|
||||
|
||||
repository.AddOrUpdate(content);
|
||||
_unitOfWork.Commit();
|
||||
|
||||
@@ -669,7 +675,11 @@ namespace Umbraco.Core.Services
|
||||
foreach (var content in contents)
|
||||
{
|
||||
SetWriter(content, userId);
|
||||
content.ChangePublishedState(false);
|
||||
|
||||
//Only change the publish state if the "previous" version was actually published
|
||||
if (content.Published)
|
||||
content.ChangePublishedState(false);
|
||||
|
||||
repository.AddOrUpdate(content);
|
||||
_unitOfWork.Commit();
|
||||
}
|
||||
@@ -716,7 +726,11 @@ namespace Umbraco.Core.Services
|
||||
foreach (var content in contents)
|
||||
{
|
||||
SetWriter(content.Value, userId);
|
||||
content.Value.ChangePublishedState(false);
|
||||
|
||||
//Only change the publish state if the "previous" version was actually published
|
||||
if (content.Value.Published)
|
||||
content.Value.ChangePublishedState(false);
|
||||
|
||||
repository.AddOrUpdate(content.Value);
|
||||
_unitOfWork.Commit();
|
||||
}
|
||||
|
||||
@@ -264,7 +264,10 @@
|
||||
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
|
||||
<bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
|
||||
</dependentAssembly>
|
||||
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Web.WebPages.Razor" publicKeyToken="31bf3856ad364e35"/>
|
||||
<bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0"/>
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
|
||||
|
||||
@@ -2,21 +2,18 @@ using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using umbraco.BasePages;
|
||||
using umbraco.cms.businesslogic;
|
||||
using umbraco.cms.businesslogic.datatype.controls;
|
||||
using umbraco.cms.businesslogic.media;
|
||||
using umbraco.cms.businesslogic.property;
|
||||
using umbraco.cms.businesslogic.propertytype;
|
||||
using umbraco.cms.businesslogic.web;
|
||||
using umbraco.interfaces;
|
||||
using umbraco.uicontrols;
|
||||
using Umbraco.Core.IO;
|
||||
using Content = umbraco.cms.businesslogic.Content;
|
||||
using SystemDirectories = umbraco.IO.SystemDirectories;
|
||||
|
||||
@@ -30,7 +27,7 @@ namespace umbraco.controls
|
||||
public class ContentControl : TabView
|
||||
{
|
||||
private Content _content;
|
||||
private ArrayList _dataFields = new ArrayList();
|
||||
internal Dictionary<string, IDataType> DataTypes = new Dictionary<string, IDataType>();
|
||||
private UmbracoEnsuredPage prntpage;
|
||||
public event EventHandler SaveAndPublish;
|
||||
public event EventHandler SaveToPublish;
|
||||
@@ -248,9 +245,10 @@ namespace umbraco.controls
|
||||
return;
|
||||
}
|
||||
}
|
||||
foreach (IDataEditor df in _dataFields)
|
||||
|
||||
foreach (var type in DataTypes)
|
||||
{
|
||||
df.Save();
|
||||
type.Value.DataEditor.Save();
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(NameTxt.Text))
|
||||
@@ -308,15 +306,14 @@ namespace umbraco.controls
|
||||
dt.DataEditor.Editor.ID = string.Format("prop_{0}", p.PropertyType.Alias);
|
||||
dt.Data.PropertyId = p.Id;
|
||||
|
||||
//Add the DataType to an internal dictionary, which will be used to call the save method on the IDataEditor
|
||||
//and to retrieve the value from IData in editContent.aspx.cs, so that it can be set on the legacy Document class.
|
||||
DataTypes.Add(p.PropertyType.Alias, dt);
|
||||
|
||||
// check for buttons
|
||||
IDataFieldWithButtons df1 = dt.DataEditor.Editor as IDataFieldWithButtons;
|
||||
if (df1 != null)
|
||||
{
|
||||
// df1.Alias = p.PropertyType.Alias;
|
||||
/*
|
||||
// df1.Version = _content.Version;
|
||||
editDataType.Data.PropertyId = p.Id;
|
||||
*/
|
||||
((Control)df1).ID = p.PropertyType.Alias;
|
||||
|
||||
|
||||
@@ -389,14 +386,6 @@ namespace umbraco.controls
|
||||
menuElement.ElementClass, menuElement.ExtraMenuWidth);
|
||||
}
|
||||
|
||||
|
||||
// fieldData.Alias = p.PropertyType.Alias;
|
||||
// ((Control) fieldData).ID = p.PropertyType.Alias;
|
||||
// fieldData.Text = p.Value.ToString();
|
||||
|
||||
_dataFields.Add(dt.DataEditor.Editor);
|
||||
|
||||
|
||||
Pane pp = new Pane();
|
||||
Control holder = new Control();
|
||||
holder.Controls.Add(dt.DataEditor.Editor);
|
||||
|
||||
@@ -291,8 +291,14 @@ namespace umbraco.cms.presentation
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//The value of the properties has been set on IData through IDataEditor in the ContentControl
|
||||
//so we need to 'retrieve' that value and set it on the property of the new IContent object.
|
||||
//NOTE This is a workaround for the legacy approach to saving values through the DataType instead of the Property
|
||||
//- (The DataType shouldn't be responsible for saving the value - especically directly to the db).
|
||||
foreach (var item in cControl.DataTypes)
|
||||
{
|
||||
_document.Content.SetValue(item.Key, item.Value.Data.Value);
|
||||
}
|
||||
|
||||
// Run Handler
|
||||
BusinessLogic.Actions.Action.RunActionHandlers(_document, ActionUpdate.Instance);
|
||||
|
||||
@@ -670,9 +670,7 @@ namespace umbraco.cms.businesslogic
|
||||
continue;
|
||||
|
||||
//get the propertyId
|
||||
var property = propData
|
||||
.Where(x => x.PropertyTypeId == pt.Id)
|
||||
.SingleOrDefault();
|
||||
var property = propData.LastOrDefault(x => x.PropertyTypeId == pt.Id);
|
||||
if (property == null)
|
||||
continue;
|
||||
var propertyId = property.Id;
|
||||
|
||||
@@ -138,7 +138,7 @@ namespace umbraco.cms.businesslogic.datatype
|
||||
}
|
||||
set
|
||||
{
|
||||
if (!PreviewMode)
|
||||
/*if (!PreviewMode)
|
||||
{
|
||||
// Try to set null values if possible
|
||||
try
|
||||
@@ -168,8 +168,9 @@ namespace umbraco.cms.businesslogic.datatype
|
||||
if (value == null) value = "";
|
||||
SqlHelper.ExecuteNonQuery("update cmsPropertyData set " + _dataType.DataFieldName + " = @value where id = " + m_PropertyId, SqlHelper.CreateParameter("@value", value));
|
||||
}
|
||||
}
|
||||
}*/
|
||||
m_Value = value;
|
||||
m_ValueLoaded = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -77,27 +77,27 @@ namespace umbraco.cms.businesslogic.web
|
||||
this._optimizedMode = optimizedMode;
|
||||
if (optimizedMode)
|
||||
{
|
||||
_content = ServiceContext.Current.ContentService.GetById(id);
|
||||
Content = ServiceContext.Current.ContentService.GetById(id);
|
||||
bool hasChildren = ServiceContext.Current.ContentService.HasChildren(id);
|
||||
int templateId = _content.Template == null ? 0 : _content.Template.Id;
|
||||
int templateId = Content.Template == null ? 0 : Content.Template.Id;
|
||||
|
||||
SetupDocumentForTree(_content.Key, _content.Level, _content.ParentId, _content.CreatorId,
|
||||
_content.WriterId,
|
||||
_content.Published, _content.Path, _content.Name, _content.CreateDate,
|
||||
_content.UpdateDate, _content.UpdateDate, _content.ContentType.Icon, hasChildren,
|
||||
_content.ContentType.Alias, _content.ContentType.Thumbnail,
|
||||
_content.ContentType.Description, null, _content.ContentType.Id,
|
||||
templateId, _content.ContentType.IsContainer);
|
||||
SetupDocumentForTree(Content.Key, Content.Level, Content.ParentId, Content.CreatorId,
|
||||
Content.WriterId,
|
||||
Content.Published, Content.Path, Content.Name, Content.CreateDate,
|
||||
Content.UpdateDate, Content.UpdateDate, Content.ContentType.Icon, hasChildren,
|
||||
Content.ContentType.Alias, Content.ContentType.Thumbnail,
|
||||
Content.ContentType.Description, null, Content.ContentType.Id,
|
||||
templateId, Content.ContentType.IsContainer);
|
||||
|
||||
var tmpReleaseDate = _content.ReleaseDate.HasValue ? _content.ReleaseDate.Value : new DateTime();
|
||||
var tmpExpireDate = _content.ExpireDate.HasValue ? _content.ExpireDate.Value : new DateTime();
|
||||
var creator = new User(_content.CreatorId, true);
|
||||
var writer = new User(_content.WriterId, true);
|
||||
var tmpReleaseDate = Content.ReleaseDate.HasValue ? Content.ReleaseDate.Value : new DateTime();
|
||||
var tmpExpireDate = Content.ExpireDate.HasValue ? Content.ExpireDate.Value : new DateTime();
|
||||
var creator = new User(Content.CreatorId, true);
|
||||
var writer = new User(Content.WriterId, true);
|
||||
|
||||
InitializeContent(_content.ContentType.Id, _content.Version, _content.UpdateDate,
|
||||
_content.ContentType.Icon);
|
||||
InitializeDocument(creator, writer, _content.Name, templateId, tmpReleaseDate, tmpExpireDate,
|
||||
_content.UpdateDate, _content.Published);
|
||||
InitializeContent(Content.ContentType.Id, Content.Version, Content.UpdateDate,
|
||||
Content.ContentType.Icon);
|
||||
InitializeDocument(creator, writer, Content.Name, templateId, tmpReleaseDate, tmpExpireDate,
|
||||
Content.UpdateDate, Content.Published);
|
||||
}
|
||||
/*if (optimizedMode)
|
||||
{
|
||||
@@ -253,7 +253,7 @@ namespace umbraco.cms.businesslogic.web
|
||||
private User _writer;
|
||||
private int? _writerId;
|
||||
private bool _optimizedMode;
|
||||
private IContent _content;
|
||||
protected internal IContent Content;
|
||||
|
||||
/// <summary>
|
||||
/// This is used to cache the child documents of Document when the children property
|
||||
@@ -680,7 +680,7 @@ namespace umbraco.cms.businesslogic.web
|
||||
set
|
||||
{
|
||||
_published = value;
|
||||
_content.ChangePublishedState(value);
|
||||
Content.ChangePublishedState(value);
|
||||
/*SqlHelper.ExecuteNonQuery(
|
||||
string.Format("update cmsDocument set published = {0} where nodeId = {1}", Id, value ? 1 : 0));*/
|
||||
}
|
||||
@@ -710,14 +710,14 @@ and node.nodeObjectType='C66BA18E-EAF3-4CFF-8A22-41B16D66A972'");
|
||||
{
|
||||
get
|
||||
{
|
||||
return _content.Name;
|
||||
return Content.Name;
|
||||
//return base.Text;
|
||||
}
|
||||
set
|
||||
{
|
||||
value = value.Trim();
|
||||
base.Text = value;
|
||||
_content.Name = value;
|
||||
Content.Name = value;
|
||||
|
||||
/*SqlHelper.ExecuteNonQuery("update cmsDocument set text = @text where versionId = @versionId",
|
||||
SqlHelper.CreateParameter("@text", value),
|
||||
@@ -735,7 +735,7 @@ and node.nodeObjectType='C66BA18E-EAF3-4CFF-8A22-41B16D66A972'");
|
||||
set
|
||||
{
|
||||
_updated = value;
|
||||
_content.UpdateDate = value;
|
||||
Content.UpdateDate = value;
|
||||
/*SqlHelper.ExecuteNonQuery("update cmsDocument set updateDate = @value where versionId = @versionId",
|
||||
SqlHelper.CreateParameter("@value", value),
|
||||
SqlHelper.CreateParameter("@versionId", Version));*/
|
||||
@@ -752,7 +752,7 @@ and node.nodeObjectType='C66BA18E-EAF3-4CFF-8A22-41B16D66A972'");
|
||||
set
|
||||
{
|
||||
_release = value;
|
||||
_content.ReleaseDate = value;
|
||||
Content.ReleaseDate = value;
|
||||
/*if (_release.Year != 1 || _release.Month != 1 || _release.Day != 1)
|
||||
SqlHelper.ExecuteNonQuery("update cmsDocument set releaseDate = @value where versionId = @versionId",
|
||||
SqlHelper.CreateParameter("@value", value),
|
||||
@@ -773,7 +773,7 @@ and node.nodeObjectType='C66BA18E-EAF3-4CFF-8A22-41B16D66A972'");
|
||||
set
|
||||
{
|
||||
_expire = value;
|
||||
_content.ExpireDate = value;
|
||||
Content.ExpireDate = value;
|
||||
/*if (_expire.Year != 1 || _expire.Month != 1 || _expire.Day != 1)
|
||||
SqlHelper.ExecuteNonQuery("update cmsDocument set expireDate = @value where versionId=@versionId",
|
||||
SqlHelper.CreateParameter("@value", value),
|
||||
@@ -803,12 +803,12 @@ and node.nodeObjectType='C66BA18E-EAF3-4CFF-8A22-41B16D66A972'");
|
||||
_template = value;
|
||||
if (value == 0)
|
||||
{
|
||||
_content.Template = null;
|
||||
Content.Template = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
var template = ServiceContext.Current.FileService.GetTemplate(value);
|
||||
_content.Template = template;
|
||||
Content.Template = template;
|
||||
}
|
||||
/*if (value == 0)
|
||||
{
|
||||
@@ -878,7 +878,7 @@ and node.nodeObjectType='C66BA18E-EAF3-4CFF-8A22-41B16D66A972'");
|
||||
[Obsolete("Deprecated, Use Umbraco.Core.Services.ContentService.Publish()", false)]
|
||||
public void Publish(User u)
|
||||
{
|
||||
ServiceContext.Current.ContentService.Publish(_content, u.Id, true);
|
||||
ServiceContext.Current.ContentService.Publish(Content, u.Id, true);
|
||||
//PublishWithResult(u);
|
||||
}
|
||||
|
||||
@@ -899,7 +899,7 @@ and node.nodeObjectType='C66BA18E-EAF3-4CFF-8A22-41B16D66A972'");
|
||||
|
||||
if (!e.Cancel)
|
||||
{
|
||||
var result = ServiceContext.Current.ContentService.Publish(_content, u.Id, true);
|
||||
var result = ServiceContext.Current.ContentService.Publish(Content, u.Id, true);
|
||||
_published = result;
|
||||
|
||||
// make a lookup to see if template is 0 as the template is not initialized in the optimized
|
||||
@@ -954,7 +954,7 @@ and node.nodeObjectType='C66BA18E-EAF3-4CFF-8A22-41B16D66A972'");
|
||||
[Obsolete("Deprecated, Use Umbraco.Core.Services.ContentService.PublishWithChildren()", false)]
|
||||
public bool PublishWithChildrenWithResult(User u)
|
||||
{
|
||||
return ServiceContext.Current.ContentService.PublishWithChildren(_content, u.Id, true);
|
||||
return ServiceContext.Current.ContentService.PublishWithChildren(Content, u.Id, true);
|
||||
|
||||
/*if (PublishWithResult(u))
|
||||
{
|
||||
@@ -985,7 +985,7 @@ and node.nodeObjectType='C66BA18E-EAF3-4CFF-8A22-41B16D66A972'");
|
||||
|
||||
if (!e.Cancel)
|
||||
{
|
||||
_content = ServiceContext.Current.ContentService.Rollback(Id, VersionId, u.Id);
|
||||
Content = ServiceContext.Current.ContentService.Rollback(Id, VersionId, u.Id);
|
||||
|
||||
FireAfterRollBack(e);
|
||||
}
|
||||
@@ -1005,7 +1005,7 @@ and node.nodeObjectType='C66BA18E-EAF3-4CFF-8A22-41B16D66A972'");
|
||||
|
||||
if (!e.Cancel)
|
||||
{
|
||||
var published = ServiceContext.Current.ContentService.PublishWithChildren(_content, u.Id, true);
|
||||
var published = ServiceContext.Current.ContentService.PublishWithChildren(Content, u.Id, true);
|
||||
|
||||
/*_published = true;
|
||||
string tempVersion = Version.ToString();
|
||||
@@ -1046,7 +1046,7 @@ and node.nodeObjectType='C66BA18E-EAF3-4CFF-8A22-41B16D66A972'");
|
||||
//SqlHelper.ExecuteNonQuery(string.Format("update cmsDocument set published = 0 where nodeId = {0}", Id));
|
||||
//_published = false;
|
||||
|
||||
ServiceContext.Current.ContentService.UnPublish(_content, 0, true);
|
||||
ServiceContext.Current.ContentService.UnPublish(Content, 0, true);
|
||||
|
||||
FireAfterUnPublish(e);
|
||||
}
|
||||
@@ -1063,7 +1063,7 @@ and node.nodeObjectType='C66BA18E-EAF3-4CFF-8A22-41B16D66A972'");
|
||||
|
||||
if (!e.Cancel)
|
||||
{
|
||||
ServiceContext.Current.ContentService.Save(_content);
|
||||
ServiceContext.Current.ContentService.Save(Content);
|
||||
|
||||
base.Save();
|
||||
// update preview xml
|
||||
@@ -1076,7 +1076,7 @@ and node.nodeObjectType='C66BA18E-EAF3-4CFF-8A22-41B16D66A972'");
|
||||
[Obsolete("Deprecated, Use Umbraco.Core.Services.ContentService.HasPublishedVersion()", false)]
|
||||
public bool HasPublishedVersion()
|
||||
{
|
||||
return _content.HasPublishedVersion();
|
||||
return Content.HasPublishedVersion();
|
||||
//return (SqlHelper.ExecuteScalar<int>("select Count(published) as tmp from cmsDocument where published = 1 And nodeId =" + Id) > 0);
|
||||
}
|
||||
|
||||
@@ -1088,7 +1088,7 @@ and node.nodeObjectType='C66BA18E-EAF3-4CFF-8A22-41B16D66A972'");
|
||||
/// <returns></returns>
|
||||
public bool HasPendingChanges()
|
||||
{
|
||||
return _content.Published == false;
|
||||
return Content.Published == false;
|
||||
//double timeDiff = new TimeSpan(UpdateDate.Ticks - VersionDate.Ticks).TotalMilliseconds;
|
||||
//return timeDiff > 2000;
|
||||
}
|
||||
@@ -1168,7 +1168,7 @@ and node.nodeObjectType='C66BA18E-EAF3-4CFF-8A22-41B16D66A972'");
|
||||
if (!e.Cancel)
|
||||
{
|
||||
// Make the new document
|
||||
var content = ServiceContext.Current.ContentService.Copy(_content, CopyTo, RelateToOrignal, u.Id);
|
||||
var content = ServiceContext.Current.ContentService.Copy(Content, CopyTo, RelateToOrignal, u.Id);
|
||||
newDoc = new Document(content);
|
||||
|
||||
e.NewDocument = newDoc;
|
||||
@@ -1209,9 +1209,9 @@ and node.nodeObjectType='C66BA18E-EAF3-4CFF-8A22-41B16D66A972'");
|
||||
/// <returns></returns>
|
||||
public override IEnumerable GetDescendants()
|
||||
{
|
||||
var descendants = _content == null
|
||||
var descendants = Content == null
|
||||
? ServiceContext.Current.ContentService.GetDescendants(Id)
|
||||
: ServiceContext.Current.ContentService.GetDescendants(_content);
|
||||
: ServiceContext.Current.ContentService.GetDescendants(Content);
|
||||
|
||||
return descendants.Select(x => new Document(x.Id, true));
|
||||
}
|
||||
@@ -1424,29 +1424,29 @@ and node.nodeObjectType='C66BA18E-EAF3-4CFF-8A22-41B16D66A972'");
|
||||
|
||||
private void setupNode(IContent content)
|
||||
{
|
||||
_content = content;
|
||||
Content = content;
|
||||
//Setting private properties from IContent replacing CMSNode.setupNode() / CMSNode.PopulateCMSNodeFromReader()
|
||||
base.PopulateCMSNodeFromContent(_content, _objectType);
|
||||
base.PopulateCMSNodeFromContent(Content, _objectType);
|
||||
|
||||
//If the version is empty we update with the latest version from the current IContent.
|
||||
if (Version == Guid.Empty)
|
||||
Version = _content.Version;
|
||||
Version = Content.Version;
|
||||
|
||||
//Setting private properties from IContent replacing Document.setupNode()
|
||||
_creator = User.GetUser(_content.CreatorId);
|
||||
_writer = User.GetUser(_content.WriterId);
|
||||
_updated = _content.UpdateDate;
|
||||
_creator = User.GetUser(Content.CreatorId);
|
||||
_writer = User.GetUser(Content.WriterId);
|
||||
_updated = Content.UpdateDate;
|
||||
|
||||
if (_content.Template != null)
|
||||
_template = _content.Template.Id;
|
||||
if (Content.Template != null)
|
||||
_template = Content.Template.Id;
|
||||
|
||||
if (_content.ExpireDate.HasValue)
|
||||
_expire = _content.ExpireDate.Value;
|
||||
if (Content.ExpireDate.HasValue)
|
||||
_expire = Content.ExpireDate.Value;
|
||||
|
||||
if (_content.ReleaseDate.HasValue)
|
||||
_release = _content.ReleaseDate.Value;
|
||||
if (Content.ReleaseDate.HasValue)
|
||||
_release = Content.ReleaseDate.Value;
|
||||
|
||||
_published = _content.HasPublishedVersion();
|
||||
_published = Content.HasPublishedVersion();
|
||||
}
|
||||
|
||||
[Obsolete("Deprecated", false)]
|
||||
@@ -1574,14 +1574,14 @@ and node.nodeObjectType='C66BA18E-EAF3-4CFF-8A22-41B16D66A972'");
|
||||
if (!e.Cancel)
|
||||
{
|
||||
umbraco.BusinessLogic.Actions.Action.RunActionHandlers(this, ActionDelete.Instance);
|
||||
if (_content != null)
|
||||
if (Content != null)
|
||||
{
|
||||
ServiceContext.Current.ContentService.Delete(_content);
|
||||
ServiceContext.Current.ContentService.Delete(Content);
|
||||
}
|
||||
else
|
||||
{
|
||||
_content = ServiceContext.Current.ContentService.GetById(Id);
|
||||
ServiceContext.Current.ContentService.Delete(_content);
|
||||
Content = ServiceContext.Current.ContentService.GetById(Id);
|
||||
ServiceContext.Current.ContentService.Delete(Content);
|
||||
}
|
||||
|
||||
//Keeping the base.delete() as it looks to be clear 'private/internal cache'
|
||||
@@ -1606,14 +1606,14 @@ and node.nodeObjectType='C66BA18E-EAF3-4CFF-8A22-41B16D66A972'");
|
||||
{
|
||||
umbraco.BusinessLogic.Actions.Action.RunActionHandlers(this, ActionDelete.Instance);
|
||||
UnPublish();
|
||||
if (_content != null)
|
||||
if (Content != null)
|
||||
{
|
||||
ServiceContext.Current.ContentService.MoveToRecycleBin(_content);
|
||||
ServiceContext.Current.ContentService.MoveToRecycleBin(Content);
|
||||
}
|
||||
else
|
||||
{
|
||||
_content = ServiceContext.Current.ContentService.GetById(Id);
|
||||
ServiceContext.Current.ContentService.MoveToRecycleBin(_content);
|
||||
Content = ServiceContext.Current.ContentService.GetById(Id);
|
||||
ServiceContext.Current.ContentService.MoveToRecycleBin(Content);
|
||||
}
|
||||
FireAfterMoveToTrash(e);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user