ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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

 $db
 
 $user
 
 $lng
 
 $tabs
 
 $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 49 of file class.ilWikiHTMLExport.php.

50 {
51 global $DIC;
52
53 $this->db = $DIC->database();
54 $this->user = $DIC->user();
55 $this->lng = $DIC->language();
56 $this->tabs = $DIC->tabs();
57 $this->wiki = $a_wiki;
58 $this->log = ilLoggerFactory::getLogger('wiki');
59 }
user()
Definition: user.php:4
static getLogger($a_component_id)
Get component logger.
global $DIC
Definition: saml.php:7

References $DIC, ilLoggerFactory\getLogger(), and user().

+ Here is the call graph for this function:

Member Function Documentation

◆ buildExportFile()

ilWikiHTMLExport::buildExportFile ( )

Build export file.

Parameters

return string

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

88 {
89 $this->log->debug("buildExportFile...");
90 //init the mathjax rendering for HTML export
91 include_once './Services/MathJax/classes/class.ilMathJax.php';
93
94 if ($this->getMode() == self::MODE_USER) {
97 include_once("./Modules/Wiki/classes/class.ilWikiUserHTMLExport.php");
98 $this->user_html_exp = new ilWikiUserHTMLExport($this->wiki, $ilDB, $ilUser);
99 }
100
101 $ascii_name = str_replace(" ", "_", ilUtil::getASCIIFilename($this->wiki->getTitle()));
102
103 // create export file
104 include_once("./Services/Export/classes/class.ilExport.php");
105 ilExport::_createExportDirectory($this->wiki->getId(), $this->getMode(), "wiki");
106 $exp_dir =
107 ilExport::_getExportDirectory($this->wiki->getId(), $this->getMode(), "wiki");
108
109 if ($this->getMode() == self::MODE_USER) {
110 ilUtil::delDir($exp_dir, true);
111 }
112
113 if ($this->getMode() == self::MODE_USER) {
114 $this->subdir = $ascii_name;
115 } else {
116 $this->subdir = $this->wiki->getType() . "_" . $this->wiki->getId();
117 }
118 $this->export_dir = $exp_dir . "/" . $this->subdir;
119 //echo "+".$this->export_dir."+";
120 // initialize temporary target directory
121 ilUtil::delDir($this->export_dir);
122 ilUtil::makeDir($this->export_dir);
123
124 $this->log->debug("export directory: " . $this->export_dir);
125
126 // system style html exporter
127 include_once("./Services/Style/System/classes/class.ilSystemStyleHTMLExport.php");
128 $this->sys_style_html_export = new ilSystemStyleHTMLExport($this->export_dir);
129 $this->sys_style_html_export->addImage("icon_wiki.svg");
130 $this->sys_style_html_export->export();
131
132 // init co page html exporter
133 include_once("./Services/COPage/classes/class.ilCOPageHTMLExport.php");
134 $this->co_page_html_export = new ilCOPageHTMLExport($this->export_dir);
135 $this->co_page_html_export->setContentStyleId(
137 $this->wiki->getStyleSheetId(),
138 $this->wiki->getType()
139 )
140 );
141 $this->co_page_html_export->createDirectories();
142 $this->co_page_html_export->exportStyles();
143 $this->co_page_html_export->exportSupportScripts();
144
145 // export pages
146 $this->log->debug("export pages");
147 $this->exportHTMLPages();
148
149 $date = time();
150 $zip_file_name = ($this->getMode() == self::MODE_USER)
151 ? $ascii_name . ".zip"
152 : $date . "__" . IL_INST_ID . "__" . $this->wiki->getType() . "_" . $this->wiki->getId() . ".zip";
153
154 // zip everything
155 if (true) {
156 // zip it all
157 $zip_file = ilExport::_getExportDirectory($this->wiki->getId(), $this->getMode(), "wiki") .
158 "/" . $zip_file_name;
159 $this->log->debug("zip: " . $zip_file);
160 ilUtil::zip($this->export_dir, $zip_file);
161 ilUtil::delDir($this->export_dir);
162 }
163 return $zip_file;
164 }
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
static getEffectiveContentStyleId($a_style_id, $a_type="")
Get effective Style Id.
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)
zips given directory/file into given zip.file
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 $db, $ilDB, $ilUser, $user, ilExport\_createExportDirectory(), ilExport\_getExportDirectory(), ilUtil\delDir(), exportHTMLPages(), ilUtil\getASCIIFilename(), ilObjStyleSheet\getEffectiveContentStyleId(), 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 169 of file class.ilWikiHTMLExport.php.

170 {
171 $pages = ilWikiPage::getAllWikiPages($this->wiki->getId());
172
173 include_once("./Services/COPage/classes/class.ilPageContentUsage.php");
174 include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
175 $cnt = 0;
176 foreach ($pages as $page) {
177 $this->log->debug("page: " . $page["id"]);
178 if (ilWikiPage::_exists("wpg", $page["id"])) {
179 $this->log->debug("export page");
180 $this->exportPageHTML($page["id"]);
181 $this->log->debug("collect page elements");
182 $this->co_page_html_export->collectPageElements("wpg:pg", $page["id"]);
183 }
184
185 if ($this->getMode() == self::MODE_USER) {
186 $cnt++;
187 $this->log->debug("update status: " . $cnt);
188 $this->user_html_exp->updateStatus((int) (50 / count($pages) * $cnt), ilWikiUserHTMLExport::RUNNING);
189 }
190 }
191 $this->co_page_html_export->exportPageElements($this->updateUserHTMLStatusForPageElements);
192 }
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.

References 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 210 of file class.ilWikiHTMLExport.php.

211 {
214 $ilTabs = $this->tabs;
215
216 $ilTabs->clearTargets();
217
218 $this->tpl = $this->co_page_html_export->getPreparedMainTemplate();
219
220 $this->tpl->getStandardTemplate();
221 $file = $this->export_dir . "/wpg_" . $a_page_id . ".html";
222 // return if file is already existing
223 if (@is_file($file)) {
224 $this->log->debug("file already exists");
225 return;
226 }
227
228 // page
229 $this->log->debug("init page gui");
230 include_once("./Modules/Wiki/classes/class.ilWikiPageGUI.php");
231 $wpg_gui = new ilWikiPageGUI($a_page_id);
232 $wpg_gui->setOutputMode("offline");
233 $page_content = $wpg_gui->showPage();
234
235 // export template: page content
236 $this->log->debug("init page gui");
237 $ep_tpl = new ilTemplate(
238 "tpl.export_page.html",
239 true,
240 true,
241 "Modules/Wiki"
242 );
243 $ep_tpl->setVariable("PAGE_CONTENT", $page_content);
244
245 // export template: right content
246 include_once("./Modules/Wiki/classes/class.ilWikiImportantPagesBlockGUI.php");
248 $ep_tpl->setVariable("RIGHT_CONTENT", $bl->getHTML(true));
249
250 // workaround
251 // $this->tpl->setVariable("MAINMENU", "<div style='min-height:40px;'></div>");
252 $this->tpl->setVariable("MAINMENU", "");
253
254 $this->log->debug("set title");
255 $this->tpl->setTitle($this->wiki->getTitle());
256 $this->tpl->setTitleIcon(
257 "./images/icon_wiki.svg",
258 $lng->txt("obj_wiki")
259 );
260
261 $this->tpl->setContent($ep_tpl->get());
262 //$this->tpl->fillMainContent();
263 $content = $this->tpl->get(
264 "DEFAULT",
265 false,
266 false,
267 false,
268 true,
269 true,
270 true
271 );
272
273 //echo htmlentities($content); exit;
274 // open file
275 $this->log->debug("write file: " . $file);
276 if (!($fp = @fopen($file, "w+"))) {
277 $this->log->error("Could not open " . $file . " for writing.");
278 include_once("./Modules/Wiki/exceptions/class.ilWikiExportException.php");
279 throw new ilWikiExportException("Could not open \"" . $file . "\" for writing.");
280 }
281
282 // set file permissions
283 $this->log->debug("set permissions");
284 chmod($file, 0770);
285
286 // write xml data into the file
287 fwrite($fp, $content);
288
289 // close file
290 fclose($fp);
291
292 if ($this->wiki->getStartPage() == $wpg_gui->getPageObject()->getTitle()) {
293 copy($file, $this->export_dir . "/index.html");
294 }
295 }
special template class to simplify handling of ITX/PEAR
Base exception class for wikis.
Class ilWikiPage GUI class.

References $ilUser, $lng, $tabs, and $user.

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 76 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 303 of file class.ilWikiHTMLExport.php.

304 {
305 include_once("./Services/Export/classes/class.ilExport.php");
306 $exp_dir =
307 ilExport::_getExportDirectory($this->wiki->getId(), $this->getMode(), "wiki");
308 $this->log->debug("dir: " . $exp_dir);
309 foreach (new DirectoryIterator($exp_dir) as $fileInfo) {
310 $this->log->debug("file: " . $fileInfo->getFilename());
311 if (pathinfo($fileInfo->getFilename(), PATHINFO_EXTENSION) == "zip") {
312 $this->log->debug("return: " . $exp_dir . "/" . $fileInfo->getFilename());
313 return $exp_dir . "/" . $fileInfo->getFilename();
314 }
315 }
316 return false;
317 }

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 66 of file class.ilWikiHTMLExport.php.

67 {
68 $this->mode = $a_val;
69 }

◆ updateUserHTMLStatusForPageElements()

ilWikiHTMLExport::updateUserHTMLStatusForPageElements (   $a_total,
  $a_cnt 
)

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

Parameters

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

200 {
201 if ($this->getMode() == self::MODE_USER) {
202 $this->user_html_exp->updateStatus((int) 50 + (50 / count($a_total) * $a_cnt), ilWikiUserHTMLExport::RUNNING);
203 }
204 }

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

◆ $db

ilWikiHTMLExport::$db
protected

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

Referenced by buildExportFile().

◆ $lng

ilWikiHTMLExport::$lng
protected

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

Referenced by exportPageHTML().

◆ $log

ilWikiHTMLExport::$log
protected

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

◆ $mode

ilWikiHTMLExport::$mode = self::MODE_DEFAULT
protected

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

Referenced by getMode().

◆ $tabs

ilWikiHTMLExport::$tabs
protected

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

Referenced by exportPageHTML().

◆ $user

ilWikiHTMLExport::$user
protected

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

Referenced by buildExportFile(), and exportPageHTML().

◆ $wiki

ilWikiHTMLExport::$wiki
protected

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

◆ MODE_DEFAULT

const ilWikiHTMLExport::MODE_DEFAULT = "html"

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

◆ MODE_USER

const ilWikiHTMLExport::MODE_USER = "user_html"

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