ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.BlogPrintViewProviderGUI.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
21 namespace ILIAS\Blog;
22 
23 use ILIAS\COPage;
24 use 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(
41  \ilLanguage $lng,
42  \ilCtrl $ctrl,
43  \ilObjBlog $blog,
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  {
103  $lng = $this->lng;
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  $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 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getAllPostings(int $a_blog_id, int $a_limit=1000, int $a_offset=0)
Get all postings of blog.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(\ilLanguage $lng, \ilCtrl $ctrl, \ilObjBlog $blog, int $node_id, object $access_handler, int $style_id, ?array $selected_pages=null)
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
Injects resources into a template.
Collects all js/css/onload resources necessary for page rendering.
Class ilObjBlog.
getSelectionForm()
form which is featured in the modal form target is modified to open in new window (not yet possible w...
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...
Definition: PageLinker.php:19