ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
ilCOPageHTMLExport Class Reference

HTML export class for pages. More...

+ Collaboration diagram for ilCOPageHTMLExport:

Public Member Functions

 __construct (string $a_exp_dir, \ILIAS\COPage\PageLinker $linker=null, int $ref_id=0, protected ?ExportCollector $export_collector=null)
 
 setContentStyleId (int $a_val)
 
 getContentStyleId ()
 
 createDirectories ()
 
 exportStyles ()
 Export content style. More...
 
 exportSupportScripts ()
 Export support scripts. More...
 
 getPreparedMainTemplate (ilGlobalTemplateInterface $a_tpl=null)
 
 collectPageElements (string $a_type, int $a_id, string $lang="")
 Collect page elements (that need to be exported separately) More...
 
 exportPageElements (callable $a_update_callback=null)
 Export page elements. More...
 
 exportHTMLMOB (int $a_mob_id, array &$a_linked_mobs)
 Export media object to html. More...
 
 exportHTMLFile (string $a_file_id)
 Export file object. More...
 
 exportHTMLFileDirect (string $a_file_id, string $a_source_file, string $a_file_name)
 Export file from path. More...
 
 exportHTMLGlossaryTerms ()
 

Protected Member Functions

 exportResourceFile (string $target_dir, string $file)
 
 initResourceTemplate (string $template_file)
 Get resource template. More...
 
 renderMob (\ilObjMediaObject $mob_obj, string $link_xml, array $params)
 Render Mob. More...
 
 exportQuestionFiles ()
 Export question images. More...
 

Protected Attributes

ILIAS MediaObjects MediaObjectManager $media_manager
 
ILIAS Style Content InternalDomainService $content_style
 
ILIAS COPage Xsl XslManager $xsl
 
string $css_dir = ""
 
string $js_yahoo_dir = ""
 
string $js_dir = ""
 
string $media_service_dir = ""
 
string $services_dir = ""
 
string $content_style_img_dir = ""
 
string $content_style_dir = ""
 
string $tex_dir = ""
 
string $files_dir = ""
 
string $mobs_dir = ""
 
array $mobs = []
 
array $glossary_terms = []
 
array $files = []
 
array $files_direct = []
 
array $int_links = []
 
array $q_ids = []
 
string $exp_dir = ""
 
int $content_style_id = 0
 
ilObjUser $user
 
ilLogger $log
 
ILIAS GlobalScreen Services $global_screen
 
ILIAS Skill Service SkillTreeService $skill_tree_service
 
ILIAS Skill Service SkillPersonalService $skill_personal_service
 
ILIAS COPage PageLinker $page_linker
 
int $ref_id
 

Detailed Description

HTML export class for pages.

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

Definition at line 26 of file class.ilCOPageHTMLExport.php.

Constructor & Destructor Documentation

◆ __construct()

ilCOPageHTMLExport::__construct ( string  $a_exp_dir,
\ILIAS\COPage\PageLinker  $linker = null,
int  $ref_id = 0,
protected ?ExportCollector  $export_collector = null 
)

Definition at line 57 of file class.ilCOPageHTMLExport.php.

References $DIC, $ref_id, ilLoggerFactory\getLogger(), and ILIAS\Repository\user().

62  {
63  global $DIC;
64  $this->log = ilLoggerFactory::getLogger('copg');
65  $this->user = $DIC->user();
66  $this->global_screen = $DIC->globalScreen();
67  $this->skill_tree_service = $DIC->skills()->tree();
68  $this->skill_personal_service = $DIC->skills()->personal();
69  $this->page_linker = is_null($linker)
70  ? new ilPageLinker("", true)
71  : $linker;
72  $this->ref_id = $ref_id;
73 
74  $this->exp_dir = $a_exp_dir;
75  $this->mobs_dir = $a_exp_dir . "/mobs";
76  $this->files_dir = $a_exp_dir . "/files";
77  $this->tex_dir = $a_exp_dir . "/teximg";
78  $this->content_style_dir = $a_exp_dir . "/content_style";
79  $this->content_style_img_dir = $a_exp_dir . "/content_style/images";
80 
81  $this->services_dir = $a_exp_dir . "/components/ILIAS";
82  $this->media_service_dir = $this->services_dir . "/MediaObjects";
83 
84  $this->js_dir = $a_exp_dir . '/js';
85  $this->js_yahoo_dir = $a_exp_dir . '/js/yahoo';
86  $this->css_dir = $a_exp_dir . '/css';
87  $this->xsl = $DIC->copage()->internal()->domain()->xsl();
88  $this->content_style = $DIC->contentStyle()->internal()->domain();
89  $this->media_manager = $DIC->mediaObjects()->internal()->domain()->mediaObject();
90  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getLogger(string $a_component_id)
Get component logger.
global $DIC
Definition: shib_login.php:25
+ Here is the call graph for this function:

Member Function Documentation

◆ collectPageElements()

ilCOPageHTMLExport::collectPageElements ( string  $a_type,
int  $a_id,
string  $lang = "" 
)

Collect page elements (that need to be exported separately)

Definition at line 259 of file class.ilCOPageHTMLExport.php.

References Vendor\Package\$f, $user_id, ilObjMediaObject\_getMobsOfObject(), ilPCQuestion\_getQuestionIdsForPage(), ilInternalLink\_getTargetsOfSource(), ilSkillTemplateReference\_lookupTemplateId(), ilObject\_lookupTitle(), ilSkillTreeNode\_lookupType(), ilObject\_lookupType(), ilSkillTreeNodeFactory\getInstance(), ilPageContentUsage\getUsagesOfPage(), and ILIAS\Repository\int().

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

263  : void {
264  $this->log->debug("collect page elements");
265 
266  // collect all dependent pages (only one level deep)
267  $pages[] = [
268  "type" => $a_type,
269  "id" => $a_id
270  ];
271 
272  // ... content includes
273  $pcs = ilPageContentUsage::getUsagesOfPage($a_id, $a_type, 0, false, $lang);
274  foreach ($pcs as $pc) {
275  // content includes
276  if ($pc["type"] == "incl") {
277  $pages[] = [
278  "type" => "mep:pg",
279  "id" => $pc["id"]
280  ];
281  }
282  }
283 
284  // ... internal links
285  $pg_links = \ilInternalLink::_getTargetsOfSource($a_type, $a_id, $lang);
286  $this->int_links = array_merge($this->int_links, $pg_links);
287  $this->glossary_terms = [];
288 
289  // ... glossary pages of internal links
290  foreach ($this->int_links as $int_link) {
291  if ($int_link["type"] == "git") {
292  $this->glossary_terms[] = $int_link["id"];
293  // store linked/embedded media objects of glosssary term
294  $pages[] = [
295  "type" => "term:pg",
296  "id" => $int_link["id"]
297  ];
298  }
299  }
300 
301  // resources of pages
302  foreach ($pages as $page) {
303  $page_id = $page["id"];
304  $page_type = $page["type"];
305 
306  // collect media objects
307  $pg_mobs = ilObjMediaObject::_getMobsOfObject($page_type, $page_id, 0, $lang);
308  foreach ($pg_mobs as $pg_mob) {
309  $this->mobs[$pg_mob] = $pg_mob;
310  $this->log->debug("HTML Export: Add media object $pg_mob (" . \ilObject::_lookupTitle($pg_mob) . ") " .
311  " due to page $page_id, $page_type ).");
312  }
313 
314  // collect all files
315  $files = ilObjFile::_getFilesOfObject($page_type, $page_id, 0, $lang);
316  foreach ($files as $f) {
317  $this->files[$f] = $f;
318  }
319 
320  // collect all questions
321  $q_ids = \ilPCQuestion::_getQuestionIdsForPage($a_type, $a_id, $lang);
322  foreach ($q_ids as $q_id) {
323  $this->q_ids[$q_id] = $q_id;
324  }
325  }
326 
327  // collect page content items
328  $skill_tree = $ws_tree = null;
329 
330  // skills
331  foreach ($pcs as $pc) {
332  if ($pc["type"] == "skmg") {
333  $skill_id = $pc["id"];
334 
335  // trying to find user id
336  $user_id = null;
337  switch ($a_type) {
338  case "prtf:pg":
339  $page = new ilPortfolioPage($a_id);
340  $user_id = $page->getCreationUserId();
341  break;
342 
343  default:
344  // :TODO:
345  break;
346  }
347 
348  if ($user_id) {
349  // we only need 1 instance each
350  if (!$skill_tree) {
351  $skill_tree = $this->skill_tree_service->getGlobalSkillTree();
352 
353  $ws_tree = new ilWorkspaceTree($user_id);
354  }
355 
356  // walk skill tree
357  $skill_id = (int) $skill_id;
358  $vtree = $this->skill_tree_service->getVirtualSkillTreeForNodeId($skill_id);
359  $tref_id = 0;
360  if (ilSkillTreeNode::_lookupType($skill_id) == "sktr") {
361  $tref_id = $skill_id;
362  $skill_id = ilSkillTemplateReference::_lookupTemplateId($skill_id);
363  }
364  $b_skills = $vtree->getSubTreeForCSkillId($skill_id . ":" . $tref_id, true);
365 
366  foreach ($b_skills as $bs) {
367  $skill = ilSkillTreeNodeFactory::getInstance($bs["skill_id"]);
368  $level_data = $skill->getLevelData();
369  foreach ($level_data as $k => $v) {
370  // get assigned materials from personal skill
371  $mat = $this->skill_personal_service->getAssignedMaterials($user_id, $bs["tref_id"], $v["id"]);
372  if (count($mat)) {
373  foreach ($mat as $item) {
374  $wsp_id = $item->getWorkspaceId();
375  $obj_id = $ws_tree->lookupObjectId($wsp_id);
376 
377  // all possible material types for now
378  switch (ilObject::_lookupType($obj_id)) {
379  case "file":
380  $this->files[$obj_id] = $obj_id;
381  break;
382 
383  case "tstv":
384  $obj = new ilObjTestVerification($obj_id, false);
385  $this->files_direct[$obj_id] = array($obj->getFilePath(),
386  $obj->getOfflineFilename());
387  break;
388 
389  case "excv":
390  $obj = new ilObjExerciseVerification($obj_id, false);
391  $this->files_direct[$obj_id] = array($obj->getFilePath(),
392  $obj->getOfflineFilename());
393  break;
394 
395  case "crsv":
396  $obj = new ilObjCourseVerification($obj_id, false);
397  $this->files_direct[$obj_id] = array($obj->getFilePath(),
398  $obj->getOfflineFilename());
399  break;
400 
401  case "cmxv":
402  $obj = new ilObjCmiXapiVerification($obj_id, false);
403  $this->files_direct[$obj_id] = array($obj->getFilePath(),
404  $obj->getOfflineFilename());
405  break;
406 
407  case "ltiv":
408  $obj = new ilObjLTIConsumerVerification($obj_id, false);
409  $this->files_direct[$obj_id] = array($obj->getFilePath(),
410  $obj->getOfflineFilename());
411  break;
412 
413  case "scov":
414  $obj = new ilObjSCORMVerification($obj_id, false);
415  $this->files_direct[$obj_id] = array($obj->getFilePath(),
416  $obj->getOfflineFilename());
417  break;
418  }
419  }
420  }
421  }
422  }
423  }
424  }
425  }
426  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getUsagesOfPage(int $a_usage_id, string $a_usage_type, int $a_hist_nr=0, bool $a_all_hist_nrs=false, string $a_lang="-")
Get page content usages for page.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookupType(int $a_obj_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookupTitle(int $obj_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _getMobsOfObject(string $a_type, int $a_id, int $a_usage_hist_nr=0, string $a_lang="-")
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookupType(int $id, bool $reference=false)
static _getQuestionIdsForPage(string $a_parent_type, int $a_page_id, string $a_lang="-")
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createDirectories()

ilCOPageHTMLExport::createDirectories ( )

Definition at line 102 of file class.ilCOPageHTMLExport.php.

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

102  : void
103  {
104  ilFileUtils::makeDir($this->mobs_dir);
105  ilFileUtils::makeDir($this->files_dir);
106  ilFileUtils::makeDir($this->tex_dir);
107  ilFileUtils::makeDir($this->content_style_dir);
108  ilFileUtils::makeDir($this->content_style_img_dir);
109  ilFileUtils::makeDir($this->services_dir);
110  ilFileUtils::makeDir($this->media_service_dir);
111 
112  ilFileUtils::makeDirParents($this->js_dir);
113  ilFileUtils::makeDirParents($this->js_yahoo_dir);
114  ilFileUtils::makeDirParents($this->css_dir);
115  ilFileUtils::makeDirParents($this->css_dir . "/yahoo");
116  }
static makeDirParents(string $a_dir)
Create a new directory and all parent directories.
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:

◆ exportHTMLFile()

ilCOPageHTMLExport::exportHTMLFile ( string  $a_file_id)

Export file object.

Definition at line 591 of file class.ilCOPageHTMLExport.php.

References ilFileUtils\makeDir().

Referenced by exportPageElements().

591  : void
592  {
593  $file_dir = $this->files_dir . "/file_" . $a_file_id;
594  ilFileUtils::makeDir($file_dir);
595 
596  $file_obj = new ilObjFile($a_file_id, false);
597  $source_file = $file_obj->getFile($file_obj->getVersion());
598  if (!is_file($source_file)) {
599  $source_file = $file_obj->getFile();
600  }
601  if (is_file($source_file)) {
602  copy($source_file, $file_dir . "/" . $file_obj->getFileName());
603  }
604  }
Class ilObjFile.
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:

◆ exportHTMLFileDirect()

ilCOPageHTMLExport::exportHTMLFileDirect ( string  $a_file_id,
string  $a_source_file,
string  $a_file_name 
)

Export file from path.

Definition at line 609 of file class.ilCOPageHTMLExport.php.

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

Referenced by exportPageElements().

613  : void {
614  $file_dir = $this->files_dir . "/file_" . $a_file_id;
615  ilFileUtils::makeDir($file_dir);
616 
617  if (is_file($a_source_file)) {
618  copy(
619  $a_source_file,
620  $file_dir . "/" . ilFileUtils::getASCIIFilename($a_file_name)
621  );
622  }
623  }
static getASCIIFilename(string $a_filename)
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:

◆ exportHTMLGlossaryTerms()

ilCOPageHTMLExport::exportHTMLGlossaryTerms ( )

Definition at line 642 of file class.ilCOPageHTMLExport.php.

References ilGlossaryTerm\_exists(), and initResourceTemplate().

Referenced by exportPageElements().

642  : void
643  {
644  foreach ($this->glossary_terms as $term_id) {
645  if (!ilGlossaryTerm::_exists($term_id)) {
646  continue;
647  }
648  $tpl = $this->initResourceTemplate("tpl.glossary_term_output.html");
649 
650  $term_gui = new ilGlossaryTermGUI($term_id);
651  $term_gui->setPageLinker($this->page_linker);
652  $term_gui->setOfflineDirectory($this->exp_dir);
653  $term_gui->output(true, $tpl);
654 
655  // write file
656  $html = $tpl->printToString();
657  $file = $this->exp_dir . "/term_" . $term_id . ".html";
658  $fp = fopen($file, "w+");
659  fwrite($fp, $html);
660  fclose($fp);
661  }
662  }
static _exists(int $a_id)
checks whether a glossary term with specified id exists or not
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
initResourceTemplate(string $template_file)
Get resource template.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ exportHTMLMOB()

ilCOPageHTMLExport::exportHTMLMOB ( int  $a_mob_id,
array &  $a_linked_mobs 
)

Export media object to html.

Definition at line 498 of file class.ilCOPageHTMLExport.php.

References $params, $ref_id, ilMediaItem\_getMapAreasIntLinks(), ilUtil\getImagePath(), ilFileUtils\getWebspaceDir(), initResourceTemplate(), ilObjMediaObject\isTypeAllowed(), ilFileUtils\makeDir(), ilFileUtils\rCopy(), and renderMob().

Referenced by exportPageElements().

501  : void {
502  $this->log->debug("export html mobs");
503 
504  if (is_null($this->export_collector)) {
505  $source_dir = ilFileUtils::getWebspaceDir() . "/mobs/mm_" . $a_mob_id;
506  if (is_dir($source_dir)) {
507  ilFileUtils::makeDir($this->mobs_dir . "/mm_" . $a_mob_id);
508  ilFileUtils::rCopy($source_dir, $this->mobs_dir . "/mm_" . $a_mob_id);
509  }
510  } else {
511  $mob_res_id = $this->media_manager->getContainerResourceId($a_mob_id);
512  if ($mob_res_id) {
513  $this->export_collector->addContainerDirectory(
514  $mob_res_id->serialize(),
515  "",
516  "/mobs/mm_" . $a_mob_id,
517  );
518  }
519  }
520 
521  $mob_obj = new ilObjMediaObject($a_mob_id);
522 
523  $tpl = $this->initResourceTemplate("tpl.fullscreen.html");
524  $med_links = ilMediaItem::_getMapAreasIntLinks($a_mob_id);
525  $link_xml = $this->page_linker->getLinkXML($med_links);
526 
527  $params = [
528  "mode" => "media",
529  'enlarge_path' => ilUtil::getImagePath("media/enlarge.svg", false, "output", true),
530  'enable_html_mob' => ilObjMediaObject::isTypeAllowed("html") ? "y" : "n",
531  'fullscreen_link' => $this->page_linker->getFullScreenLink()
532  ];
533  if ($this->ref_id > 0) {
534  $params["ref_id"] = $this->ref_id;
535  $params["link_params"] = "ref_id=" . $this->ref_id;
536  }
537 
538  $tpl->setVariable("MEDIA_CONTENT", $this->renderMob($mob_obj, $link_xml, $params));
539  $html = $tpl->printToString();
540  if (is_null($this->export_collector)) {
541  $file = $this->exp_dir . "/media_" . $a_mob_id . ".html";
542  $fp = fopen($file, "w+");
543  fwrite($fp, $html);
544  fclose($fp);
545  unset($fp);
546  } else {
547  $this->export_collector->addString($html, "/media_" . $a_mob_id . ".html");
548  }
549 
550  if ($mob_obj->hasFullscreenItem()) {
551  $tpl = $this->initResourceTemplate("tpl.fullscreen.html");
552  $params["mode"] = "fullscreen";
553  $tpl->setVariable("MEDIA_CONTENT", $this->renderMob($mob_obj, $link_xml, $params));
554  $html = $tpl->printToString();
555  if (is_null($this->export_collector)) {
556  $file = $this->exp_dir . "/fullscreen_" . $a_mob_id . ".html";
557  $fp = fopen($file, "w+");
558  fwrite($fp, $html);
559  fclose($fp);
560  unset($fp);
561  } else {
562  $this->export_collector->addString($html, "/fullscreen_" . $a_mob_id . ".html");
563  }
564  }
565 
566  $linked_mobs = $mob_obj->getLinkedMediaObjects();
567  $a_linked_mobs = array_merge($a_linked_mobs, $linked_mobs);
568  }
static getWebspaceDir(string $mode="filesystem")
get webspace directory
renderMob(\ilObjMediaObject $mob_obj, string $link_xml, array $params)
Render Mob.
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
Definition: ltiregstart.php:31
static rCopy(string $a_sdir, string $a_tdir, bool $preserveTimeAttributes=false)
Copies content of a directory $a_sdir recursively to a directory $a_tdir.
static isTypeAllowed(string $a_type)
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
static _getMapAreasIntLinks(int $a_mob_id)
get all internal links of map areas of a mob
initResourceTemplate(string $template_file)
Get resource template.
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:

◆ exportPageElements()

ilCOPageHTMLExport::exportPageElements ( callable  $a_update_callback = null)

Export page elements.

Definition at line 431 of file class.ilCOPageHTMLExport.php.

References ilObject\_exists(), ilObject\_lookupType(), exportHTMLFile(), exportHTMLFileDirect(), exportHTMLGlossaryTerms(), exportHTMLMOB(), and exportQuestionFiles().

433  : void {
434  $this->log->debug("export page elements");
435 
436  $total = count($this->mobs) + count($this->files) + count($this->files_direct);
437  $cnt = 0;
438  // export all media objects
439  $linked_mobs = array();
440  foreach ($this->mobs as $mob) {
441  if (ilObject::_exists($mob) && ilObject::_lookupType($mob) == "mob") {
442  $this->exportHTMLMOB($mob, $linked_mobs);
443  }
444  if (is_callable($a_update_callback)) {
445  $cnt++;
446  $a_update_callback($total, $cnt);
447  }
448  }
449  $linked_mobs2 = array(); // mobs linked in link areas
450  foreach ($linked_mobs as $mob) {
451  if (ilObject::_exists($mob)) {
452  $this->exportHTMLMOB($mob, $linked_mobs2);
453  }
454  }
455 
456  // export all file objects
457  foreach ($this->files as $file) {
458  $this->exportHTMLFile($file);
459  if (is_callable($a_update_callback)) {
460  $cnt++;
461  $a_update_callback($total, $cnt);
462  }
463  }
464 
465  // export all files (which are not objects
466  foreach ($this->files_direct as $file_id => $attr) {
467  $this->exportHTMLFileDirect($file_id, $attr[0], $attr[1]);
468  if (is_callable($a_update_callback)) {
469  $cnt++;
470  $a_update_callback($total, $cnt);
471  }
472  }
473 
474  $this->exportQuestionFiles();
475 
476  // export all glossary terms
477  $this->exportHTMLGlossaryTerms();
478  }
exportHTMLMOB(int $a_mob_id, array &$a_linked_mobs)
Export media object to html.
static _exists(int $id, bool $reference=false, ?string $type=null)
checks if an object exists in object_data
exportHTMLFile(string $a_file_id)
Export file object.
exportHTMLFileDirect(string $a_file_id, string $a_source_file, string $a_file_name)
Export file from path.
exportQuestionFiles()
Export question images.
static _lookupType(int $id, bool $reference=false)
+ Here is the call graph for this function:

◆ exportQuestionFiles()

ilCOPageHTMLExport::exportQuestionFiles ( )
protected

Export question images.

Definition at line 628 of file class.ilCOPageHTMLExport.php.

References ilFileUtils\getWebspaceDir(), ilFileUtils\makeDirParents(), and ilFileUtils\rCopy().

Referenced by exportPageElements().

628  : void
629  {
630  // export questions (images)
631  if (count($this->q_ids) > 0) {
632  foreach ($this->q_ids as $q_id) {
633  ilFileUtils::makeDirParents($this->exp_dir . "/assessment/0/" . $q_id . "/images");
635  ilFileUtils::getWebspaceDir() . "/assessment/0/" . $q_id . "/images",
636  $this->exp_dir . "/assessment/0/" . $q_id . "/images"
637  );
638  }
639  }
640  }
static getWebspaceDir(string $mode="filesystem")
get webspace directory
static rCopy(string $a_sdir, string $a_tdir, bool $preserveTimeAttributes=false)
Copies content of a directory $a_sdir recursively to a directory $a_tdir.
static makeDirParents(string $a_dir)
Create a new directory and all parent directories.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ exportResourceFile()

ilCOPageHTMLExport::exportResourceFile ( string  $target_dir,
string  $file 
)
protected

Definition at line 197 of file class.ilCOPageHTMLExport.php.

References ilFileUtils\makeDirParents().

Referenced by exportStyles(), and exportSupportScripts().

200  : void {
201  if (is_int(strpos($file, "?"))) {
202  $file = substr($file, 0, strpos($file, "?"));
203  }
204  if (is_file($file)) {
205  if (is_null($this->export_collector)) {
206  $dir = dirname($file);
207  ilFileUtils::makeDirParents($target_dir . "/" . $dir);
208  if (!is_file($target_dir . "/" . $file)) {
209  copy($file, $target_dir . "/" . $file);
210  }
211  } else {
212  $this->export_collector->addFile($file, $file);
213  }
214  }
215  }
static makeDirParents(string $a_dir)
Create a new directory and all parent directories.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ exportStyles()

ilCOPageHTMLExport::exportStyles ( )

Export content style.

Exceptions

Definition at line 124 of file class.ilCOPageHTMLExport.php.

References exportResourceFile(), ilObjStyleSheet\getBasicImageDir(), ilObjStyleSheet\getContentPrintStyle(), getContentStyleId(), ilObjStyleSheet\getContentStylePath(), ilObjStyleSheet\getExportContentStylePath(), ilObjStyleSheet\getSyntaxStylePath(), ilFileUtils\makeDirParents(), and ilFileUtils\rCopy().

124  : void
125  {
126  $this->log->debug("export styles");
127 
128  // export content style sheet
129  if ($this->getContentStyleId() < 1) { // basic style
130  if (is_null($this->export_collector)) {
133  $this->exp_dir . "/" . ilObjStyleSheet::getBasicImageDir()
134  );
135  ilFileUtils::makeDirParents($this->exp_dir . "/components/ILIAS/COPage/css");
136  copy("../components/ILIAS/COPage/resources/content.css",
137  $this->exp_dir . "/components/ILIAS/COPage/css/content.css");
138  } else {
139  $this->export_collector->addDirectory(
141  "/basic_style/images"
142  );
143  $this->export_collector->addFile(
144  "../components/ILIAS/COPage/css/content.css",
146  );
147  }
148  } else {
149  $style = new ilObjStyleSheet($this->getContentStyleId());
150  if (is_null($this->export_collector)) {
151  $style->copyImagesToDir($this->exp_dir . "/" . $style->getImagesDirectory());
152  $this->exportResourceFile(
153  $this->exp_dir,
155  );
156  } else {
157  $res_id = $this->content_style->style($this->getContentStyleId())->getResourceIdentification();
158  if ($res_id) {
159  $this->export_collector->addContainerDirectory(
160  $res_id->serialize(),
161  "",
162  "content_style"
163  );
164  }
165  }
166  }
167 
168  // export syntax highlighting style
169  $syn_stylesheet = ilObjStyleSheet::getSyntaxStylePath();
170  $this->exportResourceFile($this->exp_dir, $syn_stylesheet);
171 
172  // export print style
173  $print_stylesheet = ilObjStyleSheet::getContentPrintStyle();
174  $this->exportResourceFile($this->exp_dir, $print_stylesheet);
175  }
static rCopy(string $a_sdir, string $a_tdir, bool $preserveTimeAttributes=false)
Copies content of a directory $a_sdir recursively to a directory $a_tdir.
static makeDirParents(string $a_dir)
Create a new directory and all parent directories.
static getContentStylePath(int $a_style_id, bool $add_random=true, bool $add_token=true)
get content style path static (to avoid full reading)
exportResourceFile(string $target_dir, string $file)
+ Here is the call graph for this function:

◆ exportSupportScripts()

ilCOPageHTMLExport::exportSupportScripts ( )

Export support scripts.

Todo:
: use ilPageContent js/css functions here (problem: currently they need a page object for init)

Definition at line 182 of file class.ilCOPageHTMLExport.php.

References exportResourceFile(), and ilPageObjectGUI\OFFLINE.

182  : void
183  {
184  $this->log->debug("export scripts");
185 
186  $collector = new \ILIAS\COPage\ResourcesCollector(ilPageObjectGUI::OFFLINE);
187 
188  foreach ($collector->getJavascriptFiles() as $js) {
189  $this->exportResourceFile($this->exp_dir, $js);
190  }
191 
192  foreach ($collector->getCssFiles() as $css) {
193  $this->exportResourceFile($this->exp_dir, $css);
194  }
195  }
exportResourceFile(string $target_dir, string $file)
+ Here is the call graph for this function:

◆ getContentStyleId()

ilCOPageHTMLExport::getContentStyleId ( )

Definition at line 97 of file class.ilCOPageHTMLExport.php.

References $content_style_id.

Referenced by exportStyles(), and initResourceTemplate().

97  : int
98  {
100  }
+ Here is the caller graph for this function:

◆ getPreparedMainTemplate()

ilCOPageHTMLExport::getPreparedMainTemplate ( ilGlobalTemplateInterface  $a_tpl = null)

Definition at line 217 of file class.ilCOPageHTMLExport.php.

References $DIC, ilObjStyleSheet\getExportContentStylePath(), ilUtil\getStyleSheetLocation(), ilObjStyleSheet\getSyntaxStylePath(), and ilPageObjectGUI\OFFLINE.

Referenced by initResourceTemplate().

220  global $DIC;
221  $this->log->debug("get main template");
222 
223 
224  $resource_collector = new \ILIAS\COPage\ResourcesCollector(ilPageObjectGUI::OFFLINE);
225  $resource_injector = new \ILIAS\COPage\ResourcesInjector($resource_collector);
226 
227  if (!is_null($a_tpl)) {
228  $tpl = $a_tpl;
229  } else {
230  // template workaround: reset of template
231  $tpl = new ilGlobalPageTemplate($DIC->globalScreen(), $DIC->ui(), $DIC->http());
232  }
233 
234  // scripts needed
235  /* @todo check
236  $scripts = [];
237  $scripts = array_merge($scripts, ilPlayerUtil::getJsFilePaths());
238 
239  $mathJaxSetting = new ilSetting("MathJax");
240  $use_mathjax = $mathJaxSetting->get("enable");
241  if ($use_mathjax) {
242  $scripts[] = $mathJaxSetting->get("path_to_mathjax");
243  }
244  */
245 
246  $tpl->addCss(\ilUtil::getStyleSheetLocation());
247  // important, we pass 0 here, since the export will use the standard directory
249  $tpl->addCss(ilObjStyleSheet::getSyntaxStylePath());
250 
251  $resource_injector->inject($tpl);
252 
253  return $tpl;
254  }
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:25
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initResourceTemplate()

ilCOPageHTMLExport::initResourceTemplate ( string  $template_file)
protected

Get resource template.

Definition at line 483 of file class.ilCOPageHTMLExport.php.

References getContentStyleId(), ilObjStyleSheet\getContentStylePath(), getPreparedMainTemplate(), ilUtil\getStyleSheetLocation(), and ilObjStyleSheet\getSyntaxStylePath().

Referenced by exportHTMLGlossaryTerms(), and exportHTMLMOB().

486  $this->global_screen->layout()->meta()->reset();
487  $tpl = new ilGlobalTemplate($template_file, true, true, "components/ILIAS/COPage");
488  $this->getPreparedMainTemplate($tpl);
489  $tpl->addCss(\ilUtil::getStyleSheetLocation());
491  $tpl->addCss(ilObjStyleSheet::getSyntaxStylePath());
492  return $tpl;
493  }
static getStyleSheetLocation(string $mode="output", string $a_css_name="")
get full style sheet file name (path inclusive) of current user
special template class to simplify handling of ITX/PEAR
getPreparedMainTemplate(ilGlobalTemplateInterface $a_tpl=null)
static getContentStylePath(int $a_style_id, bool $add_random=true, bool $add_token=true)
get content style path static (to avoid full reading)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ renderMob()

ilCOPageHTMLExport::renderMob ( \ilObjMediaObject  $mob_obj,
string  $link_xml,
array  $params 
)
protected

Render Mob.

Definition at line 573 of file class.ilCOPageHTMLExport.php.

References ilObjMediaObject\getXML(), IL_MODE_ALIAS, and IL_MODE_OUTPUT.

Referenced by exportHTMLMOB().

577  : string {
578  $xml = "<dummy>" .
579  $mob_obj->getXML(IL_MODE_ALIAS) .
580  $mob_obj->getXML(IL_MODE_OUTPUT) .
581  $link_xml .
582  "</dummy>";
583 
584  return $this->xsl->process($xml, $params);
585  }
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
Definition: ltiregstart.php:31
const IL_MODE_ALIAS
const IL_MODE_OUTPUT
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setContentStyleId()

ilCOPageHTMLExport::setContentStyleId ( int  $a_val)

Definition at line 92 of file class.ilCOPageHTMLExport.php.

92  : void
93  {
94  $this->content_style_id = $a_val;
95  }

Field Documentation

◆ $content_style

ILIAS Style Content InternalDomainService ilCOPageHTMLExport::$content_style
protected

Definition at line 29 of file class.ilCOPageHTMLExport.php.

◆ $content_style_dir

string ilCOPageHTMLExport::$content_style_dir = ""
protected

Definition at line 37 of file class.ilCOPageHTMLExport.php.

◆ $content_style_id

int ilCOPageHTMLExport::$content_style_id = 0
protected

Definition at line 48 of file class.ilCOPageHTMLExport.php.

Referenced by getContentStyleId().

◆ $content_style_img_dir

string ilCOPageHTMLExport::$content_style_img_dir = ""
protected

Definition at line 36 of file class.ilCOPageHTMLExport.php.

◆ $css_dir

string ilCOPageHTMLExport::$css_dir = ""
protected

Definition at line 31 of file class.ilCOPageHTMLExport.php.

◆ $exp_dir

string ilCOPageHTMLExport::$exp_dir = ""
protected

Definition at line 47 of file class.ilCOPageHTMLExport.php.

◆ $files

array ilCOPageHTMLExport::$files = []
protected

Definition at line 43 of file class.ilCOPageHTMLExport.php.

◆ $files_dir

string ilCOPageHTMLExport::$files_dir = ""
protected

Definition at line 39 of file class.ilCOPageHTMLExport.php.

◆ $files_direct

array ilCOPageHTMLExport::$files_direct = []
protected

Definition at line 44 of file class.ilCOPageHTMLExport.php.

◆ $global_screen

ILIAS GlobalScreen Services ilCOPageHTMLExport::$global_screen
protected

Definition at line 51 of file class.ilCOPageHTMLExport.php.

◆ $glossary_terms

array ilCOPageHTMLExport::$glossary_terms = []
protected

Definition at line 42 of file class.ilCOPageHTMLExport.php.

◆ $int_links

array ilCOPageHTMLExport::$int_links = []
protected

Definition at line 45 of file class.ilCOPageHTMLExport.php.

◆ $js_dir

string ilCOPageHTMLExport::$js_dir = ""
protected

Definition at line 33 of file class.ilCOPageHTMLExport.php.

◆ $js_yahoo_dir

string ilCOPageHTMLExport::$js_yahoo_dir = ""
protected

Definition at line 32 of file class.ilCOPageHTMLExport.php.

◆ $log

ilLogger ilCOPageHTMLExport::$log
protected

Definition at line 50 of file class.ilCOPageHTMLExport.php.

◆ $media_manager

ILIAS MediaObjects MediaObjectManager ilCOPageHTMLExport::$media_manager
protected

Definition at line 28 of file class.ilCOPageHTMLExport.php.

◆ $media_service_dir

string ilCOPageHTMLExport::$media_service_dir = ""
protected

Definition at line 34 of file class.ilCOPageHTMLExport.php.

◆ $mobs

array ilCOPageHTMLExport::$mobs = []
protected

Definition at line 41 of file class.ilCOPageHTMLExport.php.

◆ $mobs_dir

string ilCOPageHTMLExport::$mobs_dir = ""
protected

Definition at line 40 of file class.ilCOPageHTMLExport.php.

◆ $page_linker

ILIAS COPage PageLinker ilCOPageHTMLExport::$page_linker
protected

Definition at line 54 of file class.ilCOPageHTMLExport.php.

◆ $q_ids

array ilCOPageHTMLExport::$q_ids = []
protected

Definition at line 46 of file class.ilCOPageHTMLExport.php.

◆ $ref_id

int ilCOPageHTMLExport::$ref_id
protected

Definition at line 55 of file class.ilCOPageHTMLExport.php.

Referenced by __construct(), and exportHTMLMOB().

◆ $services_dir

string ilCOPageHTMLExport::$services_dir = ""
protected

Definition at line 35 of file class.ilCOPageHTMLExport.php.

◆ $skill_personal_service

ILIAS Skill Service SkillPersonalService ilCOPageHTMLExport::$skill_personal_service
protected

Definition at line 53 of file class.ilCOPageHTMLExport.php.

◆ $skill_tree_service

ILIAS Skill Service SkillTreeService ilCOPageHTMLExport::$skill_tree_service
protected

Definition at line 52 of file class.ilCOPageHTMLExport.php.

◆ $tex_dir

string ilCOPageHTMLExport::$tex_dir = ""
protected

Definition at line 38 of file class.ilCOPageHTMLExport.php.

◆ $user

ilObjUser ilCOPageHTMLExport::$user
protected

Definition at line 49 of file class.ilCOPageHTMLExport.php.

◆ $xsl

ILIAS COPage Xsl XslManager ilCOPageHTMLExport::$xsl
protected

Definition at line 30 of file class.ilCOPageHTMLExport.php.


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