From 614a6b4d911de2ec54d499c6669ee3eadaf0a39c Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Mon, 14 Mar 2016 17:56:37 +0100 Subject: [PATCH] Add {$username} and ${email} placeholders for notices --- com.woltlab.wcf/templates/userNotice.tpl | 2 +- .../install/files/acp/templates/noticeAdd.tpl | 1 + .../files/lib/data/notice/Notice.class.php | 27 +++++++++++++++---- wcfsetup/install/lang/de.xml | 1 + wcfsetup/install/lang/en.xml | 1 + 5 files changed, 26 insertions(+), 6 deletions(-) diff --git a/com.woltlab.wcf/templates/userNotice.tpl b/com.woltlab.wcf/templates/userNotice.tpl index 34c7e7d06f..3d7bc20dad 100644 --- a/com.woltlab.wcf/templates/userNotice.tpl +++ b/com.woltlab.wcf/templates/userNotice.tpl @@ -30,7 +30,7 @@ {/if} - {if $notice->noticeUseHtml}{@$notice->notice|language}{else}{@$notice->notice|language|htmlspecialchars|nl2br}{/if} + {@$notice}

{/foreach} {/content} diff --git a/wcfsetup/install/files/acp/templates/noticeAdd.tpl b/wcfsetup/install/files/acp/templates/noticeAdd.tpl index 22be48ecd3..617d44db37 100644 --- a/wcfsetup/install/files/acp/templates/noticeAdd.tpl +++ b/wcfsetup/install/files/acp/templates/noticeAdd.tpl @@ -80,6 +80,7 @@ {/if} {/if} + {lang}wcf.acp.notice.notice.description{/lang} {include file='multipleLanguageInputJavascript' elementIdentifier='notice' forceSelection=false} diff --git a/wcfsetup/install/files/lib/data/notice/Notice.class.php b/wcfsetup/install/files/lib/data/notice/Notice.class.php index 21bd84cff6..07739a8757 100644 --- a/wcfsetup/install/files/lib/data/notice/Notice.class.php +++ b/wcfsetup/install/files/lib/data/notice/Notice.class.php @@ -1,5 +1,6 @@ * @package com.woltlab.wcf * @subpackage data.notice @@ -24,26 +25,42 @@ class Notice extends DatabaseObject implements IRouteController { protected $isDismissed = null; /** - * @see \wcf\data\DatabaseObject::$databaseTableName + * @inheritDoc */ protected static $databaseTableName = 'notice'; /** - * @see \wcf\data\DatabaseObject::$databaseIndexName + * @inheritDoc */ protected static $databaseTableIndexName = 'noticeID'; + /** + * Returns the textual representation of the notice. + * + * @return string + */ + public function __toString() { + // replace `{$username}` with the active user's name and the `{$email}` with the active users' email address + $text = str_replace(['{$username}', '{$email}'], [WCF::getUser()->username, WCF::getUser()->email], WCF::getLanguage()->get($this->notice)); + + if (!$this->noticeUseHtml) { + $text = nl2br(htmlspecialchars($text)); + } + + return $text; + } + /** * Returns the conditions of the notice. * - * @return array<\wcf\data\condition\Condition> + * @return Condition[] */ public function getConditions() { return ConditionHandler::getInstance()->getConditions('com.woltlab.wcf.condition.notice', $this->noticeID); } /** - * @see \wcf\data\ITitledObject::getTitle() + * @inheritDoc */ public function getTitle() { return $this->noticeName; diff --git a/wcfsetup/install/lang/de.xml b/wcfsetup/install/lang/de.xml index 78bede918e..f5a7042b80 100644 --- a/wcfsetup/install/lang/de.xml +++ b/wcfsetup/install/lang/de.xml @@ -678,6 +678,7 @@ + {literal}{$username}{/literal} wird durch den Namen und {literal}{$email} durch die Email-Adresse des aktuellen Benutzers ersetzt.]]> diff --git a/wcfsetup/install/lang/en.xml b/wcfsetup/install/lang/en.xml index 4d80569277..05b96a7ea0 100644 --- a/wcfsetup/install/lang/en.xml +++ b/wcfsetup/install/lang/en.xml @@ -677,6 +677,7 @@ Examples for medium ID detection: + {literal}{$username}{/literal} will be replaced by the name and {literal}{$email}{/literal} by the mail address of the active user.]]> -- 2.20.1