-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5713 from WoltLab/notice-form-node
Add a form node for showing notices
- Loading branch information
Showing
2 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
wcfsetup/install/files/lib/system/form/builder/NoticeFormNode.class.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
namespace wcf\system\form\builder; | ||
|
||
/** | ||
* Form node that shows a notice. | ||
* | ||
* @author Marcel Werk | ||
* @copyright 2001-2023 WoltLab GmbH | ||
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php> | ||
* @since 6.1 | ||
*/ | ||
class NoticeFormNode extends LanguageItemFormNode | ||
{ | ||
protected NoticeFormNodeType $type = NoticeFormNodeType::Info; | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function getHtml() | ||
{ | ||
return '<woltlab-core-notice type="' . $this->getType()->toString() . '">' . parent::getHtml() . '</woltlab-core-notice>'; | ||
} | ||
|
||
/** | ||
* Sets the type of this notice. | ||
*/ | ||
public function type(NoticeFormNodeType $type): static | ||
{ | ||
$this->type = $type; | ||
|
||
return $this; | ||
} | ||
|
||
public function getType(): NoticeFormNodeType | ||
{ | ||
return $this->type; | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
wcfsetup/install/files/lib/system/form/builder/NoticeFormNodeType.class.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
namespace wcf\system\form\builder; | ||
|
||
/** | ||
* Defines the available types for the notice form node. | ||
* | ||
* @author Marcel Werk | ||
* @copyright 2001-2023 WoltLab GmbH | ||
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php> | ||
* @since 6.1 | ||
*/ | ||
enum NoticeFormNodeType | ||
{ | ||
case Info; | ||
case Success; | ||
case Warning; | ||
case Error; | ||
|
||
public function toString(): string | ||
{ | ||
return match ($this) { | ||
self::Info => 'info', | ||
self::Success => 'success', | ||
self::Warning => 'warning', | ||
self::Error => 'error', | ||
}; | ||
} | ||
} |