ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilWikiImportantPagesBlockGUI.php
Go to the documentation of this file.
1<?php
2
25{
26 public static string $block_type = "wikiimppages";
27 protected \ILIAS\Wiki\Navigation\ImportantPageManager $imp_pages;
28 protected \ILIAS\Wiki\WikiGUIRequest $wiki_request;
29 protected \ILIAS\Wiki\InternalGUIService $gui;
30 protected \ILIAS\Wiki\Wiki\DomainService $wiki_manager;
31 protected string $lang;
32 protected \ILIAS\Wiki\Page\PageManager $pm;
33 protected \ILIAS\Wiki\InternalDomainService $domain;
34 protected \ILIAS\Wiki\InternalService $service;
35 protected bool $export = false;
36
37 public function __construct()
38 {
39 global $DIC;
40
41 $this->service = $DIC->wiki()->internal();
42
43 $this->domain = $this->service->domain();
44 $this->gui = $this->service->gui();
45 $this->wiki_request = $this->gui->request();
46
47 $ref_id = $this->wiki_request->getRefId();
48 $this->pm = $this->domain->page()->page($ref_id);
49 $this->wiki_manager = $this->domain->wiki();
50 $this->imp_pages = $this->domain->importantPage($ref_id);
51 $this->lang = $this->wiki_request->getTranslation();
52
53 $this->ctrl = $this->gui->ctrl();
54 $this->lng = $this->domain->lng();
55 $this->access = $this->domain->access();
56
58
59 $this->lng->loadLanguageModule("wiki");
60 $this->setEnableNumInfo(false);
61
62 $this->setTitle($this->lng->txt("wiki_navigation"));
63 $this->allow_moving = false;
64 $this->gui = $DIC->wiki()->internal()->gui();
65 }
66
67 public function getBlockType(): string
68 {
69 return self::$block_type;
70 }
71
72 protected function isRepositoryObject(): bool
73 {
74 return false;
75 }
76
80 public function executeCommand()
81 {
82 $ilCtrl = $this->ctrl;
83
84 $next_class = $ilCtrl->getNextClass();
85 $cmd = $ilCtrl->getCmd("getHTML");
86
87 switch ($next_class) {
88 default:
89 return $this->$cmd();
90 }
91 }
92
93 public function getHTML(bool $a_export = false): string
94 {
95 $ilCtrl = $this->ctrl;
97
98 $this->export = $a_export;
99
100 if (!$this->export && ilWikiPerm::check("edit_wiki_navigation", $this->requested_ref_id)) {
101 $this->addBlockCommand(
102 $ilCtrl->getLinkTargetByClass("ilobjwikigui", "editImportantPages"),
103 $lng->txt("edit")
104 );
105 }
106
107 return parent::getHTML();
108 }
109 protected function getLegacyContent(): string
110 {
111 $ilCtrl = $this->ctrl;
112 $cpar[1] = 0;
113
114 $listing = $this->gui->listing();
115
116 $cnt = 1;
117 $start_page_id = $this->wiki_manager->getStartingPageId($this->requested_ref_id);
118
119 if ($this->pm->exists($start_page_id, $this->lang)) {
120 $title = $this->pm->getTitle($start_page_id, $this->lang);
121 if (!$this->export) {
122 $listing->node($this->ui->factory()->link()->standard(
123 $title,
124 $this->pm->getPermaLink($start_page_id, $this->lang)
125 ), "1", "0");
126 } else {
127 $listing->node($this->ui->factory()->link()->standard(
128 $title,
129 "index.html"
130 ), "1", "0");
131 }
132 }
133
134 $cpar[0] = 1;
135
136 foreach ($this->imp_pages->getList() as $p) {
137 if ($this->pm->exists($p->getId(), $this->lang)) {
138 $cnt++;
139 $title = $this->pm->getTitle($p->getId(), $this->lang);
140 if (!$this->export) {
141 $listing->node($this->ui->factory()->link()->standard(
142 $title,
143 $this->pm->getPermaLink($p->getId(), $this->lang)
144 ), (string) $cnt, (string) ($cpar[$p->getIndent() - 1] ?? 0));
145 } else {
146 $listing->node($this->ui->factory()->link()->standard(
147 $title,
148 "wpg_" . $p->getId() . ".html"
149 ), (string) $cnt, (string) ($cpar[$p->getIndent() - 1] ?? 0));
150 }
151 $cpar[$p->getIndent()] = $cnt;
152 }
153 }
154
155 return $listing->render();
156 }
157}
This class represents a block method of a block.
ilLanguage $lng
setTitle(string $a_title)
addBlockCommand(string $a_href, string $a_text, string $a_onclick="", ?RoundTrip $modal=null)
setEnableNumInfo(bool $a_enablenuminfo)
getNextClass($a_gui_class=null)
@inheritDoc
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ILIAS Wiki Navigation ImportantPageManager $imp_pages
isRepositoryObject()
Returns whether block has a corresponding repository object.
ILIAS Wiki InternalDomainService $domain
static check(string $a_perm, int $a_ref_id, string $a_cmd="")
$ref_id
Definition: ltiauth.php:66
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26