ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.BlogPrintViewProviderGUI.php
Go to the documentation of this file.
1 <?php
2 
19 namespace ILIAS\Blog;
20 
21 use ILIAS\COPage;
22 use ILIAS\Export;
24 
29 {
30  protected \ilLanguage $lng;
31  protected ?array $selected_pages = null;
32  protected \ilObjBlog $blog;
33  protected \ilCtrl $ctrl;
34  protected object $access_handler;
35  protected int $style_sheet_id = 0;
36  protected int $node_id = 0;
37 
38  public function __construct(
39  \ilLanguage $lng,
40  \ilCtrl $ctrl,
41  \ilObjBlog $blog,
42  int $node_id,
43  object $access_handler,
44  int $style_id,
45  ?array $selected_pages = null
46  ) {
47  $this->lng = $lng;
48  $this->ctrl = $ctrl;
49  $this->blog = $blog;
50  $this->node_id = $node_id;
51  $this->access_handler = $access_handler;
52  $this->style_sheet_id = $style_id;
53 
54  $this->selected_pages = $selected_pages;
55  }
56 
57  public function getTemplateInjectors(): array
58  {
59  $resource_collector = new COPage\ResourcesCollector(
61  new \ilBlogPosting()
62  );
63  $resource_injector = new COPage\ResourcesInjector($resource_collector);
64 
65  return [
66  function ($tpl) use ($resource_injector) {
67  $resource_injector->inject($tpl);
68  }
69  ];
70  }
71 
72  public function getPages(): array
73  {
74  $print_pages = [];
75 
76  $selected_pages = (count($this->selected_pages) > 0)
77  ? $this->selected_pages
78  : array_map(static function ($i) {
79  return $i["id"];
80  }, \ilBlogPosting::getAllPostings($this->blog->getId()));
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 
99  public function getSelectionForm(): ?ilPropertyFormGUI
100  {
101  $lng = $this->lng;
102  $ilCtrl = $this->ctrl;
103  $postings = \ilBlogPosting::getAllPostings($this->blog->getId());
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  $p["id"],
124  $p["title"],
125  0,
126  false,
127  false,
128  \ilUtil::getImagePath("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  "ilObjBlogGUI",
141  "printPostings"
142  )
143  );
144 
145  return $form;
146  }
147 }
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.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41
$i
Definition: metadata.php:41