removes old template editor webforms files
This commit is contained in:
@@ -449,12 +449,6 @@
|
||||
<Compile Include="Umbraco\Search\QuickSearch.ascx.designer.cs">
|
||||
<DependentUpon>QuickSearch.ascx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Umbraco\Settings\EditTemplate.aspx.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Umbraco\Settings\EditTemplate.aspx.designer.cs">
|
||||
<DependentUpon>editTemplate.aspx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Umbraco\Settings\Stylesheet\editstylesheet.aspx.cs">
|
||||
<DependentUpon>editstylesheet.aspx</DependentUpon>
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
@@ -797,22 +791,6 @@
|
||||
<DependentUpon>applications.config</DependentUpon>
|
||||
<SubType>Designer</SubType>
|
||||
</None>
|
||||
<Content Include="Umbraco\Scripting\templates\cshtml\EmptyTemplate.cshtml">
|
||||
<SubType>Code</SubType>
|
||||
</Content>
|
||||
<Content Include="Umbraco\Scripting\templates\cshtml\Gallery.cshtml" />
|
||||
<Content Include="Umbraco\Scripting\templates\cshtml\ListAncestorsFromCurrentPage.cshtml" />
|
||||
<Content Include="Umbraco\Scripting\templates\cshtml\ListChildPagesFromChangeableSource.cshtml" />
|
||||
<Content Include="Umbraco\Scripting\templates\cshtml\ListChildPagesFromCurrentPage.cshtml" />
|
||||
<Content Include="Umbraco\Scripting\templates\cshtml\ListChildPagesOrderedByDate.cshtml" />
|
||||
<Content Include="Umbraco\Scripting\templates\cshtml\ListChildPagesOrderedByName.cshtml" />
|
||||
<Content Include="Umbraco\Scripting\templates\cshtml\ListChildPagesOrderedByProperty.cshtml" />
|
||||
<Content Include="Umbraco\Scripting\templates\cshtml\ListChildPagesWithDoctype.cshtml" />
|
||||
<Content Include="Umbraco\Scripting\templates\cshtml\ListDescendantsFromCurrentPage.cshtml" />
|
||||
<Content Include="Umbraco\Scripting\templates\cshtml\ListImagesFromMediaFolder.cshtml">
|
||||
<SubType>Code</SubType>
|
||||
</Content>
|
||||
<Content Include="Umbraco\Scripting\templates\cshtml\MultinodeTree-picker.cshtml" />
|
||||
<Content Include="Umbraco\Views\Default.cshtml" />
|
||||
<Content Include="Umbraco\PartialViewMacros\Templates\EditProfile.cshtml" />
|
||||
<Content Include="Umbraco\PartialViewMacros\Templates\Empty.cshtml" />
|
||||
@@ -868,9 +846,6 @@
|
||||
<Content Include="Umbraco\Masterpages\umbracoPage.Master" />
|
||||
<Content Include="Umbraco\Masterpages\umbracoDialog.Master" />
|
||||
<Content Include="Umbraco\Search\QuickSearchHandler.ashx" />
|
||||
<Content Include="Umbraco\Scripting\Templates\Cshtml\Breadcrumb.cshtml" />
|
||||
<Content Include="Umbraco\Scripting\Templates\Cshtml\Navigation.cshtml" />
|
||||
<Content Include="Umbraco\Scripting\Templates\Cshtml\SiteMap.cshtml" />
|
||||
<Content Include="Umbraco\Webservices\CheckForUpgrade.asmx" />
|
||||
<Content Include="Umbraco\Xslt\searchResult.xslt" />
|
||||
<Content Include="Umbraco\Xslt\Templates\RelatedLinks.xslt" />
|
||||
@@ -912,7 +887,6 @@
|
||||
<Content Include="Umbraco\publishStatus.aspx" />
|
||||
<Content Include="Umbraco\Settings\EditDictionaryItem.aspx" />
|
||||
<Content Include="Umbraco\Settings\editLanguage.aspx" />
|
||||
<Content Include="Umbraco\Settings\editTemplate.aspx" />
|
||||
<Content Include="Umbraco\Settings\Modals\ShowUmbracoTags.aspx" />
|
||||
<Content Include="Umbraco\Settings\Stylesheet\editstylesheet.aspx" />
|
||||
<Content Include="Umbraco\Settings\Stylesheet\Property\EditStyleSheetProperty.aspx" />
|
||||
@@ -932,7 +906,6 @@
|
||||
<SubType>Form</SubType>
|
||||
</Content>
|
||||
<Content Include="Umbraco\Webservices\publication.asmx" />
|
||||
<Content Include="Umbraco\Webservices\templates.asmx" />
|
||||
<Content Include="Umbraco\Webservices\wsdl.xslt" />
|
||||
<Content Include="Umbraco\Xslt\macroGetCurrent.xsl" />
|
||||
<Content Include="Umbraco\Xslt\macroGetSubs.xsl" />
|
||||
|
||||
@@ -1176,9 +1176,6 @@
|
||||
<Compile Include="umbraco.presentation\umbraco\Search\QuickSearch.ascx.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="umbraco.presentation\umbraco\settings\editTemplate.aspx.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="umbraco.presentation\umbraco\settings\modals\ShowUmbracoTags.aspx.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
@@ -1730,10 +1727,6 @@
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="umbraco.presentation\umbraco\webservices\RegexComWebservice.cs" />
|
||||
<Compile Include="umbraco.presentation\umbraco\webservices\templates.asmx.cs">
|
||||
<DependentUpon>templates.asmx</DependentUpon>
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="umbraco.presentation\umbraco\Web\UI\ContentPage.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
@@ -1901,7 +1894,6 @@
|
||||
<SubType>Form</SubType>
|
||||
</Content>
|
||||
<Content Include="umbraco.presentation\umbraco\webservices\publication.asmx" />
|
||||
<Content Include="umbraco.presentation\umbraco\webservices\templates.asmx" />
|
||||
<Content Include="umbraco.presentation\umbraco\webservices\TreeDataService.ashx" />
|
||||
<None Include="umbraco.presentation\umbraco\Trees\Trees.cd" />
|
||||
<None Include="umbraco.presentation\umbraco\Trees\XmlTree.xsd">
|
||||
|
||||
@@ -1,356 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.IO;
|
||||
using umbraco.BasePages;
|
||||
using umbraco.BusinessLogic;
|
||||
|
||||
using umbraco.cms.businesslogic.template;
|
||||
using umbraco.cms.presentation.Trees;
|
||||
using umbraco.DataLayer;
|
||||
using umbraco.uicontrols;
|
||||
using System.Linq;
|
||||
|
||||
namespace umbraco.cms.presentation.settings
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for editTemplate.
|
||||
/// </summary>
|
||||
public partial class editTemplate : UmbracoEnsuredPage
|
||||
{
|
||||
private Template _template;
|
||||
public MenuButton SaveButton;
|
||||
|
||||
public editTemplate()
|
||||
{
|
||||
CurrentApp = DefaultApps.settings.ToString();
|
||||
}
|
||||
|
||||
protected override void OnPreRender(EventArgs e)
|
||||
{
|
||||
base.OnPreRender(e);
|
||||
|
||||
ScriptManager.GetCurrent(Page).Services.Add(
|
||||
new ServiceReference(IOHelper.ResolveUrl(SystemDirectories.WebServices + "/codeEditorSave.asmx")));
|
||||
ScriptManager.GetCurrent(Page).Services.Add(
|
||||
new ServiceReference(IOHelper.ResolveUrl(SystemDirectories.WebServices + "/legacyAjaxCalls.asmx")));
|
||||
}
|
||||
|
||||
protected string TemplateTreeSyncPath { get; private set; }
|
||||
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
MasterTemplate.Attributes.Add("onchange", "changeMasterPageFile()");
|
||||
TemplateTreeSyncPath = "-1,init," + _template.Path.Replace("-1,", "");
|
||||
|
||||
if (!IsPostBack)
|
||||
{
|
||||
MasterTemplate.Items.Add(new ListItem(ui.Text("none"), "0"));
|
||||
foreach (Template t in Template.GetAllAsList())
|
||||
{
|
||||
if (t.Id != _template.Id)
|
||||
{
|
||||
var li = new ListItem(t.Text, t.Id.ToString());
|
||||
li.Attributes.Add("id", t.Alias.Replace(" ", ""));
|
||||
MasterTemplate.Items.Add(li);
|
||||
}
|
||||
}
|
||||
|
||||
NameTxt.Text = _template.GetRawText();
|
||||
AliasTxt.Text = _template.Alias;
|
||||
editorSource.Text = _template.Design;
|
||||
|
||||
try
|
||||
{
|
||||
if (_template.MasterTemplate > 0)
|
||||
MasterTemplate.SelectedValue = _template.MasterTemplate.ToString();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
|
||||
ClientTools
|
||||
.SetActiveTreeType(Constants.Trees.Templates)
|
||||
.SyncTree(TemplateTreeSyncPath, false);
|
||||
|
||||
LoadScriptingTemplates();
|
||||
LoadMacros();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnInit(EventArgs e)
|
||||
{
|
||||
_template = new Template(int.Parse(Request.QueryString["templateID"]));
|
||||
//
|
||||
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
|
||||
//
|
||||
InitializeComponent();
|
||||
base.OnInit(e);
|
||||
Panel1.hasMenu = true;
|
||||
|
||||
var editor = Panel1.NewTabPage(ui.Text("template"));
|
||||
editor.Controls.Add(Pane8);
|
||||
|
||||
var props = Panel1.NewTabPage(ui.Text("properties"));
|
||||
props.Controls.Add(Pane7);
|
||||
|
||||
SaveButton = Panel1.Menu.NewButton();
|
||||
SaveButton.Text = ui.Text("save");
|
||||
SaveButton.ButtonType = MenuButtonType.Primary;
|
||||
SaveButton.ID = "save";
|
||||
SaveButton.CssClass = "client-side";
|
||||
|
||||
Panel1.Text = ui.Text("edittemplate");
|
||||
pp_name.Text = ui.Text("name", UmbracoUser);
|
||||
pp_alias.Text = ui.Text("alias", UmbracoUser);
|
||||
pp_masterTemplate.Text = ui.Text("mastertemplate", UmbracoUser);
|
||||
|
||||
|
||||
// Editing buttons
|
||||
MenuIconI umbField = editorSource.Menu.NewIcon();
|
||||
umbField.ImageURL = UmbracoPath + "/images/editor/insField.gif";
|
||||
umbField.OnClickCommand =
|
||||
ClientTools.Scripts.OpenModalWindow(
|
||||
IOHelper.ResolveUrl(SystemDirectories.Umbraco) + "/dialogs/umbracoField.aspx?objectId=" +
|
||||
editorSource.ClientID + "&tagName=UMBRACOGETDATA", ui.Text("template", "insertPageField"), 640, 550);
|
||||
umbField.AltText = ui.Text("template", "insertPageField");
|
||||
|
||||
|
||||
// TODO: Update icon
|
||||
MenuIconI umbDictionary = editorSource.Menu.NewIcon();
|
||||
umbDictionary.ImageURL = GlobalSettings.Path + "/images/editor/dictionaryItem.gif";
|
||||
umbDictionary.OnClickCommand =
|
||||
ClientTools.Scripts.OpenModalWindow(
|
||||
IOHelper.ResolveUrl(SystemDirectories.Umbraco) + "/dialogs/umbracoField.aspx?objectId=" +
|
||||
editorSource.ClientID + "&tagName=UMBRACOGETDICTIONARY", ui.Text("template", "insertDictionaryItem"),
|
||||
640, 550);
|
||||
umbDictionary.AltText = "Insert umbraco dictionary item";
|
||||
|
||||
editorSource.Menu.NewElement("div", "splitButtonMacroPlaceHolder", "sbPlaceHolder", 40);
|
||||
|
||||
if (UmbracoConfig.For.UmbracoSettings().Templates.UseAspNetMasterPages)
|
||||
{
|
||||
MenuIconI umbContainer = editorSource.Menu.NewIcon();
|
||||
umbContainer.ImageURL = UmbracoPath + "/images/editor/masterpagePlaceHolder.gif";
|
||||
umbContainer.AltText = ui.Text("template", "insertContentAreaPlaceHolder");
|
||||
umbContainer.OnClickCommand =
|
||||
ClientTools.Scripts.OpenModalWindow(
|
||||
IOHelper.ResolveUrl(SystemDirectories.Umbraco) +
|
||||
"/dialogs/insertMasterpagePlaceholder.aspx?&id=" + _template.Id,
|
||||
ui.Text("template", "insertContentAreaPlaceHolder"), 470, 320);
|
||||
|
||||
MenuIconI umbContent = editorSource.Menu.NewIcon();
|
||||
umbContent.ImageURL = UmbracoPath + "/images/editor/masterpageContent.gif";
|
||||
umbContent.AltText = ui.Text("template", "insertContentArea");
|
||||
umbContent.OnClickCommand =
|
||||
ClientTools.Scripts.OpenModalWindow(
|
||||
IOHelper.ResolveUrl(SystemDirectories.Umbraco) + "/dialogs/insertMasterpageContent.aspx?id=" +
|
||||
_template.Id, ui.Text("template", "insertContentArea"), 470, 300);
|
||||
}
|
||||
|
||||
|
||||
//Spit button
|
||||
editorSource.Menu.InsertSplitter();
|
||||
editorSource.Menu.NewElement("div", "splitButtonPlaceHolder", "sbPlaceHolder", 40);
|
||||
|
||||
// Help
|
||||
editorSource.Menu.InsertSplitter();
|
||||
|
||||
MenuIconI helpIcon = editorSource.Menu.NewIcon();
|
||||
helpIcon.OnClickCommand =
|
||||
ClientTools.Scripts.OpenModalWindow(
|
||||
IOHelper.ResolveUrl(SystemDirectories.Umbraco) + "/settings/modals/showumbracotags.aspx?alias=" +
|
||||
_template.Alias, ui.Text("template", "quickGuide"), 600, 580);
|
||||
helpIcon.ImageURL = UmbracoPath + "/images/editor/help.png";
|
||||
helpIcon.AltText = ui.Text("template", "quickGuide");
|
||||
}
|
||||
|
||||
|
||||
private void LoadScriptingTemplates()
|
||||
{
|
||||
string path = SystemDirectories.Umbraco + "/scripting/templates/cshtml/";
|
||||
string abPath = IOHelper.MapPath(path);
|
||||
|
||||
var files = new List<KeyValuePair<string, string>>();
|
||||
|
||||
if (Directory.Exists(abPath))
|
||||
{
|
||||
string extension = ".cshtml";
|
||||
|
||||
foreach (FileInfo fi in new DirectoryInfo(abPath).GetFiles("*" + extension))
|
||||
{
|
||||
string filename = Path.GetFileName(fi.FullName);
|
||||
|
||||
files.Add(new KeyValuePair<string, string>(
|
||||
filename,
|
||||
filename.Replace(extension, "").SplitPascalCasing().ToFirstUpperInvariant()
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
rpt_codeTemplates.DataSource = files;
|
||||
rpt_codeTemplates.DataBind();
|
||||
}
|
||||
|
||||
private void LoadMacros()
|
||||
{
|
||||
using (var sqlHelper = BusinessLogic.Application.SqlHelper)
|
||||
using (IRecordsReader macroRenderings =
|
||||
sqlHelper.ExecuteReader("select id, macroAlias, macroName from cmsMacro order by macroName"))
|
||||
{
|
||||
rpt_macros.DataSource = macroRenderings;
|
||||
rpt_macros.DataBind();
|
||||
}
|
||||
}
|
||||
|
||||
public string DoesMacroHaveSettings(string macroId)
|
||||
{
|
||||
using (var sqlHelper = BusinessLogic.Application.SqlHelper)
|
||||
if (
|
||||
sqlHelper.ExecuteScalar<int>(string.Format("select 1 from cmsMacroProperty where macro = {0}", macroId)) ==
|
||||
1)
|
||||
return "1";
|
||||
else
|
||||
return "0";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// CssInclude1 control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::ClientDependency.Core.Controls.CssInclude CssInclude1;
|
||||
|
||||
/// <summary>
|
||||
/// JsInclude control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::ClientDependency.Core.Controls.JsInclude JsInclude;
|
||||
|
||||
/// <summary>
|
||||
/// Panel1 control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::umbraco.uicontrols.TabView Panel1;
|
||||
|
||||
/// <summary>
|
||||
/// Pane7 control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::umbraco.uicontrols.Pane Pane7;
|
||||
protected global::umbraco.uicontrols.Pane Pane8;
|
||||
|
||||
/// <summary>
|
||||
/// pp_name control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::umbraco.uicontrols.PropertyPanel pp_name;
|
||||
|
||||
/// <summary>
|
||||
/// NameTxt control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.TextBox NameTxt;
|
||||
|
||||
/// <summary>
|
||||
/// pp_alias control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::umbraco.uicontrols.PropertyPanel pp_alias;
|
||||
|
||||
/// <summary>
|
||||
/// AliasTxt control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.TextBox AliasTxt;
|
||||
|
||||
/// <summary>
|
||||
/// pp_masterTemplate control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::umbraco.uicontrols.PropertyPanel pp_masterTemplate;
|
||||
|
||||
/// <summary>
|
||||
/// MasterTemplate control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.DropDownList MasterTemplate;
|
||||
|
||||
/// <summary>
|
||||
/// pp_source control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::umbraco.uicontrols.PropertyPanel pp_source;
|
||||
|
||||
/// <summary>
|
||||
/// editorSource control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::umbraco.uicontrols.CodeArea editorSource;
|
||||
|
||||
/// <summary>
|
||||
/// rpt_codeTemplates control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.Repeater rpt_codeTemplates;
|
||||
|
||||
/// <summary>
|
||||
/// rpt_macros control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.Repeater rpt_macros;
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
<%@ WebService Language="c#" Codebehind="templates.asmx.cs" Class="umbraco.webservices.templates" %>
|
||||
@@ -1,113 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Diagnostics;
|
||||
using System.Web;
|
||||
using System.Web.Services;
|
||||
using System.Xml;
|
||||
using System.Web.Script.Services;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Web.WebServices;
|
||||
using umbraco.BusinessLogic;
|
||||
using umbraco.presentation.webservices;
|
||||
|
||||
namespace umbraco.webservices
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for templates.
|
||||
/// </summary>
|
||||
[WebService(Namespace="http://umbraco.org/webservices/")]
|
||||
[ScriptService]
|
||||
public class templates : UmbracoAuthorizedWebService
|
||||
{
|
||||
|
||||
[WebMethod]
|
||||
public XmlNode GetTemplates(string Login, string Password)
|
||||
{
|
||||
if (ValidateCredentials(Login, Password) && UserHasAppAccess(DefaultApps.settings.ToString(), Login))
|
||||
{
|
||||
var xmlDoc = new XmlDocument();
|
||||
xmlDoc.LoadXml("<templates/>");
|
||||
foreach (cms.businesslogic.template.Template t in cms.businesslogic.template.Template.GetAllAsList())
|
||||
{
|
||||
var tt = xmlDoc.CreateElement("template");
|
||||
tt.Attributes.Append(XmlHelper.AddAttribute(xmlDoc, "id", t.Id.ToString()));
|
||||
tt.Attributes.Append(XmlHelper.AddAttribute(xmlDoc, "name", t.Text));
|
||||
xmlDoc.DocumentElement.AppendChild(tt);
|
||||
}
|
||||
return xmlDoc.DocumentElement;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
[WebMethod]
|
||||
public XmlNode GetTemplate(int Id, string Login, string Password)
|
||||
{
|
||||
if (ValidateCredentials(Login, Password) && UserHasAppAccess(DefaultApps.settings.ToString(), Login))
|
||||
{
|
||||
var t = new cms.businesslogic.template.Template(Id);
|
||||
var xmlDoc = new XmlDocument();
|
||||
var tXml = xmlDoc.CreateElement("template");
|
||||
tXml.Attributes.Append(XmlHelper.AddAttribute(xmlDoc, "id", t.Id.ToString()));
|
||||
tXml.Attributes.Append(XmlHelper.AddAttribute(xmlDoc, "master", t.MasterTemplate.ToString()));
|
||||
tXml.Attributes.Append(XmlHelper.AddAttribute(xmlDoc, "name", t.Text));
|
||||
tXml.AppendChild(XmlHelper.AddCDataNode(xmlDoc, "design", t.Design));
|
||||
return tXml;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
[WebMethod]
|
||||
public bool UpdateTemplate(int Id, int Master, string Design, string Login, string Password)
|
||||
{
|
||||
if (ValidateCredentials(Login, Password) && UserHasAppAccess(DefaultApps.settings.ToString(), Login))
|
||||
{
|
||||
try
|
||||
{
|
||||
var t = new cms.businesslogic.template.Template(Id)
|
||||
{
|
||||
MasterTemplate = Master,
|
||||
Design = Design
|
||||
};
|
||||
//ensure events are raised
|
||||
t.Save();
|
||||
return true;
|
||||
}
|
||||
catch (ArgumentException)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
[WebMethod]
|
||||
[ScriptMethod]
|
||||
public string GetCodeSnippet(object templateId)
|
||||
{
|
||||
//NOTE: The legacy code threw an exception so will continue to do that.
|
||||
AuthorizeRequest(DefaultApps.settings.ToString(), true);
|
||||
|
||||
var snippetPath = SystemDirectories.Umbraco + "/scripting/templates/cshtml/";
|
||||
var filePath = IOHelper.MapPath(snippetPath + templateId);
|
||||
|
||||
//Directory check.. only allow files in script dir and below to be edited
|
||||
if (filePath.StartsWith(IOHelper.MapPath(snippetPath)))
|
||||
{
|
||||
var templateFile =
|
||||
System.IO.File.OpenText(filePath);
|
||||
var content = templateFile.ReadToEnd();
|
||||
templateFile.Close();
|
||||
return content;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new ArgumentException("Couldn't open snippet - Illegal path");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user