|
| 1 | +<?php |
| 2 | + |
| 3 | +/** |
| 4 | + * This file is part of ILIAS, a powerful learning management system |
| 5 | + * published by ILIAS open source e-Learning e.V. |
| 6 | + * |
| 7 | + * ILIAS is licensed with the GPL-3.0, |
| 8 | + * see https://www.gnu.org/licenses/gpl-3.0.en.html |
| 9 | + * You should have received a copy of said license along with the |
| 10 | + * source code, too. |
| 11 | + * |
| 12 | + * If this is not the case or you just want to try ILIAS, you'll find |
| 13 | + * us at: |
| 14 | + * https://www.ilias.de |
| 15 | + * https://github.com/ILIAS-eLearning |
| 16 | + * |
| 17 | + *********************************************************************/ |
| 18 | + |
| 19 | +declare(strict_types=1); |
| 20 | + |
| 21 | +namespace ILIAS\Wiki\Page; |
| 22 | + |
| 23 | +use ILIAS\ILIASObject\Properties\Translations\Translations; |
| 24 | +use ILIAS\Repository\RetrievalInterface; |
| 25 | +use ILIAS\Repository\Table\CommonTableBuilder; |
| 26 | +use ILIAS\Repository\Table\TableAdapterGUI; |
| 27 | + |
| 28 | +class PageTemplateTableBuilder extends CommonTableBuilder |
| 29 | +{ |
| 30 | + protected PageManager $pm; |
| 31 | + protected Translations $translations; |
| 32 | + |
| 33 | + public function __construct( |
| 34 | + protected \ILIAS\Wiki\InternalDomainService $domain, |
| 35 | + protected \ILIAS\Wiki\InternalGUIService $gui, |
| 36 | + protected int $wiki_id, |
| 37 | + object $parent_gui, |
| 38 | + string $parent_cmd |
| 39 | + ) { |
| 40 | + $ref_id = $this->gui->request()->getRefId(); |
| 41 | + $this->translations = $this->domain->wiki()->translation($ref_id); |
| 42 | + $this->pm = $this->domain->page()->page($ref_id); |
| 43 | + |
| 44 | + parent::__construct($parent_gui, $parent_cmd); |
| 45 | + } |
| 46 | + |
| 47 | + protected function getId(): string |
| 48 | + { |
| 49 | + return 'wiki_page_templates_' . $this->wiki_id; |
| 50 | + } |
| 51 | + |
| 52 | + protected function getTitle(): string |
| 53 | + { |
| 54 | + return ''; |
| 55 | + } |
| 56 | + |
| 57 | + protected function getRetrieval(): RetrievalInterface |
| 58 | + { |
| 59 | + return $this->domain->page()->pageTemplateRetrieval($this->wiki_id); |
| 60 | + } |
| 61 | + |
| 62 | + protected function transformRow(array $data_row): array |
| 63 | + { |
| 64 | + $lng = $this->domain->lng(); |
| 65 | + |
| 66 | + return [ |
| 67 | + 'id' => $data_row['id'], |
| 68 | + 'title' => $data_row['title'], |
| 69 | + 'translations' => $this->translations->getContentTranslationActivated() |
| 70 | + ? implode(', ', $this->pm->getLanguages((int) $data_row['wpage_id'])) |
| 71 | + : '', |
| 72 | + 'new_pages' => $data_row['new_pages'] ? $lng->txt('yes') : $lng->txt('no'), |
| 73 | + 'add_to_page' => $data_row['add_to_page'] ? $lng->txt('yes') : $lng->txt('no') |
| 74 | + ]; |
| 75 | + } |
| 76 | + |
| 77 | + protected function build(TableAdapterGUI $table): TableAdapterGUI |
| 78 | + { |
| 79 | + $lng = $this->domain->lng(); |
| 80 | + |
| 81 | + $table = $table |
| 82 | + ->textColumn('title', $lng->txt('title'), true); |
| 83 | + |
| 84 | + if ($this->translations->getContentTranslationActivated()) { |
| 85 | + $table = $table->textColumn( |
| 86 | + 'translations', |
| 87 | + $lng->txt('wiki_translations') |
| 88 | + ); |
| 89 | + } |
| 90 | + |
| 91 | + return $table |
| 92 | + ->textColumn('new_pages', $lng->txt('wiki_templ_new_pages')) |
| 93 | + ->textColumn('add_to_page', $lng->txt('wiki_templ_add_to_page')) |
| 94 | + ->singleAction('toggleNewPages', $lng->txt('wiki_templ_new_pages')) |
| 95 | + ->singleAction('toggleAddToPage', $lng->txt('wiki_templ_add_to_page')) |
| 96 | + ->multiAction( |
| 97 | + 'confirmRemove', |
| 98 | + $lng->txt('wiki_remove_template_status'), |
| 99 | + true |
| 100 | + ); |
| 101 | + } |
| 102 | +} |
0 commit comments