Initial import
This commit is contained in:
parent
0c865416ca
commit
04804b89a9
279 changed files with 12945 additions and 0 deletions
22
web/Thanks/ThanksConfigurationCollection.cs
Normal file
22
web/Thanks/ThanksConfigurationCollection.cs
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
using System;
|
||||
using System.Configuration;
|
||||
|
||||
namespace Yavsc
|
||||
{
|
||||
public class ThanksConfigurationCollection : ConfigurationElementCollection
|
||||
{
|
||||
protected override object GetElementKey (ConfigurationElement element)
|
||||
{
|
||||
return ((ThanksConfigurationElement) element).Name;
|
||||
}
|
||||
protected override ConfigurationElement CreateNewElement ()
|
||||
{
|
||||
return new ThanksConfigurationElement();
|
||||
}
|
||||
public ThanksConfigurationElement GetElement (string name)
|
||||
{
|
||||
return this.BaseGet(name) as ThanksConfigurationElement;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
48
web/Thanks/ThanksConfigurationElement.cs
Normal file
48
web/Thanks/ThanksConfigurationElement.cs
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
using System;
|
||||
using System.Configuration;
|
||||
|
||||
namespace Yavsc
|
||||
{
|
||||
public class ThanksConfigurationElement : ConfigurationElement
|
||||
{
|
||||
[ConfigurationProperty("name", IsKey=true, IsRequired=true)]
|
||||
public string Name {
|
||||
get {
|
||||
return (string) base ["name"];
|
||||
}
|
||||
set { base ["name"] = value; }
|
||||
}
|
||||
|
||||
[ConfigurationProperty("url")]
|
||||
public string Url {
|
||||
get {
|
||||
return (string) base ["url"];
|
||||
}
|
||||
set { base ["url"] = value; }
|
||||
}
|
||||
|
||||
[ConfigurationProperty("image")]
|
||||
public string Image {
|
||||
get {
|
||||
return (string) base ["image"];
|
||||
}
|
||||
set { base ["image"] = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the display.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The displaied text when no image is provided and we
|
||||
/// don't want use the name attribute.
|
||||
/// </value>
|
||||
[ConfigurationProperty("display")]
|
||||
public string Display {
|
||||
get {
|
||||
return (string) base ["display"];
|
||||
}
|
||||
set { base ["display"] = value; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
39
web/Thanks/ThanksConfigurationSection.cs
Normal file
39
web/Thanks/ThanksConfigurationSection.cs
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
using System;
|
||||
using System.Configuration;
|
||||
|
||||
namespace Yavsc
|
||||
{
|
||||
public class ThanksConfigurationSection : ConfigurationSection
|
||||
{
|
||||
[ConfigurationProperty("to")]
|
||||
public ThanksConfigurationCollection To {
|
||||
get {
|
||||
return (ThanksConfigurationCollection) this["to"];
|
||||
}
|
||||
set {
|
||||
this ["to"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
[ConfigurationProperty("html_class")]
|
||||
public string HtmlClass {
|
||||
get {
|
||||
return (string)this ["html_class"];
|
||||
}
|
||||
set {
|
||||
this ["html_class"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
[ConfigurationProperty("title_format")]
|
||||
public string TitleFormat {
|
||||
get {
|
||||
return (string)this ["title_format"];
|
||||
}
|
||||
set {
|
||||
this ["title_format"] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
38
web/Thanks/ThanksHelper.cs
Normal file
38
web/Thanks/ThanksHelper.cs
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
using System;
|
||||
using System.Configuration;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Yavsc
|
||||
{
|
||||
public static class ThanksHelper {
|
||||
|
||||
public static string[] Links ()
|
||||
{
|
||||
List<string> result = new List<string>() ;
|
||||
ThanksConfigurationSection s = (ThanksConfigurationSection) ConfigurationManager.GetSection ("system.web/thanks");
|
||||
if (s == null) return result.ToArray();
|
||||
if (s.To == null) return result.ToArray();
|
||||
foreach (ThanksConfigurationElement e in s.To) {
|
||||
string link = "";
|
||||
if (!string.IsNullOrEmpty(e.Url))
|
||||
link = string.Format("<a class=\"athanks\" href=\"{0}\">",e.Url);
|
||||
link += "<div class=\"thanks\">";
|
||||
string dsp = (string.IsNullOrEmpty(e.Display))?e.Name:e.Display;
|
||||
if (!string.IsNullOrEmpty(e.Image)) {
|
||||
string ttl = (string.IsNullOrEmpty(s.TitleFormat))?"Go and see the website ({0})":s.TitleFormat;
|
||||
ttl = string.Format(ttl,dsp);
|
||||
link += string.Format(
|
||||
"<img src=\"{1}\" alt=\"{0}\" title=\"{2}\"/>",
|
||||
dsp,e.Image,ttl);
|
||||
}
|
||||
else link += dsp;
|
||||
link += "</div>";
|
||||
if (e.Url!=null)
|
||||
link += "</a> ";
|
||||
result.Add (link);
|
||||
}
|
||||
return result.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue