ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\Blog\Export\BlogHtmlExport Class Reference
+ Collaboration diagram for ILIAS\Blog\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\Blog\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\Blog\Export\BlogHtmlExport::collectAllPagesPageElements ( \ilCOPageHTMLExport  $co_page_html_export)

Definition at line 293 of file BlogHtmlExport.php.

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 }
ilCOPageHTMLExport $co_page_html_export
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.

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

+ Here is the call graph for this function:

◆ delete()

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

Definition at line 408 of file BlogHtmlExport.php.

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

◆ exportHTML()

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

Export HTML.

Exceptions

ILIAS\UI\NotImplementedException

Exceptions

ilTemplateException

Definition at line 116 of file BlogHtmlExport.php.

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 }
exportHTMLPagesPrint()
Export all pages as one print version.
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!)

◆ exportHTMLPages()

ILIAS\Blog\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

ILIAS\UI\NotImplementedException

Exceptions

ilTemplateException

Definition at line 160 of file BlogHtmlExport.php.

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 }
writeExportFile(string $a_file, \ilGlobalPageTemplate $a_tpl, string $a_content, string $a_right_content="", bool $a_back=false, string $comments="")
Write HTML to file.
static buildExportLink(string $a_template, string $a_type, string $a_id, array $keywords)
Build static export link.
getInitialisedTemplate(string $a_back_url="")
Get initialised template.
const IL_CAL_DATE
$comments

◆ exportHTMLPagesPrint()

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

Export all pages as one print version.

Definition at line 281 of file BlogHtmlExport.php.

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)

◆ exportUserImages()

ILIAS\Blog\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\Blog\Export\BlogHtmlExport::getFilePath ( )

Definition at line 413 of file BlogHtmlExport.php.

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

◆ getInitialisedTemplate()

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

Get initialised template.

Definition at line 336 of file BlogHtmlExport.php.

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();
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 resetInitialState()
Reset initial state (for exports)
setBackTarget(string $a_title, string $a_target, string $a_frame="")
clearTargets()
clear all targets
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

◆ includeComments()

ILIAS\Blog\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\Blog\Export\BlogHtmlExport::init ( )
protected

Definition at line 89 of file BlogHtmlExport.php.

89 : void
90 {
91 }

◆ initDirectories()

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

Definition at line 104 of file BlogHtmlExport.php.

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

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

+ Here is the call graph for this function:

◆ setPrintVersion()

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

Definition at line 93 of file BlogHtmlExport.php.

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

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

◆ writeExportFile()

ILIAS\Blog\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

ilTemplateException

Definition at line 369 of file BlogHtmlExport.php.

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 }

Field Documentation

◆ $blog

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

Definition at line 29 of file BlogHtmlExport.php.

◆ $blog_gui

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

Definition at line 30 of file BlogHtmlExport.php.

◆ $co_page_html_export

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

Definition at line 36 of file BlogHtmlExport.php.

◆ $collector

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

Definition at line 28 of file BlogHtmlExport.php.

◆ $content_style_domain

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

Definition at line 45 of file BlogHtmlExport.php.

◆ $export_dir

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

Definition at line 31 of file BlogHtmlExport.php.

◆ $export_key_set

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

Definition at line 44 of file BlogHtmlExport.php.

◆ $export_util

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

Definition at line 35 of file BlogHtmlExport.php.

◆ $global_screen

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

Definition at line 34 of file BlogHtmlExport.php.

◆ $include_comments

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

Definition at line 42 of file BlogHtmlExport.php.

◆ $items

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

Definition at line 39 of file BlogHtmlExport.php.

◆ $keyword_export_map

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

Definition at line 40 of file BlogHtmlExport.php.

◆ $keywords

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

Definition at line 41 of file BlogHtmlExport.php.

◆ $lng

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

Definition at line 37 of file BlogHtmlExport.php.

◆ $print_version

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

Definition at line 43 of file BlogHtmlExport.php.

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

◆ $sub_dir

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

Definition at line 32 of file BlogHtmlExport.php.

◆ $tabs

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

Definition at line 38 of file BlogHtmlExport.php.

◆ $target_dir

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

Definition at line 33 of file BlogHtmlExport.php.


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