GridViewColumn::for('userAgent')
->label('wcf.user.userAgent')
->sortable()
+ ->valueEncoding(false)
->renderer(new TruncatedTextColumnRenderer())
->filter(new TextFilter()),
GridViewColumn::for('time')
use wcf\system\gridView\action\IGridViewAction;
use wcf\system\request\LinkHandler;
use wcf\system\WCF;
+use wcf\util\StringUtil;
/**
* Abstract implementation of a grid view.
*/
public function renderColumn(GridViewColumn $column, mixed $row): string
{
- $value = $column->render($this->getData($row, $column->getID()), $row);
+ $value = $this->getData($row, $column->getID());
+ if ($column->encodeValue()) {
+ $value = StringUtil::encodeHTML($value);
+ }
+
+ $value = $column->render($value, $row);
if (isset($this->rowLink) && $column->applyRowLink()) {
$value = $this->rowLink->render($value, $row, $column->isTitleColumn());
private string $sortById = '';
private ?IGridViewFilter $filter = null;
private bool $hidden = false;
+ private bool $valueEncoding = true;
private function __construct(private readonly string $id) {}
return $this->hidden;
}
+ /**
+ * Determines whether the value of this column should be encoded before rendering.
+ */
+ public function valueEncoding(bool $valueEncoding = true): static
+ {
+ $this->valueEncoding = $valueEncoding;
+
+ return $this;
+ }
+
+ /**
+ * Returns true if the value of this column should be encoded before rendering.
+ */
+ public function encodeValue(): bool
+ {
+ return $this->valueEncoding;
+ }
+
/**
* Returns true if the row link should be applied to this column.
*/
#[\Override]
public function render(mixed $value, mixed $context = null): string
{
- return StringUtil::encodeHTML($value);
+ return $value;
}
#[\Override]
#[\Override]
public function render(mixed $value, mixed $context = null): string
{
- return \sprintf('<a href="mailto:%s">%s</a>', StringUtil::encodeHTML($value), StringUtil::encodeHTML($value));
+ return \sprintf('<a href="mailto:%s">%s</a>', $value, $value);
}
}
return '';
}
- return StringUtil::encodeHTML(UserUtil::convertIPv6To4($value));
+ return UserUtil::convertIPv6To4($value);
}
}
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @since 6.2
*/
-class LinkColumnRenderer extends AbstractColumnRenderer implements ILinkColumnRenderer
+class LinkColumnRenderer extends DefaultColumnRenderer implements ILinkColumnRenderer
{
public function __construct(
private readonly string $controllerClass,
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @since 6.2
*/
-abstract class ObjectLinkColumnRenderer extends AbstractColumnRenderer implements ILinkColumnRenderer
+abstract class ObjectLinkColumnRenderer extends DefaultColumnRenderer implements ILinkColumnRenderer
{
public function __construct(
private readonly string $controllerClass = '',
#[\Override]
public function render(mixed $value, mixed $context = null): string
{
- return StringUtil::encodeHTML(WCF::getLanguage()->get($value));
+ return WCF::getLanguage()->get($value);
}
}
use wcf\util\StringUtil;
/**
- * Formats the content of a column as a user.
+ * Formats the content of a column as a user. The value of the column must be a user id.
*
* @author Marcel Werk
* @copyright 2001-2024 WoltLab GmbH
use wcf\system\cache\runtime\UserRuntimeCache;
/**
- * Formats the content of a column as a user link.
+ * Formats the content of a column as a user link. The value of the column must be a user id.
*
* @author Marcel Werk
* @copyright 2001-2024 WoltLab GmbH