ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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

return

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

24 {
25 $this->portfolio_gui = $a_portfolio_gui;
26 $this->object = $a_object;
27 $this->export_material = array(); // #16571
28 }

Member Function Documentation

◆ buildExportFile()

ilPortfolioHTMLExport::buildExportFile ( )

Build export file.

Parameters

return

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

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/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 foreach($this->export_material as $items)
97 {
98 $images = array_merge($images, $items["images"]);
99 $files = array_merge($files, $items["files"]);
100 $js_files = array_merge($js_files, $items["js"]);
101 }
102 foreach(array_unique($images) as $image)
103 {
104 if(is_file($image))
105 {
106 copy($image, $this->export_dir."/images/".basename($image));
107 }
108 }
109 foreach(array_unique($js_files) as $js_file)
110 {
111 if(is_file($js_file))
112 {
113 copy($js_file, $this->export_dir."/js/".basename($js_file));
114 }
115 }
116 foreach(array_unique($files) as $file)
117 {
118 if(is_file($file))
119 {
120 copy($file, $this->export_dir."/files/".basename($file));
121 }
122 }
123
124 // zip everything
125 if (true)
126 {
127 // zip it all
128 $date = time();
129 $zip_file = ilExport::_getExportDirectory($this->object->getId(), "html", "prtf").
130 "/".$date."__".IL_INST_ID."__".
131 $this->object->getType()."_".$this->object->getId().".zip";
132 ilUtil::zip($this->export_dir, $zip_file);
133 ilUtil::delDir($this->export_dir);
134 }
135
136 return $zip_file;
137 }
print $file
HTML export class for pages.
static _getExportDirectory($a_obj_id, $a_type="xml", $a_obj_type="", $a_entity="")
Get export directory for an repository object.
_createExportDirectory($a_obj_id, $a_export_type="xml", $a_obj_type="")
Create export directory.
static _getPersonalPicturePath($a_usr_id, $a_size="small", $a_force_pic=false, $a_prevent_no_photo_image=false)
Get path to personal picture.
ILIAS Setting Class.
HTML export class for system styles.
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
static zip($a_dir, $a_file, $compress_content=false)
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...

References $file, ilExport\_createExportDirectory(), ilExport\_getExportDirectory(), ilObjUser\_getPersonalPicturePath(), ilUtil\delDir(), exportHTMLPages(), ilUtil\makeDir(), and ilUtil\zip().

+ Here is the call graph for this function:

◆ buildExportTemplate()

ilPortfolioHTMLExport::buildExportTemplate ( array  $a_js_files = null)

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

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

References $tpl, and ilObjPortfolioBaseGUI\renderFullscreenHeader().

Referenced by writeExportFile().

+ 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 142 of file class.ilPortfolioHTMLExport.php.

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

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

Referenced by buildExportFile().

+ 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 290 of file class.ilPortfolioHTMLExport.php.

291 {
292 global $lng;
293
294 // page
295 include_once "Modules/Portfolio/classes/class.ilPortfolioPageGUI.php";
296 $pgui = new ilPortfolioPageGUI($this->object->getId(), $a_post_id);
297 $pgui->setOutputMode("offline");
298 $pgui->setFullscreenLink("fullscreen.html"); // #12930 - see page.xsl
299 $page_content = $pgui->showPage();
300
301 $material = $pgui->getExportMaterial();
302 $this->export_material[] = $material;
303
304 $this->writeExportFile("prtf_".$a_post_id.".html", $page_content, $pgui->getJsOnloadCode(), $material["js"]);
305 }
writeExportFile($a_file, $a_content, $a_onload=null, $a_js_files=null)
Portfolio page gui class.
global $lng
Definition: privfeed.php:40

References $lng, and writeExportFile().

Referenced by exportHTMLPages().

+ 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 245 of file class.ilPortfolioHTMLExport.php.

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

References $file, and buildExportTemplate().

Referenced by exportPageHTML().

+ 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: