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.
MetaData: wired up vocab table, added lang vars
- Loading branch information
1 parent
86ed6c4
commit c49090e
Showing
7 changed files
with
478 additions
and
152 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
119 changes: 119 additions & 0 deletions
119
Services/MetaData/classes/Settings/Vocabularies/DataRetrieval.php
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 |
---|---|---|
@@ -0,0 +1,119 @@ | ||
<?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); | ||
|
||
namespace ILIAS\MetaData\Settings\Vocabularies; | ||
|
||
use ILIAS\UI\Component\Table\DataRetrieval as BaseDataRetrieval; | ||
use ILIAS\UI\Component\Table\DataRowBuilder; | ||
use ILIAS\Data\Range; | ||
use ILIAS\Data\Order; | ||
use ILIAS\MetaData\Vocabularies\Manager\Manager as VocabManager; | ||
use ILIAS\MetaData\Vocabularies\VocabularyInterface; | ||
|
||
class DataRetrieval implements BaseDataRetrieval | ||
{ | ||
protected const MAX_PREVIEW_VALUES = 5; | ||
|
||
protected VocabManager $vocab_manager; | ||
protected Presentation $presentation; | ||
|
||
/** | ||
* @var VocabularyInterface[] | ||
*/ | ||
protected array $vocabs; | ||
|
||
public function __construct( | ||
VocabManager $vocab_manager, | ||
Presentation $presentation | ||
) { | ||
$this->vocab_manager = $vocab_manager; | ||
$this->presentation = $presentation; | ||
} | ||
|
||
public function getRows( | ||
DataRowBuilder $row_builder, | ||
array $visible_column_ids, | ||
Range $range, | ||
Order $order, | ||
?array $filter_data, | ||
?array $additional_parameters | ||
): \Generator { | ||
$infos = $this->vocab_manager->infos(); | ||
foreach ($this->getVocabs($range) as $vocab) { | ||
$record = []; | ||
|
||
$record['element'] = $this->presentation->makeSlotPresentable($vocab->slot()); | ||
$record['type'] = $this->presentation->makeTypePresentable($vocab->type()); | ||
$record['source'] = $vocab->source(); | ||
$record['preview'] = implode( | ||
', ', | ||
$this->presentation->makeValuesPresentable($vocab, self::MAX_PREVIEW_VALUES) | ||
); | ||
$record['active'] = $vocab->isActive(); | ||
if ($infos->isCustomInputApplicable($vocab)) { | ||
$record['custom_input'] = $vocab->allowsCustomInputs(); | ||
} | ||
|
||
yield $row_builder->buildDataRow( | ||
$vocab->id(), | ||
$record | ||
)->withDisabledAction( | ||
'delete', | ||
!$infos->canBeDeleted($vocab) | ||
)->withDisabledAction( | ||
'activate', | ||
$vocab->isActive() | ||
)->withDisabledAction( | ||
'deactivate', | ||
!$vocab->isActive() || | ||
!$infos->isDeactivatable($vocab) | ||
)->withDisabledAction( | ||
'allow_custom_input', | ||
!$infos->isCustomInputApplicable($vocab) || | ||
$vocab->allowsCustomInputs() | ||
)->withDisabledAction( | ||
'disallow_custom_input', | ||
!$infos->isCustomInputApplicable($vocab) || | ||
!$infos->canDisallowCustomInput($vocab) || | ||
!$vocab->allowsCustomInputs() | ||
); | ||
}; | ||
} | ||
|
||
public function getTotalRowCount(?array $filter_data, ?array $additional_parameters): ?int | ||
{ | ||
return count($this->getVocabs()); | ||
} | ||
|
||
protected function getVocabs(Range $range = null): array | ||
{ | ||
if (isset($this->vocabs)) { | ||
$vocabs = $this->vocabs; | ||
} else { | ||
$vocabs = iterator_to_array($this->vocab_manager->getAllVocabularies(), false); | ||
} | ||
|
||
if ($range) { | ||
$vocabs = array_slice($vocabs, $range->getStart(), $range->getLength()); | ||
} | ||
|
||
return $this->vocabs = $vocabs; | ||
} | ||
} |
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
Oops, something went wrong.