--HG--
branch : 1.x
This commit is contained in:
Dave Reed
2011-04-07 10:16:34 -07:00
6 changed files with 20 additions and 25 deletions

View File

@@ -50,7 +50,7 @@ namespace Orchard.Core.Containers.Drivers {
var listItems = new[] { new SelectListItem { Text = T("(None)").Text, Value = "0" } } var listItems = new[] { new SelectListItem { Text = T("(None)").Text, Value = "0" } }
.Concat(containers.Select(x => new SelectListItem { .Concat(containers.Select(x => new SelectListItem {
Value = Convert.ToString(x.Id), Value = Convert.ToString(x.Id),
Text = x.ContentItem.TypeDefinition.DisplayName + ": " + x.As<IRoutableAspect>().Title, Text = x.ContentItem.TypeDefinition.DisplayName + ": " + _contentManager.GetItemMetadata(x.ContentItem).DisplayText,
Selected = x.Id == model.ContainerId, Selected = x.Id == model.ContainerId,
})) }))
.ToList(); .ToList();

View File

@@ -311,7 +311,7 @@ namespace Lists.Controllers {
// ensure the item can be in that container. // ensure the item can be in that container.
if (!string.IsNullOrEmpty(itemContentType) && item.ContentType != itemContentType) { if (!string.IsNullOrEmpty(itemContentType) && item.ContentType != itemContentType) {
Services.TransactionManager.Cancel(); Services.TransactionManager.Cancel();
Services.Notifier.Information(T("One or more items could not be moved to '{0}' because it is restricted to containing items of type '{1}'.", _contentManager.GetItemMetadata(targetContainer).DisplayText, itemContentType)); Services.Notifier.Information(T("One or more items could not be moved to '{0}' because it is restricted to containing items of type '{1}'.", _contentManager.GetItemMetadata(targetContainer).DisplayText ?? targetContainer.ContentItem.ContentType, itemContentType));
return true; // todo: transactions return true; // todo: transactions
} }
@@ -319,7 +319,7 @@ namespace Lists.Controllers {
FixItemPath(item); FixItemPath(item);
} }
Services.Notifier.Information(T("Content successfully moved to <a href=\"{0}\">{1}</a>.", Services.Notifier.Information(T("Content successfully moved to <a href=\"{0}\">{1}</a>.",
Url.Action("List", new { containerId = targetContainerId }), _contentManager.GetItemMetadata(targetContainer).DisplayText)); Url.Action("List", new { containerId = targetContainerId }), _contentManager.GetItemMetadata(targetContainer).DisplayText ?? targetContainer.ContentItem.ContentType));
return true; return true;
} }

View File

@@ -8,14 +8,14 @@
var targetContainers = ((IEnumerable<ContentItem>)Model.Containers).Select( var targetContainers = ((IEnumerable<ContentItem>)Model.Containers).Select(
contentItem => new SelectListItem { contentItem => new SelectListItem {
Text = T("Move to {0}", contentItem.ContentManager.GetItemMetadata(contentItem).DisplayText).ToString(), Text = T("Move to {0}", contentItem.ContentManager.GetItemMetadata(contentItem).DisplayText ?? contentItem.ContentType).ToString(),
Value = contentItem.Id.ToString(System.Globalization.CultureInfo.InvariantCulture), Value = contentItem.Id.ToString(System.Globalization.CultureInfo.InvariantCulture),
Selected = contentItem.Id == targetContainerId Selected = contentItem.Id == targetContainerId
}).ToList(); }).ToList();
var sourceContainers = ((IEnumerable<ContentItem>)Model.Containers).Select( var sourceContainers = ((IEnumerable<ContentItem>)Model.Containers).Select(
contentItem => new SelectListItem { contentItem => new SelectListItem {
Text = contentItem.ContentManager.GetItemMetadata(contentItem).DisplayText, Text = contentItem.ContentManager.GetItemMetadata(contentItem).DisplayText ?? contentItem.ContentType,
Value = contentItem.Id.ToString(System.Globalization.CultureInfo.InvariantCulture), Value = contentItem.Id.ToString(System.Globalization.CultureInfo.InvariantCulture),
Selected = contentItem.Id == sourceContainerId Selected = contentItem.Id == sourceContainerId
}).ToList(); }).ToList();

View File

@@ -31,15 +31,16 @@
</div> </div>
@using (Html.BeginFormAntiForgeryPost()) { @using (Html.BeginFormAntiForgeryPost()) {
var options = (ContentOptions) Model.Options;
<fieldset class="bulk-actions"> <fieldset class="bulk-actions">
<label for="publishActions">@T("Actions:")</label> <label for="publishActions">@T("Actions:")</label>
<select id="publishActions" name="Options.BulkAction"> <select id="publishActions" name="Options.BulkAction">
@Html.SelectOption((ContentsBulkAction)Model.Options.BulkAction, ContentsBulkAction.None, T("Choose action...").ToString()) @Html.SelectOption(options.BulkAction, ContentsBulkAction.None, T("Choose action...").ToString())
@Html.SelectOption((ContentsBulkAction)Model.Options.BulkAction, ContentsBulkAction.PublishNow, T("Publish Now").ToString()) @Html.SelectOption(options.BulkAction, ContentsBulkAction.PublishNow, T("Publish Now").ToString())
@Html.SelectOption((ContentsBulkAction)Model.Options.BulkAction, ContentsBulkAction.Unpublish, T("Unpublish").ToString()) @Html.SelectOption(options.BulkAction, ContentsBulkAction.Unpublish, T("Unpublish").ToString())
@Html.SelectOption((ContentsBulkAction)Model.Options.BulkAction, ContentsBulkAction.Remove, T("Delete").ToString()) @Html.SelectOption(options.BulkAction, ContentsBulkAction.Remove, T("Delete").ToString())
@Html.SelectOption((ContentsBulkAction)Model.Options.BulkAction, ContentsBulkAction.RemoveFromList, T("Remove from List").ToString()) @Html.SelectOption(options.BulkAction, ContentsBulkAction.RemoveFromList, T("Remove from List").ToString())
@Html.SelectOption((ContentsBulkAction)Model.Options.BulkAction, ContentsBulkAction.MoveToList, T("Move to List...").ToString()) @Html.SelectOption(options.BulkAction, ContentsBulkAction.MoveToList, T("Move to List...").ToString())
</select> </select>
@Html.DropDownList("TargetContainerId", lists, new { id = "TargetContainerId" }) @Html.DropDownList("TargetContainerId", lists, new { id = "TargetContainerId" })
<button type="submit" name="submit.BulkEdit" value="yes">@T("Apply")</button> <button type="submit" name="submit.BulkEdit" value="yes">@T("Apply")</button>

View File

@@ -233,16 +233,8 @@ namespace Orchard.Media.Controllers {
} }
} }
public ActionResult EditMedia(string name, DateTime lastUpdated, long size, string folderName, string mediaPath) { public ActionResult EditMedia(MediaItemEditViewModel model) {
var model = new MediaItemEditViewModel(); model.PublicUrl = _mediaService.GetPublicUrl(Path.Combine(model.MediaPath, model.Name));
model.Name = name;
// todo: reimplement
//model.Caption = caption ?? String.Empty;
model.LastUpdated = lastUpdated;
model.Size = size;
model.FolderName = folderName;
model.MediaPath = mediaPath;
model.PublicUrl = _mediaService.GetPublicUrl(Path.Combine(mediaPath, name));
return View(model); return View(model);
} }
@@ -293,9 +285,8 @@ namespace Orchard.Media.Controllers {
mediaPath = viewModel.MediaPath }); mediaPath = viewModel.MediaPath });
} }
catch (Exception exception) { catch (Exception exception) {
this.Error(exception, T("Editing media file failed: {0}", exception.Message), Logger, Services.Notifier); this.Error(exception, T("Editing media file failed."), Logger, Services.Notifier);
return EditMedia(viewModel);
return View(viewModel);
} }
} }
} }

View File

@@ -140,7 +140,10 @@ namespace Orchard.Media.Services {
Argument.ThrowIfNullOrEmpty(newFileName, "newFileName"); Argument.ThrowIfNullOrEmpty(newFileName, "newFileName");
if (!FileAllowed(newFileName, false)) { if (!FileAllowed(newFileName, false)) {
throw new ArgumentException(T("New file name {0} is not allowed", newFileName).ToString()); if (string.IsNullOrEmpty(Path.GetExtension(newFileName))) {
throw new ArgumentException(T("New file name \"{0}\" is not allowed. Please provide a file extension.", newFileName).ToString());
}
throw new ArgumentException(T("New file name \"{0}\" is not allowed.", newFileName).ToString());
} }
_storageProvider.RenameFile(_storageProvider.Combine(folderPath, currentFileName), _storageProvider.Combine(folderPath, newFileName)); _storageProvider.RenameFile(_storageProvider.Combine(folderPath, currentFileName), _storageProvider.Combine(folderPath, newFileName));