2015-02-09 17:37:21 +11:00
|
|
|
using System;
|
2012-11-06 10:47:14 -01:00
|
|
|
using System.Collections.Generic;
|
2012-10-24 11:29:51 -02:00
|
|
|
using Umbraco.Core.Models;
|
|
|
|
|
|
2012-11-06 10:47:14 -01:00
|
|
|
namespace Umbraco.Core.Services
|
2012-10-24 11:29:51 -02:00
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Defines the File Service, which is an easy access to operations involving <see cref="IFile"/> objects like Scripts, Stylesheets and Templates
|
|
|
|
|
/// </summary>
|
|
|
|
|
public interface IFileService : IService
|
|
|
|
|
{
|
2015-01-09 18:39:44 +11:00
|
|
|
IEnumerable<string> GetPartialViewSnippetNames(params string[] filterNames);
|
|
|
|
|
void DeletePartialViewFolder(string folderPath);
|
|
|
|
|
void DeletePartialViewMacroFolder(string folderPath);
|
|
|
|
|
IPartialView GetPartialView(string path);
|
|
|
|
|
IPartialView GetPartialViewMacro(string path);
|
|
|
|
|
Attempt<IPartialView> CreatePartialView(IPartialView partialView, string snippetName = null, int userId = 0);
|
|
|
|
|
Attempt<IPartialView> CreatePartialViewMacro(IPartialView partialView, string snippetName = null, int userId = 0);
|
|
|
|
|
bool DeletePartialView(string path, int userId = 0);
|
|
|
|
|
bool DeletePartialViewMacro(string path, int userId = 0);
|
|
|
|
|
Attempt<IPartialView> SavePartialView(IPartialView partialView, int userId = 0);
|
|
|
|
|
Attempt<IPartialView> SavePartialViewMacro(IPartialView partialView, int userId = 0);
|
2015-01-14 12:09:30 +11:00
|
|
|
bool ValidatePartialView(PartialView partialView);
|
2015-09-08 17:48:26 +02:00
|
|
|
bool ValidatePartialViewMacro(PartialView partialView);
|
2015-01-09 18:39:44 +11:00
|
|
|
|
2012-10-24 11:29:51 -02:00
|
|
|
/// <summary>
|
|
|
|
|
/// Gets a list of all <see cref="Stylesheet"/> objects
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>An enumerable list of <see cref="Stylesheet"/> objects</returns>
|
|
|
|
|
IEnumerable<Stylesheet> GetStylesheets(params string[] names);
|
2015-01-15 11:49:32 +11:00
|
|
|
|
2012-10-24 11:29:51 -02:00
|
|
|
/// <summary>
|
|
|
|
|
/// Gets a <see cref="Stylesheet"/> object by its name
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="name">Name of the stylesheet incl. extension</param>
|
|
|
|
|
/// <returns>A <see cref="Stylesheet"/> object</returns>
|
|
|
|
|
Stylesheet GetStylesheetByName(string name);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Saves a <see cref="Stylesheet"/>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="stylesheet"><see cref="Stylesheet"/> to save</param>
|
2012-12-10 13:49:20 -01:00
|
|
|
/// <param name="userId">Optional id of the user saving the stylesheet</param>
|
2013-01-25 08:58:21 -01:00
|
|
|
void SaveStylesheet(Stylesheet stylesheet, int userId = 0);
|
2012-10-24 11:29:51 -02:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Deletes a stylesheet by its name
|
|
|
|
|
/// </summary>
|
Updates PartialView & PartialViewMacros models/services/repositories, streamlines their operations, fixes up other underlying problems with the FileRepository, fixes tree syncing for partial views, partial view macros and scripts, fixes scripts being created in folders, allows partial views and partial view macros to be managed and created in folders, fixes FileUnitOfWork to use a queue, publicizes some internal test classes, fixes tree syncing when dealing with invariant case, adds correct validation to the create dialogs of scripts and partial views (and partial view macros)
2014-10-22 16:44:45 +10:00
|
|
|
/// <param name="path">Name incl. extension of the Stylesheet to delete</param>
|
2012-12-10 13:49:20 -01:00
|
|
|
/// <param name="userId">Optional id of the user deleting the stylesheet</param>
|
Updates PartialView & PartialViewMacros models/services/repositories, streamlines their operations, fixes up other underlying problems with the FileRepository, fixes tree syncing for partial views, partial view macros and scripts, fixes scripts being created in folders, allows partial views and partial view macros to be managed and created in folders, fixes FileUnitOfWork to use a queue, publicizes some internal test classes, fixes tree syncing when dealing with invariant case, adds correct validation to the create dialogs of scripts and partial views (and partial view macros)
2014-10-22 16:44:45 +10:00
|
|
|
void DeleteStylesheet(string path, int userId = 0);
|
2012-10-24 11:29:51 -02:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Validates a <see cref="Stylesheet"/>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="stylesheet"><see cref="Stylesheet"/> to validate</param>
|
|
|
|
|
/// <returns>True if Stylesheet is valid, otherwise false</returns>
|
|
|
|
|
bool ValidateStylesheet(Stylesheet stylesheet);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets a list of all <see cref="Script"/> objects
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>An enumerable list of <see cref="Script"/> objects</returns>
|
|
|
|
|
IEnumerable<Script> GetScripts(params string[] names);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets a <see cref="Script"/> object by its name
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="name">Name of the script incl. extension</param>
|
|
|
|
|
/// <returns>A <see cref="Script"/> object</returns>
|
|
|
|
|
Script GetScriptByName(string name);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Saves a <see cref="Script"/>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="script"><see cref="Script"/> to save</param>
|
2012-12-10 13:49:20 -01:00
|
|
|
/// <param name="userId">Optional id of the user saving the script</param>
|
2013-01-25 08:58:21 -01:00
|
|
|
void SaveScript(Script script, int userId = 0);
|
2012-10-24 11:29:51 -02:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Deletes a script by its name
|
|
|
|
|
/// </summary>
|
Updates PartialView & PartialViewMacros models/services/repositories, streamlines their operations, fixes up other underlying problems with the FileRepository, fixes tree syncing for partial views, partial view macros and scripts, fixes scripts being created in folders, allows partial views and partial view macros to be managed and created in folders, fixes FileUnitOfWork to use a queue, publicizes some internal test classes, fixes tree syncing when dealing with invariant case, adds correct validation to the create dialogs of scripts and partial views (and partial view macros)
2014-10-22 16:44:45 +10:00
|
|
|
/// <param name="path">Name incl. extension of the Script to delete</param>
|
2012-12-10 13:49:20 -01:00
|
|
|
/// <param name="userId">Optional id of the user deleting the script</param>
|
Updates PartialView & PartialViewMacros models/services/repositories, streamlines their operations, fixes up other underlying problems with the FileRepository, fixes tree syncing for partial views, partial view macros and scripts, fixes scripts being created in folders, allows partial views and partial view macros to be managed and created in folders, fixes FileUnitOfWork to use a queue, publicizes some internal test classes, fixes tree syncing when dealing with invariant case, adds correct validation to the create dialogs of scripts and partial views (and partial view macros)
2014-10-22 16:44:45 +10:00
|
|
|
void DeleteScript(string path, int userId = 0);
|
2012-10-24 11:29:51 -02:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Validates a <see cref="Script"/>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="script"><see cref="Script"/> to validate</param>
|
|
|
|
|
/// <returns>True if Script is valid, otherwise false</returns>
|
|
|
|
|
bool ValidateScript(Script script);
|
|
|
|
|
|
2014-01-09 18:08:13 +11:00
|
|
|
/// <summary>
|
|
|
|
|
/// Creates a folder for scripts
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="folderPath"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
void CreateScriptFolder(string folderPath);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Deletes a folder for scripts
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="folderPath"></param>
|
|
|
|
|
void DeleteScriptFolder(string folderPath);
|
|
|
|
|
|
2012-10-24 11:29:51 -02:00
|
|
|
/// <summary>
|
2012-11-11 12:20:14 -01:00
|
|
|
/// Gets a list of all <see cref="ITemplate"/> objects
|
2012-10-24 11:29:51 -02:00
|
|
|
/// </summary>
|
2012-11-11 12:20:14 -01:00
|
|
|
/// <returns>An enumerable list of <see cref="ITemplate"/> objects</returns>
|
|
|
|
|
IEnumerable<ITemplate> GetTemplates(params string[] aliases);
|
2012-10-24 11:29:51 -02:00
|
|
|
|
2014-11-20 19:51:42 +11:00
|
|
|
/// <summary>
|
|
|
|
|
/// Gets a list of all <see cref="ITemplate"/> objects
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>An enumerable list of <see cref="ITemplate"/> objects</returns>
|
|
|
|
|
IEnumerable<ITemplate> GetTemplates(int masterTemplateId);
|
|
|
|
|
|
2012-10-24 11:29:51 -02:00
|
|
|
/// <summary>
|
2015-11-03 14:07:05 +01:00
|
|
|
/// Gets a <see cref="ITemplate"/> object by its alias.
|
2012-10-24 11:29:51 -02:00
|
|
|
/// </summary>
|
2015-11-03 14:07:05 +01:00
|
|
|
/// <param name="alias">The alias of the template.</param>
|
|
|
|
|
/// <returns>The <see cref="ITemplate"/> object matching the alias, or null.</returns>
|
2012-12-12 15:17:48 -01:00
|
|
|
ITemplate GetTemplate(string alias);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2015-11-03 14:07:05 +01:00
|
|
|
/// Gets a <see cref="ITemplate"/> object by its identifier.
|
2012-12-12 15:17:48 -01:00
|
|
|
/// </summary>
|
2015-11-03 14:07:05 +01:00
|
|
|
/// <param name="id">The identifer of the template.</param>
|
|
|
|
|
/// <returns>The <see cref="ITemplate"/> object matching the identifier, or null.</returns>
|
2012-12-12 15:17:48 -01:00
|
|
|
ITemplate GetTemplate(int id);
|
2012-10-24 11:29:51 -02:00
|
|
|
|
2015-11-03 14:07:05 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Gets a <see cref="ITemplate"/> object by its guid identifier.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="id">The guid identifier of the template.</param>
|
|
|
|
|
/// <returns>The <see cref="ITemplate"/> object matching the identifier, or null.</returns>
|
|
|
|
|
ITemplate GetTemplate(Guid id);
|
|
|
|
|
|
2013-12-16 18:10:44 +11:00
|
|
|
/// <summary>
|
2015-08-05 11:50:20 +02:00
|
|
|
/// Gets the template descendants
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="alias"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
IEnumerable<ITemplate> GetTemplateDescendants(string alias);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the template descendants
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="masterTemplateId"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
IEnumerable<ITemplate> GetTemplateDescendants(int masterTemplateId);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the template children
|
2013-12-16 18:10:44 +11:00
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="alias"></param>
|
|
|
|
|
/// <returns></returns>
|
2015-08-05 11:50:20 +02:00
|
|
|
IEnumerable<ITemplate> GetTemplateChildren(string alias);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the template children
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="masterTemplateId"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
IEnumerable<ITemplate> GetTemplateChildren(int masterTemplateId);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Returns a template as a template node which can be traversed (parent, children)
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="alias"></param>
|
|
|
|
|
/// <returns></returns>
|
2013-12-16 18:10:44 +11:00
|
|
|
TemplateNode GetTemplateNode(string alias);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Given a template node in a tree, this will find the template node with the given alias if it is found in the hierarchy, otherwise null
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="anyNode"></param>
|
|
|
|
|
/// <param name="alias"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
TemplateNode FindTemplateInTree(TemplateNode anyNode, string alias);
|
|
|
|
|
|
2012-10-24 11:29:51 -02:00
|
|
|
/// <summary>
|
2012-11-11 12:20:14 -01:00
|
|
|
/// Saves a <see cref="ITemplate"/>
|
2012-10-24 11:29:51 -02:00
|
|
|
/// </summary>
|
2012-11-11 12:20:14 -01:00
|
|
|
/// <param name="template"><see cref="ITemplate"/> to save</param>
|
2012-12-10 13:49:20 -01:00
|
|
|
/// <param name="userId">Optional id of the user saving the template</param>
|
2013-01-25 08:58:21 -01:00
|
|
|
void SaveTemplate(ITemplate template, int userId = 0);
|
2012-10-24 11:29:51 -02:00
|
|
|
|
2016-01-19 21:38:11 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Creates a template for a content type
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="contentTypeAlias"></param>
|
|
|
|
|
/// <param name="contentTypeName"></param>
|
|
|
|
|
/// <param name="userId"></param>
|
|
|
|
|
/// <returns>
|
|
|
|
|
/// The template created
|
|
|
|
|
/// </returns>
|
|
|
|
|
Attempt<OperationStatus<ITemplate, OperationStatusType>> CreateTemplateForContentType(string contentTypeAlias, string contentTypeName, int userId = 0);
|
|
|
|
|
|
2014-11-25 18:48:19 +11:00
|
|
|
ITemplate CreateTemplateWithIdentity(string name, string content, ITemplate masterTemplate = null, int userId = 0);
|
|
|
|
|
|
2012-10-24 11:29:51 -02:00
|
|
|
/// <summary>
|
|
|
|
|
/// Deletes a template by its alias
|
|
|
|
|
/// </summary>
|
2012-11-11 12:20:14 -01:00
|
|
|
/// <param name="alias">Alias of the <see cref="ITemplate"/> to delete</param>
|
2012-12-10 13:49:20 -01:00
|
|
|
/// <param name="userId">Optional id of the user deleting the template</param>
|
2013-01-25 08:58:21 -01:00
|
|
|
void DeleteTemplate(string alias, int userId = 0);
|
2012-10-24 11:29:51 -02:00
|
|
|
|
|
|
|
|
/// <summary>
|
2012-11-11 12:20:14 -01:00
|
|
|
/// Validates a <see cref="ITemplate"/>
|
2012-10-24 11:29:51 -02:00
|
|
|
/// </summary>
|
2012-11-11 12:20:14 -01:00
|
|
|
/// <param name="template"><see cref="ITemplate"/> to validate</param>
|
2012-10-24 11:29:51 -02:00
|
|
|
/// <returns>True if Script is valid, otherwise false</returns>
|
2012-11-11 12:20:14 -01:00
|
|
|
bool ValidateTemplate(ITemplate template);
|
2013-03-20 20:31:44 -01:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Saves a collection of <see cref="Template"/> objects
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="templates">List of <see cref="Template"/> to save</param>
|
|
|
|
|
/// <param name="userId">Optional id of the user</param>
|
|
|
|
|
void SaveTemplate(IEnumerable<ITemplate> templates, int userId = 0);
|
2015-01-14 12:09:30 +11:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// This checks what the default rendering engine is set in config but then also ensures that there isn't already
|
|
|
|
|
/// a template that exists in the opposite rendering engine's template folder, then returns the appropriate
|
|
|
|
|
/// rendering engine to use.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
/// <remarks>
|
|
|
|
|
/// The reason this is required is because for example, if you have a master page file already existing under ~/masterpages/Blah.aspx
|
|
|
|
|
/// and then you go to create a template in the tree called Blah and the default rendering engine is MVC, it will create a Blah.cshtml
|
|
|
|
|
/// empty template in ~/Views. This means every page that is using Blah will go to MVC and render an empty page.
|
|
|
|
|
/// This is mostly related to installing packages since packages install file templates to the file system and then create the
|
|
|
|
|
/// templates in business logic. Without this, it could cause the wrong rendering engine to be used for a package.
|
|
|
|
|
/// </remarks>
|
|
|
|
|
RenderingEngine DetermineTemplateRenderingEngine(ITemplate template);
|
2012-10-24 11:29:51 -02:00
|
|
|
}
|
|
|
|
|
}
|