ILIAS  trunk Revision v11.0_alpha-1861-g09f3d197f78
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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...
 
 zipPackage ()
 
 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 323 of file BlogHtmlExport.php.

328  : string {
329  switch ($a_type) {
330  case "list":
331  $a_type = "m";
332  break;
333 
334  case "keyword":
335  if (!isset(self::$keyword_export_map)) {
336  self::$keyword_export_map = array_flip(array_keys($keywords));
337  }
338  $a_id = (string) (self::$keyword_export_map[$a_id] ?? "");
339  $a_type = "k";
340  break;
341 
342  default:
343  $a_type = "p";
344  break;
345  }
346 
347  return str_replace(array("{TYPE}", "{ID}"), array($a_type, $a_id), $a_template);
348  }

◆ collectAllPagesPageElements()

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

Definition at line 310 of file BlogHtmlExport.php.

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

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

310  : void
311  {
312  $pages = \ilBlogPosting::getAllPostings($this->blog->getId(), 0);
313  foreach ($pages as $page) {
314  if (\ilBlogPosting::_exists("blp", $page["id"])) {
315  $co_page_html_export->collectPageElements("blp:pg", $page["id"]);
316  }
317  }
318  }
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 426 of file BlogHtmlExport.php.

426  : void
427  {
428  $this->collector->delete();
429  }

◆ 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(), ILIAS\Wiki\Export\BlogHtmlExport\initDirectories(), and ILIAS\Wiki\Export\BlogHtmlExport\zipPackage().

116  : string
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 
146  return $this->zipPackage();
147  }
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 177 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().

182  : void {
183  if (!$a_link_template) {
184  $a_link_template = "bl{TYPE}_{ID}.html";
185  }
186 
187  if ($a_co_page_html_export) {
188  $this->co_page_html_export = $a_co_page_html_export;
189  }
190 
191  // lists
192 
193  // global nav
194  $nav = $this->blog_gui->renderNavigation("", "", $a_link_template);
195 
196  // month list
197  $has_index = false;
198  foreach (array_keys($this->items) as $month) {
199  $list = $this->blog_gui->renderList($this->items[$month], "render", $a_link_template, false, $this->target_dir);
200 
201  if (!$list) {
202  continue;
203  }
204 
205  if (!$a_tpl_callback) {
206  $tpl = $this->getInitialisedTemplate();
207  } else {
208  $tpl = $a_tpl_callback();
209  }
210 
211  $file = self::buildExportLink($a_link_template, "list", $month, $this->keywords);
212  $file = $this->writeExportFile($file, $tpl, $list, $nav);
213 
214  if (!$has_index) {
215  $file = $this->writeExportFile($a_index_name, $tpl, $list, $nav);
216  $has_index = true;
217  }
218  }
219 
220  // keywords
221  foreach (array_keys($this->blog_gui->getKeywords(false)) as $keyword) {
222  $list_items = $this->blog_gui->filterItemsByKeyword($this->items, $keyword);
223  $list = $this->blog_gui->renderList($list_items, "render", $a_link_template, false, $this->target_dir);
224 
225  if (!$list) {
226  continue;
227  }
228 
229  if (!$a_tpl_callback) {
230  $tpl = $this->getInitialisedTemplate();
231  } else {
232  $tpl = $a_tpl_callback();
233  }
234 
235  $file = self::buildExportLink($a_link_template, "keyword", $keyword, $this->keywords);
236  $file = $this->writeExportFile($file, $tpl, $list, $nav);
237  }
238 
239 
240  // single postings
241 
242  $pages = \ilBlogPosting::getAllPostings($this->blog->getId(), 0);
243  foreach ($pages as $page) {
244  if (\ilBlogPosting::_exists("blp", $page["id"])) {
245  $blp_gui = new \ilBlogPostingGUI(0, null, $page["id"]);
246  $blp_gui->setOutputMode("offline");
247  $blp_gui->setFullscreenLink("fullscreen.html"); // #12930 - see page.xsl
248  $blp_gui->add_date = true;
249  $page_content = $blp_gui->showPage();
250 
251  $back = self::buildExportLink(
252  $a_link_template,
253  "list",
254  substr($page["created"]->get(IL_CAL_DATE), 0, 7),
255  $this->keywords
256  );
257 
258  $file = self::buildExportLink($a_link_template, "posting", (string) $page["id"], $this->keywords);
259 
260  if (!$a_tpl_callback) {
261  $tpl = $this->getInitialisedTemplate();
262  } else {
263  $tpl = $a_tpl_callback();
264  }
265 
267  ? $blp_gui->getCommentsHTMLExport()
268  : "";
269 
270  // posting nav
271  $nav = $this->blog_gui->renderNavigation(
272  "",
273  "",
274  $a_link_template,
275  false,
276  $page["id"]
277  );
278 
279  $this->writeExportFile($file, $tpl, $page_content, $nav, (bool) $back, $comments);
280 
281  $this->co_page_html_export->collectPageElements("blp:pg", $page["id"]);
282  }
283  }
284 
285  if (!$has_index) {
286  if (!$a_tpl_callback) {
287  $tpl = $this->getInitialisedTemplate();
288  } else {
289  $tpl = $a_tpl_callback();
290  }
291  $file = $this->writeExportFile($a_index_name, $tpl, "", $nav);
292  }
293  }
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 298 of file BlogHtmlExport.php.

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

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

298  : void
299  {
300  $this->collectAllPagesPageElements($this->co_page_html_export);
301 
302  // render print view
303  $print_view = $this->blog_gui->getPrintView();
304  $print_view->setOffline(true);
305  $html = $print_view->renderPrintView();
306  file_put_contents($this->target_dir . "/index.html", $html);
307  }
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 149 of file BlogHtmlExport.php.

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

◆ getFilePath()

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

Definition at line 431 of file BlogHtmlExport.php.

431  : string
432  {
433  return $this->collector->getFilePath();
434  }

◆ getInitialisedTemplate()

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

Get initialised template.

Definition at line 353 of file BlogHtmlExport.php.

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

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

356  global $DIC;
357 
358  $this->global_screen->layout()->meta()->reset();
359 
360  $location_stylesheet = \ilUtil::getStyleSheetLocation();
361  $this->global_screen->layout()->meta()->addCss($location_stylesheet);
362  $this->global_screen->layout()->meta()->addCss(
364  );
366 
367  $tabs = $DIC->tabs();
368  $tabs->clearTargets();
369  $tabs->clearSubTabs();
370  if ($a_back_url) {
371  $tabs->setBackTarget($this->lng->txt("back"), $a_back_url);
372  }
373  $tpl = new \ilGlobalPageTemplate($DIC->globalScreen(), $DIC->ui(), $DIC->http());
374 
375  $this->co_page_html_export->getPreparedMainTemplate($tpl);
376 
377  $this->blog_gui->renderFullscreenHeader($tpl, $this->blog->getOwner(), true);
378 
379  return $tpl;
380  }
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:22
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 386 of file BlogHtmlExport.php.

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

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

393  : string {
394  $file = $this->target_dir . "/" . $a_file;
395 
396  // export template: page content
397  $ep_tpl = new \ilTemplate(
398  "tpl.export_page.html",
399  true,
400  true,
401  "components/ILIAS/Blog"
402  );
403  if ($a_back) {
404  $ep_tpl->setVariable("PAGE_CONTENT", $a_content);
405  $ep_tpl->setVariable("COMMENTS", $comments);
406  } else {
407  $ep_tpl->setVariable("LIST", $a_content);
408  }
409  $a_tpl->setContent($ep_tpl->get());
410  unset($ep_tpl);
411 
412  // template: right content
413  if ($a_right_content) {
414  $a_tpl->setRightContent($a_right_content);
415  }
416 
417  $content = $a_tpl->printToString();
418 
419  // open file
420  // file_put_contents($file, $content);
421  $this->collector->addString($content, $a_file);
422 
423  return $file;
424  }
$comments
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ zipPackage()

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

Definition at line 157 of file BlogHtmlExport.php.

References ILIAS\Wiki\Export\BlogHtmlExport\$include_comments, ilExport\_getExportDirectory(), ilFileUtils\delDir(), IL_INST_ID, and ilFileUtils\zip().

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

157  : string
158  {
159  // zip it all
160  $date = time();
161  $type = ($this->include_comments)
162  ? "html_comments"
163  : "html";
164  $zip_file = \ilExport::_getExportDirectory($this->blog->getId(), $type, "blog") .
165  "/" . $date . "__" . IL_INST_ID . "__" .
166  $this->blog->getType() . "_" . $this->blog->getId() . ".zip";
167  ilFileUtils::zip($this->target_dir, $zip_file);
168  ilFileUtils::delDir($this->target_dir);
169  return $zip_file;
170  }
const IL_INST_ID
Definition: constants.php:40
static _getExportDirectory(int $a_obj_id, string $a_type="xml", string $a_obj_type="", string $a_entity="")
Get export directory for an repository object
static delDir(string $a_dir, bool $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
static zip(string $a_dir, string $a_file, bool $compress_content=false)
+ 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

◆ $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: