ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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;
26
31{
32 protected \ilLanguage $lng;
33 protected ?array $selected_pages = null;
34 protected \ilObjBlog $blog;
35 protected \ilCtrl $ctrl;
36 protected object $access_handler;
37 protected int $style_sheet_id = 0;
38 protected int $node_id = 0;
39
40 public function __construct(
44 int $node_id,
45 object $access_handler,
46 int $style_id,
47 ?array $selected_pages = null
48 ) {
49 $this->lng = $lng;
50 $this->ctrl = $ctrl;
51 $this->blog = $blog;
52 $this->node_id = $node_id;
53 $this->access_handler = $access_handler;
54 $this->style_sheet_id = $style_id;
55
56 $this->selected_pages = $selected_pages;
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 : array_map(static function ($i) {
81 return $i["id"];
82 }, \ilBlogPosting::getAllPostings($this->blog->getId()));
83
84 foreach ($selected_pages as $p_id) {
85 $page_gui = new \ilBlogPostingGUI(
86 $this->node_id,
87 $this->access_handler,
88 $p_id,
89 0,
90 false,
91 false,
92 $this->style_sheet_id
93 );
94 $page_gui->setOutputMode($this->getOutputMode());
95 $print_pages[] = $page_gui->showPage();
96 }
97
98 return $print_pages;
99 }
100
102 {
104 $ilCtrl = $this->ctrl;
105 $postings = \ilBlogPosting::getAllPostings($this->blog->getId());
106 $lng->loadLanguageModule("content");
107 $lng->loadLanguageModule("blog");
108 $form = new \ilPropertyFormGUI();
109
110 //var_dump($pages);
111 // selection type
112 $radg = new \ilRadioGroupInputGUI($lng->txt("cont_selection"), "sel_type");
113 $radg->setValue("page");
114 $op1 = new \ilRadioOption($lng->txt("blog_whole_blog")
115 . " (" . $lng->txt("blog_postings") . ": " . count($postings) . ")", "wiki");
116 $radg->addOption($op1);
117 $op2 = new \ilRadioOption($lng->txt("blog_selected_pages"), "selection");
118 $radg->addOption($op2);
119
120 $nl = new \ilNestedListInputGUI("", "obj_id");
121 $op2->addSubItem($nl);
122
123 foreach ($postings as $p) {
124 $nl->addListNode(
125 (string) $p["id"],
126 $p["title"],
127 "0",
128 false,
129 false,
130 \ilUtil::getImagePath("standard/icon_pg.svg"),
131 $lng->txt("blog_posting")
132 );
133 }
134
135 $form->addItem($radg);
136
137 $form->addCommandButton("printPostings", $lng->txt("blog_show_print_view"));
138
139 $form->setTitle($lng->txt("cont_print_selection"));
140 $form->setFormAction(
141 $ilCtrl->getFormActionByClass(
142 "ilObjBlogGUI",
143 "printPostings"
144 )
145 );
146
147 return $form;
148 }
149}
__construct(\ilLanguage $lng, \ilCtrl $ctrl, \ilObjBlog $blog, int $node_id, object $access_handler, int $style_id, ?array $selected_pages=null)
Collects all js/css/onload resources necessary for page rendering.
Injects resources into a template.
Class ilBlogPosting.
static getAllPostings(int $a_blog_id, int $a_limit=1000, int $a_offset=0)
Get all postings of blog.
Class ilCtrl provides processing control methods.
language handling
loadLanguageModule(string $a_module)
Load language module.
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.
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...