コード例 #1
0
ファイル: Service.asmx.cs プロジェクト: davelondon/dontstayin
		public string ImageUrl(string urlSrc, string urlHref)
		{
			StringBuilder sb = new StringBuilder();

			TagBuilder tImg = new TagBuilder("img", sb);

			urlSrc = urlSrc.Trim();
			if (urlSrc.StartsWith("/"))
				urlSrc = "http://pix.dontstayin.com" + urlSrc;
			else if (!urlSrc.StartsWith("http://") && !urlSrc.StartsWith("https://"))
				urlSrc = "http://" + urlSrc;
			tImg.AddAttribute("src", urlSrc);

			if (urlSrc.Contains(".dontstayin.com/"))
				tImg.AddAttribute("class", "BorderBlack All");

			urlHref = urlHref.Trim();
			if (urlHref.Length > 0)
			{
				tImg.AddAttribute("border", "0");

				TagBuilder tA = new TagBuilder("a", sb);

				if (urlHref.StartsWith("/"))
					urlHref = "http://www.dontstayin.com" + urlHref;
				else if (!urlHref.StartsWith("http://") && !urlHref.StartsWith("https://"))
					urlHref = "http://" + urlHref;

				tA.AddAttribute("href", urlHref);

				if (urlHref.StartsWith("http://www.dontstayin.com/"))
					tA.AddAttribute("target", "_blank");

				tA.RenderStartTag();
				tImg.RenderEmptyTag();
				tA.RenderEndTag();
			}
			else
			{
				tImg.RenderEmptyTag();
			}

			return sb.ToString();
		}
コード例 #2
0
ファイル: Service.asmx.cs プロジェクト: davelondon/dontstayin
		public string LinkProfile(string nickName)
		{
			StringBuilder sb = new StringBuilder();

			int usrK = 0;
			try
			{
				usrK = Bobs.Usr.GetFromNickName(nickName).K;
			}
			catch{}

			if (usrK == 0)
				return "[Error!]";

			TagBuilder t = new TagBuilder("dsi:object", sb);

			t.AddAttribute("type", "usr");
			t.AddAttribute("ref", usrK.ToString());

			t.RenderEmptyTag();

			return sb.ToString();
		}
コード例 #3
0
ファイル: HtmlCleaner.cs プロジェクト: davelondon/dontstayin
		public string UrlReplacementGeneric(Match m, string contents)
		{
			try
			{
				bool hasContents = contents != null && contents.Length > 0;

				if (m.Groups[4].Value.ToLower().EndsWith(".dontstayin.com") || m.Groups[4].Value.ToLower() == "localhost")
				{
					try
					{
						string urlWithoutBookmark = m.Groups[5].Value;
						string anchorBookmark = "";
						if (urlWithoutBookmark.Contains("#"))
						{
							anchorBookmark = urlWithoutBookmark.Substring(urlWithoutBookmark.IndexOf("#") + 1);
							urlWithoutBookmark = urlWithoutBookmark.Substring(0, urlWithoutBookmark.IndexOf("#"));
						}
						UrlInfo url = new UrlInfo(urlWithoutBookmark.ToLower(), null, true, false, false);

						if (url.HasCustomPage ||
							url.HasMusicFilter ||
							url.HasTagFilter ||
							url.HasThemeFilter)
							return getSimpleLink(m, contents);

						if (url.HasArticleObjectFilter ||
							url.HasBrandObjectFilter ||
							url.HasEventObjectFilter ||
							url.HasGroupObjectFilter ||
							url.HasPhotoObjectFilter ||
							url.HasPlaceObjectFilter ||
							url.HasUsrObjectFilter ||
							url.HasVenueObjectFilter)
						{
							//create dsi usr link...
							StringBuilder sb = new StringBuilder();
							TagBuilder t = new TagBuilder(hasContents ? "dsi:link" : "dsi:object", sb);

							if (url.HasEventObjectFilter && url.CurrentApplication == "photos" && url["photo"].IsInt)
							{
								Photo p = new Photo(url["photo"]);
								t.AddAttribute("type", "photo");
								t.AddAttribute("ref", p.K.ToString());
							}
							else
							{
								switch (url.ObjectFilterType)
								{
									case Model.Entities.ObjectType.Article: t.AddAttribute("type", "article"); break;
									case Model.Entities.ObjectType.Brand: t.AddAttribute("type", "brand"); break;
									case Model.Entities.ObjectType.Event: t.AddAttribute("type", "event"); break;
									case Model.Entities.ObjectType.Group: t.AddAttribute("type", "group"); break;
									case Model.Entities.ObjectType.Photo: t.AddAttribute("type", "photo"); break;
									case Model.Entities.ObjectType.Place: t.AddAttribute("type", "place"); break;
									case Model.Entities.ObjectType.Usr: t.AddAttribute("type", "usr"); break;
									case Model.Entities.ObjectType.Venue: t.AddAttribute("type", "venue"); break;
								}
								t.AddAttribute("ref", url.ObjectFilterK.ToString());


								if (url.CurrentApplication != null && url.CurrentApplication.Length > 0 && url.CurrentApplication != "home")
									t.AddAttribute("app", url.CurrentApplication);

								if (url.HasYearFilter && url.ObjectFilterType != Model.Entities.ObjectType.Event && url.ObjectFilterType != Model.Entities.ObjectType.Photo && url.ObjectFilterType != Model.Entities.ObjectType.Article)
								{
									string date = url.DateFilter.ToString("yyyy");
									if (url.HasMonthFilter)
										date += "-" + url.DateFilter.ToString("MMM").ToLower();
									if (url.HasDayFilter)
										date += "-" + url.DateFilter.ToString("dd");

									t.AddAttribute("date", date);
								}

								if (url.Count > 0)
								{
									string parStr = "";
									for (int i = 0; i < url.Count; i++)
									{
										if (url[i].HasKeyValuePair())
											parStr += (parStr.Length == 0 ? "" : "&") + System.Web.HttpUtility.UrlEncode(url[i].Key) + "=" + System.Web.HttpUtility.UrlEncode(url[i].Value);
										else
											parStr += (parStr.Length == 0 ? "" : "&") + System.Web.HttpUtility.UrlEncode(url[i].Key);

									}
									if (parStr.Length > 0)
										t.AddAttribute("par", parStr);
								}
							}

							if (anchorBookmark.Length > 0)
								t.AddAttribute("jump",  urlDecodeEncode(anchorBookmark));

							if (hasContents)
							{
								t.RenderStartTag();
								t.RenderContentAndEndTag(contents);
							}
							else
								t.RenderEmptyTag();

							return addLeadingAndTrailingWhitespace(m, sb.ToString());

						}
						else
							return getSimpleLink(m, contents);
					}
					catch
					{
						return getSimpleLink(m, contents);
					}
				}
				else
				{
					//just create a link
					return getSimpleLink(m, contents);
				}

			}
			catch
			{
				//if (Bobs.Vars.Devenv
				return "Error!";
			}
		}
コード例 #4
0
ファイル: Service.asmx.cs プロジェクト: davelondon/dontstayin
		public string FlashSwfUrl(string urlSwf, string widthStr, string heightStr, string draw)
		{
			StringBuilder sb = new StringBuilder();

			TagBuilder t = new TagBuilder("dsi:flash", sb);

			if (!urlSwf.StartsWith("http://") && !urlSwf.StartsWith("https://"))
				urlSwf = "http://" + urlSwf;

			t.AddAttribute("src", urlSwf);

			int width = 0;
			try
			{
				width = int.Parse(widthStr);
			}
			catch { }
			if (width > 0)
				t.AddAttribute("width", width.ToString());

			int height = 0;
			try
			{
				height = int.Parse(heightStr);
			}
			catch { }
			if (height > 0)
				t.AddAttribute("height", height.ToString());

			if (draw != null && draw == "1")
				t.AddAttribute("draw", "click");
			else if (draw != null && draw == "2")
				t.AddAttribute("draw", "load");
			//else if (draw != null && draw == "3")
			//	t.AddAttribute("draw", "raw");
			
			t.RenderEmptyTag();

			return sb.ToString();
		}
コード例 #5
0
ファイル: Service.asmx.cs プロジェクト: davelondon/dontstayin
		public string VideoFlv(string urlFlv, string widthStr, string heightStr)
		{
			StringBuilder sb = new StringBuilder();

			TagBuilder t = new TagBuilder("dsi:video", sb);

			if (!urlFlv.StartsWith("http://") && !urlFlv.StartsWith("https://"))
				urlFlv = "http://" + urlFlv;

			t.AddAttribute("type", "flv");
			t.AddAttribute("src", urlFlv);

			int width = 0;
			try
			{
				width = int.Parse(widthStr);
			}
			catch { }
			if (width > 0)
				t.AddAttribute("width", width.ToString());

			int height = 0;
			try
			{
				height = int.Parse(heightStr);
			}
			catch { }
			if (height > 0)
				t.AddAttribute("height", height.ToString());

			t.RenderEmptyTag();
			
			return sb.ToString();
		}