|
2 | 2 |
|
3 | 3 | namespace wcf\system\listView; |
4 | 4 |
|
| 5 | +use wcf\action\ApiAction; |
5 | 6 | use wcf\action\ListViewFilterAction; |
6 | 7 | use wcf\data\DatabaseObject; |
7 | 8 | use wcf\data\DatabaseObjectDecorator; |
|
16 | 17 | use wcf\system\listView\filter\exception\InvalidFilterValue; |
17 | 18 | use wcf\system\request\LinkHandler; |
18 | 19 | use wcf\system\WCF; |
| 20 | +use wcf\util\StringUtil; |
19 | 21 |
|
20 | 22 | /** |
21 | 23 | * Abstract implementation of a list view. |
@@ -48,6 +50,7 @@ abstract class AbstractListView |
48 | 50 | private bool $allowInteractions = true; |
49 | 51 | private bool $allowBulkInteractions = true; |
50 | 52 | private int $fixedNumberOfItems = 0; |
| 53 | + private string $markAsReadEndpoint = ''; |
51 | 54 |
|
52 | 55 | /** |
53 | 56 | * @var array<string, string> |
@@ -673,6 +676,35 @@ public function getContainerCssClassName(): string |
673 | 676 | return $this->containerCssClassName; |
674 | 677 | } |
675 | 678 |
|
| 679 | + public function setMarkAsReadEndpoints(string $endpoint): void |
| 680 | + { |
| 681 | + $this->markAsReadEndpoint = $endpoint; |
| 682 | + } |
| 683 | + |
| 684 | + public function renderMarkAsReadButton(DatabaseObject $object): string |
| 685 | + { |
| 686 | + if (!$this->markAsReadEndpoint) { |
| 687 | + throw new \BadMethodCallException("No mark as read endpoint has been specified."); |
| 688 | + } |
| 689 | + |
| 690 | + $endpoint = StringUtil::encodeHTML( |
| 691 | + LinkHandler::getInstance()->getControllerLink(ApiAction::class, ['id' => 'rpc']) . |
| 692 | + \sprintf($this->markAsReadEndpoint, $object->getObjectID()) |
| 693 | + ); |
| 694 | + $title = WCF::getLanguage()->get('wcf.global.button.markAsRead'); |
| 695 | + |
| 696 | + return <<<HTML |
| 697 | + <button |
| 698 | + type="button" |
| 699 | + class="listView__item__markAsRead jsTooltip" |
| 700 | + title="{$title}" |
| 701 | + data-endpoint="{$endpoint}" |
| 702 | + > |
| 703 | + <span class="listView__item__unread__indicator" aria-hidden="true"></span> |
| 704 | + </button> |
| 705 | + HTML; |
| 706 | + } |
| 707 | + |
676 | 708 | /** |
677 | 709 | * @return TDatabaseObjectList |
678 | 710 | */ |
|
0 commit comments