Skip to content

Commit

Permalink
updated module
Browse files Browse the repository at this point in the history
  • Loading branch information
w8tcha committed Nov 12, 2023
1 parent 2a5c69a commit 2525693
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 14 deletions.
47 changes: 35 additions & 12 deletions yaf_dnn/Components/WebAPI/AlbumController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,44 @@ public class AlbumController : DnnApiController, IHaveServiceLocator
public IServiceLocator ServiceLocator => BoardContext.Current.ServiceLocator;

/// <summary>
/// The change image caption.
/// Change the album title.
/// </summary>
/// <param name="jsonData">
/// The JSON Data.
/// </param>
/// <returns>
/// the return object.
/// </returns>
[DnnAuthorize]
[HttpPost]
public IHttpActionResult ChangeImageCaption(JObject jsonData)
public IHttpActionResult ChangeAlbumTitle()
{
dynamic json = jsonData;
var imageId = this.Get<HttpRequestBase>().Form["id"].ToType<int>();
var newCaption = HttpUtility.HtmlEncode(this.Get<HttpRequestBase>().Form["value"].Trim());

if (newCaption.Equals(this.Get<ILocalization>().GetText("ALBUM_CHANGE_TITLE")))
{
return this.Ok();
}

this.Get<IAlbum>().ChangeAlbumTitle(imageId, newCaption);

return this.Ok();
}

/// <summary>
/// Change the album image caption.
/// </summary>
[DnnAuthorize]
[HttpPost]
public IHttpActionResult ChangeImageCaption()
{
var imageId = this.Get<HttpRequestBase>().Form["id"].ToType<int>();
var newCaption = HttpUtility.HtmlEncode(this.Get<HttpRequestBase>().Form["value"].Trim());

if (newCaption.Equals(this.Get<ILocalization>().GetText("ALBUM_IMAGE_CHANGE_CAPTION"))
|| newCaption.Equals(this.Get<ILocalization>().GetText("ALBUM_IMAGE_CHANGE_CAPTION2")))
{
return this.Ok();
}

this.Get<IAlbum>().ChangeImageCaption(imageId, newCaption);

return this.Ok(this.Get<IAlbum>().ChangeImageCaption((int)json.ImageId, (string)json.NewCaption));
return this.Ok();
}

/// <summary>
Expand Down Expand Up @@ -88,9 +111,9 @@ public IHttpActionResult GetAlbumImages(PagedResults pagedResults)
var attachment = new AttachmentItem
{
FileName = image.FileName,
OnClick = $"CKEDITOR.tools.insertAlbumImage('{image.ID}')",
OnClick = $"setStyle('AlbumImgId', '{image.ID}')",
IconImage =
$@"<img class=""popupitemIcon"" src=""{url}"" alt=""{(image.Caption.IsSet() ? image.Caption : image.FileName)}"" title=""{(image.Caption.IsSet() ? image.Caption : image.FileName)}"" class=""img-fluid img-thumbnail me-1"" />",
$"""<img src="{url}" alt="{(image.Caption.IsSet() ? image.Caption : image.FileName)}" title="{(image.Caption.IsSet() ? image.Caption : image.FileName)}" class="img-fluid img-thumbnail me-1 attachments-preview" />""",
DataURL = url
};

Expand Down
4 changes: 2 additions & 2 deletions yaf_dnn/Components/WebAPI/AttachmentController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,13 @@ public IHttpActionResult GetAttachments([FromBody] PagedResults pagedResults)
var description = $"{attach.FileName} ({attach.Bytes / 1024} kb)";

var iconImage = attach.FileName.IsImageName()
? $@"<img class=""popupitemIcon"" src=""{url}"" alt=""{description}"" title=""{description}"" class=""img-fluid img-thumbnail me-1"" />"
? $@"<img src=""{url}"" alt=""{description}"" title=""{description}"" class=""img-fluid img-thumbnail me-1 attachments-preview"" />"
: "<i class=\"far fa-file-alt attachment-icon\"></i>";

var attachment = new AttachmentItem
{
FileName = attach.FileName,
OnClick = $"CKEDITOR.tools.insertAttachment('{attach.ID}')",
OnClick = $"insertAttachment('{attach.ID}', '{url}')",
IconImage = $@"{iconImage}<span>{description}</span>"
};

Expand Down

0 comments on commit 2525693

Please sign in to comment.