File: PermaLink.cs

package info (click to toggle)
mono 6.8.0.105%2Bdfsg-3.3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,284,512 kB
  • sloc: cs: 11,172,132; xml: 2,850,069; ansic: 671,653; cpp: 122,091; perl: 59,366; javascript: 30,841; asm: 22,168; makefile: 20,093; sh: 15,020; python: 4,827; pascal: 925; sql: 859; sed: 16; php: 1
file content (272 lines) | stat: -rw-r--r-- 11,065 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
//------------------------------------------------------------------------------
// <copyright file="PermaLink.cs" company="Microsoft">
//     Copyright (c) Microsoft Corporation.  All rights reserved.
// </copyright>
//------------------------------------------------------------------------------

// Permalink temporarily removed

//namespace System.Web.UI {

//    using System;
//    using System.Collections.Generic;
//    using System.ComponentModel;
//    using System.Diagnostics.CodeAnalysis;
//    using System.Drawing.Design;
//    using System.Security.Permissions;
//    using System.Web;
//    using System.Web.UI.WebControls;

//    /// <devdoc>
//    ///    <para>Creates a link to the current page that automatically updates its url as history state changes.</para>
//    /// </devdoc>
//    [
//    ControlBuilderAttribute(typeof(HyperLinkControlBuilder)),
//    DefaultProperty("Text"),
//    ToolboxData("<{0}:PermaLink runat=\"server\">PermaLink</{0}:PermaLink>"),
//    ParseChildren(false),
//    AspNetHostingPermission(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal),
//    AspNetHostingPermission(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)
//    ]
//    public class PermaLink : ScriptControl {

//        private string _url;

//        /// <devdoc>
//        ///    <para>Gets or sets the URL reference to an image to display as an alternative to plain text for the
//        ///       Permalink.</para>
//        /// </devdoc>
//        [
//        Bindable(true),
//        Category("Appearance"),
//        DefaultValue(""),
//        Editor("System.Web.UI.Design.ImageUrlEditor, " + AssemblyRef.SystemDesign, typeof(UITypeEditor)),
//        UrlProperty(),
//        ResourceDescription("PermaLink_ImageUrl"),
//        SuppressMessage("Microsoft.Design", "CA1056:UriPropertiesShouldNotBeStrings", Justification = "Consistent with other asp.net url properties.")
//        ]
//        public virtual string ImageUrl {
//            get {
//                return ((string)ViewState["ImageUrl"]) ?? String.Empty;
//            }
//            set {
//                ViewState["ImageUrl"] = value;
//            }
//        }

//        /// <devdoc>
//        ///    <para>Gets the URL to navigate to when the Permalink is clicked.</para>
//        /// </devdoc>
//        [
//        UrlProperty(),
//        ResourceDescription("PermaLink_NavigateUrl"),
//        SuppressMessage("Microsoft.Design", "CA1056:UriPropertiesShouldNotBeStrings", Justification = "Consistent with other asp.net url properties.")
//        ]
//        public string NavigateUrl {
//            get {
//                if ((Context == null) || (Context.Request == null)) {
//                    return String.Empty;
//                }

//                if (String.IsNullOrEmpty(_url)) {
//                    // Logic to figure out a reliable path to the current page as copied from HtmlForm.
//                    VirtualPath clientFilePath = Context.Request.ClientFilePath;

//                    // ASURT 15075/11054/59970: always set the action to the current page.
//                    VirtualPath currentFilePath = Context.Request.CurrentExecutionFilePathObject;
//                    if (Object.ReferenceEquals(currentFilePath, clientFilePath)) {
//                        // There hasn't been any Server.Transfer or RewritePath.
//                        // ASURT 15979: need to use a relative path, not absolute
//                        _url = currentFilePath.VirtualPathString;
//                        int iPos = _url.LastIndexOf('/');
//                        if (iPos >= 0) {
//                            _url = _url.Substring(iPos + 1);
//                        }
//                    }
//                    else {
//                        // Server.Transfer or RewritePath case.  We need to make the form action relative
//                        // to the original ClientFilePath (since that's where the browser thinks we are).
//                        currentFilePath = clientFilePath.MakeRelative(currentFilePath);
//                        _url = currentFilePath.VirtualPathString;
//                    }

//                    // Note: PermaLink url does not contain cookieless session information.

//                    string queryString = Page.ClientQueryString;
//                    // ASURT 15355: Don't lose the query string if there is one.
//                    // In scriptless mobile HTML, we prepend __EVENTTARGET, et. al. to the query string.  These have to be
//                    // removed from the form action.  Use new HttpValueCollection to leverage ToString(bool encoded).
//                    if (!String.IsNullOrEmpty(queryString)) {
//                        _url += "?" + queryString;
//                    }
//                }

//                return _url;
//            }
//        }

//        protected override HtmlTextWriterTag TagKey {
//            get {
//                return HtmlTextWriterTag.A;
//            }
//        }

//        /// <devdoc>
//        ///    <para>Gets or sets the target window or frame the contents of
//        ///       the <see cref='System.Web.UI.WebControls.PermaLink'/> will be displayed into when clicked.</para>
//        /// </devdoc>
//        [
//        Category("Navigation"),
//        DefaultValue(""),
//        ResourceDescription("PermaLink_Target"),
//        TypeConverter(typeof(TargetConverter))
//        ]
//        public string Target {
//            get {
//                return ((string)ViewState["Target"]) ?? String.Empty;
//            }
//            set {
//                ViewState["Target"] = value;
//            }
//        }


//        /// <devdoc>
//        ///    <para>
//        ///       Gets or sets the text displayed for the <see cref='System.Web.UI.WebControls.PermaLink'/>.</para>
//        /// </devdoc>
//        [
//        Localizable(true),
//        Bindable(true),
//        Category("Appearance"),
//        DefaultValue(""),
//        ResourceDescription("PermaLink_Text"),
//        PersistenceMode(PersistenceMode.InnerDefaultProperty)
//        ]
//        public virtual string Text {
//            get {
//                return ((string)ViewState["Text"]) ?? String.Empty;
//            }
//            set {
//                if (HasControls()) {
//                    Controls.Clear();
//                }
//                ViewState["Text"] = value;
//            }
//        }

//        /// <internalonly/>
//        /// <devdoc>
//        /// <para>Adds the attribututes of the a <see cref='System.Web.UI.WebControls.PermaLink'/> to the output
//        ///    stream for rendering.</para>
//        /// </devdoc>
//        protected override void AddAttributesToRender(HtmlTextWriter writer) {
//            if (Enabled && !IsEnabled) {
//                // We need to do the cascade effect on the server, because the browser
//                // only renders as disabled, but doesn't disable the functionality.
//                writer.AddAttribute(HtmlTextWriterAttribute.Disabled, "disabled");
//            }

//            base.AddAttributesToRender(writer);

//            string s = NavigateUrl;
//            if (!String.IsNullOrEmpty(s) && IsEnabled) {
//                string resolvedUrl = ResolveClientUrl(s);
//                writer.AddAttribute(HtmlTextWriterAttribute.Href, resolvedUrl);
//            }
//            s = Target;
//            if (!String.IsNullOrEmpty(s)) {
//                writer.AddAttribute(HtmlTextWriterAttribute.Target, s);
//            }
//        }

//        protected override void AddParsedSubObject(object obj) {
//            if (HasControls()) {
//                base.AddParsedSubObject(obj);
//            }
//            else {
//                if (obj is LiteralControl) {
//                    Text = ((LiteralControl)obj).Text;
//                }
//                else {
//                    string currentText = Text;
//                    if (!String.IsNullOrEmpty(currentText)) {
//                        Text = String.Empty;
//                        base.AddParsedSubObject(new LiteralControl(currentText));
//                    }
//                    base.AddParsedSubObject(obj);
//                }
//            }
//        }

//        [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate",
//            Justification = "Matches IScriptControl interface.")]
//        protected override IEnumerable<ScriptDescriptor> GetScriptDescriptors() {
//            // Don't render any scripts when history is not enabled
//            if (Page != null) {
//                ScriptManager sm = ScriptManager.GetCurrent(Page);
//                if (sm.EnableHistory && Visible) {
//                    ScriptControlDescriptor desc = new ScriptControlDescriptor("Sys.UI.PermaLink", ClientID);
//                    yield return desc;
//                }
//            }

//            yield break;
//        }

//        [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate",
//            Justification = "Matches IScriptControl interface.")]
//        protected override IEnumerable<ScriptReference> GetScriptReferences() {
//            yield break;
//        }

//        /// <internalonly/>
//        /// <devdoc>
//        ///    Load previously saved state.
//        ///    Overridden to synchronize Text property with LiteralContent.
//        /// </devdoc>
//        protected override void LoadViewState(object savedState) {
//            if (savedState != null) {
//                base.LoadViewState(savedState);
//                string s = (string)ViewState["Text"];
//                if (s != null)
//                    Text = s;
//            }
//        }

//        /// <internalonly/>
//        /// <devdoc>
//        /// <para>Displays the <see cref='System.Web.UI.WebControls.PermaLink'/> on a page.</para>
//        /// </devdoc>
//        protected internal override void RenderContents(HtmlTextWriter writer) {
//            string s = ImageUrl;
//            if (!String.IsNullOrEmpty(s)) {
//                Image img = new Image();

//                // NOTE: The Url resolution happens right here, because the image is not parented
//                //       and will not be able to resolve when it tries to do so.
//                img.ImageUrl = ResolveClientUrl(s);

//                s = ToolTip;
//                if (!String.IsNullOrEmpty(s)) {
//                    img.ToolTip = s;
//                }

//                s = Text;
//                if (!String.IsNullOrEmpty(s)) {
//                    img.AlternateText = s;
//                }
//                img.RenderControl(writer);
//            }
//            else {
//                if (HasRenderingData()) {
//                    base.RenderContents(writer);
//                }
//                else {
//                    writer.Write(Text);
//                }
//            }
//        }
//    }
//}