/** * export media objects to xml (see ilias_co.dtd) * * @param object $a_xml_writer ilXmlWriter object that receives the * xml data */ function exportXMLMediaObjects(&$a_xml_writer, $a_inst, $a_target_dir, &$expLog) { include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php"; foreach ($this->mob_ids as $mob_id) { $expLog->write(date("[y-m-d H:i:s] ") . "Media Object " . $mob_id); if (ilObjMediaObject::_exists($mob_id)) { $media_obj = new ilObjMediaObject($mob_id); $media_obj->exportXML($a_xml_writer, $a_inst); $media_obj->exportFiles($a_target_dir); unset($media_obj); } } }
/** * export media objects to xml (see ilias_co.dtd) * * @param object $a_xml_writer ilXmlWriter object that receives the * xml data */ function exportXMLMediaObjects(&$a_xml_writer, $a_inst, $a_target_dir, &$expLog) { include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php"; $linked_mobs = array(); // mobs directly embedded into pages foreach ($this->mob_ids as $mob_id) { if ($mob_id > 0 && ilObject::_lookupType($mob_id) == "mob") { $expLog->write(date("[y-m-d H:i:s] ") . "Media Object " . $mob_id); $media_obj = new ilObjMediaObject($mob_id); $media_obj->exportXML($a_xml_writer, $a_inst); $media_obj->exportFiles($a_target_dir); $lmobs = $media_obj->getLinkedMediaObjects($this->mob_ids); $linked_mobs = array_merge($linked_mobs, $lmobs); unset($media_obj); } } // linked mobs (in map areas) foreach ($linked_mobs as $mob_id) { if ($mob_id > 0) { $expLog->write(date("[y-m-d H:i:s] ") . "Media Object " . $mob_id); $media_obj = new ilObjMediaObject($mob_id); $media_obj->exportXML($a_xml_writer, $a_inst); $media_obj->exportFiles($a_target_dir); unset($media_obj); } } }
/** * export files of file itmes * */ function exportFileItems($a_target_dir, &$expLog) { include_once "./Modules/File/classes/class.ilObjFile.php"; if (is_array($this->file_ids)) { foreach ($this->file_ids as $file_id) { $expLog->write(date("[y-m-d H:i:s] ") . "File Item " . $file_id); if (ilObject::_lookupType($file_id) == "file") { $file_obj = new ilObjFile($file_id, false); $file_obj->export($a_target_dir); unset($file_obj); } else { $expLog->write(date("[y-m-d H:i:s] ") . "File Item not found, ID: " . $file_id); } } } include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php"; $linked_mobs = array(); if (is_array($this->mob_ids)) { // mobs directly embedded into pages foreach ($this->mob_ids as $mob_id) { if ($mob_id > 0 && ilObject::_exists($mob_id)) { $expLog->write(date("[y-m-d H:i:s] ") . "Media Object " . $mob_id); $media_obj = new ilObjMediaObject($mob_id); $media_obj->exportFiles($a_target_dir, $expLog); $lmobs = $media_obj->getLinkedMediaObjects($this->mob_ids); $linked_mobs = array_merge($linked_mobs, $lmobs); unset($media_obj); } } // linked mobs (in map areas) foreach ($linked_mobs as $mob_id) { if ($mob_id > 0 && ilObject::_exists($mob_id)) { $expLog->write(date("[y-m-d H:i:s] ") . "Media Object " . $mob_id); $media_obj = new ilObjMediaObject($mob_id); $media_obj->exportFiles($a_target_dir); unset($media_obj); } } } //media files in questions foreach ($this->q_media as $media) { if ($media != "") { error_log($media); copy($media, $a_target_dir . "/objects/" . basename($media)); } } }
function start() { 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 (ilObjMediaObject::_exists($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; }