ILIAS  release_4-4 Revision
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 ()
 
 writeExportFile ($a_file, $a_content, $a_onload=null)
 
 exportPageHTML ($a_post_id)
 Export page html. More...
 

Protected Attributes

 $portfolio_gui
 

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

23  {
24  $this->portfolio_gui = $a_portfolio_gui;
25  $this->object = $a_object;
26  }

Member Function Documentation

◆ buildExportFile()

ilPortfolioHTMLExport::buildExportFile ( )

Build export file.

Parameters

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

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

35  {
36  global $ilias;
37 
38  // create export file
39  include_once("./Services/Export/classes/class.ilExport.php");
40  ilExport::_createExportDirectory($this->object->getId(), "html", "prtf");
41  $exp_dir = ilExport::_getExportDirectory($this->object->getId(), "html", "prtf");
42 
43  $this->subdir = $this->object->getType()."_".$this->object->getId();
44  $this->export_dir = $exp_dir."/".$this->subdir;
45 
46  // initialize temporary target directory
47  ilUtil::delDir($this->export_dir);
48  ilUtil::makeDir($this->export_dir);
49 
50  // system style html exporter
51  include_once("./Services/Style/classes/class.ilSystemStyleHTMLExport.php");
52  $this->sys_style_html_export = new ilSystemStyleHTMLExport($this->export_dir);
53  // $this->sys_style_html_export->addImage("icon_prtf_b.png");
54  $this->sys_style_html_export->export();
55 
56  // init co page html exporter
57  include_once("./Services/COPage/classes/class.ilCOPageHTMLExport.php");
58  $this->co_page_html_export = new ilCOPageHTMLExport($this->export_dir);
59  $this->co_page_html_export->setContentStyleId($this->object->getStyleSheetId());
60  $this->co_page_html_export->createDirectories();
61  $this->co_page_html_export->exportStyles();
62  $this->co_page_html_export->exportSupportScripts();
63 
64  // banner / profile picture
65  $prfa_set = new ilSetting("prfa");
66  if($prfa_set->get("banner"))
67  {
68  $banner = $this->object->getImageFullPath();
69  if($banner) // #16096
70  {
71  copy($banner, $this->export_dir."/".basename($banner));
72  }
73  }
74  $ppic = ilObjUser::_getPersonalPicturePath($this->object->getOwner(), "big");
75  if($ppic)
76  {
77  $ppic = array_shift(explode("?", $ppic));
78  copy($ppic, $this->export_dir."/".basename($ppic));
79  }
80 
81  // export pages
82  $this->exportHTMLPages();
83 
84  // zip everything
85  if (true)
86  {
87  // zip it all
88  $date = time();
89  $zip_file = ilExport::_getExportDirectory($this->object->getId(), "html", "prtf").
90  "/".$date."__".IL_INST_ID."__".
91  $this->object->getType()."_".$this->object->getId().".zip";
92  ilUtil::zip($this->export_dir, $zip_file);
93  ilUtil::delDir($this->export_dir);
94  }
95 
96  return $zip_file;
97  }
ILIAS Setting Class.
HTML export class for pages.
HTML export class for system styles.
_createExportDirectory($a_obj_id, $a_export_type="xml", $a_obj_type="")
Create export directory.
static zip($a_dir, $a_file, $compress_content=false)
zips given directory/file into given zip.file
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
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.
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 ( )

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

References $tpl, and ilObjPortfolioBaseGUI\renderFullscreenHeader().

Referenced by writeExportFile().

161  {
162  global $ilTabs;
163 
164  $this->tpl = $this->co_page_html_export->getPreparedMainTemplate();
165  $this->tpl->getStandardTemplate();
166  $this->tpl->addOnLoadCode('il.Tooltip.init();', 3);
167 
168  // workaround
169  $this->tpl->setVariable("MAINMENU", "<div style='min-height:40px;'></div>");
170  $this->tpl->setTitle($this->object->getTitle());
171 
172  $ilTabs->clearTargets();
173  if($this->tabs)
174  {
175  foreach($this->tabs as $id => $caption)
176  {
177  $ilTabs->addTab("user_page_".$id, $caption, "prtf_".$id.".html");
178  }
179 
180  $ilTabs->activateTab($this->active_tab);
181  }
182 
183  include_once "Modules/Portfolio/classes/class.ilObjPortfolioGUI.php";
184  ilObjPortfolioGUI::renderFullscreenHeader($this->object, $this->tpl, $this->object->getOwner(), true);
185  $this->tpl->setFrameFixedWidth(true);
186 
187  return $this->tpl;
188  }
if(isset($_FILES['img_file']['size']) && $_FILES['img_file']['size'] > 0) $tpl
static renderFullscreenHeader($a_portfolio, $a_tpl, $a_user_id, $a_export=false)
Render banner, user name.
+ 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 102 of file class.ilPortfolioHTMLExport.php.

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

Referenced by buildExportFile().

103  {
104  global $tpl, $ilBench, $ilLocator;
105 
106  require_once "Modules/Portfolio/classes/class.ilPortfolioPage.php";
107  $pages = ilPortfolioPage::getAllPages($this->object->getId());
108 
109  $this->tabs = array();
110  foreach($pages as $page)
111  {
112  // substitute blog id with title
113  if($page["type"] == ilPortfolioPage::TYPE_BLOG)
114  {
115  include_once "Modules/Blog/classes/class.ilObjBlog.php";
116  $page["title"] = ilObjBlog::_lookupTitle((int)$page["title"]);
117  }
118 
119  $this->tabs[$page["id"]] = $page["title"];
120  }
121 
122  // for sub-pages, e.g. blog postings
123  $tpl_callback = array($this, "buildExportTemplate");
124 
125  include_once("./Services/COPage/classes/class.ilPageContentUsage.php");
126  include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
127  include_once("./Modules/Portfolio/classes/class.ilPortfolioPage.php");
128  $has_index = false;
129  foreach ($pages as $page)
130  {
131  if (ilPortfolioPage::_exists("prtf", $page["id"]))
132  {
133  $this->active_tab = "user_page_".$page["id"];
134 
135  if($page["type"] == ilPortfolioPage::TYPE_BLOG)
136  {
137  $link_template = "prtf_".$page["id"]."_bl{TYPE}_{ID}.html";
138 
139  include_once "Modules/Blog/classes/class.ilObjBlogGUI.php";
140  $blog = new ilObjBlogGUI((int)$page["title"], ilObject2GUI::WORKSPACE_OBJECT_ID);
141  $blog->exportHTMLPages($this->export_dir."/", $link_template, $tpl_callback, $this->co_page_html_export, "prtf_".$page["id"].".html");
142  }
143  else
144  {
145  $this->exportPageHTML($page["id"]);
146  $this->co_page_html_export->collectPageElements("prtf:pg", $page["id"]);
147  }
148 
149  if(!$has_index)
150  {
151  copy($this->export_dir."/prtf_".$page["id"].".html",
152  $this->export_dir."/index.html");
153  $has_index = true;
154  }
155  }
156  }
157  $this->co_page_html_export->exportPageElements();
158  }
static _lookupTitle($a_id)
static _exists($a_parent_type, $a_id, $a_lang="")
Checks whether page exists.
Class ilObjBlogGUI.
if(isset($_FILES['img_file']['size']) && $_FILES['img_file']['size'] > 0) $tpl
static getAllPages($a_portfolio_id)
Get pages of portfolio.
exportPageHTML($a_post_id)
Export page html.
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 235 of file class.ilPortfolioHTMLExport.php.

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

Referenced by exportHTMLPages().

236  {
237  global $lng;
238 
239  // page
240  include_once "Modules/Portfolio/classes/class.ilPortfolioPageGUI.php";
241  $pgui = new ilPortfolioPageGUI($this->object->getId(), $a_post_id);
242  $pgui->setOutputMode("offline");
243  $pgui->setFullscreenLink("fullscreen.html"); // #12930 - see page.xsl
244  $page_content = $pgui->showPage();
245 
246  $this->writeExportFile("prtf_".$a_post_id.".html", $page_content, $pgui->getJsOnloadCode());
247  }
Portfolio page gui class.
writeExportFile($a_file, $a_content, $a_onload=null)
global $lng
Definition: privfeed.php:40
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 
)

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

References $file, and buildExportTemplate().

Referenced by exportPageHTML().

191  {
192  $file = $this->export_dir."/".$a_file;
193  // return if file is already existing
194  if (@is_file($file))
195  {
196  return;
197  }
198 
199  // export template: page content
200  $ep_tpl = new ilTemplate("tpl.export_page.html", true, true,
201  "Modules/Portfolio");
202  $ep_tpl->setVariable("PAGE_CONTENT", $a_content);
203 
204  $this->buildExportTemplate();
205  $this->tpl->setContent($ep_tpl->get());
206 
207  if(is_array($a_onload))
208  {
209  foreach($a_onload as $item)
210  {
211  $this->tpl->addOnLoadCode($item);
212  }
213  }
214 
215 
216  $content = $this->tpl->get("DEFAULT", false, false, false,
217  true, true, true);
218 
219  // open file
220  if (!file_put_contents($file, $content))
221  {
222  die ("<b>Error</b>: Could not open \"".$file."\" for writing".
223  " in <b>".__FILE__."</b> on line <b>".__LINE__."</b><br />");
224  }
225 
226  // set file permissions
227  chmod($file, 0770);
228 
229  return $file;
230  }
print $file
special template class to simplify handling of ITX/PEAR
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $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: