Implementation of 27753.

[TFS Changeset #70229]
This commit is contained in:
kenny
2010-06-20 13:43:53 +00:00
parent 8749ceabf0
commit 35158abb32
4 changed files with 182 additions and 48 deletions

View File

@@ -598,6 +598,26 @@ namespace umbraco
}
}
/// <summary>
/// Gets HelpPage configurations.
/// A help page configuration specify language, user type, application, application url and
/// the target help page url.
/// </summary>
public static XmlNode HelpPages
{
get
{
try
{
return GetKeyAsNode("/settings/help");
}
catch
{
return null;
}
}
}
/// <summary>
/// Gets all repositories registered, and returns them as XmlNodes, containing name, alias and webservice url.
/// These repositories are used by the build-in package installer and uninstaller to install new packages and check for updates.

View File

@@ -25,6 +25,7 @@
<!-- <errorPage culture="en-US">200</errorPage>-->
<error404>1050</error404>
</errors>
<notifications>
<!-- the email that should be used as from mail when umbraco sends a notification -->
<email>robot@umbraco.dk</email>
@@ -142,4 +143,11 @@
<DefaultBackofficeProvider>UsersMembershipProvider</DefaultBackofficeProvider>
</users>
</providers>
<!-- Maps language, usertype, application and application_url to help pages -->
<help defaultUrl="http://our.umbraco.org/wiki/umbraco-help/{0}/{1}">
<!-- Add links that should open custom help pages -->
<!--<link application="content" applicationUrl="dashboard.aspx" language="en" userType="Administrators" helpUrl="http://www.xyz.no?{0}/{1}/{2}/{3}" /> -->
</help>
</settings>

View File

@@ -4,14 +4,120 @@ using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml;
namespace umbraco.presentation.umbraco
{
public class Help
{
public string DefaultURL { get; set; }
public List<HelpConfigPage> HelpConfigPages { get; set; }
public Help(XmlNode helpConfigNode)
{
DefaultURL = GetXmlAttributeAsString(helpConfigNode.Attributes["defaultUrl"]);
HelpConfigPages = new List<HelpConfigPage>();
foreach (XmlNode linkNode in helpConfigNode.ChildNodes)
{
if (linkNode.NodeType != XmlNodeType.Element) continue;
HelpConfigPages.Add(new HelpConfigPage
{
Application = GetXmlAttributeAsString(linkNode.Attributes["application"]),
ApplicationUrl = GetXmlAttributeAsString(linkNode.Attributes["applicationUrl"]),
Language = GetXmlAttributeAsString(linkNode.Attributes["language"]),
UserType = GetXmlAttributeAsString(linkNode.Attributes["userType"]),
HelpUrl = GetXmlAttributeAsString(linkNode.Attributes["helpUrl"])
});
}
}
public string ResolveHelpUrl(HelpPage requestedHelpPage)
{
HelpConfigPage bestMatchingConfigPage = null;
int currentBestMatchCount = 0;
foreach (HelpConfigPage helpConfigPage in HelpConfigPages)
{
int attributeMatchCount = 0;
if ((helpConfigPage.Application != "" && String.Compare(helpConfigPage.Application, requestedHelpPage.Application, true) != 0) ||
(helpConfigPage.ApplicationUrl != "" && String.Compare(helpConfigPage.ApplicationUrl, requestedHelpPage.ApplicationUrl, true) != 0) ||
(helpConfigPage.Language != "" && String.Compare(helpConfigPage.Language, requestedHelpPage.Language, true) != 0) ||
(helpConfigPage.UserType != "" && String.Compare(helpConfigPage.UserType, requestedHelpPage.UserType, true) != 0))
{
continue;
}
if (String.Compare(helpConfigPage.Application, requestedHelpPage.Application, true) == 0) attributeMatchCount++;
if (String.Compare(helpConfigPage.ApplicationUrl, requestedHelpPage.ApplicationUrl, true) == 0) attributeMatchCount++;
if (String.Compare(helpConfigPage.Language, requestedHelpPage.Language, true) == 0) attributeMatchCount++;
if (String.Compare(helpConfigPage.UserType, requestedHelpPage.UserType, true) == 0) attributeMatchCount++;
if (attributeMatchCount > currentBestMatchCount)
{
currentBestMatchCount = attributeMatchCount;
bestMatchingConfigPage = helpConfigPage;
}
}
return bestMatchingConfigPage == null ? GenerateDefaultUrl(requestedHelpPage) : GenerateConfiguredUrl(bestMatchingConfigPage);
}
public string GenerateConfiguredUrl(HelpConfigPage helpConfigPage)
{
return String.Format(helpConfigPage.HelpUrl,
helpConfigPage.Application,
helpConfigPage.ApplicationUrl,
helpConfigPage.Language,
helpConfigPage.UserType).ToLower();
}
public string GenerateDefaultUrl(HelpPage helpPage)
{
return string.Format(DefaultURL,
helpPage.Application,
helpPage.ApplicationUrl);
}
private string GetXmlAttributeAsString(XmlAttribute attribute) {
if (attribute == null) return "";
return attribute.Value.Trim();
}
}
public class HelpPage
{
public string Application { get; set; }
public string ApplicationUrl { get; set; }
public string Language { get; set; }
public string UserType { get; set; }
}
public class HelpConfigPage : HelpPage
{
public string HelpUrl { get; set; }
}
public partial class helpRedirect : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Help help = new Help(UmbracoSettings.HelpPages);
HelpPage requestedHelpPage = new HelpPage {
Application = Request.QueryString["Application"],
ApplicationUrl = Request.QueryString["ApplicationUrl"],
Language = Request.QueryString["Language"],
UserType = Request.QueryString["UserType"]
};
Response.Redirect(help.ResolveHelpUrl(requestedHelpPage));
}
}
}

View File

@@ -6,7 +6,7 @@
Umbraco.Sys.registerNamespace("Umbraco.Application");
Umbraco.Application.Actions = function() {
Umbraco.Application.Actions = function () {
/// <summary>
/// Application actions actions for the context menu, help dialogs, logout, etc...
/// This class supports an event listener model. Currently the available events are:
@@ -22,24 +22,24 @@ Umbraco.Application.Actions = function() {
_windowTitle: " - Umbraco CMS - ",
_currApp: "",
addEventHandler: function(fnName, fn) {
addEventHandler: function (fnName, fn) {
/// <summary>Adds an event listener to the event name event</summary>
if (typeof (jQuery) != "undefined") jQuery(window.top).bind(fnName, fn); //if there's no jQuery, there is no events
},
removeEventHandler: function(fnName, fn) {
removeEventHandler: function (fnName, fn) {
/// <summary>Removes an event listener to the event name event</summary>
if (typeof (jQuery) != "undefined") jQuery(window.top).unbind(fnName, fn); //if there's no jQuery, there is no events
},
showSpeachBubble: function(ico, hdr, msg) {
showSpeachBubble: function (ico, hdr, msg) {
if (typeof (UmbClientMgr.mainWindow().UmbSpeechBubble) != "undefined") {
UmbClientMgr.mainWindow().UmbSpeechBubble.ShowMessage(ico, hdr, msg);
}
else alert(msg);
},
launchHelp: function(lang, userType) {
launchHelp: function (lang, userType) {
/// <summary>Launches the contextual help window</summary>
var rightUrl = UmbClientMgr.contentFrame().document.location.href.split("\/");
if (rightUrl.length > 0) {
@@ -48,18 +48,18 @@ Umbraco.Application.Actions = function() {
if (rightUrl.indexOf("?") > 0) {
rightUrl = rightUrl.substring(0, rightUrl.indexOf("?"));
}
var url = "http://umbraco.org/redir/help/" + lang + "/" + userType + "/" + this._currApp + "/" + rightUrl;
window.open(url, 'help', 'width=750,height=500,scrollbars=auto,resizable=1;');
var url = "/umbraco/helpRedirect.aspx?Application=" + this._currApp + '&ApplicationURL=' + rightUrl + '&Language=' + lang + "&UserType=" + userType;
window.open(url);
return false;
},
launchAbout: function() {
launchAbout: function () {
/// <summary>Launches the about Umbraco window</summary>
UmbClientMgr.openModalWindow("dialogs/about.aspx", UmbClientMgr.uiKeys()['general_about'], true, 450, 390);
return false;
},
launchCreateWizard: function() {
launchCreateWizard: function () {
/// <summary>Launches the create content wizard</summary>
if (this._currApp == 'media' || this._currApp == 'content' || this._currApp == '') {
@@ -74,7 +74,7 @@ Umbraco.Application.Actions = function() {
alert('Not supported - please create by right clicking the parentnode and choose new...');
},
logout: function() {
logout: function () {
/// <summary>Logs the user out</summary>
if (confirm(UmbClientMgr.uiKeys()["defaultdialogs_confirmlogout"])) {
//raise beforeLogout event
@@ -85,7 +85,7 @@ Umbraco.Application.Actions = function() {
return false;
},
shiftApp: function(whichApp, appName) {
shiftApp: function (whichApp, appName) {
/// <summary>Changes the application</summary>
this._debug("shiftApp: " + whichApp + ", " + appName);
@@ -112,7 +112,7 @@ Umbraco.Application.Actions = function() {
}
}
UmbClientMgr.mainTree().rebuildTree(whichApp, function(args) {
UmbClientMgr.mainTree().rebuildTree(whichApp, function (args) {
//the callback will fire when the tree rebuilding is done, we
//need to check the args to see if the tree was rebuild from cache
//and if it had a previously selected node, if it didn't then load the dashboard.
@@ -126,13 +126,13 @@ Umbraco.Application.Actions = function() {
UmbClientMgr.mainWindow().document.title = appName + this._windowTitle + window.location.hostname.toLowerCase().replace('www', '');
},
getCurrApp: function() {
getCurrApp: function () {
return this._currApp;
},
//TODO: Move this into a window manager class
openDialog: function(diaTitle, diaDoc, dwidth, dheight, optionalParams) {
openDialog: function (diaTitle, diaDoc, dwidth, dheight, optionalParams) {
/// <summary>Opens the dialog window</summary>
if (this._dialogWindow != null && !this._dialogWindow.closed) {
@@ -141,16 +141,16 @@ Umbraco.Application.Actions = function() {
this._dialogWindow = UmbClientMgr.mainWindow().open(diaDoc, 'dialogpage', "width=" + dwidth + "px,height=" + dheight + "px" + optionalParams);
},
openDashboard: function(whichApp) {
openDashboard: function (whichApp) {
UmbClientMgr.contentFrame('dashboard.aspx?app=' + whichApp);
},
actionTreeEditMode: function() {
actionTreeEditMode: function () {
/// <summary></summary>
UmbClientMgr.mainTree().toggleEditMode(true);
},
actionSort: function() {
actionSort: function () {
/// <summary></summary>
if (UmbClientMgr.mainTree().getActionNode().nodeId != '0' && UmbClientMgr.mainTree().getActionNode().nodeType != '') {
@@ -159,7 +159,7 @@ Umbraco.Application.Actions = function() {
},
actionRights: function() {
actionRights: function () {
/// <summary></summary>
if (UmbClientMgr.mainTree().getActionNode().nodeId != '-1' && UmbClientMgr.mainTree().getActionNode().nodeType != '') {
@@ -167,7 +167,7 @@ Umbraco.Application.Actions = function() {
}
},
actionProtect: function() {
actionProtect: function () {
/// <summary></summary>
if (UmbClientMgr.mainTree().getActionNode().nodeId != '-1' && UmbClientMgr.mainTree().getActionNode().nodeType != '') {
@@ -175,20 +175,20 @@ Umbraco.Application.Actions = function() {
}
},
actionRollback: function() {
actionRollback: function () {
/// <summary></summary>
UmbClientMgr.openModalWindow('dialogs/rollback.aspx?nodeId=' + UmbClientMgr.mainTree().getActionNode().nodeId + '&rnd=' + this._utils.generateRandom(), uiKeys['actions_rollback'], true, 600, 550);
},
actionRefresh: function() {
actionRefresh: function () {
/// <summary></summary>
//raise nodeRefresh event
jQuery(window.top).trigger("nodeRefresh", []);
},
actionNotify: function() {
actionNotify: function () {
/// <summary></summary>
if (UmbClientMgr.mainTree().getActionNode().nodeId != '-1' && UmbClientMgr.mainTree().getActionNode().nodeType != '') {
@@ -196,11 +196,11 @@ Umbraco.Application.Actions = function() {
}
},
actionUpdate: function() {
actionUpdate: function () {
/// <summary></summary>
},
actionPublish: function() {
actionPublish: function () {
/// <summary></summary>
if (UmbClientMgr.mainTree().getActionNode().nodeId != '' != '-1' && UmbClientMgr.mainTree().getActionNode().nodeType != '') {
@@ -208,7 +208,7 @@ Umbraco.Application.Actions = function() {
}
},
actionToPublish: function() {
actionToPublish: function () {
/// <summary></summary>
if (UmbClientMgr.mainTree().getActionNode().nodeId != '-1' && UmbClientMgr.mainTree().getActionNode().nodeType != '') {
@@ -218,20 +218,20 @@ Umbraco.Application.Actions = function() {
}
},
actionQuit: function() {
actionQuit: function () {
/// <summary></summary>
if (confirm(uiKeys['defaultdialogs_confirmlogout'] + '\n\n'))
document.location.href = 'logout.aspx';
},
actionRePublish: function() {
actionRePublish: function () {
/// <summary></summary>
UmbClientMgr.openModalWindow('dialogs/republish.aspx?rnd=' + this._utils.generateRandom(), 'Republishing entire site', true, 450, 210);
},
actionAssignDomain: function() {
actionAssignDomain: function () {
/// <summary></summary>
if (UmbClientMgr.mainTree().getActionNode().nodeId != '-1' && UmbClientMgr.mainTree().getActionNode().nodeType != '') {
@@ -239,13 +239,13 @@ Umbraco.Application.Actions = function() {
}
},
actionLiveEdit: function() {
actionLiveEdit: function () {
/// <summary></summary>
window.open("canvas.aspx?redir=/" + UmbClientMgr.mainTree().getActionNode().nodeId + ".aspx", "liveediting");
},
actionNew: function() {
actionNew: function () {
/// <summary>Show the create new modal overlay</summary>
var actionNode = UmbClientMgr.mainTree().getActionNode();
if (actionNode.nodeType != '') {
@@ -264,7 +264,7 @@ Umbraco.Application.Actions = function() {
}
},
actionNewFolder: function() {
actionNewFolder: function () {
/// <summary></summary>
if (UmbClientMgr.mainTree().getActionNode().nodeType != '') {
@@ -272,7 +272,7 @@ Umbraco.Application.Actions = function() {
}
},
actionSendToTranslate: function() {
actionSendToTranslate: function () {
/// <summary></summary>
if (UmbClientMgr.mainTree().getActionNode().nodeId != '-1' && UmbClientMgr.mainTree().getActionNode().nodeType != '') {
@@ -280,7 +280,7 @@ Umbraco.Application.Actions = function() {
}
},
actionEmptyTranscan: function() {
actionEmptyTranscan: function () {
/// <summary></summary>
if (UmbClientMgr.mainTree().getActionNode().nodeId != '-1' && UmbClientMgr.mainTree().getActionNode().nodeType != '') {
@@ -288,7 +288,7 @@ Umbraco.Application.Actions = function() {
}
},
actionImport: function() {
actionImport: function () {
/// <summary></summary>
if (UmbClientMgr.mainTree().getActionNode().nodeType != '') {
@@ -296,7 +296,7 @@ Umbraco.Application.Actions = function() {
}
},
actionExport: function() {
actionExport: function () {
/// <summary></summary>
if (UmbClientMgr.mainTree().getActionNode().nodeType != '') {
@@ -304,17 +304,17 @@ Umbraco.Application.Actions = function() {
}
},
actionAudit: function() {
actionAudit: function () {
/// <summary></summary>
UmbClientMgr.openModalWindow('dialogs/viewAuditTrail.aspx?nodeId=' + UmbClientMgr.mainTree().getActionNode().nodeId + '&rnd=' + this._utils.generateRandom(), uiKeys['actions_auditTrail'], true, 550, 500);
},
actionPackage: function() {
actionPackage: function () {
/// <summary></summary>
},
actionDelete: function() {
actionDelete: function () {
/// <summary></summary>
var actionNode = UmbClientMgr.mainTree().getActionNode();
@@ -334,7 +334,7 @@ Umbraco.Application.Actions = function() {
umbraco.presentation.webservices.legacyAjaxCalls.DeleteContentPermanently(
UmbClientMgr.mainTree().getActionNode().nodeId,
UmbClientMgr.mainTree().getActionNode().nodeType,
function() {
function () {
_this._debug("actionDelete: Raising event");
//raise nodeDeleted event
jQuery(window.top).trigger("nodeDeleted", []);
@@ -343,30 +343,30 @@ Umbraco.Application.Actions = function() {
else {
umbraco.presentation.webservices.legacyAjaxCalls.Delete(
UmbClientMgr.mainTree().getActionNode().nodeId, "",
UmbClientMgr.mainTree().getActionNode().nodeType,
function() {
UmbClientMgr.mainTree().getActionNode().nodeType,
function () {
_this._debug("actionDelete: Raising event");
//raise nodeDeleted event
jQuery(window.top).trigger("nodeDeleted", []);
});
});
}
}
},
actionDisable: function() {
actionDisable: function () {
/// <summary>
/// Used for users when disable is selected.
/// </summary>
if (confirm(uiKeys['defaultdialogs_confirmdisable'] + ' "' + UmbClientMgr.mainTree().getActionNode().nodeName + '"?\n\n')) {
umbraco.presentation.webservices.legacyAjaxCalls.DisableUser(UmbClientMgr.mainTree().getActionNode().nodeId, function() {
umbraco.presentation.webservices.legacyAjaxCalls.DisableUser(UmbClientMgr.mainTree().getActionNode().nodeId, function () {
UmbClientMgr.mainTree().reloadActionNode();
});
}
},
actionMove: function() {
actionMove: function () {
/// <summary></summary>
if (UmbClientMgr.mainTree().getActionNode().nodeId != '-1' && UmbClientMgr.mainTree().getActionNode().nodeType != '') {
@@ -374,19 +374,19 @@ Umbraco.Application.Actions = function() {
}
},
actionCopy: function() {
actionCopy: function () {
/// <summary></summary>
if (UmbClientMgr.mainTree().getActionNode().nodeId != '-1' && UmbClientMgr.mainTree().getActionNode().nodeType != '') {
UmbClientMgr.openModalWindow("dialogs/moveOrCopy.aspx?app=" + this._currApp + "&mode=copy&id=" + UmbClientMgr.mainTree().getActionNode().nodeId + '&rnd=' + this._utils.generateRandom(), uiKeys['actions_copy'], true, 500, 470);
}
},
_debug: function(strMsg) {
_debug: function (strMsg) {
if (this._isDebug) {
Sys.Debug.trace("AppActions: " + strMsg);
}
},
actionExportCode: function() {
actionExportCode: function () {
/// <summary></summary>
UmbClientMgr.openModalWindow("dialogs/exportCode.aspx", UmbClientMgr.uiKeys()['exportDocumentTypeAsCode'], true, 400, 350);
return false;