DROP FUNCTION {databaseOwner}{objectQualifier}DMXDAV_GetPath
GO

CREATE FUNCTION {databaseOwner}{objectQualifier}DMXDAV_GetPath
 (@EntryId INT, @PortalId INT, @Locale NVarChar(10))
RETURNS NVARCHAR(4000)
AS
BEGIN
 DECLARE @res NVARCHAR(4000)
 IF EXISTS (SELECT EntryId FROM {databaseOwner}{objectQualifier}DMX_Entries WHERE EntryId=@EntryId AND PortalId=@PortalId)
 BEGIN
  DECLARE @collection INT
  SELECT @collection = CollectionId FROM {databaseOwner}{objectQualifier}DMX_Entries WHERE EntryId=@EntryId AND PortalId=@PortalId
  DECLARE @name NVARCHAR(2000)
  SELECT @name = ISNULL((SELECT [Text] FROM {databaseOwner}{objectQualifier}DMX_ShortTexts WHERE TypeKey='ENT' AND SubTypeKey='TITLE' AND ObjectId=@EntryId AND Locale=@Locale),
  (SELECT [Text] FROM {databaseOwner}{objectQualifier}DMX_ShortTexts WHERE TypeKey='ENT' AND SubTypeKey='TITLE' AND ObjectId=@EntryId AND Locale=''))
  DECLARE @orig NVARCHAR(300)
  SELECT @orig = OriginalFilename FROM {databaseOwner}{objectQualifier}DMX_Entries WHERE EntryId=@EntryId AND PortalId=@PortalId
  SELECT @res = {databaseOwner}{objectQualifier}DMXDAV_GetPath(@collection, @PortalId, @Locale)+'/'+@name+{databaseOwner}{objectQualifier}DMXDAV_GetExtension(@orig)
 END
ELSE
 SELECT @res = ''
RETURN @res
END
GO

UPDATE {databaseOwner}{objectQualifier}DMX_Extensions
   SET [NodePattern] = 'ent(\d+)|recyclebin'
 WHERE [ExtensionKey] = 'Contents.Collections'
GO

