ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
ILIAS\Wiki\Export\BlogHtmlExport Class Reference
+ Collaboration diagram for ILIAS\Wiki\Export\BlogHtmlExport:

Public Member Functions

 setPrintVersion (bool $print_version)
 
 includeComments (bool $a_include_comments)
 
 exportHTML ()
 Export HTML. More...
 
 exportHTMLPages (?string $a_link_template=null, ?\Closure $a_tpl_callback=null, ?\ilCOPageHTMLExport $a_co_page_html_export=null, string $a_index_name="index.html")
 Export all pages (note: this one is called from the portfolio html export!) More...
 
 exportHTMLPagesPrint ()
 Export all pages as one print version. More...
 
 collectAllPagesPageElements (\ilCOPageHTMLExport $co_page_html_export)
 
 delete ()
 
 getFilePath ()
 

Static Public Member Functions

static buildExportLink (string $a_template, string $a_type, string $a_id, array $keywords)
 Build static export link. More...
 

Protected Member Functions

 init ()
 
 initDirectories ()
 
 exportUserImages ()
 
 getInitialisedTemplate (string $a_back_url="")
 Get initialised template. More...
 
 writeExportFile (string $a_file, \ilGlobalPageTemplate $a_tpl, string $a_content, string $a_right_content="", bool $a_back=false, string $comments="")
 Write HTML to file. More...
 

Protected Attributes

ILIAS components Export HTML ExportCollector $collector
 
ilObjBlog $blog
 
ilObjBlogGUI $blog_gui
 
string $export_dir
 
string $sub_dir
 
string $target_dir
 
ILIAS GlobalScreen Services $global_screen
 
Util $export_util
 
ilCOPageHTMLExport $co_page_html_export
 
ilLanguage $lng
 
ilTabsGUI $tabs
 
array $items
 
array $keywords
 
bool $include_comments = false
 
bool $print_version = false
 
ILIAS Style Content Object ObjectFacade $content_style_domain
 

Static Protected Attributes

static array $keyword_export_map
 
static bool $export_key_set = false
 

Detailed Description

Definition at line 26 of file BlogHtmlExport.php.

Member Function Documentation

◆ buildExportLink()

static ILIAS\Wiki\Export\BlogHtmlExport::buildExportLink ( string  $a_template,
string  $a_type,
string  $a_id,
array  $keywords 
)
static

Build static export link.

Definition at line 306 of file BlogHtmlExport.php.

311  : string {
312  switch ($a_type) {
313  case "list":
314  $a_type = "m";
315  break;
316 
317  case "keyword":
318  if (!isset(self::$keyword_export_map)) {
319  self::$keyword_export_map = array_flip(array_keys($keywords));
320  }
321  $a_id = (string) (self::$keyword_export_map[$a_id] ?? "");
322  $a_type = "k";
323  break;
324 
325  default:
326  $a_type = "p";
327  break;
328  }
329 
330  return str_replace(array("{TYPE}", "{ID}"), array($a_type, $a_id), $a_template);
331  }

◆ collectAllPagesPageElements()

ILIAS\Wiki\Export\BlogHtmlExport::collectAllPagesPageElements ( \ilCOPageHTMLExport  $co_page_html_export)

Definition at line 293 of file BlogHtmlExport.php.

References ilPageObject\_exists(), ilCOPageHTMLExport\collectPageElements(), and ilBlogPosting\getAllPostings().

Referenced by ILIAS\Wiki\Export\BlogHtmlExport\exportHTMLPagesPrint().

293  : void
294  {
295  $pages = \ilBlogPosting::getAllPostings($this->blog->getId(), 0);
296  foreach ($pages as $page) {
297  if (\ilBlogPosting::_exists("blp", $page["id"])) {
298  $co_page_html_export->collectPageElements("blp:pg", $page["id"]);
299  }
300  }
301  }
static getAllPostings(int $a_blog_id, int $a_limit=1000, int $a_offset=0)
Get all postings of blog.
collectPageElements(string $a_type, int $a_id, string $lang="")
Collect page elements (that need to be exported separately)
static _exists(string $a_parent_type, int $a_id, string $a_lang="", bool $a_no_cache=false)
Checks whether page exists.
ilCOPageHTMLExport $co_page_html_export
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ delete()

ILIAS\Wiki\Export\BlogHtmlExport::delete ( )

Definition at line 408 of file BlogHtmlExport.php.

408  : void
409  {
410  $this->collector->delete();
411  }

◆ exportHTML()

ILIAS\Wiki\Export\BlogHtmlExport::exportHTML ( )

Export HTML.

Exceptions

Definition at line 116 of file BlogHtmlExport.php.

References ILIAS\Wiki\Export\BlogHtmlExport\exportHTMLPages(), ILIAS\Wiki\Export\BlogHtmlExport\exportHTMLPagesPrint(), and ILIAS\Wiki\Export\BlogHtmlExport\initDirectories().

116  : void
117  {
118  $this->initDirectories();
119 
120  $this->export_util->exportSystemStyle(
121  [
122  "icon_blog.svg"
123  ]
124  );
125 
126  $this->export_util->exportCOPageFiles(
127  $this->content_style_domain->getEffectiveStyleId(),
128  "blog"
129  );
130  /*
131  \ilObjUser::copyProfilePicturesToDirectory($this->blog->getOwner(), $this->target_dir);
132  */
133  // export pages
134  if ($this->print_version) {
135  $this->exportHTMLPagesPrint();
136  } else {
137  $this->exportHTMLPages();
138  }
139  /*
140  // export comments user images
141  $this->exportUserImages();
142  */
143  $this->export_util->exportResourceFiles();
144  $this->co_page_html_export->exportPageElements();
145  }
exportHTMLPages(?string $a_link_template=null, ?\Closure $a_tpl_callback=null, ?\ilCOPageHTMLExport $a_co_page_html_export=null, string $a_index_name="index.html")
Export all pages (note: this one is called from the portfolio html export!)
exportHTMLPagesPrint()
Export all pages as one print version.
+ Here is the call graph for this function:

◆ exportHTMLPages()

ILIAS\Wiki\Export\BlogHtmlExport::exportHTMLPages ( ?string  $a_link_template = null,
?\Closure  $a_tpl_callback = null,
?\ilCOPageHTMLExport  $a_co_page_html_export = null,
string  $a_index_name = "index.html" 
)

Export all pages (note: this one is called from the portfolio html export!)

Exceptions

Definition at line 160 of file BlogHtmlExport.php.

References $comments, ILIAS\Wiki\Export\BlogHtmlExport\$include_comments, ilPageObject\_exists(), ilBlogPosting\getAllPostings(), ILIAS\Wiki\Export\BlogHtmlExport\getInitialisedTemplate(), IL_CAL_DATE, null, and ILIAS\Wiki\Export\BlogHtmlExport\writeExportFile().

Referenced by ILIAS\Wiki\Export\BlogHtmlExport\exportHTML().

165  : void {
166  if (!$a_link_template) {
167  $a_link_template = "bl{TYPE}_{ID}.html";
168  }
169 
170  if ($a_co_page_html_export) {
171  $this->co_page_html_export = $a_co_page_html_export;
172  }
173 
174  // lists
175 
176  // global nav
177  $nav = $this->blog_gui->renderNavigation("", "", $a_link_template);
178 
179  // month list
180  $has_index = false;
181  foreach (array_keys($this->items) as $month) {
182  $list = $this->blog_gui->renderList($this->items[$month], "render", $a_link_template, false, $this->target_dir);
183 
184  if (!$list) {
185  continue;
186  }
187 
188  if (!$a_tpl_callback) {
189  $tpl = $this->getInitialisedTemplate();
190  } else {
191  $tpl = $a_tpl_callback();
192  }
193 
194  $file = self::buildExportLink($a_link_template, "list", $month, $this->keywords);
195  $file = $this->writeExportFile($file, $tpl, $list, $nav);
196 
197  if (!$has_index) {
198  $file = $this->writeExportFile($a_index_name, $tpl, $list, $nav);
199  $has_index = true;
200  }
201  }
202 
203  // keywords
204  foreach (array_keys($this->blog_gui->getKeywords(false)) as $keyword) {
205  $list_items = $this->blog_gui->filterItemsByKeyword($this->items, $keyword);
206  $list = $this->blog_gui->renderList($list_items, "render", $a_link_template, false, $this->target_dir);
207 
208  if (!$list) {
209  continue;
210  }
211 
212  if (!$a_tpl_callback) {
213  $tpl = $this->getInitialisedTemplate();
214  } else {
215  $tpl = $a_tpl_callback();
216  }
217 
218  $file = self::buildExportLink($a_link_template, "keyword", $keyword, $this->keywords);
219  $file = $this->writeExportFile($file, $tpl, $list, $nav);
220  }
221 
222 
223  // single postings
224 
225  $pages = \ilBlogPosting::getAllPostings($this->blog->getId(), 0);
226  foreach ($pages as $page) {
227  if (\ilBlogPosting::_exists("blp", $page["id"])) {
228  $blp_gui = new \ilBlogPostingGUI(0, null, $page["id"]);
229  $blp_gui->setOutputMode("offline");
230  $blp_gui->setFullscreenLink("fullscreen.html"); // #12930 - see page.xsl
231  $blp_gui->add_date = true;
232  $page_content = $blp_gui->showPage();
233 
234  $back = self::buildExportLink(
235  $a_link_template,
236  "list",
237  substr($page["created"]->get(IL_CAL_DATE), 0, 7),
238  $this->keywords
239  );
240 
241  $file = self::buildExportLink($a_link_template, "posting", (string) $page["id"], $this->keywords);
242 
243  if (!$a_tpl_callback) {
244  $tpl = $this->getInitialisedTemplate();
245  } else {
246  $tpl = $a_tpl_callback();
247  }
248 
250  ? $blp_gui->getCommentsHTMLExport()
251  : "";
252 
253  // posting nav
254  $nav = $this->blog_gui->renderNavigation(
255  "",
256  "",
257  $a_link_template,
258  false,
259  $page["id"]
260  );
261 
262  $this->writeExportFile($file, $tpl, $page_content, $nav, (bool) $back, $comments);
263 
264  $this->co_page_html_export->collectPageElements("blp:pg", $page["id"]);
265  }
266  }
267 
268  if (!$has_index) {
269  if (!$a_tpl_callback) {
270  $tpl = $this->getInitialisedTemplate();
271  } else {
272  $tpl = $a_tpl_callback();
273  }
274  $file = $this->writeExportFile($a_index_name, $tpl, "", $nav);
275  }
276  }
static getAllPostings(int $a_blog_id, int $a_limit=1000, int $a_offset=0)
Get all postings of blog.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static _exists(string $a_parent_type, int $a_id, string $a_lang="", bool $a_no_cache=false)
Checks whether page exists.
$comments
getInitialisedTemplate(string $a_back_url="")
Get initialised template.
const IL_CAL_DATE
writeExportFile(string $a_file, \ilGlobalPageTemplate $a_tpl, string $a_content, string $a_right_content="", bool $a_back=false, string $comments="")
Write HTML to file.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ exportHTMLPagesPrint()

ILIAS\Wiki\Export\BlogHtmlExport::exportHTMLPagesPrint ( )

Export all pages as one print version.

Definition at line 281 of file BlogHtmlExport.php.

References ILIAS\Wiki\Export\BlogHtmlExport\collectAllPagesPageElements().

Referenced by ILIAS\Wiki\Export\BlogHtmlExport\exportHTML().

281  : void
282  {
283  $this->collectAllPagesPageElements($this->co_page_html_export);
284 
285  // render print view
286  $print_view = $this->blog_gui->getPrintView();
287  $print_view->setOffline(true);
288  $html = $print_view->renderPrintView();
289  $this->collector->addString($html, "index.html");
290  }
collectAllPagesPageElements(\ilCOPageHTMLExport $co_page_html_export)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ exportUserImages()

ILIAS\Wiki\Export\BlogHtmlExport::exportUserImages ( )
protected

Definition at line 147 of file BlogHtmlExport.php.

147  : void
148  {
149  if ($this->include_comments) {
150  $user_export = new \ILIAS\Notes\Export\UserImageExporter();
151  $user_export->exportUserImagesForRepObjId($this->target_dir, $this->blog->getId());
152  }
153  }

◆ getFilePath()

ILIAS\Wiki\Export\BlogHtmlExport::getFilePath ( )

Definition at line 413 of file BlogHtmlExport.php.

413  : string
414  {
415  return $this->collector->getFilePath();
416  }

◆ getInitialisedTemplate()

ILIAS\Wiki\Export\BlogHtmlExport::getInitialisedTemplate ( string  $a_back_url = "")
protected

Get initialised template.

Definition at line 336 of file BlogHtmlExport.php.

References $DIC, ilObjStyleSheet\getExportContentStylePath(), ilUtil\getStyleSheetLocation(), ILIAS\Repository\lng(), and ilPCQuestion\resetInitialState().

Referenced by ILIAS\Wiki\Export\BlogHtmlExport\exportHTMLPages().

339  global $DIC;
340 
341  $this->global_screen->layout()->meta()->reset();
342 
343  $location_stylesheet = \ilUtil::getStyleSheetLocation();
344  $this->global_screen->layout()->meta()->addCss($location_stylesheet);
345  $this->global_screen->layout()->meta()->addCss(
347  );
349 
350  $tabs = $DIC->tabs();
351  $tabs->clearTargets();
352  $tabs->clearSubTabs();
353  if ($a_back_url) {
354  $tabs->setBackTarget($this->lng->txt("back"), $a_back_url);
355  }
356  $tpl = new \ilGlobalPageTemplate($DIC->globalScreen(), $DIC->ui(), $DIC->http());
357 
358  $this->co_page_html_export->getPreparedMainTemplate($tpl);
359 
360  $this->blog_gui->renderFullscreenHeader($tpl, $this->blog->getOwner(), true);
361 
362  return $tpl;
363  }
static getStyleSheetLocation(string $mode="output", string $a_css_name="")
get full style sheet file name (path inclusive) of current user
global $DIC
Definition: shib_login.php:26
setBackTarget(string $a_title, string $a_target, string $a_frame="")
clearTargets()
clear all targets
static resetInitialState()
Reset initial state (for exports)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ includeComments()

ILIAS\Wiki\Export\BlogHtmlExport::includeComments ( bool  $a_include_comments)

Definition at line 98 of file BlogHtmlExport.php.

100  : void {
101  $this->include_comments = $a_include_comments;
102  }

◆ init()

ILIAS\Wiki\Export\BlogHtmlExport::init ( )
protected

Definition at line 89 of file BlogHtmlExport.php.

89  : void
90  {
91  }

◆ initDirectories()

ILIAS\Wiki\Export\BlogHtmlExport::initDirectories ( )
protected

Definition at line 104 of file BlogHtmlExport.php.

References ilFileUtils\delDir(), and ilFileUtils\makeDir().

Referenced by ILIAS\Wiki\Export\BlogHtmlExport\exportHTML().

104  : void
105  {
106  // initialize temporary target directory
107  ilFileUtils::delDir($this->target_dir);
108  ilFileUtils::makeDir($this->target_dir);
109  }
static delDir(string $a_dir, bool $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
static makeDir(string $a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setPrintVersion()

ILIAS\Wiki\Export\BlogHtmlExport::setPrintVersion ( bool  $print_version)

Definition at line 93 of file BlogHtmlExport.php.

References ILIAS\Wiki\Export\BlogHtmlExport\$print_version.

93  : void
94  {
95  $this->print_version = $print_version;
96  }

◆ writeExportFile()

ILIAS\Wiki\Export\BlogHtmlExport::writeExportFile ( string  $a_file,
\ilGlobalPageTemplate  $a_tpl,
string  $a_content,
string  $a_right_content = "",
bool  $a_back = false,
string  $comments = "" 
)
protected

Write HTML to file.

Exceptions

Definition at line 369 of file BlogHtmlExport.php.

References $comments, ilGlobalPageTemplate\printToString(), ilGlobalPageTemplate\setContent(), and ilGlobalPageTemplate\setRightContent().

Referenced by ILIAS\Wiki\Export\BlogHtmlExport\exportHTMLPages().

376  : string {
377  $file = $this->target_dir . "/" . $a_file;
378 
379  // export template: page content
380  $ep_tpl = new \ilTemplate(
381  "tpl.export_page.html",
382  true,
383  true,
384  "components/ILIAS/Blog"
385  );
386  if ($a_back) {
387  $ep_tpl->setVariable("PAGE_CONTENT", $a_content);
388  $ep_tpl->setVariable("COMMENTS", $comments);
389  } else {
390  $ep_tpl->setVariable("LIST", $a_content);
391  }
392  $a_tpl->setContent($ep_tpl->get());
393  unset($ep_tpl);
394 
395  // template: right content
396  if ($a_right_content) {
397  $a_tpl->setRightContent($a_right_content);
398  }
399 
400  $content = $a_tpl->printToString();
401 
402  // open file
403  $this->collector->addString($content, $a_file);
404 
405  return $file;
406  }
$comments
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $blog

ilObjBlog ILIAS\Wiki\Export\BlogHtmlExport::$blog
protected

Definition at line 29 of file BlogHtmlExport.php.

◆ $blog_gui

ilObjBlogGUI ILIAS\Wiki\Export\BlogHtmlExport::$blog_gui
protected

Definition at line 30 of file BlogHtmlExport.php.

◆ $co_page_html_export

ilCOPageHTMLExport ILIAS\Wiki\Export\BlogHtmlExport::$co_page_html_export
protected

Definition at line 36 of file BlogHtmlExport.php.

◆ $collector

ILIAS components Export HTML ExportCollector ILIAS\Wiki\Export\BlogHtmlExport::$collector
protected

Definition at line 28 of file BlogHtmlExport.php.

◆ $content_style_domain

ILIAS Style Content Object ObjectFacade ILIAS\Wiki\Export\BlogHtmlExport::$content_style_domain
protected

Definition at line 45 of file BlogHtmlExport.php.

◆ $export_dir

string ILIAS\Wiki\Export\BlogHtmlExport::$export_dir
protected

Definition at line 31 of file BlogHtmlExport.php.

◆ $export_key_set

bool ILIAS\Wiki\Export\BlogHtmlExport::$export_key_set = false
staticprotected

Definition at line 44 of file BlogHtmlExport.php.

◆ $export_util

Util ILIAS\Wiki\Export\BlogHtmlExport::$export_util
protected

Definition at line 35 of file BlogHtmlExport.php.

◆ $global_screen

ILIAS GlobalScreen Services ILIAS\Wiki\Export\BlogHtmlExport::$global_screen
protected

Definition at line 34 of file BlogHtmlExport.php.

◆ $include_comments

bool ILIAS\Wiki\Export\BlogHtmlExport::$include_comments = false
protected

Definition at line 42 of file BlogHtmlExport.php.

Referenced by ILIAS\Wiki\Export\BlogHtmlExport\exportHTMLPages().

◆ $items

array ILIAS\Wiki\Export\BlogHtmlExport::$items
protected

Definition at line 39 of file BlogHtmlExport.php.

◆ $keyword_export_map

array ILIAS\Wiki\Export\BlogHtmlExport::$keyword_export_map
staticprotected

Definition at line 40 of file BlogHtmlExport.php.

◆ $keywords

array ILIAS\Wiki\Export\BlogHtmlExport::$keywords
protected

Definition at line 41 of file BlogHtmlExport.php.

◆ $lng

ilLanguage ILIAS\Wiki\Export\BlogHtmlExport::$lng
protected

Definition at line 37 of file BlogHtmlExport.php.

◆ $print_version

bool ILIAS\Wiki\Export\BlogHtmlExport::$print_version = false
protected

Definition at line 43 of file BlogHtmlExport.php.

Referenced by ILIAS\Wiki\Export\BlogHtmlExport\setPrintVersion().

◆ $sub_dir

string ILIAS\Wiki\Export\BlogHtmlExport::$sub_dir
protected

Definition at line 32 of file BlogHtmlExport.php.

◆ $tabs

ilTabsGUI ILIAS\Wiki\Export\BlogHtmlExport::$tabs
protected

Definition at line 38 of file BlogHtmlExport.php.

◆ $target_dir

string ILIAS\Wiki\Export\BlogHtmlExport::$target_dir
protected

Definition at line 33 of file BlogHtmlExport.php.


The documentation for this class was generated from the following file: