Adding support for Public Properties on Dashboard controls (simply add values as attributes on the <control/> element [case-sensitive!])

This commit is contained in:
hartvig
2010-12-16 23:39:31 -01:00
parent ddbbf5e799
commit 94722e82dd
6 changed files with 62 additions and 5 deletions

View File

@@ -229,7 +229,6 @@ Global
{6AE67079-2C00-476C-81DE-2800D1AC14BC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6AE67079-2C00-476C-81DE-2800D1AC14BC}.Release|Any CPU.Build.0 = Release|Any CPU
{89C09045-1064-466B-B94A-DB3AFE2A5853}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{89C09045-1064-466B-B94A-DB3AFE2A5853}.Debug|Any CPU.Build.0 = Debug|Any CPU
{89C09045-1064-466B-B94A-DB3AFE2A5853}.Release|Any CPU.ActiveCfg = Release|Any CPU
{89C09045-1064-466B-B94A-DB3AFE2A5853}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection

Binary file not shown.

View File

@@ -49,7 +49,12 @@
<areas>
<area>content</area>
</areas>
<tab caption="Get Started">
<tab caption="Property Test">
<control addPanel="true" panelCaption="PropertyTest" First="Hello World" Second="Even more" Third="[#userContentStartNode]" Fourth="yaddi">
/usercontrols/propertyTest.ascx
</control>
</tab>
<tab caption="Get Started">
<control showOnce="true" addPanel="true" panelCaption="">
/umbraco/dashboard/startupdashboardintro.ascx
</control>

View File

@@ -3,6 +3,7 @@ using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Reflection;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
@@ -88,6 +89,27 @@ namespace umbraco.cms.presentation
{
Control c = LoadControl(path);
// set properties
Type type = c.GetType();
if (type != null)
{
foreach (XmlAttribute att in uc.Attributes)
{
string attributeName = att.Name;
string attributeValue = parseControlValues(att.Value).ToString(); // parse special type of values
PropertyInfo prop = type.GetProperty(attributeName);
if (prop == null)
{
continue;
}
prop.SetValue(c, Convert.ChangeType(attributeValue, prop.PropertyType), null);
}
}
//resolving files from dashboard config which probably does not map to a virtual fi
tab.Controls.Add(AddPanel(uc, c));
}
@@ -135,6 +157,37 @@ namespace umbraco.cms.presentation
}
}
private object parseControlValues(string value)
{
if (!String.IsNullOrEmpty(value))
{
if (value.StartsWith("[#"))
{
value = value.Substring(2, value.Length - 3).ToLower();
switch (value)
{
case "usertype":
return BusinessLogic.User.GetCurrent().UserType.Alias;
case "username":
return BusinessLogic.User.GetCurrent().Name;
case "userlogin":
return BusinessLogic.User.GetCurrent().LoginName;
case "usercontentstartnode":
return BusinessLogic.User.GetCurrent().StartNodeId;
break;
case "usermediastartnode":
return BusinessLogic.User.GetCurrent().StartMediaId;
break;
default:
return value;
break;
}
}
}
return value;
}
private Control AddPanel(XmlNode node, Control c)
{
LiteralControl hide = AddShowOnceLink(node);

View File

@@ -33,8 +33,8 @@
<Examine configSource="config\ExamineSettings.config" />
<ExamineLuceneIndexSets configSource="config\ExamineIndex.config" />
<appSettings>
<add key="umbracoDbDSN" value="server=.\sqlexpress;database=umbraco-nightly;integrated security=true;" />
<add key="umbracoConfigurationStatus" value="4.6.0.Alpha" />
<add key="umbracoDbDSN" value="server=.\sqlexpress;database=CNUG;user id=DBUSER;password=DBPASSWORD" />
<add key="umbracoConfigurationStatus" value="4.1.0.RC" />
<add key="umbracoReservedUrls" value="~/config/splashes/booting.aspx,~/install/default.aspx,~/config/splashes/noNodes.aspx,~/VSEnterpriseHelper.axd" />
<add key="umbracoReservedPaths" value="~/umbraco,~/install/" />
<add key="umbracoContentXML" value="~/App_Data/umbraco.config" />

View File

@@ -4,7 +4,7 @@
<!-- Set up a local connection string -->
<xsl:template match="/configuration/appSettings/add[@key='umbracoDbDSN']/@value">
<xsl:attribute name="value">server=.\sqlexpress;database=41RC;user id=DBUSER;password=DBPASSWORD</xsl:attribute>
<xsl:attribute name="value">server=.\sqlexpress;database=CNUG;user id=DBUSER;password=DBPASSWORD</xsl:attribute>
</xsl:template>
<xsl:template match="/configuration/appSettings/add[@key='umbracoConfigurationStatus']/@value">