Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions wcfsetup/install/files/acp/templates/labelGroupAdd.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,13 @@
<div class="section">
{foreach from=$labelObjectTypeContainers item=container}
<dl>
<dt>{lang}wcf.acp.label.container.{$container->getObjectTypeName()}{/lang}</dt>
<dt>{$container->getTitle()}</dt>
<dd>
<ul class="structuredList">
{foreach from=$container item=objectType}
<li class="{if $objectType->isCategory()} category{/if}"{if $objectType->getDepth()} style="padding-left: {$objectType->getDepth() * 20}px"{/if} data-depth="{$objectType->getDepth()}">
<span>{$objectType->getLabel()}</span>
<label><input id="checkbox_{$container->getObjectTypeID()}_{$objectType->getObjectID()}" type="checkbox" name="objectTypes[{$container->getObjectTypeID()}][]" value="{$objectType->getObjectID()}"{if $objectType->getOptionValue()} checked{/if}></label>
<label><input id="checkbox_{$container->objectTypeID}_{$objectType->getObjectID()}" type="checkbox" name="objectTypes[{$container->objectTypeID}][]" value="{$objectType->getObjectID()}"{if $objectType->getOptionValue()} checked{/if}></label>
</li>
{/foreach}
</ul>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
namespace wcf\system\label\object\type;

use wcf\data\object\type\ObjectTypeCache;
use wcf\system\WCF;

/**
* Label object type container.
* This type of container is used to allow the user when editing label groups to specify
* in which sub-areas (e.g., categories or sub-forums) a label group is available.
*
* @author Alexander Ebert
* @copyright 2001-2022 WoltLab GmbH
Expand All @@ -15,28 +17,16 @@
final class LabelObjectTypeContainer implements \Countable, \Iterator
{
/**
* list of object types
* @var LabelObjectType[]
*/
public array $objectTypes = [];
private array $objectTypes = [];

/**
* object type id
*/
public int $objectTypeID = 0;

/**
* iterator position
*/
private int $position = 0;

/**
* Creates a new LabelObjectTypeContainer object.
*/
public function __construct(int $objectTypeID)
{
$this->objectTypeID = $objectTypeID;
}
public function __construct(
public readonly int $objectTypeID,
public readonly string $title = ''
) {}

/**
* Adds a label object type.
Expand All @@ -46,65 +36,47 @@ public function add(LabelObjectType $objectType): void
$this->objectTypes[] = $objectType;
}

/**
* Returns the object type id.
*/
public function getObjectTypeID(): int
public function getObjectTypeName(): string
{
return $this->objectTypeID;
return ObjectTypeCache::getInstance()->getObjectType($this->objectTypeID)->objectType;
}

/**
* Returns the object type name.
*/
public function getObjectTypeName(): string
public function getTitle(): string
{
return ObjectTypeCache::getInstance()->getObjectType($this->getObjectTypeID())->objectType;
return $this->title ?: WCF::getLanguage()->get('wcf.acp.label.container.' . $this->getObjectTypeName());
}

/**
* @inheritDoc
*/
#[\Override]
public function current(): LabelObjectType
{
return $this->objectTypes[$this->position];
}

/**
* @inheritDoc
*/
#[\Override]
public function key(): int
{
return $this->position;
}

/**
* @inheritDoc
*/
#[\Override]
public function next(): void
{
$this->position++;
}

/**
* @inheritDoc
*/
#[\Override]
public function rewind(): void
{
$this->position = 0;
}

/**
* @inheritDoc
*/
#[\Override]
public function valid(): bool
{
return isset($this->objectTypes[$this->position]);
}

/**
* @inheritDoc
*/
#[\Override]
public function count(): int
{
return \count($this->objectTypes);
Expand Down