diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/controls/ContentControl.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/controls/ContentControl.cs index ccc43040aa..25cca7c1f4 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/controls/ContentControl.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/controls/ContentControl.cs @@ -3,10 +3,10 @@ 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.Core.IO; using umbraco.BasePages; using umbraco.cms.businesslogic; using umbraco.cms.businesslogic.datatype.controls; @@ -16,8 +16,8 @@ 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 System.Linq; using SystemDirectories = umbraco.IO.SystemDirectories; namespace umbraco.controls diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/editMedia.aspx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/editMedia.aspx.cs index 0c820a3cd5..5fce0bd039 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/editMedia.aspx.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/editMedia.aspx.cs @@ -19,6 +19,10 @@ namespace umbraco.cms.presentation /// public partial class editMedia : BasePages.UmbracoEnsuredPage { + private uicontrols.Pane mediaPropertyPane = new uicontrols.Pane(); + private LiteralControl updateDateLiteral = new LiteralControl(); + + public editMedia() { CurrentApp = BusinessLogic.DefaultApps.media.ToString(); @@ -29,7 +33,51 @@ namespace umbraco.cms.presentation controls.ContentControl tmp; //protected System.Web.UI.WebControls.Literal SyncPath; - + + override protected void OnInit(EventArgs e) + { + // + // CODEGEN: This call is required by the ASP.NET Web Form Designer. + // + InitializeComponent(); + base.OnInit(e); + + _media = new cms.businesslogic.media.Media(int.Parse(Request.QueryString["id"])); + + // Save media on first load + bool exists = SqlHelper.ExecuteScalar("SELECT COUNT(nodeId) FROM cmsContentXml WHERE nodeId = @nodeId", + SqlHelper.CreateParameter("@nodeId", _media.Id)) > 0; + if (!exists) + _media.XmlGenerate(new XmlDocument()); + + + tmp = new controls.ContentControl(_media, controls.ContentControl.publishModes.NoPublish, "TabView1"); + tmp.Width = Unit.Pixel(666); + tmp.Height = Unit.Pixel(666); + plc.Controls.Add(tmp); + + tmp.Save += new System.EventHandler(Save); + + updateDateLiteral.ID = "updateDate"; + updateDateLiteral.Text = _media.VersionDate.ToShortDateString() + " " + _media.VersionDate.ToShortTimeString(); + + mediaPropertyPane.addProperty(ui.Text("content", "updateDate", base.getUser()), updateDateLiteral); + + // TODO: move the LinkToMediaItem property here - that way it's updated after save, rather than relying on a reload + + // add the property pane to the page rendering + tmp.tpProp.Controls.AddAt(1, mediaPropertyPane); + } + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + + } + protected void Page_Load(object sender, System.EventArgs e) { //if (!IsPostBack) @@ -64,44 +112,11 @@ namespace umbraco.cms.presentation } } _media.Save(); + + this.updateDateLiteral.Text = _media.VersionDate.ToShortDateString() + " " + _media.VersionDate.ToShortTimeString(); + _media.XmlGenerate(new XmlDocument()); ClientTools.SyncTree(_media.Path, true); } - - #region Web Form Designer generated code - override protected void OnInit(EventArgs e) - { - // - // CODEGEN: This call is required by the ASP.NET Web Form Designer. - // - InitializeComponent(); - base.OnInit(e); - - _media = new cms.businesslogic.media.Media(int.Parse(Request.QueryString["id"])); - - // Save media on first load - bool exists = SqlHelper.ExecuteScalar("SELECT COUNT(nodeId) FROM cmsContentXml WHERE nodeId = @nodeId", - SqlHelper.CreateParameter("@nodeId", _media.Id)) > 0; - if (!exists) - _media.XmlGenerate(new XmlDocument()); - - - tmp = new controls.ContentControl(_media,controls.ContentControl.publishModes.NoPublish, "TabView1"); - tmp.Width = Unit.Pixel(666); - tmp.Height = Unit.Pixel(666); - plc.Controls.Add(tmp); - - tmp.Save += new System.EventHandler(Save); - } - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - - } - #endregion } } diff --git a/src/umbraco.cms/businesslogic/Content.cs b/src/umbraco.cms/businesslogic/Content.cs index 90b4c35caa..1a5d228760 100644 --- a/src/umbraco.cms/businesslogic/Content.cs +++ b/src/umbraco.cms/businesslogic/Content.cs @@ -160,15 +160,32 @@ namespace umbraco.cms.businesslogic { if (!_versionDateInitialized) { - object o = SqlHelper.ExecuteScalar( - "select VersionDate from cmsContentVersion where versionId = '" + this.Version.ToString() + "'"); - if (o == null) + // A Media item only contains a single version (which relates to it's creation) so get this value from the media xml fragment instead + if (this is media.Media) { - _versionDate = DateTime.Now; + // get the xml fragment from cmsXmlContent + string xmlFragment = SqlHelper.ExecuteScalar(@"SELECT [xml] FROM cmsContentXml WHERE nodeId = " + this.Id); + if (!string.IsNullOrWhiteSpace(xmlFragment)) + { + XmlDocument xmlDocument = new XmlDocument(); + xmlDocument.LoadXml(xmlFragment); + + _versionDateInitialized = DateTime.TryParse(xmlDocument.SelectSingleNode("//*[1]").Attributes["updateDate"].Value, out _versionDate); + } } - else + + if (!_versionDateInitialized) { - _versionDateInitialized = DateTime.TryParse(o.ToString(), out _versionDate); + object o = SqlHelper.ExecuteScalar( + "select VersionDate from cmsContentVersion where versionId = '" + this.Version.ToString() + "'"); + if (o == null) + { + _versionDate = DateTime.Now; + } + else + { + _versionDateInitialized = DateTime.TryParse(o.ToString(), out _versionDate); + } } } return _versionDate;