ILIAS  Release_4_2_x_branch Revision 61807
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilPortfolioHTMLExport Class Reference

Portfolio HTML exporter class. More...

+ Collaboration diagram for ilPortfolioHTMLExport:

Public Member Functions

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

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

ilPortfolioHTMLExport::__construct (   $a_portfolio_gui,
  $a_object 
)

Constructor.

Parameters
@return

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

{
$this->portfolio_gui = $a_portfolio_gui;
$this->object = $a_object;
}

Member Function Documentation

ilPortfolioHTMLExport::buildExportFile ( )

Build export file.

Parameters
@return

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

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

{
global $ilias;
// create export file
include_once("./Services/Export/classes/class.ilExport.php");
ilExport::_createExportDirectory($this->object->getId(), "html", "prtf");
$exp_dir = ilExport::_getExportDirectory($this->object->getId(), "html", "prtf");
$this->subdir = $this->object->getType()."_".$this->object->getId();
$this->export_dir = $exp_dir."/".$this->subdir;
// initialize temporary target directory
ilUtil::delDir($this->export_dir);
ilUtil::makeDir($this->export_dir);
// system style html exporter
include_once("./Services/Style/classes/class.ilSystemStyleHTMLExport.php");
$this->sys_style_html_export = new ilSystemStyleHTMLExport($this->export_dir);
// $this->sys_style_html_export->addImage("icon_prtf_b.gif");
$this->sys_style_html_export->export();
// init co page html exporter
include_once("./Services/COPage/classes/class.ilCOPageHTMLExport.php");
$this->co_page_html_export = new ilCOPageHTMLExport($this->export_dir);
/* $this->co_page_html_export->setContentStyleId(
$this->object->getStyleSheetId()); */
$this->co_page_html_export->createDirectories();
$this->co_page_html_export->exportStyles();
$this->co_page_html_export->exportSupportScripts();
// banner / profile picture
$prfa_set = new ilSetting("prfa");
if($prfa_set->get("banner"))
{
$banner = $this->object->getImageFullPath();
copy($banner, $this->export_dir."/".basename($banner));
}
$ppic = ilObjUser::_getPersonalPicturePath($this->object->getOwner(), "big");
if($ppic)
{
$ppic = array_shift(explode("?", $ppic));
copy($ppic, $this->export_dir."/".basename($ppic));
}
// export pages
$this->exportHTMLPages();
// zip everything
if (true)
{
// zip it all
$date = time();
$zip_file = ilExport::_getExportDirectory($this->object->getId(), "html", "prtf").
"/".$date."__".IL_INST_ID."__".
$this->object->getType()."_".$this->object->getId().".zip";
ilUtil::zip($this->export_dir, $zip_file);
ilUtil::delDir($this->export_dir);
}
return $zip_file;
}

+ Here is the call graph for this function:

ilPortfolioHTMLExport::buildExportTemplate ( )

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

References $tpl, and ilObjPortfolioGUI\renderFullscreenHeader().

Referenced by writeExportFile().

{
global $ilTabs;
$this->tpl = $this->co_page_html_export->getPreparedMainTemplate();
$this->tpl->getStandardTemplate();
$this->tpl->addOnLoadCode('ilTooltip.init();', 3);
// workaround
$this->tpl->setVariable("MAINMENU", "<div style='min-height:40px;'></div>");
$this->tpl->setTitle($this->object->getTitle());
$ilTabs->clearTargets();
if($this->tabs)
{
foreach($this->tabs as $id => $caption)
{
$ilTabs->addTab("user_page_".$id, $caption, "prtf_".$id.".html");
}
$ilTabs->activateTab($this->active_tab);
}
include_once "Services/Portfolio/classes/class.ilObjPortfolioGUI.php";
ilObjPortfolioGUI::renderFullscreenHeader($this->object, $this->tpl, $this->object->getOwner(), true);
$this->tpl->setFrameFixedWidth(true);
return $this->tpl;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilPortfolioHTMLExport::exportHTMLPages ( )

Export all pages.

Definition at line 100 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().

{
global $tpl, $ilBench, $ilLocator;
require_once "Services/Portfolio/classes/class.ilPortfolioPage.php";
$pages = ilPortfolioPage::getAllPages($this->object->getId());
$this->tabs = array();
foreach($pages as $page)
{
// substitute blog id with title
if($page["type"] == ilPortfolioPage::TYPE_BLOG)
{
include_once "Modules/Blog/classes/class.ilObjBlog.php";
$page["title"] = ilObjBlog::_lookupTitle((int)$page["title"]);
}
$this->tabs[$page["id"]] = $page["title"];
}
// for sub-pages, e.g. blog postings
$tpl_callback = array($this, "buildExportTemplate");
include_once("./Services/COPage/classes/class.ilPageContentUsage.php");
include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
$has_index = false;
foreach ($pages as $page)
{
if (ilPageObject::_exists("prtf", $page["id"]))
{
$this->active_tab = "user_page_".$page["id"];
if($page["type"] == ilPortfolioPage::TYPE_BLOG)
{
$link_template = "prtf_".$page["id"]."_bl{TYPE}_{ID}.html";
include_once "Modules/Blog/classes/class.ilObjBlogGUI.php";
$blog = new ilObjBlogGUI((int)$page["title"], ilObject2GUI::WORKSPACE_OBJECT_ID);
$blog->exportHTMLPages($this->export_dir."/", $link_template, $tpl_callback, $this->co_page_html_export, "prtf_".$page["id"].".html");
}
else
{
$this->exportPageHTML($page["id"]);
$this->co_page_html_export->collectPageElements("prtf:pg", $page["id"]);
}
if(!$has_index)
{
copy($this->export_dir."/prtf_".$page["id"].".html",
$this->export_dir."/index.html");
$has_index = true;
}
}
}
$this->co_page_html_export->exportPageElements();
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilPortfolioHTMLExport::exportPageHTML (   $a_post_id)

Export page html.

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

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

Referenced by exportHTMLPages().

{
global $lng;
// page
include_once "Services/Portfolio/classes/class.ilPortfolioPageGUI.php";
$pgui = new ilPortfolioPageGUI($this->object->getId(), $a_post_id);
$pgui->setOutputMode("offline");
$page_content = $pgui->showPage();
$this->writeExportFile("prtf_".$a_post_id.".html", $page_content, $pgui->getJsOnloadCode());
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

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

References $file, and buildExportTemplate().

Referenced by exportPageHTML().

{
$file = $this->export_dir."/".$a_file;
// return if file is already existing
if (@is_file($file))
{
return;
}
// export template: page content
$ep_tpl = new ilTemplate("tpl.export_page.html", true, true,
"Services/Portfolio");
$ep_tpl->setVariable("PAGE_CONTENT", $a_content);
$this->tpl->setContent($ep_tpl->get());
if(is_array($a_onload))
{
foreach($a_onload as $item)
{
$this->tpl->addOnLoadCode($item);
}
}
$content = $this->tpl->get("DEFAULT", false, false, false,
true, true, true);
// open file
if (!file_put_contents($file, $content))
{
die ("<b>Error</b>: Could not open \"".$file."\" for writing".
" in <b>".__FILE__."</b> on line <b>".__LINE__."</b><br />");
}
// set file permissions
chmod($file, 0770);
return $file;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Field Documentation

ilPortfolioHTMLExport::$portfolio_gui
protected

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


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