forked from ILIAS-eLearning/ILIAS
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Calendar: handle multiple files with same name better (40847)
- Loading branch information
1 parent
3f3ecc2
commit 960a73a
Showing
1 changed file
with
40 additions
and
11 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,7 +1,25 @@ | ||
<?php | ||
|
||
/** | ||
* 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); | ||
|
||
use ILIAS\UI\Component\Link\Standard as StandardLink; | ||
|
||
/** | ||
* @author Jesús López Reyes <[email protected]> | ||
* @ilCtrl_IsCalledBy ilAppointmentPresentationSessionGUI: ilCalendarAppointmentPresentationGUI | ||
|
@@ -11,10 +29,8 @@ class ilAppointmentPresentationSessionGUI extends ilAppointmentPresentationGUI i | |
{ | ||
public function collectPropertiesAndActions(): void | ||
{ | ||
global $DIC; | ||
|
||
$f = $DIC->ui()->factory(); | ||
$r = $DIC->ui()->renderer(); | ||
$f = $this->ui->factory(); | ||
$r = $this->ui->renderer(); | ||
$this->lng->loadLanguageModule("sess"); | ||
$this->lng->loadLanguageModule("crs"); | ||
|
||
|
@@ -76,7 +92,7 @@ public function collectPropertiesAndActions(): void | |
|
||
$eventItems = ilObjectActivation::getItemsByEvent($this->getObjIdForAppointment()); | ||
if (count($eventItems)) { | ||
$str = array(); | ||
$links = []; | ||
foreach ($eventItems as $file) { | ||
if ($file['type'] == "file") { | ||
$this->has_files = true; | ||
|
@@ -85,13 +101,13 @@ public function collectPropertiesAndActions(): void | |
if (ilObjFileAccess::_isFileInline($file["title"])) { | ||
$link = $link->withOpenInNewViewport(true); | ||
} | ||
$str[$file['title']] = $r->render($link); | ||
$links[] = $link; | ||
} | ||
} | ||
if ($this->has_files) { | ||
ksort($str, SORT_NATURAL | SORT_FLAG_CASE); | ||
$this->addInfoProperty($this->lng->txt("files"), implode("<br>", $str)); | ||
$this->addListItemProperty($this->lng->txt("files"), implode(", ", $str)); | ||
$rendered = $this->sortAndRenderLinks(...$links); | ||
$this->addInfoProperty($this->lng->txt("files"), implode("<br>", $rendered)); | ||
$this->addListItemProperty($this->lng->txt("files"), implode(", ", $rendered)); | ||
} | ||
} | ||
|
||
|
@@ -120,8 +136,6 @@ public function collectPropertiesAndActions(): void | |
*/ | ||
protected function getOtherMaterials(): array | ||
{ | ||
global $DIC; | ||
|
||
$event_items = new ilEventItems($this->getObjIdForAppointment()); | ||
$others = []; | ||
foreach ($event_items->getItems() as $ref_id) { | ||
|
@@ -135,4 +149,19 @@ protected function getOtherMaterials(): array | |
} | ||
return $others; | ||
} | ||
|
||
/** | ||
* @return string[] | ||
*/ | ||
protected function sortAndRenderLinks(StandardLink ...$links): array | ||
{ | ||
usort($links, function (StandardLink $a, $b) { | ||
return $a->getLabel() <=> $b->getLabel(); | ||
}); | ||
$rendered = []; | ||
foreach ($links as $link) { | ||
$rendered[] = $this->ui->renderer()->render($link); | ||
} | ||
return $rendered; | ||
} | ||
} |