ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
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)
 
 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

string $mp3_dir = ""
 
string $flv_dir = ""
 
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
 
SkillTreeService $skill_tree_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 
)

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

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

59  {
60  global $DIC;
61 
62  $this->log = ilLoggerFactory::getLogger('copg');
63  $this->user = $DIC->user();
64  $this->global_screen = $DIC->globalScreen();
65  $this->skill_tree_service = $DIC->skills()->tree();
66  $this->page_linker = is_null($linker)
67  ? new ilPageLinker("", true)
68  : $linker;
69  $this->ref_id = $ref_id;
70 
71  $this->exp_dir = $a_exp_dir;
72  $this->mobs_dir = $a_exp_dir . "/mobs";
73  $this->files_dir = $a_exp_dir . "/files";
74  $this->tex_dir = $a_exp_dir . "/teximg";
75  $this->content_style_dir = $a_exp_dir . "/content_style";
76  $this->content_style_img_dir = $a_exp_dir . "/content_style/images";
77 
78  $this->services_dir = $a_exp_dir . "/Services";
79  $this->media_service_dir = $this->services_dir . "/MediaObjects";
80  $this->flv_dir = $a_exp_dir . "/" . ilPlayerUtil::getFlashVideoPlayerDirectory();
81  $this->mp3_dir = $this->media_service_dir . "/flash_mp3_player";
82 
83  $this->js_dir = $a_exp_dir . '/js';
84  $this->js_yahoo_dir = $a_exp_dir . '/js/yahoo';
85  $this->css_dir = $a_exp_dir . '/css';
86  }
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: feed.php:28
static getFlashVideoPlayerDirectory()
+ 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 231 of file class.ilCOPageHTMLExport.php.

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

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

235  : void {
236  $this->log->debug("collect page elements");
237 
238  // collect all dependent pages (only one level deep)
239  $pages[] = [
240  "type" => $a_type,
241  "id" => $a_id
242  ];
243 
244  // ... content includes
245  $pcs = ilPageContentUsage::getUsagesOfPage($a_id, $a_type, 0, false, $lang);
246  foreach ($pcs as $pc) {
247  // content includes
248  if ($pc["type"] == "incl") {
249  $pages[] = [
250  "type" => "mep:pg",
251  "id" => $pc["id"]
252  ];
253  }
254  }
255 
256  // ... internal links
257  $pg_links = \ilInternalLink::_getTargetsOfSource($a_type, $a_id, $lang);
258  $this->int_links = array_merge($this->int_links, $pg_links);
259  $this->glossary_terms = [];
260 
261  // ... glossary pages of internal links
262  foreach ($this->int_links as $int_link) {
263  if ($int_link["type"] == "git") {
264  $this->glossary_terms[] = $int_link["id"];
265  // store linked/embedded media objects of glosssary term
266  $defs = \ilGlossaryDefinition::getDefinitionList($int_link["id"]);
267  foreach ($defs as $def) {
268  $pages[] = [
269  "type" => "gdf:pg",
270  "id" => $def["id"]
271  ];
272  }
273  }
274  }
275 
276  // resources of pages
277  foreach ($pages as $page) {
278  $page_id = $page["id"];
279  $page_type = $page["type"];
280 
281  // collect media objects
282  $pg_mobs = ilObjMediaObject::_getMobsOfObject($page_type, $page_id, 0, $lang);
283  foreach ($pg_mobs as $pg_mob) {
284  $this->mobs[$pg_mob] = $pg_mob;
285  $this->log->debug("HTML Export: Add media object $pg_mob (" . \ilObject::_lookupTitle($pg_mob) . ") " .
286  " due to page $page_id, $page_type ).");
287  }
288 
289  // collect all files
290  $files = ilObjFile::_getFilesOfObject($page_type, $page_id, 0, $lang);
291  foreach ($files as $f) {
292  $this->files[$f] = $f;
293  }
294 
295  // collect all questions
297  foreach ($q_ids as $q_id) {
298  $this->q_ids[$q_id] = $q_id;
299  }
300  }
301 
302  // collect page content items
303  $skill_tree = $ws_tree = null;
304 
305  // skills
306  foreach ($pcs as $pc) {
307  if ($pc["type"] == "skmg") {
308  $skill_id = $pc["id"];
309 
310  // trying to find user id
311  $user_id = null;
312  switch ($a_type) {
313  case "prtf:pg":
314  $page = new ilPortfolioPage($a_id);
315  $user_id = $page->getCreationUserId();
316  break;
317 
318  default:
319  // :TODO:
320  break;
321  }
322 
323  if ($user_id) {
324  // we only need 1 instance each
325  if (!$skill_tree) {
326  $skill_tree = $this->skill_tree_service->getGlobalSkillTree();
327 
328  $ws_tree = new ilWorkspaceTree($user_id);
329  }
330 
331  // walk skill tree
332  $skill_id = (int) $skill_id;
333  $vtree = $this->skill_tree_service->getVirtualSkillTreeForNodeId($skill_id);
334  $tref_id = 0;
335  if (ilSkillTreeNode::_lookupType($skill_id) == "sktr") {
336  $tref_id = $skill_id;
337  $skill_id = ilSkillTemplateReference::_lookupTemplateId($skill_id);
338  }
339  $b_skills = $vtree->getSubTreeForCSkillId($skill_id . ":" . $tref_id, true);
340 
341  foreach ($b_skills as $bs) {
342  $skill = ilSkillTreeNodeFactory::getInstance($bs["skill_id"]);
343  $level_data = $skill->getLevelData();
344  foreach ($level_data as $k => $v) {
345  // get assigned materials from personal skill
346  $mat = ilPersonalSkill::getAssignedMaterial($user_id, $bs["tref_id"], $v["id"]);
347  if (count($mat)) {
348  foreach ($mat as $item) {
349  $wsp_id = $item["wsp_id"];
350  $obj_id = $ws_tree->lookupObjectId($wsp_id);
351 
352  // all possible material types for now
353  switch (ilObject::_lookupType($obj_id)) {
354  case "file":
355  $this->files[$obj_id] = $obj_id;
356  break;
357 
358  case "tstv":
359  $obj = new ilObjTestVerification($obj_id, false);
360  $this->files_direct[$obj_id] = array($obj->getFilePath(),
361  $obj->getOfflineFilename());
362  break;
363 
364  case "excv":
365  $obj = new ilObjExerciseVerification($obj_id, false);
366  $this->files_direct[$obj_id] = array($obj->getFilePath(),
367  $obj->getOfflineFilename());
368  break;
369 
370  case "crsv":
371  $obj = new ilObjCourseVerification($obj_id, false);
372  $this->files_direct[$obj_id] = array($obj->getFilePath(),
373  $obj->getOfflineFilename());
374  break;
375 
376  case "cmxv":
377  $obj = new ilObjCmiXapiVerification($obj_id, false);
378  $this->files_direct[$obj_id] = array($obj->getFilePath(),
379  $obj->getOfflineFilename());
380  break;
381 
382  case "ltiv":
383  $obj = new ilObjLTIConsumerVerification($obj_id, false);
384  $this->files_direct[$obj_id] = array($obj->getFilePath(),
385  $obj->getOfflineFilename());
386  break;
387 
388  case "scov":
389  $obj = new ilObjSCORMVerification($obj_id, false);
390  $this->files_direct[$obj_id] = array($obj->getFilePath(),
391  $obj->getOfflineFilename());
392  break;
393  }
394  }
395  }
396  }
397  }
398  }
399  }
400  }
401  }
static getAssignedMaterial(int $a_user_id, int $a_tref_id, int $a_level)
Get assigned material (for a skill level and user)
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...
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="-")
static getDefinitionList(int $a_term_id)
$lang
Definition: xapiexit.php:26
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 98 of file class.ilCOPageHTMLExport.php.

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

98  : void
99  {
100  ilFileUtils::makeDir($this->mobs_dir);
101  ilFileUtils::makeDir($this->files_dir);
102  ilFileUtils::makeDir($this->tex_dir);
103  ilFileUtils::makeDir($this->content_style_dir);
104  ilFileUtils::makeDir($this->content_style_img_dir);
105  ilFileUtils::makeDir($this->services_dir);
106  ilFileUtils::makeDir($this->media_service_dir);
107  ilFileUtils::makeDirParents($this->flv_dir);
108  ilFileUtils::makeDirParents($this->mp3_dir);
109 
110  ilFileUtils::makeDirParents($this->js_dir);
111  ilFileUtils::makeDirParents($this->js_yahoo_dir);
112  ilFileUtils::makeDirParents($this->css_dir);
113  ilFileUtils::makeDirParents($this->css_dir . "/yahoo");
114  }
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 561 of file class.ilCOPageHTMLExport.php.

References ilFileUtils\makeDir().

Referenced by exportPageElements().

561  : void
562  {
563  $file_dir = $this->files_dir . "/file_" . $a_file_id;
564  ilFileUtils::makeDir($file_dir);
565 
566  $file_obj = new ilObjFile($a_file_id, false);
567  $source_file = $file_obj->getFile($file_obj->getVersion());
568  if (!is_file($source_file)) {
569  $source_file = $file_obj->getFile();
570  }
571  if (is_file($source_file)) {
572  copy($source_file, $file_dir . "/" . $file_obj->getFileName());
573  }
574  }
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 579 of file class.ilCOPageHTMLExport.php.

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

Referenced by exportPageElements().

583  : void {
584  $file_dir = $this->files_dir . "/file_" . $a_file_id;
585  ilFileUtils::makeDir($file_dir);
586 
587  if (is_file($a_source_file)) {
588  copy(
589  $a_source_file,
590  $file_dir . "/" . ilFileUtils::getASCIIFilename($a_file_name)
591  );
592  }
593  }
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 612 of file class.ilCOPageHTMLExport.php.

References $tpl, and initResourceTemplate().

Referenced by exportPageElements().

612  : void
613  {
614  foreach ($this->glossary_terms as $term_id) {
615  $tpl = $this->initResourceTemplate("tpl.glossary_term_output.html");
616 
617  $term_gui = new ilGlossaryTermGUI($term_id);
618  $term_gui->setPageLinker($this->page_linker);
619  $term_gui->setOfflineDirectory($this->exp_dir);
620  $term_gui->output(true, $tpl);
621 
622  // write file
623  $html = $tpl->printToString();
624  $file = $this->exp_dir . "/term_" . $term_id . ".html";
625  $fp = fopen($file, "w+");
626  fwrite($fp, $html);
627  fclose($fp);
628  }
629  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41
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 473 of file class.ilCOPageHTMLExport.php.

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

Referenced by exportPageElements().

476  : void {
477  $this->log->debug("export html mobs");
478 
479  $source_dir = ilFileUtils::getWebspaceDir() . "/mobs/mm_" . $a_mob_id;
480  if (is_dir($source_dir)) {
481  ilFileUtils::makeDir($this->mobs_dir . "/mm_" . $a_mob_id);
482  ilFileUtils::rCopy($source_dir, $this->mobs_dir . "/mm_" . $a_mob_id);
483  }
484 
485  $mob_obj = new ilObjMediaObject($a_mob_id);
486 
487  $tpl = $this->initResourceTemplate("tpl.fullscreen.html");
488  $med_links = ilMediaItem::_getMapAreasIntLinks($a_mob_id);
489  $link_xml = $this->page_linker->getLinkXML($med_links);
490 
491  $params = [
492  "mode" => "media",
493  'enlarge_path' => ilUtil::getImagePath("enlarge.svg", false, "output", true),
494  'enable_html_mob' => ilObjMediaObject::isTypeAllowed("html") ? "y" : "n",
495  'fullscreen_link' => $this->page_linker->getFullScreenLink()
496  ];
497  if ($this->ref_id > 0) {
498  $params["ref_id"] = $this->ref_id;
499  $params["link_params"] = "ref_id=" . $this->ref_id;
500  }
501 
502  $tpl->setVariable("MEDIA_CONTENT", $this->renderMob($mob_obj, $link_xml, $params));
503  $html = $tpl->printToString();
504  $file = $this->exp_dir . "/media_" . $a_mob_id . ".html";
505  $fp = fopen($file, "w+");
506  fwrite($fp, $html);
507  fclose($fp);
508  unset($fp);
509 
510  if ($mob_obj->hasFullscreenItem()) {
511  $tpl = $this->initResourceTemplate("tpl.fullscreen.html");
512  $params["mode"] = "fullscreen";
513  $tpl->setVariable("MEDIA_CONTENT", $this->renderMob($mob_obj, $link_xml, $params));
514  $html = $tpl->printToString();
515  $file = $this->exp_dir . "/fullscreen_" . $a_mob_id . ".html";
516  $fp = fopen($file, "w+");
517  fwrite($fp, $html);
518  fclose($fp);
519  unset($fp);
520  }
521 
522  $linked_mobs = $mob_obj->getLinkedMediaObjects();
523  $a_linked_mobs = array_merge($a_linked_mobs, $linked_mobs);
524  }
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:33
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template 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 isTypeAllowed(string $a_type)
static _getMapAreasIntLinks(int $a_mob_id)
get all internal links of map areas of a mob
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41
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 406 of file class.ilCOPageHTMLExport.php.

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

408  : void {
409  $this->log->debug("export page elements");
410 
411  $total = count($this->mobs) + count($this->files) + count($this->files_direct);
412  $cnt = 0;
413  // export all media objects
414  $linked_mobs = array();
415  foreach ($this->mobs as $mob) {
416  if (ilObject::_exists($mob) && ilObject::_lookupType($mob) == "mob") {
417  $this->exportHTMLMOB($mob, $linked_mobs);
418  }
419  if (is_callable($a_update_callback)) {
420  $cnt++;
421  $a_update_callback($total, $cnt);
422  }
423  }
424  $linked_mobs2 = array(); // mobs linked in link areas
425  foreach ($linked_mobs as $mob) {
426  if (ilObject::_exists($mob)) {
427  $this->exportHTMLMOB($mob, $linked_mobs2);
428  }
429  }
430 
431  // export all file objects
432  foreach ($this->files as $file) {
433  $this->exportHTMLFile($file);
434  if (is_callable($a_update_callback)) {
435  $cnt++;
436  $a_update_callback($total, $cnt);
437  }
438  }
439 
440  // export all files (which are not objects
441  foreach ($this->files_direct as $file_id => $attr) {
442  $this->exportHTMLFileDirect($file_id, $attr[0], $attr[1]);
443  if (is_callable($a_update_callback)) {
444  $cnt++;
445  $a_update_callback($total, $cnt);
446  }
447  }
448 
449  $this->exportQuestionFiles();
450 
451  // export all glossary terms
452  $this->exportHTMLGlossaryTerms();
453  }
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 598 of file class.ilCOPageHTMLExport.php.

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

Referenced by exportPageElements().

598  : void
599  {
600  // export questions (images)
601  if (count($this->q_ids) > 0) {
602  foreach ($this->q_ids as $q_id) {
603  ilFileUtils::makeDirParents($this->exp_dir . "/assessment/0/" . $q_id . "/images");
605  ilFileUtils::getWebspaceDir() . "/assessment/0/" . $q_id . "/images",
606  $this->exp_dir . "/assessment/0/" . $q_id . "/images"
607  );
608  }
609  }
610  }
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 174 of file class.ilCOPageHTMLExport.php.

References ilFileUtils\makeDirParents().

Referenced by exportStyles(), and exportSupportScripts().

177  : void {
178  if (is_int(strpos($file, "?"))) {
179  $file = substr($file, 0, strpos($file, "?"));
180  }
181  if (is_file($file)) {
182  $dir = dirname($file);
183  ilFileUtils::makeDirParents($target_dir . "/" . $dir);
184  if (!is_file($target_dir . "/" . $file)) {
185  copy($file, $target_dir . "/" . $file);
186  }
187  }
188  }
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 122 of file class.ilCOPageHTMLExport.php.

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

122  : void
123  {
124  $this->log->debug("export styles");
125 
126  // export content style sheet
127  if ($this->getContentStyleId() < 1) { // basic style
130  $this->exp_dir . "/" . ilObjStyleSheet::getBasicImageDir()
131  );
132  ilFileUtils::makeDirParents($this->exp_dir . "/Services/COPage/css");
133  copy("Services/COPage/css/content.css", $this->exp_dir . "/Services/COPage/css/content.css");
134  } else {
135  $style = new ilObjStyleSheet($this->getContentStyleId());
136  $style->copyImagesToDir($this->exp_dir . "/" . $style->getImagesDirectory());
137  $this->exportResourceFile(
138  $this->exp_dir,
140  );
141  }
142 
143  // export syntax highlighting style
144  $syn_stylesheet = ilObjStyleSheet::getSyntaxStylePath();
145  $this->exportResourceFile($this->exp_dir, $syn_stylesheet);
146 
147  // export print style
148  $print_stylesheet = ilObjStyleSheet::getContentPrintStyle();
149  $this->exportResourceFile($this->exp_dir, $print_stylesheet);
150  }
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 157 of file class.ilCOPageHTMLExport.php.

References ilPlayerUtil\copyPlayerFilesToTargetDirectory(), exportResourceFile(), and ilPageObjectGUI\OFFLINE.

157  : void
158  {
159  $this->log->debug("export scripts");
160 
161  $collector = new \ILIAS\COPage\ResourcesCollector(ilPageObjectGUI::OFFLINE);
162 
163  foreach ($collector->getJavascriptFiles() as $js) {
164  $this->exportResourceFile($this->exp_dir, $js);
165  }
166 
167  foreach ($collector->getCssFiles() as $css) {
168  $this->exportResourceFile($this->exp_dir, $css);
169  }
170  // mediaelement.js
172  }
exportResourceFile(string $target_dir, string $file)
static copyPlayerFilesToTargetDirectory(string $a_target_dir)
+ Here is the call graph for this function:

◆ getContentStyleId()

ilCOPageHTMLExport::getContentStyleId ( )

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

References $content_style_id.

Referenced by exportStyles(), getPreparedMainTemplate(), and initResourceTemplate().

93  : int
94  {
96  }
+ Here is the caller graph for this function:

◆ getPreparedMainTemplate()

ilCOPageHTMLExport::getPreparedMainTemplate ( ilGlobalTemplateInterface  $a_tpl = null)

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

References $DIC, $tpl, getContentStyleId(), ilObjStyleSheet\getContentStylePath(), ilUtil\getStyleSheetLocation(), ilObjStyleSheet\getSyntaxStylePath(), and ilPageObjectGUI\OFFLINE.

Referenced by initResourceTemplate().

193  global $DIC;
194  $this->log->debug("get main template");
195 
196 
197  $resource_collector = new \ILIAS\COPage\ResourcesCollector(ilPageObjectGUI::OFFLINE);
198  $resource_injector = new \ILIAS\COPage\ResourcesInjector($resource_collector);
199 
200  if (!is_null($a_tpl)) {
201  $tpl = $a_tpl;
202  } else {
203  // template workaround: reset of template
204  $tpl = new ilGlobalPageTemplate($DIC->globalScreen(), $DIC->ui(), $DIC->http());
205  }
206 
207  // scripts needed
208  /* @todo check
209  $scripts = [];
210  $scripts = array_merge($scripts, ilPlayerUtil::getJsFilePaths());
211 
212  $mathJaxSetting = new ilSetting("MathJax");
213  $use_mathjax = $mathJaxSetting->get("enable");
214  if ($use_mathjax) {
215  $scripts[] = $mathJaxSetting->get("path_to_mathjax");
216  }
217  */
218 
222 
223  $resource_injector->inject($tpl);
224 
225  return $tpl;
226  }
static getStyleSheetLocation(string $mode="output", string $a_css_name="", string $a_css_location="")
get full style sheet file name (path inclusive) of current user
global $DIC
Definition: feed.php:28
static getContentStylePath(int $a_style_id, bool $add_random=true, bool $add_token=true)
get content style path static (to avoid full reading)
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41
+ 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 458 of file class.ilCOPageHTMLExport.php.

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

Referenced by exportHTMLGlossaryTerms(), and exportHTMLMOB().

461  $this->global_screen->layout()->meta()->reset();
462  $tpl = new ilGlobalTemplate($template_file, true, true, "Services/COPage");
467  return $tpl;
468  }
special template class to simplify handling of ITX/PEAR
static getStyleSheetLocation(string $mode="output", string $a_css_name="", string $a_css_location="")
get full style sheet file name (path inclusive) of current user
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)
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41
+ 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 529 of file class.ilCOPageHTMLExport.php.

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

Referenced by exportHTMLMOB().

533  : string {
534  // render media object html
535  $xh = xslt_create();
536  $output = xslt_process(
537  $xh,
538  "arg:/_xml",
539  "arg:/_xsl",
540  null,
541  array(
542  "/_xml" =>
543  "<dummy>" .
544  $mob_obj->getXML(IL_MODE_ALIAS) .
545  $mob_obj->getXML(IL_MODE_OUTPUT) .
546  $link_xml .
547  "</dummy>",
548  "/_xsl" => file_get_contents("./Services/COPage/xsl/page.xsl")
549  ),
550  $params
551  );
552  xslt_free($xh);
553  unset($xh);
554  return $output;
555  }
xslt_create()
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
Definition: ltiregstart.php:33
xslt_free(&$proc)
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 88 of file class.ilCOPageHTMLExport.php.

88  : void
89  {
90  $this->content_style_id = $a_val;
91  }

Field Documentation

◆ $content_style_dir

string ilCOPageHTMLExport::$content_style_dir = ""
protected

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

◆ $content_style_id

int ilCOPageHTMLExport::$content_style_id = 0
protected

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

Referenced by getContentStyleId().

◆ $content_style_img_dir

string ilCOPageHTMLExport::$content_style_img_dir = ""
protected

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

◆ $css_dir

string ilCOPageHTMLExport::$css_dir = ""
protected

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

◆ $exp_dir

string ilCOPageHTMLExport::$exp_dir = ""
protected

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

◆ $files

array ilCOPageHTMLExport::$files = []
protected

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

◆ $files_dir

string ilCOPageHTMLExport::$files_dir = ""
protected

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

◆ $files_direct

array ilCOPageHTMLExport::$files_direct = []
protected

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

◆ $flv_dir

string ilCOPageHTMLExport::$flv_dir = ""
protected

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

◆ $global_screen

ILIAS GlobalScreen Services ilCOPageHTMLExport::$global_screen
protected

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

◆ $glossary_terms

array ilCOPageHTMLExport::$glossary_terms = []
protected

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

◆ $int_links

array ilCOPageHTMLExport::$int_links = []
protected

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

◆ $js_dir

string ilCOPageHTMLExport::$js_dir = ""
protected

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

◆ $js_yahoo_dir

string ilCOPageHTMLExport::$js_yahoo_dir = ""
protected

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

◆ $log

ilLogger ilCOPageHTMLExport::$log
protected

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

◆ $media_service_dir

string ilCOPageHTMLExport::$media_service_dir = ""
protected

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

◆ $mobs

array ilCOPageHTMLExport::$mobs = []
protected

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

◆ $mobs_dir

string ilCOPageHTMLExport::$mobs_dir = ""
protected

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

◆ $mp3_dir

string ilCOPageHTMLExport::$mp3_dir = ""
protected

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

◆ $page_linker

ILIAS COPage PageLinker ilCOPageHTMLExport::$page_linker
protected

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

◆ $q_ids

array ilCOPageHTMLExport::$q_ids = []
protected

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

◆ $ref_id

int ilCOPageHTMLExport::$ref_id
protected

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

Referenced by __construct(), and exportHTMLMOB().

◆ $services_dir

string ilCOPageHTMLExport::$services_dir = ""
protected

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

◆ $skill_tree_service

SkillTreeService ilCOPageHTMLExport::$skill_tree_service
protected

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

◆ $tex_dir

string ilCOPageHTMLExport::$tex_dir = ""
protected

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

◆ $user

ilObjUser ilCOPageHTMLExport::$user
protected

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


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