ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilPortfolioHTMLExport Class Reference

Portfolio HTML exporter class. More...

+ Collaboration diagram for ilPortfolioHTMLExport:

Public Member Functions

 __construct ($a_portfolio_gui, $a_object)
 Constructor. More...
 
 buildExportFile ()
 Build export file. More...
 
 exportHTMLPages ()
 Export all pages. More...
 
 buildExportTemplate (array $a_js_files=null)
 
 writeExportFile ($a_file, $a_content, $a_onload=null, $a_js_files=null)
 
 exportPageHTML ($a_post_id)
 Export page html. More...
 

Protected Attributes

 $portfolio_gui
 
 $export_material
 

Detailed Description

Portfolio HTML exporter class.

Author
Jörg Lützenkirchen luetz.nosp@m.enki.nosp@m.rchen.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
$Id$

Definition at line 12 of file class.ilPortfolioHTMLExport.php.

Constructor & Destructor Documentation

◆ __construct()

ilPortfolioHTMLExport::__construct (   $a_portfolio_gui,
  $a_object 
)

Constructor.

Parameters

Definition at line 23 of file class.ilPortfolioHTMLExport.php.

References array.

24  {
25  $this->portfolio_gui = $a_portfolio_gui;
26  $this->object = $a_object;
27  $this->export_material = array(); // #16571
28  }
Create styles array
The data for the language used.

Member Function Documentation

◆ buildExportFile()

ilPortfolioHTMLExport::buildExportFile ( )

Build export file.

Parameters

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

References $file, $files, ilExport\_createExportDirectory(), ilExport\_getExportDirectory(), ilObjUser\_getPersonalPicturePath(), array, ilUtil\delDir(), exportHTMLPages(), ilUIFramework\getJSFiles(), ilUtil\makeDir(), object, time, and ilUtil\zip().

37  {
38  global $ilias;
39 
40  // create export file
41  include_once("./Services/Export/classes/class.ilExport.php");
42  ilExport::_createExportDirectory($this->object->getId(), "html", "prtf");
43  $exp_dir = ilExport::_getExportDirectory($this->object->getId(), "html", "prtf");
44 
45  $this->subdir = $this->object->getType()."_".$this->object->getId();
46  $this->export_dir = $exp_dir."/".$this->subdir;
47 
48  // initialize temporary target directory
49  ilUtil::delDir($this->export_dir);
50  ilUtil::makeDir($this->export_dir);
51 
52  // system style html exporter
53  include_once("./Services/Style/System/classes/class.ilSystemStyleHTMLExport.php");
54  $this->sys_style_html_export = new ilSystemStyleHTMLExport($this->export_dir);
55  // $this->sys_style_html_export->addImage("icon_prtf.svg");
56  $this->sys_style_html_export->export();
57 
58  // init co page html exporter
59  include_once("./Services/COPage/classes/class.ilCOPageHTMLExport.php");
60  $this->co_page_html_export = new ilCOPageHTMLExport($this->export_dir);
61  $this->co_page_html_export->setContentStyleId($this->object->getStyleSheetId());
62  $this->co_page_html_export->createDirectories();
63  $this->co_page_html_export->exportStyles();
64  $this->co_page_html_export->exportSupportScripts();
65 
66  // banner
67  $prfa_set = new ilSetting("prfa");
68  if($prfa_set->get("banner"))
69  {
70  $banner = $this->object->getImageFullPath();
71  if($banner) // #16096
72  {
73  copy($banner, $this->export_dir."/".basename($banner));
74  }
75  }
76  // page element: profile picture
77  $ppic = ilObjUser::_getPersonalPicturePath($this->object->getOwner(), "big", true, true);
78  if($ppic)
79  {
80  $ppic = array_shift(explode("?", $ppic));
81  copy($ppic, $this->export_dir."/".basename($ppic));
82  }
83  // header image: profile picture
84  $ppic = ilObjUser::_getPersonalPicturePath($this->object->getOwner(), "xsmall", true, true);
85  if($ppic)
86  {
87  $ppic = array_shift(explode("?", $ppic));
88  copy($ppic, $this->export_dir."/".basename($ppic));
89  }
90 
91  // export pages
92  $this->exportHTMLPages();
93 
94  // add js/images/file to zip
95  $images = $files = $js_files = array();
96  include_once("./Services/UICore/classes/class.ilUIFramework.php");
97  $js_files = ilUIFramework::getJSFiles();
98  foreach($this->export_material as $items)
99  {
100  $images = array_merge($images, $items["images"]);
101  $files = array_merge($files, $items["files"]);
102  $js_files = array_merge($js_files, $items["js"]);
103  }
104  foreach(array_unique($images) as $image)
105  {
106  if(is_file($image))
107  {
108  copy($image, $this->export_dir."/images/".basename($image));
109  }
110  }
111  foreach(array_unique($js_files) as $js_file)
112  {
113  if(is_file($js_file))
114  {
115  copy($js_file, $this->export_dir."/js/".basename($js_file));
116  }
117  }
118  foreach(array_unique($files) as $file)
119  {
120  if(is_file($file))
121  {
122  copy($file, $this->export_dir."/files/".basename($file));
123  }
124  }
125 
126  // zip everything
127  if (true)
128  {
129  // zip it all
130  $date = time();
131  $zip_file = ilExport::_getExportDirectory($this->object->getId(), "html", "prtf").
132  "/".$date."__".IL_INST_ID."__".
133  $this->object->getType()."_".$this->object->getId().".zip";
134  ilUtil::zip($this->export_dir, $zip_file);
135  ilUtil::delDir($this->export_dir);
136  }
137 
138  return $zip_file;
139  }
$files
Definition: add-vimline.php:18
static _createExportDirectory($a_obj_id, $a_export_type="xml", $a_obj_type="")
ILIAS Setting Class.
HTML export class for pages.
static getJSFiles()
Get javascript files.
HTML export class for system styles.
static zip($a_dir, $a_file, $compress_content=false)
zips given directory/file into given zip.file
Create styles array
The data for the language used.
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
Create new PHPExcel object
obj_idprivate
static _getPersonalPicturePath($a_usr_id, $a_size="small", $a_force_pic=false, $a_prevent_no_photo_image=false)
Get path to personal picture.
static _getExportDirectory($a_obj_id, $a_type="xml", $a_obj_type="", $a_entity="")
Get export directory for an repository object.
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
+ Here is the call graph for this function:

◆ buildExportTemplate()

ilPortfolioHTMLExport::buildExportTemplate ( array  $a_js_files = null)

Definition at line 205 of file class.ilPortfolioHTMLExport.php.

References $tpl, object, and ilObjPortfolioBaseGUI\renderFullscreenHeader().

Referenced by writeExportFile().

206  {
207  global $ilTabs;
208 
209  $this->tpl = $this->co_page_html_export->getPreparedMainTemplate();
210  $this->tpl->getStandardTemplate();
211  $this->tpl->addOnLoadCode('il.Tooltip.init();', 3);
212 
213  // js files
214  if(is_array($a_js_files))
215  {
216  foreach($a_js_files as $js_file)
217  {
218  $this->tpl->setCurrentBlock("js_file");
219  $this->tpl->setVariable("JS_FILE", !stristr($js_file, "://")
220  ? "./js/".basename($js_file)
221  : $js_file);
222  $this->tpl->parseCurrentBlock();
223  }
224  }
225 
226  // workaround
227  $this->tpl->setVariable("MAINMENU", "<div style='min-height:40px;'></div>");
228  $this->tpl->setTitle($this->object->getTitle());
229 
230  $ilTabs->clearTargets();
231  if($this->tabs)
232  {
233  foreach($this->tabs as $id => $caption)
234  {
235  $ilTabs->addTab("user_page_".$id, $caption, "prtf_".$id.".html");
236  }
237 
238  $ilTabs->activateTab($this->active_tab);
239  }
240 
241  include_once "Modules/Portfolio/classes/class.ilObjPortfolioGUI.php";
242  ilObjPortfolioGUI::renderFullscreenHeader($this->object, $this->tpl, $this->object->getOwner(), true);
243 
244  return $this->tpl;
245  }
global $tpl
Definition: ilias.php:8
static renderFullscreenHeader($a_portfolio, $a_tpl, $a_user_id, $a_export=false)
Render banner, user name.
Create new PHPExcel object
obj_idprivate
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ exportHTMLPages()

ilPortfolioHTMLExport::exportHTMLPages ( )

Export all pages.

Definition at line 144 of file class.ilPortfolioHTMLExport.php.

References $ilBench, $tpl, ilPageObject\_exists(), ilObject2\_lookupTitle(), array, exportPageHTML(), ilPortfolioPage\getAllPortfolioPages(), object, ilPortfolioPage\TYPE_BLOG, and ilObject2GUI\WORKSPACE_OBJECT_ID.

Referenced by buildExportFile().

145  {
146  global $tpl, $ilBench, $ilLocator;
147 
148  require_once "Modules/Portfolio/classes/class.ilPortfolioPage.php";
149  $pages = ilPortfolioPage::getAllPortfolioPages($this->object->getId());
150 
151  $this->tabs = array();
152  foreach($pages as $page)
153  {
154  // substitute blog id with title
155  if($page["type"] == ilPortfolioPage::TYPE_BLOG)
156  {
157  include_once "Modules/Blog/classes/class.ilObjBlog.php";
158  $page["title"] = ilObjBlog::_lookupTitle((int)$page["title"]);
159  }
160 
161  $this->tabs[$page["id"]] = $page["title"];
162  }
163 
164  // for sub-pages, e.g. blog postings
165  $tpl_callback = array($this, "buildExportTemplate");
166 
167  include_once("./Services/COPage/classes/class.ilPageContentUsage.php");
168  include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
169  include_once("./Modules/Portfolio/classes/class.ilPortfolioPage.php");
170  $has_index = false;
171  foreach ($pages as $page)
172  {
173  if (ilPortfolioPage::_exists("prtf", $page["id"]))
174  {
175  $this->active_tab = "user_page_".$page["id"];
176 
177  if($page["type"] == ilPortfolioPage::TYPE_BLOG)
178  {
179  $link_template = "prtf_".$page["id"]."_bl{TYPE}_{ID}.html";
180 
181  include_once "Modules/Blog/classes/class.ilObjBlogGUI.php";
182  $blog = new ilObjBlogGUI((int)$page["title"], ilObject2GUI::WORKSPACE_OBJECT_ID);
183  $blog->exportHTMLPages($this->export_dir."/", $link_template, $tpl_callback, $this->co_page_html_export, "prtf_".$page["id"].".html");
184  }
185  else
186  {
187  $this->exportPageHTML($page["id"]);
188  $this->co_page_html_export->collectPageElements("prtf:pg", $page["id"]);
189  }
190 
191  if(!$has_index)
192  {
193  if (is_file($this->export_dir."/prtf_".$page["id"].".html")) // #20144
194  {
195  copy($this->export_dir . "/prtf_" . $page["id"] . ".html",
196  $this->export_dir . "/index.html");
197  $has_index = true;
198  }
199  }
200  }
201  }
202  $this->co_page_html_export->exportPageElements();
203  }
static _exists($a_parent_type, $a_id, $a_lang="", $a_no_cache=false)
Checks whether page exists.
static getAllPortfolioPages($a_portfolio_id)
Get pages of portfolio.
static _lookupTitle($a_id)
global $tpl
Definition: ilias.php:8
Class ilObjBlogGUI.
Create styles array
The data for the language used.
exportPageHTML($a_post_id)
Export page html.
Create new PHPExcel object
obj_idprivate
global $ilBench
Definition: ilias.php:18
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ exportPageHTML()

ilPortfolioHTMLExport::exportPageHTML (   $a_post_id)

Export page html.

Definition at line 292 of file class.ilPortfolioHTMLExport.php.

References $lng, ilUIFramework\getJSFiles(), object, ilPageObjectGUI\setOutputMode(), and writeExportFile().

Referenced by exportHTMLPages().

293  {
294  global $lng;
295 
296  // page
297  include_once "Modules/Portfolio/classes/class.ilPortfolioPageGUI.php";
298  $pgui = new ilPortfolioPageGUI($this->object->getId(), $a_post_id);
299  $pgui->setOutputMode("offline");
300  $pgui->setFullscreenLink("fullscreen.html"); // #12930 - see page.xsl
301  $page_content = $pgui->showPage();
302 
303  $material = $pgui->getExportMaterial();
304  $this->export_material[] = $material;
305 
306  include_once("./Services/UICore/classes/class.ilUIFramework.php");
307  $js_files = array_merge(ilUIFramework::getJSFiles(), $material["js"]);
308 
309  $this->writeExportFile("prtf_".$a_post_id.".html", $page_content, $pgui->getJsOnloadCode(), $js_files);
310  }
static getJSFiles()
Get javascript files.
Portfolio page gui class.
writeExportFile($a_file, $a_content, $a_onload=null, $a_js_files=null)
Create new PHPExcel object
obj_idprivate
global $lng
Definition: privfeed.php:17
setOutputMode($a_mode=IL_PAGE_PRESENTATION)
Set Output Mode.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ writeExportFile()

ilPortfolioHTMLExport::writeExportFile (   $a_file,
  $a_content,
  $a_onload = null,
  $a_js_files = null 
)

Definition at line 247 of file class.ilPortfolioHTMLExport.php.

References $a_content, $file, and buildExportTemplate().

Referenced by exportPageHTML().

248  {
249  $file = $this->export_dir."/".$a_file;
250  // return if file is already existing
251  if (@is_file($file))
252  {
253  return;
254  }
255 
256  // export template: page content
257  $ep_tpl = new ilTemplate("tpl.export_page.html", true, true,
258  "Modules/Portfolio");
259  $ep_tpl->setVariable("PAGE_CONTENT", $a_content);
260 
261  $this->buildExportTemplate($a_js_files);
262  $this->tpl->setContent($ep_tpl->get());
263 
264  if(is_array($a_onload))
265  {
266  foreach($a_onload as $item)
267  {
268  $this->tpl->addOnLoadCode($item);
269  }
270  }
271 
272 
273  $content = $this->tpl->get("DEFAULT", false, false, false,
274  true, true, true);
275 
276  // open file
277  if (!file_put_contents($file, $content))
278  {
279  die ("<b>Error</b>: Could not open \"".$file."\" for writing".
280  " in <b>".__FILE__."</b> on line <b>".__LINE__."</b><br />");
281  }
282 
283  // set file permissions
284  chmod($file, 0770);
285 
286  return $file;
287  }
$a_content
Definition: workflow.php:94
special template class to simplify handling of ITX/PEAR
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
buildExportTemplate(array $a_js_files=null)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $export_material

ilPortfolioHTMLExport::$export_material
protected

Definition at line 15 of file class.ilPortfolioHTMLExport.php.

◆ $portfolio_gui

ilPortfolioHTMLExport::$portfolio_gui
protected

Definition at line 14 of file class.ilPortfolioHTMLExport.php.


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