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

Wiki HTML exporter class. More...

+ Collaboration diagram for ilWikiHTMLExport:

Public Member Functions

 __construct ($a_wiki)
 Constructor. More...
 
 setMode ($a_val)
 Set mode. More...
 
 getMode ()
 Get mode. More...
 
 buildExportFile ()
 Build export file. More...
 
 exportHTMLPages ()
 Export all pages. More...
 
 updateUserHTMLStatusForPageElements ($a_total, $a_cnt)
 Callback for updating the export status during elements export (media objects, files, ...) More...
 
 exportPageHTML ($a_page_id)
 Export page html. More...
 
 getUserExportFile ()
 Get user export file. More...
 

Data Fields

const MODE_DEFAULT = "html"
 
const MODE_USER = "user_html"
 

Protected Attributes

 $wiki
 
 $mode = self::MODE_DEFAULT
 
 $log
 

Detailed Description

Wiki HTML exporter class.

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$ /

Definition at line 11 of file class.ilWikiHTMLExport.php.

Constructor & Destructor Documentation

◆ __construct()

ilWikiHTMLExport::__construct (   $a_wiki)

Constructor.

Parameters

return

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

30 {
31 $this->wiki = $a_wiki;
32 $this->log = ilLoggerFactory::getLogger('wiki');
33 }
static getLogger($a_component_id)
Get component logger.

References ilLoggerFactory\getLogger().

+ Here is the call graph for this function:

Member Function Documentation

◆ buildExportFile()

ilWikiHTMLExport::buildExportFile ( )

Build export file.

Parameters

return

Definition at line 61 of file class.ilWikiHTMLExport.php.

62 {
63 $this->log->debug("buildExportFile...");
64 //init the mathjax rendering for HTML export
65 include_once './Services/MathJax/classes/class.ilMathJax.php';
67
68 if ($this->getMode() == self::MODE_USER)
69 {
70 global $ilDB, $ilUser;
71 include_once("./Modules/Wiki/classes/class.ilWikiUserHTMLExport.php");
72 $this->user_html_exp = new ilWikiUserHTMLExport($this->wiki, $ilDB, $ilUser);
73 }
74
75 $ascii_name = str_replace(" ", "_", ilUtil::getASCIIFilename($this->wiki->getTitle()));
76
77 // create export file
78 include_once("./Services/Export/classes/class.ilExport.php");
79 ilExport::_createExportDirectory($this->wiki->getId(), $this->getMode(), "wiki");
80 $exp_dir =
81 ilExport::_getExportDirectory($this->wiki->getId(), $this->getMode(), "wiki");
82
83 if ($this->getMode() == self::MODE_USER)
84 {
85 ilUtil::delDir($exp_dir, true);
86 }
87
88 if ($this->getMode() == self::MODE_USER)
89 {
90 $this->subdir = $ascii_name;
91 }
92 else
93 {
94 $this->subdir = $this->wiki->getType()."_".$this->wiki->getId();
95 }
96 $this->export_dir = $exp_dir."/".$this->subdir;
97//echo "+".$this->export_dir."+";
98 // initialize temporary target directory
99 ilUtil::delDir($this->export_dir);
100 ilUtil::makeDir($this->export_dir);
101
102 $this->log->debug("export directory: ".$this->export_dir);
103
104 // system style html exporter
105 include_once("./Services/Style/System/classes/class.ilSystemStyleHTMLExport.php");
106 $this->sys_style_html_export = new ilSystemStyleHTMLExport($this->export_dir);
107 $this->sys_style_html_export->addImage("icon_wiki.svg");
108 $this->sys_style_html_export->export();
109
110 // init co page html exporter
111 include_once("./Services/COPage/classes/class.ilCOPageHTMLExport.php");
112 $this->co_page_html_export = new ilCOPageHTMLExport($this->export_dir);
113 $this->co_page_html_export->setContentStyleId(
114 $this->wiki->getStyleSheetId());
115 $this->co_page_html_export->createDirectories();
116 $this->co_page_html_export->exportStyles();
117 $this->co_page_html_export->exportSupportScripts();
118
119 // export pages
120 $this->log->debug("export pages");
121 $this->exportHTMLPages();
122
123 $date = time();
124 $zip_file_name = ($this->getMode() == self::MODE_USER)
125 ? $ascii_name.".zip"
126 : $date."__".IL_INST_ID."__".$this->wiki->getType()."_".$this->wiki->getId().".zip";
127
128 // zip everything
129 if (true)
130 {
131 // zip it all
132 $zip_file = ilExport::_getExportDirectory($this->wiki->getId(), $this->getMode(), "wiki").
133 "/".$zip_file_name;
134 $this->log->debug("zip: ".$zip_file);
135 ilUtil::zip($this->export_dir, $zip_file);
136 ilUtil::delDir($this->export_dir);
137 }
138 }
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.
static _createExportDirectory($a_obj_id, $a_export_type="xml", $a_obj_type="")
static getInstance()
Singleton: get instance.
const PURPOSE_EXPORT
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 getASCIIFilename($a_filename)
convert utf8 to ascii filename
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
exportHTMLPages()
Export all pages.
Class manages user html export.
global $ilDB
$ilUser
Definition: imgupload.php:18

References $ilDB, $ilUser, ilExport\_createExportDirectory(), ilExport\_getExportDirectory(), ilUtil\delDir(), exportHTMLPages(), ilUtil\getASCIIFilename(), ilMathJax\getInstance(), getMode(), ilUtil\makeDir(), MODE_USER, ilMathJax\PURPOSE_EXPORT, and ilUtil\zip().

+ Here is the call graph for this function:

◆ exportHTMLPages()

ilWikiHTMLExport::exportHTMLPages ( )

Export all pages.

Definition at line 143 of file class.ilWikiHTMLExport.php.

144 {
145 global $tpl, $ilBench, $ilLocator;
146
147 $pages = ilWikiPage::getAllWikiPages($this->wiki->getId());
148
149 include_once("./Services/COPage/classes/class.ilPageContentUsage.php");
150 include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
151 $cnt = 0;
152 foreach ($pages as $page)
153 {
154 $this->log->debug("page: ".$page["id"]);
155 if (ilWikiPage::_exists("wpg", $page["id"]))
156 {
157 $this->log->debug("export page");
158 $this->exportPageHTML($page["id"]);
159 $this->log->debug("collect page elements");
160 $this->co_page_html_export->collectPageElements("wpg:pg", $page["id"]);
161 }
162//sleep(2);
163 if ($this->getMode() == self::MODE_USER)
164 {
165 $cnt++;
166 $this->log->debug("update status: ".$cnt);
167 $this->user_html_exp->updateStatus((int) (50 / count($pages) * $cnt) ,ilWikiUserHTMLExport::RUNNING);
168 }
169
170 }
171 $this->co_page_html_export->exportPageElements($this->updateUserHTMLStatusForPageElements);
172 }
global $tpl
Definition: ilias.php:8
static _exists($a_parent_type, $a_id, $a_lang="", $a_no_cache=false)
Checks whether page exists.
updateUserHTMLStatusForPageElements($a_total, $a_cnt)
Callback for updating the export status during elements export (media objects, files,...
exportPageHTML($a_page_id)
Export page html.
static getAllWikiPages($a_wiki_id)
Get all pages of wiki
global $ilBench
Definition: ilias.php:18

References $ilBench, $tpl, ilPageObject\_exists(), exportPageHTML(), ilWikiPage\getAllWikiPages(), getMode(), ilWikiUserHTMLExport\RUNNING, and updateUserHTMLStatusForPageElements().

Referenced by buildExportFile().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ exportPageHTML()

ilWikiHTMLExport::exportPageHTML (   $a_page_id)

Export page html.

Definition at line 191 of file class.ilWikiHTMLExport.php.

192 {
193 global $ilUser, $lng, $ilTabs;
194
195 $ilTabs->clearTargets();
196
197 $this->tpl = $this->co_page_html_export->getPreparedMainTemplate();
198
199 $this->tpl->getStandardTemplate();
200 $file = $this->export_dir."/wpg_".$a_page_id.".html";
201 // return if file is already existing
202 if (@is_file($file))
203 {
204 $this->log->debug("file already exists");
205 return;
206 }
207
208 // page
209 $this->log->debug("init page gui");
210 include_once("./Modules/Wiki/classes/class.ilWikiPageGUI.php");
211 $wpg_gui = new ilWikiPageGUI($a_page_id);
212 $wpg_gui->setOutputMode("offline");
213 $page_content = $wpg_gui->showPage();
214
215 // export template: page content
216 $this->log->debug("init page gui");
217 $ep_tpl = new ilTemplate("tpl.export_page.html", true, true,
218 "Modules/Wiki");
219 $ep_tpl->setVariable("PAGE_CONTENT", $page_content);
220
221 // export template: right content
222 include_once("./Modules/Wiki/classes/class.ilWikiImportantPagesBlockGUI.php");
224 $ep_tpl->setVariable("RIGHT_CONTENT", $bl->getHTML(true));
225
226 // workaround
227// $this->tpl->setVariable("MAINMENU", "<div style='min-height:40px;'></div>");
228 $this->tpl->setVariable("MAINMENU", "");
229
230 $this->log->debug("set title");
231 $this->tpl->setTitle($this->wiki->getTitle());
232 $this->tpl->setTitleIcon("./images/icon_wiki.svg",
233 $lng->txt("obj_wiki"));
234
235 $this->tpl->setContent($ep_tpl->get());
236 //$this->tpl->fillMainContent();
237 $content = $this->tpl->get("DEFAULT", false, false, false,
238 true, true, true);
239
240//echo htmlentities($content); exit;
241 // open file
242 $this->log->debug("write file: ".$file);
243 if (!($fp = @fopen($file,"w+")))
244 {
245 $this->log->error("Could not open ".$file." for writing.");
246 include_once("./Modules/Wiki/exceptions/class.ilWikiExportException.php");
247 throw new ilWikiExportException("Could not open \"".$file."\" for writing.");
248 }
249
250 // set file permissions
251 $this->log->debug("set permissions");
252 chmod($file, 0770);
253
254 // write xml data into the file
255 fwrite($fp, $content);
256
257 // close file
258 fclose($fp);
259
260 if ($this->wiki->getStartPage() == $wpg_gui->getPageObject()->getTitle())
261 {
262 copy($file, $this->export_dir."/index.html");
263 }
264 }
special template class to simplify handling of ITX/PEAR
Base exception class for wikis.
Class ilWikiPage GUI class.
global $lng
Definition: privfeed.php:17
if(!file_exists("$old.txt")) if( $old===$new) if(file_exists("$new.txt")) $file

References $file, $ilUser, and $lng.

Referenced by exportHTMLPages().

+ Here is the caller graph for this function:

◆ getMode()

ilWikiHTMLExport::getMode ( )

Get mode.

Returns
int MODE_DEFAULT|MODE_USER

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

References $mode.

Referenced by buildExportFile(), exportHTMLPages(), and updateUserHTMLStatusForPageElements().

+ Here is the caller graph for this function:

◆ getUserExportFile()

ilWikiHTMLExport::getUserExportFile ( )

Get user export file.

Parameters

return

Definition at line 272 of file class.ilWikiHTMLExport.php.

273 {
274 include_once("./Services/Export/classes/class.ilExport.php");
275 $exp_dir =
276 ilExport::_getExportDirectory($this->wiki->getId(), $this->getMode(), "wiki");
277 $this->log->debug("dir: ".$exp_dir);
278 foreach (new DirectoryIterator($exp_dir) as $fileInfo)
279 {
280 $this->log->debug("file: ".$fileInfo->getFilename());
281 if (pathinfo($fileInfo->getFilename(),PATHINFO_EXTENSION) == "zip")
282 {
283 $this->log->debug("return: ".$exp_dir."/".$fileInfo->getFilename());
284 return $exp_dir."/".$fileInfo->getFilename();
285 }
286 }
287 return false;
288 }

References ilExport\_getExportDirectory().

+ Here is the call graph for this function:

◆ setMode()

ilWikiHTMLExport::setMode (   $a_val)

Set mode.

Parameters
int$a_valMODE_DEFAULT|MODE_USER

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

41 {
42 $this->mode = $a_val;
43 }

◆ updateUserHTMLStatusForPageElements()

ilWikiHTMLExport::updateUserHTMLStatusForPageElements (   $a_total,
  $a_cnt 
)

Callback for updating the export status during elements export (media objects, files, ...)

Parameters

Definition at line 179 of file class.ilWikiHTMLExport.php.

180 {
181 if ($this->getMode() == self::MODE_USER)
182 {
183 $this->user_html_exp->updateStatus((int) 50 + (50 / count($a_total) * $a_cnt) ,ilWikiUserHTMLExport::RUNNING);
184 }
185 }

References getMode(), and ilWikiUserHTMLExport\RUNNING.

Referenced by exportHTMLPages().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $log

ilWikiHTMLExport::$log
protected

Definition at line 21 of file class.ilWikiHTMLExport.php.

◆ $mode

ilWikiHTMLExport::$mode = self::MODE_DEFAULT
protected

Definition at line 16 of file class.ilWikiHTMLExport.php.

Referenced by getMode().

◆ $wiki

ilWikiHTMLExport::$wiki
protected

Definition at line 13 of file class.ilWikiHTMLExport.php.

◆ MODE_DEFAULT

const ilWikiHTMLExport::MODE_DEFAULT = "html"

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

◆ MODE_USER

const ilWikiHTMLExport::MODE_USER = "user_html"

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