Fixes issues with safeAlias and imported packages

[TFS Changeset #70920]
This commit is contained in:
hartvig
2010-06-23 11:34:28 +00:00
parent 730a905d96
commit 011b71652d
12 changed files with 170 additions and 97 deletions

View File

@@ -260,7 +260,7 @@ namespace umbraco.Linq.Core.Node
foreach (var ancestor in elements)
{
var alias = Casing.SafeAlias(ancestor.Name.LocalName);
var alias = Casing.SafeAliasWithForcingCheck(ancestor.Name.LocalName);
var t = KnownTypes[alias];
var instaceOfT = (DocTypeBase)Activator.CreateInstance(t); //create an instance of the type and down-cast so we can use it
this.LoadFromXml(ancestor, instaceOfT);
@@ -286,7 +286,7 @@ namespace umbraco.Linq.Core.Node
});
foreach (var type in types)
this._knownTypes.Add(Casing.SafeAlias(type.Key), type.Value);
this._knownTypes.Add(Casing.SafeAliasWithForcingCheck(type.Key), type.Value);
}
@@ -337,7 +337,7 @@ namespace umbraco.Linq.Core.Node
{
var attr = ReflectionAssistance.GetUmbracoInfoAttribute(p);
var data = xml.Element(Casing.SafeAlias(attr.Alias)).Value;
var data = xml.Element(Casing.SafeAliasWithForcingCheck(attr.Alias)).Value;
if (p.PropertyType == typeof(int) && string.IsNullOrEmpty(data))
data = "-1";

View File

@@ -19,6 +19,7 @@ namespace umbraco.editorControls.macrocontainer
{
[ClientDependency(ClientDependencyType.Javascript, "ui/jqueryui.js", "UmbracoClient")]
[ClientDependency(ClientDependencyType.Css, "/macroContainer/macroContainer.css", "UmbracoClient")]
public class Editor : UpdatePanel, IDataEditor
{
private IData _data;
@@ -65,7 +66,8 @@ namespace umbraco.editorControls.macrocontainer
_addMacro.Click += new EventHandler(_addMacro_Click);
_addMacro.Text = "Add";
_addMacro.Text = ui.Text("insertMacro");
_addMacro.CssClass = "macroContainerAdd";
this.ContentTemplateContainer.Controls.Add(_addMacro);
@@ -77,7 +79,13 @@ namespace umbraco.editorControls.macrocontainer
this.ContentTemplateContainer.Controls.Add(_limit);
this.ContentTemplateContainer.Controls.Add(new LiteralControl("<div id=\"" + ID + "container\" class=\"macrocontainer\">"));
string widthHeight = "";
if (_preferedHeight > 0 && _preferedWidth > 0)
{
widthHeight = String.Format(" style=\"min-width: {0}px; min-height: {1}px;\"", _preferedWidth, _preferedHeight);
}
this.ContentTemplateContainer.Controls.Add(new LiteralControl(String.Format("<div id=\"" + ID + "container\" class=\"macrocontainer\"{0}>", widthHeight)));
Regex tagregex = new Regex("<[^>]*(>|$)", RegexOptions.Singleline | RegexOptions.ExplicitCapture | RegexOptions.Compiled);
MatchCollection tags = tagregex.Matches(_data.Value.ToString());

View File

@@ -11,7 +11,7 @@ using System.Web;
namespace umbraco.editorControls.macrocontainer
{
public class MacroEditor: System.Web.UI.Control
public class MacroEditor : System.Web.UI.Control
{
private List<string> _allowedMacros;
private DropDownList _macroSelectDropdown;
@@ -19,6 +19,7 @@ namespace umbraco.editorControls.macrocontainer
private Table _formTable;
private Hashtable _dataValues;
private string _data;
private LiteralControl propertiesHeader = new LiteralControl("<h4>" + ui.Text("macroContainerSettings") + " <span class=\"settingsToggle\"><a href=\"#\" onClick=\"jQuery(this).closest('.macroeditor').find('.macroSettings').toggle()\">Show/Hide</a></span> </h4> ");
public MacroEditor(string Data, List<string> allowedMacros)
{
@@ -28,29 +29,33 @@ namespace umbraco.editorControls.macrocontainer
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
base.OnInit(e);
_macroSelectDropdown = new DropDownList();
_macroSelectDropdown.ID = ID + "_ddselectmacro";
_macroSelectDropdown.SelectedIndexChanged += new EventHandler(_macroSelectDropdown_SelectedIndexChanged);
_macroSelectDropdown.Items.Add(new ListItem(umbraco.ui.Text("choose"), ""));
foreach (string item in _allowedMacros)
{
_macroSelectDropdown.Items.Add(new ListItem(Macro.GetByAlias(item).Name, item));
}
_macroSelectDropdown.AutoPostBack = true;
_macroSelectDropdown = new DropDownList();
_macroSelectDropdown.ID = ID + "_ddselectmacro";
_macroSelectDropdown.SelectedIndexChanged += new EventHandler(_macroSelectDropdown_SelectedIndexChanged);
_macroSelectDropdown.Items.Add(new ListItem(umbraco.ui.Text("choose"), ""));
foreach (string item in _allowedMacros)
{
_macroSelectDropdown.Items.Add(new ListItem(Macro.GetByAlias(item).Name, item));
}
_macroSelectDropdown.AutoPostBack = true;
_delete = new LinkButton();
_delete.ID = ID + "_btndelete";
_delete.Text = "Delete";
_delete.Attributes.Add("style", "color:red;");
_delete.Click += new EventHandler(_delete_Click);
_formTable = new Table();
_formTable.ID = ID + "_tblform";
_delete = new LinkButton();
_delete.CssClass = "macroDelete";
_delete.ID = ID + "_btndelete";
_delete.Text = ui.Text("removeMacro");
_delete.Attributes.Add("style", "color:red;");
_delete.Click += new EventHandler(_delete_Click);
_formTable = new Table();
_formTable.ID = ID + "_tblform";
_formTable.CssClass = "macroSettings";
this.Controls.Add(_macroSelectDropdown);
this.Controls.Add(_delete);
this.Controls.Add(_formTable);
propertiesHeader.Visible = false;
this.Controls.Add(_delete);
this.Controls.Add(_macroSelectDropdown);
this.Controls.Add(propertiesHeader);
this.Controls.Add(_formTable);
}
void _delete_Click(object sender, EventArgs e)
@@ -61,89 +66,90 @@ namespace umbraco.editorControls.macrocontainer
MacroContainerEvent.Delete();
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
base.OnLoad(e);
if (!GlobalSettings.RequestIsInUmbracoApplication(HttpContext.Current) && umbraco.presentation.UmbracoContext.Current.LiveEditingContext.Enabled)
{
if (ViewState[ID + "init"] == null)
{
if (DataValues["macroalias"] != null)
{
//Data is available from the database, initialize the form with the data
string alias = DataValues["macroalias"].ToString();
if (!GlobalSettings.RequestIsInUmbracoApplication(HttpContext.Current) && umbraco.presentation.UmbracoContext.Current.LiveEditingContext.Enabled)
{
if (ViewState[ID + "init"] == null)
{
if (DataValues["macroalias"] != null)
{
//Data is available from the database, initialize the form with the data
string alias = DataValues["macroalias"].ToString();
//Set Pulldown selected value based on the macro alias
_macroSelectDropdown.SelectedValue = alias;
//Set Pulldown selected value based on the macro alias
_macroSelectDropdown.SelectedValue = alias;
//Create from with values based on the alias
InitializeForm(alias);
}
else
{
this.Visible = false;
}
//Create from with values based on the alias
InitializeForm(alias);
}
else
{
this.Visible = false;
}
ViewState[ID + "init"] = "ok";
}
else
{
//Render form if properties are in the viewstate
if (SelectedProperties.Count > 0)
{
RendeFormControls();
}
}
}
else
{
ViewState[ID + "init"] = "ok";
}
else
{
//Render form if properties are in the viewstate
if (SelectedProperties.Count > 0)
{
RendeFormControls();
}
}
}
else
{
if (!Page.IsPostBack)
{
if (!Page.IsPostBack)
{
//Handle Initial Request
if (DataValues["macroalias"] != null)
{
//Data is available from the database, initialize the form with the data
string alias = DataValues["macroalias"].ToString();
//Handle Initial Request
if (DataValues["macroalias"] != null)
{
//Data is available from the database, initialize the form with the data
string alias = DataValues["macroalias"].ToString();
//Set Pulldown selected value based on the macro alias
_macroSelectDropdown.SelectedValue = alias;
//Set Pulldown selected value based on the macro alias
_macroSelectDropdown.SelectedValue = alias;
//Create from with values based on the alias
InitializeForm(alias);
}
else
{
this.Visible = false;
}
//Create from with values based on the alias
InitializeForm(alias);
}
else
{
this.Visible = false;
}
}
else
{
//Render form if properties are in the viewstate
if (SelectedProperties.Count > 0)
{
RendeFormControls();
}
}
}
//Make sure child controls get rendered
EnsureChildControls();
}
else
{
//Render form if properties are in the viewstate
if (SelectedProperties.Count > 0)
{
RendeFormControls();
}
}
}
//Make sure child controls get rendered
EnsureChildControls();
}
protected override void Render(HtmlTextWriter writer)
{
{
writer.Write("<div id=\"container" + ID + "\" class=\"macroeditor\">");
_delete.RenderControl(writer);
writer.Write("<h4>Macro:</h4>");
_macroSelectDropdown.RenderControl(writer);
writer.Write(" ");//<a style=\"color: red;\" href=\"javascript:deletemacro('" + _macroSelectDropdown.ClientID + "','"+ID+"container' )\">Delete</a>");
_delete.RenderControl(writer);
propertiesHeader.RenderControl(writer);
_formTable.RenderControl(writer);
writer.Write("</div>");
}
@@ -174,6 +180,10 @@ namespace umbraco.editorControls.macrocontainer
///Only render form when macro is found
if (formMacro != null)
{
if (formMacro.Properties.Length > 0)
{
propertiesHeader.Visible = true;
}
foreach (MacroProperty macroProperty in formMacro.Properties)
{
//Only add properties that people may see.
@@ -216,7 +226,7 @@ namespace umbraco.editorControls.macrocontainer
caption.Text = prop.Name;
//Get the MacroControl
Control macroControl = MacroControlFactory.GetMacroRenderControlByType(prop,ID + "_" + prop.Alias);
Control macroControl = MacroControlFactory.GetMacroRenderControlByType(prop, ID + "_" + prop.Alias);
AddFormRow(caption, macroControl);
@@ -286,7 +296,7 @@ namespace umbraco.editorControls.macrocontainer
private string SelectedMacroAlias
{
get { return string.Format("{0}", ViewState[ID + "SelectedMacroAlias"]); }
set { ViewState[ID + "SelectedMacroAlias"] = value; }
}

View File

@@ -533,7 +533,7 @@ namespace umbraco.cms.businesslogic
protected virtual XmlNode generateXmlWithoutSaving(XmlDocument xd)
{
string nodeName = UmbracoSettings.UseLegacyXmlSchema ? "node" : Casing.SafeAlias(ContentType.Alias);
string nodeName = UmbracoSettings.UseLegacyXmlSchema ? "node" : Casing.SafeAliasWithForcingCheck(ContentType.Alias);
XmlNode x = xd.CreateNode(XmlNodeType.Element, nodeName, "");
XmlPopulate(xd, ref x, false);
return x;

View File

@@ -262,7 +262,7 @@ namespace umbraco.cms.businesslogic.propertytype
SqlHelper.ExecuteNonQuery("INSERT INTO cmsPropertyType (DataTypeId, ContentTypeId, alias, name) VALUES (@DataTypeId, @ContentTypeId, @alias, @name)",
SqlHelper.CreateParameter("@DataTypeId", dt.Id),
SqlHelper.CreateParameter("@ContentTypeId", ct.Id),
SqlHelper.CreateParameter("@alias", helpers.Casing.SafeAliasWithForcingCheck(alias)),
SqlHelper.CreateParameter("@alias", alias),
SqlHelper.CreateParameter("@name", name));
pt = new PropertyType(SqlHelper.ExecuteScalar<int>("SELECT MAX(id) FROM cmsPropertyType WHERE alias=@alias",
SqlHelper.CreateParameter("@alias", alias)));

View File

@@ -34,8 +34,9 @@ namespace umbraco.cms.helpers
else
{
// first char should always be lowercase (camel style)
if (safeString.Length == 0)
currentChar = currentChar.ToLower();
// Skipping this check as it can cause incompatibility issues with 3rd party packages
// if (safeString.Length == 0)
// currentChar = currentChar.ToLower();
if (i < aliasLength - 1 && i > 0 && alias.Substring(i - 1, 1) == " ")
currentChar = currentChar.ToUpper();

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 7.2 KiB

View File

@@ -26,7 +26,7 @@
AutoPostBack="True" onselectedindexchanged="DatabaseType_SelectedIndexChanged">
<asp:ListItem Value="SqlServer" Text="Microsoft SQL Server" Selected="True" />
<asp:ListItem Value="MySql" Text="MySQL" />
<asp:ListItem Value="SqlServerE" Text="Embedded database (Microsoft SQL Server Express user instance)" />
<!-- <asp:ListItem Value="SqlServerE" Text="Embedded database (Microsoft SQL Server Express user instance)" /> -->
<asp:ListItem Value="" Text="Custom connection" />
</asp:DropDownList>
</li>

View File

@@ -2279,6 +2279,12 @@ namespace umbraco
}
content.AfterUpdateDocumentCache += new content.DocumentCacheEventHandler(content_AfterUpdateDocumentCache);
content.AfterRefreshContent += new content.RefreshContentEventHandler(content_AfterRefreshContent);
}
void content_AfterRefreshContent(Document sender, RefreshContentEventArgs e)
{
library.ClearNiceUrlCache();
}
void content_AfterUpdateDocumentCache(Document sender, DocumentCacheEventArgs e)

View File

@@ -46,7 +46,9 @@
<key alias="recycleBinWarning" version="4.0">When items are deleted from the recycle bin, they will be gone forever</key>
<key alias="recycleBinDeleting" version="4.0">The items in the recycle bin is now being deleted. Please do not close this window while this operation takes place</key>
<key alias="closeThisWindow" version="4.0">Close this window</key>
<key alias="removeMacro" version="4.5">Remove Macro</key>
<key alias="insertMacro" version="4.5">Click to add a Macro</key>
<key alias="macroContainerSettings" version="4.5">Macro Settings</key>
<key alias="templateContentAreaHelp" version="4.0">
<![CDATA[<strong>Set a placeholder id</strong> by setting an ID on your placeholder you can inject content into this template from child templates,
by refering this ID using a <code>&lt;asp:content /&gt;</code> element.]]>

View File

@@ -0,0 +1,46 @@
.macroeditor
{
border: 2px dotted #33cc66;
padding: 8px 5px 10px 25px;
margin: 5px 0;
}
.macroeditor:hover
{
border: 2px solid #33cc66;
cursor: move;
}
.macroeditor td
{
padding: 10px 0;
}
.macroeditor h4
{
font-size: 14px;
font-weight: bold;
}
.macroeditor .macroDelete
{
float: right;
border: 1px solid #f00;
background-color: #fcc;
padding: 3px;
text-decoration: none;
}
.macroContainerAdd
{
font-size: 14px;
font-weight: bold;
text-decoration: none;
}
.macrocontainer
{
margin: 5px 0;
border: 1px solid #ccc;
padding: 10px;
}