Beispiel #1
0
    /// <summary>
    /// Returns URL of the media item according site settings.
    /// </summary>
    /// <param name="nodeGuid">Node GUID of the current attachment node</param>
    /// <param name="documentUrlPath">URL path of the current attachment document</param>
    /// <param name="maxSideSize">Maximum dimension for images displayed for tile and thumbnails view</param>
    /// <param name="nodeAlias">Node alias of the current attachment node</param>
    /// <param name="nodeAliasPath">Node alias path of the current attachment node</param>
    /// <param name="nodeIsLink">Indicates if node is linked node.</param>
    public string GetContentItemUrl(Guid nodeGuid, string documentUrlPath, string nodeAlias, string nodeAliasPath, bool nodeIsLink, int height, int width, int maxSideSize, bool notAttachment, string documentExtension)
    {
        string result = "";

        if (documentExtension.Contains(";"))
        {
            documentExtension = documentExtension.Split(';')[0];
        }

        // Generate URL
        if (UsePermanentUrls)
        {
            bool isLink = ((OutputFormat == OutputFormatEnum.BBLink) || (OutputFormat == OutputFormatEnum.HTMLLink)) ||
                          ((OutputFormat == OutputFormatEnum.URL) && (SelectableContent == SelectableContentEnum.AllContent));

            if (String.IsNullOrEmpty(nodeAlias))
            {
                nodeAlias = "default";
            }

            if (notAttachment || isLink)
            {
                result = TreePathUtils.GetPermanentDocUrl(nodeGuid, nodeAlias, SiteObj.SiteName, null, documentExtension);
            }
            else
            {
                result = AttachmentInfoProvider.GetPermanentAttachmentUrl(nodeGuid, nodeAlias, documentExtension);
            }
        }
        else
        {
            string docUrlPath = nodeIsLink ? null : documentUrlPath;

            // Ensure live site view mode for URLs edited in on-site edit mode
            if (PortalContext.ViewMode == ViewModeEnum.EditLive)
            {
                PortalContext.SetRequestViewMode(ViewModeEnum.LiveSite);
            }

            result = TreePathUtils.GetUrl(nodeAliasPath, docUrlPath, SiteObj.SiteName, null, documentExtension);
        }

        // Make URL absolute if required
        int currentSiteId = CMSContext.CurrentSiteID;

        if (Config.UseFullURL || (currentSiteId != SiteObj.SiteID) || (currentSiteId != GetCurrentSiteId()))
        {
            result = URLHelper.GetAbsoluteUrl(result, SiteObj.DomainName, URLHelper.GetApplicationUrl(SiteObj.DomainName), null);
        }

        return(AddURLDimensionsAndResolve(result, height, width, maxSideSize));
    }
Beispiel #2
0
    /// <summary>
    /// Returns URL of the media item according site settings.
    /// </summary>
    /// <param name="nodeGuid">Node GUID of the current attachment node</param>
    /// <param name="documentUrlPath">URL path of the current attachment document</param>
    /// <param name="maxSideSize">Maximum dimension for images displayed for tile and thumbnails view</param>
    /// <param name="nodeAlias">Node alias of the current attachment node</param>
    /// <param name="nodeAliasPath">Node alias path of the current attachment node</param>
    /// <param name="nodeIsLink">Indicates if node is linked node.</param>
    public string GetContentItemUrl(Guid nodeGuid, string documentUrlPath, string nodeAlias, string nodeAliasPath, bool nodeIsLink, int height, int width, int maxSideSize, bool notAttachment, string documentExtension)
    {
        string result = "";

        if (documentExtension.Contains(";"))
        {
            documentExtension = documentExtension.Split(';')[0];
        }

        // Generate URL
        if (UsePermanentUrls)
        {
            bool isLink = ((OutputFormat == OutputFormatEnum.BBLink) || (OutputFormat == OutputFormatEnum.HTMLLink)) ||
                          ((OutputFormat == OutputFormatEnum.URL) && (SelectableContent == SelectableContentEnum.AllContent));

            if (String.IsNullOrEmpty(nodeAlias))
            {
                nodeAlias = "default";
            }

            if (notAttachment || isLink)
            {
                result = TreePathUtils.GetPermanentDocUrl(nodeGuid, nodeAlias, SiteObj.SiteName, null, documentExtension);
            }
            else
            {
                result = AttachmentManager.GetPermanentAttachmentUrl(nodeGuid, nodeAlias, documentExtension);
            }
        }
        else
        {
            string docUrlPath = nodeIsLink ? null : documentUrlPath;
            result = TreePathUtils.GetUrl(nodeAliasPath, docUrlPath, null, null, documentExtension);
        }

        // Make URL absolute if required
        int currentSiteId = CMSContext.CurrentSiteID;

        if (Config.UseFullURL || (currentSiteId != SiteObj.SiteID) || (currentSiteId != GetCurrentSiteId()))
        {
            result = URLHelper.GetAbsoluteUrl(result, SiteObj.DomainName, URLHelper.GetApplicationUrl(SiteObj.DomainName), null);
        }

        // Image dimensions to URL
        if (maxSideSize > 0)
        {
            result = URLHelper.AddParameterToUrl(result, "maxsidesize", maxSideSize.ToString());
        }
        if (height > 0)
        {
            result = URLHelper.AddParameterToUrl(result, "height", height.ToString());
        }
        if (width > 0)
        {
            result = URLHelper.AddParameterToUrl(result, "width", width.ToString());
        }

        // Media selctor should returns non-resolved URL in all cases
        bool isMediaSelector = (OutputFormat == OutputFormatEnum.URL) && (SelectableContent == SelectableContentEnum.OnlyMedia);

        return(isMediaSelector ? result : URLHelper.ResolveUrl(result, true, false));
    }