Beispiel #1
0
 /// <summary>
 /// Constructor of <see cref="MilvaTestInjectAttribute"/>
 /// </summary>
 public MilvaTestInjectAttribute(string url, string httpMethod, UrlTypeEnum obkInlineDataEnum = UrlTypeEnum.InController, object specificObj = null)
 {
     _url               = url;
     _httpMethod        = new HttpMethod(httpMethod);
     _obkInlineDataEnum = obkInlineDataEnum;
     _specificObj       = specificObj;
 }
Beispiel #2
0
 /// <summary>
 /// Constructor of <see cref="MilvaTestInjectAttribute"/>
 /// </summary>
 public MilvaTestInjectAttribute()
 {
     _url               = "";
     _httpMethod        = HttpMethod.Get;
     _obkInlineDataEnum = UrlTypeEnum.InController;
     _specificObj       = null;
 }
 /// <summary>
 /// Constructor of <see cref="MilvaSecurityTestInjectAttribute"/>.
 /// </summary>
 /// <param name="url"></param>
 /// <param name="httpMethod"></param>
 /// <param name="acceptedRoles"></param>
 /// <param name="authorizeTypeEnum"></param>
 /// <param name="obkInlineDataEnum"></param>
 public MilvaSecurityTestInjectAttribute(string url, string httpMethod, string acceptedRoles, AuthorizeTypeEnum authorizeTypeEnum = AuthorizeTypeEnum.Or, UrlTypeEnum obkInlineDataEnum = UrlTypeEnum.InController)
 {
     _url               = url;
     _httpMethod        = new HttpMethod(httpMethod);
     _obkInlineDataEnum = obkInlineDataEnum;
     _authorizeTypeEnum = authorizeTypeEnum;
     _acceptedRoles     = string.IsNullOrWhiteSpace(acceptedRoles) ? new List <string>() : acceptedRoles.Split(',').ToList();
 }
Beispiel #4
0
        public static string GetAdminUrl(this UrlTypeEnum urlType, string prefix, long?id = null)
        {
            string url = $"/admin/{prefix}";

            if (urlType != UrlTypeEnum.List)
            {
                url += $"/{urlType}";
            }

            if (id != null)
            {
                url += $"/{id}";
            }

            return(url);
        }
Beispiel #5
0
        public static string ToProtocolString(this UrlTypeEnum urlType)
        {
            switch (urlType)
            {
            case UrlTypeEnum.Official:
                return("official");

            case UrlTypeEnum.File:
                return("file");

            case UrlTypeEnum.Freenet:
                return("freenet");

            case UrlTypeEnum.Url:
                return("url");

            default:
                throw new ArgumentOutOfRangeException(nameof(urlType));
            }
        }
Beispiel #6
0
        /// <summary>
        /// Called by the framework when the component needs to be rendered as HTML.
        /// </summary>
        /// <param name="model">The model being rendered by the component.</param>
        /// <returns>The component rendered as HTML.</returns>
        public async Task <string> RenderAsync(string model)
        {
            HtmlBuilder hb = new HtmlBuilder();

            UrlTypeEnum type = PropData.GetAdditionalAttributeValue("UrlType", UrlTypeEnum.Remote);

            UrlUI ui = new UrlUI {
                UrlType = type,
                _Local  = model,
                _Remote = model,
            };

            hb.Append($@"
<div id='{ControlId}' class='yt_url t_edit'>");

            YTagBuilder tag = new YTagBuilder("input");

            tag.AddCssClass("t_hidden");
            tag.Attributes["type"] = "hidden";
            FieldSetup(tag, FieldType.Validated);
            tag.MergeAttribute("value", model);
            hb.Append(tag.ToString(YTagRenderMode.StartTag));

            using (Manager.StartNestedComponent(FieldName)) {
                hb.Append($@"
    {await HtmlHelper.ForEditAsync(ui, nameof(ui.UrlType), Validation: false)}
");

                if ((type & UrlTypeEnum.Local) != 0)
                {
                    hb.Append($@"
    <div class='t_local'>
        {await HtmlHelper.ForEditAsync(ui, nameof(ui._Local), Validation: false)}
    </div>");
                }
                if ((type & UrlTypeEnum.Remote) != 0)
                {
                    hb.Append($@"
    <div class='t_remote'>
        {await HtmlHelper.ForEditAsync(ui, nameof(ui._Remote), Validation: false)}
    </div>");
                }
            }

            // link
            tag = new YTagBuilder("a");
            tag.MergeAttribute("href", Utility.UrlEncodePath(model));
            tag.MergeAttribute("target", "_blank");
            tag.MergeAttribute("rel", "nofollow noopener noreferrer");

            tag.InnerHtml = tag.InnerHtml + ImageHTML.BuildKnownIcon("#UrlRemote", sprites: Info.PredefSpriteIcons);
            string link = tag.ToString(YTagRenderMode.Normal);

            UrlEditSetup setup = new UrlEditSetup {
                Type = type,
                Url  = model,
            };

            hb.Append($@"
    <div class='t_link'>
        {link}
    </div>
</div>");

            Manager.ScriptManager.AddLast($"new YetaWF_ComponentsHTML.UrlEditComponent('{ControlId}', {Utility.JsonSerialize(setup)});");

            return(hb.ToString());
        }
 public UrlType()
 {
     this.typeField = UrlTypeEnum.website;
 }