24include_once(
'Modules/Course/classes/class.ilFSStorageCourse.php');
 
   71        $this->ARCHIVE_XML = 1;
 
   72        $this->ARCHIVE_HTML = 2;
 
   73        $this->ARCHIVE_PDF = 3;
 
   83        return $this->archives;
 
   88        return $this->archives[$a_id];
 
   93        foreach ($this->archives as 
$id => $archive) {
 
   94            if ($archive[
'archive_type'] == $this->ARCHIVE_XML) {
 
   97            if ($this->course_obj->getArchiveType() != $this->course_obj->ARCHIVE_DOWNLOAD and
 
   98                $archive[
'archive_type'] == $this->ARCHIVE_PDF) {
 
  101            $public_archives[
$id] = $archive;
 
  104        return $public_archives ? $public_archives : array();
 
  113        return $this->archive_type ? $this->archive_type : $this->ARCHIVE_XML;
 
  118        $this->archive_date = $a_date;
 
  122        return $this->archive_date ? $this->archive_date : time();
 
  127        $this->archive_size = $a_size;
 
  135        $this->archive_name = $a_name;
 
  143        $this->archive_lang = $a_lang_code;
 
  157            return $this->course_files_obj->getArchiveDirectory() . 
'/' . $archive[
'archive_name'] . 
'.zip';
 
  159            return $this->course_files_obj->getArchiveDirectory() . 
'/' . $archive[
'archive_name'];
 
  168    public function addXML($a_selection = 
"")
 
  170        $this->
setType($this->ARCHIVE_XML);
 
  171        $this->
setName(time() . 
'__' . $this->
ilias->getSetting(
'inst_id') . 
'__crs_' . $this->course_obj->getId());
 
  176        $this->course_files_obj->addArchiveSubDirectory($this->
getName());
 
  181        $this->course_xml_writer->start();
 
  182        $this->course_files_obj->writeArchiveFile($this->course_xml_writer->getXML(), $this->getName() . 
'/' . $this->getName() . 
'.xml');
 
  187        $this->course_files_obj->addArchiveSubDirectory($this->
getName() . 
'/objects');
 
  189        $this->copied_files = array();
 
  190        $this->
__addZipFiles($this->course_obj->getRefId(), $a_selection);
 
  193        include_once(
"./Services/Export/classes/class.ilExport.php");
 
  195            $this->getName() . 
'/index.html', $this->course_obj->getId(), $this->copied_files);
 
  198        $this->
setSize($this->course_files_obj->zipArchive($this->getName(), $this->getName() . 
'.zip'));
 
  209        $this->
setType($this->ARCHIVE_HTML);
 
  211        $this->
setName($this->
getDate() . 
'__' . $this->
ilias->getSetting(
'inst_id') . 
'__crs_' . $this->course_obj->getId());
 
  215        $this->course_files_obj->addArchiveSubDirectory($this->
getName());
 
  218        $this->course_files_obj->addArchiveSubDirectory($this->
getName() . 
'/objects');
 
  225        $this->course_files_obj->createArchiveOnlineVersion($this->
getName());
 
  228        $this->
setSize($this->course_files_obj->zipArchive($this->getName(), $this->getName() . 
'.zip'));
 
  241        $next_id = 
$ilDB->nextId(
'crs_archives');
 
  242        $query = 
"INSERT INTO crs_archives (archive_id,course_id,archive_name,archive_type,archive_date,archive_size,archive_lang) " .
 
  244            $ilDB->quote($next_id, 
'integer') . 
", " .
 
  245            $ilDB->quote($this->course_obj->getId(), 
'integer') . 
"," .
 
  247            $ilDB->quote($this->
getType(), 
'integer') . 
", " .
 
  248            $ilDB->quote($this->
getDate(), 
'integer') . 
"," .
 
  249            $ilDB->quote($this->
getSize(), 
'integer') . 
"," .
 
  258    public function delete($a_id)
 
  265        $this->course_files_obj->deleteArchive($this->archives[$a_id][
"archive_name"]);
 
  267        $query = 
"DELETE FROM crs_archives " .
 
  268            "WHERE course_id = " . 
$ilDB->quote($this->course_obj->getId(), 
'integer') . 
" " .
 
  269            "AND archive_id = " . 
$ilDB->quote($a_id, 
'integer') . 
" ";
 
  285        if (!is_object($this->course_files_obj)) {
 
  286            include_once(
'Modules/Course/classes/class.ilFSStorageCourse.php');
 
  294        if (!is_object($this->course_xml_writer)) {
 
  295            include_once 
"./Modules/Course/classes/class.ilCourseXMLWriter.php";
 
  310        $this->course_obj->initCourseItemObject();
 
  311        $this->course_obj->items_obj->setParentId($a_parent_id);
 
  313        foreach ($this->course_obj->items_obj->getAllItems() as $item) {
 
  317            $action = $a_selection[$item[
'child']];
 
  318            if ($a_selection == 
"") {
 
  327                $abs_file_name = $tmp_obj->getXMLZip();
 
  329                include_once(
"./Services/Export/classes/class.ilExport.php");
 
  332                if (!@is_file($abs_file_name)) {
 
  338            if ($abs_file_name != 
"") {
 
  340                $new_name = basename($abs_file_name);
 
  341                $this->course_files_obj->copyFile($abs_file_name, $this->course_files_obj->getArchiveDirectory() . 
'/' .
 
  342                                                                $this->getName() . 
'/' . $new_name);
 
  343                if (is_file($this->course_files_obj->getArchiveDirectory() . 
'/' .
 
  344                    $this->getName() . 
'/' . $new_name)) {
 
  345                    $this->copied_files[] = array(
"title" => $item[
'title'],
 
  346                        "file" => $new_name, 
"type" => $item[
'type']);
 
  358        $this->course_obj->initCourseItemObject();
 
  359        $this->course_obj->items_obj->setParentId($a_parent_id);
 
  361        foreach ($this->course_obj->items_obj->getAllItems() as $item) {
 
  365            if ($abs_dir_name = $tmp_obj->getHTMLDirectory()) {
 
  366                $new_name = 
'il_' . $this->
ilias->getSetting(
'inst_id') . 
'_' . $tmp_obj->getType() . 
'_' . $item[
'obj_id'];
 
  368                $this->course_files_obj->addDirectory($this->
getName() . 
'/objects/' . $new_name);
 
  369                $this->course_files_obj->rCopy($abs_dir_name, $this->
getName() . 
'/objects/' . $new_name);
 
  372                $this->html_files[
"$item[obj_id]"] = 
"objects/" . $new_name . 
"/index.html";
 
  387            $lng->loadLanguageModule(
'crs');
 
  392        $tmp_tpl = 
new ilTemplate(
"tpl.crs_export.html", 
true, 
true, 
'Modules/Course');
 
  394        $this->course_files_obj->copyFile(
 
  395            $tpl->tplPath . 
'/' . 
$ilias->account->prefs[
"style"] . 
'.css',
 
  396            $this->course_files_obj->getArchiveDirectory() . 
'/' . $this->getName() . 
'/default.css' 
  399        $tmp_tpl->setVariable(
'TITLE', 
$lng->txt(
'crs_export'));
 
  400        $tmp_tpl->setVariable(
"CRS_STRUCTURE", 
$lng->txt(
'crs_structure'));
 
  403        $tmp_tpl->setVariable(
"DETAILS_TITLE", 
$lng->txt(
"crs_details"));
 
  406        $tmp_tpl->setVariable(
"TXT_SYLLABUS", 
$lng->txt(
"crs_syllabus"));
 
  407        $tmp_tpl->setVariable(
"TXT_CONTACT", 
$lng->txt(
"crs_contact"));
 
  408        $tmp_tpl->setVariable(
"TXT_CONTACT_NAME", 
$lng->txt(
"crs_contact_name"));
 
  409        $tmp_tpl->setVariable(
"TXT_CONTACT_RESPONSIBILITY", 
$lng->txt(
"crs_contact_responsibility"));
 
  410        $tmp_tpl->setVariable(
"TXT_CONTACT_EMAIL", 
$lng->txt(
"crs_contact_email"));
 
  411        $tmp_tpl->setVariable(
"TXT_CONTACT_PHONE", 
$lng->txt(
"crs_contact_phone"));
 
  412        $tmp_tpl->setVariable(
"TXT_CONTACT_CONSULTATION", 
$lng->txt(
"crs_contact_consultation"));
 
  413        $tmp_tpl->setVariable(
"TXT_DATES", 
$lng->txt(
"crs_dates"));
 
  414        $tmp_tpl->setVariable(
"TXT_ACTIVATION", 
$lng->txt(
"crs_activation"));
 
  415        $tmp_tpl->setVariable(
"TXT_SUBSCRIPTION", 
$lng->txt(
"crs_subscription"));
 
  416        $tmp_tpl->setVariable(
"TXT_ARCHIVE", 
$lng->txt(
"crs_archive"));
 
  419        $tmp_tpl->setVariable(
"SYLLABUS", nl2br($this->course_obj->getSyllabus() ?
 
  420                                                 $this->course_obj->getSyllabus() :
 
  421                                                 $lng->txt(
"crs_not_available")));
 
  423        $tmp_tpl->setVariable(
"CONTACT_NAME", $this->course_obj->getContactName() ?
 
  424                                $this->course_obj->getContactName() :
 
  425                                $lng->txt(
"crs_not_available"));
 
  426        $tmp_tpl->setVariable(
"CONTACT_RESPONSIBILITY", $this->course_obj->getContactResponsibility() ?
 
  427                                $this->course_obj->getContactResponsibility() :
 
  428                                $lng->txt(
"crs_not_available"));
 
  429        $tmp_tpl->setVariable(
"CONTACT_PHONE", $this->course_obj->getContactPhone() ?
 
  430                                $this->course_obj->getContactPhone() :
 
  431                                $lng->txt(
"crs_not_available"));
 
  432        $tmp_tpl->setVariable(
"CONTACT_CONSULTATION", nl2br($this->course_obj->getContactConsultation() ?
 
  433                                $this->course_obj->getContactConsultation() :
 
  434                                $lng->txt(
"crs_not_available")));
 
  435        if ($this->course_obj->getContactEmail()) {
 
  436            $tmp_tpl->setCurrentBlock(
"email_link");
 
  437            #$tmp_tpl->setVariable("EMAIL_LINK","ilias.php?baseClass=ilMailGUI&type=new&rcp_to=".$this->course_obj->getContactEmail());
 
  438            $tmp_tpl->setVariable(
"CONTACT_EMAIL", $this->course_obj->getContactEmail());
 
  439            $tmp_tpl->parseCurrentBlock();
 
  441            $tmp_tpl->setCurrentBlock(
"no_mail");
 
  442            $tmp_tpl->setVariable(
"NO_CONTACT_EMAIL", $this->course_obj->getContactEmail());
 
  443            $tmp_tpl->parseCurrentBlock();
 
  445        if ($this->course_obj->getActivationUnlimitedStatus()) {
 
  446            $tmp_tpl->setVariable(
"ACTIVATION", 
$lng->txt(
'crs_unlimited'));
 
  448            $str = 
$lng->txt(
"crs_from") . 
" " . strftime(
"%Y-%m-%d %R", $this->course_obj->getActivationStart()) . 
" " .
 
  449                $lng->txt(
"crs_to") . 
" " . strftime(
"%Y-%m-%d %R", $this->course_obj->getActivationEnd());
 
  450            $tmp_tpl->setVariable(
"ACTIVATION", $str);
 
  452        if ($this->course_obj->getSubscriptionUnlimitedStatus()) {
 
  453            $tmp_tpl->setVariable(
"SUBSCRIPTION", 
$lng->txt(
'crs_unlimited'));
 
  455            $str = 
$lng->txt(
"crs_from") . 
" " . strftime(
"%Y-%m-%d %R", $this->course_obj->getSubscriptionStart()) . 
" " .
 
  456                $lng->txt(
"crs_to") . 
" " . strftime(
"%Y-%m-%d %R", $this->course_obj->getSubscriptionEnd());
 
  457            $tmp_tpl->setVariable(
"SUBSCRIPTION", $str);
 
  459        if ($this->course_obj->getArchiveType() == $this->course_obj->ARCHIVE_DISABLED) {
 
  460            $tmp_tpl->setVariable(
"ARCHIVE", 
$lng->txt(
'crs_archive_disabled'));
 
  462            $str = 
$lng->txt(
"crs_from") . 
" " . strftime(
"%Y-%m-%d %R", $this->course_obj->getArchiveStart()) . 
" " .
 
  463                $lng->txt(
"crs_to") . 
" " . strftime(
"%Y-%m-%d %R", $this->course_obj->getArchiveEnd());
 
  464            $tmp_tpl->setVariable(
"ARCHIVE", $str);
 
  467        $this->structure = 
'';
 
  469        $tmp_tpl->setVariable(
"STRUCTURE", $this->structure);
 
  471        $this->course_files_obj->writeArchiveFile($tmp_tpl->get(), $this->getName() . 
'/index.html');
 
  478        $this->course_obj->initCourseItemObject();
 
  479        $this->course_obj->items_obj->setParentId($a_parent_id);
 
  481        $items = $this->course_obj->items_obj->getAllItems();
 
  483        foreach ($items as 
$key => $item) {
 
  490                $this->structure .= 
"<ul>";
 
  493            $this->structure .= 
"<li>";
 
  495            if (isset($this->html_files[
"$item[obj_id]"])) {
 
  496                $link = 
"<a href=\"./" . $this->html_files[
"$item[obj_id]"] . 
"\">" . $item[
"title"] . 
"</a>";
 
  498                $link = $item[
'title'];
 
  500            $this->structure .= $link;
 
  501            $this->structure .= 
"</li>";
 
  505            if (
$key == (count($items) - 1)) {
 
  506                $this->structure .= 
"</ul>";
 
  531        $this->archives = array();
 
  532        $query = 
"SELECT * FROM crs_archives " .
 
  533            "WHERE course_id = " . 
$ilDB->quote($this->course_obj->getId(), 
'integer') . 
" " .
 
  534            "ORDER BY archive_date DESC";
 
  538            $this->archives[
$row->archive_id][
"archive_id"]             = 
$row->archive_id;
 
  539            $this->archives[
$row->archive_id][
"archive_type"]   = 
$row->archive_type;
 
  540            $this->archives[
$row->archive_id][
"archive_date"]   = 
$row->archive_date;
 
  541            $this->archives[
$row->archive_id][
"archive_size"]   = 
$row->archive_size;
 
  542            $this->archives[
$row->archive_id][
"archive_name"]   = 
$row->archive_name;
 
  543            $this->archives[
$row->archive_id][
"archive_lang"]   = 
$row->archive_lang;
 
An exception for terminatinating execution or to throw for unit testing.
__addZipFiles($a_parent_id, $a_selection="")
Add zip files to folder.
addXML($a_selection="")
Add XML archive.
setLanguage($a_lang_code)
__buildStructure(&$tmp_tpl, $a_parent_id)
__construct($course_obj)
Constructor.
cloneArchives()
Clone archives.
__addHTMLFiles($a_parent_id)
query($sql, $a_handle_error=true)
Query.
static _getLastExportFileInformation($a_obj_id, $a_type="", $a_obj_type="")
Get last export file information.
static _getExportDirectory($a_obj_id, $a_type="xml", $a_obj_type="", $a_entity="")
Get export directory for an repository object.
static _generateIndexFile($a_filename, $a_obj_id, $a_files, $a_type="")
Generates an index.html file including links to all xml files included (for container exports)
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
special template class to simplify handling of ITX/PEAR
if(!array_key_exists('StateId', $_REQUEST)) $id
redirection script todo: (a better solution should control the processing via a xml file)
foreach($_POST as $key=> $value) $res