ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.PagePrintViewProviderGUI.php
Go to the documentation of this file.
1<?php
2
20
21use ILIAS\Export;
24
29{
30 protected \ILIAS\Survey\Editing\EditingGUIRequest $request;
31 protected \ilObjSurvey $survey;
32 protected int $ref_id;
33 protected \ilLanguage $lng;
34 protected \ilCtrl $ctrl;
35
36 public function __construct(
39 int $ref_id
40 ) {
41 global $DIC;
42
43 $this->request = $DIC->survey()
44 ->internal()
45 ->gui()
46 ->editing()
47 ->request();
48
49 $this->lng = $lng;
50 $this->ctrl = $ctrl;
51 $this->ref_id = $ref_id;
52 $this->survey = new \ilObjSurvey($this->ref_id);
53 }
54
55 public function getTemplateInjectors(): array
56 {
57 return [
58 static function (\ilGlobalTemplate $tpl): void {
59 //$tpl add js/css
60 }
61 ];
62 }
63
65 {
67 $ilCtrl = $this->ctrl;
68
69 $form = new \ilPropertyFormGUI();
70
71 $radg = new \ilRadioGroupInputGUI($lng->txt("svy_selection"), "print_selection");
72 $radg->setValue("page");
73 $op1 = new \ilRadioOption($lng->txt("svy_current_page"), "page");
74 $radg->addOption($op1);
75 $op2 = new \ilRadioOption($lng->txt("svy_all_pages"), "all");
76 $radg->addOption($op2);
77
78 $form->addItem($radg);
79
80 // include labels in print view
81 if ($this->survey->getShowQuestionTitles()) {
82 $cb = new \ilCheckboxInputGUI($lng->txt("svy_print_show_labels"), "include_labels");
83 $form->addItem($cb);
84 }
85
86 $form->addCommandButton("printView", $lng->txt("print_view"));
87
88 $form->setTitle($lng->txt("svy_print_selection"));
89 $ilCtrl->setParameterByClass("ilSurveyEditorGUI", "pg", $this->request->getPage());
90 $form->setFormAction(
91 $ilCtrl->getFormActionByClass(
92 "ilSurveyEditorGUI",
93 "printView"
94 )
95 );
96
97 return $form;
98 }
99
100 public function getPages(): array
101 {
102 $print_pages = [];
103
104
105 $pages = $this->survey->getSurveyPages();
106 if ($this->request->getPrintSelection() === "page") {
107 $pg = $this->request->getPage();
108 if ($pg === 0) {
109 $pg = 1;
110 }
111 $pages = [$pages[$pg - 1]];
112 }
113
114 $question_title_mode = $this->request->getIncludeLables()
115 ? 3
116 : 1;
117
118 foreach ($pages as $page) {
119 $page_renderer = new PageRenderer(
120 $this->survey,
121 $page,
122 [],
123 [],
124 $question_title_mode
125 );
126 $print_pages[] = $page_renderer->render();
127 }
128 return $print_pages;
129 }
130}
__construct(\ilLanguage $lng, \ilCtrl $ctrl, int $ref_id)
Class ilCtrl provides processing control methods.
special template class to simplify handling of ITX/PEAR
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...
This class represents a property form user interface.
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 $DIC
Definition: shib_login.php:26