--- /dev/null
+<?php
+namespace wcf\system\template\plugin;
+use wcf\data\user\UserProfile;
+use wcf\system\template\TemplateEngine;
+use wcf\util\ClassUtil;
+use wcf\util\StringUtil;
+
+/**
+ * Template function plugin which generates links to user profiles.
+ *
+ * Attributes:
+ * - `object` (required) has to be a (decorated) `UserProfile` object.
+ * - `type` (optional) supports the following values:
+ * - `default` (default value) generates a link with the formatted username with popover support.
+ * - `avatarXY` generates a link with the user's avatar in size `XY`.
+ * - `plain` generates a link link without username formatting and popover support
+ * - `append` (optional) is appended to the user link.
+ *
+ * All other additional parameter values are added as attributes to the `a` element. Parameter names
+ * in camel case are changed to kebab case (`fooBar` becomes `foo-bar`).
+ *
+ * Usage:
+ * {user object=$user}
+ * {user object=$user type='plain'}
+ * {user object=$user type='avatar48'}
+ * {user object=$user append='#wall'}
+ *
+ * @author Matthias Schmidt
+ * @copyright 2001-2020 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package WoltLabSuite\Core\System\Template\Plugin
+ * @since 5.3
+ */
+class UserFunctionTemplatePlugin implements IFunctionTemplatePlugin {
+ /**
+ * @inheritDoc
+ */
+ public function execute($tagArgs, TemplateEngine $tplObj) {
+ if (!isset($tagArgs['object'])) {
+ throw new \InvalidArgumentException("Missing 'object' attribute.");
+ }
+
+ $object = $tagArgs['object'];
+ unset($tagArgs['object']);
+ if (!($object instanceof UserProfile) && !ClassUtil::isDecoratedInstanceOf($object, UserProfile::class)) {
+ throw new \InvalidArgumentException("'object' attribute is no '" . UserProfile::class . "' object.");
+ }
+
+ $additionalParameters = '';
+ $content = '';
+ if (isset($tagArgs['type'])) {
+ $type = $tagArgs['type'];
+ unset($tagArgs['type']);
+
+ if ($type === 'plain') {
+ $content = $object->getTitle();
+ }
+ else if (preg_match('~^avatar(\d+)$~', $type, $matches)) {
+ $content = $object->getAvatar()->getImageTag($matches[1]);
+ }
+ else if ($type !== 'default') {
+ throw new \InvalidArgumentException("Unknown 'type' value '{$type}'.");
+ }
+ }
+
+ // default case
+ if ($content === '') {
+ $additionalParameters = ' data-object-id="' . $object->getObjectID() . '"';
+ $content = $object->getFormattedUsername();
+ if (isset($tagArgs['class'])) {
+ $tagArgs['class'] = 'userLink ' . $tagArgs['class'];
+ }
+ else {
+ $tagArgs['class'] = 'userLink';
+ }
+ }
+
+ $append = '';
+ if (isset($tagArgs['append'])) {
+ $append = $tagArgs['append'];
+ unset($tagArgs['append']);
+ }
+
+ foreach ($tagArgs as $name => $value) {
+ if (!preg_match('~^[a-z]+([A-z]+)+$~', $name)) {
+ throw new \InvalidArgumentException("Invalid additional argument name '{$name}'.");
+ }
+
+ $additionalParameters .= ' ' . strtolower(preg_replace('~([A-Z])~', '-$1', $name))
+ . '="' . StringUtil::encodeHTML($value) . '"';
+ }
+
+ return '<a href="' . StringUtil::encodeHTML($object->getLink() . $append) . '"' . $additionalParameters . '>' . $content . '</a>';
+ }
+}
<item name="wcf.acp.group.option.user.signature.disallowedBBCodes.description"><![CDATA[Die hier ausgewählten BBCodes dürfen von Mitgliedern dieser Benutzergruppe in ihrer Signatur <em>nicht</em> verwendet werden.]]></item>
<item name="wcf.acp.group.priority"><![CDATA[Priorisierung]]></item>
<item name="wcf.acp.group.priority.description"><![CDATA[Bestimmt u.a. die Reihenfolge auf der Team-Seite sowie die Auswahl von Benutzerrängen und „Wer ist online“-Darstellungen auf Basis der höchsten Priorität.]]></item>
- <item name="wcf.acp.group.userOnlineMarking"><![CDATA[„Benutzer online“-Darstellung]]></item>
- <item name="wcf.acp.group.userOnlineMarking.description"><![CDATA[{if LANGUAGE_USE_INFORMAL_VARIANT}Du kannst{else}Sie können{/if} die HTML-Formatierung für Mitglieder dieser Benutzergruppe in der „Wer ist online“-Anzeige anpassen. <em><strong>%s</strong></em> stellt Mitglieder dieser Gruppe beispielsweise in Fettdruck dar.]]></item>
+ <item name="wcf.acp.group.userOnlineMarking"><![CDATA[Benutzer-Darstellung]]></item>
+ <item name="wcf.acp.group.userOnlineMarking.description"><![CDATA[{if LANGUAGE_USE_INFORMAL_VARIANT}Du kannst{else}Sie können{/if} die HTML-Formatierung für Mitglieder dieser Benutzergruppe anpassen. <em><strong>%s</strong></em> stellt Mitglieder dieser Gruppe beispielsweise in Fettdruck dar.]]></item>
<item name="wcf.acp.group.userOnlineMarking.error.invalid"><![CDATA[Die Darstellung muss „%s“ enthalten]]></item>
<item name="wcf.acp.group.showOnTeamPage"><![CDATA[Mitglieder dieser Benutzergruppe auf der Team-Seite anzeigen]]></item>
<item name="wcf.acp.group.option.admin.user.canEnableUser"><![CDATA[Kann Benutzer aktivieren]]></item>
<item name="wcf.acp.group.option.user.signature.disallowedBBCodes.description"><![CDATA[Selected BBCodes <em>cannot</em> be used in the signature.]]></item>
<item name="wcf.acp.group.priority"><![CDATA[Priority]]></item>
<item name="wcf.acp.group.priority.description"><![CDATA[Determines the display order on the team page, user rank, and ‘users online’ marking based on highest priority.]]></item>
- <item name="wcf.acp.group.userOnlineMarking"><![CDATA[Users Online Marking]]></item>
- <item name="wcf.acp.group.userOnlineMarking.description"><![CDATA[Adjust the HTML formatting for members of this user group in the ‘users online’ list. <em><strong>%s</strong></em> results in a bolder appearance.]]></item>
+ <item name="wcf.acp.group.userOnlineMarking"><![CDATA[User Marking]]></item>
+ <item name="wcf.acp.group.userOnlineMarking.description"><![CDATA[Adjust the HTML formatting for members of this user group. <em><strong>%s</strong></em> results in a bolder appearance.]]></item>
<item name="wcf.acp.group.userOnlineMarking.error.invalid"><![CDATA[There must be an occurrence of “%s”.]]></item>
<item name="wcf.acp.group.showOnTeamPage"><![CDATA[Display members on team page]]></item>
<item name="wcf.acp.group.option.admin.user.canEnableUser"><![CDATA[Can approve users]]></item>