Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI/Legacy: factory->legacy() will return Legacy\Factory, not Component #8436

Merged
merged 3 commits into from
Jan 8, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function getValuePresentation(
ilAccessibilityCriterionConfig $config,
Factory $uiFactory
): Component {
return $uiFactory->legacy('-');
return $uifactory->legacy()->content('-');
}

public function getSelection(ilAccessibilityCriterionConfig $config): ilSelectInputGUI
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ public function getValuePresentation(ilAccessibilityCriterionConfig $config, Fac
$lng = $config['lng'] ?? '';

if (!is_string($lng) || 2 !== strlen($lng)) {
return $uiFactory->legacy('');
return $uifactory->legacy()->content('');
}

return $uiFactory->legacy($this->lng->txt('meta_l_' . $lng));
return $uifactory->legacy()->content($this->lng->txt('meta_l_' . $lng));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ protected function formatCriterionAssignments(string $column, array $row): strin
$typeGui->getIdentPresentation(),
($this->isEditable ? $this->uiRenderer->render($dropDown) : '')
])] =
$this->uiFactory->legacy(
$this->uiFactory->legacy()->content(
$this->uiRenderer->render(
$typeGui->getValuePresentation(
$criterion->getCriterionValue(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public function getStaticSubItems(): array
->withParent($top)
->withPosition($position * 10)
->withAlwaysAvailable(true)
->withNonAvailableReason($this->dic->ui()->factory()->legacy("{$this->dic->language()->txt('item_must_be_always_active')}"))
->withNonAvailableReason($this->dic->ui()->factory()->legacy()->content("{$this->dic->language()->txt('item_must_be_always_active')}"))
->withVisibilityCallable(
$access_helper->hasAdministrationAccess()
)->withAvailableCallable(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<?php

declare(strict_types=1);

/**
* This file is part of ILIAS, a powerful learning management system
* published by ILIAS open source e-Learning e.V.
Expand All @@ -18,6 +16,8 @@
*
*********************************************************************/

declare(strict_types=1);

use ILIAS\GlobalScreen\Scope\Tool\Provider\AbstractDynamicToolProvider;
use ILIAS\GlobalScreen\ScreenContext\Stack\CalledContexts;
use ILIAS\GlobalScreen\ScreenContext\Stack\ContextCollection;
Expand Down Expand Up @@ -45,7 +45,7 @@ public function getToolsForContextStack(CalledContexts $called_contexts): array
return $this->identification_provider->contextAwareIdentifier($id, true);
};
$l = function (string $content) {
return $this->dic->ui()->factory()->legacy($content);
return $this->dic->ui()->factory()->legacy()->content($content);
};
$tools[] = $this->factory->tool($iff("tree"))
->withTitle("Tree")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function getMetaBarItems(): array
$result = $gui->getAwarenessList(true);
$online = explode(":", $result["cnt"]);
$online = (int) $online[0];
$content = $this->dic->ui()->factory()->legacy($result["html"]);
$content = $this->dic->ui()->factory()->legacy()->content($result["html"]);
if ($online === 0) {
$is_widget_visible = false;
}
Expand Down
24 changes: 12 additions & 12 deletions components/ILIAS/BackgroundTasks_/classes/class.ilBTPopOverGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
use ILIAS\BackgroundTasks\Task\UserInteraction;
use ILIAS\UI\Component\Button\Button;
use ILIAS\UI\Component\Button\Shy;
use ILIAS\UI\Component\Legacy\Legacy;
use ILIAS\UI\Component\Legacy\Content;

/**
* Class ilBTPopOverGUI
Expand Down Expand Up @@ -97,11 +97,11 @@ public function getItemForObserver(Bucket $observer): ILIAS\UI\Component\Item\No
}
$item = $f->item()->notification($title, $icon);

// $item = $item->withProperties([
// $this->dic->language()->txt('nc_mail_prop_time') => \ilDatePresentation::formatDate(
// new \ilDateTime(time(), IL_CAL_UNIX)
// )
// ]);
// $item = $item->withProperties([
// $this->dic->language()->txt('nc_mail_prop_time') => \ilDatePresentation::formatDate(
// new \ilDateTime(time(), IL_CAL_UNIX)
// )
// ]);

$item = $item->withActions($f->dropdown()->standard($actions));
$input = $current_task->getInput();
Expand All @@ -123,7 +123,7 @@ public function getItemForObserver(Bucket $observer): ILIAS\UI\Component\Item\No
if ($state === State::RUNNING) {
$url = $this->getRefreshUrl($observer);
//Running Items probably need to refresh themselves, right?
$item = $item->withAdditionalOnLoadCode(fn ($id) => "var notification_item = il.UI.item.notification.getNotificationItemObject($('#$id'));
$item = $item->withAdditionalOnLoadCode(fn($id) => "var notification_item = il.UI.item.notification.getNotificationItemObject($('#$id'));
il.BGTask.refreshItem(notification_item,'$url');");

$expected = $current_task->getExpectedTimeOfTaskInSeconds();
Expand All @@ -140,14 +140,14 @@ public function getItemForObserver(Bucket $observer): ILIAS\UI\Component\Item\No
}


private function getDefaultCardContent(Bucket $observer): Legacy
private function getDefaultCardContent(Bucket $observer): Content
{
return $this->getProgressbar($observer);
}


/**
* @return \ILIAS\UI\Component\Legacy\Legacy[]|\ILIAS\UI\Component\Button\Shy[]
* @return \ILIAS\UI\Component\Legacy\Content[]|\ILIAS\UI\Component\Button\Shy[]
*/
public function getUserInteractionContent(Bucket $observer, string $redirect_uri): array
{
Expand All @@ -157,7 +157,7 @@ public function getUserInteractionContent(Bucket $observer, string $redirect_uri
$ctrl = $this->dic->ctrl();

if (!$observer->getCurrentTask() instanceof UserInteraction) {
return [$factory->legacy('')];
return [$factory->legacy()->content('')];
}
/** @var UserInteraction $userInteraction */
$userInteraction = $observer->getCurrentTask();
Expand Down Expand Up @@ -193,7 +193,7 @@ function (UserInteraction\Option $option) use ($ctrl, $factory, $observer, $pers
}


private function getProgressbar(Bucket $observer): Legacy
private function getProgressbar(Bucket $observer): Content
{
$percentage = $observer->getOverallPercentage();

Expand All @@ -212,7 +212,7 @@ private function getProgressbar(Bucket $observer): Legacy
break;
}

return $this->dic->ui()->factory()->legacy(" <div class='progress'>
return $this->dic->ui()->factory()->legacy()->content(" <div class='progress'>
<div class='progress-bar progress-bar-striped {$running}' role='progressbar' aria-valuenow='{$percentage}'
aria-valuemin='0' aria-valuemax='100' style='width:{$percentage}%'>
{$content}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function getStaticSubItems(): array
->withPosition(40)
->withParent(StandardTopItemsProvider::getInstance()->getAchievementsIdentification())
->withSymbol($icon)
->withNonAvailableReason($this->dic->ui()->factory()->legacy($this->dic->language()->txt('component_not_active')))
->withNonAvailableReason($this->dic->ui()->factory()->legacy()->content($this->dic->language()->txt('component_not_active')))
->withAvailableCallable(
function () {
return ilBadgeHandler::getInstance()->isActive();
Expand Down
4 changes: 2 additions & 2 deletions components/ILIAS/Badge/classes/BadgeParent.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ public function asComponent(ilBadge $badge): ?Component
->link()
->standard($meta_data['title'], ($this->link_to)($parent_ref_id));
} else {
$parent_link = $this->container->ui()->factory()->legacy($meta_data['title']);
$parent_link = $this->container->ui()->factory()->legacy()->content($meta_data['title']);
}

return $this->container->ui()->factory()->listing()->descriptive([
$this->container->language()->txt('object') => $this->container->ui()->factory()->legacy(
$this->container->language()->txt('object') => $this->container->ui()->factory()->legacy()->content(
$this->container->ui()->renderer()->render([$parent_icon, $parent_link])
)
]);
Expand Down
21 changes: 10 additions & 11 deletions components/ILIAS/Badge/tests/BadgeParentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
use ILIAS\DI\Container;
use ILIAS\Badge\BadgeParent;
use ILIAS\UI\Component\Listing\Descriptive;
use ILIAS\UI\Component\Legacy\Legacy;
use ILIAS\UI\Component\Legacy;
use ilBadge;
use ILIAS\UI\Factory as UI;
use ILIAS\DI\UIServices;
Expand Down Expand Up @@ -54,7 +54,8 @@ public function testShowWithParentReadRight(): void
$descriptive = $this->getMockBuilder(Descriptive::class)->getMock();
$factory = $this->getMockBuilder(UI::class)->disableOriginalConstructor()->getMock();
$language = $this->getMockBuilder(ilLanguage::class)->disableOriginalConstructor()->getMock();
$legacy = $this->getMockBuilder(Legacy::class)->disableOriginalConstructor()->getMock();
$legacy = $this->getMockBuilder(Legacy\Content::class)->disableOriginalConstructor()->getMock();
$legacy_factory = $this->getMockBuilder(Legacy\Factory::class)->disableOriginalConstructor()->getMock();
$link = $this->getMockBuilder(Link::class)->disableOriginalConstructor()->getMock();
$listing = $this->getMockBuilder(Listing::class)->disableOriginalConstructor()->getMock();
$renderer = $this->getMockBuilder(Renderer::class)->disableOriginalConstructor()->getMock();
Expand All @@ -71,7 +72,8 @@ public function testShowWithParentReadRight(): void

$factory->method('listing')->willReturn($listing);
$factory->method('link')->willReturn($link);
$factory->expects(self::once())->method('legacy')->with($rendered)->willReturn($legacy);
$legacy_factory->expects(self::once())->method('content')->with($rendered)->willReturn($legacy);
$factory->expects(self::once())->method('legacy')->willReturn($legacy_factory);

$renderer->expects(self::once())->method('render')->willReturn($rendered);

Expand Down Expand Up @@ -118,9 +120,10 @@ public function testShowWithoutParentReadRight(): void
$descriptive = $this->getMockBuilder(Descriptive::class)->getMock();
$factory = $this->getMockBuilder(UI::class)->disableOriginalConstructor()->getMock();
$language = $this->getMockBuilder(ilLanguage::class)->disableOriginalConstructor()->getMock();
$legacy = $this->getMockBuilder(Legacy::class)->disableOriginalConstructor()->getMock();
$legacy = $this->getMockBuilder(Legacy\Content::class)->disableOriginalConstructor()->getMock();
$legacy_factory = $this->getMockBuilder(Legacy\Factory::class)->disableOriginalConstructor()->getMock();
$listing = $this->getMockBuilder(Listing::class)->disableOriginalConstructor()->getMock();
$parent_link = $this->getMockBuilder(Legacy::class)->disableOriginalConstructor()->getMock();
$parent_link = $this->getMockBuilder(Content::class)->disableOriginalConstructor()->getMock();
$renderer = $this->getMockBuilder(Renderer::class)->disableOriginalConstructor()->getMock();
$ui = $this->getMockBuilder(UIServices::class)->disableOriginalConstructor()->getMock();

Expand All @@ -131,12 +134,8 @@ public function testShowWithoutParentReadRight(): void
])->willReturn($descriptive);

$factory->method('listing')->willReturn($listing);
$consecutive_returns = [
'Lorem' => $parent_link,
$rendered => $legacy
];
$factory->method('legacy')
->willReturnCallback(fn($k) => $consecutive_returns[$k]);
$legacy_factory->method('content')->willReturn($legacy);
$factory->method('legacy')->willReturn($legacy_factory);

$renderer->expects(self::once())->method('render')->willReturn($rendered);

Expand Down
8 changes: 4 additions & 4 deletions components/ILIAS/Block/classes/class.ilBlockGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -394,14 +394,14 @@ public function getHTML(): string
case self::PRES_SEC_LEG:
$panel = $this->factory->panel()->secondary()->legacy(
$this->specialCharsAsEntities($this->getTitle()),
$this->factory->legacy($this->getLegacyContent())
$this->factory->legacy()->content($this->getLegacyContent())
);
break;

case self::PRES_MAIN_LEG:
$panel = $this->factory->panel()->standard(
$this->specialCharsAsEntities($this->getTitle()),
$this->factory->legacy($this->getLegacyContent())
$this->factory->legacy()->content($this->getLegacyContent())
);
break;

Expand Down Expand Up @@ -429,12 +429,12 @@ public function getHTML(): string
if ($this->getPresentation() === self::PRES_SEC_LIST) {
$panel = $this->factory->panel()->secondary()->legacy(
$this->specialCharsAsEntities($this->getTitle()),
$this->factory->legacy($this->getNoItemFoundContent())
$this->factory->legacy()->content($this->getNoItemFoundContent())
);
} else {
$panel = $this->factory->panel()->standard(
$this->specialCharsAsEntities($this->getTitle()),
$this->factory->legacy($this->getNoItemFoundContent())
$this->factory->legacy()->content($this->getNoItemFoundContent())
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion components/ILIAS/Blog/classes/class.ilObjBlogGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -1787,7 +1787,7 @@ public function renderNavigation(

$content = $block[1];

$secondary_panel = $ui_factory->panel()->secondary()->legacy($title, $ui_factory->legacy($content));
$secondary_panel = $ui_factory->panel()->secondary()->legacy($title, $ui_factory->legacy()->content($content));

if (isset($block[2]) && is_array($block[2])) {
$link = $ui_factory->button()->shy($block[2][1], $block[2][0]);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
<?php

declare(strict_types=1);

/**
* This file is part of ILIAS, a powerful learning management system
* published by ILIAS open source e-Learning e.V.
*
* ILIAS is licensed with the GPL-3.0,
* see https://www.gnu.org/licenses/gpl-3.0.en.html
* You should have received a copy of said license along with the
* source code, too.
*
* If this is not the case or you just want to try ILIAS, you'll find
* us at:
* https://www.ilias.de
* https://github.com/ILIAS-eLearning
*
*********************************************************************/

declare(strict_types=1);

namespace ILIAS\BookingManager\BookingProcess;

/**
Expand Down Expand Up @@ -75,7 +78,7 @@ public function render(): string

$p = $this->ui->factory()->panel()->secondary()->legacy(
$this->lng->txt("book_object_selection"),
$this->ui->factory()->legacy($tpl->get())
$this->ui->factory()->legacy()->content($tpl->get())
);
return $this->ui->renderer()->render($p);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
<?php

declare(strict_types=1);

/**
* This file is part of ILIAS, a powerful learning management system
* published by ILIAS open source e-Learning e.V.
*
* ILIAS is licensed with the GPL-3.0,
* see https://www.gnu.org/licenses/gpl-3.0.en.html
* You should have received a copy of said license along with the
* source code, too.
*
* If this is not the case or you just want to try ILIAS, you'll find
* us at:
* https://www.ilias.de
* https://github.com/ILIAS-eLearning
*
*********************************************************************/

declare(strict_types=1);

namespace ILIAS\BookingManager\BookingProcess;

use ILIAS\BookingManager\getObjectSettingsCommand;
Expand Down Expand Up @@ -59,7 +62,7 @@ public function render(): string
$ui = $DIC->ui();
$tpl = new \ilTemplate("tpl.slot.html", true, true, "components/ILIAS/BookingManager/BookingProcess");

$modal = $ui->factory()->modal()->roundtrip("", $ui->factory()->legacy(""));
$modal = $ui->factory()->modal()->roundtrip("", $ui->factory()->legacy()->content(""));
$url = $this->link . '&replaceSignal=' . $modal->getReplaceSignal()->getId();
$modal = $modal->withAsyncRenderUrl($url);
$button = $ui->factory()->button()->shy($this->title, "#")
Expand Down
2 changes: 1 addition & 1 deletion components/ILIAS/COPage/Editor/UI/Init.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function initUI(
$dummy->getHTML();
// ensure modal.js from ui framework is loaded
$this->ui->renderer()->render(
$this->ui->factory()->modal()->roundtrip("", $this->ui->factory()->legacy(""))
$this->ui->factory()->modal()->roundtrip("", $this->ui->factory()->legacy()->content(""))
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function getToolsForContextStack(CalledContexts $called_contexts): array
return $this->identification_provider->contextAwareIdentifier($id);
};
$l = function (string $content) {
return $this->dic->ui()->factory()->legacy($content);
return $this->dic->ui()->factory()->legacy()->content($content);
};
$identification = $iff("copg_editor");
$hashed = $this->hash($identification->serialize());
Expand Down
4 changes: 2 additions & 2 deletions components/ILIAS/COPage/IntLink/class.ilInternalLinkGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -941,7 +941,7 @@ public static function getInitHTML(string $a_url): string
$mt = self::getModalTemplate();
$tpl->addOnLoadCode('il.IntLink.setModalTemplate("' . addslashes(json_encode($mt["template"])) . '");');

$html = "<div id='ilIntLinkModal' data-show-signal='".$mt["show"]."' data-close-signal='".$mt["close"]."'></div>";
$html = "<div id='ilIntLinkModal' data-show-signal='" . $mt["show"] . "' data-close-signal='" . $mt["close"] . "'></div>";

return $html;
}
Expand All @@ -953,7 +953,7 @@ public static function getModalTemplate(): array
$lng = $DIC->language();

$ui = $DIC->ui();
$modal = $ui->factory()->modal()->roundtrip($lng->txt("link_link"), $ui->factory()->legacy("<div id='ilIntLinkModalContent'></div>"));
$modal = $ui->factory()->modal()->roundtrip($lng->txt("link_link"), $ui->factory()->legacy()->content("<div id='ilIntLinkModalContent'></div>"));
$modalt["show"] = $modal->getShowSignal()->getId();
$modalt["close"] = $modal->getCloseSignal()->getId();
$modalt["template"] = $ui->renderer()->renderAsync($modal);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function initUI(
$dummy->getHTML();
// ensure modal.js from ui framework is loaded
$this->ui->renderer()->render(
$this->ui->factory()->modal()->roundtrip("", $this->ui->factory()->legacy(""))
$this->ui->factory()->modal()->roundtrip("", $this->ui->factory()->legacy()->content(""))
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ protected function getBackgroundProperties(): string
public function getModalTemplate(): array
{
$ui = $this->ui;
$modal = $ui->factory()->modal()->roundtrip('#title#', $ui->factory()->legacy('#content#'))
$modal = $ui->factory()->modal()->roundtrip('#title#', $ui->factory()->legacy()->content('#content#'))
->withActionButtons([
$ui->factory()->button()->standard('#button_title#', '#'),
]);
Expand Down
Loading
Loading