diff --git a/src/Umbraco.Web.UI.Client/src/common/resources/entity.resource.js b/src/Umbraco.Web.UI.Client/src/common/resources/entity.resource.js
index 9cf1181cfa..61d646afc0 100644
--- a/src/Umbraco.Web.UI.Client/src/common/resources/entity.resource.js
+++ b/src/Umbraco.Web.UI.Client/src/common/resources/entity.resource.js
@@ -127,6 +127,25 @@ function entityResource($q, $http, umbRequestHelper) {
'Failed to retrieve url for id:' + id);
},
+ getUrlByUdi: function (udi, culture) {
+
+ if (!udi) {
+ return "";
+ }
+
+ if (!culture) {
+ culture = "";
+ }
+
+ return umbRequestHelper.resourcePromise(
+ $http.get(
+ umbRequestHelper.getApiUrl(
+ "entityApiBaseUrl",
+ "GetUrl",
+ [{ udi: udi }, {culture: culture }])),
+ 'Failed to retrieve url for UDI:' + udi);
+ },
+
/**
* @ngdoc method
* @name umbraco.resources.entityResource#getById
@@ -166,18 +185,22 @@ function entityResource($q, $http, umbRequestHelper) {
},
- getUrlAndAnchors: function (id) {
+ getUrlAndAnchors: function (id, culture) {
if (id === -1 || id === "-1") {
return null;
}
+ if (!culture) {
+ culture = "";
+ }
+
return umbRequestHelper.resourcePromise(
$http.get(
umbRequestHelper.getApiUrl(
"entityApiBaseUrl",
"GetUrlAndAnchors",
- [{ id: id }])),
+ [{ id: id }, {culture: culture }])),
'Failed to retrieve url and anchors data for id ' + id);
},
diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/multiurlpicker/multiurlpicker.controller.js b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/multiurlpicker/multiurlpicker.controller.js
index 951b593b8b..2e4313ec76 100644
--- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/multiurlpicker/multiurlpicker.controller.js
+++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/multiurlpicker/multiurlpicker.controller.js
@@ -144,6 +144,16 @@ function multiUrlPickerController($scope, angularHelper, localizationService, en
if ($scope.model.validation && $scope.model.validation.mandatory && !$scope.model.config.minNumber) {
$scope.model.config.minNumber = 1;
}
+
+ _.each($scope.model.value, function (item){
+ // we must reload the "document" link URLs to match the current editor culture
+ if (item.udi.indexOf("/document/") > 0) {
+ item.url = null;
+ entityResource.getUrlByUdi(item.udi).then(function (data) {
+ item.url = data;
+ });
+ }
+ });
}
init();
diff --git a/src/Umbraco.Web/Editors/EntityController.cs b/src/Umbraco.Web/Editors/EntityController.cs
index 0513017b70..ca5bec4fce 100644
--- a/src/Umbraco.Web/Editors/EntityController.cs
+++ b/src/Umbraco.Web/Editors/EntityController.cs
@@ -206,6 +206,35 @@ namespace Umbraco.Web.Editors
throw new HttpResponseException(HttpStatusCode.NotFound);
}
+ ///
+ /// Gets the url of an entity
+ ///
+ /// UDI of the entity to fetch URL for
+ /// The culture to fetch the URL for
+ /// The URL or path to the item
+ public HttpResponseMessage GetUrl(Udi udi, string culture = "*")
+ {
+ var intId = Services.EntityService.GetId(udi);
+ if (!intId.Success)
+ throw new HttpResponseException(HttpStatusCode.NotFound);
+ UmbracoEntityTypes entityType;
+ switch(udi.EntityType)
+ {
+ case Constants.UdiEntityType.Document:
+ entityType = UmbracoEntityTypes.Document;
+ break;
+ case Constants.UdiEntityType.Media:
+ entityType = UmbracoEntityTypes.Media;
+ break;
+ case Constants.UdiEntityType.Member:
+ entityType = UmbracoEntityTypes.Member;
+ break;
+ default:
+ throw new HttpResponseException(HttpStatusCode.NotFound);
+ }
+ return GetUrl(intId.Result, entityType, culture);
+ }
+
///
/// Gets the url of an entity
///
@@ -303,7 +332,9 @@ namespace Umbraco.Web.Editors
[HttpGet]
public UrlAndAnchors GetUrlAndAnchors(int id, string culture = "*")
{
- var url = UmbracoContext.UrlProvider.GetUrl(id);
+ culture = culture ?? ClientCulture();
+
+ var url = UmbracoContext.UrlProvider.GetUrl(id, culture: culture);
var anchorValues = Services.ContentService.GetAnchorValuesFromRTEs(id, culture);
return new UrlAndAnchors(url, anchorValues);
}