ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
class.WikiPrintViewProviderGUI.php
Go to the documentation of this file.
1<?php
2
19namespace ILIAS\Wiki;
20
21use ILIAS\COPage;
22use ILIAS\Export;
24
30{
31 protected \ilLanguage $lng;
32 protected array|null $selected_pages = null;
33 protected \ilObjWiki $wiki;
34 protected \ilCtrl $ctrl;
35
36 public function __construct(
39 int $wiki_ref_id,
40 ?array $selected_pages
41 ) {
42 $this->lng = $lng;
43 $this->ctrl = $ctrl;
44 $this->wiki = new \ilObjWiki($wiki_ref_id);
45 $this->selected_pages = (!is_null($selected_pages))
47 : array_map(
48 static function ($p) {
49 return $p["id"];
50 },
51 \ilWikiPage::getAllWikiPages($this->wiki->getId())
52 );
53 }
54
55 public function getTemplateInjectors(): array
56 {
57 $page = new \ilWikiPage();
58 $page->setEmptyPageXml();
59 $resource_collector = new COPage\ResourcesCollector(
61 $page
62 );
63 $resource_injector = new COPage\ResourcesInjector($resource_collector);
64
65 return [
66 function ($tpl) use ($resource_injector) {
67 $resource_injector->inject($tpl);
68 }
69 ];
70 }
71
72 public function getPages(): array
73 {
74 $print_pages = [];
75 foreach ($this->selected_pages as $p_id) {
76 $page_gui = new \ilWikiPageGUI(
77 $p_id,
78 0,
79 $this->wiki->getRefId()
80 );
81 $page_gui->setWiki($this->wiki);
82 $page_gui->setOutputMode($this->getOutputMode());
83 $print_pages[] = $page_gui->showPage();
84 }
85
86 return $print_pages;
87 }
88
90 {
92 $ilCtrl = $this->ctrl;
93
95 \ilObject::_lookupObjId($this->wiki->getRefId())
96 );
97
98 $form = new \ilPropertyFormGUI();
99
100 //var_dump($pages);
101 // selection type
102 $radg = new \ilRadioGroupInputGUI($lng->txt("cont_selection"), "sel_type");
103 $radg->setValue("page");
104 $op1 = new \ilRadioOption($lng->txt("cont_current_page"), "page");
105 $radg->addOption($op1);
106 $op2 = new \ilRadioOption($lng->txt("wiki_whole_wiki")
107 . " (" . $lng->txt("wiki_pages") . ": " . count($pages) . ")", "wiki");
108 $radg->addOption($op2);
109 $op3 = new \ilRadioOption($lng->txt("wiki_selected_pages"), "selection");
110 $radg->addOption($op3);
111
112 $nl = new \ilNestedListInputGUI("", "obj_id");
113 $op3->addSubItem($nl);
114
115 foreach ($pages as $p) {
116 $nl->addListNode(
117 $p["id"],
118 $p["title"],
119 0,
120 false,
121 false,
122 \ilUtil::getImagePath("standard/icon_pg.svg"),
123 $lng->txt("wiki_page")
124 );
125 }
126
127 $form->addItem($radg);
128
129 $form->addCommandButton("printViewOrder", $lng->txt("wiki_show_print_view"));
130
131 $form->setTitle($lng->txt("cont_print_selection"));
132 $form->setFormAction(
133 $ilCtrl->getFormActionByClass(
134 "ilWikiPageGUI",
135 "printViewOrder"
136 )
137 );
138
139 return $form;
140 }
141}
Collects all js/css/onload resources necessary for page rendering.
Injects resources into a template.
__construct(\ilLanguage $lng, \ilCtrl $ctrl, int $wiki_ref_id, ?array $selected_pages)
Class ilCtrl provides processing control methods.
language handling
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...
static _lookupObjId(int $ref_id)
This class represents a property form user interface.
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
static getAllWikiPages(int $a_wiki_id, string $lang="-")
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...