Esempio n. 1
0
        private string EncodeTransferData(HyperlinkData data)
        {
            if (data == null)
            {
                return(null);
            }

            data.Href   = ReplaceSpecChar(data.Href);
            data.Title  = ReplaceSpecChar(data.Title);
            data.Target = ReplaceSpecChar(data.Target);
            data.Text   = ReplaceSpecChar(data.Text);

            var sb = new StringBuilder();

            sb.Append("<a");
            if (data.Href != null)
            {
                sb.Append(" href=\"").Append(data.Href).Append("\"");
            }
            if (data.Target != null)
            {
                sb.Append(" target=\"").Append(data.Target).Append("\"");
            }
            if (data.Title != null)
            {
                sb.Append(" title=\"").Append(data.Title).Append("\"");
            }
            sb.Append(">");
            sb.Append(data.Text ?? "");
            sb.Append("</a>");
            return(sb.ToString());
        }
Esempio n. 2
0
        public void addHyperLinkData(HLink hlink)
        {
            HyperlinkData hld = new HyperlinkData();

            hld.colFirst = hlink.colFirst;
            hld.colLast  = hlink.colLast;
            hld.rwFirst  = hlink.rwFirst;
            hld.rwLast   = hlink.rwLast;
            hld.absolute = hlink.hlstmfIsAbsolute;
            hld.url      = hlink.monikerString;
            hld.location = hlink.location;
            hld.display  = hlink.displayName;

            this.HyperLinkList.Add(hld);
        }
Esempio n. 3
0
        protected override object ConvertTo(object[] handlerValues)
        {
            var data = new HyperlinkData();
            var src  = (string)handlerValues[0];

            if (!String.IsNullOrEmpty(src))
            {
                try
                {
                    var          escapeError = false;
                    XmlAttribute attr;
                    var          xd = new XmlDocument();

                    try
                    {
                        xd.LoadXml(src);
                    }
                    catch (Exception e) // logged
                    {
                        SnLog.WriteException(e);

                        escapeError = true;
                    }

                    if (escapeError)
                    {
                        try
                        {
                            // robustness: load old not-replace-data
                            var escaped = src.Replace("&amp;", "&").Replace("&", "&amp;");

                            // this will throw an exception if something is still wrong...
                            xd.LoadXml(escaped);
                        }
                        catch (Exception)
                        {
                            // something is seriously wrong with the hyperlink data
                            return(data);
                        }
                    }

                    if (xd.DocumentElement == null)
                    {
                        return(data);
                    }

                    data.Text = xd.DocumentElement.InnerXml;
                    data.Text = data.Text.Length == 0 ? null : ReplaceSpecCharBack(data.Text);

                    attr        = xd.DocumentElement.Attributes["href"];
                    data.Href   = attr == null ? null : attr.Value;
                    attr        = xd.DocumentElement.Attributes["title"];
                    data.Title  = attr == null ? null : ReplaceSpecCharBack(attr.Value);
                    attr        = xd.DocumentElement.Attributes["target"];
                    data.Target = attr == null ? null : attr.Value;
                }
                catch (Exception e)                // rethrow
                {
                    throw new ApplicationException(String.Concat("Invalid hyperlink data: ", src, ". Content: ", this.Content.Path, ", Field: ", this.Name), e);
                }
            }
            return(data);
        }
Esempio n. 4
0
		protected override object ConvertTo(object[] handlerValues)
		{
			var data = new HyperlinkData();
			var src = (string)handlerValues[0];

			if (!String.IsNullOrEmpty(src))
			{
				try
				{
				    var escapeError = false;
					XmlAttribute attr;
					var xd = new XmlDocument();

                    try
                    {
                        xd.LoadXml(src);
                    }
                    catch(Exception e) //logged
                    {
                        Logger.WriteException(e);

                        escapeError = true;
                    }

                    if (escapeError)
                    {
                        try
                        {
                            //-- robustness: load old not-replace-data
                            var escaped = src.Replace("&amp;", "&").Replace("&", "&amp;");

                            //this will throw an exception if something is still wrong...
                            xd.LoadXml(escaped);
                        }
                        catch (Exception)
                        {
                            //something is seriously wrong with the hyperlink data
                            return data;
                        }
                    }

                    if (xd.DocumentElement == null)
                        return data;

					data.Text = xd.DocumentElement.InnerXml;
					data.Text = data.Text.Length == 0 ? null : ReplaceSpecCharBack(data.Text);

					attr = xd.DocumentElement.Attributes["href"];
					data.Href = attr == null ? null : attr.Value;
					attr = xd.DocumentElement.Attributes["title"];
                    data.Title = attr == null ? null : ReplaceSpecCharBack(attr.Value);
					attr = xd.DocumentElement.Attributes["target"];
					data.Target = attr == null ? null : attr.Value;
				}
				catch(Exception e) //rethrow
				{
					throw new ApplicationException(String.Concat("Invalid hyperlink data: ", src, ". Content: ", this.Content.Path, ", Field: ", this.Name), e);
				}
			}
			return data;
		}
Esempio n. 5
0
		private string EncodeTransferData(HyperlinkData data)
		{
			if (data == null)
				return null;

			data.Href = ReplaceSpecChar(data.Href);
			data.Title = ReplaceSpecChar(data.Title);
			data.Target = ReplaceSpecChar(data.Target);
			data.Text = ReplaceSpecChar(data.Text);

			var sb = new StringBuilder();
			sb.Append("<a");
			if (data.Href != null)
				sb.Append(" href=\"").Append(data.Href).Append("\"");
			if (data.Target != null)
				sb.Append(" target=\"").Append(data.Target).Append("\"");
			if (data.Title != null)
				sb.Append(" title=\"").Append(data.Title).Append("\"");
			sb.Append(">");
			sb.Append(data.Text ?? "");
			sb.Append("</a>");
			return sb.ToString();
		}