Method Renaming to follow standards

Marking IOHelper methods as internal
Removing unneeded umbraco setting
Missing icon and missing folder in UI project
This commit is contained in:
PerPloug
2012-09-28 09:19:16 -02:00
parent 6c4869f931
commit 04e0b35c7d
9 changed files with 143 additions and 149 deletions

View File

@@ -1170,9 +1170,7 @@ namespace Umbraco.Core.Configuration
}
catch (Exception ex)
{
Trace.WriteLine("Could not load /settings/templates/enableMvcSupport from umbracosettings.config:\r\n {0}",
ex.Message);
LogHelper.Error<UmbracoSettings>("Could not load /settings/templates/enableMvcSupport from umbracosettings.config", ex);
_enableMvc = false;
}
}
@@ -1180,35 +1178,6 @@ namespace Umbraco.Core.Configuration
}
}
private static string[] _mvcViewExtensions;
public static string[] MvcViewExtensions
{
get
{
string[] defaultValue = "cshtml".Split(',');
if (_mvcViewExtensions == null)
{
try
{
string value = GetKey("/settings/templates/mvcViewExtensions");
if (!string.IsNullOrEmpty(value))
_mvcViewExtensions = value.Split(',');
else
_mvcViewExtensions = defaultValue;
}
catch (Exception ex)
{
Trace.WriteLine("Could not load /settings/templates/mvcViewExtensions from umbracosettings.config:\r\n {0}",
ex.Message);
_mvcViewExtensions = defaultValue;
}
}
return _mvcViewExtensions;
}
}
/// <summary>
/// Configuration regarding webservices

View File

@@ -152,7 +152,7 @@ namespace Umbraco.Core.IO
/// <param name="filePath">filepath </param>
/// <param name="validDir"></param>
/// <returns>true if valid, throws a FileSecurityException if not</returns>
public static bool ValidateEditPath(string filePath, string validDir)
internal static bool ValidateEditPath(string filePath, string validDir)
{
if (!filePath.StartsWith(MapPath(SystemDirectories.Root)))
filePath = MapPath(filePath);
@@ -165,7 +165,7 @@ namespace Umbraco.Core.IO
return true;
}
public static bool ValidateEditPath(string filePath, string[] validDirs)
internal static bool ValidateEditPath(string filePath, IEnumerable<string> validDirs)
{
foreach (var dir in validDirs)
{
@@ -182,7 +182,7 @@ namespace Umbraco.Core.IO
throw new FileSecurityException(String.Format("The filepath '{0}' is not within an allowed directory for this type of files", filePath.Replace(MapPath(SystemDirectories.Root), "")));
}
public static bool ValidateFileExtension(string filePath, List<string> validFileExtensions)
internal static bool ValidateFileExtension(string filePath, List<string> validFileExtensions)
{
if (!filePath.StartsWith(MapPath(SystemDirectories.Root)))
filePath = MapPath(filePath);

View File

@@ -370,6 +370,7 @@
<Content Include="umbraco\plugins\uGoLive\run.png" />
<Content Include="umbraco\plugins\uGoLive\throbber.gif" />
<Content Include="umbraco\plugins\uGoLive\tick.png" />
<Content Include="umbraco\settings\views\editView.aspx" />
<Content Include="umbraco\webservices\api\DocumentService.asmx" />
<Content Include="umbraco\webservices\api\FileService.asmx" />
<Content Include="umbraco\webservices\api\MaintanceService.asmx" />

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@@ -0,0 +1,95 @@
<%@ Page Language="C#" MasterPageFile="../../masterpages/umbracoPage.Master" AutoEventWireup="true"
CodeBehind="editView.aspx.cs" Inherits="umbraco.cms.presentation.settings.views.EditView"
ValidateRequest="False" %>
<%@ Register TagPrefix="cc1" Namespace="umbraco.uicontrols" Assembly="controls" %>
<%@ Register TagPrefix="umb" Namespace="ClientDependency.Core.Controls" Assembly="ClientDependency.Core" %>
<asp:Content ContentPlaceHolderID="head" runat="server">
<script language="javascript" type="text/javascript">
function doSubmit() {
var codeVal = UmbEditor.GetCode();
umbraco.presentation.webservices.codeEditorSave.SaveTemplate(jQuery('#<%= NameTxt.ClientID %>').val(), jQuery('#<%= AliasTxt.ClientID %>').val(), codeVal, '<%= Request.QueryString["templateID"] %>', jQuery('#<%= MasterTemplate.ClientID %>').val(), submitSucces, submitFailure);
}
function submitSucces(t)
{
if(t != 'true')
{
top.UmbSpeechBubble.ShowMessage('error', '<%= umbraco.ui.Text("speechBubbles", "templateErrorHeader") %>', '<%= umbraco.ui.Text("speechBubbles", "templateErrorText") %>');
}
else
{
top.UmbSpeechBubble.ShowMessage('save', '<%= umbraco.ui.Text("speechBubbles", "templateSavedHeader") %>', '<%= umbraco.ui.Text("speechBubbles", "templateSavedText") %>')
}
}
function submitFailure(t)
{
top.UmbSpeechBubble.ShowMessage('error', '<%= umbraco.ui.Text("speechBubbles", "templateErrorHeader") %>', '<%= umbraco.ui.Text("speechBubbles", "templateErrorText") %>')
}
function changeMasterPageFile(){
var editor = document.getElementById("<%= editorSource.ClientID %>");
var templateDropDown = document.getElementById("<%= MasterTemplate.ClientID %>");
var templateCode = UmbEditor.GetCode();
var newValue = templateDropDown.options[templateDropDown.selectedIndex].id;
var layoutDefRegex = new RegExp("(@{[\\s\\S]*?Layout\\s*?=\\s*?\")[^\"]*?(\";[\\s\\S]*?})", "gi");
if(newValue != undefined && newValue != "") {
if (layoutDefRegex.test(templateCode)) {
// Declaration exists, so just update it
templateCode = templateCode.replace(layoutDefRegex, "$1" + newValue + "$2");
} else {
// Declaration doesn't exist, so prepend to start of doc
//TODO: Maybe insert at the cursor position, rather than just at the top of the doc?
templateCode = "@{\n\tLayout = \"" + newValue + "\";\n}\n" + templateCode;
}
} else {
if (layoutDefRegex.test(templateCode)) {
// Declaration exists, so just update it
templateCode = templateCode.replace(layoutDefRegex, "$1$2");
}
}
UmbEditor.SetCode(templateCode);
return false;
}
</script>
</asp:Content>
<asp:Content ContentPlaceHolderID="body" runat="server">
<cc1:UmbracoPanel ID="Panel1" runat="server" Width="608px" Height="336px" hasMenu="true">
<cc1:Pane ID="Pane7" runat="server" Height="44px" Width="528px">
<cc1:PropertyPanel ID="pp_name" runat="server">
<asp:TextBox ID="NameTxt" Width="350px" runat="server"></asp:TextBox>
</cc1:PropertyPanel>
<cc1:PropertyPanel ID="pp_alias" runat="server">
<asp:TextBox ID="AliasTxt" Width="350px" runat="server"></asp:TextBox>
</cc1:PropertyPanel>
<cc1:PropertyPanel ID="pp_masterTemplate" runat="server">
<asp:DropDownList ID="MasterTemplate" Width="350px" runat="server" />
</cc1:PropertyPanel>
<cc1:PropertyPanel ID="pp_source" runat="server">
<cc1:CodeArea ID="editorSource" runat="server" CodeBase="Razor" ClientSaveMethod="doSubmit" AutoResize="true" OffSetX="37" OffSetY="54"/>
</cc1:PropertyPanel>
</cc1:Pane>
</cc1:UmbracoPanel>
<script type="text/javascript">
jQuery(document).ready(function () {
UmbClientMgr.appActions().bindSaveShortCut();
});
</script>
</asp:Content>

View File

@@ -1,5 +1,5 @@
<%@ Page Language="C#" MasterPageFile="../../masterpages/umbracoPage.Master" AutoEventWireup="true"
CodeBehind="editView.aspx.cs" Inherits="umbraco.cms.presentation.settings.views.editView"
CodeBehind="editView.aspx.cs" Inherits="umbraco.cms.presentation.settings.views.EditView"
ValidateRequest="False" %>
<%@ Register TagPrefix="cc1" Namespace="umbraco.uicontrols" Assembly="controls" %>
@@ -7,11 +7,6 @@
<asp:Content ContentPlaceHolderID="head" runat="server">
<script language="javascript" type="text/javascript">
jQuery(document).ready(function() {
jQuery(".codeTemplate").click(function(){
insertCodeBlockFromTemplate(jQuery(this).attr("rel"));
});
});
function doSubmit() {
var codeVal = UmbEditor.GetCode();
@@ -35,16 +30,6 @@
top.UmbSpeechBubble.ShowMessage('error', '<%= umbraco.ui.Text("speechBubbles", "templateErrorHeader") %>', '<%= umbraco.ui.Text("speechBubbles", "templateErrorText") %>')
}
function umbracoTemplateInsertMasterPageContentContainer() {
var master = document.getElementById('<%= MasterTemplate.ClientID %>')[document.getElementById('<%= MasterTemplate.ClientID %>').selectedIndex].value;
if (master == "") master = 0;
umbraco.presentation.webservices.legacyAjaxCalls.TemplateMasterPageContentContainer(<%=Request["templateID"] %>, master, umbracoTemplateInsertMasterPageContentContainerDo);
}
function umbracoTemplateInsertMasterPageContentContainerDo(result) {
UmbEditor.Insert(result + '\n', '\n</asp\:Content>\n', '<%= editorSource.ClientID%>');
}
function changeMasterPageFile(){
var editor = document.getElementById("<%= editorSource.ClientID %>");
var templateDropDown = document.getElementById("<%= MasterTemplate.ClientID %>");
@@ -72,58 +57,8 @@
return false;
}
function insertContentElement(id){
//nasty hack to avoid asp.net freaking out because of the markup...
var cp = 'asp:Content ContentPlaceHolderId="' + id + '"';
cp += ' runat="server"';
cp += '>\n\t<!-- Insert "' + id + '" markup here -->';
UmbEditor.Insert('\n<' + cp, '\n</asp:Content' + '>\n', '<%= editorSource.ClientID %>');
}
function insertPlaceHolderElement(id){
var cp = 'asp:ContentPlaceHolder Id="' + id + '"';
cp += ' runat="server"';
cp += '>\n\t<!-- Insert default "' + id + '" markup here -->';
UmbEditor.Insert('\n<' + cp, '\n</asp:ContentPlaceHolder' + '>\n', '<%= editorSource.ClientID %>');
}
function insertCodeBlock()
{
var snip = umbracoInsertSnippet();
UmbEditor.Insert(snip.BeginTag, snip.EndTag, '<%= editorSource.ClientID %>');
}
function umbracoInsertSnippet() {
var snip = new UmbracoCodeSnippet();
var cp = 'umbraco:Macro runat="server" language="cshtml"';
snip.BeginTag = '\n<' + cp + '>\n';
snip.EndTag = '\n<' + '/umbraco:Macro' + '>\n';
snip.TargetId = "<%= editorSource.ClientID %>";
return snip;
}
function insertMacro(alias)
{
var macroElement = "umbraco:Macro";
var cp = macroElement + ' Alias="'+ alias +'" runat="server"';
UmbEditor.Insert('<' + cp +' />','', '<%= editorSource.ClientID %>');
}
function openMacroModal(alias)
{
var t = "";
if(alias != null && alias != ""){
t = "&alias="+alias;
}
UmbClientMgr.openModalWindow('<%= umbraco.IO.IOHelper.ResolveUrl(umbraco.IO.SystemDirectories.Umbraco) %>/dialogs/editMacro.aspx?objectId=<%= editorSource.ClientID %>' + t, 'Insert Macro', true, 470, 530, 0, 0, '', '');
}
</script>
</asp:Content>

View File

@@ -14,7 +14,7 @@ using umbraco.uicontrols;
namespace umbraco.cms.presentation.settings.views
{
public partial class editView : BasePages.UmbracoEnsuredPage
public partial class EditView : BasePages.UmbracoEnsuredPage
{
private Template _template;
@@ -35,46 +35,41 @@ namespace umbraco.cms.presentation.settings.views
protected global::System.Web.UI.WebControls.Repeater rpt_macros;
public editView()
public EditView()
{
CurrentApp = BusinessLogic.DefaultApps.settings.ToString();
}
protected void Page_Load(object sender, EventArgs e)
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
MasterTemplate.Attributes.Add("onchange", "changeMasterPageFile()");
if (!IsPostBack)
{
MasterTemplate.Items.Add(new ListItem(ui.Text("none"), "0"));
var selectedTemplate = string.Empty;
foreach (Template t in Template.GetAllAsList())
{
if (t.Id != _template.Id)
{
var li = new ListItem(t.Text, t.Id.ToString());
if (t.Id == _template.Id) continue;
var li = new ListItem(t.Text, t.Id.ToString());
li.Attributes.Add("id", t.Alias.Replace(" ", ""));
li.Attributes.Add("id", t.Alias.Replace(" ", ""));
if (t.Id == _template.MasterTemplate)
{
try
{
li.Selected = true;
}
catch
{
}
}
MasterTemplate.Items.Add(li);
}
if (t.Id == _template.MasterTemplate)
selectedTemplate = t.Alias.Replace(" ", "");
MasterTemplate.Items.Add(li);
}
MasterTemplate.SelectedValue = selectedTemplate;
NameTxt.Text = _template.GetRawText();
AliasTxt.Text = _template.Alias;
editorSource.Text = _template.Design;
ClientTools
.SetActiveTreeType(TreeDefinitionCollection.Instance.FindTree<loadTemplates>().Tree.Alias)
.SyncTree("-1,init," + _template.Path.Replace("-1,", ""), false);
@@ -82,7 +77,6 @@ namespace umbraco.cms.presentation.settings.views
}
#region Web Form Designer generated code
protected override void OnInit(EventArgs e)
{

View File

@@ -17,7 +17,7 @@ namespace umbraco.cms.businesslogic.template
string masterpageContent = "";
if (!File.Exists(t.MasterPageFile) || overWrite)
masterpageContent = saveTemplateToFile(t, t.Alias);
masterpageContent = SaveTemplateToFile(t, t.Alias);
else
{
System.IO.TextReader tr = new StreamReader(t.MasterPageFile);
@@ -42,19 +42,19 @@ namespace umbraco.cms.businesslogic.template
internal static string UpdateMasterpageFile(Template t, string currentAlias)
{
return saveTemplateToFile(t, currentAlias);
return SaveTemplateToFile(t, currentAlias);
}
internal static string saveTemplateToFile(Template template, string currentAlias)
internal static string SaveTemplateToFile(Template template, string currentAlias)
{
var masterPageContent = template.Design;
if (!isMasterPageSyntax(masterPageContent))
if (!IsMasterPageSyntax(masterPageContent))
masterPageContent = ConvertToMasterPageSyntax(template);
// Add header to master page if it doesn't exist
if (!masterPageContent.TrimStart().StartsWith("<%@"))
{
masterPageContent = getMasterPageHeader(template) + "\n" + masterPageContent;
masterPageContent = GetMasterPageHeader(template) + "\n" + masterPageContent;
}
else
{
@@ -73,7 +73,7 @@ namespace umbraco.cms.businesslogic.template
{
// validate the masterpagefile
string currentMasterPageFile = attributeSet.Groups["attributeValue"].Value;
string currentMasterTemplateFile = parentTemplatePath(template);
string currentMasterTemplateFile = ParentTemplatePath(template);
if (currentMasterPageFile != currentMasterTemplateFile)
{
@@ -131,17 +131,17 @@ namespace umbraco.cms.businesslogic.template
return masterPageContent;
}
private static bool isMasterPageSyntax(string code)
private static bool IsMasterPageSyntax(string code)
{
return code.Contains("<%@ Master") || code.Contains("<umbraco:Item") || code.Contains("<asp:") || code.Contains("<umbraco:Macro");
}
private static string getMasterPageHeader(Template template)
private static string GetMasterPageHeader(Template template)
{
return String.Format("<%@ Master Language=\"C#\" MasterPageFile=\"{0}\" AutoEventWireup=\"true\" %>", parentTemplatePath(template)) + Environment.NewLine;
return String.Format("<%@ Master Language=\"C#\" MasterPageFile=\"{0}\" AutoEventWireup=\"true\" %>", ParentTemplatePath(template)) + Environment.NewLine;
}
private static string parentTemplatePath(Template template)
private static string ParentTemplatePath(Template template)
{
var masterTemplate = DefaultMasterTemplate;
if (template.MasterTemplate != 0)
@@ -168,18 +168,18 @@ namespace umbraco.cms.businesslogic.template
internal static string EnsureMasterPageSyntax(string templateAlias, string masterPageContent)
{
replaceElement(ref masterPageContent, "?UMBRACO_GETITEM", "umbraco:Item", true);
replaceElement(ref masterPageContent, "?UMBRACO_GETITEM", "umbraco:Item", false);
ReplaceElement(ref masterPageContent, "?UMBRACO_GETITEM", "umbraco:Item", true);
ReplaceElement(ref masterPageContent, "?UMBRACO_GETITEM", "umbraco:Item", false);
// Parse the design for macros
replaceElement(ref masterPageContent, "?UMBRACO_MACRO", "umbraco:Macro", true);
replaceElement(ref masterPageContent, "?UMBRACO_MACRO", "umbraco:Macro", false);
ReplaceElement(ref masterPageContent, "?UMBRACO_MACRO", "umbraco:Macro", true);
ReplaceElement(ref masterPageContent, "?UMBRACO_MACRO", "umbraco:Macro", false);
// Parse the design for load childs
masterPageContent = masterPageContent.Replace("<?UMBRACO_TEMPLATE_LOAD_CHILD/>", createDefaultPlaceHolder(templateAlias))
.Replace("<?UMBRACO_TEMPLATE_LOAD_CHILD />", createDefaultPlaceHolder(templateAlias));
masterPageContent = masterPageContent.Replace("<?UMBRACO_TEMPLATE_LOAD_CHILD/>", CreateDefaultPlaceHolder(templateAlias))
.Replace("<?UMBRACO_TEMPLATE_LOAD_CHILD />", CreateDefaultPlaceHolder(templateAlias));
// Parse the design for aspnet forms
getAspNetMasterPageForm(ref masterPageContent, templateAlias);
GetAspNetMasterPageForm(ref masterPageContent, templateAlias);
masterPageContent = masterPageContent.Replace("</?ASPNET_FORM>", "</form>");
// Parse the design for aspnet heads
masterPageContent = masterPageContent.Replace("</ASPNET_HEAD>", String.Format("<head id=\"{0}Head\" runat=\"server\">", templateAlias.Replace(" ", "")));
@@ -188,9 +188,9 @@ namespace umbraco.cms.businesslogic.template
}
private static void getAspNetMasterPageForm(ref string design, string templateAlias)
private static void GetAspNetMasterPageForm(ref string design, string templateAlias)
{
Match formElement = Regex.Match(design, getElementRegExp("?ASPNET_FORM", false), RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace);
Match formElement = Regex.Match(design, GetElementRegExp("?ASPNET_FORM", false), RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace);
if (formElement != null && formElement.Value != "")
{
@@ -203,15 +203,15 @@ namespace umbraco.cms.businesslogic.template
}
}
private static string createDefaultPlaceHolder(string templateAlias)
private static string CreateDefaultPlaceHolder(string templateAlias)
{
return String.Format("<asp:ContentPlaceHolder ID=\"{0}ContentPlaceHolder\" runat=\"server\"></asp:ContentPlaceHolder>", templateAlias.Replace(" ", ""));
}
private static void replaceElement(ref string design, string elementName, string newElementName, bool checkForQuotes)
private static void ReplaceElement(ref string design, string elementName, string newElementName, bool checkForQuotes)
{
MatchCollection m =
Regex.Matches(design, getElementRegExp(elementName, checkForQuotes),
Regex.Matches(design, GetElementRegExp(elementName, checkForQuotes),
RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace);
foreach (Match match in m)
@@ -248,7 +248,7 @@ namespace umbraco.cms.businesslogic.template
}
}
private static string getElementRegExp(string elementName, bool checkForQuotes)
private static string GetElementRegExp(string elementName, bool checkForQuotes)
{
if (checkForQuotes)
return String.Format("\"<[^>\\s]*\\b{0}(\\b[^>]*)>\"", elementName);

View File

@@ -30,7 +30,7 @@ namespace umbraco.cms.businesslogic.template
string path = IOHelper.MapPath(ViewPath(t));
if (!File.Exists(path) || overWrite)
viewContent = saveTemplateToFile(t, t.Alias);
viewContent = SaveTemplateToFile(t, t.Alias);
else
{
System.IO.TextReader tr = new StreamReader(path);
@@ -41,7 +41,7 @@ namespace umbraco.cms.businesslogic.template
return viewContent;
}
internal static string saveTemplateToFile(Template template, string currentAlias)
internal static string SaveTemplateToFile(Template template, string currentAlias)
{
var design = EnsureInheritedLayout(template);
System.IO.File.WriteAllText(IOHelper.MapPath(ViewPath(template)), design, Encoding.UTF8);