ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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
65 if ($this->getMode() == self::MODE_USER)
66 {
67 global $ilDB, $ilUser;
68 include_once("./Modules/Wiki/classes/class.ilWikiUserHTMLExport.php");
69 $this->user_html_exp = new ilWikiUserHTMLExport($this->wiki, $ilDB, $ilUser);
70 }
71
72 $ascii_name = str_replace(" ", "_", ilUtil::getASCIIFilename($this->wiki->getTitle()));
73
74 // create export file
75 include_once("./Services/Export/classes/class.ilExport.php");
76 ilExport::_createExportDirectory($this->wiki->getId(), $this->getMode(), "wiki");
77 $exp_dir =
78 ilExport::_getExportDirectory($this->wiki->getId(), $this->getMode(), "wiki");
79
80 if ($this->getMode() == self::MODE_USER)
81 {
82 ilUtil::delDir($exp_dir, true);
83 }
84
85 if ($this->getMode() == self::MODE_USER)
86 {
87 $this->subdir = $ascii_name;
88 }
89 else
90 {
91 $this->subdir = $this->wiki->getType()."_".$this->wiki->getId();
92 }
93 $this->export_dir = $exp_dir."/".$this->subdir;
94//echo "+".$this->export_dir."+";
95 // initialize temporary target directory
96 ilUtil::delDir($this->export_dir);
97 ilUtil::makeDir($this->export_dir);
98
99 $this->log->debug("export directory: ".$this->export_dir);
100
101 // system style html exporter
102 include_once("./Services/Style/classes/class.ilSystemStyleHTMLExport.php");
103 $this->sys_style_html_export = new ilSystemStyleHTMLExport($this->export_dir);
104 $this->sys_style_html_export->addImage("icon_wiki.svg");
105 $this->sys_style_html_export->export();
106
107 // init co page html exporter
108 include_once("./Services/COPage/classes/class.ilCOPageHTMLExport.php");
109 $this->co_page_html_export = new ilCOPageHTMLExport($this->export_dir);
110 $this->co_page_html_export->setContentStyleId(
111 $this->wiki->getStyleSheetId());
112 $this->co_page_html_export->createDirectories();
113 $this->co_page_html_export->exportStyles();
114 $this->co_page_html_export->exportSupportScripts();
115
116 // export pages
117 $this->log->debug("export pages");
118 $this->exportHTMLPages();
119
120 $date = time();
121 $zip_file_name = ($this->getMode() == self::MODE_USER)
122 ? $ascii_name.".zip"
123 : $date."__".IL_INST_ID."__".$this->wiki->getType()."_".$this->wiki->getId().".zip";
124
125 // zip everything
126 if (true)
127 {
128 // zip it all
129 $zip_file = ilExport::_getExportDirectory($this->wiki->getId(), $this->getMode(), "wiki").
130 "/".$zip_file_name;
131 $this->log->debug("zip: ".$zip_file);
132 ilUtil::zip($this->export_dir, $zip_file);
133 ilUtil::delDir($this->export_dir);
134 }
135 }
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.
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
global $ilUser
Definition: imgupload.php:15

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

+ Here is the call graph for this function:

◆ exportHTMLPages()

ilWikiHTMLExport::exportHTMLPages ( )

Export all pages.

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

141 {
142 global $tpl, $ilBench, $ilLocator;
143
144 $pages = ilWikiPage::getAllPages($this->wiki->getId());
145
146 include_once("./Services/COPage/classes/class.ilPageContentUsage.php");
147 include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
148 $cnt = 0;
149 foreach ($pages as $page)
150 {
151 $this->log->debug("page: ".$page["id"]);
152 if (ilWikiPage::_exists("wpg", $page["id"]))
153 {
154 $this->log->debug("export page");
155 $this->exportPageHTML($page["id"]);
156 $this->log->debug("collect page elements");
157 $this->co_page_html_export->collectPageElements("wpg:pg", $page["id"]);
158 }
159//sleep(2);
160 if ($this->getMode() == self::MODE_USER)
161 {
162 $cnt++;
163 $this->log->debug("update status: ".$cnt);
164 $this->user_html_exp->updateStatus((int) (50 / count($pages) * $cnt) ,ilWikiUserHTMLExport::RUNNING);
165 }
166
167 }
168 $this->co_page_html_export->exportPageElements($this->updateUserHTMLStatusForPageElements);
169 }
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 getAllPages($a_wiki_id)
Get all pages of wiki
global $ilBench
Definition: ilias.php:18

References $ilBench, $tpl, ilPageObject\_exists(), exportPageHTML(), ilWikiPage\getAllPages(), 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 188 of file class.ilWikiHTMLExport.php.

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

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

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

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

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

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: