Skip to content

Commit

Permalink
WIP Add control for None and URL GH-117
Browse files Browse the repository at this point in the history
  • Loading branch information
roman-yagodin committed Feb 19, 2021
1 parent 4530f58 commit e8a9b82
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 5 deletions.
17 changes: 12 additions & 5 deletions R7.Documents.Dnn/Controls/UrlControlWrapper.ascx
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
<%@ Control Language="C#" CodeBehind="UrlControlWrapper.ascx.cs" Inherits="R7.Documents.Controls.UrlControlWrapper" %>
<%@ Register TagPrefix="dnn" TagName="Url" Src="~/controls/DnnUrlControl.ascx" %>
<dnn:Url id="ctlUrl" runat="server"
UrlType="F"
ShowTabs="true" IncludeActiveTab="true"
ShowNone="True" ShowNewWindow="True"
ShowSecure="True" ShowDatabase="True" />

<div style="float:left">
<div>None? <asp:CheckBox id="chkNone" runat="server" /></div>
<div>URL: <asp:TextBox id="txtUrl" runat="server" /></div>

<dnn:Url id="ctlUrl" runat="server"
UrlType="F"
ShowUrls="false"
ShowTabs="true" IncludeActiveTab="true"
ShowNone="false" ShowNewWindow="True"
ShowSecure="True" ShowDatabase="True" />
</div>
76 changes: 76 additions & 0 deletions R7.Documents.Dnn/Controls/UrlControlWrapper.ascx.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
using System.Web.UI;
using System.Web.UI.WebControls;
using DotNetNuke.Common;
using DotNetNuke.Entities.Tabs;
using DotNetNuke.Web.UI.WebControls;

namespace R7.Documents.Controls
{
public class UrlControlWrapper : UserControl
{
#region Controls

protected DnnUrlControl ctlUrl;
protected CheckBox chkNone;
protected TextBox txtUrl;

#endregion

public string Url
{
get => GetUrl ();
set => SetUrl (value);
}

string GetUrl ()
{
if (chkNone.Checked) {
return string.Empty;
}

if (!string.IsNullOrEmpty (txtUrl.Text)) {
return txtUrl.Text;
}

return ctlUrl.Url;
}

void SetUrl(string url)
{
if (string.IsNullOrEmpty (url)) {
chkNone.Checked = true;
ctlUrl.Url = string.Empty;
ctlUrl.UrlType = "N";
txtUrl.Text = string.Empty;
return;
}

var urlType = Globals.GetURLType (url);
if (urlType == TabType.File || urlType == TabType.Tab) {
ctlUrl.Url = url;
txtUrl.Text = string.Empty;
chkNone.Checked = false;
return;
}

ctlUrl.Url = string.Empty;
ctlUrl.UrlType = "N";
txtUrl.Text = url;
chkNone.Checked = false;
}

public bool NewWindow {
get => ctlUrl.NewWindow;
set => ctlUrl.NewWindow = value;
}

public bool Log => ctlUrl.Log;

public bool Track => ctlUrl.Track;

public string UrlType => ctlUrl.UrlType;

public DnnUrlControl BaseUrlControl => ctlUrl;
}
}

0 comments on commit e8a9b82

Please sign in to comment.