diff --git a/components/umbraco.controls/feedback.cs b/components/umbraco.controls/feedback.cs index 9e3c1b2c24..df1e54036f 100644 --- a/components/umbraco.controls/feedback.cs +++ b/components/umbraco.controls/feedback.cs @@ -1,9 +1,13 @@ using System; using System.Collections.Generic; using System.Text; +using ClientDependency.Core; namespace umbraco.uicontrols { - public class Feedback : System.Web.UI.WebControls.Panel { + + [ClientDependency(ClientDependencyType.Css, "ui/default.css", "UmbracoClient")] + public class Feedback : System.Web.UI.WebControls.Panel + { public Feedback() { @@ -15,9 +19,6 @@ namespace umbraco.uicontrols { protected override void OnLoad(System.EventArgs EventArguments) { } - private bool _hasMenu = false; - private string _StatusBarText = ""; - public feedbacktype type { get; set; } private string _text = string.Empty; diff --git a/umbraco/businesslogic/BasePages/BasePage.cs b/umbraco/businesslogic/BasePages/BasePage.cs index a17ce33609..570bd8cfbf 100644 --- a/umbraco/businesslogic/BasePages/BasePage.cs +++ b/umbraco/businesslogic/BasePages/BasePage.cs @@ -1,10 +1,11 @@ using System; using System.Data; using System.Web; - +using System.Linq; using umbraco.BusinessLogic; using umbraco.DataLayer; using umbraco.IO; +using System.Web.UI; namespace umbraco.BasePages { /// diff --git a/umbraco/businesslogic/BasePages/UmbracoBasePage.cs b/umbraco/businesslogic/BasePages/UmbracoEnsuredPage.cs similarity index 100% rename from umbraco/businesslogic/BasePages/UmbracoBasePage.cs rename to umbraco/businesslogic/BasePages/UmbracoEnsuredPage.cs diff --git a/umbraco/businesslogic/umbraco.businesslogic.csproj b/umbraco/businesslogic/umbraco.businesslogic.csproj index b0f7ba93ed..dc7e96142e 100644 --- a/umbraco/businesslogic/umbraco.businesslogic.csproj +++ b/umbraco/businesslogic/umbraco.businesslogic.csproj @@ -136,7 +136,7 @@ ASPXCodeBehind - + ASPXCodeBehind diff --git a/umbraco/cms/businesslogic/web/Document.cs b/umbraco/cms/businesslogic/web/Document.cs index 7224a7d387..40db4baf10 100644 --- a/umbraco/cms/businesslogic/web/Document.cs +++ b/umbraco/cms/businesslogic/web/Document.cs @@ -28,6 +28,7 @@ namespace umbraco.cms.businesslogic.web /// public class Document : Content { + #region Constants private const string m_SQLOptimizedSingle = @" Select (select count(id) from umbracoNode where parentId = @id) as Children, @@ -35,7 +36,7 @@ namespace umbraco.cms.businesslogic.web cmsContentVersion.VersionId, cmsContentVersion.versionDate, contentTypeNode.uniqueId as ContentTypeGuid, - cmsContent.ContentType, cmsContentType.icon, cmsContentType.alias, cmsContentType.thumbnail, cmsContentType.description, cmsContentType.masterContentType, cmsContentType.nodeId as contentTypeId + cmsContent.ContentType, cmsContentType.icon, cmsContentType.alias, cmsContentType.thumbnail, cmsContentType.description, cmsContentType.masterContentType, cmsContentType.nodeId as contentTypeId, published, documentUser, coalesce(templateId, cmsDocumentType.templateNodeId) as templateId, cmsDocument.text as DocumentText, releaseDate, expireDate, updateDate, umbracoNode.createDate, umbracoNode.trashed, umbracoNode.parentId, umbracoNode.nodeObjectType, umbracoNode.nodeUser, umbracoNode.level, umbracoNode.path, umbracoNode.sortOrder, umbracoNode.uniqueId, umbracoNode.text from @@ -84,8 +85,10 @@ namespace umbraco.cms.businesslogic.web inner join cmsPreviewXml on cmsPreviewXml.nodeId = cmsDocument.nodeId and cmsPreviewXml.versionId = cmsDocument.versionId where newest = 1 and trashed = 0 and path like '{0}' order by level,sortOrder - "; + "; + #endregion + #region Private properties public static Guid _objectType = new Guid("c66ba18e-eaf3-4cff-8a22-41b16d66a972"); private DateTime _updated; private DateTime _release; @@ -109,6 +112,51 @@ namespace umbraco.cms.businesslogic.web // special for tree performance private int _userId = -1; + private Dictionary _knownProperties = new Dictionary(); + private Func, string, bool> propertyTypeByAlias = (pt, alias) => pt.Key.PropertyType.Alias == alias; + #endregion + + /// + /// Indexed property to return the property value by name + /// + /// + /// + public object this[string alias] + { + get + { + if (this._optimizedMode) + { + return this._knownProperties.Single(p => propertyTypeByAlias(p, alias)).Value; + } + else + { + return this.getProperty(alias).Value; + } + } + set + { + if (this._optimizedMode) + { + if (this._knownProperties.SingleOrDefault(p => propertyTypeByAlias(p, alias)).Key == null) + { + var pt = this.getProperty(alias); + + this._knownProperties.Add(pt, pt.Value); + } + else + { + var pt = this._knownProperties.Single(p => propertyTypeByAlias(p, alias)).Key; + this._knownProperties[pt] = value; + } + } + else + { + this.getProperty(alias).Value = value; + } + } + } + /// /// Gets a value indicating whether the document was constructed for the optimized mode /// @@ -451,9 +499,9 @@ namespace umbraco.cms.businesslogic.web public Document(bool optimizedMode, int id) : base(id, optimizedMode) { - this._optimizedMode = OptimizedMode; + this._optimizedMode = optimizedMode; - if (OptimizedMode) + if (optimizedMode) { using (IRecordsReader dr = @@ -522,7 +570,7 @@ namespace umbraco.cms.businesslogic.web } /// - /// Used to persist object changes to the database. In Version3.0 it's just a stub for future compatibility + /// Used to persist object changes to the database. /// public override void Save() { @@ -1750,47 +1798,7 @@ namespace umbraco.cms.businesslogic.web AfterRollBack(this, e); } - private Dictionary _knownProperties; - private Func, string, bool> propertyTypeByAlias = (pt, alias) => pt.Key.PropertyType.Alias == alias; - public object this[string alias] - { - get - { - if (this._optimizedMode) - { - if (this._knownProperties == null) this._knownProperties = new Dictionary(); - - return this._knownProperties.Single(p => propertyTypeByAlias(p, alias)).Value; - } - else - { - return this.getProperty(alias).Value; - } - } - set - { - if (this._optimizedMode) - { - if (this._knownProperties == null) this._knownProperties = new Dictionary(); - - if (this._knownProperties.SingleOrDefault(p => propertyTypeByAlias(p, alias)).Key == null) - { - var pt = this.getProperty(alias); - - this._knownProperties.Add(pt, pt.Value); - } - else - { - var pt = this._knownProperties.Single(p => propertyTypeByAlias(p, alias)).Key; - this._knownProperties[pt] = value; - } - } - else - { - this.getProperty(alias).Value = value; - } - } - } + } /// diff --git a/umbraco/presentation/BasePageExtensions.cs b/umbraco/presentation/BasePageExtensions.cs new file mode 100644 index 0000000000..ff91659f33 --- /dev/null +++ b/umbraco/presentation/BasePageExtensions.cs @@ -0,0 +1,60 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using umbraco.BasePages; +using umbraco.uicontrols; +using System.Web.UI; +using System.Web.UI.WebControls; +using System.Web.UI.HtmlControls; +using ClientDependency.Core; + +namespace umbraco.presentation +{ + /// + /// Extension methods for the Umbraco BasePage + /// + public static class BasePageExtensions + { + + /// + /// Used to display an error message to the user and disable further execution. + /// This will remove all controls from being rendered and show a feedback control with an error + /// + /// + public static void DisplayFatalError(this BasePage page, string msg) + { + foreach (var ctl in page.Controls.Cast()) + { + if (!HideControls(ctl)) + { + var ctls = ctl.FlattenChildren(); + foreach (var c in ctls) + { + HideControls(c); + } + } + } + var feedback = new Feedback(); + feedback.type = Feedback.feedbacktype.error; + feedback.Text = string.Format("{0}

{1}", ui.GetText("error"), msg); + page.Controls.Add(feedback); + } + + private static bool HideControls(this Control c) + { + if (c is MasterPage) + { + return false; + } + else if (c is UserControl || c is WebControl || c is HtmlForm) + { + c.Visible = false; + return true; + } + return false; + + } + + } +} diff --git a/umbraco/presentation/config/ClientDependency.config b/umbraco/presentation/config/ClientDependency.config index 2f2ce11aa4..4da6c4c0ae 100644 --- a/umbraco/presentation/config/ClientDependency.config +++ b/umbraco/presentation/config/ClientDependency.config @@ -10,7 +10,7 @@ NOTES: * Compression/Combination/Minification is not enabled unless debug="false" is specified on the 'compiliation' element in the web.config * A new version will invalidate both client and server cache and create new persisted files --> - + diff --git a/umbraco/presentation/umbraco.presentation.csproj b/umbraco/presentation/umbraco.presentation.csproj index a2fb73897d..0a60877bbb 100644 --- a/umbraco/presentation/umbraco.presentation.csproj +++ b/umbraco/presentation/umbraco.presentation.csproj @@ -199,6 +199,7 @@ Code + ASPXCodeBehind booting.aspx diff --git a/umbraco/presentation/umbraco/editContent.aspx.cs b/umbraco/presentation/umbraco/editContent.aspx.cs index 2f5ff11202..c5f16bd291 100644 --- a/umbraco/presentation/umbraco/editContent.aspx.cs +++ b/umbraco/presentation/umbraco/editContent.aspx.cs @@ -16,7 +16,8 @@ using umbraco.IO; using umbraco.uicontrols.DatePicker; using umbraco.BusinessLogic; using umbraco.presentation.preview; - +using umbraco.cms.businesslogic.web; +using umbraco.presentation; namespace umbraco.cms.presentation { @@ -25,20 +26,11 @@ namespace umbraco.cms.presentation protected uicontrols.TabView TabView1; protected System.Web.UI.WebControls.TextBox documentName; private cms.businesslogic.web.Document _document; - protected System.Web.UI.WebControls.Literal jsIds; - - /* - private controls.datePicker dp = new controls.datePicker(); - private controls.datePicker dpRelease = new controls.datePicker(); - private controls.datePicker dpExpire = new controls.datePicker(); - */ - + protected System.Web.UI.WebControls.Literal jsIds; private LiteralControl dp = new LiteralControl(); private DateTimePicker dpRelease = new DateTimePicker(); private DateTimePicker dpExpire = new DateTimePicker(); - //private bool _refreshTree = false; - controls.ContentControl tmp; DropDownList ddlDefaultTemplate = new DropDownList(); @@ -51,13 +43,150 @@ namespace umbraco.cms.presentation private Literal l = new Literal(); private Literal domainText = new Literal(); - - //protected System.Web.UI.WebControls.Literal SyncPath; - private controls.ContentControl.publishModes _canPublish = controls.ContentControl.publishModes.Publish; + private int? m_ContentId = null; + + override protected void OnInit(EventArgs e) + { + base.OnInit(e); + + //validate! + int id; + if (!int.TryParse(Request.QueryString["id"], out id)) + { + //if this is invalid show an error + this.DisplayFatalError("Invalid query string"); + return; + } + m_ContentId = id; + + + this.UnPublish.Click += new System.EventHandler(this.UnPublishDo); + + //_document = new cms.businesslogic.web.Document(int.Parse(Request.QueryString["id"])); + _document = new Document(true, id); + + // Check publishing permissions + if (!base.getUser().GetPermissions(_document.Path).Contains(ActionPublish.Instance.Letter.ToString())) + _canPublish = controls.ContentControl.publishModes.SendToPublish; + tmp = new controls.ContentControl(_document, _canPublish, "TabView1"); + + tmp.ID = "TabView1"; + + tmp.Width = Unit.Pixel(666); + tmp.Height = Unit.Pixel(666); + + // Add preview button + + foreach (uicontrols.TabPage tp in tmp.GetPanels()) + { + addPreviewButton(tp.Menu, _document.Id); + } + + plc.Controls.Add(tmp); + + + System.Web.UI.WebControls.PlaceHolder publishStatus = new PlaceHolder(); + if (_document.Published) + { + littPublishStatus.Text = ui.Text("content", "lastPublished", base.getUser()) + ": " + _document.VersionDate.ToShortDateString() + "   "; + + publishStatus.Controls.Add(littPublishStatus); + if (base.getUser().GetPermissions(_document.Path).IndexOf("U") > -1) + UnPublish.Visible = true; + else + UnPublish.Visible = false; + } + else + { + littPublishStatus.Text = ui.Text("content", "itemNotPublished", base.getUser()); + publishStatus.Controls.Add(littPublishStatus); + UnPublish.Visible = false; + } + + UnPublish.Text = ui.Text("content", "unPublish", base.getUser()); + UnPublish.ID = "UnPublishButton"; + UnPublish.Attributes.Add("onClick", "if (!confirm('" + ui.Text("defaultdialogs", "confirmSure", base.getUser()) + "')) return false; "); + publishStatus.Controls.Add(UnPublish); + + publishProps.addProperty(ui.Text("content", "publishStatus", base.getUser()), publishStatus); + + // Template + PlaceHolder template = new PlaceHolder(); + cms.businesslogic.web.DocumentType DocumentType = new cms.businesslogic.web.DocumentType(_document.ContentType.Id); + tmp.PropertiesPane.addProperty(ui.Text("documentType"), new LiteralControl(DocumentType.Text)); + tmp.PropertiesPane.addProperty(ui.Text("template"), template); + + int defaultTemplate; + if (_document.Template != 0) + defaultTemplate = _document.Template; + else + defaultTemplate = DocumentType.DefaultTemplate; + + if (this.getUser().UserType.Name == "writer") + { + if (defaultTemplate != 0) + template.Controls.Add(new LiteralControl(cms.businesslogic.template.Template.GetTemplate(defaultTemplate).Text)); + else + template.Controls.Add(new LiteralControl(ui.Text("content", "noDefaultTemplate"))); + } + else + { + ddlDefaultTemplate.Items.Add(new ListItem(ui.Text("choose") + "...", "")); + foreach (cms.businesslogic.template.Template t in DocumentType.allowedTemplates) + { + ListItem tTemp = new ListItem(t.Text, t.Id.ToString()); + if (t.Id == defaultTemplate) + tTemp.Selected = true; + ddlDefaultTemplate.Items.Add(tTemp); + } + template.Controls.Add(ddlDefaultTemplate); + } + + + // Editable update date, release date and expire date added by NH 13.12.04 + dp.ID = "updateDate"; + dp.Text = _document.UpdateDate.ToShortDateString() + " " + _document.UpdateDate.ToShortTimeString(); + publishProps.addProperty(ui.Text("content", "updateDate", base.getUser()), dp); + + dpRelease.ID = "releaseDate"; + dpRelease.DateTime = _document.ReleaseDate; + dpRelease.ShowTime = true; + publishProps.addProperty(ui.Text("content", "releaseDate", base.getUser()), dpRelease); + + dpExpire.ID = "expireDate"; + dpExpire.DateTime = _document.ExpireDate; + dpExpire.ShowTime = true; + publishProps.addProperty(ui.Text("content", "expireDate", base.getUser()), dpExpire); + + // url's + updateLinks(); + linkProps.addProperty(ui.Text("content", "urls", base.getUser()), l); + + if (domainText.Text != "") + linkProps.addProperty(ui.Text("content", "alternativeUrls", base.getUser()), domainText); + + tmp.Save += new System.EventHandler(Save); + tmp.SaveAndPublish += new System.EventHandler(Publish); + tmp.SaveToPublish += new System.EventHandler(SendToPublish); + + // Add panes to property page... + tmp.tpProp.Controls.Add(publishProps); + tmp.tpProp.Controls.Add(linkProps); + + // add preview to properties pane too + addPreviewButton(tmp.tpProp.Menu, _document.Id); + + + + } + protected void Page_Load(object sender, System.EventArgs e) { + if (!m_ContentId.HasValue) + return; + if (!CheckUserValidation()) return; @@ -191,7 +320,7 @@ namespace umbraco.cms.presentation //newPublishStatus.Text = "0"; - } + } private void updateLinks() { @@ -307,129 +436,6 @@ namespace umbraco.cms.presentation } } - #region Web Form Designer generated code - override protected void OnInit(EventArgs e) - { - base.OnInit(e); - - this.UnPublish.Click += new System.EventHandler(this.UnPublishDo); - - _document = new cms.businesslogic.web.Document(int.Parse(Request.QueryString["id"])); - - // Check publishing permissions - if (!base.getUser().GetPermissions(_document.Path).Contains(ActionPublish.Instance.Letter.ToString())) - _canPublish = controls.ContentControl.publishModes.SendToPublish; - tmp = new controls.ContentControl(_document, _canPublish, "TabView1"); - - tmp.ID = "TabView1"; - - tmp.Width = Unit.Pixel(666); - tmp.Height = Unit.Pixel(666); - - // Add preview button - - foreach (uicontrols.TabPage tp in tmp.GetPanels()) - { - addPreviewButton(tp.Menu, _document.Id); - } - - plc.Controls.Add(tmp); - - - System.Web.UI.WebControls.PlaceHolder publishStatus = new PlaceHolder(); - if (_document.Published) - { - littPublishStatus.Text = ui.Text("content", "lastPublished", base.getUser()) + ": " + _document.VersionDate.ToShortDateString() + "   "; - - publishStatus.Controls.Add(littPublishStatus); - if (base.getUser().GetPermissions(_document.Path).IndexOf("U") > -1) - UnPublish.Visible = true; - else - UnPublish.Visible = false; - } - else - { - littPublishStatus.Text = ui.Text("content", "itemNotPublished", base.getUser()); - publishStatus.Controls.Add(littPublishStatus); - UnPublish.Visible = false; - } - - UnPublish.Text = ui.Text("content", "unPublish", base.getUser()); - UnPublish.ID = "UnPublishButton"; - UnPublish.Attributes.Add("onClick", "if (!confirm('" + ui.Text("defaultdialogs", "confirmSure", base.getUser()) + "')) return false; "); - publishStatus.Controls.Add(UnPublish); - - publishProps.addProperty(ui.Text("content", "publishStatus", base.getUser()), publishStatus); - - // Template - PlaceHolder template = new PlaceHolder(); - cms.businesslogic.web.DocumentType DocumentType = new cms.businesslogic.web.DocumentType(_document.ContentType.Id); - tmp.PropertiesPane.addProperty(ui.Text("documentType"), new LiteralControl(DocumentType.Text)); - tmp.PropertiesPane.addProperty(ui.Text("template"), template); - - int defaultTemplate; - if (_document.Template != 0) - defaultTemplate = _document.Template; - else - defaultTemplate = DocumentType.DefaultTemplate; - - if (this.getUser().UserType.Name == "writer") - { - if (defaultTemplate != 0) - template.Controls.Add(new LiteralControl(cms.businesslogic.template.Template.GetTemplate(defaultTemplate).Text)); - else - template.Controls.Add(new LiteralControl(ui.Text("content", "noDefaultTemplate"))); - } - else - { - ddlDefaultTemplate.Items.Add(new ListItem(ui.Text("choose") + "...", "")); - foreach (cms.businesslogic.template.Template t in DocumentType.allowedTemplates) - { - ListItem tTemp = new ListItem(t.Text, t.Id.ToString()); - if (t.Id == defaultTemplate) - tTemp.Selected = true; - ddlDefaultTemplate.Items.Add(tTemp); - } - template.Controls.Add(ddlDefaultTemplate); - } - - - // Editable update date, release date and expire date added by NH 13.12.04 - dp.ID = "updateDate"; - dp.Text = _document.UpdateDate.ToShortDateString() + " " + _document.UpdateDate.ToShortTimeString(); - publishProps.addProperty(ui.Text("content", "updateDate", base.getUser()), dp); - - dpRelease.ID = "releaseDate"; - dpRelease.DateTime = _document.ReleaseDate; - dpRelease.ShowTime = true; - publishProps.addProperty(ui.Text("content", "releaseDate", base.getUser()), dpRelease); - - dpExpire.ID = "expireDate"; - dpExpire.DateTime = _document.ExpireDate; - dpExpire.ShowTime = true; - publishProps.addProperty(ui.Text("content", "expireDate", base.getUser()), dpExpire); - - // url's - updateLinks(); - linkProps.addProperty(ui.Text("content", "urls", base.getUser()), l); - - if (domainText.Text != "") - linkProps.addProperty(ui.Text("content", "alternativeUrls", base.getUser()), domainText); - - tmp.Save += new System.EventHandler(Save); - tmp.SaveAndPublish += new System.EventHandler(Publish); - tmp.SaveToPublish += new System.EventHandler(SendToPublish); - - // Add panes to property page... - tmp.tpProp.Controls.Add(publishProps); - tmp.tpProp.Controls.Add(linkProps); - - // add preview to properties pane too - addPreviewButton(tmp.tpProp.Menu, _document.Id); - - - - } private void addPreviewButton(uicontrols.ScrollingMenu menu, int id) { @@ -440,7 +446,5 @@ namespace umbraco.cms.presentation menuItem.ImageURL = SystemDirectories.Umbraco + "/images/editor/vis.gif"; } - - #endregion } } diff --git a/umbraco/presentation/umbraco_client/Application/UmbracoClientManager.js b/umbraco/presentation/umbraco_client/Application/UmbracoClientManager.js index c378b39601..1dc064f721 100644 --- a/umbraco/presentation/umbraco_client/Application/UmbracoClientManager.js +++ b/umbraco/presentation/umbraco_client/Application/UmbracoClientManager.js @@ -55,7 +55,13 @@ Umbraco.Sys.registerNamespace("Umbraco.Application"); if (this.mainWindow().jQuery == null || this.mainWindow().jQuery(".umbTree").length == 0 || this.mainWindow().jQuery(".umbTree").UmbracoTreeAPI() == null) { - this._mainTree = null; + //creates a false tree with all the public tree params set to a false method. + var tmpTree = {}; + var treeProps = ["init", "setRecycleBinNodeId", "clearTreeCache", "toggleEditMode", "refreshTree", "rebuildTree", "saveTreeState", "syncTree", "childNodeCreated", "moveNode", "copyNode", "findNode", "selectNode", "reloadActionNode", "getActionNode", "setActiveTreeType", "getNodeDef"]; + for (var p in treeProps) { + tmpTree[treeProps[p]] = function() { return false; }; + } + this._mainTree = tmpTree; } else { this._mainTree = this.mainWindow().jQuery(".umbTree").UmbracoTreeAPI();