Skip to content

Add content types to notices#5072

Open
ThoWagen wants to merge 1 commit intovufind-org:devfrom
ThoWagen:pull-request/add-content-types-to-notices
Open

Add content types to notices#5072
ThoWagen wants to merge 1 commit intovufind-org:devfrom
ThoWagen:pull-request/add-content-types-to-notices

Conversation

@ThoWagen
Copy link
Contributor

This PR adds the option for notices to allow HTML or Markdown.

It also makes all messages translatable using the normal language files.

Copy link
Member

@demiankatz demiankatz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @ThoWagen, this makes sense to me, but see below for some minor comments.

/**
* Apply encoding to the content based on the provided content type.
*
* @param string $contentType Content type
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we list legal values here?

Suggested change
* @param string $contentType Content type
* @param string $contentType Content type (text, html, or markdown)

* @param Markdown $markdownHelper Markdown view helper
*/
protected $contextHelper;
public function __construct(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably target this branch against dev-12.0 due to the BC-breaking changes to this helper... unless you feel strongly that we should roll this out early with a changelog warning. (I could be persuaded either way; I think it's relatively unlikely that anyone has locally extended the helper, but it's good to be fairly strict about semantic versioning when we can be).

$content = ($this->escapeHtml)($content);
$content = $this->contentHelper->handleContentType(
$notice['contentType'] ?? 'text',
$this->translate($content)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible there might be scenarios where we would not want to translate the content? (Certainly, passing a big chunk of markdown as a translation key isn't going to work -- though it shouldn't cause harm either). Might we want a config setting to explicitly toggle translation, or is that overkill?

'component' => 'VuFind\View\Helper\Root\Component',
'config' => 'VuFind\View\Helper\Root\Config',
'content' => 'VuFind\View\Helper\Root\Content',
'content' => \VuFind\View\Helper\Root\Content::class,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're going to make this change, maybe it would be best to do a separate PR to just universally adjust the style, rather than doing it piecemeal. I think @LuomaJuha was thinking of such a thing at one point, though I'm not sure if it's still on his to-do list somewhere.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants