19 declare(strict_types=1);
56 return new class ($selection_active) extends
NullSettings {
57 public function __construct(
protected bool $selection_active)
63 return $this->selection_active;
74 protected string $path =
'';
76 public function withNextStep(
string $name,
bool $add_as_first =
false):
BuilderInterface 79 $clone->path .=
'>' . $name;
108 public function id():
int 121 array $outdated_entry_ids,
122 int $default_entry_id
125 foreach ($entry_ids as
$id) {
129 return new class ($entries, $outdated_entry_ids, $default_entry_id) extends
NullRepository {
131 protected array $entries,
132 protected array $outdated_entry_ids,
133 protected int $default_entry_id
137 public function getAllEntries(): \Generator
139 yield
from $this->entries;
142 public function getActiveEntries(): \Generator
144 foreach ($this->entries as $entry) {
145 if (!in_array($entry->id(), $this->outdated_entry_ids)) {
153 foreach ($this->entries as $entry) {
154 if ($entry->id() === $this->default_entry_id) {
158 throw new \ilMDServicesException(
'Default entry id not found.');
163 foreach ($this->entries as $entry) {
164 if ($entry->id() ===
$id) {
168 throw new \ilMDServicesException(
'Entry id not found.');
176 public function isIdentifierValid(
string $identifier):
bool 178 return str_contains($identifier,
'valid_');
181 public function parseEntryIDFromIdentifier(
string $identifier):
int 183 if ($this->isIdentifierValid($identifier)) {
184 return (
int) str_replace(
'valid_',
'', $identifier);
193 return new class () extends NullSearchClauseFactory {
194 public function getBasicClause(
198 bool $is_mode_negated =
false 200 $search_data =
'"' . $path->
toString() .
'" ' .
201 ($is_mode_negated ?
'not ' :
'') .
202 $mode->value .
' "' . $value .
'"';
203 return new class ($search_data) extends
NullClause {
204 public function __construct(
public string $exposed_search_data)
210 public function getJoinedClauses(
216 foreach ([$first_clause, ...$further_clauses] as $clause) {
217 $clauses_data[] = $clause->exposed_search_data;
219 $search_data = implode(
' ' . $operator->value .
' ', $clauses_data);
220 return new class ($search_data) extends
NullClause {
221 public function __construct(
public string $exposed_search_data)
231 return new class ($raw_copyright) extends
NullReader {
232 public function __construct(
protected string $raw_copyright)
238 if ($path->
toString() !==
'>rights>description>string') {
239 throw new \ilMDServicesException(
'Wrong Path!');
241 return new class ($this->raw_copyright) extends
NullData {
242 public function __construct(
protected string $raw_copyright)
246 public function value():
string 248 return $this->raw_copyright;
258 public array $prepared_creates_or_updates = [];
262 $clone = clone $this;
263 $clone->prepared_creates_or_updates[] = [
287 public function __construct(
public string $exposed_id)
296 public function __construct(
public string $exposed_id)
311 $this->assertTrue($helper->isCopyrightSelectionActive());
321 $this->assertFalse($helper->isCopyrightSelectionActive());
332 $this->assertTrue($helper->hasPresetCopyright($reader));
343 $this->assertTrue($helper->hasPresetCopyright($reader));
352 $reader = $this->
getReader(
'something else');
354 $this->assertFalse($helper->hasPresetCopyright($reader));
365 $this->assertFalse($helper->hasPresetCopyright($reader));
376 $this->assertSame(
'5', $helper->readPresetCopyright($reader)->exposed_id);
387 $this->assertSame(
'null', $helper->readPresetCopyright($reader)->exposed_id);
396 $reader = $this->
getReader(
'something else');
398 $this->assertSame(
'null', $helper->readPresetCopyright($reader)->exposed_id);
409 $this->assertSame(
'13', $helper->readPresetCopyright($reader)->exposed_id);
418 $reader = $this->
getReader(
'custom info about the copyright');
421 'custom info about the copyright',
422 $helper->readCustomCopyright($reader)
436 $helper->readCustomCopyright($reader)
450 $helper->readCustomCopyright($reader)
462 $manipulator = $helper->prepareCreateOrUpdateOfCopyrightFromPreset(
468 [[
'path' =>
'>rights>description>string',
'values' => [
'valid_5']]],
469 $manipulator->prepared_creates_or_updates
481 $manipulator = $helper->prepareCreateOrUpdateOfCustomCopyright(
483 'custom info about the copyright' 487 [[
'path' =>
'>rights>description>string',
'values' => [
'custom info about the copyright']]],
488 $manipulator->prepared_creates_or_updates
499 $presets = $helper->getAllCopyrightPresets();
501 $this->assertSame(
'13', $presets->current()->exposed_id);
503 $this->assertSame(
'77', $presets->current()->exposed_id);
505 $this->assertSame(
'932', $presets->current()->exposed_id);
507 $this->assertSame(
'5', $presets->current()->exposed_id);
509 $this->assertNull($presets->current());
519 $presets = $helper->getAllCopyrightPresets();
521 $this->assertNull($presets->current());
531 $presets = $helper->getNonOutdatedCopyrightPresets();
533 $this->assertSame(
'13', $presets->current()->exposed_id);
535 $this->assertSame(
'932', $presets->current()->exposed_id);
537 $this->assertSame(
'5', $presets->current()->exposed_id);
539 $this->assertNull($presets->current());
549 $presets = $helper->getNonOutdatedCopyrightPresets();
551 $this->assertNull($presets->current());
561 $clause = $helper->getCopyrightSearchClause(
'valid_5');
564 '">rights>description>string" equals "valid_5"',
565 $clause->exposed_search_data
576 $clause = $helper->getCopyrightSearchClause(
583 '">rights>description>string" equals "valid_5" or ' .
584 '">rights>description>string" equals "valid_77" or ' .
585 '">rights>description>string" equals "something else"',
586 $clause->exposed_search_data
597 $clause = $helper->getCopyrightSearchClause(
'valid_13');
600 '">rights>description>string" equals "valid_13" or ' .
601 '">rights>description>string" equals ""',
602 $clause->exposed_search_data
613 $clause = $helper->getCopyrightSearchClause(
'valid_13');
616 '">rights>description>string" equals "valid_13"',
617 $clause->exposed_search_data
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
custom()
expected output: > ILIAS shows a base horizontal bar chart but customized with e.g.