mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-26 20:16:15 +08:00
Initializing localizer
Adding information notifications Adding localization invocations where necessary Replacing tabs for spaces in views --HG-- branch : dev
This commit is contained in:
@@ -5,6 +5,10 @@ namespace Orchard.Media {
|
||||
public class AdminMenu : INavigationProvider {
|
||||
public Localizer T { get; set; }
|
||||
|
||||
public AdminMenu() {
|
||||
T = NullLocalizer.Instance;
|
||||
}
|
||||
|
||||
public string MenuName { get { return "admin"; } }
|
||||
|
||||
public void GetNavigation(NavigationBuilder builder) {
|
||||
@@ -13,4 +17,4 @@ namespace Orchard.Media {
|
||||
.Permission(Permissions.ManageMediaFiles)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,8 @@ namespace Orchard.Media.Controllers {
|
||||
public AdminController(IOrchardServices services, IMediaService mediaService) {
|
||||
Services = services;
|
||||
_mediaService = mediaService;
|
||||
|
||||
T = NullLocalizer.Instance;
|
||||
}
|
||||
|
||||
public IOrchardServices Services { get; set;}
|
||||
@@ -61,6 +63,8 @@ namespace Orchard.Media.Controllers {
|
||||
UpdateModel(viewModel);
|
||||
|
||||
_mediaService.CreateFolder(viewModel.MediaPath, viewModel.Name);
|
||||
|
||||
Services.Notifier.Information(T("Media folder created"));
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
catch (Exception exception) {
|
||||
@@ -86,6 +90,8 @@ namespace Orchard.Media.Controllers {
|
||||
if (!Services.Authorizer.Authorize(Permissions.ManageMediaFiles, T("Couldn't delete media file")))
|
||||
return new HttpUnauthorizedResult();
|
||||
_mediaService.DeleteFile(fileName, folderName);
|
||||
|
||||
Services.Notifier.Information(T("Media file deleted"));
|
||||
}
|
||||
else if (key.StartsWith("Checkbox.Folder.") && input[key] == "true") {
|
||||
string folderName = key.Substring("Checkbox.Folder.".Length);
|
||||
@@ -93,6 +99,8 @@ namespace Orchard.Media.Controllers {
|
||||
if (!Services.Authorizer.Authorize(Permissions.ManageMediaFiles, T("Couldn't delete media folder")))
|
||||
return new HttpUnauthorizedResult();
|
||||
_mediaService.DeleteFolder(folderPath);
|
||||
|
||||
Services.Notifier.Information(T("Media folder deleted"));
|
||||
}
|
||||
}
|
||||
return RedirectToAction("Index");
|
||||
@@ -120,10 +128,11 @@ namespace Orchard.Media.Controllers {
|
||||
|
||||
_mediaService.DeleteFolder(viewModel.MediaPath);
|
||||
|
||||
Services.Notifier.Information(T("Media folder deleted"));
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
catch (Exception exception) {
|
||||
Services.Notifier.Error(T("Modifying Folder Properties failed: {0}", exception.Message));
|
||||
Services.Notifier.Error(T("Deleting media folder failed: {0}", exception.Message));
|
||||
return View(viewModel);
|
||||
}
|
||||
}
|
||||
@@ -140,9 +149,10 @@ namespace Orchard.Media.Controllers {
|
||||
|
||||
_mediaService.RenameFolder(viewModel.MediaPath, viewModel.Name);
|
||||
|
||||
Services.Notifier.Information(T("Media folder properties modified"));
|
||||
return RedirectToAction("Index");
|
||||
} catch (Exception exception) {
|
||||
Services.Notifier.Error(T("Modifying Folder Properties failed: {0}", exception.Message));
|
||||
Services.Notifier.Error(T("Modifying media folder properties failed: {0}", exception.Message));
|
||||
return View(viewModel);
|
||||
}
|
||||
}
|
||||
@@ -182,6 +192,7 @@ namespace Orchard.Media.Controllers {
|
||||
_mediaService.UploadMediaFile(viewModel.MediaPath, file);
|
||||
}
|
||||
|
||||
Services.Notifier.Information(T("Media file(s) uploaded"));
|
||||
return RedirectToAction("Edit", new { name = viewModel.FolderName, mediaPath = viewModel.MediaPath });
|
||||
}
|
||||
catch (Exception exception) {
|
||||
@@ -244,6 +255,8 @@ namespace Orchard.Media.Controllers {
|
||||
UpdateModel(viewModel);
|
||||
|
||||
_mediaService.DeleteFile(viewModel.Name, viewModel.MediaPath);
|
||||
|
||||
Services.Notifier.Information(T("Media deleted"));
|
||||
return RedirectToAction("Edit", new { name = viewModel.FolderName, mediaPath = viewModel.MediaPath });
|
||||
} catch (Exception exception) {
|
||||
Services.Notifier.Error(T("Removing media file failed: {0}", exception.Message));
|
||||
@@ -268,6 +281,7 @@ namespace Orchard.Media.Controllers {
|
||||
viewModelName = input["NewName"];
|
||||
}
|
||||
|
||||
Services.Notifier.Information(T("Media information updated"));
|
||||
return RedirectToAction("EditMedia", new { name = viewModelName,
|
||||
caption = viewModel.Caption,
|
||||
lastUpdated = viewModel.LastUpdated,
|
||||
|
||||
@@ -25,4 +25,4 @@ namespace Orchard.Media.Helpers {
|
||||
return navigations;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
using Orchard.ContentManagement;
|
||||
using System;
|
||||
|
||||
namespace Orchard.Media.Models {
|
||||
public class MediaSettingsPart : ContentPart<MediaSettingsPartRecord> {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System.Net.Mail;
|
||||
using Orchard.ContentManagement.Records;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Orchard.ContentManagement.Records;
|
||||
|
||||
namespace Orchard.Media.Models {
|
||||
public class MediaSettingsPartRecord : ContentPartRecord {
|
||||
|
||||
@@ -6,7 +6,7 @@ using ICSharpCode.SharpZipLib.Zip;
|
||||
using JetBrains.Annotations;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.FileSystems.Media;
|
||||
using Orchard.Logging;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Media.Models;
|
||||
|
||||
namespace Orchard.Media.Services {
|
||||
@@ -18,10 +18,11 @@ namespace Orchard.Media.Services {
|
||||
public MediaService(IStorageProvider storageProvider, IOrchardServices orchardServices) {
|
||||
_storageProvider = storageProvider;
|
||||
_orchardServices = orchardServices;
|
||||
Logger = NullLogger.Instance;
|
||||
|
||||
T = NullLocalizer.Instance;
|
||||
}
|
||||
|
||||
public ILogger Logger { get; set; }
|
||||
public Localizer T { get; set; }
|
||||
|
||||
public string GetPublicUrl(string path) {
|
||||
return _storageProvider.GetPublicUrl(path);
|
||||
@@ -84,7 +85,7 @@ namespace Orchard.Media.Services {
|
||||
|
||||
public void RenameFile(string name, string newName, string folderName) {
|
||||
if (!FileAllowed(newName, false)) {
|
||||
throw new ArgumentException("New file name " + newName + " not allowed.");
|
||||
throw new ArgumentException(T("New file name {0} not allowed", newName).ToString());
|
||||
}
|
||||
|
||||
_storageProvider.RenameFile(_storageProvider.Combine(folderName, name), _storageProvider.Combine(folderName, newName));
|
||||
|
||||
@@ -17,12 +17,12 @@
|
||||
<fieldset>
|
||||
<label for="pageTitle">@T("File Path <span> - multiple files must be in a zipped folder</span>")</label>
|
||||
<input id="MediaItemPath" name="MediaItemPath" type="file" value="@T("Browse")" size="64"/>
|
||||
<span class="hint">@T("After your files have been uploaded, you can edit the titles and descriptions.")</span>
|
||||
<span class="hint">@T("After your files have been uploaded, you can edit the titles and descriptions.")</span>
|
||||
<input type="hidden" id="FolderName" name="FolderName" value="@Model.FolderName" />
|
||||
<input type="hidden" id="MediaPath" name="MediaPath" value="@Model.MediaPath" />
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<button class="primaryAction" type="submit">@T("Upload")</button>
|
||||
@Html.AntiForgeryTokenOrchard()
|
||||
</fieldset>
|
||||
@Html.AntiForgeryTokenOrchard()
|
||||
</fieldset>
|
||||
}
|
||||
@@ -6,20 +6,20 @@
|
||||
<h1>@Html.TitleForPage(T("Add a Folder").ToString())</h1>
|
||||
<div class="breadCrumbs">
|
||||
<p>@Html.ActionLink(T("Media Folders").ToString(), "Index") >
|
||||
@foreach (FolderNavigation navigation in MediaHelpers.GetFolderNavigationHierarchy(Model.MediaPath)) {
|
||||
@Html.ActionLink(navigation.FolderName, "Edit", new {name = navigation.FolderName, mediaPath = navigation.FolderPath}) <text>></text>
|
||||
}
|
||||
@T("Add a Folder") </p>
|
||||
@foreach (FolderNavigation navigation in MediaHelpers.GetFolderNavigationHierarchy(Model.MediaPath)) {
|
||||
@Html.ActionLink(navigation.FolderName, "Edit", new {name = navigation.FolderName, mediaPath = navigation.FolderPath}) <text>></text>
|
||||
}
|
||||
@T("Add a Folder") </p>
|
||||
</div>
|
||||
|
||||
|
||||
@using (Html.BeginFormAntiForgeryPost()) {
|
||||
@Html.ValidationSummary()
|
||||
<fieldset>
|
||||
<label for="Name">@T("Folder Name")</label>
|
||||
<input id="Name" class="textMedium" name="Name" type="text" />
|
||||
<input type="hidden" id="MediaPath" name="MediaPath" value="@Model.MediaPath" />
|
||||
<input id="Name" class="textMedium" name="Name" type="text" />
|
||||
<input type="hidden" id="MediaPath" name="MediaPath" value="@Model.MediaPath" />
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<fieldset>
|
||||
<button class="primaryAction" type="submit">@T("Save")</button>
|
||||
</fieldset>
|
||||
}
|
||||
@@ -24,7 +24,7 @@
|
||||
@* todo: make these real (including markup) *@
|
||||
<div>
|
||||
@* <label>@T("Dimensions: <span>500 x 375 pixels</span>")</label> *@
|
||||
|
||||
|
||||
<label>@T("Size: <span>{0}</span>", Model.Size.ToFriendlySizeString())</label>
|
||||
|
||||
<label>@T("Added on: <span>{0}</span>", Model.LastUpdated)</label>
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
@foreach (FolderNavigation navigation in MediaHelpers.GetFolderNavigationHierarchy(Model.MediaPath)) {
|
||||
@Html.ActionLink(navigation.FolderName, "Edit",
|
||||
new {name = navigation.FolderName, mediaPath = navigation.FolderPath}) <text>></text>
|
||||
|
||||
}
|
||||
@T("Folder Properties")</p>
|
||||
</div>
|
||||
@@ -18,10 +17,10 @@
|
||||
@Html.ValidationSummary()
|
||||
<fieldset>
|
||||
<label for="Name">@T("Folder Name:")</label>
|
||||
<input id="MediaPath" name="MediaPath" type="hidden" value="@Model.MediaPath" />
|
||||
<input id="Name" class="textMedium" name="Name" type="text" value="@Model.Name" />
|
||||
<input id="MediaPath" name="MediaPath" type="hidden" value="@Model.MediaPath" />
|
||||
<input id="Name" class="textMedium" name="Name" type="text" value="@Model.Name" />
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<fieldset>
|
||||
<button class="primaryAction" type="submit" name="submit.Save" value="@T("Save")">@T("Save")</button>
|
||||
<button type="submit" name="submit.Delete" value="@T("Remove")">@T("Remove")</button>
|
||||
</fieldset>
|
||||
|
||||
Reference in New Issue
Block a user