--- /dev/null
+<?php
+
+namespace wcf\event\gridView;
+
+use wcf\event\IPsr14Event;
+use wcf\system\view\grid\CronjobLogGridView;
+
+/**
+ * Indicates that the cronjob log grid view has been initialized.
+ *
+ * @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 CronjobLogGridViewInitialized implements IPsr14Event
+{
+ public function __construct(public readonly CronjobLogGridView $gridView) {}
+}
--- /dev/null
+<?php
+
+namespace wcf\event\gridView;
+
+use wcf\event\IPsr14Event;
+use wcf\system\view\grid\ExceptionLogGridView;
+
+/**
+ * Indicates that the exception log grid view has been initialized.
+ *
+ * @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 ExceptionLogGridViewInitialized implements IPsr14Event
+{
+ public function __construct(public readonly ExceptionLogGridView $gridView) {}
+}
--- /dev/null
+<?php
+
+namespace wcf\event\gridView;
+
+use wcf\event\IPsr14Event;
+use wcf\system\view\grid\UserRankGridView;
+
+/**
+ * Indicates that the user rank grid view has been initialized.
+ *
+ * @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 UserRankGridViewInitialized implements IPsr14Event
+{
+ public function __construct(public readonly UserRankGridView $gridView) {}
+}
use LogicException;
use wcf\action\GridViewFilterAction;
+use wcf\event\IPsr14Event;
+use wcf\system\event\EventHandler;
use wcf\system\request\LinkHandler;
use wcf\system\view\grid\action\IGridViewAction;
use wcf\system\WCF;
private int $pageNo = 1;
private array $activeFilters = [];
+ /**
+ * Adds a new column to the grid view.
+ */
public function addColumn(GridViewColumn $column): void
{
$this->columns[] = $column;
}
/**
+ * Adds a new column to the grid view at the position before the specific id.
+ */
+ public function addColumnBefore(GridViewColumn $column, string $beforeID): void
+ {
+ $position = -1;
+
+ foreach ($this->getColumns() as $key => $existingColumn) {
+ if ($existingColumn->getID() === $beforeID) {
+ $position = $key;
+ break;
+ }
+ }
+
+ if ($position === -1) {
+ throw new \InvalidArgumentException("Invalid column id '{$beforeID}' given.");
+ }
+
+ array_splice($this->columns, $position, 0, [
+ $column,
+ ]);
+ }
+
+ /**
+ * Adds a new column to the grid view at the position after the specific id.
+ */
+ public function addColumnAfter(GridViewColumn $column, string $afterID): void
+ {
+ $position = -1;
+
+ foreach ($this->getColumns() as $key => $existingColumn) {
+ if ($existingColumn->getID() === $afterID) {
+ $position = $key;
+ break;
+ }
+ }
+
+ if ($position === -1) {
+ throw new \InvalidArgumentException("Invalid column id '{$afterID}' given.");
+ }
+
+ array_splice($this->columns, $position + 1, 0, [
+ $column,
+ ]);
+ }
+
+ /**
+ * Adds multiple new columns to the grid view.
* @param GridViewColumn[] $columns
*/
public function addColumns(array $columns): void
}
/**
+ * Returns all columns of the grid view.
* @return GridViewColumn[]
*/
public function getColumns(): array
}
/**
+ * Returns all visible (non-hidden) columns of the grid view.
* @return GridViewColumn[]
*/
public function getVisibleColumns(): array
return \array_filter($this->getColumns(), fn($column) => !$column->isHidden());
}
+ /**
+ * Returns the column with the given id or null if no such column exists.
+ */
public function getColumn(string $id): ?GridViewColumn
{
foreach ($this->getColumns() as $column) {
{
return '';
}
+
+ protected function fireInitializedEvent(): void
+ {
+ $event = $this->getInitializedEvent();
+ if ($event === null) {
+ return;
+ }
+
+ EventHandler::getInstance()->fire($event);
+ }
+
+ protected function getInitializedEvent(): ?IPsr14Event
+ {
+ return null;
+ }
}
if (!isset($this->dataArray)) {
$this->dataArray = $this->loadDataArray();
$this->applyFilters();
+ $this->fireInitializedEvent();
}
return $this->dataArray;
use wcf\data\cronjob\log\CronjobLog;
use wcf\data\cronjob\log\CronjobLogList;
use wcf\data\DatabaseObjectList;
+use wcf\event\gridView\CronjobLogGridViewInitialized;
+use wcf\event\IPsr14Event;
use wcf\system\view\grid\filter\SelectFilter;
use wcf\system\view\grid\renderer\DefaultColumnRenderer;
use wcf\system\view\grid\renderer\NumberColumnRenderer;
return new CronjobLogList();
}
+ #[\Override]
+ protected function getInitializedEvent(): ?IPsr14Event
+ {
+ return new CronjobLogGridViewInitialized($this);
+ }
+
private function getAvailableCronjobs(): array
{
$list = new I18nCronjobList();
}
}
$this->applyFilters();
+ $this->fireInitializedEvent();
}
public function getObjectList(): DatabaseObjectList
namespace wcf\system\view\grid;
+use wcf\event\gridView\ExceptionLogGridViewInitialized;
+use wcf\event\IPsr14Event;
use wcf\system\Regex;
use wcf\system\view\grid\filter\SelectFilter;
use wcf\system\view\grid\filter\TextFilter;
{
return \array_key_first($this->getAvailableLogFiles());
}
+
+ #[\Override]
+ protected function getInitializedEvent(): ?IPsr14Event
+ {
+ return new ExceptionLogGridViewInitialized($this);
+ }
}
use wcf\data\user\group\UserGroup;
use wcf\data\user\rank\I18nUserRankList;
use wcf\data\user\rank\UserRank;
+use wcf\event\gridView\UserRankGridViewInitialized;
+use wcf\event\IPsr14Event;
use wcf\system\view\grid\action\DeleteAction;
use wcf\system\view\grid\action\EditAction;
use wcf\system\view\grid\renderer\DefaultColumnRenderer;
{
return new I18nUserRankList();
}
+
+ #[\Override]
+ protected function getInitializedEvent(): ?IPsr14Event
+ {
+ return new UserRankGridViewInitialized($this);
+ }
}