ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilForumXMLWriter Class Reference

XML writer class. More...

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

Public Member Functions

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

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

ilForumXMLWriter::__construct ( )

constructor

Parameters
stringxml version
stringoutput encoding
stringinput encoding public

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

Member Function Documentation

ilForumXMLWriter::getXML ( )

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

References ilXmlWriter\xmlDumpMem().

{
// Replace ascii code 11 characters because of problems with xml sax parser
return str_replace('', '', $this->xmlDumpMem(false));
}

+ Here is the call graph for this function:

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.

{
$this->target_dir_relative = $a_rel;
$this->target_dir_absolute = $a_abs;
}
ilForumXMLWriter::setForumId (   $id)

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

{
$this->forum_id = $id;
}
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().

{
global $ilDB;
ilUtil::makeDir($this->target_dir_absolute."/objects");
$query_frm = 'SELECT * FROM frm_settings fs '.
'JOIN object_data od ON fs.obj_id = od.obj_id '.
'JOIN frm_data ON top_frm_fk = od.obj_id '.
'WHERE fs.obj_id = '.$ilDB->quote($this->forum_id, 'integer');
$res = $ilDB->query($query_frm);
while( $row = $res->fetchRow(DB_FETCHMODE_OBJECT) )
{
break;
}
$this->xmlStartTag("Forum", null);
$this->xmlElement("Id", null, (int)$row->top_pk);
$this->xmlElement("ObjId", null, (int)$row->obj_id);
$this->xmlElement("Title", null, $row->title);
$this->xmlElement("Description", null, $row->description);
$this->xmlElement("DefaultView", null, (int)$row->default_view);
$this->xmlElement("Pseudonyms", null, (int)$row->anonymized);
$this->xmlElement("Statistics", null, (int)$row->statistics_enabled);
$this->xmlElement("PostingActivation", null, (int)$row->post_activation);
$this->xmlElement("PresetSubject", null, (int)$row->preset_subject);
$this->xmlElement("PresetRe", null, (int)$row->add_re_subject);
$this->xmlElement("NotificationType", null, $row->notification_type);
$this->xmlElement("ForceNotification", null, (int)$row->admin_force_noti);
$this->xmlElement("ToggleNotification", null, (int)$row->user_toggle_noti);
$this->xmlElement("LastPost", null, $row->top_last_post);
$this->xmlElement("Moderator", null, (int)$row->top_mods);
$this->xmlElement("CreateDate", null, $row->top_date);
$this->xmlElement("UpdateDate", null, $row->top_update);
$this->xmlElement("UpdateUserId", null, $row->update_user);
$this->xmlElement("UserId", null, (int)$row->top_usr_id);
$query_thr = "SELECT frm_threads.* ".
" FROM frm_threads ".
" INNER JOIN frm_data ON top_pk = thr_top_fk ".
'WHERE top_frm_fk = '.$ilDB->quote($this->forum_id, 'integer');
$res = $ilDB->query($query_thr);
while( $row = $ilDB->fetchObject($res) )
{
$this->xmlStartTag("Thread");
$this->xmlElement("Id", null, (int)$row->thr_pk);
$this->xmlElement("Subject", null, $row->thr_subject);
$this->xmlElement("UserId", null, (int)$row->thr_usr_id);
$this->xmlElement("Alias", null, $row->thr_usr_alias);
$this->xmlElement("LastPost", null, $row->thr_last_post);
$this->xmlElement("CreateDate", null, $row->thr_date);
$this->xmlElement("UpdateDate", null, $row->thr_date);
$this->xmlElement("ImportName", null, $row->import_name);
$this->xmlElement("Sticky", null, (int)$row->is_sticky);
$this->xmlElement("Closed", null, (int)$row->is_closed);
$query = 'SELECT frm_posts.*, frm_posts_tree.*
FROM frm_posts
INNER JOIN frm_data
ON top_pk = pos_top_fk
INNER JOIN frm_posts_tree
ON pos_fk = pos_pk
WHERE pos_thr_fk = '.$ilDB->quote($row->thr_pk, 'integer').' ';
$query .= " ORDER BY frm_posts_tree.lft ASC";
$resPosts = $ilDB->query($query);
$lastDepth = null;
while( $rowPost = $ilDB->fetchObject($resPosts) )
{
/*
// Used for nested postings
if( $rowPost->depth < $lastDepth )
{
for( $i = $rowPost->depth; $i <= $lastDepth; $i++ )
{
$this->xmlEndTag("Post");
}
}*/
$this->xmlStartTag("Post");
$this->xmlElement("Id", null, (int)$rowPost->pos_pk);
$this->xmlElement("UserId", null, (int)$rowPost->pos_usr_id);
$this->xmlElement("Alias", null, $rowPost->pos_usr_alias);
$this->xmlElement("Subject", null, $rowPost->pos_subject);
$this->xmlElement("CreateDate", null, $rowPost->pos_date);
$this->xmlElement("UpdateDate", null, $rowPost->pos_update);
$this->xmlElement("UpdateUserId", null, (int)$rowPost->update_user);
$this->xmlElement("Censorship", null, (int)$rowPost->pos_cens);
$this->xmlElement("CensorshipMessage", null, $rowPost->pos_cens_com);
$this->xmlElement("Notification", null, $rowPost->notify);
$this->xmlElement("ImportName", null, $rowPost->import_name);
$this->xmlElement("Status", null, (int)$rowPost->pos_status);
$this->xmlElement("Message", null, ilRTE::_replaceMediaObjectImageSrc($rowPost->pos_message, 0));
$media_exists = false;
$mobs = ilObjMediaObject::_getMobsOfObject('frm:html', $rowPost->pos_pk);
foreach($mobs as $mob)
{
$moblabel = "il_" . IL_INST_ID . "_mob_" . $mob;
{
if(!$media_exists)
{
$this->xmlStartTag("MessageMediaObjects");
$media_exists = true;
}
$mob_obj = new ilObjMediaObject($mob);
$imgattrs = array(
"label" => $moblabel,
"uri" => $this->target_dir_relative . "/objects/" . "il_" . IL_INST_ID . "_mob_" . $mob . "/" . $mob_obj->getTitle()
);
$this->xmlElement("MediaObject", $imgattrs, NULL);
$mob_obj->exportFiles($this->target_dir_absolute);
}
}
if($media_exists)
{
$this->xmlEndTag("MessageMediaObjects");
}
$this->xmlElement("Lft", null, (int)$rowPost->lft);
$this->xmlElement("Rgt", null, (int)$rowPost->rgt);
$this->xmlElement("Depth", null, (int)$rowPost->depth);
$this->xmlElement("ParentId", null, (int)$rowPost->parent_pos);
$tmp_file_obj = new ilFileDataForum(
$this->forum_id, $rowPost->pos_pk
);
$set = array();
if ( count($tmp_file_obj->getFilesOfPost()) )
{
foreach ($tmp_file_obj->getFilesOfPost() as $file)
{
$this->xmlStartTag("Attachment");
copy($file['path'], $this->target_dir_absolute."/".basename($file['path']));
$content = $this->target_dir_relative."/".basename($file['path']);
$this->xmlElement("Content", null, $content);
$this->xmlEndTag("Attachment");
}
}
//Used for nested postings
//$lastDepth = $rowPost->depth;
$this->xmlEndTag("Post");
}
/*
// Used for nested postings
if( $lastDepth )
{
for( $i = 1; $i <= $lastDepth ; $i++ )
{
$this->xmlEndTag("Post");
}
$lastDepth = null;
}*/
$this->xmlEndTag("Thread");
}
$this->xmlEndTag("Forum");
return true;
}

+ Here is the call graph for this function:

Field Documentation

ilForumXMLWriter::$forum_id = null

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


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