Example #1
0
    /// <inheritdoc />
    public virtual UrlInfo?GetMediaUrl(
        IPublishedContent content,
        string propertyAlias,
        UrlMode mode,
        string?culture,
        Uri current)
    {
        IPublishedProperty?prop = content.GetProperty(propertyAlias);

        // get the raw source value since this is what is used by IDataEditorWithMediaPath for processing
        var value = prop?.GetSourceValue(culture);

        if (value == null)
        {
            return(null);
        }

        IPublishedPropertyType?propType = prop?.PropertyType;

        if (_mediaPathGenerators.TryGetMediaPath(propType?.EditorAlias, value, out var path))
        {
            Uri url = AssembleUrl(path !, current, mode);
            return(UrlInfo.Url(url.ToString(), culture));
        }

        return(null);
    }
Example #2
0
        public virtual bool HasValue(IPublishedProperty property, string culture, string segment)
        {
            // the default implementation uses the old magic null & string comparisons,
            // other implementations may be more clever, and/or test the final converted object values
            var value = property.GetSourceValue(culture, segment);

            return(value != null && (!(value is string) || string.IsNullOrWhiteSpace((string)value) == false));
        }
        /// <summary>
        /// Check if is a linked Node for Nested Content, Grid and TinyMCE
        /// </summary>
        /// <param name="list">List with already linked Nodes</param>
        /// <param name="node">Content Node to check</param>
        /// <param name="prop">Property to check</param>
        /// <param name="nodePath">Complete node Path</param>
        /// <param name="currentUdi">UDI from current Content Node</param>
        /// <param name="isContent">true, if User is in Content Section; false, if User is in Media Section</param>
        /// <returns>List of LinkedNodesDataModel</returns>
        private List <LinkedNodesDataModel> AddRelatedNodeFromJsonSource(List <LinkedNodesDataModel> list, IPublishedContent node, IPublishedProperty prop, string nodePath, string currentUdi, bool isContent)
        {
            var ncValue = prop.GetSourceValue();

            if (ncValue != null)
            {
                Regex r;
                if (isContent)
                {
                    r = new Regex("\"umb://document/(.*?)\"", RegexOptions.IgnoreCase);
                }
                else
                {
                    r = new Regex("\"umb://media/(.*?)\"", RegexOptions.IgnoreCase);
                }

                MatchCollection mc = r.Matches(ncValue.ToString());

                foreach (var result in mc)
                {
                    var cleanedResultList = result.ToString().Replace("\"", string.Empty).Replace("\\", string.Empty).Split(',');
                    if (cleanedResultList.Count() == 1)
                    {
                        list = AddRelatedNode(list, node, null, prop, nodePath, currentUdi, cleanedResultList.FirstOrDefault());
                    }
                    else
                    {
                        foreach (var resultItem in cleanedResultList)
                        {
                            list = AddRelatedNode(list, node, null, prop, nodePath, currentUdi, resultItem);
                        }
                    }
                }
            }
            return(list);
        }
Example #4
0
        public virtual bool HasValue(IPublishedProperty property, string culture, string segment)
        {
            var value = property.GetSourceValue(culture, segment);

            return(value != null && (!(value is string stringValue) || !string.IsNullOrWhiteSpace(stringValue)));
        }