ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.PortfolioPrintViewProviderGUI.php
Go to the documentation of this file.
1<?php
2
19namespace ILIAS\Portfolio;
20
21use ILIAS\COPage;
22use ILIAS\Export;
24
29{
30 protected bool $include_declaration = false;
32 protected \ilLanguage $lng;
33 protected \ilObjPortfolio $portfolio;
34 protected ?array $selected_pages = null;
35 protected bool $include_signature;
37 protected \ilObjUser $user;
38 protected \ilCtrl $ctrl;
39
40 public function __construct(
44 bool $include_signature = false,
45 ?array $selected_pages = null,
46 bool $include_declaration = false
47 ) {
48 global $DIC;
49
50 $this->lng = $lng;
51 $this->ctrl = $ctrl;
52 $this->portfolio = $portfolio;
53 $this->selected_pages = $selected_pages;
54 $this->include_signature = $include_signature;
55 $this->include_declaration = $include_declaration;
56 $this->port_request = $DIC->portfolio()
57 ->internal()
58 ->gui()
59 ->standardRequest();
60 }
61
65 ): self {
66 $c = clone $this;
67 $c->declaration_of_authorship = $decl;
68 $c->user = $user;
69 return $c;
70 }
71
73 {
75 $ilCtrl = $this->ctrl;
76
77 $pages = \ilPortfolioPage::getAllPortfolioPages($this->portfolio->getId());
78
79
80 $form = new \ilPropertyFormGUI();
81
82 // declaration of authorship
83 if ($this->declaration_of_authorship &&
84 $this->declaration_of_authorship->getForUser($this->user) !== "") {
85 $cb = new \ilCheckboxInputGUI($this->lng->txt("prtf_decl_authorship"), "decl_author");
86 $cb->setInfo($this->declaration_of_authorship->getForUser($this->user));
87 $form->addItem($cb);
88 }
89
90 // signature
91 $cb = new \ilCheckboxInputGUI($this->lng->txt("prtf_signature"), "signature");
92 $cb->setInfo($this->lng->txt("prtf_signature_info"));
93 $form->addItem($cb);
94
95
96 // selection type
97 $radg = new \ilRadioGroupInputGUI($lng->txt("prtf_print_selection"), "sel_type");
98 $radg->setValue("all_pages");
99 $op2 = new \ilRadioOption($lng->txt("prtf_all_pages"), "all_pages");
100 $radg->addOption($op2);
101 $op3 = new \ilRadioOption($lng->txt("prtf_selected_pages"), "selection");
102 $radg->addOption($op3);
103
104 $nl = new \ilNestedListInputGUI("", "obj_id");
105 $op3->addSubItem($nl);
106
107 foreach ($pages as $p) {
108 $nl->addListNode(
109 $p["id"],
110 $p["title"],
111 0,
112 false,
113 false,
114 \ilUtil::getImagePath("standard/icon_pg.svg"),
115 $lng->txt("page")
116 );
117 }
118
119 $form->addItem($radg);
120
121 $form->addCommandButton("showPrintView", $lng->txt("exp_show_print_view"));
122
123 $form->setTitle($lng->txt("prtf_print_options"));
124 $form->setFormAction(
125 $ilCtrl->getFormActionByClass(
126 "ilObjPortfolioGUI",
127 "showPrintView"
128 )
129 );
130
131 return $form;
132 }
133
134 public function getTemplateInjectors(): array
135 {
136 $page = new \ilPortfolioPage();
137 $page->setEmptyPageXml();
138 $resource_collector = new COPage\ResourcesCollector(
140 $page
141 );
142 $resource_injector = new COPage\ResourcesInjector($resource_collector);
143
144 return [
145 function ($tpl) use ($resource_injector) {
146 $resource_injector->inject($tpl);
147 }
148 ];
149 }
150
151 public function getPages(): array
152 {
154 $portfolio = $this->portfolio;
155
157 $portfolio->getId()
158 );
159
160 $print_pages = [];
161
162 // cover page
163 $cover_tpl = new \ilTemplate(
164 "tpl.prtf_cover.html",
165 true,
166 true,
167 "components/ILIAS/Portfolio"
168 );
169 foreach ($pages as $page) {
170 if (is_array($this->selected_pages) &&
171 !in_array($page["id"], $this->selected_pages)) {
172 continue;
173 }
174 $cover_tpl->setCurrentBlock("content_item");
175 $cover_tpl->setVariable("ITEM_TITLE", $page["title"]);
176 $cover_tpl->parseCurrentBlock();
177 }
178
179 if ($this->include_signature) {
180 $cover_tpl->setCurrentBlock("signature");
181 $cover_tpl->setVariable("TXT_SIGNATURE", $lng->txt("prtf_signature_date"));
182 $cover_tpl->parseCurrentBlock();
183 }
184
185 if (!is_null($this->declaration_of_authorship) && $this->include_declaration) {
186 $cover_tpl->setCurrentBlock("decl_author");
187 $cover_tpl->setVariable(
188 "TXT_DECL_AUTHOR",
189 nl2br($this->declaration_of_authorship->getForUser($this->user))
190 );
191 $cover_tpl->parseCurrentBlock();
192 }
193
194 $cover_tpl->setVariable("PORTFOLIO_TITLE", $this->portfolio->getTitle());
195 $cover_tpl->setVariable("PORTFOLIO_ICON", \ilUtil::getImagePath("standard/icon_prtf.svg"));
196
197 $cover_tpl->setVariable("TXT_AUTHOR", $lng->txt("prtf_author"));
198 $cover_tpl->setVariable("TXT_LINK", $lng->txt("prtf_link"));
199 $cover_tpl->setVariable("TXT_DATE", $lng->txt("prtf_date_of_print"));
200 $cover_tpl->setVariable("TXT_TABLE_OF_CONTENTS", $lng->txt("prtf_table_of_contents"));
201
202 $author = \ilObjUser::_lookupName($this->portfolio->getOwner());
203 $author_str = $author["firstname"] . " " . $author["lastname"];
204 $cover_tpl->setVariable("AUTHOR", $author_str);
205
206 $href = \ilLink::_getStaticLink($this->portfolio->getId(), "prtf");
207 $cover_tpl->setVariable("LINK", $href);
208
210 $date_str = \ilDatePresentation::formatDate(new \ilDate(date("Y-m-d"), IL_CAL_DATE));
211 $cover_tpl->setVariable("DATE", $date_str);
212
213 $print_pages[] = $cover_tpl->get();
214
215 $page_head_tpl = new \ilTemplate("tpl.prtf_page_head.html", true, true, "components/ILIAS/Portfolio");
216 $page_head_tpl->setVariable("AUTHOR", $author_str);
217 $page_head_tpl->setVariable("DATE", $date_str);
218 $page_head_str = $page_head_tpl->get();
219
220 foreach ($pages as $page) {
221 if (is_array($this->selected_pages) &&
222 !in_array($page["id"], $this->selected_pages)) {
223 continue;
224 }
225 $page_gui = new \ilPortfolioPageGUI($this->portfolio->getId(), $page["id"]);
226 $page_gui->setOutputMode($this->getOutputMode());
227 $page_gui->setPresentationTitle($page["title"]);
228 $html = $this->ctrl->getHTML($page_gui);
229 $print_pages[] = $page_head_str . $html;
230 }
231
232 return $print_pages;
233 }
234}
Collects all js/css/onload resources necessary for page rendering.
Injects resources into a template.
withDeclarationOfAuthorship(\ilPortfolioDeclarationOfAuthorship $decl, \ilObjUser $user)
__construct(\ilLanguage $lng, \ilCtrl $ctrl, \ilObjPortfolio $portfolio, bool $include_signature=false, ?array $selected_pages=null, bool $include_declaration=false)
const IL_CAL_DATE
Class ilCtrl provides processing control methods.
static setUseRelativeDates(bool $a_status)
set use relative dates
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
Class for single dates.
language handling
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
User class.
static _lookupName(int $a_user_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getAllPortfolioPages(int $a_portfolio_id)
Get pages of portfolio.
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)
$c
Definition: deliver.php:25
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...
global $lng
Definition: privfeed.php:31
global $DIC
Definition: shib_login.php:26