ILIAS  trunk Revision v13.0_alpha-52-g21c366bbdd4
class.BlogPrintViewProviderGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21namespace ILIAS\Blog;
22
23use ILIAS\COPage;
24use ILIAS\Export;
27
29{
31 protected \ilLanguage $lng;
32 protected ?array $selected_pages = null;
33 protected \ilObjBlog $blog;
34 protected \ilCtrl $ctrl;
35 protected object $access_handler;
36 protected int $style_sheet_id = 0;
37 protected int $node_id = 0;
38
39 public function __construct(
42 protected int $blog_id,
43 int $node_id,
44 object $access_handler,
45 int $style_id,
46 ?array $selected_pages = null
47 ) {
48 global $DIC;
49 $this->lng = $lng;
50 $this->ctrl = $ctrl;
51 $this->node_id = $node_id;
52 $this->access_handler = $access_handler;
53 $this->style_sheet_id = $style_id;
54
55 $this->selected_pages = $selected_pages;
56 $this->posting_manager = $DIC->blog()->internal()->domain()->posting();
57 }
58
59 public function getTemplateInjectors(): array
60 {
61 $resource_collector = new COPage\ResourcesCollector(
63 new \ilBlogPosting()
64 );
65 $resource_injector = new COPage\ResourcesInjector($resource_collector);
66
67 return [
68 function ($tpl) use ($resource_injector) {
69 $resource_injector->inject($tpl);
70 }
71 ];
72 }
73
74 public function getPages(): array
75 {
76 $print_pages = [];
77
78 $selected_pages = (count($this->selected_pages ?? []) > 0)
79 ? $this->selected_pages
80 : $this->posting_manager->getAllPostingIds($this->blog_id);
81
82 foreach ($selected_pages as $p_id) {
83 $page_gui = new \ilBlogPostingGUI(
84 $this->node_id,
85 $this->access_handler,
86 $p_id,
87 0,
88 false,
89 false,
90 $this->style_sheet_id
91 );
92 $page_gui->setOutputMode($this->getOutputMode());
93 $print_pages[] = $page_gui->showPage();
94 }
95
96 return $print_pages;
97 }
98
100 {
102 $ilCtrl = $this->ctrl;
103 $postings = $this->posting_manager->getAllPostings($this->blog_id);
104 $lng->loadLanguageModule("content");
105 $lng->loadLanguageModule("blog");
106 $form = new \ilPropertyFormGUI();
107
108 //var_dump($pages);
109 // selection type
110 $radg = new \ilRadioGroupInputGUI($lng->txt("cont_selection"), "sel_type");
111 $radg->setValue("page");
112 $op1 = new \ilRadioOption($lng->txt("blog_whole_blog")
113 . " (" . $lng->txt("blog_postings") . ": " . count($postings) . ")", "wiki");
114 $radg->addOption($op1);
115 $op2 = new \ilRadioOption($lng->txt("blog_selected_pages"), "selection");
116 $radg->addOption($op2);
117
118 $nl = new \ilNestedListInputGUI("", "obj_id");
119 $op2->addSubItem($nl);
120
121 foreach ($postings as $p) {
122 $nl->addListNode(
123 (string) $p->getId(),
124 $p->getTitle(),
125 "0",
126 false,
127 false,
128 \ilUtil::getImagePath("standard/icon_pg.svg"),
129 $lng->txt("blog_posting")
130 );
131 }
132
133 $form->addItem($radg);
134
135 $form->addCommandButton("printPostings", $lng->txt("blog_show_print_view"));
136
137 $form->setTitle($lng->txt("cont_print_selection"));
138 $form->setFormAction(
139 $ilCtrl->getFormActionByClass(
140 EditingGUI::class,
141 "printPostings"
142 )
143 );
144
145 return $form;
146 }
147}
__construct(\ilLanguage $lng, \ilCtrl $ctrl, protected int $blog_id, int $node_id, object $access_handler, int $style_id, ?array $selected_pages=null)
@ilCtrl_Calls ILIAS\Blog\Editing\EditingGUI: ilRepositorySearchGUI, ilBlogPostingGUI
Definition: EditingGUI.php:37
Collects all js/css/onload resources necessary for page rendering.
Injects resources into a template.
Class ilBlogPosting.
Class ilCtrl provides processing control methods.
language handling
loadLanguageModule(string $a_module)
Load language module.
txt(string|LanguageIdentifier $a_topic, ?int $n=null)
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.
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
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...
readonly ilGlobalTemplateInterface $tpl
global $DIC
Definition: shib_login.php:26