use wcf\system\exception\PermissionDeniedException;
use wcf\system\exception\UserInputException;
use wcf\system\form\builder\Psr15DialogForm;
-use wcf\system\view\grid\AbstractGridView;
+use wcf\system\gridView\AbstractGridView;
use wcf\system\WCF;
+/**
+ * Handles the filter dialog of grid views.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2024 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @since 6.2
+ */
final class GridViewFilterAction implements RequestHandlerInterface
{
#[\Override]
use wcf\system\gridView\AbstractGridView;
use wcf\system\WCF;
+/**
+ * Abstract implementation of a page that is rendering a grid view.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2024 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @since 6.2
+ */
abstract class AbstractGridViewPage extends AbstractPage
{
protected AbstractGridView $gridView;
$this->gridView->setBaseUrl(LinkHandler::getInstance()->getControllerLink(static::class));
}
+ /**
+ * Returns the grid view instance for the rendering of this page.
+ */
protected abstract function createGridViewController(): AbstractGridView;
}
use wcf\system\exception\UserInputException;
use wcf\system\gridView\AbstractGridView;
+/**
+ * Retrieves the rows for a grid view.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2024 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @since 6.2
+ */
#[GetRequest('/core/gridViews/rows')]
final class GetRows implements IController
{
use wcf\system\request\LinkHandler;
use wcf\system\WCF;
+/**
+ * Abstract implementation of a grid view.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2024 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @since 6.2
+ */
abstract class AbstractGridView
{
/**
}
/**
+ * Returns all columns that are sortable.
+ * @return GridViewColumn[]
+ */
+ public function getSortableColumns(): array
+ {
+ return \array_filter($this->getColumns(), fn($column) => $column->isSortable());
+ }
+
+ /**
+ * Returns all columns that are filterable.
+ * @return GridViewColumn[]
+ */
+ public function getFilterableColumns(): array
+ {
+ return \array_filter($this->getColumns(), fn($column) => $column->getFilter() !== null);
+ }
+
+ /**
+ * Adds the given actions to the grid view.
* @param IGridViewAction[] $columns
*/
public function addActions(array $actions): void
}
}
+ /**
+ * Adds the given action to the grid view.
+ */
public function addAction(IGridViewAction $action): void
{
$this->actions[] = $action;
}
/**
+ * Returns all actions of the grid view.
* @return IGridViewAction[]
*/
public function getActions(): array
return $this->actions;
}
+ /**
+ * Returns true, if this grid view has actions.
+ */
public function hasActions(): bool
{
return $this->actions !== [];
}
+ /**
+ * Returns true, if this grid view has actions that should be displayed in the dropdown.
+ */
public function hasDropdownActions(): bool
{
return $this->getDropdownActions() !== [];
}
/**
+ * Returns the actions that should be displayed in the dropdown.
* @return IGridViewAction[]
*/
public function getDropdownActions(): array
}
/**
+ * Returns the quick actions.
* @return IGridViewAction[]
*/
public function getQuickActions(): array
return \array_filter($this->getActions(), fn($action) => $action->isQuickAction());
}
+ /**
+ * Renders the grid view and returns the HTML code.
+ */
public function render(): string
{
return WCF::getTPL()->fetch('shared_gridView', 'wcf', ['view' => $this], true);
}
+ /**
+ * Renders the rows and returns the HTML code.
+ */
public function renderRows(): string
{
return WCF::getTPL()->fetch('shared_gridViewRows', 'wcf', ['view' => $this], true);
}
+ /**
+ * Renders the given grid view column.
+ */
public function renderColumn(GridViewColumn $column, mixed $row): string
{
$value = $column->render($this->getData($row, $column->getID()), $row);
return $value;
}
+ /**
+ * Renders the given action.
+ */
public function renderAction(IGridViewAction $action, mixed $row): string
{
return $action->render($row);
}
+ /**
+ * Renders the initialization code for the actions of the grid view.
+ */
public function renderActionInitialization(): string
{
return implode(
);
}
+ /**
+ * Returns the row data for the given identifier.
+ */
protected function getData(mixed $row, string $identifer): mixed
{
return $row[$identifer] ?? '';
}
- public abstract function getRows(): array;
-
- public abstract function countRows(): int;
-
+ /**
+ * Counts the pages of the grid view.
+ */
public function countPages(): int
{
return \ceil($this->countRows() / $this->getRowsPerPage());
}
+ /**
+ * Returns the class name of this grid view.
+ */
public function getClassName(): string
{
return \get_class($this);
}
+ /**
+ * Returns true, if this grid view is accessible for the active user.
+ */
public function isAccessible(): bool
{
return true;
}
+ /**
+ * Returns the id of this grid view.
+ */
public function getID(): string
{
$classNamePieces = \explode('\\', static::class);
return \implode('-', $classNamePieces);
}
+ /**
+ * Sets the base url of the grid view.
+ */
public function setBaseUrl(string $url): void
{
$this->baseUrl = $url;
}
- public function getBaseUrl(): string
- {
- return $this->baseUrl;
- }
-
/**
- * @return GridViewColumn[]
+ * Returns the base url of the grid view.
*/
- public function getSortableColumns(): array
+ public function getBaseUrl(): string
{
- return \array_filter($this->getColumns(), fn($column) => $column->isSortable());
+ return $this->baseUrl;
}
/**
- * @return GridViewColumn[]
+ * Sets the sort field of the grid view.
*/
- public function getFilterableColumns(): array
- {
- return \array_filter($this->getColumns(), fn($column) => $column->getFilter() !== null);
- }
-
public function setSortField(string $sortField): void
{
if (!\in_array($sortField, \array_map(fn($column) => $column->getID(), $this->getSortableColumns()))) {
$this->sortField = $sortField;
}
+ /**
+ * Sets the sort order of the grid view.
+ */
public function setSortOrder(string $sortOrder): void
{
if ($sortOrder !== 'ASC' && $sortOrder !== 'DESC') {
$this->sortOrder = $sortOrder;
}
+ /**
+ * Returns the sort field of the grid view.
+ */
public function getSortField(): string
{
return $this->sortField;
}
+ /**
+ * Returns the sort order of the grid view.
+ */
public function getSortOrder(): string
{
return $this->sortOrder;
}
+ /**
+ * Returns the page number.
+ */
public function getPageNo(): int
{
return $this->pageNo;
}
+ /**
+ * Sets the page number.
+ */
public function setPageNo(int $pageNo): void
{
$this->pageNo = $pageNo;
}
+ /**
+ * Returns the number of rows per page.
+ */
public function getRowsPerPage(): int
{
return $this->rowsPerPage;
}
+ /**
+ * Sets the number of rows per page.
+ */
public function setRowsPerPage(int $rowsPerPage): void
{
$this->rowsPerPage = $rowsPerPage;
}
+ /**
+ * Returns true, if the grid view is filterable.
+ */
public function isFilterable(): bool
{
return $this->getFilterableColumns() !== [];
}
+ /**
+ * Returns the endpoint for the filter action.
+ */
public function getFilterActionEndpoint(): string
{
return LinkHandler::getInstance()->getControllerLink(
);
}
+ /**
+ * Sets the active filter values.
+ */
public function setActiveFilters(array $filters): void
{
$this->activeFilters = $filters;
}
+ /**
+ * Returns the active filter values.
+ */
public function getActiveFilters(): array
{
return $this->activeFilters;
}
+ /**
+ * Returns the label for the given filter.
+ */
public function getFilterLabel(string $id): string
{
$column = $this->getColumn($id);
return $column->getLabel() . ': ' . $column->getFilter()->renderValue($this->activeFilters[$id]);
}
+ /**
+ * Gets the additional parameters of the grid view.
+ */
public function getParameters(): array
{
return [];
}
+ /**
+ * Adds the given row link to the grid view.
+ */
public function addRowLink(GridViewRowLink $rowLink): void
{
$this->rowLink = $rowLink;
}
+ /**
+ * Returns the id for the given row.
+ */
public function getObjectID(mixed $row): mixed
{
return '';
}
+ /**
+ * Fires the initialized event.
+ */
protected function fireInitializedEvent(): void
{
$event = $this->getInitializedEvent();
EventHandler::getInstance()->fire($event);
}
+ /**
+ * Returns the initialized event or null if there is no such event for this grid view.
+ */
protected function getInitializedEvent(): ?IPsr14Event
{
return null;
}
+
+ /**
+ * Returns the rows for the active page.
+ */
+ public abstract function getRows(): array;
+
+ /**
+ * Returns the total number of rows.
+ */
+ public abstract function countRows(): int;
}
use wcf\system\WCF;
use wcf\util\StringUtil;
+/**
+ * Grid view for the cronjob log.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2024 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @since 6.2
+ */
final class CronjobLogGridView extends DatabaseObjectListGridView
{
public function __construct()
use LogicException;
+/**
+ * Abstract implementation of a grid view that uses an array as the data source.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2024 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @since 6.2
+ */
abstract class DataSourceGridView extends AbstractGridView
{
protected array $dataSource;
+ #[\Override]
public function getRows(): array
{
$this->sortRows();
return $this->getRowsForPage();
}
+ /**
+ * Sorts the rows.
+ */
protected function sortRows(): void
{
+ // Necessary to ensure that dataSource has been initialized.
$this->getDataSource();
\uasort($this->dataSource, function (array $a, array $b) {
});
}
+ /**
+ * Returns the rows for the active page.
+ */
protected function getRowsForPage(): array
{
return \array_slice($this->getDataSource(), ($this->getPageNo() - 1) * $this->getRowsPerPage(), $this->getRowsPerPage());
}
+ #[\Override]
public function countRows(): int
{
return \count($this->getDataSource());
}
+ /**
+ * Returns the data source array.
+ */
protected function getDataSource(): array
{
if (!isset($this->dataSource)) {
return $this->dataSource;
}
+ /**
+ * Applies the active filters.
+ */
protected function applyFilters(): void
{
foreach ($this->getActiveFilters() as $key => $value) {
}
}
+ /**
+ * Loads the data source array.
+ */
protected abstract function loadDataSource(): array;
}
use wcf\data\DatabaseObject;
use wcf\data\DatabaseObjectList;
+/**
+ * Abstract implementation of a grid view that uses a database object list as the data source.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2024 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @since 6.2
+ */
abstract class DatabaseObjectListGridView extends AbstractGridView
{
protected DatabaseObjectList $objectList;
private int $objectCount;
+ #[\Override]
public function getRows(): array
{
$this->getObjectList()->readObjects();
return $this->getObjectList()->getObjects();
}
+ #[\Override]
public function countRows(): int
{
if (!isset($this->objectCount)) {
return $this->objectCount;
}
+ #[\Override]
protected function getData(mixed $row, string $identifer): mixed
{
\assert($row instanceof DatabaseObject);
return $row->__get($identifer);
}
+ /**
+ * Initializes the database object list.
+ */
protected function initObjectList(): void
{
$this->objectList = $this->createObjectList();
$this->fireInitializedEvent();
}
+ /**
+ * Returns the database object list.
+ */
public function getObjectList(): DatabaseObjectList
{
if (!isset($this->objectList)) {
return $this->objectList;
}
+ /**
+ * Applies the active filters.
+ */
protected function applyFilters(): void
{
foreach ($this->getActiveFilters() as $key => $value) {
return $row->getObjectID();
}
+ /**
+ * Creates the database object list of this grid view.
+ */
protected abstract function createObjectList(): DatabaseObjectList;
}
use wcf\util\DirectoryUtil;
use wcf\util\ExceptionLogUtil;
+/**
+ * Grid view for the exception log.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2024 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @since 6.2
+ */
final class ExceptionLogGridView extends DataSourceGridView
{
private array $availableLogFiles;
use wcf\system\gridView\renderer\TitleColumnRenderer;
use wcf\system\WCF;
+/**
+ * Represents a column of a grid view.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2024 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @since 6.2
+ */
final class GridViewColumn
{
/**
private function __construct(private readonly string $id) {}
+ /**
+ * Creates a new column with the given id.
+ */
public static function for(string $id): static
{
return new static($id);
}
+ /**
+ * Renders the column with the given value.
+ */
public function render(mixed $value, mixed $context = null): string
{
if ($this->getRenderers() === []) {
return $value;
}
+ /**
+ * Returns the css classes of this column.
+ */
public function getClasses(): string
{
if ($this->getRenderers() === []) {
));
}
+ /**
+ * Sets the renderer of this column.
+ */
public function renderer(array|IColumnRenderer $renderers): static
{
if (!\is_array($renderers)) {
return $this;
}
+ /**
+ * Sets the label of this column.
+ */
public function label(string $languageItem): static
{
$this->label = WCF::getLanguage()->get($languageItem);
return $this;
}
+ /**
+ * Sets the sortable state of this column.
+ */
public function sortable(bool $sortable = true): static
{
$this->sortable = $sortable;
return $this;
}
+ /**
+ * Defines the ID by which this column is to be sorted.
+ */
public function sortById(string $id): static
{
$this->sortById = $id;
}
/**
+ * Returns the renderers of this column.
* @return IColumnRenderer[]
*/
public function getRenderers(): array
return $this->renderer;
}
+ /**
+ * Returns the id of this column.
+ */
public function getID(): string
{
return $this->id;
}
+ /**
+ * Returns the label of this column.
+ */
public function getLabel(): string
{
return $this->label;
}
+ /**
+ * Returns true if this column is sortable.
+ */
public function isSortable(): bool
{
return $this->sortable;
}
+ /**
+ * Returns the ID by which this column is to be sorted.
+ */
public function getSortById(): string
{
return $this->sortById;
}
+ /**
+ * Sets a filter for this column.
+ */
public function filter(?IGridViewFilter $filter): static
{
$this->filter = $filter;
return $this;
}
+ /**
+ * Returns the filter of this column.
+ */
public function getFilter(): ?IGridViewFilter
{
return $this->filter;
}
+ /**
+ * Returns the filter form field of this column.
+ */
public function getFilterFormField(): AbstractFormField
{
if ($this->getFilter() === null) {
return $this->getFilter()->getFormField($this->getID(), $this->getLabel());
}
- private static function getDefaultRenderer(): DefaultColumnRenderer
- {
- if (!isset(self::$defaultRenderer)) {
- self::$defaultRenderer = new DefaultColumnRenderer();
- }
-
- return self::$defaultRenderer;
- }
-
+ /**
+ * Returns true if this column is a title column.
+ */
public function isTitleColumn(): bool
{
foreach ($this->getRenderers() as $renderer) {
return false;
}
+ /**
+ * Sets the hidden state of this column.
+ */
public function hidden(bool $hidden = true): static
{
$this->hidden = $hidden;
return $this;
}
+ /**
+ * Returns true if this column is hidden.
+ */
public function isHidden(): bool
{
return $this->hidden;
}
+
+ /**
+ * Returns the default renderer for the rendering of columns.
+ */
+ private static function getDefaultRenderer(): DefaultColumnRenderer
+ {
+ if (!isset(self::$defaultRenderer)) {
+ self::$defaultRenderer = new DefaultColumnRenderer();
+ }
+
+ return self::$defaultRenderer;
+ }
}
use wcf\system\request\LinkHandler;
use wcf\util\StringUtil;
+/**
+ * Represents a row link of a grid view.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2024 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @since 6.2
+ */
class GridViewRowLink
{
public function __construct(
private readonly string $cssClass = ''
) {}
+ /**
+ * Renders the row link.
+ */
public function render(mixed $value, mixed $context = null, bool $isPrimaryColumn = false): string
{
$href = '';
use wcf\system\WCF;
use wcf\util\StringUtil;
+/**
+ * Grid view for the list of user options.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2024 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @since 6.2
+ */
final class UserOptionGridView extends DatabaseObjectListGridView
{
public function __construct()
use wcf\system\WCF;
use wcf\util\StringUtil;
+/**
+ * Grid view for the list of user ranks.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2024 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @since 6.2
+ */
final class UserRankGridView extends DatabaseObjectListGridView
{
public function __construct()
use Closure;
+/**
+ * Provides an abstract implementation of a grid view action.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2024 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @since 6.2
+ */
abstract class AbstractAction implements IGridViewAction
{
public function __construct(
use wcf\system\WCF;
use wcf\util\StringUtil;
+/**
+ * Represents a delete action.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2024 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @since 6.2
+ */
class DeleteAction extends AbstractAction
{
public function __construct(
use wcf\system\request\LinkHandler;
use wcf\system\WCF;
+/**
+ * Represents an edit action.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2024 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @since 6.2
+ */
class EditAction extends AbstractAction
{
public function __construct(
use wcf\system\gridView\AbstractGridView;
+/**
+ * Represents an action of a grid view.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2024 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @since 6.2
+ */
interface IGridViewAction
{
+ /**
+ * Renders the action.
+ */
public function render(mixed $row): string;
+ /**
+ * Renders the initialization code for this action.
+ */
public function renderInitialization(AbstractGridView $gridView): ?string;
+ /**
+ * Returns true if this is a quick action.
+ */
public function isQuickAction(): bool;
+ /**
+ * Returns true if this action is available for the given row.
+ */
public function isAvailable(mixed $row): bool;
}
use wcf\system\WCF;
use wcf\util\StringUtil;
+/**
+ * Represents a toggle action.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2024 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @since 6.2
+ */
class ToggleAction extends AbstractAction
{
public function __construct(
use wcf\data\DatabaseObjectList;
use wcf\system\WCF;
+/**
+ * Filter for text columns that are using i18n phrases.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2024 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @since 6.2
+ */
class I18nTextFilter extends TextFilter
{
#[\Override]
use wcf\data\DatabaseObjectList;
use wcf\system\form\builder\field\AbstractFormField;
+/**
+ * Represents a filter of a grid view.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2024 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @since 6.2
+ */
interface IGridViewFilter
{
+ /**
+ * Returns the form field for the input of this filter.
+ */
public function getFormField(string $id, string $label): AbstractFormField;
+ /**
+ * Applies the filter to the given database object list.
+ */
public function applyFilter(DatabaseObjectList $list, string $id, string $value): void;
+ /**
+ * Returns true if the given filter value matches the row.
+ */
public function matches(string $filterValue, string $rowValue): bool;
+ /**
+ * Renders the filter value in a human readable format.
+ */
public function renderValue(string $value): string;
}
use wcf\system\form\builder\field\SelectFormField;
use wcf\system\WCF;
+/**
+ * Allows a column to be filtered on the basis of a select dropdown.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2024 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @since 6.2
+ */
class SelectFilter implements IGridViewFilter
{
public function __construct(private readonly array $options) {}
use wcf\system\form\builder\field\AbstractFormField;
use wcf\system\form\builder\field\TextFormField;
+/**
+ * Filter for text columns.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2024 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @since 6.2
+ */
class TextFilter implements IGridViewFilter
{
#[\Override]
use wcf\system\form\builder\field\DateRangeFormField;
use wcf\system\WCF;
+/**
+ * Filter for time columns.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2024 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @since 6.2
+ */
class TimeFilter implements IGridViewFilter
{
#[\Override]
namespace wcf\system\gridView\renderer;
+/**
+ * Provides an abstract implementation of a column renderer.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2024 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @since 6.2
+ */
abstract class AbstractColumnRenderer implements IColumnRenderer
{
+ #[\Override]
public function getClasses(): string
{
return '';
use wcf\util\StringUtil;
+/**
+ * The default column renderer is automatically applied to all columns if no other renderers have been set.
+ * It converts special characters to HTML entities.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2024 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @since 6.2
+ */
class DefaultColumnRenderer extends AbstractColumnRenderer
{
+ #[\Override]
public function render(mixed $value, mixed $context = null): string
{
return StringUtil::encodeHTML($value);
}
+ #[\Override]
public function getClasses(): string
{
return 'gridView__column--text';
namespace wcf\system\gridView\renderer;
+/**
+ * Represents a column renderer of a grid view.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2024 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @since 6.2
+ */
interface IColumnRenderer
{
+ /**
+ * Renders the content of a column with the given value.
+ */
public function render(mixed $value, mixed $context = null): string;
+ /**
+ * Returns the css classes of a column.
+ */
public function getClasses(): string;
}
use wcf\system\request\LinkHandler;
use wcf\system\WCF;
+/**
+ * Allows the setting of a link to a column.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2024 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @since 6.2
+ */
class LinkColumnRenderer extends AbstractColumnRenderer
{
public function __construct(
private readonly string $titleLanguageItem = ''
) {}
+ #[\Override]
public function render(mixed $value, mixed $context = null): string
{
\assert($context instanceof DatabaseObject);
use wcf\util\StringUtil;
+/**
+ * Formats the content of a column as a number.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2024 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @since 6.2
+ */
class NumberColumnRenderer extends AbstractColumnRenderer
{
+ #[\Override]
public function render(mixed $value, mixed $context = null): string
{
return StringUtil::formatNumeric($value);
}
+ #[\Override]
public function getClasses(): string
{
return 'gridView__column--digits';
use wcf\system\WCF;
use wcf\util\StringUtil;
+/**
+ * Formats the content of a column as a phrase.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2024 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @since 6.2
+ */
class PhraseColumnRenderer extends DefaultColumnRenderer
{
+ #[\Override]
public function render(mixed $value, mixed $context = null): string
{
return StringUtil::encodeHTML(WCF::getLanguage()->get($value));
use wcf\system\WCF;
+/**
+ * Renders a unix timestamp into a human readable format.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2024 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @since 6.2
+ */
class TimeColumnRenderer extends AbstractColumnRenderer
{
+ #[\Override]
public function render(mixed $value, mixed $context = null): string
{
$timestamp = \intval($value);
);
}
+ #[\Override]
public function getClasses(): string
{
return 'gridView__column--date';
namespace wcf\system\gridView\renderer;
+/**
+ * Formats the content of a column as a title.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2024 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @since 6.2
+ */
class TitleColumnRenderer extends DefaultColumnRenderer
{
+ #[\Override]
public function getClasses(): string
{
return 'gridView__column--title';