ILIAS  release_4-4 Revision
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
 ilXmlWriter ($version="1.0", $outEnc="utf-8", $inEnc="utf-8")
 constructor More...
 
 _ilXmlWriter ()
 destructor public More...
 
 xmlSetDtdDef ($dtdDef)
 Sets dtd definition. More...
 
 xmlSetStSheet ($stSheet)
 Sets stylesheet. More...
 
 xmlSetGenCmt ($genCmt)
 Sets generated comment. More...
 
 _xmlEscapeData ($data)
 Escapes reserved characters. 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 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 public More...
 

Data Fields

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

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 24 of file class.ilForumXMLWriter.php.

Constructor & Destructor Documentation

◆ __construct()

ilForumXMLWriter::__construct ( )

constructor

Parameters
stringxml version
stringoutput encoding
stringinput encoding public

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

36  {
37  parent::__construct();
38  }

Member Function Documentation

◆ getXML()

ilForumXMLWriter::getXML ( )

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

References ilXmlWriter\xmlDumpMem().

235  {
236  // Replace ascii code 11 characters because of problems with xml sax parser
237  return str_replace('', '', $this->xmlDumpMem(false));
238  }
xmlDumpMem($format=TRUE)
Returns xml document from memory.
+ 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 53 of file class.ilForumXMLWriter.php.

54  {
55  $this->target_dir_relative = $a_rel;
56  $this->target_dir_absolute = $a_abs;
57  }

◆ setForumId()

ilForumXMLWriter::setForumId (   $id)

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

42  {
43  $this->forum_id = $id;
44  }

◆ start()

ilForumXMLWriter::start ( )

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

References $file, $mobs, $query, $res, $row, ilObjMediaObject\_exists(), ilObjMediaObject\_getMobsOfObject(), ilRTE\_replaceMediaObjectImageSrc(), DB_FETCHMODE_OBJECT, ilUtil\makeDir(), ilXmlWriter\xmlElement(), ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

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

Field Documentation

◆ $forum_id

ilForumXMLWriter::$forum_id = null

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


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