From 2e9a52b1f8bd2f6deea03ea1268dac18dabd94d9 Mon Sep 17 00:00:00 2001
From: Shannon Deminick
Date: Wed, 10 Apr 2013 00:56:43 +0600
Subject: [PATCH 01/29] Fixes: #U4-2075
---
.../developer/Packages/installer.aspx.cs | 27 +++++++------------
1 file changed, 10 insertions(+), 17 deletions(-)
diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/developer/Packages/installer.aspx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/developer/Packages/installer.aspx.cs
index 20526f6f20..ed5e1a323c 100644
--- a/src/Umbraco.Web/umbraco.presentation/umbraco/developer/Packages/installer.aspx.cs
+++ b/src/Umbraco.Web/umbraco.presentation/umbraco/developer/Packages/installer.aspx.cs
@@ -11,8 +11,9 @@ using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Xml;
using System.Xml.XPath;
+using Umbraco.Core.IO;
using umbraco.BasePages;
-using umbraco.IO;
+using umbraco.BusinessLogic;
using umbraco.cms.presentation.Trees;
using BizLogicAction = umbraco.BusinessLogic.Actions.Action;
@@ -21,16 +22,21 @@ namespace umbraco.presentation.developer.packages
///
/// Summary description for packager.
///
- public partial class Installer : BasePages.UmbracoEnsuredPage
+ public partial class Installer : UmbracoEnsuredPage
{
+ public Installer()
+ {
+ CurrentApp = DefaultApps.developer.ToString();
+ }
+
private Control _configControl;
private cms.businesslogic.packager.repositories.Repository _repo;
private readonly cms.businesslogic.packager.Installer _installer = new cms.businesslogic.packager.Installer();
private string _tempFileName = "";
- protected void Page_Load(object sender, System.EventArgs e)
+ protected void Page_Load(object sender, EventArgs e)
{
- Exception ex = new Exception();
+ var ex = new Exception();
if (!cms.businesslogic.packager.Settings.HasFileAccess(ref ex))
{
fb.Style.Add("margin-top", "7px");
@@ -285,19 +291,6 @@ namespace umbraco.presentation.developer.packages
Response.Redirect("installer.aspx?installing=businesslogic&dir=" + tempFile.Value + "&pId=" + pId.ToString());
}
-
- private void DrawConfig()
- {
- HideAllPanes();
-
- _configControl = new System.Web.UI.UserControl().LoadControl(SystemDirectories.Root + helper.Request("config"));
- _configControl.ID = "packagerConfigControl";
-
- pane_optional.Controls.Add(_configControl);
- pane_optional.Visible = true;
- }
-
-
private void HideAllPanes()
{
pane_authenticate.Visible = false;
From 0430e7966cfc30b5b4f56f582666424143b8de1d Mon Sep 17 00:00:00 2001
From: Shannon Deminick
Date: Wed, 10 Apr 2013 01:24:06 +0600
Subject: [PATCH 02/29] Fixes: #U4-2074 and cleans up a bit of code
---
.../Packages/installedPackage.aspx.cs | 402 ++++++++----------
1 file changed, 181 insertions(+), 221 deletions(-)
diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/developer/Packages/installedPackage.aspx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/developer/Packages/installedPackage.aspx.cs
index 9b782673c3..7967a7b561 100644
--- a/src/Umbraco.Web/umbraco.presentation/umbraco/developer/Packages/installedPackage.aspx.cs
+++ b/src/Umbraco.Web/umbraco.presentation/umbraco/developer/Packages/installedPackage.aspx.cs
@@ -3,20 +3,21 @@ using System.Data;
using System.Configuration;
using System.Collections;
using System.Collections.Generic;
-
+using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
-
+using Umbraco.Core.IO;
+using Umbraco.Core.Logging;
+using umbraco.BusinessLogic;
using umbraco.cms.businesslogic.template;
using umbraco.cms.businesslogic.web;
using umbraco.cms.businesslogic.macro;
using runtimeMacro = umbraco.macro;
using System.Xml;
-using umbraco.IO;
using umbraco.cms.presentation.Trees;
using BizLogicAction = umbraco.BusinessLogic.Actions.Action;
@@ -24,20 +25,25 @@ namespace umbraco.presentation.developer.packages
{
public partial class installedPackage : BasePages.UmbracoEnsuredPage
{
- private cms.businesslogic.packager.InstalledPackage pack;
- private cms.businesslogic.packager.repositories.Repository repo = new global::umbraco.cms.businesslogic.packager.repositories.Repository();
+ public installedPackage()
+ {
+ CurrentApp = DefaultApps.developer.ToString();
+ }
+
+ private cms.businesslogic.packager.InstalledPackage _pack;
+ private cms.businesslogic.packager.repositories.Repository _repo = new cms.businesslogic.packager.repositories.Repository();
protected void Page_Load(object sender, EventArgs e)
{
if (Request.QueryString["id"] != null)
{
- pack = cms.businesslogic.packager.InstalledPackage.GetById(int.Parse(Request.QueryString["id"]));
+ _pack = cms.businesslogic.packager.InstalledPackage.GetById(int.Parse(Request.QueryString["id"]));
- lt_packagename.Text = pack.Data.Name;
- lt_packageVersion.Text = pack.Data.Version;
- lt_packageAuthor.Text = pack.Data.Author;
- lt_readme.Text = library.ReplaceLineBreaks( pack.Data.Readme );
+ lt_packagename.Text = _pack.Data.Name;
+ lt_packageVersion.Text = _pack.Data.Version;
+ lt_packageAuthor.Text = _pack.Data.Author;
+ lt_readme.Text = library.ReplaceLineBreaks( _pack.Data.Readme );
bt_confirmUninstall.Attributes.Add("onClick", "jQuery('#buttons').hide(); jQuery('#loadingbar').show();; return true;");
@@ -45,26 +51,19 @@ namespace umbraco.presentation.developer.packages
if (!Page.IsPostBack)
{
//temp list to contain failing items...
- List tempList = new List();
+ var tempList = new List();
- foreach (string str in pack.Data.Documenttypes)
+ foreach (var str in _pack.Data.Documenttypes)
{
- int tId = 0;
+ var tId = 0;
if (int.TryParse(str, out tId))
{
try
{
- DocumentType dc = new DocumentType(tId);
- if (dc != null)
- {
- ListItem li = new ListItem(dc.Text, dc.Id.ToString());
- li.Selected = true;
- documentTypes.Items.Add(li);
- }
- else
- {
- tempList.Add(str);
- }
+ var dc = new DocumentType(tId);
+ var li = new ListItem(dc.Text, dc.Id.ToString());
+ li.Selected = true;
+ documentTypes.Items.Add(li);
}
catch
{
@@ -73,27 +72,20 @@ namespace umbraco.presentation.developer.packages
}
}
//removing failing documentTypes items from the uninstall manifest
- syncLists(pack.Data.Documenttypes, tempList);
+ SyncLists(_pack.Data.Documenttypes, tempList);
- foreach (string str in pack.Data.Templates)
+ foreach (var str in _pack.Data.Templates)
{
- int tId = 0;
+ var tId = 0;
if (int.TryParse(str, out tId))
{
try
{
- Template t = new Template(tId);
- if (t != null)
- {
- ListItem li = new ListItem(t.Text, t.Id.ToString());
- li.Selected = true;
- templates.Items.Add(li);
- }
- else
- {
- tempList.Add(str);
- }
+ var t = new Template(tId);
+ var li = new ListItem(t.Text, t.Id.ToString());
+ li.Selected = true;
+ templates.Items.Add(li);
}
catch
{
@@ -102,26 +94,19 @@ namespace umbraco.presentation.developer.packages
}
}
//removing failing template items from the uninstall manifest
- syncLists(pack.Data.Templates, tempList);
+ SyncLists(_pack.Data.Templates, tempList);
- foreach (string str in pack.Data.Stylesheets)
+ foreach (string str in _pack.Data.Stylesheets)
{
int tId = 0;
if (int.TryParse(str, out tId))
{
try
{
- StyleSheet s = new StyleSheet(tId);
- if (s != null)
- {
- ListItem li = new ListItem(s.Text, s.Id.ToString());
- li.Selected = true;
- stylesheets.Items.Add(li);
- }
- else
- {
- tempList.Add(str);
- }
+ var s = new StyleSheet(tId);
+ ListItem li = new ListItem(s.Text, s.Id.ToString());
+ li.Selected = true;
+ stylesheets.Items.Add(li);
}
catch
{
@@ -130,20 +115,20 @@ namespace umbraco.presentation.developer.packages
}
}
//removing failing stylesheet items from the uninstall manifest
- syncLists(pack.Data.Stylesheets, tempList);
+ SyncLists(_pack.Data.Stylesheets, tempList);
- foreach (string str in pack.Data.Macros)
+ foreach (var str in _pack.Data.Macros)
{
- int tId = 0;
+ var tId = 0;
if (int.TryParse(str, out tId))
{
try
{
- Macro m = new Macro(tId);
-
- if (m != null && !string.IsNullOrEmpty(m.Name))
- { //Macros need an extra check to see if they actually exists. For some reason the macro does not return null, if the id is not found...
- ListItem li = new ListItem(m.Name, m.Id.ToString());
+ var m = new Macro(tId);
+ if (!string.IsNullOrEmpty(m.Name))
+ {
+ //Macros need an extra check to see if they actually exists. For some reason the macro does not return null, if the id is not found...
+ var li = new ListItem(m.Name, m.Id.ToString());
li.Selected = true;
macros.Items.Add(li);
}
@@ -159,16 +144,15 @@ namespace umbraco.presentation.developer.packages
}
}
//removing failing macros items from the uninstall manifest
- syncLists(pack.Data.Macros, tempList);
+ SyncLists(_pack.Data.Macros, tempList);
- foreach (string str in pack.Data.Files)
+ foreach (var str in _pack.Data.Files)
{
try
- {
-
- if (!String.IsNullOrEmpty(str) && System.IO.File.Exists( IOHelper.MapPath(str) ))
+ {
+ if (!string.IsNullOrEmpty(str) && System.IO.File.Exists(IOHelper.MapPath(str) ))
{
- ListItem li = new ListItem(str, str);
+ var li = new ListItem(str, str);
li.Selected = true;
files.Items.Add(li);
}
@@ -185,29 +169,22 @@ namespace umbraco.presentation.developer.packages
}
//removing failing files from the uninstall manifest
- syncLists(pack.Data.Files, tempList);
+ SyncLists(_pack.Data.Files, tempList);
- foreach (string str in pack.Data.DictionaryItems)
+ foreach (string str in _pack.Data.DictionaryItems)
{
- int tId = 0;
+ var tId = 0;
if (int.TryParse(str, out tId))
{
try
{
- cms.businesslogic.Dictionary.DictionaryItem di = new global::umbraco.cms.businesslogic.Dictionary.DictionaryItem(tId);
+ var di = new cms.businesslogic.Dictionary.DictionaryItem(tId);
- if (di != null)
- {
- ListItem li = new ListItem(di.key, di.id.ToString());
- li.Selected = true;
+ var li = new ListItem(di.key, di.id.ToString());
+ li.Selected = true;
- dictionaryItems.Items.Add(li);
- }
- else
- {
- tempList.Add(str);
- }
+ dictionaryItems.Items.Add(li);
}
catch
{
@@ -217,22 +194,22 @@ namespace umbraco.presentation.developer.packages
}
//removing failing files from the uninstall manifest
- syncLists(pack.Data.DictionaryItems, tempList);
+ SyncLists(_pack.Data.DictionaryItems, tempList);
- foreach (string str in pack.Data.DataTypes)
+ foreach (var str in _pack.Data.DataTypes)
{
- int tId = 0;
+ var tId = 0;
if (int.TryParse(str, out tId))
{
try
{
- cms.businesslogic.datatype.DataTypeDefinition dtd = new global::umbraco.cms.businesslogic.datatype.DataTypeDefinition(tId);
+ var dtd = new cms.businesslogic.datatype.DataTypeDefinition(tId);
if (dtd != null)
{
- ListItem li = new ListItem(dtd.Text, dtd.Id.ToString());
+ var li = new ListItem(dtd.Text, dtd.Id.ToString());
li.Selected = true;
dataTypes.Items.Add(li);
@@ -250,47 +227,53 @@ namespace umbraco.presentation.developer.packages
}
//removing failing files from the uninstall manifest
- syncLists(pack.Data.DataTypes, tempList);
+ SyncLists(_pack.Data.DataTypes, tempList);
//save the install manifest, so even tho the user doesn't uninstall, it stays uptodate.
- pack.Save();
+ _pack.Save();
//Look for updates on packages.
- if (!String.IsNullOrEmpty(pack.Data.RepositoryGuid) && !String.IsNullOrEmpty(pack.Data.PackageGuid))
+ if (!string.IsNullOrEmpty(_pack.Data.RepositoryGuid) && !string.IsNullOrEmpty(_pack.Data.PackageGuid))
{
try
{
- repo = cms.businesslogic.packager.repositories.Repository.getByGuid(pack.Data.RepositoryGuid);
+ _repo = cms.businesslogic.packager.repositories.Repository.getByGuid(_pack.Data.RepositoryGuid);
- if (repo != null)
+ if (_repo != null)
{
- hl_packageRepo.Text = repo.Name;
- hl_packageRepo.NavigateUrl = "BrowseRepository.aspx?repoGuid=" + repo.Guid;
+ hl_packageRepo.Text = _repo.Name;
+ hl_packageRepo.NavigateUrl = "BrowseRepository.aspx?repoGuid=" + _repo.Guid;
pp_repository.Visible = true;
}
- cms.businesslogic.packager.repositories.Package repoPackage = repo.Webservice.PackageByGuid(pack.Data.PackageGuid);
+ var repoPackage = _repo.Webservice.PackageByGuid(_pack.Data.PackageGuid);
- if (repoPackage != null) {
- if (repoPackage.HasUpgrade && repoPackage.UpgradeVersion != pack.Data.Version) {
+ if (repoPackage != null)
+ {
+ if (repoPackage.HasUpgrade && repoPackage.UpgradeVersion != _pack.Data.Version)
+ {
bt_update.Visible = true;
bt_update.Text = "Update available: version: " + repoPackage.UpgradeVersion;
lt_upgradeReadme.Text = repoPackage.UpgradeReadMe;
bt_gotoUpgrade.OnClientClick = "window.location.href = 'browseRepository.aspx?url=" + repoPackage.Url + "'; return true;";
lt_noUpdate.Visible = false;
- } else {
+ }
+ else
+ {
bt_update.Visible = false;
lt_noUpdate.Visible = true;
}
- if (!string.IsNullOrEmpty(repoPackage.Demo)) {
- lb_demoLink.OnClientClick = "openDemo(this, '" + pack.Data.PackageGuid + "'); return false;";
+ if (!string.IsNullOrEmpty(repoPackage.Demo))
+ {
+ lb_demoLink.OnClientClick = "openDemo(this, '" + _pack.Data.PackageGuid + "'); return false;";
pp_documentation.Visible = true;
}
-
- if(!string.IsNullOrEmpty(repoPackage.Documentation)) {
+
+ if (!string.IsNullOrEmpty(repoPackage.Documentation))
+ {
hl_docLink.NavigateUrl = repoPackage.Documentation;
hl_docLink.Target = "_blank";
pp_documentation.Visible = true;
@@ -305,7 +288,7 @@ namespace umbraco.presentation.developer.packages
}
- bool deletePackage = true;
+ var deletePackage = true;
//sync the UI to match what is in the package
if (macros.Items.Count == 0)
pp_macros.Visible = false;
@@ -353,14 +336,14 @@ namespace umbraco.presentation.developer.packages
}
}
- private void syncLists(List list, List removed)
+ private static void SyncLists(List list, List removed)
{
- foreach (string str in removed)
+ foreach (var str in removed)
{
list.Remove(str);
}
- for (int i = 0; i < list.Count; i++)
+ for (var i = 0; i < list.Count; i++)
{
if (String.IsNullOrEmpty(list[i].Trim()))
list.RemoveAt(i);
@@ -371,7 +354,7 @@ namespace umbraco.presentation.developer.packages
protected void delPack(object sender, EventArgs e)
{
- pack.Delete();
+ _pack.Delete();
packageUninstalled.Visible = true;
installedPackagePanel.Visible = false;
}
@@ -379,10 +362,7 @@ namespace umbraco.presentation.developer.packages
protected void confirmUnInstall(object sender, EventArgs e)
{
-
-
-
- bool refreshCache = false;
+ var refreshCache = false;
//Uninstall Stylesheets
foreach (ListItem li in stylesheets.Items)
@@ -393,12 +373,9 @@ namespace umbraco.presentation.developer.packages
if (int.TryParse(li.Value, out nId))
{
- StyleSheet s = new StyleSheet(nId);
- if (s != null)
- {
- s.delete();
- pack.Data.Stylesheets.Remove(nId.ToString());
- }
+ var s = new StyleSheet(nId);
+ s.delete();
+ _pack.Data.Stylesheets.Remove(nId.ToString());
}
}
}
@@ -412,13 +389,10 @@ namespace umbraco.presentation.developer.packages
if (int.TryParse(li.Value, out nId))
{
- Template s = new Template(nId);
- if (s != null)
- {
- s.RemoveAllReferences();
- s.delete();
- pack.Data.Templates.Remove(nId.ToString());
- }
+ var s = new Template(nId);
+ s.RemoveAllReferences();
+ s.delete();
+ _pack.Data.Templates.Remove(nId.ToString());
}
}
}
@@ -432,21 +406,19 @@ namespace umbraco.presentation.developer.packages
if (int.TryParse(li.Value, out nId))
{
- Macro s = new Macro(nId);
- if (s != null && !String.IsNullOrEmpty(s.Name))
+ var s = new Macro(nId);
+ if (!string.IsNullOrEmpty(s.Name))
{
// remove from cache
runtimeMacro.GetMacro(s.Id).removeFromCache();
s.Delete();
}
- pack.Data.Macros.Remove(nId.ToString());
+ _pack.Data.Macros.Remove(nId.ToString());
}
}
}
-
-
-
+
//Remove Document types
foreach (ListItem li in documentTypes.Items)
{
@@ -456,16 +428,12 @@ namespace umbraco.presentation.developer.packages
if (int.TryParse(li.Value, out nId))
{
- DocumentType s = new DocumentType(nId);
- if (s != null)
- {
- s.delete();
- pack.Data.Documenttypes.Remove(nId.ToString());
+ var s = new DocumentType(nId);
+ s.delete();
+ _pack.Data.Documenttypes.Remove(nId.ToString());
- // refresh content cache when document types are removed
- refreshCache = true;
-
- }
+ // refresh content cache when document types are removed
+ refreshCache = true;
}
}
}
@@ -479,12 +447,9 @@ namespace umbraco.presentation.developer.packages
if (int.TryParse(li.Value, out nId))
{
- cms.businesslogic.Dictionary.DictionaryItem di = new global::umbraco.cms.businesslogic.Dictionary.DictionaryItem(nId);
- if (di != null)
- {
- di.delete();
- pack.Data.DictionaryItems.Remove(nId.ToString());
- }
+ var di = new cms.businesslogic.Dictionary.DictionaryItem(nId);
+ di.delete();
+ _pack.Data.DictionaryItems.Remove(nId.ToString());
}
}
}
@@ -498,41 +463,45 @@ namespace umbraco.presentation.developer.packages
if (int.TryParse(li.Value, out nId))
{
- cms.businesslogic.datatype.DataTypeDefinition dtd = new global::umbraco.cms.businesslogic.datatype.DataTypeDefinition(nId);
- if (dtd != null)
- {
- dtd.delete();
- pack.Data.DataTypes.Remove(nId.ToString());
- }
+ var dtd = new cms.businesslogic.datatype.DataTypeDefinition(nId);
+ dtd.delete();
+ _pack.Data.DataTypes.Remove(nId.ToString());
}
}
}
- pack.Save();
+ _pack.Save();
- if (!isManifestEmpty())
+ if (!IsManifestEmpty())
{
Response.Redirect(Request.RawUrl);
}
else
{
- BusinessLogic.Log.Add(global::umbraco.BusinessLogic.LogTypes.Debug, -1, "executing undo actions");
-
+
// uninstall actions
- try {
- System.Xml.XmlDocument actionsXml = new System.Xml.XmlDocument();
- actionsXml.LoadXml("" + pack.Data.Actions + "");
+ try
+ {
+ var actionsXml = new XmlDocument();
+ actionsXml.LoadXml("" + _pack.Data.Actions + "");
- BusinessLogic.Log.Add(global::umbraco.BusinessLogic.LogTypes.Debug, -1, actionsXml.OuterXml);
- foreach (XmlNode n in actionsXml.DocumentElement.SelectNodes("//Action")) {
- try {
- cms.businesslogic.packager.PackageAction.UndoPackageAction(pack.Data.Name, n.Attributes["alias"].Value, n);
- } catch (Exception ex) {
- BusinessLogic.Log.Add(global::umbraco.BusinessLogic.LogTypes.Debug, -1, ex.ToString());
+ LogHelper.Debug("executing undo actions: {0}", () => actionsXml.OuterXml);
+
+ foreach (XmlNode n in actionsXml.DocumentElement.SelectNodes("//Action"))
+ {
+ try
+ {
+ cms.businesslogic.packager.PackageAction.UndoPackageAction(_pack.Data.Name, n.Attributes["alias"].Value, n);
+ }
+ catch (Exception ex)
+ {
+ LogHelper.Error("An error occurred running undo actions", ex);
}
}
- } catch (Exception ex) {
- BusinessLogic.Log.Add(global::umbraco.BusinessLogic.LogTypes.Debug, -1, ex.ToString());
+ }
+ catch (Exception ex)
+ {
+ LogHelper.Error("An error occurred running undo actions", ex);
}
//moved remove of files here so custom package actions can still undo
@@ -543,26 +512,27 @@ namespace umbraco.presentation.developer.packages
{
//here we need to try to find the file in question as most packages does not support the tilde char
- string file = IOHelper.FindFile(li.Value);
+ var file = IOHelper.FindFile(li.Value);
- string filePath = IOHelper.MapPath(file);
+ var filePath = IOHelper.MapPath(file);
if (System.IO.File.Exists(filePath))
{
System.IO.File.Delete(filePath);
- pack.Data.Files.Remove(li.Value);
+ _pack.Data.Files.Remove(li.Value);
}
}
}
- pack.Save();
+ _pack.Save();
- pack.Delete();
+ _pack.Delete();
packageUninstalled.Visible = true;
installedPackagePanel.Visible = false;
}
// refresh cache
- if (refreshCache) {
+ if (refreshCache)
+ {
library.RefreshContent();
}
@@ -576,72 +546,62 @@ namespace umbraco.presentation.developer.packages
}
- private bool isManifestEmpty()
+ private bool IsManifestEmpty()
{
- pack.Data.Documenttypes.TrimExcess();
- pack.Data.Files.TrimExcess();
- pack.Data.Macros.TrimExcess();
- pack.Data.Stylesheets.TrimExcess();
- pack.Data.Templates.TrimExcess();
- pack.Data.DataTypes.TrimExcess();
- pack.Data.DictionaryItems.TrimExcess();
+ _pack.Data.Documenttypes.TrimExcess();
+ _pack.Data.Files.TrimExcess();
+ _pack.Data.Macros.TrimExcess();
+ _pack.Data.Stylesheets.TrimExcess();
+ _pack.Data.Templates.TrimExcess();
+ _pack.Data.DataTypes.TrimExcess();
+ _pack.Data.DictionaryItems.TrimExcess();
+
+ var lists = new List>
+ {
+ _pack.Data.Documenttypes,
+ _pack.Data.Macros,
+ _pack.Data.Stylesheets,
+ _pack.Data.Templates,
+ _pack.Data.DictionaryItems,
+ _pack.Data.DataTypes
+ };
- List> lists = new List>();
- lists.Add(pack.Data.Documenttypes);
-
//Not including files, since there might be assemblies that contain package actions
//lists.Add(pack.Data.Files);
- lists.Add(pack.Data.Macros);
- lists.Add(pack.Data.Stylesheets);
- lists.Add(pack.Data.Templates);
- lists.Add(pack.Data.DictionaryItems);
- lists.Add(pack.Data.DataTypes);
-
-
- foreach (List list in lists)
- {
-
- foreach (string str in list)
- {
- if (!String.IsNullOrEmpty(str.Trim()))
- return false;
- }
-
- }
-
- return true;
+ return lists.SelectMany(list => list).All(str => string.IsNullOrEmpty(str.Trim()));
}
protected override void OnInit(EventArgs e)
{
- base.OnInit(e);
- Panel1.Text = ui.Text("treeHeaders", "installedPackages");
- pane_meta.Text = ui.Text("packager", "packageMetaData");
- pp_name.Text = ui.Text("packager", "packageName");
- pp_version.Text = ui.Text("packager", "packageVersion");
- pp_author.Text = ui.Text("packager", "packageAuthor");
- pp_repository.Text = ui.Text("packager", "packageRepository");
- pp_documentation.Text = ui.Text("packager", "packageDocumentation");
- pp_readme.Text = ui.Text("packager", "packageReadme");
- hl_docLink.Text = ui.Text("packager", "packageDocumentation");
- lb_demoLink.Text = ui.Text("packager", "packageDemonstration");
+ base.OnInit(e);
- pane_options.Text = ui.Text("packager", "packageOptions");
- lt_noUpdate.Text = ui.Text("packager", "packageNoUpgrades");
- bt_update.Text = ui.Text("packager", "packageUpgradeHeader");
- pp_upgradeInstruction.Text = ui.Text("packager", "packageUpgradeInstructions");
- bt_gotoUpgrade.Text = ui.Text("packager", "packageUpgradeDownload");
+ Panel1.Text = ui.Text("treeHeaders", "installedPackages");
+ pane_meta.Text = ui.Text("packager", "packageMetaData");
+ pp_name.Text = ui.Text("packager", "packageName");
+ pp_version.Text = ui.Text("packager", "packageVersion");
+ pp_author.Text = ui.Text("packager", "packageAuthor");
+ pp_repository.Text = ui.Text("packager", "packageRepository");
+ pp_documentation.Text = ui.Text("packager", "packageDocumentation");
+ pp_readme.Text = ui.Text("packager", "packageReadme");
+ hl_docLink.Text = ui.Text("packager", "packageDocumentation");
+ lb_demoLink.Text = ui.Text("packager", "packageDemonstration");
- pane_noItems.Text = ui.Text("packager", "packageNoItemsHeader");
+ pane_options.Text = ui.Text("packager", "packageOptions");
+ lt_noUpdate.Text = ui.Text("packager", "packageNoUpgrades");
+ bt_update.Text = ui.Text("packager", "packageUpgradeHeader");
+ pp_upgradeInstruction.Text = ui.Text("packager", "packageUpgradeInstructions");
+ bt_gotoUpgrade.Text = ui.Text("packager", "packageUpgradeDownload");
- pane_uninstall.Text = ui.Text("packager", "packageUninstallHeader");
- bt_uninstall.Text = ui.Text("packager", "packageUninstallHeader");
- bt_deletePackage.Text = ui.Text("packager", "packageUninstallHeader");
- bt_confirmUninstall.Text = ui.Text("packager", "packageUninstallConfirm");
+ pane_noItems.Text = ui.Text("packager", "packageNoItemsHeader");
- pane_uninstalled.Text = ui.Text("packager", "packageUninstalledHeader");
+ pane_uninstall.Text = ui.Text("packager", "packageUninstallHeader");
+ bt_uninstall.Text = ui.Text("packager", "packageUninstallHeader");
+ bt_deletePackage.Text = ui.Text("packager", "packageUninstallHeader");
+ bt_confirmUninstall.Text = ui.Text("packager", "packageUninstallConfirm");
+
+ pane_uninstalled.Text = ui.Text("packager", "packageUninstalledHeader");
}
}
}
From bb70bee6aefc9da4c49449f817d6350921ea9eca Mon Sep 17 00:00:00 2001
From: Shannon Deminick
Date: Wed, 10 Apr 2013 01:42:15 +0600
Subject: [PATCH 03/29] Fixes: #U4-2071 and cleans up some code.
---
.../umbraco/dialogs/moveOrCopy.aspx.cs | 350 +++++++++---------
.../BasePages/UmbracoEnsuredPage.cs | 9 +-
2 files changed, 174 insertions(+), 185 deletions(-)
diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/moveOrCopy.aspx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/moveOrCopy.aspx.cs
index 3bd289e1e0..24f1f5f088 100644
--- a/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/moveOrCopy.aspx.cs
+++ b/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/moveOrCopy.aspx.cs
@@ -9,11 +9,11 @@ using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Xml;
+using Umbraco.Core.IO;
using umbraco.cms.helpers;
using umbraco.BasePages;
using umbraco.presentation;
using umbraco.cms.businesslogic.media;
-using umbraco.IO;
using System.Linq;
using umbraco.cms.businesslogic;
using umbraco.cms.presentation.user;
@@ -28,7 +28,14 @@ namespace umbraco.dialogs
public partial class moveOrCopy : UmbracoEnsuredPage
{
- protected void Page_Load(object sender, System.EventArgs e)
+ protected override void OnInit(EventArgs e)
+ {
+ CurrentApp = Request["app"];
+
+ base.OnInit(e);
+ }
+
+ protected void Page_Load(object sender, EventArgs e)
{
JTree.DataBind();
@@ -37,41 +44,36 @@ namespace umbraco.dialogs
{
pp_relate.Text = ui.Text("moveOrCopy", "relateToOriginal");
- //Document Type copy Hack...
- string app = helper.Request("app");
+ //Document Type copy Hack...
- if (app == "settings") {
+ if (CurrentApp == "settings")
+ {
pane_form.Visible = false;
pane_form_notice.Visible = false;
-
-
-
pane_settings.Visible = true;
ok.Text = ui.Text("general", "ok", this.getUser());
ok.Attributes.Add("style", "width: 60px");
- cms.businesslogic.web.DocumentType dt = new umbraco.cms.businesslogic.web.DocumentType(int.Parse(helper.Request("id")));
+ var dt = new cms.businesslogic.web.DocumentType(int.Parse(helper.Request("id")));
//Load master types...
masterType.Attributes.Add("style", "width: 350px;");
masterType.Items.Add(new ListItem(ui.Text("none") + "...", "0"));
- foreach (cms.businesslogic.web.DocumentType docT in cms.businesslogic.web.DocumentType.GetAllAsList()) {
+ foreach (cms.businesslogic.web.DocumentType docT in cms.businesslogic.web.DocumentType.GetAllAsList())
+ {
masterType.Items.Add(new ListItem(docT.Text, docT.Id.ToString()));
}
masterType.SelectedValue = dt.MasterContentType.ToString();
- //hack to close window if not a doctype...
- if (dt == null) {
- Response.Write("");
- } else {
- rename.Text = dt.Text + " (copy)";
- pane_settings.Text = "Make a copy of the document type '" + dt.Text + "' and save it under a new name";
- }
+ rename.Text = dt.Text + " (copy)";
+ pane_settings.Text = "Make a copy of the document type '" + dt.Text + "' and save it under a new name";
- } else {
+ }
+ else
+ {
pane_form.Visible = true;
pane_form_notice.Visible = true;
@@ -83,28 +85,30 @@ namespace umbraco.dialogs
ok.Attributes.Add("style", "width: 60px");
ok.Attributes.Add("disabled", "true");
-
- string currentPath = "";
- CMSNode d = new CMSNode(int.Parse(helper.Request("id")));
- foreach (string s in d.Path.Split(',')) {
+
+ var currentPath = "";
+ var d = new CMSNode(int.Parse(helper.Request("id")));
+ foreach (var s in d.Path.Split(','))
+ {
if (int.Parse(s) > 0)
currentPath += "/" + new CMSNode(int.Parse(s)).Text;
}
-
- //
-
- bool validAction = true;
+
+ var validAction = true;
// only validate permissions in content
- if (app == "content" && d.HasChildren)
+ if (CurrentApp == "content" && d.HasChildren)
{
validAction = ValidAction(helper.Request("mode") == "cut" ? 'M' : 'O');
}
- if (helper.Request("mode") == "cut") {
+ if (helper.Request("mode") == "cut")
+ {
pane_form.Text = ui.Text("moveOrCopy", "moveTo", d.Text, base.getUser());
pp_relate.Visible = false;
- } else {
+ }
+ else
+ {
pane_form.Text = ui.Text("moveOrCopy", "copyTo", d.Text, base.getUser());
pp_relate.Visible = true;
}
@@ -119,192 +123,194 @@ namespace umbraco.dialogs
}
- private bool ValidAction(char actionLetter)
+ private static bool ValidAction(char actionLetter)
{
- CMSNode d = new CMSNode(int.Parse(helper.Request("id")));
- IAction currentAction = umbraco.BusinessLogic.Actions.Action.GetPermissionAssignable().Where(a => a.Letter == actionLetter).First();
+ var d = new CMSNode(int.Parse(helper.Request("id")));
+ var currentAction = BusinessLogic.Actions.Action.GetPermissionAssignable().First(a => a.Letter == actionLetter);
return CheckPermissions(d, currentAction,actionLetter);
}
- private bool CheckPermissions(CMSNode node, IAction currentAction, char actionLetter)
- {
-
- UserPermissions currUserPermissions = new UserPermissions(UmbracoEnsuredPage.CurrentUser);
- List lstCurrUserActions = currUserPermissions.GetExistingNodePermission(node.Id);
+ private static bool CheckPermissions(CMSNode node, IAction currentAction, char actionLetter)
+ {
+ var currUserPermissions = new UserPermissions(CurrentUser);
+ var lstCurrUserActions = currUserPermissions.GetExistingNodePermission(node.Id);
if (!lstCurrUserActions.Contains(currentAction))
return false;
if (node.HasChildren)
{
- foreach (CMSNode c in node.Children)
- if (!CheckPermissions(c,currentAction,actionLetter))
- return false;
+ return node.Children.Cast().All(c => CheckPermissions(c, currentAction, actionLetter));
}
return true;
}
+
//PPH moving multiple nodes and publishing them aswell.
- private void handleChildNodes(cms.businesslogic.web.Document d) {
- //store children array here because iterating over an Array object is very inneficient.
- var c = d.Children;
- foreach (cms.businesslogic.web.Document cd in c)
+ private static void HandleChildNodes(cms.businesslogic.web.Document d)
+ {
+ var c = d.Children;
+ foreach (var cd in c)
+ {
+ if (cd.Published)
+ {
+ cd.Publish(new BusinessLogic.User(0));
+ //using library.publish to support load balancing.
+ library.UpdateDocumentCache(cd);
+
+
+ if (cd.HasChildren)
+ {
+ HandleChildNodes(cd);
+ }
+ }
+ }
+ }
+
+ //PPH Handle doctype copies..
+ private void HandleDocumentTypeCopy()
+ {
+
+ var eDt = new cms.businesslogic.web.DocumentType(int.Parse(helper.Request("id")));
+
+ var alias = rename.Text;
+ var dt = cms.businesslogic.web.DocumentType.MakeNew(getUser(), alias.Replace("'", "''"));
+
+ dt.IconUrl = eDt.IconUrl;
+ dt.Thumbnail = eDt.Thumbnail;
+ dt.Description = eDt.Description;
+ dt.allowedTemplates = eDt.allowedTemplates;
+ dt.DefaultTemplate = eDt.DefaultTemplate;
+ dt.AllowedChildContentTypeIDs = eDt.AllowedChildContentTypeIDs;
+
+ dt.MasterContentType = int.Parse(masterType.SelectedValue);
+
+ var oldNewTabIds = new Hashtable();
+ foreach (var tab in eDt.getVirtualTabs.ToList())
{
- if (cd.Published) {
- cd.Publish(new umbraco.BusinessLogic.User(0));
- //using library.publish to support load balancing.
- umbraco.library.UpdateDocumentCache(cd);
+ if (tab.ContentType == eDt.Id)
+ {
+ var tId = dt.AddVirtualTab(tab.Caption);
+ oldNewTabIds.Add(tab.Id, tId);
+ }
+ }
+ foreach (var pt in eDt.PropertyTypes)
+ {
+ if (pt.ContentTypeId == eDt.Id)
+ {
+ var nPt = cms.businesslogic.propertytype.PropertyType.MakeNew(pt.DataTypeDefinition, dt, pt.Name, pt.Alias);
+ nPt.ValidationRegExp = pt.ValidationRegExp;
+ nPt.SortOrder = pt.SortOrder;
+ nPt.Mandatory = pt.Mandatory;
+ nPt.Description = pt.Description;
- if (cd.HasChildren) {
- handleChildNodes(cd);
+ if (pt.TabId > 0 && oldNewTabIds[pt.TabId] != null)
+ {
+ var newTabId = (int)oldNewTabIds[pt.TabId];
+ nPt.TabId = newTabId;
}
}
}
- }
- //PPH Handle doctype copies..
- private void HandleDocumentTypeCopy() {
+ var returnUrl = SystemDirectories.Umbraco + "/settings/editNodeTypeNew.aspx?id=" + dt.Id.ToString();
- cms.businesslogic.web.DocumentType eDt = new umbraco.cms.businesslogic.web.DocumentType(int.Parse(helper.Request("id")));
-
- //Documentype exists.. create new doc type...
- if (eDt != null) {
- string Alias = rename.Text;
- cms.businesslogic.web.DocumentType dt = cms.businesslogic.web.DocumentType.MakeNew(base.getUser(), Alias.Replace("'", "''"));
-
- dt.IconUrl = eDt.IconUrl;
- dt.Thumbnail = eDt.Thumbnail;
- dt.Description = eDt.Description;
- dt.allowedTemplates = eDt.allowedTemplates;
- dt.DefaultTemplate = eDt.DefaultTemplate;
- dt.AllowedChildContentTypeIDs = eDt.AllowedChildContentTypeIDs;
-
- dt.MasterContentType = int.Parse(masterType.SelectedValue);
-
- Hashtable oldNewTabIds = new Hashtable();
- foreach (cms.businesslogic.web.DocumentType.TabI tab in eDt.getVirtualTabs.ToList())
- {
- if (tab.ContentType == eDt.Id)
- {
- int tId = dt.AddVirtualTab(tab.Caption);
- oldNewTabIds.Add(tab.Id, tId);
- }
- }
-
- foreach (cms.businesslogic.propertytype.PropertyType pt in eDt.PropertyTypes) {
-
- if (pt.ContentTypeId == eDt.Id)
- {
- cms.businesslogic.propertytype.PropertyType nPt = umbraco.cms.businesslogic.propertytype.PropertyType.MakeNew(pt.DataTypeDefinition, dt, pt.Name, pt.Alias);
- nPt.ValidationRegExp = pt.ValidationRegExp;
- nPt.SortOrder = pt.SortOrder;
- nPt.Mandatory = pt.Mandatory;
- nPt.Description = pt.Description;
-
- if (pt.TabId > 0 && oldNewTabIds[pt.TabId] != null)
- {
- int newTabId = (int)oldNewTabIds[pt.TabId];
- nPt.TabId = newTabId;
- }
- }
- }
-
- string returnUrl = SystemDirectories.Umbraco + "/settings/editNodeTypeNew.aspx?id=" + dt.Id.ToString();
-
- dt.Save();
+ dt.Save();
- pane_settings.Visible = false;
- panel_buttons.Visible = false;
+ pane_settings.Visible = false;
+ panel_buttons.Visible = false;
- feedback.Text = "Document type copied";
- feedback.type = umbraco.uicontrols.Feedback.feedbacktype.success;
+ feedback.Text = "Document type copied";
+ feedback.type = uicontrols.Feedback.feedbacktype.success;
- ClientTools.ChangeContentFrameUrl(returnUrl);
-
- }
- }
-
- public void HandleMoveOrCopy(object sender, EventArgs e) {
- if (UmbracoContext.Current.Request["app"] == "settings")
- HandleDocumentTypeCopy();
- else
- HandleDocumentMoveOrCopy();
- }
+ ClientTools.ChangeContentFrameUrl(returnUrl);
+ }
- protected override void OnPreRender(EventArgs e) {
- base.OnPreRender(e);
+ public void HandleMoveOrCopy(object sender, EventArgs e)
+ {
+ if (Request["app"] == "settings")
+ HandleDocumentTypeCopy();
+ else
+ HandleDocumentMoveOrCopy();
+ }
- ScriptManager.GetCurrent(Page).Services.Add(new ServiceReference("../webservices/cmsnode.asmx"));
- ScriptManager.GetCurrent(Page).Services.Add(new ServiceReference("../webservices/legacyAjaxCalls.asmx"));
- }
+ protected override void OnPreRender(EventArgs e)
+ {
+ base.OnPreRender(e);
+ ScriptManager.GetCurrent(Page).Services.Add(new ServiceReference("../webservices/cmsnode.asmx"));
+ ScriptManager.GetCurrent(Page).Services.Add(new ServiceReference("../webservices/legacyAjaxCalls.asmx"));
+ }
- private void HandleDocumentMoveOrCopy()
+ private void HandleDocumentMoveOrCopy()
{
if (helper.Request("copyTo") != "" && helper.Request("id") != "")
{
// Check if the current node is allowed at new position
- bool nodeAllowed = false;
+ var nodeAllowed = false;
- cms.businesslogic.Content currentNode = new cms.businesslogic.Content(int.Parse(helper.Request("id")));
- int oldParent = -1;
+ var currentNode = new cms.businesslogic.Content(int.Parse(helper.Request("id")));
+ var oldParent = -1;
if (currentNode.Level > 1)
oldParent = currentNode.Parent.Id;
- cms.businesslogic.Content newNode = new cms.businesslogic.Content(int.Parse(helper.Request("copyTo")));
+ var newNode = new cms.businesslogic.Content(int.Parse(helper.Request("copyTo")));
// Check on contenttypes
- if (int.Parse(helper.Request("copyTo")) == -1)
- nodeAllowed = true;
- else
- {
- foreach (int i in newNode.ContentType.AllowedChildContentTypeIDs.ToList())
- if (i == currentNode.ContentType.Id)
- {
- nodeAllowed = true;
- break;
- }
- if (!nodeAllowed) {
- feedback.Text = ui.Text("moveOrCopy", "notAllowedByContentType", base.getUser());
- feedback.type = umbraco.uicontrols.Feedback.feedbacktype.error;
- } else {
- // Check on paths
- if (((string)("," + newNode.Path + ",")).IndexOf("," + currentNode.Id + ",") > -1) {
- nodeAllowed = false;
- feedback.Text = ui.Text("moveOrCopy", "notAllowedByPath", base.getUser());
- feedback.type = umbraco.uicontrols.Feedback.feedbacktype.error;
- }
- }
- }
+ if (int.Parse(helper.Request("copyTo")) == -1)
+ {
+ nodeAllowed = true;
+ }
+ else
+ {
+ if (newNode.ContentType.AllowedChildContentTypeIDs.ToList().Any(i => i == currentNode.ContentType.Id))
+ {
+ nodeAllowed = true;
+ }
+ if (!nodeAllowed)
+ {
+ feedback.Text = ui.Text("moveOrCopy", "notAllowedByContentType", base.getUser());
+ feedback.type = uicontrols.Feedback.feedbacktype.error;
+ }
+ else
+ {
+ // Check on paths
+ if (("," + newNode.Path + ",").IndexOf("," + currentNode.Id + ",") > -1)
+ {
+ nodeAllowed = false;
+ feedback.Text = ui.Text("moveOrCopy", "notAllowedByPath", getUser());
+ feedback.type = uicontrols.Feedback.feedbacktype.error;
+ }
+ }
+ }
- if (nodeAllowed)
+ if (nodeAllowed)
{
pane_form.Visible = false;
pane_form_notice.Visible = false;
panel_buttons.Visible = false;
- string newNodeCaption = newNode.Id == -1 ? ui.Text(helper.Request("app")) : newNode.Text;
+ var newNodeCaption = newNode.Id == -1 ? ui.Text(helper.Request("app")) : newNode.Text;
string[] nodes = {currentNode.Text, newNodeCaption };
- if (UmbracoContext.Current.Request["mode"] == "cut")
+ if (Request["mode"] == "cut")
{
- if (UmbracoContext.Current.Request["app"] == "content")
+ if (Request["app"] == "content")
{
//PPH changed this to document instead of cmsNode to handle republishing.
- cms.businesslogic.web.Document d = new umbraco.cms.businesslogic.web.Document(int.Parse(helper.Request("id")));
+ var d = new cms.businesslogic.web.Document(int.Parse(helper.Request("id")));
d.Move(int.Parse(helper.Request("copyTo")));
if (d.Published)
{
- d.Publish(new umbraco.BusinessLogic.User(0));
+ d.Publish(new BusinessLogic.User(0));
//using library.publish to support load balancing.
//umbraco.library.PublishSingleNode(d.Id);
- umbraco.library.UpdateDocumentCache(d);
+ library.UpdateDocumentCache(d);
//PPH added handling of load balanced moving of multiple nodes...
if (d.HasChildren)
{
- handleChildNodes(d);
+ HandleChildNodes(d);
}
//Using the general Refresh content method instead as it supports load balancing.
@@ -315,14 +321,14 @@ namespace umbraco.dialogs
}
else
{
- Media m = new Media(int.Parse(UmbracoContext.Current.Request["id"]));
- m.Move(int.Parse(UmbracoContext.Current.Request["copyTo"]));
+ var m = new Media(int.Parse(Request["id"]));
+ m.Move(int.Parse(Request["copyTo"]));
m.XmlGenerate(new XmlDocument());
library.ClearLibraryCacheForMedia(m.Id);
}
- feedback.Text = ui.Text("moveOrCopy", "moveDone", nodes, base.getUser()) + "
" + ui.Text("closeThisWindow") + "";
- feedback.type = umbraco.uicontrols.Feedback.feedbacktype.success;
+ feedback.Text = ui.Text("moveOrCopy", "moveDone", nodes, getUser()) + "
" + ui.Text("closeThisWindow") + "";
+ feedback.type = uicontrols.Feedback.feedbacktype.success;
// refresh tree
ClientTools.MoveNode(currentNode.Id.ToString(), newNode.Path);
@@ -330,33 +336,15 @@ namespace umbraco.dialogs
}
else
{
- cms.businesslogic.web.Document d = new cms.businesslogic.web.Document(int.Parse(helper.Request("id")));
- d.Copy(int.Parse(helper.Request("copyTo")), this.getUser(), RelateDocuments.Checked);
- feedback.Text = ui.Text("moveOrCopy", "copyDone", nodes, base.getUser()) + "
" + ui.Text("closeThisWindow") + "";
- feedback.type = umbraco.uicontrols.Feedback.feedbacktype.success;
+ var d = new cms.businesslogic.web.Document(int.Parse(helper.Request("id")));
+ d.Copy(int.Parse(helper.Request("copyTo")), getUser(), RelateDocuments.Checked);
+ feedback.Text = ui.Text("moveOrCopy", "copyDone", nodes, getUser()) + "
" + ui.Text("closeThisWindow") + "";
+ feedback.type = uicontrols.Feedback.feedbacktype.success;
ClientTools.CopyNode(currentNode.Id.ToString(), newNode.Path);
}
}
}
}
- #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);
- }
-
- ///
- /// 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.businesslogic/BasePages/UmbracoEnsuredPage.cs b/src/umbraco.businesslogic/BasePages/UmbracoEnsuredPage.cs
index 16109f91dc..03d5ad81c1 100644
--- a/src/umbraco.businesslogic/BasePages/UmbracoEnsuredPage.cs
+++ b/src/umbraco.businesslogic/BasePages/UmbracoEnsuredPage.cs
@@ -1,8 +1,9 @@
using System;
using System.Linq;
+using Umbraco.Core.IO;
+using Umbraco.Core.Logging;
using umbraco.BusinessLogic;
using umbraco.businesslogic.Exceptions;
-using umbraco.IO;
namespace umbraco.BasePages
{
@@ -54,7 +55,7 @@ namespace umbraco.BasePages
if (permissions.IndexOf(Action) > -1 && (Path.Contains("-20") || ("," + Path + ",").Contains("," + getUser().StartNodeId.ToString() + ",")))
return true;
- Log.Add(LogTypes.LoginFailure, getUser(), -1, "Insufficient permissions in UmbracoEnsuredPage: '" + Path + "', '" + permissions + "', '" + Action + "'");
+ LogHelper.Info("Insufficient permissions in UmbracoEnsuredPage: '" + Path + "', '" + permissions + "', '" + Action + "'");
return false;
}
@@ -81,7 +82,7 @@ namespace umbraco.BasePages
{
ensureContext();
- if (!String.IsNullOrEmpty(CurrentApp))
+ if (!string.IsNullOrEmpty(CurrentApp))
{
if (!ValidateUserApp(CurrentApp))
throw new UserAuthorizationException(String.Format("The current user doesn't have access to the section/app '{0}'", CurrentApp));
@@ -89,7 +90,7 @@ namespace umbraco.BasePages
}
catch (UserAuthorizationException)
{
- Log.Add(LogTypes.Error, CurrentUser, -1, String.Format("Tried to access '{0}'", CurrentApp));
+ LogHelper.Warn(string.Format("{0} tried to access '{1}'", CurrentUser.Id, CurrentApp));
throw;
}
catch
From 72790d74f5781b87a8c397a34fdb303b6307270d Mon Sep 17 00:00:00 2001
From: Shannon Deminick
Date: Wed, 10 Apr 2013 01:47:17 +0600
Subject: [PATCH 04/29] Fixes: #U4-2072 and cleans up some code.
---
.../umbraco/dialogs/publish.aspx.cs | 109 +++++++++---------
1 file changed, 54 insertions(+), 55 deletions(-)
diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/publish.aspx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/publish.aspx.cs
index 7d05314df7..054a63ece5 100644
--- a/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/publish.aspx.cs
+++ b/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/publish.aspx.cs
@@ -1,16 +1,9 @@
using System;
-using System.Collections;
-using System.ComponentModel;
-using System.Data;
-using System.Drawing;
-using System.Web;
-using System.Web.SessionState;
+using System.Collections.Generic;
using System.Web.UI;
using System.Web.UI.WebControls;
-using System.Web.UI.HtmlControls;
-
-using System.Threading;
-using umbraco.cms.helpers;
+using Umbraco.Core.Logging;
+using umbraco.BusinessLogic;
using umbraco.BasePages;
namespace umbraco.dialogs
@@ -18,18 +11,24 @@ namespace umbraco.dialogs
///
/// Summary description for publish.
///
- public partial class publish : BasePages.UmbracoEnsuredPage
+ public partial class publish : UmbracoEnsuredPage
{
- protected System.Web.UI.WebControls.Literal total;
+ protected Literal total;
- private int nodeId;
- private int nodesPublished = 0;
+ private int _nodeId;
+ private int _nodesPublished = 0;
+ private readonly List _documents = new List();
public static string pageName = "";
- protected void Page_Load(object sender, System.EventArgs e)
+ public publish()
+ {
+ CurrentApp = DefaultApps.content.ToString();
+ }
+
+ protected void Page_Load(object sender, EventArgs e)
{
- nodeId = int.Parse(helper.Request("id"));
- cms.businesslogic.web.Document d = new cms.businesslogic.web.Document(nodeId);
+ _nodeId = int.Parse(helper.Request("id"));
+ var d = new cms.businesslogic.web.Document(_nodeId);
pageName = d.Text;
if (d.Level > 1 && !(new cms.businesslogic.web.Document(d.ParentId).PathPublished))
@@ -37,37 +36,37 @@ namespace umbraco.dialogs
TheForm.Visible = false;
theEnd.Visible = true;
feedbackMsg.type = uicontrols.Feedback.feedbacktype.notice;
- feedbackMsg.Text = ui.Text("publish", "contentPublishedFailedByParent", d.Text, base.getUser()) + "
" + ui.Text("closeThisWindow") + "";
+ feedbackMsg.Text = ui.Text("publish", "contentPublishedFailedByParent", d.Text, getUser()) + "
" + ui.Text("closeThisWindow") + "";
return;
}
// add control prefix to variable for support with masterpages
- string prefix = PublishUnpublishedItems.ClientID.Replace(PublishUnpublishedItems.ID, "");
+ var prefix = PublishUnpublishedItems.ClientID.Replace(PublishUnpublishedItems.ID, "");
masterPagePrefix.Text = prefix;
// by default we only count the published ones
- int TotalNodesToPublish = cms.businesslogic.web.Document.CountSubs(nodeId, true);
+ var totalNodesToPublish = cms.businesslogic.web.Document.CountSubs(_nodeId, true);
try
{
Application.Lock();
// We add both all nodes and only published nodes to the application variables so we can ajax query depending on checkboxes
- Application["publishTotalAll" + nodeId.ToString()] = cms.businesslogic.CMSNode.CountSubs(nodeId).ToString();
- Application["publishTotal" + nodeId.ToString()] = TotalNodesToPublish.ToString();
- Application["publishDone" + nodeId.ToString()] = "0";
+ Application["publishTotalAll" + _nodeId.ToString()] = cms.businesslogic.CMSNode.CountSubs(_nodeId).ToString();
+ Application["publishTotal" + _nodeId.ToString()] = totalNodesToPublish.ToString();
+ Application["publishDone" + _nodeId.ToString()] = "0";
}
finally
{
Application.UnLock();
}
- total.Text = TotalNodesToPublish.ToString();
+ total.Text = totalNodesToPublish.ToString();
// Put user code to initialize the page here
if (!IsPostBack)
{
// Add caption to checkbox
- PublishAll.Text = ui.Text("publish", "publishAll", d.Text, base.getUser());
- ok.Text = ui.Text("content", "publish", base.getUser());
+ PublishAll.Text = ui.Text("publish", "publishAll", d.Text, getUser());
+ ok.Text = ui.Text("content", "publish", getUser());
ok.Attributes.Add("style", "width: 60px");
ok.Attributes.Add("onClick", "startPublication();");
@@ -82,13 +81,13 @@ namespace umbraco.dialogs
if (PublishAll.Checked)
{
- nodesPublished = 0;
+ _nodesPublished = 0;
- doPublishSubs(d);
+ DoPublishSubs(d);
//PPH added load balancing...
//content.Instance.PublishNode(documents);
- foreach (cms.businesslogic.web.Document doc in documents)
+ foreach (var doc in _documents)
{
if (doc.Published)
{
@@ -97,32 +96,32 @@ namespace umbraco.dialogs
}
Application.Lock();
- Application["publishTotal" + nodeId.ToString()] = 0;
+ Application["publishTotal" + _nodeId.ToString()] = 0;
Application.UnLock();
- feedbackMsg.type = umbraco.uicontrols.Feedback.feedbacktype.success;
+ feedbackMsg.type = uicontrols.Feedback.feedbacktype.success;
- feedbackMsg.Text = ui.Text("publish", "nodePublishAll", d.Text, base.getUser()) + "
" + ui.Text("closeThisWindow") + "";
+ feedbackMsg.Text = ui.Text("publish", "nodePublishAll", d.Text, getUser()) + "
" + ui.Text("closeThisWindow") + "";
ClientTools.ReloadActionNode(true, true);
Application.Lock();
- Application["publishTotal" + nodeId.ToString()] = null;
- Application["publishDone" + nodeId.ToString()] = null;
+ Application["publishTotal" + _nodeId.ToString()] = null;
+ Application["publishDone" + _nodeId.ToString()] = null;
Application.UnLock();
}
else
{
- if (d.PublishWithResult(base.getUser()))
+ if (d.PublishWithResult(getUser()))
{
library.UpdateDocumentCache(d);
- feedbackMsg.type = umbraco.uicontrols.Feedback.feedbacktype.success;
- feedbackMsg.Text = ui.Text("publish", "nodePublish", d.Text, base.getUser()) + "
" + ui.Text("closeThisWindow") + "";
+ feedbackMsg.type = uicontrols.Feedback.feedbacktype.success;
+ feedbackMsg.Text = ui.Text("publish", "nodePublish", d.Text, getUser()) + "
" + ui.Text("closeThisWindow") + "";
}
else {
- feedbackMsg.type = umbraco.uicontrols.Feedback.feedbacktype.notice;
- feedbackMsg.Text = ui.Text("publish", "contentPublishedFailedByEvent", d.Text, base.getUser()) + "
" + ui.Text("closeThisWindow") + "";
+ feedbackMsg.type = uicontrols.Feedback.feedbacktype.notice;
+ feedbackMsg.Text = ui.Text("publish", "contentPublishedFailedByEvent", d.Text, getUser()) + "
" + ui.Text("closeThisWindow") + "";
}
ClientTools.ReloadActionNode(true, false);
}
@@ -130,10 +129,9 @@ namespace umbraco.dialogs
TheForm.Visible = false;
theEnd.Visible = true;
}
- }
- private System.Collections.Generic.List documents = new System.Collections.Generic.List();
+ }
- private void doPublishSubs(cms.businesslogic.web.Document d)
+ private void DoPublishSubs(cms.businesslogic.web.Document d)
{
if (d.Published || PublishUnpublishedItems.Checked)
{
@@ -143,29 +141,30 @@ namespace umbraco.dialogs
if (UmbracoSettings.UseDistributedCalls)
library.UpdateDocumentCache(d);
else
- documents.Add(d);
+ _documents.Add(d);
- nodesPublished++;
+ _nodesPublished++;
Application.Lock();
- Application["publishDone" + nodeId.ToString()] = nodesPublished.ToString();
+ Application["publishDone" + _nodeId.ToString()] = _nodesPublished.ToString();
Application.UnLock();
- foreach (cms.businesslogic.web.Document dc in d.Children)
+ foreach (var dc in d.Children)
{
- doPublishSubs(dc);
+ DoPublishSubs(dc);
}
}
- else {
- BusinessLogic.Log.Add(umbraco.BusinessLogic.LogTypes.Error, d.Id, "Publishing failed due to event cancelling the publishing");
+ else
+ {
+ LogHelper.Warn("Publishing failed due to event cancelling the publishing for document " + d.Id);
}
}
}
- protected override void OnPreRender(EventArgs e) {
- base.OnPreRender(e);
-
- ScriptManager.GetCurrent(Page).Services.Add(new ServiceReference("../webservices/publication.asmx"));
- ScriptManager.GetCurrent(Page).Services.Add(new ServiceReference("../webservices/legacyAjaxCalls.asmx"));
- }
+ protected override void OnPreRender(EventArgs e)
+ {
+ base.OnPreRender(e);
+ ScriptManager.GetCurrent(Page).Services.Add(new ServiceReference("../webservices/publication.asmx"));
+ ScriptManager.GetCurrent(Page).Services.Add(new ServiceReference("../webservices/legacyAjaxCalls.asmx"));
+ }
}
}
From 9684255e6e1179ac8516f803a9bc30f2ec03c344 Mon Sep 17 00:00:00 2001
From: Shannon Deminick
Date: Wed, 10 Apr 2013 01:58:22 +0600
Subject: [PATCH 05/29] ensures validation is correct in editContent, cleans up
some code.
---
.../umbraco/editContent.aspx.cs | 208 +++++++++---------
1 file changed, 103 insertions(+), 105 deletions(-)
diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/editContent.aspx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/editContent.aspx.cs
index 0b971a189a..9b838e184a 100644
--- a/src/Umbraco.Web/umbraco.presentation/umbraco/editContent.aspx.cs
+++ b/src/Umbraco.Web/umbraco.presentation/umbraco/editContent.aspx.cs
@@ -10,10 +10,10 @@ using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Reflection;
+using Umbraco.Core.IO;
using umbraco.BusinessLogic.Actions;
using umbraco.cms.businesslogic.language;
using umbraco.cms.helpers;
-using umbraco.IO;
using umbraco.uicontrols.DatePicker;
using umbraco.BusinessLogic;
using umbraco.presentation.preview;
@@ -29,27 +29,27 @@ namespace umbraco.cms.presentation
public partial class editContent : BasePages.UmbracoEnsuredPage
{
protected uicontrols.TabView TabView1;
- protected System.Web.UI.WebControls.TextBox documentName;
- private cms.businesslogic.web.Document _document;
+ protected TextBox documentName;
+ private Document _document;
private bool _documentHasPublishedVersion = false;
- protected System.Web.UI.WebControls.Literal jsIds;
- private LiteralControl dp = new LiteralControl();
- private DateTimePicker dpRelease = new DateTimePicker();
- private DateTimePicker dpExpire = new DateTimePicker();
+ protected Literal jsIds;
+ private readonly LiteralControl _dp = new LiteralControl();
+ private readonly DateTimePicker _dpRelease = new DateTimePicker();
+ private readonly DateTimePicker _dpExpire = new DateTimePicker();
- controls.ContentControl cControl;
+ private controls.ContentControl _cControl;
- DropDownList ddlDefaultTemplate = new DropDownList();
+ private readonly DropDownList _ddlDefaultTemplate = new DropDownList();
- uicontrols.Pane publishProps = new uicontrols.Pane();
- uicontrols.Pane linkProps = new uicontrols.Pane();
+ private readonly uicontrols.Pane _publishProps = new uicontrols.Pane();
+ private readonly uicontrols.Pane _linkProps = new uicontrols.Pane();
- Button UnPublish = new Button();
- private Literal littPublishStatus = new Literal();
+ private readonly Button _unPublish = new Button();
+ private readonly Literal _littPublishStatus = new Literal();
private controls.ContentControl.publishModes _canPublish = controls.ContentControl.publishModes.Publish;
- private int? m_ContentId = null;
+ private int? _contentId = null;
override protected void OnInit(EventArgs e)
{
@@ -63,10 +63,10 @@ namespace umbraco.cms.presentation
this.DisplayFatalError("Invalid query string");
return;
}
- m_ContentId = id;
+ _contentId = id;
- this.UnPublish.Click += new System.EventHandler(this.UnPublishDo);
+ _unPublish.Click += UnPublishDo;
//_document = new cms.businesslogic.web.Document(int.Parse(Request.QueryString["id"]));
_document = new Document(true, id);
@@ -75,9 +75,9 @@ namespace umbraco.cms.presentation
if (string.IsNullOrEmpty(_document.Path))
{
//if this is invalid show an error
- this.DisplayFatalError("No document found with id " + m_ContentId);
+ this.DisplayFatalError("No document found with id " + _contentId);
//reset the content id to null so processing doesn't continue on OnLoad
- m_ContentId = null;
+ _contentId = null;
return;
}
@@ -87,116 +87,116 @@ namespace umbraco.cms.presentation
// Check publishing permissions
if (!base.getUser().GetPermissions(_document.Path).Contains(ActionPublish.Instance.Letter.ToString()))
_canPublish = controls.ContentControl.publishModes.SendToPublish;
- cControl = new controls.ContentControl(_document, _canPublish, "TabView1");
+ _cControl = new controls.ContentControl(_document, _canPublish, "TabView1");
- cControl.ID = "TabView1";
+ _cControl.ID = "TabView1";
- cControl.Width = Unit.Pixel(666);
- cControl.Height = Unit.Pixel(666);
+ _cControl.Width = Unit.Pixel(666);
+ _cControl.Height = Unit.Pixel(666);
// Add preview button
- foreach (uicontrols.TabPage tp in cControl.GetPanels())
+ foreach (uicontrols.TabPage tp in _cControl.GetPanels())
{
- addPreviewButton(tp.Menu, _document.Id);
+ AddPreviewButton(tp.Menu, _document.Id);
}
- plc.Controls.Add(cControl);
+ plc.Controls.Add(_cControl);
- System.Web.UI.WebControls.PlaceHolder publishStatus = new PlaceHolder();
+ var publishStatus = new PlaceHolder();
if (_documentHasPublishedVersion)
{
- littPublishStatus.Text = ui.Text("content", "lastPublished", base.getUser()) + ": " + _document.VersionDate.ToShortDateString() + " ";
+ _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;
+ publishStatus.Controls.Add(_littPublishStatus);
+ if (getUser().GetPermissions(_document.Path).IndexOf("U") > -1)
+ _unPublish.Visible = true;
else
- UnPublish.Visible = false;
+ _unPublish.Visible = false;
}
else
{
- littPublishStatus.Text = ui.Text("content", "itemNotPublished", base.getUser());
- publishStatus.Controls.Add(littPublishStatus);
- UnPublish.Visible = false;
+ _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);
+ _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);
+ _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);
- cControl.PropertiesPane.addProperty(ui.Text("documentType"), new LiteralControl(DocumentType.Text));
+ var template = new PlaceHolder();
+ var DocumentType = new DocumentType(_document.ContentType.Id);
+ _cControl.PropertiesPane.addProperty(ui.Text("documentType"), new LiteralControl(DocumentType.Text));
//template picker
- cControl.PropertiesPane.addProperty(ui.Text("template"), template);
+ _cControl.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 (getUser().UserType.Name == "writer")
{
if (defaultTemplate != 0)
- template.Controls.Add(new LiteralControl(cms.businesslogic.template.Template.GetTemplate(defaultTemplate).Text));
+ template.Controls.Add(new LiteralControl(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)
+ _ddlDefaultTemplate.Items.Add(new ListItem(ui.Text("choose") + "...", ""));
+ foreach (var t in DocumentType.allowedTemplates)
{
- ListItem tTemp = new ListItem(t.Text, t.Id.ToString());
+ var tTemp = new ListItem(t.Text, t.Id.ToString());
if (t.Id == defaultTemplate)
tTemp.Selected = true;
- ddlDefaultTemplate.Items.Add(tTemp);
+ _ddlDefaultTemplate.Items.Add(tTemp);
}
- template.Controls.Add(ddlDefaultTemplate);
+ 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);
+ _dp.ID = "updateDate";
+ _dp.Text = _document.UpdateDate.ToShortDateString() + " " + _document.UpdateDate.ToShortTimeString();
+ _publishProps.addProperty(ui.Text("content", "updateDate", getUser()), _dp);
- dpRelease.ID = "releaseDate";
- dpRelease.DateTime = _document.ReleaseDate;
- dpRelease.ShowTime = true;
- publishProps.addProperty(ui.Text("content", "releaseDate", base.getUser()), dpRelease);
+ _dpRelease.ID = "releaseDate";
+ _dpRelease.DateTime = _document.ReleaseDate;
+ _dpRelease.ShowTime = true;
+ _publishProps.addProperty(ui.Text("content", "releaseDate", getUser()), _dpRelease);
- dpExpire.ID = "expireDate";
- dpExpire.DateTime = _document.ExpireDate;
- dpExpire.ShowTime = true;
- publishProps.addProperty(ui.Text("content", "expireDate", base.getUser()), dpExpire);
+ _dpExpire.ID = "expireDate";
+ _dpExpire.DateTime = _document.ExpireDate;
+ _dpExpire.ShowTime = true;
+ _publishProps.addProperty(ui.Text("content", "expireDate", getUser()), _dpExpire);
- cControl.Save += new System.EventHandler(Save);
- cControl.SaveAndPublish += new System.EventHandler(Publish);
- cControl.SaveToPublish += new System.EventHandler(SendToPublish);
+ _cControl.Save += Save;
+ _cControl.SaveAndPublish += Publish;
+ _cControl.SaveToPublish += SendToPublish;
// Add panes to property page...
- cControl.tpProp.Controls.AddAt(1, publishProps);
- cControl.tpProp.Controls.AddAt(2, linkProps);
+ _cControl.tpProp.Controls.AddAt(1, _publishProps);
+ _cControl.tpProp.Controls.AddAt(2, _linkProps);
// add preview to properties pane too
- addPreviewButton(cControl.tpProp.Menu, _document.Id);
+ AddPreviewButton(_cControl.tpProp.Menu, _document.Id);
}
- protected void Page_Load(object sender, System.EventArgs e)
+ protected void Page_Load(object sender, EventArgs e)
{
- if (!m_ContentId.HasValue)
+ if (!_contentId.HasValue)
return;
if (!CheckUserValidation())
@@ -209,7 +209,7 @@ namespace umbraco.cms.presentation
if (!IsPostBack)
{
- BusinessLogic.Log.Add(BusinessLogic.LogTypes.Open, base.getUser(), _document.Id, "");
+ Log.Add(LogTypes.Open, base.getUser(), _document.Id, "");
ClientTools.SyncTree(_document.Path, false);
}
@@ -224,12 +224,12 @@ namespace umbraco.cms.presentation
UpdateNiceUrls();
}
- protected void Save(object sender, System.EventArgs e)
+ protected void Save(object sender, EventArgs e)
{
// error handling test
if (!Page.IsValid)
{
- foreach (uicontrols.TabPage tp in cControl.GetPanels())
+ foreach (uicontrols.TabPage tp in _cControl.GetPanels())
{
tp.ErrorControl.Visible = true;
tp.ErrorHeader = ui.Text("errorHandling", "errorButDataWasSaved");
@@ -239,36 +239,36 @@ namespace umbraco.cms.presentation
else if (Page.IsPostBack)
{
// hide validation summaries
- foreach (uicontrols.TabPage tp in cControl.GetPanels())
+ foreach (uicontrols.TabPage tp in _cControl.GetPanels())
{
tp.ErrorControl.Visible = false;
}
}
//Audit trail...
- BusinessLogic.Log.Add(BusinessLogic.LogTypes.Save, base.getUser(), _document.Id, "");
+ Log.Add(LogTypes.Save, getUser(), _document.Id, "");
// Update name
- if (_document.Text != cControl.NameTxt.Text)
+ if (_document.Text != _cControl.NameTxt.Text)
{
//_refreshTree = true;
- _document.Text = cControl.NameTxt.Text;
+ _document.Text = _cControl.NameTxt.Text;
//newName.Text = _document.Text;
}
- if (dpRelease.DateTime > new DateTime(1753, 1, 1) && dpRelease.DateTime < new DateTime(9999, 12, 31))
- _document.ReleaseDate = dpRelease.DateTime;
+ if (_dpRelease.DateTime > new DateTime(1753, 1, 1) && _dpRelease.DateTime < new DateTime(9999, 12, 31))
+ _document.ReleaseDate = _dpRelease.DateTime;
else
_document.ReleaseDate = new DateTime(1, 1, 1, 0, 0, 0);
- if (dpExpire.DateTime > new DateTime(1753, 1, 1) && dpExpire.DateTime < new DateTime(9999, 12, 31))
- _document.ExpireDate = dpExpire.DateTime;
+ if (_dpExpire.DateTime > new DateTime(1753, 1, 1) && _dpExpire.DateTime < new DateTime(9999, 12, 31))
+ _document.ExpireDate = _dpExpire.DateTime;
else
_document.ExpireDate = new DateTime(1, 1, 1, 0, 0, 0);
// Update default template
- if (ddlDefaultTemplate.SelectedIndex > 0)
+ if (_ddlDefaultTemplate.SelectedIndex > 0)
{
- _document.Template = int.Parse(ddlDefaultTemplate.SelectedValue);
+ _document.Template = int.Parse(_ddlDefaultTemplate.SelectedValue);
}
else
{
@@ -286,28 +286,28 @@ namespace umbraco.cms.presentation
_document.Save();
// Update the update date
- dp.Text = _document.UpdateDate.ToShortDateString() + " " + _document.UpdateDate.ToShortTimeString();
+ _dp.Text = _document.UpdateDate.ToShortDateString() + " " + _document.UpdateDate.ToShortTimeString();
- if (!cControl.DoesPublish)
+ if (!_cControl.DoesPublish)
ClientTools.ShowSpeechBubble(speechBubbleIcon.save, ui.Text("speechBubbles", "editContentSavedHeader", null), ui.Text("speechBubbles", "editContentSavedText", null));
ClientTools.SyncTree(_document.Path, true);
}
- protected void SendToPublish(object sender, System.EventArgs e)
+ protected void SendToPublish(object sender, EventArgs e)
{
if (Page.IsValid)
{
ClientTools.ShowSpeechBubble(speechBubbleIcon.save, ui.Text("speechBubbles", "editContentSendToPublish", base.getUser()), ui.Text("speechBubbles", "editContentSendToPublishText", base.getUser()));
- _document.SendToPublication(base.getUser());
+ _document.SendToPublication(getUser());
}
}
- protected void Publish(object sender, System.EventArgs e)
+ protected void Publish(object sender, EventArgs e)
{
if (Page.IsValid)
{
- if (_document.Level == 1 || new cms.businesslogic.web.Document(_document.Parent.Id).PathPublished)
+ if (_document.Level == 1 || new Document(_document.Parent.Id).PathPublished)
{
var previouslyPublished = _document.Published;
@@ -319,10 +319,10 @@ namespace umbraco.cms.presentation
ClientTools.ShowSpeechBubble(speechBubbleIcon.save, ui.Text("speechBubbles", "editContentPublishedHeader", null), ui.Text("speechBubbles", "editContentPublishedText", null));
library.UpdateDocumentCache(_document);
- littPublishStatus.Text = ui.Text("content", "lastPublished", base.getUser()) + ": " + _document.VersionDate.ToString() + "
";
+ _littPublishStatus.Text = ui.Text("content", "lastPublished", base.getUser()) + ": " + _document.VersionDate.ToString() + "
";
- if (base.getUser().GetPermissions(_document.Path).IndexOf("U") > -1)
- UnPublish.Visible = true;
+ if (getUser().GetPermissions(_document.Path).IndexOf("U") > -1)
+ _unPublish.Visible = true;
if (previouslyPublished == false)
@@ -352,11 +352,11 @@ namespace umbraco.cms.presentation
}
}
- protected void UnPublishDo(object sender, System.EventArgs e)
+ protected void UnPublishDo(object sender, EventArgs e)
{
_document.UnPublish();
- littPublishStatus.Text = ui.Text("content", "itemNotPublished", base.getUser());
- UnPublish.Visible = false;
+ _littPublishStatus.Text = ui.Text("content", "itemNotPublished", base.getUser());
+ _unPublish.Visible = false;
_documentHasPublishedVersion = false;
library.UnPublishSingleNode(_document.Id);
@@ -369,19 +369,17 @@ namespace umbraco.cms.presentation
void UpdateNiceUrlProperties(string niceUrlText, string altUrlsText)
{
- Literal lit;
+ _linkProps.Controls.Clear();
- linkProps.Controls.Clear();
-
- lit = new Literal();
+ var lit = new Literal();
lit.Text = niceUrlText;
- linkProps.addProperty(ui.Text("content", "urls", base.getUser()), lit);
+ _linkProps.addProperty(ui.Text("content", "urls", getUser()), lit);
if (!string.IsNullOrWhiteSpace(altUrlsText))
{
lit = new Literal();
lit.Text = altUrlsText;
- linkProps.addProperty(ui.Text("content", "alternativeUrls", base.getUser()), lit);
+ _linkProps.addProperty(ui.Text("content", "alternativeUrls", getUser()), lit);
}
}
@@ -442,18 +440,18 @@ namespace umbraco.cms.presentation
private bool CheckUserValidation()
{
// Validate permissions
- if (!base.ValidateUserApp("content"))
+ if (!ValidateUserApp("content"))
{
ShowUserValidationError("The current user doesn't have access to this application. Please contact the system administrator.");
return false;
}
- if (!base.ValidateUserNodeTreePermissions(_document.Path, ActionBrowse.Instance.Letter.ToString()))
+ if (!ValidateUserNodeTreePermissions(_document.Path, ActionBrowse.Instance.Letter.ToString()))
{
ShowUserValidationError("The current user doesn't have permissions to browse this document. Please contact the system administrator.");
return false;
}
//TODO: Change this, when we add view capabilities, the user will be able to view but not edit!
- if (!base.ValidateUserNodeTreePermissions(_document.Path, ActionUpdate.Instance.Letter.ToString()))
+ if (!ValidateUserNodeTreePermissions(_document.Path, ActionUpdate.Instance.Letter.ToString()))
{
ShowUserValidationError("The current user doesn't have permissions to edit this document. Please contact the system administrator.");
return false;
@@ -461,10 +459,10 @@ namespace umbraco.cms.presentation
return true;
}
- private void addPreviewButton(uicontrols.ScrollingMenu menu, int id)
+ private void AddPreviewButton(uicontrols.ScrollingMenu menu, int id)
{
menu.InsertSplitter(2);
- uicontrols.MenuIconI menuItem = menu.NewIcon(3);
+ var menuItem = menu.NewIcon(3);
menuItem.ImageURL = SystemDirectories.Umbraco + "/images/editor/vis.gif";
// Fix for U4-682, if there's no template, disable the preview button
if (_document.Template != -1)
From a50e192ab76ea175d7859390363d1a5c1a3652c1 Mon Sep 17 00:00:00 2001
From: Shannon Deminick
Date: Wed, 10 Apr 2013 02:03:04 +0600
Subject: [PATCH 06/29] updates #U4-2070 for sort.aspx
---
.../umbraco/dialogs/sort.aspx.cs | 90 +++++++------------
1 file changed, 34 insertions(+), 56 deletions(-)
diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/sort.aspx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/sort.aspx.cs
index ba370db88b..8348ae2b52 100644
--- a/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/sort.aspx.cs
+++ b/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/sort.aspx.cs
@@ -17,19 +17,20 @@ namespace umbraco.cms.presentation
///
public partial class sort : UmbracoEnsuredPage
{
- private int parentId;
- private List _nodes = new List();
+ private readonly List _nodes = new List();
+
+ protected override void OnInit(EventArgs e)
+ {
+ CurrentApp = helper.Request("app");
+
+ base.OnInit(e);
+ }
protected void Page_Load(object sender, EventArgs e)
{
- parentId = int.Parse(Request.QueryString["id"]);
-
sortDone.Text = ui.Text("sort", "sortDone");
-
-
}
-
protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);
@@ -37,49 +38,49 @@ namespace umbraco.cms.presentation
ScriptManager.GetCurrent(Page).Services.Add(new ServiceReference("../webservices/nodesorter.asmx"));
ScriptManager.GetCurrent(Page).Services.Add(new ServiceReference("../webservices/legacyAjaxCalls.asmx"));
- int ParentId = 0;
- string App = umbraco.helper.Request("app");
- string icon = "../images/umbraco/doc.gif";
+ var parentId = 0;
+
+ var icon = "../images/umbraco/doc.gif";
- if (int.TryParse(umbraco.helper.Request("ID"), out ParentId))
+ if (int.TryParse(helper.Request("ID"), out parentId))
{
- if (ParentId == -1)
+ if (parentId == -1)
{
- if (App == "media")
+ if (CurrentApp == "media")
{
icon = "../images/umbraco/mediaPhoto.gif";
- foreach (cms.businesslogic.media.Media child in cms.businesslogic.media.Media.GetRootMedias())
- _nodes.Add(createNode(child.Id, child.sortOrder, child.Text, child.CreateDateTime, icon));
+ foreach (var child in Media.GetRootMedias())
+ _nodes.Add(CreateNode(child.Id, child.sortOrder, child.Text, child.CreateDateTime, icon));
}
else
{
- foreach (cms.businesslogic.web.Document child in cms.businesslogic.web.Document.GetRootDocuments())
+ foreach (var child in Document.GetRootDocuments())
{
- _nodes.Add(createNode(child.Id, child.sortOrder, child.Text, child.CreateDateTime, icon));
+ _nodes.Add(CreateNode(child.Id, child.sortOrder, child.Text, child.CreateDateTime, icon));
}
}
}
else
{
// "hack for stylesheet"
- cms.businesslogic.CMSNode n = new cms.businesslogic.CMSNode(ParentId);
- if (App == "settings")
+ var n = new CMSNode(parentId);
+ if (CurrentApp == "settings")
{
icon = "../images/umbraco/settingCss.gif";
- StyleSheet ss = new StyleSheet(n.Id);
- foreach (cms.businesslogic.web.StylesheetProperty child in ss.Properties)
- _nodes.Add(createNode(child.Id, child.sortOrder, child.Text, child.CreateDateTime, icon));
+ var ss = new StyleSheet(n.Id);
+ foreach (var child in ss.Properties)
+ _nodes.Add(CreateNode(child.Id, child.sortOrder, child.Text, child.CreateDateTime, icon));
}
else
{
//store children array here because iterating over an Array property object is very inneficient.
var children = n.Children;
- foreach (cms.businesslogic.CMSNode child in children)
- _nodes.Add(createNode(child.Id, child.sortOrder, child.Text, child.CreateDateTime, icon));
+ foreach (CMSNode child in children)
+ _nodes.Add(CreateNode(child.Id, child.sortOrder, child.Text, child.CreateDateTime, icon));
}
}
@@ -100,29 +101,27 @@ namespace umbraco.cms.presentation
case "createDate":
_nodes.Sort(new createDateCompare());
break;
- default:
- break;
}
}
//lt_nodes.Text = "";
- foreach (SortableNode n in _nodes)
+ foreach (var n in _nodes)
{
lt_nodes.Text += "| " + n.Name + " | " + n.createDate.ToShortDateString() + " " + n.createDate.ToShortTimeString() + " | " + n.sortOder + " |
";
}
}
- private static SortableNode createNode(int id, int sortOrder, string name, DateTime createDateTime, string icon)
+ private static SortableNode CreateNode(int id, int sortOrder, string name, DateTime createDateTime, string icon)
{
- SortableNode _node = new SortableNode();
- _node.id = id;
- _node.sortOder = sortOrder;
- _node.Name = name;
- _node.icon = icon;
- _node.createDate = createDateTime;
- return _node;
+ var node = new SortableNode();
+ node.id = id;
+ node.sortOder = sortOrder;
+ node.Name = name;
+ node.icon = icon;
+ node.createDate = createDateTime;
+ return node;
}
public struct SortableNode
@@ -134,27 +133,6 @@ namespace umbraco.cms.presentation
public DateTime createDate;
}
-
- #region Web Form Designer generated code
-
- protected override void OnInit(EventArgs e)
- {
- //
- // CODEGEN: This call is required by the ASP.NET Web Form Designer.
- //
- InitializeComponent();
- base.OnInit(e);
- }
-
- ///
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- ///
- private void InitializeComponent()
- {
- }
-
- #endregion
}
public class nodeNameCompare : IComparer
From 205bf5fe4e231d1a189e447c9f4b0ff6f4fad121 Mon Sep 17 00:00:00 2001
From: Shannon Deminick
Date: Wed, 10 Apr 2013 02:05:52 +0600
Subject: [PATCH 07/29] updates #U4-2070 for EditRelationType.aspx
---
.../RelationTypes/EditRelationType.aspx.cs | 86 ++++++++++---------
1 file changed, 45 insertions(+), 41 deletions(-)
diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/developer/RelationTypes/EditRelationType.aspx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/developer/RelationTypes/EditRelationType.aspx.cs
index 81e8d264d3..765d628df3 100644
--- a/src/Umbraco.Web/umbraco.presentation/umbraco/developer/RelationTypes/EditRelationType.aspx.cs
+++ b/src/Umbraco.Web/umbraco.presentation/umbraco/developer/RelationTypes/EditRelationType.aspx.cs
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Web.UI;
using System.Web.UI.WebControls;
using umbraco.BasePages;
+using umbraco.BusinessLogic;
using umbraco.cms.businesslogic.relation;
using umbraco.DataLayer;
using umbraco.uicontrols;
@@ -14,26 +15,31 @@ namespace umbraco.cms.presentation.developer.RelationTypes
///
public partial class EditRelationType : UmbracoEnsuredPage
{
+ public EditRelationType()
+ {
+ CurrentApp = DefaultApps.developer.ToString();
+ }
+
///
/// Class scope reference to the current RelationType being edited
///
- private RelationType relationType = null;
+ private RelationType _relationType = null;
///
/// Class scope reference to the relations associated with the current RelationType
///
- private List relations = null;
+ private List _relations = null;
///
/// Umbraco ObjectType used to represent all parent items in this relation type
///
///
- private uQuery.UmbracoObjectType parentObjectType = uQuery.UmbracoObjectType.Unknown;
+ private uQuery.UmbracoObjectType _parentObjectType = uQuery.UmbracoObjectType.Unknown;
///
/// Umbraco ObjectType used to represent all child items in this relation type
///
- private uQuery.UmbracoObjectType childObjectType = uQuery.UmbracoObjectType.Unknown;
+ private uQuery.UmbracoObjectType _childObjectType = uQuery.UmbracoObjectType.Unknown;
///
/// Gets the name of the parent object type for all relations in this relation type
@@ -42,7 +48,7 @@ namespace umbraco.cms.presentation.developer.RelationTypes
{
get
{
- return this.parentObjectType.GetName(); //UmbracoHelper.GetName(this.parentObjectType);
+ return this._parentObjectType.GetName(); //UmbracoHelper.GetName(this.parentObjectType);
}
}
@@ -53,7 +59,7 @@ namespace umbraco.cms.presentation.developer.RelationTypes
{
get
{
- return this.childObjectType.GetName(); //UmbracoHelper.GetName(this.childObjectType);
+ return this._childObjectType.GetName(); //UmbracoHelper.GetName(this.childObjectType);
}
}
@@ -64,7 +70,7 @@ namespace umbraco.cms.presentation.developer.RelationTypes
{
get
{
- return this.relationType.Dual == true ? "bidirectional" : "parentToChild";
+ return this._relationType.Dual == true ? "bidirectional" : "parentToChild";
}
}
@@ -75,13 +81,11 @@ namespace umbraco.cms.presentation.developer.RelationTypes
{
get
{
- if (this.relations == null)
+ if (this._relations == null)
{
- this.relations = new List();
+ this._relations = new List();
- ReadOnlyRelation readOnlyRelation;
-
- using (IRecordsReader reader = uQuery.SqlHelper.ExecuteReader(@"
+ using (var reader = uQuery.SqlHelper.ExecuteReader(@"
SELECT A.id,
A.parentId,
B.[text] AS parentText,
@@ -93,11 +97,11 @@ namespace umbraco.cms.presentation.developer.RelationTypes
FROM umbracoRelation A
LEFT OUTER JOIN umbracoNode B ON A.parentId = B.id
LEFT OUTER JOIN umbracoNode C ON A.childId = C.id
- WHERE A.relType = " + this.relationType.Id.ToString()))
+ WHERE A.relType = " + this._relationType.Id.ToString()))
{
while (reader.Read())
{
- readOnlyRelation = new ReadOnlyRelation();
+ var readOnlyRelation = new ReadOnlyRelation();
readOnlyRelation.Id = reader.GetInt("id");
readOnlyRelation.ParentId = reader.GetInt("parentId");
@@ -108,12 +112,12 @@ namespace umbraco.cms.presentation.developer.RelationTypes
readOnlyRelation.DateTime = reader.GetDateTime("datetime");
readOnlyRelation.Comment = reader.GetString("comment");
- this.relations.Add(readOnlyRelation);
+ this._relations.Add(readOnlyRelation);
}
}
}
- return this.relations;
+ return this._relations;
}
}
@@ -127,16 +131,16 @@ namespace umbraco.cms.presentation.developer.RelationTypes
int id;
if (int.TryParse(Request.QueryString["id"], out id))
{
- this.relationType = new RelationType(id);
- if (this.relationType != null)
+ this._relationType = new RelationType(id);
+ if (this._relationType != null)
{
// API doens't allow us to pull the object Type, so sql needed
// this.parentObjectType = UmbracoHelper.GetUmbracoObjectType(uQuery.SqlHelper.ExecuteScalar("SELECT parentObjectType FROM umbracoRelationType WHERE id = " + this.relationType.Id.ToString()));
// this.childObjectType = UmbracoHelper.GetUmbracoObjectType(uQuery.SqlHelper.ExecuteScalar("SELECT childObjectType FROM umbracoRelationType WHERE id = " + this.relationType.Id.ToString()));
// uQuery has the above in a helper method, so no sql needed now
- this.parentObjectType = this.relationType.GetParentUmbracoObjectType();
- this.childObjectType = this.relationType.GetChildUmbracoObjectType();
+ this._parentObjectType = this._relationType.GetParentUmbracoObjectType();
+ this._childObjectType = this._relationType.GetChildUmbracoObjectType();
// -----------
@@ -144,11 +148,11 @@ namespace umbraco.cms.presentation.developer.RelationTypes
{
this.EnsureChildControls();
- this.idLiteral.Text = this.relationType.Id.ToString();
- this.nameTextBox.Text = this.relationType.Name;
- this.aliasTextBox.Text = this.relationType.Alias;
+ this.idLiteral.Text = this._relationType.Id.ToString();
+ this.nameTextBox.Text = this._relationType.Name;
+ this.aliasTextBox.Text = this._relationType.Alias;
- if (this.relationType.Dual)
+ if (this._relationType.Dual)
{
this.dualRadioButtonList.Items.FindByValue("1").Selected = true;
}
@@ -157,8 +161,8 @@ namespace umbraco.cms.presentation.developer.RelationTypes
this.dualRadioButtonList.Items.FindByValue("0").Selected = true;
}
- this.parentLiteral.Text = this.parentObjectType.GetFriendlyName(); // UmbracoHelper.GetFriendlyName(this.parentObjectType);
- this.childLiteral.Text = this.childObjectType.GetFriendlyName(); // UmbracoHelper.GetFriendlyName(this.childObjectType);
+ this.parentLiteral.Text = this._parentObjectType.GetFriendlyName(); // UmbracoHelper.GetFriendlyName(this.parentObjectType);
+ this.childLiteral.Text = this._childObjectType.GetFriendlyName(); // UmbracoHelper.GetFriendlyName(this.childObjectType);
this.relationsCountLiteral.Text = this.Relations.Count.ToString();
@@ -184,26 +188,26 @@ namespace umbraco.cms.presentation.developer.RelationTypes
{
base.CreateChildControls();
- TabPage relationTypeTabPage = this.tabControl.NewTabPage("Relation Type");
+ var relationTypeTabPage = this.tabControl.NewTabPage("Relation Type");
relationTypeTabPage.Controls.Add(this.idPane);
relationTypeTabPage.Controls.Add(this.nameAliasPane);
relationTypeTabPage.Controls.Add(this.directionPane);
relationTypeTabPage.Controls.Add(this.objectTypePane);
- MenuImageButton saveMenuImageButton = relationTypeTabPage.Menu.NewImageButton();
+ var saveMenuImageButton = relationTypeTabPage.Menu.NewImageButton();
saveMenuImageButton.AlternateText = "save relation type";
- saveMenuImageButton.Click += new ImageClickEventHandler(this.SaveMenuImageButton_Click);
+ saveMenuImageButton.Click += this.SaveMenuImageButton_Click;
saveMenuImageButton.ImageURL = "/umbraco/images/editor/save.gif";
saveMenuImageButton.CausesValidation = true;
saveMenuImageButton.ValidationGroup = "RelationType";
- TabPage relationsTabPage = this.tabControl.NewTabPage("Relations");
+ var relationsTabPage = this.tabControl.NewTabPage("Relations");
relationsTabPage.Controls.Add(this.relationsCountPane);
relationsTabPage.Controls.Add(this.relationsPane);
- MenuImageButton refreshMenuImageButton = relationsTabPage.Menu.NewImageButton();
+ var refreshMenuImageButton = relationsTabPage.Menu.NewImageButton();
refreshMenuImageButton.AlternateText = "refresh relations";
- refreshMenuImageButton.Click += new ImageClickEventHandler(this.RefreshMenuImageButton_Click);
+ refreshMenuImageButton.Click += this.RefreshMenuImageButton_Click;
refreshMenuImageButton.ImageUrl = "/umbraco/developer/RelationTypes/Images/Refresh.gif";
refreshMenuImageButton.CausesValidation = false;
}
@@ -216,7 +220,7 @@ namespace umbraco.cms.presentation.developer.RelationTypes
protected void AliasCustomValidator_ServerValidate(object source, ServerValidateEventArgs args)
{
args.IsValid = (RelationType.GetByAlias(this.aliasTextBox.Text.Trim()) == null) ||
- (this.aliasTextBox.Text.Trim() == this.relationType.Alias);
+ (this.aliasTextBox.Text.Trim() == this._relationType.Alias);
}
///
@@ -237,9 +241,9 @@ namespace umbraco.cms.presentation.developer.RelationTypes
{
if (this.Page.IsValid)
{
- bool nameChanged = this.relationType.Name != this.nameTextBox.Text.Trim();
- bool aliasChanged = this.relationType.Alias != this.aliasTextBox.Text.Trim();
- bool directionChanged = this.relationType.Dual != (this.dualRadioButtonList.SelectedValue == "1");
+ var nameChanged = this._relationType.Name != this.nameTextBox.Text.Trim();
+ var aliasChanged = this._relationType.Alias != this.aliasTextBox.Text.Trim();
+ var directionChanged = this._relationType.Dual != (this.dualRadioButtonList.SelectedValue == "1");
if (nameChanged || aliasChanged || directionChanged)
{
@@ -249,28 +253,28 @@ namespace umbraco.cms.presentation.developer.RelationTypes
{
bubbleBody += "Name, ";
- this.relationType.Name = this.nameTextBox.Text.Trim();
+ this._relationType.Name = this.nameTextBox.Text.Trim();
// Refresh tree, as the name as changed
- BasePage.Current.ClientTools.SyncTree(this.relationType.Id.ToString(), true);
+ ClientTools.SyncTree(this._relationType.Id.ToString(), true);
}
if (directionChanged)
{
bubbleBody += "Direction, ";
- this.relationType.Dual = this.dualRadioButtonList.SelectedValue == "1";
+ this._relationType.Dual = this.dualRadioButtonList.SelectedValue == "1";
}
if (aliasChanged)
{
bubbleBody += "Alias, ";
- this.relationType.Alias = this.aliasTextBox.Text.Trim();
+ this._relationType.Alias = this.aliasTextBox.Text.Trim();
}
bubbleBody = bubbleBody.Remove(bubbleBody.LastIndexOf(','), 1);
bubbleBody = bubbleBody + "Changed";
- BasePage.Current.ClientTools.ShowSpeechBubble(speechBubbleIcon.save, "Relation Type Updated", bubbleBody);
+ ClientTools.ShowSpeechBubble(speechBubbleIcon.save, "Relation Type Updated", bubbleBody);
}
}
}
From 1838a8dac5d5fab1d8615fcf28302ae549f5ec2b Mon Sep 17 00:00:00 2001
From: Shannon Deminick
Date: Wed, 10 Apr 2013 02:07:16 +0600
Subject: [PATCH 08/29] updates #U4-2070 for NewRelationType.aspx
---
.../RelationTypes/NewRelationType.aspx.cs | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/developer/RelationTypes/NewRelationType.aspx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/developer/RelationTypes/NewRelationType.aspx.cs
index 4090798362..af7a4e7658 100644
--- a/src/Umbraco.Web/umbraco.presentation/umbraco/developer/RelationTypes/NewRelationType.aspx.cs
+++ b/src/Umbraco.Web/umbraco.presentation/umbraco/developer/RelationTypes/NewRelationType.aspx.cs
@@ -1,6 +1,7 @@
using System;
using System.Web.UI.WebControls;
using umbraco.BasePages;
+using umbraco.BusinessLogic;
using umbraco.cms.businesslogic.relation;
namespace umbraco.cms.presentation.developer.RelationTypes
@@ -10,6 +11,11 @@ namespace umbraco.cms.presentation.developer.RelationTypes
///
public partial class NewRelationType : UmbracoEnsuredPage
{
+ public NewRelationType()
+ {
+ CurrentApp = DefaultApps.developer.ToString();
+ }
+
///
/// On Load event
///
@@ -44,9 +50,9 @@ namespace umbraco.cms.presentation.developer.RelationTypes
/// expects EventArgs for addButton
protected void AddButton_Click(object sender, EventArgs e)
{
- if (this.Page.IsValid)
+ if (Page.IsValid)
{
- string newRelationTypeAlias = this.aliasTextBox.Text.Trim();
+ var newRelationTypeAlias = this.aliasTextBox.Text.Trim();
uQuery.SqlHelper.ExecuteNonQuery(
string.Format("INSERT INTO umbracoRelationType ([dual], parentObjectType, childObjectType, name, alias) VALUES ({0}, '{1}', '{2}', '{3}', '{4}')",
@@ -56,11 +62,11 @@ namespace umbraco.cms.presentation.developer.RelationTypes
this.descriptionTextBox.Text,
newRelationTypeAlias));
- int newRelationTypeId = uQuery.SqlHelper.ExecuteScalar("SELECT id FROM umbracoRelationType WHERE alias = '" + newRelationTypeAlias + "'");
+ var newRelationTypeId = uQuery.SqlHelper.ExecuteScalar("SELECT id FROM umbracoRelationType WHERE alias = '" + newRelationTypeAlias + "'");
// base.speechBubble(BasePage.speechBubbleIcon.success, "New Relation Type", "relation type created");
- BasePage.Current.ClientTools.ChangeContentFrameUrl("/umbraco/developer/RelationTypes/EditRelationType.aspx?id=" + newRelationTypeId.ToString()).CloseModalWindow().ChildNodeCreated();
+ ClientTools.ChangeContentFrameUrl("/umbraco/developer/RelationTypes/EditRelationType.aspx?id=" + newRelationTypeId.ToString()).CloseModalWindow().ChildNodeCreated();
}
}
From 036b888d30df45a69fffc6c54554e0c0037b5bbd Mon Sep 17 00:00:00 2001
From: Shannon Deminick
Date: Wed, 10 Apr 2013 02:08:56 +0600
Subject: [PATCH 09/29] updates #U4-2070 for ShowUmbracoTags.aspx
---
.../umbraco/settings/modals/ShowUmbracoTags.aspx.cs | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/settings/modals/ShowUmbracoTags.aspx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/settings/modals/ShowUmbracoTags.aspx.cs
index fb594ac657..d79da04cfb 100644
--- a/src/Umbraco.Web/umbraco.presentation/umbraco/settings/modals/ShowUmbracoTags.aspx.cs
+++ b/src/Umbraco.Web/umbraco.presentation/umbraco/settings/modals/ShowUmbracoTags.aspx.cs
@@ -8,17 +8,23 @@ using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
+using umbraco.BusinessLogic;
namespace umbraco.cms.presentation.settings.modal
{
///
/// Summary description for ShowUmbracoTags.
///
- public partial class ShowUmbracoTags : umbraco.BasePages.UmbracoEnsuredPage
+ public partial class ShowUmbracoTags : BasePages.UmbracoEnsuredPage
{
+ public ShowUmbracoTags()
+ {
+ CurrentApp = DefaultApps.settings.ToString();
+ }
+
public static string alias = "";
- protected void Page_Load(object sender, System.EventArgs e)
+ protected void Page_Load(object sender, EventArgs e)
{
alias = Request.QueryString["alias"].Replace(" ", "").Trim();
// Put user code to initialize the page here
@@ -31,6 +37,6 @@ namespace umbraco.cms.presentation.settings.modal
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
///
- protected global::umbraco.uicontrols.Pane Pane7;
+ protected uicontrols.Pane Pane7;
}
}
From bf024e901146d0ced05e8c6103da76cfebfb82ac Mon Sep 17 00:00:00 2001
From: Shannon Deminick
Date: Wed, 10 Apr 2013 02:14:13 +0600
Subject: [PATCH 10/29] updates #U4-2070 for assemblyBrowser.aspx
---
.../developer/Macros/assemblyBrowser.aspx.cs | 142 +++++++-----------
1 file changed, 54 insertions(+), 88 deletions(-)
diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/developer/Macros/assemblyBrowser.aspx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/developer/Macros/assemblyBrowser.aspx.cs
index 848d5eba40..b1e7ddf6e0 100644
--- a/src/Umbraco.Web/umbraco.presentation/umbraco/developer/Macros/assemblyBrowser.aspx.cs
+++ b/src/Umbraco.Web/umbraco.presentation/umbraco/developer/Macros/assemblyBrowser.aspx.cs
@@ -3,6 +3,7 @@ using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
+using System.Linq;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
@@ -10,10 +11,10 @@ using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Reflection;
using System.Collections.Specialized;
-
+using Umbraco.Core.IO;
+using umbraco.BusinessLogic;
using umbraco.cms.businesslogic.macro;
using System.Collections.Generic;
-using umbraco.IO;
namespace umbraco.developer
{
@@ -22,15 +23,16 @@ namespace umbraco.developer
///
public partial class assemblyBrowser : BasePages.UmbracoEnsuredPage
{
+ public assemblyBrowser()
+ {
+ CurrentApp = DefaultApps.developer.ToString();
+ }
- private string _ConnString = GlobalSettings.DbDSN;
- protected void Page_Load(object sender, System.EventArgs e)
+ protected void Page_Load(object sender, EventArgs e)
{
- // if (!IsPostBack)
- // {
- bool isUserControl = false;
- bool errorReadingControl = false;
+ var isUserControl = false;
+ var errorReadingControl = false;
try
{
@@ -39,7 +41,7 @@ namespace umbraco.developer
if (Request.QueryString["type"] == null)
{
isUserControl = true;
- string fileName = Request.QueryString["fileName"];
+ var fileName = Request.QueryString["fileName"];
if (!fileName.StartsWith("~"))
{
if (fileName.StartsWith("/"))
@@ -51,12 +53,11 @@ namespace umbraco.developer
fileName = "~/" + fileName;
}
}
- IOHelper.ValidateEditPath(fileName, SystemDirectories.Usercontrols);
-
-
+ IOHelper.ValidateEditPath(fileName, SystemDirectories.UserControls);
+
if (System.IO.File.Exists(IOHelper.MapPath(fileName)))
{
- UserControl oControl = (UserControl)LoadControl(fileName);
+ var oControl = (UserControl)LoadControl(fileName);
type = oControl.GetType();
}
@@ -69,13 +70,11 @@ namespace umbraco.developer
}
else
{
- string currentAss = IOHelper.MapPath(SystemDirectories.Bin + "/" + Request.QueryString["fileName"] + ".dll");
- Assembly asm = System.Reflection.Assembly.LoadFrom(currentAss);
+ var currentAss = IOHelper.MapPath(SystemDirectories.Bin + "/" + Request.QueryString["fileName"] + ".dll");
+ var asm = Assembly.LoadFrom(currentAss);
type = asm.GetType(Request.QueryString["type"]);
}
-
-
if (!errorReadingControl)
{
string fullControlAssemblyName;
@@ -94,23 +93,18 @@ namespace umbraco.developer
if (!IsPostBack && type != null)
{
MacroProperties.Items.Clear();
- foreach (PropertyInfo pi in type.GetProperties())
+ foreach (var pi in type.GetProperties())
{
if (pi.CanWrite && fullControlAssemblyName == pi.DeclaringType.Namespace + "." + pi.DeclaringType.Name)
{
MacroProperties.Items.Add(new ListItem(pi.Name + " (" + pi.PropertyType.Name + ")", pi.PropertyType.Name));
-
- // Response.Write("" + pi.Name + ", " + pi.CanWrite.ToString() + ", " + pi.DeclaringType.Namespace+"."+pi.DeclaringType.Name + ", " + pi.PropertyType.Name + "");
}
foreach (ListItem li in MacroProperties.Items)
li.Selected = true;
}
}
- else if (type == null)
- {
- AssemblyName.Text = "Type '" + Request.QueryString["type"] + "' is null";
- }
+
}
}
catch (Exception err)
@@ -119,130 +113,102 @@ namespace umbraco.developer
Button1.Visible = false;
ChooseProperties.Controls.Add(new LiteralControl("" + err.ToString() + "
"));
}
- // }
-
}
-
- #region Web Form Designer generated code
- override protected void OnInit(EventArgs e)
+
+ protected void Button1_Click(object sender, EventArgs e)
{
- //
- // CODEGEN: This call is required by the ASP.NET Web Form Designer.
- //
- InitializeComponent();
- base.OnInit(e);
- }
-
- ///
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- ///
- private void InitializeComponent()
- {
-
- }
- #endregion
-
- protected void Button1_Click(object sender, System.EventArgs e)
- {
- string result = "";
+ var result = "";
// Get the macro object
- umbraco.cms.businesslogic.macro.Macro macroObject =
- new umbraco.cms.businesslogic.macro.Macro(Convert.ToInt32(Request.QueryString["macroID"]));
+ var macroObject = new Macro(Convert.ToInt32(Request.QueryString["macroID"]));
// Load all macroPropertyTypes
- Hashtable macroPropertyTypes = new Hashtable();
- Hashtable macroPropertyIds = new Hashtable();
+ var macroPropertyTypes = new Hashtable();
+ var macroPropertyIds = new Hashtable();
- // SqlDataReader dr = SqlHelper.ExecuteReader(_ConnString, CommandType.Text, "select id, macroPropertyTypeBaseType, macroPropertyTypeAlias from cmsMacroPropertyType");
- List macroPropTypes = MacroPropertyType.GetAll;
- foreach (MacroPropertyType mpt in macroPropTypes)
+ var macroPropTypes = MacroPropertyType.GetAll;
+ foreach (var mpt in macroPropTypes)
{
macroPropertyIds.Add(mpt.Alias, mpt.Id.ToString());
macroPropertyTypes.Add(mpt.Alias, mpt.BaseType);
}
- // dr.Close();
foreach (ListItem li in MacroProperties.Items)
{
- if (li.Selected && !macrohasProperty(macroObject, li.Text.Substring(0, li.Text.IndexOf(" ")).ToLower()))
+ if (li.Selected && !MacroHasProperty(macroObject, li.Text.Substring(0, li.Text.IndexOf(" ")).ToLower()))
{
- result += "Added: " + spaceCamelCasing(li.Text) + "";
- string _macroPropertyTypeAlias = findMacroType(macroPropertyTypes, li.Value);
- if (_macroPropertyTypeAlias == "")
- _macroPropertyTypeAlias = "text";
- object propertyId = macroPropertyIds[_macroPropertyTypeAlias];
+ result += "Added: " + SpaceCamelCasing(li.Text) + "";
+ var macroPropertyTypeAlias = FindMacroType(macroPropertyTypes, li.Value);
+ if (macroPropertyTypeAlias == "")
+ macroPropertyTypeAlias = "text";
+ var propertyId = macroPropertyIds[macroPropertyTypeAlias];
if (propertyId != null)
{
- int macroPropertyTypeId = 0;
+ var macroPropertyTypeId = 0;
if(int.TryParse(string.Format("{0}", propertyId), out macroPropertyTypeId))
{
MacroProperty.MakeNew(macroObject,
true,
li.Text.Substring(0, li.Text.IndexOf(" ")),
- spaceCamelCasing(li.Text),
- macroPropTypes.Find(delegate(MacroPropertyType mpt) { return mpt.Id == macroPropertyTypeId; }));
+ SpaceCamelCasing(li.Text),
+ macroPropTypes.Find(mpt => mpt.Id == macroPropertyTypeId));
}
}
}
else if (li.Selected)
- result += "Skipped: " + spaceCamelCasing(li.Text) + " (already exists as a parameter)";
+ result += "Skipped: " + SpaceCamelCasing(li.Text) + " (already exists as a parameter)";
}
ChooseProperties.Visible = false;
ConfigProperties.Visible = true;
resultLiteral.Text = result;
}
- private bool macrohasProperty(umbraco.cms.businesslogic.macro.Macro macroObject, string propertyAlias)
+ private static bool MacroHasProperty(Macro macroObject, string propertyAlias)
{
- foreach (cms.businesslogic.macro.MacroProperty mp in macroObject.Properties)
- if (mp.Alias.ToLower() == propertyAlias)
- return true;
-
- return false;
+ return macroObject.Properties.Any(mp => mp.Alias.ToLower() == propertyAlias);
}
- private string spaceCamelCasing(string text)
+ private static string SpaceCamelCasing(string text)
{
- string _tempString = text.Substring(0, 1).ToUpper();
- for (int i = 1; i < text.Length; i++)
+ var tempString = text.Substring(0, 1).ToUpper();
+ for (var i = 1; i < text.Length; i++)
{
if (text.Substring(i, 1) == " ")
break;
if (text.Substring(i, 1).ToUpper() == text.Substring(i, 1))
- _tempString += " ";
- _tempString += text.Substring(i, 1);
+ tempString += " ";
+ tempString += text.Substring(i, 1);
}
- return _tempString;
+ return tempString;
}
- private string findMacroType(Hashtable macroPropertyTypes, string baseTypeName)
+ private static string FindMacroType(Hashtable macroPropertyTypes, string baseTypeName)
{
- string _tempType = "";
+ var tempType = "";
// Hard-code numeric values
if (baseTypeName == "Int32")
- _tempType = "number";
+ tempType = "number";
else if (baseTypeName == "Decimal")
- _tempType = "decimal";
+ tempType = "decimal";
else if (baseTypeName == "String")
- _tempType = "text";
+ tempType = "text";
else if (baseTypeName == "Boolean")
- _tempType = "bool";
+ tempType = "bool";
else
{
-
foreach (DictionaryEntry de in macroPropertyTypes)
+ {
if (de.Value.ToString() == baseTypeName)
{
- _tempType = de.Key.ToString();
+ tempType = de.Key.ToString();
break;
}
+ }
}
- return _tempType;
+ return tempType;
}
}
From f64e0c7eb764a930cf1c19807c2f02a86cf4140b Mon Sep 17 00:00:00 2001
From: Shannon Deminick
Date: Wed, 10 Apr 2013 02:17:02 +0600
Subject: [PATCH 11/29] updates #U4-2070 for autodoc.aspx
---
.../umbraco/developer/autoDoc.aspx.cs | 41 ++++++-------------
1 file changed, 13 insertions(+), 28 deletions(-)
diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/developer/autoDoc.aspx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/developer/autoDoc.aspx.cs
index 352b4c7ca6..3484a4504e 100644
--- a/src/Umbraco.Web/umbraco.presentation/umbraco/developer/autoDoc.aspx.cs
+++ b/src/Umbraco.Web/umbraco.presentation/umbraco/developer/autoDoc.aspx.cs
@@ -9,6 +9,7 @@ using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Linq;
+using umbraco.BusinessLogic;
namespace umbraco.developer
{
@@ -17,56 +18,40 @@ namespace umbraco.developer
///
public partial class autoDoc : BasePages.UmbracoEnsuredPage
{
-
- protected void Page_Load(object sender, System.EventArgs e)
+ public autoDoc()
+ {
+ CurrentApp = DefaultApps.developer.ToString();
+ }
+
+ protected void Page_Load(object sender, EventArgs e)
{
// Put user code to initialize the page here
- foreach(cms.businesslogic.web.DocumentType dt in cms.businesslogic.web.DocumentType.GetAllAsList())
+ foreach(var dt in cms.businesslogic.web.DocumentType.GetAllAsList())
{
LabelDoc.Text +=
"" + dt.Text + "
Id: " + dt.Id.ToString() + ", Alias: " + dt.Alias + ")
";
if (dt.PropertyTypes.Count > 0)
LabelDoc.Text += "";
- foreach (cms.businesslogic.propertytype.PropertyType pt in dt.PropertyTypes)
+ foreach (var pt in dt.PropertyTypes)
LabelDoc.Text +=
"
" + pt.Id.ToString() + ", " + pt.Alias + ", " + pt.Name + "
";
if (dt.getVirtualTabs.Length > 0)
LabelDoc.Text += "";
- foreach (cms.businesslogic.ContentType.TabI t in dt.getVirtualTabs.ToList())
+ foreach (var t in dt.getVirtualTabs.ToList())
LabelDoc.Text +=
"
" + t.Id.ToString() + ", " + t.Caption + "
";
if (dt.AllowedChildContentTypeIDs.Length > 0)
LabelDoc.Text += "";
- foreach (int child in dt.AllowedChildContentTypeIDs.ToList())
+ foreach (var child in dt.AllowedChildContentTypeIDs.ToList())
{
- cms.businesslogic.ContentType _child = new cms.businesslogic.ContentType(child);
+ var contentType = new cms.businesslogic.ContentType(child);
LabelDoc.Text +=
- "
" + _child.Id.ToString() + ", " + _child.Text + "
";
+ "
" + contentType.Id.ToString() + ", " + contentType.Text + "
";
}
LabelDoc.Text += "
";
-
}
}
- #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);
- }
-
- ///
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- ///
- private void InitializeComponent()
- {
-
- }
- #endregion
}
}
From e1f93029a5e13631cefed0d9b04f1cb043de97b8 Mon Sep 17 00:00:00 2001
From: Shannon Deminick
Date: Wed, 10 Apr 2013 02:19:29 +0600
Subject: [PATCH 12/29] updates #U4-2070 for assigndomain.aspx
---
.../umbraco/dialogs/AssignDomain.aspx.cs | 133 ++++++++----------
1 file changed, 60 insertions(+), 73 deletions(-)
diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/AssignDomain.aspx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/AssignDomain.aspx.cs
index f663fdee0d..27d0742baa 100644
--- a/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/AssignDomain.aspx.cs
+++ b/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/AssignDomain.aspx.cs
@@ -1,6 +1,7 @@
using System;
using System.Web.UI.WebControls;
using umbraco.BasePages;
+using umbraco.BusinessLogic;
using umbraco.cms.businesslogic.language;
using umbraco.cms.businesslogic.web;
@@ -11,47 +12,51 @@ namespace umbraco.dialogs
///
public partial class AssignDomain : UmbracoEnsuredPage
{
- private int currentID;
- private int editDomain;
+ private int _currentId;
+ private int _editDomain;
+
+ public AssignDomain()
+ {
+ CurrentApp = DefaultApps.content.ToString();
+ }
protected void Page_Load(object sender, EventArgs e)
{
- currentID = int.Parse(helper.Request("id"));
- prop_domain.Text = umbraco.ui.Text("assignDomain", "domain", this.getUser());
- prop_lang.Text = umbraco.ui.Text("general", "language", this.getUser());
- pane_addnew.Text = umbraco.ui.Text("assignDomain", "addNew", this.getUser());
- pane_edit.Text = umbraco.ui.Text("assignDomain", "orEdit", this.getUser());
+ _currentId = int.Parse(helper.Request("id"));
+ prop_domain.Text = ui.Text("assignDomain", "domain", this.getUser());
+ prop_lang.Text = ui.Text("general", "language", this.getUser());
+ pane_addnew.Text = ui.Text("assignDomain", "addNew", this.getUser());
+ pane_edit.Text = ui.Text("assignDomain", "orEdit", this.getUser());
// Put user code to initialize the page here
if (helper.Request("editDomain").Trim() != "")
{
- editDomain = int.Parse(helper.Request("editDomain"));
+ _editDomain = int.Parse(helper.Request("editDomain"));
}
if (helper.Request("delDomain").Trim() != "")
{
- Domain d = new Domain(int.Parse(helper.Request("delDomain")));
- FeedBackMessage.type = umbraco.uicontrols.Feedback.feedbacktype.success;
- FeedBackMessage.Text = ui.Text("assignDomain", "domainDeleted", d.Name, base.getUser());
+ var d = new Domain(int.Parse(helper.Request("delDomain")));
+ FeedBackMessage.type = uicontrols.Feedback.feedbacktype.success;
+ FeedBackMessage.Text = ui.Text("assignDomain", "domainDeleted", d.Name, getUser());
d.Delete();
- updateDomainList();
+ UpdateDomainList();
}
if (!IsPostBack)
{
// Add caption to button
- ok.Text = ui.Text("assignDomain", "addNew", base.getUser());
+ ok.Text = ui.Text("assignDomain", "addNew", getUser());
-
- int selectedLanguage = -1;
+ var selectedLanguage = -1;
// Maybe add editing info - not the best way this is made ;-)
- if (editDomain > 0)
+ if (_editDomain > 0)
{
- Domain d = new Domain(editDomain);
+ var d = new Domain(_editDomain);
selectedLanguage = d.Language.id;
DomainName.Text = d.Name.StartsWith("*") ? "*" : d.Name;
- ok.Text = ui.Text("general", "update", base.getUser());
+ ok.Text = ui.Text("general", "update", getUser());
}
// Add caption to language validator
@@ -63,9 +68,9 @@ namespace umbraco.dialogs
DomainValidator2.ValidationExpression = @"^(\*|((?i:http[s]?://)?([-\w]+(\.[-\w]+)*)(:\d+)?(/[-\w]*)?))$";
Languages.Items.Add(new ListItem(ui.Text("general", "choose", base.getUser()), ""));
- foreach (Language l in Language.getAll)
+ foreach (var l in Language.getAll)
{
- ListItem li = new ListItem();
+ var li = new ListItem();
li.Text = l.FriendlyName;
li.Value = l.id.ToString();
if (selectedLanguage == l.id)
@@ -74,102 +79,84 @@ namespace umbraco.dialogs
}
}
- updateDomainList();
+ UpdateDomainList();
}
- private void updateDomainList()
+ private void UpdateDomainList()
{
- Domain[] domainList = Domain.GetDomainsById(currentID);
+ var domainList = Domain.GetDomainsById(_currentId);
- if (domainList.Length > 0) {
+ if (domainList.Length > 0)
+ {
allDomains.Text = "";
- pane_edit.Visible = true;
- } else {
- pane_edit.Visible = false;
+ pane_edit.Visible = true;
}
-
-
+ else
+ {
+ pane_edit.Visible = false;
+ }
}
protected void SaveDomain(object sender, EventArgs e)
{
if (Page.IsValid)
{
- if (editDomain > 0)
+ if (_editDomain > 0)
{
- Domain d = new Domain(editDomain);
+ var d = new Domain(_editDomain);
d.Language = new Language(int.Parse(Languages.SelectedValue));
d.Name = DomainName.Text.ToLower();
- FeedBackMessage.type = umbraco.uicontrols.Feedback.feedbacktype.success;
- FeedBackMessage.Text = ui.Text("assignDomain", "domainUpdated", DomainName.Text, base.getUser());
+ FeedBackMessage.type = uicontrols.Feedback.feedbacktype.success;
+ FeedBackMessage.Text = ui.Text("assignDomain", "domainUpdated", DomainName.Text, getUser());
d.Save();
DomainName.Text = "";
Languages.SelectedIndex = 0;
- updateDomainList();
+ UpdateDomainList();
//this is probably the worst webform I've ever seen...
- Response.Redirect("AssignDomain.aspx?id=" + currentID.ToString());
+ Response.Redirect("AssignDomain.aspx?id=" + _currentId.ToString());
}
else
{
// have to handle wildcard
var domainName = DomainName.Text.Trim();
- domainName = domainName == "*" ? ("*" + currentID.ToString()) : domainName;
+ domainName = domainName == "*" ? ("*" + _currentId.ToString()) : domainName;
- if (!Domain.Exists(domainName.ToLower()))
- {
- Domain.MakeNew(domainName, currentID, int.Parse(Languages.SelectedValue));
- FeedBackMessage.Text = ui.Text("assignDomain", "domainCreated", domainName, base.getUser());
- FeedBackMessage.type = umbraco.uicontrols.Feedback.feedbacktype.success;
+ if (!Domain.Exists(domainName.ToLower()))
+ {
+ Domain.MakeNew(domainName, _currentId, int.Parse(Languages.SelectedValue));
+ FeedBackMessage.Text = ui.Text("assignDomain", "domainCreated", domainName, getUser());
+ FeedBackMessage.type = uicontrols.Feedback.feedbacktype.success;
DomainName.Text = "";
Languages.SelectedIndex = 0;
- updateDomainList();
+ UpdateDomainList();
//this is probably the worst webform I've ever seen...
- Response.Redirect("AssignDomain.aspx?id=" + currentID.ToString());
- } else {
- FeedBackMessage.Text = ui.Text("assignDomain", "domainExists", DomainName.Text.Trim(), base.getUser());
- FeedBackMessage.type = umbraco.uicontrols.Feedback.feedbacktype.error;
+ Response.Redirect("AssignDomain.aspx?id=" + _currentId.ToString());
}
- }
-
-
+ else
+ {
+ FeedBackMessage.Text = ui.Text("assignDomain", "domainExists", DomainName.Text.Trim(), getUser());
+ FeedBackMessage.type = uicontrols.Feedback.feedbacktype.error;
+ }
+ }
}
}
- #region Web Form Designer generated code
-
- protected override void OnInit(EventArgs e)
- {
- //
- // CODEGEN: This call is required by the ASP.NET Web Form Designer.
- //
- InitializeComponent();
- base.OnInit(e);
- }
-
- ///
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- ///
- private void InitializeComponent()
- {
- }
-
- #endregion
}
}
\ No newline at end of file
From 57792de185eae6a0847be46d995f1724bde32309 Mon Sep 17 00:00:00 2001
From: Shannon Deminick
Date: Wed, 10 Apr 2013 02:21:59 +0600
Subject: [PATCH 13/29] updates #U4-2070 for imageViewer.aspx
---
.../umbraco/dialogs/imageViewer.aspx.cs | 92 ++++++++++---------
1 file changed, 50 insertions(+), 42 deletions(-)
diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/imageViewer.aspx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/imageViewer.aspx.cs
index d99af8c630..81b0866ff5 100644
--- a/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/imageViewer.aspx.cs
+++ b/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/imageViewer.aspx.cs
@@ -10,6 +10,7 @@ using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.IO;
+using umbraco.BusinessLogic;
using umbraco.IO;
namespace umbraco.dialogs
@@ -17,8 +18,13 @@ namespace umbraco.dialogs
[Obsolete("Use the ImageViewer user control instead")]
public partial class imageViewer : BasePages.UmbracoEnsuredPage
{
+
+ public imageViewer()
+ {
+ CurrentApp = DefaultApps.media.ToString();
+ }
- protected void Page_Load(object sender, System.EventArgs e)
+ protected void Page_Load(object sender, EventArgs e)
{
//Response.Write(umbraco.helper.Request("id"));
//Response.End();
@@ -28,53 +34,55 @@ namespace umbraco.dialogs
if (Request.QueryString["id"] != "")
{
//TODO: fix Nasty FAST'N'CANELINE HACK. ..
- int MediaId = int.Parse(Request.QueryString["id"]);
+ var mediaId = int.Parse(Request.QueryString["id"]);
image.Controls.Clear();
- int fileWidth = 0;
- int fileHeight = 0;
- string fileName = "/blank.gif";
- string altText = "";
+ var fileWidth = 0;
+ var fileHeight = 0;
+ var fileName = "/blank.gif";
+ var altText = "";
- try
- {
- cms.businesslogic.media.Media m = new cms.businesslogic.media.Media(MediaId);
+ try
+ {
+ var m = new cms.businesslogic.media.Media(mediaId);
- // TODO: Remove "Magic strings" from code.
- try
- {
- fileName = m.getProperty("fileName").Value.ToString();
- }
- catch
- {
- try
- {
- fileName = m.getProperty("umbracoFile").Value.ToString();
- }
- catch
- {
- fileName = m.getProperty("file").Value.ToString();
- }
- }
+ // TODO: Remove "Magic strings" from code.
+ try
+ {
+ fileName = m.getProperty("fileName").Value.ToString();
+ }
+ catch
+ {
+ try
+ {
+ fileName = m.getProperty("umbracoFile").Value.ToString();
+ }
+ catch
+ {
+ fileName = m.getProperty("file").Value.ToString();
+ }
+ }
- altText = m.Text;
- try
- {
- fileWidth = int.Parse(m.getProperty("umbracoWidth").Value.ToString());
- fileHeight = int.Parse(m.getProperty("umbracoHeight").Value.ToString());
- }
- catch {
-
- }
- string fileNameOrg = fileName;
- string ext = fileNameOrg.Substring(fileNameOrg.LastIndexOf(".")+1, fileNameOrg.Length-fileNameOrg.LastIndexOf(".")-1);
- string fileNameThumb = SystemDirectories.Root + fileNameOrg.Replace("."+ext, "_thumb.jpg");
- image.Controls.Add(new LiteralControl("
"));
- }
- catch {
- }
+ altText = m.Text;
+ try
+ {
+ fileWidth = int.Parse(m.getProperty("umbracoWidth").Value.ToString());
+ fileHeight = int.Parse(m.getProperty("umbracoHeight").Value.ToString());
+ }
+ catch
+ {
- image.Controls.Add(new LiteralControl(""));
+ }
+ var fileNameOrg = fileName;
+ var ext = fileNameOrg.Substring(fileNameOrg.LastIndexOf(".") + 1, fileNameOrg.Length - fileNameOrg.LastIndexOf(".") - 1);
+ var fileNameThumb = SystemDirectories.Root + fileNameOrg.Replace("." + ext, "_thumb.jpg");
+ image.Controls.Add(new LiteralControl("
"));
+ }
+ catch
+ {
+ }
+
+ image.Controls.Add(new LiteralControl(""));
}
}
From 8112c13857855b6942539bf7b8c7cc9a42b38907 Mon Sep 17 00:00:00 2001
From: Shannon Deminick
Date: Wed, 10 Apr 2013 02:28:50 +0600
Subject: [PATCH 14/29] updates #U4-2070 for insertMacro.aspx
---
.../umbraco/dialogs/insertMacro.aspx.cs | 60 +++++++------------
1 file changed, 23 insertions(+), 37 deletions(-)
diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/insertMacro.aspx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/insertMacro.aspx.cs
index 55fd69cfab..9d8286e098 100644
--- a/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/insertMacro.aspx.cs
+++ b/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/insertMacro.aspx.cs
@@ -10,8 +10,10 @@ using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Reflection;
+using Umbraco.Core.IO;
+using umbraco.BusinessLogic;
using umbraco.DataLayer;
-using umbraco.IO;
+using umbraco.businesslogic.Exceptions;
namespace umbraco.dialogs
{
@@ -20,8 +22,18 @@ namespace umbraco.dialogs
///
public partial class insertMacro : BasePages.UmbracoEnsuredPage
{
- protected System.Web.UI.WebControls.Button Button1;
- protected void Page_Load(object sender, System.EventArgs e)
+ protected Button Button1;
+
+ protected override void OnInit(EventArgs e)
+ {
+ base.OnInit(e);
+
+ //this could be used for media or content so we need to at least validate that the user has access to one or the other
+ if (!ValidateUserApp(DefaultApps.content.ToString()) && !ValidateUserApp(DefaultApps.media.ToString()))
+ throw new UserAuthorizationException("The current user doesn't have access to the section/app");
+ }
+
+ protected void Page_Load(object sender, EventArgs e)
{
pane_edit.Text = ui.Text("general", "edit",this.getUser()) + " " + ui.Text("general", "macro",this.getUser());
pane_insert.Text = ui.Text("general", "insert",this.getUser()) + " " + ui.Text("general", "macro",this.getUser());
@@ -31,27 +43,24 @@ namespace umbraco.dialogs
// Put user code to initialize the page here
cms.businesslogic.macro.Macro m;
if (helper.Request("macroID") != "")
- m = new umbraco.cms.businesslogic.macro.Macro(int.Parse(helper.Request("macroID")));
+ m = new cms.businesslogic.macro.Macro(int.Parse(helper.Request("macroID")));
else
m = cms.businesslogic.macro.Macro.GetByAlias(helper.Request("macroAlias"));
- String macroAssembly = "";
- String macroType = "";
-
- foreach (cms.businesslogic.macro.MacroProperty mp in m.Properties) {
+ foreach (var mp in m.Properties) {
- macroAssembly = mp.Type.Assembly;
- macroType = mp.Type.Type;
+ var macroAssembly = mp.Type.Assembly;
+ var macroType = mp.Type.Type;
try
{
- Assembly assembly = Assembly.LoadFrom( IOHelper.MapPath(SystemDirectories.Bin + "/" + macroAssembly + ".dll"));
+ var assembly = Assembly.LoadFrom( IOHelper.MapPath(SystemDirectories.Bin + "/" + macroAssembly + ".dll"));
Type type = assembly.GetType(macroAssembly+"."+macroType);
- interfaces.IMacroGuiRendering typeInstance = Activator.CreateInstance(type) as interfaces.IMacroGuiRendering;
+ var typeInstance = Activator.CreateInstance(type) as interfaces.IMacroGuiRendering;
if (typeInstance != null)
{
- Control control = Activator.CreateInstance(type) as Control;
+ var control = Activator.CreateInstance(type) as Control;
control.ID = mp.Alias;
if (Request[mp.Alias] != null)
{
@@ -62,7 +71,7 @@ namespace umbraco.dialogs
}
// register alias
- umbraco.uicontrols.PropertyPanel pp = new umbraco.uicontrols.PropertyPanel();
+ var pp = new uicontrols.PropertyPanel();
pp.Text = mp.Name;
pp.Controls.Add(control);
@@ -103,29 +112,6 @@ namespace umbraco.dialogs
}
-
-
-
}
-
- #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);
- }
-
- ///
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- ///
- private void InitializeComponent()
- {
-
- }
- #endregion
}
}
From deda2534f8bccad7d47f03f11ff69761cf696f75 Mon Sep 17 00:00:00 2001
From: Shannon Deminick
Date: Wed, 10 Apr 2013 02:30:53 +0600
Subject: [PATCH 15/29] updates #U4-2070 for SendPublish.aspx
---
.../umbraco/dialogs/SendPublish.aspx.cs | 20 ++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)
diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/SendPublish.aspx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/SendPublish.aspx.cs
index d1325124cc..da69599d44 100644
--- a/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/SendPublish.aspx.cs
+++ b/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/SendPublish.aspx.cs
@@ -8,6 +8,7 @@ using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
+using umbraco.BusinessLogic;
using umbraco.BusinessLogic.Actions;
using umbraco.cms.businesslogic.web;
@@ -19,18 +20,23 @@ namespace umbraco.dialogs
///
public partial class SendPublish : BasePages.UmbracoEnsuredPage
{
- protected void Page_Load(object sender, System.EventArgs e)
+ public SendPublish()
+ {
+ CurrentApp = DefaultApps.content.ToString();
+ }
+
+ protected void Page_Load(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(Request.QueryString["id"]))
{
- int docID;
- if (int.TryParse(Request.QueryString["id"], out docID))
+ int docId;
+ if (int.TryParse(Request.QueryString["id"], out docId))
{
- Document _document = new Document(docID);
- if (_document != null)
- BusinessLogic.Actions.Action.RunActionHandlers(_document, ActionToPublish.Instance);
+ var document = new Document(docId);
+ BusinessLogic.Actions.Action.RunActionHandlers(document, ActionToPublish.Instance);
+
}
-
+
}
}
From e90c46dd78288339606d5105a51f4ccc5546d4eb Mon Sep 17 00:00:00 2001
From: Shannon Deminick
Date: Wed, 10 Apr 2013 02:33:08 +0600
Subject: [PATCH 16/29] updates #U4-2070 for canvas.aspx
---
.../umbraco/canvas.aspx.cs | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/canvas.aspx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/canvas.aspx.cs
index 44d5441efe..77d8f48765 100644
--- a/src/Umbraco.Web/umbraco.presentation/umbraco/canvas.aspx.cs
+++ b/src/Umbraco.Web/umbraco.presentation/umbraco/canvas.aspx.cs
@@ -1,29 +1,37 @@
using System;
using umbraco.BasePages;
+using umbraco.BusinessLogic;
using umbraco.businesslogic.Exceptions;
namespace umbraco.presentation
{
- public partial class LiveEditingEnabler : BasePages.UmbracoEnsuredPage
+ public partial class LiveEditingEnabler : UmbracoEnsuredPage
{
+ public LiveEditingEnabler()
+ {
+ CurrentApp = DefaultApps.content.ToString();
+ }
+
protected void Page_Load(object sender, EventArgs e)
{
- if ((UmbracoSettings.EnableCanvasEditing || !String.IsNullOrEmpty(UmbracoContext.Current.Request["umbSkinning"]) ) && base.getUser() != null)
+ if ((UmbracoSettings.EnableCanvasEditing || !String.IsNullOrEmpty(Request["umbSkinning"]) ) && getUser() != null)
{
UmbracoContext.Current.LiveEditingContext.Enabled = true;
- string redirUrl = "/";
- if (!String.IsNullOrEmpty(helper.Request("redir")))
+ var redirUrl = "/";
+ if (!string.IsNullOrEmpty(helper.Request("redir")))
redirUrl = helper.Request("redir");
else if (Request.UrlReferrer != null && !Request.UrlReferrer.AbsolutePath.Contains("login.aspx"))
redirUrl = Request.UrlReferrer.AbsolutePath;
Response.Redirect(redirUrl +
- (string.IsNullOrEmpty(UmbracoContext.Current.Request["umbSkinning"]) ? "" : "?umbSkinning=true") + (string.IsNullOrEmpty(UmbracoContext.Current.Request["umbSkinningConfigurator"]) ? "" : "&umbSkinningConfigurator=true"), true);
+ (string.IsNullOrEmpty(Request["umbSkinning"]) ? "" : "?umbSkinning=true") + (string.IsNullOrEmpty(Request["umbSkinningConfigurator"]) ? "" : "&umbSkinningConfigurator=true"), true);
}
else if (!UmbracoSettings.EnableCanvasEditing)
+ {
throw new UserAuthorizationException(
"Canvas editing isn't enabled. It can be enabled via the UmbracoSettings.config");
+ }
else
{
throw new Exception("User not logged in");
From 436322f58cb38aafd900f82420e86fa1331214d3 Mon Sep 17 00:00:00 2001
From: Shannon Deminick
Date: Wed, 10 Apr 2013 02:34:44 +0600
Subject: [PATCH 17/29] updates #U4-2070 for directoryBrowser.aspx
---
.../umbraco/developer/Packages/DirectoryBrowser.aspx.cs | 5 +++++
.../umbraco/developer/Packages/directoryBrowser.aspx.cs | 6 ++++++
2 files changed, 11 insertions(+)
diff --git a/src/Umbraco.Web.UI/umbraco/developer/Packages/DirectoryBrowser.aspx.cs b/src/Umbraco.Web.UI/umbraco/developer/Packages/DirectoryBrowser.aspx.cs
index c16c6ca950..370cf11e1a 100644
--- a/src/Umbraco.Web.UI/umbraco/developer/Packages/DirectoryBrowser.aspx.cs
+++ b/src/Umbraco.Web.UI/umbraco/developer/Packages/DirectoryBrowser.aspx.cs
@@ -9,11 +9,16 @@ using System.Web.UI;
using Umbraco.Core;
using Umbraco.Core.IO;
using umbraco.BasePages;
+using umbraco.BusinessLogic;
namespace Umbraco.Web.UI.Umbraco.Developer.Packages
{
public partial class DirectoryBrowser : UmbracoEnsuredPage
{
+ public DirectoryBrowser()
+ {
+ CurrentApp = DefaultApps.developer.ToString();
+ }
string _lsTitle;
string _lsLink;
diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/developer/Packages/directoryBrowser.aspx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/developer/Packages/directoryBrowser.aspx.cs
index cb6cc75fca..f6a7742423 100644
--- a/src/Umbraco.Web/umbraco.presentation/umbraco/developer/Packages/directoryBrowser.aspx.cs
+++ b/src/Umbraco.Web/umbraco.presentation/umbraco/developer/Packages/directoryBrowser.aspx.cs
@@ -8,12 +8,18 @@ using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
+using umbraco.BusinessLogic;
namespace umbraco.presentation.developer.packages
{
[Obsolete("This class is no longer used and will be removed from the codebase in the future")]
public partial class directoryBrowser : BasePages.UmbracoEnsuredPage
{
+ public directoryBrowser()
+ {
+ CurrentApp = DefaultApps.developer.ToString();
+ }
+
///
/// pane control.
///
From 0bffa8e3f46c6859c5056322c8b00a8162b81113 Mon Sep 17 00:00:00 2001
From: Shannon Deminick
Date: Wed, 10 Apr 2013 02:35:31 +0600
Subject: [PATCH 18/29] updates #U4-2070 for preview.aspx
---
.../umbraco.presentation/umbraco/dialogs/Preview.aspx.cs | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/Preview.aspx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/Preview.aspx.cs
index 3ca6247c7a..5e0b8772d4 100644
--- a/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/Preview.aspx.cs
+++ b/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/Preview.aspx.cs
@@ -18,10 +18,15 @@ namespace umbraco.presentation.dialogs
{
public partial class Preview : BasePages.UmbracoEnsuredPage
{
+ public Preview()
+ {
+ CurrentApp = DefaultApps.content.ToString();
+ }
+
protected void Page_Load(object sender, EventArgs e)
{
- Document d = new Document(int.Parse(helper.Request("id")));
- PreviewContent pc = new PreviewContent(base.getUser(), Guid.NewGuid(), false);
+ var d = new Document(int.Parse(helper.Request("id")));
+ var pc = new PreviewContent(base.getUser(), Guid.NewGuid(), false);
pc.PrepareDocument(base.getUser(), d, true);
pc.SavePreviewSet();
docLit.Text = d.Text;
From a9aa3a04b5fd221f7bc90153f7a5fb8ba90e1410 Mon Sep 17 00:00:00 2001
From: Shannon Deminick
Date: Wed, 10 Apr 2013 02:39:32 +0600
Subject: [PATCH 19/29] updates #U4-2070 for search.aspx
---
.../umbraco/dialogs/search.aspx.cs | 66 +++++++++----------
1 file changed, 31 insertions(+), 35 deletions(-)
diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/search.aspx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/search.aspx.cs
index 5e9df5ed2e..a26a960021 100644
--- a/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/search.aspx.cs
+++ b/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/search.aspx.cs
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
+using Umbraco.Core;
using UmbracoExamine;
using System.Xml;
using Examine;
@@ -14,50 +15,52 @@ namespace umbraco.presentation.dialogs
{
public partial class search : BasePages.UmbracoEnsuredPage
{
+
+ protected override void OnInit(EventArgs e)
+ {
+ CurrentApp = IndexTypes.Content;
+ if (!string.IsNullOrEmpty(Request["app"]))
+ {
+ CurrentApp = Request["app"].ToLower();
+ }
+
+ base.OnInit(e);
+ }
+
protected void Page_Load(object sender, EventArgs e)
{
- this.Page.Form.DefaultButton = this.searchButton.UniqueID;
+ Page.Form.DefaultButton = searchButton.UniqueID;
- if (!IsPostBack && UmbracoContext.Current.Request["search"] != "")
+ if (!IsPostBack && Request["search"] != "")
{
- keyword.Text = UmbracoContext.Current.Request["search"];
- doSearch();
+ keyword.Text = Request["search"];
+ DoSearch();
}
}
protected void search_Click(object sender, EventArgs e)
{
- doSearch();
-
-
+ DoSearch();
}
- private void doSearch()
+ private void DoSearch()
{
-
var txt = keyword.Text.ToLower();
- //the app can be Content or Media only, otherwise an exception will be thrown
- var app = UmbracoExamine.IndexTypes.Content;
- if (!string.IsNullOrEmpty(UmbracoContext.Current.Request["app"]))
- {
- app = UmbracoContext.Current.Request["app"].ToLower();
- }
-
int limit;
- if (!int.TryParse(UmbracoContext.Current.Request["limit"], out limit))
+ if (!int.TryParse(Request["limit"], out limit))
{
limit = 100;
}
//if it doesn't start with "*", then search only nodeName and nodeId
- var internalSearcher = (app == "member")
+ var internalSearcher = (CurrentApp == "member")
? UmbracoContext.Current.InternalMemberSearchProvider
: UmbracoContext.Current.InternalSearchProvider;
//create some search criteria, make everything combined to be 'And' and only search the current app
- var criteria = internalSearcher.CreateSearchCriteria(app, Examine.SearchCriteria.BooleanOperation.And);
+ var criteria = internalSearcher.CreateSearchCriteria(CurrentApp, Examine.SearchCriteria.BooleanOperation.And);
IEnumerable results;
if (txt.StartsWith("*"))
@@ -70,39 +73,32 @@ namespace umbraco.presentation.dialogs
var operation = criteria.Field("__nodeName", txt.MultipleCharacterWildcard());
// ensure the user can only find nodes they are allowed to see
- if (UmbracoContext.Current.UmbracoUser.StartNodeId > 0)
+ if (CurrentUser.StartNodeId > 0)
{
- operation = operation.And().Id(UmbracoContext.Current.UmbracoUser.StartNodeId);
+ operation = operation.And().Id(CurrentUser.StartNodeId);
}
results = internalSearcher.Search(operation.Compile());
}
- if (results.Count() == 0)
- {
- nothingFound.Visible = true;
- }
- else
- {
- nothingFound.Visible = false;
- }
+ nothingFound.Visible = !results.Any();
searchResult.XPathNavigator = ResultsAsXml(results).CreateNavigator();
}
private XmlDocument ResultsAsXml(IEnumerable results)
{
- XmlDocument result = new XmlDocument();
+ var result = new XmlDocument();
result.LoadXml("");
foreach (var r in results)
{
- XmlNode x = xmlHelper.addTextNode(result, "result", "");
- x.Attributes.Append(xmlHelper.addAttribute(result, "id", r.Id.ToString()));
- x.Attributes.Append(xmlHelper.addAttribute(result, "title", r.Fields["nodeName"]));
- x.Attributes.Append(xmlHelper.addAttribute(result, "author", r.Fields["writerName"]));
- x.Attributes.Append(xmlHelper.addAttribute(result, "changeDate", r.Fields["updateDate"]));
+ var x = XmlHelper.AddTextNode(result, "result", "");
+ x.Attributes.Append(XmlHelper.AddAttribute(result, "id", r.Id.ToString()));
+ x.Attributes.Append(XmlHelper.AddAttribute(result, "title", r.Fields["nodeName"]));
+ x.Attributes.Append(XmlHelper.AddAttribute(result, "author", r.Fields["writerName"]));
+ x.Attributes.Append(XmlHelper.AddAttribute(result, "changeDate", r.Fields["updateDate"]));
result.DocumentElement.AppendChild(x);
}
From c8330d60f91361a5adf5f8cb7b321c678bd1c03b Mon Sep 17 00:00:00 2001
From: Shannon Deminick
Date: Wed, 10 Apr 2013 02:41:22 +0600
Subject: [PATCH 20/29] updates #U4-2070 for sendToTranslation.aspx
---
.../umbraco/dialogs/sendToTranslation.aspx.cs | 21 ++++++++++++-------
1 file changed, 13 insertions(+), 8 deletions(-)
diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/sendToTranslation.aspx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/sendToTranslation.aspx.cs
index 1b8de4fa0f..588bbe5bfc 100644
--- a/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/sendToTranslation.aspx.cs
+++ b/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/sendToTranslation.aspx.cs
@@ -20,9 +20,14 @@ namespace umbraco.presentation.dialogs
{
private CMSNode _currentPage;
+ public sendToTranslation()
+ {
+ CurrentApp = DefaultApps.content.ToString();
+ }
+
protected void Page_Load(object sender, EventArgs e)
{
- _currentPage = new cms.businesslogic.CMSNode(int.Parse(helper.Request("id")));
+ _currentPage = new CMSNode(int.Parse(helper.Request("id")));
pp_translator.Text = ui.Text("translation","translator", this.getUser());
pp_language.Text = ui.Text("translation", "translateTo", this.getUser());
@@ -34,9 +39,9 @@ namespace umbraco.presentation.dialogs
if (!IsPostBack)
{
// default language
- int selectedLanguage = 0;
+ var selectedLanguage = 0;
- Domain[] domains = library.GetCurrentDomains(_currentPage.Id);
+ var domains = library.GetCurrentDomains(_currentPage.Id);
if (domains != null)
{
selectedLanguage = domains[0].Language.id;
@@ -49,9 +54,9 @@ namespace umbraco.presentation.dialogs
// languages
language.Items.Add(new ListItem(ui.Text("general", "choose", base.getUser()), ""));
- foreach (cms.businesslogic.language.Language l in cms.businesslogic.language.Language.getAll)
+ foreach (var l in cms.businesslogic.language.Language.getAll)
{
- ListItem li = new ListItem();
+ var li = new ListItem();
li.Text = l.FriendlyName;
li.Value = l.id.ToString();
if (selectedLanguage == l.id)
@@ -64,13 +69,13 @@ namespace umbraco.presentation.dialogs
includeSubpages.Enabled = false;
// Translators
- foreach (User u in BusinessLogic.User.getAll())
+ foreach (var u in BusinessLogic.User.getAll())
if (u.UserType.Alias.ToLower() == "translator")
translator.Items.Add(new ListItem(u.Name, u.Id.ToString()));
if (translator.Items.Count == 0) {
feedback.Text = ui.Text("translation", "noTranslators");
- feedback.type = global::umbraco.uicontrols.Feedback.feedbacktype.error;
+ feedback.type = uicontrols.Feedback.feedbacktype.error;
doTranslation.Enabled = false;
}
@@ -94,7 +99,7 @@ namespace umbraco.presentation.dialogs
pl_buttons.Visible = false;
feedback.Text = ui.Text("translation","pageHasBeenSendToTranslation", _currentPage.Text, base.getUser()) + "
" + ui.Text("defaultdialogs", "closeThisWindow") + "
";
- feedback.type = global::umbraco.uicontrols.Feedback.feedbacktype.success;
+ feedback.type = uicontrols.Feedback.feedbacktype.success;
}
}
}
From 4ccb655f7332a527276d581c894c496f09d7f5fe Mon Sep 17 00:00:00 2001
From: Shannon Deminick
Date: Wed, 10 Apr 2013 02:43:03 +0600
Subject: [PATCH 21/29] updates #U4-2070 for members/search.aspx
---
.../umbraco.presentation/umbraco/members/search.aspx.cs | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/members/search.aspx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/members/search.aspx.cs
index 43bc1cb69a..218e891034 100644
--- a/src/Umbraco.Web/umbraco.presentation/umbraco/members/search.aspx.cs
+++ b/src/Umbraco.Web/umbraco.presentation/umbraco/members/search.aspx.cs
@@ -16,6 +16,9 @@ namespace umbraco.presentation.members
public partial class search : BasePages.UmbracoEnsuredPage
{
-
+ public search()
+ {
+ CurrentApp = DefaultApps.member.ToString();
+ }
}
}
From 423643d66ce63e4fd1b70697ee867c4f09810ea5 Mon Sep 17 00:00:00 2001
From: Shannon Deminick
Date: Wed, 10 Apr 2013 02:46:11 +0600
Subject: [PATCH 22/29] updates #U4-2070 for tinymce3/insertmacro.aspx
---
.../plugins/tinymce3/insertMacro.aspx.cs | 72 ++++++++++---------
1 file changed, 39 insertions(+), 33 deletions(-)
diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/plugins/tinymce3/insertMacro.aspx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/plugins/tinymce3/insertMacro.aspx.cs
index fa254ddbb6..7425522783 100644
--- a/src/Umbraco.Web/umbraco.presentation/umbraco/plugins/tinymce3/insertMacro.aspx.cs
+++ b/src/Umbraco.Web/umbraco.presentation/umbraco/plugins/tinymce3/insertMacro.aspx.cs
@@ -5,12 +5,13 @@ using System.Reflection;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
-
+using Umbraco.Core.IO;
using umbraco.BasePages;
+using umbraco.BusinessLogic;
+using umbraco.businesslogic.Exceptions;
using umbraco.cms.businesslogic.macro;
using umbraco.interfaces;
using umbraco.DataLayer;
-using umbraco.IO;
namespace umbraco.presentation.tinymce3
{
@@ -20,15 +21,24 @@ namespace umbraco.presentation.tinymce3
public partial class insertMacro : UmbracoEnsuredPage
{
protected Button Button1;
- private ArrayList _dataFields = new ArrayList();
+ private readonly ArrayList _dataFields = new ArrayList();
public Macro m;
private string _scriptOnLoad = "";
+ protected override void OnInit(EventArgs e)
+ {
+ base.OnInit(e);
+
+ //this could be used for media or content so we need to at least validate that the user has access to one or the other
+ if (!ValidateUserApp(DefaultApps.content.ToString()) && !ValidateUserApp(DefaultApps.media.ToString()))
+ throw new UserAuthorizationException("The current user doesn't have access to the section/app");
+ }
+
protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);
- if (!String.IsNullOrEmpty(_scriptOnLoad))
+ if (!string.IsNullOrEmpty(_scriptOnLoad))
{
jQueryReady.Text = _scriptOnLoad;
}
@@ -40,14 +50,14 @@ namespace umbraco.presentation.tinymce3
_scriptOnLoad = "";
- string reqMacroID = UmbracoContext.Current.Request["umb_macroID"];
- string reqMacroAlias = UmbracoContext.Current.Request["umb_macroAlias"];
- bool ignoreForm = string.IsNullOrEmpty(UmbracoContext.Current.Request["class"]);
+ var reqMacroId = Request["umb_macroID"];
+ var reqMacroAlias = Request["umb_macroAlias"];
+ var ignoreForm = string.IsNullOrEmpty(Request["class"]);
pane_insert.Text = ui.Text("insertMacro");
Page.Title = ui.Text("insertMacro");
- if (!String.IsNullOrEmpty(reqMacroID) || !String.IsNullOrEmpty(reqMacroAlias))
+ if (!string.IsNullOrEmpty(reqMacroId) || !string.IsNullOrEmpty(reqMacroAlias))
{
pane_edit.Visible = true;
@@ -56,9 +66,9 @@ namespace umbraco.presentation.tinymce3
insert_buttons.Visible = false;
// Put user code to initialize the page here
- if (!string.IsNullOrEmpty(reqMacroID))
+ if (!string.IsNullOrEmpty(reqMacroId))
{
- m = new Macro(int.Parse(reqMacroID));
+ m = new Macro(int.Parse(reqMacroId));
}
else
{
@@ -68,9 +78,6 @@ namespace umbraco.presentation.tinymce3
pane_edit.Text = ui.Text("edit") + " " + m.Name;
Page.Title = ui.Text("edit") + " " + m.Name;
- String macroAssembly = "";
- String macroType = "";
-
if (m.Properties.Length == 0)
{
@@ -80,7 +87,7 @@ namespace umbraco.presentation.tinymce3
}
else
{
- Literal fb = new Literal();
+ var fb = new Literal();
fb.Text = "" + ui.Text("macroDoesNotHaveProperties") + "
" + ui.Text("closeThisWindow") + "";
macroProperties.Controls.Add(fb);
edit_buttons.Visible = false;
@@ -89,20 +96,20 @@ namespace umbraco.presentation.tinymce3
}
else
{
- foreach (MacroProperty mp in m.Properties)
+ foreach (var mp in m.Properties)
{
- macroAssembly = mp.Type.Assembly;
- macroType = mp.Type.Type;
+ var macroAssembly = mp.Type.Assembly;
+ var macroType = mp.Type.Type;
try
{
- Assembly assembly = Assembly.LoadFrom(IOHelper.MapPath(SystemDirectories.Bin + "/" + macroAssembly + ".dll"));
+ var assembly = Assembly.LoadFrom(IOHelper.MapPath(SystemDirectories.Bin + "/" + macroAssembly + ".dll"));
- Type type = assembly.GetType(macroAssembly + "." + macroType);
- IMacroGuiRendering typeInstance = Activator.CreateInstance(type) as IMacroGuiRendering;
+ var type = assembly.GetType(macroAssembly + "." + macroType);
+ var typeInstance = Activator.CreateInstance(type) as IMacroGuiRendering;
if (typeInstance != null)
{
- Control control = Activator.CreateInstance(type) as Control;
+ var control = Activator.CreateInstance(type) as Control;
control.ID = mp.Alias;
if (!IsPostBack)
@@ -129,16 +136,15 @@ namespace umbraco.presentation.tinymce3
}
- uicontrols.PropertyPanel pp = new global::umbraco.uicontrols.PropertyPanel();
+ var pp = new uicontrols.PropertyPanel();
pp.Text = mp.Name;
pp.Controls.Add(control);
_scriptOnLoad += "\t\tregisterAlias('" + control.ID + "');\n";
- // pp.Controls.Add(new LiteralControl("\n"));
macroProperties.Controls.Add(pp);
_dataFields.Add(control);
- //macroProperties.Controls.Add(new LiteralControl(""));
+
}
else
{
@@ -158,7 +164,7 @@ namespace umbraco.presentation.tinymce3
else
{
IRecordsReader macroRenderings;
- if (UmbracoContext.Current.Request["editor"] != "")
+ if (Request["editor"] != "")
macroRenderings = SqlHelper.ExecuteReader("select macroAlias, macroName from cmsMacro where macroUseInEditor = 1 order by macroName");
else
macroRenderings = SqlHelper.ExecuteReader("select macroAlias, macroName from cmsMacro order by macroName");
@@ -174,19 +180,19 @@ namespace umbraco.presentation.tinymce3
protected void renderMacro_Click(object sender, EventArgs e)
{
- int pageID = int.Parse(UmbracoContext.Current.Request["umbPageId"]);
+ var pageId = int.Parse(Request["umbPageId"]);
- string macroAttributes = string.Format("macroAlias=\"{0}\"", m.Alias);
+ var macroAttributes = string.Format("macroAlias=\"{0}\"", m.Alias);
- Guid pageVersion = new Guid(UmbracoContext.Current.Request["umbVersionId"]);
+ var pageVersion = new Guid(Request["umbVersionId"]);
- Hashtable attributes = new Hashtable { { "macroAlias", m.Alias } };
+ var attributes = new Hashtable { { "macroAlias", m.Alias } };
foreach (Control c in _dataFields)
{
try
{
- IMacroGuiRendering ic = (IMacroGuiRendering)c;
+ var ic = (IMacroGuiRendering)c;
attributes.Add(c.ID.ToLower(), ic.Value);
macroAttributes += string.Format(" {0}=\"{1}\"", c.ID, ic.Value.Replace("\"", "\\\"").Replace("\n", "\\n").Replace("\r", "\\r"));
}
@@ -196,11 +202,11 @@ namespace umbraco.presentation.tinymce3
}
HttpContext.Current.Items["macrosAdded"] = 0;
- HttpContext.Current.Items["pageID"] = pageID.ToString();
+ HttpContext.Current.Items["pageID"] = pageId.ToString();
- string div = macro.renderMacroStartTag(attributes, pageID, pageVersion).Replace("\\", "\\\\").Replace("'", "\\'");
+ var div = macro.renderMacroStartTag(attributes, pageId, pageVersion).Replace("\\", "\\\\").Replace("'", "\\'");
- string macroContent = macro.MacroContentByHttp(pageID, pageVersion, attributes).Replace("\\", "\\\\").Replace("'", "\\'").Replace("/", "\\/").Replace("\n", "\\n");
+ var macroContent = macro.MacroContentByHttp(pageId, pageVersion, attributes).Replace("\\", "\\\\").Replace("'", "\\'").Replace("/", "\\/").Replace("\n", "\\n");
if (macroContent.Length > 0 && macroContent.ToLower().IndexOf("";
macroProperties.Controls.Add(noProps);
}
else
{
//if we have properties, we'll render the controls for them...
- foreach (cms.businesslogic.macro.MacroProperty mp in m.Properties)
+ foreach (cms.businesslogic.macro.MacroProperty mp in _m.Properties)
{
- macroAssembly = mp.Type.Assembly;
- macroType = mp.Type.Type;
+ var macroAssembly = mp.Type.Assembly;
+ var macroType = mp.Type.Type;
try
{
- Assembly assembly = Assembly.LoadFrom(IOHelper.MapPath(SystemDirectories.Bin + "/" + macroAssembly + ".dll"));
+ var assembly = Assembly.LoadFrom(IOHelper.MapPath(SystemDirectories.Bin + "/" + macroAssembly + ".dll"));
- Type type = assembly.GetType(macroAssembly + "." + macroType);
- interfaces.IMacroGuiRendering typeInstance = Activator.CreateInstance(type) as interfaces.IMacroGuiRendering;
+ var type = assembly.GetType(macroAssembly + "." + macroType);
+ var typeInstance = Activator.CreateInstance(type) as interfaces.IMacroGuiRendering;
if (typeInstance != null)
{
- Control control = Activator.CreateInstance(type) as Control;
+ var control = Activator.CreateInstance(type) as Control;
control.ID = mp.Alias;
if (!IsPostBack)
@@ -71,7 +75,7 @@ namespace umbraco.presentation.umbraco.LiveEditing.Modules.SkinModule
}
// register alias
- uicontrols.PropertyPanel pp = new uicontrols.PropertyPanel();
+ var pp = new uicontrols.PropertyPanel();
pp.Text = mp.Name;
pp.Controls.Add(control);
macroProperties.Controls.Add(pp);
@@ -94,10 +98,6 @@ namespace umbraco.presentation.umbraco.LiveEditing.Modules.SkinModule
}
}
}
- else
- {
-
- }
}
}
}
\ No newline at end of file
diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/LiveEditing/Modules/SkinModule/ModuleInstaller.aspx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/LiveEditing/Modules/SkinModule/ModuleInstaller.aspx.cs
index 5b6a9fe182..8cfd78a93f 100644
--- a/src/Umbraco.Web/umbraco.presentation/umbraco/LiveEditing/Modules/SkinModule/ModuleInstaller.aspx.cs
+++ b/src/Umbraco.Web/umbraco.presentation/umbraco/LiveEditing/Modules/SkinModule/ModuleInstaller.aspx.cs
@@ -4,42 +4,45 @@ using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
+using umbraco.BusinessLogic;
using umbraco.cms.businesslogic.packager;
namespace umbraco.presentation.umbraco.LiveEditing.Modules.SkinModule
{
public partial class ModuleInstaller : BasePages.UmbracoEnsuredPage
{
- private cms.businesslogic.packager.repositories.Repository repo;
- private string repoGuid = "65194810-1f85-11dd-bd0b-0800200c9a66";
-
+ private readonly cms.businesslogic.packager.repositories.Repository _repo;
+ private const string RepoGuid = "65194810-1f85-11dd-bd0b-0800200c9a66";
public ModuleInstaller()
{
- this.repo = cms.businesslogic.packager.repositories.Repository.getByGuid(this.repoGuid);
+ _repo = cms.businesslogic.packager.repositories.Repository.getByGuid(RepoGuid);
+ //for skinning, you need to be a developer
+ CurrentApp = DefaultApps.developer.ToString();
}
protected void Page_Load(object sender, EventArgs e)
{
- if(!string.IsNullOrEmpty(Request["guid"])){
+ if (!string.IsNullOrEmpty(Request["guid"]))
+ {
- Guid guid = new Guid(Request["guid"]);
+ var guid = new Guid(Request["guid"]);
- if (this.repo.HasConnection())
+ if (_repo.HasConnection())
{
- Installer installer = new Installer();
- string tempDir = installer.Import(this.repo.fetch(guid.ToString()));
+ var installer = new Installer();
+ var tempDir = installer.Import(_repo.fetch(guid.ToString()));
installer.LoadConfig(tempDir);
- int packageId = installer.CreateManifest(tempDir, guid.ToString(), this.repoGuid);
+ var packageId = installer.CreateManifest(tempDir, guid.ToString(), RepoGuid);
installer.InstallFiles(packageId, tempDir);
installer.InstallBusinessLogic(packageId, tempDir);
installer.InstallCleanUp(packageId, tempDir);
library.RefreshContent();
if (cms.businesslogic.skinning.Skinning.IsPackageInstalled(new Guid(Request["guid"])) ||
- cms.businesslogic.skinning.Skinning.IsPackageInstalled(Request["name"]))
+ cms.businesslogic.skinning.Skinning.IsPackageInstalled(Request["name"]))
{
- Response.Write(cms.businesslogic.skinning.Skinning.GetModuleAlias(Request["name"]));
+ Response.Write(cms.businesslogic.skinning.Skinning.GetModuleAlias(Request["name"]));
}
else
{
From 1012a4814d43fd2b258c23c9a322d1d82725c540 Mon Sep 17 00:00:00 2001
From: Shannon Deminick
Date: Wed, 10 Apr 2013 03:22:11 +0600
Subject: [PATCH 27/29] updates #U4-2070 for tiny mce plugins
---
.../plugins/tinymce3/InsertAnchor.aspx.cs | 11 +++++++
.../plugins/tinymce3/insertChar.aspx.cs | 11 +++++++
.../plugins/tinymce3/insertImage.aspx.cs | 29 +++++++------------
.../plugins/tinymce3/insertLink.aspx.cs | 25 ++++++----------
4 files changed, 42 insertions(+), 34 deletions(-)
diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/plugins/tinymce3/InsertAnchor.aspx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/plugins/tinymce3/InsertAnchor.aspx.cs
index 57452b9498..0b50bb9b72 100644
--- a/src/Umbraco.Web/umbraco.presentation/umbraco/plugins/tinymce3/InsertAnchor.aspx.cs
+++ b/src/Umbraco.Web/umbraco.presentation/umbraco/plugins/tinymce3/InsertAnchor.aspx.cs
@@ -3,12 +3,23 @@ using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
+using umbraco.BusinessLogic;
+using umbraco.businesslogic.Exceptions;
namespace umbraco.presentation.umbraco.plugins.tinymce3
{
public partial class InsertAnchor : BasePages.UmbracoEnsuredPage
{
+ protected override void OnInit(EventArgs e)
+ {
+ base.OnInit(e);
+
+ //this could be used for media or content so we need to at least validate that the user has access to one or the other
+ if (!ValidateUserApp(DefaultApps.content.ToString()) && !ValidateUserApp(DefaultApps.media.ToString()))
+ throw new UserAuthorizationException("The current user doesn't have access to the section/app");
+ }
+
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/plugins/tinymce3/insertChar.aspx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/plugins/tinymce3/insertChar.aspx.cs
index 478c1bdea7..6b81b2c129 100644
--- a/src/Umbraco.Web/umbraco.presentation/umbraco/plugins/tinymce3/insertChar.aspx.cs
+++ b/src/Umbraco.Web/umbraco.presentation/umbraco/plugins/tinymce3/insertChar.aspx.cs
@@ -3,11 +3,22 @@ using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
+using umbraco.BusinessLogic;
+using umbraco.businesslogic.Exceptions;
namespace umbraco.presentation.umbraco.plugins.tinymce3
{
public partial class insertChar : BasePages.UmbracoEnsuredPage
{
+ protected override void OnInit(EventArgs e)
+ {
+ base.OnInit(e);
+
+ //this could be used for media or content so we need to at least validate that the user has access to one or the other
+ if (!ValidateUserApp(DefaultApps.content.ToString()) && !ValidateUserApp(DefaultApps.media.ToString()))
+ throw new UserAuthorizationException("The current user doesn't have access to the section/app");
+ }
+
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/plugins/tinymce3/insertImage.aspx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/plugins/tinymce3/insertImage.aspx.cs
index 753074eb43..9a392b36e0 100644
--- a/src/Umbraco.Web/umbraco.presentation/umbraco/plugins/tinymce3/insertImage.aspx.cs
+++ b/src/Umbraco.Web/umbraco.presentation/umbraco/plugins/tinymce3/insertImage.aspx.cs
@@ -3,6 +3,8 @@ using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
+using umbraco.BusinessLogic;
+using umbraco.businesslogic.Exceptions;
namespace umbraco.presentation.plugins.tinymce3
{
@@ -11,7 +13,7 @@ namespace umbraco.presentation.plugins.tinymce3
protected uicontrols.TabView tbv = new uicontrols.TabView();
- protected void Page_Load(object sender, System.EventArgs e)
+ protected void Page_Load(object sender, EventArgs e)
{
ClientLoader.DataBind();
@@ -27,38 +29,29 @@ namespace umbraco.presentation.plugins.tinymce3
Title = ui.Text("insertimage");
// Put user code to initialize the page here
- uicontrols.TabPage tp = tv_options.NewTabPage(ui.Text("choose"));
+ var tp = tv_options.NewTabPage(ui.Text("choose"));
tp.HasMenu = false;
tp.Controls.Add(pane_select);
- uicontrols.TabPage tp2 = tv_options.NewTabPage(ui.Text("create") + " " + ui.Text("new"));
+ var tp2 = tv_options.NewTabPage(ui.Text("create") + " " + ui.Text("new"));
tp2.HasMenu = false;
tp2.Controls.Add(pane_upload);
}
- #region Web Form Designer generated code
- override protected void OnInit(EventArgs e)
+
+ protected override void OnInit(EventArgs e)
{
- //
- // CODEGEN: This call is required by the ASP.NET Web Form Designer.
- //
tbv.ID = "tabview1";
tbv.AutoResize = false;
tbv.Width = 500;
tbv.Height = 290;
- InitializeComponent();
+ //this could be used for media or content so we need to at least validate that the user has access to one or the other
+ if (!ValidateUserApp(DefaultApps.content.ToString()) && !ValidateUserApp(DefaultApps.media.ToString()))
+ throw new UserAuthorizationException("The current user doesn't have access to the section/app");
+
base.OnInit(e);
}
- ///
- /// 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.Web/umbraco.presentation/umbraco/plugins/tinymce3/insertLink.aspx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/plugins/tinymce3/insertLink.aspx.cs
index 255c310b98..833d98e262 100644
--- a/src/Umbraco.Web/umbraco.presentation/umbraco/plugins/tinymce3/insertLink.aspx.cs
+++ b/src/Umbraco.Web/umbraco.presentation/umbraco/plugins/tinymce3/insertLink.aspx.cs
@@ -3,17 +3,22 @@ using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
+using umbraco.BusinessLogic;
+using umbraco.businesslogic.Exceptions;
namespace umbraco.presentation.plugins.tinymce3
{
public partial class insertLink : BasePages.UmbracoEnsuredPage
{
- //protected uicontrols.TabView tbv = new uicontrols.TabView();
- public insertLink()
+ protected override void OnInit(EventArgs e)
{
- CurrentApp = BusinessLogic.DefaultApps.content.ToString();
+ base.OnInit(e);
+ //this could be used for media or content so we need to at least validate that the user has access to one or the other
+ if (!ValidateUserApp(DefaultApps.content.ToString()) && !ValidateUserApp(DefaultApps.media.ToString()))
+ throw new UserAuthorizationException("The current user doesn't have access to the section/app");
}
+
protected void Page_Load(object sender, System.EventArgs e)
{
ClientLoader.DataBind();
@@ -48,23 +53,11 @@ namespace umbraco.presentation.plugins.tinymce3
base.Render(writer);
}
- public BusinessLogic.User GetUser()
+ public User GetUser()
{
return base.getUser();
}
- override protected void OnInit(EventArgs e)
- {
- //
- // CODEGEN: This call is required by the ASP.NET Web Form Designer.
- //
- //tbv.ID = "tabview1";
- //tbv.Width = 300;
- //tbv.Height = 320;
- //tbv.AutoResize = false;
-
- base.OnInit(e);
- }
}
}
From 1f86d8c562ab63d356a3bd12569e07e510a57d8b Mon Sep 17 00:00:00 2001
From: Shannon Deminick
Date: Wed, 10 Apr 2013 03:56:10 +0600
Subject: [PATCH 28/29] fixes merge issues
---
.../umbraco/developer/Packages/installedPackage.aspx.cs | 3 ++-
.../umbraco/dialogs/moveOrCopy.aspx.cs | 8 ++++----
.../umbraco.presentation/umbraco/editContent.aspx.cs | 4 ++--
3 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/developer/Packages/installedPackage.aspx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/developer/Packages/installedPackage.aspx.cs
index 0c61feddda..67b58f1395 100644
--- a/src/Umbraco.Web/umbraco.presentation/umbraco/developer/Packages/installedPackage.aspx.cs
+++ b/src/Umbraco.Web/umbraco.presentation/umbraco/developer/Packages/installedPackage.aspx.cs
@@ -15,6 +15,7 @@ using Umbraco.Core.IO;
using Umbraco.Core;
using Umbraco.Core.Logging;
using Umbraco.Core.Models;
+using umbraco.BusinessLogic;
using umbraco.cms.businesslogic.web;
using runtimeMacro = umbraco.macro;
using System.Xml;
@@ -436,7 +437,7 @@ namespace umbraco.presentation.developer.packages
if (contentType != null)
{
contentTypes.Add(contentType);
- pack.Data.Documenttypes.Remove(nId.ToString(CultureInfo.InvariantCulture));
+ _pack.Data.Documenttypes.Remove(nId.ToString(CultureInfo.InvariantCulture));
// refresh content cache when document types are removed
refreshCache = true;
}
diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/moveOrCopy.aspx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/moveOrCopy.aspx.cs
index ba7126f244..e9397cd889 100644
--- a/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/moveOrCopy.aspx.cs
+++ b/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/moveOrCopy.aspx.cs
@@ -60,8 +60,8 @@ namespace umbraco.dialogs
masterType.SelectedValue = documentType.MasterContentType.ToString();
- rename.Text = dt.Text + " (copy)";
- pane_settings.Text = "Make a copy of the document type '" + dt.Text + "' and save it under a new name";
+ rename.Text = documentType.Text + " (copy)";
+ pane_settings.Text = "Make a copy of the document type '" + documentType.Text + "' and save it under a new name";
}
else
@@ -79,7 +79,7 @@ namespace umbraco.dialogs
var cmsNode = new CMSNode(int.Parse(helper.Request("id")));
var validAction = true;
- if (app == "content" && cmsNode.HasChildren)
+ if (CurrentApp == "content" && cmsNode.HasChildren)
validAction = ValidAction(helper.Request("mode") == "cut" ? 'M' : 'O');
@@ -103,7 +103,7 @@ namespace umbraco.dialogs
}
- private static bool ValidAction(char actionLetter)
+ private bool ValidAction(char actionLetter)
{
var cmsNode = new CMSNode(int.Parse(helper.Request("id")));
var currentAction = BusinessLogic.Actions.Action.GetPermissionAssignable().First(a => a.Letter == actionLetter);
diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/editContent.aspx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/editContent.aspx.cs
index b682abe5b5..006e2148ce 100644
--- a/src/Umbraco.Web/umbraco.presentation/umbraco/editContent.aspx.cs
+++ b/src/Umbraco.Web/umbraco.presentation/umbraco/editContent.aspx.cs
@@ -280,7 +280,7 @@ namespace umbraco.cms.presentation
//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)
+ foreach (var item in _cControl.DataTypes)
{
_document.getProperty(item.Key).Value = item.Value.Data.Value;
}
@@ -321,7 +321,7 @@ namespace umbraco.cms.presentation
{
ClientTools.ShowSpeechBubble(speechBubbleIcon.save, ui.Text("speechBubbles", "editContentPublishedHeader", null), ui.Text("speechBubbles", "editContentPublishedText", null));
- littPublishStatus.Text = string.Format("{0}: {1}
", ui.Text("content", "lastPublished", base.getUser()), _document.VersionDate.ToString());
+ _littPublishStatus.Text = string.Format("{0}: {1}
", ui.Text("content", "lastPublished", base.getUser()), _document.VersionDate.ToString());
if (getUser().GetPermissions(_document.Path).IndexOf("U") > -1)
_unPublish.Visible = true;
From 1b086e226792221e1e4f8796c44fbf8846291330 Mon Sep 17 00:00:00 2001
From: Shannon Deminick
Date: Wed, 10 Apr 2013 04:04:33 +0600
Subject: [PATCH 29/29] fixes merge issue
---
src/Umbraco.Web/umbraco.presentation/umbraco/editContent.aspx.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/editContent.aspx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/editContent.aspx.cs
index 006e2148ce..3526213d72 100644
--- a/src/Umbraco.Web/umbraco.presentation/umbraco/editContent.aspx.cs
+++ b/src/Umbraco.Web/umbraco.presentation/umbraco/editContent.aspx.cs
@@ -88,6 +88,7 @@ namespace umbraco.cms.presentation
}
}
+ _cControl = new controls.ContentControl(_document, _canPublish, "TabView1");
_cControl.ID = "TabView1";