ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
ilForumXMLWriter Class Reference

XML writer class. More...

+ Inheritance diagram for ilForumXMLWriter:
+ Collaboration diagram for ilForumXMLWriter:

Public Member Functions

 __construct ()
 constructor More...
 
 setForumId ($id)
 
 setFileTargetDirectories ($a_rel, $a_abs)
 Set file target directories. More...
 
 start ()
 
 getXML ()
 
- Public Member Functions inherited from ilXmlWriter
 __construct ($version="1.0", $outEnc="utf-8", $inEnc="utf-8")
 constructor More...
 
 _ilXmlWriter ()
 destructor @access public More...
 
 xmlSetDtdDef ($dtdDef)
 Sets dtd definition. More...
 
 xmlSetStSheet ($stSheet)
 Sets stylesheet. More...
 
 xmlSetGenCmt ($genCmt)
 Sets generated comment. More...
 
 xmlEncodeData ($data)
 Encodes text from input encoding into output encoding. More...
 
 xmlFormatData ($data)
 Indents text for better reading. More...
 
 xmlFormatElement ($array)
 Callback function for xmlFormatData; do not invoke directly. More...
 
 xmlHeader ()
 Writes xml header @access public. More...
 
 xmlStartTag ($tag, $attrs=null, $empty=false, $encode=true, $escape=true)
 Writes a starttag. More...
 
 xmlEndTag ($tag)
 Writes an endtag. More...
 
 xmlComment ($comment)
 Writes a comment. More...
 
 xmlData ($data, $encode=true, $escape=true)
 Writes data. More...
 
 xmlElement ($tag, $attrs=null, $data=null, $encode=true, $escape=true)
 Writes a basic element (no children, just textual content) More...
 
 xmlDumpFile ($file, $format=true)
 Dumps xml document from memory into a file. More...
 
 xmlDumpMem ($format=true)
 Returns xml document from memory. More...
 
 appendXML ($a_str)
 append xml string to document More...
 
 xmlClear ()
 clears xmlStr @access public More...
 

Data Fields

 $forum_id = null
 
- Data Fields inherited from ilXmlWriter
 $xmlStr
 
 $version
 
 $outEnc
 
 $inEnc
 
 $dtdDef = ""
 
 $stSheet = ""
 
 $genCmt = "Generated by ILIAS XmlWriter"
 

Additional Inherited Members

- Static Public Member Functions inherited from ilXmlWriter
static _xmlEscapeData ($data)
 Escapes reserved characters. More...
 

Detailed Description

XML writer class.

Class to simplify manual writing of xml documents. It only supports writing xml sequentially, because the xml document is saved in a string with no additional structure information. The author is responsible for well-formedness and validity of the xml document.

Author
Andreas Kordosz (akord.nosp@m.osz@.nosp@m.datab.nosp@m.ay.d.nosp@m.e)
Version
Id
class.ilExerciseXMLWriter.php,v 1.3 2005/11/04 12:50:24 smeyer Exp

Definition at line 19 of file class.ilForumXMLWriter.php.

Constructor & Destructor Documentation

◆ __construct()

ilForumXMLWriter::__construct ( )

constructor

Parameters
stringxml version
stringoutput encoding
stringinput encoding @access public

Definition at line 30 of file class.ilForumXMLWriter.php.

31 {
33 }
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

References ILIAS\GlobalScreen\Provider\__construct().

+ Here is the call graph for this function:

Member Function Documentation

◆ getXML()

ilForumXMLWriter::getXML ( )

Definition at line 241 of file class.ilForumXMLWriter.php.

242 {
243 // Replace ascii code 11 characters because of problems with xml sax parser
244 return str_replace('', '', $this->xmlDumpMem(false));
245 }
xmlDumpMem($format=true)
Returns xml document from memory.

References ilXmlWriter\xmlDumpMem().

+ Here is the call graph for this function:

◆ setFileTargetDirectories()

ilForumXMLWriter::setFileTargetDirectories (   $a_rel,
  $a_abs 
)

Set file target directories.

Parameters
stringrelative file target directory
stringabsolute file target directory

Definition at line 48 of file class.ilForumXMLWriter.php.

49 {
50 $this->target_dir_relative = $a_rel;
51 $this->target_dir_absolute = $a_abs;
52 }

◆ setForumId()

ilForumXMLWriter::setForumId (   $id)

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

37 {
38 $this->forum_id = $id;
39 }

◆ start()

ilForumXMLWriter::start ( )

Definition at line 54 of file class.ilForumXMLWriter.php.

55 {
56 global $DIC;
57 $ilDB = $DIC->database();
58
59 ilUtil::makeDir($this->target_dir_absolute . "/objects");
60
61 $query_frm = '
62 SELECT *
63 FROM object_data od
64 INNER JOIN frm_data
65 ON top_frm_fk = od.obj_id
66 LEFT JOIN frm_settings fs
67 ON fs.obj_id = od.obj_id
68 WHERE od.obj_id = ' . $ilDB->quote($this->forum_id, 'integer');
69
70 $res = $ilDB->query($query_frm);
71
72 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
73 break;
74 }
75
76 $this->xmlStartTag("Forum", null);
77
78 $this->xmlElement("Id", null, (int) $row->top_pk);
79 $this->xmlElement("ObjId", null, (int) $row->obj_id);
80 $this->xmlElement("Title", null, $row->title);
81 $this->xmlElement("Description", null, $row->description);
82 $this->xmlElement("DefaultView", null, (int) $row->default_view);
83 $this->xmlElement("Pseudonyms", null, (int) $row->anonymized);
84 $this->xmlElement("Statistics", null, (int) $row->statistics_enabled);
85 $this->xmlElement("ThreadRatings", null, (int) $row->thread_rating);
86 $this->xmlElement("Sorting", null, (int) $row->thread_sorting);
87 $this->xmlElement("MarkModeratorPosts", null, (int) $row->mark_mod_posts);
88 $this->xmlElement("PostingActivation", null, (int) $row->post_activation);
89 $this->xmlElement("PresetSubject", null, (int) $row->preset_subject);
90 $this->xmlElement("PresetRe", null, (int) $row->add_re_subject);
91 $this->xmlElement("NotificationType", null, $row->notification_type);
92 $this->xmlElement("ForceNotification", null, (int) $row->admin_force_noti);
93 $this->xmlElement("ToggleNotification", null, (int) $row->user_toggle_noti);
94 $this->xmlElement("LastPost", null, $row->top_last_post);
95 $this->xmlElement("Moderator", null, (int) $row->top_mods);
96 $this->xmlElement("CreateDate", null, $row->top_date);
97 $this->xmlElement("UpdateDate", null, $row->top_update);
98 $this->xmlElement("FileUpload", null, (int) $row->file_upload_allowed);
99 $this->xmlElement("UpdateUserId", null, $row->update_user);
100 $this->xmlElement("UserId", null, (int) $row->top_usr_id);
101 $this->xmlElement("AuthorId", null, (int) $row->thr_author_id);
102
103 $query_thr = "SELECT frm_threads.* " .
104 " FROM frm_threads " .
105 " INNER JOIN frm_data ON top_pk = thr_top_fk " .
106 'WHERE top_frm_fk = ' . $ilDB->quote($this->forum_id, 'integer');
107
108 $res = $ilDB->query($query_thr);
109
110 while ($row = $ilDB->fetchObject($res)) {
111 $this->xmlStartTag("Thread");
112
113 $this->xmlElement("Id", null, (int) $row->thr_pk);
114 $this->xmlElement("Subject", null, $row->thr_subject);
115 $this->xmlElement("UserId", null, (int) $row->thr_display_user_id);
116 $this->xmlElement("AuthorId", null, (int) $row->thr_author_id);
117 $this->xmlElement("Alias", null, $row->thr_usr_alias);
118 $this->xmlElement("LastPost", null, $row->thr_last_post);
119 $this->xmlElement("CreateDate", null, $row->thr_date);
120 $this->xmlElement("UpdateDate", null, $row->thr_date);
121 $this->xmlElement("ImportName", null, $row->import_name);
122 $this->xmlElement("Sticky", null, (int) $row->is_sticky);
123 $this->xmlElement("Closed", null, (int) $row->is_closed);
124
125 $query = 'SELECT frm_posts.*, frm_posts_tree.*
126 FROM frm_posts
127 INNER JOIN frm_data
128 ON top_pk = pos_top_fk
129 INNER JOIN frm_posts_tree
130 ON pos_fk = pos_pk
131 WHERE pos_thr_fk = ' . $ilDB->quote($row->thr_pk, 'integer') . ' ';
132 $query .= " ORDER BY frm_posts_tree.lft ASC";
133 $resPosts = $ilDB->query($query);
134
135 $lastDepth = null;
136 while ($rowPost = $ilDB->fetchObject($resPosts)) {
137 /*
138 // Used for nested postings
139 if( $rowPost->depth < $lastDepth )
140 {
141 for( $i = $rowPost->depth; $i <= $lastDepth; $i++ )
142 {
143 $this->xmlEndTag("Post");
144 }
145 }*/
146
147 $this->xmlStartTag("Post");
148 $this->xmlElement("Id", null, (int) $rowPost->pos_pk);
149 $this->xmlElement("UserId", null, (int) $rowPost->pos_display_user_id);
150 $this->xmlElement("AuthorId", null, (int) $rowPost->pos_author_id);
151 $this->xmlElement("Alias", null, $rowPost->pos_usr_alias);
152 $this->xmlElement("Subject", null, $rowPost->pos_subject);
153 $this->xmlElement("CreateDate", null, $rowPost->pos_date);
154 $this->xmlElement("UpdateDate", null, $rowPost->pos_update);
155 $this->xmlElement("UpdateUserId", null, (int) $rowPost->update_user);
156 $this->xmlElement("Censorship", null, (int) $rowPost->pos_cens);
157 $this->xmlElement("CensorshipMessage", null, $rowPost->pos_cens_com);
158 $this->xmlElement("Notification", null, $rowPost->notify);
159 $this->xmlElement("ImportName", null, $rowPost->import_name);
160 $this->xmlElement("Status", null, (int) $rowPost->pos_status);
161 $this->xmlElement("Message", null, ilRTE::_replaceMediaObjectImageSrc($rowPost->pos_message, 0));
162
163 if ($rowPost->is_author_moderator === null) {
164 $is_moderator_string = 'NULL';
165 } else {
166 $is_moderator_string = (string) $rowPost->is_author_moderator;
167 }
168
169 $this->xmlElement("isAuthorModerator", null, $is_moderator_string);
170
171 $media_exists = false;
172 $mobs = ilObjMediaObject::_getMobsOfObject('frm:html', $rowPost->pos_pk);
173 foreach ($mobs as $mob) {
174 $moblabel = "il_" . IL_INST_ID . "_mob_" . $mob;
175 if (ilObjMediaObject::_exists($mob)) {
176 if (!$media_exists) {
177 $this->xmlStartTag("MessageMediaObjects");
178 $media_exists = true;
179 }
180
181 $mob_obj = new ilObjMediaObject($mob);
182 $imgattrs = array(
183 "label" => $moblabel,
184 "uri" => $this->target_dir_relative . "/objects/" . "il_" . IL_INST_ID . "_mob_" . $mob . "/" . $mob_obj->getTitle()
185 );
186
187 $this->xmlElement("MediaObject", $imgattrs, null);
188 $mob_obj->exportFiles($this->target_dir_absolute);
189 }
190 }
191 if ($media_exists) {
192 $this->xmlEndTag("MessageMediaObjects");
193 }
194
195 $this->xmlElement("Lft", null, (int) $rowPost->lft);
196 $this->xmlElement("Rgt", null, (int) $rowPost->rgt);
197 $this->xmlElement("Depth", null, (int) $rowPost->depth);
198 $this->xmlElement("ParentId", null, (int) $rowPost->parent_pos);
199
200 $tmp_file_obj = new ilFileDataForum(
201 $this->forum_id,
202 $rowPost->pos_pk
203 );
204
205 $set = array();
206 if (count($tmp_file_obj->getFilesOfPost())) {
207 foreach ($tmp_file_obj->getFilesOfPost() as $file) {
208 $this->xmlStartTag("Attachment");
209
210 copy($file['path'], $this->target_dir_absolute . "/" . basename($file['path']));
211 $content = $this->target_dir_relative . "/" . basename($file['path']);
212 $this->xmlElement("Content", null, $content);
213
214 $this->xmlEndTag("Attachment");
215 }
216 }
217
218 //Used for nested postings
219 //$lastDepth = $rowPost->depth;
220
221 $this->xmlEndTag("Post");
222 }
223 /*
224 // Used for nested postings
225 if( $lastDepth )
226 {
227 for( $i = 1; $i <= $lastDepth ; $i++ )
228 {
229 $this->xmlEndTag("Post");
230 }
231
232 $lastDepth = null;
233 }*/
234 $this->xmlEndTag("Thread");
235 }
236 $this->xmlEndTag("Forum");
237
238 return true;
239 }
This class handles all operations on files for the forum object.
Class ilObjMediaObject.
static _getMobsOfObject($a_type, $a_id, $a_usage_hist_nr=0, $a_lang="-")
get mobs of object
static _exists($a_id, $a_reference=false, $a_type=null)
checks wether a lm content object with specified id exists or not
static _replaceMediaObjectImageSrc($a_text, $a_direction=0, $nic=IL_INST_ID)
Replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
xmlEndTag($tag)
Writes an endtag.
xmlElement($tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
xmlStartTag($tag, $attrs=null, $empty=false, $encode=true, $escape=true)
Writes a starttag.
$query
foreach($_POST as $key=> $value) $res
global $ilDB
$mobs
$DIC
Definition: xapitoken.php:46

References $DIC, $ilDB, $mobs, $query, $res, ilObjMediaObject\_exists(), ilObjMediaObject\_getMobsOfObject(), ilRTE\_replaceMediaObjectImageSrc(), ilDBConstants\FETCHMODE_OBJECT, ilUtil\makeDir(), ilXmlWriter\xmlElement(), ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

+ Here is the call graph for this function:

Field Documentation

◆ $forum_id

ilForumXMLWriter::$forum_id = null

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


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