DateFormat
3 days ago
FieldTypeConfigurator
3 days ago
Media
3 days ago
Post
3 days ago
Pro
3 days ago
ActionIcons.php
3 days ago
AttachmentDisplay.php
3 days ago
BaseComponentFactory.php
3 days ago
BeforeAfter.php
3 days ago
BooleanValues.php
3 days ago
CharacterLimit.php
3 days ago
ColumnInfo.php
3 days ago
CommentDisplay.php
3 days ago
CommentLink.php
3 days ago
CommentStatus.php
3 days ago
CustomField.php
3 days ago
CustomFieldFactory.php
3 days ago
DateFormat.php
3 days ago
DateSaveFormat.php
3 days ago
ExifData.php
3 days ago
FieldType.php
3 days ago
FieldTypeFactory.php
3 days ago
FieldTypeFactoryBuilder.php
3 days ago
FileDisplay.php
3 days ago
FileLink.php
3 days ago
FilePreviewSize.php
3 days ago
HiddenInput.php
3 days ago
HiddenLabel.php
3 days ago
ImageSize.php
3 days ago
ImageSizeBase.php
3 days ago
IncludeMissingSizes.php
3 days ago
InputNameAware.php
3 days ago
IsLink.php
3 days ago
IsLinkable.php
3 days ago
IsMultiple.php
3 days ago
Label.php
3 days ago
LinkLabel.php
3 days ago
LinkToMenu.php
3 days ago
LinkablePostProperty.php
3 days ago
MediaLink.php
3 days ago
Message.php
3 days ago
ModalDisplay.php
3 days ago
Name.php
3 days ago
NumberFormat.php
3 days ago
NumberOfItems.php
3 days ago
Password.php
3 days ago
PathScope.php
3 days ago
PostExtendedProperty.php
3 days ago
PostLink.php
3 days ago
PostProperty.php
3 days ago
PostStatus.php
3 days ago
PostStatusIcon.php
3 days ago
PostType.php
3 days ago
PostTypeFactory.php
3 days ago
RelatedUserMetaField.php
3 days ago
SelectOptions.php
3 days ago
Separator.php
3 days ago
SerializedArrayKeys.php
3 days ago
SerializedDisplay.php
3 days ago
StringLimit.php
3 days ago
Taxonomy.php
3 days ago
TaxonomyFactory.php
3 days ago
TermLink.php
3 days ago
TermProperty.php
3 days ago
UseIcon.php
3 days ago
UserLink.php
3 days ago
UserLinkFactory.php
3 days ago
UserProperty.php
3 days ago
VideoDisplay.php
3 days ago
Width.php
3 days ago
WordLimit.php
3 days ago
WordsPerMinute.php
3 days ago
CommentDisplay.php
102 lines
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace AC\Setting\ComponentFactory; |
| 6 | |
| 7 | use AC; |
| 8 | use AC\Expression\StringComparisonSpecification; |
| 9 | use AC\FormatterCollection; |
| 10 | use AC\Setting\Children; |
| 11 | use AC\Setting\ComponentCollection; |
| 12 | use AC\Setting\Config; |
| 13 | use AC\Setting\Control\Input; |
| 14 | use AC\Setting\Control\Input\OptionFactory; |
| 15 | use AC\Setting\Control\OptionCollection; |
| 16 | |
| 17 | final class CommentDisplay extends BaseComponentFactory |
| 18 | { |
| 19 | public const PROPERTY_COMMENT = 'comment'; |
| 20 | public const PROPERTY_DATE = 'date'; |
| 21 | public const PROPERTY_ID = 'id'; |
| 22 | public const PROPERTY_AUTHOR = 'author'; |
| 23 | public const PROPERTY_AUTHOR_EMAIL = 'author_email'; |
| 24 | |
| 25 | private StringLimit $string_limit; |
| 26 | |
| 27 | private CommentLink $comment_link; |
| 28 | |
| 29 | private UserProperty $user_display; |
| 30 | |
| 31 | public function __construct( |
| 32 | StringLimit $string_limit, |
| 33 | CommentLink $comment_link, |
| 34 | UserProperty $user_display |
| 35 | ) { |
| 36 | $this->string_limit = $string_limit; |
| 37 | $this->comment_link = $comment_link; |
| 38 | $this->user_display = $user_display; |
| 39 | } |
| 40 | |
| 41 | protected function get_label(Config $config): ?string |
| 42 | { |
| 43 | return __('Comment Display', 'codepress-admin-columns'); |
| 44 | } |
| 45 | |
| 46 | protected function get_input(Config $config): ?Input |
| 47 | { |
| 48 | return OptionFactory::create_select( |
| 49 | 'comment', |
| 50 | OptionCollection::from_array([ |
| 51 | self::PROPERTY_COMMENT => __('Comment'), |
| 52 | self::PROPERTY_ID => __('ID'), |
| 53 | self::PROPERTY_AUTHOR => __('Author'), |
| 54 | self::PROPERTY_AUTHOR_EMAIL => __('Author Email', 'codepress-admin-column'), |
| 55 | self::PROPERTY_DATE => __('Date'), |
| 56 | ]), |
| 57 | $config->get('comment', self::PROPERTY_COMMENT) |
| 58 | ); |
| 59 | } |
| 60 | |
| 61 | protected function get_children(Config $config): ?Children |
| 62 | { |
| 63 | return new Children( |
| 64 | new ComponentCollection([ |
| 65 | $this->string_limit->create( |
| 66 | $config, |
| 67 | StringComparisonSpecification::equal(self::PROPERTY_COMMENT) |
| 68 | ), |
| 69 | $this->comment_link->create( |
| 70 | $config, |
| 71 | StringComparisonSpecification::equal(self::PROPERTY_COMMENT) |
| 72 | ), |
| 73 | $this->user_display->create( |
| 74 | $config, |
| 75 | StringComparisonSpecification::equal(self::PROPERTY_AUTHOR) |
| 76 | ), |
| 77 | ]) |
| 78 | ); |
| 79 | } |
| 80 | |
| 81 | protected function add_formatters(Config $config, FormatterCollection $formatters): void |
| 82 | { |
| 83 | switch ($config->get('comment')) { |
| 84 | case self::PROPERTY_DATE: |
| 85 | $formatters->add(new AC\Formatter\Comment\Property('comment_date')); |
| 86 | break; |
| 87 | case self::PROPERTY_AUTHOR: |
| 88 | $formatters->add(new AC\Formatter\Comment\Property('comment_author')); |
| 89 | break; |
| 90 | case self::PROPERTY_AUTHOR_EMAIL: |
| 91 | $formatters->add(new AC\Formatter\Comment\Property('comment_author_email')); |
| 92 | break; |
| 93 | case self::PROPERTY_ID: |
| 94 | break; |
| 95 | default: |
| 96 | $formatters->add(new AC\Formatter\Comment\Content()); |
| 97 | $formatters->add(new AC\Formatter\StringSanitizer()); |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | } |
| 102 |